@lvce-editor/extension-host-worker 8.20.0 → 8.24.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/extension-api/index.js +380 -26
- package/dist/extension-api/parts/Activation/Activation.js +4 -2
- package/dist/extension-api/parts/ExecuteCommand/ExecuteCommand.js +2 -2
- package/dist/extension-api/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.js +6 -1
- package/dist/extension-api/parts/NotifyStatusBarChange/NotifyStatusBarChange.js +2 -2
- package/dist/extension-api/parts/OutputChannel/OutputChannel.js +71 -0
- package/dist/extension-api/parts/OutputChannelHandle/OutputChannelHandle.js +0 -0
- package/dist/extension-api/parts/OutputChannelRegistrySnapshot/OutputChannelRegistrySnapshot.js +0 -0
- package/dist/extension-api/parts/QuickPick/QuickPick.js +2 -2
- package/dist/extension-api/parts/RegisteredOutputChannel/RegisteredOutputChannel.js +0 -0
- package/dist/extension-api/parts/View/View.js +0 -0
- package/dist/extension-api/parts/ViewRegistry/ViewRegistry.js +55 -0
- package/dist/extensionHostWorkerMain.js +112 -41
- package/extension-api/dist/index.d.ts +6 -0
- package/extension-api/dist/index.js +2 -0
- package/extension-api/dist/parts/Activation/Activation.js +4 -2
- package/extension-api/dist/parts/CommandMap/CommandMap.d.ts +3 -0
- package/extension-api/dist/parts/ExecuteCommand/ExecuteCommand.js +2 -2
- package/extension-api/dist/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.d.ts +3 -0
- package/extension-api/dist/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.js +5 -0
- package/extension-api/dist/parts/ExtensionApiWorkerCommandMap/ExtensionApiWorkerCommandMap.d.ts +3 -0
- package/extension-api/dist/parts/NotifyStatusBarChange/NotifyStatusBarChange.js +2 -2
- package/extension-api/dist/parts/OutputChannel/OutputChannel.d.ts +9 -0
- package/extension-api/dist/parts/OutputChannel/OutputChannel.js +64 -0
- package/extension-api/dist/parts/OutputChannelHandle/OutputChannelHandle.d.ts +6 -0
- package/extension-api/dist/parts/OutputChannelHandle/OutputChannelHandle.js +1 -0
- package/extension-api/dist/parts/OutputChannelRegistrySnapshot/OutputChannelRegistrySnapshot.d.ts +4 -0
- package/extension-api/dist/parts/OutputChannelRegistrySnapshot/OutputChannelRegistrySnapshot.js +1 -0
- package/extension-api/dist/parts/QuickPick/QuickPick.js +2 -2
- package/extension-api/dist/parts/RegisteredOutputChannel/RegisteredOutputChannel.d.ts +3 -0
- package/extension-api/dist/parts/RegisteredOutputChannel/RegisteredOutputChannel.js +1 -0
- package/extension-api/dist/parts/View/View.d.ts +14 -0
- package/extension-api/dist/parts/View/View.js +1 -0
- package/extension-api/dist/parts/ViewRegistry/ViewRegistry.d.ts +6 -0
- package/extension-api/dist/parts/ViewRegistry/ViewRegistry.js +49 -0
- package/extension-api/package.json +3 -2
- package/extension-api/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/extension-api/parts/Rpc/Rpc.js +0 -14
- package/extension-api/dist/parts/Rpc/Rpc.d.ts +0 -3
- package/extension-api/dist/parts/Rpc/Rpc.js +0 -10
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ExtensionManagementWorker } from '@lvce-editor/rpc-registry';
|
|
2
|
+
import { ExtensionApiError } from "../ExtensionApiError/ExtensionApiError.js";
|
|
3
|
+
const outputChannels = Object.create(null);
|
|
4
|
+
let isActivated = false;
|
|
5
|
+
const RE_DASH_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
6
|
+
const assertOutputChannelId = (id) => {
|
|
7
|
+
if (typeof id !== 'string' || id.length === 0) {
|
|
8
|
+
throw new ExtensionApiError('output channel id is required');
|
|
9
|
+
}
|
|
10
|
+
if (!RE_DASH_CASE.test(id)) {
|
|
11
|
+
throw new ExtensionApiError(`output channel id ${id} must be dash-case`);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const assertCanWrite = (id) => {
|
|
15
|
+
if (!isActivated) {
|
|
16
|
+
throw new ExtensionApiError(`output channel ${id} cannot be written before activate`);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
class ExtensionOutputChannel {
|
|
20
|
+
#id;
|
|
21
|
+
constructor(id) {
|
|
22
|
+
this.#id = id;
|
|
23
|
+
}
|
|
24
|
+
async append(text) {
|
|
25
|
+
assertCanWrite(this.#id);
|
|
26
|
+
await ExtensionManagementWorker.invoke('ExtensionApi.appendOutputChannel', this.#id, text);
|
|
27
|
+
}
|
|
28
|
+
async appendLine(text) {
|
|
29
|
+
assertCanWrite(this.#id);
|
|
30
|
+
await ExtensionManagementWorker.invoke('ExtensionApi.appendOutputChannel', this.#id, `${text}\n`);
|
|
31
|
+
}
|
|
32
|
+
async clear() {
|
|
33
|
+
assertCanWrite(this.#id);
|
|
34
|
+
await ExtensionManagementWorker.invoke('ExtensionApi.clearOutputChannel', this.#id);
|
|
35
|
+
}
|
|
36
|
+
async replace(text) {
|
|
37
|
+
assertCanWrite(this.#id);
|
|
38
|
+
await ExtensionManagementWorker.invoke('ExtensionApi.replaceOutputChannel', this.#id, text);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const activateOutputChannels = () => {
|
|
42
|
+
isActivated = true;
|
|
43
|
+
};
|
|
44
|
+
export const createOutputChannel = (id) => {
|
|
45
|
+
assertOutputChannelId(id);
|
|
46
|
+
if (id in outputChannels) {
|
|
47
|
+
throw new ExtensionApiError(`output channel ${id} is already created`);
|
|
48
|
+
}
|
|
49
|
+
outputChannels[id] = {
|
|
50
|
+
id,
|
|
51
|
+
};
|
|
52
|
+
return new ExtensionOutputChannel(id);
|
|
53
|
+
};
|
|
54
|
+
export const getOutputChannelRegistrySnapshot = () => {
|
|
55
|
+
return {
|
|
56
|
+
outputChannels: Object.values(outputChannels),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export const resetOutputChannelRegistry = () => {
|
|
60
|
+
for (const id of Object.keys(outputChannels)) {
|
|
61
|
+
delete outputChannels[id];
|
|
62
|
+
}
|
|
63
|
+
isActivated = false;
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/extension-api/dist/parts/OutputChannelRegistrySnapshot/OutputChannelRegistrySnapshot.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExtensionManagementWorker } from '@lvce-editor/rpc-registry';
|
|
2
2
|
export const showQuickPick = async (options) => {
|
|
3
|
-
return
|
|
3
|
+
return ExtensionManagementWorker.invoke('ExtensionHostQuickPick.showQuickPick', options);
|
|
4
4
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface View {
|
|
2
|
+
readonly create: () => unknown;
|
|
3
|
+
readonly icon?: string;
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly title?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RegisteredView {
|
|
8
|
+
readonly icon?: string;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly title?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ViewRegistrySnapshot {
|
|
13
|
+
readonly views: readonly RegisteredView[];
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Disposable } from '../Disposable/Disposable.ts';
|
|
2
|
+
import type { View, ViewRegistrySnapshot } from '../View/View.ts';
|
|
3
|
+
export declare const registerView: (view: View) => Disposable;
|
|
4
|
+
export declare const executeViewProvider: (id: string) => unknown;
|
|
5
|
+
export declare const getViewRegistrySnapshot: () => ViewRegistrySnapshot;
|
|
6
|
+
export declare const resetViewRegistry: () => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ExtensionApiError } from "../ExtensionApiError/ExtensionApiError.js";
|
|
2
|
+
const views = Object.create(null);
|
|
3
|
+
const assertView = (view) => {
|
|
4
|
+
if (!view) {
|
|
5
|
+
throw new ExtensionApiError('view is not defined');
|
|
6
|
+
}
|
|
7
|
+
if (typeof view.id !== 'string' || view.id.length === 0) {
|
|
8
|
+
throw new ExtensionApiError('view is missing id');
|
|
9
|
+
}
|
|
10
|
+
if (typeof view.create !== 'function') {
|
|
11
|
+
throw new ExtensionApiError(`view ${view.id} is missing create function`);
|
|
12
|
+
}
|
|
13
|
+
if (view.id in views) {
|
|
14
|
+
throw new ExtensionApiError(`view ${view.id} is already registered`);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const toRegisteredView = (view) => {
|
|
18
|
+
return {
|
|
19
|
+
icon: view.icon,
|
|
20
|
+
id: view.id,
|
|
21
|
+
title: view.title,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const registerView = (view) => {
|
|
25
|
+
assertView(view);
|
|
26
|
+
views[view.id] = view;
|
|
27
|
+
return {
|
|
28
|
+
dispose() {
|
|
29
|
+
delete views[view.id];
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export const executeViewProvider = (id) => {
|
|
34
|
+
const view = views[id];
|
|
35
|
+
if (!view) {
|
|
36
|
+
throw new ExtensionApiError(`view ${id} not found`);
|
|
37
|
+
}
|
|
38
|
+
return view.create();
|
|
39
|
+
};
|
|
40
|
+
export const getViewRegistrySnapshot = () => {
|
|
41
|
+
return {
|
|
42
|
+
views: Object.values(views).map(toRegisteredView),
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export const resetViewRegistry = () => {
|
|
46
|
+
for (const id of Object.keys(views)) {
|
|
47
|
+
delete views[id];
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/api",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.24.0",
|
|
4
4
|
"description": "Tree-shakeable extension API for Lvce Editor extensions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lvce-editor",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@lvce-editor/rpc": "^6.4.0"
|
|
30
|
+
"@lvce-editor/rpc": "^6.4.0",
|
|
31
|
+
"@lvce-editor/rpc-registry": "^9.24.0"
|
|
31
32
|
}
|
|
32
33
|
}
|