@lvce-editor/renderer-process 30.33.4 → 30.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.
@@ -125,7 +125,7 @@ const state$d = {
125
125
  const set$b = (id, sheet) => {
126
126
  state$d.styleSheets[id] = sheet;
127
127
  };
128
- const get$9 = id => {
128
+ const get$a = id => {
129
129
  return state$d.styleSheets[id];
130
130
  };
131
131
  const setText$2 = (id, text) => {
@@ -140,7 +140,7 @@ const remove$5 = id => {
140
140
  };
141
141
 
142
142
  const addCssStyleSheet = (id, text) => {
143
- const existing = get$9(id);
143
+ const existing = get$a(id);
144
144
  if (existing) {
145
145
  existing.replaceSync(text);
146
146
  setText$2(id, text);
@@ -153,7 +153,7 @@ const addCssStyleSheet = (id, text) => {
153
153
  document.adoptedStyleSheets.push(sheet);
154
154
  };
155
155
  const patchCssStyleSheet = (id, start, deleteCount, replacement) => {
156
- const sheet = get$9(id);
156
+ const sheet = get$a(id);
157
157
  const text = getText(id);
158
158
  if (!sheet || typeof text !== 'string') {
159
159
  throw new Error(`stylesheet ${id} must be initialized before it can be patched`);
@@ -172,7 +172,7 @@ const patchCssStyleSheet = (id, start, deleteCount, replacement) => {
172
172
  setText$2(id, newText);
173
173
  };
174
174
  const removeCssStyleSheet = id => {
175
- const sheet = get$9(id);
175
+ const sheet = get$a(id);
176
176
  if (!sheet) {
177
177
  return;
178
178
  }
@@ -1277,7 +1277,7 @@ const {
1277
1277
  } = ElementTagMap;
1278
1278
 
1279
1279
  const instances = Object.create(null);
1280
- const get$8 = viewletId => {
1280
+ const get$9 = viewletId => {
1281
1281
  return instances[viewletId];
1282
1282
  };
1283
1283
  const set$a = (viewletId, instance) => {
@@ -1312,7 +1312,7 @@ const has$1 = listener => {
1312
1312
  const set$9 = (listener, value) => {
1313
1313
  cache.set(listener, value);
1314
1314
  };
1315
- const get$7 = listener => {
1315
+ const get$8 = listener => {
1316
1316
  return cache.get(listener);
1317
1317
  };
1318
1318
 
@@ -1334,7 +1334,7 @@ const getWrappedListener = (listener, returnValue) => {
1334
1334
  nameAnonymousFunction$1(wrapped, listener.name);
1335
1335
  set$9(listener, wrapped);
1336
1336
  }
1337
- return get$7(listener);
1337
+ return get$8(listener);
1338
1338
  };
1339
1339
 
1340
1340
  const attachedListeners = new WeakMap();
@@ -1568,7 +1568,7 @@ const renderDomElement = (element, eventMap, newEventMap) => {
1568
1568
  return $Element;
1569
1569
  };
1570
1570
  const renderReferenceNode = (element, eventMap, newEventMap) => {
1571
- const instance = get$8(element.uid);
1571
+ const instance = get$9(element.uid);
1572
1572
  if (!instance || !instance.state) {
1573
1573
  return document.createTextNode('Reference node not found');
1574
1574
  }
@@ -1714,7 +1714,7 @@ const handleNavigateSibling = (state, patch, $Element, patchIndex) => {
1714
1714
  return true;
1715
1715
  };
1716
1716
  const handleSetReferenceNodeUid = (state, patch) => {
1717
- const instance = get$8(patch.uid);
1717
+ const instance = get$9(patch.uid);
1718
1718
  if (!instance || !instance.state) {
1719
1719
  console.error('Cannot set reference node uid: instance not found', {
1720
1720
  uid: patch.uid
@@ -1930,7 +1930,7 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
1930
1930
  }
1931
1931
  };
1932
1932
 
1933
- const get$6 = ids => {
1933
+ const get$7 = ids => {
1934
1934
  return getFileHandles$1(ids);
1935
1935
  };
1936
1936
 
@@ -2857,7 +2857,7 @@ const execute = (command, ...args) => {
2857
2857
 
2858
2858
  const Two$1 = '2.0';
2859
2859
  const callbacks = Object.create(null);
2860
- const get$5 = id => {
2860
+ const get$6 = id => {
2861
2861
  return callbacks[id];
2862
2862
  };
2863
2863
  const remove$4 = id => {
@@ -3047,7 +3047,7 @@ const warn = (...args) => {
3047
3047
  console.warn(...args);
3048
3048
  };
3049
3049
  const resolve = (id, response) => {
3050
- const fn = get$5(id);
3050
+ const fn = get$6(id);
3051
3051
  if (!fn) {
3052
3052
  console.log(response);
3053
3053
  warn(`callback ${id} may already be disposed`);
@@ -3523,7 +3523,7 @@ const ipcs = Object.create(null);
3523
3523
  const set$7 = (name, ipc) => {
3524
3524
  ipcs[name] = ipc;
3525
3525
  };
3526
- const get$4 = name => {
3526
+ const get$5 = name => {
3527
3527
  return ipcs[name];
3528
3528
  };
3529
3529
  const remove$2 = name => {
@@ -3736,47 +3736,17 @@ const hydrate$2 = async () => {
3736
3736
  listen(result.value);
3737
3737
  return success(undefined);
3738
3738
  };
3739
-
3740
- // TODO needed?
3741
- const dispose$j = () => {
3742
- if (state$9.rpc) {
3743
- state$9.rpc.dispose();
3744
- }
3745
- };
3746
- const send = (method, ...params) => {
3739
+ const send$1 = (method, ...params) => {
3747
3740
  record('sent', method, params);
3748
3741
  // @ts-ignore
3749
3742
  state$9.rpc.send(method, ...params);
3750
3743
  };
3751
- const invoke$1 = (method, ...params) => {
3752
- record('sent', method, params);
3753
- // @ts-ignore
3754
- return state$9.rpc.invoke(method, ...params);
3755
- };
3756
- const sendAndTransfer = message => {
3757
- if (Array.isArray(message) && typeof message[0] === 'string') {
3758
- record('sent', message[0], message.slice(1));
3759
- }
3760
- // @ts-expect-error
3761
- state$9.rpc.sendAndTransfer(message);
3762
- };
3763
3744
  const invokeAndTransfer = (method, ...params) => {
3764
3745
  record('sent', method, params);
3765
3746
  // @ts-ignore
3766
3747
  return state$9.rpc.invokeAndTransfer(method, ...params);
3767
3748
  };
3768
3749
 
3769
- const RendererWorker = {
3770
- __proto__: null,
3771
- dispose: dispose$j,
3772
- hydrate: hydrate$2,
3773
- invoke: invoke$1,
3774
- invokeAndTransfer,
3775
- send,
3776
- sendAndTransfer,
3777
- state: state$9
3778
- };
3779
-
3780
3750
  const create$u = async ({
3781
3751
  method,
3782
3752
  ...options
@@ -3787,7 +3757,7 @@ const create$u = async ({
3787
3757
  }
3788
3758
  // TODO rename method
3789
3759
  // TODO avoid cyclic dependency
3790
- const port = get$4(options.name);
3760
+ const port = get$5(options.name);
3791
3761
  remove$2(options.name);
3792
3762
  await invokeAndTransfer('Transferrable.transfer', options.id, port);
3793
3763
  return;
@@ -3980,7 +3950,7 @@ const handleNotificationClick = event => {
3980
3950
  switch ($Target.className) {
3981
3951
  case 'NotificationOption':
3982
3952
  const index = findIndex$1($Target);
3983
- send(/* Notification.handleClick */'Notification.handleClick', /* index */index);
3953
+ send$1(/* Notification.handleClick */'Notification.handleClick', /* index */index);
3984
3954
  break;
3985
3955
  }
3986
3956
  };
@@ -4051,7 +4021,7 @@ const create$BackDrop = () => {
4051
4021
  };
4052
4022
 
4053
4023
  const set$5 = setComponentUid;
4054
- const get$3 = getComponentUid;
4024
+ const get$4 = getComponentUid;
4055
4025
  const fromEvent = getComponentUidFromEvent;
4056
4026
 
4057
4027
  const AriaOwns = 'aria-owns';
@@ -4236,7 +4206,7 @@ const handleMouseDown$4 = event => {
4236
4206
  }
4237
4207
  preventDefault(event);
4238
4208
  const level = getLevel($Menu);
4239
- send(/* Menu.handleClick */'Menu.selectIndex', /* level */level, /* index */index);
4209
+ send$1(/* Menu.handleClick */'Menu.selectIndex', /* level */level, /* index */index);
4240
4210
  };
4241
4211
 
4242
4212
  // const handleKeyDown = (event) => {
@@ -4281,7 +4251,7 @@ const handleMouseEnter = event => {
4281
4251
  return;
4282
4252
  }
4283
4253
  const level = getLevel($Menu);
4284
- send(/* Menu.handleMouseEnter */'Menu.handleMouseEnter', /* level */level, /* index */index, /* x */clientX, /* y */clientY, /* timeStamp */timeStamp);
4254
+ send$1(/* Menu.handleMouseEnter */'Menu.handleMouseEnter', /* level */level, /* index */index, /* x */clientX, /* y */clientY, /* timeStamp */timeStamp);
4285
4255
  };
4286
4256
  const handleMouseLeave = event => {
4287
4257
  const $RelatedTarget = event.relatedTarget;
@@ -4343,7 +4313,7 @@ const focusIndex = (level, oldFocusedIndex, newFocusedIndex) => {
4343
4313
  const handleBackDropMouseDown = event => {
4344
4314
  preventDefault(event);
4345
4315
  stopPropagation(event);
4346
- send(/* Menu.hide */'Menu.hide');
4316
+ send$1(/* Menu.hide */'Menu.hide');
4347
4317
  if (state$5.$BackDrop) {
4348
4318
  remove$1(state$5.$BackDrop);
4349
4319
  state$5.$BackDrop = undefined;
@@ -4378,7 +4348,7 @@ const showMenu = (x, y, width, height, items, level, parentIndex = -1, dom = [],
4378
4348
  append$1($Menu);
4379
4349
  if (level === 0) {
4380
4350
  focus$e($Menu);
4381
- send('Focus.setFocus', FocusMenu);
4351
+ send$1('Focus.setFocus', FocusMenu);
4382
4352
  }
4383
4353
  };
4384
4354
  const hideSubmenu = level => {
@@ -4430,7 +4400,7 @@ const showControlled = ({
4430
4400
  showMenu(x, y, width, height, items, level);
4431
4401
  const $Menu = state$5.$$Menus.at(-1);
4432
4402
  if ($Parent && $Menu) {
4433
- const uid = get$3($Parent);
4403
+ const uid = get$4($Parent);
4434
4404
  set$5($Menu, uid);
4435
4405
  }
4436
4406
  // TODO menu should not necessarily know about parent (titleBarMenuBar)
@@ -4517,7 +4487,7 @@ const prompt = (message, defaultValue) => {
4517
4487
  };
4518
4488
 
4519
4489
  const screenCaptures = Object.create(null);
4520
- const get$2 = id => {
4490
+ const get$3 = id => {
4521
4491
  return screenCaptures[id];
4522
4492
  };
4523
4493
  const set$4 = (id, captureStream) => {
@@ -4583,9 +4553,9 @@ class VError extends Error {
4583
4553
  }
4584
4554
  }
4585
4555
 
4586
- const get$1 = id => {
4556
+ const get$2 = id => {
4587
4557
  number(id);
4588
- return get$2(id);
4558
+ return get$3(id);
4589
4559
  };
4590
4560
  const start = async (id, options) => {
4591
4561
  try {
@@ -5160,7 +5130,7 @@ const createAction = action => {
5160
5130
  $action.style.border = 'none';
5161
5131
  $action.style.borderRadius = '5px';
5162
5132
  $action.addEventListener('click', () => {
5163
- send(action.command);
5133
+ send$1(action.command);
5164
5134
  });
5165
5135
  return $action;
5166
5136
  };
@@ -5242,7 +5212,7 @@ const webViews = Object.create(null);
5242
5212
  const set$3 = (id, webView) => {
5243
5213
  webViews[id] = webView;
5244
5214
  };
5245
- const get = id => {
5215
+ const get$1 = id => {
5246
5216
  return webViews[id];
5247
5217
  };
5248
5218
  const remove = id => {
@@ -5262,7 +5232,7 @@ const acquire = objectId => {
5262
5232
  // TODO transfer port directly instead of storing
5263
5233
  // it for a short time in state
5264
5234
  const transferToWebView = objectId => {
5265
- const $Iframe = get(1);
5235
+ const $Iframe = get$1(1);
5266
5236
  if (!$Iframe) {
5267
5237
  throw new Error(`webview not found`);
5268
5238
  }
@@ -5291,6 +5261,30 @@ const attachEvents$7 = ($Node, eventMap) => {
5291
5261
  }
5292
5262
  };
5293
5263
 
5264
+ const rpcs = new Map();
5265
+ const viewRpcIds = new Map();
5266
+ const get = uid => {
5267
+ const rpcId = viewRpcIds.get(uid);
5268
+ return rpcId === undefined ? undefined : rpcs.get(rpcId);
5269
+ };
5270
+ const registerRpc = (rpcId, rpc) => {
5271
+ const previous = rpcs.get(rpcId);
5272
+ if (previous && previous !== rpc) {
5273
+ previous.dispose();
5274
+ }
5275
+ rpcs.set(rpcId, rpc);
5276
+ };
5277
+ const registerView = (uid, rpcId) => {
5278
+ if (rpcId === undefined) {
5279
+ viewRpcIds.delete(uid);
5280
+ return;
5281
+ }
5282
+ viewRpcIds.set(uid, rpcId);
5283
+ };
5284
+ const unregisterView = uid => {
5285
+ viewRpcIds.delete(uid);
5286
+ };
5287
+
5294
5288
  const state$4 = {
5295
5289
  currentDragInfo: undefined
5296
5290
  };
@@ -5486,9 +5480,9 @@ const ViewletActivityBar = {
5486
5480
  Events: Events$6
5487
5481
  };
5488
5482
 
5489
- const executeViewletCommand = (uid, command, ...args) => {
5483
+ const executeViewletCommand$1 = (uid, command, ...args) => {
5490
5484
  number(uid);
5491
- send('Viewlet.executeViewletCommand', uid, command, ...args);
5485
+ send$1('Viewlet.executeViewletCommand', uid, command, ...args);
5492
5486
  };
5493
5487
 
5494
5488
  const nameAnonymousFunction = (fn, name) => {
@@ -5499,7 +5493,7 @@ const nameAnonymousFunction = (fn, name) => {
5499
5493
 
5500
5494
  const forwardViewletCommand = name => {
5501
5495
  const fn = (uid, ...args) => {
5502
- executeViewletCommand(uid, name, ...args);
5496
+ executeViewletCommand$1(uid, name, ...args);
5503
5497
  };
5504
5498
  nameAnonymousFunction(fn, name);
5505
5499
  return fn;
@@ -5667,7 +5661,7 @@ const applyUidWorkaround = element => {
5667
5661
  if (!editor) {
5668
5662
  throw new Error('no editor found');
5669
5663
  }
5670
- const editorUid = get$3(editor);
5664
+ const editorUid = get$4(editor);
5671
5665
  set$5(element, editorUid);
5672
5666
  };
5673
5667
 
@@ -5690,7 +5684,7 @@ const create$o = (pointerDown, pointerMove, pointerUp) => {
5690
5684
  return;
5691
5685
  }
5692
5686
  const uid = fromEvent(event);
5693
- send('Viewlet.executeViewletCommand', uid, ...message);
5687
+ send$1('Viewlet.executeViewletCommand', uid, ...message);
5694
5688
  };
5695
5689
  const handlePointerMove = event => {
5696
5690
  shared(pointerMove, event);
@@ -5867,7 +5861,7 @@ const ViewletDefineKeyBinding = {
5867
5861
  };
5868
5862
 
5869
5863
  const handleClick$5 = index => {
5870
- send(/* Dialog.handleClick */'Dialog.handleClick', /* index */index);
5864
+ send$1(/* Dialog.handleClick */'Dialog.handleClick', /* index */index);
5871
5865
  };
5872
5866
 
5873
5867
  const handleClick$4 = event => {
@@ -6142,7 +6136,7 @@ const sendToIframe = (contentWindow, message, origin, transfer) => {
6142
6136
  const handleLoad$1 = event => {
6143
6137
  // eslint-disable-next-line no-console
6144
6138
  console.log(event.target.src);
6145
- send('E2eTests.handleLoad');
6139
+ send$1('E2eTests.handleLoad');
6146
6140
  };
6147
6141
  const setIframe$2 = (state, src, sandbox = []) => {
6148
6142
  if (!src) {
@@ -6315,7 +6309,7 @@ const handleWheel$1 = event => {
6315
6309
  deltaY
6316
6310
  } = event;
6317
6311
  const uid = fromEvent(event);
6318
- executeViewletCommand(uid, 'EditorCompletion.handleWheel', deltaMode, deltaY);
6312
+ executeViewletCommand$1(uid, 'EditorCompletion.handleWheel', deltaMode, deltaY);
6319
6313
  };
6320
6314
 
6321
6315
  const Small$1 = 1;
@@ -7151,9 +7145,9 @@ const handleLocationsMouseDown = event => {
7151
7145
  const $Target = event.target;
7152
7146
  if ($Target.classList.contains('TreeItem')) {
7153
7147
  const index = getNodeIndex($Target);
7154
- send(/* ViewletLocations.selectIndex */'Locations.selectIndex', /* index */index);
7148
+ send$1(/* ViewletLocations.selectIndex */'Locations.selectIndex', /* index */index);
7155
7149
  } else if ($Target.classList.contains('LocationList')) {
7156
- send(/* ViewletLocations.focusIndex */'Locations.focusIndex', /* index */-1);
7150
+ send$1(/* ViewletLocations.focusIndex */'Locations.focusIndex', /* index */-1);
7157
7151
  }
7158
7152
  };
7159
7153
 
@@ -7191,7 +7185,7 @@ const focus$8 = state => {
7191
7185
  } = state;
7192
7186
  $Locations.classList.add('FocusOutline');
7193
7187
  $Locations.focus();
7194
- send('Focus.setFocus', FocusLocationList);
7188
+ send$1('Focus.setFocus', FocusLocationList);
7195
7189
  };
7196
7190
 
7197
7191
  const ViewletImplementations = {
@@ -7344,7 +7338,7 @@ const isMatchingKeyBinding = (identifiers, identifier) => {
7344
7338
  };
7345
7339
 
7346
7340
  const handleMatchingKeyBinding = identifier => {
7347
- send(/* KeyBindings.handleKeyBinding */'KeyBindings.handleKeyBinding', /* keyBinding */identifier);
7341
+ send$1(/* KeyBindings.handleKeyBinding */'KeyBindings.handleKeyBinding', /* keyBinding */identifier);
7348
7342
  };
7349
7343
  const isNativeButtonActivation = event => {
7350
7344
  const {
@@ -7376,27 +7370,27 @@ const handleKeyDown$1 = event => {
7376
7370
  const handleKeyUp$1 = event => {};
7377
7371
 
7378
7372
  const handleSashPointerMove$1 = (x, y) => {
7379
- send('Layout.handleSashPointerMove', x, y);
7373
+ send$1('Layout.handleSashPointerMove', x, y);
7380
7374
  };
7381
7375
  const handleSashPointerDown$1 = id => {
7382
- send('Layout.handleSashPointerDown', id);
7376
+ send$1('Layout.handleSashPointerDown', id);
7383
7377
  };
7384
7378
 
7385
7379
  // TODO send component uid
7386
7380
  const handleSashPointerUp = id => {
7387
- send('Layout.handleSashPointerUp', id);
7381
+ send$1('Layout.handleSashPointerUp', id);
7388
7382
  };
7389
7383
  const handleSashDoubleClick$1 = id => {
7390
- send('Layout.handleSashDoubleClick', id);
7384
+ send$1('Layout.handleSashDoubleClick', id);
7391
7385
  };
7392
7386
  const handleResize$1 = (width, height) => {
7393
- send('Layout.handleResize', width, height);
7387
+ send$1('Layout.handleResize', width, height);
7394
7388
  };
7395
7389
  const handleFocus$3 = () => {
7396
- send('Layout.handleFocus');
7390
+ send$1('Layout.handleFocus');
7397
7391
  };
7398
7392
  const handleBlur$3 = () => {
7399
- send('Layout.handleBlur');
7393
+ send$1('Layout.handleBlur');
7400
7394
  };
7401
7395
 
7402
7396
  const handleSashPointerMove = event => {
@@ -7593,7 +7587,7 @@ const handleError$2 = (state, error) => {
7593
7587
  const focus$7 = state => {
7594
7588
  object(state);
7595
7589
  focus$e(state.$ViewletOutputContent);
7596
- send('Focus.setFocus', FocusOutput);
7590
+ send$1('Focus.setFocus', FocusOutput);
7597
7591
  };
7598
7592
 
7599
7593
  // TODO handle case when output is opened -> find widget is opened -> output is disposed before find widget is ready
@@ -7641,7 +7635,7 @@ const handleClickAction$1 = target => {
7641
7635
  console.info('[panel] action command not found');
7642
7636
  return;
7643
7637
  }
7644
- const childUid = get$3(target);
7638
+ const childUid = get$4(target);
7645
7639
  handleClickAction$2(childUid, index, command);
7646
7640
  };
7647
7641
  const handleHeaderClick$1 = event => {
@@ -7767,7 +7761,7 @@ const setActionsDom$1 = (state, actions, childUid) => {
7767
7761
  const {
7768
7762
  $PanelActions
7769
7763
  } = state;
7770
- const instance = get$8(childUid);
7764
+ const instance = get$9(childUid);
7771
7765
  if (!instance) {
7772
7766
  throw new Error(`child instance not found`);
7773
7767
  }
@@ -7820,7 +7814,7 @@ const setScreenCapture = (state, id) => {
7820
7814
  $Viewlet
7821
7815
  } = state;
7822
7816
  const $Video = document.createElement('video');
7823
- const screenCapture = get$1(id);
7817
+ const screenCapture = get$2(id);
7824
7818
  $Video.srcObject = screenCapture;
7825
7819
  $Video.onloadedmetadata = handleLoadedMetadata;
7826
7820
  $Viewlet.append($Video);
@@ -7924,22 +7918,22 @@ const ViewletSidebar = {
7924
7918
  };
7925
7919
 
7926
7920
  const handleInput$3 = value => {
7927
- send('SimpleBrowser.handleInput', value);
7921
+ send$1('SimpleBrowser.handleInput', value);
7928
7922
  };
7929
7923
  const forward = () => {
7930
- send('SimpleBrowser.forward');
7924
+ send$1('SimpleBrowser.forward');
7931
7925
  };
7932
7926
  const backward = () => {
7933
- send('SimpleBrowser.backward');
7927
+ send$1('SimpleBrowser.backward');
7934
7928
  };
7935
7929
  const reload$1 = () => {
7936
- send('SimpleBrowser.reload');
7930
+ send$1('SimpleBrowser.reload');
7937
7931
  };
7938
7932
  const cancelNavigation = () => {
7939
- send('SimpleBrowser.cancelNavigation');
7933
+ send$1('SimpleBrowser.cancelNavigation');
7940
7934
  };
7941
7935
  const openExternal = () => {
7942
- send('SimpleBrowser.openExternal');
7936
+ send$1('SimpleBrowser.openExternal');
7943
7937
  };
7944
7938
 
7945
7939
  const handleInput$2 = event => {
@@ -7955,7 +7949,7 @@ const handleFocus$1 = event => {
7955
7949
  const {
7956
7950
  target
7957
7951
  } = event;
7958
- send('Focus.setFocus', FocusSimpleBrowserInput);
7952
+ send$1('Focus.setFocus', FocusSimpleBrowserInput);
7959
7953
  setTimeout(() => {
7960
7954
  target.select();
7961
7955
  });
@@ -8199,7 +8193,7 @@ const handleMouseDown$1 = event => {
8199
8193
  if (!terminal) {
8200
8194
  return;
8201
8195
  }
8202
- const terminalUid = get$3(terminal);
8196
+ const terminalUid = get$4(terminal);
8203
8197
  if (!terminalUid) {
8204
8198
  return;
8205
8199
  }
@@ -8256,10 +8250,15 @@ const handleFocusOut = event => {
8256
8250
  if (relatedTarget && isInsideTitleBarMenu(relatedTarget)) {
8257
8251
  return;
8258
8252
  }
8259
- if (!relatedTarget && target && !target.isConnected && isInsideTitleBarMenu(target)) {
8253
+ const uid = fromEvent(event);
8254
+ if (!relatedTarget && target && isInsideTitleBarMenu(target)) {
8255
+ queueMicrotask(() => {
8256
+ if (target.isConnected) {
8257
+ closeMenu$1(uid);
8258
+ }
8259
+ });
8260
8260
  return;
8261
8261
  }
8262
- const uid = fromEvent(event);
8263
8262
  closeMenu$1(uid);
8264
8263
  };
8265
8264
  const handlePointerOver = event => {
@@ -8657,7 +8656,7 @@ const ViewletTitleBarTitle = {
8657
8656
  };
8658
8657
 
8659
8658
  const handleVideoError$1 = (code, message) => {
8660
- send('Video.handleVideoError', code, message);
8659
+ send$1('Video.handleVideoError', code, message);
8661
8660
  };
8662
8661
 
8663
8662
  const handleVideoError = event => {
@@ -8758,7 +8757,7 @@ const setPort$1 = (state, portId, origin) => {
8758
8757
  });
8759
8758
  };
8760
8759
  const setPosition = (state, id, x, y, width, height) => {
8761
- const $Iframe = get(id);
8760
+ const $Iframe = get$1(id);
8762
8761
  if (!$Iframe) {
8763
8762
  return;
8764
8763
  }
@@ -8843,7 +8842,7 @@ const create$2 = (id, uid = id) => {
8843
8842
  if (!module) {
8844
8843
  throw new Error(`module not found: ${id}`);
8845
8844
  }
8846
- const existing = get$8(id);
8845
+ const existing = get$9(id);
8847
8846
  if (existing?.state.$Viewlet.isConnected) {
8848
8847
  existing.state.$Viewlet.remove();
8849
8848
  }
@@ -8857,7 +8856,7 @@ const create$2 = (id, uid = id) => {
8857
8856
  state: instanceState
8858
8857
  });
8859
8858
  };
8860
- const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8859
+ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcId) => {
8861
8860
  let module = state$1.modules[id];
8862
8861
  if (hasFunctionalEvents) {
8863
8862
  module ||= {};
@@ -8865,7 +8864,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8865
8864
  if (!module) {
8866
8865
  throw new Error(`module not found: ${id}`);
8867
8866
  }
8868
- const existing = get$8(id);
8867
+ const existing = get$9(id);
8869
8868
  if (existing?.state.$Viewlet.isConnected) {
8870
8869
  existing.state.$Viewlet.remove();
8871
8870
  }
@@ -8873,6 +8872,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8873
8872
  $Viewlet: document.createElement('div')
8874
8873
  };
8875
8874
  set$5(instanceState.$Viewlet, uid);
8875
+ registerView(uid, directEventRpcId);
8876
8876
  set$a(uid, {
8877
8877
  factory: module,
8878
8878
  state: instanceState
@@ -8896,7 +8896,7 @@ const loadModule = async id => {
8896
8896
  };
8897
8897
  const invoke = (viewletId, method, ...args) => {
8898
8898
  string(method);
8899
- const instance = get$8(viewletId);
8899
+ const instance = get$9(viewletId);
8900
8900
  if (!instance?.factory) {
8901
8901
  if (viewletId && method !== 'setActionsDom') {
8902
8902
  warn$1(`cannot execute ${method} viewlet instance ${viewletId} not found`);
@@ -8914,7 +8914,7 @@ const focus$1 = viewletId => {
8914
8914
  // eslint-disable-next-line no-console
8915
8915
  console.trace(`focus ${viewletId}`);
8916
8916
  }
8917
- const instance = get$8(viewletId);
8917
+ const instance = get$9(viewletId);
8918
8918
  if (instance.factory?.setFocused) {
8919
8919
  instance.factory.setFocused(instance.state, true);
8920
8920
  } else if (instance?.factory?.focus) {
@@ -8930,7 +8930,7 @@ const focusElementByName = (viewletId, name) => {
8930
8930
  // eslint-disable-next-line no-console
8931
8931
  console.trace(`focusByName ${viewletId} ${name}`);
8932
8932
  }
8933
- const instance = get$8(viewletId);
8933
+ const instance = get$9(viewletId);
8934
8934
  if (!instance) {
8935
8935
  return;
8936
8936
  }
@@ -8945,7 +8945,7 @@ const focusElementByName = (viewletId, name) => {
8945
8945
  };
8946
8946
  const setElementProperty = (viewletId, name, key, value) => {
8947
8947
  const selector = `[name="${name}"]`;
8948
- const instance = get$8(viewletId);
8948
+ const instance = get$9(viewletId);
8949
8949
  if (!instance) {
8950
8950
  return;
8951
8951
  }
@@ -8974,7 +8974,7 @@ const setCheckboxValue = (viewletId, name, value) => {
8974
8974
  };
8975
8975
  const setSelectionByName = (viewletId, name, start, end) => {
8976
8976
  const selector = `[name="${name}"]`;
8977
- const instance = get$8(viewletId);
8977
+ const instance = get$9(viewletId);
8978
8978
  if (!instance) {
8979
8979
  return;
8980
8980
  }
@@ -8989,7 +8989,7 @@ const setSelectionByName = (viewletId, name, start, end) => {
8989
8989
  $Element.selectionEnd = end;
8990
8990
  };
8991
8991
  const setUid = (viewletId, uid) => {
8992
- const instance = get$8(viewletId);
8992
+ const instance = get$9(viewletId);
8993
8993
  if (!instance) {
8994
8994
  return;
8995
8995
  }
@@ -9007,7 +9007,7 @@ const resetFocusCallback = () => {
9007
9007
  focusCallback.selector = '';
9008
9008
  };
9009
9009
  const focusSelector = (viewletId, selector) => {
9010
- const instance = get$8(viewletId);
9010
+ const instance = get$9(viewletId);
9011
9011
  if (!instance) {
9012
9012
  return;
9013
9013
  }
@@ -9039,7 +9039,7 @@ const focusSelectorAfterRender = (viewletId, selector) => {
9039
9039
  * @deprecated
9040
9040
  */
9041
9041
  const refresh = (viewletId, viewletContext) => {
9042
- const instance = get$8(viewletId);
9042
+ const instance = get$9(viewletId);
9043
9043
  if (instance) {
9044
9044
  instance.factory.refresh(instance.state, viewletContext);
9045
9045
  } else {
@@ -9058,7 +9058,7 @@ const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
9058
9058
  if (isSpecial(viewletId)) {
9059
9059
  $Placeholder.id = viewletId;
9060
9060
  }
9061
- const parentInstance = get$8(parentId);
9061
+ const parentInstance = get$9(parentId);
9062
9062
  const $Parent = parentInstance.state.$Viewlet;
9063
9063
  $Parent.append($Placeholder);
9064
9064
  set$a(viewletId, {
@@ -9074,7 +9074,7 @@ const getDragData = () => {
9074
9074
  return getCurrent();
9075
9075
  };
9076
9076
  const setDom = (viewletId, dom) => {
9077
- const instance = get$8(viewletId);
9077
+ const instance = get$9(viewletId);
9078
9078
  if (!instance) {
9079
9079
  return;
9080
9080
  }
@@ -9087,7 +9087,7 @@ const setDom = (viewletId, dom) => {
9087
9087
  renderInto($Viewlet, dom, Events);
9088
9088
  };
9089
9089
  const setDom2 = (viewletId, dom) => {
9090
- const instance = get$8(viewletId);
9090
+ const instance = get$9(viewletId);
9091
9091
  if (!instance) {
9092
9092
  return;
9093
9093
  }
@@ -9100,7 +9100,7 @@ const setDom2 = (viewletId, dom) => {
9100
9100
  let uid;
9101
9101
  if ($Viewlet) {
9102
9102
  try {
9103
- uid = get$3($Viewlet);
9103
+ uid = get$4($Viewlet);
9104
9104
  } catch {}
9105
9105
  }
9106
9106
  // TODO optimize rendering with virtual DOM diffing
@@ -9118,7 +9118,7 @@ const setDom2 = (viewletId, dom) => {
9118
9118
  });
9119
9119
  };
9120
9120
  const setPatches = (uid, patches) => {
9121
- const instance = get$8(uid);
9121
+ const instance = get$9(uid);
9122
9122
  if (!instance) {
9123
9123
  return;
9124
9124
  }
@@ -9189,7 +9189,8 @@ const commitPending = (uid, transactionId) => {
9189
9189
  const dispose$3 = id => {
9190
9190
  try {
9191
9191
  number(id);
9192
- const instance = get$8(id);
9192
+ unregisterView(id);
9193
+ const instance = get$9(id);
9193
9194
  if (!instance) {
9194
9195
  warn$1(`viewlet instance ${id} not found and cannot be disposed`);
9195
9196
  return;
@@ -9208,7 +9209,7 @@ const dispose$3 = id => {
9208
9209
  };
9209
9210
  const handleError$1 = (id, parentId, message) => {
9210
9211
  info(`[viewlet-error] ${id}: ${message}`);
9211
- const instance = get$8(id);
9212
+ const instance = get$9(id);
9212
9213
  if (instance?.state.$Viewlet.isConnected) {
9213
9214
  instance.state.$Viewlet.remove();
9214
9215
  }
@@ -9220,7 +9221,7 @@ const handleError$1 = (id, parentId, message) => {
9220
9221
  instance.state.$Viewlet.textContent = String(message);
9221
9222
  }
9222
9223
  // TODO error should bubble up to until highest possible component
9223
- const parentInstance = get$8(parentId);
9224
+ const parentInstance = get$9(parentId);
9224
9225
  if (parentInstance?.factory?.handleError) {
9225
9226
  parentInstance.factory.handleError(instance.state, message);
9226
9227
  }
@@ -9234,9 +9235,9 @@ const appendViewlet = (parentId, childId, focus) => {
9234
9235
  // TODO
9235
9236
  return;
9236
9237
  }
9237
- const parentInstanceState = get$8(parentId); // TODO must ensure that parent is already created
9238
+ const parentInstanceState = get$9(parentId); // TODO must ensure that parent is already created
9238
9239
  const parentModule = parentInstanceState.factory;
9239
- const childInstance = get$8(childId);
9240
+ const childInstance = get$9(childId);
9240
9241
  if (!childInstance) {
9241
9242
  throw new Error(`child instance ${childId} must be defined to be appended to parent ${parentId}`);
9242
9243
  }
@@ -9260,7 +9261,7 @@ const prependChild = ($Parent, $Child) => {
9260
9261
  const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9261
9262
  for (let i = childIndex - 1; i >= 0; i--) {
9262
9263
  const beforeId = referenceNodes[i];
9263
- const beforeInstance = get$8(beforeId);
9264
+ const beforeInstance = get$9(beforeId);
9264
9265
  if (beforeInstance) {
9265
9266
  const $ReferenceNode = beforeInstance.state.$Viewlet;
9266
9267
  $ReferenceNode.after($Child);
@@ -9272,7 +9273,7 @@ const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9272
9273
  const appendBeforeNextReference = (referenceNodes, childIndex, $Child) => {
9273
9274
  for (let i = childIndex + 1; i < referenceNodes.length; i++) {
9274
9275
  const afterId = referenceNodes[i];
9275
- const afterInstance = get$8(afterId);
9276
+ const afterInstance = get$9(afterId);
9276
9277
  if (afterInstance) {
9277
9278
  const $ReferenceNode = afterInstance.state.$Viewlet;
9278
9279
  $ReferenceNode.before($Child);
@@ -9302,12 +9303,12 @@ const appendWithReferenceNodes = ($Parent, $Child, childId, referenceNodes) => {
9302
9303
  const append = (parentId, childId, referenceNodes) => {
9303
9304
  number(parentId);
9304
9305
  number(childId);
9305
- const parentInstance = get$8(parentId);
9306
+ const parentInstance = get$9(parentId);
9306
9307
  if (!parentInstance) {
9307
9308
  throw new Error(`cannot append child: instance ${parentId} not found`);
9308
9309
  }
9309
9310
  const $Parent = parentInstance.state.$Viewlet;
9310
- const childInstance = get$8(childId);
9311
+ const childInstance = get$9(childId);
9311
9312
  if (!childInstance) {
9312
9313
  throw new Error(`cannot append child: child instance not found ${childId}`);
9313
9314
  }
@@ -9326,11 +9327,11 @@ const append = (parentId, childId, referenceNodes) => {
9326
9327
  applyLateFocusMaybe();
9327
9328
  };
9328
9329
  const replaceChildren = (parentId, childIds) => {
9329
- const parentInstance = get$8(parentId);
9330
+ const parentInstance = get$9(parentId);
9330
9331
  const $Parent = parentInstance.state.$Viewlet;
9331
9332
  const $Fragment = document.createDocumentFragment();
9332
9333
  for (const childId of childIds) {
9333
- const childInstance = get$8(childId);
9334
+ const childInstance = get$9(childId);
9334
9335
  const $Child = childInstance.state.$Viewlet;
9335
9336
  $Fragment.append($Child);
9336
9337
  }
@@ -9345,7 +9346,7 @@ const applyLateFocusMaybe = () => {
9345
9346
  selector
9346
9347
  } = focusCallback;
9347
9348
  resetFocusCallback();
9348
- const instance = get$8(id);
9349
+ const instance = get$9(id);
9349
9350
  if (instance) {
9350
9351
  const {
9351
9352
  $Viewlet
@@ -9358,7 +9359,7 @@ const applyLateFocusMaybe = () => {
9358
9359
  };
9359
9360
  const appendToBody = childId => {
9360
9361
  const $Parent = document.body;
9361
- const childInstance = get$8(childId);
9362
+ const childInstance = get$9(childId);
9362
9363
  const $Child = childInstance.state.$Viewlet;
9363
9364
  $Parent.append($Child);
9364
9365
  applyLateFocusMaybe();
@@ -9371,7 +9372,7 @@ const executeCommands = commands => {
9371
9372
  }
9372
9373
  };
9373
9374
  const show = id => {
9374
- const instance = get$8(id);
9375
+ const instance = get$9(id);
9375
9376
  const $Viewlet = instance.state.$Viewlet;
9376
9377
  const $Workbench = document.getElementById('Workbench');
9377
9378
  // @ts-expect-error
@@ -9381,7 +9382,7 @@ const show = id => {
9381
9382
  }
9382
9383
  };
9383
9384
  const setBounds$1 = (id, left, top, width, height) => {
9384
- const instance = get$8(id);
9385
+ const instance = get$9(id);
9385
9386
  if (!instance) {
9386
9387
  return;
9387
9388
  }
@@ -9389,7 +9390,7 @@ const setBounds$1 = (id, left, top, width, height) => {
9389
9390
  setBounds$a($Viewlet, left, top, width, height);
9390
9391
  };
9391
9392
  const setProperty = (id, selector, property, value) => {
9392
- const instance = get$8(id);
9393
+ const instance = get$9(id);
9393
9394
  if (!instance) {
9394
9395
  return;
9395
9396
  }
@@ -9497,13 +9498,13 @@ const toggleFullScreen = () => {
9497
9498
  return document.documentElement.requestFullscreen();
9498
9499
  };
9499
9500
  const handleFullScreenChange = isFullScreen => {
9500
- send('Layout.handleFullScreenChange', isFullScreen);
9501
+ send$1('Layout.handleFullScreenChange', isFullScreen);
9501
9502
  };
9502
9503
  const handleDocumentFullScreenChange = () => {
9503
9504
  handleFullScreenChange(Boolean(document.fullscreenElement));
9504
9505
  };
9505
9506
  const sendVisibilityChangeHint = () => {
9506
- send(/* SaveState.handleVisibilityChange */'SaveState.handleVisibilityChange', /* visibilityState */'hidden');
9507
+ send$1(/* SaveState.handleVisibilityChange */'SaveState.handleVisibilityChange', /* visibilityState */'hidden');
9507
9508
  };
9508
9509
  const handleBeforeUnload = () => {
9509
9510
  sendVisibilityChangeHint();
@@ -9554,13 +9555,16 @@ const getFilePathElectron = async file => {
9554
9555
  return filePath;
9555
9556
  };
9556
9557
 
9557
- const handleMessagePort = async port => {
9558
- await create$x({
9558
+ const handleMessagePort = async (port, rpcId) => {
9559
+ const rpc = await create$x({
9559
9560
  commandMap: {
9560
9561
  'Viewlet.queueCommands': queueCommands
9561
9562
  },
9562
9563
  messagePort: port
9563
9564
  });
9565
+ if (rpcId !== undefined) {
9566
+ registerRpc(rpcId, rpc);
9567
+ }
9564
9568
  };
9565
9569
 
9566
9570
  const set = ($Iframe, permissionPolicy) => {
@@ -9598,12 +9602,12 @@ const create$1 = async (uid, src, sandbox, csp, credentialless, permissionPolicy
9598
9602
  // TODO make make waitForFrameToLoad a separate command
9599
9603
  };
9600
9604
  const loadOnly = async uid => {
9601
- const $Iframe = get(uid);
9605
+ const $Iframe = get$1(uid);
9602
9606
  const promise = waitForFrameToLoad($Iframe);
9603
9607
  await promise;
9604
9608
  };
9605
9609
  const appendOnly = async uid => {
9606
- const $Iframe = get(uid);
9610
+ const $Iframe = get$1(uid);
9607
9611
  const parent = document.getElementById('Workbench');
9608
9612
  parent.append($Iframe);
9609
9613
  };
@@ -9612,7 +9616,7 @@ const appendOnly = async uid => {
9612
9616
  * @deprecated use loadOnly and appendOnly instead
9613
9617
  */
9614
9618
  const load = async uid => {
9615
- const $Iframe = get(uid);
9619
+ const $Iframe = get$1(uid);
9616
9620
  const promise = waitForFrameToLoad($Iframe);
9617
9621
  const parent = document.getElementById('Workbench');
9618
9622
  parent.append($Iframe);
@@ -9621,7 +9625,7 @@ const load = async uid => {
9621
9625
 
9622
9626
  // TODO rename to sendMessage
9623
9627
  const setPort = (uid, port, origin, portType) => {
9624
- const $Iframe = get(uid);
9628
+ const $Iframe = get$1(uid);
9625
9629
  // TODO use jsonrpc invoke
9626
9630
  const {
9627
9631
  contentWindow
@@ -9636,7 +9640,7 @@ const setPort = (uid, port, origin, portType) => {
9636
9640
  }, origin, [port]);
9637
9641
  };
9638
9642
  const dispose$2 = uid => {
9639
- const $Iframe = get(uid);
9643
+ const $Iframe = get$1(uid);
9640
9644
  $Iframe.remove();
9641
9645
  remove(uid);
9642
9646
  };
@@ -9654,7 +9658,7 @@ const queryAudio = (uid, elementLocator) => {
9654
9658
  // @ts-ignore
9655
9659
  return remoteAudio;
9656
9660
  }
9657
- const $Viewlet = get$8(uid);
9661
+ const $Viewlet = get$9(uid);
9658
9662
  const remoteAudio = $Viewlet.querySelector(elementLocator);
9659
9663
  if (!remoteAudio) {
9660
9664
  console.error('[webrtc] audio element not found');
@@ -9829,7 +9833,7 @@ const commandMap = {
9829
9833
  'Css.getSelectionText': getSelectionText,
9830
9834
  'Developer.showState': showState,
9831
9835
  'Download.downloadFile': downloadFile,
9832
- 'FileHandles.get': get$6,
9836
+ 'FileHandles.get': get$7,
9833
9837
  'FilePicker.showDirectoryPicker': showDirectoryPicker,
9834
9838
  'FilePicker.showFilePicker': showFilePicker,
9835
9839
  'FilePicker.showSaveFilePicker': showSaveFilePicker,
@@ -10289,7 +10293,7 @@ const handleFocusIn = event => {
10289
10293
  };
10290
10294
  const handleBlur = event => {
10291
10295
  const uid = fromEvent(event);
10292
- executeViewletCommand(uid, 'EditorRename.handleBlur');
10296
+ executeViewletCommand$1(uid, 'EditorRename.handleBlur');
10293
10297
  };
10294
10298
  const handleInput = event => {
10295
10299
  const {
@@ -10299,7 +10303,7 @@ const handleInput = event => {
10299
10303
  value
10300
10304
  } = target;
10301
10305
  const uid = fromEvent(event);
10302
- executeViewletCommand(uid, 'EditorRename.handleInput', value);
10306
+ executeViewletCommand$1(uid, 'EditorRename.handleInput', value);
10303
10307
  };
10304
10308
 
10305
10309
  const ViewletEditorRenameEvents = {
@@ -10334,6 +10338,23 @@ const ViewletEditorRename = {
10334
10338
  setBounds
10335
10339
  };
10336
10340
 
10341
+ const executeViewletCommand = 'Viewlet.executeViewletCommand';
10342
+ const send = (method, uid, ...args) => {
10343
+ if (method === executeViewletCommand) {
10344
+ const rpc = get(uid);
10345
+ if (rpc) {
10346
+ rpc.send(method, uid, ...args);
10347
+ return;
10348
+ }
10349
+ }
10350
+ send$1(method, uid, ...args);
10351
+ };
10352
+
10353
+ const ViewletEventRouter = {
10354
+ __proto__: null,
10355
+ send
10356
+ };
10357
+
10337
10358
  const handleContentSecurityPolicyViolation = event => {
10338
10359
  };
10339
10360
 
@@ -10389,7 +10410,7 @@ const main = async () => {
10389
10410
  await handleError(launchWorkersResult.error, true);
10390
10411
  return;
10391
10412
  }
10392
- setIpc(RendererWorker);
10413
+ setIpc(ViewletEventRouter);
10393
10414
  };
10394
10415
 
10395
10416
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.33.4",
3
+ "version": "30.34.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"