@lvce-editor/extension-host-worker 8.63.0 → 8.65.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.
@@ -0,0 +1,114 @@
1
+ import { executeCommand } from "../ExecuteCommand/ExecuteCommand.js";
2
+ import { ExtensionApiError } from "../ExtensionApiError/ExtensionApiError.js";
3
+ const providers = /* @__PURE__ */ Object.create(null);
4
+ const requiredMethods = [
5
+ "evaluate",
6
+ "getProperties",
7
+ "listProcesses",
8
+ "pause",
9
+ "resume",
10
+ "setPauseOnExceptions",
11
+ "start",
12
+ "step",
13
+ "stepInto",
14
+ "stepOut",
15
+ "stepOver"
16
+ ];
17
+ const assertDebugProvider = (provider) => {
18
+ if (!provider) {
19
+ throw new ExtensionApiError("debug provider is not defined");
20
+ }
21
+ if (typeof provider.id !== "string" || provider.id.length === 0) {
22
+ throw new ExtensionApiError("debug provider is missing id");
23
+ }
24
+ for (const methodName of requiredMethods) {
25
+ if (typeof provider[methodName] !== "function") {
26
+ throw new ExtensionApiError(`debug provider ${provider.id} is missing ${methodName} function`);
27
+ }
28
+ }
29
+ if (provider.id in providers) {
30
+ throw new ExtensionApiError(`debug provider ${provider.id} is already registered`);
31
+ }
32
+ };
33
+ const getProvider = (id) => {
34
+ const provider = providers[id];
35
+ if (!provider) {
36
+ throw new ExtensionApiError(`debug provider ${id} not found`);
37
+ }
38
+ return provider;
39
+ };
40
+ const emitter = {
41
+ async handleChange() {
42
+ },
43
+ async handlePaused(params) {
44
+ await executeCommand("Debug.paused", params);
45
+ },
46
+ async handleResumed() {
47
+ await executeCommand("Debug.resumed");
48
+ },
49
+ async handleScriptParsed(script) {
50
+ await executeCommand("Debug.scriptParsed", script);
51
+ }
52
+ };
53
+ const registerDebugProvider = (provider) => {
54
+ assertDebugProvider(provider);
55
+ providers[provider.id] = provider;
56
+ return {
57
+ dispose() {
58
+ delete providers[provider.id];
59
+ }
60
+ };
61
+ };
62
+ const executeDebugStart = async (id, path) => {
63
+ return getProvider(id).start(emitter, path);
64
+ };
65
+ const executeDebugListProcesses = async (id, path) => {
66
+ return getProvider(id).listProcesses(path);
67
+ };
68
+ const executeDebugResume = async (id) => {
69
+ return getProvider(id).resume();
70
+ };
71
+ const executeDebugPause = async (id) => {
72
+ return getProvider(id).pause();
73
+ };
74
+ const executeDebugStepOver = async (id) => {
75
+ return getProvider(id).stepOver();
76
+ };
77
+ const executeDebugStepInto = async (id) => {
78
+ return getProvider(id).stepInto();
79
+ };
80
+ const executeDebugStepOut = async (id) => {
81
+ return getProvider(id).stepOut();
82
+ };
83
+ const executeDebugStep = async (id) => {
84
+ return getProvider(id).step();
85
+ };
86
+ const executeDebugSetPauseOnExceptions = async (id, value) => {
87
+ return getProvider(id).setPauseOnExceptions(value);
88
+ };
89
+ const executeDebugGetProperties = async (id, objectId) => {
90
+ return getProvider(id).getProperties(objectId);
91
+ };
92
+ const executeDebugEvaluate = async (id, expression, callFrameId) => {
93
+ return getProvider(id).evaluate(expression, callFrameId);
94
+ };
95
+ const resetDebugProviderRegistry = () => {
96
+ for (const id of Object.keys(providers)) {
97
+ delete providers[id];
98
+ }
99
+ };
100
+ export {
101
+ executeDebugEvaluate,
102
+ executeDebugGetProperties,
103
+ executeDebugListProcesses,
104
+ executeDebugPause,
105
+ executeDebugResume,
106
+ executeDebugSetPauseOnExceptions,
107
+ executeDebugStart,
108
+ executeDebugStep,
109
+ executeDebugStepInto,
110
+ executeDebugStepOut,
111
+ executeDebugStepOver,
112
+ registerDebugProvider,
113
+ resetDebugProviderRegistry
114
+ };
@@ -1,5 +1,18 @@
1
1
  import { executeCommand, getCommandRegistrySnapshot } from "../CommandRegistry/CommandRegistry.js";
