@lvce-editor/renderer-process 5.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.
@@ -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
  };
@@ -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
@@ -981,13 +991,39 @@ const hydrate$1 = async () => {
981
991
  // @ts-expect-error
982
992
  state$9.ipc = ipc;
983
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
+ }
1002
+ };
984
1003
  const send = (method, ...params) => {
985
1004
  send$1(state$9.ipc, method, ...params);
986
1005
  };
1006
+ const invoke$1 = (method, ...params) => {
1007
+ return invoke$2(state$9.ipc, method, ...params);
1008
+ };
987
1009
  const sendAndTransfer = (message, transfer) => {
988
1010
  // @ts-expect-error
989
1011
  state$9.ipc.sendAndTransfer(message, transfer);
990
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
1026
+ };
991
1027
 
992
1028
  let AssertionError$1 = class AssertionError extends Error {
993
1029
  constructor(message) {
@@ -1739,1394 +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$8 = {
1824
- styleSheets: Object.create(null)
1825
- };
1826
- const set$4 = (id, sheet) => {
1827
- state$8.styleSheets[id] = sheet;
1828
- };
1829
- const get$5 = id => {
1830
- return state$8.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$7 = {
1905
- $AriaAlert1: undefined,
1906
- $AriaAlert2: undefined,
1907
- $AriaMessages: undefined
1908
- };
1909
- const getAriaAlert1 = () => {
1910
- return state$7.$AriaAlert1;
1911
- };
1912
- const getAriaAlert2 = () => {
1913
- return state$7.$AriaAlert2;
1914
- };
1915
- const setElements = ($AriaMessages, $AriaAlert1, $AriaAlert2) => {
1916
- state$7.$AriaMessages = $AriaMessages;
1917
- state$7.$AriaAlert1 = $AriaAlert1;
1918
- state$7.$AriaAlert2 = $AriaAlert2;
1919
- };
1920
- const hasElements = () => {
1921
- return state$7.$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$6 = {
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$6.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$6.widgetSet.add($Element);
2016
- if (state$6.$Widgets) {
2017
- // @ts-expect-error
2018
- state$6.$Widgets.append($Element);
2019
- } else {
2020
- // @ts-expect-error
2021
- state$6.$Widgets = create$Widgets();
2022
- // @ts-expect-error
2023
- state$6.$Widgets.append($Element);
2024
- // @ts-expect-error
2025
- document.body.append(state$6.$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$6.widgetSet.delete($Element);
2034
- $Element.remove();
2035
- // TODO state.$Widgets should always be defined at this point
2036
- if (state$6.widgetSet.size === 0 && state$6.$Widgets) {
2037
- // @ts-expect-error
2038
- state$6.$Widgets.remove();
2039
- state$6.$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$5 = {
2078
- /**
2079
- * @type {HTMLElement|undefined}
2080
- */
2081
- $PreviousFocusElement: undefined,
2082
- currentFocus: ''
2083
- };
2084
- const setElement = $Element => {
2085
- state$5.$PreviousFocusElement = $Element;
2086
- };
2087
- const getElement = () => {
2088
- return state$5.$PreviousFocusElement;
2173
+ // src/parts/VirtualDomElement/VirtualDomElement.ts
2174
+ var renderDomTextNode = element => {
2175
+ return document.createTextNode(element.text);
2089
2176
  };
2090
-
2091
- const focus$i = $Element => {
2092
- if ($Element === document.activeElement) {
2093
- return;
2094
- }
2095
- setElement(document.activeElement);
2096
- $Element.focus({
2097
- preventScroll: true
2098
- });
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;
2099
2182
  };
2100
- const focusPrevious$1 = () => {
2101
- const $Element = getElement();
2102
- if ($Element) {
2103
- // @ts-expect-error
2104
- $Element.focus();
2183
+ var render = (element, eventMap) => {
2184
+ switch (element.type) {
2185
+ case Text$2:
2186
+ return renderDomTextNode(element);
2187
+ default:
2188
+ return renderDomElement(element, eventMap);
2105
2189
  }
2106
2190
  };
2107
2191
 
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;
2117
- };
2118
-
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`;
2124
- };
2125
- const setYAndHeight = ($Element, y, height) => {
2126
- if (!$Element) {
2127
- return;
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);
2128
2204
  }
2129
- $Element.style.translate = typeof y === 'string' ? y : `0 ${y}px`;
2130
- $Element.style.height = typeof height === 'string' ? height : `${height}px`;
2131
- };
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`;
2205
+ $Parent.append(...stack);
2145
2206
  };
2146
2207
 
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`;
2208
+ // src/parts/VirtualDom/VirtualDom.ts
2209
+ var renderInto = ($Parent, dom, eventMap = {}) => {
2210
+ clearNode($Parent);
2211
+ renderInternal2($Parent, dom, eventMap);
2155
2212
  };
2156
- const setHeight = ($Element, height) => {
2157
- $Element.style.height = `${height}px`;
2213
+ var render2 = (elements, eventMap = {}) => {
2214
+ const $Root = document.createElement("div");
2215
+ renderInternal2($Root, elements, eventMap);
2216
+ return $Root;
2158
2217
  };
2159
2218
 
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
-
2171
- const handleBlur$a = () => {
2172
- send( /* EditorRename.abort */'EditorRename.abort');
2219
+ // src/parts/RememberFocus/RememberFocus.ts
2220
+ var queryInputs = $Viewlet => {
2221
+ return [...$Viewlet.querySelectorAll("input, textarea")];
2173
2222
  };
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
- };
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;
2233
+ }
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;
2189
2257
  };
2190
- const dispose$i = state => {
2191
- // TODO focus editor
2192
- remove$1(state.$RenameWidget);
2258
+
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 => {
2226
- // @ts-expect-error
2227
- return window.showSaveFilePicker(options);
2301
+ const writeImage = async blob => {
2302
+ await navigator.clipboard.write([new ClipboardItem({
2303
+ [blob.type]: blob
2304
+ })]);
2228
2305
  };
2229
-
2230
- const name$q = 'FilePicker';
2231
- const Commands$r = {
2232
- showDirectoryPicker: showDirectoryPicker,
2233
- showFilePicker: showFilePicker,
2234
- showSaveFilePicker: showSaveFilePicker
2306
+ const execCopy = async () => {
2307
+ // @ts-expect-error
2308
+ const text = getSelection().toString();
2309
+ await writeText(text);
2235
2310
  };
2236
2311
 
2237
- const FilePicker_ipc = {
2312
+ const name$x = 'ClipBoard';
2313
+ const Commands$y = {
2314
+ execCopy: execCopy,
2315
+ readText: readText,
2316
+ writeImage: writeImage,
2317
+ writeText: writeText
2318
+ };
2319
+
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
2337
+ Commands: Commands$x,
2338
+ name: name$w
2256
2339
  };
2257
2340
 
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';
2341
+ const state$7 = {
2342
+ styleSheets: Object.create(null)
2269
2343
  };
2270
-
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
- };
2344
+ const set$4 = (id, sheet) => {
2345
+ state$7.styleSheets[id] = sheet;
2291
2346
  };
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
- };
2347
+ const get$5 = id => {
2348
+ return state$7.styleSheets[id];
2313
2349
  };
2314
- const update = (state, uri) => {
2315
- state.$ImagePreviewImage.uri = uri;
2350
+
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);
2316
2361
  };
2317
- const dispose$h = state => {
2318
- remove$1(state.$ImagePreview);
2362
+
2363
+ const name$v = 'Css';
2364
+ const Commands$w = {
2365
+ addCssStyleSheet: addCssStyleSheet
2319
2366
  };
2320
2367
 
2321
- const ImagePreview$1 = {
2368
+ const Css_ipc = {
2322
2369
  __proto__: null,
2323
- create: create$G,
2324
- dispose: dispose$h,
2325
- showError,
2326
- update
2370
+ Commands: Commands$w,
2371
+ name: name$v
2327
2372
  };
2328
2373
 
2329
- const name$o = 'ImagePreview';
2330
- const Commands$p = {
2331
- create: create$G,
2332
- dispose: dispose$h,
2333
- showError: showError,
2334
- update: update
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'];
2375
+
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
+ }
2387
+ }
2388
+ info(state);
2335
2389
  };
2336
2390
 
2337
- const ImagePreview_ipc = {
2391
+ const name$u = 'Developer';
2392
+ const Commands$v = {
2393
+ showState: showState
2394
+ };
2395
+
2396
+ const Developer_ipc = {
2338
2397
  __proto__: null,
2339
- Commands: Commands$p,
2340
- name: name$o
2398
+ Commands: Commands$v,
2399
+ name: name$u
2341
2400
  };
2342
2401
 
2343
- const getOrigin = () => {
2344
- return location.origin;
2402
+ const downloadFile = (fileName, url) => {
2403
+ const a = document.createElement('a');
2404
+ a.href = url;
2405
+ a.download = fileName;
2406
+ a.click();
2345
2407
  };
2346
- const getPathName = () => {
2347
- return location.pathname;
2408
+
2409
+ const name$t = 'Download';
2410
+ const Commands$u = {
2411
+ downloadFile: downloadFile
2348
2412
  };
2349
- const getHref = () => {
2350
- return location.href;
2413
+
2414
+ const Download_ipc = {
2415
+ __proto__: null,
2416
+ Commands: Commands$u,
2417
+ name: name$t
2351
2418
  };
2352
2419
 
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);
2420
+ // based on https://github.com/microsoft/vscode/blob/5f87632829dc3ac80203e2377727935184399431/src/vs/base/browser/ui/aria/aria.ts (License MIT)
2421
+
2422
+ const state$6 = {
2423
+ $AriaAlert1: undefined,
2424
+ $AriaAlert2: undefined,
2425
+ $AriaMessages: undefined
2361
2426
  };
2362
- const hydrate = () => {
2363
- // addEventListener('popstate', handlePopState)
2427
+ const getAriaAlert1 = () => {
2428
+ return state$6.$AriaAlert1;
2364
2429
  };
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;
2373
- }
2374
- return 0;
2430
+ const getAriaAlert2 = () => {
2431
+ return state$6.$AriaAlert2;
2375
2432
  };
2376
- const getBounds = () => {
2377
- return {
2378
- windowWidth: window.innerWidth,
2379
- windowHeight: window.innerHeight,
2380
- titleBarHeight: getTitleBarHeight()
2381
- };
2433
+ const setElements = ($AriaMessages, $AriaAlert1, $AriaAlert2) => {
2434
+ state$6.$AriaMessages = $AriaMessages;
2435
+ state$6.$AriaAlert1 = $AriaAlert1;
2436
+ state$6.$AriaAlert2 = $AriaAlert2;
2382
2437
  };
2383
-
2384
- const getInitData = () => {
2385
- const initData = {
2386
- Location: {
2387
- href: getHref()
2388
- },
2389
- Layout: {
2390
- bounds: getBounds()
2391
- }
2392
- };
2393
- return initData;
2438
+ const hasElements = () => {
2439
+ return state$6.$AriaMessages;
2394
2440
  };
2395
2441
 
2396
- const name$n = 'InitData';
2397
- const Commands$o = {
2398
- getInitData: getInitData
2399
- };
2442
+ const True = 'true';
2443
+ const False = 'false';
2400
2444
 
2401
- const InitData_ipc = {
2402
- __proto__: null,
2403
- Commands: Commands$o,
2404
- name: name$n
2405
- };
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';
2406
2463
 
2407
- const name$m = 'IpcParent';
2408
- const Commands$n = {
2409
- create: create$L
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';
2471
+
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;
2410
2479
  };
2411
-
2412
- const IpcParent_ipc = {
2413
- __proto__: null,
2414
- Commands: Commands$n,
2415
- name: name$m
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;
2416
2485
  };
2417
-
2418
- const name$l = 'Layout';
2419
- const Commands$m = {
2420
- getBounds: getBounds
2486
+ const alert$1 = message => {
2487
+ if (!message) {
2488
+ return;
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();
2502
+ // @ts-expect-error
2503
+ if ($AriaAlert1.textContent === message) {
2504
+ setMessage$3($AriaAlert1, $AriaAlert2, message);
2505
+ } else {
2506
+ setMessage$3($AriaAlert2, $AriaAlert1, message);
2507
+ }
2421
2508
  };
2422
2509
 
2423
- const Layout_ipc = {
2510
+ const AriaAlert = {
2424
2511
  __proto__: null,
2425
- Commands: Commands$m,
2426
- name: name$l
2512
+ alert: alert$1
2427
2513
  };
2428
2514
 
2429
- const name$k = 'Location';
2430
- const Commands$l = {
2431
- getHref: getHref,
2432
- getPathName: getPathName,
2433
- hydrate: hydrate,
2434
- setPathName: setPathName
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
2435
2521
  };
2436
-
2437
- const Location_ipc = {
2438
- __proto__: null,
2439
- Commands: Commands$l,
2440
- name: name$k
2522
+ const create$Widgets = () => {
2523
+ const $Widgets = document.createElement('div');
2524
+ $Widgets.id = 'Widgets';
2525
+ $Widgets.className = 'Widgets';
2526
+ return $Widgets;
2441
2527
  };
2442
-
2443
- const getElementHeight = $Element => {
2444
- document.body.append($Element);
2445
- const height = $Element.offsetHeight;
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;
2532
+ }
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);
2544
+ }
2545
+ };
2546
+ const remove$1 = $Element => {
2547
+ if (!$Element) {
2548
+ // TODO $Element should always be defined
2549
+ return;
2550
+ }
2551
+ state$5.widgetSet.delete($Element);
2446
2552
  $Element.remove();
2447
- return height;
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;
2558
+ }
2448
2559
  };
2449
2560
 
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);
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
2565
+
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
+ };
2461
2582
  };
2462
2583
 
2463
- const name$j = 'MeasureTextHeight';
2464
- const Commands$k = {
2465
- measureTextHeight: measureTextHeight
2584
+ const name$s = 'EditorError';
2585
+ const Commands$t = {
2586
+ create: create$J
2466
2587
  };
2467
2588
 
2468
- const MeasureTextHeight_ipc = {
2589
+ const EditorError_ipc = {
2469
2590
  __proto__: null,
2470
- Commands: Commands$k,
2471
- name: name$j
2591
+ Commands: Commands$t,
2592
+ name: name$s
2472
2593
  };
2473
2594
 
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);
2595
+ const state$4 = {
2596
+ /**
2597
+ * @type {HTMLElement|undefined}
2598
+ */
2599
+ $PreviousFocusElement: undefined,
2600
+ currentFocus: ''
2490
2601
  };
2491
-
2492
- const name$i = 'MeasureTextBlockHeight';
2493
- const Commands$j = {
2494
- measureTextBlockHeight: measureTextBlockHeight
2602
+ const setElement = $Element => {
2603
+ state$4.$PreviousFocusElement = $Element;
2495
2604
  };
2496
-
2497
- const MeasureTextBlockHeight_ipc = {
2498
- __proto__: null,
2499
- Commands: Commands$j,
2500
- name: name$i
2605
+ const getElement = () => {
2606
+ return state$4.$PreviousFocusElement;
2501
2607
  };
2502
2608
 
2503
- const setThemeColor = color => {
2504
- const meta = document.querySelector('meta[name="theme-color"]');
2505
- if (!meta) {
2609
+ const focus$i = $Element => {
2610
+ if ($Element === document.activeElement) {
2506
2611
  return;
2507
2612
  }
2508
- // @ts-expect-error
2509
- meta.content = color;
2613
+ setElement(document.activeElement);
2614
+ $Element.focus({
2615
+ preventScroll: true
2616
+ });
2510
2617
  };
2511
-
2512
- const name$h = 'Meta';
2513
- const Commands$i = {
2514
- setThemeColor: setThemeColor
2618
+ const focusPrevious$1 = () => {
2619
+ const $Element = getElement();
2620
+ if ($Element) {
2621
+ // @ts-expect-error
2622
+ $Element.focus();
2623
+ }
2515
2624
  };
2516
2625
 
2517
- const Meta_ipc = {
2518
- __proto__: null,
2519
- Commands: Commands$i,
2520
- name: name$h
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;
2521
2635
  };
2522
2636
 
2523
- const create$Notification = message => {
2524
- const $Notification = document.createElement('div');
2525
- $Notification.className = 'Notification';
2526
- $Notification.textContent = message;
2527
- return $Notification;
2528
- };
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);
2533
- };
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
- }
2540
- }
2541
- return -1;
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`;
2542
2642
  };
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;
2643
+ const setYAndHeight = ($Element, y, height) => {
2644
+ if (!$Element) {
2645
+ return;
2550
2646
  }
2647
+ $Element.style.translate = typeof y === 'string' ? y : `0 ${y}px`;
2648
+ $Element.style.height = typeof height === 'string' ? height : `${height}px`;
2551
2649
  };
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);
2563
- }
2564
- const $Notification = document.createElement('div');
2565
- $Notification.className = 'Notification';
2566
- $Notification.append($NotificationMessage, $NotificationOptions);
2567
- $Notification.onclick = handleNotificationClick;
2568
- return $Notification;
2650
+ const setXAndWidth = ($Element, x, width) => {
2651
+ $Element.style.translate = `${x}px 0`;
2652
+ $Element.style.width = `${width}px`;
2569
2653
  };
2570
- const createWithOptions = (type, message, options) => {
2571
- const $Notification = create$NotificationWithOptions(message, options);
2572
- append$1($Notification);
2654
+ const setTop = ($Element, top) => {
2655
+ $Element.style.top = `${top}px`;
2573
2656
  };
2574
- const dispose$g = id => {
2575
- // const $Notification = state.$Notifications
2657
+ const setWidth = ($Element, width) => {
2658
+ $Element.style.width = `${width}px`;
2576
2659
  };
2577
-
2578
- const name$g = 'Notification';
2579
-
2580
- // prettier-ignore
2581
- const Commands$h = {
2582
- create: create$F,
2583
- createWithOptions: createWithOptions,
2584
- dispose: dispose$g
2660
+ const setXAndY = ($Element, x, y) => {
2661
+ $Element.style.left = `${x}px`;
2662
+ $Element.style.top = `${y}px`;
2585
2663
  };
2586
2664
 
2587
- const Notification_ipc = {
2588
- __proto__: null,
2589
- Commands: Commands$h,
2590
- name: name$g
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`;
2591
2676
  };
2592
2677
 
2593
- const Two = '2.0';
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;
2594
2688
 
2595
- const state$4 = {
2596
- canvasObjects: Object.create(null)
2689
+ const handleBlur$a = () => {
2690
+ send( /* EditorRename.abort */'EditorRename.abort');
2597
2691
  };
2598
- const get$4 = id => {
2599
- return state$4.canvasObjects[id];
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
+ };
2600
2707
  };
2601
- const set$3 = (canvasId, canvas) => {
2602
- state$4.canvasObjects[canvasId] = canvas;
2708
+ const dispose$i = state => {
2709
+ // TODO focus editor
2710
+ remove$1(state.$RenameWidget);
2603
2711
  };
2604
2712
 
2605
- const get$3 = id => {
2606
- return get$4(id);
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;
2607
2720
  };
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]);
2721
+
2722
+ const name$r = 'EditorRename';
2723
+ const Commands$s = {
2724
+ create: create$H,
2725
+ dispose: dispose$i,
2726
+ finish: finish
2617
2727
  };
2618
2728
 
2619
- const name$f = 'OffscreenCanvas';
2729
+ const EditorRename_ipc = {
2730
+ __proto__: null,
2731
+ Commands: Commands$s,
2732
+ name: name$r
2733
+ };
2620
2734
 
2621
- // prettier-ignore
2622
- const Commands$g = {
2623
- create: create$E
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);
2624
2746
  };
2625
2747
 
2626
- const OffscreenCanvas_ipc = {
2748
+ const name$q = 'FilePicker';
2749
+ const Commands$r = {
2750
+ showDirectoryPicker: showDirectoryPicker,
2751
+ showFilePicker: showFilePicker,
2752
+ showSaveFilePicker: showSaveFilePicker
2753
+ };
2754
+
2755
+ const FilePicker_ipc = {
2627
2756
  __proto__: null,
2628
- Commands: Commands$g,
2629
- name: name$f
2757
+ Commands: Commands$r,
2758
+ name: name$q
2630
2759
  };
2631
2760
 
2632
- // TODO this module should be called dom or dom utils
2761
+ const requestPermission = (handle, options) => {
2762
+ return handle.requestPermission(options);
2763
+ };
2633
2764
 
2634
- // TODO this module makes for weird code splitting chunks,
2635
- // maybe duplicate the code per file for better chunks
2765
+ const name$p = 'FileSystemHandle';
2766
+ const Commands$q = {
2767
+ requestPermission: requestPermission
2768
+ };
2636
2769
 
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
- }
2648
- }
2649
- return -1;
2770
+ const FileSystemHandle_ipc = {
2771
+ __proto__: null,
2772
+ Commands: Commands$q,
2773
+ name: name$p
2650
2774
  };
2651
2775
 
2652
- const create$BackDrop = () => {
2653
- const $BackDrop = document.createElement('div');
2654
- $BackDrop.className = 'BackDrop';
2655
- return $BackDrop;
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';
2656
2787
  };
2657
2788
 
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';
2789
+ // TODO duplicate code with below
2694
2790
 
2695
- // src/parts/ComponentUid/ComponentUid.ts
2696
- var uidSymbol$1 = Symbol("uid");
2697
- var getUidTarget$1 = $Element => {
2698
- while ($Element) {
2699
- if ($Element[uidSymbol$1]) {
2700
- return $Element;
2701
- }
2702
- $Element = $Element.parentNode;
2703
- }
2704
- return void 0;
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
+ };
2705
2809
  };
2706
- var getComponentUid = $Element => {
2707
- const $Target = getUidTarget$1($Element);
2708
- return $Target[uidSymbol$1];
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;
2709
2834
  };
2710
- var getComponentUidFromEvent = event => {
2711
- const {
2712
- target,
2713
- currentTarget
2714
- } = event;
2715
- return getComponentUid(currentTarget || target);
2835
+ const dispose$h = state => {
2836
+ remove$1(state.$ImagePreview);
2716
2837
  };
2717
2838
 
2718
- // src/parts/IpcState/IpcState.ts
2719
- var state$3 = {
2720
- ipc: void 0
2721
- };
2722
- var getIpc = () => {
2723
- return state$3.ipc;
2839
+ const ImagePreview$1 = {
2840
+ __proto__: null,
2841
+ create: create$G,
2842
+ dispose: dispose$h,
2843
+ showError,
2844
+ update
2724
2845
  };
2725
2846
 
2726
- // src/parts/ClearNode/ClearNode.ts
2727
- var clearNode = $Node => {
2728
- $Node.textContent = "";
2847
+ const name$o = 'ImagePreview';
2848
+ const Commands$p = {
2849
+ create: create$G,
2850
+ dispose: dispose$h,
2851
+ showError: showError,
2852
+ update: update
2729
2853
  };
2730
2854
 
2731
- // src/parts/ElementTags/ElementTags.ts
2732
- var Audio$2 = "audio";
2733
- var Button = "button";
2734
- var Col = "col";
2735
- var ColGroup = "colgroup";
2736
- var Del = "del";
2737
- var Div = "div";
2738
- var H1 = "h1";
2739
- var H2 = "h2";
2740
- var H3 = "h3";
2741
- var H4 = "h4";
2742
- var H5 = "h5";
2743
- var H6 = "h6";
2744
- var I = "i";
2745
- var Img = "img";
2746
- var Input = "input";
2747
- var Ins = "ins";
2748
- var Kbd = "kbd";
2749
- var Span = "span";
2750
- var Table = "table";
2751
- var TBody = "tbody";
2752
- var Td = "td";
2753
- var Th = "th";
2754
- var THead = "thead";
2755
- var Tr = "tr";
2756
- var Article = "article";
2757
- var Aside = "aside";
2758
- var Footer = "footer";
2759
- var Header = "header";
2760
- var Nav = "nav";
2761
- var Section = "section";
2762
- var Search$1 = "search";
2763
- var Dd = "dd";
2764
- var Dl = "dl";
2765
- var Figcaption = "figcaption";
2766
- var Figure = "figure";
2767
- var Hr = "hr";
2768
- var Li = "li";
2769
- var Ol = "ol";
2770
- var P = "p";
2771
- var Pre = "pre";
2772
- var A = "a";
2773
- var Br = "br";
2774
- var Cite = "cite";
2775
- var Data = "data";
2776
- var Time$1 = "time";
2777
- var Tfoot = "tfoot";
2778
- var Ul = "ul";
2779
- var Video$1 = "video";
2780
- var TextArea = "textarea";
2781
- var Select = "select";
2782
- var Option = "option";
2855
+ const ImagePreview_ipc = {
2856
+ __proto__: null,
2857
+ Commands: Commands$p,
2858
+ name: name$o
2859
+ };
2783
2860
 
2784
- // src/parts/VirtualDomElements/VirtualDomElements.ts
2785
- var Audio2 = 0;
2786
- var Button2 = 1;
2787
- var Col2 = 2;
2788
- var ColGroup2 = 3;
2789
- var Div2 = 4;
2790
- var H12 = 5;
2791
- var Input2 = 6;
2792
- var Kbd2 = 7;
2793
- var Span2 = 8;
2794
- var Table2 = 9;
2795
- var TBody2 = 10;
2796
- var Td2 = 11;
2797
- var Text$2 = 12;
2798
- var Th2 = 13;
2799
- var THead2 = 14;
2800
- var Tr2 = 15;
2801
- var I2 = 16;
2802
- var Img2 = 17;
2803
- var Ins2 = 20;
2804
- var Del2 = 21;
2805
- var H22 = 22;
2806
- var H32 = 23;
2807
- var H42 = 24;
2808
- var H52 = 25;
2809
- var H62 = 26;
2810
- var Article2 = 27;
2811
- var Aside2 = 28;
2812
- var Footer2 = 29;
2813
- var Header2 = 30;
2814
- var Nav2 = 40;
2815
- var Section2 = 41;
2816
- var Search2 = 42;
2817
- var Dd2 = 43;
2818
- var Dl2 = 44;
2819
- var Figcaption2 = 45;
2820
- var Figure2 = 46;
2821
- var Hr2 = 47;
2822
- var Li2 = 48;
2823
- var Ol2 = 49;
2824
- var P2 = 50;
2825
- var Pre2 = 51;
2826
- var A2 = 53;
2827
- var Br2 = 55;
2828
- var Cite2 = 56;
2829
- var Data2 = 57;
2830
- var Time2 = 58;
2831
- var Tfoot2 = 59;
2832
- var Ul2 = 60;
2833
- var Video2 = 61;
2834
- var TextArea2 = 62;
2835
- var Select2 = 63;
2836
- var Option2 = 64;
2861
+ const getOrigin = () => {
2862
+ return location.origin;
2863
+ };
2864
+ const getPathName = () => {
2865
+ return location.pathname;
2866
+ };
2867
+ const getHref = () => {
2868
+ return location.href;
2869
+ };
2837
2870
 
2838
- // src/parts/ElementTagMap/ElementTagMap.ts
2839
- var getElementTag = type => {
2840
- switch (type) {
2841
- case Audio2:
2842
- return Audio$2;
2843
- case H12:
2844
- return H1;
2845
- case H22:
2846
- return H2;
2847
- case H32:
2848
- return H3;
2849
- case H42:
2850
- return H4;
2851
- case H52:
2852
- return H5;
2853
- case H62:
2854
- return H6;
2855
- case Div2:
2856
- return Div;
2857
- case Kbd2:
2858
- return Kbd;
2859
- case Table2:
2860
- return Table;
2861
- case TBody2:
2862
- return TBody;
2863
- case Th2:
2864
- return Th;
2865
- case Td2:
2866
- return Td;
2867
- case THead2:
2868
- return THead;
2869
- case Tr2:
2870
- return Tr;
2871
- case Input2:
2872
- return Input;
2873
- case ColGroup2:
2874
- return ColGroup;
2875
- case Col2:
2876
- return Col;
2877
- case Button2:
2878
- return Button;
2879
- case Span2:
2880
- return Span;
2881
- case I2:
2882
- return I;
2883
- case Img2:
2884
- return Img;
2885
- case Ins2:
2886
- return Ins;
2887
- case Del2:
2888
- return Del;
2889
- case Article2:
2890
- return Article;
2891
- case Aside2:
2892
- return Aside;
2893
- case Footer2:
2894
- return Footer;
2895
- case Header2:
2896
- return Header;
2897
- case Nav2:
2898
- return Nav;
2899
- case Section2:
2900
- return Section;
2901
- case Search2:
2902
- return Search$1;
2903
- case Dd2:
2904
- return Dd;
2905
- case Dl2:
2906
- return Dl;
2907
- case Figcaption2:
2908
- return Figcaption;
2909
- case Figure2:
2910
- return Figure;
2911
- case Hr2:
2912
- return Hr;
2913
- case Li2:
2914
- return Li;
2915
- case Ol2:
2916
- return Ol;
2917
- case P2:
2918
- return P;
2919
- case Pre2:
2920
- return Pre;
2921
- case A2:
2922
- return A;
2923
- case Br2:
2924
- return Br;
2925
- case Cite2:
2926
- return Cite;
2927
- case Data2:
2928
- return Data;
2929
- case Time2:
2930
- return Time$1;
2931
- case Tfoot2:
2932
- return Tfoot;
2933
- case Ul2:
2934
- return Ul;
2935
- case Video2:
2936
- return Video$1;
2937
- case TextArea2:
2938
- return TextArea;
2939
- case Select2:
2940
- return Select;
2941
- case Option2:
2942
- return Option;
2943
- default:
2944
- throw new Error(`element tag not found ${type}`);
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;
2945
2876
  }
2877
+ // @ts-expect-error
2878
+ history.pushState(null, null, pathName);
2879
+ };
2880
+ const hydrate = () => {
2881
+ // addEventListener('popstate', handlePopState)
2946
2882
  };
2947
2883
 
2948
- // src/parts/GetEventListenerOptions/GetEventListenerOptions.ts
2949
- var getEventListenerOptions$1 = eventName => {
2950
- switch (eventName) {
2951
- case "wheel":
2952
- return {
2953
- passive: true
2954
- };
2955
- default:
2956
- return void 0;
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;
2957
2891
  }
2892
+ return 0;
2893
+ };
2894
+ const getBounds = () => {
2895
+ return {
2896
+ windowWidth: window.innerWidth,
2897
+ windowHeight: window.innerHeight,
2898
+ titleBarHeight: getTitleBarHeight()
2899
+ };
2958
2900
  };
2959
2901
 
2960
- // src/parts/NameAnonymousFunction/NameAnonymousFunction.ts
2961
- var nameAnonymousFunction$1 = (fn, name) => {
2962
- Object.defineProperty(fn, "name", {
2963
- value: name
2964
- });
2902
+ const getInitData = () => {
2903
+ const initData = {
2904
+ Location: {
2905
+ href: getHref()
2906
+ },
2907
+ Layout: {
2908
+ bounds: getBounds()
2909
+ }
2910
+ };
2911
+ return initData;
2965
2912
  };
2966
2913
 
2967
- // src/parts/GetWrappedListener/GetWrappedListener.ts
2968
- var cache$1 = /* @__PURE__ */new Map();
2969
- var getWrappedListener$1 = (listener, returnValue) => {
2970
- if (!returnValue) {
2971
- return listener;
2972
- }
2973
- if (!cache$1.has(listener)) {
2974
- const wrapped = event => {
2975
- const uid = getComponentUidFromEvent(event);
2976
- const result = listener(event);
2977
- if (result.length === 0) {
2978
- return;
2979
- }
2980
- const ipc = getIpc();
2981
- ipc.send("Viewlet.executeViewletCommand", uid, ...result);
2982
- };
2983
- nameAnonymousFunction$1(wrapped, listener.name);
2984
- cache$1.set(listener, wrapped);
2985
- }
2986
- return cache$1.get(listener);
2914
+ const name$n = 'InitData';
2915
+ const Commands$o = {
2916
+ getInitData: getInitData
2987
2917
  };
2988
2918
 
2989
- // src/parts/AttachEvent/AttachEvent.ts
2990
- var attachEvent$1 = ($Node, eventMap, key, value) => {
2991
- const listener = eventMap[value];
2992
- if (!listener) {
2993
- console.warn("listener not found", value);
2994
- return;
2995
- }
2996
- const options = getEventListenerOptions$1(eventMap);
2997
- const wrapped = getWrappedListener$1(listener, eventMap.returnValue);
2998
- $Node.addEventListener(key, wrapped, options);
2919
+ const InitData_ipc = {
2920
+ __proto__: null,
2921
+ Commands: Commands$o,
2922
+ name: name$n
2999
2923
  };
3000
2924
 
3001
- // src/parts/VirtualDomElementProp/VirtualDomElementProp.ts
3002
- var setProp = ($Element, key, value, eventMap) => {
3003
- switch (key) {
3004
- case "maskImage":
3005
- $Element.style.maskImage = `url('${value}')`;
3006
- $Element.style.webkitMaskImage = `url('${value}')`;
3007
- break;
3008
- case "paddingLeft":
3009
- case "paddingRight":
3010
- case "top":
3011
- case "left":
3012
- case "marginTop":
3013
- $Element.style[key] = typeof value === "number" ? `${value}px` : value;
3014
- break;
3015
- case "translate":
3016
- $Element.style[key] = value;
3017
- break;
3018
- case "width":
3019
- case "height":
3020
- if ($Element instanceof HTMLImageElement) {
3021
- $Element[key] = value;
3022
- } else if (typeof value === "number") {
3023
- $Element.style[key] = `${value}px`;
3024
- } else {
3025
- $Element.style[key] = value;
3026
- }
3027
- break;
3028
- case "style":
3029
- throw new Error("style property is not supported");
3030
- case "childCount":
3031
- case "type":
3032
- break;
3033
- case "ariaOwns":
3034
- if (value) {
3035
- $Element.setAttribute("aria-owns", value);
3036
- } else {
3037
- $Element.removeAttribute("aria-owns");
3038
- }
3039
- break;
3040
- case "inputType":
3041
- $Element.type = value;
3042
- break;
3043
- case "ariaLabelledBy":
3044
- $Element.setAttribute("aria-labelledby", value);
3045
- break;
3046
- case "onBlur":
3047
- case "onChange":
3048
- case "onClick":
3049
- case "onContextMenu":
3050
- case "onDblClick":
3051
- case "onFocus":
3052
- case "onFocusIn":
3053
- case "onFocusIn":
3054
- case "onFocusOut":
3055
- case "onInput":
3056
- case "onKeyDown":
3057
- case "onMouseDown":
3058
- case "onPointerDown":
3059
- case "onPointerOut":
3060
- case "onPointerOver":
3061
- case "onWheel":
3062
- const eventName = key.slice(2).toLowerCase();
3063
- if (!eventMap || !value) {
3064
- return;
3065
- }
3066
- attachEvent$1($Element, eventMap, eventName, value);
3067
- break;
3068
- default:
3069
- if (key.startsWith("data-")) {
3070
- $Element.dataset[key.slice("data-".length)] = value;
3071
- } else {
3072
- $Element[key] = value;
3073
- }
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
+ };
3009
+
3010
+ const name$i = 'MeasureTextBlockHeight';
3011
+ const Commands$j = {
3012
+ measureTextBlockHeight: measureTextBlockHeight
3013
+ };
3014
+
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;
3074
3025
  }
3026
+ // @ts-expect-error
3027
+ meta.content = color;
3075
3028
  };
3076
3029
 
3077
- // src/parts/VirtualDomElementProps/VirtualDomElementProps.ts
3078
- var setProps = ($Element, props, eventMap) => {
3079
- for (const key in props) {
3080
- setProp($Element, key, props[key], eventMap);
3081
- }
3030
+ const name$h = 'Meta';
3031
+ const Commands$i = {
3032
+ setThemeColor: setThemeColor
3082
3033
  };
3083
3034
 
3084
- // src/parts/VirtualDomElement/VirtualDomElement.ts
3085
- var renderDomTextNode = element => {
3086
- return document.createTextNode(element.text);
3035
+ const Meta_ipc = {
3036
+ __proto__: null,
3037
+ Commands: Commands$i,
3038
+ name: name$h
3087
3039
  };
3088
- var renderDomElement = (element, eventMap) => {
3089
- const tag = getElementTag(element.type);
3090
- const $Element = document.createElement(tag);
3091
- setProps($Element, element, eventMap);
3092
- return $Element;
3040
+
3041
+ const create$Notification = message => {
3042
+ const $Notification = document.createElement('div');
3043
+ $Notification.className = 'Notification';
3044
+ $Notification.textContent = message;
3045
+ return $Notification;
3093
3046
  };
3094
- var render = (element, eventMap) => {
3095
- switch (element.type) {
3096
- case Text$2:
3097
- return renderDomTextNode(element);
3098
- default:
3099
- return renderDomElement(element, eventMap);
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);
3067
+ break;
3068
+ }
3069
+ };
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);
3100
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
3101
3094
  };
3102
3095
 
3103
- // src/parts/RenderInternal/RenderInternal.ts
3104
- var renderInternal2 = ($Parent, elements, eventMap) => {
3105
- const max = elements.length - 1;
3106
- let stack = [];
3107
- for (let i = max; i >= 0; i--) {
3108
- const element = elements[i];
3109
- const $Element = render(element, eventMap);
3110
- if (element.childCount > 0) {
3111
- $Element.append(...stack.slice(0, element.childCount));
3112
- stack = stack.slice(element.childCount);
3096
+ const name$g = 'Notification';
3097
+
3098
+ // prettier-ignore
3099
+ const Commands$h = {
3100
+ create: create$F,
3101
+ createWithOptions: createWithOptions,
3102
+ dispose: dispose$g
3103
+ };
3104
+
3105
+ const Notification_ipc = {
3106
+ __proto__: null,
3107
+ Commands: Commands$h,
3108
+ name: name$g
3109
+ };
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;
3119
+ };
3120
+
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;
3113
3163
  }
3114
- stack.unshift($Element);
3115
3164
  }
3116
- $Parent.append(...stack);
3165
+ return -1;
3117
3166
  };
3118
3167
 
3119
- // src/parts/VirtualDom/VirtualDom.ts
3120
- var renderInto = ($Parent, dom, eventMap = {}) => {
3121
- clearNode($Parent);
3122
- renderInternal2($Parent, dom, eventMap);
3123
- };
3124
- var render2 = (elements, eventMap = {}) => {
3125
- const $Root = document.createElement("div");
3126
- renderInternal2($Root, elements, eventMap);
3127
- return $Root;
3168
+ const create$BackDrop = () => {
3169
+ const $BackDrop = document.createElement('div');
3170
+ $BackDrop.className = 'BackDrop';
3171
+ return $BackDrop;
3128
3172
  };
3129
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
+
3130
3211
  // TODO when pressing tab -> focus next element in tab order and close menu
3131
3212
 
3132
3213
  // TODO menu and contextmenu should have own keybinding logic
@@ -4073,30 +4154,9 @@ const Transferrable_ipc = {
4073
4154
  name: name$8
4074
4155
  };
4075
4156
 
4076
- const uidSymbol = Symbol('uid');
4077
- const set$1 = ($Element, uid) => {
4078
- $Element[uidSymbol] = uid;
4079
- };
4080
- const getUidTarget = $Element => {
4081
- while ($Element) {
4082
- if ($Element[uidSymbol]) {
4083
- return $Element;
4084
- }
4085
- $Element = $Element.parentNode;
4086
- }
4087
- return undefined;
4088
- };
4089
- const get = $Element => {
4090
- const $Target = getUidTarget($Element);
4091
- return $Target[uidSymbol];
4092
- };
4093
- const fromEvent = event => {
4094
- const {
4095
- target,
4096
- currentTarget
4097
- } = event;
4098
- return get(currentTarget || target);
4099
- };
4157
+ const set$1 = setComponentUid;
4158
+ const get = getComponentUid;
4159
+ const fromEvent = getComponentUidFromEvent;
4100
4160
 
4101
4161
  const state$1 = {
4102
4162
  identifiers: new Uint32Array()
@@ -4123,47 +4183,7 @@ const setIdentifiers = identifiers => {
4123
4183
  setIdentifiers$1(identifiers);
4124
4184
  };
4125
4185
 
4126
- const queryInputs = $Viewlet => {
4127
- return [...$Viewlet.querySelectorAll('input, textarea')];
4128
- };
4129
- const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
4130
- // TODO replace this workaround with
4131
- // virtual dom diffing
4132
- const oldLeft = $Viewlet.style.left;
4133
- const oldTop = $Viewlet.style.top;
4134
- const oldWidth = $Viewlet.style.width;
4135
- const oldHeight = $Viewlet.style.height;
4136
- // @ts-expect-error
4137
- const focused = document.activeElement.getAttribute('name');
4138
- const $$Inputs = queryInputs($Viewlet);
4139
- const inputMap = Object.create(null);
4140
- for (const $Input of $$Inputs) {
4141
- inputMap[$Input.name] = $Input.value;
4142
- }
4143
- if (uid) {
4144
- const $New = render2(dom, eventMap).firstChild;
4145
- set$1($New, uid);
4146
- $Viewlet.replaceWith($New);
4147
- $Viewlet = $New;
4148
- } else {
4149
- renderInto($Viewlet, dom, eventMap);
4150
- }
4151
- const $$NewInputs = queryInputs($Viewlet);
4152
- for (const $Input of $$NewInputs) {
4153
- $Input.value = inputMap[$Input.name] || $Input.value || '';
4154
- }
4155
- if (focused) {
4156
- const $Focused = $Viewlet.querySelector(`[name="${focused}"]`);
4157
- if ($Focused) {
4158
- $Focused.focus();
4159
- }
4160
- }
4161
- $Viewlet.style.top = oldTop;
4162
- $Viewlet.style.left = oldLeft;
4163
- $Viewlet.style.height = oldHeight;
4164
- $Viewlet.style.width = oldWidth;
4165
- return $Viewlet;
4166
- };
4186
+ const rememberFocus = rememberFocus$1;
4167
4187
 
4168
4188
  const ActivityBar = 'ActivityBar';
4169
4189
  const Audio$1 = 'Audio';
@@ -5650,7 +5670,7 @@ const create$z = async ({
5650
5670
  // TODO await promise
5651
5671
  // TODO call separate method HandleMessagePort.handleMessagePort or
5652
5672
  // HandleIncomingIpc.handleIncomingIpc
5653
- invokeAndTransfer(ipc, [port], 'initialize', 'message-port', port);
5673
+ invokeAndTransfer$1(ipc, [port], 'initialize', 'message-port', port);
5654
5674
  unhandleIpc(ipc);
5655
5675
  return undefined;
5656
5676
  };
@@ -5682,7 +5702,7 @@ const create$y = async ({
5682
5702
  }
5683
5703
  const windowIpc = IpcChildWithWindow$1.wrap(window);
5684
5704
  handleIpcOnce(windowIpc);
5685
- const webContentsIds = await invokeAndTransfer(windowIpc, [port], 'CreateMessagePort.createMessagePort', ipcId);
5705
+ const webContentsIds = await invokeAndTransfer$1(windowIpc, [port], 'CreateMessagePort.createMessagePort', ipcId);
5686
5706
  return webContentsIds;
5687
5707
  };
5688
5708
 
@@ -7330,7 +7350,7 @@ const showOverlayMessage = (state, x, y, content) => {
7330
7350
  };
7331
7351
  const hideOverlayMessage = state => {
7332
7352
  // TODO pass id of the overlay message and remove widget by id
7333
- for (const $Widget of state$6.widgetSet) {
7353
+ for (const $Widget of state$5.widgetSet) {
7334
7354
  // @ts-expect-error
7335
7355
  if ($Widget.className === 'EditorOverlayMessage') {
7336
7356
  remove$1($Widget);
@@ -7762,7 +7782,7 @@ const setDom$4 = (state, dom) => {
7762
7782
  const {
7763
7783
  $Viewlet
7764
7784
  } = state;
7765
- rememberFocus($Viewlet, dom, ViewletExplorerEvents);
7785
+ rememberFocus($Viewlet, dom, ViewletExplorerEvents, 0);
7766
7786
  };
7767
7787
 
7768
7788
  const ViewletExplorer = {
@@ -7958,7 +7978,7 @@ const attachEvents$8 = state => {
7958
7978
  $ListItems,
7959
7979
  $ScrollBar
7960
7980
  } = state;
7961
- $ExtensionHeader.addEventListener(Input$1, handleInput$6, Capture);
7981
+ $ExtensionHeader.addEventListener(Input, handleInput$6, Capture);
7962
7982
  // @ts-expect-error
7963
7983
  $ExtensionHeader.addEventListener(Click, undefined);
7964
7984
  attachEvents$c($ListItems, {
@@ -8176,7 +8196,7 @@ const setDom$3 = (state, dom) => {
8176
8196
  const {
8177
8197
  $Viewlet
8178
8198
  } = state;
8179
- rememberFocus($Viewlet, dom, ViewletFindWidgetEvents);
8199
+ rememberFocus($Viewlet, dom, ViewletFindWidgetEvents, 0);
8180
8200
  };
8181
8201
 
8182
8202
  const ViewletFindWidget = {
@@ -9037,7 +9057,11 @@ const ViewletMain = {
9037
9057
 
9038
9058
  // TODO
9039
9059
  const getUid = () => {
9040
- return get(document.getElementById('Main'));
9060
+ const $Main = document.getElementById('Main');
9061
+ if (!$Main) {
9062
+ return 0;
9063
+ }
9064
+ return get($Main);
9041
9065
  };
9042
9066
  const handleTabsWheel = event => {
9043
9067
  const uid = getUid();
@@ -9324,7 +9348,7 @@ const setActionsDom$1 = (state$1, actions, childUid) => {
9324
9348
  throw new Error(`child instance not found`);
9325
9349
  }
9326
9350
  const eventMap = instance.factory.EventMap;
9327
- rememberFocus($PanelActions, actions, eventMap);
9351
+ rememberFocus($PanelActions, actions, eventMap, 0);
9328
9352
  };
9329
9353
 
9330
9354
  const ViewletPanel = {