mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Upgrade IDE to Electron v8.2.1 (#1589)
This commit is contained in:
@@ -219,11 +219,11 @@ const selectBaseFolderPath = headerObject => {
|
||||
if (!state.projectBasePath) {
|
||||
state.projectBasePath = state.folderPath;
|
||||
}
|
||||
const selectedDir = dialog.showOpenDialog(remote.getCurrentWindow(), {
|
||||
const selectedDir = dialog.showOpenDialogSync(remote.getCurrentWindow(), {
|
||||
properties: ['openDirectory'],
|
||||
defaultPath: state.projectBasePath,
|
||||
});
|
||||
if (!selectedDir) {
|
||||
if (!selectedDir || !selectedDir.length) {
|
||||
return;
|
||||
}
|
||||
const selectedDirPath = selectedDir[0];
|
||||
|
@@ -87,7 +87,7 @@ export default class DebuggerContent extends React.Component<Props, State> {
|
||||
toolbarControls: [],
|
||||
renderEditor: () => (
|
||||
<Background>
|
||||
<Column expand noMargin>
|
||||
<Column expand noMargin useMaxHeight>
|
||||
<Line justifyContent="center">
|
||||
<RaisedButton
|
||||
label={<Trans>Refresh</Trans>}
|
||||
@@ -95,21 +95,19 @@ export default class DebuggerContent extends React.Component<Props, State> {
|
||||
primary
|
||||
/>
|
||||
</Line>
|
||||
<Line expand noMargin>
|
||||
<InspectorsList
|
||||
gameData={gameData}
|
||||
getInspectorDescriptions={getInspectorDescriptions}
|
||||
onChooseInspector={(
|
||||
<InspectorsList
|
||||
gameData={gameData}
|
||||
getInspectorDescriptions={getInspectorDescriptions}
|
||||
onChooseInspector={(
|
||||
selectedInspector,
|
||||
selectedInspectorFullPath
|
||||
) =>
|
||||
this.setState({
|
||||
selectedInspector,
|
||||
selectedInspectorFullPath
|
||||
) =>
|
||||
this.setState({
|
||||
selectedInspector,
|
||||
selectedInspectorFullPath,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Line>
|
||||
selectedInspectorFullPath,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Column>
|
||||
</Background>
|
||||
),
|
||||
|
@@ -23,30 +23,25 @@ const readJSONFile = (filepath: string): Promise<Object> => {
|
||||
|
||||
export default class LocalEventsFunctionsExtensionOpener {
|
||||
static chooseEventsFunctionExtensionFile = (): Promise<?string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!dialog) return reject('Not supported');
|
||||
if (!dialog) return Promise.reject('Not supported');
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
dialog.showOpenDialog(
|
||||
browserWindow,
|
||||
{
|
||||
title: 'Import an extension in the project',
|
||||
properties: ['openFile'],
|
||||
message: 'Choose an extension file to import (.json file)',
|
||||
filters: [
|
||||
{
|
||||
name: 'GDevelop 5 "events based" extension',
|
||||
extensions: ['json'],
|
||||
},
|
||||
],
|
||||
},
|
||||
paths => {
|
||||
if (!paths || !paths.length) return resolve(null);
|
||||
|
||||
return resolve(paths[0]);
|
||||
}
|
||||
);
|
||||
});
|
||||
return dialog
|
||||
.showOpenDialog(browserWindow, {
|
||||
title: 'Import an extension in the project',
|
||||
properties: ['openFile'],
|
||||
message: 'Choose an extension file to import (.json file)',
|
||||
filters: [
|
||||
{
|
||||
name: 'GDevelop 5 "events based" extension',
|
||||
extensions: ['json'],
|
||||
},
|
||||
],
|
||||
})
|
||||
.then(({ filePaths }) => {
|
||||
if (!filePaths || !filePaths.length) return null;
|
||||
return filePaths[0];
|
||||
});
|
||||
};
|
||||
|
||||
static readEventsFunctionExtensionFile = (
|
||||
|
@@ -30,29 +30,24 @@ const writeJSONFile = (object: Object, filepath: string): Promise<void> => {
|
||||
|
||||
export default class LocalEventsFunctionsExtensionWriter {
|
||||
static chooseEventsFunctionExtensionFile = (): Promise<?string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!dialog) return reject('Not supported');
|
||||
if (!dialog) return Promise.reject('Not supported');
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
dialog.showSaveDialog(
|
||||
browserWindow,
|
||||
{
|
||||
title: 'Export an extension of the project',
|
||||
filters: [
|
||||
{
|
||||
name: 'GDevelop 5 "events based" extension',
|
||||
extensions: ['json'],
|
||||
},
|
||||
],
|
||||
defaultPath: 'Extension.json',
|
||||
},
|
||||
path => {
|
||||
if (!path) return resolve(null);
|
||||
|
||||
return resolve(path);
|
||||
}
|
||||
);
|
||||
});
|
||||
return dialog
|
||||
.showSaveDialog(browserWindow, {
|
||||
title: 'Export an extension of the project',
|
||||
filters: [
|
||||
{
|
||||
name: 'GDevelop 5 "events based" extension',
|
||||
extensions: ['json'],
|
||||
},
|
||||
],
|
||||
defaultPath: 'Extension.json',
|
||||
})
|
||||
.then(({ filePath }) => {
|
||||
if (!filePath) return null;
|
||||
return filePath;
|
||||
});
|
||||
};
|
||||
|
||||
static writeEventsFunctionsExtension = (
|
||||
|
@@ -25,26 +25,21 @@ const readJSONFile = (filepath: string): Promise<Object> => {
|
||||
};
|
||||
|
||||
export const onOpenWithPicker = (): Promise<?FileMetadata> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!dialog) return reject('Not supported');
|
||||
if (!dialog) return Promise.reject('Not supported');
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
dialog.showOpenDialog(
|
||||
browserWindow,
|
||||
{
|
||||
title: 'Open a project',
|
||||
properties: ['openFile'],
|
||||
message:
|
||||
'If you want to open your GDevelop 4 project, be sure to save it as a .json file',
|
||||
filters: [{ name: 'GDevelop 5 project', extensions: ['json'] }],
|
||||
},
|
||||
paths => {
|
||||
if (!paths || !paths.length) return resolve(null);
|
||||
|
||||
return resolve({ fileIdentifier: paths[0] });
|
||||
}
|
||||
);
|
||||
});
|
||||
return dialog
|
||||
.showOpenDialog(browserWindow, {
|
||||
title: 'Open a project',
|
||||
properties: ['openFile'],
|
||||
message:
|
||||
'If you want to open your GDevelop 4 project, be sure to save it as a .json file',
|
||||
filters: [{ name: 'GDevelop 5 project', extensions: ['json'] }],
|
||||
})
|
||||
.then(({ filePaths }) => {
|
||||
if (!filePaths || !filePaths.length) return null;
|
||||
return { fileIdentifier: filePaths[0] };
|
||||
});
|
||||
};
|
||||
|
||||
export const onOpen = (
|
||||
|
@@ -124,7 +124,7 @@ export const onSaveProjectAs = (
|
||||
if (!dialog) {
|
||||
return Promise.reject('Unsupported');
|
||||
}
|
||||
const filePath = dialog.showSaveDialog(browserWindow, options);
|
||||
const filePath = dialog.showSaveDialogSync(browserWindow, options);
|
||||
if (!filePath) {
|
||||
return Promise.resolve({ wasSaved: false, fileMetadata });
|
||||
}
|
||||
|
@@ -235,49 +235,46 @@ const selectLocalResourcePath = (
|
||||
) => void,
|
||||
kind: ResourceKind
|
||||
): Promise<Array<string>> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!dialog) return reject('Not supported');
|
||||
if (!dialog) return Promise.reject('Not supported');
|
||||
|
||||
const properties = ['openFile'];
|
||||
if (options.multiSelections) properties.push('multiSelections');
|
||||
const projectPath = path.dirname(project.getProjectFile());
|
||||
const properties = ['openFile'];
|
||||
if (options.multiSelections) properties.push('multiSelections');
|
||||
const projectPath = path.dirname(project.getProjectFile());
|
||||
|
||||
const latestPath = getLastUsedPath(project, kind) || projectPath;
|
||||
const latestPath = getLastUsedPath(project, kind) || projectPath;
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
dialog.showOpenDialog(
|
||||
browserWindow,
|
||||
{
|
||||
title: options.title,
|
||||
properties,
|
||||
filters: [{ name: options.name, extensions: options.extensions }],
|
||||
defaultPath: latestPath,
|
||||
},
|
||||
paths => {
|
||||
if (!paths) return resolve([]);
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
|
||||
const lastUsedPath = path.parse(paths[0]).dir;
|
||||
setLastUsedPath(project, kind, lastUsedPath);
|
||||
return dialog
|
||||
.showOpenDialog(browserWindow, {
|
||||
title: options.title,
|
||||
properties,
|
||||
filters: [{ name: options.name, extensions: options.extensions }],
|
||||
defaultPath: latestPath,
|
||||
})
|
||||
.then(({ filePaths }) => {
|
||||
if (!filePaths || !filePaths.length) return [];
|
||||
|
||||
const outsideProjectFolderPaths = paths.filter(
|
||||
path => !isPathInProjectFolder(project, path)
|
||||
const lastUsedPath = path.parse(filePaths[0]).dir;
|
||||
setLastUsedPath(project, kind, lastUsedPath);
|
||||
|
||||
const outsideProjectFolderPaths = filePaths.filter(
|
||||
path => !isPathInProjectFolder(project, path)
|
||||
);
|
||||
|
||||
if (outsideProjectFolderPaths.length) {
|
||||
// eslint-disable-next-line
|
||||
const answer = confirm(
|
||||
i18n._(
|
||||
t`This/these file(s) are outside the project folder. Would you like to make a copy of them in your project folder first (recommended)?`
|
||||
)
|
||||
);
|
||||
|
||||
if (outsideProjectFolderPaths.length) {
|
||||
// eslint-disable-next-line
|
||||
const answer = confirm(
|
||||
i18n._(
|
||||
t`This/these file(s) are outside the project folder. Would you like to make a copy of them in your project folder first (recommended)?`
|
||||
)
|
||||
);
|
||||
|
||||
if (answer) {
|
||||
return resolve(copyAllToProjectFolder(project, paths));
|
||||
}
|
||||
if (answer) {
|
||||
return copyAllToProjectFolder(project, filePaths);
|
||||
}
|
||||
|
||||
return resolve(paths);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return filePaths;
|
||||
});
|
||||
};
|
||||
|
@@ -41,18 +41,16 @@ export default class LocalFilePicker extends PureComponent<Props, *> {
|
||||
if (!dialog || !electron) return;
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
dialog.showSaveDialog(
|
||||
browserWindow,
|
||||
{
|
||||
return dialog
|
||||
.showSaveDialog(browserWindow, {
|
||||
title: this.props.title,
|
||||
filters: this.props.filters,
|
||||
message: this.props.message,
|
||||
defaultPath: this.props.defaultPath,
|
||||
},
|
||||
filename => {
|
||||
this.props.onChange(filename || '');
|
||||
}
|
||||
);
|
||||
})
|
||||
.then(({ filePath }) => {
|
||||
this.props.onChange(filePath || '');
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@@ -43,20 +43,17 @@ export default class LocalFolderPicker extends PureComponent<Props, {||}> {
|
||||
if (!dialog || !electron) return;
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
dialog.showOpenDialog(
|
||||
browserWindow,
|
||||
{
|
||||
dialog
|
||||
.showOpenDialog(browserWindow, {
|
||||
title,
|
||||
properties: ['openDirectory', 'createDirectory'],
|
||||
message,
|
||||
defaultPath: this.props.defaultPath,
|
||||
},
|
||||
paths => {
|
||||
if (!paths || !paths.length) return;
|
||||
|
||||
this.props.onChange(paths[0]);
|
||||
}
|
||||
);
|
||||
})
|
||||
.then(({ filePaths }) => {
|
||||
if (!filePaths || !filePaths.length) return;
|
||||
this.props.onChange(filePaths[0]);
|
||||
});
|
||||
};
|
||||
|
||||
_getTitleAndMessage = (i18n: I18nType): TitleAndMessage => {
|
||||
|
@@ -161,7 +161,7 @@ export default class Window {
|
||||
}
|
||||
|
||||
const browserWindow = electron.remote.getCurrentWindow();
|
||||
dialog.showMessageBox(browserWindow, {
|
||||
dialog.showMessageBoxSync(browserWindow, {
|
||||
message,
|
||||
type,
|
||||
buttons: ['OK'],
|
||||
|
@@ -38,6 +38,7 @@ const loadModalWindow = ({
|
||||
center: true,
|
||||
webPreferences: {
|
||||
webSecurity: false,
|
||||
nodeIntegration: true,
|
||||
},
|
||||
};
|
||||
|
||||
|
@@ -26,43 +26,30 @@ const load = ({ isDev, devTools, path, window }) => {
|
||||
*/
|
||||
const registerGdideProtocol = ({ isDev }) => {
|
||||
if (isDev) {
|
||||
protocol.registerHttpProtocol(
|
||||
'gdide',
|
||||
(request, callback) => {
|
||||
callback({
|
||||
method: request.method,
|
||||
referrer: request.referrer,
|
||||
url: request.url.replace('gdide://', developmentServerBaseUrl + '/'),
|
||||
});
|
||||
},
|
||||
error => {
|
||||
if (error) {
|
||||
console.error('Error while registering gdide protocol:', error);
|
||||
}
|
||||
}
|
||||
);
|
||||
protocol.registerHttpProtocol('gdide', (request, callback) => {
|
||||
callback({
|
||||
method: request.method,
|
||||
referrer: request.referrer,
|
||||
url: request.url.replace('gdide://', developmentServerBaseUrl + '/'),
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Production (with npm run build)
|
||||
protocol.registerBufferProtocol(
|
||||
'gdide',
|
||||
(request, callback) => {
|
||||
fs.readFile(
|
||||
request.url.replace('gdide://', appPublicFolderBaseUrl + '/'),
|
||||
(error, buffer) => {
|
||||
if (error) {
|
||||
console.error('While while loading ' + request.url, error);
|
||||
}
|
||||
callback({ mimeType: 'text/javascript', data: buffer });
|
||||
protocol.registerBufferProtocol('gdide', (request, callback) => {
|
||||
fs.readFile(
|
||||
request.url.replace('gdide://', appPublicFolderBaseUrl + '/'),
|
||||
(error, buffer) => {
|
||||
if (error) {
|
||||
console.error('While while loading ' + request.url, error);
|
||||
}
|
||||
);
|
||||
},
|
||||
error => {
|
||||
if (error) {
|
||||
console.error('Error while registering gdide protocol:', error);
|
||||
callback({ mimeType: 'text/javascript', data: buffer });
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const isRegistered = protocol.isProtocolRegistered('gdide');
|
||||
if (!isRegistered) console.error('Error while registering gdide protocol.');
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@@ -45,7 +45,10 @@ const args = parseArgs(process.argv.slice(isDev ? 2 : 1), {
|
||||
});
|
||||
|
||||
// See registerGdideProtocol (used for HTML modules support)
|
||||
protocol.registerStandardSchemes(['gdide']);
|
||||
protocol.registerSchemesAsPrivileged([{ scheme: 'gdide' }]);
|
||||
|
||||
// Set to true, will be default value in future Electron versions
|
||||
app.allowRendererProcessReuse = true;
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function() {
|
||||
@@ -71,7 +74,8 @@ app.on('ready', function() {
|
||||
x: args.x,
|
||||
y: args.y,
|
||||
webPreferences: {
|
||||
webSecurity: false, // Allow to access to local files
|
||||
webSecurity: false, // Allow to access to local files,
|
||||
nodeIntegration: true,
|
||||
},
|
||||
enableLargerThanScreen: true,
|
||||
backgroundColor: '#f0f0f0',
|
||||
|
6
newIDE/electron-app/app/package-lock.json
generated
6
newIDE/electron-app/app/package-lock.json
generated
@@ -491,9 +491,9 @@
|
||||
"integrity": "sha1-ihBD4ys6HaHD9VPc4oznZCRhZ+M="
|
||||
},
|
||||
"electron-log": {
|
||||
"version": "2.2.14",
|
||||
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-2.2.14.tgz",
|
||||
"integrity": "sha512-Rj+XyK4nShe/nv9v1Uks4KEfjtQ6N+eSnx5CLpAjG6rlyUdAflyFHoybcHSLoq9l9pGavclULWS5IXgk8umc2g=="
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/electron-log/-/electron-log-4.1.1.tgz",
|
||||
"integrity": "sha512-vkK3rNBOciRiinxrsdgg8hyUia+ct8ZMjBblvKjgNk4uHEDjjSyn313NOwv75xOMVIKlfmYzxaN8kR/oGC33aQ=="
|
||||
},
|
||||
"electron-updater": {
|
||||
"version": "4.2.0",
|
||||
|
@@ -14,7 +14,7 @@
|
||||
"dotenv": "^4.0.0",
|
||||
"electron-editor-context-menu": "^1.1.1",
|
||||
"electron-is": "^2.4.0",
|
||||
"electron-log": "^2.2.14",
|
||||
"electron-log": "^4.1.1",
|
||||
"electron-updater": "4.2.0",
|
||||
"fs-extra": "^3.0.1",
|
||||
"jimp": "^0.2.28",
|
||||
|
1266
newIDE/electron-app/package-lock.json
generated
1266
newIDE/electron-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -46,7 +46,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "^8.2.0",
|
||||
"electron": "3.0.9",
|
||||
"electron": "8.2.1",
|
||||
"electron-builder": "20.44.4",
|
||||
"electron-notarize": "^0.2.1",
|
||||
"minimist": "^1.2.3",
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user