parent
a6f7c7690d
commit
71fb19ea14
9 changed files with 288 additions and 715 deletions
|
@ -19,14 +19,14 @@ export class IpcMainImpl extends EventEmitter {
|
||||||
throw new Error(`Expected handler to be a function, but found type '${typeof fn}'`);
|
throw new Error(`Expected handler to be a function, but found type '${typeof fn}'`);
|
||||||
}
|
}
|
||||||
this._invokeHandlers.set(method, fn);
|
this._invokeHandlers.set(method, fn);
|
||||||
}
|
};
|
||||||
|
|
||||||
handleOnce: Electron.IpcMain['handleOnce'] = (method, fn) => {
|
handleOnce: Electron.IpcMain['handleOnce'] = (method, fn) => {
|
||||||
this.handle(method, (e, ...args) => {
|
this.handle(method, (e, ...args) => {
|
||||||
this.removeHandler(method);
|
this.removeHandler(method);
|
||||||
return fn(e, ...args);
|
return fn(e, ...args);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
removeHandler (method: string) {
|
removeHandler (method: string) {
|
||||||
this._invokeHandlers.delete(method);
|
this._invokeHandlers.delete(method);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
export class MessagePortMain extends EventEmitter {
|
export class MessagePortMain extends EventEmitter {
|
||||||
_internalPort: any
|
_internalPort: any;
|
||||||
constructor (internalPort: any) {
|
constructor (internalPort: any) {
|
||||||
super();
|
super();
|
||||||
this._internalPort = internalPort;
|
this._internalPort = internalPort;
|
||||||
|
|
|
@ -53,7 +53,7 @@ export class WebViewAttribute implements MutationHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the attribute's value changes.
|
// Called when the attribute's value changes.
|
||||||
public handleMutation: MutationHandler['handleMutation'] = () => undefined
|
public handleMutation: MutationHandler['handleMutation'] = () => undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// An attribute that is treated as a Boolean.
|
// An attribute that is treated as a Boolean.
|
||||||
|
@ -73,7 +73,7 @@ class BooleanAttribute extends WebViewAttribute {
|
||||||
|
|
||||||
// Attribute representing the state of the storage partition.
|
// Attribute representing the state of the storage partition.
|
||||||
export class PartitionAttribute extends WebViewAttribute {
|
export class PartitionAttribute extends WebViewAttribute {
|
||||||
public validPartitionId = true
|
public validPartitionId = true;
|
||||||
|
|
||||||
constructor (public webViewImpl: WebViewImpl) {
|
constructor (public webViewImpl: WebViewImpl) {
|
||||||
super(WEB_VIEW_ATTRIBUTES.PARTITION, webViewImpl);
|
super(WEB_VIEW_ATTRIBUTES.PARTITION, webViewImpl);
|
||||||
|
@ -92,7 +92,7 @@ export class PartitionAttribute extends WebViewAttribute {
|
||||||
this.validPartitionId = false;
|
this.validPartitionId = false;
|
||||||
console.error(WEB_VIEW_ERROR_MESSAGES.INVALID_PARTITION_ATTRIBUTE);
|
console.error(WEB_VIEW_ERROR_MESSAGES.INVALID_PARTITION_ATTRIBUTE);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attribute that handles the location and navigation of the webview.
|
// Attribute that handles the location and navigation of the webview.
|
||||||
|
@ -134,7 +134,7 @@ export class SrcAttribute extends WebViewAttribute {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.parse();
|
this.parse();
|
||||||
}
|
};
|
||||||
|
|
||||||
// The purpose of this mutation observer is to catch assignment to the src
|
// The purpose of this mutation observer is to catch assignment to the src
|
||||||
// attribute without any changes to its value. This is useful in the case
|
// attribute without any changes to its value. This is useful in the case
|
||||||
|
|
|
@ -19,16 +19,16 @@ export interface WebViewImplHooks {
|
||||||
|
|
||||||
// Represents the internal state of the WebView node.
|
// Represents the internal state of the WebView node.
|
||||||
export class WebViewImpl {
|
export class WebViewImpl {
|
||||||
public beforeFirstNavigation = true
|
public beforeFirstNavigation = true;
|
||||||
public elementAttached = false
|
public elementAttached = false;
|
||||||
public guestInstanceId?: number
|
public guestInstanceId?: number;
|
||||||
public hasFocus = false
|
public hasFocus = false;
|
||||||
public internalInstanceId?: number;
|
public internalInstanceId?: number;
|
||||||
public viewInstanceId: number
|
public viewInstanceId: number;
|
||||||
|
|
||||||
// on* Event handlers.
|
// on* Event handlers.
|
||||||
public on: Record<string, any> = {}
|
public on: Record<string, any> = {};
|
||||||
public internalElement: HTMLIFrameElement
|
public internalElement: HTMLIFrameElement;
|
||||||
|
|
||||||
public attributes: Map<string, WebViewAttribute>;
|
public attributes: Map<string, WebViewAttribute>;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { MessagePortMain } from '@electron/internal/browser/message-port-main';
|
||||||
const { createParentPort } = process._linkedBinding('electron_utility_parent_port');
|
const { createParentPort } = process._linkedBinding('electron_utility_parent_port');
|
||||||
|
|
||||||
export class ParentPort extends EventEmitter {
|
export class ParentPort extends EventEmitter {
|
||||||
#port: ParentPort
|
#port: ParentPort;
|
||||||
constructor () {
|
constructor () {
|
||||||
super();
|
super();
|
||||||
this.#port = createParentPort();
|
this.#port = createParentPort();
|
||||||
|
|
|
@ -32,21 +32,20 @@
|
||||||
"@types/uuid": "^3.4.6",
|
"@types/uuid": "^3.4.6",
|
||||||
"@types/webpack": "^5.28.0",
|
"@types/webpack": "^5.28.0",
|
||||||
"@types/webpack-env": "^1.17.0",
|
"@types/webpack-env": "^1.17.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.4.1",
|
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||||
"@typescript-eslint/parser": "^4.4.1",
|
"@typescript-eslint/parser": "^5.59.7",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
"check-for-leaks": "^1.2.1",
|
"check-for-leaks": "^1.2.1",
|
||||||
"colors": "1.4.0",
|
"colors": "1.4.0",
|
||||||
"dotenv-safe": "^4.0.4",
|
"dotenv-safe": "^4.0.4",
|
||||||
"dugite": "^2.3.0",
|
"dugite": "^2.3.0",
|
||||||
"eslint": "^7.4.0",
|
"eslint": "^8.41.0",
|
||||||
"eslint-config-standard": "^14.1.1",
|
"eslint-config-standard": "^14.1.1",
|
||||||
"eslint-plugin-import": "^2.22.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-mocha": "^7.0.1",
|
"eslint-plugin-mocha": "^7.0.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^4.2.1",
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
"eslint-plugin-standard": "^4.0.1",
|
"eslint-plugin-standard": "^4.0.1",
|
||||||
"eslint-plugin-typescript": "^0.14.0",
|
|
||||||
"events": "^3.2.0",
|
"events": "^3.2.0",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"folder-hash": "^2.1.1",
|
"folder-hash": "^2.1.1",
|
||||||
|
|
|
@ -65,11 +65,11 @@ class RemoteControlApp {
|
||||||
req.write(js);
|
req.write(js);
|
||||||
req.end();
|
req.end();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
remotely = (script: Function, ...args: any[]): Promise<any> => {
|
remotely = (script: Function, ...args: any[]): Promise<any> => {
|
||||||
return this.remoteEval(`(${script})(...${JSON.stringify(args)})`);
|
return this.remoteEval(`(${script})(...${JSON.stringify(args)})`);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startRemoteControlApp (extraArgs: string[] = [], options?: childProcess.SpawnOptionsWithoutStdio) {
|
export async function startRemoteControlApp (extraArgs: string[] = [], options?: childProcess.SpawnOptionsWithoutStdio) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue