@lvce-editor/renderer-process 30.35.0 → 30.36.1

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.
@@ -211,49 +211,6 @@ const showState = async () => {
211
211
  info(state);
212
212
  };
213
213
 
214
- const rpcs = new Map();
215
- const viewRpcIds = new Map();
216
- const get$9 = uid => {
217
- const rpcId = viewRpcIds.get(uid);
218
- return rpcId === undefined ? undefined : rpcs.get(rpcId);
219
- };
220
- const getViewUid = rpcId => {
221
- let matchingUid;
222
- for (const [uid, registeredRpcId] of viewRpcIds) {
223
- if (registeredRpcId === rpcId) {
224
- matchingUid = uid;
225
- }
226
- }
227
- if (matchingUid === undefined) {
228
- throw new Error(`direct view not found: ${rpcId}`);
229
- }
230
- return matchingUid;
231
- };
232
- const registerRpc = (rpcId, rpc) => {
233
- const previous = rpcs.get(rpcId);
234
- if (previous && previous !== rpc) {
235
- previous.dispose();
236
- }
237
- rpcs.set(rpcId, rpc);
238
- };
239
- const registerView = (uid, rpcId) => {
240
- if (rpcId === undefined) {
241
- viewRpcIds.delete(uid);
242
- return;
243
- }
244
- viewRpcIds.set(uid, rpcId);
245
- };
246
- const unregisterView = uid => {
247
- viewRpcIds.delete(uid);
248
- };
249
-
250
- const downloadFile = (fileName, url) => {
251
- const a = document.createElement('a');
252
- a.href = url;
253
- a.download = fileName;
254
- a.click();
255
- };
256
-
257
214
  const uidSymbol = Symbol('uid');
258
215
 
