@lvce-editor/extension-host-worker 1.12.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,9 @@ const fn = value => {
89
89
  }
90
90
  };
91
91
 
92
- const state$9 = {
92
+ const state$a = {
93
+ /** @type{any[]} */
94
+ onDidOpenEditorListeners: [],
93
95
  /** @type{any[]} */
94
96
  onWillChangeEditorListeners: [],
95
97
  /** @type{any[]} */
@@ -99,19 +101,19 @@ const state$9 = {
99
101
  textDocuments: Object.create(null)
100
102
  };
101
103
  const setDocument = (textDocumentId, textDocument) => {
102
- state$9.textDocuments[textDocumentId] = textDocument;
104
+ state$a.textDocuments[textDocumentId] = textDocument;
103
105
  };
104
106
  const getDidOpenListeners = () => {
105
- return state$9.onDidSaveTextDocumentListeners;
107
+ return state$a.onDidSaveTextDocumentListeners;
106
108
  };
107
109
  const getWillChangeListeners = () => {
108
- return state$9.onWillChangeEditorListeners;
110
+ return state$a.onWillChangeEditorListeners;
109
111
  };
110
112
  const getDidChangeListeners = () => {
111
- return state$9.onDidChangeTextDocumentListeners;
113
+ return state$a.onDidChangeTextDocumentListeners;
112
114
  };
113
115
  const getDocument = textDocumentId => {
114
- return state$9.textDocuments[textDocumentId];
116
+ return state$a.textDocuments[textDocumentId];
115
117
  };
116
118
 
117
119
  const getOffset$1 = (textDocument, position) => {
@@ -301,7 +303,7 @@ const syncIncremental = (textDocumentId, changes) => {
301
303
  textDocument.text = before + syntheticChange.inserted + after;
302
304
  runListenersSafe(getDidChangeListeners(), textDocument, syntheticChanges);
303
305
  };
304
- const get$5 = textDocumentId => {
306
+ const get$6 = textDocumentId => {
305
307
  const textDocument = getDocument(textDocumentId);
306
308
  return textDocument;
307
309
  };
@@ -533,7 +535,7 @@ const registerMethod = ({
533
535
  }) => {
534
536
  context[`execute${name}Provider`] = async function (textDocumentId, ...params) {
535
537
  try {
536
- const textDocument = get$5(textDocumentId);
538
+ const textDocument = get$6(textDocumentId);
537
539
  if (!textDocument) {
538
540
  throw new Error(`textDocument with id ${textDocumentId} not found`);
539
541
  }
@@ -619,7 +621,9 @@ const String = 'string';
619
621
 
620
622
  const {
621
623
  registerBraceCompletionProvider,
622
- executeBraceCompletionProvider} = create$9({
624
+ executeBraceCompletionProvider,
625
+ reset: reset$9
626
+ } = create$9({
623
627
  name: 'BraceCompletion',
624
628
  resultShape: {
625
629
  type: Boolean
@@ -666,12 +670,12 @@ const executeOrganizeImports = async uid => {
666
670
  if (!organizeImportsAction) {
667
671
  return [];
668
672
  }
669
- const textDocument = get$5(uid);
673
+ const textDocument = get$6(uid);
670
674
  const edits = await organizeImportsAction.execute(textDocument);
671
675
  return edits;
672
676
  };
673
677
 
674
- const state$8 = {
678
+ const state$9 = {
675
679
  commands: Object.create(null)
676
680
  };
677
681
  const getCommandDisplay = command => {
@@ -694,10 +698,10 @@ const registerCommand = command => {
694
698
  if (!command.execute) {
695
699
  throw new Error('command is missing execute function');
696
700
  }
697
- if (command.id in state$8.commands) {
701
+ if (command.id in state$9.commands) {
698
702
  throw new Error(`command cannot be registered multiple times`);
699
703
  }
700
- state$8.commands[command.id] = command;
704
+ state$9.commands[command.id] = command;
701
705
  } catch (error) {
702
706
  const commandDisplayId = getCommandDisplay(command);
703
707
  throw new VError$1(error, `Failed to register command${commandDisplayId}`);
@@ -705,7 +709,7 @@ const registerCommand = command => {
705
709
  };
706
710
  const executeCommand = async (id, ...args) => {
707
711
  try {
708
- const command = state$8.commands[id];
712
+ const command = state$9.commands[id];
709
713
  if (!command) {
710
714
  throw new Error(`command ${id} not found`);
711
715
  }
@@ -744,14 +748,14 @@ const {
744
748
  }]
745
749
  });
746
750
 
747
- const state$7 = {
751
+ const state$8 = {
748
752
  configuration: Object.create(null)
749
753
  };
750
754
  const getConfiguration = key => {
751
- return state$7.configuration[key] ?? '';
755
+ return state$8.configuration[key] ?? '';
752
756
  };
753
757
  const setConfigurations = preferences => {
754
- state$7.configuration = preferences;
758
+ state$8.configuration = preferences;
755
759
  };
756
760
 
757
761
  const Two = '2.0';
@@ -762,17 +766,15 @@ const create$4$1 = (method, params) => {
762
766
  params
763
767
  };
764
768
  };
765
- const state$6 = {
766
- callbacks: Object.create(null)
767
- };
768
- const set$4 = (id, fn) => {
769
- state$6.callbacks[id] = fn;
769
+ const callbacks = Object.create(null);
770
+ const set$5 = (id, fn) => {
771
+ callbacks[id] = fn;
770
772
  };
771
- const get$4 = id => {
772
- return state$6.callbacks[id];
773
+ const get$5 = id => {
774
+ return callbacks[id];
773
775
  };
774
776
  const remove = id => {
775
- delete state$6.callbacks[id];
777
+ delete callbacks[id];
776
778
  };
777
779
  let id = 0;
778
780
  const create$3$1 = () => {
@@ -787,14 +789,14 @@ const registerPromise = () => {
787
789
  resolve,
788
790
  promise
789
791
  } = Promise.withResolvers();
790
- set$4(id, resolve);
792
+ set$5(id, resolve);
791
793
  return {
792
794
  id,
793
795
  promise
794
796
  };
795
797
  };
796
798
  const resolve = (id, response) => {
797
- const fn = get$4(id);
799
+ const fn = get$5(id);
798
800
  if (!fn) {
799
801
  console.log(response);
800
802
  warn(`callback ${id} may already be disposed`);
@@ -1134,41 +1136,41 @@ const handleIpc = ipc => {
1134
1136
  ipc.addEventListener('message', handleMessage);
1135
1137
  };
1136
1138
 
1137
- const state$5 = {
1139
+ const state$7 = {
1138
1140
  /**
1139
1141
  * @type {any}
1140
1142
  */
1141
1143
  ipc: undefined
1142
1144
  };
1143
- const get$3 = () => {
1144
- return state$5.ipc;
1145
+ const get$4 = () => {
1146
+ return state$7.ipc;
1145
1147
  };
1146
- const set$3 = ipc => {
1147
- state$5.ipc = ipc;
1148
+ const set$4 = ipc => {
1149
+ state$7.ipc = ipc;
1148
1150
  };
1149
1151
 
1150
1152
  const send = (method, ...params) => {
1151
- const ipc = get$3();
1153
+ const ipc = get$4();
1152
1154
  send$1(ipc, method, ...params);
1153
1155
  };
1154
1156
  const invoke = (method, ...params) => {
1155
- const ipc = get$3();
1157
+ const ipc = get$4();
1156
1158
  return invoke$1(ipc, method, ...params);
1157
1159
  };
1158
1160
  const invokeAndTransfer = (method, ...params) => {
1159
- const ipc = get$3();
1161
+ const ipc = get$4();
1160
1162
  return invokeAndTransfer$1(ipc, method, ...params);
1161
1163
  };
1162
- const listen$2 = ipc => {
1164
+ const listen$4 = ipc => {
1163
1165
  handleIpc(ipc);
1164
- set$3(ipc);
1166
+ set$4(ipc);
1165
1167
  };
1166
1168
 
1167
- const state$4 = {
1169
+ const state$6 = {
1168
1170
  debugProviderMap: Object.create(null)
1169
1171
  };
1170
1172
  const getDebugProvider = id => {
1171
- const provider = state$4.debugProviderMap[id];
1173
+ const provider = state$6.debugProviderMap[id];
1172
1174
  if (!provider) {
1173
1175
  // @ts-ignore
1174
1176
  throw new VError$1(`no debug provider "${id}" found`);
@@ -1179,7 +1181,7 @@ const registerDebugProvider = debugProvider => {
1179
1181
  if (!debugProvider.id) {
1180
1182
  throw new Error('Failed to register debug system provider: missing id');
1181
1183
  }
1182
- state$4.debugProviderMap[debugProvider.id] = debugProvider;
1184
+ state$6.debugProviderMap[debugProvider.id] = debugProvider;
1183
1185
  };
1184
1186
  const start = async (protocol, path) => {
1185
1187
  try {
@@ -1288,7 +1290,9 @@ const setPauseOnExceptions = async (protocol, value) => {
1288
1290
 
1289
1291
  const {
1290
1292
  registerDefinitionProvider,
1291
- executeDefinitionProvider} = create$9({
1293
+ executeDefinitionProvider,
1294
+ reset: reset$8
1295
+ } = create$9({
1292
1296
  name: 'Definition',
1293
1297
  resultShape: {
1294
1298
  allowUndefined: true,
@@ -1333,7 +1337,7 @@ const exec = async (command, args, options) => {
1333
1337
  };
1334
1338
 
1335
1339
  const fileSystemProviderMap = Object.create(null);
1336
- const get$2 = protocol => {
1340
+ const get$3 = protocol => {
1337
1341
  const provider = fileSystemProviderMap[protocol];
1338
1342
  if (!provider) {
1339
1343
  // @ts-ignore
@@ -1341,7 +1345,7 @@ const get$2 = protocol => {
1341
1345
  }
1342
1346
  return provider;
1343
1347
  };
1344
- const set$2 = (id, provider) => {
1348
+ const set$3 = (id, provider) => {
1345
1349
  if (!id) {
1346
1350
  throw new Error('Failed to register file system provider: missing id');
1347
1351
  }
@@ -1352,11 +1356,11 @@ const registerFileSystemProvider = fileSystemProvider => {
1352
1356
  if (!fileSystemProvider.id) {
1353
1357
  throw new Error('Failed to register file system provider: missing id');
1354
1358
  }
1355
- set$2(fileSystemProvider.id, fileSystemProvider);
1359
+ set$3(fileSystemProvider.id, fileSystemProvider);
1356
1360
  };
1357
1361
  const readDirWithFileTypes = async (protocol, path) => {
1358
1362
  try {
1359
- const provider = get$2(protocol);
1363
+ const provider = get$3(protocol);
1360
1364
  return await provider.readDirWithFileTypes(path);
1361
1365
  } catch (error) {
1362
1366
  throw new VError$1(error, 'Failed to execute file system provider');
@@ -1364,7 +1368,7 @@ const readDirWithFileTypes = async (protocol, path) => {
1364
1368
  };
1365
1369
  const readFile = async (protocol, path) => {
1366
1370
  try {
1367
- const provider = get$2(protocol);
1371
+ const provider = get$3(protocol);
1368
1372
  return await provider.readFile(path);
1369
1373
  } catch (error) {
1370
1374
  throw new VError$1(error, 'Failed to execute file system provider');
@@ -1392,7 +1396,7 @@ const readDirWithFileTypesExternal = async path => {
1392
1396
  };
1393
1397
  const writeFile = async (protocol, uri, content) => {
1394
1398
  try {
1395
- const provider = get$2(protocol);
1399
+ const provider = get$3(protocol);
1396
1400
  return await provider.writeFile(uri, content);
1397
1401
  } catch (error) {
1398
1402
  throw new VError$1(error, 'Failed to execute file system provider');
@@ -1400,7 +1404,7 @@ const writeFile = async (protocol, uri, content) => {
1400
1404
  };
1401
1405
  const getPathSeparator = protocol => {
1402
1406
  try {
1403
- const provider = get$2(protocol);
1407
+ const provider = get$3(protocol);
1404
1408
  return provider.pathSeparator;
1405
1409
  } catch (error) {
1406
1410
  throw new VError$1(error, 'Failed to execute file system provider');
@@ -1409,7 +1413,9 @@ const getPathSeparator = protocol => {
1409
1413
 
1410
1414
  const {
1411
1415
  registerFormattingProvider,
1412
- executeFormattingProvider} = create$9({
1416
+ executeFormattingProvider,
1417
+ reset: reset$7
1418
+ } = create$9({
1413
1419
  name: 'Formatting',
1414
1420
  executeKey: 'format',
1415
1421
  resultShape: {
@@ -1469,7 +1475,9 @@ const getPosition = (textDocument, offset) => {
1469
1475
 
1470
1476
  const {
1471
1477
  registerHoverProvider,
1472
- executeHoverProvider} = create$9({
1478
+ executeHoverProvider,
1479
+ reset: reset$6
1480
+ } = create$9({
1473
1481
  name: 'Hover',
1474
1482
  resultShape: {
1475
1483
  allowUndefined: true,
@@ -1480,7 +1488,9 @@ const {
1480
1488
 
1481
1489
  const {
1482
1490
  registerImplementationProvider,
1483
- executeImplementationProvider} = create$9({
1491
+ executeImplementationProvider,
1492
+ reset: reset$5
1493
+ } = create$9({
1484
1494
  name: 'Implementation',
1485
1495
  resultShape: {
1486
1496
  type: Array$1,
@@ -1592,7 +1602,9 @@ const showQuickPick = async ({
1592
1602
  const {
1593
1603
  registerReferenceProvider,
1594
1604
  executeReferenceProvider,
1595
- executefileReferenceProvider} = create$9({
1605
+ executefileReferenceProvider,
1606
+ reset: reset$4
1607
+ } = create$9({
1596
1608
  name: 'Reference',
1597
1609
  resultShape: {
1598
1610
  type: Array$1,
@@ -1617,7 +1629,9 @@ const {
1617
1629
  const {
1618
1630
  registerRenameProvider,
1619
1631
  executeRenameProvider,
1620
- executeprepareRenameProvider} = create$9({
1632
+ executeprepareRenameProvider,
1633
+ reset: reset$3
1634
+ } = create$9({
1621
1635
  name: 'Rename',
1622
1636
  resultShape: {
1623
1637
  type: Object$1,
@@ -1640,7 +1654,7 @@ const getExtensionHostSubWorkerUrl = () => {
1640
1654
  };
1641
1655
  const extensionHostSubWorkerUrl = getExtensionHostSubWorkerUrl();
1642
1656
 
1643
- const set$1 = async (url, contentSecurityPolicy) => {
1657
+ const set$2 = async (url, contentSecurityPolicy) => {
1644
1658
  const pathName = new URL(url).pathname;
1645
1659
  await invoke('ExtensionHostWorkerContentSecurityPolicy.set', pathName, contentSecurityPolicy);
1646
1660
  };
@@ -1649,7 +1663,7 @@ const rpcs$1 = Object.create(null);
1649
1663
  const add$1 = (id, rpc) => {
1650
1664
  rpcs$1[id] = rpc;
1651
1665
  };
1652
- const get$1 = id => {
1666
+ const get$2 = id => {
1653
1667
  return rpcs$1[id];
1654
1668
  };
1655
1669
 
@@ -1663,16 +1677,16 @@ const acquire = id => {
1663
1677
  delete registry[id];
1664
1678
  return fn;
1665
1679
  };
1666
- const get = id => {
1680
+ const get$1 = id => {
1667
1681
  return rpcs[id];
1668
1682
  };
1669
- const set = (id, rpc) => {
1683
+ const set$1 = (id, rpc) => {
1670
1684
  rpcs[id] = rpc;
1671
1685
  };
1672
1686
 
1673
1687
  const createRpcWithId$1 = async id => {
1674
1688
  const fn = acquire(id);
1675
- const info = get$1(id);
1689
+ const info = get$2(id);
1676
1690
  if (!info) {
1677
1691
  throw new Error(`rpc with id ${id} not found`);
1678
1692
  }
@@ -1687,16 +1701,16 @@ const createRpcWithId$1 = async id => {
1687
1701
  execute: fn
1688
1702
  });
1689
1703
  await newRpc.invoke('LoadFile.loadFile', info.url);
1690
- set(id, newRpc);
1704
+ set$1(id, newRpc);
1691
1705
  return newRpc;
1692
1706
  };
1693
1707
 
1694
1708
  const getOrCreateRpc = async id => {
1695
- const rpc = get(id);
1709
+ const rpc = get$1(id);
1696
1710
  if (!rpc) {
1697
- set(id, createRpcWithId$1(id));
1711
+ set$1(id, createRpcWithId$1(id));
1698
1712
  }
1699
- return get(id);
1713
+ return get$1(id);
1700
1714
  };
1701
1715
  const createRpcWithId = ({
1702
1716
  id,
@@ -1731,7 +1745,7 @@ const createLegacyRpc = async ({
1731
1745
  string(name);
1732
1746
  fn(execute);
1733
1747
  if (contentSecurityPolicy) {
1734
- await set$1(url, contentSecurityPolicy);
1748
+ await set$2(url, contentSecurityPolicy);
1735
1749
  }
1736
1750
  const ipc = await create$7({
1737
1751
  method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
@@ -1774,7 +1788,9 @@ const createRpc = ({
1774
1788
 
1775
1789
  const {
1776
1790
  registerSelectionProvider,
1777
- executeSelectionProvider} = create$9({
1791
+ executeSelectionProvider,
1792
+ reset: reset$2
1793
+ } = create$9({
1778
1794
  name: 'Selection',
1779
1795
  resultShape: {
1780
1796
  allowUndefined: true,
@@ -1785,17 +1801,17 @@ const {
1785
1801
  }
1786
1802
  });
1787
1803
 
1788
- const state$3 = {
1804
+ const state$5 = {
1789
1805
  providers: Object.create(null)
1790
1806
  };
1791
1807
  const registerSourceControlProvider = provider => {
1792
- state$3.providers[provider.id] = provider;
1808
+ state$5.providers[provider.id] = provider;
1793
1809
  };
1794
1810
  const getFilesFromProvider = provider => {
1795
1811
  return provider.getChangedFiles();
1796
1812
  };
1797
1813
  const getChangedFiles = async providerId => {
1798
- const provider = state$3.providers[providerId];
1814
+ const provider = state$5.providers[providerId];
1799
1815
  if (!provider) {
1800
1816
  throw new Error('no source control provider found');
1801
1817
  }
@@ -1806,7 +1822,7 @@ const getChangedFiles = async providerId => {
1806
1822
  const getFileBefore = async (providerId, uri) => {
1807
1823
  string(providerId);
1808
1824
  string(uri);
1809
- const provider = state$3.providers[providerId];
1825
+ const provider = state$5.providers[providerId];
1810
1826
  if (!provider) {
1811
1827
  throw new Error('no source control provider found');
1812
1828
  }
@@ -1828,7 +1844,7 @@ const getGroupsFromProvider = async (provider, cwd) => {
1828
1844
  throw new Error('source control provider is missing required function getGroups');
1829
1845
  };
1830
1846
  const getGroups = async (providerId, cwd) => {
1831
- const provider = state$3.providers[providerId];
1847
+ const provider = state$5.providers[providerId];
1832
1848
  if (!provider) {
1833
1849
  throw new Error('no source control provider found');
1834
1850
  }
@@ -1836,14 +1852,14 @@ const getGroups = async (providerId, cwd) => {
1836
1852
  return groups;
1837
1853
  };
1838
1854
  const acceptInput = async (providerId, value) => {
1839
- const provider = state$3.providers[providerId];
1855
+ const provider = state$5.providers[providerId];
1840
1856
  if (!provider) {
1841
1857
  throw new Error('no source control provider found');
1842
1858
  }
1843
1859
  await provider.acceptInput(value);
1844
1860
  };
1845
1861
  const add = async path => {
1846
- const provider = Object.values(state$3.providers)[0];
1862
+ const provider = Object.values(state$5.providers)[0];
1847
1863
  if (!provider) {
1848
1864
  return;
1849
1865
  }
@@ -1851,7 +1867,7 @@ const add = async path => {
1851
1867
  await provider.add(path);
1852
1868
  };
1853
1869
  const discard = async path => {
1854
- const provider = Object.values(state$3.providers)[0];
1870
+ const provider = Object.values(state$5.providers)[0];
1855
1871
  if (!provider) {
1856
1872
  return;
1857
1873
  }
@@ -1861,7 +1877,7 @@ const discard = async path => {
1861
1877
  const getEnabledProviderIds = async (scheme, root) => {
1862
1878
  string(scheme);
1863
1879
  string(root);
1864
- const providers = Object.values(state$3.providers);
1880
+ const providers = Object.values(state$5.providers);
1865
1881
  const enabledIds = [];
1866
1882
  for (const provider of providers) {
1867
1883
  // @ts-ignore
@@ -1880,7 +1896,9 @@ const getEnabledProviderIds = async (scheme, root) => {
1880
1896
 
1881
1897
  const {
1882
1898
  registerTabCompletionProvider,
1883
- executeTabCompletionProvider} = create$9({
1899
+ executeTabCompletionProvider,
1900
+ reset: reset$1
1901
+ } = create$9({
1884
1902
  name: 'TabCompletion',
1885
1903
  resultShape: {
1886
1904
  type: Object$1,
@@ -1888,7 +1906,7 @@ const {
1888
1906
  }
1889
1907
  });
1890
1908
 
1891
- const state$2 = {
1909
+ const state$4 = {
1892
1910
  textSearchProviders: Object.create(null)
1893
1911
  };
1894
1912
  const registerTextSearchProvider = textSearchProvider => {
@@ -1899,14 +1917,14 @@ const registerTextSearchProvider = textSearchProvider => {
1899
1917
  if (!textSearchProvider.scheme) {
1900
1918
  throw new Error('textSearchProvider is missing scheme');
1901
1919
  }
1902
- state$2.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
1920
+ state$4.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
1903
1921
  } catch (error) {
1904
1922
  throw new VError$1(error, 'Failed to register text search provider');
1905
1923
  }
1906
1924
  };
1907
1925
  const executeTextSearchProvider = async (scheme, query) => {
1908
1926
  try {
1909
- const textSearchProvider = state$2.textSearchProviders[scheme];
1927
+ const textSearchProvider = state$4.textSearchProviders[scheme];
1910
1928
  if (!textSearchProvider) {
1911
1929
  throw new Error(`No text search provider for ${scheme} found`);
1912
1930
  }
@@ -1919,7 +1937,9 @@ const executeTextSearchProvider = async (scheme, query) => {
1919
1937
 
1920
1938
  const {
1921
1939
  registerTypeDefinitionProvider,
1922
- executeTypeDefinitionProvider} = create$9({
1940
+ executeTypeDefinitionProvider,
1941
+ reset
1942
+ } = create$9({
1923
1943
  name: 'TypeDefinition',
1924
1944
  resultShape: {
1925
1945
  allowUndefined: true,
@@ -2161,14 +2181,14 @@ const createWorker = async ({
2161
2181
  return ipc;
2162
2182
  };
2163
2183
 
2164
- const state$1 = {
2184
+ const state$3 = {
2165
2185
  workspacePath: ''
2166
2186
  };
2167
2187
  const setWorkspacePath = path => {
2168
- state$1.workspacePath = path;
2188
+ state$3.workspacePath = path;
2169
2189
  };
2170
2190
  const getWorkspaceFolder = path => {
2171
- return state$1.workspacePath;
2191
+ return state$3.workspacePath;
2172
2192
  };
2173
2193
 
2174
2194
  class FormattingError extends Error {
@@ -2398,7 +2418,7 @@ class ContentSecurityPolicyError extends Error {
2398
2418
  }
2399
2419
  }
2400
2420
 
2401
- const state = {
2421
+ const state$2 = {
2402
2422
  /**
2403
2423
  * @type {any[]}
2404
2424
  */
@@ -2406,13 +2426,13 @@ const state = {
2406
2426
  };
2407
2427
  const addError = error => {
2408
2428
  // @ts-ignore
2409
- state.errors.push(error);
2429
+ state$2.errors.push(error);
2410
2430
  };
2411
2431
  const hasRecentErrors = () => {
2412
- return state.errors.length > 0;
2432
+ return state$2.errors.length > 0;
2413
2433
  };
2414
2434
  const getRecentError = () => {
2415
- return state.errors.at(-1);
2435
+ return state$2.errors.at(-1);
2416
2436
  };
2417
2437
 
2418
2438
  const isImportErrorChrome = error => {
@@ -2838,7 +2858,7 @@ const mockRpc = () => {
2838
2858
  };
2839
2859
 
2840
2860
  const getStatusBarItems = async () => {
2841
- const providers = Object.values(state$3.providers);
2861
+ const providers = Object.values(state$5.providers);
2842
2862
  const statusBarItems = [];
2843
2863
  for (const provider of providers) {
2844
2864
  // @ts-ignore
@@ -2872,6 +2892,27 @@ const Auto = () => {
2872
2892
  const getData$1 = event => {
2873
2893
  return event.data;
2874
2894
  };
2895
+ const attachEvents = that => {
2896
+ const handleMessage = (...args) => {
2897
+ const data = that.getData(...args);
2898
+ that.dispatchEvent(new MessageEvent('message', {
2899
+ data
2900
+ }));
2901
+ };
2902
+ that.onMessage(handleMessage);
2903
+ const handleClose = event => {
2904
+ that.dispatchEvent(new Event('close'));
2905
+ };
2906
+ that.onClose(handleClose);
2907
+ };
2908
+ class Ipc extends EventTarget {
2909
+ constructor(rawIpc) {
2910
+ super();
2911
+ this._rawIpc = rawIpc;
2912
+ attachEvents(this);
2913
+ }
2914
+ }
2915
+ const readyMessage = 'ready';
2875
2916
  const walkValue = (value, transferrables, isTransferrable) => {
2876
2917
  if (!value) {
2877
2918
  return;
@@ -2922,35 +2963,56 @@ const getTransferrables = value => {
2922
2963
  walkValue(value, transferrables, isTransferrable);
2923
2964
  return transferrables;
2924
2965
  };
2925
- const attachEvents = that => {
2926
- const handleMessage = (...args) => {
2927
- const data = that.getData(...args);
2928
- that.dispatchEvent(new MessageEvent('message', {
2929
- data
2930
- }));
2931
- };
2932
- that.onMessage(handleMessage);
2933
- const handleClose = event => {
2934
- that.dispatchEvent(new Event('close'));
2935
- };
2936
- that.onClose(handleClose);
2966
+ const listen$3 = ({
2967
+ port
2968
+ }) => {
2969
+ return port;
2937
2970
  };
2938
- class Ipc extends EventTarget {
2939
- constructor(rawIpc) {
2940
- super();
2941
- this._rawIpc = rawIpc;
2942
- attachEvents(this);
2971
+ const signal$3 = port => {
2972
+ port.postMessage(readyMessage);
2973
+ };
2974
+ class IpcChildWithMessagePort extends Ipc {
2975
+ constructor(port) {
2976
+ super(port);
2977
+ }
2978
+ getData(event) {
2979
+ return getData$1(event);
2980
+ }
2981
+ send(message) {
2982
+ this._rawIpc.postMessage(message);
2983
+ }
2984
+ sendAndTransfer(message) {
2985
+ const transfer = getTransferrables(message);
2986
+ this._rawIpc.postMessage(message, transfer);
2987
+ }
2988
+ dispose() {
2989
+ // ignore
2990
+ }
2991
+ onClose(callback) {
2992
+ // ignore
2993
+ }
2994
+ onMessage(callback) {
2995
+ this._rawIpc.addEventListener('message', callback);
2996
+ this._rawIpc.start();
2943
2997
  }
2944
2998
  }
2945
- const readyMessage = 'ready';
2946
- const listen$4 = () => {
2999
+ const wrap$6 = port => {
3000
+ return new IpcChildWithMessagePort(port);
3001
+ };
3002
+ const IpcChildWithMessagePort$1 = {
3003
+ __proto__: null,
3004
+ listen: listen$3,
3005
+ signal: signal$3,
3006
+ wrap: wrap$6
3007
+ };
3008
+ const listen$2 = () => {
2947
3009
  // @ts-ignore
2948
3010
  if (typeof WorkerGlobalScope === 'undefined') {
2949
3011
  throw new TypeError('module is not in web worker scope');
2950
3012
  }
2951
3013
  return globalThis;
2952
3014
  };
2953
- const signal$3 = global => {
3015
+ const signal$2 = global => {
2954
3016
  global.postMessage(readyMessage);
2955
3017
  };
2956
3018
  class IpcChildWithModuleWorker extends Ipc {
@@ -2976,14 +3038,14 @@ class IpcChildWithModuleWorker extends Ipc {
2976
3038
  this._rawIpc.addEventListener('message', callback);
2977
3039
  }
2978
3040
  }
2979
- const wrap$6 = global => {
3041
+ const wrap$5 = global => {
2980
3042
  return new IpcChildWithModuleWorker(global);
2981
3043
  };
2982
3044
  const IpcChildWithModuleWorker$1 = {
2983
3045
  __proto__: null,
2984
- listen: listen$4,
2985
- signal: signal$3,
2986
- wrap: wrap$6
3046
+ listen: listen$2,
3047
+ signal: signal$2,
3048
+ wrap: wrap$5
2987
3049
  };
2988
3050
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
2989
3051
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
@@ -3100,10 +3162,10 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
3100
3162
  };
3101
3163
  const normalizeLine = line => {
3102
3164
  if (line.startsWith('Error: ')) {
3103
- return line.slice(`Error: `.length);
3165
+ return line.slice('Error: '.length);
3104
3166
  }
3105
3167
  if (line.startsWith('VError: ')) {
3106
- return line.slice(`VError: `.length);
3168
+ return line.slice('VError: '.length);
3107
3169
  }
3108
3170
  return line;
3109
3171
  };
@@ -3201,10 +3263,10 @@ const waitForFirstMessage = async port => {
3201
3263
  // @ts-ignore
3202
3264
  return event.data;
3203
3265
  };
3204
- const listen$3 = async () => {
3205
- const parentIpcRaw = listen$4();
3206
- signal$3(parentIpcRaw);
3207
- const parentIpc = wrap$6(parentIpcRaw);
3266
+ const listen$1 = async () => {
3267
+ const parentIpcRaw = listen$2();
3268
+ signal$2(parentIpcRaw);
3269
+ const parentIpc = wrap$5(parentIpcRaw);
3208
3270
  const firstMessage = await waitForFirstMessage(parentIpc);
3209
3271
  if (firstMessage.method !== 'initialize') {
3210
3272
  throw new IpcError$1('unexpected first message');
@@ -3249,55 +3311,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
3249
3311
  this._rawIpc.start();
3250
3312
  }
3251
3313
  }
3252
- const wrap$5 = port => {
3314
+ const wrap$4$1 = port => {
3253
3315
  return new IpcChildWithModuleWorkerAndMessagePort(port);
3254
3316
  };
3255
3317
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
3256
- __proto__: null,
3257
- listen: listen$3,
3258
- wrap: wrap$5
3259
- };
3260
- const listen$1 = ({
3261
- port
3262
- }) => {
3263
- return port;
3264
- };
3265
- const signal = port => {
3266
- port.postMessage(readyMessage);
3267
- };
3268
- class IpcChildWithMessagePort extends Ipc {
3269
- constructor(port) {
3270
- super(port);
3271
- }
3272
- getData(event) {
3273
- return getData$1(event);
3274
- }
3275
- send(message) {
3276
- this._rawIpc.postMessage(message);
3277
- }
3278
- sendAndTransfer(message) {
3279
- const transfer = getTransferrables(message);
3280
- this._rawIpc.postMessage(message, transfer);
3281
- }
3282
- dispose() {
3283
- // ignore
3284
- }
3285
- onClose(callback) {
3286
- // ignore
3287
- }
3288
- onMessage(callback) {
3289
- this._rawIpc.addEventListener('message', callback);
3290
- this._rawIpc.start();
3291
- }
3292
- }
3293
- const wrap$2$1 = port => {
3294
- return new IpcChildWithMessagePort(port);
3295
- };
3296
- const IpcChildWithMessagePort$1 = {
3297
3318
  __proto__: null,
3298
3319
  listen: listen$1,
3299
- signal,
3300
- wrap: wrap$2$1
3320
+ wrap: wrap$4$1
3301
3321
  };
3302
3322
 
3303
3323
  const getModule$1 = method => {
@@ -3320,6 +3340,395 @@ const handleMessagePort = port => {
3320
3340
  ipc.send('ready');
3321
3341
  };
3322
3342
 
3343
+ const instanceOfAny = (object, constructors) => constructors.some(c => object instanceof c);
3344
+ let idbProxyableTypes;
3345
+ let cursorAdvanceMethods;
3346
+ // This is a function to prevent it throwing up in node environments.
3347
+ function getIdbProxyableTypes() {
3348
+ return idbProxyableTypes || (idbProxyableTypes = [IDBDatabase, IDBObjectStore, IDBIndex, IDBCursor, IDBTransaction]);
3349
+ }
3350
+ // This is a function to prevent it throwing up in node environments.
3351
+ function getCursorAdvanceMethods() {
3352
+ return cursorAdvanceMethods || (cursorAdvanceMethods = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey]);
3353
+ }
3354
+ const transactionDoneMap = new WeakMap();
3355
+ const transformCache = new WeakMap();
3356
+ const reverseTransformCache = new WeakMap();
3357
+ function promisifyRequest(request) {
3358
+ const promise = new Promise((resolve, reject) => {
3359
+ const unlisten = () => {
3360
+ request.removeEventListener('success', success);
3361
+ request.removeEventListener('error', error);
3362
+ };
3363
+ const success = () => {
3364
+ resolve(wrap$4(request.result));
3365
+ unlisten();
3366
+ };
3367
+ const error = () => {
3368
+ reject(request.error);
3369
+ unlisten();
3370
+ };
3371
+ request.addEventListener('success', success);
3372
+ request.addEventListener('error', error);
3373
+ });
3374
+ // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
3375
+ // is because we create many promises from a single IDBRequest.
3376
+ reverseTransformCache.set(promise, request);
3377
+ return promise;
3378
+ }
3379
+ function cacheDonePromiseForTransaction(tx) {
3380
+ // Early bail if we've already created a done promise for this transaction.
3381
+ if (transactionDoneMap.has(tx)) return;
3382
+ const done = new Promise((resolve, reject) => {
3383
+ const unlisten = () => {
3384
+ tx.removeEventListener('complete', complete);
3385
+ tx.removeEventListener('error', error);
3386
+ tx.removeEventListener('abort', error);
3387
+ };
3388
+ const complete = () => {
3389
+ resolve();
3390
+ unlisten();
3391
+ };
3392
+ const error = () => {
3393
+ reject(tx.error || new DOMException('AbortError', 'AbortError'));
3394
+ unlisten();
3395
+ };
3396
+ tx.addEventListener('complete', complete);
3397
+ tx.addEventListener('error', error);
3398
+ tx.addEventListener('abort', error);
3399
+ });
3400
+ // Cache it for later retrieval.
3401
+ transactionDoneMap.set(tx, done);
3402
+ }
3403
+ let idbProxyTraps = {
3404
+ get(target, prop, receiver) {
3405
+ if (target instanceof IDBTransaction) {
3406
+ // Special handling for transaction.done.
3407
+ if (prop === 'done') return transactionDoneMap.get(target);
3408
+ // Make tx.store return the only store in the transaction, or undefined if there are many.
3409
+ if (prop === 'store') {
3410
+ return receiver.objectStoreNames[1] ? undefined : receiver.objectStore(receiver.objectStoreNames[0]);
3411
+ }
3412
+ }
3413
+ // Else transform whatever we get back.
3414
+ return wrap$4(target[prop]);
3415
+ },
3416
+ set(target, prop, value) {
3417
+ target[prop] = value;
3418
+ return true;
3419
+ },
3420
+ has(target, prop) {
3421
+ if (target instanceof IDBTransaction && (prop === 'done' || prop === 'store')) {
3422
+ return true;
3423
+ }
3424
+ return prop in target;
3425
+ }
3426
+ };
3427
+ function replaceTraps(callback) {
3428
+ idbProxyTraps = callback(idbProxyTraps);
3429
+ }
3430
+ function wrapFunction(func) {
3431
+ // Due to expected object equality (which is enforced by the caching in `wrap`), we
3432
+ // only create one new func per func.
3433
+ // Cursor methods are special, as the behaviour is a little more different to standard IDB. In
3434
+ // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
3435
+ // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
3436
+ // with real promises, so each advance methods returns a new promise for the cursor object, or
3437
+ // undefined if the end of the cursor has been reached.
3438
+ if (getCursorAdvanceMethods().includes(func)) {
3439
+ return function (...args) {
3440
+ // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
3441
+ // the original object.
3442
+ func.apply(unwrap(this), args);
3443
+ return wrap$4(this.request);
3444
+ };
3445
+ }
3446
+ return function (...args) {
3447
+ // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
3448
+ // the original object.
3449
+ return wrap$4(func.apply(unwrap(this), args));
3450
+ };
3451
+ }
3452
+ function transformCachableValue(value) {
3453
+ if (typeof value === 'function') return wrapFunction(value);
3454
+ // This doesn't return, it just creates a 'done' promise for the transaction,
3455
+ // which is later returned for transaction.done (see idbObjectHandler).
3456
+ if (value instanceof IDBTransaction) cacheDonePromiseForTransaction(value);
3457
+ if (instanceOfAny(value, getIdbProxyableTypes())) return new Proxy(value, idbProxyTraps);
3458
+ // Return the same value back if we're not going to transform it.
3459
+ return value;
3460
+ }
3461
+ function wrap$4(value) {
3462
+ // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
3463
+ // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
3464
+ if (value instanceof IDBRequest) return promisifyRequest(value);
3465
+ // If we've already transformed this value before, reuse the transformed value.
3466
+ // This is faster, but it also provides object equality.
3467
+ if (transformCache.has(value)) return transformCache.get(value);
3468
+ const newValue = transformCachableValue(value);
3469
+ // Not all types are transformed.
3470
+ // These may be primitive types, so they can't be WeakMap keys.
3471
+ if (newValue !== value) {
3472
+ transformCache.set(value, newValue);
3473
+ reverseTransformCache.set(newValue, value);
3474
+ }
3475
+ return newValue;
3476
+ }
3477
+ const unwrap = value => reverseTransformCache.get(value);
3478
+
3479
+ /**
3480
+ * Open a database.
3481
+ *
3482
+ * @param name Name of the database.
3483
+ * @param version Schema version.
3484
+ * @param callbacks Additional callbacks.
3485
+ */
3486
+ function openDB(name, version, {
3487
+ blocked,
3488
+ upgrade,
3489
+ blocking,
3490
+ terminated
3491
+ } = {}) {
3492
+ const request = indexedDB.open(name, version);
3493
+ const openPromise = wrap$4(request);
3494
+ if (upgrade) {
3495
+ request.addEventListener('upgradeneeded', event => {
3496
+ upgrade(wrap$4(request.result), event.oldVersion, event.newVersion, wrap$4(request.transaction), event);
3497
+ });
3498
+ }
3499
+ if (blocked) {
3500
+ request.addEventListener('blocked', event => blocked(
3501
+ // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
3502
+ event.oldVersion, event.newVersion, event));
3503
+ }
3504
+ openPromise.then(db => {
3505
+ if (terminated) db.addEventListener('close', () => terminated());
3506
+ if (blocking) {
3507
+ db.addEventListener('versionchange', event => blocking(event.oldVersion, event.newVersion, event));
3508
+ }
3509
+ }).catch(() => {});
3510
+ return openPromise;
3511
+ }
3512
+ const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
3513
+ const writeMethods = ['put', 'add', 'delete', 'clear'];
3514
+ const cachedMethods = new Map();
3515
+ function getMethod(target, prop) {
3516
+ if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === 'string')) {
3517
+ return;
3518
+ }
3519
+ if (cachedMethods.get(prop)) return cachedMethods.get(prop);
3520
+ const targetFuncName = prop.replace(/FromIndex$/, '');
3521
+ const useIndex = prop !== targetFuncName;
3522
+ const isWrite = writeMethods.includes(targetFuncName);
3523
+ if (
3524
+ // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
3525
+ !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || readMethods.includes(targetFuncName))) {
3526
+ return;
3527
+ }
3528
+ const method = async function (storeName, ...args) {
3529
+ // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
3530
+ const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
3531
+ let target = tx.store;
3532
+ if (useIndex) target = target.index(args.shift());
3533
+ // Must reject if op rejects.
3534
+ // If it's a write operation, must reject if tx.done rejects.
3535
+ // Must reject with op rejection first.
3536
+ // Must resolve with op value.
3537
+ // Must handle both promises (no unhandled rejections)
3538
+ return (await Promise.all([target[targetFuncName](...args), isWrite && tx.done]))[0];
3539
+ };
3540
+ cachedMethods.set(prop, method);
3541
+ return method;
3542
+ }
3543
+ replaceTraps(oldTraps => ({
3544
+ ...oldTraps,
3545
+ get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
3546
+ has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop)
3547
+ }));
3548
+ const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];
3549
+ const methodMap = {};
3550
+ const advanceResults = new WeakMap();
3551
+ const ittrProxiedCursorToOriginalProxy = new WeakMap();
3552
+ const cursorIteratorTraps = {
3553
+ get(target, prop) {
3554
+ if (!advanceMethodProps.includes(prop)) return target[prop];
3555
+ let cachedFunc = methodMap[prop];
3556
+ if (!cachedFunc) {
3557
+ cachedFunc = methodMap[prop] = function (...args) {
3558
+ advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));
3559
+ };
3560
+ }
3561
+ return cachedFunc;
3562
+ }
3563
+ };
3564
+ async function* iterate(...args) {
3565
+ // tslint:disable-next-line:no-this-assignment
3566
+ let cursor = this;
3567
+ if (!(cursor instanceof IDBCursor)) {
3568
+ cursor = await cursor.openCursor(...args);
3569
+ }
3570
+ if (!cursor) return;
3571
+ cursor = cursor;
3572
+ const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);
3573
+ ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);
3574
+ // Map this double-proxy back to the original, so other cursor methods work.
3575
+ reverseTransformCache.set(proxiedCursor, unwrap(cursor));
3576
+ while (cursor) {
3577
+ yield proxiedCursor;
3578
+ // If one of the advancing methods was not called, call continue().
3579
+ cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());
3580
+ advanceResults.delete(proxiedCursor);
3581
+ }
3582
+ }
3583
+ function isIteratorProp(target, prop) {
3584
+ return prop === Symbol.asyncIterator && instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor]) || prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore]);
3585
+ }
3586
+ replaceTraps(oldTraps => ({
3587
+ ...oldTraps,
3588
+ get(target, prop, receiver) {
3589
+ if (isIteratorProp(target, prop)) return iterate;
3590
+ return oldTraps.get(target, prop, receiver);
3591
+ },
3592
+ has(target, prop) {
3593
+ return isIteratorProp(target, prop) || oldTraps.has(target, prop);
3594
+ }
3595
+ }));
3596
+
3597
+ const state$1 = {
3598
+ databases: Object.create(null),
3599
+ eventId: 0,
3600
+ dbVersion: 1,
3601
+ /**
3602
+ * @type {any}
3603
+ */
3604
+ cachedDb: undefined
3605
+ };
3606
+
3607
+ const isDataCloneError = error => {
3608
+ return error && error.name === 'DataCloneError';
3609
+ };
3610
+
3611
+ // TODO high memory usage in idb because of transactionDoneMap
3612
+
3613
+ const getDb$1 = async () => {
3614
+ // @ts-ignore
3615
+ const db = await openDB('session', state$1.dbVersion, {
3616
+ async upgrade(db, oldVersion) {
3617
+ if (!db.objectStoreNames.contains('session')) {
3618
+ const objectStore = await db.createObjectStore('session', {
3619
+ autoIncrement: true
3620
+ });
3621
+ objectStore.createIndex('sessionId', 'sessionId', {
3622
+ unique: false
3623
+ });
3624
+ }
3625
+ }
3626
+ });
3627
+ return db;
3628
+ };
3629
+ const getDbMemoized$1 = async () => {
3630
+ state$1.cachedDb ||= await getDb$1();
3631
+ return state$1.cachedDb;
3632
+ };
3633
+ const saveValue = async (storeId, value) => {
3634
+ try {
3635
+ const db = await getDbMemoized$1();
3636
+ await db.add('session', value);
3637
+ } catch (error) {
3638
+ if (isDataCloneError(error)) {
3639
+ // TODO
3640
+ return;
3641
+ }
3642
+ throw new VError$1(error, 'Failed to save value to indexed db');
3643
+ }
3644
+ };
3645
+ const getValues = async storeId => {
3646
+ try {
3647
+ const db = await getDbMemoized$1();
3648
+ const tx = db.transaction(storeId, 'readwrite');
3649
+ const [objects] = await Promise.all([tx.store.getAll(), tx.done]);
3650
+ console.log({
3651
+ objects
3652
+ });
3653
+ return objects;
3654
+ } catch (error) {
3655
+ throw new VError$1(error, 'Failed to get values from indexed db');
3656
+ }
3657
+ };
3658
+ const getValuesByIndexName = async (storeId, indexName, only) => {
3659
+ const db = await getDbMemoized$1();
3660
+ const transaction = db.transaction(storeId);
3661
+ const index = transaction.store.index(indexName);
3662
+ const iterator = index.iterate(only);
3663
+ const objects = [];
3664
+ for await (const cursor of iterator) {
3665
+ objects.push(cursor.value);
3666
+ }
3667
+ return objects;
3668
+ };
3669
+ const getHandleDb = async () => {
3670
+ const db = await openDB('handle', state$1.dbVersion, {
3671
+ async upgrade(db, oldVersion) {
3672
+ if (!db.objectStoreNames.contains('file-handles-store')) {
3673
+ // @ts-ignore
3674
+ await db.createObjectStore('file-handles-store', {});
3675
+ }
3676
+ }
3677
+ });
3678
+ return db;
3679
+ };
3680
+ const addHandle = async (uri, handle) => {
3681
+ const handleDb = await getHandleDb();
3682
+ await handleDb.put('file-handles-store', handle, uri);
3683
+ };
3684
+ const getHandle = async uri => {
3685
+ const handleDb = await getHandleDb();
3686
+ const handle = await handleDb.get('file-handles-store', uri);
3687
+ return handle;
3688
+ };
3689
+
3690
+ // TODO high memory usage in idb because of transactionDoneMap
3691
+
3692
+ const state = {
3693
+ databases: Object.create(null),
3694
+ dbVersion: 2,
3695
+ cachedDb: undefined
3696
+ };
3697
+ const storeId = 'lvce-keyvalue';
3698
+ const getDb = async () => {
3699
+ const db = await openDB(storeId, state.dbVersion, {
3700
+ async upgrade(db, oldVersion) {
3701
+ if (!db.objectStoreNames.contains(storeId)) {
3702
+ await db.createObjectStore(storeId, {
3703
+ autoIncrement: true
3704
+ });
3705
+ }
3706
+ }
3707
+ });
3708
+ return db;
3709
+ };
3710
+ const getDbMemoized = async () => {
3711
+ state.cachedDb ||= await getDb();
3712
+ return state.cachedDb;
3713
+ };
3714
+ const set = async (key, value) => {
3715
+ try {
3716
+ const db = await getDbMemoized();
3717
+ await db.put(storeId, value, key);
3718
+ } catch (error) {
3719
+ throw new VError$1(error, 'Failed to save value to indexed db');
3720
+ }
3721
+ };
3722
+ const get = async key => {
3723
+ try {
3724
+ const db = await getDbMemoized();
3725
+ const value = db.get(storeId, key);
3726
+ return value;
3727
+ } catch (error) {
3728
+ throw new VError$1(error, 'Failed to get value from indexed db');
3729
+ }
3730
+ };
3731
+
3323
3732
  const serializeWebView = async webView => {
3324
3733
  if (webView && webView.provider && webView.provider.saveState) {
3325
3734
  const saved = await webView.provider.saveState();
@@ -3350,8 +3759,15 @@ const saveState = async () => {
3350
3759
  };
3351
3760
 
3352
3761
  const commandMap = {
3353
- 'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
3354
3762
  'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
3763
+ 'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
3764
+ 'IndexedDb.addHandle': addHandle,
3765
+ 'IndexedDb.get': get,
3766
+ 'IndexedDb.getHandle': getHandle,
3767
+ 'IndexedDb.getValues': getValues,
3768
+ 'IndexedDb.getValuesByIndexName': getValuesByIndexName,
3769
+ 'IndexedDb.saveValue': saveValue,
3770
+ 'IndexedDb.set': set,
3355
3771
  ['ExtensionHostDebug.evaluate']: evaluate,
3356
3772
  ['ExtensionHostDebug.getProperties']: getProperties,
3357
3773
  ['ExtensionHostDebug.listProcesses']: listProcesses,
@@ -3484,7 +3900,7 @@ const main = async () => {
3484
3900
  const ipc = await listen({
3485
3901
  method: Auto()
3486
3902
  });
3487
- listen$2(ipc);
3903
+ listen$4(ipc);
3488
3904
  };
3489
3905
 
3490
3906
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-worker",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Webworker for the extension host functionality in Lvce Editor.",
5
5
  "main": "dist/extensionHostWorkerMain.js",
6
6
  "type": "module",