@lvce-editor/renderer-process 4.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -270,7 +270,7 @@ let VError$1 = class VError extends Error {
270
270
  }
271
271
  };
272
272
 
273
- const state$b = {
273
+ const state$c = {
274
274
  commands: Object.create(null),
275
275
  pendingModules: Object.create(null),
276
276
  async load(moduleId) {}
@@ -291,7 +291,7 @@ const initializeModule = module => {
291
291
  };
292
292
  const loadModule$1 = async moduleId => {
293
293
  try {
294
- const module = await state$b.load(moduleId);
294
+ const module = await state$c.load(moduleId);
295
295
  initializeModule(module);
296
296
  } catch (error) {
297
297
  if (error && error instanceof SyntaxError && error.stack === `SyntaxError: ${error.message}`) {
@@ -302,16 +302,16 @@ const loadModule$1 = async moduleId => {
302
302
  }
303
303
  };
304
304
  const getOrLoadModule = moduleId => {
305
- if (!state$b.pendingModules[moduleId]) {
306
- state$b.pendingModules[moduleId] = loadModule$1(moduleId);
305
+ if (!state$c.pendingModules[moduleId]) {
306
+ state$c.pendingModules[moduleId] = loadModule$1(moduleId);
307
307
  }
308
- return state$b.pendingModules[moduleId];
308
+ return state$c.pendingModules[moduleId];
309
309
  };
310
310
  const loadCommand = async command => {
311
311
  await getOrLoadModule(getModuleId(command));
312
312
  };
313
313
  const register = (commandId, listener) => {
314
- state$b.commands[commandId] = listener;
314
+ state$c.commands[commandId] = listener;
315
315
  };
316
316
  const hasThrown = new Set();
317
317
  const executeCommandAsync = async (command, ...args) => {
@@ -320,7 +320,7 @@ const executeCommandAsync = async (command, ...args) => {
320
320
  } catch (error) {
321
321
  throw new VError$1(error, `Failed to load command ${command}`);
322
322
  }
323
- if (!(command in state$b.commands)) {
323
+ if (!(command in state$c.commands)) {
324
324
  if (hasThrown.has(command)) {
325
325
  return;
326
326
  }
@@ -330,8 +330,8 @@ const executeCommandAsync = async (command, ...args) => {
330
330
  return execute(command, ...args);
331
331
  };
332
332
  const execute = (command, ...args) => {
333
- if (command in state$b.commands) {
334
- const fn = state$b.commands[command];
333
+ if (command in state$c.commands) {
334
+ const fn = state$c.commands[command];
335
335
  if (typeof fn !== 'function') {
336
336
  throw new Error(`[renderer-worker] Command ${command} is not a function`);
337
337
  }
@@ -340,7 +340,7 @@ const execute = (command, ...args) => {
340
340
  return executeCommandAsync(command, ...args);
341
341
  };
342
342
  const setLoad = load => {
343
- state$b.load = load;
343
+ state$c.load = load;
344
344
  };
345
345
 
346
346
  /**
@@ -361,7 +361,7 @@ const handleBeforeInstallPrompt = event => {
361
361
  preventDefault(event);
362
362
  };
363
363
 
364
- const state$a = {
364
+ const state$b = {
365
365
  /**
366
366
  * @type {any[]}
367
367
  */
@@ -369,10 +369,10 @@ const state$a = {
369
369
  };
370
370
  const addError = error => {
371
371
  // @ts-expect-error
372
- state$a.errors.push(error);
372
+ state$b.errors.push(error);
373
373
  };
374
374
  const hasRecentErrors = () => {
375
- return state$a.errors.length > 0;
375
+ return state$b.errors.length > 0;
376
376
  };
377
377
  const getRecentError = () => {
378
378
  };
@@ -493,10 +493,10 @@ const getPlatform = () => {
493
493
  };
494
494
  const platform = getPlatform();
495
495
 
496
- const Two$1 = '2.0';
496
+ const Two = '2.0';
497
497
  const create$4$1 = (method, params) => {
498
498
  return {
499
- jsonrpc: Two$1,
499
+ jsonrpc: Two,
500
500
  method,
501
501
  params
502
502
  };
@@ -547,11 +547,11 @@ const get$6 = id => {
547
547
  const remove$2 = id => {
548
548
  delete state$1$1.callbacks[id];
549
549
  };
550
- const state$9 = {
550
+ const state$a = {
551
551
  id: 0
552
552
  };
553
553
  const create$3$1 = () => {
554
- return ++state$9.id;
554
+ return ++state$a.id;
555
555
  };
556
556
  const warn$1 = (...args) => {
557
557
  console.warn(...args);
@@ -598,7 +598,7 @@ const create$2$1 = (method, params) => {
598
598
  promise
599
599
  } = registerPromise();
600
600
  const message = {
601
- jsonrpc: Two$1,
601
+ jsonrpc: Two,
602
602
  method,
603
603
  params,
604
604
  id
@@ -744,7 +744,7 @@ const unwrapJsonRpcResult = responseMessage => {
744
744
  };
745
745
  const create$1$1 = (message, error) => {
746
746
  return {
747
- jsonrpc: Two$1,
747
+ jsonrpc: Two,
748
748
  id: message.id,
749
749
  error
750
750
  };
@@ -777,7 +777,7 @@ const getErrorResponse = (message, error, ipc, preparePrettyError, logError) =>
777
777
  };
778
778
  const create$M = (message, result) => {
779
779
  return {
780
- jsonrpc: Two$1,
780
+ jsonrpc: Two,
781
781
  id: message.id,
782
782
  result: result ?? null
783
783
  };
@@ -819,7 +819,17 @@ const send$1 = (transport, method, ...params) => {
819
819
  const message = create$4$1(method, params);
820
820
  transport.send(message);
821
821
  };
822
- const invokeAndTransfer = async (ipc, handle, method, ...params) => {
822
+ const invoke$2 = async (ipc, method, ...params) => {
823
+ const {
824
+ message,
825
+ promise
826
+ } = create$2$1(method, params);
827
+ ipc.send(message);
828
+ const responseMessage = await promise;
829
+ const result = unwrapJsonRpcResult(responseMessage);
830
+ return result;
831
+ };
832
+ const invokeAndTransfer$1 = async (ipc, handle, method, ...params) => {
823
833
  const {
824
834
  message,
825
835
  promise
@@ -969,7 +979,7 @@ const launchRendererWorker = async () => {
969
979
  });
970
980
  };
971
981
 
972
- const state$8 = {
982
+ const state$9 = {
973
983
  /**
974
984
  * @type {any}
975
985
  */
@@ -979,14 +989,40 @@ const hydrate$1 = async () => {
979
989
  const ipc = await launchRendererWorker();
980
990
  handleIpc(ipc);
981
991
  // @ts-expect-error
982
- state$8.ipc = ipc;
992
+ state$9.ipc = ipc;
993
+ };
994
+
995
+ // TODO needed?
996
+ const dispose$j = () => {
997
+ // @ts-expect-error
998
+ if (state$9.rendererWorker) {
999
+ // @ts-expect-error
1000
+ state$9.rendererWorker.terminate();
1001
+ }
983
1002
  };
984
1003
  const send = (method, ...params) => {
985
- send$1(state$8.ipc, method, ...params);
1004
+ send$1(state$9.ipc, method, ...params);
1005
+ };
1006
+ const invoke$1 = (method, ...params) => {
1007
+ return invoke$2(state$9.ipc, method, ...params);
986
1008
  };
987
1009
  const sendAndTransfer = (message, transfer) => {
988
1010
  // @ts-expect-error
989
- state$8.ipc.sendAndTransfer(message, transfer);
1011
+ state$9.ipc.sendAndTransfer(message, transfer);
1012
+ };
1013
+ const invokeAndTransfer = (method, transfer, ...params) => {
1014
+ return invokeAndTransfer$1(state$9.ipc, transfer, method, ...params);
1015
+ };
1016
+
1017
+ const RendererWorker = {
1018
+ __proto__: null,
1019
+ dispose: dispose$j,
1020
+ hydrate: hydrate$1,
1021
+ invoke: invoke$1,
1022
+ invokeAndTransfer,
1023
+ send,
1024
+ sendAndTransfer,
1025
+ state: state$9
990
1026
  };
991
1027
 
992
1028
  let AssertionError$1 = class AssertionError extends Error {
@@ -1739,1309 +1775,1439 @@ const handleUnhandledError = (message, filename, lineno, colno, error) => {
1739
1775
  handleError$8(error, Boolean(error), '[renderer-process] Unhandled Error: ');
1740
1776
  };
1741
1777
 
1742
- const main = async () => {
1743
- onerror = handleUnhandledError;
1744
- onunhandledrejection = handleUnhandledRejection;
1745
- if ('SecurityPolicyViolationEvent' in self) {
1746
- self.addEventListener('securitypolicyviolation', handleContentSecurityPolicyViolation);
1747
- }
1748
- setLoad(load$1);
1749
- if (platform === Web) {
1750
- // disable prompt to download app as pwa
1751
- // @ts-expect-error
1752
- window.onbeforeinstallprompt = handleBeforeInstallPrompt;
1753
- }
1754
- // TODO this is discovered very late
1755
- await hydrate$1();
1756
- };
1757
-
1758
- main();
1759
-
1760
- const play = async src => {
1761
- const audio = new Audio(src);
1762
- await audio.play();
1763
- };
1764
-
1765
- const name$y = 'Audio';
1766
- const Commands$z = {
1767
- play: play
1768
- };
1769
-
1770
- const Audio_ipc = {
1771
- __proto__: null,
1772
- Commands: Commands$z,
1773
- name: name$y
1774
- };
1775
-
1776
- const readText = async () => {
1777
- return navigator.clipboard.readText();
1778
- };
1779
- const writeText = async text => {
1780
- string(text);
1781
- await navigator.clipboard.writeText(text);
1782
- };
1783
- const writeImage = async blob => {
1784
- await navigator.clipboard.write([new ClipboardItem({
1785
- [blob.type]: blob
1786
- })]);
1787
- };
1788
- const execCopy = async () => {
1789
- // @ts-expect-error
1790
- const text = getSelection().toString();
1791
- await writeText(text);
1792
- };
1793
-
1794
- const name$x = 'ClipBoard';
1795
- const Commands$y = {
1796
- execCopy: execCopy,
1797
- readText: readText,
1798
- writeImage: writeImage,
1799
- writeText: writeText
1800
- };
1801
-
1802
- const ClipBoard_ipc = {
1803
- __proto__: null,
1804
- Commands: Commands$y,
1805
- name: name$x
1806
- };
1807
-
1808
- const prompt$1 = message => {
1809
- return confirm(message);
1810
- };
1811
-
1812
- const name$w = 'ConfirmPrompt';
1813
- const Commands$x = {
1814
- prompt: prompt$1
1815
- };
1816
-
1817
- const ConfirmPrompt_ipc = {
1818
- __proto__: null,
1819
- Commands: Commands$x,
1820
- name: name$w
1821
- };
1822
-
1823
- const state$7 = {
1824
- styleSheets: Object.create(null)
1825
- };
1826
- const set$4 = (id, sheet) => {
1827
- state$7.styleSheets[id] = sheet;
1828
- };
1829
- const get$5 = id => {
1830
- return state$7.styleSheets[id];
1831
- };
1832
-
1833
- const addCssStyleSheet = async (id, text) => {
1834
- const existing = get$5(id);
1835
- if (existing) {
1836
- await existing.replace(text);
1837
- return;
1838
- }
1839
- const sheet = new CSSStyleSheet({});
1840
- set$4(id, sheet);
1841
- await sheet.replace(text);
1842
- document.adoptedStyleSheets.push(sheet);
1843
- };
1844
-
1845
- const name$v = 'Css';
1846
- const Commands$w = {
1847
- addCssStyleSheet: addCssStyleSheet
1848
- };
1849
-
1850
- const Css_ipc = {
1851
- __proto__: null,
1852
- Commands: Commands$w,
1853
- name: name$v
1778
+ // src/parts/ComponentUid/ComponentUid.ts
1779
+ var uidSymbol = Symbol("uid");
1780
+ var setComponentUid = ($Element, uid) => {
1781
+ $Element[uidSymbol] = uid;
1854
1782
  };
1855
-
1856
- const modules = ['ActivityBar', 'Ajax', 'Allocator', 'Callback', 'Command', 'Context', 'ContextMenu', 'Delay', 'Developer', 'DomPool', 'Editor', 'Exec', 'ExtensionHost', 'FileSystem', 'KeyBindings', 'Layout', 'Main', 'Notification', 'Panel', 'Parts', 'QuickPick', 'Renderer', 'RendererWorker', 'Search', 'SharedProcess', 'SideBar', 'StatusBar', 'TitleBar', 'Viewlet', 'ViewletController', 'ViewService', 'Vscode', 'Window', 'Workbench', 'Worker', 'Workspace'];
1857
-
1858
- // TODO send to renderer worker -> renderer worker has all state
1859
- const showState = async () => {
1860
- const state = Object.create(null);
1861
- for (const module of modules) {
1862
- let imported;
1863
- try {
1864
- imported = await import(`../${module}/${module}.js`);
1865
- } catch {}
1866
- if (imported?.state) {
1867
- state[module] = imported.state;
1783
+ var getUidTarget = $Element => {
1784
+ while ($Element) {
1785
+ if ($Element[uidSymbol]) {
1786
+ return $Element;
1868
1787
  }
1788
+ $Element = $Element.parentNode;
1869
1789
  }
1870
- info(state);
1790
+ return void 0;
1871
1791
  };
1872
-
1873
- const name$u = 'Developer';
1874
- const Commands$v = {
1875
- showState: showState
1792
+ var getComponentUid = $Element => {
1793
+ const $Target = getUidTarget($Element);
1794
+ return $Target[uidSymbol];
1876
1795
  };
1877
-
1878
- const Developer_ipc = {
1879
- __proto__: null,
1880
- Commands: Commands$v,
1881
- name: name$u
1796
+ var getComponentUidFromEvent = event => {
1797
+ const {
1798
+ target,
1799
+ currentTarget
1800
+ } = event;
1801
+ return getComponentUid(currentTarget || target);
1882
1802
  };
1883
1803
 
1884
- const downloadFile = (fileName, url) => {
1885
- const a = document.createElement('a');
1886
- a.href = url;
1887
- a.download = fileName;
1888
- a.click();
1804
+ // src/parts/IpcState/IpcState.ts
1805
+ var state$8 = {
1806
+ ipc: void 0
1889
1807
  };
1890
-
1891
- const name$t = 'Download';
1892
- const Commands$u = {
1893
- downloadFile: downloadFile
1808
+ var getIpc = () => {
1809
+ return state$8.ipc;
1894
1810
  };
1895
-
1896
- const Download_ipc = {
1897
- __proto__: null,
1898
- Commands: Commands$u,
1899
- name: name$t
1811
+ var setIpc = value => {
1812
+ state$8.ipc = value;
1900
1813
  };
1901
1814
 
1902
- // based on https://github.com/microsoft/vscode/blob/5f87632829dc3ac80203e2377727935184399431/src/vs/base/browser/ui/aria/aria.ts (License MIT)
1903
-
1904
- const state$6 = {
1905
- $AriaAlert1: undefined,
1906
- $AriaAlert2: undefined,
1907
- $AriaMessages: undefined
1908
- };
1909
- const getAriaAlert1 = () => {
1910
- return state$6.$AriaAlert1;
1911
- };
1912
- const getAriaAlert2 = () => {
1913
- return state$6.$AriaAlert2;
1914
- };
1915
- const setElements = ($AriaMessages, $AriaAlert1, $AriaAlert2) => {
1916
- state$6.$AriaMessages = $AriaMessages;
1917
- state$6.$AriaAlert1 = $AriaAlert1;
1918
- state$6.$AriaAlert2 = $AriaAlert2;
1919
- };
1920
- const hasElements = () => {
1921
- return state$6.$AriaMessages;
1815
+ // src/parts/ClearNode/ClearNode.ts
1816
+ var clearNode = $Node => {
1817
+ $Node.textContent = "";
1922
1818
  };
1923
1819
 
1924
- const True = 'true';
1925
- const False = 'false';
1926
-
1927
- const Alert = 'alert';
1928
- const Application = 'application';
1929
- const Code = 'code';
1930
- const Complementary = 'complementary';
1931
- const ContentInfo = 'contentinfo';
1932
- const Group = 'group';
1933
- const List$1 = 'list';
1934
- const ListBox = 'listbox';
1935
- const Log = 'log';
1936
- const Main$1 = 'main';
1937
- const Menu = 'menu';
1938
- const None$2 = 'none';
1939
- const Status = 'status';
1940
- const TabList = 'tablist';
1941
- const TextBox = 'textbox';
1942
- const ToolBar = 'toolbar';
1943
- const Tree = 'tree';
1944
- const ComboBox = 'combobox';
1945
-
1946
- const AriaOwns = 'aria-owns';
1947
- const AriaLabelledBy = 'aria-labelledby';
1948
- const AriaDescribedBy = 'aria-describedby';
1949
- const AriaActiveDescendant = 'aria-activedescendant';
1950
- const AriaSelected = 'aria-selected';
1951
- const AriaControls = 'aria-controls';
1952
- const AriaHidden = 'aria-hidden';
1953
-
1954
- // based on https://github.com/microsoft/vscode/blob/5f87632829dc3ac80203e2377727935184399431/src/vs/base/browser/ui/aria/aria.ts (License MIT)
1955
- const create$AriaAlert = () => {
1956
- const $AriaAlert = document.createElement('div');
1957
- $AriaAlert.className = 'AriaAlert';
1958
- $AriaAlert.role = Alert;
1959
- $AriaAlert.ariaAtomic = True;
1960
- return $AriaAlert;
1961
- };
1962
- const setMessage$3 = ($Old, $New, message) => {
1963
- $Old.textContent = String(Math.random());
1964
- $Old.ariaHidden = True;
1965
- $New.removeAttribute(AriaHidden);
1966
- $New.textContent = message;
1967
- };
1968
- const alert$1 = message => {
1969
- if (!message) {
1970
- return;
1971
- }
1972
- if (!hasElements()) {
1973
- const $AriaAlert1 = create$AriaAlert();
1974
- const $AriaAlert2 = create$AriaAlert();
1975
- // TODO find better name, for example AriaMessages, AriaOutlet, AriaContainer, ScreenReaderMessages
1976
- const $AriaMessages = document.createElement('div');
1977
- $AriaMessages.className = 'AriaContainer';
1978
- $AriaMessages.append($AriaAlert1, $AriaAlert2);
1979
- document.body.append($AriaMessages);
1980
- setElements($AriaMessages, $AriaAlert1, $AriaAlert2);
1981
- }
1982
- const $AriaAlert1 = getAriaAlert1();
1983
- const $AriaAlert2 = getAriaAlert2();
1984
- // @ts-expect-error
1985
- if ($AriaAlert1.textContent === message) {
1986
- setMessage$3($AriaAlert1, $AriaAlert2, message);
1987
- } else {
1988
- setMessage$3($AriaAlert2, $AriaAlert1, message);
1820
+ // src/parts/ElementTags/ElementTags.ts
1821
+ var Audio$2 = "audio";
1822
+ var Button = "button";
1823
+ var Col = "col";
1824
+ var ColGroup = "colgroup";
1825
+ var Del = "del";
1826
+ var Div = "div";
1827
+ var H1 = "h1";
1828
+ var H2 = "h2";
1829
+ var H3 = "h3";
1830
+ var H4 = "h4";
1831
+ var H5 = "h5";
1832
+ var H6 = "h6";
1833
+ var I = "i";
1834
+ var Img = "img";
1835
+ var Input$1 = "input";
1836
+ var Ins = "ins";
1837
+ var Kbd = "kbd";
1838
+ var Span = "span";
1839
+ var Table = "table";
1840
+ var TBody = "tbody";
1841
+ var Td = "td";
1842
+ var Th = "th";
1843
+ var THead = "thead";
1844
+ var Tr = "tr";
1845
+ var Article = "article";
1846
+ var Aside = "aside";
1847
+ var Footer = "footer";
1848
+ var Header = "header";
1849
+ var Nav = "nav";
1850
+ var Section = "section";
1851
+ var Search$1 = "search";
1852
+ var Dd = "dd";
1853
+ var Dl = "dl";
1854
+ var Figcaption = "figcaption";
1855
+ var Figure = "figure";
1856
+ var Hr = "hr";
1857
+ var Li = "li";
1858
+ var Ol = "ol";
1859
+ var P = "p";
1860
+ var Pre = "pre";
1861
+ var A = "a";
1862
+ var Br = "br";
1863
+ var Cite = "cite";
1864
+ var Data = "data";
1865
+ var Time$1 = "time";
1866
+ var Tfoot = "tfoot";
1867
+ var Ul = "ul";
1868
+ var Video$1 = "video";
1869
+ var TextArea = "textarea";
1870
+ var Select = "select";
1871
+ var Option = "option";
1872
+
1873
+ // src/parts/VirtualDomElements/VirtualDomElements.ts
1874
+ var Audio2 = 0;
1875
+ var Button2 = 1;
1876
+ var Col2 = 2;
1877
+ var ColGroup2 = 3;
1878
+ var Div2 = 4;
1879
+ var H12 = 5;
1880
+ var Input2 = 6;
1881
+ var Kbd2 = 7;
1882
+ var Span2 = 8;
1883
+ var Table2 = 9;
1884
+ var TBody2 = 10;
1885
+ var Td2 = 11;
1886
+ var Text$2 = 12;
1887
+ var Th2 = 13;
1888
+ var THead2 = 14;
1889
+ var Tr2 = 15;
1890
+ var I2 = 16;
1891
+ var Img2 = 17;
1892
+ var Ins2 = 20;
1893
+ var Del2 = 21;
1894
+ var H22 = 22;
1895
+ var H32 = 23;
1896
+ var H42 = 24;
1897
+ var H52 = 25;
1898
+ var H62 = 26;
1899
+ var Article2 = 27;
1900
+ var Aside2 = 28;
1901
+ var Footer2 = 29;
1902
+ var Header2 = 30;
1903
+ var Nav2 = 40;
1904
+ var Section2 = 41;
1905
+ var Search2 = 42;
1906
+ var Dd2 = 43;
1907
+ var Dl2 = 44;
1908
+ var Figcaption2 = 45;
1909
+ var Figure2 = 46;
1910
+ var Hr2 = 47;
1911
+ var Li2 = 48;
1912
+ var Ol2 = 49;
1913
+ var P2 = 50;
1914
+ var Pre2 = 51;
1915
+ var A2 = 53;
1916
+ var Br2 = 55;
1917
+ var Cite2 = 56;
1918
+ var Data2 = 57;
1919
+ var Time2 = 58;
1920
+ var Tfoot2 = 59;
1921
+ var Ul2 = 60;
1922
+ var Video2 = 61;
1923
+ var TextArea2 = 62;
1924
+ var Select2 = 63;
1925
+ var Option2 = 64;
1926
+
1927
+ // src/parts/ElementTagMap/ElementTagMap.ts
1928
+ var getElementTag = type => {
1929
+ switch (type) {
1930
+ case Audio2:
1931
+ return Audio$2;
1932
+ case H12:
1933
+ return H1;
1934
+ case H22:
1935
+ return H2;
1936
+ case H32:
1937
+ return H3;
1938
+ case H42:
1939
+ return H4;
1940
+ case H52:
1941
+ return H5;
1942
+ case H62:
1943
+ return H6;
1944
+ case Div2:
1945
+ return Div;
1946
+ case Kbd2:
1947
+ return Kbd;
1948
+ case Table2:
1949
+ return Table;
1950
+ case TBody2:
1951
+ return TBody;
1952
+ case Th2:
1953
+ return Th;
1954
+ case Td2:
1955
+ return Td;
1956
+ case THead2:
1957
+ return THead;
1958
+ case Tr2:
1959
+ return Tr;
1960
+ case Input2:
1961
+ return Input$1;
1962
+ case ColGroup2:
1963
+ return ColGroup;
1964
+ case Col2:
1965
+ return Col;
1966
+ case Button2:
1967
+ return Button;
1968
+ case Span2:
1969
+ return Span;
1970
+ case I2:
1971
+ return I;
1972
+ case Img2:
1973
+ return Img;
1974
+ case Ins2:
1975
+ return Ins;
1976
+ case Del2:
1977
+ return Del;
1978
+ case Article2:
1979
+ return Article;
1980
+ case Aside2:
1981
+ return Aside;
1982
+ case Footer2:
1983
+ return Footer;
1984
+ case Header2:
1985
+ return Header;
1986
+ case Nav2:
1987
+ return Nav;
1988
+ case Section2:
1989
+ return Section;
1990
+ case Search2:
1991
+ return Search$1;
1992
+ case Dd2:
1993
+ return Dd;
1994
+ case Dl2:
1995
+ return Dl;
1996
+ case Figcaption2:
1997
+ return Figcaption;
1998
+ case Figure2:
1999
+ return Figure;
2000
+ case Hr2:
2001
+ return Hr;
2002
+ case Li2:
2003
+ return Li;
2004
+ case Ol2:
2005
+ return Ol;
2006
+ case P2:
2007
+ return P;
2008
+ case Pre2:
2009
+ return Pre;
2010
+ case A2:
2011
+ return A;
2012
+ case Br2:
2013
+ return Br;
2014
+ case Cite2:
2015
+ return Cite;
2016
+ case Data2:
2017
+ return Data;
2018
+ case Time2:
2019
+ return Time$1;
2020
+ case Tfoot2:
2021
+ return Tfoot;
2022
+ case Ul2:
2023
+ return Ul;
2024
+ case Video2:
2025
+ return Video$1;
2026
+ case TextArea2:
2027
+ return TextArea;
2028
+ case Select2:
2029
+ return Select;
2030
+ case Option2:
2031
+ return Option;
2032
+ default:
2033
+ throw new Error(`element tag not found ${type}`);
1989
2034
  }
1990
2035
  };
1991
2036
 
1992
- const AriaAlert = {
1993
- __proto__: null,
1994
- alert: alert$1
2037
+ // src/parts/GetEventListenerOptions/GetEventListenerOptions.ts
2038
+ var getEventListenerOptions$1 = eventName => {
2039
+ switch (eventName) {
2040
+ case "wheel":
2041
+ return {
2042
+ passive: true
2043
+ };
2044
+ default:
2045
+ return void 0;
2046
+ }
1995
2047
  };
1996
2048
 
1997
- // TODO this file is not needed when all elements are position fixed
1998
- const state$5 = {
1999
- isInDom: false,
2000
- $PreviousFocusElement: undefined,
2001
- widgetSet: new Set(),
2002
- $Widgets: undefined
2003
- };
2004
- const create$Widgets = () => {
2005
- const $Widgets = document.createElement('div');
2006
- $Widgets.id = 'Widgets';
2007
- $Widgets.className = 'Widgets';
2008
- return $Widgets;
2049
+ // src/parts/NameAnonymousFunction/NameAnonymousFunction.ts
2050
+ var nameAnonymousFunction$1 = (fn, name) => {
2051
+ Object.defineProperty(fn, "name", {
2052
+ value: name
2053
+ });
2009
2054
  };
2010
- const append$1 = $Element => {
2011
- // TODO should not call append in the first place if it is already in dom
2012
- if (state$5.widgetSet.has($Element)) {
2013
- return;
2055
+
2056
+ // src/parts/GetWrappedListener/GetWrappedListener.ts
2057
+ var cache$1 = /* @__PURE__ */new Map();
2058
+ var getWrappedListener$1 = (listener, returnValue) => {
2059
+ if (!returnValue) {
2060
+ return listener;
2014
2061
  }
2015
- state$5.widgetSet.add($Element);
2016
- if (state$5.$Widgets) {
2017
- // @ts-expect-error
2018
- state$5.$Widgets.append($Element);
2019
- } else {
2020
- // @ts-expect-error
2021
- state$5.$Widgets = create$Widgets();
2022
- // @ts-expect-error
2023
- state$5.$Widgets.append($Element);
2024
- // @ts-expect-error
2025
- document.body.append(state$5.$Widgets);
2062
+ if (!cache$1.has(listener)) {
2063
+ const wrapped = event => {
2064
+ const uid = getComponentUidFromEvent(event);
2065
+ const result = listener(event);
2066
+ if (result.length === 0) {
2067
+ return;
2068
+ }
2069
+ const ipc = getIpc();
2070
+ ipc.send("Viewlet.executeViewletCommand", uid, ...result);
2071
+ };
2072
+ nameAnonymousFunction$1(wrapped, listener.name);
2073
+ cache$1.set(listener, wrapped);
2026
2074
  }
2075
+ return cache$1.get(listener);
2027
2076
  };
2028
- const remove$1 = $Element => {
2029
- if (!$Element) {
2030
- // TODO $Element should always be defined
2077
+
2078
+ // src/parts/AttachEvent/AttachEvent.ts
2079
+ var attachEvent$1 = ($Node, eventMap, key, value) => {
2080
+ const listener = eventMap[value];
2081
+ if (!listener) {
2082
+ console.warn("listener not found", value);
2031
2083
  return;
2032
2084
  }
2033
- state$5.widgetSet.delete($Element);
2034
- $Element.remove();
2035
- // TODO state.$Widgets should always be defined at this point
2036
- if (state$5.widgetSet.size === 0 && state$5.$Widgets) {
2037
- // @ts-expect-error
2038
- state$5.$Widgets.remove();
2039
- state$5.$Widgets = undefined;
2040
- }
2041
- };
2042
-
2043
- // TODO not sure whether created dom node
2044
- // should stay in state or be removed
2045
- // one option would result in less memory usage
2046
- // the other option would result in less garbage collection
2047
-
2048
- // probably should optimize for less memory usage by default
2049
- // unless the element is very likely to be used again soon (<30s)
2050
- // but that's difficult to know
2051
-
2052
- // TODO hide widget after timeout or mousemove
2053
- const create$J = (message, x, y) => {
2054
- const $EditorError = document.createElement('div');
2055
- $EditorError.className = 'EditorWidgetError';
2056
- $EditorError.textContent = message;
2057
- $EditorError.style.left = `${x}px`;
2058
- $EditorError.style.top = `${y}px`;
2059
- alert$1(message);
2060
- append$1($EditorError);
2061
- return {
2062
- $EditorError
2063
- };
2085
+ const options = getEventListenerOptions$1(eventMap);
2086
+ const wrapped = getWrappedListener$1(listener, eventMap.returnValue);
2087
+ $Node.addEventListener(key, wrapped, options);
2064
2088
  };
2065
2089
 
2066
- const name$s = 'EditorError';
2067
- const Commands$t = {
2068
- create: create$J
2090
+ // src/parts/VirtualDomElementProp/VirtualDomElementProp.ts
2091
+ var setProp = ($Element, key, value, eventMap) => {
2092
+ switch (key) {
2093
+ case "maskImage":
2094
+ $Element.style.maskImage = `url('${value}')`;
2095
+ $Element.style.webkitMaskImage = `url('${value}')`;
2096
+ break;
2097
+ case "paddingLeft":
2098
+ case "paddingRight":
2099
+ case "top":
2100
+ case "left":
2101
+ case "marginTop":
2102
+ $Element.style[key] = typeof value === "number" ? `${value}px` : value;
2103
+ break;
2104
+ case "translate":
2105
+ $Element.style[key] = value;
2106
+ break;
2107
+ case "width":
2108
+ case "height":
2109
+ if ($Element instanceof HTMLImageElement) {
2110
+ $Element[key] = value;
2111
+ } else if (typeof value === "number") {
2112
+ $Element.style[key] = `${value}px`;
2113
+ } else {
2114
+ $Element.style[key] = value;
2115
+ }
2116
+ break;
2117
+ case "style":
2118
+ throw new Error("style property is not supported");
2119
+ case "childCount":
2120
+ case "type":
2121
+ break;
2122
+ case "ariaOwns":
2123
+ if (value) {
2124
+ $Element.setAttribute("aria-owns", value);
2125
+ } else {
2126
+ $Element.removeAttribute("aria-owns");
2127
+ }
2128
+ break;
2129
+ case "inputType":
2130
+ $Element.type = value;
2131
+ break;
2132
+ case "ariaLabelledBy":
2133
+ $Element.setAttribute("aria-labelledby", value);
2134
+ break;
2135
+ case "onBlur":
2136
+ case "onChange":
2137
+ case "onClick":
2138
+ case "onContextMenu":
2139
+ case "onDblClick":
2140
+ case "onFocus":
2141
+ case "onFocusIn":
2142
+ case "onFocusIn":
2143
+ case "onFocusOut":
2144
+ case "onInput":
2145
+ case "onKeyDown":
2146
+ case "onMouseDown":
2147
+ case "onPointerDown":
2148
+ case "onPointerOut":
2149
+ case "onPointerOver":
2150
+ case "onWheel":
2151
+ const eventName = key.slice(2).toLowerCase();
2152
+ if (!eventMap || !value) {
2153
+ return;
2154
+ }
2155
+ attachEvent$1($Element, eventMap, eventName, value);
2156
+ break;
2157
+ default:
2158
+ if (key.startsWith("data-")) {
2159
+ $Element.dataset[key.slice("data-".length)] = value;
2160
+ } else {
2161
+ $Element[key] = value;
2162
+ }
2163
+ }
2069
2164
  };
2070
2165
 
2071
- const EditorError_ipc = {
2072
- __proto__: null,
2073
- Commands: Commands$t,
2074
- name: name$s
2166
+ // src/parts/VirtualDomElementProps/VirtualDomElementProps.ts
2167
+ var setProps = ($Element, props, eventMap) => {
2168
+ for (const key in props) {
2169
+ setProp($Element, key, props[key], eventMap);
2170
+ }
2075
2171
  };
2076
2172
 
2077
- const state$4 = {
2078
- /**
2079
- * @type {HTMLElement|undefined}
2080
- */
2081
- $PreviousFocusElement: undefined,
2082
- currentFocus: ''
2083
- };
2084
- const setElement = $Element => {
2085
- state$4.$PreviousFocusElement = $Element;
2173
+ // src/parts/VirtualDomElement/VirtualDomElement.ts
2174
+ var renderDomTextNode = element => {
2175
+ return document.createTextNode(element.text);
2086
2176
  };
2087
- const getElement = () => {
2088
- return state$4.$PreviousFocusElement;
2177
+ var renderDomElement = (element, eventMap) => {
2178
+ const tag = getElementTag(element.type);
2179
+ const $Element = document.createElement(tag);
2180
+ setProps($Element, element, eventMap);
2181
+ return $Element;
2089
2182
  };
2090
-
2091
- const focus$i = $Element => {
2092
- if ($Element === document.activeElement) {
2093
- return;
2183
+ var render = (element, eventMap) => {
2184
+ switch (element.type) {
2185
+ case Text$2:
2186
+ return renderDomTextNode(element);
2187
+ default:
2188
+ return renderDomElement(element, eventMap);
2094
2189
  }
2095
- setElement(document.activeElement);
2096
- $Element.focus({
2097
- preventScroll: true
2098
- });
2099
2190
  };
2100
- const focusPrevious$1 = () => {
2101
- const $Element = getElement();
2102
- if ($Element) {
2103
- // @ts-expect-error
2104
- $Element.focus();
2191
+
2192
+ // src/parts/RenderInternal/RenderInternal.ts
2193
+ var renderInternal2 = ($Parent, elements, eventMap) => {
2194
+ const max = elements.length - 1;
2195
+ let stack = [];
2196
+ for (let i = max; i >= 0; i--) {
2197
+ const element = elements[i];
2198
+ const $Element = render(element, eventMap);
2199
+ if (element.childCount > 0) {
2200
+ $Element.append(...stack.slice(0, element.childCount));
2201
+ stack = stack.slice(element.childCount);
2202
+ }
2203
+ stack.unshift($Element);
2105
2204
  }
2205
+ $Parent.append(...stack);
2106
2206
  };
2107
2207
 
2108
- const create$I = () => {
2109
- const $InputBox = document.createElement('input');
2110
- $InputBox.className = 'InputBox';
2111
- $InputBox.spellcheck = false;
2112
- $InputBox.autocapitalize = 'off';
2113
- // $InputBox.autocomplete = 'off' // TODO needed?
2114
- $InputBox.type = 'text';
2115
- $InputBox.setAttribute('autocorrect', 'off'); // for ios
2116
- return $InputBox;
2208
+ // src/parts/VirtualDom/VirtualDom.ts
2209
+ var renderInto = ($Parent, dom, eventMap = {}) => {
2210
+ clearNode($Parent);
2211
+ renderInternal2($Parent, dom, eventMap);
2212
+ };
2213
+ var render2 = (elements, eventMap = {}) => {
2214
+ const $Root = document.createElement("div");
2215
+ renderInternal2($Root, elements, eventMap);
2216
+ return $Root;
2117
2217
  };
2118
2218
 
2119
- const setBounds$6 = ($Element, x, y, width, height) => {
2120
- $Element.style.top = `${y}px`;
2121
- $Element.style.left = `${x}px`;
2122
- $Element.style.width = `${width}px`;
2123
- $Element.style.height = `${height}px`;
2219
+ // src/parts/RememberFocus/RememberFocus.ts
2220
+ var queryInputs = $Viewlet => {
2221
+ return [...$Viewlet.querySelectorAll("input, textarea")];
2124
2222
  };
2125
- const setYAndHeight = ($Element, y, height) => {
2126
- if (!$Element) {
2127
- return;
2223
+ var rememberFocus$1 = ($Viewlet, dom, eventMap, uid = 0) => {
2224
+ const oldLeft = $Viewlet.style.left;
2225
+ const oldTop = $Viewlet.style.top;
2226
+ const oldWidth = $Viewlet.style.width;
2227
+ const oldHeight = $Viewlet.style.height;
2228
+ const focused = document.activeElement.getAttribute("name");
2229
+ const $$Inputs = queryInputs($Viewlet);
2230
+ const inputMap = /* @__PURE__ */Object.create(null);
2231
+ for (const $Input of $$Inputs) {
2232
+ inputMap[$Input.name] = $Input.value;
2128
2233
  }
2129
- $Element.style.translate = typeof y === 'string' ? y : `0 ${y}px`;
2130
- $Element.style.height = typeof height === 'string' ? height : `${height}px`;
2234
+ if (uid) {
2235
+ const $New = render2(dom, eventMap).firstChild;
2236
+ setComponentUid($New, uid);
2237
+ $Viewlet.replaceWith($New);
2238
+ $Viewlet = $New;
2239
+ } else {
2240
+ renderInto($Viewlet, dom, eventMap);
2241
+ }
2242
+ const $$NewInputs = queryInputs($Viewlet);
2243
+ for (const $Input of $$NewInputs) {
2244
+ $Input.value = inputMap[$Input.name] || $Input.value || "";
2245
+ }
2246
+ if (focused) {
2247
+ const $Focused = $Viewlet.querySelector(`[name="${focused}"]`);
2248
+ if ($Focused) {
2249
+ $Focused.focus();
2250
+ }
2251
+ }
2252
+ $Viewlet.style.top = oldTop;
2253
+ $Viewlet.style.left = oldLeft;
2254
+ $Viewlet.style.height = oldHeight;
2255
+ $Viewlet.style.width = oldWidth;
2256
+ return $Viewlet;
2131
2257
  };
2132
- const setXAndWidth = ($Element, x, width) => {
2133
- $Element.style.translate = `${x}px 0`;
2134
- $Element.style.width = `${width}px`;
2135
- };
2136
- const setTop = ($Element, top) => {
2137
- $Element.style.top = `${top}px`;
2138
- };
2139
- const setWidth = ($Element, width) => {
2140
- $Element.style.width = `${width}px`;
2141
- };
2142
- const setXAndY = ($Element, x, y) => {
2143
- $Element.style.left = `${x}px`;
2144
- $Element.style.top = `${y}px`;
2145
- };
2146
-
2147
- /**
2148
- *
2149
- * @param {HTMLElement} $Element
2150
- * @param {number} x
2151
- * @param {number} y
2152
- */
2153
- const setXAndYTransform = ($Element, x, y) => {
2154
- $Element.style.translate = `${x}px ${y}px`;
2155
- };
2156
- const setHeight = ($Element, height) => {
2157
- $Element.style.height = `${height}px`;
2158
- };
2159
-
2160
- const FocusDebugInput = 6;
2161
- const FocusEditorRename = 11;
2162
- const FocusExplorer = 13;
2163
- const FocusExplorerEditBox = 14;
2164
- const FocusLocationList = 17;
2165
- const FocusMenu = 18;
2166
- const FocusQuickPickInput = 20;
2167
- const FocusSearchInput = 21;
2168
- const FocusSimpleBrowserInput = 23;
2169
- const FocusOutput = 28;
2170
2258
 
2171
- const handleBlur$a = () => {
2172
- send( /* EditorRename.abort */'EditorRename.abort');
2173
- };
2174
- const create$H = (x, y) => {
2175
- const $RenameWidgetInputBox = create$I();
2176
- $RenameWidgetInputBox.className = 'RenameWidgetInputBox';
2177
- $RenameWidgetInputBox.onblur = handleBlur$a;
2178
- const $RenameWidget = document.createElement('div');
2179
- $RenameWidget.className = 'RenameWidget';
2180
- $RenameWidget.append($RenameWidgetInputBox);
2181
- setXAndY($RenameWidget, x, y);
2182
- append$1($RenameWidget);
2183
- focus$i($RenameWidgetInputBox);
2184
- send('Focus.setFocus', FocusEditorRename);
2185
- return {
2186
- $RenameWidget,
2187
- $RenameWidgetInputBox
2188
- };
2189
- };
2190
- const dispose$i = state => {
2191
- // TODO focus editor
2192
- remove$1(state.$RenameWidget);
2259
+ const main = async () => {
2260
+ onerror = handleUnhandledError;
2261
+ onunhandledrejection = handleUnhandledRejection;
2262
+ if ('SecurityPolicyViolationEvent' in self) {
2263
+ self.addEventListener('securitypolicyviolation', handleContentSecurityPolicyViolation);
2264
+ }
2265
+ setLoad(load$1);
2266
+ if (platform === Web) {
2267
+ // disable prompt to download app as pwa
2268
+ // @ts-expect-error
2269
+ window.onbeforeinstallprompt = handleBeforeInstallPrompt;
2270
+ }
2271
+ // TODO this is discovered very late
2272
+ await hydrate$1();
2273
+ setIpc(RendererWorker);
2193
2274
  };
2194
2275
 
2195
- // TODO could also be event based
2196
- // finish -> finish -> finishWithValue
2276
+ main();
2197
2277
 
2198
- const finish = state => {
2199
- const value = state.$RenameWidgetInputBox.value;
2200
- // TODO don't like side effect here
2201
- return value;
2278
+ const play = async src => {
2279
+ const audio = new Audio(src);
2280
+ await audio.play();
2202
2281
  };
2203
2282
 
2204
- const name$r = 'EditorRename';
2205
- const Commands$s = {
2206
- create: create$H,
2207
- dispose: dispose$i,
2208
- finish: finish
2283
+ const name$y = 'Audio';
2284
+ const Commands$z = {
2285
+ play: play
2209
2286
  };
2210
2287
 
2211
- const EditorRename_ipc = {
2288
+ const Audio_ipc = {
2212
2289
  __proto__: null,
2213
- Commands: Commands$s,
2214
- name: name$r
2290
+ Commands: Commands$z,
2291
+ name: name$y
2215
2292
  };
2216
2293
 
2217
- const showDirectoryPicker = options => {
2218
- // @ts-expect-error
2219
- return window.showDirectoryPicker(options);
2294
+ const readText = async () => {
2295
+ return navigator.clipboard.readText();
2220
2296
  };
2221
- const showFilePicker = options => {
2222
- // @ts-expect-error
2223
- return window.showFilePicker(options);
2297
+ const writeText = async text => {
2298
+ string(text);
2299
+ await navigator.clipboard.writeText(text);
2224
2300
  };
2225
- const showSaveFilePicker = options => {
2301
+ const writeImage = async blob => {
2302
+ await navigator.clipboard.write([new ClipboardItem({
2303
+ [blob.type]: blob
2304
+ })]);
2305
+ };
2306
+ const execCopy = async () => {
2226
2307
  // @ts-expect-error
2227
- return window.showSaveFilePicker(options);
2308
+ const text = getSelection().toString();
2309
+ await writeText(text);
2228
2310
  };
2229
2311
 
2230
- const name$q = 'FilePicker';
2231
- const Commands$r = {
2232
- showDirectoryPicker: showDirectoryPicker,
2233
- showFilePicker: showFilePicker,
2234
- showSaveFilePicker: showSaveFilePicker
2312
+ const name$x = 'ClipBoard';
2313
+ const Commands$y = {
2314
+ execCopy: execCopy,
2315
+ readText: readText,
2316
+ writeImage: writeImage,
2317
+ writeText: writeText
2235
2318
  };
2236
2319
 
2237
- const FilePicker_ipc = {
2320
+ const ClipBoard_ipc = {
2238
2321
  __proto__: null,
2239
- Commands: Commands$r,
2240
- name: name$q
2322
+ Commands: Commands$y,
2323
+ name: name$x
2241
2324
  };
2242
2325
 
2243
- const requestPermission = (handle, options) => {
2244
- return handle.requestPermission(options);
2326
+ const prompt$1 = message => {
2327
+ return confirm(message);
2245
2328
  };
2246
2329
 
2247
- const name$p = 'FileSystemHandle';
2248
- const Commands$q = {
2249
- requestPermission: requestPermission
2330
+ const name$w = 'ConfirmPrompt';
2331
+ const Commands$x = {
2332
+ prompt: prompt$1
2250
2333
  };
2251
2334
 
2252
- const FileSystemHandle_ipc = {
2335
+ const ConfirmPrompt_ipc = {
2253
2336
  __proto__: null,
2254
- Commands: Commands$q,
2255
- name: name$p
2256
- };
2257
-
2258
- const handleImageLoad = event => {
2259
- const $ImagePreviewImage = event.target;
2260
- const $ImagePreviewCaption = $ImagePreviewImage.nextSibling;
2261
- const width = $ImagePreviewImage.naturalWidth;
2262
- const height = $ImagePreviewImage.naturalHeight;
2263
- $ImagePreviewCaption.textContent = `${width} × ${height}`;
2264
- };
2265
- const handleImageError$1 = event => {
2266
- const $ImagePreviewImage = event.target;
2267
- const $ImagePreviewCaption = $ImagePreviewImage.nextSibling;
2268
- $ImagePreviewCaption.textContent = 'Image could not be loaded';
2337
+ Commands: Commands$x,
2338
+ name: name$w
2269
2339
  };
2270
2340
 
2271
- // TODO duplicate code with below
2272
-
2273
- const showError = (message, y, x) => {
2274
- const $ImagePreviewImage = document.createElement('img');
2275
- $ImagePreviewImage.className = 'ImagePreviewImage';
2276
- $ImagePreviewImage.alt = '';
2277
- const $ImagePreviewCaption = document.createElement('figcaption');
2278
- $ImagePreviewCaption.className = 'ImagePreviewCaption';
2279
- $ImagePreviewCaption.textContent = message;
2280
- const $ImagePreview = document.createElement('figure');
2281
- $ImagePreview.className = 'ImagePreview';
2282
- $ImagePreview.append($ImagePreviewImage, $ImagePreviewCaption);
2283
- setXAndY($ImagePreview, x, y);
2284
- $ImagePreview.style.display = 'none';
2285
- append$1($ImagePreview);
2286
- return {
2287
- $ImagePreview,
2288
- $ImagePreviewCaption,
2289
- $ImagePreviewImage
2290
- };
2291
- };
2292
- const create$G = (uri, top, left) => {
2293
- const $ImagePreviewImage = document.createElement('img');
2294
- $ImagePreviewImage.className = 'ImagePreviewImage';
2295
- $ImagePreviewImage.src = uri;
2296
- $ImagePreviewImage.alt = '';
2297
- const $ImagePreviewCaption = document.createElement('figcaption');
2298
- $ImagePreviewCaption.className = 'ImagePreviewCaption';
2299
- const $ImagePreview = document.createElement('figure');
2300
- $ImagePreview.className = 'ImagePreview';
2301
- $ImagePreview.append($ImagePreviewImage, $ImagePreviewCaption);
2302
- $ImagePreviewImage.onload = handleImageLoad;
2303
- $ImagePreviewImage.onerror = handleImageError$1;
2304
- $ImagePreview.style.top = `${top}px`;
2305
- $ImagePreview.style.left = `${left}px`;
2306
- $ImagePreview.style.display = 'none';
2307
- append$1($ImagePreview);
2308
- return {
2309
- $ImagePreview,
2310
- $ImagePreviewCaption,
2311
- $ImagePreviewImage
2312
- };
2341
+ const state$7 = {
2342
+ styleSheets: Object.create(null)
2313
2343
  };
2314
- const update = (state, uri) => {
2315
- state.$ImagePreviewImage.uri = uri;
2344
+ const set$4 = (id, sheet) => {
2345
+ state$7.styleSheets[id] = sheet;
2316
2346
  };
2317
- const dispose$h = state => {
2318
- remove$1(state.$ImagePreview);
2347
+ const get$5 = id => {
2348
+ return state$7.styleSheets[id];
2319
2349
  };
2320
2350
 
2321
- const ImagePreview$1 = {
2322
- __proto__: null,
2323
- create: create$G,
2324
- dispose: dispose$h,
2325
- showError,
2326
- update
2351
+ const addCssStyleSheet = async (id, text) => {
2352
+ const existing = get$5(id);
2353
+ if (existing) {
2354
+ await existing.replace(text);
2355
+ return;
2356
+ }
2357
+ const sheet = new CSSStyleSheet({});
2358
+ set$4(id, sheet);
2359
+ await sheet.replace(text);
2360
+ document.adoptedStyleSheets.push(sheet);
2327
2361
  };
2328
2362
 
2329
- const name$o = 'ImagePreview';
2330
- const Commands$p = {
2331
- create: create$G,
2332
- dispose: dispose$h,
2333
- showError: showError,
2334
- update: update
2363
+ const name$v = 'Css';
2364
+ const Commands$w = {
2365
+ addCssStyleSheet: addCssStyleSheet
2335
2366
  };
2336
2367
 
2337
- const ImagePreview_ipc = {
2368
+ const Css_ipc = {
2338
2369
  __proto__: null,
2339
- Commands: Commands$p,
2340
- name: name$o
2370
+ Commands: Commands$w,
2371
+ name: name$v
2341
2372
  };
2342
2373
 
2343
- const getOrigin = () => {
2344
- return location.origin;
2345
- };
2346
- const getPathName = () => {
2347
- return location.pathname;
2348
- };
2349
- const getHref = () => {
2350
- return location.href;
2351
- };
2374
+ const modules = ['ActivityBar', 'Ajax', 'Allocator', 'Callback', 'Command', 'Context', 'ContextMenu', 'Delay', 'Developer', 'DomPool', 'Editor', 'Exec', 'ExtensionHost', 'FileSystem', 'KeyBindings', 'Layout', 'Main', 'Notification', 'Panel', 'Parts', 'QuickPick', 'Renderer', 'RendererWorker', 'Search', 'SharedProcess', 'SideBar', 'StatusBar', 'TitleBar', 'Viewlet', 'ViewletController', 'ViewService', 'Vscode', 'Window', 'Workbench', 'Worker', 'Workspace'];
2352
2375
 
2353
- // TODO should do nothing if it is already at this path
2354
- const setPathName = pathName => {
2355
- const currentPathName = getPathName();
2356
- if (currentPathName === pathName) {
2357
- return;
2358
- }
2359
- // @ts-expect-error
2360
- history.pushState(null, null, pathName);
2361
- };
2362
- const hydrate = () => {
2363
- // addEventListener('popstate', handlePopState)
2364
- };
2365
-
2366
- const getTitleBarHeight = () => {
2367
- if (
2368
- // @ts-expect-error
2369
- navigator.windowControlsOverlay?.getTitlebarAreaRect) {
2370
- // @ts-expect-error
2371
- const titleBarRect = navigator.windowControlsOverlay.getTitlebarAreaRect();
2372
- return titleBarRect.height;
2376
+ // TODO send to renderer worker -> renderer worker has all state
2377
+ const showState = async () => {
2378
+ const state = Object.create(null);
2379
+ for (const module of modules) {
2380
+ let imported;
2381
+ try {
2382
+ imported = await import(`../${module}/${module}.js`);
2383
+ } catch {}
2384
+ if (imported?.state) {
2385
+ state[module] = imported.state;
2386
+ }
2373
2387
  }
2374
- return 0;
2375
- };
2376
- const getBounds = () => {
2377
- return {
2378
- windowWidth: window.innerWidth,
2379
- windowHeight: window.innerHeight,
2380
- titleBarHeight: getTitleBarHeight()
2381
- };
2388
+ info(state);
2382
2389
  };
2383
2390
 
2384
- const getInitData = () => {
2385
- const initData = {
2386
- Location: {
2387
- href: getHref()
2388
- },
2389
- Layout: {
2390
- bounds: getBounds()
2391
- }
2392
- };
2393
- return initData;
2391
+ const name$u = 'Developer';
2392
+ const Commands$v = {
2393
+ showState: showState
2394
2394
  };
2395
2395
 
2396
- const name$n = 'InitData';
2397
- const Commands$o = {
2398
- getInitData: getInitData
2396
+ const Developer_ipc = {
2397
+ __proto__: null,
2398
+ Commands: Commands$v,
2399
+ name: name$u
2399
2400
  };
2400
2401
 
2401
- const InitData_ipc = {
2402
- __proto__: null,
2403
- Commands: Commands$o,
2404
- name: name$n
2402
+ const downloadFile = (fileName, url) => {
2403
+ const a = document.createElement('a');
2404
+ a.href = url;
2405
+ a.download = fileName;
2406
+ a.click();
2405
2407
  };
2406
2408
 
2407
- const name$m = 'IpcParent';
2408
- const Commands$n = {
2409
- create: create$L
2409
+ const name$t = 'Download';
2410
+ const Commands$u = {
2411
+ downloadFile: downloadFile
2410
2412
  };
2411
2413
 
2412
- const IpcParent_ipc = {
2414
+ const Download_ipc = {
2413
2415
  __proto__: null,
2414
- Commands: Commands$n,
2415
- name: name$m
2416
+ Commands: Commands$u,
2417
+ name: name$t
2416
2418
  };
2417
2419
 
2418
- const name$l = 'Layout';
2419
- const Commands$m = {
2420
- getBounds: getBounds
2421
- };
2420
+ // based on https://github.com/microsoft/vscode/blob/5f87632829dc3ac80203e2377727935184399431/src/vs/base/browser/ui/aria/aria.ts (License MIT)
2422
2421
 
2423
- const Layout_ipc = {
2424
- __proto__: null,
2425
- Commands: Commands$m,
2426
- name: name$l
2422
+ const state$6 = {
2423
+ $AriaAlert1: undefined,
2424
+ $AriaAlert2: undefined,
2425
+ $AriaMessages: undefined
2427
2426
  };
2428
-
2429
- const name$k = 'Location';
2430
- const Commands$l = {
2431
- getHref: getHref,
2432
- getPathName: getPathName,
2433
- hydrate: hydrate,
2434
- setPathName: setPathName
2427
+ const getAriaAlert1 = () => {
2428
+ return state$6.$AriaAlert1;
2435
2429
  };
2436
-
2437
- const Location_ipc = {
2438
- __proto__: null,
2439
- Commands: Commands$l,
2440
- name: name$k
2430
+ const getAriaAlert2 = () => {
2431
+ return state$6.$AriaAlert2;
2441
2432
  };
2442
-
2443
- const getElementHeight = $Element => {
2444
- document.body.append($Element);
2445
- const height = $Element.offsetHeight;
2446
- $Element.remove();
2447
- return height;
2433
+ const setElements = ($AriaMessages, $AriaAlert1, $AriaAlert2) => {
2434
+ state$6.$AriaMessages = $AriaMessages;
2435
+ state$6.$AriaAlert1 = $AriaAlert1;
2436
+ state$6.$AriaAlert2 = $AriaAlert2;
2448
2437
  };
2449
-
2450
- const measureTextHeight = (text, fontSize, fontFamily) => {
2451
- string(text);
2452
- string(fontSize);
2453
- string(fontFamily);
2454
- const $Measure = document.createElement('div');
2455
- $Measure.style.contain = 'content';
2456
- $Measure.style.position = 'absolute';
2457
- $Measure.style.top = '-9999px';
2458
- $Measure.style.left = '-9999px';
2459
- $Measure.textContent = text;
2460
- return getElementHeight($Measure);
2438
+ const hasElements = () => {
2439
+ return state$6.$AriaMessages;
2461
2440
  };
2462
2441
 
2463
- const name$j = 'MeasureTextHeight';
2464
- const Commands$k = {
2465
- measureTextHeight: measureTextHeight
2466
- };
2442
+ const True = 'true';
2443
+ const False = 'false';
2467
2444
 
2468
- const MeasureTextHeight_ipc = {
2469
- __proto__: null,
2470
- Commands: Commands$k,
2471
- name: name$j
2472
- };
2445
+ const Alert = 'alert';
2446
+ const Application = 'application';
2447
+ const Code = 'code';
2448
+ const Complementary = 'complementary';
2449
+ const ContentInfo = 'contentinfo';
2450
+ const Group = 'group';
2451
+ const List$1 = 'list';
2452
+ const ListBox = 'listbox';
2453
+ const Log = 'log';
2454
+ const Main$1 = 'main';
2455
+ const Menu = 'menu';
2456
+ const None$2 = 'none';
2457
+ const Status = 'status';
2458
+ const TabList = 'tablist';
2459
+ const TextBox = 'textbox';
2460
+ const ToolBar = 'toolbar';
2461
+ const Tree = 'tree';
2462
+ const ComboBox = 'combobox';
2473
2463
 
2474
- const measureTextBlockHeight = (text, fontSize, fontFamily, lineHeight, width) => {
2475
- string(text);
2476
- number(fontSize);
2477
- string(fontFamily);
2478
- number(width);
2479
- string(lineHeight);
2480
- const $Measure = document.createElement('div');
2481
- $Measure.style.width = `${width}px`;
2482
- $Measure.style.contain = 'content';
2483
- $Measure.style.position = 'absolute';
2484
- $Measure.style.top = '-9999px';
2485
- $Measure.style.left = '-9999px';
2486
- $Measure.style.fontSize = `${fontSize}px`;
2487
- $Measure.style.lineHeight = lineHeight;
2488
- $Measure.textContent = text;
2489
- return getElementHeight($Measure);
2490
- };
2464
+ const AriaOwns = 'aria-owns';
2465
+ const AriaLabelledBy = 'aria-labelledby';
2466
+ const AriaDescribedBy = 'aria-describedby';
2467
+ const AriaActiveDescendant = 'aria-activedescendant';
2468
+ const AriaSelected = 'aria-selected';
2469
+ const AriaControls = 'aria-controls';
2470
+ const AriaHidden = 'aria-hidden';
2491
2471
 
2492
- const name$i = 'MeasureTextBlockHeight';
2493
- const Commands$j = {
2494
- measureTextBlockHeight: measureTextBlockHeight
2472
+ // based on https://github.com/microsoft/vscode/blob/5f87632829dc3ac80203e2377727935184399431/src/vs/base/browser/ui/aria/aria.ts (License MIT)
2473
+ const create$AriaAlert = () => {
2474
+ const $AriaAlert = document.createElement('div');
2475
+ $AriaAlert.className = 'AriaAlert';
2476
+ $AriaAlert.role = Alert;
2477
+ $AriaAlert.ariaAtomic = True;
2478
+ return $AriaAlert;
2495
2479
  };
2496
-
2497
- const MeasureTextBlockHeight_ipc = {
2498
- __proto__: null,
2499
- Commands: Commands$j,
2500
- name: name$i
2480
+ const setMessage$3 = ($Old, $New, message) => {
2481
+ $Old.textContent = String(Math.random());
2482
+ $Old.ariaHidden = True;
2483
+ $New.removeAttribute(AriaHidden);
2484
+ $New.textContent = message;
2501
2485
  };
2502
-
2503
- const setThemeColor = color => {
2504
- const meta = document.querySelector('meta[name="theme-color"]');
2505
- if (!meta) {
2486
+ const alert$1 = message => {
2487
+ if (!message) {
2506
2488
  return;
2507
2489
  }
2490
+ if (!hasElements()) {
2491
+ const $AriaAlert1 = create$AriaAlert();
2492
+ const $AriaAlert2 = create$AriaAlert();
2493
+ // TODO find better name, for example AriaMessages, AriaOutlet, AriaContainer, ScreenReaderMessages
2494
+ const $AriaMessages = document.createElement('div');
2495
+ $AriaMessages.className = 'AriaContainer';
2496
+ $AriaMessages.append($AriaAlert1, $AriaAlert2);
2497
+ document.body.append($AriaMessages);
2498
+ setElements($AriaMessages, $AriaAlert1, $AriaAlert2);
2499
+ }
2500
+ const $AriaAlert1 = getAriaAlert1();
2501
+ const $AriaAlert2 = getAriaAlert2();
2508
2502
  // @ts-expect-error
2509
- meta.content = color;
2510
- };
2511
-
2512
- const name$h = 'Meta';
2513
- const Commands$i = {
2514
- setThemeColor: setThemeColor
2503
+ if ($AriaAlert1.textContent === message) {
2504
+ setMessage$3($AriaAlert1, $AriaAlert2, message);
2505
+ } else {
2506
+ setMessage$3($AriaAlert2, $AriaAlert1, message);
2507
+ }
2515
2508
  };
2516
2509
 
2517
- const Meta_ipc = {
2510
+ const AriaAlert = {
2518
2511
  __proto__: null,
2519
- Commands: Commands$i,
2520
- name: name$h
2512
+ alert: alert$1
2521
2513
  };
2522
2514
 
2523
- const create$Notification = message => {
2524
- const $Notification = document.createElement('div');
2525
- $Notification.className = 'Notification';
2526
- $Notification.textContent = message;
2527
- return $Notification;
2515
+ // TODO this file is not needed when all elements are position fixed
2516
+ const state$5 = {
2517
+ isInDom: false,
2518
+ $PreviousFocusElement: undefined,
2519
+ widgetSet: new Set(),
2520
+ $Widgets: undefined
2528
2521
  };
2529
- const create$F = (type, message) => {
2530
- // TODO this pattern might be also useful for activitybar, sidebar etc., creating elements as late as possible, only when actually needed
2531
- const $Notification = create$Notification(message);
2532
- append$1($Notification);
2522
+ const create$Widgets = () => {
2523
+ const $Widgets = document.createElement('div');
2524
+ $Widgets.id = 'Widgets';
2525
+ $Widgets.className = 'Widgets';
2526
+ return $Widgets;
2533
2527
  };
2534
- const findIndex$1 = $Child => {
2535
- const $Parent = $Child.parentNode;
2536
- for (let i = 0; i < $Parent.children.length; i++) {
2537
- if ($Parent.children[i] === $Child) {
2538
- return i;
2539
- }
2528
+ const append$1 = $Element => {
2529
+ // TODO should not call append in the first place if it is already in dom
2530
+ if (state$5.widgetSet.has($Element)) {
2531
+ return;
2540
2532
  }
2541
- return -1;
2542
- };
2543
- const handleNotificationClick = event => {
2544
- const $Target = event.target;
2545
- switch ($Target.className) {
2546
- case 'NotificationOption':
2547
- const index = findIndex$1($Target);
2548
- send( /* Notification.handleClick */'Notification.handleClick', /* index */index);
2549
- break;
2533
+ state$5.widgetSet.add($Element);
2534
+ if (state$5.$Widgets) {
2535
+ // @ts-expect-error
2536
+ state$5.$Widgets.append($Element);
2537
+ } else {
2538
+ // @ts-expect-error
2539
+ state$5.$Widgets = create$Widgets();
2540
+ // @ts-expect-error
2541
+ state$5.$Widgets.append($Element);
2542
+ // @ts-expect-error
2543
+ document.body.append(state$5.$Widgets);
2550
2544
  }
2551
2545
  };
2552
- const create$NotificationWithOptions = (message, options) => {
2553
- const $NotificationMessage = document.createElement('p');
2554
- $NotificationMessage.className = 'NotificationMessage';
2555
- $NotificationMessage.textContent = message;
2556
- const $NotificationOptions = document.createElement('div');
2557
- $NotificationOptions.className = 'NotificationOptions';
2558
- for (const option of options) {
2559
- const $NotificationOption = document.createElement('button');
2560
- $NotificationOption.className = 'NotificationOption';
2561
- $NotificationOption.textContent = option;
2562
- $NotificationOptions.append($NotificationOption);
2546
+ const remove$1 = $Element => {
2547
+ if (!$Element) {
2548
+ // TODO $Element should always be defined
2549
+ return;
2550
+ }
2551
+ state$5.widgetSet.delete($Element);
2552
+ $Element.remove();
2553
+ // TODO state.$Widgets should always be defined at this point
2554
+ if (state$5.widgetSet.size === 0 && state$5.$Widgets) {
2555
+ // @ts-expect-error
2556
+ state$5.$Widgets.remove();
2557
+ state$5.$Widgets = undefined;
2563
2558
  }
2564
- const $Notification = document.createElement('div');
2565
- $Notification.className = 'Notification';
2566
- $Notification.append($NotificationMessage, $NotificationOptions);
2567
- $Notification.onclick = handleNotificationClick;
2568
- return $Notification;
2569
- };
2570
- const createWithOptions = (type, message, options) => {
2571
- const $Notification = create$NotificationWithOptions(message, options);
2572
- append$1($Notification);
2573
- };
2574
- const dispose$g = id => {
2575
- // const $Notification = state.$Notifications
2576
2559
  };
2577
2560
 
2578
- const name$g = 'Notification';
2561
+ // TODO not sure whether created dom node
2562
+ // should stay in state or be removed
2563
+ // one option would result in less memory usage
2564
+ // the other option would result in less garbage collection
2579
2565
 
2580
- // prettier-ignore
2581
- const Commands$h = {
2582
- create: create$F,
2583
- createWithOptions: createWithOptions,
2584
- dispose: dispose$g
2566
+ // probably should optimize for less memory usage by default
2567
+ // unless the element is very likely to be used again soon (<30s)
2568
+ // but that's difficult to know
2569
+
2570
+ // TODO hide widget after timeout or mousemove
2571
+ const create$J = (message, x, y) => {
2572
+ const $EditorError = document.createElement('div');
2573
+ $EditorError.className = 'EditorWidgetError';
2574
+ $EditorError.textContent = message;
2575
+ $EditorError.style.left = `${x}px`;
2576
+ $EditorError.style.top = `${y}px`;
2577
+ alert$1(message);
2578
+ append$1($EditorError);
2579
+ return {
2580
+ $EditorError
2581
+ };
2585
2582
  };
2586
2583
 
2587
- const Notification_ipc = {
2588
- __proto__: null,
2589
- Commands: Commands$h,
2590
- name: name$g
2584
+ const name$s = 'EditorError';
2585
+ const Commands$t = {
2586
+ create: create$J
2591
2587
  };
2592
2588
 
2593
- const Two = '2.0';
2589
+ const EditorError_ipc = {
2590
+ __proto__: null,
2591
+ Commands: Commands$t,
2592
+ name: name$s
2593
+ };
2594
2594
 
2595
- const state$3 = {
2596
- canvasObjects: Object.create(null)
2595
+ const state$4 = {
2596
+ /**
2597
+ * @type {HTMLElement|undefined}
2598
+ */
2599
+ $PreviousFocusElement: undefined,
2600
+ currentFocus: ''
2597
2601
  };
2598
- const get$4 = id => {
2599
- return state$3.canvasObjects[id];
2602
+ const setElement = $Element => {
2603
+ state$4.$PreviousFocusElement = $Element;
2600
2604
  };
2601
- const set$3 = (canvasId, canvas) => {
2602
- state$3.canvasObjects[canvasId] = canvas;
2605
+ const getElement = () => {
2606
+ return state$4.$PreviousFocusElement;
2603
2607
  };
2604
2608
 
2605
- const get$3 = id => {
2606
- return get$4(id);
2609
+ const focus$i = $Element => {
2610
+ if ($Element === document.activeElement) {
2611
+ return;
2612
+ }
2613
+ setElement(document.activeElement);
2614
+ $Element.focus({
2615
+ preventScroll: true
2616
+ });
2607
2617
  };
2608
- const create$E = (canvasId, callbackId) => {
2609
- const canvas = document.createElement('canvas');
2610
- const offscreenCanvas = canvas.transferControlToOffscreen();
2611
- set$3(canvasId, canvas);
2612
- sendAndTransfer({
2613
- jsonrpc: Two,
2614
- id: callbackId,
2615
- params: [offscreenCanvas]
2616
- }, [offscreenCanvas]);
2618
+ const focusPrevious$1 = () => {
2619
+ const $Element = getElement();
2620
+ if ($Element) {
2621
+ // @ts-expect-error
2622
+ $Element.focus();
2623
+ }
2617
2624
  };
2618
2625
 
2619
- const name$f = 'OffscreenCanvas';
2620
-
2621
- // prettier-ignore
2622
- const Commands$g = {
2623
- create: create$E
2626
+ const create$I = () => {
2627
+ const $InputBox = document.createElement('input');
2628
+ $InputBox.className = 'InputBox';
2629
+ $InputBox.spellcheck = false;
2630
+ $InputBox.autocapitalize = 'off';
2631
+ // $InputBox.autocomplete = 'off' // TODO needed?
2632
+ $InputBox.type = 'text';
2633
+ $InputBox.setAttribute('autocorrect', 'off'); // for ios
2634
+ return $InputBox;
2624
2635
  };
2625
2636
 
2626
- const OffscreenCanvas_ipc = {
2627
- __proto__: null,
2628
- Commands: Commands$g,
2629
- name: name$f
2637
+ const setBounds$6 = ($Element, x, y, width, height) => {
2638
+ $Element.style.top = `${y}px`;
2639
+ $Element.style.left = `${x}px`;
2640
+ $Element.style.width = `${width}px`;
2641
+ $Element.style.height = `${height}px`;
2630
2642
  };
2631
-
2632
- // TODO this module should be called dom or dom utils
2633
-
2634
- // TODO this module makes for weird code splitting chunks,
2635
- // maybe duplicate the code per file for better chunks
2636
-
2637
- const findIndex = ($Container, $Target) => {
2638
- while ($Target && $Target.parentNode !== $Container) {
2639
- $Target = $Target.parentNode;
2640
- }
2641
- if (!$Target) {
2642
- return -1;
2643
- }
2644
- for (let i = 0; i < $Container.children.length; i++) {
2645
- if ($Container.children[i] === $Target) {
2646
- return i;
2647
- }
2643
+ const setYAndHeight = ($Element, y, height) => {
2644
+ if (!$Element) {
2645
+ return;
2648
2646
  }
2649
- return -1;
2647
+ $Element.style.translate = typeof y === 'string' ? y : `0 ${y}px`;
2648
+ $Element.style.height = typeof height === 'string' ? height : `${height}px`;
2650
2649
  };
2651
-
2652
- const create$BackDrop = () => {
2653
- const $BackDrop = document.createElement('div');
2654
- $BackDrop.className = 'BackDrop';
2655
- return $BackDrop;
2650
+ const setXAndWidth = ($Element, x, width) => {
2651
+ $Element.style.translate = `${x}px 0`;
2652
+ $Element.style.width = `${width}px`;
2656
2653
  };
2657
-
2658
- const BeforeInput = 'beforeinput';
2659
- const Blur = 'blur';
2660
- const Click = 'click';
2661
- const CompositionEnd = 'compositionend';
2662
- const CompositionStart = 'compositionstart';
2663
- const CompositionUpdate = 'compositionupdate';
2664
- const ContextMenu = 'contextmenu';
2665
- const Cut = 'cut';
2666
- const DoubleClick = 'dblclick';
2667
- const DragEnd = 'dragend';
2668
- const DragLeave = 'dragleave';
2669
- const DragOver = 'dragover';
2670
- const DragStart = 'dragstart';
2671
- const Drop = 'drop';
2672
- const Error$3 = 'error';
2673
- const Focus = 'focus';
2674
- const FocusIn = 'focusin';
2675
- const FocusOut = 'focusout';
2676
- const Input$1 = 'input';
2677
- const KeyDown = 'keydown';
2678
- const KeyUp = 'keyup';
2679
- const LostPointerCapture = 'lostpointercapture';
2680
- const MouseDown = 'mousedown';
2681
- const MouseEnter = 'mouseenter';
2682
- const MouseLeave = 'mouseleave';
2683
- const MouseUp = 'mouseup';
2684
- const Paste = 'paste';
2685
- const PointerDown = 'pointerdown';
2686
- const PointerMove = 'pointermove';
2687
- const PointerUp = 'pointerup';
2688
- const Resize = 'resize';
2689
- const Scroll = 'scroll';
2690
- const TouchEnd = 'touchend';
2691
- const TouchMove = 'touchmove';
2692
- const TouchStart = 'touchstart';
2693
- const Wheel = 'wheel';
2694
-
2695
- // src/parts/ClearNode/ClearNode.ts
2696
- var clearNode = $Node => {
2697
- $Node.textContent = "";
2654
+ const setTop = ($Element, top) => {
2655
+ $Element.style.top = `${top}px`;
2656
+ };
2657
+ const setWidth = ($Element, width) => {
2658
+ $Element.style.width = `${width}px`;
2659
+ };
2660
+ const setXAndY = ($Element, x, y) => {
2661
+ $Element.style.left = `${x}px`;
2662
+ $Element.style.top = `${y}px`;
2698
2663
  };
2699
2664
 
2700
- // src/parts/ElementTags/ElementTags.ts
2701
- var Audio$2 = "audio";
2702
- var Button = "button";
2703
- var Col = "col";
2704
- var ColGroup = "colgroup";
2705
- var Del = "del";
2706
- var Div = "div";
2707
- var H1 = "h1";
2708
- var H2 = "h2";
2709
- var H3 = "h3";
2710
- var H4 = "h4";
2711
- var H5 = "h5";
2712
- var H6 = "h6";
2713
- var I = "i";
2714
- var Img = "img";
2715
- var Input = "input";
2716
- var Ins = "ins";
2717
- var Kbd = "kbd";
2718
- var Span = "span";
2719
- var Table = "table";
2720
- var TBody = "tbody";
2721
- var Td = "td";
2722
- var Th = "th";
2723
- var THead = "thead";
2724
- var Tr = "tr";
2725
- var Article = "article";
2726
- var Aside = "aside";
2727
- var Footer = "footer";
2728
- var Header = "header";
2729
- var Nav = "nav";
2730
- var Section = "section";
2731
- var Search$1 = "search";
2732
- var Dd = "dd";
2733
- var Dl = "dl";
2734
- var Figcaption = "figcaption";
2735
- var Figure = "figure";
2736
- var Hr = "hr";
2737
- var Li = "li";
2738
- var Ol = "ol";
2739
- var P = "p";
2740
- var Pre = "pre";
2741
- var A = "a";
2742
- var Br = "br";
2743
- var Cite = "cite";
2744
- var Data = "data";
2745
- var Time$1 = "time";
2746
- var Tfoot = "tfoot";
2747
- var Ul = "ul";
2748
- var Video$1 = "video";
2749
- var TextArea = "textarea";
2750
- var Select = "select";
2751
- var Option = "option";
2665
+ /**
2666
+ *
2667
+ * @param {HTMLElement} $Element
2668
+ * @param {number} x
2669
+ * @param {number} y
2670
+ */
2671
+ const setXAndYTransform = ($Element, x, y) => {
2672
+ $Element.style.translate = `${x}px ${y}px`;
2673
+ };
2674
+ const setHeight = ($Element, height) => {
2675
+ $Element.style.height = `${height}px`;
2676
+ };
2677
+
2678
+ const FocusDebugInput = 6;
2679
+ const FocusEditorRename = 11;
2680
+ const FocusExplorer = 13;
2681
+ const FocusExplorerEditBox = 14;
2682
+ const FocusLocationList = 17;
2683
+ const FocusMenu = 18;
2684
+ const FocusQuickPickInput = 20;
2685
+ const FocusSearchInput = 21;
2686
+ const FocusSimpleBrowserInput = 23;
2687
+ const FocusOutput = 28;
2688
+
2689
+ const handleBlur$a = () => {
2690
+ send( /* EditorRename.abort */'EditorRename.abort');
2691
+ };
2692
+ const create$H = (x, y) => {
2693
+ const $RenameWidgetInputBox = create$I();
2694
+ $RenameWidgetInputBox.className = 'RenameWidgetInputBox';
2695
+ $RenameWidgetInputBox.onblur = handleBlur$a;
2696
+ const $RenameWidget = document.createElement('div');
2697
+ $RenameWidget.className = 'RenameWidget';
2698
+ $RenameWidget.append($RenameWidgetInputBox);
2699
+ setXAndY($RenameWidget, x, y);
2700
+ append$1($RenameWidget);
2701
+ focus$i($RenameWidgetInputBox);
2702
+ send('Focus.setFocus', FocusEditorRename);
2703
+ return {
2704
+ $RenameWidget,
2705
+ $RenameWidgetInputBox
2706
+ };
2707
+ };
2708
+ const dispose$i = state => {
2709
+ // TODO focus editor
2710
+ remove$1(state.$RenameWidget);
2711
+ };
2712
+
2713
+ // TODO could also be event based
2714
+ // finish -> finish -> finishWithValue
2715
+
2716
+ const finish = state => {
2717
+ const value = state.$RenameWidgetInputBox.value;
2718
+ // TODO don't like side effect here
2719
+ return value;
2720
+ };
2721
+
2722
+ const name$r = 'EditorRename';
2723
+ const Commands$s = {
2724
+ create: create$H,
2725
+ dispose: dispose$i,
2726
+ finish: finish
2727
+ };
2728
+
2729
+ const EditorRename_ipc = {
2730
+ __proto__: null,
2731
+ Commands: Commands$s,
2732
+ name: name$r
2733
+ };
2734
+
2735
+ const showDirectoryPicker = options => {
2736
+ // @ts-expect-error
2737
+ return window.showDirectoryPicker(options);
2738
+ };
2739
+ const showFilePicker = options => {
2740
+ // @ts-expect-error
2741
+ return window.showFilePicker(options);
2742
+ };
2743
+ const showSaveFilePicker = options => {
2744
+ // @ts-expect-error
2745
+ return window.showSaveFilePicker(options);
2746
+ };
2747
+
2748
+ const name$q = 'FilePicker';
2749
+ const Commands$r = {
2750
+ showDirectoryPicker: showDirectoryPicker,
2751
+ showFilePicker: showFilePicker,
2752
+ showSaveFilePicker: showSaveFilePicker
2753
+ };
2754
+
2755
+ const FilePicker_ipc = {
2756
+ __proto__: null,
2757
+ Commands: Commands$r,
2758
+ name: name$q
2759
+ };
2760
+
2761
+ const requestPermission = (handle, options) => {
2762
+ return handle.requestPermission(options);
2763
+ };
2764
+
2765
+ const name$p = 'FileSystemHandle';
2766
+ const Commands$q = {
2767
+ requestPermission: requestPermission
2768
+ };
2769
+
2770
+ const FileSystemHandle_ipc = {
2771
+ __proto__: null,
2772
+ Commands: Commands$q,
2773
+ name: name$p
2774
+ };
2775
+
2776
+ const handleImageLoad = event => {
2777
+ const $ImagePreviewImage = event.target;
2778
+ const $ImagePreviewCaption = $ImagePreviewImage.nextSibling;
2779
+ const width = $ImagePreviewImage.naturalWidth;
2780
+ const height = $ImagePreviewImage.naturalHeight;
2781
+ $ImagePreviewCaption.textContent = `${width} × ${height}`;
2782
+ };
2783
+ const handleImageError$1 = event => {
2784
+ const $ImagePreviewImage = event.target;
2785
+ const $ImagePreviewCaption = $ImagePreviewImage.nextSibling;
2786
+ $ImagePreviewCaption.textContent = 'Image could not be loaded';
2787
+ };
2788
+
2789
+ // TODO duplicate code with below
2790
+
2791
+ const showError = (message, y, x) => {
2792
+ const $ImagePreviewImage = document.createElement('img');
2793
+ $ImagePreviewImage.className = 'ImagePreviewImage';
2794
+ $ImagePreviewImage.alt = '';
2795
+ const $ImagePreviewCaption = document.createElement('figcaption');
2796
+ $ImagePreviewCaption.className = 'ImagePreviewCaption';
2797
+ $ImagePreviewCaption.textContent = message;
2798
+ const $ImagePreview = document.createElement('figure');
2799
+ $ImagePreview.className = 'ImagePreview';
2800
+ $ImagePreview.append($ImagePreviewImage, $ImagePreviewCaption);
2801
+ setXAndY($ImagePreview, x, y);
2802
+ $ImagePreview.style.display = 'none';
2803
+ append$1($ImagePreview);
2804
+ return {
2805
+ $ImagePreview,
2806
+ $ImagePreviewCaption,
2807
+ $ImagePreviewImage
2808
+ };
2809
+ };
2810
+ const create$G = (uri, top, left) => {
2811
+ const $ImagePreviewImage = document.createElement('img');
2812
+ $ImagePreviewImage.className = 'ImagePreviewImage';
2813
+ $ImagePreviewImage.src = uri;
2814
+ $ImagePreviewImage.alt = '';
2815
+ const $ImagePreviewCaption = document.createElement('figcaption');
2816
+ $ImagePreviewCaption.className = 'ImagePreviewCaption';
2817
+ const $ImagePreview = document.createElement('figure');
2818
+ $ImagePreview.className = 'ImagePreview';
2819
+ $ImagePreview.append($ImagePreviewImage, $ImagePreviewCaption);
2820
+ $ImagePreviewImage.onload = handleImageLoad;
2821
+ $ImagePreviewImage.onerror = handleImageError$1;
2822
+ $ImagePreview.style.top = `${top}px`;
2823
+ $ImagePreview.style.left = `${left}px`;
2824
+ $ImagePreview.style.display = 'none';
2825
+ append$1($ImagePreview);
2826
+ return {
2827
+ $ImagePreview,
2828
+ $ImagePreviewCaption,
2829
+ $ImagePreviewImage
2830
+ };
2831
+ };
2832
+ const update = (state, uri) => {
2833
+ state.$ImagePreviewImage.uri = uri;
2834
+ };
2835
+ const dispose$h = state => {
2836
+ remove$1(state.$ImagePreview);
2837
+ };
2838
+
2839
+ const ImagePreview$1 = {
2840
+ __proto__: null,
2841
+ create: create$G,
2842
+ dispose: dispose$h,
2843
+ showError,
2844
+ update
2845
+ };
2846
+
2847
+ const name$o = 'ImagePreview';
2848
+ const Commands$p = {
2849
+ create: create$G,
2850
+ dispose: dispose$h,
2851
+ showError: showError,
2852
+ update: update
2853
+ };
2854
+
2855
+ const ImagePreview_ipc = {
2856
+ __proto__: null,
2857
+ Commands: Commands$p,
2858
+ name: name$o
2859
+ };
2860
+
2861
+ const getOrigin = () => {
2862
+ return location.origin;
2863
+ };
2864
+ const getPathName = () => {
2865
+ return location.pathname;
2866
+ };
2867
+ const getHref = () => {
2868
+ return location.href;
2869
+ };
2870
+
2871
+ // TODO should do nothing if it is already at this path
2872
+ const setPathName = pathName => {
2873
+ const currentPathName = getPathName();
2874
+ if (currentPathName === pathName) {
2875
+ return;
2876
+ }
2877
+ // @ts-expect-error
2878
+ history.pushState(null, null, pathName);
2879
+ };
2880
+ const hydrate = () => {
2881
+ // addEventListener('popstate', handlePopState)
2882
+ };
2883
+
2884
+ const getTitleBarHeight = () => {
2885
+ if (
2886
+ // @ts-expect-error
2887
+ navigator.windowControlsOverlay?.getTitlebarAreaRect) {
2888
+ // @ts-expect-error
2889
+ const titleBarRect = navigator.windowControlsOverlay.getTitlebarAreaRect();
2890
+ return titleBarRect.height;
2891
+ }
2892
+ return 0;
2893
+ };
2894
+ const getBounds = () => {
2895
+ return {
2896
+ windowWidth: window.innerWidth,
2897
+ windowHeight: window.innerHeight,
2898
+ titleBarHeight: getTitleBarHeight()
2899
+ };
2900
+ };
2901
+
2902
+ const getInitData = () => {
2903
+ const initData = {
2904
+ Location: {
2905
+ href: getHref()
2906
+ },
2907
+ Layout: {
2908
+ bounds: getBounds()
2909
+ }
2910
+ };
2911
+ return initData;
2912
+ };
2913
+
2914
+ const name$n = 'InitData';
2915
+ const Commands$o = {
2916
+ getInitData: getInitData
2917
+ };
2918
+
2919
+ const InitData_ipc = {
2920
+ __proto__: null,
2921
+ Commands: Commands$o,
2922
+ name: name$n
2923
+ };
2924
+
2925
+ const name$m = 'IpcParent';
2926
+ const Commands$n = {
2927
+ create: create$L
2928
+ };
2929
+
2930
+ const IpcParent_ipc = {
2931
+ __proto__: null,
2932
+ Commands: Commands$n,
2933
+ name: name$m
2934
+ };
2935
+
2936
+ const name$l = 'Layout';
2937
+ const Commands$m = {
2938
+ getBounds: getBounds
2939
+ };
2940
+
2941
+ const Layout_ipc = {
2942
+ __proto__: null,
2943
+ Commands: Commands$m,
2944
+ name: name$l
2945
+ };
2946
+
2947
+ const name$k = 'Location';
2948
+ const Commands$l = {
2949
+ getHref: getHref,
2950
+ getPathName: getPathName,
2951
+ hydrate: hydrate,
2952
+ setPathName: setPathName
2953
+ };
2954
+
2955
+ const Location_ipc = {
2956
+ __proto__: null,
2957
+ Commands: Commands$l,
2958
+ name: name$k
2959
+ };
2960
+
2961
+ const getElementHeight = $Element => {
2962
+ document.body.append($Element);
2963
+ const height = $Element.offsetHeight;
2964
+ $Element.remove();
2965
+ return height;
2966
+ };
2967
+
2968
+ const measureTextHeight = (text, fontSize, fontFamily) => {
2969
+ string(text);
2970
+ string(fontSize);
2971
+ string(fontFamily);
2972
+ const $Measure = document.createElement('div');
2973
+ $Measure.style.contain = 'content';
2974
+ $Measure.style.position = 'absolute';
2975
+ $Measure.style.top = '-9999px';
2976
+ $Measure.style.left = '-9999px';
2977
+ $Measure.textContent = text;
2978
+ return getElementHeight($Measure);
2979
+ };
2980
+
2981
+ const name$j = 'MeasureTextHeight';
2982
+ const Commands$k = {
2983
+ measureTextHeight: measureTextHeight
2984
+ };
2985
+
2986
+ const MeasureTextHeight_ipc = {
2987
+ __proto__: null,
2988
+ Commands: Commands$k,
2989
+ name: name$j
2990
+ };
2991
+
2992
+ const measureTextBlockHeight = (text, fontSize, fontFamily, lineHeight, width) => {
2993
+ string(text);
2994
+ number(fontSize);
2995
+ string(fontFamily);
2996
+ number(width);
2997
+ string(lineHeight);
2998
+ const $Measure = document.createElement('div');
2999
+ $Measure.style.width = `${width}px`;
3000
+ $Measure.style.contain = 'content';
3001
+ $Measure.style.position = 'absolute';
3002
+ $Measure.style.top = '-9999px';
3003
+ $Measure.style.left = '-9999px';
3004
+ $Measure.style.fontSize = `${fontSize}px`;
3005
+ $Measure.style.lineHeight = lineHeight;
3006
+ $Measure.textContent = text;
3007
+ return getElementHeight($Measure);
3008
+ };
2752
3009
 
2753
- // src/parts/VirtualDomElements/VirtualDomElements.ts
2754
- var Audio2 = 0;
2755
- var Button2 = 1;
2756
- var Col2 = 2;
2757
- var ColGroup2 = 3;
2758
- var Div2 = 4;
2759
- var H12 = 5;
2760
- var Input2 = 6;
2761
- var Kbd2 = 7;
2762
- var Span2 = 8;
2763
- var Table2 = 9;
2764
- var TBody2 = 10;
2765
- var Td2 = 11;
2766
- var Text$2 = 12;
2767
- var Th2 = 13;
2768
- var THead2 = 14;
2769
- var Tr2 = 15;
2770
- var I2 = 16;
2771
- var Img2 = 17;
2772
- var Ins2 = 20;
2773
- var Del2 = 21;
2774
- var H22 = 22;
2775
- var H32 = 23;
2776
- var H42 = 24;
2777
- var H52 = 25;
2778
- var H62 = 26;
2779
- var Article2 = 27;
2780
- var Aside2 = 28;
2781
- var Footer2 = 29;
2782
- var Header2 = 30;
2783
- var Nav2 = 40;
2784
- var Section2 = 41;
2785
- var Search2 = 42;
2786
- var Dd2 = 43;
2787
- var Dl2 = 44;
2788
- var Figcaption2 = 45;
2789
- var Figure2 = 46;
2790
- var Hr2 = 47;
2791
- var Li2 = 48;
2792
- var Ol2 = 49;
2793
- var P2 = 50;
2794
- var Pre2 = 51;
2795
- var A2 = 53;
2796
- var Br2 = 55;
2797
- var Cite2 = 56;
2798
- var Data2 = 57;
2799
- var Time2 = 58;
2800
- var Tfoot2 = 59;
2801
- var Ul2 = 60;
2802
- var Video2 = 61;
2803
- var TextArea2 = 62;
2804
- var Select2 = 63;
2805
- var Option2 = 64;
3010
+ const name$i = 'MeasureTextBlockHeight';
3011
+ const Commands$j = {
3012
+ measureTextBlockHeight: measureTextBlockHeight
3013
+ };
2806
3014
 
2807
- // src/parts/ElementTagMap/ElementTagMap.ts
2808
- var getElementTag = type => {
2809
- switch (type) {
2810
- case Audio2:
2811
- return Audio$2;
2812
- case H12:
2813
- return H1;
2814
- case H22:
2815
- return H2;
2816
- case H32:
2817
- return H3;
2818
- case H42:
2819
- return H4;
2820
- case H52:
2821
- return H5;
2822
- case H62:
2823
- return H6;
2824
- case Div2:
2825
- return Div;
2826
- case Kbd2:
2827
- return Kbd;
2828
- case Table2:
2829
- return Table;
2830
- case TBody2:
2831
- return TBody;
2832
- case Th2:
2833
- return Th;
2834
- case Td2:
2835
- return Td;
2836
- case THead2:
2837
- return THead;
2838
- case Tr2:
2839
- return Tr;
2840
- case Input2:
2841
- return Input;
2842
- case ColGroup2:
2843
- return ColGroup;
2844
- case Col2:
2845
- return Col;
2846
- case Button2:
2847
- return Button;
2848
- case Span2:
2849
- return Span;
2850
- case I2:
2851
- return I;
2852
- case Img2:
2853
- return Img;
2854
- case Ins2:
2855
- return Ins;
2856
- case Del2:
2857
- return Del;
2858
- case Article2:
2859
- return Article;
2860
- case Aside2:
2861
- return Aside;
2862
- case Footer2:
2863
- return Footer;
2864
- case Header2:
2865
- return Header;
2866
- case Nav2:
2867
- return Nav;
2868
- case Section2:
2869
- return Section;
2870
- case Search2:
2871
- return Search$1;
2872
- case Dd2:
2873
- return Dd;
2874
- case Dl2:
2875
- return Dl;
2876
- case Figcaption2:
2877
- return Figcaption;
2878
- case Figure2:
2879
- return Figure;
2880
- case Hr2:
2881
- return Hr;
2882
- case Li2:
2883
- return Li;
2884
- case Ol2:
2885
- return Ol;
2886
- case P2:
2887
- return P;
2888
- case Pre2:
2889
- return Pre;
2890
- case A2:
2891
- return A;
2892
- case Br2:
2893
- return Br;
2894
- case Cite2:
2895
- return Cite;
2896
- case Data2:
2897
- return Data;
2898
- case Time2:
2899
- return Time$1;
2900
- case Tfoot2:
2901
- return Tfoot;
2902
- case Ul2:
2903
- return Ul;
2904
- case Video2:
2905
- return Video$1;
2906
- case TextArea2:
2907
- return TextArea;
2908
- case Select2:
2909
- return Select;
2910
- case Option2:
2911
- return Option;
2912
- default:
2913
- throw new Error(`element tag not found ${type}`);
3015
+ const MeasureTextBlockHeight_ipc = {
3016
+ __proto__: null,
3017
+ Commands: Commands$j,
3018
+ name: name$i
3019
+ };
3020
+
3021
+ const setThemeColor = color => {
3022
+ const meta = document.querySelector('meta[name="theme-color"]');
3023
+ if (!meta) {
3024
+ return;
2914
3025
  }
3026
+ // @ts-expect-error
3027
+ meta.content = color;
2915
3028
  };
2916
3029
 
2917
- // src/parts/VirtualDomElementProp/VirtualDomElementProp.ts
2918
- var setProp = ($Element, key, value, eventMap) => {
2919
- switch (key) {
2920
- case "maskImage":
2921
- $Element.style.maskImage = `url('${value}')`;
2922
- $Element.style.webkitMaskImage = `url('${value}')`;
2923
- break;
2924
- case "paddingLeft":
2925
- case "paddingRight":
2926
- case "top":
2927
- case "left":
2928
- case "marginTop":
2929
- $Element.style[key] = typeof value === "number" ? `${value}px` : value;
2930
- break;
2931
- case "translate":
2932
- $Element.style[key] = value;
2933
- break;
2934
- case "width":
2935
- case "height":
2936
- if ($Element instanceof HTMLImageElement) {
2937
- $Element[key] = value;
2938
- } else if (typeof value === "number") {
2939
- $Element.style[key] = `${value}px`;
2940
- } else {
2941
- $Element.style[key] = value;
2942
- }
2943
- break;
2944
- case "style":
2945
- throw new Error("style property is not supported");
2946
- case "childCount":
2947
- case "type":
2948
- break;
2949
- case "ariaOwns":
2950
- if (value) {
2951
- $Element.setAttribute("aria-owns", value);
2952
- } else {
2953
- $Element.removeAttribute("aria-owns");
2954
- }
2955
- break;
2956
- case "inputType":
2957
- $Element.type = value;
2958
- break;
2959
- case "ariaLabelledBy":
2960
- $Element.setAttribute("aria-labelledby", value);
2961
- break;
2962
- case "onBlur":
2963
- case "onChange":
2964
- case "onClick":
2965
- case "onContextMenu":
2966
- case "onDblClick":
2967
- case "onFocus":
2968
- case "onFocusIn":
2969
- case "onFocusIn":
2970
- case "onFocusOut":
2971
- case "onInput":
2972
- case "onKeyDown":
2973
- case "onMouseDown":
2974
- case "onPointerDown":
2975
- case "onPointerOut":
2976
- case "onPointerOver":
2977
- case "onWheel":
2978
- key.slice(2).toLowerCase();
2979
- if (!eventMap || !value) {
2980
- return;
2981
- }
3030
+ const name$h = 'Meta';
3031
+ const Commands$i = {
3032
+ setThemeColor: setThemeColor
3033
+ };
3034
+
3035
+ const Meta_ipc = {
3036
+ __proto__: null,
3037
+ Commands: Commands$i,
3038
+ name: name$h
3039
+ };
3040
+
3041
+ const create$Notification = message => {
3042
+ const $Notification = document.createElement('div');
3043
+ $Notification.className = 'Notification';
3044
+ $Notification.textContent = message;
3045
+ return $Notification;
3046
+ };
3047
+ const create$F = (type, message) => {
3048
+ // TODO this pattern might be also useful for activitybar, sidebar etc., creating elements as late as possible, only when actually needed
3049
+ const $Notification = create$Notification(message);
3050
+ append$1($Notification);
3051
+ };
3052
+ const findIndex$1 = $Child => {
3053
+ const $Parent = $Child.parentNode;
3054
+ for (let i = 0; i < $Parent.children.length; i++) {
3055
+ if ($Parent.children[i] === $Child) {
3056
+ return i;
3057
+ }
3058
+ }
3059
+ return -1;
3060
+ };
3061
+ const handleNotificationClick = event => {
3062
+ const $Target = event.target;
3063
+ switch ($Target.className) {
3064
+ case 'NotificationOption':
3065
+ const index = findIndex$1($Target);
3066
+ send( /* Notification.handleClick */'Notification.handleClick', /* index */index);
2982
3067
  break;
2983
- default:
2984
- if (key.startsWith("data-")) {
2985
- $Element.dataset[key.slice("data-".length)] = value;
2986
- } else {
2987
- $Element[key] = value;
2988
- }
2989
3068
  }
2990
3069
  };
2991
-
2992
- // src/parts/VirtualDomElementProps/VirtualDomElementProps.ts
2993
- var setProps = ($Element, props, eventMap) => {
2994
- for (const key in props) {
2995
- setProp($Element, key, props[key], eventMap);
3070
+ const create$NotificationWithOptions = (message, options) => {
3071
+ const $NotificationMessage = document.createElement('p');
3072
+ $NotificationMessage.className = 'NotificationMessage';
3073
+ $NotificationMessage.textContent = message;
3074
+ const $NotificationOptions = document.createElement('div');
3075
+ $NotificationOptions.className = 'NotificationOptions';
3076
+ for (const option of options) {
3077
+ const $NotificationOption = document.createElement('button');
3078
+ $NotificationOption.className = 'NotificationOption';
3079
+ $NotificationOption.textContent = option;
3080
+ $NotificationOptions.append($NotificationOption);
2996
3081
  }
3082
+ const $Notification = document.createElement('div');
3083
+ $Notification.className = 'Notification';
3084
+ $Notification.append($NotificationMessage, $NotificationOptions);
3085
+ $Notification.onclick = handleNotificationClick;
3086
+ return $Notification;
3087
+ };
3088
+ const createWithOptions = (type, message, options) => {
3089
+ const $Notification = create$NotificationWithOptions(message, options);
3090
+ append$1($Notification);
3091
+ };
3092
+ const dispose$g = id => {
3093
+ // const $Notification = state.$Notifications
2997
3094
  };
2998
3095
 
2999
- // src/parts/VirtualDomElement/VirtualDomElement.ts
3000
- var renderDomTextNode = element => {
3001
- return document.createTextNode(element.text);
3096
+ const name$g = 'Notification';
3097
+
3098
+ // prettier-ignore
3099
+ const Commands$h = {
3100
+ create: create$F,
3101
+ createWithOptions: createWithOptions,
3102
+ dispose: dispose$g
3002
3103
  };
3003
- var renderDomElement = (element, eventMap) => {
3004
- const tag = getElementTag(element.type);
3005
- const $Element = document.createElement(tag);
3006
- setProps($Element, element, eventMap);
3007
- return $Element;
3104
+
3105
+ const Notification_ipc = {
3106
+ __proto__: null,
3107
+ Commands: Commands$h,
3108
+ name: name$g
3008
3109
  };
3009
- var render = (element, eventMap) => {
3010
- switch (element.type) {
3011
- case Text$2:
3012
- return renderDomTextNode(element);
3013
- default:
3014
- return renderDomElement(element, eventMap);
3015
- }
3110
+
3111
+ const state$3 = {
3112
+ canvasObjects: Object.create(null)
3113
+ };
3114
+ const get$4 = id => {
3115
+ return state$3.canvasObjects[id];
3116
+ };
3117
+ const set$3 = (canvasId, canvas) => {
3118
+ state$3.canvasObjects[canvasId] = canvas;
3016
3119
  };
3017
3120
 
3018
- // src/parts/RenderInternal/RenderInternal.ts
3019
- var renderInternal2 = ($Parent, elements, eventMap) => {
3020
- const max = elements.length - 1;
3021
- let stack = [];
3022
- for (let i = max; i >= 0; i--) {
3023
- const element = elements[i];
3024
- const $Element = render(element, eventMap);
3025
- if (element.childCount > 0) {
3026
- $Element.append(...stack.slice(0, element.childCount));
3027
- stack = stack.slice(element.childCount);
3121
+ const get$3 = id => {
3122
+ return get$4(id);
3123
+ };
3124
+ const create$E = (canvasId, callbackId) => {
3125
+ const canvas = document.createElement('canvas');
3126
+ const offscreenCanvas = canvas.transferControlToOffscreen();
3127
+ set$3(canvasId, canvas);
3128
+ sendAndTransfer({
3129
+ jsonrpc: '2.0',
3130
+ id: callbackId,
3131
+ params: [offscreenCanvas]
3132
+ }, [offscreenCanvas]);
3133
+ };
3134
+
3135
+ const name$f = 'OffscreenCanvas';
3136
+
3137
+ // prettier-ignore
3138
+ const Commands$g = {
3139
+ create: create$E
3140
+ };
3141
+
3142
+ const OffscreenCanvas_ipc = {
3143
+ __proto__: null,
3144
+ Commands: Commands$g,
3145
+ name: name$f
3146
+ };
3147
+
3148
+ // TODO this module should be called dom or dom utils
3149
+
3150
+ // TODO this module makes for weird code splitting chunks,
3151
+ // maybe duplicate the code per file for better chunks
3152
+
3153
+ const findIndex = ($Container, $Target) => {
3154
+ while ($Target && $Target.parentNode !== $Container) {
3155
+ $Target = $Target.parentNode;
3156
+ }
3157
+ if (!$Target) {
3158
+ return -1;
3159
+ }
3160
+ for (let i = 0; i < $Container.children.length; i++) {
3161
+ if ($Container.children[i] === $Target) {
3162
+ return i;
3028
3163
  }
3029
- stack.unshift($Element);
3030
3164
  }
3031
- $Parent.append(...stack);
3165
+ return -1;
3032
3166
  };
3033
3167
 
3034
- // src/parts/VirtualDom/VirtualDom.ts
3035
- var renderInto = ($Parent, dom, eventMap = {}) => {
3036
- clearNode($Parent);
3037
- renderInternal2($Parent, dom, eventMap);
3038
- };
3039
- var render2 = (elements, eventMap = {}) => {
3040
- const $Root = document.createElement("div");
3041
- renderInternal2($Root, elements, eventMap);
3042
- return $Root;
3168
+ const create$BackDrop = () => {
3169
+ const $BackDrop = document.createElement('div');
3170
+ $BackDrop.className = 'BackDrop';
3171
+ return $BackDrop;
3043
3172
  };
3044
3173
 
3174
+ const BeforeInput = 'beforeinput';
3175
+ const Blur = 'blur';
3176
+ const Click = 'click';
3177
+ const CompositionEnd = 'compositionend';
3178
+ const CompositionStart = 'compositionstart';
3179
+ const CompositionUpdate = 'compositionupdate';
3180
+ const ContextMenu = 'contextmenu';
3181
+ const Cut = 'cut';
3182
+ const DoubleClick = 'dblclick';
3183
+ const DragEnd = 'dragend';
3184
+ const DragLeave = 'dragleave';
3185
+ const DragOver = 'dragover';
3186
+ const DragStart = 'dragstart';
3187
+ const Drop = 'drop';
3188
+ const Error$3 = 'error';
3189
+ const Focus = 'focus';
3190
+ const FocusIn = 'focusin';
3191
+ const FocusOut = 'focusout';
3192
+ const Input = 'input';
3193
+ const KeyDown = 'keydown';
3194
+ const KeyUp = 'keyup';
3195
+ const LostPointerCapture = 'lostpointercapture';
3196
+ const MouseDown = 'mousedown';
3197
+ const MouseEnter = 'mouseenter';
3198
+ const MouseLeave = 'mouseleave';
3199
+ const MouseUp = 'mouseup';
3200
+ const Paste = 'paste';
3201
+ const PointerDown = 'pointerdown';
3202
+ const PointerMove = 'pointermove';
3203
+ const PointerUp = 'pointerup';
3204
+ const Resize = 'resize';
3205
+ const Scroll = 'scroll';
3206
+ const TouchEnd = 'touchend';
3207
+ const TouchMove = 'touchmove';
3208
+ const TouchStart = 'touchstart';
3209
+ const Wheel = 'wheel';
3210
+
3045
3211
  // TODO when pressing tab -> focus next element in tab order and close menu
3046
3212
 
3047
3213
  // TODO menu and contextmenu should have own keybinding logic
@@ -3988,30 +4154,9 @@ const Transferrable_ipc = {
3988
4154
  name: name$8
3989
4155
  };
3990
4156
 
3991
- const uidSymbol = Symbol('uid');
3992
- const set$1 = ($Element, uid) => {
3993
- $Element[uidSymbol] = uid;
3994
- };
3995
- const getUidTarget = $Element => {
3996
- while ($Element) {
3997
- if ($Element[uidSymbol]) {
3998
- return $Element;
3999
- }
4000
- $Element = $Element.parentNode;
4001
- }
4002
- return undefined;
4003
- };
4004
- const get = $Element => {
4005
- const $Target = getUidTarget($Element);
4006
- return $Target[uidSymbol];
4007
- };
4008
- const fromEvent = event => {
4009
- const {
4010
- target,
4011
- currentTarget
4012
- } = event;
4013
- return get(currentTarget || target);
4014
- };
4157
+ const set$1 = setComponentUid;
4158
+ const get = getComponentUid;
4159
+ const fromEvent = getComponentUidFromEvent;
4015
4160
 
4016
4161
  const state$1 = {
4017
4162
  identifiers: new Uint32Array()
@@ -4038,47 +4183,7 @@ const setIdentifiers = identifiers => {
4038
4183
  setIdentifiers$1(identifiers);
4039
4184
  };
4040
4185
 
4041
- const queryInputs = $Viewlet => {
4042
- return [...$Viewlet.querySelectorAll('input, textarea')];
4043
- };
4044
- const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
4045
- // TODO replace this workaround with
4046
- // virtual dom diffing
4047
- const oldLeft = $Viewlet.style.left;
4048
- const oldTop = $Viewlet.style.top;
4049
- const oldWidth = $Viewlet.style.width;
4050
- const oldHeight = $Viewlet.style.height;
4051
- // @ts-expect-error
4052
- const focused = document.activeElement.getAttribute('name');
4053
- const $$Inputs = queryInputs($Viewlet);
4054
- const inputMap = Object.create(null);
4055
- for (const $Input of $$Inputs) {
4056
- inputMap[$Input.name] = $Input.value;
4057
- }
4058
- if (uid) {
4059
- const $New = render2(dom, eventMap).firstChild;
4060
- set$1($New, uid);
4061
- $Viewlet.replaceWith($New);
4062
- $Viewlet = $New;
4063
- } else {
4064
- renderInto($Viewlet, dom, eventMap);
4065
- }
4066
- const $$NewInputs = queryInputs($Viewlet);
4067
- for (const $Input of $$NewInputs) {
4068
- $Input.value = inputMap[$Input.name] || $Input.value || '';
4069
- }
4070
- if (focused) {
4071
- const $Focused = $Viewlet.querySelector(`[name="${focused}"]`);
4072
- if ($Focused) {
4073
- $Focused.focus();
4074
- }
4075
- }
4076
- $Viewlet.style.top = oldTop;
4077
- $Viewlet.style.left = oldLeft;
4078
- $Viewlet.style.height = oldHeight;
4079
- $Viewlet.style.width = oldWidth;
4080
- return $Viewlet;
4081
- };
4186
+ const rememberFocus = rememberFocus$1;
4082
4187
 
4083
4188
  const ActivityBar = 'ActivityBar';
4084
4189
  const Audio$1 = 'Audio';
@@ -5565,7 +5670,7 @@ const create$z = async ({
5565
5670
  // TODO await promise
5566
5671
  // TODO call separate method HandleMessagePort.handleMessagePort or
5567
5672
  // HandleIncomingIpc.handleIncomingIpc
5568
- invokeAndTransfer(ipc, [port], 'initialize', 'message-port', port);
5673
+ invokeAndTransfer$1(ipc, [port], 'initialize', 'message-port', port);
5569
5674
  unhandleIpc(ipc);
5570
5675
  return undefined;
5571
5676
  };
@@ -5597,7 +5702,7 @@ const create$y = async ({
5597
5702
  }
5598
5703
  const windowIpc = IpcChildWithWindow$1.wrap(window);
5599
5704
  handleIpcOnce(windowIpc);
5600
- const webContentsIds = await invokeAndTransfer(windowIpc, [port], 'CreateMessagePort.createMessagePort', ipcId);
5705
+ const webContentsIds = await invokeAndTransfer$1(windowIpc, [port], 'CreateMessagePort.createMessagePort', ipcId);
5601
5706
  return webContentsIds;
5602
5707
  };
5603
5708
 
@@ -7677,7 +7782,7 @@ const setDom$4 = (state, dom) => {
7677
7782
  const {
7678
7783
  $Viewlet
7679
7784
  } = state;
7680
- rememberFocus($Viewlet, dom, ViewletExplorerEvents);
7785
+ rememberFocus($Viewlet, dom, ViewletExplorerEvents, 0);
7681
7786
  };
7682
7787
 
7683
7788
  const ViewletExplorer = {
@@ -7873,7 +7978,7 @@ const attachEvents$8 = state => {
7873
7978
  $ListItems,
7874
7979
  $ScrollBar
7875
7980
  } = state;
7876
- $ExtensionHeader.addEventListener(Input$1, handleInput$6, Capture);
7981
+ $ExtensionHeader.addEventListener(Input, handleInput$6, Capture);
7877
7982
  // @ts-expect-error
7878
7983
  $ExtensionHeader.addEventListener(Click, undefined);
7879
7984
  attachEvents$c($ListItems, {
@@ -8091,7 +8196,7 @@ const setDom$3 = (state, dom) => {
8091
8196
  const {
8092
8197
  $Viewlet
8093
8198
  } = state;
8094
- rememberFocus($Viewlet, dom, ViewletFindWidgetEvents);
8199
+ rememberFocus($Viewlet, dom, ViewletFindWidgetEvents, 0);
8095
8200
  };
8096
8201
 
8097
8202
  const ViewletFindWidget = {
@@ -8952,7 +9057,11 @@ const ViewletMain = {
8952
9057
 
8953
9058
  // TODO
8954
9059
  const getUid = () => {
8955
- return get(document.getElementById('Main'));
9060
+ const $Main = document.getElementById('Main');
9061
+ if (!$Main) {
9062
+ return 0;
9063
+ }
9064
+ return get($Main);
8956
9065
  };
8957
9066
  const handleTabsWheel = event => {
8958
9067
  const uid = getUid();
@@ -9239,7 +9348,7 @@ const setActionsDom$1 = (state$1, actions, childUid) => {
9239
9348
  throw new Error(`child instance not found`);
9240
9349
  }
9241
9350
  const eventMap = instance.factory.EventMap;
9242
- rememberFocus($PanelActions, actions, eventMap);
9351
+ rememberFocus($PanelActions, actions, eventMap, 0);
9243
9352
  };
9244
9353
 
9245
9354
  const ViewletPanel = {