@lvce-editor/renderer-process 30.60.3 → 30.62.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.
@@ -1556,7 +1556,7 @@ const launchRendererWorker = async () => {
1556
1556
  };
1557
1557
 
1558
1558
  const selector = 'script.RendererWorkerTrace';
1559
- const state$i = {
1559
+ const state$j = {
1560
1560
  enabled: false,
1561
1561
  entries: []
1562
1562
  };
@@ -1606,14 +1606,14 @@ const isCommand = value => {
1606
1606
  };
1607
1607
  const initialize = search => {
1608
1608
  const searchParams = new URLSearchParams(search);
1609
- state$i.enabled = searchParams.has('traceRendererWorker');
1610
- state$i.entries = [];
1609
+ state$j.enabled = searchParams.has('traceRendererWorker');
1610
+ state$j.entries = [];
1611
1611
  };
1612
1612
  const record = (direction, method, params) => {
1613
- if (!state$i.enabled) {
1613
+ if (!state$j.enabled) {
1614
1614
  return;
1615
1615
  }
1616
- state$i.entries.push({
1616
+ state$j.entries.push({
1617
1617
  direction,
1618
1618
  method,
1619
1619
  params: serialize(params),
@@ -1621,7 +1621,7 @@ const record = (direction, method, params) => {
1621
1621
  });
1622
1622
  };
1623
1623
  const listen$1 = rpc => {
1624
- if (!state$i.enabled) {
1624
+ if (!state$j.enabled) {
1625
1625
  return;
1626
1626
  }
1627
1627
  const ipc = rpc.ipc;
@@ -1636,7 +1636,7 @@ const listen$1 = rpc => {
1636
1636
  });
1637
1637
  };
1638
1638
  const exportToDom = () => {
1639
- if (!state$i.enabled) {
1639
+ if (!state$j.enabled) {
1640
1640
  return;
1641
1641
  }
1642
1642
  const existing = document.querySelector(selector);
@@ -1644,7 +1644,7 @@ const exportToDom = () => {
1644
1644
  script.className = 'RendererWorkerTrace';
1645
1645
  script.type = 'application/json';
1646
1646
  script.textContent = JSON.stringify({
1647
- entries: state$i.entries,
1647
+ entries: state$j.entries,
1648
1648
  version: 1
1649
1649
  });
1650
1650
  if (!existing) {
@@ -1652,42 +1652,42 @@ const exportToDom = () => {
1652
1652
  }
1653
1653
  };
1654
1654
  const scheduleExport = () => {
1655
- if (!state$i.enabled) {
1655
+ if (!state$j.enabled) {
1656
1656
  return;
1657
1657
  }
1658
1658
  queueMicrotask(exportToDom);
1659
1659
  };
1660
1660
 
1661
- const state$h = {
1661
+ const state$i = {
1662
1662
  rpc: undefined
1663
1663
  };
1664
1664
  const hydrate$4 = async () => {
1665
1665
  const result = await launchRendererWorker();
1666
1666
  if (isError(result)) {
1667
- state$h.rpc = undefined;
1667
+ state$i.rpc = undefined;
1668
1668
  return result;
1669
1669
  }
1670
- state$h.rpc = result.value;
1670
+ state$i.rpc = result.value;
1671
1671
  listen$1(result.value);
1672
1672
  return success(undefined);
1673
1673
  };
1674
1674
  const send$1 = (method, ...params) => {
1675
1675
  record('sent', method, params);
1676
1676
  // @ts-ignore
1677
- state$h.rpc.send(method, ...params);
1677
+ state$i.rpc.send(method, ...params);
1678
1678
  };
1679
1679
  const invoke$1 = (method, ...params) => {
1680
1680
  record('sent', method, params);
1681
1681
  // @ts-ignore
1682
- return state$h.rpc.invoke(method, ...params);
1682
+ return state$i.rpc.invoke(method, ...params);
1683
1683
  };
1684
1684
  const invokeAndTransfer = (method, ...params) => {
1685
1685
  record('sent', method, params);
1686
1686
  // @ts-ignore
1687
- return state$h.rpc.invokeAndTransfer(method, ...params);
1687
+ return state$i.rpc.invokeAndTransfer(method, ...params);
1688
1688
  };
1689
1689
 
1690
- const state$g = {
1690
+ const state$h = {
1691
1691
  client: undefined,
1692
1692
  enabled: false,
1693
1693
  lastError: '',
@@ -1697,38 +1697,38 @@ const state$g = {
1697
1697
  const workerUrl = new URL('sessionReplayWorkerMain.js', import.meta.url);
1698
1698
  const reloadMessage = 'Reload the window to start session replay with the complete DOM command history';
1699
1699
  const report = error => {
1700
- state$g.lastError = error instanceof Error ? error.message : String(error);
1701
- state$g.stopObserving?.();
1702
- state$g.stopObserving = undefined;
1703
- console.warn(`Session replay: ${state$g.lastError}`);
1700
+ state$h.lastError = error instanceof Error ? error.message : String(error);
1701
+ state$h.stopObserving?.();
1702
+ state$h.stopObserving = undefined;
1703
+ console.warn(`Session replay: ${state$h.lastError}`);
1704
1704
  };
1705
1705
 
1706
1706
  // Retain snapshot recording for older renderer workers during dependency rollout.
1707
- const configure = async options => {
1708
- state$g.stopObserving?.();
1709
- state$g.stopObserving = undefined;
1710
- state$g.enabled = false;
1711
- if (state$g.client) {
1707
+ const configure$1 = async options => {
1708
+ state$h.stopObserving?.();
1709
+ state$h.stopObserving = undefined;
1710
+ state$h.enabled = false;
1711
+ if (state$h.client) {
1712
1712
  try {
1713
- await state$g.client.invoke('stop');
1713
+ await state$h.client.invoke('stop');
1714
1714
  } catch (error) {
1715
1715
  report(error);
1716
1716
  }
1717
1717
  // Live channels still need their proxy after capture stops.
1718
- if (!state$g.proxy) {
1719
- state$g.client.dispose();
1720
- state$g.client = undefined;
1718
+ if (!state$h.proxy) {
1719
+ state$h.client.dispose();
1720
+ state$h.client = undefined;
1721
1721
  }
1722
1722
  }
1723
1723
  if (!options.local && !options.upload) return '';
1724
- if (state$g.proxy) throw new Error(reloadMessage);
1725
- state$g.lastError = '';
1724
+ if (state$h.proxy) throw new Error(reloadMessage);
1725
+ state$h.lastError = '';
1726
1726
  const client = createClient(workerUrl);
1727
1727
  try {
1728
1728
  const id = await client.invoke('start', options);
1729
- state$g.stopObserving = observe(document, (type, data) => client.invoke('record', type, data), report);
1730
- state$g.client = client;
1731
- state$g.enabled = true;
1729
+ state$h.stopObserving = observe(document, (type, data) => client.invoke('record', type, data), report);
1730
+ state$h.client = client;
1731
+ state$h.enabled = true;
1732
1732
  return id;
1733
1733
  } catch (error) {
1734
1734
  client.dispose();
@@ -1736,7 +1736,7 @@ const configure = async options => {
1736
1736
  }
1737
1737
  };
1738
1738
  const configureProxy = async (options, port) => {
1739
- if (state$g.client || !options.local && !options.upload) {
1739
+ if (state$h.client || !options.local && !options.upload) {
1740
1740
  port.close();
1741
1741
  throw new Error(reloadMessage);
1742
1742
  }
@@ -1749,25 +1749,25 @@ const configureProxy = async (options, port) => {
1749
1749
  commandMap: commandMapRef,
1750
1750
  messagePort: proxyPort
1751
1751
  });
1752
- const original = state$h.rpc;
1753
- state$h.rpc = {
1752
+ const original = state$i.rpc;
1753
+ state$i.rpc = {
1754
1754
  ...rpc,
1755
1755
  async dispose() {
1756
1756
  try {
1757
1757
  await rpc.dispose();
1758
1758
  } finally {
1759
1759
  client.dispose();
1760
- state$g.client = undefined;
1761
- state$g.enabled = false;
1762
- state$g.proxy = false;
1760
+ state$h.client = undefined;
1761
+ state$h.enabled = false;
1762
+ state$h.proxy = false;
1763
1763
  await original?.dispose();
1764
1764
  }
1765
1765
  }
1766
1766
  };
1767
- state$g.client = client;
1768
- state$g.enabled = true;
1769
- state$g.proxy = true;
1770
- state$g.lastError = '';
1767
+ state$h.client = client;
1768
+ state$h.enabled = true;
1769
+ state$h.proxy = true;
1770
+ state$h.lastError = '';
1771
1771
  return id;
1772
1772
  } catch (error) {
1773
1773
  proxyPort?.close();
@@ -1777,21 +1777,21 @@ const configureProxy = async (options, port) => {
1777
1777
  }
1778
1778
  };
1779
1779
  const getSession = async () => {
1780
- if (!state$g.enabled || !state$g.client) throw new Error('Session replay is disabled in settings');
1781
- return state$g.client.invoke('export');
1780
+ if (!state$h.enabled || !state$h.client) throw new Error('Session replay is disabled in settings');
1781
+ return state$h.client.invoke('export');
1782
1782
  };
1783
1783
  const getStatus = async () => {
1784
- if (!state$g.client) return {
1784
+ if (!state$h.client) return {
1785
1785
  enabled: false,
1786
- error: state$g.lastError
1786
+ error: state$h.lastError
1787
1787
  };
1788
1788
  return {
1789
- enabled: state$g.enabled,
1790
- ...(await state$g.client.invoke('status')),
1791
- captureError: state$g.lastError
1789
+ enabled: state$h.enabled,
1790
+ ...(await state$h.client.invoke('status')),
1791
+ captureError: state$h.lastError
1792
1792
  };
1793
1793
  };
1794
- const flush = async () => state$g.client?.invoke('flush');
1794
+ const flush = async () => state$h.client?.invoke('flush');
1795
1795
  const openLocalFile = async () => {
1796
1796
  const input = document.createElement('input');
1797
1797
  input.type = 'file';
@@ -1802,7 +1802,7 @@ const openLocalFile = async () => {
1802
1802
  try {
1803
1803
  if (file.size > 64 * 1024 * 1024) throw new Error('Session replay file is too large');
1804
1804
  const session = JSON.parse(await file.text());
1805
- await configure({
1805
+ await configure$1({
1806
1806
  endpoint: '',
1807
1807
  local: false,
1808
1808
  upload: false
@@ -1911,25 +1911,25 @@ const confirm = message => {
1911
1911
  return window.confirm(message);
1912
1912
  };
1913
1913
 
1914
- const state$f = {
1914
+ const state$g = {
1915
1915
  styleSheets: Object.create(null),
1916
1916
  texts: Object.create(null)
1917
1917
  };
1918
1918
  const set$b = (id, sheet) => {
1919
- state$f.styleSheets[id] = sheet;
1919
+ state$g.styleSheets[id] = sheet;
1920
1920
  };
1921
1921
  const get$a = id => {
1922
- return state$f.styleSheets[id];
1922
+ return state$g.styleSheets[id];
1923
1923
  };
1924
1924
  const setText$2 = (id, text) => {
1925
- state$f.texts[id] = text;
1925
+ state$g.texts[id] = text;
1926
1926
  };
1927
1927
  const getText = id => {
1928
- return state$f.texts[id];
1928
+ return state$g.texts[id];
1929
1929
  };
1930
1930
  const remove$4 = id => {
1931
- delete state$f.styleSheets[id];
1932
- delete state$f.texts[id];
1931
+ delete state$g.styleSheets[id];
1932
+ delete state$g.texts[id];
1933
1933
  };
1934
1934
 
1935
1935
  const addCssStyleSheet = (id, text) => {
@@ -2124,7 +2124,7 @@ const createIdGenerator = () => {
2124
2124
  };
2125
2125
  const create$A = createIdGenerator();
2126
2126
 
2127
- const state$e = Object.create(null);
2127
+ const state$f = Object.create(null);
2128
2128
  const retainString = (item, index) => {
2129
2129
  const value = new Promise(resolve => {
2130
2130
  item.getAsString(resolve);
@@ -2175,25 +2175,25 @@ const retainItems = dataTransfer => {
2175
2175
  };
2176
2176
  const addItems = items => {
2177
2177
  const id = create$A();
2178
- state$e[id] = items;
2178
+ state$f[id] = items;
2179
2179
  return id;
2180
2180
  };
2181
2181
  const add$2 = dataTransfer => {
2182
2182
  return addItems(retainItems(dataTransfer));
2183
2183
  };
2184
2184
  const acquire$2 = id => {
2185
- const items = state$e[id];
2185
+ const items = state$f[id];
2186
2186
  if (!items) {
2187
2187
  throw new Error(`Drop data not found: ${id}`);
2188
2188
  }
2189
- delete state$e[id];
2189
+ delete state$f[id];
2190
2190
  return items;
2191
2191
  };
2192
2192
 
2193
- const state$d = Object.create(null);
2193
+ const state$e = Object.create(null);
2194
2194
  const acquire$1 = id => {
2195
- const promise = state$d[id];
2196
- delete state$d[id];
2195
+ const promise = state$e[id];
2196
+ delete state$e[id];
2197
2197
  return promise;
2198
2198
  };
2199
2199
  const getFileHandles = async ids => {
@@ -2203,7 +2203,7 @@ const getFileHandles = async ids => {
2203
2203
  };
2204
2204
  const add$1 = promise => {
2205
2205
  const id = create$A();
2206
- state$d[id] = promise;
2206
+ state$e[id] = promise;
2207
2207
  return id;
2208
2208
  };
2209
2209
  const addFileHandle$1 = fileHandle => {
@@ -2394,14 +2394,14 @@ const getEventListenerArgs = (params, event) => {
2394
2394
  return serialized;
2395
2395
  };
2396
2396
 
2397
- const state$c = {
2397
+ const state$d = {
2398
2398
  ipc: undefined
2399
2399
  };
2400
2400
  const getIpc = () => {
2401
- return state$c.ipc;
2401
+ return state$d.ipc;
2402
2402
  };
2403
2403
  const setIpc = value => {
2404
- state$c.ipc = value;
2404
+ state$d.ipc = value;
2405
2405
  };
2406
2406
 
2407
2407
  const nameAnonymousFunction$1 = (fn, name) => {
@@ -2592,7 +2592,7 @@ const Span = 8;
2592
2592
  const Table = 9;
2593
2593
  const TBody = 10;
2594
2594
  const Td = 11;
2595
- const Text$2 = 12;
2595
+ const Text$3 = 12;
2596
2596
  const Th = 13;
2597
2597
  const THead = 14;
2598
2598
  const Tr = 15;
@@ -2733,7 +2733,7 @@ const VirtualDomElements = {
2733
2733
  THead,
2734
2734
  Table,
2735
2735
  Td,
2736
- Text: Text$2,
2736
+ Text: Text$3,
2737
2737
  TextArea,
2738
2738
  Tfoot,
2739
2739
  Th,
@@ -3241,6 +3241,19 @@ const detachEvent = ($Node, key) => {
3241
3241
  $Node.removeEventListener(keyLower, previous.listener, previous.options);
3242
3242
  listenersByEvent?.delete(keyLower);
3243
3243
  };
3244
+ const detachAll = $Node => {
3245
+ const listeners = attachedListeners.get($Node);
3246
+ if (!listeners) {
3247
+ return;
3248
+ }
3249
+ for (const [name, {
3250
+ listener,
3251
+ options
3252
+ }] of listeners) {
3253
+ $Node.removeEventListener(name, listener, options);
3254
+ }
3255
+ attachedListeners.delete($Node);
3256
+ };
3244
3257
 
3245
3258
  const toCamelCase = key => {
3246
3259
  let camelCaseKey = '';
@@ -3440,7 +3453,7 @@ const {
3440
3453
  Polyline,
3441
3454
  Rect,
3442
3455
  Svg,
3443
- Text: Text$1,
3456
+ Text: Text$2,
3444
3457
  Use,
3445
3458
  Reference} = VirtualDomElements;
3446
3459
 
@@ -3465,18 +3478,18 @@ const renderReferenceNode = (element, eventMap, newEventMap) => {
3465
3478
  setProps($Node, props, eventMap, newEventMap);
3466
3479
  return $Node;
3467
3480
  };
3468
- const render$1 = (element, eventMap, newEventMap) => {
3481
+ const render$2 = (element, eventMap, newEventMap) => {
3469
3482
  switch (element.type) {
3470
3483
  case Reference:
3471
3484
  return renderReferenceNode(element, eventMap, newEventMap);
3472
- case Text$1:
3485
+ case Text$2:
3473
3486
  return renderDomTextNode(element);
3474
3487
  default:
3475
3488
  return renderDomElement(element, eventMap, newEventMap);
3476
3489
  }
3477
3490
  };
3478
3491
 
3479
- const renderInternal = ($Parent, elements, eventMap, newEventMap, renderElement = render$1) => {
3492
+ const renderInternal = ($Parent, elements, eventMap, newEventMap, renderElement = render$2) => {
3480
3493
  const max = elements.length - 1;
3481
3494
  let stack = [];
3482
3495
  for (let i = max; i >= 0; i--) {
@@ -3492,7 +3505,7 @@ const renderInternal = ($Parent, elements, eventMap, newEventMap, renderElement
3492
3505
  $Parent.append(...stack);
3493
3506
  };
3494
3507
 
3495
- const renderInto = ($Parent, dom, eventMap = {}) => {
3508
+ const renderInto$1 = ($Parent, dom, eventMap = {}) => {
3496
3509
  clearNode($Parent);
3497
3510
  renderInternal($Parent, dom, eventMap);
3498
3511
  };
@@ -3501,7 +3514,7 @@ const renderInto = ($Parent, dom, eventMap = {}) => {
3501
3514
  * @param {any[]} elements
3502
3515
  * @returns
3503
3516
  */
3504
- const render = (elements, eventMap = {}, newEventMap = {}) => {
3517
+ const render$1 = (elements, eventMap = {}, newEventMap = {}) => {
3505
3518
  const $Root = document.createElement('div');
3506
3519
  renderInternal($Root, elements, eventMap, newEventMap);
3507
3520
  return $Root;
@@ -3516,13 +3529,13 @@ const removeChild = ($Element, index) => {
3516
3529
  $Child.remove();
3517
3530
  }
3518
3531
  };
3519
- const add = ($Element, nodes, eventMap = {}) => {
3520
- renderInternal($Element, nodes, eventMap, eventMap);
3532
+ const add = ($Element, nodes, eventMap = {}, renderElement) => {
3533
+ renderInternal($Element, nodes, eventMap, eventMap, renderElement);
3521
3534
  };
3522
- const replace = ($Element, nodes, eventMap = {}) => {
3535
+ const replace = ($Element, nodes, eventMap = {}, renderElement) => {
3523
3536
  // Create a temporary container to render the new nodes
3524
3537
  const $Temp = document.createElement('div');
3525
- renderInternal($Temp, nodes, eventMap, eventMap);
3538
+ renderInternal($Temp, nodes, eventMap, eventMap, renderElement);
3526
3539
  // Replace the current element with the new node(s)
3527
3540
  const $NewNode = $Temp.firstChild;
3528
3541
  if (!$NewNode) {
@@ -3626,7 +3639,7 @@ const handleMultiNavigation = (state, navigations, nextPatchType, $Element, patc
3626
3639
  }
3627
3640
  return true;
3628
3641
  };
3629
- const handleSetReferenceNodeUid = (state, patch) => {
3642
+ const handleSetReferenceNodeUid = (state, patch, options) => {
3630
3643
  const instance = get$9(patch.uid);
3631
3644
  if (!instance || !instance.state) {
3632
3645
  console.error('Cannot set reference node uid: instance not found', {
@@ -3635,6 +3648,7 @@ const handleSetReferenceNodeUid = (state, patch) => {
3635
3648
  return false;
3636
3649
  }
3637
3650
  const $NewNode = instance.state.$Viewlet;
3651
+ options.onRemove?.(state.current);
3638
3652
  // @ts-ignore
3639
3653
  state.current.replaceWith($NewNode);
3640
3654
  state.current = $NewNode;
@@ -3655,10 +3669,10 @@ const handleNavigationPatch = (state, patch, patches, patchIndex, $Element) => {
3655
3669
  return true;
3656
3670
  }
3657
3671
  };
3658
- const applyMutationPatch = (state, patch, events) => {
3672
+ const applyMutationPatch = (state, patch, events, options) => {
3659
3673
  switch (patch.type) {
3660
3674
  case Add:
3661
- add(state.current, patch.nodes, events);
3675
+ add(state.current, patch.nodes, events, options.renderElement);
3662
3676
  state.hasAppliedMutation = true;
3663
3677
  break;
3664
3678
  case RemoveAttribute:
@@ -3666,11 +3680,13 @@ const applyMutationPatch = (state, patch, events) => {
3666
3680
  state.hasAppliedMutation = true;
3667
3681
  break;
3668
3682
  case RemoveChild:
3683
+ options.onRemove?.(state.current.childNodes[patch.index]);
3669
3684
  removeChild(state.current, patch.index);
3670
3685
  state.hasAppliedMutation = true;
3671
3686
  break;
3672
3687
  case Replace:
3673
- state.current = replace(state.current, patch.nodes, events);
3688
+ options.onRemove?.(state.current);
3689
+ state.current = replace(state.current, patch.nodes, events, options.renderElement);
3674
3690
  state.hasAppliedMutation = true;
3675
3691
  break;
3676
3692
  case SetAttribute:
@@ -3683,7 +3699,7 @@ const applyMutationPatch = (state, patch, events) => {
3683
3699
  break;
3684
3700
  }
3685
3701
  };
3686
- const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
3702
+ const applyPatch$2 = ($Element, patches, eventMap = {}, id = 0, options = {}) => {
3687
3703
  const events = getEventListenerMap(id) || eventMap;
3688
3704
  const state = {
3689
3705
  current: $Element,
@@ -3696,12 +3712,12 @@ const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
3696
3712
  return;
3697
3713
  }
3698
3714
  if (patch.type === SetReferenceNodeUid) {
3699
- if (!handleSetReferenceNodeUid(state, patch)) {
3715
+ if (!handleSetReferenceNodeUid(state, patch, options)) {
3700
3716
  return;
3701
3717
  }
3702
3718
  continue;
3703
3719
  }
3704
- applyMutationPatch(state, patch, events);
3720
+ applyMutationPatch(state, patch, events, options);
3705
3721
  } catch (error) {
3706
3722
  console.error('Error applying patch at index ' + patchIndex, patch, error);
3707
3723
  throw error;
@@ -3782,7 +3798,7 @@ const restoreFocusedElement = ($Hidden, $New, focused) => {
3782
3798
  };
3783
3799
  const renderWithUid = ($Viewlet, dom, eventMap, uid, inputMap, focused, activeElement) => {
3784
3800
  const newEventMap = getEventListenerMap(uid);
3785
- const $New = render(dom, eventMap, newEventMap).firstChild;
3801
+ const $New = render$1(dom, eventMap, newEventMap).firstChild;
3786
3802
  // A referenced pane can be temporarily absent from the new layout. Leave its
3787
3803
  // focused input in that pane unless there is a replacement to transfer it to.
3788
3804
  const hasReplacement = focused && $New.querySelector(`[name="${CSS.escape(focused)}"]`);
@@ -3841,7 +3857,7 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
3841
3857
  }
3842
3858
  if (!uid) {
3843
3859
  const $Hidden = createHiddenContainer(activeElement, focused);
3844
- renderInto($Viewlet, dom, eventMap);
3860
+ renderInto$1($Viewlet, dom, eventMap);
3845
3861
  $Hidden.remove();
3846
3862
  }
3847
3863
  restoreFocus($Viewlet, isRootTree, isTreeFocused, focused);
@@ -3855,6 +3871,156 @@ const rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
3855
3871
  }
3856
3872
  };
3857
3873
 
3874
+ const safeTags = new Set(['div', 'span', 'p', 'section', 'header', 'footer', 'main', 'nav']);
3875
+ const safeProps = new Set(['type', 'childCount', 'id', 'className', 'title', 'role', 'style']);
3876
+ const validateLimit = limit => {
3877
+ if (!Number.isSafeInteger(limit) || limit < 0) {
3878
+ throw new RangeError('Cache limits must be nonnegative safe integers');
3879
+ }
3880
+ return limit;
3881
+ };
3882
+ const createRenderer = (options = {}) => {
3883
+ const domLimit = validateLimit(options.cache?.dom ?? 0);
3884
+ const textLimit = validateLimit(options.cache?.text ?? 0);
3885
+ const elements = [];
3886
+ const texts = [];
3887
+ const owned = new WeakSet();
3888
+ const recyclable = new WeakSet();
3889
+ const rootNodes = new Map();
3890
+ const rootByNode = new WeakMap();
3891
+ const parentRoots = new WeakMap();
3892
+ let activeRoot;
3893
+ const rememberNode = node => {
3894
+ owned.add(node);
3895
+ if (activeRoot) {
3896
+ rootNodes.get(activeRoot)?.add(node);
3897
+ rootByNode.set(node, activeRoot);
3898
+ }
3899
+ };
3900
+ const renderElement = (node, eventMap, newEventMap) => {
3901
+ if (node.type === Reference) {
3902
+ return render$2(node, eventMap, newEventMap);
3903
+ }
3904
+ let result;
3905
+ if (node.type === Text$2) {
3906
+ const text = texts.pop() || document.createTextNode('');
3907
+ text.data = node.text;
3908
+ result = text;
3909
+ } else {
3910
+ const tag = getElementTag(node.type);
3911
+ const index = elements.findIndex(element => element.localName === tag && element.ownerDocument === document);
3912
+ if (index === -1) {
3913
+ result = render$2(node, eventMap, newEventMap);
3914
+ } else {
3915
+ const element = elements.splice(index, 1)[0];
3916
+ setProps(element, node, eventMap, newEventMap);
3917
+ result = element;
3918
+ }
3919
+ recyclable.delete(result);
3920
+ if (safeTags.has(tag) && Object.keys(node).every(key => safeProps.has(key) || key.startsWith('aria-') || key.startsWith('data-') || key.startsWith('on'))) {
3921
+ recyclable.add(result);
3922
+ }
3923
+ }
3924
+ rememberNode(result);
3925
+ return result;
3926
+ };
3927
+ const collect = node => {
3928
+ if (!node || !owned.has(node)) {
3929
+ return;
3930
+ }
3931
+ owned.delete(node);
3932
+ rootByNode.delete(node);
3933
+ for (const child of node.childNodes) {
3934
+ collect(child);
3935
+ }
3936
+ if (node instanceof Text) {
3937
+ node.data = '';
3938
+ if (texts.length < textLimit) {
3939
+ texts.push(node);
3940
+ }
3941
+ } else if (node instanceof Element) {
3942
+ detachAll(node);
3943
+ node.replaceChildren();
3944
+ if (node instanceof HTMLElement && recyclable.has(node) && Object.getOwnPropertyNames(node).length === 0) {
3945
+ for (const name of node.getAttributeNames()) {
3946
+ node.removeAttribute(name);
3947
+ }
3948
+ node.scrollTop = 0;
3949
+ node.scrollLeft = 0;
3950
+ if (elements.length < domLimit) {
3951
+ elements.push(node);
3952
+ }
3953
+ }
3954
+ }
3955
+ };
3956
+ const dispose = root => {
3957
+ const trackedRoot = rootNodes.has(root) ? root : parentRoots.get(root);
3958
+ if (!trackedRoot) {
3959
+ return;
3960
+ }
3961
+ const nodes = rootNodes.get(trackedRoot);
3962
+ rootNodes.delete(trackedRoot);
3963
+ trackedRoot.remove();
3964
+ const nodesToCollect = nodes || [];
3965
+ for (const node of nodesToCollect) {
3966
+ collect(node);
3967
+ }
3968
+ trackedRoot.replaceChildren();
3969
+ };
3970
+ const render = (nodes, eventMap = {}, newEventMap = {}) => {
3971
+ const root = document.createElement('div');
3972
+ rootNodes.set(root, new Set());
3973
+ activeRoot = root;
3974
+ try {
3975
+ renderInternal(root, nodes, eventMap, newEventMap, renderElement);
3976
+ } finally {
3977
+ activeRoot = undefined;
3978
+ }
3979
+ return root;
3980
+ };
3981
+ const renderInto = (parent, nodes, eventMap = {}, newEventMap = {}) => {
3982
+ dispose(parent);
3983
+ const root = render(nodes, eventMap, newEventMap);
3984
+ parent.replaceChildren(...root.childNodes);
3985
+ parentRoots.set(parent, root);
3986
+ };
3987
+ const getRoot = node => {
3988
+ let current = node;
3989
+ while (current) {
3990
+ const root = rootByNode.get(current);
3991
+ if (root) {
3992
+ return root;
3993
+ }
3994
+ current = current.parentNode;
3995
+ }
3996
+ return undefined;
3997
+ };
3998
+ const applyPatch = (element, patches, eventMap = {}, id = 0) => {
3999
+ const root = getRoot(element);
4000
+ activeRoot = root;
4001
+ try {
4002
+ const options = {
4003
+ onRemove: collect,
4004
+ renderElement
4005
+ };
4006
+ applyPatch$2(element, patches, eventMap, id, options);
4007
+ } finally {
4008
+ activeRoot = undefined;
4009
+ }
4010
+ };
4011
+ const clearCache = () => {
4012
+ elements.length = 0;
4013
+ texts.length = 0;
4014
+ };
4015
+ return {
4016
+ applyPatch,
4017
+ render,
4018
+ renderInto,
4019
+ dispose,
4020
+ clearCache
4021
+ };
4022
+ };
4023
+
3858
4024
  const set$8 = setComponentUid;
3859
4025
  const get$7 = getComponentUid;
3860
4026
  const fromEvent = getComponentUidFromEvent;
@@ -3931,26 +4097,26 @@ const launchDragAndDropWorker = async () => {
3931
4097
  }
3932
4098
  };
3933
4099
 
3934
- const state$b = {
4100
+ const state$c = {
3935
4101
  rpc: undefined
3936
4102
  };
3937
4103
  const hydrate$3 = async () => {
3938
4104
  const result = await launchDragAndDropWorker();
3939
4105
  if (isError(result)) {
3940
- state$b.rpc = undefined;
4106
+ state$c.rpc = undefined;
3941
4107
  return result;
3942
4108
  }
3943
- state$b.rpc = result.value;
4109
+ state$c.rpc = result.value;
3944
4110
  return success(undefined);
3945
4111
  };
3946
4112
  const handleMessagePort$1 = async port => {
3947
- if (!state$b.rpc) {
4113
+ if (!state$c.rpc) {
3948
4114
  const result = await hydrate$3();
3949
4115
  if (isError(result)) {
3950
4116
  throw result.error;
3951
4117
  }
3952
4118
  }
3953
- const rpc = state$b.rpc;
4119
+ const rpc = state$c.rpc;
3954
4120
  if (!rpc) {
3955
4121
  throw new Error('Drag And Drop Worker failed to initialize');
3956
4122
  }
@@ -4553,7 +4719,7 @@ const create$u = async ({
4553
4719
  // @ts-ignore
4554
4720
  return module.create(options);
4555
4721
  };
4556
- const dispose$i = id => {
4722
+ const dispose$j = id => {
4557
4723
  const worker = remove$3(id);
4558
4724
  worker?.terminate();
4559
4725
  };
@@ -4609,6 +4775,10 @@ const setThemeColor = color => {
4609
4775
  meta.content = color;
4610
4776
  };
4611
4777
 
4778
+ const setModernUi = enabled => {
4779
+ document.body.classList.toggle('ModernUi', enabled);
4780
+ };
4781
+
4612
4782
  const Alert = 'alert';
4613
4783
  const Application = 'application';
4614
4784
  const Complementary = 'complementary';
@@ -4651,7 +4821,7 @@ const create$Button = (label, icon) => {
4651
4821
  };
4652
4822
 
4653
4823
  // TODO this file is not needed when all elements are position fixed
4654
- const state$a = {
4824
+ const state$b = {
4655
4825
  $Widgets: undefined,
4656
4826
  widgetSet: new Set()
4657
4827
  };
@@ -4663,20 +4833,20 @@ const create$Widgets = () => {
4663
4833
  };
4664
4834
  const append$1 = $Element => {
4665
4835
  // TODO should not call append in the first place if it is already in DOM
4666
- if (state$a.widgetSet.has($Element)) {
4836
+ if (state$b.widgetSet.has($Element)) {
4667
4837
  return;
4668
4838
  }
4669
- state$a.widgetSet.add($Element);
4670
- if (state$a.$Widgets) {
4839
+ state$b.widgetSet.add($Element);
4840
+ if (state$b.$Widgets) {
4671
4841
  // @ts-expect-error
4672
- state$a.$Widgets.append($Element);
4842
+ state$b.$Widgets.append($Element);
4673
4843
  } else {
4674
4844
  // @ts-expect-error
4675
- state$a.$Widgets = create$Widgets();
4845
+ state$b.$Widgets = create$Widgets();
4676
4846
  // @ts-expect-error
4677
- state$a.$Widgets.append($Element);
4847
+ state$b.$Widgets.append($Element);
4678
4848
  // @ts-expect-error
4679
- document.body.append(state$a.$Widgets);
4849
+ document.body.append(state$b.$Widgets);
4680
4850
  }
4681
4851
  };
4682
4852
  const remove$1 = $Element => {
@@ -4684,17 +4854,17 @@ const remove$1 = $Element => {
4684
4854
  // TODO $Element should always be defined
4685
4855
  return;
4686
4856
  }
4687
- state$a.widgetSet.delete($Element);
4857
+ state$b.widgetSet.delete($Element);
4688
4858
  $Element.remove();
4689
4859
  // TODO state.$Widgets should always be defined at this point
4690
- if (state$a.widgetSet.size === 0 && state$a.$Widgets) {
4860
+ if (state$b.widgetSet.size === 0 && state$b.$Widgets) {
4691
4861
  // @ts-expect-error
4692
- state$a.$Widgets.remove();
4693
- state$a.$Widgets = undefined;
4862
+ state$b.$Widgets.remove();
4863
+ state$b.$Widgets = undefined;
4694
4864
  }
4695
4865
  };
4696
4866
 
4697
- const state$9 = {
4867
+ const state$a = {
4698
4868
  nextNotificationId: 0
4699
4869
  };
4700
4870
  const handleCloseClick = event => {
@@ -4717,7 +4887,7 @@ const create$Notification = message => {
4717
4887
  const $NotificationMessage = create$NotificationMessage(message);
4718
4888
  const $CloseButton = create$CloseButton();
4719
4889
  const $Notification = document.createElement('div');
4720
- $Notification.id = `Notification-${++state$9.nextNotificationId}`;
4890
+ $Notification.id = `Notification-${++state$a.nextNotificationId}`;
4721
4891
  $Notification.className = 'Notification';
4722
4892
  $Notification.append($NotificationMessage, $CloseButton);
4723
4893
  return $Notification;
@@ -4766,7 +4936,7 @@ const create$NotificationWithOptions = (message, options) => {
4766
4936
  $NotificationOptions.append($NotificationOption);
4767
4937
  }
4768
4938
  const $Notification = document.createElement('div');
4769
- $Notification.id = `Notification-${++state$9.nextNotificationId}`;
4939
+ $Notification.id = `Notification-${++state$a.nextNotificationId}`;
4770
4940
  $Notification.className = 'Notification';
4771
4941
  $Notification.append($NotificationMessage, $CloseButton, $NotificationOptions);
4772
4942
  $Notification.onclick = handleNotificationClick;
@@ -4777,7 +4947,7 @@ const createWithOptions = (type, message, options) => {
4777
4947
  append$1($Notification);
4778
4948
  return $Notification.id;
4779
4949
  };
4780
- const dispose$h = id => {
4950
+ const dispose$i = id => {
4781
4951
  const $Notification = document.getElementById(id);
4782
4952
  if ($Notification?.classList.contains('Notification')) {
4783
4953
  remove$1($Notification);
@@ -4791,11 +4961,11 @@ const revokeObjectUrl = url => {
4791
4961
  URL.revokeObjectURL(url);
4792
4962
  };
4793
4963
 
4794
- const state$8 = {
4964
+ const state$9 = {
4795
4965
  canvasObjects: Object.create(null)
4796
4966
  };
4797
4967
  const set$5 = (canvasId, canvas) => {
4798
- state$8.canvasObjects[canvasId] = canvas;
4968
+ state$9.canvasObjects[canvasId] = canvas;
4799
4969
  };
4800
4970
 
4801
4971
  const create$r = async (canvasId, objectId) => {
@@ -4894,16 +5064,16 @@ const findIndex = ($Container, $Target) => {
4894
5064
  return -1;
4895
5065
  };
4896
5066
 
4897
- const state$7 = {
5067
+ const state$8 = {
4898
5068
  /**
4899
5069
  * @type {HTMLElement|undefined}
4900
5070
  */
4901
5071
  $PreviousFocusElement: undefined};
4902
5072
  const setElement = $Element => {
4903
- state$7.$PreviousFocusElement = $Element;
5073
+ state$8.$PreviousFocusElement = $Element;
4904
5074
  };
4905
5075
  const getElement = () => {
4906
- return state$7.$PreviousFocusElement;
5076
+ return state$8.$PreviousFocusElement;
4907
5077
  };
4908
5078
 
4909
5079
  const focus$e = $Element => {
@@ -4960,6 +5130,34 @@ const setHeight = ($Element, height) => {
4960
5130
  $Element.style.height = `${height}px`;
4961
5131
  };
4962
5132
 
5133
+ const state$7 = {
5134
+ renderer: undefined
5135
+ };
5136
+ const configure = options => {
5137
+ const cache = options?.cache;
5138
+ state$7.renderer = cache?.dom > 0 || cache?.text > 0 ? createRenderer(options) : undefined;
5139
+ };
5140
+ const render = (nodes, eventMap = {}, newEventMap = {}) => {
5141
+ return state$7.renderer?.render(nodes, eventMap, newEventMap) || render$1(nodes, eventMap, newEventMap);
5142
+ };
5143
+ const renderInto = (parent, nodes, eventMap = {}, newEventMap = {}) => {
5144
+ if (state$7.renderer) {
5145
+ state$7.renderer.renderInto(parent, nodes, eventMap, newEventMap);
5146
+ return;
5147
+ }
5148
+ renderInto$1(parent, nodes, eventMap);
5149
+ };
5150
+ const applyPatch$1 = (element, patches, eventMap = {}, id = 0) => {
5151
+ if (state$7.renderer) {
5152
+ state$7.renderer.applyPatch(element, patches, eventMap, id);
5153
+ return;
5154
+ }
5155
+ applyPatch$2(element, patches, eventMap, id);
5156
+ };
5157
+ const dispose$h = root => {
5158
+ state$7.renderer?.dispose(root);
5159
+ };
5160
+
4963
5161
  const FocusLocationList = 17;
4964
5162
  const FocusMenu = 18;
4965
5163
  const FocusSimpleBrowserInput = 23;
@@ -5495,7 +5693,7 @@ const ElementActions = {
5495
5693
  };
5496
5694
 
5497
5695
  const Css = 1;
5498
- const Text = 2;
5696
+ const Text$1 = 2;
5499
5697
  const HasText = 3;
5500
5698
  const Nth = 4;
5501
5699
 
@@ -5533,7 +5731,7 @@ const selectorToString = parsedSelector => {
5533
5731
  result += ` >> ${part.selector}`;
5534
5732
  continue;
5535
5733
  }
5536
- if (part.type === Text || part.type === 'text') {
5734
+ if (part.type === Text$1 || part.type === 'text') {
5537
5735
  if (!result) {
5538
5736
  result = `text=${part.text}`;
5539
5737
  continue;
@@ -5557,7 +5755,7 @@ const querySelector = parsedSelector => {
5557
5755
  }
5558
5756
  let elements = [document.body];
5559
5757
  for (const part of parsedSelector) {
5560
- if (part.type === Text || part.type === 'text') {
5758
+ if (part.type === Text$1 || part.type === 'text') {
5561
5759
  elements = elements.flatMap(element => {
5562
5760
  return querySelectorByText(element, part.text);
5563
5761
  });
@@ -6140,6 +6338,10 @@ const transferToWebView = objectId => {
6140
6338
  }, targetOrigin, [port]);
6141
6339
  };
6142
6340
 
6341
+ const applyPatch = (element, patches, eventMap = {}, id = 0) => {
6342
+ applyPatch$1(element, patches, eventMap, id);
6343
+ };
6344
+
6143
6345
  const attachEvents$7 = ($Node, eventMap) => {
6144
6346
  for (const [key, value] of Object.entries(eventMap)) {
6145
6347
  $Node.addEventListener(key, value);
@@ -7353,7 +7555,6 @@ const setDom$8 = (state, dom) => {
7353
7555
  $Viewlet
7354
7556
  } = state;
7355
7557
  const $Root = render(dom);
7356
- // @ts-expect-error
7357
7558
  $ListItems.replaceChildren(...$Root.firstChild.childNodes);
7358
7559
  append$1($Viewlet);
7359
7560
  // TODO recycle nodes
@@ -7429,7 +7630,6 @@ const setDom$7 = (state, dom) => {
7429
7630
  $Viewlet
7430
7631
  } = state;
7431
7632
  const $Root = render(dom);
7432
- // @ts-expect-error
7433
7633
  $Viewlet.replaceChildren(...$Root.firstChild.childNodes);
7434
7634
  append$1($Viewlet);
7435
7635
  };
@@ -10443,6 +10643,7 @@ const dispose$3 = id => {
10443
10643
  if (instance.factory.dispose) {
10444
10644
  instance.factory.dispose(instance.state);
10445
10645
  }
10646
+ dispose$h(instance.state.$Viewlet);
10446
10647
  if (instance.state.$Viewlet?.isConnected) {
10447
10648
  instance.state.$Viewlet.remove();
10448
10649
  }
@@ -11224,7 +11425,7 @@ const commandMap = {
11224
11425
  'HandleMessagePort.handleMessagePort': handleMessagePort,
11225
11426
  'InitData.getInitData': getInitData,
11226
11427
  'IpcParent.create': create$u,
11227
- 'IpcParent.dispose': dispose$i,
11428
+ 'IpcParent.dispose': dispose$j,
11228
11429
  'KeyBindings.setIdentifiers': setIdentifiers,
11229
11430
  'Layout.getBounds': getBounds,
11230
11431
  'Location.getHref': getHref,
@@ -11242,7 +11443,7 @@ const commandMap = {
11242
11443
  'Meta.setThemeColor': setThemeColor,
11243
11444
  'Notification.create': create$s,
11244
11445
  'Notification.createWithOptions': createWithOptions,
11245
- 'Notification.dispose': dispose$h,
11446
+ 'Notification.dispose': dispose$i,
11246
11447
  'ObjectUrl.create': createObjectUrl,
11247
11448
  'ObjectUrl.revoke': revokeObjectUrl,
11248
11449
  'OffscreenCanvas.create': create$r,
@@ -11256,7 +11457,7 @@ const commandMap = {
11256
11457
  'PointerCapture.unmock': unmock,
11257
11458
  'Prompt.prompt': prompt,
11258
11459
  'ScreenCapture.start': start,
11259
- 'SessionReplay.configure': configure,
11460
+ 'SessionReplay.configure': configure$1,
11260
11461
  'SessionReplay.configureProxy': configureProxy,
11261
11462
  'SessionReplay.flush': flush,
11262
11463
  'SessionReplay.getSession': getSession,
@@ -11297,6 +11498,7 @@ const commandMap = {
11297
11498
  'Viewlet.setBounds': setBounds$1,
11298
11499
  'Viewlet.setComponentDom': setComponentDom,
11299
11500
  'Viewlet.show': show,
11501
+ 'VirtualDom.configure': configure,
11300
11502
  'WebRtc.readMicLevels': readMicLevels,
11301
11503
  'WebRtc.setRemoteDescription': setRemoteDescription,
11302
11504
  'WebRtc.startWebRtcAudioStream': startWebRtcAudioStream,
@@ -11327,7 +11529,8 @@ const commandMap = {
11327
11529
  'Window.revealBrowserTab': revealBrowserTab,
11328
11530
  'Window.toggleFullScreen': toggleFullScreen,
11329
11531
  'Window.unmaximize': unmaximize,
11330
- 'WindowTitle.set': set$1
11532
+ 'WindowTitle.set': set$1,
11533
+ 'Workbench.setModernUi': setModernUi
11331
11534
  };
11332
11535
 
11333
11536
  const RE_AT = /^\s+at/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.60.3",
3
+ "version": "30.62.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"