@lynker-desktop/electron-window-manager 0.0.9-alpha.42 → 0.0.9-alpha.44

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.
@@ -60,10 +60,6 @@ export declare class WindowsManager {
60
60
  type: 'BV';
61
61
  }): Promise<BVItem>;
62
62
  create(options: ElectronWindowsManagerOptions): Promise<BVItem | BWItem>;
63
- /**
64
- * 处理创建队列
65
- */
66
- private processCreateQueue;
67
63
  /**
68
64
  * 实际的窗口创建逻辑
69
65
  */
@@ -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;AAEzG,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,gCAAgC,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEvD,8BAA8B,EAAE,MAAM,GAAG,IAAI,CAAQ;IAErD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAClC,UAAU,EAAE,OAAO,CAAS;IAC5B,sBAAsB,EAAE,MAAM,EAAE,CAAM;IAEtC,OAAO,CAAC,WAAW,CAIX;IACR,OAAO,CAAC,UAAU,CAAkB;IACpC;;;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I,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IACvC,MAAM,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 () => {
@@ -200,6 +210,7 @@ class WindowsManager {
200
210
  ...options,
201
211
  webPreferences: {
202
212
  ...webPreferences,
213
+ sandbox: false,
203
214
  webviewTag: true,
204
215
  plugins: true,
205
216
  nodeIntegration: this.preloadWebContentsConfig?.nodeIntegration ?? true,
@@ -253,6 +264,7 @@ class WindowsManager {
253
264
  const instance = new BrowserView({
254
265
  webPreferences: {
255
266
  ...webPreferences,
267
+ sandbox: false,
256
268
  webviewTag: true,
257
269
  plugins: true,
258
270
  nodeIntegration: this.preloadWebContentsConfig?.nodeIntegration ?? true,
@@ -295,36 +307,13 @@ class WindowsManager {
295
307
  }
296
308
  });
297
309
  }
298
- create(options) {
299
- return new Promise((resolve, reject) => {
300
- // 将创建请求添加到队列
301
- this.createQueue.push({ options, resolve, reject });
302
- // 如果当前没有在创建,则开始处理队列
303
- if (!this.isCreating) {
304
- this.processCreateQueue();
305
- }
310
+ async create(options) {
311
+ const queue = await getQueue();
312
+ const win = await queue.add(async () => {
313
+ const window = await this._createWindow(options);
314
+ return window;
306
315
  });
307
- }
308
- /**
309
- * 处理创建队列
310
- */
311
- async processCreateQueue() {
312
- if (this.isCreating || this.createQueue.length === 0) {
313
- return;
314
- }
315
- this.isCreating = true;
316
- while (this.createQueue.length > 0) {
317
- const { options, resolve, reject } = this.createQueue.shift();
318
- try {
319
- const window = await this._createWindow(options);
320
- resolve(window);
321
- }
322
- catch (error) {
323
- log('error', 'create window failed:', error);
324
- reject(error);
325
- }
326
- }
327
- this.isCreating = false;
316
+ return win;
328
317
  }
329
318
  /**
330
319
  * 实际的窗口创建逻辑
@@ -502,6 +491,7 @@ class WindowsManager {
502
491
  window = type === 'BV' ?
503
492
  new BrowserView(lodash.merge((browserWindowOptions || {}), {
504
493
  webPreferences: lodash.merge({
494
+ sandbox: false,
505
495
  webviewTag: true,
506
496
  // session: getCustomSession(),
507
497
  plugins: true,
@@ -520,6 +510,7 @@ class WindowsManager {
520
510
  }, (browserWindowOptions || {}), {
521
511
  parent: parentWin,
522
512
  webPreferences: lodash.merge({
513
+ sandbox: false,
523
514
  webviewTag: true,
524
515
  // session: getCustomSession(),
525
516
  plugins: true,
@@ -823,6 +814,7 @@ class WindowsManager {
823
814
  const { loadingView, preventOriginNavigate = false, } = createOptions;
824
815
  let _loadingView = new BrowserView({
825
816
  webPreferences: {
817
+ sandbox: false,
826
818
  // session: getCustomSession(),
827
819
  contextIsolation: false,
828
820
  nodeIntegration: true,