@lvce-editor/renderer-process 30.82.4 → 30.84.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.
@@ -1391,6 +1391,48 @@ const observe = (document, record, onError) => {
1391
1391
  document.defaultView.removeEventListener('resize', mark);
1392
1392
  };
1393
1393
  };
1394
+ // Coalesce high-frequency browser events and keep at most one write in flight.
1395
+ const observePointer = (document, record, onError) => {
1396
+ let timer;
1397
+ let latest;
1398
+ let stopped = false;
1399
+ const stop = () => {
1400
+ stopped = true;
1401
+ clearTimeout(timer);
1402
+ document.removeEventListener('pointermove', move, true);
1403
+ };
1404
+ const flush = async () => {
1405
+ const position = latest;
1406
+ latest = undefined;
1407
+ try {
1408
+ await record(position);
1409
+ } catch (error) {
1410
+ if (stopped) return;
1411
+ stop();
1412
+ onError(error);
1413
+ return;
1414
+ }
1415
+ timer = undefined;
1416
+ schedule();
1417
+ };
1418
+ const schedule = () => {
1419
+ if (!stopped && latest && timer === undefined) {
1420
+ timer = setTimeout(() => {
1421
+ void flush();
1422
+ }, 50);
1423
+ }
1424
+ };
1425
+ const move = event => {
1426
+ if (!event.isTrusted || !event.isPrimary) return;
1427
+ latest = [Math.round(event.clientX), Math.round(event.clientY)];
1428
+ schedule();
1429
+ };
1430
+ document.addEventListener('pointermove', move, {
1431
+ capture: true,
1432
+ passive: true
1433
+ });
1434
+ return stop;
1435
+ };
1394
1436
 
1395
1437
  // Walk the structured-clone graph, including collections and shared buffer views.
