@lvce-editor/renderer-process 30.33.5 → 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
  }
@@ -8662,7 +8656,7 @@ const ViewletTitleBarTitle = {
8662
8656
  };
8663
8657
 
8664
8658
  const handleVideoError$1 = (code, message) => {
8665
- send('Video.handleVideoError', code, message);
8659
+ send$1('Video.handleVideoError', code, message);
8666
8660
  };
8667
8661
 
8668
8662
  const handleVideoError = event => {
@@ -8763,7 +8757,7 @@ const setPort$1 = (state, portId, origin) => {
8763
8757
  });
8764
8758
  };
8765
8759
  const setPosition = (state, id, x, y, width, height) => {
8766
- const $Iframe = get(id);
8760
+ const $Iframe = get$1(id);
8767
8761
  if (!$Iframe) {
8768
8762
  return;
8769
8763
  }
@@ -8848,7 +8842,7 @@ const create$2 = (id, uid = id) => {
8848
8842
  if (!module) {
8849
8843
  throw new Error(`module not found: ${id}`);
8850
8844
  }
8851
- const existing = get$8(id);
8845
+ const existing = get$9(id);
8852
8846
  if (existing?.state.$Viewlet.isConnected) {
8853
8847
  existing.state.$Viewlet.remove();
8854
8848
  }
@@ -8862,7 +8856,7 @@ const create$2 = (id, uid = id) => {
8862
8856
  state: instanceState
8863
8857
  });
8864
8858
  };
