@lvce-editor/renderer-process 30.71.0 → 30.72.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.
@@ -629,7 +629,7 @@ class CommandNotFoundError extends Error {
629
629
  }
630
630
  }
631
631
  const commands = Object.create(null);
632
- const register = commandMap => {
632
+ const register$1 = commandMap => {
633
633
  Object.assign(commands, commandMap);
634
634
  };
635
635
  const getCommand = key => {
@@ -785,9 +785,12 @@ const applyDataProperties = (restoredError, error) => {
785
785
  writable: true
786
786
  });
787
787
  }
788
- if (error.data.type) {
789
- // @ts-ignore
790
- restoredError.name = error.data.type;
788
+ const name = error.data.name || error.data.type;
789
+ if (name) {
790
+ Object.defineProperty(restoredError, 'name', {
791
+ configurable: true,
792
+ value: name
793
+ });
791
794
  }
792
795
  };
793
796
  const applyDirectProperties = (restoredError, error) => {
@@ -804,7 +807,7 @@ const applyDirectProperties = (restoredError, error) => {
804
807
  }
805
808
  };
806
809
  const restoreMessageError = (error, _currentStack) => {
807
- const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
810
+ const restoredError = constructError(error.message, error.type || error.data?.type, error.name || error.data?.name);
808
811
  if (typeof error.code === 'string' || typeof error.code === 'number') {
809
812
  Object.defineProperty(restoredError, 'code', {
810
813
  configurable: true,
@@ -1161,7 +1164,7 @@ const create$F = async ({
1161
1164
  window
1162
1165
  }) => {
1163
1166
  // TODO create a commandMap per rpc instance
1164
- register(commandMap);
1167
+ register$1(commandMap);
1165
1168
  const ipc = IpcChildWithElectronWindow$1.wrap(window);
1166
1169
  handleIpc(ipc);
1167
1170
  const rpc = createRpc(ipc);
@@ -1174,7 +1177,7 @@ const create$E = async ({
1174
1177
  messagePort
1175
1178
  }) => {
1176
1179
  // TODO create a commandMap per rpc instance
1177
- register(commandMap);
1180
+ register$1(commandMap);
1178
1181
  const rawIpc = await IpcParentWithMessagePort$1$1.create({
1179
1182
  isMessagePortOpen,
1180
1183
  messagePort
@@ -1196,7 +1199,7 @@ const create$D = async ({
1196
1199
  url
1197
1200
  }) => {
1198
1201
  // TODO create a commandMap per rpc instance
1199
- register(commandMap);
1202
+ register$1(commandMap);
1200
1203
  const worker = await IpcParentWithModuleWorker$1$1.create({
1201
1204
  name,
1202
1205
  url
@@ -1217,7 +1220,7 @@ const create$C = async ({
1217
1220
  url
1218
1221
  }) => {
1219
1222
  // TODO create a commandMap per rpc instance
1220
- register(commandMap);
1223
+ register$1(commandMap);
1221
1224
  const worker = await IpcParentWithModuleWorker$1$1.create({
1222
1225
  name,
1223
1226
  url
@@ -1780,7 +1783,7 @@ const hydrate$4 = async () => {
1780
1783
  };
1781
1784
 
1782
1785
  // TODO needed?
1783
- const dispose$n = async () => {
1786
+ const dispose$o = async () => {
1784
1787
  const rpc = state$l.rpc;
1785
1788
  state$l.rpc = undefined;
1786
1789
  await rpc?.dispose();
@@ -1962,7 +1965,7 @@ const initializeLayout = async href => {
1962
1965
  }
1963
1966
  return true;
1964
1967
  };
1965
- const dispose$m = async () => {
1968
+ const dispose$n = async () => {
1966
1969
  state$k.stopObserving?.();
1967
1970
  state$k.stopObserving = undefined;
1968
1971
  const client = state$k.client;
@@ -4157,7 +4160,7 @@ const handleMessagePort$1 = async port => {
4157
4160
  }
4158
4161
  await rpc.invokeAndTransfer('DragAndDrop.handleMessagePort', port);
4159
4162
  };
4160
- const dispose$l = async () => {
4163
+ const dispose$m = async () => {
4161
4164
  const rpc = state$g.rpc;
4162
4165
  state$g.rpc = undefined;
4163
4166
  await rpc?.dispose();
@@ -4656,7 +4659,7 @@ const create$u = async ({
4656
4659
  // @ts-ignore
4657
4660
  return module.create(options);
4658
4661
  };
4659
- const dispose$k = id => {
4662
+ const dispose$l = id => {
4660
4663
  const worker = remove$3(id);
4661
4664
  if (worker) {
4662
4665
  remove$5(worker);
@@ -4775,7 +4778,7 @@ const applyPatch$1 = (element, patches, eventMap = {}, id = 0) => {
4775
4778
  }
4776
4779
  applyPatch$2(element, patches, eventMap, id);
4777
4780
  };
4778
- const dispose$j = root => {
4781
+ const dispose$k = root => {
4779
4782
  state$e.renderer?.dispose(root);
4780
4783
  };
4781
4784
 
@@ -4928,6 +4931,87 @@ const info = (...args) => {
4928
4931
  console.info(...args);
4929
4932
  };
4930
4933
 
4934
+ const executeViewletCommand$1 = 'Viewlet.executeViewletCommand';
4935
+ const send = (method, uid, ...args) => {
4936
+ if (method === executeViewletCommand$1) {
4937
+ const rpc = get$8(uid);
4938
+ if (rpc) {
4939
+ rpc.send(method, uid, ...args);
4940
+ return;
4941
+ }
4942
+ }
4943
+ send$1(method, uid, ...args);
4944
+ };
4945
+
4946
+ const ViewletEventRouter = {
4947
+ __proto__: null,
4948
+ send
4949
+ };
4950
+
4951
+ const executeViewletCommand = (uid, command, ...args) => {
4952
+ number(uid);
4953
+ send('Viewlet.executeViewletCommand', uid, command, ...args);
4954
+ };
4955
+
4956
+ const cleanups = new Map();
4957
+ const dispose$j = uid => {
4958
+ cleanups.get(uid)?.();
4959
+ cleanups.delete(uid);
4960
+ };
4961
+
4962
+ // The owner controls the lifetime; events can target the component owning a widget.
4963
+ const register = (uid, targetUid, listeners) => {
4964
+ dispose$j(uid);
4965
+ const root = get$b(uid)?.state.$Viewlet;
4966
+ if (!root) {
4967
+ return;
4968
+ }
4969
+ let active = true;
4970
+ const removals = [];
4971
+ const isInside = (target, selectors) => {
4972
+ if (!(target instanceof Element)) {
4973
+ return false;
4974
+ }
4975
+ if (get$b(uid)?.state.$Viewlet.contains(target)) {
4976
+ return true;
4977
+ }
4978
+ const parentRoot = get$b(targetUid)?.state.$Viewlet;
4979
+ return selectors.some(selector => {
4980
+ const match = target.closest(selector);
4981
+ return match && parentRoot?.contains(match);
4982
+ });
4983
+ };
4984
+ for (const listener of listeners) {
4985
+ const {
4986
+ event,
4987
+ ignoreSelectors,
4988
+ params
4989
+ } = listener;
4990
+ const notify = target => {
4991
+ if (active && !isInside(target, ignoreSelectors)) {
4992
+ executeViewletCommand(targetUid, params[0], ...params.slice(1));
4993
+ }
4994
+ };
4995
+ const handleEvent = event => {
4996
+ if (event.type === 'focusout') {
4997
+ // DOM replacement can briefly clear focus before a following focus command.
4998
+ queueMicrotask(() => notify(document.activeElement));
4999
+ } else {
5000
+ notify(event.target);
5001
+ }
5002
+ };
5003
+ const target = event === 'focusout' ? root : document;
5004
+ target.addEventListener(event, handleEvent);
5005
+ removals.push(() => target.removeEventListener(event, handleEvent));
5006
+ }
5007
+ cleanups.set(uid, () => {
5008
+ active = false;
5009
+ for (const remove of removals) {
5010
+ remove();
5011
+ }
5012
+ });
5013
+ };
5014
+
4931
5015
  const pendingBatches = new Map();
4932
5016
  const state$a = {
4933
5017
  nextTransactionId: 1
@@ -5323,28 +5407,6 @@ const ViewletActivityBar = {
5323
5407
  Events: Events$6
5324
5408
  };
5325
5409
 
5326
- const executeViewletCommand$1 = 'Viewlet.executeViewletCommand';
5327
- const send = (method, uid, ...args) => {
5328
- if (method === executeViewletCommand$1) {
5329
- const rpc = get$8(uid);
5330
- if (rpc) {
5331
- rpc.send(method, uid, ...args);
5332
- return;
5333
- }
5334
- }
5335
- send$1(method, uid, ...args);
5336
- };
5337
-
5338
- const ViewletEventRouter = {
5339
- __proto__: null,
5340
- send
5341
- };
5342
-
5343
- const executeViewletCommand = (uid, command, ...args) => {
5344
- number(uid);
5345
- send('Viewlet.executeViewletCommand', uid, command, ...args);
5346
- };
5347
-
5348
5410
  const nameAnonymousFunction = (fn, name) => {
5349
5411
  Object.defineProperty(fn, 'name', {
5350
5412
  value: name
@@ -9418,7 +9480,7 @@ const create$4 = (id, uid = id) => {
9418
9480
  state: instanceState
9419
9481
  });
9420
9482
  };
9421
- const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcId) => {
9483
+ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcId, eventTargetUid = uid) => {
9422
9484
  let module = state$5.modules[id];
9423
9485
  if (hasFunctionalEvents) {
9424
9486
  module ||= {};
@@ -9426,7 +9488,8 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcI
9426
9488
  if (!module) {
9427
9489
  throw new Error(`module not found: ${id}`);
9428
9490
  }
9429
- const existing = get$b(id);
9491
+ const existing = get$b(uid);
9492
+ dispose$j(uid);
9430
9493
  if (existing?.state.$Viewlet.isConnected) {
9431
9494
  existing.state.$Viewlet.remove();
9432
9495
  }
@@ -9435,6 +9498,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcI
9435
9498
  };
9436
9499
  set$a(instanceState.$Viewlet, uid);
9437
9500
  if (existing) dispose$i(uid);
9501
+ set$a(instanceState.$Viewlet, eventTargetUid);
9438
9502
  registerView(uid, directEventRpcId);
9439
9503
  set$c(uid, {
9440
9504
  factory: module,
@@ -9928,6 +9992,7 @@ const dispose$4 = id => {
9928
9992
  try {
9929
9993
  number(id);
9930
9994
  restoreComponentDom(id);
9995
+ dispose$j(id);
9931
9996
  unregisterView(id);
9932
9997
  dispose$i(id);
9933
9998
  const instance = get$b(id);
@@ -9938,7 +10003,7 @@ const dispose$4 = id => {
9938
10003
  if (instance.factory.dispose) {
9939
10004
  instance.factory.dispose(instance.state);
9940
10005
  }
9941
- dispose$j(instance.state.$Viewlet);
10006
+ dispose$k(instance.state.$Viewlet);
9942
10007
  if (instance.state.$Viewlet?.isConnected) {
9943
10008
  instance.state.$Viewlet.remove();
9944
10009
  }
@@ -10217,6 +10282,7 @@ const commandHandlers = {
10217
10282
  'Viewlet.move': move,
10218
10283
  'Viewlet.patchCss': patchCssStyleSheet,
10219
10284
  'Viewlet.registerEventListeners': registerEventListeners,
10285
+ 'Viewlet.registerOutsideEventListeners': register,
10220
10286
  'Viewlet.removeKeyBindings': removeKeyBindings,
10221
10287
  'Viewlet.renderCanvas': renderCanvas,
10222
10288
  'Viewlet.replaceChildren': replaceChildren,
@@ -10273,9 +10339,9 @@ const restart = async () => {
10273
10339
  const snapshot = await invoke$1('Reload.prepareHotReload');
10274
10340
  set$9(snapshot);
10275
10341
  await invoke$1('Reload.retire');
10276
- await dispose$m();
10277
10342
  await dispose$n();
10278
- await dispose$l();
10343
+ await dispose$o();
10344
+ await dispose$m();
10279
10345
  terminateAll();
10280
10346
  clear$2();
10281
10347
  clear$4();
@@ -12324,7 +12390,7 @@ const commandMap = {
12324
12390
  'HotReload.request': request,
12325
12391
  'InitData.getInitData': getInitData,
12326
12392
  'IpcParent.create': create$u,
12327
- 'IpcParent.dispose': dispose$k,
12393
+ 'IpcParent.dispose': dispose$l,
12328
12394
  'KeyBindings.setIdentifiers': setIdentifiers,
12329
12395
  'Layout.getBounds': getBounds,
12330
12396
  'Location.getHref': getHref,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.71.0",
3
+ "version": "30.72.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"