parent
a6f7c7690d
commit
71fb19ea14
9 changed files with 288 additions and 715 deletions
|
@ -83,50 +83,50 @@ abstract class TouchBarItem<ConfigType> extends EventEmitter {
|
|||
|
||||
class TouchBarButton extends TouchBarItem<Electron.TouchBarButtonConstructorOptions> implements Electron.TouchBarButton {
|
||||
@ImmutableProperty(() => 'button')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarButton>(config => config.label)
|
||||
label!: string;
|
||||
label!: string;
|
||||
|
||||
@LiveProperty<TouchBarButton>(config => config.accessibilityLabel)
|
||||
accessibilityLabel!: string;
|
||||
accessibilityLabel!: string;
|
||||
|
||||
@LiveProperty<TouchBarButton>(config => config.backgroundColor)
|
||||
backgroundColor!: string;
|
||||
backgroundColor!: string;
|
||||
|
||||
@LiveProperty<TouchBarButton>(config => config.icon)
|
||||
icon!: Electron.NativeImage;
|
||||
icon!: Electron.NativeImage;
|
||||
|
||||
@LiveProperty<TouchBarButton>(config => config.iconPosition)
|
||||
iconPosition!: Electron.TouchBarButton['iconPosition'];
|
||||
iconPosition!: Electron.TouchBarButton['iconPosition'];
|
||||
|
||||
@LiveProperty<TouchBarButton>(config => typeof config.enabled !== 'boolean' ? true : config.enabled)
|
||||
enabled!: boolean;
|
||||
enabled!: boolean;
|
||||
|
||||
@ImmutableProperty<TouchBarButton>(({ click: onClick }) => typeof onClick === 'function' ? () => onClick() : null)
|
||||
onInteraction!: Function | null;
|
||||
onInteraction!: Function | null;
|
||||
}
|
||||
|
||||
class TouchBarColorPicker extends TouchBarItem<Electron.TouchBarColorPickerConstructorOptions> implements Electron.TouchBarColorPicker {
|
||||
@ImmutableProperty(() => 'colorpicker')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarColorPicker>(config => config.availableColors)
|
||||
availableColors!: string[];
|
||||
availableColors!: string[];
|
||||
|
||||
@LiveProperty<TouchBarColorPicker>(config => config.selectedColor)
|
||||
selectedColor!: string;
|
||||
selectedColor!: string;
|
||||
|
||||
@ImmutableProperty<TouchBarColorPicker>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { color: string }) => {
|
||||
setInternalProp('selectedColor', details.color);
|
||||
onChange(details.color);
|
||||
} : null)
|
||||
onInteraction!: Function | null;
|
||||
onInteraction!: Function | null;
|
||||
}
|
||||
|
||||
class TouchBarGroup extends TouchBarItem<Electron.TouchBarGroupConstructorOptions> implements Electron.TouchBarGroup {
|
||||
@ImmutableProperty(() => 'group')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarGroup>(config => config.items instanceof TouchBar ? config.items : new TouchBar(config.items), (self, newChild: TouchBar) => {
|
||||
if (self.child) {
|
||||
|
@ -138,39 +138,39 @@ class TouchBarGroup extends TouchBarItem<Electron.TouchBarGroupConstructorOption
|
|||
item._addParent(self);
|
||||
}
|
||||
})
|
||||
child!: TouchBar;
|
||||
child!: TouchBar;
|
||||
|
||||
onInteraction = null;
|
||||
}
|
||||
|
||||
class TouchBarLabel extends TouchBarItem<Electron.TouchBarLabelConstructorOptions> implements Electron.TouchBarLabel {
|
||||
@ImmutableProperty(() => 'label')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarLabel>(config => config.label)
|
||||
label!: string;
|
||||
label!: string;
|
||||
|
||||
@LiveProperty<TouchBarLabel>(config => config.accessibilityLabel)
|
||||
accessibilityLabel!: string;
|
||||
accessibilityLabel!: string;
|
||||
|
||||
@LiveProperty<TouchBarLabel>(config => config.textColor)
|
||||
textColor!: string;
|
||||
textColor!: string;
|
||||
|
||||
onInteraction = null;
|
||||
}
|
||||
|
||||
class TouchBarPopover extends TouchBarItem<Electron.TouchBarPopoverConstructorOptions> implements Electron.TouchBarPopover {
|
||||
@ImmutableProperty(() => 'popover')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarPopover>(config => config.label)
|
||||
label!: string;
|
||||
label!: string;
|
||||
|
||||
@LiveProperty<TouchBarPopover>(config => config.icon)
|
||||
icon!: Electron.NativeImage;
|
||||
icon!: Electron.NativeImage;
|
||||
|
||||
@LiveProperty<TouchBarPopover>(config => config.showCloseButton)
|
||||
showCloseButton!: boolean;
|
||||
showCloseButton!: boolean;
|
||||
|
||||
@LiveProperty<TouchBarPopover>(config => config.items instanceof TouchBar ? config.items : new TouchBar(config.items), (self, newChild: TouchBar) => {
|
||||
if (self.child) {
|
||||
|
@ -182,88 +182,88 @@ class TouchBarPopover extends TouchBarItem<Electron.TouchBarPopoverConstructorOp
|
|||
item._addParent(self);
|
||||
}
|
||||
})
|
||||
child!: TouchBar;
|
||||
child!: TouchBar;
|
||||
|
||||
onInteraction = null;
|
||||
}
|
||||
|
||||
class TouchBarSlider extends TouchBarItem<Electron.TouchBarSliderConstructorOptions> implements Electron.TouchBarSlider {
|
||||
@ImmutableProperty(() => 'slider')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarSlider>(config => config.label)
|
||||
label!: string;
|
||||
label!: string;
|
||||
|
||||
@LiveProperty<TouchBarSlider>(config => config.minValue)
|
||||
minValue!: number;
|
||||
minValue!: number;
|
||||
|
||||
@LiveProperty<TouchBarSlider>(config => config.maxValue)
|
||||
maxValue!: number;
|
||||
maxValue!: number;
|
||||
|
||||
@LiveProperty<TouchBarSlider>(config => config.value)
|
||||
value!: number;
|
||||
value!: number;
|
||||
|
||||
@ImmutableProperty<TouchBarSlider>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { value: number }) => {
|
||||
setInternalProp('value', details.value);
|
||||
onChange(details.value);
|
||||
} : null)
|
||||
onInteraction!: Function | null;
|
||||
onInteraction!: Function | null;
|
||||
}
|
||||
|
||||
class TouchBarSpacer extends TouchBarItem<Electron.TouchBarSpacerConstructorOptions> implements Electron.TouchBarSpacer {
|
||||
@ImmutableProperty(() => 'spacer')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@ImmutableProperty<TouchBarSpacer>(config => config.size)
|
||||
size!: Electron.TouchBarSpacer['size'];
|
||||
size!: Electron.TouchBarSpacer['size'];
|
||||
|
||||
onInteraction = null;
|
||||
}
|
||||
|
||||
class TouchBarSegmentedControl extends TouchBarItem<Electron.TouchBarSegmentedControlConstructorOptions> implements Electron.TouchBarSegmentedControl {
|
||||
@ImmutableProperty(() => 'segmented_control')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarSegmentedControl>(config => config.segmentStyle)
|
||||
segmentStyle!: Electron.TouchBarSegmentedControl['segmentStyle'];
|
||||
segmentStyle!: Electron.TouchBarSegmentedControl['segmentStyle'];
|
||||
|
||||
@LiveProperty<TouchBarSegmentedControl>(config => config.segments || [])
|
||||
segments!: Electron.SegmentedControlSegment[];
|
||||
segments!: Electron.SegmentedControlSegment[];
|
||||
|
||||
@LiveProperty<TouchBarSegmentedControl>(config => config.selectedIndex)
|
||||
selectedIndex!: number;
|
||||
selectedIndex!: number;
|
||||
|
||||
@LiveProperty<TouchBarSegmentedControl>(config => config.mode)
|
||||
mode!: Electron.TouchBarSegmentedControl['mode'];
|
||||
mode!: Electron.TouchBarSegmentedControl['mode'];
|
||||
|
||||
@ImmutableProperty<TouchBarSegmentedControl>(({ change: onChange }, setInternalProp) => typeof onChange === 'function' ? (details: { selectedIndex: number, isSelected: boolean }) => {
|
||||
setInternalProp('selectedIndex', details.selectedIndex);
|
||||
onChange(details.selectedIndex, details.isSelected);
|
||||
} : null)
|
||||
onInteraction!: Function | null;
|
||||
onInteraction!: Function | null;
|
||||
}
|
||||
|
||||
class TouchBarScrubber extends TouchBarItem<Electron.TouchBarScrubberConstructorOptions> implements Electron.TouchBarScrubber {
|
||||
@ImmutableProperty(() => 'scrubber')
|
||||
type!: string;
|
||||
type!: string;
|
||||
|
||||
@LiveProperty<TouchBarScrubber>(config => config.items)
|
||||
items!: Electron.ScrubberItem[];
|
||||
items!: Electron.ScrubberItem[];
|
||||
|
||||
@LiveProperty<TouchBarScrubber>(config => config.selectedStyle || null)
|
||||
selectedStyle!: Electron.TouchBarScrubber['selectedStyle'];
|
||||
selectedStyle!: Electron.TouchBarScrubber['selectedStyle'];
|
||||
|
||||
@LiveProperty<TouchBarScrubber>(config => config.overlayStyle || null)
|
||||
overlayStyle!: Electron.TouchBarScrubber['overlayStyle'];
|
||||
overlayStyle!: Electron.TouchBarScrubber['overlayStyle'];
|
||||
|
||||
@LiveProperty<TouchBarScrubber>(config => config.showArrowButtons || false)
|
||||
showArrowButtons!: boolean;
|
||||
showArrowButtons!: boolean;
|
||||
|
||||
@LiveProperty<TouchBarScrubber>(config => config.mode || 'free')
|
||||
mode!: Electron.TouchBarScrubber['mode'];
|
||||
mode!: Electron.TouchBarScrubber['mode'];
|
||||
|
||||
@LiveProperty<TouchBarScrubber>(config => typeof config.continuous === 'undefined' ? true : config.continuous)
|
||||
continuous!: boolean;
|
||||
continuous!: boolean;
|
||||
|
||||
@ImmutableProperty<TouchBarScrubber>(({ select: onSelect, highlight: onHighlight }) => typeof onSelect === 'function' || typeof onHighlight === 'function' ? (details: { type: 'select'; selectedIndex: number } | { type: 'highlight'; highlightedIndex: number }) => {
|
||||
if (details.type === 'select') {
|
||||
|
@ -272,7 +272,7 @@ class TouchBarScrubber extends TouchBarItem<Electron.TouchBarScrubberConstructor
|
|||
if (onHighlight) onHighlight(details.highlightedIndex);
|
||||
}
|
||||
} : null)
|
||||
onInteraction!: Function | null;
|
||||
onInteraction!: Function | null;
|
||||
}
|
||||
|
||||
class TouchBarOtherItemsProxy extends TouchBarItem<null> implements Electron.TouchBarOtherItemsProxy {
|
||||
|
|
|
@ -19,14 +19,14 @@ export class IpcMainImpl extends EventEmitter {
|
|||
throw new Error(`Expected handler to be a function, but found type '${typeof fn}'`);
|
||||
}
|
||||
this._invokeHandlers.set(method, fn);
|
||||
}
|
||||
};
|
||||
|
||||
handleOnce: Electron.IpcMain['handleOnce'] = (method, fn) => {
|
||||
this.handle(method, (e, ...args) => {
|
||||
this.removeHandler(method);
|
||||
return fn(e, ...args);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
removeHandler (method: string) {
|
||||
this._invokeHandlers.delete(method);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { EventEmitter } from 'events';
|
||||
|
||||
export class MessagePortMain extends EventEmitter {
|
||||
_internalPort: any
|
||||
_internalPort: any;
|
||||
constructor (internalPort: any) {
|
||||
super();
|
||||
this._internalPort = internalPort;
|
||||
|
|
|
@ -53,7 +53,7 @@ export class WebViewAttribute implements MutationHandler {
|
|||
}
|
||||
|
||||
// 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.
|
||||
|
@ -73,7 +73,7 @@ class BooleanAttribute extends WebViewAttribute {
|
|||
|
||||
// Attribute representing the state of the storage partition.
|
||||
export class PartitionAttribute extends WebViewAttribute {
|
||||
public validPartitionId = true
|
||||
public validPartitionId = true;
|
||||
|
||||
constructor (public webViewImpl: WebViewImpl) {
|
||||
super(WEB_VIEW_ATTRIBUTES.PARTITION, webViewImpl);
|
||||
|
@ -92,7 +92,7 @@ export class PartitionAttribute extends WebViewAttribute {
|
|||
this.validPartitionId = false;
|
||||
console.error(WEB_VIEW_ERROR_MESSAGES.INVALID_PARTITION_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Attribute that handles the location and navigation of the webview.
|
||||
|
@ -134,7 +134,7 @@ export class SrcAttribute extends WebViewAttribute {
|
|||
return;
|
||||
}
|
||||
this.parse();
|
||||
}
|
||||
};
|
||||
|
||||
// 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
|
||||
|
|
|
@ -19,16 +19,16 @@ export interface WebViewImplHooks {
|
|||
|
||||
// Represents the internal state of the WebView node.
|
||||
export class WebViewImpl {
|
||||
public beforeFirstNavigation = true
|
||||
public elementAttached = false
|
||||
public guestInstanceId?: number
|
||||
public hasFocus = false
|
||||
public beforeFirstNavigation = true;
|
||||
public elementAttached = false;
|
||||
public guestInstanceId?: number;
|
||||
public hasFocus = false;
|
||||
public internalInstanceId?: number;
|
||||
public viewInstanceId: number
|
||||
public viewInstanceId: number;
|
||||
|
||||
// on* Event handlers.
|
||||
public on: Record<string, any> = {}
|
||||
public internalElement: HTMLIFrameElement
|
||||
public on: Record<string, any> = {};
|
||||
public internalElement: HTMLIFrameElement;
|
||||
|
||||
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');
|
||||
|
||||
export class ParentPort extends EventEmitter {
|
||||
#port: ParentPort
|
||||
#port: ParentPort;
|
||||
constructor () {
|
||||
super();
|
||||
this.#port = createParentPort();
|
||||
|
|
|
@ -32,21 +32,20 @@
|
|||
"@types/uuid": "^3.4.6",
|
||||
"@types/webpack": "^5.28.0",
|
||||
"@types/webpack-env": "^1.17.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.4.1",
|
||||
"@typescript-eslint/parser": "^4.4.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"buffer": "^6.0.3",
|
||||
"check-for-leaks": "^1.2.1",
|
||||
"colors": "1.4.0",
|
||||
"dotenv-safe": "^4.0.4",
|
||||
"dugite": "^2.3.0",
|
||||
"eslint": "^7.4.0",
|
||||
"eslint": "^8.41.0",
|
||||
"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-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"eslint-plugin-typescript": "^0.14.0",
|
||||
"events": "^3.2.0",
|
||||
"express": "^4.16.4",
|
||||
"folder-hash": "^2.1.1",
|
||||
|
|
|
@ -65,11 +65,11 @@ class RemoteControlApp {
|
|||
req.write(js);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
remotely = (script: Function, ...args: any[]): Promise<any> => {
|
||||
return this.remoteEval(`(${script})(...${JSON.stringify(args)})`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export async function startRemoteControlApp (extraArgs: string[] = [], options?: childProcess.SpawnOptionsWithoutStdio) {
|
||||
|
|
Loading…
Reference in a new issue