@aiot-nexus/plugin-sdk 2.1.0 → 3.0.2

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 (38) hide show
  1. package/README.md +151 -96
  2. package/dev-host/host.html +13 -12
  3. package/dev-host/main.js +362 -506
  4. package/dist/.generated/plugin-framework-version.d.ts +1 -1
  5. package/dist/.generated/plugin-framework-version.js +1 -1
  6. package/dist/.generated/plugin-manifest.schema.json +1 -1
  7. package/dist/browser/frame-client.d.ts +1 -0
  8. package/dist/browser/frame-client.mjs +121 -13
  9. package/dist/src/browser/frame-client.d.ts +1 -0
  10. package/dist/src/browser/frame-client.js +121 -13
  11. package/dist/src/cli/run.js +2 -2
  12. package/dist/src/dev.js +3 -3
  13. package/dist/src/{electron-facade.js → electron-namespaces.js} +2 -3
  14. package/dist/src/index.d.ts +2 -2
  15. package/dist/src/index.js +2 -2
  16. package/dist/src/nexus-dev-control.d.ts +1 -1
  17. package/dist/src/nexus-dev-control.js +2 -2
  18. package/dist/src/nexus-dev.d.ts +0 -3
  19. package/dist/src/nexus-dev.js +118 -53
  20. package/dist/src/types.d.ts +14 -98
  21. package/package.json +1 -1
  22. package/templates/minimal/.vscode/launch.json +1 -1
  23. package/templates/minimal/README.md.tmpl +68 -19
  24. package/templates/minimal/src/main.ts.tmpl +5 -4
  25. package/templates/sqlite/.vscode/launch.json +1 -1
  26. package/templates/sqlite/README.md.tmpl +13 -11
  27. package/templates/sqlite/src/main.ts.tmpl +180 -81
  28. package/templates/sqlite/src/renderer/app.ts.tmpl +9 -5
  29. package/dev-host/plugin-host.js +0 -4
  30. package/dist/internal/src-electron/main/core/runtime-result.js +0 -42
  31. package/dist/internal/src-electron/main/plugins/plugin-electron-facade-broker.js +0 -890
  32. package/dist/internal/src-electron/plugin-host-bootstrap.js +0 -417
  33. package/dist/internal/src-electron/shared/contracts.js +0 -2
  34. package/dist/internal/src-electron/shared/plugin-electron-facade-client.js +0 -181
  35. package/dist/internal/src-electron/shared/plugin-electron-facade-descriptors.js +0 -70
  36. package/dist/internal/src-electron/shared/plugin-electron-facade.js +0 -243
  37. package/dist/internal/src-electron/shared/plugin-rpc.js +0 -245
  38. /package/dist/src/{electron-facade.d.ts → electron-namespaces.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- export declare const PLUGIN_FRAMEWORK_VERSION = "2.1.0";
1
+ export declare const PLUGIN_FRAMEWORK_VERSION = "3.0.0";
2
2
  export declare const PLUGIN_MANIFEST_SCHEMA_VERSION = 1;
3
3
  export declare const PLUGIN_COMPATIBLE_VERSION_PATTERN = "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?(\\.(0|[1-9][0-9]*))?$";
4
4
  export interface ParsedPluginVersion {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isPluginFrameworkVersionCompatible = exports.comparePluginVersions = exports.parsePluginCompatibleVersion = exports.PLUGIN_COMPATIBLE_VERSION_PATTERN = exports.PLUGIN_MANIFEST_SCHEMA_VERSION = exports.PLUGIN_FRAMEWORK_VERSION = void 0;
4
- exports.PLUGIN_FRAMEWORK_VERSION = "2.1.0";
4
+ exports.PLUGIN_FRAMEWORK_VERSION = "3.0.0";
5
5
  exports.PLUGIN_MANIFEST_SCHEMA_VERSION = 1;
6
6
  exports.PLUGIN_COMPATIBLE_VERSION_PATTERN = "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?(\\.(0|[1-9][0-9]*))?$";
7
7
  function parsePluginCompatibleVersion(value) {
@@ -33,7 +33,7 @@
33
33
  "permissions": {
34
34
  "type": "array",
35
35
  "items": {
36
- "enum": ["businessLog", "settings", "filesystem", "udp", "serial", "externalProcess", "dialog", "electronHostControl"]
36
+ "enum": ["businessLog", "settings", "filesystem", "udp", "serial", "externalProcess", "dialog"]
37
37
  },
38
38
  "uniqueItems": true
39
39
  },
@@ -7,6 +7,7 @@ export declare class PluginFrameClientError extends Error {
7
7
  export interface PluginFrameClientOptions {
8
8
  frameWindow?: Window;
9
9
  targetWindow?: Window;
10
+ initializationTimeoutMs?: number;
10
11
  requestTimeoutMs?: number;
11
12
  autoResize?: boolean;
12
13
  resizeRoot?: HTMLElement;
@@ -4,7 +4,7 @@ const readyMessageType = "nexus-plugin:ready";
4
4
  const requestMessageType = "nexus-plugin:request";
5
5
  const responseMessageType = "nexus-plugin:response";
6
6
  const resizeMessageType = "nexus-plugin:resize";
7
- const defaultRequestTimeoutMs = 20000;
7
+ const defaultInitializationTimeoutMs = 20000;
8
8
  export class PluginFrameClientError extends Error {
9
9
  constructor(code, message) {
10
10
  super(message);
@@ -19,9 +19,13 @@ export function createPluginFrameClient(options = {}) {
19
19
  }
20
20
  const frameWindow = resolvedFrameWindow;
21
21
  const targetWindow = options.targetWindow || frameWindow.parent;
22
- const requestTimeoutMs = options.requestTimeoutMs === undefined ? defaultRequestTimeoutMs : options.requestTimeoutMs;
23
- if (!Number.isFinite(requestTimeoutMs) || requestTimeoutMs <= 0) {
24
- throw new PluginFrameClientError("ProtocolError", "requestTimeoutMs must be a positive finite number.");
22
+ const initializationTimeoutMs = options.initializationTimeoutMs === undefined ? defaultInitializationTimeoutMs : options.initializationTimeoutMs;
23
+ const requestTimeoutMs = options.requestTimeoutMs === undefined ? 0 : options.requestTimeoutMs;
24
+ if (!Number.isFinite(initializationTimeoutMs) || initializationTimeoutMs <= 0) {
25
+ throw new PluginFrameClientError("ProtocolError", "initializationTimeoutMs must be a positive finite number.");
26
+ }
27
+ if (!Number.isFinite(requestTimeoutMs) || requestTimeoutMs < 0) {
28
+ throw new PluginFrameClientError("ProtocolError", "requestTimeoutMs must be zero or a positive finite number.");
25
29
  }
26
30
  let requestSequence = 0;
27
31
  let disposed = false;
@@ -46,7 +50,7 @@ export function createPluginFrameClient(options = {}) {
46
50
  contextSettled = true;
47
51
  rejectContext(new PluginFrameClientError("RequestTimeout", "PluginFrame initialization timed out."));
48
52
  }
49
- }, requestTimeoutMs);
53
+ }, initializationTimeoutMs);
50
54
  frameWindow.addEventListener("message", handleMessage);
51
55
  if (options.autoResize !== false) {
52
56
  frameWindow.addEventListener("resize", scheduleResize);
@@ -80,16 +84,18 @@ export function createPluginFrameClient(options = {}) {
80
84
  }
81
85
  const requestId = "nexus-sdk-" + Date.now() + "-" + (++requestSequence);
82
86
  return new Promise((resolve, reject) => {
83
- const timeoutId = frameWindow.setTimeout(() => {
84
- pendingRequests.delete(requestId);
85
- reject(new PluginFrameClientError("RequestTimeout", "PluginFrame request timed out: " + method));
86
- }, requestTimeoutMs);
87
+ const timeoutId = requestTimeoutMs > 0
88
+ ? frameWindow.setTimeout(() => {
89
+ pendingRequests.delete(requestId);
90
+ reject(new PluginFrameClientError("RequestTimeout", "PluginFrame request timed out: " + method));
91
+ }, requestTimeoutMs)
92
+ : undefined;
87
93
  pendingRequests.set(requestId, {
88
94
  resolve: (result) => resolve(result),
89
95
  reject,
90
96
  timeoutId
91
97
  });
92
- post({ type: requestMessageType, requestId, method, params });
98
+ post({ type: requestMessageType, requestId, method, params: encodeFrameValue(params) });
93
99
  });
94
100
  }
95
101
  function getSettings() {
@@ -140,12 +146,14 @@ export function createPluginFrameClient(options = {}) {
140
146
  return;
141
147
  }
142
148
  pendingRequests.delete(event.data.requestId);
143
- frameWindow.clearTimeout(pending.timeoutId);
149
+ if (pending.timeoutId !== undefined) {
150
+ frameWindow.clearTimeout(pending.timeoutId);
151
+ }
144
152
  if (!isNexusResult(event.data.result)) {
145
153
  pending.reject(new PluginFrameClientError("ProtocolError", "PluginFrame response is malformed."));
146
154
  return;
147
155
  }
148
- pending.resolve(event.data.result);
156
+ pending.resolve(decodeFrameResult(event.data.result));
149
157
  }
150
158
  function notifyContextChanged(context) {
151
159
  for (const listener of Array.from(contextListeners)) {
@@ -202,7 +210,9 @@ export function createPluginFrameClient(options = {}) {
202
210
  rejectContext(error);
203
211
  }
204
212
  for (const pending of pendingRequests.values()) {
205
- frameWindow.clearTimeout(pending.timeoutId);
213
+ if (pending.timeoutId !== undefined) {
214
+ frameWindow.clearTimeout(pending.timeoutId);
215
+ }
206
216
  pending.reject(error);
207
217
  }
208
218
  pendingRequests.clear();
@@ -237,3 +247,101 @@ function isNexusResult(value) {
237
247
  }
238
248
  return isRecord(value.error) && typeof value.error.code === "string" && typeof value.error.message === "string";
239
249
  }
250
+ function encodeFrameValue(value, seen = new WeakSet()) {
251
+ if (value === undefined) {
252
+ return { __nexusWire: "undefined" };
253
+ }
254
+ if (value === null || typeof value === "string" || typeof value === "boolean") {
255
+ return value;
256
+ }
257
+ if (typeof value === "number") {
258
+ return Number.isFinite(value) ? value : null;
259
+ }
260
+ if (typeof value === "bigint") {
261
+ return { __nexusWire: "bigint", value: value.toString(10) };
262
+ }
263
+ if (value instanceof Date) {
264
+ return { __nexusWire: "date", value: value.toISOString() };
265
+ }
266
+ if (value instanceof Error) {
267
+ return { __nexusWire: "error", name: value.name, message: value.message, stack: value.stack };
268
+ }
269
+ if (value instanceof Uint8Array) {
270
+ return { __nexusWire: "buffer", value: bytesToHex(value) };
271
+ }
272
+ if (typeof value !== "object" || seen.has(value)) {
273
+ return null;
274
+ }
275
+ seen.add(value);
276
+ try {
277
+ if (Array.isArray(value)) {
278
+ return value.map((item) => encodeFrameValue(item, seen));
279
+ }
280
+ const encoded = Object.fromEntries(Object.entries(value).map(([key, item]) => [key, encodeFrameValue(item, seen)]));
281
+ return Object.prototype.hasOwnProperty.call(value, "__nexusWire")
282
+ ? { __nexusWire: "object", value: encoded }
283
+ : encoded;
284
+ }
285
+ finally {
286
+ seen.delete(value);
287
+ }
288
+ }
289
+ function decodeFrameResult(result) {
290
+ return result.ok
291
+ ? { ok: true, value: decodeFrameValue(result.value) }
292
+ : { ok: false, error: { ...result.error, details: decodeFrameValue(result.error.details) } };
293
+ }
294
+ function decodeFrameValue(value) {
295
+ if (value === null || typeof value !== "object") {
296
+ return value;
297
+ }
298
+ const record = value;
299
+ if (record.__nexusWire === "undefined") {
300
+ return undefined;
301
+ }
302
+ if (record.__nexusWire === "bigint" && typeof record.value === "string") {
303
+ try {
304
+ return BigInt(record.value);
305
+ }
306
+ catch {
307
+ return null;
308
+ }
309
+ }
310
+ if (record.__nexusWire === "date" && typeof record.value === "string") {
311
+ const date = new Date(record.value);
312
+ return Number.isNaN(date.getTime()) ? null : date;
313
+ }
314
+ if (record.__nexusWire === "buffer" && typeof record.value === "string") {
315
+ return hexToUint8Array(record.value);
316
+ }
317
+ if (record.__nexusWire === "error" && typeof record.message === "string") {
318
+ const error = new Error(record.message);
319
+ if (typeof record.name === "string") {
320
+ error.name = record.name;
321
+ }
322
+ if (typeof record.stack === "string") {
323
+ error.stack = record.stack;
324
+ }
325
+ return error;
326
+ }
327
+ if (record.__nexusWire === "object" && isRecord(record.value)) {
328
+ return decodeFrameValue(record.value);
329
+ }
330
+ if (Array.isArray(value)) {
331
+ return value.map((item) => decodeFrameValue(item));
332
+ }
333
+ return Object.fromEntries(Object.entries(record).map(([key, item]) => [key, decodeFrameValue(item)]));
334
+ }
335
+ function bytesToHex(bytes) {
336
+ return Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("");
337
+ }
338
+ function hexToUint8Array(value) {
339
+ if (value.length % 2 !== 0 || !/^[0-9a-f]*$/i.test(value)) {
340
+ return null;
341
+ }
342
+ const bytes = new Uint8Array(value.length / 2);
343
+ for (let index = 0; index < bytes.length; index += 1) {
344
+ bytes[index] = Number.parseInt(value.slice(index * 2, index * 2 + 2), 16);
345
+ }
346
+ return bytes;
347
+ }
@@ -7,6 +7,7 @@ export declare class PluginFrameClientError extends Error {
7
7
  export interface PluginFrameClientOptions {
8
8
  frameWindow?: Window;
9
9
  targetWindow?: Window;
10
+ initializationTimeoutMs?: number;
10
11
  requestTimeoutMs?: number;
11
12
  autoResize?: boolean;
12
13
  resizeRoot?: HTMLElement;
@@ -7,7 +7,7 @@ const readyMessageType = "nexus-plugin:ready";
7
7
  const requestMessageType = "nexus-plugin:request";
8
8
  const responseMessageType = "nexus-plugin:response";
9
9
  const resizeMessageType = "nexus-plugin:resize";
10
- const defaultRequestTimeoutMs = 20000;
10
+ const defaultInitializationTimeoutMs = 20000;
11
11
  class PluginFrameClientError extends Error {
12
12
  constructor(code, message) {
13
13
  super(message);
@@ -23,9 +23,13 @@ function createPluginFrameClient(options = {}) {
23
23
  }
24
24
  const frameWindow = resolvedFrameWindow;
25
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.");
26
+ const initializationTimeoutMs = options.initializationTimeoutMs === undefined ? defaultInitializationTimeoutMs : options.initializationTimeoutMs;
27
+ const requestTimeoutMs = options.requestTimeoutMs === undefined ? 0 : options.requestTimeoutMs;
28
+ if (!Number.isFinite(initializationTimeoutMs) || initializationTimeoutMs <= 0) {
29
+ throw new PluginFrameClientError("ProtocolError", "initializationTimeoutMs must be a positive finite number.");
30
+ }
31
+ if (!Number.isFinite(requestTimeoutMs) || requestTimeoutMs < 0) {
32
+ throw new PluginFrameClientError("ProtocolError", "requestTimeoutMs must be zero or a positive finite number.");
29
33
  }
30
34
  let requestSequence = 0;
31
35
  let disposed = false;
@@ -50,7 +54,7 @@ function createPluginFrameClient(options = {}) {
50
54
  contextSettled = true;
51
55
  rejectContext(new PluginFrameClientError("RequestTimeout", "PluginFrame initialization timed out."));
52
56
  }
53
- }, requestTimeoutMs);
57
+ }, initializationTimeoutMs);
54
58
  frameWindow.addEventListener("message", handleMessage);
55
59
  if (options.autoResize !== false) {
56
60
  frameWindow.addEventListener("resize", scheduleResize);
@@ -84,16 +88,18 @@ function createPluginFrameClient(options = {}) {
84
88
  }
85
89
  const requestId = "nexus-sdk-" + Date.now() + "-" + (++requestSequence);
86
90
  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
+ const timeoutId = requestTimeoutMs > 0
92
+ ? frameWindow.setTimeout(() => {
93
+ pendingRequests.delete(requestId);
94
+ reject(new PluginFrameClientError("RequestTimeout", "PluginFrame request timed out: " + method));
95
+ }, requestTimeoutMs)
96
+ : undefined;
91
97
  pendingRequests.set(requestId, {
92
98
  resolve: (result) => resolve(result),
93
99
  reject,
94
100
  timeoutId
95
101
  });
96
- post({ type: requestMessageType, requestId, method, params });
102
+ post({ type: requestMessageType, requestId, method, params: encodeFrameValue(params) });
97
103
  });
98
104
  }
99
105
  function getSettings() {
@@ -144,12 +150,14 @@ function createPluginFrameClient(options = {}) {
144
150
  return;
145
151
  }
146
152
  pendingRequests.delete(event.data.requestId);
147
- frameWindow.clearTimeout(pending.timeoutId);
153
+ if (pending.timeoutId !== undefined) {
154
+ frameWindow.clearTimeout(pending.timeoutId);
155
+ }
148
156
  if (!isNexusResult(event.data.result)) {
149
157
  pending.reject(new PluginFrameClientError("ProtocolError", "PluginFrame response is malformed."));
150
158
  return;
151
159
  }
152
- pending.resolve(event.data.result);
160
+ pending.resolve(decodeFrameResult(event.data.result));
153
161
  }
154
162
  function notifyContextChanged(context) {
155
163
  for (const listener of Array.from(contextListeners)) {
@@ -206,7 +214,9 @@ function createPluginFrameClient(options = {}) {
206
214
  rejectContext(error);
207
215
  }
208
216
  for (const pending of pendingRequests.values()) {
209
- frameWindow.clearTimeout(pending.timeoutId);
217
+ if (pending.timeoutId !== undefined) {
218
+ frameWindow.clearTimeout(pending.timeoutId);
219
+ }
210
220
  pending.reject(error);
211
221
  }
212
222
  pendingRequests.clear();
@@ -242,3 +252,101 @@ function isNexusResult(value) {
242
252
  }
243
253
  return isRecord(value.error) && typeof value.error.code === "string" && typeof value.error.message === "string";
244
254
  }
255
+ function encodeFrameValue(value, seen = new WeakSet()) {
256
+ if (value === undefined) {
257
+ return { __nexusWire: "undefined" };
258
+ }
259
+ if (value === null || typeof value === "string" || typeof value === "boolean") {
260
+ return value;
261
+ }
262
+ if (typeof value === "number") {
263
+ return Number.isFinite(value) ? value : null;
264
+ }
265
+ if (typeof value === "bigint") {
266
+ return { __nexusWire: "bigint", value: value.toString(10) };
267
+ }
268
+ if (value instanceof Date) {
269
+ return { __nexusWire: "date", value: value.toISOString() };
270
+ }
271
+ if (value instanceof Error) {
272
+ return { __nexusWire: "error", name: value.name, message: value.message, stack: value.stack };
273
+ }
274
+ if (value instanceof Uint8Array) {
275
+ return { __nexusWire: "buffer", value: bytesToHex(value) };
276
+ }
277
+ if (typeof value !== "object" || seen.has(value)) {
278
+ return null;
279
+ }
280
+ seen.add(value);
281
+ try {
282
+ if (Array.isArray(value)) {
283
+ return value.map((item) => encodeFrameValue(item, seen));
284
+ }
285
+ const encoded = Object.fromEntries(Object.entries(value).map(([key, item]) => [key, encodeFrameValue(item, seen)]));
286
+ return Object.prototype.hasOwnProperty.call(value, "__nexusWire")
287
+ ? { __nexusWire: "object", value: encoded }
288
+ : encoded;
289
+ }
290
+ finally {
291
+ seen.delete(value);
292
+ }
293
+ }
294
+ function decodeFrameResult(result) {
295
+ return result.ok
296
+ ? { ok: true, value: decodeFrameValue(result.value) }
297
+ : { ok: false, error: { ...result.error, details: decodeFrameValue(result.error.details) } };
298
+ }
299
+ function decodeFrameValue(value) {
300
+ if (value === null || typeof value !== "object") {
301
+ return value;
302
+ }
303
+ const record = value;
304
+ if (record.__nexusWire === "undefined") {
305
+ return undefined;
306
+ }
307
+ if (record.__nexusWire === "bigint" && typeof record.value === "string") {
308
+ try {
309
+ return BigInt(record.value);
310
+ }
311
+ catch {
312
+ return null;
313
+ }
314
+ }
315
+ if (record.__nexusWire === "date" && typeof record.value === "string") {
316
+ const date = new Date(record.value);
317
+ return Number.isNaN(date.getTime()) ? null : date;
318
+ }
319
+ if (record.__nexusWire === "buffer" && typeof record.value === "string") {
320
+ return hexToUint8Array(record.value);
321
+ }
322
+ if (record.__nexusWire === "error" && typeof record.message === "string") {
323
+ const error = new Error(record.message);
324
+ if (typeof record.name === "string") {
325
+ error.name = record.name;
326
+ }
327
+ if (typeof record.stack === "string") {
328
+ error.stack = record.stack;
329
+ }
330
+ return error;
331
+ }
332
+ if (record.__nexusWire === "object" && isRecord(record.value)) {
333
+ return decodeFrameValue(record.value);
334
+ }
335
+ if (Array.isArray(value)) {
336
+ return value.map((item) => decodeFrameValue(item));
337
+ }
338
+ return Object.fromEntries(Object.entries(record).map(([key, item]) => [key, decodeFrameValue(item)]));
339
+ }
340
+ function bytesToHex(bytes) {
341
+ return Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("");
342
+ }
343
+ function hexToUint8Array(value) {
344
+ if (value.length % 2 !== 0 || !/^[0-9a-f]*$/i.test(value)) {
345
+ return null;
346
+ }
347
+ const bytes = new Uint8Array(value.length / 2);
348
+ for (let index = 0; index < bytes.length; index += 1) {
349
+ bytes[index] = Number.parseInt(value.slice(index * 2, index * 2 + 2), 16);
350
+ }
351
+ return bytes;
352
+ }
@@ -126,7 +126,7 @@ function runNexusDev(args, io) {
126
126
  const inspector = parseInspectorOption(option);
127
127
  if (inspector) {
128
128
  if (options.inspectorMode) {
129
- return usageError(io, "Only one plugin worker inspector option can be used.");
129
+ return usageError(io, "Only one plugin main-process inspector option can be used.");
130
130
  }
131
131
  const key = "--" + inspector.mode;
132
132
  if (seen.has(key)) {
@@ -304,7 +304,7 @@ function runDev(args, io) {
304
304
  const inspector = parseInspectorOption(option);
305
305
  if (inspector) {
306
306
  if (options.inspectorMode) {
307
- return usageError(io, "Only one plugin worker inspector option can be used.");
307
+ return usageError(io, "Only one plugin main-process inspector option can be used.");
308
308
  }
309
309
  const key = "--" + inspector.mode;
310
310
  if (seen.has(key)) {
package/dist/src/dev.js CHANGED
@@ -52,14 +52,14 @@ function runPluginDev(options, io) {
52
52
  + "\nContribution: " + target.surface + ":" + target.contributionId
53
53
  + "\nSimulated Nexus application version: " + target.hostVersion);
54
54
  if (options.inspectorMode) {
55
- io.stdout("Plugin worker debugger: " + options.inspectorMode
55
+ io.stdout("Plugin main-process debugger: " + options.inspectorMode
56
56
  + " on 127.0.0.1:" + String(options.inspectorPort || 9229));
57
57
  }
58
58
  const electronArgs = [];
59
- electronArgs.push(target.devHostMainPath, "--plugin-package=" + target.packageDirectory, "--project-directory=" + target.projectDirectory, "--surface=" + target.surface, "--contribution-id=" + target.contributionId, "--language=" + target.language, "--theme=" + target.themeMode, "--host-version=" + target.hostVersion);
60
59
  if (options.inspectorMode) {
61
- electronArgs.push("--worker-inspector=" + options.inspectorMode + ":" + String(options.inspectorPort || 9229));
60
+ electronArgs.push("--" + options.inspectorMode + "=" + String(options.inspectorPort || 9229));
62
61
  }
62
+ electronArgs.push(target.devHostMainPath, "--plugin-package=" + target.packageDirectory, "--project-directory=" + target.projectDirectory, "--surface=" + target.surface, "--contribution-id=" + target.contributionId, "--language=" + target.language, "--theme=" + target.themeMode, "--host-version=" + target.hostVersion);
63
63
  if (!options.openDevTools) {
64
64
  electronArgs.push("--no-devtools");
65
65
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isPluginElectronProtocolScheme = exports.isPluginElectronIpcChannel = exports.createPluginElectronProtocolScheme = exports.createPluginElectronIpcChannel = void 0;
4
4
  const ipcPrefix = "nexus-plugin:";
5
5
  const protocolPrefix = "nexus-plugin-";
6
- const pluginIdPattern = /^[a-z0-9][a-z0-9._-]{0,63}$/;
6
+ const pluginIdPattern = /^[a-z0-9][a-z0-9._-]{1,63}$/;
7
7
  const channelPattern = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/;
8
8
  const schemePattern = /^[a-z][a-z0-9+.-]{0,62}$/;
9
9
  function createPluginElectronIpcChannel(pluginId, channel) {
@@ -44,8 +44,7 @@ function requirePluginId(value) {
44
44
  return normalized;
45
45
  }
46
46
  function normalizePluginId(value) {
47
- const normalized = typeof value === "string" ? value.trim() : "";
48
- return pluginIdPattern.test(normalized) ? normalized : undefined;
47
+ return typeof value === "string" && pluginIdPattern.test(value) ? value : undefined;
49
48
  }
50
49
  function requireLogicalName(value, pattern, label) {
51
50
  const normalized = String(value).trim();
@@ -1,8 +1,8 @@
1
1
  import pluginManifestSchema from "../.generated/plugin-manifest.schema.json";
2
- export declare const PLUGIN_SDK_VERSION = "2.1.0";
2
+ export declare const PLUGIN_SDK_VERSION = "3.0.2";
3
3
  export { pluginManifestSchema };
4
4
  export * from "../.generated/plugin-framework-version";
5
5
  export * from "./types";
6
- export * from "./electron-facade";
6
+ export * from "./electron-namespaces";
7
7
  export * from "./browser/frame-client";
8
8
  export * from "./validation";
package/dist/src/index.js CHANGED
@@ -20,9 +20,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.pluginManifestSchema = exports.PLUGIN_SDK_VERSION = void 0;
21
21
  const plugin_manifest_schema_json_1 = __importDefault(require("../.generated/plugin-manifest.schema.json"));
22
22
  exports.pluginManifestSchema = plugin_manifest_schema_json_1.default;
23
- exports.PLUGIN_SDK_VERSION = "2.1.0";
23
+ exports.PLUGIN_SDK_VERSION = "3.0.2";
24
24
  __exportStar(require("../.generated/plugin-framework-version"), exports);
25
25
  __exportStar(require("./types"), exports);
26
- __exportStar(require("./electron-facade"), exports);
26
+ __exportStar(require("./electron-namespaces"), exports);
27
27
  __exportStar(require("./browser/frame-client"), exports);
28
28
  __exportStar(require("./validation"), exports);
@@ -1,4 +1,4 @@
1
- export type NexusDevUpdateType = "rendererUpdated" | "manifestUpdated" | "packageUpdatePreparing" | "packageUpdated";
1
+ export type NexusDevUpdateType = "hostReady" | "rendererUpdated" | "manifestUpdated";
2
2
  export interface NexusDevUpdateResult {
3
3
  ok: boolean;
4
4
  message: string;
@@ -30,7 +30,7 @@ const net = __importStar(require("net"));
30
30
  const os = __importStar(require("os"));
31
31
  const path = __importStar(require("path"));
32
32
  const dev_1 = require("./dev");
33
- const protocolVersion = 2;
33
+ const protocolVersion = 3;
34
34
  const maximumMessageBytes = 64 * 1024;
35
35
  const requestTimeoutMs = 10000;
36
36
  class NexusDevControlServer {
@@ -371,7 +371,7 @@ function isUpdateResult(value) {
371
371
  return isRecord(value)
372
372
  && value.type === "updateResult"
373
373
  && typeof value.requestId === "string"
374
- && (value.updateType === "rendererUpdated" || value.updateType === "manifestUpdated" || value.updateType === "packageUpdatePreparing" || value.updateType === "packageUpdated")
374
+ && (value.updateType === "hostReady" || value.updateType === "rendererUpdated" || value.updateType === "manifestUpdated")
375
375
  && typeof value.pluginId === "string"
376
376
  && typeof value.ok === "boolean"
377
377
  && typeof value.message === "string"
@@ -13,9 +13,6 @@ export interface PluginNexusDevIo {
13
13
  }
14
14
  export type PluginSourceChangeKind = "renderer" | "manifest" | "package";
15
15
  export declare function runPluginNexusDev(options: PluginNexusDevOptions, io: PluginNexusDevIo): Promise<number>;
16
- export declare function recoverPreparedPluginPackageUpdate(transaction: {
17
- rollback(): void;
18
- } | undefined, pluginId: string, control: Pick<NexusDevControlServer, "sendUpdate">): Promise<void>;
19
16
  export declare function classifyPluginSourceChange(projectDirectory: string, changedPath: string): PluginSourceChangeKind | undefined;
20
17
  export declare function manifestChangeRequiresPackageUpdate(previous: PluginManifest, next: PluginManifest): boolean;
21
18
  export declare function mergePluginSourceChange(current: PluginSourceChangeKind | undefined, incoming: PluginSourceChangeKind): PluginSourceChangeKind;