8865
- const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8859
+ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcId) => {
8866
8860
  let module = state$1.modules[id];
8867
8861
  if (hasFunctionalEvents) {
8868
8862
  module ||= {};
@@ -8870,7 +8864,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8870
8864
  if (!module) {
8871
8865
  throw new Error(`module not found: ${id}`);
8872
8866
  }
8873
- const existing = get$8(id);
8867
+ const existing = get$9(id);
8874
8868
  if (existing?.state.$Viewlet.isConnected) {
8875
8869
  existing.state.$Viewlet.remove();
8876
8870
  }
@@ -8878,6 +8872,7 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents) => {
8878
8872
  $Viewlet: document.createElement('div')
8879
8873
  };
8880
8874
  set$5(instanceState.$Viewlet, uid);
8875
+ registerView(uid, directEventRpcId);
8881
8876
  set$a(uid, {
8882
8877
  factory: module,
8883
8878
  state: instanceState
@@ -8901,7 +8896,7 @@ const loadModule = async id => {
8901
8896
  };
8902
8897
  const invoke = (viewletId, method, ...args) => {
8903
8898
  string(method);
8904
- const instance = get$8(viewletId);
8899
+ const instance = get$9(viewletId);
8905
8900
  if (!instance?.factory) {
8906
8901
  if (viewletId && method !== 'setActionsDom') {
8907
8902
  warn$1(`cannot execute ${method} viewlet instance ${viewletId} not found`);
@@ -8919,7 +8914,7 @@ const focus$1 = viewletId => {
8919
8914
  // eslint-disable-next-line no-console
8920
8915
  console.trace(`focus ${viewletId}`);
8921
8916
  }
8922
- const instance = get$8(viewletId);
8917
+ const instance = get$9(viewletId);
8923
8918
  if (instance.factory?.setFocused) {
8924
8919
  instance.factory.setFocused(instance.state, true);
8925
8920
  } else if (instance?.factory?.focus) {
@@ -8935,7 +8930,7 @@ const focusElementByName = (viewletId, name) => {
8935
8930
  // eslint-disable-next-line no-console
8936
8931
  console.trace(`focusByName ${viewletId} ${name}`);
8937
8932
  }
8938
- const instance = get$8(viewletId);
8933
+ const instance = get$9(viewletId);
8939
8934
  if (!instance) {
8940
8935
  return;
8941
8936
  }
@@ -8950,7 +8945,7 @@ const focusElementByName = (viewletId, name) => {
8950
8945
  };
8951
8946
  const setElementProperty = (viewletId, name, key, value) => {
8952
8947
  const selector = `[name="${name}"]`;
8953
- const instance = get$8(viewletId);
8948
+ const instance = get$9(viewletId);
8954
8949
  if (!instance) {
8955
8950
  return;
8956
8951
  }
@@ -8979,7 +8974,7 @@ const setCheckboxValue = (viewletId, name, value) => {
8979
8974
  };
8980
8975
  const setSelectionByName = (viewletId, name, start, end) => {
8981
8976
  const selector = `[name="${name}"]`;
8982
- const instance = get$8(viewletId);
8977
+ const instance = get$9(viewletId);
8983
8978
  if (!instance) {
8984
8979
  return;
8985
8980
  }
@@ -8994,7 +8989,7 @@ const setSelectionByName = (viewletId, name, start, end) => {
8994
8989
  $Element.selectionEnd = end;
8995
8990
  };
8996
8991
  const setUid = (viewletId, uid) => {
8997
- const instance = get$8(viewletId);
8992
+ const instance = get$9(viewletId);
8998
8993
  if (!instance) {
8999
8994
  return;
9000
8995
  }
@@ -9012,7 +9007,7 @@ const resetFocusCallback = () => {
9012
9007
  focusCallback.selector = '';
9013
9008
  };
9014
9009
  const focusSelector = (viewletId, selector) => {
9015
- const instance = get$8(viewletId);
9010
+ const instance = get$9(viewletId);
9016
9011
  if (!instance) {
9017
9012
  return;
9018
9013
  }
@@ -9044,7 +9039,7 @@ const focusSelectorAfterRender = (viewletId, selector) => {
9044
9039
  * @deprecated
9045
9040
  */
9046
9041
  const refresh = (viewletId, viewletContext) => {
9047
- const instance = get$8(viewletId);
9042
+ const instance = get$9(viewletId);
9048
9043
  if (instance) {
9049
9044
  instance.factory.refresh(instance.state, viewletContext);
9050
9045
  } else {
@@ -9063,7 +9058,7 @@ const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
9063
9058
  if (isSpecial(viewletId)) {
9064
9059
  $Placeholder.id = viewletId;
9065
9060
  }
9066
- const parentInstance = get$8(parentId);
9061
+ const parentInstance = get$9(parentId);
9067
9062
  const $Parent = parentInstance.state.$Viewlet;
9068
9063
  $Parent.append($Placeholder);
9069
9064
  set$a(viewletId, {
@@ -9079,7 +9074,7 @@ const getDragData = () => {
9079
9074
  return getCurrent();
9080
9075
  };
9081
9076
  const setDom = (viewletId, dom) => {
9082
- const instance = get$8(viewletId);
9077
+ const instance = get$9(viewletId);
9083
9078
  if (!instance) {
9084
9079
  return;
9085
9080
  }
@@ -9092,7 +9087,7 @@ const setDom = (viewletId, dom) => {
9092
9087
  renderInto($Viewlet, dom, Events);
9093
9088
  };
9094
9089
  const setDom2 = (viewletId, dom) => {
9095
- const instance = get$8(viewletId);
9090
+ const instance = get$9(viewletId);
9096
9091
  if (!instance) {
9097
9092
  return;
9098
9093
  }
@@ -9105,7 +9100,7 @@ const setDom2 = (viewletId, dom) => {
9105
9100
  let uid;
9106
9101
  if ($Viewlet) {
9107
9102
  try {
9108
- uid = get$3($Viewlet);
9103
+ uid = get$4($Viewlet);
9109
9104
  } catch {}
9110
9105
  }
9111
9106
  // TODO optimize rendering with virtual DOM diffing
@@ -9123,7 +9118,7 @@ const setDom2 = (viewletId, dom) => {
9123
9118
  });
9124
9119
  };
9125
9120
  const setPatches = (uid, patches) => {
9126
- const instance = get$8(uid);
9121
+ const instance = get$9(uid);
9127
9122
  if (!instance) {
9128
9123
  return;
9129
9124
  }
@@ -9194,7 +9189,8 @@ const commitPending = (uid, transactionId) => {
9194
9189
  const dispose$3 = id => {
9195
9190
  try {
9196
9191
  number(id);
9197
- const instance = get$8(id);
9192
+ unregisterView(id);
9193
+ const instance = get$9(id);
9198
9194
  if (!instance) {
9199
9195
  warn$1(`viewlet instance ${id} not found and cannot be disposed`);
9200
9196
  return;
@@ -9213,7 +9209,7 @@ const dispose$3 = id => {
9213
9209
  };
9214
9210
  const handleError$1 = (id, parentId, message) => {
9215
9211
  info(`[viewlet-error] ${id}: ${message}`);
9216
- const instance = get$8(id);
9212
+ const instance = get$9(id);
9217
9213
  if (instance?.state.$Viewlet.isConnected) {
9218
9214
  instance.state.$Viewlet.remove();
9219
9215
  }
@@ -9225,7 +9221,7 @@ const handleError$1 = (id, parentId, message) => {
9225
9221
  instance.state.$Viewlet.textContent = String(message);
9226
9222
  }
9227
9223
  // TODO error should bubble up to until highest possible component
9228
- const parentInstance = get$8(parentId);
9224
+ const parentInstance = get$9(parentId);
9229
9225
  if (parentInstance?.factory?.handleError) {
9230
9226
  parentInstance.factory.handleError(instance.state, message);
9231
9227
  }
@@ -9239,9 +9235,9 @@ const appendViewlet = (parentId, childId, focus) => {
9239
9235
  // TODO
9240
9236
  return;
9241
9237
  }
9242
- 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
9243
9239
  const parentModule = parentInstanceState.factory;
9244
- const childInstance = get$8(childId);
9240
+ const childInstance = get$9(childId);
9245
9241
  if (!childInstance) {
9246
9242
  throw new Error(`child instance ${childId} must be defined to be appended to parent ${parentId}`);
9247
9243
  }
@@ -9265,7 +9261,7 @@ const prependChild = ($Parent, $Child) => {
9265
9261
  const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9266
9262
  for (let i = childIndex - 1; i >= 0; i--) {
9267
9263
  const beforeId = referenceNodes[i];
9268
- const beforeInstance = get$8(beforeId);
9264
+ const beforeInstance = get$9(beforeId);
9269
9265
  if (beforeInstance) {
9270
9266
  const $ReferenceNode = beforeInstance.state.$Viewlet;
9271
9267
  $ReferenceNode.after($Child);
@@ -9277,7 +9273,7 @@ const appendAfterPreviousReference = (referenceNodes, childIndex, $Child) => {
9277
9273
  const appendBeforeNextReference = (referenceNodes, childIndex, $Child) => {
9278
9274
  for (let i = childIndex + 1; i < referenceNodes.length; i++) {
9279
9275
  const afterId = referenceNodes[i];
9280
- const afterInstance = get$8(afterId);
9276
+ const afterInstance = get$9(afterId);
9281
9277
  if (afterInstance) {
9282
9278
  const $ReferenceNode = afterInstance.state.$Viewlet;
9283
9279
  $ReferenceNode.before($Child);
@@ -9307,12 +9303,12 @@ const appendWithReferenceNodes = ($Parent, $Child, childId, referenceNodes) => {
9307
9303
  const append = (parentId, childId, referenceNodes) => {
9308
9304
  number(parentId);
9309
9305
  number(childId);
9310
- const parentInstance = get$8(parentId);
9306
+ const parentInstance = get$9(parentId);
9311
9307
  if (!parentInstance) {
9312
9308
  throw new Error(`cannot append child: instance ${parentId} not found`);
9313
9309
  }
9314
9310
  const $Parent = parentInstance.state.$Viewlet;
9315
- const childInstance = get$8(childId);
9311
+ const childInstance = get$9(childId);
9316
9312
  if (!childInstance) {
9317
9313
  throw new Error(`cannot append child: child instance not found ${childId}`);
9318
9314
  }
@@ -9331,11 +9327,11 @@ const append = (parentId, childId, referenceNodes) => {
9331
9327
  applyLateFocusMaybe();
9332
9328
  };
9333
9329
  const replaceChildren = (parentId, childIds) => {
9334
- const parentInstance = get$8(parentId);
9330
+ const parentInstance = get$9(parentId);
9335
9331
  const $Parent = parentInstance.state.$Viewlet;
9336
9332
  const $Fragment = document.createDocumentFragment();
9337
9333
  for (const childId of childIds) {
9338
- const childInstance = get$8(childId);
9334
+ const childInstance = get$9(childId);
9339
9335
  const $Child = childInstance.state.$Viewlet;
9340
9336
  $Fragment.append($Child);
9341
9337
  }
@@ -9350,7 +9346,7 @@ const applyLateFocusMaybe = () => {
9350
9346
  selector
9351
9347
  } = focusCallback;
9352
9348
  resetFocusCallback();
9353
- const instance = get$8(id);
9349
+ const instance = get$9(id);
9354
9350
  if (instance) {
9355
9351
  const {
9356
9352
  $Viewlet
@@ -9363,7 +9359,7 @@ const applyLateFocusMaybe = () => {
9363
9359
  };
9364
9360
  const appendToBody = childId => {
9365
9361
  const $Parent = document.body;
9366
- const childInstance = get$8(childId);
9362
+ const childInstance = get$9(childId);
9367
9363
  const $Child = childInstance.state.$Viewlet;
9368
9364
  $Parent.append($Child);
9369
9365
  applyLateFocusMaybe();
@@ -9376,7 +9372,7 @@ const executeCommands = commands => {
9376
9372
  }
9377
9373
  };
9378
9374
  const show = id => {
9379
- const instance = get$8(id);
9375
+ const instance = get$9(id);
9380
9376
  const $Viewlet = instance.state.$Viewlet;
9381
9377
  const $Workbench = document.getElementById('Workbench');
9382
9378
  // @ts-expect-error
@@ -9386,7 +9382,7 @@ const show = id => {
9386
9382
  }
9387
9383
  };
9388
9384
  const setBounds$1 = (id, left, top, width, height) => {
9389
- const instance = get$8(id);
9385
+ const instance = get$9(id);
9390
9386
  if (!instance) {
9391
9387
  return;
9392
9388
  }
@@ -9394,7 +9390,7 @@ const setBounds$1 = (id, left, top, width, height) => {
9394
9390
  setBounds$a($Viewlet, left, top, width, height);
9395
9391
  };
9396
9392
  const setProperty = (id, selector, property, value) => {
9397
- const instance = get$8(id);
9393
+ const instance = get$9(id);
9398
9394
  if (!instance) {
9399
9395
  return;
9400
9396
  }
@@ -9502,13 +9498,13 @@ const toggleFullScreen = () => {
9502
9498
  return document.documentElement.requestFullscreen();
9503
9499
  };
9504
9500
  const handleFullScreenChange = isFullScreen => {
9505
- send('Layout.handleFullScreenChange', isFullScreen);
9501
+ send$1('Layout.handleFullScreenChange', isFullScreen);
9506
9502
  };
9507
9503
  const handleDocumentFullScreenChange = () => {
9508
9504
  handleFullScreenChange(Boolean(document.fullscreenElement));
9509
9505
  };
9510
9506
  const sendVisibilityChangeHint = () => {
9511
- send(/* SaveState.handleVisibilityChange */'SaveState.handleVisibilityChange', /* visibilityState */'hidden');
9507
+ send$1(/* SaveState.handleVisibilityChange */'SaveState.handleVisibilityChange', /* visibilityState */'hidden');
9512
9508
  };
9513
9509
  const handleBeforeUnload = () => {
9514
9510
  sendVisibilityChangeHint();
@@ -9559,13 +9555,16 @@ const getFilePathElectron = async file => {
9559
9555
  return filePath;
9560
9556
  };
9561
9557
 
9562
- const handleMessagePort = async port => {
9563
- await create$x({
9558
+ const handleMessagePort = async (port, rpcId) => {
9559
+ const rpc = await create$x({
9564
9560
  commandMap: {
9565
9561
  'Viewlet.queueCommands': queueCommands
9566
9562
  },
9567
9563
  messagePort: port
9568
9564
  });
9565
+ if (rpcId !== undefined) {
9566
+ registerRpc(rpcId, rpc);
9567
+ }
9569
9568
  };
9570
9569
 
9571
9570
  const set = ($Iframe, permissionPolicy) => {
@@ -9603,12 +9602,12 @@ const create$1 = async (uid, src, sandbox, csp, credentialless, permissionPolicy
9603
9602
  // TODO make make waitForFrameToLoad a separate command
9604
9603
  };
9605
9604
  const loadOnly = async uid => {
9606
- const $Iframe = get(uid);
9605
+ const $Iframe = get$1(uid);
9607
9606
  const promise = waitForFrameToLoad($Iframe);
9608
9607
  await promise;
9609
9608
  };
9610
9609
  const appendOnly = async uid => {
9611
- const $Iframe = get(uid);
9610
+ const $Iframe = get$1(uid);
9612
9611
  const parent = document.getElementById('Workbench');
9613
9612
  parent.append($Iframe);
9614
9613
  };
@@ -9617,7 +9616,7 @@ const appendOnly = async uid => {
9617
9616
  * @deprecated use loadOnly and appendOnly instead
9618
9617
  */
9619
9618
  const load = async uid => {
9620
- const $Iframe = get(uid);
9619
+ const $Iframe = get$1(uid);
9621
9620
  const promise = waitForFrameToLoad($Iframe);
9622
9621
  const parent = document.getElementById('Workbench');
9623
9622
  parent.append($Iframe);
@@ -9626,7 +9625,7 @@ const load = async uid => {
9626
9625
 
9627
9626
  // TODO rename to sendMessage
9628
9627
  const setPort = (uid, port, origin, portType) => {
9629
- const $Iframe = get(uid);
9628
+ const $Iframe = get$1(uid);
9630
9629
  // TODO use jsonrpc invoke
9631
9630
  const {
9632
9631
  contentWindow
@@ -9641,7 +9640,7 @@ const setPort = (uid, port, origin, portType) => {
9641
9640
  }, origin, [port]);
9642
9641
  };
9643
9642
  const dispose$2 = uid => {
9644
- const $Iframe = get(uid);
9643
+ const $Iframe = get$1(uid);
9645
9644
  $Iframe.remove();
9646
9645
  remove(uid);
9647
9646
  };
@@ -9659,7 +9658,7 @@ const queryAudio = (uid, elementLocator) => {
9659
9658
  // @ts-ignore
9660
9659
  return remoteAudio;
9661
9660
  }
9662
- const $Viewlet = get$8(uid);
9661
+ const $Viewlet = get$9(uid);
9663
9662
  const remoteAudio = $Viewlet.querySelector(elementLocator);
9664
9663
  if (!remoteAudio) {
9665
9664
  console.error('[webrtc] audio element not found');
@@ -9834,7 +9833,7 @@ const commandMap = {
9834
9833
  'Css.getSelectionText': getSelectionText,
9835
9834
  'Developer.showState': showState,
9836
9835
  'Download.downloadFile': downloadFile,
9837
- 'FileHandles.get': get$6,
9836
+ 'FileHandles.get': get$7,
9838
9837
  'FilePicker.showDirectoryPicker': showDirectoryPicker,
9839
9838
  'FilePicker.showFilePicker': showFilePicker,
9840
9839
  'FilePicker.showSaveFilePicker': showSaveFilePicker,
@@ -10294,7 +10293,7 @@ const handleFocusIn = event => {
10294
10293
  };
10295
10294
  const handleBlur = event => {
10296
10295
  const uid = fromEvent(event);
10297
- executeViewletCommand(uid, 'EditorRename.handleBlur');
10296
+ executeViewletCommand$1(uid, 'EditorRename.handleBlur');
10298
10297
  };
10299
10298
  const handleInput = event => {
10300
10299
  const {
@@ -10304,7 +10303,7 @@ const handleInput = event => {
10304
10303
  value
10305
10304
  } = target;
10306
10305
  const uid = fromEvent(event);
10307
- executeViewletCommand(uid, 'EditorRename.handleInput', value);
10306
+ executeViewletCommand$1(uid, 'EditorRename.handleInput', value);
10308
10307
  };
10309
10308
 
10310
10309
  const ViewletEditorRenameEvents = {
@@ -10339,6 +10338,23 @@ const ViewletEditorRename = {
10339
10338
  setBounds
10340
10339
  };
10341
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
+
10342
10358
  const handleContentSecurityPolicyViolation = event => {
10343
10359
  };
10344
10360
 
@@ -10394,7 +10410,7 @@ const main = async () => {
10394
10410
  await handleError(launchWorkersResult.error, true);
10395
10411
  return;
10396
10412
  }
10397
- setIpc(RendererWorker);
10413
+ setIpc(ViewletEventRouter);
10398
10414
  };
10399
10415
 
10400
10416
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.33.5",
3
+ "version": "30.34.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"