@lvce-editor/renderer-process 30.71.1 → 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 => {
@@ -1164,7 +1164,7 @@ const create$F = async ({
1164
1164
  window
1165
1165
  }) => {
1166
1166
  // TODO create a commandMap per rpc instance
1167
- register(commandMap);
1167
+ register$1(commandMap);
1168
1168
  const ipc = IpcChildWithElectronWindow$1.wrap(window);
1169
1169
  handleIpc(ipc);
1170
1170
  const rpc = createRpc(ipc);
@@ -1177,7 +1177,7 @@ const create$E = async ({
1177
1177
  messagePort
1178
1178
  }) => {
1179
1179
  // TODO create a commandMap per rpc instance
1180
- register(commandMap);
1180
+ register$1(commandMap);
1181
1181
  const rawIpc = await IpcParentWithMessagePort$1$1.create({
1182
1182
  isMessagePortOpen,
1183
1183
  messagePort
@@ -1199,7 +1199,7 @@ const create$D = async ({
1199
1199
  url
1200
1200
  }) => {
1201
1201
  // TODO create a commandMap per rpc instance
1202
- register(commandMap);
1202
+ register$1(commandMap);
1203
1203
  const worker = await IpcParentWithModuleWorker$1$1.create({
1204
1204
  name,
1205
1205
  url
@@ -1220,7 +1220,7 @@ const create$C = async ({
1220
1220
  url
1221
1221
  }) => {
1222
1222
  // TODO create a commandMap per rpc instance
1223
- register(commandMap);
1223
+ register$1(commandMap);
1224
1224
  const worker = await IpcParentWithModuleWorker$1$1.create({
1225
1225
  name,
1226
1226
  url
@@ -1783,7 +1783,7 @@ const hydrate$4 = async () => {
1783
1783
  };
1784
1784
 
1785
1785
  // TODO needed?
1786
- const dispose$n = async () => {
1786
+ const dispose$o = async () => {
1787
1787
  const rpc = state$l.rpc;
1788
1788
  state$l.rpc = undefined;
1789
1789
  await rpc?.dispose();
@@ -1965,7 +1965,7 @@ const initializeLayout = async href => {
1965
1965
  }
1966
1966
  return true;
1967
1967
  };
1968
- const dispose$m = async () => {
1968
+ const dispose$n = async () => {
1969
1969
  state$k.stopObserving?.();
1970
1970
  state$k.stopObserving = undefined;
1971
1971
  const client = state$k.client;
@@ -4160,7 +4160,7 @@ const handleMessagePort$1 = async port => {
4160
4160
  }
4161
4161
  await rpc.invokeAndTransfer('DragAndDrop.handleMessagePort', port);
4162
4162
  };
4163
- const dispose$l = async () => {
4163
+ const dispose$m = async () => {
4164
4164
  const rpc = state$g.rpc;
4165
4165
  state$g.rpc = undefined;
4166
4166
  await rpc?.dispose();
@@ -4659,7 +4659,7 @@ const create$u = async ({
4659
4659
  // @ts-ignore
4660
4660
  return module.create(options);
4661
4661
  };
4662
- const dispose$k = id => {
4662
+ const dispose$l = id => {
4663
4663
  const worker = remove$3(id);
4664
4664
  if (worker) {
4665
4665
  remove$5(worker);
@@ -4778,7 +4778,7 @@ const applyPatch$1 = (element, patches, eventMap = {}, id = 0) => {
4778
4778
  }
4779
4779
  applyPatch$2(element, patches, eventMap, id);
4780
4780
  };
4781
- const dispose$j = root => {
4781
+ const dispose$k = root => {
4782
4782
  state$e.renderer?.dispose(root);
4783
4783
  };
4784
4784
 
@@ -4931,6 +4931,87 @@ const info = (...args) => {
4931
4931
  console.info(...args);
4932
4932
  };
4933
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
+
4934
5015
  const pendingBatches = new Map();
4935
5016
  const state$a = {
4936
5017
  nextTransactionId: 1
@@ -5326,28 +5407,6 @@ const ViewletActivityBar = {
5326
5407
  Events: Events$6
5327
5408
  };
5328
5409
 
5329
- const executeViewletCommand$1 = 'Viewlet.executeViewletCommand';
5330
- const send = (method, uid, ...args) => {
5331
- if (method === executeViewletCommand$1) {
5332
- const rpc = get$8(uid);
5333
- if (rpc) {
5334
- rpc.send(method, uid, ...args);
5335
- return;
5336
- }
5337
- }
5338
- send$1(method, uid, ...args);
5339
- };
5340
-
5341
- const ViewletEventRouter = {
5342
- __proto__: null,
5343
- send
5344
- };
5345
-
5346
- const executeViewletCommand = (uid, command, ...args) => {
5347
- number(uid);
5348
- send('Viewlet.executeViewletCommand', uid, command, ...args);
5349
- };
5350
-
5351
5410
  const nameAnonymousFunction = (fn, name) => {
5352
5411
  Object.defineProperty(fn, 'name', {
5353
5412
  value: name
@@ -9421,7 +9480,7 @@ const create$4 = (id, uid = id) => {
9421
9480
  state: instanceState
9422
9481
  });
9423
9482
  };
9424
- const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcId) => {
9483
+ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcId, eventTargetUid = uid) => {
9425
9484
  let module = state$5.modules[id];
9426
9485
  if (hasFunctionalEvents) {
9427
9486
  module ||= {};
@@ -9429,7 +9488,8 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcI
9429
9488
  if (!module) {
9430
9489
  throw new Error(`module not found: ${id}`);
9431
9490
  }
9432
- const existing = get$b(id);
9491
+ const existing = get$b(uid);
9492
+ dispose$j(uid);
9433
9493
  if (existing?.state.$Viewlet.isConnected) {
9434
9494
  existing.state.$Viewlet.remove();
9435
9495
  }
@@ -9438,6 +9498,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcI
9438
9498
  };
9439
9499
  set$a(instanceState.$Viewlet, uid);
9440
9500
  if (existing) dispose$i(uid);
9501
+ set$a(instanceState.$Viewlet, eventTargetUid);
9441
9502
  registerView(uid, directEventRpcId);
9442
9503
  set$c(uid, {
9443
9504
  factory: module,
@@ -9931,6 +9992,7 @@ const dispose$4 = id => {
9931
9992
  try {
9932
9993
  number(id);
9933
9994
  restoreComponentDom(id);
9995
+ dispose$j(id);
9934
9996
  unregisterView(id);
9935
9997
  dispose$i(id);
9936
9998
  const instance = get$b(id);
@@ -9941,7 +10003,7 @@ const dispose$4 = id => {
9941
10003
  if (instance.factory.dispose) {
9942
10004
  instance.factory.dispose(instance.state);
9943
10005
  }
9944
- dispose$j(instance.state.$Viewlet);
10006
+ dispose$k(instance.state.$Viewlet);
9945
10007
  if (instance.state.$Viewlet?.isConnected) {
9946
10008
  instance.state.$Viewlet.remove();
9947
10009
  }
@@ -10220,6 +10282,7 @@ const commandHandlers = {
10220
10282
  'Viewlet.move': move,
10221
10283
  'Viewlet.patchCss': patchCssStyleSheet,
10222
10284
  'Viewlet.registerEventListeners': registerEventListeners,
10285
+ 'Viewlet.registerOutsideEventListeners': register,
10223
10286
  'Viewlet.removeKeyBindings': removeKeyBindings,
10224
10287
  'Viewlet.renderCanvas': renderCanvas,
10225
10288
  'Viewlet.replaceChildren': replaceChildren,
@@ -10276,9 +10339,9 @@ const restart = async () => {
10276
10339
  const snapshot = await invoke$1('Reload.prepareHotReload');
10277
10340
  set$9(snapshot);
10278
10341
  await invoke$1('Reload.retire');
10279
- await dispose$m();
10280
10342
  await dispose$n();
10281
- await dispose$l();
10343
+ await dispose$o();
10344
+ await dispose$m();
10282
10345
  terminateAll();
10283
10346
  clear$2();
10284
10347
  clear$4();
@@ -12327,7 +12390,7 @@ const commandMap = {
12327
12390
  'HotReload.request': request,
12328
12391
  'InitData.getInitData': getInitData,
12329
12392
  'IpcParent.create': create$u,
12330
- 'IpcParent.dispose': dispose$k,
12393
+ 'IpcParent.dispose': dispose$l,
12331
12394
  'KeyBindings.setIdentifiers': setIdentifiers,
12332
12395
  'Layout.getBounds': getBounds,
12333
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.1",
3
+ "version": "30.72.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"