Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a8fc24ff6 | ||
|
|
3ed41626b1 | ||
|
|
b3e25cfe79 | ||
|
|
00bb15a891 | ||
|
|
94da51128a | ||
|
|
b573f09494 | ||
|
|
f05e36de34 | ||
|
|
44c7c70793 | ||
|
|
bcbca7aceb | ||
|
|
9515458545 | ||
|
|
219e90cad8 | ||
|
|
ba23c8019d | ||
|
|
2fef96a2b2 | ||
|
|
2d8cb9748d | ||
|
|
eaefbb7ad0 | ||
|
|
d5f28253f8 | ||
|
|
ac451d6b4a | ||
|
|
b5e0e63766 | ||
|
|
49538ea55a | ||
|
|
23ac9b8e02 | ||
|
|
4bf2bee7c8 | ||
|
|
e742d8426c | ||
|
|
6bdc995eb6 | ||
|
|
72cbcd46d1 | ||
|
|
f1e51c71a3 | ||
|
|
95e88c0eee | ||
|
|
a54037ef0e | ||
|
|
83bb6fc73e | ||
|
|
f8f1f0ec08 | ||
|
|
f7a19b92a8 | ||
|
|
dc76b78337 | ||
|
|
f6f3e94a97 | ||
|
|
89cede25b1 | ||
|
|
8e8eec3cc6 | ||
|
|
a0d8ca4019 | ||
|
|
1f0581afbc |
@@ -15,13 +15,13 @@ address bar.
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/378023/49716908-7d2b0500-fc98-11e8-8f52-def504802509.png" width="880px" alt="Electron Fiddle screenshot">
|
||||
<img src="https://user-images.githubusercontent.com/1426799/52155868-d3357c80-2639-11e9-9496-fa97b1dc7897.jpg" width="880px" alt="Electron Fiddle screenshot">
|
||||
|
||||
# Features
|
||||
|
||||
### Explore Electron
|
||||
|
||||

|
||||

|
||||
|
||||
Try Electron without installing any dependencies: Fiddle includes everything
|
||||
you'll need to explore the platform. It also includes examples for every API
|
||||
@@ -40,7 +40,7 @@ all Electron APIs only a few keystrokes away.
|
||||
|
||||
### Compile and Package
|
||||
|
||||

|
||||

