From: SangYong Park Date: Wed, 9 Feb 2022 06:43:06 +0000 (+0900) Subject: Remove WRTWindow and WRTWebContents modules X-Git-Tag: submit/tizen/20220228.174607^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F99%2F270799%2F1;p=platform%2Fframework%2Fweb%2Fwrtjs.git Remove WRTWindow and WRTWebContents modules . remove unnecesary modules . fix typescript build errors Change-Id: I1338fbea96f612e4087dcea2e56be656063a9a60 Signed-off-by: SangYong Park --- diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index b729517..e605fba 100644 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -23,9 +23,9 @@ Source: %{name}-%{version}.tar.gz # The category is public feature %if "%{?profile}" != "tv" && "%{?profile}" != "wearable" && "%{?_with_da_profile}" != "1" %ifarch armv7l - %define _use_nmt 1 + %define _use_nmt 0 %endif - %define _use_category 1 + %define _use_category 0 %endif BuildRequires: pkgconfig(chromium-efl) diff --git a/wrt_app/addon/browser/modules/messaging.ts b/wrt_app/addon/browser/modules/messaging.ts index eeccb5f..7a68b39 100644 --- a/wrt_app/addon/browser/modules/messaging.ts +++ b/wrt_app/addon/browser/modules/messaging.ts @@ -7,6 +7,7 @@ export const on = function (channel: string, listener: (event: Electron.IpcMainE }; export const send = function (winId: number, channel: string, ...args: any[]) { - let window = BrowserWindow.fromId(winId); - window.webContents.send(channel, ...args); + const window = BrowserWindow.fromId(winId); + if (window) + window.webContents.send(channel, ...args); }; diff --git a/wrt_app/addon/browser/modules/window.ts b/wrt_app/addon/browser/modules/window.ts index 1a5e7c2..b775fe8 100644 --- a/wrt_app/addon/browser/modules/window.ts +++ b/wrt_app/addon/browser/modules/window.ts @@ -1,40 +1,41 @@ 'use strict'; import { dialog, BrowserWindow } from 'electron'; -import * as WRTWebContents from '../../../browser/wrt_web_contents'; -import { WRTWindow } from '../../../browser/wrt_window'; -export const loadURL= function (winId: number, url: string) { - let window = BrowserWindow.fromId(winId); - window.loadURL(url); +export const loadURL = function (winId: number, url: string) { + const window = BrowserWindow.fromId(winId); + if (window) + window.loadURL(url); }; -export const showMessageBox = function (winId: number, options: Electron.MessageBoxOptions) { - let window = BrowserWindow.fromId(winId); - let showMessageBox = (dialog.showMessageBoxSync || dialog.showMessageBox); - showMessageBox(window, options); +export const showMessageBox = function (winId: number, options: Electron.MessageBoxOptions) { + const showMessageBox = (dialog.showMessageBoxSync || dialog.showMessageBox); + const window = BrowserWindow.fromId(winId); + if (window) + showMessageBox(window, options); }; export const show = function (winId: number) { - let window = BrowserWindow.fromId(winId); - window.show(); + const window = BrowserWindow.fromId(winId); + if (window) + window.show(); }; -export const executeJavaScript= function (winId: number, string: string) { - let window = BrowserWindow.fromId(winId); - window.webContents.executeJavaScript(string, true); +export const executeJavaScript = function (winId: number, string: string) { + const window = BrowserWindow.fromId(winId); + if (window) + window.webContents.executeJavaScript(string, true); }; export const open = function (url: string) { - let window = new WRTWindow( - { webPreferences: { - nodeIntegration: true, - nodeIntegrationInSubFrames: true, - nodeIntegrationInWorker: false, - nativeWindowOpen: true, - }, - webContents: WRTWebContents.create(), + const window = new BrowserWindow({ + webPreferences: { + nodeIntegration: true, + nodeIntegrationInSubFrames: true, + nodeIntegrationInWorker: false, + nativeWindowOpen: true, + }, }); window.loadURL(url); return window.id; diff --git a/wrt_app/browser/wrt_web_contents.ts b/wrt_app/browser/wrt_web_contents.ts deleted file mode 100644 index 38ab268..0000000 --- a/wrt_app/browser/wrt_web_contents.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const binding: NativeWRTjs.WRTWebContentsBinding = process.wrtBinding('wrt_web_contents'); -const { WRTWebContents } = binding; -const { WebContents: ElectronWebContents } = process.wrtBinding('electron_browser_web_contents'); - -const parent = ElectronWebContents.prototype; -ElectronWebContents.prototype = WRTWebContents.prototype; - -Object.setPrototypeOf(WRTWebContents.prototype, parent); - -WRTWebContents.prototype._init = function () { - parent._init.call(this); -} - -export const create = (options = {}) => { - return binding.create(options); -} diff --git a/wrt_app/browser/wrt_window.ts b/wrt_app/browser/wrt_window.ts deleted file mode 100644 index ebb7423..0000000 --- a/wrt_app/browser/wrt_window.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { BrowserWindow } from 'electron'; -import * as WRTWebContents from '../browser/wrt_web_contents'; - -export const { WRTWindow } = process.wrtBinding('wrt_window'); - -Object.setPrototypeOf(WRTWindow.prototype, BrowserWindow.prototype); - -WRTWindow.prototype._init = function () { - (BrowserWindow.prototype as any)._init.call(this); - // This removes a macOS specific hack present in electron - // that causes side effects on Tizen - this.webContents.removeAllListeners('load-url'); - if (typeof this.setup === 'function') - this.setup(); - this.constructor = BrowserWindow; - this.webContents.on('new-window', (event: Electron.NewWindowWebContentsEvent, - url: string, - frameName: string, - disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'), - options: any) => { - event.preventDefault(); - if (!options.webContents) { - options.webContents = WRTWebContents.create(); - options.webContents.loadURL(url); - } - event.newGuest = new WRTWindow(options); - }); -} diff --git a/wrt_app/src/runtime.ts b/wrt_app/src/runtime.ts index f92cfeb..6cb1e77 100644 --- a/wrt_app/src/runtime.ts +++ b/wrt_app/src/runtime.ts @@ -132,7 +132,7 @@ class Runtime { const Module = require('module'); Module.globalPaths.push(wrt.getAppPath()); let filePath = src[7] === '/' ? src.substr(8) : src.substr(7); // strip "file://" - let pkgJson = require(filePath); + let pkgJson: any = require(filePath); let pos = filePath.lastIndexOf('/'); let mainJsPath = (pos !== -1 ? filePath.substr(0, pos + 1) : '') + diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index eeaaae5..ca8a5d0 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -174,9 +174,9 @@ Then you can get profile log from the initial loading.`; this.webApplication.windowList.forEach((window) => { //clear webframe cache this.tv.clearWebCache(window.webContents); - window.webContents.session.clearCache(function() { + window.webContents.session.clearCache().then(() => { console.log('clear session Cache complete'); - }) + }); }); } diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 640b49c..b206872 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -16,10 +16,8 @@ 'use strict'; -import { app, session } from 'electron'; +import { BrowserWindow, app, session } from 'electron'; import { wrt } from '../browser/wrt'; -import * as WRTWebContents from '../browser/wrt_web_contents'; -import { WRTWindow } from '../browser/wrt_window'; import { addonManager } from './addon_manager'; import { WebApplicationDelegate } from '../common/web_application_delegate'; import { WebApplicationDelegateTV } from './tv/web_application_tv'; @@ -53,7 +51,7 @@ export class WebApplication { this.profileDelegate = new WebApplicationDelegate(this); } this.setupEventListener(options); - this.mainWindow = new WRTWindow(this.getWindowOption(options)); + this.mainWindow = new BrowserWindow(this.getWindowOption(options)); this.initDisplayDelay(); this.setupMainWindowEventListener(); } @@ -166,7 +164,7 @@ export class WebApplication { }); } - private getWindowOption(options: RuntimeOption): NativeWRTjs.WRTWindowConstructorOptions { + private getWindowOption(options: RuntimeOption): Electron.BrowserWindowConstructorOptions { return { fullscreen: false, backgroundColor: this.defaultBackgroundColor, @@ -178,7 +176,6 @@ export class WebApplication { nodeIntegrationInWorker: false, nativeWindowOpen: true, }, - webContents: WRTWebContents.create(), }; }