@lynker-desktop/electron-window-manager 0.0.9-alpha.43 → 0.0.9-alpha.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/main/index.d.ts +0 -4
- package/esm/main/index.d.ts.map +1 -1
- package/esm/main/index.js +21 -30
- package/esm/main/index.js.map +1 -1
- package/main/index.d.ts +0 -4
- package/main/index.d.ts.map +1 -1
- package/main/index.js +21 -30
- package/main/index.js.map +1 -1
- package/package.json +4 -3
package/esm/main/index.d.ts
CHANGED
package/esm/main/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,WAAW,EAAiG,MAAM,UAAU,CAAA;AAItK,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,WAAW,EAAiG,MAAM,UAAU,CAAA;AAItK,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAczG,eAAO,MAAM,gBAAgB,wBAQzB,CAAC;AAUL,eAAO,MAAM,MAAM,QAAS,WAAW,SAEtC,CAAA;AAoBD,qBAAa,cAAc;IACzB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAEtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAElC,gC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AAM,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IACvC,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAyBtC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAqC/B,QAAQ;IA0BR,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM;IAqCjD,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS;IAgB9E,UAAU;IAKV,OAAO,CAAC,0BAA0B;IAqGlC,OAAO,CAAC,wBAAwB;IA+B1B,wBAAwB,CAAC,GAAG,EAAE,MAAM;IAsBpC,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAwB1E;;;OAGG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAOjD;;;OAGG;IACH,OAAO,CAAC,yBAAyB,CAE1B;IAEP;;;OAGG;IACH,OAAO,CAAC,iBAAiB;CA6D1B;AAID,eAAO,IAAI,aAAa,SAAQ,CAAC;AAEjC,eAAO,MAAM,UAAU,aAAc,MAAM,mBAAmB,MAAM,iBAAiB,MAAM,6BAA6B,wBAAwB,2BAA2B,MAAM,EAAE,KAAG,cAqRrL,CAAA"}
|
package/esm/main/index.js
CHANGED
|
@@ -4,6 +4,16 @@ import * as remote from '@electron/remote/main';
|
|
|
4
4
|
import eIpc from '@lynker-desktop/electron-ipc/main';
|
|
5
5
|
import md5 from 'md5';
|
|
6
6
|
|
|
7
|
+
const getQueue = (() => {
|
|
8
|
+
let queue;
|
|
9
|
+
return async () => {
|
|
10
|
+
if (!queue) {
|
|
11
|
+
const { default: PQueue } = await import('p-queue');
|
|
12
|
+
queue = new PQueue({ concurrency: 1 });
|
|
13
|
+
}
|
|
14
|
+
return queue;
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
7
17
|
const getCustomSession = (() => {
|
|
8
18
|
let customSession;
|
|
9
19
|
return () => {
|
|
@@ -91,6 +101,7 @@ class WindowsManager {
|
|
|
91
101
|
if (this.preloadWebContentsConfig.contextIsolation === undefined) {
|
|
92
102
|
this.preloadWebContentsConfig.contextIsolation = false;
|
|
93
103
|
}
|
|
104
|
+
getQueue();
|
|
94
105
|
app.whenReady().then(() => {
|
|
95
106
|
if (this.preloadWebContentsConfig) {
|
|
96
107
|
this.setPreloadWebContentsConfig(this.preloadWebContentsConfig);
|
|
@@ -106,7 +117,9 @@ class WindowsManager {
|
|
|
106
117
|
try {
|
|
107
118
|
this.preloadWebContentsConfig = preloadWebContentsConfig;
|
|
108
119
|
if (this.preloadWebContentsConfig) {
|
|
109
|
-
|
|
120
|
+
getQueue().then(q => q.add(async () => {
|
|
121
|
+
return await this._preloadInstances();
|
|
122
|
+
}));
|
|
110
123
|
}
|
|
111
124
|
else {
|
|
112
125
|
this.preloadedBW = null;
|
|
@@ -176,6 +189,7 @@ class WindowsManager {
|
|
|
176
189
|
}
|
|
177
190
|
}
|
|
178
191
|
}
|
|
192
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
179
193
|
}
|
|
180
194
|
catch (e) {
|
|
181
195
|
log('error', '预创建实例失败', e);
|
|
@@ -297,36 +311,13 @@ class WindowsManager {
|
|
|
297
311
|
}
|
|
298
312
|
});
|
|
299
313
|
}
|
|
300
|
-
create(options) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this.
|
|
304
|
-
|
|
305
|
-
if (!this.isCreating) {
|
|
306
|
-
this.processCreateQueue();
|
|
307
|
-
}
|
|
314
|
+
async create(options) {
|
|
315
|
+
const queue = await getQueue();
|
|
316
|
+
const win = await queue.add(async () => {
|
|
317
|
+
const window = await this._createWindow(options);
|
|
318
|
+
return window;
|
|
308
319
|
});
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* 处理创建队列
|
|
312
|
-
*/
|
|
313
|
-
async processCreateQueue() {
|
|
314
|
-
if (this.isCreating || this.createQueue.length === 0) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
this.isCreating = true;
|
|
318
|
-
while (this.createQueue.length > 0) {
|
|
319
|
-
const { options, resolve, reject } = this.createQueue.shift();
|
|
320
|
-
try {
|
|
321
|
-
const window = await this._createWindow(options);
|
|
322
|
-
resolve(window);
|
|
323
|
-
}
|
|
324
|
-
catch (error) {
|
|
325
|
-
log('error', 'create window failed:', error);
|
|
326
|
-
reject(error);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
this.isCreating = false;
|
|
320
|
+
return win;
|
|
330
321
|
}
|
|
331
322
|
/**
|
|
332
323
|
* 实际的窗口创建逻辑
|