Remove WRTWindow and WRTWebContents modules 99/270799/1 submit/tizen/20220228.174607
authorSangYong Park <sy302.park@samsung.com>
Wed, 9 Feb 2022 06:43:06 +0000 (15:43 +0900)
committerSangYong Park <sy302.park@samsung.com>
Wed, 9 Feb 2022 06:43:06 +0000 (15:43 +0900)
. remove unnecesary modules
. fix typescript build errors

Change-Id: I1338fbea96f612e4087dcea2e56be656063a9a60
Signed-off-by: SangYong Park <sy302.park@samsung.com>
packaging/wrtjs.spec
wrt_app/addon/browser/modules/messaging.ts
wrt_app/addon/browser/modules/window.ts
wrt_app/browser/wrt_web_contents.ts [deleted file]
wrt_app/browser/wrt_window.ts [deleted file]
wrt_app/src/runtime.ts
wrt_app/src/tv/web_application_tv.ts
wrt_app/src/web_application.ts

index b729517..e605fba 100644 (file)
@@ -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)
index eeccb5f..7a68b39 100644 (file)
@@ -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);
 };
index 1a5e7c2..b775fe8 100644 (file)
@@ -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 (file)
index 38ab268..0000000
+++ /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 (file)
index ebb7423..0000000
+++ /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);
-  });
-}
index f92cfeb..6cb1e77 100644 (file)
@@ -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) : '') +
index eeaaae5..ca8a5d0 100644 (file)
@@ -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');
-      })
+      });
     });
   }
 
index 640b49c..b206872 100644 (file)
 
 '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(),
     };
   }