|
||||
|
||||
Fiddle can automatically turn your experiment into binaries you can share with
|
||||
your friends, coworkers, or grandparents. It does so thanks to
|
||||
|
||||
Generated
+3412
-4610
File diff suppressed because it is too large
Load Diff
+40
-40
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "electron-fiddle",
|
||||
"productName": "Electron Fiddle",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"description": "The easiest way to get started with Electron",
|
||||
"repository": "https://github.com/electron/fiddle",
|
||||
"main": "./dist/src/main/main",
|
||||
@@ -11,7 +11,7 @@
|
||||
"lint:style": "stylelint ./src/less/*.less --fix",
|
||||
"lint:ts": "tslint -c tslint.json -p tsconfig.json -e \"node_modules/**/*.ts\" --fix",
|
||||
"lint:tests": "tslint ./tests/**/*.ts{,x} -c tslint.json --fix",
|
||||
"lint:templates": "standard ./static/templates/**/*.js",
|
||||
"lint:templates": "standard ./static/show-me/**/*.js",
|
||||
"lint": "npm-run-all lint:*",
|
||||
"make": "electron-forge make",
|
||||
"package": "electron-forge package",
|
||||
@@ -36,9 +36,9 @@
|
||||
"forge": "./forge.config.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blueprintjs/core": "^3.10.0",
|
||||
"@blueprintjs/select": "^3.4.0",
|
||||
"@octokit/rest": "^15.12.1",
|
||||
"@blueprintjs/core": "^3.14.1",
|
||||
"@blueprintjs/select": "^3.7.0",
|
||||
"@octokit/rest": "^16.20.0",
|
||||
"builtin-modules": "^3.0.0",
|
||||
"classnames": "^2.2.6",
|
||||
"electron-default-menu": "^1.0.1",
|
||||
@@ -47,60 +47,60 @@
|
||||
"extract-zip": "^1.6.7",
|
||||
"fix-path": "^2.1.0",
|
||||
"fs-extra": "^7.0.1",
|
||||
"mobx": "^5.8.0",
|
||||
"mobx": "^5.9.0",
|
||||
"mobx-react": "^5.4.3",
|
||||
"monaco-loader": "^0.15.0",
|
||||
"namor": "^1.1.1",
|
||||
"react": "^16.7.0",
|
||||
"react-dom": "^16.7.0",
|
||||
"react-mosaic-component": "^2.0.2",
|
||||
"monaco-loader": "^0.16.0",
|
||||
"namor": "^1.1.2",
|
||||
"react": "^16.8.5",
|
||||
"react-dom": "^16.8.5",
|
||||
"react-mosaic-component": "^2.1.0",
|
||||
"semver": "^5.6.0",
|
||||
"tmp": "0.0.33",
|
||||
"tslib": "^1.9.3",
|
||||
"update-electron-app": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "^6.0.0-beta.32",
|
||||
"@electron-forge/maker-deb": "^6.0.0-beta.32",
|
||||
"@electron-forge/maker-rpm": "^6.0.0-beta.32",
|
||||
"@electron-forge/maker-squirrel": "^6.0.0-beta.32",
|
||||
"@electron-forge/maker-zip": "^6.0.0-beta.32",
|
||||
"@electron-forge/publisher-github": "^6.0.0-beta.32",
|
||||
"@electron-forge/cli": "^6.0.0-beta.34",
|
||||
"@electron-forge/maker-deb": "^6.0.0-beta.34",
|
||||
"@electron-forge/maker-rpm": "^6.0.0-beta.34",
|
||||
"@electron-forge/maker-squirrel": "^6.0.0-beta.34",
|
||||
"@electron-forge/maker-zip": "^6.0.0-beta.34",
|
||||
"@electron-forge/publisher-github": "^6.0.0-beta.34",
|
||||
"@types/builtin-modules": "^2.0.0",
|
||||
"@types/classnames": "^2.2.7",
|
||||
"@types/enzyme": "^3.1.13",
|
||||
"@types/fs-extra": "^5.0.4",
|
||||
"@types/jest": "^23.3.2",
|
||||
"@types/enzyme": "^3.9.1",
|
||||
"@types/fs-extra": "^5.0.5",
|
||||
"@types/jest": "^24.0.11",
|
||||
"@types/log-symbols": "^2.0.0",
|
||||
"@types/node": "^10.11.1",
|
||||
"@types/react": "^16.7.18",
|
||||
"@types/react-dom": "^16.0.11",
|
||||
"@types/react": "^16.8.8",
|
||||
"@types/react-dom": "^16.8.3",
|
||||
"@types/semver": "^5.5.0",
|
||||
"@types/tmp": "0.0.33",
|
||||
"chokidar": "^2.0.4",
|
||||
"coveralls": "^3.0.2",
|
||||
"electron": "4.0.2",
|
||||
"enzyme": "^3.6.0",
|
||||
"enzyme-adapter-react-16": "^1.5.0",
|
||||
"@types/tmp": "0.0.34",
|
||||
"chokidar": "^2.1.5",
|
||||
"coveralls": "^3.0.3",
|
||||
"electron": "4.1.1",
|
||||
"enzyme": "^3.9.0",
|
||||
"enzyme-adapter-react-16": "^1.11.2",
|
||||
"enzyme-to-json": "^3.3.5",
|
||||
"jest": "^23.6.0",
|
||||
"jest-fetch-mock": "^1.6.6",
|
||||
"less": "^3.8.1",
|
||||
"jest": "^24.5.0",
|
||||
"jest-fetch-mock": "^2.1.1",
|
||||
"less": "^3.9.0",
|
||||
"log-symbols": "^2.2.0",
|
||||
"monaco-editor": "^0.15.6",
|
||||
"node-abi": "^2.5.1",
|
||||
"monaco-editor": "^0.16.2",
|
||||
"node-abi": "^2.7.1",
|
||||
"node-fetch": "^2.3.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"parcel-bundler": "^1.11.0",
|
||||
"react-test-renderer": "^16.7.0",
|
||||
"parcel-bundler": "^1.12.3",
|
||||
"react-test-renderer": "^16.8.5",
|
||||
"rimraf": "^2.6.3",
|
||||
"standard": "^12.0.1",
|
||||
"stylelint": "^9.9.0",
|
||||
"stylelint": "^9.10.1",
|
||||
"stylelint-config-standard": "^18.2.0",
|
||||
"ts-jest": "^23.10.5",
|
||||
"tslint": "^5.12.0",
|
||||
"tslint-microsoft-contrib": "^6.0.0",
|
||||
"ts-jest": "^24.0.0",
|
||||
"tslint": "^5.14.0",
|
||||
"tslint-microsoft-contrib": "^6.1.0",
|
||||
"tslint-react": "^3.6.0",
|
||||
"typescript": "^3.2.2"
|
||||
"typescript": "^3.3.4000"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
// Variables, also imported in each file
|
||||
@import "variables.less";
|
||||
|
||||
@import "main.less";
|
||||
@import "container.less";
|
||||
@import "mosaic-vendor.less";
|
||||
|
||||
@@ -28,6 +28,15 @@ export async function onReady() {
|
||||
setupDialogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the "before-quit" event
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export function onBeforeQuit() {
|
||||
(global as any).isQuitting = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* All windows have been closed, quit on anything but
|
||||
* macOS.
|
||||
@@ -62,6 +71,7 @@ export function main() {
|
||||
|
||||
// Launch
|
||||
app.on('ready', onReady);
|
||||
app.on('before-quit', onBeforeQuit);
|
||||
app.on('window-all-closed', onWindowsAllClosed);
|
||||
app.on('activate', getOrCreateMainWindow);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export class AddressBar extends React.Component<AddressBarProps, AddressBarState
|
||||
this.loadFiddle = this.loadFiddle.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.submit = this.submit.bind(this);
|
||||
|
||||
const { gistId } = this.props.appState;
|
||||
const value = gistId ? urlFromId(gistId) : '';
|
||||
@@ -39,15 +40,19 @@ export class AddressBar extends React.Component<AddressBarProps, AddressBarState
|
||||
*
|
||||
* @param {React.SyntheticEvent<HTMLFormElement>} event
|
||||
*/
|
||||
public async handleSubmit(event: React.SyntheticEvent<HTMLFormElement>) {
|
||||
public handleSubmit(event: React.SyntheticEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
this.submit();
|
||||
}
|
||||
|
||||
this.props.appState.gistId = idFromUrl(this.state.value) || this.state.value;
|
||||
|
||||
console.log('Loading');
|
||||
|
||||
/**
|
||||
* Commit the address bar's value to app state and load the fiddle.
|
||||
*
|
||||
* @memberof AddressBar
|
||||
*/
|
||||
public submit() {
|
||||
if (this.state.value) {
|
||||
this.loadFiddle();
|
||||
this.loadFiddle(idFromUrl(this.state.value) || this.state.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,16 +81,24 @@ export class AddressBar extends React.Component<AddressBarProps, AddressBarState
|
||||
* @returns {Promise<boolean>}
|
||||
* @memberof AddressBar
|
||||
*/
|
||||
public async loadFiddle(): Promise<boolean> {
|
||||
public async loadFiddle(gistId: string): Promise<boolean> {
|
||||
const { appState } = this.props;
|
||||
|
||||
try {
|
||||
const octo = await getOctokit();
|
||||
const gist = await octo.gists.get({
|
||||
gist_id: appState.gistId
|
||||
});
|
||||
|
||||
this.props.appState.setWarningDialogTexts({
|
||||
// You can load Gists without being authenticated,
|
||||
// but we get better rate limits when authenticated
|
||||
if (appState.gitHubToken) {
|
||||
octo.authenticate({
|
||||
type: 'token',
|
||||
token: appState.gitHubToken!
|
||||
});
|
||||
}
|
||||
|
||||
const gist = await octo.gists.get({ gist_id: gistId });
|
||||
|
||||
appState.setWarningDialogTexts({
|
||||
label: 'Loading the fiddle will replace your current unsaved changes. Do you want to discard them?'
|
||||
});
|
||||
|
||||
@@ -96,8 +109,16 @@ export class AddressBar extends React.Component<AddressBarProps, AddressBarState
|
||||
});
|
||||
|
||||
document.title = getTitle(appState);
|
||||
appState.gistId = gistId;
|
||||
appState.localPath = null;
|
||||
} catch (error) {
|
||||
appState.setWarningDialogTexts({
|
||||
label: `Loading the fiddle failed: ${error}`,
|
||||
cancel: undefined
|
||||
});
|
||||
|
||||
appState.toogleWarningDialog();
|
||||
|
||||
console.warn(`Loading Fiddle failed`, error);
|
||||
return false;
|
||||
}
|
||||
@@ -111,7 +132,7 @@ export class AddressBar extends React.Component<AddressBarProps, AddressBarState
|
||||
disabled={!isValueCorrect}
|
||||
icon='cloud-download'
|
||||
text='Load Fiddle'
|
||||
onClick={this.loadFiddle}
|
||||
onClick={this.submit}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,10 +121,26 @@ export class VersionChooser extends React.Component<VersionChooserProps, Version
|
||||
}
|
||||
|
||||
public getItems(): Array<ElectronVersion> {
|
||||
const { versions, versionsToShow } = this.props.appState;
|
||||
const { versions, versionsToShow, statesToShow } = this.props.appState;
|
||||
|
||||
return sortedElectronMap<ElectronVersion>(versions, (_key, item) => item)
|
||||
.filter((item) => !!item && versionsToShow.includes(getReleaseChannel(item)));
|
||||
.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if we want to show the version
|
||||
if (!versionsToShow.includes(getReleaseChannel(item))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if we want to show the state
|
||||
if (!statesToShow.includes(item.state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
||||
@@ -64,7 +64,7 @@ export class TokenDialog extends React.Component<TokenDialogProps, TokenDialogSt
|
||||
});
|
||||
|
||||
try {
|
||||
const { data } = await octo.users.get({});
|
||||
const { data } = await octo.users.getAuthenticated();
|
||||
this.props.appState.gitHubAvatarUrl = data.avatar_url;
|
||||
this.props.appState.gitHubLogin = data.login;
|
||||
this.props.appState.gitHubName = data.name;
|
||||
|
||||
@@ -41,6 +41,7 @@ export class ElectronSettings extends React.Component<ElectronSettingsProps, Ele
|
||||
this.handleDownloadAll = this.handleDownloadAll.bind(this);
|
||||
this.handleDeleteAll = this.handleDeleteAll.bind(this);
|
||||
this.handleChannelChange = this.handleChannelChange.bind(this);
|
||||
this.handleStateChange = this.handleStateChange.bind(this);
|
||||
this.handleDownloadClick = this.handleDownloadClick.bind(this);
|
||||
this.handleAddVersion = this.handleAddVersion.bind(this);
|
||||
|
||||
@@ -54,6 +55,24 @@ export class ElectronSettings extends React.Component<ElectronSettingsProps, Ele
|
||||
this.props.appState.updateElectronVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a change in which channels should be displayed.
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLInputElement>} event
|
||||
*/
|
||||
public handleStateChange(
|
||||
event: React.FormEvent<HTMLInputElement>
|
||||
) {
|
||||
const { id, checked } = event.currentTarget;
|
||||
const { appState } = this.props;
|
||||
|
||||
if (!checked) {
|
||||
appState.statesToShow = appState.statesToShow.filter((s) => s !== id);
|
||||
} else {
|
||||
appState.statesToShow.push(id as ElectronVersionState);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a change in which channels should be displayed.
|
||||
*
|
||||
@@ -120,7 +139,10 @@ export class ElectronSettings extends React.Component<ElectronSettingsProps, Ele
|
||||
return (
|
||||
<div className='settings-electron'>
|
||||
<h2>Electron Settings</h2>
|
||||
{this.renderVersionOptions()}
|
||||
<Callout>
|
||||
{this.renderVersionChannelOptions()}
|
||||
{this.renderVersionStateOptions()}
|
||||
</Callout>
|
||||
<br />
|
||||
<Callout>
|
||||
{this.renderAdvancedButtons()}
|
||||
@@ -173,51 +195,91 @@ export class ElectronSettings extends React.Component<ElectronSettingsProps, Ele
|
||||
|
||||
/**
|
||||
* Renders the various options for which versions should be displayed
|
||||
* in the small dropdown.
|
||||
*
|
||||
* @private
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
private renderVersionOptions(): JSX.Element {
|
||||
private renderVersionStateOptions(): JSX.Element {
|
||||
const { appState } = this.props;
|
||||
const getIsChecked = (state: ElectronVersionState) => {
|
||||
return appState.statesToShow.includes(state);
|
||||
};
|
||||
|
||||
return (
|
||||
<FormGroup
|
||||
label='Include Electron versions that are:'
|
||||
>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronVersionState.downloading)}
|
||||
label='Downloading'
|
||||
id='downloading'
|
||||
onChange={this.handleStateChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronVersionState.ready)}
|
||||
label='Downloaded'
|
||||
id='ready'
|
||||
onChange={this.handleStateChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronVersionState.unknown)}
|
||||
label='Not Downloaded'
|
||||
id='unknown'
|
||||
onChange={this.handleStateChange}
|
||||
inline={true}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the various options for which versions should be displayed
|
||||
*
|
||||
* @private
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
private renderVersionChannelOptions(): JSX.Element {
|
||||
const { appState } = this.props;
|
||||
const getIsChecked = (channel: ElectronReleaseChannel) => {
|
||||
return appState.versionsToShow.includes(channel);
|
||||
};
|
||||
|
||||
return (
|
||||
<Callout>
|
||||
<FormGroup
|
||||
label='Include Electron versions from these release channels:'
|
||||
>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.stable)}
|
||||
label='Stable'
|
||||
id='Stable'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.beta)}
|
||||
label='Beta'
|
||||
id='Beta'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.nightly)}
|
||||
label='Nightly'
|
||||
id='Nightly'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.unsupported)}
|
||||
label='Unsupported'
|
||||
id='Unsupported'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Callout>
|
||||
<FormGroup
|
||||
label='Include Electron versions from these release channels:'
|
||||
>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.stable)}
|
||||
label='Stable'
|
||||
id='Stable'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.beta)}
|
||||
label='Beta'
|
||||
id='Beta'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.nightly)}
|
||||
label='Nightly'
|
||||
id='Nightly'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={getIsChecked(ElectronReleaseChannel.unsupported)}
|
||||
label='Unsupported'
|
||||
id='Unsupported'
|
||||
onChange={this.handleChannelChange}
|
||||
inline={true}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -254,7 +316,7 @@ export class ElectronSettings extends React.Component<ElectronSettingsProps, Ele
|
||||
* @returns {Array<JSX.Element>}
|
||||
*/
|
||||
private renderTableRows(): Array<JSX.Element | null> {
|
||||
const { versions, versionsToShow } = this.props.appState;
|
||||
const { versions, versionsToShow, statesToShow } = this.props.appState;
|
||||
|
||||
return sortedElectronMap<JSX.Element | null>(versions, (key, item) => {
|
||||
// Check if we want to show the version
|
||||
@@ -262,6 +324,11 @@ export class ElectronSettings extends React.Component<ElectronSettingsProps, Ele
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if we want to show the state
|
||||
if (!statesToShow.includes(item.state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<tr key={item.version}>
|
||||
<td>{item.version}</td>
|
||||
@@ -273,7 +340,7 @@ export class ElectronSettings extends React.Component<ElectronSettingsProps, Ele
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human-readable state indicator for an Electorn version
|
||||
* Returns a human-readable state indicator for an Electron version
|
||||
*
|
||||
* @param {ElectronVersion} item
|
||||
* @returns {JSX.Element}
|
||||
|
||||
@@ -20,6 +20,7 @@ export class ExecutionSettings extends React.Component<ExecutionSettingsProps, {
|
||||
super(props);
|
||||
|
||||
this.handleDeleteDataChange = this.handleDeleteDataChange.bind(this);
|
||||
this.handleElectronLoggingChange = this.handleElectronLoggingChange.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,14 +36,30 @@ export class ExecutionSettings extends React.Component<ExecutionSettingsProps, {
|
||||
this.props.appState.isKeepingUserDataDirs = checked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a change on whether or not electron should log more things
|
||||
*
|
||||
* @param {React.ChangeEvent<HTMLInputElement>} event
|
||||
*/
|
||||
public handleElectronLoggingChange(
|
||||
event: React.FormEvent<HTMLInputElement>
|
||||
) {
|
||||
const { checked } = event.currentTarget;
|
||||
this.props.appState.isEnablingElectronLogging = checked;
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { isKeepingUserDataDirs } = this.props.appState;
|
||||
const { isKeepingUserDataDirs, isEnablingElectronLogging } = this.props.appState;
|
||||
|
||||
const deleteUserDirLabel = `
|
||||
Whenever Electron runs, it creates a user data directory for cookies, the cache,
|
||||
and various other things that it needs to keep around. Since fiddles are usually
|
||||
just run once, we delete this directory after your fiddle exits. Enable this
|
||||
setting to keep the user data directories around.
|
||||
`.trim();
|
||||
const electronLoggingLabel = `
|
||||
There are some flags that Electron uses to log extra information both internally
|
||||
and through Chromium. Enable this option to make Fiddle produce those logs.`.trim();
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -52,14 +69,24 @@ export class ExecutionSettings extends React.Component<ExecutionSettingsProps, {
|
||||
</Callout>
|
||||
<br />
|
||||
<Callout>
|
||||
<FormGroup label={deleteUserDirLabel}>
|
||||
<Checkbox
|
||||
checked={isKeepingUserDataDirs}
|
||||
label='Do not delete user data directories.'
|
||||
onChange={this.handleDeleteDataChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Callout>
|
||||
<FormGroup label={deleteUserDirLabel}>
|
||||
<Checkbox
|
||||
checked={isKeepingUserDataDirs}
|
||||
label='Do not delete user data directories.'
|
||||
onChange={this.handleDeleteDataChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Callout>
|
||||
<br />
|
||||
<Callout>
|
||||
<FormGroup label={electronLoggingLabel}>
|
||||
<Checkbox
|
||||
checked={isEnablingElectronLogging}
|
||||
label='Enable advanced Electron logging.'
|
||||
onChange={this.handleElectronLoggingChange}
|
||||
/>
|
||||
</FormGroup>
|
||||
</Callout>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+13
-1
@@ -181,7 +181,19 @@ export class Runner {
|
||||
const binaryPath = binaryManager.getElectronBinaryPath(version, localPath);
|
||||
console.log(`Runner: Binary ${binaryPath} ready, launching`);
|
||||
|
||||
this.child = spawn(binaryPath, [ dir, '--inspect' ]);
|
||||
const env = { ...process.env };
|
||||
if (this.appState.isEnablingElectronLogging) {
|
||||
env.ELECTRON_ENABLE_LOGGING = 'true';
|
||||
env.ELECTRON_ENABLE_STACK_DUMPING = 'true';
|
||||
} else {
|
||||
delete env.ELECTRON_ENABLE_LOGGING;
|
||||
delete env.ELECTRON_ENABLE_STACK_DUMPING;
|
||||
}
|
||||
|
||||
this.child = spawn(binaryPath, [ dir, '--inspect' ], {
|
||||
cwd: dir,
|
||||
env,
|
||||
});
|
||||
this.appState.isRunning = true;
|
||||
pushOutput(`Electron v${version} started.`);
|
||||
|
||||
|
||||
+16
-1
@@ -62,7 +62,11 @@ export class AppState {
|
||||
@observable public versionsToShow: Array<ElectronReleaseChannel> =
|
||||
this.retrieve('versionsToShow') as Array<ElectronReleaseChannel>
|
||||
|| [ ElectronReleaseChannel.stable, ElectronReleaseChannel.beta ];
|
||||
@observable public statesToShow: Array<ElectronVersionState> =
|
||||
this.retrieve('statesToShow') as Array<ElectronVersionState>
|
||||
|| [ ElectronVersionState.downloading, ElectronVersionState.ready, ElectronVersionState.unknown ];
|
||||
@observable public isKeepingUserDataDirs: boolean = !!this.retrieve('isKeepingUserDataDirs');
|
||||
@observable public isEnablingElectronLogging: boolean = !!this.retrieve('isEnablingElectronLogging');
|
||||
|
||||
@observable public binaryManager: BinaryManager = new BinaryManager();
|
||||
|
||||
@@ -114,8 +118,10 @@ export class AppState {
|
||||
autorun(() => this.save('gitHubToken', this.gitHubToken));
|
||||
autorun(() => this.save('gitHubPublishAsPublic', this.gitHubPublishAsPublic));
|
||||
autorun(() => this.save('isKeepingUserDataDirs', this.isKeepingUserDataDirs));
|
||||
autorun(() => this.save('isEnablingElectronLogging', this.isEnablingElectronLogging));
|
||||
autorun(() => this.save('version', this.version));
|
||||
autorun(() => this.save('versionsToShow', this.versionsToShow));
|
||||
autorun(() => this.save('statesToShow', this.statesToShow));
|
||||
|
||||
autorun(() => {
|
||||
if (this.isUnsaved) {
|
||||
@@ -132,7 +138,16 @@ export class AppState {
|
||||
// The user confirmed, let's close for real.
|
||||
if (this.warningDialogLastResult) {
|
||||
window.onbeforeunload = null;
|
||||
window.close();
|
||||
|
||||
// Should we just close or quit?
|
||||
const remote = require('electron').remote;
|
||||
const isQuitting = remote.getGlobal('isQuitting');
|
||||
|
||||
if (isQuitting) {
|
||||
remote.app.quit();
|
||||
} else {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import { fancyImport } from '../utils/import';
|
||||
export async function getTemplateValues(name: string): Promise<EditorValues> {
|
||||
const path = await fancyImport<typeof pathType>('path');
|
||||
const fs = await fancyImport<typeof fsExtraType>('fs-extra');
|
||||
|
||||
const templatePath = path.join(__dirname, '../../static/templates', name.toLowerCase());
|
||||
const templatesPath = path.join(__dirname, '../../static/show-me');
|
||||
const templatePath = path.join(templatesPath, name.toLowerCase());
|
||||
|
||||
const getFile = async (fileName: string) => {
|
||||
try {
|
||||
@@ -25,7 +25,15 @@ export async function getTemplateValues(name: string): Promise<EditorValues> {
|
||||
|
||||
return content;
|
||||
} catch (error) {
|
||||
console.warn(`Could not get template file:`, error);
|
||||
console.warn(`getTemplateValues(): Could not get template file:`, error);
|
||||
|
||||
if (fs.existsSync(templatesPath)) {
|
||||
const contents = fs.readdirSync(templatesPath);
|
||||
console.log(`getTemplateValues(): ${templatesPath} contents:`, contents);
|
||||
} else {
|
||||
console.log(`getTemplateValues(): ${templatesPath} does not exist`);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"version":"0.1.0"},{"version":"0.1.1"},{"version":"0.1.2"},{"version":"0.2.0"},{"version":"0.2.1"},{"version":"0.3.0"},{"version":"0.4.0"},{"version":"0.4.1"},{"version":"1.3.1"},{"version":"1.3.2"},{"version":"1.3.3"},{"version":"1.3.4"},{"version":"1.3.5"},{"version":"1.3.6"},{"version":"1.4.0"},{"version":"1.4.1"},{"version":"1.3.7"},{"version":"1.4.2"},{"version":"1.4.3"},{"version":"1.4.4"},{"version":"1.3.8"},{"version":"1.4.5"},{"version":"1.4.6"},{"version":"1.4.7"},{"version":"1.3.9"},{"version":"1.3.10"},{"version":"1.4.8"},{"version":"1.3.12"},{"version":"1.4.10"},{"version":"1.3.13"},{"version":"1.4.11"},{"version":"1.4.12"},{"version":"1.4.13"},{"version":"1.4.14"},{"version":"1.4.15"},{"version":"1.5.0"},{"version":"1.5.1"},{"version":"1.6.0"},{"version":"1.6.1"},{"version":"1.6.2"},{"version":"1.6.3"},{"version":"1.3.14"},{"version":"1.6.4"},{"version":"1.6.5"},{"version":"1.4.16"},{"version":"1.6.6"},{"version":"1.6.7"},{"version":"1.3.15"},{"version":"1.6.8"},{"version":"1.6.9"},{"version":"1.7.0"},{"version":"1.6.10"},{"version":"1.7.1"},{"version":"1.6.11"},{"version":"1.7.2"},{"version":"1.7.3"},{"version":"1.7.4"},{"version":"1.7.5"},{"version":"1.6.12"},{"version":"1.7.6"},{"version":"1.7.7"},{"version":"1.6.13"},{"version":"1.7.8"},{"version":"1.6.14"},{"version":"1.8.1"},{"version":"1.7.9"},{"version":"1.6.15"},{"version":"1.8.2-beta.1"},{"version":"1.8.2-beta.2"},{"version":"1.8.2-beta.3"},{"version":"1.7.10"},{"version":"1.7.11"},{"version":"1.6.16"},{"version":"1.8.2-beta.4"},{"version":"1.8.2-beta.5"},{"version":"1.7.12"},{"version":"1.6.17"},{"version":"1.8.2"},{"version":"2.0.0-beta.1"},{"version":"2.0.0-beta.2"},{"version":"1.8.3"},{"version":"2.0.0-beta.3"},{"version":"1.7.13"},{"version":"2.0.0-beta.4"},{"version":"1.8.4"},{"version":"2.0.0-beta.5"},{"version":"2.0.0-beta.6"},{"version":"2.0.0-beta.7"},{"version":"2.0.0-beta.8"},{"version":"1.8.5"},{"version":"1.7.14"},{"version":"1.8.6"},{"version":"2.0.0"},{"version":"1.6.18"},{"version":"1.7.15"},{"version":"1.8.7"},{"version":"2.0.1"},{"version":"2.0.2"},{"version":"3.0.0-beta.1"},{"version":"2.0.3"},{"version":"2.0.4"},{"version":"3.0.0-beta.2"},{"version":"2.0.5"},{"version":"3.0.0-beta.3"},{"version":"2.0.6"},{"version":"3.0.0-beta.4"},{"version":"2.0.7"},{"version":"2.1.0-unsupported.20180809"},{"version":"3.0.0-beta.5"},{"version":"4.0.0-nightly.20180816"},{"version":"4.0.0-nightly.20180817"},{"version":"3.0.0-nightly.20180818"},{"version":"4.0.0-nightly.20180819"},{"version":"2.0.8-nightly.20180819"},{"version":"3.0.0-beta.6"},{"version":"2.0.8-nightly.20180820"},{"version":"3.0.0-nightly.20180821"},{"version":"4.0.0-nightly.20180821"},{"version":"3.0.0-beta.7"},{"version":"2.0.8"},{"version":"1.8.8"},{"version":"1.7.16"},{"version":"3.0.0-beta.8"},{"version":"3.0.0-nightly.20180904"},{"version":"3.0.0-beta.9"},{"version":"3.0.0-beta.10"},{"version":"2.0.9"},{"version":"3.0.0-beta.11"},{"version":"3.0.0-beta.12"},{"version":"3.0.0-beta.13"},{"version":"3.0.0"},{"version":"2.0.10"},{"version":"3.0.1"},{"version":"3.0.2"},{"version":"4.0.0-nightly.20180929"},{"version":"2.0.11"},{"version":"4.0.0-nightly.20181006"},{"version":"3.0.3"},{"version":"4.0.0-nightly.20181010"},{"version":"3.0.4"},{"version":"4.0.0-beta.1"},{"version":"4.0.0-beta.2"},{"version":"4.0.0-beta.3"},{"version":"3.0.5"},{"version":"2.0.12"},{"version":"4.0.0-beta.4"},{"version":"4.0.0-beta.5"},{"version":"3.0.6"},{"version":"3.0.7"},{"version":"2.0.13"},{"version":"4.0.0-beta.6"},{"version":"3.0.8"},{"version":"4.0.0-beta.7"},{"version":"3.0.9"},{"version":"2.0.14"},{"version":"3.0.10"},{"version":"4.0.0-beta.8"},{"version":"3.1.0-beta.1"},{"version":"3.1.0-beta.2"},{"version":"3.0.11"},{"version":"4.0.0-beta.9"},{"version":"2.0.15"},{"version":"3.0.12"},{"version":"3.1.0-beta.3"},{"version":"3.0.13"},{"version":"3.1.0-beta.4"},{"version":"4.0.0-beta.10"}]
|
||||
[{"version":"0.1.0"},{"version":"0.1.1"},{"version":"0.1.2"},{"version":"0.2.0"},{"version":"0.2.1"},{"version":"0.3.0"},{"version":"0.4.0"},{"version":"0.4.1"},{"version":"1.3.1"},{"version":"1.3.2"},{"version":"1.3.3"},{"version":"1.3.4"},{"version":"1.3.5"},{"version":"1.3.6"},{"version":"1.4.0"},{"version":"1.4.1"},{"version":"1.3.7"},{"version":"1.4.2"},{"version":"1.4.3"},{"version":"1.4.4"},{"version":"1.3.8"},{"version":"1.4.5"},{"version":"1.4.6"},{"version":"1.4.7"},{"version":"1.3.9"},{"version":"1.3.10"},{"version":"1.4.8"},{"version":"1.3.12"},{"version":"1.4.10"},{"version":"1.3.13"},{"version":"1.4.11"},{"version":"1.4.12"},{"version":"1.4.13"},{"version":"1.4.14"},{"version":"1.4.15"},{"version":"1.5.0"},{"version":"1.5.1"},{"version":"1.6.0"},{"version":"1.6.1"},{"version":"1.6.2"},{"version":"1.6.3"},{"version":"1.3.14"},{"version":"1.6.4"},{"version":"1.6.5"},{"version":"1.4.16"},{"version":"1.6.6"},{"version":"1.6.7"},{"version":"1.3.15"},{"version":"1.6.8"},{"version":"1.6.9"},{"version":"1.7.0"},{"version":"1.6.10"},{"version":"1.7.1"},{"version":"1.6.11"},{"version":"1.7.2"},{"version":"1.7.3"},{"version":"1.7.4"},{"version":"1.7.5"},{"version":"1.6.12"},{"version":"1.7.6"},{"version":"1.7.7"},{"version":"1.6.13"},{"version":"1.7.8"},{"version":"1.6.14"},{"version":"1.8.1"},{"version":"1.7.9"},{"version":"1.6.15"},{"version":"1.8.2-beta.1"},{"version":"1.8.2-beta.2"},{"version":"1.8.2-beta.3"},{"version":"1.7.10"},{"version":"1.7.11"},{"version":"1.6.16"},{"version":"1.8.2-beta.4"},{"version":"1.8.2-beta.5"},{"version":"1.7.12"},{"version":"1.6.17"},{"version":"1.8.2"},{"version":"2.0.0-beta.1"},{"version":"2.0.0-beta.2"},{"version":"1.8.3"},{"version":"2.0.0-beta.3"},{"version":"1.7.13"},{"version":"2.0.0-beta.4"},{"version":"1.8.4"},{"version":"2.0.0-beta.5"},{"version":"2.0.0-beta.6"},{"version":"2.0.0-beta.7"},{"version":"2.0.0-beta.8"},{"version":"1.8.5"},{"version":"1.7.14"},{"version":"1.8.6"},{"version":"2.0.0"},{"version":"1.6.18"},{"version":"1.7.15"},{"version":"1.8.7"},{"version":"2.0.1"},{"version":"2.0.2"},{"version":"3.0.0-beta.1"},{"version":"2.0.3"},{"version":"2.0.4"},{"version":"3.0.0-beta.2"},{"version":"2.0.5"},{"version":"3.0.0-beta.3"},{"version":"2.0.6"},{"version":"3.0.0-beta.4"},{"version":"2.0.7"},{"version":"2.1.0-unsupported.20180809"},{"version":"3.0.0-beta.5"},{"version":"4.0.0-nightly.20180816"},{"version":"4.0.0-nightly.20180817"},{"version":"3.0.0-nightly.20180818"},{"version":"4.0.0-nightly.20180819"},{"version":"2.0.8-nightly.20180819"},{"version":"3.0.0-beta.6"},{"version":"2.0.8-nightly.20180820"},{"version":"3.0.0-nightly.20180821"},{"version":"4.0.0-nightly.20180821"},{"version":"3.0.0-beta.7"},{"version":"2.0.8"},{"version":"1.8.8"},{"version":"1.7.16"},{"version":"3.0.0-beta.8"},{"version":"3.0.0-nightly.20180904"},{"version":"3.0.0-beta.9"},{"version":"3.0.0-beta.10"},{"version":"2.0.9"},{"version":"3.0.0-beta.11"},{"version":"3.0.0-beta.12"},{"version":"3.0.0-beta.13"},{"version":"3.0.0"},{"version":"2.0.10"},{"version":"3.0.1"},{"version":"3.0.2"},{"version":"4.0.0-nightly.20180929"},{"version":"2.0.11"},{"version":"4.0.0-nightly.20181006"},{"version":"3.0.3"},{"version":"4.0.0-nightly.20181010"},{"version":"3.0.4"},{"version":"4.0.0-beta.1"},{"version":"4.0.0-beta.2"},{"version":"4.0.0-beta.3"},{"version":"3.0.5"},{"version":"2.0.12"},{"version":"4.0.0-beta.4"},{"version":"4.0.0-beta.5"},{"version":"3.0.6"},{"version":"3.0.7"},{"version":"2.0.13"},{"version":"4.0.0-beta.6"},{"version":"3.0.8"},{"version":"4.0.0-beta.7"},{"version":"3.0.9"},{"version":"2.0.14"},{"version":"3.0.10"},{"version":"4.0.0-beta.8"},{"version":"3.1.0-beta.1"},{"version":"3.1.0-beta.2"},{"version":"3.0.11"},{"version":"4.0.0-beta.9"},{"version":"2.0.15"},{"version":"3.0.12"},{"version":"3.1.0-beta.3"},{"version":"3.0.13"},{"version":"3.1.0-beta.4"},{"version":"4.0.0-beta.10"},{"version":"2.0.16"},{"version":"4.0.0-beta.11"},{"version":"4.0.0"},{"version":"3.1.0-beta.5"},{"version":"4.0.1"},{"version":"3.0.14"},{"version":"3.1.0"},{"version":"3.1.1"},{"version":"4.0.2"},{"version":"5.0.0-beta.1"},{"version":"3.1.2"},{"version":"4.0.3"},{"version":"2.0.17"},{"version":"3.0.15"},{"version":"3.1.3"},{"version":"4.0.4"},{"version":"5.0.0-beta.2"},{"version":"4.0.5"},{"version":"5.0.0-beta.3"},{"version":"3.1.4"},{"version":"4.0.6"},{"version":"5.0.0-beta.4"},{"version":"3.1.5"},{"version":"4.0.7"},{"version":"5.0.0-beta.5"},{"version":"2.0.18"},{"version":"3.1.6"},{"version":"3.0.16"},{"version":"4.0.8"},{"version":"4.1.0"},{"version":"5.0.0-beta.6"},{"version":"4.1.1"},{"version":"3.1.7"},{"version":"5.0.0-beta.7"}]
|
||||
@@ -1,17 +0,0 @@
|
||||
// The "app" object controls your applications life-cycle. It exposes various
|
||||
// events and methods to control how your app exposes itself to the operating
|
||||
// system.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/app
|
||||
|
||||
const { app } = require('electron')
|
||||
|
||||
app.on('ready', () => console.log('The app is now ready for action'))
|
||||
|
||||
app.on('browser-window-created', () => console.log('A window was created!'))
|
||||
app.on('browser-window-focus', () => console.log('...and focused!'))
|
||||
|
||||
console.log(`The app lives at: ${app.getAppPath()}`)
|
||||
console.log(`It's named: ${app.getName()}`)
|
||||
console.log(`It has the version: ${app.getVersion()}`)
|
||||
@@ -1,50 +0,0 @@
|
||||
// The "autoUpdater" module enables apps to automatically update themselves.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/auto-updater
|
||||
|
||||
const { app, autoUpdater } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
const server = 'https://your-deployment-url.com'
|
||||
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
|
||||
|
||||
// The following code won't work unless the app has been packaged.
|
||||
// You should only use the autoUpdater with packaged and code-signed
|
||||
// versions of your application.
|
||||
try {
|
||||
autoUpdater.setFeedURL(feed)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
// Once you've done that, you can go ahead and ask for updates:
|
||||
// autoUpdater.checkForUpdates()
|
||||
|
||||
autoUpdater.on('checking-for-update', () => {
|
||||
console.log('The autoUpdater is checking for an update')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
console.log('The autoUpdater has found an update!')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
console.log('The autoUpdater has found an update and is now downloading it!')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
console.log('The autoUpdater has not found any updates :(')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-downloaded', (event, notes, name, date) => {
|
||||
console.log('The autoUpdater has downloaded an update!')
|
||||
console.log(`The new release is named ${name} and was released on ${date}`)
|
||||
console.log(`The release notes are: ${notes}`)
|
||||
|
||||
// The update will automatically be installed the next time the
|
||||
// app launches. If you want to, you can force the installation
|
||||
// now:
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
})
|
||||
@@ -1,50 +0,0 @@
|
||||
// The "autoUpdater" module enables apps to automatically update themselves.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/auto-updater
|
||||
|
||||
const { app, autoUpdater } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
const server = 'https://your-deployment-url.com'
|
||||
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
|
||||
|
||||
// The following code won't work unless the app has been packaged.
|
||||
// You should only use the autoUpdater with packaged and code-signed
|
||||
// versions of your application.
|
||||
try {
|
||||
autoUpdater.setFeedURL(feed)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
// Once you've done that, you can go ahead and ask for updates:
|
||||
// autoUpdater.checkForUpdates()
|
||||
|
||||
autoUpdater.on('checking-for-update', () => {
|
||||
console.log('The autoUpdater is checking for an update')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
console.log('The autoUpdater has found an update!')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
console.log('The autoUpdater has found an update and is now downloading it!')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
console.log('The autoUpdater has not found any updates :(')
|
||||
})
|
||||
|
||||
autoUpdater.on('update-downloaded', (event, notes, name, date) => {
|
||||
console.log('The autoUpdater has downloaded an update!')
|
||||
console.log(`The new release is named ${name} and was released on ${date}`)
|
||||
console.log(`The release notes are: ${notes}`)
|
||||
|
||||
// The update will automatically be installed the next time the
|
||||
// app launches. If you want to, you can force the installation
|
||||
// now:
|
||||
autoUpdater.quitAndInstall()
|
||||
})
|
||||
})
|
||||
@@ -1,26 +0,0 @@
|
||||
// A BrowserView can be used to embed additional web content into a BrowserWindow.
|
||||
// It is like a child window, except that it is positioned relative to its owning
|
||||
// window. It is meant to be an alternative to the webview tag.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/browser-view
|
||||
|
||||
// In the main process.
|
||||
const { BrowserView, BrowserWindow, app } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
let win = new BrowserWindow({ width: 800, height: 600 })
|
||||
win.on('closed', () => {
|
||||
win = null
|
||||
})
|
||||
|
||||
let view = new BrowserView({
|
||||
webPreferences: {
|
||||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
|
||||
win.setBrowserView(view)
|
||||
view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
|
||||
view.webContents.loadURL('https://electronjs.org')
|
||||
})
|
||||
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>BrowserWindow</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello from your BrowserWindow!</h1>
|
||||
<button></button>
|
||||
<script>
|
||||
document.querySelector('Close this window').onclick = () => {
|
||||
window.close()
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,53 +0,0 @@
|
||||
// The "BrowserWindow" class is the primary way to create user interfaces
|
||||
// in Electron. A BrowserWindow is, like the name suggests, a window.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/browser-window
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
const windows = []
|
||||
|
||||
app.on('ready', () => {
|
||||
// BrowserWindows can be created in plenty of shapes, sizes, and forms.
|
||||
// Check out the editor's auto-completion for all the configuration
|
||||
// options available in the current version.
|
||||
//
|
||||
// Let's make a few windows!
|
||||
|
||||
// A window that's only half visible
|
||||
windows.push(
|
||||
new BrowserWindow({
|
||||
opacity: 0.5,
|
||||
x: 200,
|
||||
y: 200
|
||||
})
|
||||
)
|
||||
|
||||
// A transparent window
|
||||
windows.push(
|
||||
new BrowserWindow({
|
||||
transparent: true,
|
||||
x: 300,
|
||||
y: 300
|
||||
})
|
||||
)
|
||||
|
||||
// A window that's fixed and always on top
|
||||
windows.push(
|
||||
new BrowserWindow({
|
||||
movable: false,
|
||||
resizable: false,
|
||||
alwaysOnTop: true,
|
||||
maximizable: false,
|
||||
minimizable: false,
|
||||
x: 600,
|
||||
y: 600
|
||||
})
|
||||
)
|
||||
|
||||
windows.forEach((window) => {
|
||||
// Load our index.html
|
||||
window.loadFile('index.html')
|
||||
})
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Clipboard</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Clipboard Demo</h1>
|
||||
<button id="copy">Copy "Hello from Electron!"</button>
|
||||
<button id="paste">Paste into TextArea</button>
|
||||
<br />
|
||||
<textarea></textarea>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,14 +0,0 @@
|
||||
// Perform copy and paste operations on the system clipboard.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/clipboard
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
const { clipboard } = require('electron')
|
||||
|
||||
const copyButton = document.querySelector('#copy')
|
||||
const pasteButton = document.querySelector('#paste')
|
||||
const textarea = document.querySelector('textarea')
|
||||
|
||||
copyButton.onclick = () => {
|
||||
clipboard.writeText('Hello from Electron!')
|
||||
}
|
||||
|
||||
pasteButton.onclick = () => {
|
||||
textarea.value = clipboard.readText()
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// Collect tracing data from Chromium's content module for finding performance
|
||||
// bottlenecks and slow operations.
|
||||
//
|
||||
// This module does not include a web interface so you need to open
|
||||
// chrome://tracing/ in a Chrome browser and load the generated file to view
|
||||
// the result.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/contentTracing
|
||||
|
||||
const { app, contentTracing } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
const options = {
|
||||
categoryFilter: '*',
|
||||
traceOptions: 'record-until-full,enable-sampling'
|
||||
}
|
||||
|
||||
contentTracing.startRecording(options, () => {
|
||||
console.log('Tracing started')
|
||||
|
||||
setTimeout(() => {
|
||||
contentTracing.stopRecording('', (path) => {
|
||||
console.log('Tracing data recorded to ' + path)
|
||||
})
|
||||
}, 5000)
|
||||
})
|
||||
})
|
||||
@@ -1,28 +0,0 @@
|
||||
// Collect tracing data from Chromium's content module for finding performance
|
||||
// bottlenecks and slow operations.
|
||||
//
|
||||
// This module does not include a web interface so you need to open
|
||||
// chrome://tracing/ in a Chrome browser and load the generated file to view
|
||||
// the result.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/contentTracing
|
||||
|
||||
const { app, contentTracing } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
const options = {
|
||||
categoryFilter: '*',
|
||||
traceOptions: 'record-until-full,enable-sampling'
|
||||
}
|
||||
|
||||
contentTracing.startRecording(options, () => {
|
||||
console.log('Tracing started')
|
||||
|
||||
setTimeout(() => {
|
||||
contentTracing.stopRecording('', (path) => {
|
||||
console.log('Tracing data recorded to ' + path)
|
||||
})
|
||||
}, 5000)
|
||||
})
|
||||
})
|
||||
@@ -1,41 +0,0 @@
|
||||
// Query and modify a session's cookies.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/cookies
|
||||
|
||||
const { app, BrowserWindow, session } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({
|
||||
height: 600,
|
||||
width: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
|
||||
// Once the window has finished loading, let's check out
|
||||
// the cookies
|
||||
mainWindow.webContents.on('did-finish-load', () => {
|
||||
// Query all cookies.
|
||||
session.defaultSession.cookies.get({}, (error, cookies) => {
|
||||
console.log(error, cookies)
|
||||
})
|
||||
|
||||
// Query all cookies associated with a specific url.
|
||||
session.defaultSession.cookies.get({ url: 'http://www.github.com' }, (error, cookies) => {
|
||||
console.log(error, cookies)
|
||||
})
|
||||
|
||||
// Set a cookie with the given cookie data;
|
||||
// may overwrite equivalent cookies if they exist.
|
||||
const cookie = { url: 'http://www.github.com', name: 'dummy_name', value: 'dummy' }
|
||||
session.defaultSession.cookies.set(cookie, (error) => {
|
||||
if (error) console.error(error)
|
||||
})
|
||||
})
|
||||
|
||||
mainWindow.loadURL('https://electronjs.org')
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>CrashReporter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CrashReporter Demo</h1>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,17 +0,0 @@
|
||||
// Submit crash reports to a remote server.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/crash-reporter
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.webContents.on('crashed', () => {
|
||||
console.log(`Window crashed!`)
|
||||
})
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
const { crashReporter } = require('electron')
|
||||
|
||||
crashReporter.start({
|
||||
productName: 'YourName',
|
||||
companyName: 'YourCompany',
|
||||
submitURL: 'https://your-domain.com/url-to-submit',
|
||||
uploadToServer: true
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
process.crash()
|
||||
}, 2000)
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>CrashReporter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CrashReporter Demo</h1>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,17 +0,0 @@
|
||||
// Submit crash reports to a remote server.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/crash-reporter
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.webContents.on('crashed', () => {
|
||||
console.log(`Window crashed!`)
|
||||
})
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
const { crashReporter } = require('electron')
|
||||
|
||||
crashReporter.start({
|
||||
productName: 'YourName',
|
||||
companyName: 'YourCompany',
|
||||
submitURL: 'https://your-domain.com/url-to-submit',
|
||||
uploadToServer: true
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
process.crash()
|
||||
}, 2000)
|
||||
@@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,37 +0,0 @@
|
||||
// An alternate transport for Chrome's remote debugging protocol.
|
||||
//
|
||||
// Chrome Developer Tools has a special binding available at JavaScript
|
||||
// runtime that allows interacting with pages and instrumenting them.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/debugger
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
try {
|
||||
mainWindow.webContents.debugger.attach('1.1')
|
||||
} catch (err) {
|
||||
console.log('Debugger attach failed: ', err)
|
||||
}
|
||||
|
||||
mainWindow.webContents.debugger.on('detach', (event, reason) => {
|
||||
console.log('Debugger detached due to: ', reason)
|
||||
})
|
||||
|
||||
mainWindow.webContents.debugger.on('message', (event, method, params) => {
|
||||
if (method === 'Network.requestWillBeSent') {
|
||||
if (params.request.url === 'https://www.github.com') {
|
||||
mainWindow.webContents.debugger.detach()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mainWindow.webContents.debugger.sendCommand('Network.enable')
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<video></video>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
// Access information about media sources that can be used to capture audio
|
||||
// and video from the desktop using the navigator.mediaDevices.getUserMedia API.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/desktop-capturer
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
})
|
||||
@@ -1,37 +0,0 @@
|
||||
const { desktopCapturer } = require('electron')
|
||||
|
||||
// The following example shows how to capture video from
|
||||
// the screen. It also grabs each window, so you could
|
||||
// just grab video from a single window.
|
||||
//
|
||||
desktopCapturer.getSources({
|
||||
types: ['window', 'screen']
|
||||
}, (error, sources) => {
|
||||
if (error) throw error
|
||||
for (let i = 0; i < sources.length; ++i) {
|
||||
console.log(sources[i])
|
||||
|
||||
if (sources[i].id.startsWith('screen')) {
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
audio: false,
|
||||
video: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'desktop',
|
||||
chromeMediaSourceId: sources[i].id,
|
||||
minWidth: 1280,
|
||||
maxWidth: 1280,
|
||||
minHeight: 720,
|
||||
maxHeight: 720
|
||||
}
|
||||
}
|
||||
}).then((stream) => handleStream(stream))
|
||||
.catch((error) => console.log(error))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function handleStream (stream) {
|
||||
const video = document.querySelector('video')
|
||||
video.srcObject = stream
|
||||
video.onloadedmetadata = (e) => video.play()
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<video></video>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
// Access information about media sources that can be used to capture audio
|
||||
// and video from the desktop using the navigator.mediaDevices.getUserMedia API.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/desktop-capturer
|
||||
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
})
|
||||
@@ -1,37 +0,0 @@
|
||||
const { desktopCapturer } = require('electron')
|
||||
|
||||
// The following example shows how to capture video from
|
||||
// the screen. It also grabs each window, so you could
|
||||
// just grab video from a single window.
|
||||
//
|
||||
desktopCapturer.getSources({
|
||||
types: ['window', 'screen']
|
||||
}, (error, sources) => {
|
||||
if (error) throw error
|
||||
for (let i = 0; i < sources.length; ++i) {
|
||||
console.log(sources[i])
|
||||
|
||||
if (sources[i].id.startsWith('screen')) {
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
audio: false,
|
||||
video: {
|
||||
mandatory: {
|
||||
chromeMediaSource: 'desktop',
|
||||
chromeMediaSourceId: sources[i].id,
|
||||
minWidth: 1280,
|
||||
maxWidth: 1280,
|
||||
minHeight: 720,
|
||||
maxHeight: 720
|
||||
}
|
||||
}
|
||||
}).then((stream) => handleStream(stream))
|
||||
.catch((error) => console.log(error))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function handleStream (stream) {
|
||||
const video = document.querySelector('video')
|
||||
video.srcObject = stream
|
||||
video.onloadedmetadata = (e) => video.play()
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// Display native system dialogs for opening and saving files, alerting, etc.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/dialog
|
||||
|
||||
const { app, BrowserWindow, dialog } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
// Show an "Open File" dialog and attempt to open
|
||||
// the chosen file in our window.
|
||||
//
|
||||
// If you provide a callback, the method will be asynchronous,
|
||||
// but in thise case, we'll just use the synchronous variant.
|
||||
const file = dialog.showOpenDialog({
|
||||
title: 'Hello!',
|
||||
properties: ['openFile']
|
||||
})
|
||||
|
||||
mainWindow.loadURL(`file://${file}`)
|
||||
})
|
||||
@@ -1,40 +0,0 @@
|
||||
// The globalShortcut module can register/unregister a global keyboard shortcut
|
||||
// with the operating system so that you can customize the operations for various
|
||||
// shortcuts.
|
||||
//
|
||||
// Note: The shortcut is global; it will work even if the app does not have the
|
||||
// keyboard focus. You should not use this module until the ready event of the
|
||||
// app module is emitted. In this example, we're using "Accelerators":
|
||||
// Accelerators are Strings that can contain multiple modifiers and key codes,
|
||||
// combined by the + character, and are used to define keyboard shortcuts
|
||||
// throughout your application.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/accelerator
|
||||
// https://electronjs.org/docs/api/global-shortcut
|
||||
|
||||
const { app, globalShortcut } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
// Register a 'CommandOrControl+Y' shortcut listener.
|
||||
//
|
||||
// On Linux and Windows, the Command key does not have any effect, so use
|
||||
// CommandOrControl which represents Command on macOS and Control on
|
||||
// Linux and Windows to define some accelerators.
|
||||
globalShortcut.register('CommandOrControl+Y', () => {
|
||||
console.log(`The global shortkey was pressed!`)
|
||||
})
|
||||
|
||||
// It supports "special names". Check out the API documentation for a full
|
||||
// list.
|
||||
globalShortcut.register('VolumeUp', () => console.log(`Turn it up!`))
|
||||
globalShortcut.register('VolumeDown', () => console.log(`Turn it down!`))
|
||||
})
|
||||
|
||||
app.on('will-quit', () => {
|
||||
// Unregister a shortcut.
|
||||
globalShortcut.unregister('CommandOrControl+Y')
|
||||
|
||||
// Unregister all shortcuts.
|
||||
globalShortcut.unregisterAll()
|
||||
})
|
||||
@@ -1,40 +0,0 @@
|
||||
// The globalShortcut module can register/unregister a global keyboard shortcut
|
||||
// with the operating system so that you can customize the operations for various
|
||||
// shortcuts.
|
||||
//
|
||||
// Note: The shortcut is global; it will work even if the app does not have the
|
||||
// keyboard focus. You should not use this module until the ready event of the
|
||||
// app module is emitted. In this example, we're using "Accelerators":
|
||||
// Accelerators are Strings that can contain multiple modifiers and key codes,
|
||||
// combined by the + character, and are used to define keyboard shortcuts
|
||||
// throughout your application.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/accelerator
|
||||
// https://electronjs.org/docs/api/global-shortcut
|
||||
|
||||
const { app, globalShortcut } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
// Register a 'CommandOrControl+Y' shortcut listener.
|
||||
//
|
||||
// On Linux and Windows, the Command key does not have any effect, so use
|
||||
// CommandOrControl which represents Command on macOS and Control on
|
||||
// Linux and Windows to define some accelerators.
|
||||
globalShortcut.register('CommandOrControl+Y', () => {
|
||||
console.log(`The global shortkey was pressed!`)
|
||||
})
|
||||
|
||||
// It supports "special names". Check out the API documentation for a full
|
||||
// list.
|
||||
globalShortcut.register('VolumeUp', () => console.log(`Turn it up!`))
|
||||
globalShortcut.register('VolumeDown', () => console.log(`Turn it down!`))
|
||||
})
|
||||
|
||||
app.on('will-quit', () => {
|
||||
// Unregister a shortcut.
|
||||
globalShortcut.unregister('CommandOrControl+Y')
|
||||
|
||||
// Unregister all shortcuts.
|
||||
globalShortcut.unregisterAll()
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
// The inAppPurchase module enables in-app purchases in the Mac App Store.
|
||||
//
|
||||
// This example will not work when run with Electron Fiddle, since the
|
||||
// needs to be packaged for and published in the Mac App Store.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/in-app-purchase
|
||||
|
||||
const { app, inAppPurchase } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
// Can the user can make a payment?
|
||||
if (inAppPurchase.canMakePayments()) {
|
||||
const productID = 'myProductId'
|
||||
const quantity = 1
|
||||
|
||||
// Let's go shopping!
|
||||
inAppPurchase.purchaseProduct(productID, quantity)
|
||||
}
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
// The inAppPurchase module enables in-app purchases in the Mac App Store.
|
||||
//
|
||||
// This example will not work when run with Electron Fiddle, since the
|
||||
// needs to be packaged for and published in the Mac App Store.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/in-app-purchase
|
||||
|
||||
const { app, inAppPurchase } = require('electron')
|
||||
|
||||
app.on('ready', () => {
|
||||
// Can the user can make a payment?
|
||||
if (inAppPurchase.canMakePayments()) {
|
||||
const productID = 'myProductId'
|
||||
const quantity = 1
|
||||
|
||||
// Let's go shopping!
|
||||
inAppPurchase.purchaseProduct(productID, quantity)
|
||||
}
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>IPC Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>IPC Example</h1>
|
||||
<p>Open the developer tools to see the IPC in action.</p>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,26 +0,0 @@
|
||||
// The ipcMain and ipcRenderer modules allow communication between the mai
|
||||
// process and the renderer processes.
|
||||
//
|
||||
// For more info, see:
|
||||
// https://electronjs.org/docs/api/ipc-main
|
||||
// https://electronjs.org/docs/api/ipc-renderer
|
||||
|
||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = new BrowserWindow({ height: 600, width: 600 })
|
||||
|
||||
ipcMain.on('asynchronous-message', (event, arg) => {
|
||||
console.log(arg) // prints "ping"
|
||||
event.sender.send('asynchronous-reply', 'pong')
|
||||
})
|
||||
|
||||
ipcMain.on('synchronous-message', (event, arg) => {
|
||||
console.log(arg) // prints "ping"
|
||||
event.returnValue = 'pong'
|
||||
})
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
})
|
||||
@@ -1,9 +0,0 @@
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
// prints "pong"
|
||||
console.log(ipcRenderer.sendSync('synchronous-message', 'ping'))
|
||||
|
||||
// prints "pong"
|
||||
ipcRenderer.on('asynchronous-reply', (...args) => console.log(args))
|
||||
|
||||
ipcRenderer.send('asynchronous-message', 'ping')
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user