refactor: don't expose isPromise as an internal module (#19139)

This commit is contained in:
Milan Burda 2019-07-08 08:17:50 +02:00 committed by Cheng Zhao
parent 949f8685d2
commit 69369cf365
6 changed files with 9 additions and 19 deletions

View file

@ -123,7 +123,6 @@ auto_filenames = {
"lib/browser/api/module-keys.js", "lib/browser/api/module-keys.js",
"lib/common/api/clipboard.js", "lib/common/api/clipboard.js",
"lib/common/api/deprecate.ts", "lib/common/api/deprecate.ts",
"lib/common/api/is-promise.js",
"lib/common/api/module-list.js", "lib/common/api/module-list.js",
"lib/common/api/native-image.js", "lib/common/api/native-image.js",
"lib/common/api/shell.js", "lib/common/api/shell.js",
@ -132,6 +131,7 @@ auto_filenames = {
"lib/common/crash-reporter.js", "lib/common/crash-reporter.js",
"lib/common/electron-binding-setup.ts", "lib/common/electron-binding-setup.ts",
"lib/common/error-utils.js", "lib/common/error-utils.js",
"lib/common/is-promise.ts",
"lib/common/web-view-methods.js", "lib/common/web-view-methods.js",
"lib/renderer/api/crash-reporter.js", "lib/renderer/api/crash-reporter.js",
"lib/renderer/api/desktop-capturer.ts", "lib/renderer/api/desktop-capturer.ts",
@ -252,7 +252,6 @@ auto_filenames = {
"lib/common/api/clipboard.js", "lib/common/api/clipboard.js",
"lib/common/api/deprecate.ts", "lib/common/api/deprecate.ts",
"lib/common/api/exports/electron.js", "lib/common/api/exports/electron.js",
"lib/common/api/is-promise.js",
"lib/common/api/module-list.js", "lib/common/api/module-list.js",
"lib/common/api/native-image.js", "lib/common/api/native-image.js",
"lib/common/api/shell.js", "lib/common/api/shell.js",
@ -262,6 +261,7 @@ auto_filenames = {
"lib/common/electron-binding-setup.ts", "lib/common/electron-binding-setup.ts",
"lib/common/error-utils.js", "lib/common/error-utils.js",
"lib/common/init.ts", "lib/common/init.ts",
"lib/common/is-promise.ts",
"lib/common/parse-features-string.js", "lib/common/parse-features-string.js",
"lib/common/reset-search-paths.ts", "lib/common/reset-search-paths.ts",
"lib/common/web-view-methods.js", "lib/common/web-view-methods.js",
@ -277,7 +277,6 @@ auto_filenames = {
"lib/common/api/clipboard.js", "lib/common/api/clipboard.js",
"lib/common/api/deprecate.ts", "lib/common/api/deprecate.ts",
"lib/common/api/exports/electron.js", "lib/common/api/exports/electron.js",
"lib/common/api/is-promise.js",
"lib/common/api/module-list.js", "lib/common/api/module-list.js",
"lib/common/api/native-image.js", "lib/common/api/native-image.js",
"lib/common/api/shell.js", "lib/common/api/shell.js",
@ -287,6 +286,7 @@ auto_filenames = {
"lib/common/electron-binding-setup.ts", "lib/common/electron-binding-setup.ts",
"lib/common/error-utils.js", "lib/common/error-utils.js",
"lib/common/init.ts", "lib/common/init.ts",
"lib/common/is-promise.ts",
"lib/common/reset-search-paths.ts", "lib/common/reset-search-paths.ts",
"lib/common/web-view-methods.js", "lib/common/web-view-methods.js",
"lib/renderer/api/crash-reporter.js", "lib/renderer/api/crash-reporter.js",
@ -327,7 +327,6 @@ auto_filenames = {
"lib/common/api/clipboard.js", "lib/common/api/clipboard.js",
"lib/common/api/deprecate.ts", "lib/common/api/deprecate.ts",
"lib/common/api/exports/electron.js", "lib/common/api/exports/electron.js",
"lib/common/api/is-promise.js",
"lib/common/api/module-list.js", "lib/common/api/module-list.js",
"lib/common/api/native-image.js", "lib/common/api/native-image.js",
"lib/common/api/shell.js", "lib/common/api/shell.js",
@ -337,6 +336,7 @@ auto_filenames = {
"lib/common/electron-binding-setup.ts", "lib/common/electron-binding-setup.ts",
"lib/common/error-utils.js", "lib/common/error-utils.js",
"lib/common/init.ts", "lib/common/init.ts",
"lib/common/is-promise.ts",
"lib/common/reset-search-paths.ts", "lib/common/reset-search-paths.ts",
"lib/renderer/api/crash-reporter.js", "lib/renderer/api/crash-reporter.js",
"lib/renderer/api/desktop-capturer.ts", "lib/renderer/api/desktop-capturer.ts",

View file

@ -9,8 +9,6 @@ const eventBinding = process.electronBinding('event')
const clipboard = process.electronBinding('clipboard') const clipboard = process.electronBinding('clipboard')
const features = process.electronBinding('features') const features = process.electronBinding('features')
const { isPromise } = electron
const { getContentScripts } = require('@electron/internal/browser/chrome-extension') const { getContentScripts } = require('@electron/internal/browser/chrome-extension')
const { crashReporterInit } = require('@electron/internal/browser/crash-reporter-init') const { crashReporterInit } = require('@electron/internal/browser/crash-reporter-init')
const { ipcMainInternal } = require('@electron/internal/browser/ipc-main-internal') 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 bufferUtils = require('@electron/internal/common/buffer-utils')
const errorUtils = require('@electron/internal/common/error-utils') const errorUtils = require('@electron/internal/common/error-utils')
const clipboardUtils = require('@electron/internal/common/clipboard-utils') const clipboardUtils = require('@electron/internal/common/clipboard-utils')
const { isPromise } = require('@electron/internal/common/is-promise')
const hasProp = {}.hasOwnProperty const hasProp = {}.hasOwnProperty

View file

@ -6,6 +6,5 @@ module.exports = [
{ name: 'nativeImage', loader: () => require('./native-image') }, { name: 'nativeImage', loader: () => require('./native-image') },
{ name: 'shell', loader: () => require('./shell') }, { name: 'shell', loader: () => require('./shell') },
// The internal modules, invisible unless you know their names. // The internal modules, invisible unless you know their names.
{ name: 'deprecate', loader: () => require('./deprecate'), private: true }, { name: 'deprecate', loader: () => require('./deprecate'), private: true }
{ name: 'isPromise', loader: () => require('./is-promise'), private: true }
] ]

View file

@ -1,6 +1,4 @@
'use strict' export function isPromise (val: any) {
module.exports = function isPromise (val) {
return ( return (
val && val &&
val.then && val.then &&

View file

@ -1,12 +1,11 @@
'use strict' 'use strict'
const v8Util = process.electronBinding('v8_util') 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 { CallbacksRegistry } = require('@electron/internal/renderer/callbacks-registry')
const bufferUtils = require('@electron/internal/common/buffer-utils') const bufferUtils = require('@electron/internal/common/buffer-utils')
const errorUtils = require('@electron/internal/common/error-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 { ipcRendererInternal } = require('@electron/internal/renderer/ipc-renderer-internal')
const callbacksRegistry = new CallbacksRegistry() const callbacksRegistry = new CallbacksRegistry()
@ -216,7 +215,7 @@ function metaToValue (meta) {
value: () => meta.value, value: () => meta.value,
array: () => meta.members.map((member) => metaToValue(member)), array: () => meta.members.map((member) => metaToValue(member)),
buffer: () => bufferUtils.metaToBuffer(meta.value), buffer: () => bufferUtils.metaToBuffer(meta.value),
promise: () => resolvePromise({ then: metaToValue(meta.then) }), promise: () => Promise.resolve({ then: metaToValue(meta.then) }),
error: () => metaToPlainObject(meta), error: () => metaToPlainObject(meta),
date: () => new Date(meta.value), date: () => new Date(meta.value),
exception: () => { throw errorUtils.deserialize(meta.value) } exception: () => { throw errorUtils.deserialize(meta.value) }

View file

@ -34,10 +34,5 @@ module.exports = [
name: 'deprecate', name: 'deprecate',
load: () => require('@electron/internal/common/api/deprecate'), load: () => require('@electron/internal/common/api/deprecate'),
private: true private: true
},
{
name: 'isPromise',
load: () => require('@electron/internal/common/api/is-promise'),
private: true
} }
] ]