@lvce-editor/extension-host-worker 1.5.0 → 1.6.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 +70 -48
- package/package.json +1 -1
|
@@ -89,7 +89,7 @@ const fn = value => {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
const state$
|
|
92
|
+
const state$a = {
|
|
93
93
|
/** @type{any[]} */
|
|
94
94
|
onDidOpenEditorListeners: [],
|
|
95
95
|
/** @type{any[]} */
|
|
@@ -101,19 +101,19 @@ const state$b = {
|
|
|
101
101
|
textDocuments: Object.create(null)
|
|
102
102
|
};
|
|
103
103
|
const setDocument = (textDocumentId, textDocument) => {
|
|
104
|
-
state$
|
|
104
|
+
state$a.textDocuments[textDocumentId] = textDocument;
|
|
105
105
|
};
|
|
106
106
|
const getDidOpenListeners = () => {
|
|
107
|
-
return state$
|
|
107
|
+
return state$a.onDidSaveTextDocumentListeners;
|
|
108
108
|
};
|
|
109
109
|
const getWillChangeListeners = () => {
|
|
110
|
-
return state$
|
|
110
|
+
return state$a.onWillChangeEditorListeners;
|
|
111
111
|
};
|
|
112
112
|
const getDidChangeListeners = () => {
|
|
113
|
-
return state$
|
|
113
|
+
return state$a.onDidChangeTextDocumentListeners;
|
|
114
114
|
};
|
|
115
115
|
const getDocument = textDocumentId => {
|
|
116
|
-
return state$
|
|
116
|
+
return state$a.textDocuments[textDocumentId];
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
const getOffset$1 = (textDocument, position) => {
|
|
@@ -303,7 +303,7 @@ 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$5 = textDocumentId => {
|
|
307
307
|
const textDocument = getDocument(textDocumentId);
|
|
308
308
|
return textDocument;
|
|
309
309
|
};
|
|
@@ -536,7 +536,7 @@ const registerMethod = ({
|
|
|
536
536
|
}) => {
|
|
537
537
|
context[`execute${name}Provider`] = async function (textDocumentId, ...params) {
|
|
538
538
|
try {
|
|
539
|
-
const textDocument = get$
|
|
539
|
+
const textDocument = get$5(textDocumentId);
|
|
540
540
|
if (!textDocument) {
|
|
541
541
|
throw new Error(`textDocument with id ${textDocumentId} not found`);
|
|
542
542
|
}
|
|
@@ -671,12 +671,12 @@ const executeOrganizeImports = async uid => {
|
|
|
671
671
|
if (!organizeImportsAction) {
|
|
672
672
|
return [];
|
|
673
673
|
}
|
|
674
|
-
const textDocument = get$
|
|
674
|
+
const textDocument = get$5(uid);
|
|
675
675
|
const edits = await organizeImportsAction.execute(textDocument);
|
|
676
676
|
return edits;
|
|
677
677
|
};
|
|
678
678
|
|
|
679
|
-
const state$
|
|
679
|
+
const state$9 = {
|
|
680
680
|
commands: Object.create(null)
|
|
681
681
|
};
|
|
682
682
|
const getCommandDisplay = command => {
|
|
@@ -699,10 +699,10 @@ const registerCommand = command => {
|
|
|
699
699
|
if (!command.execute) {
|
|
700
700
|
throw new Error('command is missing execute function');
|
|
701
701
|
}
|
|
702
|
-
if (command.id in state$
|
|
702
|
+
if (command.id in state$9.commands) {
|
|
703
703
|
throw new Error(`command cannot be registered multiple times`);
|
|
704
704
|
}
|
|
705
|
-
state$
|
|
705
|
+
state$9.commands[command.id] = command;
|
|
706
706
|
} catch (error) {
|
|
707
707
|
const commandDisplayId = getCommandDisplay(command);
|
|
708
708
|
throw new VError$1(error, `Failed to register command${commandDisplayId}`);
|
|
@@ -710,7 +710,7 @@ const registerCommand = command => {
|
|
|
710
710
|
};
|
|
711
711
|
const executeCommand = async (id, ...args) => {
|
|
712
712
|
try {
|
|
713
|
-
const command = state$
|
|
713
|
+
const command = state$9.commands[id];
|
|
714
714
|
if (!command) {
|
|
715
715
|
throw new Error(`command ${id} not found`);
|
|
716
716
|
}
|
|
@@ -749,14 +749,14 @@ const {
|
|
|
749
749
|
}]
|
|
750
750
|
});
|
|
751
751
|
|
|
752
|
-
const state$
|
|
752
|
+
const state$8 = {
|
|
753
753
|
configuration: Object.create(null)
|
|
754
754
|
};
|
|
755
755
|
const getConfiguration = key => {
|
|
756
|
-
return state$
|
|
756
|
+
return state$8.configuration[key] ?? '';
|
|
757
757
|
};
|
|
758
758
|
const setConfigurations = preferences => {
|
|
759
|
-
state$
|
|
759
|
+
state$8.configuration = preferences;
|
|
760
760
|
};
|
|
761
761
|
|
|
762
762
|
const Two = '2.0';
|
|
@@ -804,20 +804,20 @@ const number = value => {
|
|
|
804
804
|
const state$1$1 = {
|
|
805
805
|
callbacks: Object.create(null)
|
|
806
806
|
};
|
|
807
|
-
const set$
|
|
807
|
+
const set$4 = (id, fn) => {
|
|
808
808
|
state$1$1.callbacks[id] = fn;
|
|
809
809
|
};
|
|
810
|
-
const get$
|
|
810
|
+
const get$4 = id => {
|
|
811
811
|
return state$1$1.callbacks[id];
|
|
812
812
|
};
|
|
813
813
|
const remove = id => {
|
|
814
814
|
delete state$1$1.callbacks[id];
|
|
815
815
|
};
|
|
816
|
-
const state$
|
|
816
|
+
const state$7 = {
|
|
817
817
|
id: 0
|
|
818
818
|
};
|
|
819
819
|
const create$3$1 = () => {
|
|
820
|
-
return ++state$
|
|
820
|
+
return ++state$7.id;
|
|
821
821
|
};
|
|
822
822
|
const warn = (...args) => {
|
|
823
823
|
console.warn(...args);
|
|
@@ -841,7 +841,7 @@ const registerPromise = () => {
|
|
|
841
841
|
resolve,
|
|
842
842
|
promise
|
|
843
843
|
} = withResolvers$2();
|
|
844
|
-
set$
|
|
844
|
+
set$4(id, resolve);
|
|
845
845
|
return {
|
|
846
846
|
id,
|
|
847
847
|
promise
|
|
@@ -849,7 +849,7 @@ const registerPromise = () => {
|
|
|
849
849
|
};
|
|
850
850
|
const resolve = (id, args) => {
|
|
851
851
|
number(id);
|
|
852
|
-
const fn = get$
|
|
852
|
+
const fn = get$4(id);
|
|
853
853
|
if (!fn) {
|
|
854
854
|
console.log(args);
|
|
855
855
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -1159,13 +1159,13 @@ class CommandNotFoundError extends Error {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
1161
|
|
|
1162
|
-
const state$
|
|
1162
|
+
const state$6 = {};
|
|
1163
1163
|
const register$1 = commandMap => {
|
|
1164
|
-
Object.assign(state$
|
|
1164
|
+
Object.assign(state$6, commandMap);
|
|
1165
1165
|
};
|
|
1166
1166
|
const execute = (method, ...params) => {
|
|
1167
1167
|
// @ts-ignore
|
|
1168
|
-
const fn = state$
|
|
1168
|
+
const fn = state$6[method];
|
|
1169
1169
|
// @ts-ignore
|
|
1170
1170
|
if (!fn) {
|
|
1171
1171
|
throw new CommandNotFoundError(method);
|
|
@@ -1191,41 +1191,41 @@ const handleIpc = ipc => {
|
|
|
1191
1191
|
ipc.addEventListener('message', handleMessage);
|
|
1192
1192
|
};
|
|
1193
1193
|
|
|
1194
|
-
const state$
|
|
1194
|
+
const state$5 = {
|
|
1195
1195
|
/**
|
|
1196
1196
|
* @type {any}
|
|
1197
1197
|
*/
|
|
1198
1198
|
ipc: undefined
|
|
1199
1199
|
};
|
|
1200
|
-
const get$
|
|
1201
|
-
return state$
|
|
1200
|
+
const get$3 = () => {
|
|
1201
|
+
return state$5.ipc;
|
|
1202
1202
|
};
|
|
1203
|
-
const set$
|
|
1204
|
-
state$
|
|
1203
|
+
const set$3 = ipc => {
|
|
1204
|
+
state$5.ipc = ipc;
|
|
1205
1205
|
};
|
|
1206
1206
|
|
|
1207
1207
|
const send = (method, ...params) => {
|
|
1208
|
-
const ipc = get$
|
|
1208
|
+
const ipc = get$3();
|
|
1209
1209
|
send$1(ipc, method, ...params);
|
|
1210
1210
|
};
|
|
1211
1211
|
const invoke = (method, ...params) => {
|
|
1212
|
-
const ipc = get$
|
|
1212
|
+
const ipc = get$3();
|
|
1213
1213
|
return invoke$1(ipc, method, ...params);
|
|
1214
1214
|
};
|
|
1215
1215
|
const invokeAndTransfer = (method, ...params) => {
|
|
1216
|
-
const ipc = get$
|
|
1216
|
+
const ipc = get$3();
|
|
1217
1217
|
return invokeAndTransfer$1(ipc, method, ...params);
|
|
1218
1218
|
};
|
|
1219
1219
|
const listen$2 = ipc => {
|
|
1220
1220
|
handleIpc(ipc);
|
|
1221
|
-
set$
|
|
1221
|
+
set$3(ipc);
|
|
1222
1222
|
};
|
|
1223
1223
|
|
|
1224
|
-
const state$
|
|
1224
|
+
const state$4 = {
|
|
1225
1225
|
debugProviderMap: Object.create(null)
|
|
1226
1226
|
};
|
|
1227
1227
|
const getDebugProvider = id => {
|
|
1228
|
-
const provider = state$
|
|
1228
|
+
const provider = state$4.debugProviderMap[id];
|
|
1229
1229
|
if (!provider) {
|
|
1230
1230
|
// @ts-ignore
|
|
1231
1231
|
throw new VError$1(`no debug provider "${id}" found`);
|
|
@@ -1236,7 +1236,7 @@ const registerDebugProvider = debugProvider => {
|
|
|
1236
1236
|
if (!debugProvider.id) {
|
|
1237
1237
|
throw new Error('Failed to register debug system provider: missing id');
|
|
1238
1238
|
}
|
|
1239
|
-
state$
|
|
1239
|
+
state$4.debugProviderMap[debugProvider.id] = debugProvider;
|
|
1240
1240
|
};
|
|
1241
1241
|
const start = async (protocol, path) => {
|
|
1242
1242
|
try {
|
|
@@ -1391,26 +1391,31 @@ const exec = async (command, args, options) => {
|
|
|
1391
1391
|
throw new DepecratedError(`vscode.exec is deprecated, use createNodeRpc instead`);
|
|
1392
1392
|
};
|
|
1393
1393
|
|
|
1394
|
-
const
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
const getFileSystemProvider = protocol => {
|
|
1398
|
-
const provider = state$4.fileSystemProviderMap[protocol];
|
|
1394
|
+
const fileSystemProviderMap = Object.create(null);
|
|
1395
|
+
const get$2 = protocol => {
|
|
1396
|
+
const provider = fileSystemProviderMap[protocol];
|
|
1399
1397
|
if (!provider) {
|
|
1400
1398
|
// @ts-ignore
|
|
1401
1399
|
throw new VError$1(`no file system provider for protocol "${protocol}" found`);
|
|
1402
1400
|
}
|
|
1403
1401
|
return provider;
|
|
1404
1402
|
};
|
|
1403
|
+
const set$2 = (id, provider) => {
|
|
1404
|
+
if (!id) {
|
|
1405
|
+
throw new Error('Failed to register file system provider: missing id');
|
|
1406
|
+
}
|
|
1407
|
+
fileSystemProviderMap[id] = provider;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1405
1410
|
const registerFileSystemProvider = fileSystemProvider => {
|
|
1406
1411
|
if (!fileSystemProvider.id) {
|
|
1407
1412
|
throw new Error('Failed to register file system provider: missing id');
|
|
1408
1413
|
}
|
|
1409
|
-
|
|
1414
|
+
set$2(fileSystemProvider.id, fileSystemProvider);
|
|
1410
1415
|
};
|
|
1411
1416
|
const readDirWithFileTypes = async (protocol, path) => {
|
|
1412
1417
|
try {
|
|
1413
|
-
const provider =
|
|
1418
|
+
const provider = get$2(protocol);
|
|
1414
1419
|
return await provider.readDirWithFileTypes(path);
|
|
1415
1420
|
} catch (error) {
|
|
1416
1421
|
throw new VError$1(error, 'Failed to execute file system provider');
|
|
@@ -1418,7 +1423,7 @@ const readDirWithFileTypes = async (protocol, path) => {
|
|
|
1418
1423
|
};
|
|
1419
1424
|
const readFile = async (protocol, path) => {
|
|
1420
1425
|
try {
|
|
1421
|
-
const provider =
|
|
1426
|
+
const provider = get$2(protocol);
|
|
1422
1427
|
return await provider.readFile(path);
|
|
1423
1428
|
} catch (error) {
|
|
1424
1429
|
throw new VError$1(error, 'Failed to execute file system provider');
|
|
@@ -1434,9 +1439,19 @@ const readFileExternal = async path => {
|
|
|
1434
1439
|
const content = await invoke('FileSystem.readFile', path);
|
|
1435
1440
|
return content;
|
|
1436
1441
|
};
|
|
1442
|
+
const readDirWithFileTypesExternal = async path => {
|
|
1443
|
+
// TODO when file is local,
|
|
1444
|
+
// don't ask renderer worker
|
|
1445
|
+
// instead read file directly from shared process
|
|
1446
|
+
// this avoid parsing the potentially large message
|
|
1447
|
+
// and improve performance by not blocking the renderer worker
|
|
1448
|
+
// when reading / writing large files
|
|
1449
|
+
const content = await invoke('FileSystem.readDirWithFileTypes', path);
|
|
1450
|
+
return content;
|
|
1451
|
+
};
|
|
1437
1452
|
const writeFile = async (protocol, uri, content) => {
|
|
1438
1453
|
try {
|
|
1439
|
-
const provider =
|
|
1454
|
+
const provider = get$2(protocol);
|
|
1440
1455
|
return await provider.writeFile(uri, content);
|
|
1441
1456
|
} catch (error) {
|
|
1442
1457
|
throw new VError$1(error, 'Failed to execute file system provider');
|
|
@@ -1444,7 +1459,7 @@ const writeFile = async (protocol, uri, content) => {
|
|
|
1444
1459
|
};
|
|
1445
1460
|
const getPathSeparator = protocol => {
|
|
1446
1461
|
try {
|
|
1447
|
-
const provider =
|
|
1462
|
+
const provider = get$2(protocol);
|
|
1448
1463
|
return provider.pathSeparator;
|
|
1449
1464
|
} catch (error) {
|
|
1450
1465
|
throw new VError$1(error, 'Failed to execute file system provider');
|
|
@@ -2286,7 +2301,7 @@ const api = {
|
|
|
2286
2301
|
// File System
|
|
2287
2302
|
registerFileSystemProvider: registerFileSystemProvider,
|
|
2288
2303
|
readFile: readFileExternal,
|
|
2289
|
-
|
|
2304
|
+
readDirWithFileTypes: readDirWithFileTypesExternal,
|
|
2290
2305
|
// Formatting
|
|
2291
2306
|
registerFormattingProvider: registerFormattingProvider,
|
|
2292
2307
|
executeFormattingProvider: executeFormattingProvider,
|
|
@@ -2910,6 +2925,12 @@ const registerChangeListener = () => {
|
|
|
2910
2925
|
// TODO
|
|
2911
2926
|
};
|
|
2912
2927
|
|
|
2928
|
+
const handleBeforeUnload = () => {
|
|
2929
|
+
// TODO save all webviews in localstorage
|
|
2930
|
+
// cannot use indexeddb during unload
|
|
2931
|
+
console.log('before unload');
|
|
2932
|
+
};
|
|
2933
|
+
|
|
2913
2934
|
const MessagePort$1 = 1;
|
|
2914
2935
|
const ModuleWorker = 2;
|
|
2915
2936
|
const ModuleWorkerWithMessagePort = 4;
|
|
@@ -3386,6 +3407,7 @@ const commandMap = {
|
|
|
3386
3407
|
['ExtensionHostWebView.create']: createWebView,
|
|
3387
3408
|
['ExtensionHostWebView.dispose']: disposeWebView,
|
|
3388
3409
|
['ExtensionHostWebView.load']: load,
|
|
3410
|
+
['HandleBeforeUnload.handleBeforeUnload']: handleBeforeUnload,
|
|
3389
3411
|
['HandleMessagePort.handleMessagePort']: handleMessagePort,
|
|
3390
3412
|
[BraceCompletionExecuteBraceCompletionProvider]: executeBraceCompletionProvider,
|
|
3391
3413
|
[ClosingTagExecuteClosingTagProvider]: executeClosingTagProvider,
|
package/package.json
CHANGED