diff --git a/filenames.auto.gni b/filenames.auto.gni index dc6bc7777210..7d0145216089 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -123,7 +123,6 @@ auto_filenames = { "lib/browser/api/module-keys.js", "lib/common/api/clipboard.js", "lib/common/api/deprecate.ts", - "lib/common/api/is-promise.js", "lib/common/api/module-list.js", "lib/common/api/native-image.js", "lib/common/api/shell.js", @@ -132,6 +131,7 @@ auto_filenames = { "lib/common/crash-reporter.js", "lib/common/electron-binding-setup.ts", "lib/common/error-utils.js", + "lib/common/is-promise.ts", "lib/common/web-view-methods.js", "lib/renderer/api/crash-reporter.js", "lib/renderer/api/desktop-capturer.ts", @@ -252,7 +252,6 @@ auto_filenames = { "lib/common/api/clipboard.js", "lib/common/api/deprecate.ts", "lib/common/api/exports/electron.js", - "lib/common/api/is-promise.js", "lib/common/api/module-list.js", "lib/common/api/native-image.js", "lib/common/api/shell.js", @@ -262,6 +261,7 @@ auto_filenames = { "lib/common/electron-binding-setup.ts", "lib/common/error-utils.js", "lib/common/init.ts", + "lib/common/is-promise.ts", "lib/common/parse-features-string.js", "lib/common/reset-search-paths.ts", "lib/common/web-view-methods.js", @@ -277,7 +277,6 @@ auto_filenames = { "lib/common/api/clipboard.js", "lib/common/api/deprecate.ts", "lib/common/api/exports/electron.js", - "lib/common/api/is-promise.js", "lib/common/api/module-list.js", "lib/common/api/native-image.js", "lib/common/api/shell.js", @@ -287,6 +286,7 @@ auto_filenames = { "lib/common/electron-binding-setup.ts", "lib/common/error-utils.js", "lib/common/init.ts", + "lib/common/is-promise.ts", "lib/common/reset-search-paths.ts", "lib/common/web-view-methods.js", "lib/renderer/api/crash-reporter.js", @@ -327,7 +327,6 @@ auto_filenames = { "lib/common/api/clipboard.js", "lib/common/api/deprecate.ts", "lib/common/api/exports/electron.js", - "lib/common/api/is-promise.js", "lib/common/api/module-list.js", "lib/common/api/native-image.js", "lib/common/api/shell.js", @@ -337,6 +336,7 @@ auto_filenames = { "lib/common/electron-binding-setup.ts", "lib/common/error-utils.js", "lib/common/init.ts", + "lib/common/is-promise.ts", "lib/common/reset-search-paths.ts", "lib/renderer/api/crash-reporter.js", "lib/renderer/api/desktop-capturer.ts", diff --git a/lib/browser/rpc-server.js b/lib/browser/rpc-server.js index 19a7674f28f1..fd511c9439e9 100644 --- a/lib/browser/rpc-server.js +++ b/lib/browser/rpc-server.js @@ -9,8 +9,6 @@ const eventBinding = process.electronBinding('event') const clipboard = process.electronBinding('clipboard') const features = process.electronBinding('features') -const { isPromise } = electron - const { getContentScripts } = require('@electron/internal/browser/chrome-extension') const { crashReporterInit } = require('@electron/internal/browser/crash-reporter-init') const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal') @@ -20,6 +18,7 @@ const guestViewManager = require('@electron/internal/browser/guest-view-manager' const bufferUtils = require('@electron/internal/common/buffer-utils') const errorUtils = require('@electron/internal/common/error-utils') const clipboardUtils = require('@electron/internal/common/clipboard-utils') +const { isPromise } = require('@electron/internal/common/is-promise') const hasProp = {}.hasOwnProperty diff --git a/lib/common/api/module-list.js b/lib/common/api/module-list.js index 615a6927265a..da75e7d36fb2 100644 --- a/lib/common/api/module-list.js +++ b/lib/common/api/module-list.js @@ -6,6 +6,5 @@ module.exports = [ { name: 'nativeImage', loader: () => require('./native-image') }, { name: 'shell', loader: () => require('./shell') }, // The internal modules, invisible unless you know their names. - { name: 'deprecate', loader: () => require('./deprecate'), private: true }, - { name: 'isPromise', loader: () => require('./is-promise'), private: true } + { name: 'deprecate', loader: () => require('./deprecate'), private: true } ] diff --git a/lib/common/api/is-promise.js b/lib/common/is-promise.ts similarity index 81% rename from lib/common/api/is-promise.js rename to lib/common/is-promise.ts index d6115a145585..2d5203f9bd3e 100644 --- a/lib/common/api/is-promise.js +++ b/lib/common/is-promise.ts @@ -1,6 +1,4 @@ -'use strict' - -module.exports = function isPromise (val) { +export function isPromise (val: any) { return ( val && val.then && diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index 009e7ea3c7d9..04ed257ef6f1 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -1,12 +1,11 @@ 'use strict' const v8Util = process.electronBinding('v8_util') -const { isPromise } = require('electron') -const resolvePromise = Promise.resolve.bind(Promise) const { CallbacksRegistry } = require('@electron/internal/renderer/callbacks-registry') const bufferUtils = require('@electron/internal/common/buffer-utils') const errorUtils = require('@electron/internal/common/error-utils') +const { isPromise } = require('@electron/internal/common/is-promise') const { ipcRendererInternal } = require('@electron/internal/renderer/ipc-renderer-internal') const callbacksRegistry = new CallbacksRegistry() @@ -216,7 +215,7 @@ function metaToValue (meta) { value: () => meta.value, array: () => meta.members.map((member) => metaToValue(member)), buffer: () => bufferUtils.metaToBuffer(meta.value), - promise: () => resolvePromise({ then: metaToValue(meta.then) }), + promise: () => Promise.resolve({ then: metaToValue(meta.then) }), error: () => metaToPlainObject(meta), date: () => new Date(meta.value), exception: () => { throw errorUtils.deserialize(meta.value) } diff --git a/lib/sandboxed_renderer/api/module-list.js b/lib/sandboxed_renderer/api/module-list.js index 81b0ef36a8dd..5afffe694e93 100644 --- a/lib/sandboxed_renderer/api/module-list.js +++ b/lib/sandboxed_renderer/api/module-list.js @@ -34,10 +34,5 @@ module.exports = [ name: 'deprecate', load: () => require('@electron/internal/common/api/deprecate'), private: true - }, - { - name: 'isPromise', - load: () => require('@electron/internal/common/api/is-promise'), - private: true } ]