Commit Graph

610 Commits

Author SHA1 Message Date
toasted-nutbread
3949db26d7
Text scanner refactor (#517)
* Fix return type

* Pass search function as a constructor argument

* Pass constructor as a details object

For consistency with other complex constructors and improved semantics.

* Convert _ignorePoints to a single optional function

* Organize functions

* Rename ignorePoints to ignorePoint
2020-05-08 19:05:50 -04:00
toasted-nutbread
b936c3e4b1
Popup proxy host refactor (#516)
* Rename PopupProxyHost to PopupFactory

* Update FrontendApiReceiver to support non-async handlers

* Make some functions non-async

* Make setCustomCss non-async

* Make setContentScale non-async

* Remove static

* Rename variables

* Pass frameId into PopupFactory's constructor

* Change FrontendApiReceiver source from popup-proxy-host to popup-factor

* Rename _invokeHostApi to _invoke

* Rename PopupProxy.getHostUrl to getUrl
2020-05-08 19:04:53 -04:00
toasted-nutbread
edb86d9ec3
Organize frontend functions (#513) 2020-05-07 19:38:09 -04:00
toasted-nutbread
38d6f58fac
Frontend refactor (#508)
* Use this.popup instead of this.frontend.popup

* Rename Frontend.popup to _popup

* Make Frontend functions private

* Clean up Frontend constructor
2020-05-06 19:35:36 -04:00
toasted-nutbread
d6ae322961
Text scanning update (#507)
* Fix unity test missing a parameter

* Update docSentenceExtract to not rescan content
2020-05-06 19:34:32 -04:00
toasted-nutbread
f7df6254d6
Dom text scanner fixes (#505)
* Fix test case

* Add test-dom-text-scanner

* Ensure that DOMTextScanner._node never becomes null

* Add remainder
2020-05-06 19:33:17 -04:00
toasted-nutbread
501281e887
Popup init update (#497)
* Add API function to send a message to a specific frameId in a tab

* Update _windowMessageHandlers to support additional info per handler

* Remove message token

* Add new authorization check

* Set up new initialization handler

* Update initialization

* Remove message token

* Replace 'prepare' with 'configure'

* Create new prepare function

* Change configure guard

* Log errors in onMessage

* Improve popup initialize function

* Clear secret/token in _resetFrame

* Remove backend message token

* Clear src and srcdoc attributes before loading

* Don't treat about:blank unloads as load events
2020-05-06 19:27:21 -04:00
siikamiika
a88501ff10
Text selection fixes (#511)
* select matched text in Frontend.findKanji

* blur search query input when setting content
2020-05-07 01:49:42 +03:00
siikamiika
7d7ff165ce
Extract textSource text inside TextScanner (#500)
* extract text inside TextScanner

* clone textSource before text extraction
2020-05-05 00:13:43 +03:00
siikamiika
77b744e675
Modifier key profile condition (#487)
* update Frontend options on modifier change

* add modifier key profile condition

* use select element for modifier condition value

* support "is" and "is not" modifier key conditions

* use plural

* remove dead null check

it's never null in that function

* pass element on rather than assigning to this

* rename event

* remove Firefox OS key to Meta detection

* hide Meta from dropdown on Firefox

* move input type
2020-05-03 04:39:24 +03:00
toasted-nutbread
d4ae9aa501
DOMTextScanner (#458)
* Create new class for scanning text in a document

* Update test styles

* Add tests
2020-05-02 13:05:43 -04:00
toasted-nutbread
d581bffa15
Style fixes (#494)
* Place multi-line expression parentheses on the correct line

* Add function-paren-newline eslint rule

* Add some additional eslint rules
2020-05-02 13:04:17 -04:00
toasted-nutbread
c4ea9321dc
Validate document nodes before use (#493)
* Validate document.body before use in loadScripts

This also fixes an issue where reject wasn't being passed to loadScriptSentinel.

* Validate document nodes before use in _getSiteColor

* Validate document.body before use in _getViewport

* Validate document.body before use in setContentScale

* Validate document.body before use in docImposterCreate
2020-05-02 13:00:46 -04:00
toasted-nutbread
51032d1eca
Catch WrongDocumentError thrown by compareBoundaryPoints (#491)
* Catch WrongDocumentError thrown by compareBoundaryPoints

* Filter error based on name
2020-05-02 12:59:59 -04:00
toasted-nutbread
efa7a5ecc3
Remove and unload the popup frame if an unexpected load occurs (#490)
* Remove and unload the popup frame if an unexpected load occurs

* Remove unused fields

* Only update _injectPromiseComplete if the promise is the most recent one

* Remove redundant this._injectPromise !== null check
2020-05-02 12:59:13 -04:00
toasted-nutbread
8a368aaddc
Don't parent the popup frame to elements which cause unload (#488) 2020-05-02 12:58:24 -04:00
toasted-nutbread
6c341a13d8
Refactor frontend API classes (#482)
* Mark functions as private

* Remove constructor side effects

* Use safer handler invocation

* Mark functions as private

* Mark fields as private

* Update BackendApiForwarder public API
2020-05-02 12:50:44 -04:00
toasted-nutbread
08ada6844a
Remove Frontend inheritance (#486)
* Make Frontend use composition instead of inheritance for TextScanner

* Use push instead of concat

* Update setOptions and setEnabled APIs

* Update how onWindowMessage event listener is added/removed

* Rename options to _options

* Use bind instead of arrow function

* Fix selection being cleared due to settings changes
2020-05-02 12:47:15 -04:00
toasted-nutbread
48c7010f4e
Frontend refactor (part 1) (#484)
* Remove _getVisualViewportScale

* Use super's mouse event listener definitions

* Remove redundant override

* Remove getTouchEventListeners override

* Rename Display.onSearchClear to onEscape

* Change onSearchClear to clearSelection and use an event

* Update how text is marked for selection and deselection

* Replace onError with yomichan.logError

* Update setEnabled to refresh all event listeners
2020-04-27 18:10:37 -04:00
toasted-nutbread
887d769786
Use dynamicLoader for main (#481)
* Update style of search-main and float-main to have better parity

* Use dynamicLoader to inject scripts and CSS
2020-04-26 16:56:34 -04:00
toasted-nutbread
5b96559df8
Error logging refactoring (#454)
* Create new logging methods on yomichan object

* Use new yomichan.logError instead of global logError

* Remove old logError

* Handle unhandledrejection events

* Add addEventListener stub

* Update log function

* Update error conversion to support more types

* Add log event

* Add API log function

* Log errors to the backend

* Make error/warning logs update the badge

* Clear log error indicator on extension button click

* Log correct URL on the background page

* Fix incorrect error conversion

* Remove unhandledrejection handling

Firefox doesn't support it properly.

* Remove unused argument type from log function

* Improve function name

* Change console.warn to yomichan.logWarning

* Move log forwarding initialization into main scripts
2020-04-26 16:55:25 -04:00
siikamiika
ca033a87a0
Update Popup and DisplayFloat optionsContext from Frontend (#464)
* set optionsContext from Frontend

* update Popup+Display options on Frontend change

* remove popup setOptions

* only update DisplayFloat options from Frontend

* fix optionsContext usage

* fix preview frame arguments

* keep Frontend URL up to date

* cache url

* fix preview frame

* trigger modifyingProfileChange in correct places

* remove async from function not using await

* refactor optionsContext in Frontend
2020-04-26 22:33:50 +03:00
toasted-nutbread
d8276a9d5d Use IIFE for entry points 2020-04-22 21:42:20 -04:00
toasted-nutbread
d106c638ed Move popup-nested content into float-main 2020-04-21 18:38:55 -04:00
toasted-nutbread
9ca906ef90 Create float-main.js 2020-04-19 14:29:43 -04:00
toasted-nutbread
6c93d1984f Change frontend-initialize.js to content-script-main.js 2020-04-19 14:26:20 -04:00
siikamiika
d66ca93ce4 cache invalidation 2020-04-18 23:28:00 +03:00
siikamiika
a81c33b60a simplify element source lazy load 2020-04-18 23:28:00 +03:00
siikamiika
691b739849 cache closed shadow dom content windows 2020-04-18 23:28:00 +03:00
siikamiika
66354f1f9e lazy load element sources 2020-04-18 23:28:00 +03:00
siikamiika
bb3ad78e37 optimize source frame finding 2020-04-18 23:28:00 +03:00
siikamiika
350a113996 use getFullscreenElement to check fullscreen 2020-04-18 23:28:00 +03:00
siikamiika
b786e2da19 move open shadow root iframe finder to a function 2020-04-18 23:28:00 +03:00
siikamiika
85706c421b show popup inside iframe for closed shadow dom 2020-04-18 23:28:00 +03:00
siikamiika
fbaf50def1 support iframes inside open shadow dom 2020-04-18 23:28:00 +03:00
siikamiika
4fdc300b61 disable root frame popup when iframe is fullscreen 2020-04-18 23:28:00 +03:00
toasted-nutbread
106172e2c1
Merge pull request #447 from toasted-nutbread/util-conversions
Util conversions
2020-04-18 14:12:41 -04:00
siikamiika
e6053eefa5
Merge pull request #439 from siikamiika/popup-live-toggle
Popup live toggle
2020-04-17 01:31:25 +03:00
siikamiika
b6f7f8c026 fix _canEnable being used before setting options 2020-04-14 20:59:42 +03:00
siikamiika
950f50ef94 don't focus tab when changing settings 2020-04-14 20:35:52 +03:00
siikamiika
362ac84e6c prevent spawning multiple FrameOffsetForwarders 2020-04-12 19:17:50 +03:00
siikamiika
e627ab2537 fix optionsContext URL for root popup 2020-04-12 19:11:18 +03:00
toasted-nutbread
bf4c1aef6a Fix default value of _orphaned 2020-04-11 22:27:31 -04:00
toasted-nutbread
3c48290cd8 Add isExtensionUrl utility function to yomichan object 2020-04-11 15:17:25 -04:00
siikamiika
e6078ce8f6 remove redundant call guard 2020-04-11 21:04:30 +03:00
siikamiika
5c3641eadb simplify frontend disable override 2020-04-11 21:04:30 +03:00
siikamiika
d93e3e1a67 use setters instead of EventDispatcher 2020-04-11 21:04:30 +03:00
siikamiika
275f455e73 fix preview frame error 2020-04-11 21:04:30 +03:00
siikamiika
565e3a8c6a change iframe popup live 2020-04-11 21:04:30 +03:00
siikamiika
b9035854b2 cache created popups 2020-04-11 21:03:22 +03:00