@lvce-editor/extension-host-worker 3.14.0 → 3.16.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.
- package/dist/extensionHostWorkerMain.js +1105 -622
- package/package.json +1 -1
|
@@ -89,7 +89,7 @@ const fn = value => {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
const state$
|
|
92
|
+
const state$e = {
|
|
93
93
|
/** @type{any[]} */
|
|
94
94
|
onDidOpenEditorListeners: [],
|
|
95
95
|
/** @type{any[]} */
|
|
@@ -101,19 +101,19 @@ const state$c = {
|
|
|
101
101
|
textDocuments: Object.create(null)
|
|
102
102
|
};
|
|
103
103
|
const setDocument = (textDocumentId, textDocument) => {
|
|
104
|
-
state$
|
|
104
|
+
state$e.textDocuments[textDocumentId] = textDocument;
|
|
105
105
|
};
|
|
106
106
|
const getDidOpenListeners = () => {
|
|
107
|
-
return state$
|
|
107
|
+
return state$e.onDidSaveTextDocumentListeners;
|
|
108
108
|
};
|
|
109
109
|
const getWillChangeListeners = () => {
|
|
110
|
-
return state$
|
|
110
|
+
return state$e.onWillChangeEditorListeners;
|
|
111
111
|
};
|
|
112
112
|
const getDidChangeListeners = () => {
|
|
113
|
-
return state$
|
|
113
|
+
return state$e.onDidChangeTextDocumentListeners;
|
|
114
114
|
};
|
|
115
115
|
const getDocument = textDocumentId => {
|
|
116
|
-
return state$
|
|
116
|
+
return state$e.textDocuments[textDocumentId];
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
const getOffset$1 = (textDocument, position) => {
|
|
@@ -303,11 +303,11 @@ const syncIncremental = (textDocumentId, changes) => {
|
|
|
303
303
|
textDocument.text = before + syntheticChange.inserted + after;
|
|
304
304
|
runListenersSafe(getDidChangeListeners(), textDocument, syntheticChanges);
|
|
305
305
|
};
|
|
306
|
-
const get$
|
|
306
|
+
const get$a = textDocumentId => {
|
|
307
307
|
const textDocument = getDocument(textDocumentId);
|
|
308
308
|
return textDocument;
|
|
309
309
|
};
|
|
310
|
-
const getText$
|
|
310
|
+
const getText$2 = textDocument => {
|
|
311
311
|
return textDocument.text;
|
|
312
312
|
};
|
|
313
313
|
const setLanguageId = (textDocumentId, languageId) => {
|
|
@@ -319,8 +319,8 @@ const setLanguageId = (textDocumentId, languageId) => {
|
|
|
319
319
|
runListenersSafe(getDidOpenListeners(), newTextDocument);
|
|
320
320
|
};
|
|
321
321
|
|
|
322
|
-
const BABEL_PARSER_SYNTAX_ERROR = 'BABEL_PARSER_SYNTAX_ERROR';
|
|
323
322
|
const E_NO_PROVIDER_FOUND = 'E_NO_PROVIDER_FOUND';
|
|
323
|
+
const BABEL_PARSER_SYNTAX_ERROR = 'BABEL_PARSER_SYNTAX_ERROR';
|
|
324
324
|
|
|
325
325
|
class NoProviderFoundError extends Error {
|
|
326
326
|
constructor(message) {
|
|
@@ -439,9 +439,9 @@ const getCombinedMessage = (error, message) => {
|
|
|
439
439
|
}
|
|
440
440
|
return stringifiedError;
|
|
441
441
|
};
|
|
442
|
-
const NewLine$
|
|
442
|
+
const NewLine$3 = '\n';
|
|
443
443
|
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
444
|
-
return string.indexOf(NewLine$
|
|
444
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
445
445
|
};
|
|
446
446
|
const mergeStacks = (parent, child) => {
|
|
447
447
|
if (!child) {
|
|
@@ -535,7 +535,7 @@ const registerMethod = ({
|
|
|
535
535
|
}) => {
|
|
536
536
|
context[`execute${name}Provider`] = async function (textDocumentId, ...params) {
|
|
537
537
|
try {
|
|
538
|
-
const textDocument = get$
|
|
538
|
+
const textDocument = get$a(textDocumentId);
|
|
539
539
|
if (!textDocument) {
|
|
540
540
|
throw new Error(`textDocument with id ${textDocumentId} not found`);
|
|
541
541
|
}
|
|
@@ -670,12 +670,12 @@ const executeOrganizeImports = async uid => {
|
|
|
670
670
|
if (!organizeImportsAction) {
|
|
671
671
|
return [];
|
|
672
672
|
}
|
|
673
|
-
const textDocument = get$
|
|
673
|
+
const textDocument = get$a(uid);
|
|
674
674
|
const edits = await organizeImportsAction.execute(textDocument);
|
|
675
675
|
return edits;
|
|
676
676
|
};
|
|
677
677
|
|
|
678
|
-
const state$
|
|
678
|
+
const state$d = {
|
|
679
679
|
commands: Object.create(null)
|
|
680
680
|
};
|
|
681
681
|
const getCommandDisplay = command => {
|
|
@@ -698,10 +698,10 @@ const registerCommand = command => {
|
|
|
698
698
|
if (!command.execute) {
|
|
699
699
|
throw new Error('command is missing execute function');
|
|
700
700
|
}
|
|
701
|
-
if (command.id in state$
|
|
701
|
+
if (command.id in state$d.commands) {
|
|
702
702
|
throw new Error(`command cannot be registered multiple times`);
|
|
703
703
|
}
|
|
704
|
-
state$
|
|
704
|
+
state$d.commands[command.id] = command;
|
|
705
705
|
} catch (error) {
|
|
706
706
|
const commandDisplayId = getCommandDisplay(command);
|
|
707
707
|
throw new VError(error, `Failed to register command${commandDisplayId}`);
|
|
@@ -709,7 +709,7 @@ const registerCommand = command => {
|
|
|
709
709
|
};
|
|
710
710
|
const executeCommand = async (id, ...args) => {
|
|
711
711
|
try {
|
|
712
|
-
const command = state$
|
|
712
|
+
const command = state$d.commands[id];
|
|
713
713
|
if (!command) {
|
|
714
714
|
throw new Error(`command ${id} not found`);
|
|
715
715
|
}
|
|
@@ -748,40 +748,40 @@ const {
|
|
|
748
748
|
}]
|
|
749
749
|
});
|
|
750
750
|
|
|
751
|
-
const state$
|
|
751
|
+
const state$c = {
|
|
752
752
|
configuration: Object.create(null)
|
|
753
753
|
};
|
|
754
754
|
const getConfiguration = key => {
|
|
755
|
-
return state$
|
|
755
|
+
return state$c.configuration[key] ?? '';
|
|
756
756
|
};
|
|
757
757
|
const setConfigurations = preferences => {
|
|
758
|
-
state$
|
|
758
|
+
state$c.configuration = preferences;
|
|
759
759
|
};
|
|
760
760
|
|
|
761
|
-
const state$
|
|
761
|
+
const state$b = {
|
|
762
762
|
rpc: undefined
|
|
763
763
|
};
|
|
764
764
|
const invoke$2 = (method, ...params) => {
|
|
765
|
-
const rpc = state$
|
|
765
|
+
const rpc = state$b.rpc;
|
|
766
766
|
return rpc.invoke(method, ...params);
|
|
767
767
|
};
|
|
768
768
|
const send$1 = (method, ...params) => {
|
|
769
|
-
const rpc = state$
|
|
769
|
+
const rpc = state$b.rpc;
|
|
770
770
|
return rpc.send(method, ...params);
|
|
771
771
|
};
|
|
772
772
|
const invokeAndTransfer$1 = (method, ...params) => {
|
|
773
|
-
const rpc = state$
|
|
773
|
+
const rpc = state$b.rpc;
|
|
774
774
|
return rpc.invokeAndTransfer(method, ...params);
|
|
775
775
|
};
|
|
776
776
|
const setRpc = rpc => {
|
|
777
|
-
state$
|
|
777
|
+
state$b.rpc = rpc;
|
|
778
778
|
};
|
|
779
779
|
|
|
780
|
-
const state$
|
|
780
|
+
const state$a = {
|
|
781
781
|
debugProviderMap: Object.create(null)
|
|
782
782
|
};
|
|
783
783
|
const getDebugProvider = id => {
|
|
784
|
-
const provider = state$
|
|
784
|
+
const provider = state$a.debugProviderMap[id];
|
|
785
785
|
if (!provider) {
|
|
786
786
|
// @ts-ignore
|
|
787
787
|
throw new VError(`no debug provider "${id}" found`);
|
|
@@ -792,7 +792,7 @@ const registerDebugProvider = debugProvider => {
|
|
|
792
792
|
if (!debugProvider.id) {
|
|
793
793
|
throw new Error('Failed to register debug system provider: missing id');
|
|
794
794
|
}
|
|
795
|
-
state$
|
|
795
|
+
state$a.debugProviderMap[debugProvider.id] = debugProvider;
|
|
796
796
|
};
|
|
797
797
|
const start = async (protocol, path) => {
|
|
798
798
|
try {
|
|
@@ -948,7 +948,7 @@ const exec = async (command, args, options) => {
|
|
|
948
948
|
};
|
|
949
949
|
|
|
950
950
|
const fileSystemProviderMap = Object.create(null);
|
|
951
|
-
const get$
|
|
951
|
+
const get$9 = protocol => {
|
|
952
952
|
const provider = fileSystemProviderMap[protocol];
|
|
953
953
|
if (!provider) {
|
|
954
954
|
// @ts-ignore
|
|
@@ -956,7 +956,7 @@ const get$5 = protocol => {
|
|
|
956
956
|
}
|
|
957
957
|
return provider;
|
|
958
958
|
};
|
|
959
|
-
const set$
|
|
959
|
+
const set$8 = (id, provider) => {
|
|
960
960
|
if (!id) {
|
|
961
961
|
throw new Error('Failed to register file system provider: missing id');
|
|
962
962
|
}
|
|
@@ -967,11 +967,11 @@ const registerFileSystemProvider = fileSystemProvider => {
|
|
|
967
967
|
if (!fileSystemProvider.id) {
|
|
968
968
|
throw new Error('Failed to register file system provider: missing id');
|
|
969
969
|
}
|
|
970
|
-
set$
|
|
970
|
+
set$8(fileSystemProvider.id, fileSystemProvider);
|
|
971
971
|
};
|
|
972
972
|
const readDirWithFileTypes$2 = async (protocol, path) => {
|
|
973
973
|
try {
|
|
974
|
-
const provider = get$
|
|
974
|
+
const provider = get$9(protocol);
|
|
975
975
|
return await provider.readDirWithFileTypes(path);
|
|
976
976
|
} catch (error) {
|
|
977
977
|
throw new VError(error, 'Failed to execute file system provider');
|
|
@@ -979,7 +979,7 @@ const readDirWithFileTypes$2 = async (protocol, path) => {
|
|
|
979
979
|
};
|
|
980
980
|
const readFile$2 = async (protocol, path) => {
|
|
981
981
|
try {
|
|
982
|
-
const provider = get$
|
|
982
|
+
const provider = get$9(protocol);
|
|
983
983
|
return await provider.readFile(path);
|
|
984
984
|
} catch (error) {
|
|
985
985
|
throw new VError(error, 'Failed to execute file system provider');
|
|
@@ -1007,7 +1007,7 @@ const readDirWithFileTypesExternal = async path => {
|
|
|
1007
1007
|
};
|
|
1008
1008
|
const writeFile$2 = async (protocol, uri, content) => {
|
|
1009
1009
|
try {
|
|
1010
|
-
const provider = get$
|
|
1010
|
+
const provider = get$9(protocol);
|
|
1011
1011
|
return await provider.writeFile(uri, content);
|
|
1012
1012
|
} catch (error) {
|
|
1013
1013
|
throw new VError(error, 'Failed to execute file system provider');
|
|
@@ -1015,7 +1015,7 @@ const writeFile$2 = async (protocol, uri, content) => {
|
|
|
1015
1015
|
};
|
|
1016
1016
|
const getPathSeparator = protocol => {
|
|
1017
1017
|
try {
|
|
1018
|
-
const provider = get$
|
|
1018
|
+
const provider = get$9(protocol);
|
|
1019
1019
|
return provider.pathSeparator;
|
|
1020
1020
|
} catch (error) {
|
|
1021
1021
|
throw new VError(error, 'Failed to execute file system provider');
|
|
@@ -1188,9 +1188,9 @@ class Ipc extends EventTarget {
|
|
|
1188
1188
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1189
1189
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1190
1190
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1191
|
-
const NewLine$
|
|
1191
|
+
const NewLine$2 = '\n';
|
|
1192
1192
|
const joinLines$1 = lines => {
|
|
1193
|
-
return lines.join(NewLine$
|
|
1193
|
+
return lines.join(NewLine$2);
|
|
1194
1194
|
};
|
|
1195
1195
|
const RE_AT = /^\s+at/;
|
|
1196
1196
|
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
@@ -1217,7 +1217,7 @@ const getDetails = lines => {
|
|
|
1217
1217
|
};
|
|
1218
1218
|
};
|
|
1219
1219
|
const splitLines$2 = lines => {
|
|
1220
|
-
return lines.split(NewLine$
|
|
1220
|
+
return lines.split(NewLine$2);
|
|
1221
1221
|
};
|
|
1222
1222
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1223
1223
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
@@ -1645,18 +1645,18 @@ const create$4$1 = (method, params) => {
|
|
|
1645
1645
|
};
|
|
1646
1646
|
};
|
|
1647
1647
|
const callbacks = Object.create(null);
|
|
1648
|
-
const set$
|
|
1648
|
+
const set$7 = (id, fn) => {
|
|
1649
1649
|
callbacks[id] = fn;
|
|
1650
1650
|
};
|
|
1651
|
-
const get$
|
|
1651
|
+
const get$8 = id => {
|
|
1652
1652
|
return callbacks[id];
|
|
1653
1653
|
};
|
|
1654
1654
|
const remove$2 = id => {
|
|
1655
1655
|
delete callbacks[id];
|
|
1656
1656
|
};
|
|
1657
|
-
let id = 0;
|
|
1657
|
+
let id$1 = 0;
|
|
1658
1658
|
const create$3$1 = () => {
|
|
1659
|
-
return ++id;
|
|
1659
|
+
return ++id$1;
|
|
1660
1660
|
};
|
|
1661
1661
|
const registerPromise = () => {
|
|
1662
1662
|
const id = create$3$1();
|
|
@@ -1664,7 +1664,7 @@ const registerPromise = () => {
|
|
|
1664
1664
|
resolve,
|
|
1665
1665
|
promise
|
|
1666
1666
|
} = Promise.withResolvers();
|
|
1667
|
-
set$
|
|
1667
|
+
set$7(id, resolve);
|
|
1668
1668
|
return {
|
|
1669
1669
|
id,
|
|
1670
1670
|
promise
|
|
@@ -1692,7 +1692,7 @@ class JsonRpcError extends Error {
|
|
|
1692
1692
|
this.name = 'JsonRpcError';
|
|
1693
1693
|
}
|
|
1694
1694
|
}
|
|
1695
|
-
const NewLine = '\n';
|
|
1695
|
+
const NewLine$1 = '\n';
|
|
1696
1696
|
const DomException = 'DOMException';
|
|
1697
1697
|
const ReferenceError$1 = 'ReferenceError';
|
|
1698
1698
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -1738,22 +1738,22 @@ const constructError = (message, type, name) => {
|
|
|
1738
1738
|
return new ErrorConstructor(message);
|
|
1739
1739
|
};
|
|
1740
1740
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1741
|
-
return string.indexOf(NewLine, startIndex);
|
|
1741
|
+
return string.indexOf(NewLine$1, startIndex);
|
|
1742
1742
|
};
|
|
1743
1743
|
const getParentStack = error => {
|
|
1744
1744
|
let parentStack = error.stack || error.data || error.message || '';
|
|
1745
1745
|
if (parentStack.startsWith(' at')) {
|
|
1746
|
-
parentStack = error.message + NewLine + parentStack;
|
|
1746
|
+
parentStack = error.message + NewLine$1 + parentStack;
|
|
1747
1747
|
}
|
|
1748
1748
|
return parentStack;
|
|
1749
1749
|
};
|
|
1750
1750
|
const joinLines = lines => {
|
|
1751
|
-
return lines.join(NewLine);
|
|
1751
|
+
return lines.join(NewLine$1);
|
|
1752
1752
|
};
|
|
1753
1753
|
const MethodNotFound = -32601;
|
|
1754
1754
|
const Custom = -32001;
|
|
1755
1755
|
const splitLines$1 = lines => {
|
|
1756
|
-
return lines.split(NewLine);
|
|
1756
|
+
return lines.split(NewLine$1);
|
|
1757
1757
|
};
|
|
1758
1758
|
const restoreJsonRpcError = error => {
|
|
1759
1759
|
if (error && error instanceof Error) {
|
|
@@ -1763,14 +1763,14 @@ const restoreJsonRpcError = error => {
|
|
|
1763
1763
|
if (error && error.code && error.code === MethodNotFound) {
|
|
1764
1764
|
const restoredError = new JsonRpcError(error.message);
|
|
1765
1765
|
const parentStack = getParentStack(error);
|
|
1766
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
1766
|
+
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
1767
1767
|
return restoredError;
|
|
1768
1768
|
}
|
|
1769
1769
|
if (error && error.message) {
|
|
1770
1770
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
1771
1771
|
if (error.data) {
|
|
1772
1772
|
if (error.data.stack && error.data.type && error.message) {
|
|
1773
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
1773
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
1774
1774
|
} else if (error.data.stack) {
|
|
1775
1775
|
restoredError.stack = error.data.stack;
|
|
1776
1776
|
}
|
|
@@ -1817,14 +1817,14 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
1817
1817
|
}
|
|
1818
1818
|
throw new JsonRpcError('unexpected response message');
|
|
1819
1819
|
};
|
|
1820
|
-
const warn = (...args) => {
|
|
1820
|
+
const warn$1 = (...args) => {
|
|
1821
1821
|
console.warn(...args);
|
|
1822
1822
|
};
|
|
1823
1823
|
const resolve = (id, response) => {
|
|
1824
|
-
const fn = get$
|
|
1824
|
+
const fn = get$8(id);
|
|
1825
1825
|
if (!fn) {
|
|
1826
1826
|
console.log(response);
|
|
1827
|
-
warn(`callback ${id} may already be disposed`);
|
|
1827
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
1828
1828
|
return;
|
|
1829
1829
|
}
|
|
1830
1830
|
fn(response);
|
|
@@ -2402,7 +2402,7 @@ const getExtensionHostSubWorkerUrl = () => {
|
|
|
2402
2402
|
};
|
|
2403
2403
|
const extensionHostSubWorkerUrl = getExtensionHostSubWorkerUrl();
|
|
2404
2404
|
|
|
2405
|
-
const set$
|
|
2405
|
+
const set$6 = async (url, contentSecurityPolicy) => {
|
|
2406
2406
|
const pathName = new URL(url).pathname;
|
|
2407
2407
|
await invoke$2('ExtensionHostWorkerContentSecurityPolicy.set', pathName, contentSecurityPolicy);
|
|
2408
2408
|
};
|
|
@@ -2422,7 +2422,7 @@ const createLegacyRpc = async ({
|
|
|
2422
2422
|
string(name);
|
|
2423
2423
|
object(commandMap);
|
|
2424
2424
|
if (contentSecurityPolicy) {
|
|
2425
|
-
await set$
|
|
2425
|
+
await set$6(url, contentSecurityPolicy);
|
|
2426
2426
|
}
|
|
2427
2427
|
const rpc = await create$2({
|
|
2428
2428
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
@@ -2443,7 +2443,7 @@ const rpcs$1 = Object.create(null);
|
|
|
2443
2443
|
const add$1 = (id, rpc) => {
|
|
2444
2444
|
rpcs$1[id] = rpc;
|
|
2445
2445
|
};
|
|
2446
|
-
const get$
|
|
2446
|
+
const get$7 = id => {
|
|
2447
2447
|
return rpcs$1[id];
|
|
2448
2448
|
};
|
|
2449
2449
|
|
|
@@ -2452,15 +2452,15 @@ const rpcs = Object.create(null);
|
|
|
2452
2452
|
const register = (id, execute) => {
|
|
2453
2453
|
registry[id] = execute;
|
|
2454
2454
|
};
|
|
2455
|
-
const get$
|
|
2455
|
+
const get$6 = id => {
|
|
2456
2456
|
return rpcs[id];
|
|
2457
2457
|
};
|
|
2458
|
-
const set$
|
|
2458
|
+
const set$5 = (id, rpc) => {
|
|
2459
2459
|
rpcs[id] = rpc;
|
|
2460
2460
|
};
|
|
2461
2461
|
|
|
2462
2462
|
const createRpcWithId$1 = async (id, commandMap, execute) => {
|
|
2463
|
-
const info = get$
|
|
2463
|
+
const info = get$7(id);
|
|
2464
2464
|
if (!info) {
|
|
2465
2465
|
throw new Error(`rpc with id ${id} not found`);
|
|
2466
2466
|
}
|
|
@@ -2476,16 +2476,16 @@ const createRpcWithId$1 = async (id, commandMap, execute) => {
|
|
|
2476
2476
|
rpc.ipc.execute = execute;
|
|
2477
2477
|
}
|
|
2478
2478
|
await rpc.invoke('LoadFile.loadFile', info.url);
|
|
2479
|
-
set$
|
|
2479
|
+
set$5(id, rpc);
|
|
2480
2480
|
return rpc;
|
|
2481
2481
|
};
|
|
2482
2482
|
|
|
2483
2483
|
const getOrCreateRpc = async (id, commandMap, execute) => {
|
|
2484
|
-
const rpc = get$
|
|
2484
|
+
const rpc = get$6(id);
|
|
2485
2485
|
if (!rpc) {
|
|
2486
|
-
set$
|
|
2486
|
+
set$5(id, createRpcWithId$1(id, commandMap, execute));
|
|
2487
2487
|
}
|
|
2488
|
-
return get$
|
|
2488
|
+
return get$6(id);
|
|
2489
2489
|
};
|
|
2490
2490
|
const createRpcWithId = ({
|
|
2491
2491
|
id,
|
|
@@ -2551,17 +2551,17 @@ const {
|
|
|
2551
2551
|
}
|
|
2552
2552
|
});
|
|
2553
2553
|
|
|
2554
|
-
const state$
|
|
2554
|
+
const state$9 = {
|
|
2555
2555
|
providers: Object.create(null)
|
|
2556
2556
|
};
|
|
2557
2557
|
const registerSourceControlProvider = provider => {
|
|
2558
|
-
state$
|
|
2558
|
+
state$9.providers[provider.id] = provider;
|
|
2559
2559
|
};
|
|
2560
2560
|
const getFilesFromProvider = provider => {
|
|
2561
2561
|
return provider.getChangedFiles();
|
|
2562
2562
|
};
|
|
2563
2563
|
const getChangedFiles = async providerId => {
|
|
2564
|
-
const provider = state$
|
|
2564
|
+
const provider = state$9.providers[providerId];
|
|
2565
2565
|
if (!provider) {
|
|
2566
2566
|
throw new Error('no source control provider found');
|
|
2567
2567
|
}
|
|
@@ -2572,7 +2572,7 @@ const getChangedFiles = async providerId => {
|
|
|
2572
2572
|
const getFileBefore = async (providerId, uri) => {
|
|
2573
2573
|
string(providerId);
|
|
2574
2574
|
string(uri);
|
|
2575
|
-
const provider = state$
|
|
2575
|
+
const provider = state$9.providers[providerId];
|
|
2576
2576
|
if (!provider) {
|
|
2577
2577
|
throw new Error('no source control provider found');
|
|
2578
2578
|
}
|
|
@@ -2594,7 +2594,7 @@ const getGroupsFromProvider = async (provider, cwd) => {
|
|
|
2594
2594
|
throw new Error('source control provider is missing required function getGroups');
|
|
2595
2595
|
};
|
|
2596
2596
|
const getGroups = async (providerId, cwd) => {
|
|
2597
|
-
const provider = state$
|
|
2597
|
+
const provider = state$9.providers[providerId];
|
|
2598
2598
|
if (!provider) {
|
|
2599
2599
|
throw new Error('no source control provider found');
|
|
2600
2600
|
}
|
|
@@ -2602,14 +2602,14 @@ const getGroups = async (providerId, cwd) => {
|
|
|
2602
2602
|
return groups;
|
|
2603
2603
|
};
|
|
2604
2604
|
const acceptInput = async (providerId, value) => {
|
|
2605
|
-
const provider = state$
|
|
2605
|
+
const provider = state$9.providers[providerId];
|
|
2606
2606
|
if (!provider) {
|
|
2607
2607
|
throw new Error('no source control provider found');
|
|
2608
2608
|
}
|
|
2609
2609
|
await provider.acceptInput(value);
|
|
2610
2610
|
};
|
|
2611
2611
|
const add = async path => {
|
|
2612
|
-
const provider = Object.values(state$
|
|
2612
|
+
const provider = Object.values(state$9.providers)[0];
|
|
2613
2613
|
if (!provider) {
|
|
2614
2614
|
return;
|
|
2615
2615
|
}
|
|
@@ -2617,7 +2617,7 @@ const add = async path => {
|
|
|
2617
2617
|
await provider.add(path);
|
|
2618
2618
|
};
|
|
2619
2619
|
const discard = async path => {
|
|
2620
|
-
const provider = Object.values(state$
|
|
2620
|
+
const provider = Object.values(state$9.providers)[0];
|
|
2621
2621
|
if (!provider) {
|
|
2622
2622
|
return;
|
|
2623
2623
|
}
|
|
@@ -2627,7 +2627,7 @@ const discard = async path => {
|
|
|
2627
2627
|
const getEnabledProviderIds = async (scheme, root) => {
|
|
2628
2628
|
string(scheme);
|
|
2629
2629
|
string(root);
|
|
2630
|
-
const providers = Object.values(state$
|
|
2630
|
+
const providers = Object.values(state$9.providers);
|
|
2631
2631
|
const enabledIds = [];
|
|
2632
2632
|
for (const provider of providers) {
|
|
2633
2633
|
// @ts-ignore
|
|
@@ -2656,7 +2656,7 @@ const {
|
|
|
2656
2656
|
}
|
|
2657
2657
|
});
|
|
2658
2658
|
|
|
2659
|
-
const state$
|
|
2659
|
+
const state$8 = {
|
|
2660
2660
|
textSearchProviders: Object.create(null)
|
|
2661
2661
|
};
|
|
2662
2662
|
const registerTextSearchProvider = textSearchProvider => {
|
|
@@ -2667,14 +2667,14 @@ const registerTextSearchProvider = textSearchProvider => {
|
|
|
2667
2667
|
if (!textSearchProvider.scheme) {
|
|
2668
2668
|
throw new Error('textSearchProvider is missing scheme');
|
|
2669
2669
|
}
|
|
2670
|
-
state$
|
|
2670
|
+
state$8.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
|
|
2671
2671
|
} catch (error) {
|
|
2672
2672
|
throw new VError(error, 'Failed to register text search provider');
|
|
2673
2673
|
}
|
|
2674
2674
|
};
|
|
2675
2675
|
const executeTextSearchProvider = async (scheme, query) => {
|
|
2676
2676
|
try {
|
|
2677
|
-
const textSearchProvider = state$
|
|
2677
|
+
const textSearchProvider = state$8.textSearchProviders[scheme];
|
|
2678
2678
|
if (!textSearchProvider) {
|
|
2679
2679
|
throw new Error(`No text search provider for ${scheme} found`);
|
|
2680
2680
|
}
|
|
@@ -2864,14 +2864,14 @@ const createWorker = async ({
|
|
|
2864
2864
|
return rpc;
|
|
2865
2865
|
};
|
|
2866
2866
|
|
|
2867
|
-
const state$
|
|
2867
|
+
const state$7 = {
|
|
2868
2868
|
workspacePath: ''
|
|
2869
2869
|
};
|
|
2870
2870
|
const setWorkspacePath = path => {
|
|
2871
|
-
state$
|
|
2871
|
+
state$7.workspacePath = path;
|
|
2872
2872
|
};
|
|
2873
2873
|
const getWorkspaceFolder = path => {
|
|
2874
|
-
return state$
|
|
2874
|
+
return state$7.workspacePath;
|
|
2875
2875
|
};
|
|
2876
2876
|
|
|
2877
2877
|
class FormattingError extends Error {
|
|
@@ -2969,7 +2969,7 @@ const api = {
|
|
|
2969
2969
|
registerTabCompletionProvider: registerTabCompletionProvider,
|
|
2970
2970
|
executeTabCompletionProvider: executeTabCompletionProvider,
|
|
2971
2971
|
// Text Document
|
|
2972
|
-
getTextFromTextDocument: getText$
|
|
2972
|
+
getTextFromTextDocument: getText$2,
|
|
2973
2973
|
// Text Search
|
|
2974
2974
|
registerTextSearchProvider: registerTextSearchProvider,
|
|
2975
2975
|
executeTextSearchProvider: executeTextSearchProvider,
|
|
@@ -3024,7 +3024,7 @@ const handleUnhandledRejection = event => {
|
|
|
3024
3024
|
console.error(output);
|
|
3025
3025
|
};
|
|
3026
3026
|
|
|
3027
|
-
const state$
|
|
3027
|
+
const state$6 = {
|
|
3028
3028
|
/**
|
|
3029
3029
|
* @type {any[]}
|
|
3030
3030
|
*/
|
|
@@ -3032,10 +3032,10 @@ const state$4 = {
|
|
|
3032
3032
|
};
|
|
3033
3033
|
const addError = error => {
|
|
3034
3034
|
// @ts-ignore
|
|
3035
|
-
state$
|
|
3035
|
+
state$6.errors.push(error);
|
|
3036
3036
|
};
|
|
3037
3037
|
const hasRecentErrors = () => {
|
|
3038
|
-
return state$
|
|
3038
|
+
return state$6.errors.length > 0;
|
|
3039
3039
|
};
|
|
3040
3040
|
const getRecentError = () => {
|
|
3041
3041
|
};
|
|
@@ -3084,236 +3084,833 @@ const applyBulkReplacement = async (files, ranges, replacement) => {
|
|
|
3084
3084
|
throw new Error('not implemented');
|
|
3085
3085
|
};
|
|
3086
3086
|
|
|
3087
|
-
const
|
|
3088
|
-
|
|
3089
|
-
if (typeof ASSET_DIR !== 'undefined') {
|
|
3090
|
-
// @ts-ignore
|
|
3091
|
-
return ASSET_DIR;
|
|
3092
|
-
}
|
|
3093
|
-
if (platform === Electron) {
|
|
3094
|
-
return '../../../../..';
|
|
3095
|
-
}
|
|
3096
|
-
return '';
|
|
3097
|
-
};
|
|
3098
|
-
const assetDir = getAssetDir();
|
|
3099
|
-
|
|
3100
|
-
const iframeWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/iframe-worker/dist/iframeWorkerMain.js`;
|
|
3101
|
-
|
|
3102
|
-
const get$1 = key => {
|
|
3103
|
-
return invoke$2('Preferences.get', key);
|
|
3104
|
-
};
|
|
3105
|
-
|
|
3106
|
-
const getConfiguredIframeWorkerUrl = async () => {
|
|
3107
|
-
let configuredWorkerUrl = (await get$1('develop.iframeWorkerPath')) || '';
|
|
3108
|
-
if (configuredWorkerUrl) {
|
|
3109
|
-
configuredWorkerUrl = '/remote' + configuredWorkerUrl;
|
|
3110
|
-
}
|
|
3111
|
-
configuredWorkerUrl = configuredWorkerUrl || iframeWorkerUrl;
|
|
3112
|
-
return configuredWorkerUrl;
|
|
3087
|
+
const addCssStyleSheet = (id, css) => {
|
|
3088
|
+
return invoke$2('Css.addCssStyleSheet', id, css);
|
|
3113
3089
|
};
|
|
3114
3090
|
|
|
3115
|
-
const
|
|
3116
|
-
id: 0
|
|
3117
|
-
};
|
|
3118
|
-
const create$1 = () => {
|
|
3119
|
-
return ++state$3.id;
|
|
3120
|
-
};
|
|
3091
|
+
const NewLine = '\n';
|
|
3121
3092
|
|
|
3122
|
-
const
|
|
3123
|
-
|
|
3124
|
-
'WebView.compatExtensionHostWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatExtensionHostWorkerInvokeAndTransfer', ...args),
|
|
3125
|
-
'WebView.compatRendererProcessInvoke': (...args) => invoke$2('WebView.compatRendererProcessInvoke', ...args),
|
|
3126
|
-
'WebView.compatRendererProcessInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatRendererProcessInvokeAndTransfer', ...args),
|
|
3127
|
-
// @ts-ignore
|
|
3128
|
-
'WebView.compatRendererWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1(...args),
|
|
3129
|
-
// @ts-ignore
|
|
3130
|
-
'WebView.compatRendererWorkerInvoke': (...args) => invoke$2(...args),
|
|
3131
|
-
'WebView.compatSharedProcessInvoke': (...args) => invoke$2('WebView.compatSharedProcessInvoke', ...args),
|
|
3132
|
-
'WebView.getSavedState': (...args) => invoke$2('WebView.getSavedState', ...args),
|
|
3133
|
-
'WebView.getWebViewInfo': (...args) => invoke$2('WebView.getWebViewInfo', ...args),
|
|
3134
|
-
'WebView.getWebViews': (...args) => invoke$2('WebView.getWebViews', ...args),
|
|
3135
|
-
'WebView.setPort': (...args) => invoke$2('WebView.setPort', ...args),
|
|
3136
|
-
'ExtensionHostManagement.activateByEvent': (...args) => invoke$2('ExtensionHostManagement.activateByEvent', ...args),
|
|
3137
|
-
'WebView.getRemoteUrl': options => getRemoteUrlForWebView(options.uri, options)
|
|
3138
|
-
};
|
|
3139
|
-
const launchIframeWorker = async () => {
|
|
3140
|
-
const configuredWorkerUrl = await getConfiguredIframeWorkerUrl();
|
|
3141
|
-
const name = 'Iframe Worker';
|
|
3142
|
-
const id = create$1();
|
|
3143
|
-
const rpc = await create$2({
|
|
3144
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
3145
|
-
name,
|
|
3146
|
-
url: configuredWorkerUrl,
|
|
3147
|
-
id,
|
|
3148
|
-
commandMap: commandMap$1
|
|
3149
|
-
});
|
|
3150
|
-
return rpc;
|
|
3093
|
+
const warn = (...args) => {
|
|
3094
|
+
console.warn(...args);
|
|
3151
3095
|
};
|
|
3152
3096
|
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
if (!workerPromise) {
|
|
3156
|
-
workerPromise = launchIframeWorker();
|
|
3157
|
-
}
|
|
3158
|
-
return workerPromise;
|
|
3159
|
-
};
|
|
3160
|
-
const invoke = async (method, ...params) => {
|
|
3161
|
-
const rpc = await ensureWorker();
|
|
3162
|
-
return rpc.invoke(method, ...params);
|
|
3097
|
+
const transparent = (color, factor) => {
|
|
3098
|
+
return color;
|
|
3163
3099
|
};
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
id,
|
|
3167
|
-
uri,
|
|
3168
|
-
isGitpod,
|
|
3169
|
-
platform,
|
|
3170
|
-
assetDir,
|
|
3171
|
-
webViewScheme,
|
|
3172
|
-
useNewWebViewHandler
|
|
3173
|
-
}) => {
|
|
3174
|
-
await invoke('WebView.create3', {
|
|
3175
|
-
id,
|
|
3176
|
-
uri,
|
|
3177
|
-
isGitpod,
|
|
3178
|
-
platform,
|
|
3179
|
-
assetDir,
|
|
3180
|
-
webViewScheme,
|
|
3181
|
-
useNewWebViewHandler
|
|
3182
|
-
});
|
|
3100
|
+
const toColorRule = ([key, value]) => {
|
|
3101
|
+
return ` --${key}: ${value};`;
|
|
3183
3102
|
};
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
// TODO this function is called from the iframe worker to create a direct
|
|
3187
|
-
// connection between a webview/iframe and it's webworker. For this to work
|
|
3188
|
-
// the iframe worker creates a messagechannel and sends one messageport to the webview
|
|
3189
|
-
// and the other messageport to the webworker. This enables direct communication via
|
|
3190
|
-
// the two message ports
|
|
3191
|
-
|
|
3192
|
-
// TODO have a way so that the worker already includes the webview api and the extension
|
|
3193
|
-
// host subworker doesn't need to import the other file
|
|
3194
|
-
await invokeAndTransfer$1('IpcParent.create', {
|
|
3195
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
3196
|
-
url: extensionHostSubWorkerUrl,
|
|
3197
|
-
name: rpcInfo.name,
|
|
3198
|
-
raw: true,
|
|
3199
|
-
port
|
|
3200
|
-
});
|
|
3103
|
+
const toTokenColorRule = tokenColor => {
|
|
3104
|
+
return `.${tokenColor.name} { color: ${tokenColor.foreground} }`;
|
|
3201
3105
|
};
|
|
3202
|
-
|
|
3203
|
-
const
|
|
3204
|
-
|
|
3205
|
-
const CommandExecute = 'ExtensionHostCommand.executeCommand';
|
|
3206
|
-
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
3207
|
-
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
3208
|
-
const DefinitionExecuteDefinitionProvider = 'ExtensionHostDefinition.executeDefinitionProvider';
|
|
3209
|
-
const DiagnosticExecuteDiagnosticProvider = 'ExtensionHost.executeDiagnosticProvider';
|
|
3210
|
-
const ExtensionActivate = 'ExtensionHostExtension.activate';
|
|
3211
|
-
const FileSystemGetPathSeparator = 'ExtensionHostFileSystem.getPathSeparator';
|
|
3212
|
-
const FileSystemReadDirWithFileTypes = 'ExtensionHostFileSystem.readDirWithFileTypes';
|
|
3213
|
-
const FileSystemReadFile = 'ExtensionHostFileSystem.readFile';
|
|
3214
|
-
const FileSystemWriteFile = 'ExtensionHostFileSystem.writeFile';
|
|
3215
|
-
const FormattingExecuteFormmattingProvider = 'ExtensionHostFormatting.executeFormattingProvider';
|
|
3216
|
-
const HoverExecute = 'ExtensionHostHover.execute';
|
|
3217
|
-
const ImplementationExecuteImplementationProvider = 'ExtensionHostImplementation.executeImplementationProvider';
|
|
3218
|
-
const MockExec = 'ExtensionHostMockExec.mockExec';
|
|
3219
|
-
const MockRpc = 'ExtensionHostMockRpc.mockRpc';
|
|
3220
|
-
const OrganizeImportsExecute = 'ExtensionHostOrganizeImports.execute';
|
|
3221
|
-
const ReferenceExecuteFileReferenceProvider = 'ExtensionHostReference.executeFileReferenceProvider';
|
|
3222
|
-
const ReferenceExecuteReferenceProvider = 'ExtensionHostReference.executeReferenceProvider';
|
|
3223
|
-
const SourceControlAcceptInput = 'ExtensionHostSourceControl.acceptInput';
|
|
3224
|
-
const SourceControlAdd = 'ExtensionHostSourceControl.add';
|
|
3225
|
-
const SourceControlDiscard = 'ExtensionHostSourceControl.discard';
|
|
3226
|
-
const SourceControlGetChangedFiles = 'ExtensionHost.sourceControlGetChangedFiles';
|
|
3227
|
-
const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
|
|
3228
|
-
const SourceControlGetFileBefore = 'ExtensionHostSourceControl.GetFileBefore';
|
|
3229
|
-
const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
|
|
3230
|
-
const StatusBarGetStatusBarItems = 'ExtensionHost.getStatusBarItems';
|
|
3231
|
-
const StatusBarRegisterChangeListener = 'ExtensionHostStatusBar.registerChangeListener';
|
|
3232
|
-
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
3233
|
-
const TextDocumentSetLanguageId = 'ExtensionHostTextDocument.setLanguageId';
|
|
3234
|
-
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
3235
|
-
const TextDocumentSyncIncremental = 'ExtensionHostTextDocument.syncIncremental';
|
|
3236
|
-
const TextSearchExecuteTextSearchProvider = 'ExtensionHostTextSearch.executeTextSearchProvider';
|
|
3237
|
-
const TypeDefinitionExecuteTypeDefinitionProvider = 'ExtensionHostTypeDefinition.executeTypeDefinitionProvider';
|
|
3238
|
-
const WorkspaceSetPath = 'Workspace.setWorkspacePath';
|
|
3239
|
-
const SelectionExecuteSelectionProvider = 'ExtensionHostSelection.executeSelectionProvider';
|
|
3240
|
-
const ConfigurationSetConfiguration = 'ExtensionHostConfiguration.setConfiguration';
|
|
3241
|
-
|
|
3242
|
-
const create = () => {
|
|
3243
|
-
return {
|
|
3244
|
-
finished: false
|
|
3106
|
+
const addFallbackColors = colors => {
|
|
3107
|
+
const newColors = {
|
|
3108
|
+
...colors
|
|
3245
3109
|
};
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
};
|
|
3250
|
-
const isCanceled = token => {
|
|
3251
|
-
return token.finished;
|
|
3252
|
-
};
|
|
3253
|
-
|
|
3254
|
-
const baseName = path => {
|
|
3255
|
-
const slashIndex = path.lastIndexOf('/');
|
|
3256
|
-
return path.slice(slashIndex + 1);
|
|
3257
|
-
};
|
|
3258
|
-
const getExtensionId = extension => {
|
|
3259
|
-
if (extension && extension.id) {
|
|
3260
|
-
return extension.id;
|
|
3110
|
+
if (!newColors.ActivityBarInactiveForeground) {
|
|
3111
|
+
// TODO don't assign, avoid mutation
|
|
3112
|
+
newColors.ActivityBarInactiveForeground = transparent(newColors.ActivityBarForeground);
|
|
3261
3113
|
}
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
}
|
|
3265
|
-
return '<unknown>';
|
|
3114
|
+
newColors.CssVariableName ||= colors.VariableName;
|
|
3115
|
+
return newColors;
|
|
3266
3116
|
};
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
return
|
|
3117
|
+
const createColorThemeFromJson = (colorThemeId, colorThemeJson) => {
|
|
3118
|
+
if (!colorThemeJson) {
|
|
3119
|
+
warn(`color theme json for "${colorThemeId}" is empty: "${colorThemeJson}"`);
|
|
3120
|
+
return '';
|
|
3271
3121
|
}
|
|
3272
|
-
if (
|
|
3273
|
-
|
|
3122
|
+
if (typeof colorThemeJson !== 'object') {
|
|
3123
|
+
warn(`color theme json for "${colorThemeId}" cannot be converted to css: "${colorThemeJson}"`);
|
|
3124
|
+
return '';
|
|
3274
3125
|
}
|
|
3275
|
-
if (
|
|
3276
|
-
|
|
3126
|
+
if (Array.isArray(colorThemeJson)) {
|
|
3127
|
+
warn(`color theme json for "${colorThemeId}" cannot be converted to css, it must be of type object but was of type array`);
|
|
3128
|
+
return '';
|
|
3277
3129
|
}
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
const handleRpcInfos = extension => {
|
|
3282
|
-
try {
|
|
3283
|
-
if (!extension) {
|
|
3284
|
-
return;
|
|
3285
|
-
}
|
|
3286
|
-
const rpcs = extension.rpc;
|
|
3287
|
-
const urlPrefix = getUrlPrefix(platform, extension.path);
|
|
3288
|
-
if (!rpcs) {
|
|
3289
|
-
return;
|
|
3290
|
-
}
|
|
3291
|
-
if (!Array.isArray(rpcs)) {
|
|
3292
|
-
return;
|
|
3293
|
-
}
|
|
3294
|
-
for (const rpc of rpcs) {
|
|
3295
|
-
rpc.url = `${urlPrefix}/${rpc.url}`;
|
|
3296
|
-
add$1(rpc.id, rpc);
|
|
3297
|
-
}
|
|
3298
|
-
} catch (error) {
|
|
3299
|
-
console.warn(`Failed to handle extension rpcs: ${error}`);
|
|
3130
|
+
const colors = colorThemeJson.colors;
|
|
3131
|
+
if (!colors) {
|
|
3132
|
+
return '';
|
|
3300
3133
|
}
|
|
3301
|
-
|
|
3134
|
+
const newColors = addFallbackColors(colors);
|
|
3135
|
+
const colorRules = Object.entries(newColors).map(toColorRule);
|
|
3136
|
+
const tokenColors = colorThemeJson.tokenColors || [];
|
|
3137
|
+
const tokenColorRules = tokenColors.map(toTokenColorRule);
|
|
3138
|
+
const extraRules = [];
|
|
3139
|
+
if (colors.ContrastBorder) {
|
|
3140
|
+
extraRules.push(`#ActivityBar, #SideBar {
|
|
3141
|
+
border-left: 1px solid var(--ContrastBorder);
|
|
3142
|
+
}`, `#Panel {
|
|
3143
|
+
border-top: 1px solid var(--ContrastBorder);
|
|
3144
|
+
}`, `#StatusBar {
|
|
3145
|
+
border-top: 1px solid var(--ContrastBorder);
|
|
3146
|
+
}`, `.ActivityBarItemBadge {
|
|
3147
|
+
border: 1px solid var(--ContrastBorder);
|
|
3148
|
+
}`, `#QuickPick {
|
|
3149
|
+
border: 1px solid var(--ContrastBorder);
|
|
3150
|
+
}`);
|
|
3151
|
+
}
|
|
3152
|
+
const colorThemeCss = `:root {\n${colorRules.join(NewLine)}\n}\n\n${tokenColorRules.join(NewLine)}\n\n${extraRules.join(NewLine)}`;
|
|
3153
|
+
return colorThemeCss;
|
|
3154
|
+
};
|
|
3155
|
+
|
|
3156
|
+
// for (let i = 0; i < 10000; i++) {
|
|
3157
|
+
// createColorThemeFromJson({
|
|
3158
|
+
// type: 'dark',
|
|
3159
|
+
// colors: {
|
|
3160
|
+
// ActivityBarBackground: 'rgb(40, 46, 47)',
|
|
3161
|
+
// ActivityBarForeground: '#878f8c',
|
|
3162
|
+
// ActivityBarActiveBackground: '#1f2727',
|
|
3163
|
+
|
|
3164
|
+
// EditorBackGround: '#1e2324',
|
|
3165
|
+
// EditorScrollBarBackground: 'rgba(57, 71, 71, 0.6)',
|
|
3166
|
+
// EditorCursorBackground: '#a8df5a',
|
|
3167
|
+
|
|
3168
|
+
// ListActiveSelectionBackground: '#515f59',
|
|
3169
|
+
// ListActiveSelectionForeground: '#ffffff',
|
|
3170
|
+
// ListHoverBackground: '#405c5033',
|
|
3171
|
+
// ListHoverForeground: '#e0e0e0',
|
|
3172
|
+
// ListInactiveSelectionBackground: '#3b474280',
|
|
3173
|
+
|
|
3174
|
+
// MainBackground: '#1e2324',
|
|
3175
|
+
|
|
3176
|
+
// PanelBackground: '#1b2020',
|
|
3177
|
+
// PanelBorderTopColor: 'rgba(128, 128, 128, 0.35)',
|
|
3178
|
+
|
|
3179
|
+
// SideBarBackground: '#1b2020',
|
|
3180
|
+
|
|
3181
|
+
// StatusBarBackground: 'rgb(40, 46, 47)',
|
|
3182
|
+
// StatusBarBorderTopColor: '#222222',
|
|
3183
|
+
|
|
3184
|
+
// TabActiveBackground: '#24292a',
|
|
3185
|
+
// TabInactiveBackground: '#282e2f',
|
|
3186
|
+
|
|
3187
|
+
// TitleBarBackground: 'rgb(40, 46, 47)',
|
|
3188
|
+
// TitleBarBorderBottomColor: '#222',
|
|
3189
|
+
// TitleBarColor: '#cccccc',
|
|
3190
|
+
// TitleBarColorInactive: 'rgba(204, 204, 204, 0.6)',
|
|
3191
|
+
// },
|
|
3192
|
+
// }) //?.
|
|
3193
|
+
// }
|
|
3302
3194
|
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
at ${sourceFile}:${lineNumber}:${columnNumber}`;
|
|
3310
|
-
} else {
|
|
3311
|
-
this.stack = `Content Security Policy Violation
|
|
3312
|
-
at <unknown>`;
|
|
3313
|
-
}
|
|
3314
|
-
}
|
|
3195
|
+
const instanceOfAny = (object, constructors) => constructors.some(c => object instanceof c);
|
|
3196
|
+
let idbProxyableTypes;
|
|
3197
|
+
let cursorAdvanceMethods;
|
|
3198
|
+
// This is a function to prevent it throwing up in node environments.
|
|
3199
|
+
function getIdbProxyableTypes() {
|
|
3200
|
+
return idbProxyableTypes || (idbProxyableTypes = [IDBDatabase, IDBObjectStore, IDBIndex, IDBCursor, IDBTransaction]);
|
|
3315
3201
|
}
|
|
3316
|
-
|
|
3202
|
+
// This is a function to prevent it throwing up in node environments.
|
|
3203
|
+
function getCursorAdvanceMethods() {
|
|
3204
|
+
return cursorAdvanceMethods || (cursorAdvanceMethods = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey]);
|
|
3205
|
+
}
|
|
3206
|
+
const transactionDoneMap = new WeakMap();
|
|
3207
|
+
const transformCache = new WeakMap();
|
|
3208
|
+
const reverseTransformCache = new WeakMap();
|
|
3209
|
+
function promisifyRequest(request) {
|
|
3210
|
+
const promise = new Promise((resolve, reject) => {
|
|
3211
|
+
const unlisten = () => {
|
|
3212
|
+
request.removeEventListener('success', success);
|
|
3213
|
+
request.removeEventListener('error', error);
|
|
3214
|
+
};
|
|
3215
|
+
const success = () => {
|
|
3216
|
+
resolve(wrap(request.result));
|
|
3217
|
+
unlisten();
|
|
3218
|
+
};
|
|
3219
|
+
const error = () => {
|
|
3220
|
+
reject(request.error);
|
|
3221
|
+
unlisten();
|
|
3222
|
+
};
|
|
3223
|
+
request.addEventListener('success', success);
|
|
3224
|
+
request.addEventListener('error', error);
|
|
3225
|
+
});
|
|
3226
|
+
// This mapping exists in reverseTransformCache but doesn't exist in transformCache. This
|
|
3227
|
+
// is because we create many promises from a single IDBRequest.
|
|
3228
|
+
reverseTransformCache.set(promise, request);
|
|
3229
|
+
return promise;
|
|
3230
|
+
}
|
|
3231
|
+
function cacheDonePromiseForTransaction(tx) {
|
|
3232
|
+
// Early bail if we've already created a done promise for this transaction.
|
|
3233
|
+
if (transactionDoneMap.has(tx)) return;
|
|
3234
|
+
const done = new Promise((resolve, reject) => {
|
|
3235
|
+
const unlisten = () => {
|
|
3236
|
+
tx.removeEventListener('complete', complete);
|
|
3237
|
+
tx.removeEventListener('error', error);
|
|
3238
|
+
tx.removeEventListener('abort', error);
|
|
3239
|
+
};
|
|
3240
|
+
const complete = () => {
|
|
3241
|
+
resolve();
|
|
3242
|
+
unlisten();
|
|
3243
|
+
};
|
|
3244
|
+
const error = () => {
|
|
3245
|
+
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
|
3246
|
+
unlisten();
|
|
3247
|
+
};
|
|
3248
|
+
tx.addEventListener('complete', complete);
|
|
3249
|
+
tx.addEventListener('error', error);
|
|
3250
|
+
tx.addEventListener('abort', error);
|
|
3251
|
+
});
|
|
3252
|
+
// Cache it for later retrieval.
|
|
3253
|
+
transactionDoneMap.set(tx, done);
|
|
3254
|
+
}
|
|
3255
|
+
let idbProxyTraps = {
|
|
3256
|
+
get(target, prop, receiver) {
|
|
3257
|
+
if (target instanceof IDBTransaction) {
|
|
3258
|
+
// Special handling for transaction.done.
|
|
3259
|
+
if (prop === 'done') return transactionDoneMap.get(target);
|
|
3260
|
+
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
3261
|
+
if (prop === 'store') {
|
|
3262
|
+
return receiver.objectStoreNames[1] ? undefined : receiver.objectStore(receiver.objectStoreNames[0]);
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
// Else transform whatever we get back.
|
|
3266
|
+
return wrap(target[prop]);
|
|
3267
|
+
},
|
|
3268
|
+
set(target, prop, value) {
|
|
3269
|
+
target[prop] = value;
|
|
3270
|
+
return true;
|
|
3271
|
+
},
|
|
3272
|
+
has(target, prop) {
|
|
3273
|
+
if (target instanceof IDBTransaction && (prop === 'done' || prop === 'store')) {
|
|
3274
|
+
return true;
|
|
3275
|
+
}
|
|
3276
|
+
return prop in target;
|
|
3277
|
+
}
|
|
3278
|
+
};
|
|
3279
|
+
function replaceTraps(callback) {
|
|
3280
|
+
idbProxyTraps = callback(idbProxyTraps);
|
|
3281
|
+
}
|
|
3282
|
+
function wrapFunction(func) {
|
|
3283
|
+
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
|
3284
|
+
// only create one new func per func.
|
|
3285
|
+
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
|
3286
|
+
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
|
3287
|
+
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
3288
|
+
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
|
3289
|
+
// undefined if the end of the cursor has been reached.
|
|
3290
|
+
if (getCursorAdvanceMethods().includes(func)) {
|
|
3291
|
+
return function (...args) {
|
|
3292
|
+
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3293
|
+
// the original object.
|
|
3294
|
+
func.apply(unwrap(this), args);
|
|
3295
|
+
return wrap(this.request);
|
|
3296
|
+
};
|
|
3297
|
+
}
|
|
3298
|
+
return function (...args) {
|
|
3299
|
+
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
3300
|
+
// the original object.
|
|
3301
|
+
return wrap(func.apply(unwrap(this), args));
|
|
3302
|
+
};
|
|
3303
|
+
}
|
|
3304
|
+
function transformCachableValue(value) {
|
|
3305
|
+
if (typeof value === 'function') return wrapFunction(value);
|
|
3306
|
+
// This doesn't return, it just creates a 'done' promise for the transaction,
|
|
3307
|
+
// which is later returned for transaction.done (see idbObjectHandler).
|
|
3308
|
+
if (value instanceof IDBTransaction) cacheDonePromiseForTransaction(value);
|
|
3309
|
+
if (instanceOfAny(value, getIdbProxyableTypes())) return new Proxy(value, idbProxyTraps);
|
|
3310
|
+
// Return the same value back if we're not going to transform it.
|
|
3311
|
+
return value;
|
|
3312
|
+
}
|
|
3313
|
+
function wrap(value) {
|
|
3314
|
+
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
3315
|
+
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
3316
|
+
if (value instanceof IDBRequest) return promisifyRequest(value);
|
|
3317
|
+
// If we've already transformed this value before, reuse the transformed value.
|
|
3318
|
+
// This is faster, but it also provides object equality.
|
|
3319
|
+
if (transformCache.has(value)) return transformCache.get(value);
|
|
3320
|
+
const newValue = transformCachableValue(value);
|
|
3321
|
+
// Not all types are transformed.
|
|
3322
|
+
// These may be primitive types, so they can't be WeakMap keys.
|
|
3323
|
+
if (newValue !== value) {
|
|
3324
|
+
transformCache.set(value, newValue);
|
|
3325
|
+
reverseTransformCache.set(newValue, value);
|
|
3326
|
+
}
|
|
3327
|
+
return newValue;
|
|
3328
|
+
}
|
|
3329
|
+
const unwrap = value => reverseTransformCache.get(value);
|
|
3330
|
+
|
|
3331
|
+
/**
|
|
3332
|
+
* Open a database.
|
|
3333
|
+
*
|
|
3334
|
+
* @param name Name of the database.
|
|
3335
|
+
* @param version Schema version.
|
|
3336
|
+
* @param callbacks Additional callbacks.
|
|
3337
|
+
*/
|
|
3338
|
+
function openDB(name, version, {
|
|
3339
|
+
blocked,
|
|
3340
|
+
upgrade,
|
|
3341
|
+
blocking,
|
|
3342
|
+
terminated
|
|
3343
|
+
} = {}) {
|
|
3344
|
+
const request = indexedDB.open(name, version);
|
|
3345
|
+
const openPromise = wrap(request);
|
|
3346
|
+
if (upgrade) {
|
|
3347
|
+
request.addEventListener('upgradeneeded', event => {
|
|
3348
|
+
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
if (blocked) {
|
|
3352
|
+
request.addEventListener('blocked', event => blocked(
|
|
3353
|
+
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
3354
|
+
event.oldVersion, event.newVersion, event));
|
|
3355
|
+
}
|
|
3356
|
+
openPromise.then(db => {
|
|
3357
|
+
if (terminated) db.addEventListener('close', () => terminated());
|
|
3358
|
+
if (blocking) {
|
|
3359
|
+
db.addEventListener('versionchange', event => blocking(event.oldVersion, event.newVersion, event));
|
|
3360
|
+
}
|
|
3361
|
+
}).catch(() => {});
|
|
3362
|
+
return openPromise;
|
|
3363
|
+
}
|
|
3364
|
+
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
|
3365
|
+
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
|
3366
|
+
const cachedMethods = new Map();
|
|
3367
|
+
function getMethod(target, prop) {
|
|
3368
|
+
if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === 'string')) {
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
if (cachedMethods.get(prop)) return cachedMethods.get(prop);
|
|
3372
|
+
const targetFuncName = prop.replace(/FromIndex$/, '');
|
|
3373
|
+
const useIndex = prop !== targetFuncName;
|
|
3374
|
+
const isWrite = writeMethods.includes(targetFuncName);
|
|
3375
|
+
if (
|
|
3376
|
+
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
3377
|
+
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || readMethods.includes(targetFuncName))) {
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
const method = async function (storeName, ...args) {
|
|
3381
|
+
// isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
|
|
3382
|
+
const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
|
|
3383
|
+
let target = tx.store;
|
|
3384
|
+
if (useIndex) target = target.index(args.shift());
|
|
3385
|
+
// Must reject if op rejects.
|
|
3386
|
+
// If it's a write operation, must reject if tx.done rejects.
|
|
3387
|
+
// Must reject with op rejection first.
|
|
3388
|
+
// Must resolve with op value.
|
|
3389
|
+
// Must handle both promises (no unhandled rejections)
|
|
3390
|
+
return (await Promise.all([target[targetFuncName](...args), isWrite && tx.done]))[0];
|
|
3391
|
+
};
|
|
3392
|
+
cachedMethods.set(prop, method);
|
|
3393
|
+
return method;
|
|
3394
|
+
}
|
|
3395
|
+
replaceTraps(oldTraps => ({
|
|
3396
|
+
...oldTraps,
|
|
3397
|
+
get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
|
|
3398
|
+
has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop)
|
|
3399
|
+
}));
|
|
3400
|
+
const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];
|
|
3401
|
+
const methodMap = {};
|
|
3402
|
+
const advanceResults = new WeakMap();
|
|
3403
|
+
const ittrProxiedCursorToOriginalProxy = new WeakMap();
|
|
3404
|
+
const cursorIteratorTraps = {
|
|
3405
|
+
get(target, prop) {
|
|
3406
|
+
if (!advanceMethodProps.includes(prop)) return target[prop];
|
|
3407
|
+
let cachedFunc = methodMap[prop];
|
|
3408
|
+
if (!cachedFunc) {
|
|
3409
|
+
cachedFunc = methodMap[prop] = function (...args) {
|
|
3410
|
+
advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));
|
|
3411
|
+
};
|
|
3412
|
+
}
|
|
3413
|
+
return cachedFunc;
|
|
3414
|
+
}
|
|
3415
|
+
};
|
|
3416
|
+
async function* iterate(...args) {
|
|
3417
|
+
// tslint:disable-next-line:no-this-assignment
|
|
3418
|
+
let cursor = this;
|
|
3419
|
+
if (!(cursor instanceof IDBCursor)) {
|
|
3420
|
+
cursor = await cursor.openCursor(...args);
|
|
3421
|
+
}
|
|
3422
|
+
if (!cursor) return;
|
|
3423
|
+
cursor = cursor;
|
|
3424
|
+
const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);
|
|
3425
|
+
ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);
|
|
3426
|
+
// Map this double-proxy back to the original, so other cursor methods work.
|
|
3427
|
+
reverseTransformCache.set(proxiedCursor, unwrap(cursor));
|
|
3428
|
+
while (cursor) {
|
|
3429
|
+
yield proxiedCursor;
|
|
3430
|
+
// If one of the advancing methods was not called, call continue().
|
|
3431
|
+
cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());
|
|
3432
|
+
advanceResults.delete(proxiedCursor);
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
function isIteratorProp(target, prop) {
|
|
3436
|
+
return prop === Symbol.asyncIterator && instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor]) || prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore]);
|
|
3437
|
+
}
|
|
3438
|
+
replaceTraps(oldTraps => ({
|
|
3439
|
+
...oldTraps,
|
|
3440
|
+
get(target, prop, receiver) {
|
|
3441
|
+
if (isIteratorProp(target, prop)) return iterate;
|
|
3442
|
+
return oldTraps.get(target, prop, receiver);
|
|
3443
|
+
},
|
|
3444
|
+
has(target, prop) {
|
|
3445
|
+
return isIteratorProp(target, prop) || oldTraps.has(target, prop);
|
|
3446
|
+
}
|
|
3447
|
+
}));
|
|
3448
|
+
|
|
3449
|
+
const storeId = 'lvce-keyvalue';
|
|
3450
|
+
|
|
3451
|
+
// TODO high memory usage in idb because of transactionDoneMap
|
|
3452
|
+
|
|
3453
|
+
const state$5 = {
|
|
3454
|
+
databases: Object.create(null),
|
|
3455
|
+
dbVersion: 2,
|
|
3456
|
+
cachedDb: undefined
|
|
3457
|
+
};
|
|
3458
|
+
const getDb$1 = async () => {
|
|
3459
|
+
const db = await openDB(storeId, state$5.dbVersion, {
|
|
3460
|
+
async upgrade(db, oldVersion) {
|
|
3461
|
+
if (!db.objectStoreNames.contains(storeId)) {
|
|
3462
|
+
await db.createObjectStore(storeId, {
|
|
3463
|
+
autoIncrement: true
|
|
3464
|
+
});
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
});
|
|
3468
|
+
return db;
|
|
3469
|
+
};
|
|
3470
|
+
const getDbMemoized$1 = async () => {
|
|
3471
|
+
state$5.cachedDb ||= await getDb$1();
|
|
3472
|
+
return state$5.cachedDb;
|
|
3473
|
+
};
|
|
3474
|
+
|
|
3475
|
+
// TODO high memory usage in idb because of transactionDoneMap
|
|
3476
|
+
|
|
3477
|
+
const set$4 = async (key, value) => {
|
|
3478
|
+
try {
|
|
3479
|
+
const db = await getDbMemoized$1();
|
|
3480
|
+
await db.put(storeId, value, key);
|
|
3481
|
+
} catch (error) {
|
|
3482
|
+
throw new VError(error, 'Failed to save value to indexed db');
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
const get$5 = async key => {
|
|
3486
|
+
try {
|
|
3487
|
+
const db = await getDbMemoized$1();
|
|
3488
|
+
const value = await db.get(storeId, key);
|
|
3489
|
+
return value;
|
|
3490
|
+
} catch (error) {
|
|
3491
|
+
throw new VError(error, 'Failed to get value from indexed db');
|
|
3492
|
+
}
|
|
3493
|
+
};
|
|
3494
|
+
|
|
3495
|
+
const getCacheKey$1 = colorThemeId => {
|
|
3496
|
+
return 'color-theme-' + colorThemeId;
|
|
3497
|
+
};
|
|
3498
|
+
const get$4 = colorThemeId => {
|
|
3499
|
+
const cacheKey = getCacheKey$1(colorThemeId);
|
|
3500
|
+
return get$5(cacheKey);
|
|
3501
|
+
};
|
|
3502
|
+
const set$3 = (colorThemeId, data) => {
|
|
3503
|
+
const cacheKey = getCacheKey$1(colorThemeId);
|
|
3504
|
+
return set$4(cacheKey, data);
|
|
3505
|
+
};
|
|
3506
|
+
|
|
3507
|
+
const GetColorThemeCssCachedIndexedDb = {
|
|
3508
|
+
__proto__: null,
|
|
3509
|
+
get: get$4,
|
|
3510
|
+
set: set$3
|
|
3511
|
+
};
|
|
3512
|
+
|
|
3513
|
+
const getText$1 = key => {
|
|
3514
|
+
return invoke$2('LocalStorage.getText', key);
|
|
3515
|
+
};
|
|
3516
|
+
const setText = (key, value) => {
|
|
3517
|
+
return invoke$2('LocalStorage.setText', key, value);
|
|
3518
|
+
};
|
|
3519
|
+
|
|
3520
|
+
const getCacheKey = colorThemeId => {
|
|
3521
|
+
return 'lvce-color-theme-' + colorThemeId;
|
|
3522
|
+
};
|
|
3523
|
+
const get$3 = colorThemeId => {
|
|
3524
|
+
const cacheKey = getCacheKey(colorThemeId);
|
|
3525
|
+
return getText$1(cacheKey);
|
|
3526
|
+
};
|
|
3527
|
+
const set$2 = (colorThemeId, data) => {
|
|
3528
|
+
const cacheKey = getCacheKey(colorThemeId);
|
|
3529
|
+
return setText(cacheKey, data);
|
|
3530
|
+
};
|
|
3531
|
+
|
|
3532
|
+
const GetColorThemeCssCachedLocalStorage = {
|
|
3533
|
+
__proto__: null,
|
|
3534
|
+
get: get$3,
|
|
3535
|
+
set: set$2
|
|
3536
|
+
};
|
|
3537
|
+
|
|
3538
|
+
const get$2 = colorThemeId => {
|
|
3539
|
+
return '';
|
|
3540
|
+
};
|
|
3541
|
+
const set$1 = (colorThemeId, data) => {
|
|
3542
|
+
// noop
|
|
3543
|
+
};
|
|
3544
|
+
|
|
3545
|
+
const GetColorThemeCssCachedNoop = {
|
|
3546
|
+
__proto__: null,
|
|
3547
|
+
get: get$2,
|
|
3548
|
+
set: set$1
|
|
3549
|
+
};
|
|
3550
|
+
|
|
3551
|
+
const get$1 = key => {
|
|
3552
|
+
return invoke$2('Preferences.get', key);
|
|
3553
|
+
};
|
|
3554
|
+
|
|
3555
|
+
const getCacheFn = config => {
|
|
3556
|
+
switch (config) {
|
|
3557
|
+
case 'localStorage':
|
|
3558
|
+
return GetColorThemeCssCachedLocalStorage;
|
|
3559
|
+
case 'indexedDb':
|
|
3560
|
+
return GetColorThemeCssCachedIndexedDb;
|
|
3561
|
+
default:
|
|
3562
|
+
return GetColorThemeCssCachedNoop;
|
|
3563
|
+
}
|
|
3564
|
+
};
|
|
3565
|
+
const getColorThemeCssCached = async (colorThemeId, getData) => {
|
|
3566
|
+
const config = await get$1('colorTheme.cache');
|
|
3567
|
+
const module = await getCacheFn(config);
|
|
3568
|
+
const cachedData = await module.get(colorThemeId);
|
|
3569
|
+
if (cachedData) {
|
|
3570
|
+
return cachedData;
|
|
3571
|
+
}
|
|
3572
|
+
const newData = await getData(colorThemeId);
|
|
3573
|
+
await module.set(colorThemeId, newData);
|
|
3574
|
+
return newData;
|
|
3575
|
+
};
|
|
3576
|
+
|
|
3577
|
+
const getColorThemeJson$2 = colorThemeId => {
|
|
3578
|
+
return invoke$2(/* ExtensionHost.getColorThemeJson */'ExtensionHost.getColorThemeJson', /* colorThemeId */colorThemeId);
|
|
3579
|
+
};
|
|
3580
|
+
|
|
3581
|
+
const getAssetDir = () => {
|
|
3582
|
+
// @ts-ignore
|
|
3583
|
+
if (typeof ASSET_DIR !== 'undefined') {
|
|
3584
|
+
// @ts-ignore
|
|
3585
|
+
return ASSET_DIR;
|
|
3586
|
+
}
|
|
3587
|
+
if (platform === Electron) {
|
|
3588
|
+
return '../../../../..';
|
|
3589
|
+
}
|
|
3590
|
+
return '';
|
|
3591
|
+
};
|
|
3592
|
+
const assetDir = getAssetDir();
|
|
3593
|
+
|
|
3594
|
+
const getJson = async url => {
|
|
3595
|
+
try {
|
|
3596
|
+
const response = await fetch(url);
|
|
3597
|
+
if (!response.ok) {
|
|
3598
|
+
throw new Error(response.statusText);
|
|
3599
|
+
}
|
|
3600
|
+
const json = await response.json();
|
|
3601
|
+
return json;
|
|
3602
|
+
} catch (error) {
|
|
3603
|
+
throw new VError(error, `Failed to get json`);
|
|
3604
|
+
}
|
|
3605
|
+
};
|
|
3606
|
+
|
|
3607
|
+
const getColorThemeUrlWeb = colorThemeId => {
|
|
3608
|
+
return `${assetDir}/extensions/builtin.theme-${colorThemeId}/color-theme.json`;
|
|
3609
|
+
};
|
|
3610
|
+
const getColorThemeJson$1 = colorThemeId => {
|
|
3611
|
+
const url = getColorThemeUrlWeb(colorThemeId);
|
|
3612
|
+
// TODO handle error ?
|
|
3613
|
+
return getJson(url);
|
|
3614
|
+
};
|
|
3615
|
+
|
|
3616
|
+
const getColorThemeJson = colorThemeId => {
|
|
3617
|
+
if (platform === Web) {
|
|
3618
|
+
return getColorThemeJson$1(colorThemeId);
|
|
3619
|
+
}
|
|
3620
|
+
return getColorThemeJson$2(colorThemeId);
|
|
3621
|
+
};
|
|
3622
|
+
|
|
3623
|
+
const getColorThemeCssFromJson = async (colorThemeId, colorThemeJson) => {
|
|
3624
|
+
const colorThemeCss = createColorThemeFromJson(/* colorThemeId */colorThemeId, /* colorThemeJson */colorThemeJson);
|
|
3625
|
+
return colorThemeCss;
|
|
3626
|
+
// TODO generate color theme from jsonc
|
|
3627
|
+
};
|
|
3628
|
+
const getColorThemeCssNew = async colorThemeId => {
|
|
3629
|
+
const colorThemeJson = await getColorThemeJson(colorThemeId);
|
|
3630
|
+
const colorThemeCss = await getColorThemeCssFromJson(colorThemeId, colorThemeJson);
|
|
3631
|
+
return colorThemeCss;
|
|
3632
|
+
};
|
|
3633
|
+
const getColorThemeCss = colorThemeId => {
|
|
3634
|
+
return getColorThemeCssCached(colorThemeId, getColorThemeCssNew);
|
|
3635
|
+
};
|
|
3636
|
+
|
|
3637
|
+
const getMetaThemeColor = colorThemeJson => {
|
|
3638
|
+
return colorThemeJson && colorThemeJson.colors && colorThemeJson.colors.TitleBarBackground;
|
|
3639
|
+
};
|
|
3640
|
+
|
|
3641
|
+
const setThemeColor = async themeColor => {
|
|
3642
|
+
await invoke$2(/* Meta.setThemeColor */'Meta.setThemeColor', /* color */themeColor);
|
|
3643
|
+
};
|
|
3644
|
+
|
|
3645
|
+
// TODO by default color theme should come from local storage, session storage, cache storage, indexeddb or blob url -> fast initial load
|
|
3646
|
+
// actual color theme can be computed after workbench has loaded (most times will be the same and doesn't need to be computed)
|
|
3647
|
+
|
|
3648
|
+
const state$4 = {
|
|
3649
|
+
watchedTheme: ''
|
|
3650
|
+
};
|
|
3651
|
+
const FALLBACK_COLOR_THEME_ID = 'slime';
|
|
3652
|
+
|
|
3653
|
+
// TODO json parsing should also happen in renderer worker
|
|
3654
|
+
// so that all validation is here (json parsing errors, invalid shape, ...)
|
|
3655
|
+
|
|
3656
|
+
const applyColorTheme = async colorThemeId => {
|
|
3657
|
+
try {
|
|
3658
|
+
string(colorThemeId);
|
|
3659
|
+
state$4.colorTheme = colorThemeId;
|
|
3660
|
+
const colorThemeCss = await getColorThemeCss(colorThemeId);
|
|
3661
|
+
await addCssStyleSheet('ContributedColorTheme', colorThemeCss);
|
|
3662
|
+
if (platform === Web) {
|
|
3663
|
+
const themeColor = getMetaThemeColor(colorThemeId) || '';
|
|
3664
|
+
await setThemeColor(themeColor);
|
|
3665
|
+
}
|
|
3666
|
+
if (platform !== Web && (await get$1('development.watchColorTheme'))) {
|
|
3667
|
+
watch(colorThemeId);
|
|
3668
|
+
}
|
|
3669
|
+
} catch (error) {
|
|
3670
|
+
throw new VError(error, `Failed to apply color theme "${colorThemeId}"`);
|
|
3671
|
+
}
|
|
3672
|
+
};
|
|
3673
|
+
const watch = async id => {
|
|
3674
|
+
if (state$4.watchedTheme === id) {
|
|
3675
|
+
return;
|
|
3676
|
+
}
|
|
3677
|
+
state$4.watchedTheme = id;
|
|
3678
|
+
await invoke$2('ExtensionHost.watchColorTheme', id);
|
|
3679
|
+
};
|
|
3680
|
+
const getPreferredColorTheme = () => {
|
|
3681
|
+
const preferredColorTheme = get$1('workbench.colorTheme');
|
|
3682
|
+
return preferredColorTheme;
|
|
3683
|
+
};
|
|
3684
|
+
|
|
3685
|
+
// TODO test this, and also the error case
|
|
3686
|
+
// TODO have icon theme, color theme together (maybe)
|
|
3687
|
+
const hydrate$1 = async () => {
|
|
3688
|
+
const preferredColorTheme = await getPreferredColorTheme();
|
|
3689
|
+
const colorThemeId = preferredColorTheme || FALLBACK_COLOR_THEME_ID;
|
|
3690
|
+
try {
|
|
3691
|
+
await applyColorTheme(colorThemeId);
|
|
3692
|
+
} catch (error) {
|
|
3693
|
+
if (colorThemeId === FALLBACK_COLOR_THEME_ID) {
|
|
3694
|
+
throw error;
|
|
3695
|
+
}
|
|
3696
|
+
console.error(error);
|
|
3697
|
+
await applyColorTheme(FALLBACK_COLOR_THEME_ID);
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3701
|
+
const iframeWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/iframe-worker/dist/iframeWorkerMain.js`;
|
|
3702
|
+
|
|
3703
|
+
const getConfiguredIframeWorkerUrl = async () => {
|
|
3704
|
+
let configuredWorkerUrl = (await get$1('develop.iframeWorkerPath')) || '';
|
|
3705
|
+
if (configuredWorkerUrl) {
|
|
3706
|
+
configuredWorkerUrl = '/remote' + configuredWorkerUrl;
|
|
3707
|
+
}
|
|
3708
|
+
configuredWorkerUrl = configuredWorkerUrl || iframeWorkerUrl;
|
|
3709
|
+
return configuredWorkerUrl;
|
|
3710
|
+
};
|
|
3711
|
+
|
|
3712
|
+
const state$3 = {
|
|
3713
|
+
id: 0
|
|
3714
|
+
};
|
|
3715
|
+
const create$1 = () => {
|
|
3716
|
+
return ++state$3.id;
|
|
3717
|
+
};
|
|
3718
|
+
|
|
3719
|
+
const commandMap$1 = {
|
|
3720
|
+
'WebView.compatExtensionHostWorkerInvoke': (...args) => invoke$2('WebView.compatExtensionHostWorkerInvoke', ...args),
|
|
3721
|
+
'WebView.compatExtensionHostWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatExtensionHostWorkerInvokeAndTransfer', ...args),
|
|
3722
|
+
'WebView.compatRendererProcessInvoke': (...args) => invoke$2('WebView.compatRendererProcessInvoke', ...args),
|
|
3723
|
+
'WebView.compatRendererProcessInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatRendererProcessInvokeAndTransfer', ...args),
|
|
3724
|
+
// @ts-ignore
|
|
3725
|
+
'WebView.compatRendererWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1(...args),
|
|
3726
|
+
// @ts-ignore
|
|
3727
|
+
'WebView.compatRendererWorkerInvoke': (...args) => invoke$2(...args),
|
|
3728
|
+
'WebView.compatSharedProcessInvoke': (...args) => invoke$2('WebView.compatSharedProcessInvoke', ...args),
|
|
3729
|
+
'WebView.getSavedState': (...args) => invoke$2('WebView.getSavedState', ...args),
|
|
3730
|
+
'WebView.getWebViewInfo': (...args) => invoke$2('WebView.getWebViewInfo', ...args),
|
|
3731
|
+
'WebView.getWebViews': (...args) => invoke$2('WebView.getWebViews', ...args),
|
|
3732
|
+
'WebView.setPort': (...args) => invoke$2('WebView.setPort', ...args),
|
|
3733
|
+
'ExtensionHostManagement.activateByEvent': (...args) => invoke$2('ExtensionHostManagement.activateByEvent', ...args),
|
|
3734
|
+
'WebView.getRemoteUrl': options => getRemoteUrlForWebView(options.uri, options)
|
|
3735
|
+
};
|
|
3736
|
+
const launchIframeWorker = async () => {
|
|
3737
|
+
const configuredWorkerUrl = await getConfiguredIframeWorkerUrl();
|
|
3738
|
+
const name = 'Iframe Worker';
|
|
3739
|
+
const id = create$1();
|
|
3740
|
+
const rpc = await create$2({
|
|
3741
|
+
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
3742
|
+
name,
|
|
3743
|
+
url: configuredWorkerUrl,
|
|
3744
|
+
id,
|
|
3745
|
+
commandMap: commandMap$1
|
|
3746
|
+
});
|
|
3747
|
+
return rpc;
|
|
3748
|
+
};
|
|
3749
|
+
|
|
3750
|
+
let workerPromise;
|
|
3751
|
+
const ensureWorker = () => {
|
|
3752
|
+
if (!workerPromise) {
|
|
3753
|
+
workerPromise = launchIframeWorker();
|
|
3754
|
+
}
|
|
3755
|
+
return workerPromise;
|
|
3756
|
+
};
|
|
3757
|
+
const invoke = async (method, ...params) => {
|
|
3758
|
+
const rpc = await ensureWorker();
|
|
3759
|
+
return rpc.invoke(method, ...params);
|
|
3760
|
+
};
|
|
3761
|
+
|
|
3762
|
+
const createWebView3 = async ({
|
|
3763
|
+
id,
|
|
3764
|
+
uri,
|
|
3765
|
+
isGitpod,
|
|
3766
|
+
platform,
|
|
3767
|
+
assetDir,
|
|
3768
|
+
webViewScheme,
|
|
3769
|
+
useNewWebViewHandler
|
|
3770
|
+
}) => {
|
|
3771
|
+
await invoke('WebView.create3', {
|
|
3772
|
+
id,
|
|
3773
|
+
uri,
|
|
3774
|
+
isGitpod,
|
|
3775
|
+
platform,
|
|
3776
|
+
assetDir,
|
|
3777
|
+
webViewScheme,
|
|
3778
|
+
useNewWebViewHandler
|
|
3779
|
+
});
|
|
3780
|
+
};
|
|
3781
|
+
|
|
3782
|
+
const createWebViewWorkerRpc = async (rpcInfo, port) => {
|
|
3783
|
+
// TODO this function is called from the iframe worker to create a direct
|
|
3784
|
+
// connection between a webview/iframe and it's webworker. For this to work
|
|
3785
|
+
// the iframe worker creates a messagechannel and sends one messageport to the webview
|
|
3786
|
+
// and the other messageport to the webworker. This enables direct communication via
|
|
3787
|
+
// the two message ports
|
|
3788
|
+
|
|
3789
|
+
// TODO have a way so that the worker already includes the webview api and the extension
|
|
3790
|
+
// host subworker doesn't need to import the other file
|
|
3791
|
+
await invokeAndTransfer$1('IpcParent.create', {
|
|
3792
|
+
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
3793
|
+
url: extensionHostSubWorkerUrl,
|
|
3794
|
+
name: rpcInfo.name,
|
|
3795
|
+
raw: true,
|
|
3796
|
+
port
|
|
3797
|
+
});
|
|
3798
|
+
};
|
|
3799
|
+
|
|
3800
|
+
const BraceCompletionExecuteBraceCompletionProvider = 'ExtensionHostBraceCompletion.executeBraceCompletionProvider';
|
|
3801
|
+
const ClosingTagExecuteClosingTagProvider = 'ExtensionHostClosingTag.executeClosingTagProvider';
|
|
3802
|
+
const CommandExecute = 'ExtensionHostCommand.executeCommand';
|
|
3803
|
+
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
3804
|
+
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
3805
|
+
const DefinitionExecuteDefinitionProvider = 'ExtensionHostDefinition.executeDefinitionProvider';
|
|
3806
|
+
const DiagnosticExecuteDiagnosticProvider = 'ExtensionHost.executeDiagnosticProvider';
|
|
3807
|
+
const ExtensionActivate = 'ExtensionHostExtension.activate';
|
|
3808
|
+
const FileSystemGetPathSeparator = 'ExtensionHostFileSystem.getPathSeparator';
|
|
3809
|
+
const FileSystemReadDirWithFileTypes = 'ExtensionHostFileSystem.readDirWithFileTypes';
|
|
3810
|
+
const FileSystemReadFile = 'ExtensionHostFileSystem.readFile';
|
|
3811
|
+
const FileSystemWriteFile = 'ExtensionHostFileSystem.writeFile';
|
|
3812
|
+
const FormattingExecuteFormmattingProvider = 'ExtensionHostFormatting.executeFormattingProvider';
|
|
3813
|
+
const HoverExecute = 'ExtensionHostHover.execute';
|
|
3814
|
+
const ImplementationExecuteImplementationProvider = 'ExtensionHostImplementation.executeImplementationProvider';
|
|
3815
|
+
const MockExec = 'ExtensionHostMockExec.mockExec';
|
|
3816
|
+
const MockRpc = 'ExtensionHostMockRpc.mockRpc';
|
|
3817
|
+
const OrganizeImportsExecute = 'ExtensionHostOrganizeImports.execute';
|
|
3818
|
+
const ReferenceExecuteFileReferenceProvider = 'ExtensionHostReference.executeFileReferenceProvider';
|
|
3819
|
+
const ReferenceExecuteReferenceProvider = 'ExtensionHostReference.executeReferenceProvider';
|
|
3820
|
+
const SourceControlAcceptInput = 'ExtensionHostSourceControl.acceptInput';
|
|
3821
|
+
const SourceControlAdd = 'ExtensionHostSourceControl.add';
|
|
3822
|
+
const SourceControlDiscard = 'ExtensionHostSourceControl.discard';
|
|
3823
|
+
const SourceControlGetChangedFiles = 'ExtensionHost.sourceControlGetChangedFiles';
|
|
3824
|
+
const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
|
|
3825
|
+
const SourceControlGetFileBefore = 'ExtensionHostSourceControl.GetFileBefore';
|
|
3826
|
+
const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
|
|
3827
|
+
const StatusBarGetStatusBarItems = 'ExtensionHost.getStatusBarItems';
|
|
3828
|
+
const StatusBarRegisterChangeListener = 'ExtensionHostStatusBar.registerChangeListener';
|
|
3829
|
+
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
3830
|
+
const TextDocumentSetLanguageId = 'ExtensionHostTextDocument.setLanguageId';
|
|
3831
|
+
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
3832
|
+
const TextDocumentSyncIncremental = 'ExtensionHostTextDocument.syncIncremental';
|
|
3833
|
+
const TextSearchExecuteTextSearchProvider = 'ExtensionHostTextSearch.executeTextSearchProvider';
|
|
3834
|
+
const TypeDefinitionExecuteTypeDefinitionProvider = 'ExtensionHostTypeDefinition.executeTypeDefinitionProvider';
|
|
3835
|
+
const WorkspaceSetPath = 'Workspace.setWorkspacePath';
|
|
3836
|
+
const SelectionExecuteSelectionProvider = 'ExtensionHostSelection.executeSelectionProvider';
|
|
3837
|
+
const ConfigurationSetConfiguration = 'ExtensionHostConfiguration.setConfiguration';
|
|
3838
|
+
|
|
3839
|
+
const create = () => {
|
|
3840
|
+
return {
|
|
3841
|
+
finished: false
|
|
3842
|
+
};
|
|
3843
|
+
};
|
|
3844
|
+
const cancel = token => {
|
|
3845
|
+
token.finished = true;
|
|
3846
|
+
};
|
|
3847
|
+
const isCanceled = token => {
|
|
3848
|
+
return token.finished;
|
|
3849
|
+
};
|
|
3850
|
+
|
|
3851
|
+
const baseName = path => {
|
|
3852
|
+
const slashIndex = path.lastIndexOf('/');
|
|
3853
|
+
return path.slice(slashIndex + 1);
|
|
3854
|
+
};
|
|
3855
|
+
const getExtensionId = extension => {
|
|
3856
|
+
if (extension && extension.id) {
|
|
3857
|
+
return extension.id;
|
|
3858
|
+
}
|
|
3859
|
+
if (extension && extension.path) {
|
|
3860
|
+
return baseName(extension.path);
|
|
3861
|
+
}
|
|
3862
|
+
return '<unknown>';
|
|
3863
|
+
};
|
|
3864
|
+
|
|
3865
|
+
const getUrlPrefix = (platform, extensionPath) => {
|
|
3866
|
+
if (extensionPath.startsWith('http://') || extensionPath.startsWith('https://')) {
|
|
3867
|
+
return extensionPath;
|
|
3868
|
+
}
|
|
3869
|
+
if (platform === Web) {
|
|
3870
|
+
return extensionPath;
|
|
3871
|
+
}
|
|
3872
|
+
if (extensionPath.startsWith('/')) {
|
|
3873
|
+
return `/remote${extensionPath}`;
|
|
3874
|
+
}
|
|
3875
|
+
return `/remote/${extensionPath}`;
|
|
3876
|
+
};
|
|
3877
|
+
|
|
3878
|
+
const handleRpcInfos = extension => {
|
|
3879
|
+
try {
|
|
3880
|
+
if (!extension) {
|
|
3881
|
+
return;
|
|
3882
|
+
}
|
|
3883
|
+
const rpcs = extension.rpc;
|
|
3884
|
+
const urlPrefix = getUrlPrefix(platform, extension.path);
|
|
3885
|
+
if (!rpcs) {
|
|
3886
|
+
return;
|
|
3887
|
+
}
|
|
3888
|
+
if (!Array.isArray(rpcs)) {
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
for (const rpc of rpcs) {
|
|
3892
|
+
rpc.url = `${urlPrefix}/${rpc.url}`;
|
|
3893
|
+
add$1(rpc.id, rpc);
|
|
3894
|
+
}
|
|
3895
|
+
} catch (error) {
|
|
3896
|
+
console.warn(`Failed to handle extension rpcs: ${error}`);
|
|
3897
|
+
}
|
|
3898
|
+
};
|
|
3899
|
+
|
|
3900
|
+
class ContentSecurityPolicyError extends Error {
|
|
3901
|
+
constructor(violatedDirective, sourceFile, lineNumber, columnNumber) {
|
|
3902
|
+
super(`Content Security Policy Violation: ${violatedDirective}`);
|
|
3903
|
+
this.name = 'ContentSecurityPolicyError';
|
|
3904
|
+
if (sourceFile) {
|
|
3905
|
+
this.stack = `Content Security Policy Violation
|
|
3906
|
+
at ${sourceFile}:${lineNumber}:${columnNumber}`;
|
|
3907
|
+
} else {
|
|
3908
|
+
this.stack = `Content Security Policy Violation
|
|
3909
|
+
at <unknown>`;
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3317
3914
|
const isImportErrorChrome = error => {
|
|
3318
3915
|
return error && error instanceof Error && error.message.startsWith('Failed to fetch dynamically imported module');
|
|
3319
3916
|
};
|
|
@@ -3724,7 +4321,7 @@ const mockRpc = () => {
|
|
|
3724
4321
|
};
|
|
3725
4322
|
|
|
3726
4323
|
const getStatusBarItems = async () => {
|
|
3727
|
-
const providers = Object.values(state$
|
|
4324
|
+
const providers = Object.values(state$9.providers);
|
|
3728
4325
|
const statusBarItems = [];
|
|
3729
4326
|
for (const provider of providers) {
|
|
3730
4327
|
// @ts-ignore
|
|
@@ -3757,19 +4354,6 @@ const getBlob$2 = async url => {
|
|
|
3757
4354
|
}
|
|
3758
4355
|
};
|
|
3759
4356
|
|
|
3760
|
-
const getJson = async url => {
|
|
3761
|
-
try {
|
|
3762
|
-
const response = await fetch(url);
|
|
3763
|
-
if (!response.ok) {
|
|
3764
|
-
throw new Error(response.statusText);
|
|
3765
|
-
}
|
|
3766
|
-
const json = await response.json();
|
|
3767
|
-
return json;
|
|
3768
|
-
} catch (error) {
|
|
3769
|
-
throw new VError(error, `Failed to get json`);
|
|
3770
|
-
}
|
|
3771
|
-
};
|
|
3772
|
-
|
|
3773
4357
|
const getText = async url => {
|
|
3774
4358
|
try {
|
|
3775
4359
|
const response = await fetch(url);
|
|
@@ -4022,7 +4606,7 @@ const getFiles = () => {
|
|
|
4022
4606
|
};
|
|
4023
4607
|
|
|
4024
4608
|
const getRpcInfo = rpcId => {
|
|
4025
|
-
const info = get$
|
|
4609
|
+
const info = get$7(rpcId);
|
|
4026
4610
|
if (!info) {
|
|
4027
4611
|
throw new Error(`Rpc not found ${rpcId}`);
|
|
4028
4612
|
}
|
|
@@ -4042,261 +4626,164 @@ const handleMessagePort = async port => {
|
|
|
4042
4626
|
});
|
|
4043
4627
|
};
|
|
4044
4628
|
|
|
4045
|
-
const
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
return
|
|
4051
|
-
}
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
const
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
request.removeEventListener('error', error);
|
|
4064
|
-
};
|
|
4065
|
-
const success = () => {
|
|
4066
|
-
resolve(wrap(request.result));
|
|
4067
|
-
unlisten();
|
|
4068
|
-
};
|
|
4069
|
-
const error = () => {
|
|
4070
|
-
reject(request.error);
|
|
4071
|
-
unlisten();
|
|
4072
|
-
};
|
|
4073
|
-
request.addEventListener('success', success);
|
|
4074
|
-
request.addEventListener('error', error);
|
|
4075
|
-
});
|
|
4076
|
-
// This mapping exists in reverseTransformCache but doesn't exist in transformCache. This
|
|
4077
|
-
// is because we create many promises from a single IDBRequest.
|
|
4078
|
-
reverseTransformCache.set(promise, request);
|
|
4079
|
-
return promise;
|
|
4080
|
-
}
|
|
4081
|
-
function cacheDonePromiseForTransaction(tx) {
|
|
4082
|
-
// Early bail if we've already created a done promise for this transaction.
|
|
4083
|
-
if (transactionDoneMap.has(tx)) return;
|
|
4084
|
-
const done = new Promise((resolve, reject) => {
|
|
4085
|
-
const unlisten = () => {
|
|
4086
|
-
tx.removeEventListener('complete', complete);
|
|
4087
|
-
tx.removeEventListener('error', error);
|
|
4088
|
-
tx.removeEventListener('abort', error);
|
|
4089
|
-
};
|
|
4090
|
-
const complete = () => {
|
|
4091
|
-
resolve();
|
|
4092
|
-
unlisten();
|
|
4093
|
-
};
|
|
4094
|
-
const error = () => {
|
|
4095
|
-
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
|
4096
|
-
unlisten();
|
|
4097
|
-
};
|
|
4098
|
-
tx.addEventListener('complete', complete);
|
|
4099
|
-
tx.addEventListener('error', error);
|
|
4100
|
-
tx.addEventListener('abort', error);
|
|
4101
|
-
});
|
|
4102
|
-
// Cache it for later retrieval.
|
|
4103
|
-
transactionDoneMap.set(tx, done);
|
|
4104
|
-
}
|
|
4105
|
-
let idbProxyTraps = {
|
|
4106
|
-
get(target, prop, receiver) {
|
|
4107
|
-
if (target instanceof IDBTransaction) {
|
|
4108
|
-
// Special handling for transaction.done.
|
|
4109
|
-
if (prop === 'done') return transactionDoneMap.get(target);
|
|
4110
|
-
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
4111
|
-
if (prop === 'store') {
|
|
4112
|
-
return receiver.objectStoreNames[1] ? undefined : receiver.objectStore(receiver.objectStoreNames[0]);
|
|
4629
|
+
const state$1 = {
|
|
4630
|
+
webExtensions: []
|
|
4631
|
+
};
|
|
4632
|
+
|
|
4633
|
+
const readJson = url => {
|
|
4634
|
+
return invoke$2('FileSystem.readJson', url);
|
|
4635
|
+
};
|
|
4636
|
+
|
|
4637
|
+
const findMatchingIconThemeExtension = (extensions, iconThemeId) => {
|
|
4638
|
+
for (const extension of extensions) {
|
|
4639
|
+
if (extension && extension.iconThemes) {
|
|
4640
|
+
for (const iconTheme of extension.iconThemes) {
|
|
4641
|
+
if (iconTheme.id === iconThemeId) {
|
|
4642
|
+
return {
|
|
4643
|
+
...iconTheme,
|
|
4644
|
+
extensionPath: extension.path
|
|
4645
|
+
};
|
|
4646
|
+
}
|
|
4113
4647
|
}
|
|
4114
4648
|
}
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4649
|
+
}
|
|
4650
|
+
return undefined;
|
|
4651
|
+
};
|
|
4652
|
+
|
|
4653
|
+
const webExtensionsUrl = `${assetDir}/config/webExtensions.json`;
|
|
4654
|
+
|
|
4655
|
+
const getSharedProcessExtensions$1 = () => {
|
|
4656
|
+
return invoke$2(/* ExtensionManagement.getExtensions */'ExtensionManagement.getExtensions');
|
|
4657
|
+
};
|
|
4658
|
+
const getStaticWebExtensions = () => {
|
|
4659
|
+
return getJson(webExtensionsUrl);
|
|
4660
|
+
};
|
|
4661
|
+
const getWebExtensionsWeb = async () => {
|
|
4662
|
+
const staticWebExtensions = await getStaticWebExtensions();
|
|
4663
|
+
return [...staticWebExtensions, ...state$1.webExtensions];
|
|
4664
|
+
};
|
|
4665
|
+
const isWebExtension = extension => {
|
|
4666
|
+
return extension && typeof extension.browser === 'string';
|
|
4667
|
+
};
|
|
4668
|
+
const getWebExtensionsDefault = async () => {
|
|
4669
|
+
const staticWebExtensions = await getStaticWebExtensions();
|
|
4670
|
+
const sharedProcessExtensions = await getSharedProcessExtensions$1();
|
|
4671
|
+
const sharedProcessWebExtensions = sharedProcessExtensions.filter(isWebExtension);
|
|
4672
|
+
return [...staticWebExtensions, sharedProcessWebExtensions, ...state$1.webExtensions];
|
|
4673
|
+
};
|
|
4674
|
+
const getWebExtensions = async () => {
|
|
4675
|
+
try {
|
|
4676
|
+
switch (platform) {
|
|
4677
|
+
case Web:
|
|
4678
|
+
return await getWebExtensionsWeb();
|
|
4679
|
+
default:
|
|
4680
|
+
return await getWebExtensionsDefault();
|
|
4125
4681
|
}
|
|
4126
|
-
|
|
4682
|
+
} catch {
|
|
4683
|
+
return state$1.webExtensions;
|
|
4127
4684
|
}
|
|
4128
4685
|
};
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
4138
|
-
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
|
4139
|
-
// undefined if the end of the cursor has been reached.
|
|
4140
|
-
if (getCursorAdvanceMethods().includes(func)) {
|
|
4141
|
-
return function (...args) {
|
|
4142
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
4143
|
-
// the original object.
|
|
4144
|
-
func.apply(unwrap(this), args);
|
|
4145
|
-
return wrap(this.request);
|
|
4146
|
-
};
|
|
4686
|
+
|
|
4687
|
+
const getSharedProcessExtensions = () => {
|
|
4688
|
+
return invoke$2(/* ExtensionManagement.getExtensions */'ExtensionManagement.getExtensions');
|
|
4689
|
+
};
|
|
4690
|
+
const getExtensions$1 = async () => {
|
|
4691
|
+
if (platform === Web) {
|
|
4692
|
+
const webExtensions = await getWebExtensions();
|
|
4693
|
+
return webExtensions;
|
|
4147
4694
|
}
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
return
|
|
4152
|
-
};
|
|
4153
|
-
}
|
|
4154
|
-
function transformCachableValue(value) {
|
|
4155
|
-
if (typeof value === 'function') return wrapFunction(value);
|
|
4156
|
-
// This doesn't return, it just creates a 'done' promise for the transaction,
|
|
4157
|
-
// which is later returned for transaction.done (see idbObjectHandler).
|
|
4158
|
-
if (value instanceof IDBTransaction) cacheDonePromiseForTransaction(value);
|
|
4159
|
-
if (instanceOfAny(value, getIdbProxyableTypes())) return new Proxy(value, idbProxyTraps);
|
|
4160
|
-
// Return the same value back if we're not going to transform it.
|
|
4161
|
-
return value;
|
|
4162
|
-
}
|
|
4163
|
-
function wrap(value) {
|
|
4164
|
-
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
4165
|
-
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
4166
|
-
if (value instanceof IDBRequest) return promisifyRequest(value);
|
|
4167
|
-
// If we've already transformed this value before, reuse the transformed value.
|
|
4168
|
-
// This is faster, but it also provides object equality.
|
|
4169
|
-
if (transformCache.has(value)) return transformCache.get(value);
|
|
4170
|
-
const newValue = transformCachableValue(value);
|
|
4171
|
-
// Not all types are transformed.
|
|
4172
|
-
// These may be primitive types, so they can't be WeakMap keys.
|
|
4173
|
-
if (newValue !== value) {
|
|
4174
|
-
transformCache.set(value, newValue);
|
|
4175
|
-
reverseTransformCache.set(newValue, value);
|
|
4695
|
+
if (platform === Remote) {
|
|
4696
|
+
const webExtensions = await getWebExtensions();
|
|
4697
|
+
const sharedProcessExtensions = await getSharedProcessExtensions();
|
|
4698
|
+
return [...sharedProcessExtensions, ...webExtensions];
|
|
4176
4699
|
}
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4700
|
+
const extensions = await getSharedProcessExtensions();
|
|
4701
|
+
return extensions;
|
|
4702
|
+
};
|
|
4180
4703
|
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
if (upgrade) {
|
|
4197
|
-
request.addEventListener('upgradeneeded', event => {
|
|
4198
|
-
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
4199
|
-
});
|
|
4704
|
+
const cache = Object.create(null);
|
|
4705
|
+
const id = 1;
|
|
4706
|
+
const get = () => {
|
|
4707
|
+
return cache[id];
|
|
4708
|
+
};
|
|
4709
|
+
const has = () => {
|
|
4710
|
+
return id in cache;
|
|
4711
|
+
};
|
|
4712
|
+
const set = value => {
|
|
4713
|
+
cache[id] = value;
|
|
4714
|
+
};
|
|
4715
|
+
|
|
4716
|
+
const getExtensions = () => {
|
|
4717
|
+
if (!has()) {
|
|
4718
|
+
set(getExtensions$1());
|
|
4200
4719
|
}
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4720
|
+
return get();
|
|
4721
|
+
};
|
|
4722
|
+
|
|
4723
|
+
const getIconThemeUrl = iconThemeId => {
|
|
4724
|
+
return `${assetDir}/extensions/builtin.${iconThemeId}/icon-theme.json`;
|
|
4725
|
+
};
|
|
4726
|
+
|
|
4727
|
+
const getIconThemeJson = async iconThemeId => {
|
|
4728
|
+
if (platform === Web) {
|
|
4729
|
+
const url = getIconThemeUrl(iconThemeId);
|
|
4730
|
+
const json = await getJson(url);
|
|
4731
|
+
return {
|
|
4732
|
+
json,
|
|
4733
|
+
extensionPath: `${assetDir}/extensions/builtin.${iconThemeId}`
|
|
4734
|
+
};
|
|
4205
4735
|
}
|
|
4206
|
-
|
|
4207
|
-
if (
|
|
4208
|
-
|
|
4209
|
-
|
|
4736
|
+
for (const webExtension of state$1.webExtensions) {
|
|
4737
|
+
if (webExtension.iconThemes) {
|
|
4738
|
+
for (const iconTheme of webExtension.iconThemes) {
|
|
4739
|
+
// TODO handle error when icon theme path is not of type string
|
|
4740
|
+
const iconThemeUrl = `${webExtension.path}/${iconTheme.path}`;
|
|
4741
|
+
const json = await getJson(iconThemeUrl);
|
|
4742
|
+
return {
|
|
4743
|
+
json,
|
|
4744
|
+
extensionPath: webExtension.path
|
|
4745
|
+
};
|
|
4746
|
+
}
|
|
4210
4747
|
}
|
|
4211
|
-
}).catch(() => {});
|
|
4212
|
-
return openPromise;
|
|
4213
|
-
}
|
|
4214
|
-
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
|
4215
|
-
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
|
4216
|
-
const cachedMethods = new Map();
|
|
4217
|
-
function getMethod(target, prop) {
|
|
4218
|
-
if (!(target instanceof IDBDatabase && !(prop in target) && typeof prop === 'string')) {
|
|
4219
|
-
return;
|
|
4220
4748
|
}
|
|
4221
|
-
|
|
4222
|
-
const
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
if (
|
|
4226
|
-
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
4227
|
-
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) || !(isWrite || readMethods.includes(targetFuncName))) {
|
|
4228
|
-
return;
|
|
4749
|
+
const extensions = await getExtensions();
|
|
4750
|
+
const iconTheme = findMatchingIconThemeExtension(extensions, iconThemeId);
|
|
4751
|
+
if (!iconTheme) {
|
|
4752
|
+
return undefined;
|
|
4229
4753
|
}
|
|
4230
|
-
const
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
// Must reject if op rejects.
|
|
4236
|
-
// If it's a write operation, must reject if tx.done rejects.
|
|
4237
|
-
// Must reject with op rejection first.
|
|
4238
|
-
// Must resolve with op value.
|
|
4239
|
-
// Must handle both promises (no unhandled rejections)
|
|
4240
|
-
return (await Promise.all([target[targetFuncName](...args), isWrite && tx.done]))[0];
|
|
4754
|
+
const iconThemePath = `${iconTheme.extensionPath}/${iconTheme.path}`;
|
|
4755
|
+
const iconThemeJson = await readJson(iconThemePath);
|
|
4756
|
+
return {
|
|
4757
|
+
extensionPath: iconTheme.extensionPath,
|
|
4758
|
+
json: iconThemeJson
|
|
4241
4759
|
};
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
}
|
|
4250
|
-
|
|
4251
|
-
const
|
|
4252
|
-
|
|
4253
|
-
const
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
if (!advanceMethodProps.includes(prop)) return target[prop];
|
|
4257
|
-
let cachedFunc = methodMap[prop];
|
|
4258
|
-
if (!cachedFunc) {
|
|
4259
|
-
cachedFunc = methodMap[prop] = function (...args) {
|
|
4260
|
-
advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));
|
|
4261
|
-
};
|
|
4760
|
+
};
|
|
4761
|
+
|
|
4762
|
+
const handleIconThemeChange = async () => {
|
|
4763
|
+
await invoke$2('IconTheme.handleIconThemeChange');
|
|
4764
|
+
};
|
|
4765
|
+
|
|
4766
|
+
const setTheme = iconTheme => {
|
|
4767
|
+
};
|
|
4768
|
+
|
|
4769
|
+
const setIconTheme = async iconThemeId => {
|
|
4770
|
+
try {
|
|
4771
|
+
const iconTheme = await getIconThemeJson(iconThemeId);
|
|
4772
|
+
if (!iconTheme) {
|
|
4773
|
+
return;
|
|
4262
4774
|
}
|
|
4263
|
-
|
|
4775
|
+
setTheme(iconTheme);
|
|
4776
|
+
await handleIconThemeChange();
|
|
4777
|
+
} catch (error) {
|
|
4778
|
+
console.error(new VError(error, 'Failed to load icon theme'));
|
|
4264
4779
|
}
|
|
4265
4780
|
};
|
|
4266
|
-
async
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
cursor = await cursor.openCursor(...args);
|
|
4271
|
-
}
|
|
4272
|
-
if (!cursor) return;
|
|
4273
|
-
cursor = cursor;
|
|
4274
|
-
const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);
|
|
4275
|
-
ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);
|
|
4276
|
-
// Map this double-proxy back to the original, so other cursor methods work.
|
|
4277
|
-
reverseTransformCache.set(proxiedCursor, unwrap(cursor));
|
|
4278
|
-
while (cursor) {
|
|
4279
|
-
yield proxiedCursor;
|
|
4280
|
-
// If one of the advancing methods was not called, call continue().
|
|
4281
|
-
cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());
|
|
4282
|
-
advanceResults.delete(proxiedCursor);
|
|
4283
|
-
}
|
|
4284
|
-
}
|
|
4285
|
-
function isIteratorProp(target, prop) {
|
|
4286
|
-
return prop === Symbol.asyncIterator && instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor]) || prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore]);
|
|
4287
|
-
}
|
|
4288
|
-
replaceTraps(oldTraps => ({
|
|
4289
|
-
...oldTraps,
|
|
4290
|
-
get(target, prop, receiver) {
|
|
4291
|
-
if (isIteratorProp(target, prop)) return iterate;
|
|
4292
|
-
return oldTraps.get(target, prop, receiver);
|
|
4293
|
-
},
|
|
4294
|
-
has(target, prop) {
|
|
4295
|
-
return isIteratorProp(target, prop) || oldTraps.has(target, prop);
|
|
4296
|
-
}
|
|
4297
|
-
}));
|
|
4781
|
+
const hydrate = async () => {
|
|
4782
|
+
const iconThemeId = (await get$1('icon-theme')) || 'vscode-icons';
|
|
4783
|
+
await setIconTheme(iconThemeId);
|
|
4784
|
+
};
|
|
4298
4785
|
|
|
4299
|
-
const state
|
|
4786
|
+
const state = {
|
|
4300
4787
|
databases: Object.create(null),
|
|
4301
4788
|
eventId: 0,
|
|
4302
4789
|
dbVersion: 1,
|
|
@@ -4312,9 +4799,9 @@ const isDataCloneError = error => {
|
|
|
4312
4799
|
|
|
4313
4800
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
4314
4801
|
|
|
4315
|
-
const getDb
|
|
4802
|
+
const getDb = async () => {
|
|
4316
4803
|
// @ts-ignore
|
|
4317
|
-
const db = await openDB('session', state
|
|
4804
|
+
const db = await openDB('session', state.dbVersion, {
|
|
4318
4805
|
async upgrade(db, oldVersion) {
|
|
4319
4806
|
if (!db.objectStoreNames.contains('session')) {
|
|
4320
4807
|
const objectStore = await db.createObjectStore('session', {
|
|
@@ -4328,13 +4815,13 @@ const getDb$1 = async () => {
|
|
|
4328
4815
|
});
|
|
4329
4816
|
return db;
|
|
4330
4817
|
};
|
|
4331
|
-
const getDbMemoized
|
|
4332
|
-
state
|
|
4333
|
-
return state
|
|
4818
|
+
const getDbMemoized = async () => {
|
|
4819
|
+
state.cachedDb ||= await getDb();
|
|
4820
|
+
return state.cachedDb;
|
|
4334
4821
|
};
|
|
4335
4822
|
const saveValue = async (storeId, value) => {
|
|
4336
4823
|
try {
|
|
4337
|
-
const db = await getDbMemoized
|
|
4824
|
+
const db = await getDbMemoized();
|
|
4338
4825
|
await db.add('session', value);
|
|
4339
4826
|
} catch (error) {
|
|
4340
4827
|
if (isDataCloneError(error)) {
|
|
@@ -4346,7 +4833,7 @@ const saveValue = async (storeId, value) => {
|
|
|
4346
4833
|
};
|
|
4347
4834
|
const getValues = async storeId => {
|
|
4348
4835
|
try {
|
|
4349
|
-
const db = await getDbMemoized
|
|
4836
|
+
const db = await getDbMemoized();
|
|
4350
4837
|
const tx = db.transaction(storeId, 'readwrite');
|
|
4351
4838
|
const [objects] = await Promise.all([tx.store.getAll(), tx.done]);
|
|
4352
4839
|
console.log({
|
|
@@ -4358,7 +4845,7 @@ const getValues = async storeId => {
|
|
|
4358
4845
|
}
|
|
4359
4846
|
};
|
|
4360
4847
|
const getValuesByIndexName = async (storeId, indexName, only) => {
|
|
4361
|
-
const db = await getDbMemoized
|
|
4848
|
+
const db = await getDbMemoized();
|
|
4362
4849
|
const transaction = db.transaction(storeId);
|
|
4363
4850
|
const index = transaction.store.index(indexName);
|
|
4364
4851
|
const iterator = index.iterate(only);
|
|
@@ -4369,7 +4856,7 @@ const getValuesByIndexName = async (storeId, indexName, only) => {
|
|
|
4369
4856
|
return objects;
|
|
4370
4857
|
};
|
|
4371
4858
|
const getHandleDb = async () => {
|
|
4372
|
-
const db = await openDB('handle', state
|
|
4859
|
+
const db = await openDB('handle', state.dbVersion, {
|
|
4373
4860
|
async upgrade(db, oldVersion) {
|
|
4374
4861
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
4375
4862
|
// @ts-ignore
|
|
@@ -4389,52 +4876,6 @@ const getHandle$1 = async uri => {
|
|
|
4389
4876
|
return handle;
|
|
4390
4877
|
};
|
|
4391
4878
|
|
|
4392
|
-
const storeId = 'lvce-keyvalue';
|
|
4393
|
-
|
|
4394
|
-
// TODO high memory usage in idb because of transactionDoneMap
|
|
4395
|
-
|
|
4396
|
-
const state = {
|
|
4397
|
-
databases: Object.create(null),
|
|
4398
|
-
dbVersion: 2,
|
|
4399
|
-
cachedDb: undefined
|
|
4400
|
-
};
|
|
4401
|
-
const getDb = async () => {
|
|
4402
|
-
const db = await openDB(storeId, state.dbVersion, {
|
|
4403
|
-
async upgrade(db, oldVersion) {
|
|
4404
|
-
if (!db.objectStoreNames.contains(storeId)) {
|
|
4405
|
-
await db.createObjectStore(storeId, {
|
|
4406
|
-
autoIncrement: true
|
|
4407
|
-
});
|
|
4408
|
-
}
|
|
4409
|
-
}
|
|
4410
|
-
});
|
|
4411
|
-
return db;
|
|
4412
|
-
};
|
|
4413
|
-
const getDbMemoized = async () => {
|
|
4414
|
-
state.cachedDb ||= await getDb();
|
|
4415
|
-
return state.cachedDb;
|
|
4416
|
-
};
|
|
4417
|
-
|
|
4418
|
-
// TODO high memory usage in idb because of transactionDoneMap
|
|
4419
|
-
|
|
4420
|
-
const set = async (key, value) => {
|
|
4421
|
-
try {
|
|
4422
|
-
const db = await getDbMemoized();
|
|
4423
|
-
await db.put(storeId, value, key);
|
|
4424
|
-
} catch (error) {
|
|
4425
|
-
throw new VError(error, 'Failed to save value to indexed db');
|
|
4426
|
-
}
|
|
4427
|
-
};
|
|
4428
|
-
const get = async key => {
|
|
4429
|
-
try {
|
|
4430
|
-
const db = await getDbMemoized();
|
|
4431
|
-
const value = await db.get(storeId, key);
|
|
4432
|
-
return value;
|
|
4433
|
-
} catch (error) {
|
|
4434
|
-
throw new VError(error, 'Failed to get value from indexed db');
|
|
4435
|
-
}
|
|
4436
|
-
};
|
|
4437
|
-
|
|
4438
4879
|
const loadWebView = async (providerId, savedState) => {
|
|
4439
4880
|
const rpc = getWebView(providerId);
|
|
4440
4881
|
await rpc.provider.create(rpc, rpc.uri, savedState);
|
|
@@ -4596,34 +5037,72 @@ const searchFile = async uri => {
|
|
|
4596
5037
|
return all;
|
|
4597
5038
|
};
|
|
4598
5039
|
|
|
5040
|
+
const getTextSearchRegex = (query, matchCase) => {
|
|
5041
|
+
const flags = matchCase ? 'u' : 'iu';
|
|
5042
|
+
const regex = new RegExp(query, flags);
|
|
5043
|
+
return regex;
|
|
5044
|
+
};
|
|
5045
|
+
|
|
5046
|
+
const getLineMatchRegex = (line, lineNumber, query, matchCase) => {
|
|
5047
|
+
const regex = getTextSearchRegex(query, matchCase);
|
|
5048
|
+
const match = line.match(regex);
|
|
5049
|
+
if (match && typeof match.index === 'number') {
|
|
5050
|
+
return [{
|
|
5051
|
+
type: Match,
|
|
5052
|
+
text: line,
|
|
5053
|
+
start: match.index,
|
|
5054
|
+
end: match.index + match[0].length,
|
|
5055
|
+
lineNumber
|
|
5056
|
+
}];
|
|
5057
|
+
}
|
|
5058
|
+
return [];
|
|
5059
|
+
};
|
|
5060
|
+
|
|
5061
|
+
const getLineMatchText = (line, lineNumber, query, queryLower, matchCase) => {
|
|
5062
|
+
const lineToQuery = matchCase ? line : line.toLowerCase();
|
|
5063
|
+
const actualQuery = matchCase ? query : queryLower;
|
|
5064
|
+
const index = lineToQuery.indexOf(actualQuery);
|
|
5065
|
+
if (index !== -1) {
|
|
5066
|
+
return [{
|
|
5067
|
+
type: Match,
|
|
5068
|
+
text: line,
|
|
5069
|
+
start: index,
|
|
5070
|
+
end: index + query.length,
|
|
5071
|
+
lineNumber
|
|
5072
|
+
}];
|
|
5073
|
+
}
|
|
5074
|
+
return [];
|
|
5075
|
+
};
|
|
5076
|
+
|
|
5077
|
+
const getLineMatch = (line, lineNumber, query, queryLower, useRegularExpression, matchCase) => {
|
|
5078
|
+
if (useRegularExpression) {
|
|
5079
|
+
return getLineMatchRegex(line, lineNumber, query, matchCase);
|
|
5080
|
+
}
|
|
5081
|
+
return getLineMatchText(line, lineNumber, query, queryLower, matchCase);
|
|
5082
|
+
};
|
|
5083
|
+
|
|
5084
|
+
const UseRegularExpression = 1 << 1; // 2
|
|
5085
|
+
const MatchCase = 1 << 4; // 16
|
|
5086
|
+
// 128
|
|
5087
|
+
|
|
4599
5088
|
const splitLines = lines => {
|
|
4600
5089
|
return lines.split('\n');
|
|
4601
5090
|
};
|
|
4602
5091
|
|
|
4603
|
-
const textSearchInText = (file, content, query) => {
|
|
4604
|
-
const
|
|
5092
|
+
const textSearchInText = (file, content, query, flags = 0) => {
|
|
5093
|
+
const matchCase = flags & MatchCase;
|
|
5094
|
+
const useRegularExpression = flags & UseRegularExpression;
|
|
4605
5095
|
const lines = splitLines(content);
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
const index = line.indexOf(query);
|
|
4609
|
-
if (index !== -1) {
|
|
4610
|
-
results.push({
|
|
4611
|
-
type: Match,
|
|
4612
|
-
text: line,
|
|
4613
|
-
start: index,
|
|
4614
|
-
end: index + query.length,
|
|
4615
|
-
lineNumber: i
|
|
4616
|
-
});
|
|
4617
|
-
}
|
|
4618
|
-
}
|
|
5096
|
+
const queryLower = query.toLowerCase();
|
|
5097
|
+
const results = lines.flatMap((line, i) => getLineMatch(line, i, query, queryLower, useRegularExpression, matchCase));
|
|
4619
5098
|
if (results.length > 0) {
|
|
4620
|
-
|
|
5099
|
+
return [{
|
|
4621
5100
|
type: File$3,
|
|
4622
5101
|
text: file,
|
|
4623
5102
|
start: 0,
|
|
4624
5103
|
end: 0,
|
|
4625
5104
|
lineNumber: 0
|
|
4626
|
-
}
|
|
5105
|
+
}, ...results];
|
|
4627
5106
|
}
|
|
4628
5107
|
return results;
|
|
4629
5108
|
};
|
|
@@ -4741,13 +5220,14 @@ const textSearch = async (scheme, root, query, options, assetDir) => {
|
|
|
4741
5220
|
const files = getFiles();
|
|
4742
5221
|
const relativeRoot = root.slice('memfs://'.length);
|
|
4743
5222
|
const allResults = [];
|
|
5223
|
+
const flags = options.flags || 0;
|
|
4744
5224
|
for (const [key, value] of Object.entries(files)) {
|
|
4745
5225
|
if (!matchesUri(key, relativeRoot, options.include, options.exclude)) {
|
|
4746
5226
|
continue;
|
|
4747
5227
|
}
|
|
4748
5228
|
if (value.type === File$1) {
|
|
4749
5229
|
const relativeUri = key.slice(relativeRoot.length + 1);
|
|
4750
|
-
const results = textSearchInText(relativeUri, value.content, query);
|
|
5230
|
+
const results = textSearchInText(relativeUri, value.content, query, flags);
|
|
4751
5231
|
allResults.push(...results);
|
|
4752
5232
|
}
|
|
4753
5233
|
}
|
|
@@ -4756,6 +5236,7 @@ const textSearch = async (scheme, root, query, options, assetDir) => {
|
|
|
4756
5236
|
|
|
4757
5237
|
const commandMap = {
|
|
4758
5238
|
'BulkReplacement.applyBulkReplacement': applyBulkReplacement,
|
|
5239
|
+
'ColorTheme.hydrate': hydrate$1,
|
|
4759
5240
|
'ExtensionHost.launchIframeWorker': launchIframeWorker,
|
|
4760
5241
|
'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
|
|
4761
5242
|
'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
|
|
@@ -4775,13 +5256,15 @@ const commandMap = {
|
|
|
4775
5256
|
'FileSystemMemory.readFile': readFile,
|
|
4776
5257
|
'FileSystemMemory.remove': remove,
|
|
4777
5258
|
'FileSystemMemory.writeFile': writeFile,
|
|
5259
|
+
'IconTheme.hydrate': hydrate,
|
|
5260
|
+
'IconTheme.setIconTheme': setIconTheme,
|
|
4778
5261
|
'IndexedDb.addHandle': addHandle,
|
|
4779
|
-
'IndexedDb.get': get,
|
|
5262
|
+
'IndexedDb.get': get$5,
|
|
4780
5263
|
'IndexedDb.getHandle': getHandle$1,
|
|
4781
5264
|
'IndexedDb.getValues': getValues,
|
|
4782
5265
|
'IndexedDb.getValuesByIndexName': getValuesByIndexName,
|
|
4783
5266
|
'IndexedDb.saveValue': saveValue,
|
|
4784
|
-
'IndexedDb.set': set,
|
|
5267
|
+
'IndexedDb.set': set$4,
|
|
4785
5268
|
'SearchFileWithFetch.searchFileWithFetch': searchFile$1,
|
|
4786
5269
|
'SearchFileWithHtml.searchFileWithHtml': searchFile,
|
|
4787
5270
|
'TextSearchFetch.textSearch': textSearch$2,
|