@lvce-editor/api 8.41.0 → 8.43.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/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/parts/FileSystem/FileSystem.d.ts +1 -0
- package/dist/parts/FileSystem/FileSystem.js +3 -0
- package/dist/parts/Host/Host.d.ts +4 -0
- package/dist/parts/Host/Host.js +13 -0
- package/dist/parts/Rpc/Rpc.d.ts +12 -0
- package/dist/parts/Rpc/Rpc.js +20 -0
- package/dist/parts/View/View.d.ts +3 -0
- package/dist/parts/ViewRegistry/ViewRegistry.js +20 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export { registerCommand } from './parts/CommandRegistry/CommandRegistry.ts';
|
|
|
6
6
|
export { executeCompletionProvider, executeResolveCompletionItemProvider, getCompletionProviderRegistrySnapshot, registerCompletionProvider, resetCompletionProviderRegistry, } from './parts/Completion/Completion.ts';
|
|
7
7
|
export { executeDiagnosticProvider, getDiagnosticProviderRegistrySnapshot, registerDiagnosticProvider, resetDiagnosticProviderRegistry, } from './parts/Diagnostic/Diagnostic.ts';
|
|
8
8
|
export { executeFormattingProvider, getFormattingProviderRegistrySnapshot, registerFormattingProvider, resetFormattingProviderRegistry, } from './parts/Formatting/Formatting.ts';
|
|
9
|
-
export { exists, mkdir, readDirWithFileTypes, readFile, remove, writeFile } from './parts/FileSystem/FileSystem.ts';
|
|
9
|
+
export { exists, mkdir, readDirWithFileTypes, readFile, remove, stat, writeFile } from './parts/FileSystem/FileSystem.ts';
|
|
10
|
+
export { confirm, getWorkspaceFolder, handleWorkspaceRefresh, openUri } from './parts/Host/Host.ts';
|
|
10
11
|
export { executeHoverProvider, getHoverProviderRegistrySnapshot, registerHoverProvider, resetHoverProviderRegistry } from './parts/Hover/Hover.ts';
|
|
11
12
|
export { executeSourceControlAcceptInput, executeSourceControlAdd, executeSourceControlDiscard, executeSourceControlGenerateCommitMessage, executeSourceControlGetBadgeCount, executeSourceControlGetChangedFiles, executeSourceControlGetFeatures, executeSourceControlGetFileBefore, executeSourceControlGetFileDecorations, executeSourceControlGetGroups, executeSourceControlIsActive, registerSourceControlProvider, resetSourceControlProviderRegistry, } from './parts/SourceControl/SourceControl.ts';
|
|
12
13
|
export { createViewInstance, dispatchViewEvent, disposeViewInstance, executeViewProvider, getViewRegistrySnapshot, renderViewInstance, registerView, resetViewRegistry, saveViewInstanceState, } from './parts/ViewRegistry/ViewRegistry.ts';
|
|
@@ -14,6 +15,7 @@ export { createOutputChannel, getOutputChannelRegistrySnapshot, resetOutputChann
|
|
|
14
15
|
export { getStatusBarItemProviderRegistrySnapshot, registerStatusBarItemProvider, resetStatusBarItemProviderRegistry, } from './parts/StatusBar/StatusBar.ts';
|
|
15
16
|
export type { RegisteredView, View, ViewAction, ViewCommand, ViewContext, ViewEvent, ViewKind, MenuEntry, ViewRegistrySnapshot, ViewRenderResult, VirtualDomViewInstance, } from './parts/View/View.ts';
|
|
16
17
|
export { handleExtensionManagementMessagePort } from './parts/HandleExtensionManagementMessagePort/HandleExtensionManagementMessagePort.ts';
|
|
18
|
+
export { createNodeRpc, createRpc } from './parts/Rpc/Rpc.ts';
|
|
17
19
|
export type { Command } from './parts/Command/Command.ts';
|
|
18
20
|
export type { CommandCallback } from './parts/CommandCallback/CommandCallback.ts';
|
|
19
21
|
export type { CommandRegistrySnapshot } from './parts/CommandRegistrySnapshot/CommandRegistrySnapshot.ts';
|
|
@@ -28,6 +30,7 @@ export type { OutputChannel } from './parts/OutputChannelHandle/OutputChannelHan
|
|
|
28
30
|
export type { OutputChannelRegistrySnapshot } from './parts/OutputChannelRegistrySnapshot/OutputChannelRegistrySnapshot.ts';
|
|
29
31
|
export type { RegisteredOutputChannel } from './parts/RegisteredOutputChannel/RegisteredOutputChannel.ts';
|
|
30
32
|
export type { QuickPickItem } from './parts/QuickPickItem/QuickPickItem.ts';
|
|
33
|
+
export type { CreateNodeRpcOptions, CreateRpcOptions } from './parts/Rpc/Rpc.ts';
|
|
31
34
|
export type { RegisteredSourceControlProvider, SourceControlProvider, SourceControlProviderRegistrySnapshot, } from './parts/SourceControl/SourceControl.ts';
|
|
32
35
|
export type { ShowQuickPickOptions } from './parts/ShowQuickPickOptions/ShowQuickPickOptions.ts';
|
|
33
36
|
export type { StatusBarItem, StatusBarItemProvider, StatusBarItemProviderHandle, StatusBarItemProviderRegistrySnapshot, } from './parts/StatusBar/StatusBar.ts';
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,12 @@ export { registerCommand } from "./parts/CommandRegistry/CommandRegistry.js";
|
|
|
6
6
|
export { executeCompletionProvider, executeResolveCompletionItemProvider, getCompletionProviderRegistrySnapshot, registerCompletionProvider, resetCompletionProviderRegistry, } from "./parts/Completion/Completion.js";
|
|
7
7
|
export { executeDiagnosticProvider, getDiagnosticProviderRegistrySnapshot, registerDiagnosticProvider, resetDiagnosticProviderRegistry, } from "./parts/Diagnostic/Diagnostic.js";
|
|
8
8
|
export { executeFormattingProvider, getFormattingProviderRegistrySnapshot, registerFormattingProvider, resetFormattingProviderRegistry, } from "./parts/Formatting/Formatting.js";
|
|
9
|
-
export { exists, mkdir, readDirWithFileTypes, readFile, remove, writeFile } from "./parts/FileSystem/FileSystem.js";
|
|
9
|
+
export { exists, mkdir, readDirWithFileTypes, readFile, remove, stat, writeFile } from "./parts/FileSystem/FileSystem.js";
|
|
10
|
+
export { confirm, getWorkspaceFolder, handleWorkspaceRefresh, openUri } from "./parts/Host/Host.js";
|
|
10
11
|
export { executeHoverProvider, getHoverProviderRegistrySnapshot, registerHoverProvider, resetHoverProviderRegistry } from "./parts/Hover/Hover.js";
|
|
11
12
|
export { executeSourceControlAcceptInput, executeSourceControlAdd, executeSourceControlDiscard, executeSourceControlGenerateCommitMessage, executeSourceControlGetBadgeCount, executeSourceControlGetChangedFiles, executeSourceControlGetFeatures, executeSourceControlGetFileBefore, executeSourceControlGetFileDecorations, executeSourceControlGetGroups, executeSourceControlIsActive, registerSourceControlProvider, resetSourceControlProviderRegistry, } from "./parts/SourceControl/SourceControl.js";
|
|
12
13
|
export { createViewInstance, dispatchViewEvent, disposeViewInstance, executeViewProvider, getViewRegistrySnapshot, renderViewInstance, registerView, resetViewRegistry, saveViewInstanceState, } from "./parts/ViewRegistry/ViewRegistry.js";
|
|
13
14
|
export { createOutputChannel, getOutputChannelRegistrySnapshot, resetOutputChannelRegistry } from "./parts/OutputChannel/OutputChannel.js";
|
|
14
15
|
export { getStatusBarItemProviderRegistrySnapshot, registerStatusBarItemProvider, resetStatusBarItemProviderRegistry, } from "./parts/StatusBar/StatusBar.js";
|
|
15
16
|
export { handleExtensionManagementMessagePort } from "./parts/HandleExtensionManagementMessagePort/HandleExtensionManagementMessagePort.js";
|
|
17
|
+
export { createNodeRpc, createRpc } from "./parts/Rpc/Rpc.js";
|
|
@@ -4,5 +4,6 @@ export declare const readDirWithFileTypes: (uri: string) => Promise<readonly Fil
|
|
|
4
4
|
export declare const readFile: (uri: string) => Promise<string>;
|
|
5
5
|
export declare const mkdir: (uri: string) => Promise<void>;
|
|
6
6
|
export declare const remove: (uri: string) => Promise<void>;
|
|
7
|
+
export declare const stat: (uri: string) => Promise<unknown>;
|
|
7
8
|
export declare const writeFile: (uri: string, content: string) => Promise<void>;
|
|
8
9
|
export type { FileSystemDirent } from '../FileSystemDirent/FileSystemDirent.ts';
|
|
@@ -21,6 +21,9 @@ export const mkdir = async (uri) => {
|
|
|
21
21
|
export const remove = async (uri) => {
|
|
22
22
|
await FileSystemWorker.remove(uri);
|
|
23
23
|
};
|
|
24
|
+
export const stat = async (uri) => {
|
|
25
|
+
return FileSystemWorker.stat(uri);
|
|
26
|
+
};
|
|
24
27
|
export const writeFile = async (uri, content) => {
|
|
25
28
|
await FileSystemWorker.writeFile(uri, content);
|
|
26
29
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { executeCommand } from "../ExecuteCommand/ExecuteCommand.js";
|
|
2
|
+
export const confirm = async (message) => {
|
|
3
|
+
return Boolean(await executeCommand('ConfirmPrompt.prompt', message));
|
|
4
|
+
};
|
|
5
|
+
export const getWorkspaceFolder = async () => {
|
|
6
|
+
return (await executeCommand('Workspace.getPath'));
|
|
7
|
+
};
|
|
8
|
+
export const handleWorkspaceRefresh = async () => {
|
|
9
|
+
await executeCommand('Layout.handleWorkspaceRefresh');
|
|
10
|
+
};
|
|
11
|
+
export const openUri = async (uri) => {
|
|
12
|
+
await executeCommand('Main.openUri', uri);
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Rpc } from '@lvce-editor/rpc';
|
|
2
|
+
export interface CreateRpcOptions {
|
|
3
|
+
readonly commandMap?: Record<string, unknown>;
|
|
4
|
+
readonly name?: string;
|
|
5
|
+
readonly url: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateNodeRpcOptions {
|
|
8
|
+
readonly name?: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const createRpc: ({ commandMap, name, url }: CreateRpcOptions) => Promise<Rpc>;
|
|
12
|
+
export declare const createNodeRpc: ({ path }: CreateNodeRpcOptions) => Promise<Rpc>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LazyTransferMessagePortRpcParent, ModuleWorkerRpcParent } from '@lvce-editor/rpc';
|
|
2
|
+
import { ExtensionManagementWorker } from '@lvce-editor/rpc-registry';
|
|
3
|
+
const sendMessagePortToNode = async (port) => {
|
|
4
|
+
await ExtensionManagementWorker.invokeAndTransfer('Extensions.sendMessagePortToElectron', port, 'HandleMessagePortForExtensionHostHelperProcess.handleMessagePortForExtensionHostHelperProcess');
|
|
5
|
+
};
|
|
6
|
+
export const createRpc = async ({ commandMap = {}, name = '', url }) => {
|
|
7
|
+
return ModuleWorkerRpcParent.create({
|
|
8
|
+
commandMap,
|
|
9
|
+
name,
|
|
10
|
+
url,
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export const createNodeRpc = async ({ path }) => {
|
|
14
|
+
const rpc = await LazyTransferMessagePortRpcParent.create({
|
|
15
|
+
commandMap: {},
|
|
16
|
+
send: sendMessagePortToNode,
|
|
17
|
+
});
|
|
18
|
+
await rpc.invoke('LoadFile.loadFile', path);
|
|
19
|
+
return rpc;
|
|
20
|
+
};
|
|
@@ -42,6 +42,7 @@ export interface VirtualDomViewInstance {
|
|
|
42
42
|
readonly render: () => readonly VirtualDomNode[] | Promise<readonly VirtualDomNode[]>;
|
|
43
43
|
readonly renderActions?: () => readonly ViewAction[] | Promise<readonly ViewAction[]>;
|
|
44
44
|
readonly renderFocus?: (oldContext: Readonly<Record<string, boolean>>, newContext: Readonly<Record<string, boolean>>) => string | Promise<string>;
|
|
45
|
+
readonly renderTitle?: () => string | Promise<string>;
|
|
45
46
|
readonly saveState?: () => unknown;
|
|
46
47
|
}
|
|
47
48
|
export type ViewCommand<State = VirtualDomViewInstance, Args extends readonly any[] = readonly any[]> = (state: State, ...args: Args) => State | Promise<State>;
|
|
@@ -71,11 +72,13 @@ export interface ViewRegistrySnapshot {
|
|
|
71
72
|
export interface ViewRenderResultDom {
|
|
72
73
|
readonly dom: readonly VirtualDomNode[];
|
|
73
74
|
readonly focusSelector?: string;
|
|
75
|
+
readonly title?: string;
|
|
74
76
|
readonly type: 'setDom';
|
|
75
77
|
}
|
|
76
78
|
export interface ViewRenderResultPatches {
|
|
77
79
|
readonly focusSelector?: string;
|
|
78
80
|
readonly patches: readonly unknown[];
|
|
81
|
+
readonly title?: string;
|
|
79
82
|
readonly type: 'setPatches';
|
|
80
83
|
}
|
|
81
84
|
export type ViewRenderResult = ViewRenderResultDom | ViewRenderResultPatches;
|
|
@@ -323,6 +323,23 @@ const withFocusSelector = async (result, instance, contextChange) => {
|
|
|
323
323
|
focusSelector,
|
|
324
324
|
};
|
|
325
325
|
};
|
|
326
|
+
const withTitle = async (result, instance) => {
|
|
327
|
+
if (typeof instance.renderTitle !== 'function') {
|
|
328
|
+
return result;
|
|
329
|
+
}
|
|
330
|
+
const title = await instance.renderTitle();
|
|
331
|
+
if (typeof title !== 'string') {
|
|
332
|
+
throw new ExtensionApiError('view renderTitle result must be a string');
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
...result,
|
|
336
|
+
title,
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
const withRenderMetadata = async (result, instance, contextChange) => {
|
|
340
|
+
const resultWithFocus = await withFocusSelector(result, instance, contextChange);
|
|
341
|
+
return withTitle(resultWithFocus, instance);
|
|
342
|
+
};
|
|
326
343
|
const maybeClearContext = async (uid, viewId) => {
|
|
327
344
|
if (!contexts[uid]) {
|
|
328
345
|
return;
|
|
@@ -365,7 +382,7 @@ export const createViewInstance = async (viewId, uid, context) => {
|
|
|
365
382
|
type: 'setDom',
|
|
366
383
|
};
|
|
367
384
|
const contextChange = await maybeNotifyContextChanged(uid, viewId, instance);
|
|
368
|
-
return
|
|
385
|
+
return withRenderMetadata(result, instance, contextChange);
|
|
369
386
|
};
|
|
370
387
|
export const dispatchViewEvent = async (uid, event) => {
|
|
371
388
|
const instance = getVirtualDomInstance(uid);
|
|
@@ -377,13 +394,13 @@ export const dispatchViewEvent = async (uid, event) => {
|
|
|
377
394
|
}
|
|
378
395
|
const result = await renderPatches(uid, instance);
|
|
379
396
|
const contextChange = await maybeNotifyContextChanged(uid, contextViewIds[uid], instance);
|
|
380
|
-
return
|
|
397
|
+
return withRenderMetadata(result, instance, contextChange);
|
|
381
398
|
};
|
|
382
399
|
export const renderViewInstance = async (uid) => {
|
|
383
400
|
const instance = getVirtualDomInstance(uid);
|
|
384
401
|
const result = await renderPatches(uid, instance);
|
|
385
402
|
const contextChange = await maybeNotifyContextChanged(uid, contextViewIds[uid], instance);
|
|
386
|
-
return
|
|
403
|
+
return withRenderMetadata(result, instance, contextChange);
|
|
387
404
|
};
|
|
388
405
|
export const disposeViewInstance = async (uid) => {
|
|
389
406
|
const instance = instances[uid];
|