@lvce-editor/api 9.20.0 → 9.22.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/README.md +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parts/ElectronWebContentsView/ElectronWebContentsView.d.ts +2 -1
- package/dist/parts/ElectronWebContentsView/ElectronWebContentsView.js +5 -2
- package/dist/parts/Platform/Platform.d.ts +1 -0
- package/dist/parts/Platform/Platform.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,14 @@ export const main = () => {
|
|
|
22
22
|
|
|
23
23
|
The package is published as unbundled ESM with TypeScript declaration files, so extensions can bundle it with their own build tooling.
|
|
24
24
|
|
|
25
|
+
Extensions running on Electron or a remote host can request the editor's user data directory as a `file:` URI. The call throws on the web platform.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { getUserDataDir } from '@lvce-editor/api'
|
|
29
|
+
|
|
30
|
+
const userDataDir = await getUserDataDir()
|
|
31
|
+
```
|
|
32
|
+
|
|
25
33
|
Electron extensions can create an off-screen web contents view. It stays hidden for the lifetime of the handle, and disposing the handle destroys its web contents.
|
|
26
34
|
|
|
27
35
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export { executeFileSystemProviderGetPathSeparator, executeFileSystemProviderIsR
|
|
|
18
18
|
export { closeUri, confirm, getRecentlyOpenedWorkspaceUris, getWorkspaceFolder, getWorkspaceUri, handleWorkspaceRefresh, openUri, setWorkspaceUri, showNotification, type NotificationType, } from './parts/Host/Host.ts';
|
|
19
19
|
export { executeHoverProvider, getHoverProviderRegistrySnapshot, registerHoverProvider, resetHoverProviderRegistry } from './parts/Hover/Hover.ts';
|
|
20
20
|
export { executeSignatureHelpProvider, getSignatureHelpProviderRegistrySnapshot, registerSignatureHelpProvider, resetSignatureHelpProviderRegistry, } from './parts/SignatureHelp/SignatureHelp.ts';
|
|
21
|
-
export { getPlatform, type Platform } from './parts/Platform/Platform.ts';
|
|
21
|
+
export { getPlatform, getUserDataDir, type Platform } from './parts/Platform/Platform.ts';
|
|
22
22
|
export { focusNextTab, focusPreviousTab } from './parts/MainArea/MainArea.ts';
|
|
23
23
|
export { openProcessExplorer } from './parts/ProcessExplorer/ProcessExplorer.ts';
|
|
24
24
|
export { openDebugConsole, openOutputView, openProblemsView, type OpenDebugConsoleOptions, type OpenOutputViewOptions, type OpenProblemsViewOptions, } from './parts/Panel/Panel.ts';
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export { executeFileSystemProviderGetPathSeparator, executeFileSystemProviderIsR
|
|
|
18
18
|
export { closeUri, confirm, getRecentlyOpenedWorkspaceUris, getWorkspaceFolder, getWorkspaceUri, handleWorkspaceRefresh, openUri, setWorkspaceUri, showNotification, } from "./parts/Host/Host.js";
|
|
19
19
|
export { executeHoverProvider, getHoverProviderRegistrySnapshot, registerHoverProvider, resetHoverProviderRegistry } from "./parts/Hover/Hover.js";
|
|
20
20
|
export { executeSignatureHelpProvider, getSignatureHelpProviderRegistrySnapshot, registerSignatureHelpProvider, resetSignatureHelpProviderRegistry, } from "./parts/SignatureHelp/SignatureHelp.js";
|
|
21
|
-
export { getPlatform } from "./parts/Platform/Platform.js";
|
|
21
|
+
export { getPlatform, getUserDataDir } from "./parts/Platform/Platform.js";
|
|
22
22
|
export { focusNextTab, focusPreviousTab } from "./parts/MainArea/MainArea.js";
|
|
23
23
|
export { openProcessExplorer } from "./parts/ProcessExplorer/ProcessExplorer.js";
|
|
24
24
|
export { openDebugConsole, openOutputView, openProblemsView, } from "./parts/Panel/Panel.js";
|
|
@@ -8,8 +8,9 @@ export interface ElectronWebContentsViewStats {
|
|
|
8
8
|
readonly url: string;
|
|
9
9
|
}
|
|
10
10
|
export interface ElectronWebContentsView {
|
|
11
|
+
readonly click: (selector: string) => Promise<boolean>;
|
|
11
12
|
readonly dispose: () => Promise<void>;
|
|
12
|
-
readonly executeJavaScript: <T = unknown>(code: string) => Promise<T>;
|
|
13
|
+
readonly executeJavaScript: <T = unknown>(code: string, userGesture?: boolean) => Promise<T>;
|
|
13
14
|
readonly getStats: () => Promise<ElectronWebContentsViewStats>;
|
|
14
15
|
readonly loadUrl: (url: string) => Promise<void>;
|
|
15
16
|
readonly reload: () => Promise<void>;
|
|
@@ -38,6 +38,9 @@ export const createElectronWebContentsView = async ({ url } = {}) => {
|
|
|
38
38
|
throw error;
|
|
39
39
|
}
|
|
40
40
|
return {
|
|
41
|
+
async click(selector) {
|
|
42
|
+
return (await rpc.invoke('ElectronWebContentsView.click', id, selector));
|
|
43
|
+
},
|
|
41
44
|
async dispose() {
|
|
42
45
|
if (disposed) {
|
|
43
46
|
return;
|
|
@@ -45,8 +48,8 @@ export const createElectronWebContentsView = async ({ url } = {}) => {
|
|
|
45
48
|
disposed = true;
|
|
46
49
|
await disposeAfterCreateError(rpc, id);
|
|
47
50
|
},
|
|
48
|
-
async executeJavaScript(code) {
|
|
49
|
-
return (await rpc.invoke('ElectronWebContentsView.insertJavaScript', id, code));
|
|
51
|
+
async executeJavaScript(code, userGesture = false) {
|
|
52
|
+
return (await rpc.invoke('ElectronWebContentsView.insertJavaScript', id, code, userGesture));
|
|
50
53
|
},
|
|
51
54
|
async getStats() {
|
|
52
55
|
return (await rpc.invoke('ElectronWebContentsView.getStats', id));
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { executeCommand } from "../ExecuteCommand/ExecuteCommand.js";
|
|
2
|
+
export const getUserDataDir = async () => {
|
|
3
|
+
return (await executeCommand('Platform.getUserDataDir'));
|
|
4
|
+
};
|
|
2
5
|
export const getPlatform = async () => {
|
|
3
6
|
const platform = await executeCommand('Layout.getPlatform');
|
|
4
7
|
switch (platform) {
|