@lvce-editor/renderer-process 10.32.0 → 10.34.0

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.
@@ -271,7 +271,7 @@ let VError$1 = class VError extends Error {
271
271
  }
272
272
  };
273
273
 
274
- const state$b = {
274
+ const state$a = {
275
275
  commands: Object.create(null),
276
276
  pendingModules: Object.create(null),
277
277
  async load(moduleId) {}
@@ -292,7 +292,7 @@ const initializeModule = module => {
292
292
  };
293
293
  const loadModule$1 = async moduleId => {
294
294
  try {
295
- const module = await state$b.load(moduleId);
295
+ const module = await state$a.load(moduleId);
296
296
  initializeModule(module);
297
297
  } catch (error) {
298
298
  if (error && error instanceof SyntaxError && error.stack === `SyntaxError: ${error.message}`) {
@@ -303,16 +303,16 @@ const loadModule$1 = async moduleId => {
303
303
  }
304
304
  };
305
305
  const getOrLoadModule = moduleId => {
306
- if (!state$b.pendingModules[moduleId]) {
307
- state$b.pendingModules[moduleId] = loadModule$1(moduleId);
306
+ if (!state$a.pendingModules[moduleId]) {
307
+ state$a.pendingModules[moduleId] = loadModule$1(moduleId);
308
308
  }
309
- return state$b.pendingModules[moduleId];
309
+ return state$a.pendingModules[moduleId];
310
310
  };
311
311
  const loadCommand = async command => {
312
312
  await getOrLoadModule(getModuleId(command));
313
313
  };
314
314
  const register = (commandId, listener) => {
315
- state$b.commands[commandId] = listener;
315
+ state$a.commands[commandId] = listener;
316
316
  };
317
317
  const hasThrown = new Set();
318
318
  const executeCommandAsync = async (command, ...args) => {
@@ -321,7 +321,7 @@ const executeCommandAsync = async (command, ...args) => {
321
321
  } catch (error) {
322
322
  throw new VError$1(error, `Failed to load command ${command}`);
323
323
  }
324
- if (!(command in state$b.commands)) {
324
+ if (!(command in state$a.commands)) {
325
325
  if (hasThrown.has(command)) {
326
326
  return;
327
327
  }
@@ -331,8 +331,8 @@ const executeCommandAsync = async (command, ...args) => {
331
331
  return execute(command, ...args);
332
332
  };
333
333
  const execute = (command, ...args) => {
334
- if (command in state$b.commands) {
335
- const fn = state$b.commands[command];
334
+ if (command in state$a.commands) {
335
+ const fn = state$a.commands[command];
336
336
  if (typeof fn !== 'function') {
337
337
  throw new Error(`[renderer-worker] Command ${command} is not a function`);
338
338
  }
@@ -341,11 +341,11 @@ const execute = (command, ...args) => {
341
341
  return executeCommandAsync(command, ...args);
342
342
  };
343
343
  const setLoad = load => {
344
- state$b.load = load;
344
+ state$a.load = load;
345
345
  };
346
346
 
347
347
  const ipcs = Object.create(null);
348
- const set$8 = (name, ipc) => {
348
+ const set$9 = (name, ipc) => {
349
349
  ipcs[name] = ipc;
350
350
  };
351
351
  const get$9 = name => {
@@ -454,47 +454,32 @@ const create$4$1 = (method, params) => {
454
454
  params
455
455
  };
456
456
  };
457
- const state$a = {
458
- callbacks: Object.create(null)
459
- };
460
- const set$7 = (id, fn) => {
461
- state$a.callbacks[id] = fn;
457
+ const callbacks = Object.create(null);
458
+ const set$8 = (id, fn) => {
459
+ callbacks[id] = fn;
462
460
  };
463
461
  const get$8 = id => {
464
- return state$a.callbacks[id];
462
+ return callbacks[id];
465
463
  };
466
464
  const remove$3 = id => {
467
- delete state$a.callbacks[id];
465
+ delete callbacks[id];
468
466
  };
469
467
  let id = 0;
470
468
  const create$3$1 = () => {
471
469
  return ++id;
472
470
  };
473
- const warn$1 = (...args) => {
474
- console.warn(...args);
475
- };
476
471
  const registerPromise = () => {
477
472
  const id = create$3$1();
478
473
  const {
479
474
  resolve,
480
475
  promise
481
476
  } = Promise.withResolvers();
482
- set$7(id, resolve);
477
+ set$8(id, resolve);
483
478
  return {
484
479
  id,
485
480
  promise
486
481
  };
487
482
  };
488
- const resolve = (id, response) => {
489
- const fn = get$8(id);
490
- if (!fn) {
491
- console.log(response);
492
- warn$1(`callback ${id} may already be disposed`);
493
- return;
494
- }
495
- fn(response);
496
- remove$3(id);
497
- };
498
483
  const create$2$1 = (method, params) => {
499
484
  const {
500
485
  id,
@@ -642,6 +627,19 @@ const unwrapJsonRpcResult = responseMessage => {
642
627
  }
643
628
  throw new JsonRpcError('unexpected response message');
644
629
  };
630
+ const warn$1 = (...args) => {
631
+ console.warn(...args);
632
+ };
633
+ const resolve = (id, response) => {
634
+ const fn = get$8(id);
635
+ if (!fn) {
636
+ console.log(response);
637
+ warn$1(`callback ${id} may already be disposed`);
638
+ return;
639
+ }
640
+ fn(response);
641
+ remove$3(id);
642
+ };
645
643
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
646
644
  const getErrorType = prettyError => {
647
645
  if (prettyError && prettyError.type) {
@@ -1022,7 +1020,7 @@ const hydrate$3 = async () => {
1022
1020
  } = new MessageChannel();
1023
1021
  // TODO only launch port and send to renderer worker
1024
1022
  const promise = launchEditorWorker(port1);
1025
- set$8('Editor Worker', port2);
1023
+ set$9('Editor Worker', port2);
1026
1024
  await promise;
1027
1025
  };
1028
1026
 
@@ -1053,7 +1051,7 @@ const hydrate$2 = async () => {
1053
1051
  // TODO only launch port and send to renderer worker
1054
1052
  const promise = launchExtensionHostWorker(port1);
1055
1053
  const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
1056
- set$8(name, port2);
1054
+ set$9(name, port2);
1057
1055
  await promise;
1058
1056
  };
1059
1057
 
@@ -1076,7 +1074,7 @@ const hydrate$1 = async () => {
1076
1074
  } = new MessageChannel();
1077
1075
  // TODO only launch port and send to renderer worker
1078
1076
  const promise = launchSyntaxHighlightingWorker(port1);
1079
- set$8('Syntax Highlighting Worker', port2);
1077
+ set$9('Syntax Highlighting Worker', port2);
1080
1078
  await promise;
1081
1079
  };
1082
1080
 
@@ -1487,7 +1485,7 @@ var cache$1 = /* @__PURE__ */new Map();
1487
1485
  var has = listener => {
1488
1486
  return cache$1.has(listener);
1489
1487
  };
1490
- var set$6 = (listener, value) => {
1488
+ var set$7 = (listener, value) => {
1491
1489
  cache$1.set(listener, value);
1492
1490
  };
1493
1491
  var get$7 = listener => {
@@ -1510,7 +1508,7 @@ var getWrappedListener$1 = (listener, returnValue) => {
1510
1508
  ipc.send("Viewlet.executeViewletCommand", uid, ...result);
1511
1509
  };
1512
1510
  nameAnonymousFunction$1(wrapped, listener.name);
1513
- set$6(listener, wrapped);
1511
+ set$7(listener, wrapped);
1514
1512
  }
1515
1513
  return get$7(listener);
1516
1514
  };
@@ -1701,7 +1699,7 @@ var rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1701
1699
  return $Viewlet;
1702
1700
  };
1703
1701
 
1704
- const set$5 = setComponentUid;
1702
+ const set$6 = setComponentUid;
1705
1703
  const get$6 = getComponentUid;
1706
1704
  const fromEvent = getComponentUidFromEvent;
1707
1705
 
@@ -1713,7 +1711,7 @@ const applyUidWorkaround = element => {
1713
1711
  throw new Error('no editor found');
1714
1712
  }
1715
1713
  const editorUid = get$6(editor);
1716
- set$5(element, editorUid);
1714
+ set$6(element, editorUid);
1717
1715
  };
1718
1716
 
1719
1717
  const setBounds$a = ($Element, x, y, width, height) => {
@@ -4066,7 +4064,7 @@ const ConfirmPrompt_ipc = {
4066
4064
  const state$5 = {
4067
4065
  styleSheets: Object.create(null)
4068
4066
  };
4069
- const set$4 = (id, sheet) => {
4067
+ const set$5 = (id, sheet) => {
4070
4068
  state$5.styleSheets[id] = sheet;
4071
4069
  };
4072
4070
  const get$5 = id => {
@@ -4080,7 +4078,7 @@ const addCssStyleSheet = async (id, text) => {
4080
4078
  return;
4081
4079
  }
4082
4080
  const sheet = new CSSStyleSheet({});
4083
- set$4(id, sheet);
4081
+ set$5(id, sheet);
4084
4082
  await sheet.replace(text);
4085
4083
  document.adoptedStyleSheets.push(sheet);
4086
4084
  };
@@ -4634,7 +4632,7 @@ const state$3 = {
4634
4632
  const get$4 = id => {
4635
4633
  return state$3.canvasObjects[id];
4636
4634
  };
4637
- const set$3 = (canvasId, canvas) => {
4635
+ const set$4 = (canvasId, canvas) => {
4638
4636
  state$3.canvasObjects[canvasId] = canvas;
4639
4637
  };
4640
4638
 
@@ -4644,7 +4642,7 @@ const get$3 = id => {
4644
4642
  const create$y = async (canvasId, objectId) => {
4645
4643
  const canvas = document.createElement('canvas');
4646
4644
  const offscreenCanvas = canvas.transferControlToOffscreen();
4647
- set$3(canvasId, canvas);
4645
+ set$4(canvasId, canvas);
4648
4646
  await invokeAndTransfer('Transferrable.transfer', objectId, offscreenCanvas);
4649
4647
  };
4650
4648
 
@@ -5091,7 +5089,7 @@ const screenCaptures = Object.create(null);
5091
5089
  const get$2 = id => {
5092
5090
  return screenCaptures[id];
5093
5091
  };
5094
- const set$2 = (id, captureStream) => {
5092
+ const set$3 = (id, captureStream) => {
5095
5093
  screenCaptures[id] = captureStream;
5096
5094
  };
5097
5095
  const remove$1 = id => {
@@ -5107,7 +5105,7 @@ const start = async (id, options) => {
5107
5105
  number(id);
5108
5106
  object(options);
5109
5107
  const captureStream = await navigator.mediaDevices.getUserMedia(options);
5110
- set$2(id, captureStream);
5108
+ set$3(id, captureStream);
5111
5109
  } catch (error) {
5112
5110
  throw new VError$1(error, `Failed to start screen capture`);
5113
5111
  }
@@ -5658,7 +5656,7 @@ const TestFrameWork_ipc = {
5658
5656
  };
5659
5657
 
5660
5658
  const webViews = Object.create(null);
5661
- const set$1 = (id, webView) => {
5659
+ const set$2 = (id, webView) => {
5662
5660
  webViews[id] = webView;
5663
5661
  };
5664
5662
  const get = id => {
@@ -5871,7 +5869,7 @@ const create$x = (id, uid = id) => {
5871
5869
  state$6.instances[id].state.$Viewlet.remove();
5872
5870
  }
5873
5871
  const instanceState = module.create();
5874
- set$5(instanceState.$Viewlet, uid);
5872
+ set$6(instanceState.$Viewlet, uid);
5875
5873
  if (module.attachEvents) {
5876
5874
  module.attachEvents(instanceState);
5877
5875
  }
@@ -6034,7 +6032,7 @@ const setDom2 = (viewletId, dom) => {
6034
6032
  const $NewViewlet = rememberFocus($Viewlet, dom, Events, viewletId);
6035
6033
  if (uid) {
6036
6034
  // @ts-ignore
6037
- set$5($NewViewlet, uid);
6035
+ set$6($NewViewlet, uid);
6038
6036
  }
6039
6037
  instance.state.$Viewlet = $NewViewlet;
6040
6038
  };
@@ -6447,13 +6445,13 @@ const Window_ipc = {
6447
6445
  name: name$6
6448
6446
  };
6449
6447
 
6450
- const set = title => {
6448
+ const set$1 = title => {
6451
6449
  document.title = title;
6452
6450
  };
6453
6451
 
6454
6452
  const name$5 = 'WindowTitle';
6455
6453
  const Commands$6 = {
6456
- set: set
6454
+ set: set$1
6457
6455
  };
6458
6456
 
6459
6457
  const WindowTitle_ipc = {
@@ -6587,6 +6585,13 @@ const setIframeCsp = ($Iframe, csp) => {
6587
6585
  }
6588
6586
  };
6589
6587
 
6588
+ const set = ($Iframe, permissionPolicy) => {
6589
+ if (permissionPolicy === undefined) {
6590
+ return;
6591
+ }
6592
+ $Iframe.allow = permissionPolicy;
6593
+ };
6594
+
6590
6595
  const setIframeSandBox = ($Iframe, sandbox) => {
6591
6596
  $Iframe.sandbox.add(...sandbox);
6592
6597
  };
@@ -6611,14 +6616,16 @@ const waitForFrameToLoad = $Frame => {
6611
6616
  };
6612
6617
 
6613
6618
  // TODO could use browser view when running in electron
6614
- const create$w = async (uid, src, sandbox, csp, credentialless) => {
6619
+ const create$w = async (uid, src, sandbox, csp, credentialless, permissionPolicy) => {
6615
6620
  const $Iframe = document.createElement('iframe');
6616
6621
  setIframeCredentialless($Iframe, credentialless);
6617
6622
  setIframeCsp($Iframe, csp);
6618
6623
  setIframeSandBox($Iframe, sandbox);
6619
6624
  setIframeSrc($Iframe, src);
6625
+ set($Iframe, permissionPolicy);
6626
+ // TODO set classname from iframe worker
6620
6627
  $Iframe.className = 'E2eTestIframe WebViewIframe';
6621
- set$1(uid, $Iframe);
6628
+ set$2(uid, $Iframe);
6622
6629
  // TODO make make waitForFrameToLoad a separate command
6623
6630
  };
6624
6631
  const load = async uid => {
@@ -11370,7 +11377,7 @@ const setMenus = (state, changes, uid) => {
11370
11377
  const menu = change[1];
11371
11378
  const dom = change[2];
11372
11379
  const $Menu = create$Menu();
11373
- set$5($Menu, uid);
11380
+ set$6($Menu, uid);
11374
11381
  $Menu.onmouseover = handleMenuMouseOver;
11375
11382
  $Menu.onclick = handleMenuClick;
11376
11383
  const {
@@ -11758,7 +11765,7 @@ const setIframe = (state, src, sandbox = [], srcDoc = '', csp = '', credentialle
11758
11765
  $Iframe.className = 'E2eTestIframe WebViewIframe';
11759
11766
  $Parent.append($Iframe);
11760
11767
  state.frame = $Iframe;
11761
- set$1(1, $Iframe);
11768
+ set$2(1, $Iframe);
11762
11769
  };
11763
11770
  const setPort = (state, portId, origin) => {
11764
11771
  const port = acquire(portId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "10.32.0",
3
+ "version": "10.34.0",
4
4
  "description": "",
5
5
  "main": "dist/rendererProcessMain.js",
6
6
  "type": "module",