1396
1438
  const getTransferrables = value => {
@@ -1474,15 +1516,15 @@ const commandMapRef = {};
1474
1516
 
1475
1517
  const workers$1 = new Map();
1476
1518
  const metadataById = new Map();
1477
- const state$p = {
1519
+ const state$q = {
1478
1520
  generation: 0,
1479
1521
  nextId: 0
1480
1522
  };
1481
- const getGeneration = () => state$p.generation;
1523
+ const getGeneration = () => state$q.generation;
1482
1524
  const createRuntimeName = (name, parentName) => {
1483
- state$p.nextId++;
1484
- const id = `worker-${state$p.nextId}`;
1485
- const runtimeId = `worker-${String(state$p.nextId).padStart(2, '0')}`;
1525
+ state$q.nextId++;
1526
+ const id = `worker-${state$q.nextId}`;
1527
+ const runtimeId = `worker-${String(state$q.nextId).padStart(2, '0')}`;
1486
1528
  let parent;
1487
1529
  if (parentName) {
1488
1530
  parent = metadataById.values().find(worker => worker.name === parentName);
@@ -1500,8 +1542,8 @@ const createRuntimeName = (name, parentName) => {
1500
1542
  metadataById.set(id, metadata);
1501
1543
  return metadata;
1502
1544
  };
1503
- const track = (worker, startedIn = state$p.generation, trackedWorker) => {
1504
- if (startedIn !== state$p.generation) {
1545
+ const track = (worker, startedIn = state$q.generation, trackedWorker) => {
1546
+ if (startedIn !== state$q.generation) {
1505
1547
  worker.terminate();
1506
1548
  throw new Error('Worker launch canceled by application restart');
1507
1549
  }
@@ -1535,7 +1577,7 @@ const terminate$1 = id => {
1535
1577
  };
1536
1578
  const getWorkers$1 = () => workers$1.values().toArray();
1537
1579
  const terminateAll = () => {
1538
- state$p.generation++;
1580
+ state$q.generation++;
1539
1581
  const retiring = workers$1.keys().toArray();
1540
1582
  workers$1.clear();
1541
1583
  metadataById.clear();
@@ -1672,7 +1714,7 @@ const launchRendererWorker = async () => {
1672
1714
  };
1673
1715
 
1674
1716
  const selector$1 = 'script.RendererWorkerTrace';
1675
- const state$o = {
1717
+ const state$p = {
1676
1718
  enabled: false,
1677
1719
  entries: []
1678
1720
  };
@@ -1722,14 +1764,14 @@ const isCommand = value => {
1722
1764
  };
1723
1765
  const initialize$1 = search => {
1724
1766
  const searchParams = new URLSearchParams(search);
1725
- state$o.enabled = searchParams.has('traceRendererWorker');
1726
- state$o.entries = [];
1767
+ state$p.enabled = searchParams.has('traceRendererWorker');
1768
+ state$p.entries = [];
1727
1769
  };
1728
1770
  const record = (direction, method, params) => {
1729
- if (!state$o.enabled) {
1771
+ if (!state$p.enabled) {
1730
1772
  return;
1731
1773
  }
1732
- state$o.entries.push({
1774
+ state$p.entries.push({
1733
1775
  direction,
1734
1776
  method,
1735
1777
  params: serialize(params),
@@ -1737,7 +1779,7 @@ const record = (direction, method, params) => {
1737
1779
  });
1738
1780
  };
1739
1781
  const listen$1 = rpc => {
1740
- if (!state$o.enabled) {
1782
+ if (!state$p.enabled) {
1741
1783
  return;
1742
1784
  }
1743
1785
  const ipc = rpc.ipc;
@@ -1752,7 +1794,7 @@ const listen$1 = rpc => {
1752
1794
  });
1753
1795
  };
1754
1796
  const exportToDom = () => {
1755
- if (!state$o.enabled) {
1797
+ if (!state$p.enabled) {
1756
1798
  return;
1757
1799
  }
1758
1800
  const existing = document.querySelector(selector$1);
@@ -1760,7 +1802,7 @@ const exportToDom = () => {
1760
1802
  script.className = 'RendererWorkerTrace';
1761
1803
  script.type = 'application/json';
1762
1804
  script.textContent = JSON.stringify({
1763
- entries: state$o.entries,
1805
+ entries: state$p.entries,
1764
1806
  version: 1
1765
1807
  });
1766
1808
  if (!existing) {
@@ -1768,49 +1810,49 @@ const exportToDom = () => {
1768
1810
  }
1769
1811
  };
1770
1812
  const scheduleExport = () => {
1771
- if (!state$o.enabled) {
1813
+ if (!state$p.enabled) {
1772
1814
  return;
1773
1815
  }
1774
1816
  queueMicrotask(exportToDom);
1775
1817
  };
1776
1818
 
1777
- const state$n = {
1819
+ const state$o = {
1778
1820
  rpc: undefined
1779
1821
  };
1780
1822
  const hydrate$4 = async () => {
1781
1823
  const result = await launchRendererWorker();
1782
1824
  if (isError(result)) {
1783
- state$n.rpc = undefined;
1825
+ state$o.rpc = undefined;
1784
1826
  return result;
1785
1827
  }
1786
- state$n.rpc = result.value;
1828
+ state$o.rpc = result.value;
1787
1829
  listen$1(result.value);
1788
1830
  return success(undefined);
1789
1831
  };
1790
1832
 
1791
1833
  // TODO needed?
1792
1834
  const dispose$q = async () => {
1793
- const rpc = state$n.rpc;
1794
- state$n.rpc = undefined;
1835
+ const rpc = state$o.rpc;
1836
+ state$o.rpc = undefined;
1795
1837
  await rpc?.dispose();
1796
1838
  };
1797
1839
  const send$1 = (method, ...params) => {
1798
1840
  record('sent', method, params);
1799
1841
  // @ts-ignore
1800
- state$n.rpc.send(method, ...params);
1842
+ state$o.rpc.send(method, ...params);
1801
1843
  };
1802
1844
  const invoke$1 = (method, ...params) => {
1803
1845
  record('sent', method, params);
1804
1846
  // @ts-ignore
1805
- return state$n.rpc.invoke(method, ...params);
1847
+ return state$o.rpc.invoke(method, ...params);
1806
1848
  };
1807
1849
  const invokeAndTransfer = (method, ...params) => {
1808
1850
  record('sent', method, params);
1809
1851
  // @ts-ignore
1810
- return state$n.rpc.invokeAndTransfer(method, ...params);
1852
+ return state$o.rpc.invokeAndTransfer(method, ...params);
1811
1853
  };
1812
1854
 
1813
- const state$m = {
1855
+ const state$n = {
1814
1856
  client: undefined,
1815
1857
  enabled: false,
1816
1858
  lastError: '',
@@ -1820,38 +1862,47 @@ const state$m = {
1820
1862
  const workerUrl = new URL('sessionReplayWorkerMain.js', import.meta.url);
1821
1863
  const reloadMessage = 'Reload the window to start session replay with the complete DOM command history';
1822
1864
  const report = error => {
1823
- state$m.lastError = error instanceof Error ? error.message : String(error);
1824
- state$m.stopObserving?.();
1825
- state$m.stopObserving = undefined;
1826
- console.warn(`Session replay: ${state$m.lastError}`);
1865
+ state$n.lastError = error instanceof Error ? error.message : String(error);
1866
+ state$n.stopObserving?.();
1867
+ state$n.stopObserving = undefined;
1868
+ console.warn(`Session replay: ${state$n.lastError}`);
1869
+ };
1870
+ const startPointerCapture = (client, options) => {
1871
+ if (options.recordPointerMovement === false) return undefined;
1872
+ return observePointer(document, position => client.invoke('record', 'pointermove', position), report);
1827
1873
  };
1828
1874
 
1829
1875
  // Retain snapshot recording for older renderer workers during dependency rollout.
1830
1876
  const configure$1 = async options => {
1831
- state$m.stopObserving?.();
1832
- state$m.stopObserving = undefined;
1833
- state$m.enabled = false;
1834
- if (state$m.client) {
1877
+ state$n.stopObserving?.();
1878
+ state$n.stopObserving = undefined;
1879
+ state$n.enabled = false;
1880
+ if (state$n.client) {
1835
1881
  try {
1836
- await state$m.client.invoke('stop');
1882
+ await state$n.client.invoke('stop');
1837
1883
  } catch (error) {
1838
1884
  report(error);
1839
1885
  }
1840
1886
  // Live channels still need their proxy after capture stops.
1841
- if (!state$m.proxy) {
1842
- state$m.client.dispose();
1843
- state$m.client = undefined;
1887
+ if (!state$n.proxy) {
1888
+ state$n.client.dispose();
1889
+ state$n.client = undefined;
1844
1890
  }
1845
1891
  }
1846
1892
  if (!options.local && !options.upload) return '';
1847
- if (state$m.proxy) throw new Error(reloadMessage);
1848
- state$m.lastError = '';
1893
+ if (state$n.proxy) throw new Error(reloadMessage);
1894
+ state$n.lastError = '';
1849
1895
  const client = createClient(workerUrl);
1850
1896
  try {
1851
1897
  const id = await client.invoke('start', options);
1852
- state$m.stopObserving = observe(document, (type, data) => client.invoke('record', type, data), report);
1853
- state$m.client = client;
1854
- state$m.enabled = true;
1898
+ const stopSnapshots = observe(document, (type, data) => client.invoke('record', type, data), report);
1899
+ const stopPointer = startPointerCapture(client, options);
1900
+ state$n.stopObserving = () => {
1901
+ stopPointer?.();
1902
+ stopSnapshots();
1903
+ };
1904
+ state$n.client = client;
1905
+ state$n.enabled = true;
1855
1906
  return id;
1856
1907
  } catch (error) {
1857
1908
  client.dispose();
@@ -1859,7 +1910,7 @@ const configure$1 = async options => {
1859
1910
  }
1860
1911
  };
1861
1912
  const configureProxy = async (options, port) => {
1862
- if (state$m.client || !options.local && !options.upload) {
1913
+ if (state$n.client || !options.local && !options.upload) {
1863
1914
  port.close();
1864
1915
  throw new Error(reloadMessage);
1865
1916
  }
@@ -1872,25 +1923,28 @@ const configureProxy = async (options, port) => {
1872
1923
  commandMap: commandMapRef,
1873
1924
  messagePort: proxyPort
1874
1925
  });
1875
- const original = state$n.rpc;
1876
- state$n.rpc = {
1926
+ state$n.stopObserving = startPointerCapture(client, options);
1927
+ const original = state$o.rpc;
1928
+ state$o.rpc = {
1877
1929
  ...rpc,
1878
1930
  async dispose() {
1931
+ state$n.stopObserving?.();
1932
+ state$n.stopObserving = undefined;
1879
1933
  try {
1880
1934
  await rpc.dispose();
1881
1935
  } finally {
1882
1936
  client.dispose();
1883
- state$m.client = undefined;
1884
- state$m.enabled = false;
1885
- state$m.proxy = false;
1937
+ state$n.client = undefined;
1938
+ state$n.enabled = false;
1939
+ state$n.proxy = false;
1886
1940
  await original?.dispose();
1887
1941
  }
1888
1942
  }
1889
1943
  };
1890
- state$m.client = client;
1891
- state$m.enabled = true;
1892
- state$m.proxy = true;
1893
- state$m.lastError = '';
1944
+ state$n.client = client;
1945
+ state$n.enabled = true;
1946
+ state$n.proxy = true;
1947
+ state$n.lastError = '';
1894
1948
  return id;
1895
1949
  } catch (error) {
1896
1950
  proxyPort?.close();
@@ -1900,21 +1954,21 @@ const configureProxy = async (options, port) => {
1900
1954
  }
1901
1955
  };
1902
1956
  const getSession = async () => {
1903
- if (!state$m.enabled || !state$m.client) throw new Error('Session replay is disabled in settings');
1904
- return state$m.client.invoke('export');
1957
+ if (!state$n.enabled || !state$n.client) throw new Error('Session replay is disabled in settings');
1958
+ return state$n.client.invoke('export');
1905
1959
  };
1906
1960
  const getStatus$1 = async () => {
1907
- if (!state$m.client) return {
1961
+ if (!state$n.client) return {
1908
1962
  enabled: false,
1909
- error: state$m.lastError
1963
+ error: state$n.lastError
1910
1964
  };
1911
1965
  return {
1912
- enabled: state$m.enabled,
1913
- ...(await state$m.client.invoke('status')),
1914
- captureError: state$m.lastError
1966
+ enabled: state$n.enabled,
1967
+ ...(await state$n.client.invoke('status')),
1968
+ captureError: state$n.lastError
1915
1969
  };
1916
1970
  };
1917
- const flush = async () => state$m.client?.invoke('flush');
1971
+ const flush = async () => state$n.client?.invoke('flush');
1918
1972
  const openLocalFile = async () => {
1919
1973
  const input = document.createElement('input');
1920
1974
  input.type = 'file';
@@ -1972,12 +2026,12 @@ const initializeLayout = async href => {
1972
2026
  return true;
1973
2027
  };
1974
2028
  const dispose$p = async () => {
1975
- state$m.stopObserving?.();
1976
- state$m.stopObserving = undefined;
1977
- const client = state$m.client;
1978
- state$m.client = undefined;
1979
- state$m.enabled = false;
1980
- state$m.proxy = false;
2029
+ state$n.stopObserving?.();
2030
+ state$n.stopObserving = undefined;
2031
+ const client = state$n.client;
2032
+ state$n.client = undefined;
2033
+ state$n.enabled = false;
2034
+ state$n.proxy = false;
1981
2035
  if (client) {
1982
2036
  try {
1983
2037
  await client.invoke('flush');
@@ -2043,7 +2097,7 @@ const register$2 = (uid, listeners, speed = 1) => {
2043
2097
  speed: normalize(speed)
2044
2098
  });
2045
2099
  };
2046
- const set$d = (uid, speed) => {
2100
+ const set$e = (uid, speed) => {
2047
2101
  const view = views.get(uid);
2048
2102
  if (view) view.speed = normalize(speed);
2049
2103
  };
@@ -2095,10 +2149,10 @@ const measurePrefix = (text, offset, fontWeight, fontSize, fontFamily, letterSpa
2095
2149
  };
2096
2150
 
2097
2151
  const pendingInputs = new Set();
2098
- const state$l = {
2152
+ const state$m = {
2099
2153
  shortcut: undefined
2100
2154
  };
2101
- const hasPending = () => Boolean(state$l.shortcut || pendingInputs.size > 0);
2155
+ const hasPending = () => Boolean(state$m.shortcut || pendingInputs.size > 0);
2102
2156
  const settle = async result => {
2103
2157
  try {
2104
2158
  await result;
@@ -2116,7 +2170,7 @@ const runAfterShortcut = async (previous, run) => {
2116
2170
  };
2117
2171
  const runInput = run => {
2118
2172
  // Inputs in the same burst run concurrently so the worker can coalesce renders.
2119
- const result = runAfterShortcut(state$l.shortcut, run);
2173
+ const result = runAfterShortcut(state$m.shortcut, run);
2120
2174
  const settled = settle(result);
2121
2175
  pendingInputs.add(settled);
2122
2176
  void removeInput(settled);
@@ -2128,15 +2182,15 @@ const runAfterInputs = async (earlier, run) => {
2128
2182
  };
2129
2183
  const clearShortcut = async settled => {
2130
2184
  await settled;
2131
- if (state$l.shortcut === settled) state$l.shortcut = undefined;
2185
+ if (state$m.shortcut === settled) state$m.shortcut = undefined;
2132
2186
  };
2133
2187
  const runShortcut = run => {
2134
2188
  // Snapshot only earlier input; later input waits for this shortcut instead.
2135
2189
  const earlier = [...pendingInputs];
2136
- if (state$l.shortcut) earlier.push(state$l.shortcut);
2190
+ if (state$m.shortcut) earlier.push(state$m.shortcut);
2137
2191
  const result = runAfterInputs(earlier, run);
2138
2192
  const settled = settle(result);
2139
- state$l.shortcut = settled;
2193
+ state$m.shortcut = settled;
2140
2194
  void clearShortcut(settled);
2141
2195
  return result;
2142
2196
  };
@@ -2643,7 +2697,7 @@ const createIdGenerator = () => {
2643
2697
  };
2644
2698
  const create$z = createIdGenerator();
2645
2699
 
2646
- const state$k = Object.create(null);
2700
+ const state$l = Object.create(null);
2647
2701
  const retainString = (item, index) => {
2648
2702
  const value = new Promise(resolve => {
2649
2703
  item.getAsString(resolve);
@@ -2694,25 +2748,25 @@ const retainItems = dataTransfer => {
2694
2748
  };
2695
2749
  const addItems = items => {
2696
2750
  const id = create$z();
2697
- state$k[id] = items;
2751
+ state$l[id] = items;
2698
2752
  return id;
2699
2753
  };
2700
2754
  const add$2 = dataTransfer => {
2701
2755
  return addItems(retainItems(dataTransfer));
2702
2756
  };
2703
2757
  const acquire$2 = id => {
2704
- const items = state$k[id];
2758
+ const items = state$l[id];
2705
2759
  if (!items) {
2706
2760
  throw new Error(`Drop data not found: ${id}`);
2707
2761
  }
2708
- delete state$k[id];
2762
+ delete state$l[id];
2709
2763
  return items;
2710
2764
  };
2711
2765
 
2712
- const state$j = Object.create(null);
2766
+ const state$k = Object.create(null);
2713
2767
  const acquire$1 = id => {
2714
- const promise = state$j[id];
2715
- delete state$j[id];
2768
+ const promise = state$k[id];
2769
+ delete state$k[id];
2716
2770
  return promise;
2717
2771
  };
2718
2772
  const getFileHandles = async ids => {
@@ -2722,7 +2776,7 @@ const getFileHandles = async ids => {
2722
2776
  };
2723
2777
  const add$1 = promise => {
2724
2778
  const id = create$z();
2725
- state$j[id] = promise;
2779
+ state$k[id] = promise;
2726
2780
  return id;
2727
2781
  };
2728
2782
  const addFileHandle$1 = fileHandle => {
@@ -2923,14 +2977,14 @@ const getEventListenerArgs = (params, event) => {
2923
2977
  return serialized;
2924
2978
  };
2925
2979
 
2926
- const state$i = {
2980
+ const state$j = {
2927
2981
  ipc: undefined
2928
2982
  };
2929
2983
  const getIpc = () => {
2930
- return state$i.ipc;
2984
+ return state$j.ipc;
2931
2985
  };
2932
2986
  const setIpc = value => {
2933
- state$i.ipc = value;
2987
+ state$j.ipc = value;
2934
2988
  };
2935
2989
 
2936
2990
  const nameAnonymousFunction$1 = (fn, name) => {
@@ -3660,7 +3714,7 @@ const instances = Object.create(null);
3660
3714
  const get$b = viewletId => {
3661
3715
  return instances[viewletId];
3662
3716
  };
3663
- const set$c = (viewletId, instance) => {
3717
+ const set$d = (viewletId, instance) => {
3664
3718
  instances[viewletId] = instance;
3665
3719
  };
3666
3720
 
@@ -3689,7 +3743,7 @@ const cache = new Map();
3689
3743
  const has$1 = listener => {
3690
3744
  return cache.has(listener);
3691
3745
  };
3692
- const set$b = (listener, value) => {
3746
+ const set$c = (listener, value) => {
3693
3747
  cache.set(listener, value);
3694
3748
  };
3695
3749
  const get$a = listener => {
@@ -3712,7 +3766,7 @@ const getWrappedListener = (listener, returnValue) => {
3712
3766
  ipc.send('Viewlet.executeViewletCommand', uid, ...result);
3713
3767
  };
3714
3768
  nameAnonymousFunction$1(wrapped, listener.name);
3715
- set$b(listener, wrapped);
3769
+ set$c(listener, wrapped);
3716
3770
  }
3717
3771
  return get$a(listener);
3718
3772
  };
@@ -4667,38 +4721,38 @@ const launchDragAndDropWorker = async () => {
4667
4721
  }
4668
4722
  };
4669
4723
 
4670
- const state$h = {
4724
+ const state$i = {
4671
4725
  rpc: undefined
4672
4726
  };
4673
4727
  const hydrate$3 = async () => {
4674
4728
  const result = await launchDragAndDropWorker();
4675
4729
  if (isError(result)) {
4676
- state$h.rpc = undefined;
4730
+ state$i.rpc = undefined;
4677
4731
  return result;
4678
4732
  }
4679
- state$h.rpc = result.value;
4733
+ state$i.rpc = result.value;
4680
4734
  return success(undefined);
4681
4735
  };
4682
4736
  const handleMessagePort$1 = async port => {
4683
- if (!state$h.rpc) {
4737
+ if (!state$i.rpc) {
4684
4738
  const result = await hydrate$3();
4685
4739
  if (isError(result)) {
4686
4740
  throw result.error;
4687
4741
  }
4688
4742
  }
4689
- const rpc = state$h.rpc;
4743
+ const rpc = state$i.rpc;
4690
4744
  if (!rpc) {
4691
4745
  throw new Error('Drag And Drop Worker failed to initialize');
4692
4746
  }
4693
4747
  await rpc.invokeAndTransfer('DragAndDrop.handleMessagePort', port);
4694
4748
  };
4695
4749
  const dispose$n = async () => {
4696
- const rpc = state$h.rpc;
4697
- state$h.rpc = undefined;
4750
+ const rpc = state$i.rpc;
4751
+ state$i.rpc = undefined;
4698
4752
  await rpc?.dispose();
4699
4753
  };
4700
4754
 
4701
- const set$a = setComponentUid;
4755
+ const set$b = setComponentUid;
4702
4756
  const get$9 = getComponentUid;
4703
4757
  const fromEvent = getComponentUidFromEvent;
4704
4758
 
@@ -4753,16 +4807,16 @@ const unregisterView = uid => {
4753
4807
  viewRpcIds.delete(uid);
4754
4808
  };
4755
4809
 
4756
- const state$g = {
4810
+ const state$h = {
4757
4811
  snapshot: undefined
4758
4812
  };
4759
- const get$7 = () => state$g.snapshot;
4760
- const set$9 = value => {
4761
- state$g.snapshot = value;
4813
+ const get$7 = () => state$h.snapshot;
4814
+ const set$a = value => {
4815
+ state$h.snapshot = value;
4762
4816
  };
4763
4817
 
4764
4818
  const ipcs = Object.create(null);
4765
- const set$8 = (name, ipc) => {
4819
+ const set$9 = (name, ipc) => {
4766
4820
  ipcs[name] = ipc;
4767
4821
  };
4768
4822
  const get$6 = name => {
@@ -5057,7 +5111,7 @@ const IpcParentWithReferencePort = {
5057
5111
  };
5058
5112
 
5059
5113
  const workers = Object.create(null);
5060
- const set$7 = (id, worker) => {
5114
+ const set$8 = (id, worker) => {
5061
5115
  workers[id] = worker;
5062
5116
  };
5063
5117
  const remove$3 = id => {
@@ -5109,7 +5163,7 @@ const create$v = async ({
5109
5163
  discard(trackedWorker);
5110
5164
  }
5111
5165
  if (typeof id === 'number' && raw && worker) {
5112
- set$7(id, worker);
5166
+ set$8(id, worker);
5113
5167
  }
5114
5168
  return undefined;
5115
5169
  };
@@ -5210,7 +5264,7 @@ const hydrate$2 = async () => {
5210
5264
  } = new MessageChannel();
5211
5265
  // TODO only launch port and send to renderer worker
5212
5266
  const promise = launchEditorWorker(port1);
5213
- set$8('Editor Worker', port2);
5267
+ set$9('Editor Worker', port2);
5214
5268
  const result = await promise;
5215
5269
  if (isError(result)) {
5216
5270
  remove$4('Editor Worker');
@@ -5235,7 +5289,7 @@ const preloadWorker = async (name, packageName, fileName, settingName) => {
5235
5289
  url
5236
5290
  });
5237
5291
  // Start creation before caching, so our own request cannot consume this port.
5238
- set$8(name, port2);
5292
+ set$9(name, port2);
5239
5293
  await pending;
5240
5294
  return success(undefined);
5241
5295
  } catch (error) {
@@ -5279,7 +5333,7 @@ const hydrate$1 = async () => {
5279
5333
  } = new MessageChannel();
5280
5334
  // TODO only launch port and send to renderer worker
5281
5335
  const promise = launchSyntaxHighlightingWorker(port1);
5282
- set$8('Syntax Highlighting Worker', port2);
5336
+ set$9('Syntax Highlighting Worker', port2);
5283
5337
  const result = await promise;
5284
5338
  if (isError(result)) {
5285
5339
  remove$4('Syntax Highlighting Worker');
@@ -5312,32 +5366,32 @@ const launchWorkers = async () => {
5312
5366
  return success(undefined);
5313
5367
  };
5314
5368
 
5315
- const state$f = {
5369
+ const state$g = {
5316
5370
  renderer: undefined
5317
5371
  };
5318
5372
  const configure = options => {
5319
5373
  const cache = options?.cache;
5320
- state$f.renderer = cache?.dom > 0 || cache?.text > 0 ? createRenderer(options) : undefined;
5374
+ state$g.renderer = cache?.dom > 0 || cache?.text > 0 ? createRenderer(options) : undefined;
5321
5375
  };
5322
5376
  const render = (nodes, eventMap = {}, newEventMap = {}) => {
5323
- return state$f.renderer?.render(nodes, eventMap, newEventMap) || render$1(nodes, eventMap, newEventMap);
5377
+ return state$g.renderer?.render(nodes, eventMap, newEventMap) || render$1(nodes, eventMap, newEventMap);
5324
5378
  };
5325
5379
  const renderInto = (parent, nodes, eventMap = {}, newEventMap = {}) => {
5326
- if (state$f.renderer) {
5327
- state$f.renderer.renderInto(parent, nodes, eventMap, newEventMap);
5380
+ if (state$g.renderer) {
5381
+ state$g.renderer.renderInto(parent, nodes, eventMap, newEventMap);
5328
5382
  return;
5329
5383
  }
5330
5384
  renderInto$1(parent, nodes, eventMap);
5331
5385
  };
5332
5386
  const applyPatch$1 = (element, patches, eventMap = {}, id = 0) => {
5333
- if (state$f.renderer) {
5334
- state$f.renderer.applyPatch(element, patches, eventMap, id);
5387
+ if (state$g.renderer) {
5388
+ state$g.renderer.applyPatch(element, patches, eventMap, id);
5335
5389
  return;
5336
5390
  }
5337
5391
  applyPatch$2(element, patches, eventMap, id);
5338
5392
  };
5339
5393
  const dispose$l = root => {
5340
- state$f.renderer?.dispose(root);
5394
+ state$g.renderer?.dispose(root);
5341
5395
  };
5342
5396
 
5343
5397
  const applyPatch = (element, patches, eventMap = {}, id = 0) => {
@@ -5351,24 +5405,24 @@ const attachEvents$7 = ($Node, eventMap) => {
5351
5405
  };
5352
5406
 
5353
5407
  const selector = 'textarea[name="composer"]';
5354
- const state$e = {
5408
+ const state$f = {
5355
5409
  handled: false
5356
5410
  };
5357
5411
  const hasFocus = () => !!document.activeElement && document.activeElement !== document.body && document.activeElement !== document.documentElement;
5358
5412
  const dispose$k = viewletId => {
5359
- const pending = state$e.pending;
5413
+ const pending = state$f.pending;
5360
5414
  if (pending && pending.id === viewletId) pending.cancel();
5361
5415
  };
5362
5416
 
5363
5417
  // The route's composer can arrive after the initial workbench frame.
5364
5418
  const focus$d = viewletId => {
5365
- if (state$e.handled || !/(?:^|\/)chat\/?$/.test(location.pathname)) {
5419
+ if (state$f.handled || !/(?:^|\/)chat\/?$/.test(location.pathname)) {
5366
5420
  return;
5367
5421
  }
5368
5422
  if (!get$b(viewletId)?.state.$Viewlet.querySelector(selector)) {
5369
5423
  return;
5370
5424
  }
5371
- state$e.handled = true;
5425
+ state$f.handled = true;
5372
5426
  if (hasFocus()) {
5373
5427
  return;
5374
5428
  }
@@ -5381,9 +5435,9 @@ const focus$d = viewletId => {
5381
5435
  document.removeEventListener('focusin', cancel, true);
5382
5436
  mutations?.disconnect();
5383
5437
  sizes?.disconnect();
5384
- state$e.pending = undefined;
5438
+ state$f.pending = undefined;
5385
5439
  };
5386
- state$e.pending = {
5440
+ state$f.pending = {
5387
5441
  cancel,
5388
5442
  id: viewletId
5389
5443
  };
@@ -5425,25 +5479,25 @@ const focus$d = viewletId => {
5425
5479
  requestAnimationFrame(() => requestAnimationFrame(tryFocus));
5426
5480
  };
5427
5481
 
5428
- const state$d = {
5482
+ const state$e = {
5429
5483
  styleSheets: Object.create(null),
5430
5484
  texts: Object.create(null)
5431
5485
  };
5432
- const set$6 = (id, sheet) => {
5433
- state$d.styleSheets[id] = sheet;
5486
+ const set$7 = (id, sheet) => {
5487
+ state$e.styleSheets[id] = sheet;
5434
5488
  };
5435
5489
  const get$5 = id => {
5436
- return state$d.styleSheets[id];
5490
+ return state$e.styleSheets[id];
5437
5491
  };
5438
5492
  const setText$1 = (id, text) => {
5439
- state$d.texts[id] = text;
5493
+ state$e.texts[id] = text;
5440
5494
  };
5441
5495
  const getText = id => {
5442
- return state$d.texts[id];
5496
+ return state$e.texts[id];
5443
5497
  };
5444
5498
  const remove$2 = id => {
5445
- delete state$d.styleSheets[id];
5446
- delete state$d.texts[id];
5499
+ delete state$e.styleSheets[id];
5500
+ delete state$e.texts[id];
5447
5501
  };
5448
5502
 
5449
5503
  const addCssStyleSheet = (id, text) => {
@@ -5461,7 +5515,7 @@ const addCssStyleSheet = (id, text) => {
5461
5515
  const sheet = new CSSStyleSheet({});
5462
5516
  sheet.replaceSync(text);
5463
5517
  document.adoptedStyleSheets.push(sheet);
5464
- set$6(id, sheet);
5518
+ set$7(id, sheet);
5465
5519
  setText$1(id, text);
5466
5520
  if (id === 'ContributedColorTheme') {
5467
5521
  window.dispatchEvent(new Event('color-theme-changed'));
@@ -5519,25 +5573,25 @@ const PointerUp = 'pointerup';
5519
5573
  const Resize = 'resize';
5520
5574
  const Wheel = 'wheel';
5521
5575
 
5522
- const state$c = {
5576
+ const state$d = {
5523
5577
  currentDragInfo: undefined
5524
5578
  };
5525
- const set$5 = (id, data) => {
5526
- state$c.currentDragInfo = data;
5579
+ const set$6 = (id, data) => {
5580
+ state$d.currentDragInfo = data;
5527
5581
  setDragInfo(id, data);
5528
5582
  };
5529
5583
  const getCurrent = () => {
5530
- return state$c.currentDragInfo;
5584
+ return state$d.currentDragInfo;
5531
5585
  };
5532
5586
 
5533
- const state$b = {
5587
+ const state$c = {
5534
5588
  identifiers: new Uint32Array()
5535
5589
  };
5536
5590
  const setIdentifiers$1 = identifiers => {
5537
- state$b.identifiers = identifiers;
5591
+ state$c.identifiers = identifiers;
5538
5592
  };
5539
5593
  const getIdentifiers = () => {
5540
- return state$b.identifiers;
5594
+ return state$c.identifiers;
5541
5595
  };
5542
5596
 
5543
5597
  // TODO store keybindings as JSON somewhere
@@ -5656,11 +5710,11 @@ const register = (uid, targetUid, listeners) => {
5656
5710
  };
5657
5711
 
5658
5712
  const pendingBatches = new Map();
5659
- const state$a = {
5713
+ const state$b = {
5660
5714
  nextTransactionId: 1
5661
5715
  };
5662
5716
  const queue = (uid, commands, focusVersion = 0) => {
5663
- const transactionId = state$a.nextTransactionId++;
5717
+ const transactionId = state$b.nextTransactionId++;
5664
5718
  pendingBatches.set(transactionId, {
5665
5719
  commands,
5666
5720
  committed: false,
@@ -5675,7 +5729,7 @@ const take = (uid, transactionId, focusVersion = 0) => {
5675
5729
  if (!batch) {
5676
5730
  // An allocated transaction may have been discarded with its view. Late or
5677
5731
  // duplicate commits are harmless and must not affect a recreated root.
5678
- if (transactionId > 0 && transactionId < state$a.nextTransactionId) return [];
5732
+ if (transactionId > 0 && transactionId < state$b.nextTransactionId) return [];
5679
5733
  throw new Error(`pending viewlet command transaction not found: ${transactionId}`);
5680
5734
  }
5681
5735
  if (batch.uid !== uid) {
@@ -5865,7 +5919,7 @@ class VError extends Error {
5865
5919
  }
5866
5920
 
5867
5921
  // TODO this file is not needed when all elements are position fixed
5868
- const state$9 = {
5922
+ const state$a = {
5869
5923
  $Widgets: undefined,
5870
5924
  widgetSet: new Set()
5871
5925
  };
@@ -5877,20 +5931,20 @@ const create$Widgets = () => {
5877
5931
  };
5878
5932
  const append$1 = $Element => {
5879
5933
  // TODO should not call append in the first place if it is already in DOM
5880
- if (state$9.widgetSet.has($Element)) {
5934
+ if (state$a.widgetSet.has($Element)) {
5881
5935
  return;
5882
5936
  }
5883
- state$9.widgetSet.add($Element);
5884
- if (state$9.$Widgets) {
5937
+ state$a.widgetSet.add($Element);
5938
+ if (state$a.$Widgets) {
5885
5939
  // @ts-expect-error
5886
- state$9.$Widgets.append($Element);
5940
+ state$a.$Widgets.append($Element);
5887
5941
  } else {
5888
5942
  // @ts-expect-error
5889
- state$9.$Widgets = create$Widgets();
5943
+ state$a.$Widgets = create$Widgets();
5890
5944
  // @ts-expect-error
5891
- state$9.$Widgets.append($Element);
5945
+ state$a.$Widgets.append($Element);
5892
5946
  // @ts-expect-error
5893
- document.body.append(state$9.$Widgets);
5947
+ document.body.append(state$a.$Widgets);
5894
5948
  }
5895
5949
  };
5896
5950
  const remove$1 = $Element => {
@@ -5898,13 +5952,13 @@ const remove$1 = $Element => {
5898
5952
  // TODO $Element should always be defined
5899
5953
  return;
5900
5954
  }
5901
- state$9.widgetSet.delete($Element);
5955
+ state$a.widgetSet.delete($Element);
5902
5956
  $Element.remove();
5903
5957
  // TODO state.$Widgets should always be defined at this point
5904
- if (state$9.widgetSet.size === 0 && state$9.$Widgets) {
5958
+ if (state$a.widgetSet.size === 0 && state$a.$Widgets) {
5905
5959
  // @ts-expect-error
5906
- state$9.$Widgets.remove();
5907
- state$9.$Widgets = undefined;
5960
+ state$a.$Widgets.remove();
5961
+ state$a.$Widgets = undefined;
5908
5962
  }
5909
5963
  };
5910
5964
 
@@ -6234,7 +6288,7 @@ const applyUidWorkaround = element => {
6234
6288
  throw new Error('no editor found');
6235
6289
  }
6236
6290
  const editorUid = get$9(editor);
6237
- set$a(element, editorUid);
6291
+ set$b(element, editorUid);
6238
6292
  };
6239
6293
 
6240
6294
  const startTracking$1 = ($Target, pointerId, handlePointerMove, handlePointerUp) => {
@@ -6753,7 +6807,7 @@ const sendToIframe = (contentWindow, message, origin, transfer) => {
6753
6807
  };
6754
6808
 
6755
6809
  const webViews = Object.create(null);
6756
- const set$4 = (id, webView) => {
6810
+ const set$5 = (id, webView) => {
6757
6811
  webViews[id] = webView;
6758
6812
  };
6759
6813
  const get$4 = id => {
@@ -8256,16 +8310,16 @@ const EditorTextError = 'EditorTextError';
8256
8310
  const EditorRename = 'EditorRename';
8257
8311
  const EditorCodeGenerator = 'EditorCodeGenerator';
8258
8312
 
8259
- const state$8 = {
8313
+ const state$9 = {
8260
8314
  /**
8261
8315
  * @type {HTMLElement|undefined}
8262
8316
  */
8263
8317
  $PreviousFocusElement: undefined};
8264
8318
  const setElement = $Element => {
8265
- state$8.$PreviousFocusElement = $Element;
8319
+ state$9.$PreviousFocusElement = $Element;
8266
8320
  };
8267
8321
  const getElement = () => {
8268
- return state$8.$PreviousFocusElement;
8322
+ return state$9.$PreviousFocusElement;
8269
8323
  };
8270
8324
 
8271
8325
  const focus$6 = $Element => {
@@ -8531,7 +8585,7 @@ const screenCaptures = Object.create(null);
8531
8585
  const get$3 = id => {
8532
8586
  return screenCaptures[id];
8533
8587
  };
8534
- const set$3 = (id, captureStream) => {
8588
+ const set$4 = (id, captureStream) => {
8535
8589
  screenCaptures[id] = captureStream;
8536
8590
  };
8537
8591
 
@@ -8544,7 +8598,7 @@ const start = async (id, options) => {
8544
8598
  number(id);
8545
8599
  object(options);
8546
8600
  const captureStream = await navigator.mediaDevices.getUserMedia(options);
8547
- set$3(id, captureStream);
8601
+ set$4(id, captureStream);
8548
8602
  } catch (error) {
8549
8603
  throw new VError(error, `Failed to start screen capture`);
8550
8604
  }
@@ -8673,11 +8727,11 @@ const ViewletSidebar = {
8673
8727
  };
8674
8728
 
8675
8729
  const pendingSelections = new WeakMap();
8676
- const state$7 = {};
8730
+ const state$8 = {};
8677
8731
  const handleFocus$1 = event => {
8678
8732
  const target = event.target;
8679
8733
  if (target instanceof HTMLElement && !target.closest('.SimpleBrowser') && target.closest('.Main, .Panel, .Editor, .Terminal')) {
8680
- state$7.codingFocus = new WeakRef(target);
8734
+ state$8.codingFocus = new WeakRef(target);
8681
8735
  }
8682
8736
  };
8683
8737
  const handleFocusOut$2 = event => {
@@ -8706,7 +8760,7 @@ const listen = () => {
8706
8760
  document.addEventListener('keydown', cancelPendingAddressSelection);
8707
8761
  };
8708
8762
  const restoreCodingFocus$1 = () => {
8709
- const target = state$7.codingFocus?.deref();
8763
+ const target = state$8.codingFocus?.deref();
8710
8764
  if (!target?.isConnected) {
8711
8765
  return false;
8712
8766
  }
@@ -9043,7 +9097,7 @@ const findIndex$1 = ($Container, $Target) => {
9043
9097
 
9044
9098
  // TODO keyboard handling
9045
9099
 
9046
- const state$6 = {
9100
+ const state$7 = {
9047
9101
  $$Menus: [],
9048
9102
  $BackDrop: undefined,
9049
9103
  anchorTime: -1,
@@ -9054,7 +9108,7 @@ const state$6 = {
9054
9108
  };
9055
9109
  const getLevel = $Menu => {
9056
9110
  // @ts-expect-error
9057
- return state$6.$$Menus.indexOf($Menu);
9111
+ return state$7.$$Menus.indexOf($Menu);
9058
9112
  };
9059
9113
  const handleMouseDown$1 = event => {
9060
9114
  const $Target = event.target;
@@ -9124,10 +9178,10 @@ const handleMouseLeave = event => {
9124
9178
 
9125
9179
  // const handleBlur = (event) => {}
9126
9180
  const handleKeyDown = event => {
9127
- state$6.handleKeyDown(event);
9181
+ state$7.handleKeyDown(event);
9128
9182
  };
9129
9183
  const handleFocusOut$1 = event => {
9130
- state$6.handleFocusOut(event);
9184
+ state$7.handleFocusOut(event);
9131
9185
  };
9132
9186
  const create$Menu$1 = () => {
9133
9187
  // TODO set aria label on menu (e.g. File, Edit, Selection)
@@ -9155,7 +9209,7 @@ const create$Menu$1 = () => {
9155
9209
  return $Menu;
9156
9210
  };
9157
9211
  const focusIndex = (level, oldFocusedIndex, newFocusedIndex) => {
9158
- const $Menu = state$6.$$Menus[level];
9212
+ const $Menu = state$7.$$Menus[level];
9159
9213
  if (oldFocusedIndex !== -1) {
9160
9214
  // @ts-expect-error
9161
9215
  $Menu.children[oldFocusedIndex].classList.remove('MenuItemFocused');
@@ -9177,21 +9231,21 @@ const handleBackDropMouseDown = event => {
9177
9231
  preventDefault(event);
9178
9232
  stopPropagation(event);
9179
9233
  send$1(/* Menu.hide */'Menu.hide');
9180
- if (state$6.$BackDrop) {
9181
- remove$1(state$6.$BackDrop);
9182
- state$6.$BackDrop = undefined;
9234
+ if (state$7.$BackDrop) {
9235
+ remove$1(state$7.$BackDrop);
9236
+ state$7.$BackDrop = undefined;
9183
9237
  }
9184
9238
  };
9185
9239
  const handleContextMenu$1 = event => {
9186
9240
  preventDefault(event);
9187
9241
  };
9188
9242
  const showMenu = async (x, y, width, height, items, level, parentIndex = -1, dom = [], mouseBlocking = false) => {
9189
- if (mouseBlocking && !state$6.$BackDrop) {
9243
+ if (mouseBlocking && !state$7.$BackDrop) {
9190
9244
  const $BackDrop = create$BackDrop();
9191
9245
  $BackDrop.onmousedown = handleBackDropMouseDown;
9192
9246
  $BackDrop.oncontextmenu = handleContextMenu$1;
9193
9247
  // @ts-expect-error
9194
- state$6.$BackDrop = $BackDrop;
9248
+ state$7.$BackDrop = $BackDrop;
9195
9249
  append$1($BackDrop);
9196
9250
  }
9197
9251
  const $Menu = create$Menu$1();
@@ -9199,7 +9253,7 @@ const showMenu = async (x, y, width, height, items, level, parentIndex = -1, dom
9199
9253
  setBounds$a($Menu, x, y, width, height);
9200
9254
  $Menu.id = `Menu-${level}`;
9201
9255
  if (parentIndex !== -1) {
9202
- const $ParentMenu = state$6.$$Menus[level - 1];
9256
+ const $ParentMenu = state$7.$$Menus[level - 1];
9203
9257
  // @ts-expect-error
9204
9258
  const $ParentMenuItem = $ParentMenu.children[parentIndex];
9205
9259
  $ParentMenuItem.ariaExpanded = True;
@@ -9207,7 +9261,7 @@ const showMenu = async (x, y, width, height, items, level, parentIndex = -1, dom
9207
9261
  }
9208
9262
 
9209
9263
  // @ts-expect-error
9210
- state$6.$$Menus.push($Menu);
9264
+ state$7.$$Menus.push($Menu);
9211
9265
  append$1($Menu);
9212
9266
  if (level === 0) {
9213
9267
  focus$6($Menu);
@@ -9215,14 +9269,14 @@ const showMenu = async (x, y, width, height, items, level, parentIndex = -1, dom
9215
9269
  }
9216
9270
  };
9217
9271
  const hideSubmenu = level => {
9218
- const $$ChildMenus = state$6.$$Menus.slice(level);
9272
+ const $$ChildMenus = state$7.$$Menus.slice(level);
9219
9273
  for (const $ChildMenu of $$ChildMenus) {
9220
9274
  remove$1($ChildMenu);
9221
9275
  }
9222
- state$6.$$Menus = state$6.$$Menus.slice(0, level);
9223
- if (state$6.$$Menus.length === 0 && state$6.$BackDrop) {
9224
- remove$1(state$6.$BackDrop);
9225
- state$6.$BackDrop = undefined;
9276
+ state$7.$$Menus = state$7.$$Menus.slice(0, level);
9277
+ if (state$7.$$Menus.length === 0 && state$7.$BackDrop) {
9278
+ remove$1(state$7.$BackDrop);
9279
+ state$7.$BackDrop = undefined;
9226
9280
  }
9227
9281
  };
9228
9282
 
@@ -9261,17 +9315,17 @@ const showControlled = ({
9261
9315
  y
9262
9316
  }) => {
9263
9317
  showMenu(x, y, width, height, items, level);
9264
- const $Menu = state$6.$$Menus.at(-1);
9318
+ const $Menu = state$7.$$Menus.at(-1);
9265
9319
  if ($Parent && $Menu) {
9266
9320
  const uid = get$9($Parent);
9267
- set$a($Menu, uid);
9321
+ set$b($Menu, uid);
9268
9322
  }
9269
9323
  // TODO menu should not necessarily know about parent (titleBarMenuBar)
9270
9324
  // it should be the other way around
9271
9325
  // @ts-expect-error
9272
- state$6.$Parent = $Parent;
9273
- state$6.handleFocusOut = handleFocusOut;
9274
- state$6.handleKeyDown = handleKeyDown;
9326
+ state$7.$Parent = $Parent;
9327
+ state$7.handleFocusOut = handleFocusOut;
9328
+ state$7.handleKeyDown = handleKeyDown;
9275
9329
  if ($Parent) {
9276
9330
  // state.$Menu.ariaLabel=''
9277
9331
  // state.$Menu.ariaLabelledBy =$Parent.id
@@ -9283,13 +9337,13 @@ const showControlled = ({
9283
9337
  // TODO have function to show submenu
9284
9338
 
9285
9339
  const hide = (restoreFocus = true) => {
9286
- for (const $Menu of state$6.$$Menus) {
9340
+ for (const $Menu of state$7.$$Menus) {
9287
9341
  remove$1($Menu);
9288
9342
  }
9289
- state$6.$$Menus = [];
9290
- if (state$6.$BackDrop) {
9291
- remove$1(state$6.$BackDrop);
9292
- state$6.$BackDrop = undefined;
9343
+ state$7.$$Menus = [];
9344
+ if (state$7.$BackDrop) {
9345
+ remove$1(state$7.$BackDrop);
9346
+ state$7.$BackDrop = undefined;
9293
9347
  }
9294
9348
  // TODO focus previous item
9295
9349
  if (restoreFocus) {
@@ -9534,8 +9588,8 @@ const openMenu = (state, unFocusIndex, index, level, menuItems, menuFocusedIndex
9534
9588
  $Viewlet.children[unFocusIndex].removeAttribute(AriaOwns);
9535
9589
  }
9536
9590
  $Viewlet.children[index].ariaExpanded = True;
9537
- const $$Menus = state$6.$$Menus;
9538
- state$6.$$Menus = [];
9591
+ const $$Menus = state$7.$$Menus;
9592
+ state$7.$$Menus = [];
9539
9593
  // @ts-expect-error
9540
9594
  showControlled({
9541
9595
  $Parent: $Viewlet.children[index],
@@ -9600,7 +9654,7 @@ const addMenu = ($$Menus, change, uid) => {
9600
9654
  const menu = change[1];
9601
9655
  const dom = change[2];
9602
9656
  const $Menu = create$Menu();
9603
- set$a($Menu, uid);
9657
+ set$b($Menu, uid);
9604
9658
  $Menu.onmousemove = handleMenuMouseOver;
9605
9659
  $Menu.onmouseleave = handleMenuMouseLeave;
9606
9660
  $Menu.onclick = handleMenuClick;
@@ -9844,7 +9898,7 @@ const setIframe = (state, src, sandbox = [], srcDoc = '', csp = '', credentialle
9844
9898
  $Iframe.className = 'E2eTestIframe WebViewIframe';
9845
9899
  $Parent.append($Iframe);
9846
9900
  state.frame = $Iframe;
9847
- set$4(1, $Iframe);
9901
+ set$5(1, $Iframe);
9848
9902
  };
9849
9903
  const setPort$1 = (state, portId, origin) => {
9850
9904
  const port = acquire(portId);
@@ -9942,14 +9996,14 @@ const load$1 = moduleId => {
9942
9996
  return loadModule();
9943
9997
  };
9944
9998
 
9945
- const state$5 = {
9999
+ const state$6 = {
9946
10000
  currentPanelView: undefined,
9947
10001
  currentSidebarView: undefined,
9948
10002
  modules: Object.create(null)
9949
10003
  };
9950
10004
 
9951
10005
  const create$4 = (id, uid = id) => {
9952
- const module = state$5.modules[id];
10006
+ const module = state$6.modules[id];
9953
10007
  if (!module) {
9954
10008
  throw new Error(`module not found: ${id}`);
9955
10009
  }
@@ -9958,17 +10012,17 @@ const create$4 = (id, uid = id) => {
9958
10012
  existing.state.$Viewlet.remove();
9959
10013
  }
9960
10014
  const instanceState = module.create();
9961
- set$a(instanceState.$Viewlet, uid);
10015
+ set$b(instanceState.$Viewlet, uid);
9962
10016
  if (module.attachEvents) {
9963
10017
  module.attachEvents(instanceState);
9964
10018
  }
9965
- set$c(uid, {
10019
+ set$d(uid, {
9966
10020
  factory: module,
9967
10021
  state: instanceState
9968
10022
  });
9969
10023
  };
9970
10024
  const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcId, eventTargetUid = uid) => {
9971
- let module = state$5.modules[id];
10025
+ let module = state$6.modules[id];
9972
10026
  if (hasFunctionalEvents) {
9973
10027
  module ||= {};
9974
10028
  }
@@ -9983,11 +10037,11 @@ const createFunctionalRoot = (id, uid = id, hasFunctionalEvents, directEventRpcI
9983
10037
  const instanceState = {
9984
10038
  $Viewlet: document.createElement('div')
9985
10039
  };
9986
- set$a(instanceState.$Viewlet, uid);
10040
+ set$b(instanceState.$Viewlet, uid);
9987
10041
  if (existing) dispose$i(uid);
9988
- set$a(instanceState.$Viewlet, eventTargetUid);
10042
+ set$b(instanceState.$Viewlet, eventTargetUid);
9989
10043
  registerView(uid, directEventRpcId);
9990
- set$c(uid, {
10044
+ set$d(uid, {
9991
10045
  factory: module,
9992
10046
  state: instanceState
9993
10047
  });
@@ -10003,7 +10057,7 @@ const removeKeyBindings = id => {
10003
10057
  const loadModule = async id => {
10004
10058
  try {
10005
10059
  const module = await load$1(id);
10006
- state$5.modules[id] = module;
10060
+ state$6.modules[id] = module;
10007
10061
  } catch (error) {
10008
10062
  throw new VError(error, `Failed to load ${id}`);
10009
10063
  }
@@ -10114,7 +10168,7 @@ const setUid = (viewletId, uid) => {
10114
10168
  const {
10115
10169
  $Viewlet
10116
10170
  } = instance.state;
10117
- set$a($Viewlet, uid);
10171
+ set$b($Viewlet, uid);
10118
10172
  };
10119
10173
  const focusCallback = {
10120
10174
  id: 0,
@@ -10189,7 +10243,7 @@ const refresh = (viewletId, viewletContext) => {
10189
10243
  instance.factory.refresh(instance.state, viewletContext);
10190
10244
  } else {
10191
10245
  // @ts-expect-error
10192
- state$5.refreshContext[viewletId] = viewletContext;
10246
+ state$6.refreshContext[viewletId] = viewletContext;
10193
10247
  }
10194
10248
  };
10195
10249
  const specialIds = new Set(['TitleBar', 'SideBar', 'Main', 'ActivityBar', 'StatusBar', 'Panel']);
@@ -10206,14 +10260,14 @@ const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
10206
10260
  const parentInstance = get$b(parentId);
10207
10261
  const $Parent = parentInstance.state.$Viewlet;
10208
10262
  $Parent.append($Placeholder);
10209
- set$c(viewletId, {
10263
+ set$d(viewletId, {
10210
10264
  state: {
10211
10265
  $Viewlet: $Placeholder
10212
10266
  }
10213
10267
  });
10214
10268
  };
10215
10269
  const setDragData = (viewletId, dragData) => {
10216
- set$5(viewletId, dragData);
10270
+ set$6(viewletId, dragData);
10217
10271
  };
10218
10272
  const getDragData = () => {
10219
10273
  return getCurrent();
@@ -10264,7 +10318,7 @@ const restoreComponentDom = viewletId => {
10264
10318
  }
10265
10319
  }
10266
10320
  instance.state.$Viewlet.replaceWith($Original);
10267
- set$c(viewletId, {
10321
+ set$d(viewletId, {
10268
10322
  ...instance,
10269
10323
  componentDom: undefined,
10270
10324
  componentDomOriginal: undefined,
@@ -10312,7 +10366,7 @@ const setComponentDom = (viewletId, dom) => {
10312
10366
  uid
10313
10367
  });
10314
10368
  }
10315
- set$c(viewletId, {
10369
+ set$d(viewletId, {
10316
10370
  ...instance,
10317
10371
  componentDomOriginal: $Original,
10318
10372
  componentDomReferences: references
@@ -10326,7 +10380,7 @@ const setComponentDom = (viewletId, dom) => {
10326
10380
  throw error;
10327
10381
  }
10328
10382
  $Viewlet.replaceWith($Preview);
10329
- set$c(viewletId, {
10383
+ set$d(viewletId, {
10330
10384
  ...instance,
10331
10385
  componentDom: dom,
10332
10386
  componentDomOriginal: $Original,
@@ -10375,9 +10429,9 @@ const setDom2 = (viewletId, dom) => {
10375
10429
  const $NewViewlet = rememberFocus($Viewlet, dom, Events, viewletId);
10376
10430
  if (uid) {
10377
10431
  // @ts-ignore
10378
- set$a($NewViewlet, uid);
10432
+ set$b($NewViewlet, uid);
10379
10433
  }
10380
- set$c(viewletId, {
10434
+ set$d(viewletId, {
10381
10435
  ...instance,
10382
10436
  state: {
10383
10437
  ...instance.state,
@@ -10500,7 +10554,7 @@ const dispose$4 = id => {
10500
10554
  instance.state.$Viewlet.remove();
10501
10555
  }
10502
10556
  removeCssStyleSheet(id);
10503
- set$c(id, undefined);
10557
+ set$d(id, undefined);
10504
10558
  } catch {
10505
10559
  throw new Error(`Failed to dispose ${id}`);
10506
10560
  }
@@ -10791,7 +10845,7 @@ const commandHandlers = {
10791
10845
  'Viewlet.setInputValues': setInputValues,
10792
10846
  'Viewlet.setPatches': setPatches,
10793
10847
  'Viewlet.setProperty': setProperty,
10794
- 'Viewlet.setScrollSpeed': set$d,
10848
+ 'Viewlet.setScrollSpeed': set$e,
10795
10849
  'Viewlet.setSelectionByName': setSelectionByName,
10796
10850
  'Viewlet.setTreePatches': setTreePatches,
10797
10851
  'Viewlet.setUid': setUid,
@@ -10806,7 +10860,7 @@ const getFn = command => {
10806
10860
  return fn;
10807
10861
  };
10808
10862
 
10809
- const state$4 = {
10863
+ const state$5 = {
10810
10864
  duration: 0,
10811
10865
  lastError: '',
10812
10866
  pending: false
@@ -10821,16 +10875,16 @@ const waitForReady = async () => {
10821
10875
  }
10822
10876
  };
10823
10877
  const getStatus = () => ({
10824
- duration: state$4.duration,
10825
- error: state$4.lastError,
10826
- pending: state$4.pending
10878
+ duration: state$5.duration,
10879
+ error: state$5.lastError,
10880
+ pending: state$5.pending
10827
10881
  });
10828
10882
  const restart = async () => {
10829
10883
  const started = performance.now();
10830
10884
  try {
10831
10885
  document.documentElement.inert = true;
10832
10886
  const snapshot = await invoke$1('Reload.prepareHotReload');
10833
- set$9(snapshot);
10887
+ set$a(snapshot);
10834
10888
  await invoke$1('Reload.retire');
10835
10889
  await dispose$p();
10836
10890
  await dispose$q();
@@ -10845,10 +10899,10 @@ const restart = async () => {
10845
10899
  const result = await launchWorkers();
10846
10900
  if (isError(result)) throw result.error;
10847
10901
  await waitForReady();
10848
- set$9(undefined);
10849
- state$4.duration = performance.now() - started;
10902
+ set$a(undefined);
10903
+ state$5.duration = performance.now() - started;
10850
10904
  } catch (error) {
10851
- state$4.lastError = error instanceof Error ? error.message : String(error);
10905
+ state$5.lastError = error instanceof Error ? error.message : String(error);
10852
10906
  console.error(error);
10853
10907
  // Keep the snapshot available for recovery; never silently discard drafts.
10854
10908
  const snapshot = get$7();
@@ -10862,21 +10916,21 @@ const restart = async () => {
10862
10916
  }
10863
10917
  }
10864
10918
  const recovery = document.createElement('button');
10865
- recovery.textContent = `Application restart failed: ${state$4.lastError}. Reload window`;
10919
+ recovery.textContent = `Application restart failed: ${state$5.lastError}. Reload window`;
10866
10920
  recovery.onclick = () => location.reload();
10867
10921
  document.body.append(recovery);
10868
10922
  } finally {
10869
10923
  document.documentElement.inert = false;
10870
- state$4.pending = false;
10924
+ state$5.pending = false;
10871
10925
  }
10872
10926
  };
10873
10927
 
10874
10928
  // Reply on the old RPC before retiring it. Awaiting restart from that RPC would
10875
10929
  // strand the caller when its worker is terminated.
10876
10930
  const request = () => {
10877
- if (state$4.pending) return;
10878
- state$4.pending = true;
10879
- state$4.lastError = '';
10931
+ if (state$5.pending) return;
10932
+ state$5.pending = true;
10933
+ state$5.lastError = '';
10880
10934
  setTimeout(() => void restart(), 0);
10881
10935
  };
10882
10936
 
@@ -11166,7 +11220,7 @@ const addFileHandle = fileHandle => {
11166
11220
  return addFileHandle$1(fileHandle);
11167
11221
  };
11168
11222
 
11169
- const state$3 = {
11223
+ const state$4 = {
11170
11224
  hydrated: false,
11171
11225
  lastPathName: ''
11172
11226
  };
@@ -11186,7 +11240,7 @@ const setPathName = pathName => {
11186
11240
  return;
11187
11241
  }
11188
11242
  history.pushState(null, '', pathName);
11189
- state$3.lastPathName = getPathName();
11243
+ state$4.lastPathName = getPathName();
11190
11244
  };
11191
11245
  const setHash = hash => {
11192
11246
  const currentHref = getHref();
@@ -11232,21 +11286,21 @@ const handlePopState = () => {
11232
11286
  } else if (isChatPath(pathName)) {
11233
11287
  send$1('Layout.enterAiNativeLayout');
11234
11288
  executeExtensionCommand('chat2.show');
11235
- } else if (isChatPath(state$3.lastPathName) || isBoardPath(state$3.lastPathName)) {
11289
+ } else if (isChatPath(state$4.lastPathName) || isBoardPath(state$4.lastPathName)) {
11236
11290
  executeExtensionCommand('chat2.showIdeLayout');
11237
11291
  }
11238
- state$3.lastPathName = pathName;
11292
+ state$4.lastPathName = pathName;
11239
11293
  };
11240
11294
  const hydrate = () => {
11241
- if (state$3.hydrated) {
11295
+ if (state$4.hydrated) {
11242
11296
  return;
11243
11297
  }
11244
- state$3.lastPathName = getPathName();
11245
- if (isChatPath(state$3.lastPathName)) {
11298
+ state$4.lastPathName = getPathName();
11299
+ if (isChatPath(state$4.lastPathName)) {
11246
11300
  send$1('Layout.enterAiNativeLayout');
11247
11301
  }
11248
11302
  addEventListener('popstate', handlePopState);
11249
- state$3.hydrated = true;
11303
+ state$4.hydrated = true;
11250
11304
  };
11251
11305
 
11252
11306
  const getConfig = () => {
@@ -11338,7 +11392,7 @@ const setModernUi = enabled => {
11338
11392
  document.body.classList.toggle('ModernUi', enabled);
11339
11393
  };
11340
11394
 
11341
- const state$2 = {
11395
+ const state$3 = {
11342
11396
  nextNotificationId: 0
11343
11397
  };
11344
11398
  const pendingChoices = new WeakMap();
@@ -11368,7 +11422,7 @@ const create$Notification = message => {
11368
11422
  const $NotificationMessage = create$NotificationMessage(message);
11369
11423
  const $CloseButton = create$CloseButton();
11370
11424
  const $Notification = document.createElement('div');
11371
- $Notification.id = `Notification-${++state$2.nextNotificationId}`;
11425
+ $Notification.id = `Notification-${++state$3.nextNotificationId}`;
11372
11426
  $Notification.className = 'Notification';
11373
11427
  $Notification.append($NotificationMessage, $CloseButton);
11374
11428
  return $Notification;
@@ -11417,7 +11471,7 @@ const create$NotificationWithOptions = (message, options) => {
11417
11471
  $NotificationOptions.append($NotificationOption);
11418
11472
  }
11419
11473
  const $Notification = document.createElement('div');
11420
- $Notification.id = `Notification-${++state$2.nextNotificationId}`;
11474
+ $Notification.id = `Notification-${++state$3.nextNotificationId}`;
11421
11475
  $Notification.className = 'Notification';
11422
11476
  $Notification.append($NotificationMessage, $CloseButton, $NotificationOptions);
11423
11477
  $Notification.onclick = handleNotificationClick;
@@ -11527,17 +11581,17 @@ const createCanvasPresentation = (canvas, onDispose) => {
11527
11581
  };
11528
11582
  };
11529
11583
 
11530
- const state$1 = {
11584
+ const state$2 = {
11531
11585
  canvasObjects: Object.create(null)
11532
11586
  };
11533
- const set$2 = (canvasId, canvas) => {
11534
- state$1.canvasObjects[canvasId] = canvas;
11587
+ const set$3 = (canvasId, canvas) => {
11588
+ state$2.canvasObjects[canvasId] = canvas;
11535
11589
  };
11536
11590
 
11537
11591
  const create$2 = async (canvasId, objectId) => {
11538
11592
  const canvas = document.createElement('canvas');
11539
11593
  const offscreenCanvas = canvas.transferControlToOffscreen();
11540
- set$2(canvasId, canvas);
11594
+ set$3(canvasId, canvas);
11541
11595
  await invokeAndTransfer('Transferrable.transfer', objectId, offscreenCanvas);
11542
11596
  };
11543
11597
  const create2 = async (canvasId, objectId, width, height) => {
@@ -11550,7 +11604,7 @@ const create2 = async (canvasId, objectId, width, height) => {
11550
11604
  }
11551
11605
  const offscreenCanvas = canvas.transferControlToOffscreen();
11552
11606
  canvas.dataset.id = canvasId;
11553
- set$c(canvasId, {
11607
+ set$d(canvasId, {
11554
11608
  factory: {},
11555
11609
  state: {
11556
11610
  $Viewlet: canvas
@@ -11569,9 +11623,9 @@ const createForPreview = async (canvasId, objectId, portId, width, height) => {
11569
11623
  canvas.height = height;
11570
11624
  canvas.dataset.id = String(canvasId);
11571
11625
  const offscreen = new OffscreenCanvas(width, height);
11572
- const presentation = createCanvasPresentation(canvas, () => set$c(canvasId, undefined));
11626
+ const presentation = createCanvasPresentation(canvas, () => set$d(canvasId, undefined));
11573
11627
  // Keep the receiving port reachable until the sandbox disposes this canvas.
11574
- set$c(canvasId, {
11628
+ set$d(canvasId, {
11575
11629
  factory: {},
11576
11630
  state: {
11577
11631
  $Viewlet: canvas,
@@ -12516,6 +12570,31 @@ const revealBrowserTab = revealBrowserTab$1;
12516
12570
  const rememberBrowserParent = rememberBrowserParent$1;
12517
12571
  const restoreBrowserParent = restoreBrowserParent$1;
12518
12572
 
12573
+ const state$1 = {
12574
+ icon: undefined
12575
+ };
12576
+
12577
+ // Keep the application's original icons intact so removing this override
12578
+ // restores the default favicon, including deployments under a path prefix.
12579
+ const set$2 = href => {
12580
+ if (!href) {
12581
+ state$1.icon?.remove();
12582
+ state$1.icon = undefined;
12583
+ return;
12584
+ }
12585
+ const url = new URL(href);
12586
+ const isImageData = /^data:image\/(?:png;base64,|svg\+xml,)/u.test(href);
12587
+ if (url.protocol !== 'https:' && !isImageData) {
12588
+ throw new Error('Favicon URL must use HTTPS or PNG/SVG image data');
12589
+ }
12590
+ if (!state$1.icon) {
12591
+ state$1.icon = document.createElement('link');
12592
+ state$1.icon.rel = 'icon';
12593
+ }
12594
+ state$1.icon.href = url.href;
12595
+ document.head.append(state$1.icon);
12596
+ };
12597
+
12519
12598
  const set$1 = title => {
12520
12599
  document.title = title;
12521
12600
  };
@@ -12593,7 +12672,7 @@ const create$1 = async (uid, src, sandbox, csp, credentialless, permissionPolicy
12593
12672
  if (title) {
12594
12673
  $Iframe.title = title;
12595
12674
  }
12596
- set$4(uid, $Iframe);
12675
+ set$5(uid, $Iframe);
12597
12676
  // TODO make make waitForFrameToLoad a separate command
12598
12677
  };
12599
12678
  const loadOnly = async uid => {
@@ -12898,6 +12977,7 @@ const commandMap = {
12898
12977
  'DropData.get': get$1,
12899
12978
  'EditorKeymap.register': register$1,
12900
12979
  'EditorKeymap.remove': remove$5,
12980
+ 'Favicon.set': set$2,
12901
12981
  'FileHandles.get': get,
12902
12982
  'FilePicker.showDirectoryPicker': showDirectoryPicker,
12903
12983
  'FilePicker.showFilePicker': showFilePicker,
@@ -12996,7 +13076,7 @@ const commandMap = {
12996
13076
  'Viewlet.sendMultiple': sendMultiple,
12997
13077
  'Viewlet.setBounds': setBounds$1,
12998
13078
  'Viewlet.setComponentDom': setComponentDom,
12999
- 'Viewlet.setScrollSpeed': set$d,
13079
+ 'Viewlet.setScrollSpeed': set$e,
13000
13080
  'Viewlet.show': show,
13001
13081
  'VirtualDom.configure': configure,
13002
13082
  'WebRtc.readMicLevels': readMicLevels,
@@ -13132,15 +13212,15 @@ const main = async () => {
13132
13212
  initialize$1(location.search);
13133
13213
  Object.assign(commandMapRef, commandMap);
13134
13214
  enable(window);
13135
- state$5.modules[ColorPicker] = ViewletColorPicker;
13136
- state$5.modules[EditorCodeGenerator] = ViewletEditorCodeGenerator;
13137
- state$5.modules[EditorCompletion] = ViewletEditorCompletion;
13138
- state$5.modules[EditorCompletionDetails] = ViewletEditorCompletionDetails;
13139
- state$5.modules[EditorHover] = ViewletEditorHover;
13140
- state$5.modules[EditorRename] = ViewletEditorRename;
13141
- state$5.modules[EditorSourceActions] = ViewletEditorSourceActions;
13142
- state$5.modules[FindWidget] = ViewletFindWidget;
13143
- state$5.modules[TitleBar] = ViewletTitleBar;
13215
+ state$6.modules[ColorPicker] = ViewletColorPicker;
13216
+ state$6.modules[EditorCodeGenerator] = ViewletEditorCodeGenerator;
13217
+ state$6.modules[EditorCompletion] = ViewletEditorCompletion;
13218
+ state$6.modules[EditorCompletionDetails] = ViewletEditorCompletionDetails;
13219
+ state$6.modules[EditorHover] = ViewletEditorHover;
13220
+ state$6.modules[EditorRename] = ViewletEditorRename;
13221
+ state$6.modules[EditorSourceActions] = ViewletEditorSourceActions;
13222
+ state$6.modules[FindWidget] = ViewletFindWidget;
13223
+ state$6.modules[TitleBar] = ViewletTitleBar;
13144
13224
  // TODO this is discovered very late
13145
13225
  const launchWorkersResult = await launchWorkers();
13146
13226
  if (isError(launchWorkersResult)) {