2
2
  import { executeCompletionProvider, executeResolveCompletionItemProvider, getCompletionProviderRegistrySnapshot } from "../Completion/Completion.js";
3
+ import {
4
+ executeDebugEvaluate,
5
+ executeDebugGetProperties,
6
+ executeDebugListProcesses,
7
+ executeDebugPause,
8
+ executeDebugResume,
9
+ executeDebugSetPauseOnExceptions,
10
+ executeDebugStart,
11
+ executeDebugStep,
12
+ executeDebugStepInto,
13
+ executeDebugStepOut,
14
+ executeDebugStepOver
15
+ } from "../Debug/Debug.js";
3
16
  import { executeDiagnosticProvider, getDiagnosticProviderRegistrySnapshot } from "../Diagnostic/Diagnostic.js";
4
17
  import {
5
18
  executeFileSystemProviderGetPathSeparator,
@@ -85,7 +98,18 @@ const commandMap = {
85
98
  "ExtensionApi.getViewMenuEntries": getViewMenuEntries,
86
99
  "ExtensionApi.getViewRegistrySnapshot": getViewRegistrySnapshot,
87
100
  "ExtensionApi.renderViewInstance": renderViewInstance,
88
- "ExtensionApi.saveViewInstanceState": saveViewInstanceState
101
+ "ExtensionApi.saveViewInstanceState": saveViewInstanceState,
102
+ "ExtensionHostDebug.evaluate": executeDebugEvaluate,
103
+ "ExtensionHostDebug.getProperties": executeDebugGetProperties,
104
+ "ExtensionHostDebug.listProcesses": executeDebugListProcesses,
105
+ "ExtensionHostDebug.pause": executeDebugPause,
106
+ "ExtensionHostDebug.resume": executeDebugResume,
107
+ "ExtensionHostDebug.setPauseOnExceptions": executeDebugSetPauseOnExceptions,
108
+ "ExtensionHostDebug.start": executeDebugStart,
109
+ "ExtensionHostDebug.step": executeDebugStep,
110
+ "ExtensionHostDebug.stepInto": executeDebugStepInto,
111
+ "ExtensionHostDebug.stepOut": executeDebugStepOut,
112
+ "ExtensionHostDebug.stepOver": executeDebugStepOver
89
113
  };
90
114
  export {
91
115
  commandMap
@@ -1,7 +1,7 @@
1
1
  import { MessagePortRpcParent } from "@lvce-editor/rpc";
2
2
  import { ExtensionManagementWorker } from "@lvce-editor/rpc-registry";
3
- const sendMessagePortToWebWorker = async (port, name, url) => {
4
- await ExtensionManagementWorker.invokeAndTransfer("Extensions.createWebViewWorkerRpc2", { name, url }, port);
3
+ const sendMessagePortToWebWorker = async (port, contentSecurityPolicy, name, url) => {
4
+ await ExtensionManagementWorker.invokeAndTransfer("Extensions.createWebViewWorkerRpc2", { contentSecurityPolicy, name, url }, port);
5
5
  };
6
6
  const createMessagePortRpc = async (commandMap, send) => {
7
7
  const { port1, port2 } = new MessageChannel();
@@ -14,8 +14,8 @@ const createMessagePortRpc = async (commandMap, send) => {
14
14
  await send(port1);
15
15
  return rpcPromise;
16
16
  };
17
- const createRpc = async ({ commandMap = {}, name = "", url }) => {
18
- return createMessagePortRpc(commandMap, (port) => sendMessagePortToWebWorker(port, name, url));
17
+ const createRpc = async ({ commandMap = {}, contentSecurityPolicy = "", name = "", url }) => {
18
+ return createMessagePortRpc(commandMap, (port) => sendMessagePortToWebWorker(port, contentSecurityPolicy, name, url));
19
19
  };
20
20
  const resolveNodeRpcOptions = async ({ id, name = "", path }) => {
21
21
  if (id) {