259
216
  const getUidTarget = $Element => {
@@ -1313,7 +1270,7 @@ const {
1313
1270
  } = ElementTagMap;
1314
1271
 
1315
1272
  const instances = Object.create(null);
1316
- const get$8 = viewletId => {
1273
+ const get$9 = viewletId => {
1317
1274
  return instances[viewletId];
1318
1275
  };
1319
1276
  const set$a = (viewletId, instance) => {
@@ -1348,7 +1305,7 @@ const has$1 = listener => {
1348
1305
  const set$9 = (listener, value) => {
1349
1306
  cache.set(listener, value);
1350
1307
  };
1351
- const get$7 = listener => {
1308
+ const get$8 = listener => {
1352
1309
  return cache.get(listener);
1353
1310
  };
1354
1311
 
@@ -1370,7 +1327,7 @@ const getWrappedListener = (listener, returnValue) => {
1370
1327
  nameAnonymousFunction$1(wrapped, listener.name);
1371
1328
  set$9(listener, wrapped);
1372
1329
  }
1373
- return get$7(listener);
1330
+ return get$8(listener);
1374
1331
  };
1375
1332
 
1376
1333
  const attachedListeners = new WeakMap();
@@ -1604,7 +1561,7 @@ const renderDomElement = (element, eventMap, newEventMap) => {
1604
1561
  return $Element;
1605
1562
  };
1606
1563
  const renderReferenceNode = (element, eventMap, newEventMap) => {
1607
- const instance = get$8(element.uid);
1564
+ const instance = get$9(element.uid);
1608
1565
  if (!instance || !instance.state) {
1609
1566
  return document.createTextNode('Reference node not found');
1610
1567
  }
@@ -1750,7 +1707,7 @@ const handleNavigateSibling = (state, patch, $Element, patchIndex) => {
1750
1707
  return true;
1751
1708
  };
1752
1709
  const handleSetReferenceNodeUid = (state, patch) => {
1753
- const instance = get$8(patch.uid);
1710
+ const instance = get$9(patch.uid);
1754
1711
  if (!instance || !instance.state) {
1755
1712
  console.error('Cannot set reference node uid: instance not found', {
1756
1713
  uid: patch.uid
@@ -1966,7 +1923,61 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1966
1923
  }
1967
1924
  };
1968
1925
 
1969
- const get$6 = ids => {
1926
+ const set$8 = setComponentUid;
1927
+ const get$7 = getComponentUid;
1928
+ const fromEvent = getComponentUidFromEvent;
1929
+
1930
+ const rpcs = new Map();
1931
+ const viewRpcIds = new Map();
1932
+ const get$6 = uid => {
1933
+ const rpcId = viewRpcIds.get(uid);
1934
+ return rpcId === undefined ? undefined : rpcs.get(rpcId);
1935
+ };
1936
+ const getViewUid = rpcId => {
1937
+ let matchingUid;
1938
+ for (const [uid, registeredRpcId] of viewRpcIds) {
1939
+ if (registeredRpcId === rpcId) {
1940
+ matchingUid = uid;
1941
+ }
1942
+ }
1943
+ if (matchingUid === undefined) {
1944
+ throw new Error(`direct view not found: ${rpcId}`);
1945
+ }
1946
+ return matchingUid;
1947
+ };
1948
+ const getFocusedViewUid = (rpcId, element = document.activeElement) => {
1949
+ const uid = element ? get$7(element) : 0;
1950
+ if (!uid || viewRpcIds.get(uid) !== rpcId) {
1951
+ throw new Error(`focused direct view not found: ${rpcId}`);
1952
+ }
1953
+ return uid;
1954
+ };
1955
+ const registerRpc = (rpcId, rpc) => {
1956
+ const previous = rpcs.get(rpcId);
1957
+ if (previous && previous !== rpc) {
1958
+ previous.dispose();
1959
+ }
1960
+ rpcs.set(rpcId, rpc);
1961
+ };
1962
+ const registerView = (uid, rpcId) => {
1963
+ if (rpcId === undefined) {
1964
+ viewRpcIds.delete(uid);
1965
+ return;
1966
+ }
1967
+ viewRpcIds.set(uid, rpcId);
1968
+ };
1969
+ const unregisterView = uid => {
1970
+ viewRpcIds.delete(uid);
1971
+ };
1972
+
1973
+ const downloadFile = (fileName, url) => {
1974
+ const a = document.createElement('a');
1975
+ a.href = url;
1976
+ a.download = fileName;
1977
+ a.click();
1978
+ };
1979
+
1980
+ const get$5 = ids => {
1970
1981
  return getFileHandles$1(ids);
1971
1982
  };
1972
1983
 
@@ -2893,7 +2904,7 @@ const execute = (command, ...args) => {
2893
2904
 
2894
2905
  const Two$1 = '2.0';
2895
2906
  const callbacks = Object.create(null);
2896
- const get$5 = id => {
2907
+ const get$4 = id => {
2897
2908
  return callbacks[id];
2898
2909
  };
2899
2910
  const remove$4 = id => {
@@ -3083,7 +3094,7 @@ const warn = (...args) => {
3083
3094
  console.warn(...args);
3084
3095
  };
3085
3096
  const resolve = (id, response) => {
3086
- const fn = get$5(id);
3097
+ const fn = get$4(id);
3087
3098
  if (!fn) {
3088
3099
  console.log(response);
3089
3100
  warn(`callback ${id} may already be disposed`);
@@ -3453,7 +3464,7 @@ const create$x = async ({
3453
3464
  };
3454
3465
 
3455
3466
  const workers = Object.create(null);
3456
- const set$8 = (id, worker) => {
3467
+ const set$7 = (id, worker) => {
3457
3468
  workers[id] = worker;
3458
3469
  };
3459
3470
  const remove$3 = id => {
@@ -3477,7 +3488,7 @@ const create$w = async ({
3477
3488
  });
3478
3489
  const worker = rpc.ipc?._rawIpc;
3479
3490
  if (typeof id === 'number' && raw && worker) {
3480
- set$8(id, worker);
3491
+ set$7(id, worker);
3481
3492
  }
3482
3493
  return undefined;
3483
3494
  };
@@ -3556,10 +3567,10 @@ const getModule = method => {
3556
3567
  };
3557
3568
 
3558
3569
  const ipcs = Object.create(null);
3559
- const set$7 = (name, ipc) => {
3570
+ const set$6 = (name, ipc) => {
3560
3571
  ipcs[name] = ipc;
3561
3572
  };
3562
- const get$4 = name => {
3573
+ const get$3 = name => {
3563
3574
  return ipcs[name];
3564
3575
  };
3565
3576
  const remove$2 = name => {
@@ -3793,7 +3804,7 @@ const create$u = async ({
3793
3804
  }
3794
3805
  // TODO rename method
3795
3806
  // TODO avoid cyclic dependency
3796
- const port = get$4(options.name);
3807
+ const port = get$3(options.name);
3797
3808
  remove$2(options.name);
3798
3809
  await invokeAndTransfer('Transferrable.transfer', options.id, port);
3799
3810
  return;
@@ -4018,14 +4029,14 @@ const dispose$h = id => {
4018
4029
  const state$7 = {
4019
4030
  canvasObjects: Object.create(null)
4020
4031
  };
4021
- const set$6 = (canvasId, canvas) => {
4032
+ const set$5 = (canvasId, canvas) => {
4022
4033
  state$7.canvasObjects[canvasId] = canvas;
4023
4034
  };
4024
4035
 
4025
4036
  const create$r = async (canvasId, objectId) => {
4026
4037
  const canvas = document.createElement('canvas');
4027
4038
  const offscreenCanvas = canvas.transferControlToOffscreen();
4028
- set$6(canvasId, canvas);
4039
+ set$5(canvasId, canvas);
4029
4040
  await invokeAndTransfer('Transferrable.transfer', objectId, offscreenCanvas);
4030
4041
  };
4031
4042
  const create2 = async (canvasId, objectId, width, height) => {
@@ -4056,10 +4067,6 @@ const create$BackDrop = () => {
4056
4067
  return $BackDrop;
4057
4068
  };
4058
4069
 
4059
- const set$5 = setComponentUid;
4060
- const get$3 = getComponentUid;
4061
- const fromEvent = getComponentUidFromEvent;
4062
-
4063
4070
  const AriaOwns = 'aria-owns';
4064
4071
  const AriaLabelledBy = 'aria-labelledby';
4065
4072
  const AriaDescribedBy = 'aria-describedby';
@@ -4436,8 +4443,8 @@ const showControlled = ({
4436
4443
  showMenu(x, y, width, height, items, level);
4437
4444
  const $Menu = state$5.$$Menus.at(-1);
4438
4445
  if ($Parent && $Menu) {
4439
- const uid = get$3($Parent);
4440
- set$5($Menu, uid);
4446
+ const uid = get$7($Parent);
4447
+ set$8($Menu, uid);
4441
4448
  }
4442
4449
  // TODO menu should not necessarily know about parent (titleBarMenuBar)
4443
4450
  // it should be the other way around
@@ -5495,7 +5502,7 @@ const ViewletActivityBar = {
5495
5502
  const executeViewletCommand$1 = 'Viewlet.executeViewletCommand';
5496
5503
  const send = (method, uid, ...args) => {
5497
5504
  if (method === executeViewletCommand$1) {
5498
- const rpc = get$9(uid);
5505
+ const rpc = get$6(uid);
5499
5506
  if (rpc) {
5500
5507
  rpc.send(method, uid, ...args);
5501
5508
  return;
@@ -5690,8 +5697,8 @@ const applyUidWorkaround = element => {
5690
5697
  if (!editor) {
5691
5698
  throw new Error('no editor found');
5692
5699
  }
5693
- const editorUid = get$3(editor);
5694
- set$5(element, editorUid);
5700
+ const editorUid = get$7(editor);
5701
+ set$8(element, editorUid);
5695
5702
  };
5696
5703
 
5697
5704
  const startTracking$1 = ($Target, pointerId, handlePointerMove, handlePointerUp) => {
@@ -7664,7 +7671,7 @@ const handleClickAction$1 = target => {
7664
7671
  console.info('[panel] action command not found');
7665
7672
  return;
7666
7673
  }
7667
- const childUid = get$3(target);
7674
+ const childUid = get$7(target);
7668
7675
  handleClickAction$2(childUid, index, command);
7669
7676
  };
7670
7677
  const handleHeaderClick$1 = event => {
@@ -7790,7 +7797,7 @@ const setActionsDom$1 = (state, actions, childUid) => {
7790
7797
  const {
7791
7798
  $PanelActions
7792
7799
  } = state;
7793
- const instance = get$8(childUid);
7800
+ const instance = get$9(childUid);
7794
7801
  if (!instance) {
7795
7802
  throw new Error(`child instance not found`);
7796
7803
  }
@@ -8222,7 +8229,7 @@ const handleMouseDown$1 = event => {
8222
8229
  if (!terminal) {
8223
8230
  return;
8224
8231
  }
8225
- const terminalUid = get$3(terminal);
8232
+ const terminalUid = get$7(terminal);
8226
8233
  if (!terminalUid) {
8227
8234
  return;
8228
8235
  }
@@ -8526,7 +8533,7 @@ const addMenu = ($$Menus, change, uid) => {
8526
8533
  const menu = change[1];
8527
8534
  const dom = change[2];
8528
8535
  const $Menu = create$Menu();
8529
- set$5($Menu, uid);
8536
+ set$8($Menu, uid);
8530
8537
  $Menu.onmouseover = handleMenuMouseOver;
8531
8538
  $Menu.onclick = handleMenuClick;
8532
8539
  const {
@@ -8871,12 +8878,12 @@ const create$2 = (id, uid = id) => {
8871
8878
  if (!module) {
8872
8879
  throw new Error(`module not found: ${id}`);
8873
8880
  }
8874
- const existing = get$8(id);
8881
+ const existing = get$9(id);
8875
8882
  if (existing?.state.$Viewlet.isConnected) {
8876
8883
  existing.state.$Viewlet.remove();
8877
8884
  }
8878
8885
  const instanceState = module.create();
8879
- set$5(instanceState.$Viewlet, uid);
8886
+ set$8(instanceState.$Viewlet, uid);
8880
8887
  if (module.attachEvents) {
8881
8888
  module.attachEvents(instanceState);
8882
8889
  }
@@ -8893,14 +8900,14 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcI
8893
8900
  if (!module) {
8894
8901
  throw new Error(`module not found: ${id}`);
8895
8902
  }
8896
- const existing = get$8(id);
8903
+ const existing = get$9(id);
8897
8904
  if (existing?.state.$Viewlet.isConnected) {
8898
8905
  existing.state.$Viewlet.remove();
8899
8906
  }
8900
8907
  const instanceState = {
8901
8908
  $Viewlet: document.createElement('div')
8902
8909
  };
8903
- set$5(instanceState.$Viewlet, uid);
8910
+ set$8(instanceState.$Viewlet, uid);
8904
8911
  registerView(uid, directEventRpcId);
8905
8912
  set$a(uid, {
8906
8913
  factory: module,
@@ -8925,7 +8932,7 @@ const loadModule = async id => {
8925
8932
  };
8926
8933
  const invoke = (viewletId, method, ...args) => {
8927
8934
  string(method);
8928
- const instance = get$8(viewletId);
8935
+ const instance = get$9(viewletId);
8929
8936
  if (!instance?.factory) {
8930
8937
  if (viewletId && method !== 'setActionsDom') {
8931
8938
  warn$1(`cannot execute ${method} viewlet instance ${viewletId} not found`);
@@ -8943,7 +8950,7 @@ const focus$1 = viewletId => {
8943
8950
  // eslint-disable-next-line no-console
8944
8951
  console.trace(`focus ${viewletId}`);
8945
8952
  }
8946
- const instance = get$8(viewletId);
8953
+ const instance = get$9(viewletId);
8947
8954
  if (instance.factory?.setFocused) {
8948
8955
  instance.factory.setFocused(instance.state, true);
8949
8956
  } else if (instance?.factory?.focus) {
@@ -8959,7 +8966,7 @@ const focusElementByName = (viewletId, name) => {
8959
8966
  // eslint-disable-next-line no-console
8960
8967
  console.trace(`focusByName ${viewletId} ${name}`);
8961
8968
  }
8962
- const instance = get$8(viewletId);
8969
+ const instance = get$9(viewletId);
8963
8970
  if (!instance) {
8964
8971
  return;
8965
8972
  }
@@ -8974,7 +8981,7 @@ const focusElementByName = (viewletId, name) => {
8974
8981
  };
8975
8982
  const setElementProperty = (viewletId, name, key, value) => {
8976
8983
  const selector = `[name="${name}"]`;
8977
- const instance = get$8(viewletId);
8984
+ const instance = get$9(viewletId);
8978
8985
  if (!instance) {
8979
8986
  return;
8980
8987
  }
@@ -9003,7 +9010,7 @@ const setCheckboxValue = (viewletId, name, value) => {
9003
9010
  };
9004
9011
  const setSelectionByName = (viewletId, name, start, end) => {
9005
9012
  const selector = `[name="${name}"]`;
9006
- const instance = get$8(viewletId);
9013
+ const instance = get$9(viewletId);
9007
9014
  if (!instance) {
9008
9015
  return;
9009
9016
  }
@@ -9018,14 +9025,14 @@ const setSelectionByName = (viewletId, name, start, end) => {
9018
9025
  $Element.selectionEnd = end;
9019
9026
  };
9020
9027
  const setUid = (viewletId, uid) => {
9021
- const instance = get$8(viewletId);
9028
+ const instance = get$9(viewletId);
9022
9029
  if (!instance) {
9023
9030
  return;
9024
9031
  }
9025
9032
  const {
9026
9033
  $Viewlet
9027
9034
  } = instance.state;
9028
- set$5($Viewlet, uid);
9035
+ set$8($Viewlet, uid);
9029
9036
  };
9030
9037
  const focusCallback = {
9031
9038
  id: 0,
@@ -9036,7 +9043,7 @@ const resetFocusCallback = () => {
9036
9043
  focusCallback.selector = '';
9037
9044
  };
9038
9045
  const focusSelector = (viewletId, selector) => {
9039
- const instance = get$8(viewletId);
9046
+ const instance = get$9(viewletId);
9040
9047
  if (!instance) {
9041
9048
  return;
9042
9049
  }
@@ -9068,7 +9075,7 @@ const focusSelectorAfterRender = (viewletId, selector) => {
9068
9075
  * @deprecated
9069
9076
  */
9070
9077
  const refresh = (viewletId, viewletContext) => {
9071
- const instance = get$8(viewletId);
9078
+ const instance = get$9(viewletId);
9072
9079
  if (instance) {
9073
9080
  instance.factory.refresh(instance.state, viewletContext);
9074
9081
  } else {
@@ -9087,7 +9094,7 @@ const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
9087
9094
  if (isSpecial(viewletId)) {
9088
9095
  $Placeholder.id = viewletId;
9089
9096
  }
9090
- const parentInstance = get$8(parentId);
9097
+ const parentInstance = get$9(parentId);
9091
9098
  const $Parent = parentInstance.state.$Viewlet;
9092
9099
  $Parent.append($Placeholder);
9093
9100
  set$a(viewletId, {
@@ -9103,7 +9110,7 @@ const getDragData = () => {
9103
9110
  return getCurrent();
9104
9111
  };
9105
9112
  const setDom = (viewletId, dom) => {
9106
- const instance = get$8(viewletId);
9113
+ const instance = get$9(viewletId);
9107
9114
  if (!instance) {
9108
9115
  return;
9109
9116
  }
@@ -9116,7 +9123,7 @@ const setDom = (viewletId, dom) => {
9116
9123
  renderInto($Viewlet, dom, Events);
9117
9124
  };
9118
9125
  const setDom2 = (viewletId, dom) => {
9119
- const instance = get$8(viewletId);
9126
+ const instance = get$9(viewletId);
9120
9127
  if (!instance) {
9121
9128
  return;
9122
9129
  }
@@ -9129,14 +9136,14 @@ const setDom2 = (viewletId, dom) => {
9129
9136
  let uid;
9130
9137
  if ($Viewlet) {
9131
9138
  try {
9132
- uid = get$3($Viewlet);
9139
+ uid = get$7($Viewlet);
9133
9140
  } catch {}
9134
9141
  }
9135
9142
  // TODO optimize rendering with virtual DOM diffing
9136
9143
  const $NewViewlet = rememberFocus($Viewlet, dom, Events, viewletId);
9137
9144
  if (uid) {
9138
9145
  // @ts-ignore
9139
- set$5($NewViewlet, uid);
9146
+ set$8($NewViewlet, uid);
9140
9147
  }
9141
9148
  set$a(viewletId, {
9142
9149
  ...instance,
@@ -9147,7 +9154,7 @@ const setDom2 = (viewletId, dom) => {
9147
9154
  });
9148
9155
  };
9149
9156
  const setPatches = (uid, patches) => {
9150
- const instance = get$8(uid);
9157
+ const instance = get$9(uid);
9151
9158
  if (!instance) {
9152
9159
  return;
9153
9160
  }
@@ -9219,7 +9226,7 @@ const dispose$3 = id => {
9219
9226
  try {
9220
9227
  number(id);
9221
9228
  unregisterView(id);
9222
- const instance = get$8(id);
9229
+ const instance = get$9(id);
9223
9230
  if (!instance) {
9224
9231
  warn$1(`viewlet instance ${id} not found and cannot be disposed`);
9225
9232
  return;
@@ -9238,7 +9245,7 @@ const dispose$3 = id => {
9238
9245
  };
9239
9246
  const handleError$1 = (id, parentId, message) => {
9240
9247
  info(`[viewlet-error] ${id}: ${message}`);
9241
- const instance = get$8(id);
9248
+ const instance = get$9(id);
9242
9249
  if (instance?.state.$Viewlet.isConnected) {
9243
9250
  instance.state.$Viewlet.remove();
9244
9251
  }
@@ -9250,7 +9257,7 @@ const handleError$1 = (id, parentId, message) => {
9250
9257
  instance.state.$Viewlet.textContent = String(message);
9251
9258
  }
9252
9259
  // TODO error should bubble up to until highest possible component
9253
- const parentInstance = get$8(parentId);
9260
+ const parentInstance = get$9(parentId);
9254
9261
  if (parentInstance?.factory?.handleError) {
9255
9262
  parentInstance.factory.handleError(instance.state, message);
9256
9263
  }
@@ -9264,9 +9271,9 @@ const appendViewlet = (parentId, childId, focus) => {
9264
9271
  // TODO
9265
9272
  return;
9266
9273
  }
9267
- const parentInstanceState = get$8(parentId); // TODO must ensure that parent is already created
9274
+ const parentInstanceState = get$9(parentId); // TODO must ensure that parent is already created
9268
9275
  const parentModule = parentInstanceState.factory;
9269
- const childInstance = get$8(childId);
9276
+ const childInstance = get$9(childId);
9270
9277
  if (!childInstance) {
9271
9278
  throw new Error(`child instance ${childId} must be defined to be appended to parent ${parentId}`);
9272
9279
  }
@@ -9290,7 +9297,7 @@ const prependChild = ($Parent, $Child) => {
9290
9297
  const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9291
9298
  for (let i = childIndex - 1; i >= 0; i--) {
9292
9299
  const beforeId = referenceNodes[i];
9293
- const beforeInstance = get$8(beforeId);
9300
+ const beforeInstance = get$9(beforeId);
9294
9301
  if (beforeInstance) {
9295
9302
  const $ReferenceNode = beforeInstance.state.$Viewlet;
9296
9303
  $ReferenceNode.after($Child);
@@ -9302,7 +9309,7 @@ const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9302
9309
  const appendBeforeNextReference = (referenceNodes, childIndex, $Child) => {
9303
9310
  for (let i = childIndex + 1; i < referenceNodes.length; i++) {
9304
9311
  const afterId = referenceNodes[i];
9305
- const afterInstance = get$8(afterId);
9312
+ const afterInstance = get$9(afterId);
9306
9313
  if (afterInstance) {
9307
9314
  const $ReferenceNode = afterInstance.state.$Viewlet;
9308
9315
  $ReferenceNode.before($Child);
@@ -9332,12 +9339,12 @@ const appendWithReferenceNodes = ($Parent, $Child, childId, referenceNodes) => {
9332
9339
  const append = (parentId, childId, referenceNodes) => {
9333
9340
  number(parentId);
9334
9341
  number(childId);
9335
- const parentInstance = get$8(parentId);
9342
+ const parentInstance = get$9(parentId);
9336
9343
  if (!parentInstance) {
9337
9344
  throw new Error(`cannot append child: instance ${parentId} not found`);
9338
9345
  }
9339
9346
  const $Parent = parentInstance.state.$Viewlet;
9340
- const childInstance = get$8(childId);
9347
+ const childInstance = get$9(childId);
9341
9348
  if (!childInstance) {
9342
9349
  throw new Error(`cannot append child: child instance not found ${childId}`);
9343
9350
  }
@@ -9356,11 +9363,11 @@ const append = (parentId, childId, referenceNodes) => {
9356
9363
  applyLateFocusMaybe();
9357
9364
  };
9358
9365
  const replaceChildren = (parentId, childIds) => {
9359
- const parentInstance = get$8(parentId);
9366
+ const parentInstance = get$9(parentId);
9360
9367
  const $Parent = parentInstance.state.$Viewlet;
9361
9368
  const $Fragment = document.createDocumentFragment();
9362
9369
  for (const childId of childIds) {
9363
- const childInstance = get$8(childId);
9370
+ const childInstance = get$9(childId);
9364
9371
  const $Child = childInstance.state.$Viewlet;
9365
9372
  $Fragment.append($Child);
9366
9373
  }
@@ -9375,7 +9382,7 @@ const applyLateFocusMaybe = () => {
9375
9382
  selector
9376
9383
  } = focusCallback;
9377
9384
  resetFocusCallback();
9378
- const instance = get$8(id);
9385
+ const instance = get$9(id);
9379
9386
  if (instance) {
9380
9387
  const {
9381
9388
  $Viewlet
@@ -9388,7 +9395,7 @@ const applyLateFocusMaybe = () => {
9388
9395
  };
9389
9396
  const appendToBody = childId => {
9390
9397
  const $Parent = document.body;
9391
- const childInstance = get$8(childId);
9398
+ const childInstance = get$9(childId);
9392
9399
  const $Child = childInstance.state.$Viewlet;
9393
9400
  $Parent.append($Child);
9394
9401
  applyLateFocusMaybe();
@@ -9401,7 +9408,7 @@ const executeCommands = commands => {
9401
9408
  }
9402
9409
  };
9403
9410
  const show = id => {
9404
- const instance = get$8(id);
9411
+ const instance = get$9(id);
9405
9412
  const $Viewlet = instance.state.$Viewlet;
9406
9413
  const $Workbench = document.getElementById('Workbench');
9407
9414
  // @ts-expect-error
@@ -9411,7 +9418,7 @@ const show = id => {
9411
9418
  }
9412
9419
  };
9413
9420
  const setBounds$1 = (id, left, top, width, height) => {
9414
- const instance = get$8(id);
9421
+ const instance = get$9(id);
9415
9422
  if (!instance) {
9416
9423
  return;
9417
9424
  }
@@ -9419,7 +9426,7 @@ const setBounds$1 = (id, left, top, width, height) => {
9419
9426
  setBounds$a($Viewlet, left, top, width, height);
9420
9427
  };
9421
9428
  const setProperty = (id, selector, property, value) => {
9422
- const instance = get$8(id);
9429
+ const instance = get$9(id);
9423
9430
  if (!instance) {
9424
9431
  return;
9425
9432
  }
@@ -9691,7 +9698,7 @@ const queryAudio = (uid, elementLocator) => {
9691
9698
  // @ts-ignore
9692
9699
  return remoteAudio;
9693
9700
  }
9694
- const $Viewlet = get$8(uid);
9701
+ const $Viewlet = get$9(uid);
9695
9702
  const remoteAudio = $Viewlet.querySelector(elementLocator);
9696
9703
  if (!remoteAudio) {
9697
9704
  console.error('[webrtc] audio element not found');
@@ -9865,9 +9872,10 @@ const commandMap = {
9865
9872
  'Css.addCssStyleSheet': addCssStyleSheet,
9866
9873
  'Css.getSelectionText': getSelectionText,
9867
9874
  'Developer.showState': showState,
9875
+ 'DirectView.getFocusedUid': getFocusedViewUid,
9868
9876
  'DirectView.getUid': getViewUid,
9869
9877
  'Download.downloadFile': downloadFile,
9870
- 'FileHandles.get': get$6,
9878
+ 'FileHandles.get': get$5,
9871
9879
  'FilePicker.showDirectoryPicker': showDirectoryPicker,
9872
9880
  'FilePicker.showFilePicker': showFilePicker,
9873
9881
  'FilePicker.showSaveFilePicker': showSaveFilePicker,
@@ -10260,7 +10268,7 @@ const hydrate$1 = async () => {
10260
10268
  } = new MessageChannel();
10261
10269
  // TODO only launch port and send to renderer worker
10262
10270
  const promise = launchEditorWorker(port1);
10263
- set$7('Editor Worker', port2);
10271
+ set$6('Editor Worker', port2);
10264
10272
  const result = await promise;
10265
10273
  if (isError(result)) {
10266
10274
  remove$2('Editor Worker');
@@ -10296,7 +10304,7 @@ const hydrate = async () => {
10296
10304
  } = new MessageChannel();
10297
10305
  // TODO only launch port and send to renderer worker
10298
10306
  const promise = launchSyntaxHighlightingWorker(port1);
10299
- set$7('Syntax Highlighting Worker', port2);
10307
+ set$6('Syntax Highlighting Worker', port2);
10300
10308
  const result = await promise;
10301
10309
  if (isError(result)) {
10302
10310
  remove$2('Syntax Highlighting Worker');
@@ -10467,6 +10475,18 @@ const flushPendingData = state => {
10467
10475
  }
10468
10476
  pendingData.length = 0;
10469
10477
  };
10478
+ const focusIfConnected = state => {
10479
+ const {
10480
+ $Viewlet,
10481
+ pendingFocus,
10482
+ terminal
10483
+ } = state;
10484
+ if (!pendingFocus || !terminal || !$Viewlet.isConnected) {
10485
+ return;
10486
+ }
10487
+ state.pendingFocus = false;
10488
+ terminal.focus();
10489
+ };
10470
10490
  const mountTerminal = async (state, uid) => {
10471
10491
  const {
10472
10492
  fitAddon,
@@ -10491,6 +10511,7 @@ const mountTerminal = async (state, uid) => {
10491
10511
  terminal.open(state.$Viewlet);
10492
10512
  const resizeObserver = new ResizeObserver(() => {
10493
10513
  fitAddon.fit();
10514
+ focusIfConnected(state);
10494
10515
  });
10495
10516
  resizeObserver.observe(state.$Viewlet);
10496
10517
  state.fitAddon = fitAddon;
@@ -10499,10 +10520,7 @@ const mountTerminal = async (state, uid) => {
10499
10520
  state.disposables = [inputDisposable, resizeDisposable];
10500
10521
  fitAddon.fit();
10501
10522
  flushPendingData(state);
10502
- if (state.pendingFocus) {
10503
- state.pendingFocus = false;
10504
- terminal.focus();
10505
- }
10523
+ focusIfConnected(state);
10506
10524
  };
10507
10525
  const create = () => {
10508
10526
  const $Viewlet = document.createElement('div');
@@ -10546,7 +10564,7 @@ const focus = state => {
10546
10564
  const {
10547
10565
  terminal
10548
10566
  } = state;
10549
- if (!terminal) {
10567
+ if (!terminal || !state.$Viewlet.isConnected) {
10550
10568
  state.pendingFocus = true;
10551
10569
  return;
10552
10570
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.35.0",
3
+ "version": "30.36.1",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"