@lvce-editor/extension-host-worker 3.16.0 → 3.18.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 +259 -169
- package/package.json +1 -1
|
@@ -89,7 +89,7 @@ const fn = value => {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
const state$
|
|
92
|
+
const state$f = {
|
|
93
93
|
/** @type{any[]} */
|
|
94
94
|
onDidOpenEditorListeners: [],
|
|
95
95
|
/** @type{any[]} */
|
|
@@ -101,19 +101,19 @@ const state$e = {
|
|
|
101
101
|
textDocuments: Object.create(null)
|
|
102
102
|
};
|
|
103
103
|
const setDocument = (textDocumentId, textDocument) => {
|
|
104
|
-
state$
|
|
104
|
+
state$f.textDocuments[textDocumentId] = textDocument;
|
|
105
105
|
};
|
|
106
106
|
const getDidOpenListeners = () => {
|
|
107
|
-
return state$
|
|
107
|
+
return state$f.onDidSaveTextDocumentListeners;
|
|
108
108
|
};
|
|
109
109
|
const getWillChangeListeners = () => {
|
|
110
|
-
return state$
|
|
110
|
+
return state$f.onWillChangeEditorListeners;
|
|
111
111
|
};
|
|
112
112
|
const getDidChangeListeners = () => {
|
|
113
|
-
return state$
|
|
113
|
+
return state$f.onDidChangeTextDocumentListeners;
|
|
114
114
|
};
|
|
115
115
|
const getDocument = textDocumentId => {
|
|
116
|
-
return state$
|
|
116
|
+
return state$f.textDocuments[textDocumentId];
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
const getOffset$1 = (textDocument, position) => {
|
|
@@ -675,7 +675,7 @@ const executeOrganizeImports = async uid => {
|
|
|
675
675
|
return edits;
|
|
676
676
|
};
|
|
677
677
|
|
|
678
|
-
const state$
|
|
678
|
+
const state$e = {
|
|
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$e.commands) {
|
|
702
702
|
throw new Error(`command cannot be registered multiple times`);
|
|
703
703
|
}
|
|
704
|
-
state$
|
|
704
|
+
state$e.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$e.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$d = {
|
|
752
752
|
configuration: Object.create(null)
|
|
753
753
|
};
|
|
754
754
|
const getConfiguration = key => {
|
|
755
|
-
return state$
|
|
755
|
+
return state$d.configuration[key] ?? '';
|
|
756
756
|
};
|
|
757
757
|
const setConfigurations = preferences => {
|
|
758
|
-
state$
|
|
758
|
+
state$d.configuration = preferences;
|
|
759
759
|
};
|
|
760
760
|
|
|
761
|
-
const state$
|
|
761
|
+
const state$c = {
|
|
762
762
|
rpc: undefined
|
|
763
763
|
};
|
|
764
764
|
const invoke$2 = (method, ...params) => {
|
|
765
|
-
const rpc = state$
|
|
765
|
+
const rpc = state$c.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$c.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$c.rpc;
|
|
774
774
|
return rpc.invokeAndTransfer(method, ...params);
|
|
775
775
|
};
|
|
776
776
|
const setRpc = rpc => {
|
|
777
|
-
state$
|
|
777
|
+
state$c.rpc = rpc;
|
|
778
778
|
};
|
|
779
779
|
|
|
780
|
-
const state$
|
|
780
|
+
const state$b = {
|
|
781
781
|
debugProviderMap: Object.create(null)
|
|
782
782
|
};
|
|
783
783
|
const getDebugProvider = id => {
|
|
784
|
-
const provider = state$
|
|
784
|
+
const provider = state$b.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$b.debugProviderMap[debugProvider.id] = debugProvider;
|
|
796
796
|
};
|
|
797
797
|
const start = async (protocol, path) => {
|
|
798
798
|
try {
|
|
@@ -2551,17 +2551,17 @@ const {
|
|
|
2551
2551
|
}
|
|
2552
2552
|
});
|
|
2553
2553
|
|
|
2554
|
-
const state$
|
|
2554
|
+
const state$a = {
|
|
2555
2555
|
providers: Object.create(null)
|
|
2556
2556
|
};
|
|
2557
2557
|
const registerSourceControlProvider = provider => {
|
|
2558
|
-
state$
|
|
2558
|
+
state$a.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$a.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$a.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$a.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$a.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$a.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$a.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$a.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$9 = {
|
|
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$9.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$9.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$8 = {
|
|
2868
2868
|
workspacePath: ''
|
|
2869
2869
|
};
|
|
2870
2870
|
const setWorkspacePath = path => {
|
|
2871
|
-
state$
|
|
2871
|
+
state$8.workspacePath = path;
|
|
2872
2872
|
};
|
|
2873
2873
|
const getWorkspaceFolder = path => {
|
|
2874
|
-
return state$
|
|
2874
|
+
return state$8.workspacePath;
|
|
2875
2875
|
};
|
|
2876
2876
|
|
|
2877
2877
|
class FormattingError extends Error {
|
|
@@ -3024,7 +3024,7 @@ const handleUnhandledRejection = event => {
|
|
|
3024
3024
|
console.error(output);
|
|
3025
3025
|
};
|
|
3026
3026
|
|
|
3027
|
-
const state$
|
|
3027
|
+
const state$7 = {
|
|
3028
3028
|
/**
|
|
3029
3029
|
* @type {any[]}
|
|
3030
3030
|
*/
|
|
@@ -3032,10 +3032,10 @@ const state$6 = {
|
|
|
3032
3032
|
};
|
|
3033
3033
|
const addError = error => {
|
|
3034
3034
|
// @ts-ignore
|
|
3035
|
-
state$
|
|
3035
|
+
state$7.errors.push(error);
|
|
3036
3036
|
};
|
|
3037
3037
|
const hasRecentErrors = () => {
|
|
3038
|
-
return state$
|
|
3038
|
+
return state$7.errors.length > 0;
|
|
3039
3039
|
};
|
|
3040
3040
|
const getRecentError = () => {
|
|
3041
3041
|
};
|
|
@@ -3450,13 +3450,13 @@ const storeId = 'lvce-keyvalue';
|
|
|
3450
3450
|
|
|
3451
3451
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
3452
3452
|
|
|
3453
|
-
const state$
|
|
3453
|
+
const state$6 = {
|
|
3454
3454
|
databases: Object.create(null),
|
|
3455
3455
|
dbVersion: 2,
|
|
3456
3456
|
cachedDb: undefined
|
|
3457
3457
|
};
|
|
3458
3458
|
const getDb$1 = async () => {
|
|
3459
|
-
const db = await openDB(storeId, state$
|
|
3459
|
+
const db = await openDB(storeId, state$6.dbVersion, {
|
|
3460
3460
|
async upgrade(db, oldVersion) {
|
|
3461
3461
|
if (!db.objectStoreNames.contains(storeId)) {
|
|
3462
3462
|
await db.createObjectStore(storeId, {
|
|
@@ -3468,8 +3468,8 @@ const getDb$1 = async () => {
|
|
|
3468
3468
|
return db;
|
|
3469
3469
|
};
|
|
3470
3470
|
const getDbMemoized$1 = async () => {
|
|
3471
|
-
state$
|
|
3472
|
-
return state$
|
|
3471
|
+
state$6.cachedDb ||= await getDb$1();
|
|
3472
|
+
return state$6.cachedDb;
|
|
3473
3473
|
};
|
|
3474
3474
|
|
|
3475
3475
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
@@ -3574,22 +3574,47 @@ const getColorThemeCssCached = async (colorThemeId, getData) => {
|
|
|
3574
3574
|
return newData;
|
|
3575
3575
|
};
|
|
3576
3576
|
|
|
3577
|
-
const
|
|
3578
|
-
return invoke$2(
|
|
3577
|
+
const readJson = url => {
|
|
3578
|
+
return invoke$2('FileSystem.readJson', url);
|
|
3579
3579
|
};
|
|
3580
3580
|
|
|
3581
|
-
const
|
|
3582
|
-
|
|
3583
|
-
if (
|
|
3584
|
-
|
|
3585
|
-
return ASSET_DIR;
|
|
3581
|
+
const dirname = (pathSeparator, path) => {
|
|
3582
|
+
const index = path.lastIndexOf(pathSeparator);
|
|
3583
|
+
if (index === -1) {
|
|
3584
|
+
return path;
|
|
3586
3585
|
}
|
|
3587
|
-
|
|
3588
|
-
|
|
3586
|
+
return path.slice(0, index);
|
|
3587
|
+
};
|
|
3588
|
+
const extname = path => {
|
|
3589
|
+
const index = path.lastIndexOf('.');
|
|
3590
|
+
if (index === -1) {
|
|
3591
|
+
return '';
|
|
3592
|
+
}
|
|
3593
|
+
return path.slice(index);
|
|
3594
|
+
};
|
|
3595
|
+
const join = (pathSeparator, ...parts) => {
|
|
3596
|
+
return parts.join(pathSeparator);
|
|
3597
|
+
};
|
|
3598
|
+
|
|
3599
|
+
const getColorThemeUri = (extensions, colorThemeId) => {
|
|
3600
|
+
for (const extension of extensions) {
|
|
3601
|
+
if (!extension.colorThemes) {
|
|
3602
|
+
continue;
|
|
3603
|
+
}
|
|
3604
|
+
for (const colorTheme of extension.colorThemes) {
|
|
3605
|
+
if (colorTheme.id !== colorThemeId) {
|
|
3606
|
+
continue;
|
|
3607
|
+
}
|
|
3608
|
+
const absolutePath = join('/', extension.uri, colorTheme.path);
|
|
3609
|
+
return absolutePath;
|
|
3610
|
+
}
|
|
3589
3611
|
}
|
|
3590
3612
|
return '';
|
|
3591
3613
|
};
|
|
3592
|
-
|
|
3614
|
+
|
|
3615
|
+
const state$5 = {
|
|
3616
|
+
webExtensions: []
|
|
3617
|
+
};
|
|
3593
3618
|
|
|
3594
3619
|
const getJson = async url => {
|
|
3595
3620
|
try {
|
|
@@ -3604,6 +3629,97 @@ const getJson = async url => {
|
|
|
3604
3629
|
}
|
|
3605
3630
|
};
|
|
3606
3631
|
|
|
3632
|
+
const getAssetDir = () => {
|
|
3633
|
+
// @ts-ignore
|
|
3634
|
+
if (typeof ASSET_DIR !== 'undefined') {
|
|
3635
|
+
// @ts-ignore
|
|
3636
|
+
return ASSET_DIR;
|
|
3637
|
+
}
|
|
3638
|
+
if (platform === Electron) {
|
|
3639
|
+
return '../../../../..';
|
|
3640
|
+
}
|
|
3641
|
+
return '';
|
|
3642
|
+
};
|
|
3643
|
+
const assetDir = getAssetDir();
|
|
3644
|
+
|
|
3645
|
+
const webExtensionsUrl = `${assetDir}/config/webExtensions.json`;
|
|
3646
|
+
|
|
3647
|
+
const getSharedProcessExtensions$1 = () => {
|
|
3648
|
+
return invoke$2(/* ExtensionManagement.getExtensions */'ExtensionManagement.getExtensions');
|
|
3649
|
+
};
|
|
3650
|
+
const getStaticWebExtensions = () => {
|
|
3651
|
+
return getJson(webExtensionsUrl);
|
|
3652
|
+
};
|
|
3653
|
+
const getWebExtensionsWeb = async () => {
|
|
3654
|
+
const staticWebExtensions = await getStaticWebExtensions();
|
|
3655
|
+
return [...staticWebExtensions, ...state$5.webExtensions];
|
|
3656
|
+
};
|
|
3657
|
+
const isWebExtension = extension => {
|
|
3658
|
+
return extension && typeof extension.browser === 'string';
|
|
3659
|
+
};
|
|
3660
|
+
const getWebExtensionsDefault = async () => {
|
|
3661
|
+
const staticWebExtensions = await getStaticWebExtensions();
|
|
3662
|
+
const sharedProcessExtensions = await getSharedProcessExtensions$1();
|
|
3663
|
+
const sharedProcessWebExtensions = sharedProcessExtensions.filter(isWebExtension);
|
|
3664
|
+
return [...staticWebExtensions, sharedProcessWebExtensions, ...state$5.webExtensions];
|
|
3665
|
+
};
|
|
3666
|
+
const getWebExtensions = async () => {
|
|
3667
|
+
try {
|
|
3668
|
+
switch (platform) {
|
|
3669
|
+
case Web:
|
|
3670
|
+
return await getWebExtensionsWeb();
|
|
3671
|
+
default:
|
|
3672
|
+
return await getWebExtensionsDefault();
|
|
3673
|
+
}
|
|
3674
|
+
} catch {
|
|
3675
|
+
return state$5.webExtensions;
|
|
3676
|
+
}
|
|
3677
|
+
};
|
|
3678
|
+
|
|
3679
|
+
const getSharedProcessExtensions = () => {
|
|
3680
|
+
return invoke$2(/* ExtensionManagement.getExtensions */'ExtensionManagement.getExtensions');
|
|
3681
|
+
};
|
|
3682
|
+
const getExtensions$1 = async () => {
|
|
3683
|
+
if (platform === Web) {
|
|
3684
|
+
const webExtensions = await getWebExtensions();
|
|
3685
|
+
return webExtensions;
|
|
3686
|
+
}
|
|
3687
|
+
if (platform === Remote) {
|
|
3688
|
+
const webExtensions = await getWebExtensions();
|
|
3689
|
+
const sharedProcessExtensions = await getSharedProcessExtensions();
|
|
3690
|
+
return [...sharedProcessExtensions, ...webExtensions];
|
|
3691
|
+
}
|
|
3692
|
+
const extensions = await getSharedProcessExtensions();
|
|
3693
|
+
return extensions;
|
|
3694
|
+
};
|
|
3695
|
+
|
|
3696
|
+
const cache = Object.create(null);
|
|
3697
|
+
const id = 1;
|
|
3698
|
+
const get = () => {
|
|
3699
|
+
return cache[id];
|
|
3700
|
+
};
|
|
3701
|
+
const has = () => {
|
|
3702
|
+
return id in cache;
|
|
3703
|
+
};
|
|
3704
|
+
const set = value => {
|
|
3705
|
+
cache[id] = value;
|
|
3706
|
+
};
|
|
3707
|
+
|
|
3708
|
+
// TODO getExtensions is still called 6 times on startup instead of 1
|
|
3709
|
+
const getExtensions = () => {
|
|
3710
|
+
if (!has()) {
|
|
3711
|
+
set(getExtensions$1());
|
|
3712
|
+
}
|
|
3713
|
+
return get();
|
|
3714
|
+
};
|
|
3715
|
+
|
|
3716
|
+
const getColorThemeJson$2 = async colorThemeId => {
|
|
3717
|
+
const extensions = await getExtensions();
|
|
3718
|
+
const colorThemeUri = getColorThemeUri(extensions, colorThemeId);
|
|
3719
|
+
const json = await readJson(colorThemeUri);
|
|
3720
|
+
return json;
|
|
3721
|
+
};
|
|
3722
|
+
|
|
3607
3723
|
const getColorThemeUrlWeb = colorThemeId => {
|
|
3608
3724
|
return `${assetDir}/extensions/builtin.theme-${colorThemeId}/color-theme.json`;
|
|
3609
3725
|
};
|
|
@@ -4321,7 +4437,7 @@ const mockRpc = () => {
|
|
|
4321
4437
|
};
|
|
4322
4438
|
|
|
4323
4439
|
const getStatusBarItems = async () => {
|
|
4324
|
-
const providers = Object.values(state$
|
|
4440
|
+
const providers = Object.values(state$a.providers);
|
|
4325
4441
|
const statusBarItems = [];
|
|
4326
4442
|
for (const provider of providers) {
|
|
4327
4443
|
// @ts-ignore
|
|
@@ -4467,21 +4583,6 @@ const getMimeType = fileExtension => {
|
|
|
4467
4583
|
}
|
|
4468
4584
|
};
|
|
4469
4585
|
|
|
4470
|
-
const dirname = (pathSeparator, path) => {
|
|
4471
|
-
const index = path.lastIndexOf(pathSeparator);
|
|
4472
|
-
if (index === -1) {
|
|
4473
|
-
return path;
|
|
4474
|
-
}
|
|
4475
|
-
return path.slice(0, index);
|
|
4476
|
-
};
|
|
4477
|
-
const extname = path => {
|
|
4478
|
-
const index = path.lastIndexOf('.');
|
|
4479
|
-
if (index === -1) {
|
|
4480
|
-
return '';
|
|
4481
|
-
}
|
|
4482
|
-
return path.slice(index);
|
|
4483
|
-
};
|
|
4484
|
-
|
|
4485
4586
|
const getContentType = uri => {
|
|
4486
4587
|
const extension = extname(uri);
|
|
4487
4588
|
const mime = getMimeType(extension);
|
|
@@ -4605,35 +4706,6 @@ const getFiles = () => {
|
|
|
4605
4706
|
return state$2.files;
|
|
4606
4707
|
};
|
|
4607
4708
|
|
|
4608
|
-
const getRpcInfo = rpcId => {
|
|
4609
|
-
const info = get$7(rpcId);
|
|
4610
|
-
if (!info) {
|
|
4611
|
-
throw new Error(`Rpc not found ${rpcId}`);
|
|
4612
|
-
}
|
|
4613
|
-
return info;
|
|
4614
|
-
};
|
|
4615
|
-
|
|
4616
|
-
const handleBeforeUnload = () => {
|
|
4617
|
-
// TODO save all webviews in localstorage
|
|
4618
|
-
// cannot use indexeddb during unload
|
|
4619
|
-
console.log('before unload');
|
|
4620
|
-
};
|
|
4621
|
-
|
|
4622
|
-
const handleMessagePort = async port => {
|
|
4623
|
-
await MessagePortRpcClient.create({
|
|
4624
|
-
messagePort: port,
|
|
4625
|
-
commandMap: {}
|
|
4626
|
-
});
|
|
4627
|
-
};
|
|
4628
|
-
|
|
4629
|
-
const state$1 = {
|
|
4630
|
-
webExtensions: []
|
|
4631
|
-
};
|
|
4632
|
-
|
|
4633
|
-
const readJson = url => {
|
|
4634
|
-
return invoke$2('FileSystem.readJson', url);
|
|
4635
|
-
};
|
|
4636
|
-
|
|
4637
4709
|
const findMatchingIconThemeExtension = (extensions, iconThemeId) => {
|
|
4638
4710
|
for (const extension of extensions) {
|
|
4639
4711
|
if (extension && extension.iconThemes) {
|
|
@@ -4650,76 +4722,6 @@ const findMatchingIconThemeExtension = (extensions, iconThemeId) => {
|
|
|
4650
4722
|
return undefined;
|
|
4651
4723
|
};
|
|
4652
4724
|
|
|
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();
|
|
4681
|
-
}
|
|
4682
|
-
} catch {
|
|
4683
|
-
return state$1.webExtensions;
|
|
4684
|
-
}
|
|
4685
|
-
};
|
|
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;
|
|
4694
|
-
}
|
|
4695
|
-
if (platform === Remote) {
|
|
4696
|
-
const webExtensions = await getWebExtensions();
|
|
4697
|
-
const sharedProcessExtensions = await getSharedProcessExtensions();
|
|
4698
|
-
return [...sharedProcessExtensions, ...webExtensions];
|
|
4699
|
-
}
|
|
4700
|
-
const extensions = await getSharedProcessExtensions();
|
|
4701
|
-
return extensions;
|
|
4702
|
-
};
|
|
4703
|
-
|
|
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());
|
|
4719
|
-
}
|
|
4720
|
-
return get();
|
|
4721
|
-
};
|
|
4722
|
-
|
|
4723
4725
|
const getIconThemeUrl = iconThemeId => {
|
|
4724
4726
|
return `${assetDir}/extensions/builtin.${iconThemeId}/icon-theme.json`;
|
|
4725
4727
|
};
|
|
@@ -4733,7 +4735,7 @@ const getIconThemeJson = async iconThemeId => {
|
|
|
4733
4735
|
extensionPath: `${assetDir}/extensions/builtin.${iconThemeId}`
|
|
4734
4736
|
};
|
|
4735
4737
|
}
|
|
4736
|
-
for (const webExtension of state$
|
|
4738
|
+
for (const webExtension of state$5.webExtensions) {
|
|
4737
4739
|
if (webExtension.iconThemes) {
|
|
4738
4740
|
for (const iconTheme of webExtension.iconThemes) {
|
|
4739
4741
|
// TODO handle error when icon theme path is not of type string
|
|
@@ -4759,11 +4761,49 @@ const getIconThemeJson = async iconThemeId => {
|
|
|
4759
4761
|
};
|
|
4760
4762
|
};
|
|
4761
4763
|
|
|
4764
|
+
const getRpcInfo = rpcId => {
|
|
4765
|
+
const info = get$7(rpcId);
|
|
4766
|
+
if (!info) {
|
|
4767
|
+
throw new Error(`Rpc not found ${rpcId}`);
|
|
4768
|
+
}
|
|
4769
|
+
return info;
|
|
4770
|
+
};
|
|
4771
|
+
|
|
4772
|
+
const handleBeforeUnload = () => {
|
|
4773
|
+
// TODO save all webviews in localstorage
|
|
4774
|
+
// cannot use indexeddb during unload
|
|
4775
|
+
console.log('before unload');
|
|
4776
|
+
};
|
|
4777
|
+
|
|
4778
|
+
const handleMessagePort = async port => {
|
|
4779
|
+
await MessagePortRpcClient.create({
|
|
4780
|
+
messagePort: port,
|
|
4781
|
+
commandMap: {}
|
|
4782
|
+
});
|
|
4783
|
+
};
|
|
4784
|
+
|
|
4762
4785
|
const handleIconThemeChange = async () => {
|
|
4763
4786
|
await invoke$2('IconTheme.handleIconThemeChange');
|
|
4764
4787
|
};
|
|
4765
4788
|
|
|
4789
|
+
const initialIconTheme = undefined;
|
|
4790
|
+
|
|
4791
|
+
const state$1 = {
|
|
4792
|
+
seenFiles: [],
|
|
4793
|
+
seenFolders: [],
|
|
4794
|
+
hasWarned: [],
|
|
4795
|
+
/**
|
|
4796
|
+
* @type{any}
|
|
4797
|
+
*/
|
|
4798
|
+
iconTheme: initialIconTheme,
|
|
4799
|
+
extensionPath: ''
|
|
4800
|
+
};
|
|
4766
4801
|
const setTheme = iconTheme => {
|
|
4802
|
+
state$1.iconTheme = iconTheme.json;
|
|
4803
|
+
state$1.extensionPath = iconTheme.extensionPath;
|
|
4804
|
+
};
|
|
4805
|
+
const getState = () => {
|
|
4806
|
+
return state$1;
|
|
4767
4807
|
};
|
|
4768
4808
|
|
|
4769
4809
|
const setIconTheme = async iconThemeId => {
|
|
@@ -4876,6 +4916,51 @@ const getHandle$1 = async uri => {
|
|
|
4876
4916
|
return handle;
|
|
4877
4917
|
};
|
|
4878
4918
|
|
|
4919
|
+
const getLanguagesFromExtension = extension => {
|
|
4920
|
+
// TODO what if extension is null? should not crash process, handle error gracefully
|
|
4921
|
+
// TODO what if extension languages is not of type array?
|
|
4922
|
+
// TODO what if language is null?
|
|
4923
|
+
if (!extension) {
|
|
4924
|
+
return [];
|
|
4925
|
+
}
|
|
4926
|
+
if (!extension.languages) {
|
|
4927
|
+
return [];
|
|
4928
|
+
}
|
|
4929
|
+
const extensionPath = extension.path;
|
|
4930
|
+
const getLanguageFromExtension = language => {
|
|
4931
|
+
if (language.tokenize) {
|
|
4932
|
+
if (typeof language.tokenize !== 'string') {
|
|
4933
|
+
console.warn(`[info] ${language.id}: language.tokenize must be of type string but was of type ${typeof language.tokenize}`);
|
|
4934
|
+
return {
|
|
4935
|
+
...language,
|
|
4936
|
+
extensionPath,
|
|
4937
|
+
tokenize: ''
|
|
4938
|
+
};
|
|
4939
|
+
}
|
|
4940
|
+
return {
|
|
4941
|
+
...language,
|
|
4942
|
+
extensionPath,
|
|
4943
|
+
tokenize: `${extensionPath}/${language.tokenize}`
|
|
4944
|
+
};
|
|
4945
|
+
}
|
|
4946
|
+
return language;
|
|
4947
|
+
};
|
|
4948
|
+
return extension.languages.map(getLanguageFromExtension);
|
|
4949
|
+
};
|
|
4950
|
+
|
|
4951
|
+
const getLanguages = async () => {
|
|
4952
|
+
try {
|
|
4953
|
+
const extensions = await getExtensions();
|
|
4954
|
+
const languages = extensions.flatMap(getLanguagesFromExtension);
|
|
4955
|
+
console.log({
|
|
4956
|
+
languages
|
|
4957
|
+
});
|
|
4958
|
+
return languages;
|
|
4959
|
+
} catch (error) {
|
|
4960
|
+
throw new VError(error, 'Failed to load languages');
|
|
4961
|
+
}
|
|
4962
|
+
};
|
|
4963
|
+
|
|
4879
4964
|
const loadWebView = async (providerId, savedState) => {
|
|
4880
4965
|
const rpc = getWebView(providerId);
|
|
4881
4966
|
await rpc.provider.create(rpc, rpc.uri, savedState);
|
|
@@ -5236,6 +5321,8 @@ const textSearch = async (scheme, root, query, options, assetDir) => {
|
|
|
5236
5321
|
|
|
5237
5322
|
const commandMap = {
|
|
5238
5323
|
'BulkReplacement.applyBulkReplacement': applyBulkReplacement,
|
|
5324
|
+
'ColorTheme.getColorThemeCssFromJson': getColorThemeCssFromJson,
|
|
5325
|
+
'ColorTheme.getColorThemeJson': getColorThemeJson,
|
|
5239
5326
|
'ColorTheme.hydrate': hydrate$1,
|
|
5240
5327
|
'ExtensionHost.launchIframeWorker': launchIframeWorker,
|
|
5241
5328
|
'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
|
|
@@ -5248,6 +5335,7 @@ const commandMap = {
|
|
|
5248
5335
|
'FileSystemFetch.remove': remove$1,
|
|
5249
5336
|
'FileSystemFetch.writeFile': writeFile$1,
|
|
5250
5337
|
'FileSystemMemory.chmod': chmod,
|
|
5338
|
+
'Languages.getLanguages': getLanguages,
|
|
5251
5339
|
'FileSystemMemory.getBlob': getBlob,
|
|
5252
5340
|
'FileSystemMemory.getBlobUrl': getBlobUrl,
|
|
5253
5341
|
'FileSystemMemory.getFiles': getFiles,
|
|
@@ -5256,6 +5344,8 @@ const commandMap = {
|
|
|
5256
5344
|
'FileSystemMemory.readFile': readFile,
|
|
5257
5345
|
'FileSystemMemory.remove': remove,
|
|
5258
5346
|
'FileSystemMemory.writeFile': writeFile,
|
|
5347
|
+
'IconTheme.getJson': getIconThemeJson,
|
|
5348
|
+
'IconTheme.getState': getState,
|
|
5259
5349
|
'IconTheme.hydrate': hydrate,
|
|
5260
5350
|
'IconTheme.setIconTheme': setIconTheme,
|
|
5261
5351
|
'IndexedDb.addHandle': addHandle,
|
package/package.json
CHANGED