@aiot-nexus/plugin-sdk 1.0.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.
Files changed (47) hide show
  1. package/README.md +74 -0
  2. package/dev-host/host.html +344 -0
  3. package/dev-host/main.js +694 -0
  4. package/dev-host/preload.js +22 -0
  5. package/dist/.generated/plugin-framework-version.d.ts +11 -0
  6. package/dist/.generated/plugin-framework-version.js +39 -0
  7. package/dist/.generated/plugin-manifest.schema.json +106 -0
  8. package/dist/browser/frame-client.d.ts +26 -0
  9. package/dist/browser/frame-client.mjs +239 -0
  10. package/dist/src/browser/frame-client.d.ts +26 -0
  11. package/dist/src/browser/frame-client.js +244 -0
  12. package/dist/src/cli/run.d.ts +7 -0
  13. package/dist/src/cli/run.js +270 -0
  14. package/dist/src/cli.d.ts +2 -0
  15. package/dist/src/cli.js +9 -0
  16. package/dist/src/dev.d.ts +36 -0
  17. package/dist/src/dev.js +224 -0
  18. package/dist/src/index.d.ts +7 -0
  19. package/dist/src/index.js +27 -0
  20. package/dist/src/scaffold.d.ts +23 -0
  21. package/dist/src/scaffold.js +306 -0
  22. package/dist/src/types.d.ts +142 -0
  23. package/dist/src/types.js +2 -0
  24. package/dist/src/validation.d.ts +9 -0
  25. package/dist/src/validation.js +160 -0
  26. package/package.json +47 -0
  27. package/templates/minimal/.gitignore.tmpl +4 -0
  28. package/templates/minimal/.vscode/launch.json +22 -0
  29. package/templates/minimal/README.md.tmpl +22 -0
  30. package/templates/minimal/scripts/build.js.tmpl +83 -0
  31. package/templates/minimal/src/main.ts.tmpl +23 -0
  32. package/templates/minimal/src/renderer/app.ts.tmpl +194 -0
  33. package/templates/minimal/src/renderer/index.html +34 -0
  34. package/templates/minimal/src/renderer/plugin.css +164 -0
  35. package/templates/minimal/tsconfig.main.json +15 -0
  36. package/templates/minimal/tsconfig.renderer.json +17 -0
  37. package/templates/sqlite/.gitignore.tmpl +4 -0
  38. package/templates/sqlite/.vscode/launch.json +22 -0
  39. package/templates/sqlite/README.md.tmpl +22 -0
  40. package/templates/sqlite/scripts/build.js.tmpl +143 -0
  41. package/templates/sqlite/src/better-sqlite3.d.ts +22 -0
  42. package/templates/sqlite/src/main.ts.tmpl +190 -0
  43. package/templates/sqlite/src/renderer/app.ts.tmpl +428 -0
  44. package/templates/sqlite/src/renderer/index.html +57 -0
  45. package/templates/sqlite/src/renderer/plugin.css +275 -0
  46. package/templates/sqlite/tsconfig.main.json +15 -0
  47. package/templates/sqlite/tsconfig.renderer.json +17 -0
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPluginFrameClient = exports.PluginFrameClientError = void 0;
4
+ const initMessageType = "nexus-plugin:init";
5
+ const contextChangedMessageType = "nexus-plugin:context-changed";
6
+ const readyMessageType = "nexus-plugin:ready";
7
+ const requestMessageType = "nexus-plugin:request";
8
+ const responseMessageType = "nexus-plugin:response";
9
+ const resizeMessageType = "nexus-plugin:resize";
10
+ const defaultRequestTimeoutMs = 15000;
11
+ class PluginFrameClientError extends Error {
12
+ constructor(code, message) {
13
+ super(message);
14
+ this.name = "PluginFrameClientError";
15
+ this.code = code;
16
+ }
17
+ }
18
+ exports.PluginFrameClientError = PluginFrameClientError;
19
+ function createPluginFrameClient(options = {}) {
20
+ const resolvedFrameWindow = options.frameWindow || (typeof window === "undefined" ? undefined : window);
21
+ if (!resolvedFrameWindow) {
22
+ throw new PluginFrameClientError("ProtocolError", "PluginFrame client requires a browser window.");
23
+ }
24
+ const frameWindow = resolvedFrameWindow;
25
+ const targetWindow = options.targetWindow || frameWindow.parent;
26
+ const requestTimeoutMs = options.requestTimeoutMs === undefined ? defaultRequestTimeoutMs : options.requestTimeoutMs;
27
+ if (!Number.isFinite(requestTimeoutMs) || requestTimeoutMs <= 0) {
28
+ throw new PluginFrameClientError("ProtocolError", "requestTimeoutMs must be a positive finite number.");
29
+ }
30
+ let requestSequence = 0;
31
+ let disposed = false;
32
+ let contextValue;
33
+ let hostOrigin;
34
+ let contextSettled = false;
35
+ let contextTimeoutId;
36
+ let resizeTimer;
37
+ let resizeObserver;
38
+ const pendingRequests = new Map();
39
+ const contextListeners = new Set();
40
+ let resolveContext;
41
+ let rejectContext;
42
+ const contextPromise = new Promise((resolve, reject) => {
43
+ resolveContext = resolve;
44
+ rejectContext = reject;
45
+ });
46
+ void contextPromise.catch(() => undefined);
47
+ contextTimeoutId = frameWindow.setTimeout(() => {
48
+ contextTimeoutId = undefined;
49
+ if (!contextSettled) {
50
+ contextSettled = true;
51
+ rejectContext(new PluginFrameClientError("RequestTimeout", "PluginFrame initialization timed out."));
52
+ }
53
+ }, requestTimeoutMs);
54
+ frameWindow.addEventListener("message", handleMessage);
55
+ if (options.autoResize !== false) {
56
+ frameWindow.addEventListener("resize", scheduleResize);
57
+ const ResizeObserverConstructor = frameWindow.ResizeObserver;
58
+ if (typeof ResizeObserverConstructor === "function") {
59
+ const observer = new ResizeObserverConstructor(scheduleResize);
60
+ observer.observe(options.resizeRoot || frameWindow.document.documentElement);
61
+ resizeObserver = observer;
62
+ }
63
+ }
64
+ targetWindow.postMessage({ type: readyMessageType }, "*");
65
+ function waitForContext() {
66
+ if (disposed) {
67
+ return Promise.reject(disposedError());
68
+ }
69
+ return contextValue ? Promise.resolve(contextValue) : contextPromise;
70
+ }
71
+ function onContextChanged(listener) {
72
+ if (disposed) {
73
+ throw disposedError();
74
+ }
75
+ contextListeners.add(listener);
76
+ return () => {
77
+ contextListeners.delete(listener);
78
+ };
79
+ }
80
+ async function request(method, params) {
81
+ await waitForContext();
82
+ if (disposed) {
83
+ throw disposedError();
84
+ }
85
+ const requestId = "nexus-sdk-" + Date.now() + "-" + (++requestSequence);
86
+ return new Promise((resolve, reject) => {
87
+ const timeoutId = frameWindow.setTimeout(() => {
88
+ pendingRequests.delete(requestId);
89
+ reject(new PluginFrameClientError("RequestTimeout", "PluginFrame request timed out: " + method));
90
+ }, requestTimeoutMs);
91
+ pendingRequests.set(requestId, {
92
+ resolve: (result) => resolve(result),
93
+ reject,
94
+ timeoutId
95
+ });
96
+ post({ type: requestMessageType, requestId, method, params });
97
+ });
98
+ }
99
+ function getSettings() {
100
+ return request("getSettings");
101
+ }
102
+ function updateSettings(values) {
103
+ return request("updateSettings", { values });
104
+ }
105
+ function appendLog(logRequest) {
106
+ return request("appendLog", logRequest);
107
+ }
108
+ function invokeMain(operation, input) {
109
+ return request("invokeMain", { operation, input });
110
+ }
111
+ function handleMessage(event) {
112
+ if (disposed || event.source !== targetWindow || !isRecord(event.data)) {
113
+ return;
114
+ }
115
+ if (hostOrigin !== undefined && event.origin !== hostOrigin) {
116
+ return;
117
+ }
118
+ if (event.data.type === initMessageType || event.data.type === contextChangedMessageType) {
119
+ if (!isPluginRendererContext(event.data.context)) {
120
+ return;
121
+ }
122
+ const hadContext = contextValue !== undefined;
123
+ hostOrigin = event.origin;
124
+ contextValue = event.data.context;
125
+ if (!contextSettled) {
126
+ contextSettled = true;
127
+ if (contextTimeoutId !== undefined) {
128
+ frameWindow.clearTimeout(contextTimeoutId);
129
+ contextTimeoutId = undefined;
130
+ }
131
+ resolveContext(contextValue);
132
+ }
133
+ if (hadContext) {
134
+ notifyContextChanged(contextValue);
135
+ }
136
+ scheduleResize();
137
+ return;
138
+ }
139
+ if (event.data.type !== responseMessageType || typeof event.data.requestId !== "string") {
140
+ return;
141
+ }
142
+ const pending = pendingRequests.get(event.data.requestId);
143
+ if (!pending) {
144
+ return;
145
+ }
146
+ pendingRequests.delete(event.data.requestId);
147
+ frameWindow.clearTimeout(pending.timeoutId);
148
+ if (!isNexusResult(event.data.result)) {
149
+ pending.reject(new PluginFrameClientError("ProtocolError", "PluginFrame response is malformed."));
150
+ return;
151
+ }
152
+ pending.resolve(event.data.result);
153
+ }
154
+ function notifyContextChanged(context) {
155
+ for (const listener of Array.from(contextListeners)) {
156
+ try {
157
+ listener(context);
158
+ }
159
+ catch (error) {
160
+ const logger = frameWindow.console;
161
+ logger?.error("PluginFrame context listener failed.", error);
162
+ }
163
+ }
164
+ }
165
+ function scheduleResize() {
166
+ if (disposed || !contextValue || options.autoResize === false) {
167
+ return;
168
+ }
169
+ if (resizeTimer !== undefined) {
170
+ frameWindow.clearTimeout(resizeTimer);
171
+ }
172
+ if (contextTimeoutId !== undefined) {
173
+ frameWindow.clearTimeout(contextTimeoutId);
174
+ }
175
+ resizeTimer = frameWindow.setTimeout(() => {
176
+ resizeTimer = undefined;
177
+ notifyResize();
178
+ }, 0);
179
+ }
180
+ function notifyResize() {
181
+ if (disposed || !contextValue) {
182
+ return;
183
+ }
184
+ const root = options.resizeRoot || frameWindow.document.documentElement;
185
+ const body = frameWindow.document.body;
186
+ const height = Math.max(root.scrollHeight, root.offsetHeight, body?.scrollHeight || 0, body?.offsetHeight || 0);
187
+ post({ type: resizeMessageType, height });
188
+ }
189
+ function post(message) {
190
+ targetWindow.postMessage(message, hostOrigin && hostOrigin !== "null" ? hostOrigin : "*");
191
+ }
192
+ function dispose() {
193
+ if (disposed) {
194
+ return;
195
+ }
196
+ disposed = true;
197
+ frameWindow.removeEventListener("message", handleMessage);
198
+ frameWindow.removeEventListener("resize", scheduleResize);
199
+ resizeObserver?.disconnect();
200
+ if (resizeTimer !== undefined) {
201
+ frameWindow.clearTimeout(resizeTimer);
202
+ }
203
+ const error = disposedError();
204
+ if (!contextSettled) {
205
+ contextSettled = true;
206
+ rejectContext(error);
207
+ }
208
+ for (const pending of pendingRequests.values()) {
209
+ frameWindow.clearTimeout(pending.timeoutId);
210
+ pending.reject(error);
211
+ }
212
+ pendingRequests.clear();
213
+ contextListeners.clear();
214
+ }
215
+ return { waitForContext, onContextChanged, request, getSettings, updateSettings, appendLog, invokeMain, notifyResize, dispose };
216
+ }
217
+ exports.createPluginFrameClient = createPluginFrameClient;
218
+ function disposedError() {
219
+ return new PluginFrameClientError("Disposed", "PluginFrame client has been disposed.");
220
+ }
221
+ function isRecord(value) {
222
+ return typeof value === "object" && value !== null && !Array.isArray(value);
223
+ }
224
+ function isPluginRendererContext(value) {
225
+ if (!isRecord(value)) {
226
+ return false;
227
+ }
228
+ return typeof value.schemaVersion === "number"
229
+ && typeof value.pluginId === "string"
230
+ && (value.surface === "business" || value.surface === "tool" || value.surface === "settings")
231
+ && typeof value.contributionId === "string"
232
+ && typeof value.language === "string"
233
+ && (value.themeMode === "light" || value.themeMode === "dark" || value.themeMode === "system")
234
+ && typeof value.hostApiVersion === "string";
235
+ }
236
+ function isNexusResult(value) {
237
+ if (!isRecord(value) || typeof value.ok !== "boolean") {
238
+ return false;
239
+ }
240
+ if (value.ok) {
241
+ return Object.prototype.hasOwnProperty.call(value, "value");
242
+ }
243
+ return isRecord(value.error) && typeof value.error.code === "string" && typeof value.error.message === "string";
244
+ }
@@ -0,0 +1,7 @@
1
+ export interface CliIo {
2
+ cwd(): string;
3
+ stdout(message: string): void;
4
+ stderr(message: string): void;
5
+ }
6
+ export declare function runCli(args: string[], io: CliIo): number;
7
+ export declare function usage(): string;
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.usage = exports.runCli = void 0;
27
+ const path = __importStar(require("path"));
28
+ const index_1 = require("../index");
29
+ const scaffold_1 = require("../scaffold");
30
+ const dev_1 = require("../dev");
31
+ const nodeEngine = ">=16.20.0 <17";
32
+ function runCli(args, io) {
33
+ const command = args[0];
34
+ if (command === "--help" || command === "-h") {
35
+ io.stdout(usage());
36
+ return 0;
37
+ }
38
+ if (command === "info") {
39
+ if (args.length !== 1) {
40
+ return usageError(io, "info does not accept arguments.");
41
+ }
42
+ io.stdout([
43
+ "SDK version: " + index_1.PLUGIN_SDK_VERSION,
44
+ "Plugin Framework API: " + index_1.PLUGIN_FRAMEWORK_VERSION,
45
+ "Manifest schema: " + index_1.PLUGIN_MANIFEST_SCHEMA_VERSION,
46
+ "Node engine: " + nodeEngine
47
+ ].join("\n"));
48
+ return 0;
49
+ }
50
+ if (command === "validate") {
51
+ if (args.length !== 2) {
52
+ return usageError(io, "validate requires one plugin package directory.");
53
+ }
54
+ const packageDirectory = path.resolve(io.cwd(), args[1]);
55
+ const result = (0, index_1.validatePluginPackage)(packageDirectory);
56
+ if (!result.valid) {
57
+ io.stderr("Invalid plugin package: " + packageDirectory + "\n" + result.errors.map((error) => " - " + error).join("\n"));
58
+ return 1;
59
+ }
60
+ io.stdout("Valid plugin package: " + result.pluginId + " (" + packageDirectory + ")");
61
+ return 0;
62
+ }
63
+ if (command === "create") {
64
+ return runCreate(args.slice(1), io);
65
+ }
66
+ if (command === "dev") {
67
+ return runDev(args.slice(1), io);
68
+ }
69
+ return usageError(io, command ? "Unknown command: " + command : "A command is required.");
70
+ }
71
+ exports.runCli = runCli;
72
+ function usage() {
73
+ return [
74
+ "Usage:",
75
+ " nexus-plugin info",
76
+ " nexus-plugin validate <plugin-package-directory>",
77
+ " nexus-plugin create <plugin-id> [--template minimal|sqlite] [--output <parent-directory>]",
78
+ " [--display-name <name>] --sdk-source <version-or-local-tgz> [--install]",
79
+ " nexus-plugin dev [plugin-project-directory] [--no-build] [--inspect[=<port>] | --inspect-brk[=<port>]]",
80
+ " [--language <culture>] [--theme system|light|dark] [--surface business|tool|settings]",
81
+ " [--contribution-id <id>] [--no-devtools]"
82
+ ].join("\n");
83
+ }
84
+ exports.usage = usage;
85
+ function runDev(args, io) {
86
+ if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
87
+ io.stdout(usage());
88
+ return 0;
89
+ }
90
+ let projectDirectory = io.cwd();
91
+ let index = 0;
92
+ if (args[0] && !args[0].startsWith("--")) {
93
+ projectDirectory = path.resolve(io.cwd(), args[0]);
94
+ index = 1;
95
+ }
96
+ const options = {
97
+ projectDirectory,
98
+ build: true,
99
+ openDevTools: true
100
+ };
101
+ const seen = new Set();
102
+ for (; index < args.length; index += 1) {
103
+ const option = args[index];
104
+ if (option === "--no-build" || option === "--no-devtools" || option === "--smoke") {
105
+ if (seen.has(option)) {
106
+ return usageError(io, "Duplicate option: " + option);
107
+ }
108
+ seen.add(option);
109
+ if (option === "--no-build") {
110
+ options.build = false;
111
+ }
112
+ else if (option === "--no-devtools") {
113
+ options.openDevTools = false;
114
+ }
115
+ else {
116
+ options.smoke = true;
117
+ }
118
+ continue;
119
+ }
120
+ const inspector = parseInspectorOption(option);
121
+ if (inspector) {
122
+ if (options.inspectorMode) {
123
+ return usageError(io, "Only one main-process inspector option can be used.");
124
+ }
125
+ const key = "--" + inspector.mode;
126
+ if (seen.has(key)) {
127
+ return usageError(io, "Duplicate option: " + key);
128
+ }
129
+ seen.add(key);
130
+ options.inspectorMode = inspector.mode;
131
+ options.inspectorPort = inspector.port;
132
+ continue;
133
+ }
134
+ if (!["--language", "--theme", "--surface", "--contribution-id"].includes(option)) {
135
+ return usageError(io, "Unknown dev option: " + option);
136
+ }
137
+ if (seen.has(option)) {
138
+ return usageError(io, "Duplicate option: " + option);
139
+ }
140
+ seen.add(option);
141
+ const value = args[index + 1];
142
+ if (value === undefined || value.startsWith("--")) {
143
+ return usageError(io, option + " requires a value.");
144
+ }
145
+ index += 1;
146
+ if (option === "--language") {
147
+ options.language = value;
148
+ }
149
+ else if (option === "--theme") {
150
+ if (value !== "system" && value !== "light" && value !== "dark") {
151
+ return usageError(io, "theme must be system, light, or dark.");
152
+ }
153
+ options.themeMode = value;
154
+ }
155
+ else if (option === "--surface") {
156
+ if (value !== "business" && value !== "tool" && value !== "settings") {
157
+ return usageError(io, "surface must be business, tool, or settings.");
158
+ }
159
+ options.surface = value;
160
+ }
161
+ else {
162
+ options.contributionId = value;
163
+ }
164
+ }
165
+ try {
166
+ return (0, dev_1.runPluginDev)(options, io);
167
+ }
168
+ catch (error) {
169
+ if (error instanceof dev_1.PluginDevError) {
170
+ io.stderr(error.message);
171
+ return error.exitCode;
172
+ }
173
+ io.stderr("Plugin dev host failed: " + (error instanceof Error ? error.message : String(error)));
174
+ return 1;
175
+ }
176
+ }
177
+ function parseInspectorOption(option) {
178
+ const match = /^--(inspect|inspect-brk)(?:=([0-9]+))?$/.exec(option);
179
+ if (!match) {
180
+ return undefined;
181
+ }
182
+ const port = match[2] === undefined ? 9229 : Number(match[2]);
183
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
184
+ return undefined;
185
+ }
186
+ return { mode: match[1], port };
187
+ }
188
+ function runCreate(args, io) {
189
+ if (args.length === 0 || args[0].startsWith("--")) {
190
+ return usageError(io, "create requires a plugin-id.");
191
+ }
192
+ const pluginId = args[0];
193
+ let template = "minimal";
194
+ let outputDirectory = io.cwd();
195
+ let displayName = (0, scaffold_1.defaultPluginDisplayName)(pluginId);
196
+ let sdkSource;
197
+ let install = false;
198
+ const seen = new Set();
199
+ for (let index = 1; index < args.length; index += 1) {
200
+ const option = args[index];
201
+ if (option === "--install") {
202
+ if (seen.has(option)) {
203
+ return usageError(io, "Duplicate option: " + option);
204
+ }
205
+ seen.add(option);
206
+ install = true;
207
+ continue;
208
+ }
209
+ if (!["--template", "--output", "--display-name", "--sdk-source"].includes(option)) {
210
+ return usageError(io, "Unknown create option: " + option);
211
+ }
212
+ if (seen.has(option)) {
213
+ return usageError(io, "Duplicate option: " + option);
214
+ }
215
+ seen.add(option);
216
+ const value = args[index + 1];
217
+ if (value === undefined || value.startsWith("--")) {
218
+ return usageError(io, option + " requires a value.");
219
+ }
220
+ index += 1;
221
+ if (option === "--template") {
222
+ if (value !== "minimal" && value !== "sqlite") {
223
+ return usageError(io, "template must be minimal or sqlite.");
224
+ }
225
+ template = value;
226
+ }
227
+ else if (option === "--output") {
228
+ outputDirectory = path.resolve(io.cwd(), value);
229
+ }
230
+ else if (option === "--display-name") {
231
+ displayName = value.trim();
232
+ }
233
+ else {
234
+ sdkSource = value;
235
+ }
236
+ }
237
+ if (!sdkSource) {
238
+ return usageError(io, "create requires --sdk-source; use a local SDK .tgz until @aiot-nexus/plugin-sdk is published.");
239
+ }
240
+ try {
241
+ const result = (0, scaffold_1.createPluginScaffold)({
242
+ pluginId,
243
+ template,
244
+ workingDirectory: io.cwd(),
245
+ outputDirectory,
246
+ displayName,
247
+ sdkSource,
248
+ install
249
+ });
250
+ io.stdout("Created " + result.template + " plugin: " + result.pluginDirectory
251
+ + "\nSDK source: " + result.sdkSource
252
+ + "\nDependencies installed: " + (result.installed ? "yes" : "no"));
253
+ return 0;
254
+ }
255
+ catch (error) {
256
+ if (error instanceof scaffold_1.PluginScaffoldError) {
257
+ if (error.exitCode === 2) {
258
+ return usageError(io, error.message);
259
+ }
260
+ io.stderr(error.message);
261
+ return 1;
262
+ }
263
+ io.stderr("Plugin scaffold failed: " + (error instanceof Error ? error.message : String(error)));
264
+ return 1;
265
+ }
266
+ }
267
+ function usageError(io, message) {
268
+ io.stderr(message + "\n" + usage());
269
+ return 2;
270
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const run_1 = require("./cli/run");
5
+ process.exitCode = (0, run_1.runCli)(process.argv.slice(2), {
6
+ cwd: () => process.cwd(),
7
+ stdout: (message) => process.stdout.write(message + "\n"),
8
+ stderr: (message) => process.stderr.write(message + "\n")
9
+ });
@@ -0,0 +1,36 @@
1
+ import type { PluginManifest, PluginRendererSurface, ThemeMode } from "./types";
2
+ export type PluginMainInspectorMode = "inspect" | "inspect-brk";
3
+ export interface PluginDevOptions {
4
+ projectDirectory: string;
5
+ build: boolean;
6
+ openDevTools: boolean;
7
+ inspectorMode?: PluginMainInspectorMode;
8
+ inspectorPort?: number;
9
+ language?: string;
10
+ themeMode?: ThemeMode;
11
+ surface?: PluginRendererSurface;
12
+ contributionId?: string;
13
+ smoke?: boolean;
14
+ }
15
+ export interface PluginDevIo {
16
+ stdout(message: string): void;
17
+ stderr(message: string): void;
18
+ }
19
+ export interface PluginDevTarget {
20
+ projectDirectory: string;
21
+ packageDirectory: string;
22
+ pluginId: string;
23
+ manifest: PluginManifest;
24
+ electronExecutable: string;
25
+ devHostMainPath: string;
26
+ surface: PluginRendererSurface;
27
+ contributionId: string;
28
+ language: string;
29
+ themeMode: ThemeMode;
30
+ }
31
+ export declare class PluginDevError extends Error {
32
+ readonly exitCode: 1;
33
+ constructor(message: string);
34
+ }
35
+ export declare function runPluginDev(options: PluginDevOptions, io: PluginDevIo): number;
36
+ export declare function preparePluginDev(options: PluginDevOptions): PluginDevTarget;