(options: BrowserViewOptions = {})
| 27 | #queue: Queue; |
| 28 | |
| 29 | constructor(options: BrowserViewOptions = {}) { |
| 30 | super(); |
| 31 | // The background color of this view should be the same with the browser, |
| 32 | // so there would be no flashing when browser is loaded later. |
| 33 | this.setBackgroundColor(style.light.bgColor, style.dark.bgColor); |
| 34 | |
| 35 | const browserOptions = { |
| 36 | devtools: true, |
| 37 | contextMenu: true, |
| 38 | hardwareAcceleration: false, |
| 39 | }; |
| 40 | if (options.browserOptions) |
| 41 | Object.assign(browserOptions, options.browserOptions); |
| 42 | this.browser = gui.Browser.create(browserOptions); |
| 43 | |
| 44 | this.browser.setStyle({flex: 1}); |
| 45 | this.connectYueSignal(this.browser.onFinishNavigation, this.#domReady.bind(this)); |
| 46 | if (this.darkMode) |
| 47 | this.browser.setBackgroundColor(style.dark.bgColor); |
| 48 | if (options.hideUntilLoaded) |
| 49 | this.browser.setVisible(false); |
| 50 | this.view.addChildView(this.browser); |
| 51 | |
| 52 | // Add bindings to the browser. |
| 53 | this.browser.beginAddingBindings(); |
| 54 | this.browser.setBindingName('chie'); |
| 55 | this.browser.addBinding('catchDomError', this.#catchDomError.bind(this)); |
| 56 | this.browser.addBinding('log', this.#log.bind(this)); |
| 57 | |
| 58 | // Calls of executeJavaScript are queued. |
| 59 | this.#queue = new Queue({concurrency: 1, autostart: false}); |
| 60 | } |
| 61 | |
| 62 | loadURL(url: string) { |
| 63 | this.#queue.end(); |
nothing calls this directly
no test coverage detected