mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: Add data parameter to app.requestSingleInstanceLock() (#30891)
* WIP * Use serialization * Rebase windows impl of new app requestSingleInstanceLock parameter * Fix test * Implement posix side * Add backwards compatibility test * Apply PR feedback Windows * Fix posix impl * Switch mac impl back to vector * Refactor Windows impl * Use vectors, inline make_span * Use blink converter * fix: ownership across sequences * Fix upstream merge from Chromium Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
26
spec/fixtures/api/singleton-data/main.js
vendored
Normal file
26
spec/fixtures/api/singleton-data/main.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
const { app } = require('electron');
|
||||
|
||||
app.whenReady().then(() => {
|
||||
console.log('started'); // ping parent
|
||||
});
|
||||
|
||||
const obj = {
|
||||
level: 1,
|
||||
testkey: 'testvalue1',
|
||||
inner: {
|
||||
level: 2,
|
||||
testkey: 'testvalue2'
|
||||
}
|
||||
};
|
||||
const gotTheLock = app.requestSingleInstanceLock(obj);
|
||||
|
||||
app.on('second-instance', (event, args, workingDirectory, data) => {
|
||||
setImmediate(() => {
|
||||
console.log([JSON.stringify(args), JSON.stringify(data)].join('||'));
|
||||
app.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.exit(1);
|
||||
}
|
||||
5
spec/fixtures/api/singleton-data/package.json
vendored
Normal file
5
spec/fixtures/api/singleton-data/package.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "electron-app-singleton-data",
|
||||
"main": "main.js"
|
||||
}
|
||||
|
||||
4
spec/fixtures/api/singleton/main.js
vendored
4
spec/fixtures/api/singleton/main.js
vendored
@@ -6,9 +6,9 @@ app.whenReady().then(() => {
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
|
||||
app.on('second-instance', (event, args) => {
|
||||
app.on('second-instance', (event, args, workingDirectory, data) => {
|
||||
setImmediate(() => {
|
||||
console.log(JSON.stringify(args));
|
||||
console.log([JSON.stringify(args), JSON.stringify(data)].join('||'));
|
||||
app.exit(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user