@wix/wix-code-diagnostics-plugin 1.1.5 → 1.1.6

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 CHANGED
@@ -39,3 +39,31 @@ best-effort and never fails the CLI run.
39
39
  > Interim: until the CLI exposes `build`/`preview` error + success events, the
40
40
  > plugin subscribes to the dev process's `dc-updated` event to exercise the
41
41
  > transport end to end.
42
+
43
+ ## Runtime errors stream (`wix dev` only)
44
+
45
+ On `cli:setup` with `cmd === 'dev'` the plugin also starts a local SSE server so
46
+ the editor can show runtime errors from the running app:
47
+
48
+ | | |
49
+ |---|---|
50
+ | Endpoint | `GET http://127.0.0.1:52415/runtime-errors/stream` |
51
+ | Port | `52415` — fixed, like the CLI dev server's `52401`. `52402` is taken by the codegen agent |
52
+ | Bind | Loopback only (`127.0.0.1`). Remote editors reach it through the sandbox's port proxy, never directly |
53
+ | Event | `event: runtime-error`, `id: <occurrence id>`, `data: <json>` |
54
+ | Payload | `{ id, name, message, file, line, column, stack, timestamp }` |
55
+ | Replay | Ring buffer of the last 100 errors, replayed on connect; `Last-Event-ID` honored |
56
+ | Heartbeat | `: ping` comment every ~25s |
57
+ | Slow clients | A connection whose unflushed buffer reaches 1 MB is dropped, so a stalled reader cannot grow the dev process's memory |
58
+ | Origins | `editor.wix.com`, `manage.wix.com`, `*.editor.wix.com`, `*.wix-code.com`. An `Origin` outside that list gets `403`; a request with no `Origin` is served without CORS headers |
59
+ | Origin override | `WIX_CODE_RUNTIME_ERRORS_ALLOWED_ORIGINS` replaces the list entirely — comma-separated. A hostname (`editor.wix.com`) matches on any scheme and port; a full origin (`http://localhost:3000`) matches **exactly**, that scheme and that port only; `*.editor.wix.com` matches any subdomain. An entry that is neither (`localhost:3000`, with a port but no scheme) is ambiguous, so it is dropped with a warning rather than widened. Set this to run a local editor against the stream |
60
+ | Port clash | A second `wix dev` in the same sandbox cannot have `52415`. The stream moves to an ephemeral port and says so in the CLI output — the editor only looks at `52415`, so that run's errors do not reach it |
61
+
62
+ The plugin subscribes to the CLI's `runtime-error` event — that subscription is
63
+ what enables capture on the CLI side. Each error is serialized, passed through a
64
+ fingerprint dedup (1s window) and a rate cap (50 per 10s), then buffered and
65
+ broadcast.
66
+
67
+ Runtime errors are ephemeral by design: no orchestrator, no persistence, and the
68
+ buffer dies with the dev server. The stream part is active on every `wix dev`
69
+ run, independent of the two diagnostics env vars above.
@@ -0,0 +1,17 @@
1
+ export declare const RUNTIME_ERRORS_PORT = 52415;
2
+ export declare const RUNTIME_ERRORS_PATH = "/runtime-errors/stream";
3
+ export declare const HEARTBEAT_INTERVAL_MS = 25000;
4
+ export declare const RECONNECT_DELAY_MS = 2000;
5
+ export declare const RUNTIME_ERRORS_BUFFER_SIZE = 100;
6
+ export declare const DEDUP_WINDOW_MS = 1000;
7
+ export declare const MAX_ERRORS_PER_WINDOW = 50;
8
+ export declare const RATE_WINDOW_MS = 10000;
9
+ export declare const MAX_TRACKED_FINGERPRINTS = 128;
10
+ export declare const ALLOWED_ORIGINS_ENV = "WIX_CODE_RUNTIME_ERRORS_ALLOWED_ORIGINS";
11
+ export declare const DEFAULT_ORIGIN_ALLOWLIST: {
12
+ readonly hosts: readonly ["editor.wix.com", "manage.wix.com"];
13
+ readonly suffixes: readonly [".editor.wix.com", ".wix-code.com"];
14
+ };
15
+ export declare const RUNTIME_ERRORS_HOST = "127.0.0.1";
16
+ export declare const MAX_CLIENT_BUFFER_BYTES = 1048576;
17
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAE5D,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAExC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,eAAO,MAAM,eAAe,OAAQ,CAAC;AAErC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,mBAAmB,4CAA4C,CAAC;AAE7E,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC;AAEX,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAE/C,eAAO,MAAM,uBAAuB,UAAY,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
- import type { WixCliPlugin } from './types';
2
- export declare const wixCodeDiagnosticsPlugin: () => WixCliPlugin;
1
+ export { wixCodeDiagnosticsPlugin } from './plugin';
2
+ export type { WixCodeDiagnosticsPluginOptions } from './plugin';
3
3
  export type { WixCliPlugin, CliErrorCtx } from './types';
4
4
  export { reportDiagnostic, cliErrorToCodeErrors } from './reportDiagnostic';
5
5
  export { readAppConfig } from './appConfig';
6
+ export { startRuntimeErrorsServer } from './runtimeErrorsServer';
7
+ export type { RuntimeErrorsServer, RuntimeErrorsServerOptions } from './runtimeErrorsServer';
8
+ export { serializeRuntimeError, createRuntimeErrorLimiter } from './runtimeError';
9
+ export type { SerializedRuntimeError } from './runtimeError';
10
+ export { RUNTIME_ERRORS_PORT, RUNTIME_ERRORS_HOST, RUNTIME_ERRORS_PATH } from './constants';
6
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM5C,eAAO,MAAM,wBAAwB,QAAO,YAwB3C,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAChE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAClF,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.mjs CHANGED
@@ -67,36 +67,342 @@ var reportDiagnostic = async ({
67
67
  }
68
68
  };
69
69
 
70
- // src/index.ts
70
+ // src/constants.ts
71
+ var RUNTIME_ERRORS_PORT = 52415;
72
+ var RUNTIME_ERRORS_PATH = "/runtime-errors/stream";
73
+ var HEARTBEAT_INTERVAL_MS = 25e3;
74
+ var RECONNECT_DELAY_MS = 2e3;
75
+ var RUNTIME_ERRORS_BUFFER_SIZE = 100;
76
+ var DEDUP_WINDOW_MS = 1e3;
77
+ var MAX_ERRORS_PER_WINDOW = 50;
78
+ var RATE_WINDOW_MS = 1e4;
79
+ var MAX_TRACKED_FINGERPRINTS = 128;
80
+ var ALLOWED_ORIGINS_ENV = "WIX_CODE_RUNTIME_ERRORS_ALLOWED_ORIGINS";
81
+ var DEFAULT_ORIGIN_ALLOWLIST = {
82
+ hosts: ["editor.wix.com", "manage.wix.com"],
83
+ suffixes: [".editor.wix.com", ".wix-code.com"]
84
+ };
85
+ var RUNTIME_ERRORS_HOST = "127.0.0.1";
86
+ var MAX_CLIENT_BUFFER_BYTES = 1048576;
87
+
88
+ // src/runtimeError.ts
89
+ import { randomUUID } from "node:crypto";
90
+ var isRecord2 = (value) => typeof value === "object" && value !== null;
91
+ var asString = (value) => typeof value === "string" ? value : void 0;
92
+ var asNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
93
+ var readLocation = (event) => {
94
+ const nested = isRecord2(event.location) ? event.location : {};
95
+ return {
96
+ file: asString(event.file) ?? asString(nested.file),
97
+ line: asNumber(event.line) ?? asNumber(nested.line),
98
+ column: asNumber(event.column) ?? asNumber(nested.column)
99
+ };
100
+ };
101
+ var serializeRuntimeError = (payload, { now = Date.now } = {}) => {
102
+ const base = { id: randomUUID(), timestamp: now() };
103
+ if (!isRecord2(payload)) {
104
+ return { ...base, name: "Error", message: String(payload) };
105
+ }
106
+ const source = isRecord2(payload.error) ? payload.error : payload;
107
+ return {
108
+ ...base,
109
+ name: asString(source.name),
110
+ message: asString(source.message),
111
+ stack: asString(source.stack),
112
+ ...readLocation(payload)
113
+ };
114
+ };
115
+ var fingerprint = ({ name, message, file, line, column }) => JSON.stringify([name, message, file, line, column]);
116
+ var createRuntimeErrorLimiter = ({
117
+ dedupWindowMs = DEDUP_WINDOW_MS,
118
+ maxPerWindow = MAX_ERRORS_PER_WINDOW,
119
+ rateWindowMs = RATE_WINDOW_MS,
120
+ maxTrackedFingerprints = MAX_TRACKED_FINGERPRINTS
121
+ } = {}) => {
122
+ const lastSeen = /* @__PURE__ */ new Map();
123
+ let windowStart = 0;
124
+ let windowCount = 0;
125
+ const forgetExpired = (now) => {
126
+ for (const [key, seenAt] of lastSeen) {
127
+ if (now - seenAt >= dedupWindowMs) {
128
+ lastSeen.delete(key);
129
+ }
130
+ }
131
+ };
132
+ return {
133
+ accept: (error) => {
134
+ const key = fingerprint(error);
135
+ const previous = lastSeen.get(key);
136
+ if (previous !== void 0 && error.timestamp - previous < dedupWindowMs) {
137
+ return false;
138
+ }
139
+ if (error.timestamp - windowStart >= rateWindowMs) {
140
+ windowStart = error.timestamp;
141
+ windowCount = 0;
142
+ }
143
+ if (windowCount >= maxPerWindow) {
144
+ return false;
145
+ }
146
+ windowCount += 1;
147
+ lastSeen.set(key, error.timestamp);
148
+ if (lastSeen.size > maxTrackedFingerprints) {
149
+ forgetExpired(error.timestamp);
150
+ }
151
+ return true;
152
+ },
153
+ trackedFingerprints: () => lastSeen.size
154
+ };
155
+ };
156
+
157
+ // src/runtimeErrorsServer.ts
158
+ import { createServer } from "node:http";
159
+
160
+ // src/origin.ts
161
+ var urlOf = (value) => {
162
+ try {
163
+ return new URL(value);
164
+ } catch {
165
+ return void 0;
166
+ }
167
+ };
168
+ var emptyAllowlist = () => ({ origins: [], hosts: [], suffixes: [] });
169
+ var parseAllowedOrigins = (value) => {
170
+ const entries = (value ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
171
+ if (entries.length === 0) {
172
+ return void 0;
173
+ }
174
+ const allowlist = emptyAllowlist();
175
+ const ignored = [];
176
+ for (const entry of entries) {
177
+ if (entry.startsWith("*.") || entry.startsWith(".")) {
178
+ allowlist.suffixes.push(entry.replace(/^\*/, ""));
179
+ continue;
180
+ }
181
+ if (entry.includes("://")) {
182
+ const url = urlOf(entry);
183
+ if (url) {
184
+ allowlist.origins.push(url.origin);
185
+ } else {
186
+ ignored.push(entry);
187
+ }
188
+ continue;
189
+ }
190
+ if (entry.includes(":") || entry.includes("/")) {
191
+ ignored.push(entry);
192
+ continue;
193
+ }
194
+ allowlist.hosts.push(entry);
195
+ }
196
+ if (ignored.length > 0) {
197
+ console.warn(
198
+ `[wix-code-diagnostics] ignoring unusable ${ALLOWED_ORIGINS_ENV} entries: ${ignored.join(", ")}. Use a hostname, a full origin, or a *.suffix pattern.`
199
+ );
200
+ }
201
+ return allowlist;
202
+ };
203
+ var shippedAllowlist = () => ({
204
+ origins: [],
205
+ hosts: [...DEFAULT_ORIGIN_ALLOWLIST.hosts],
206
+ suffixes: [...DEFAULT_ORIGIN_ALLOWLIST.suffixes]
207
+ });
208
+ var resolveOriginAllowlist = (env = process.env) => parseAllowedOrigins(env[ALLOWED_ORIGINS_ENV]) ?? shippedAllowlist();
209
+ var isEditorOrigin = (origin, allowlist) => {
210
+ const url = urlOf(origin);
211
+ if (!url) {
212
+ return false;
213
+ }
214
+ return allowlist.origins.includes(url.origin) || allowlist.hosts.includes(url.hostname) || allowlist.suffixes.some((suffix) => url.hostname.endsWith(suffix));
215
+ };
216
+
217
+ // src/sseClients.ts
218
+ var writeToClients = (clients, chunk, maxBufferedBytes) => {
219
+ for (const client of clients) {
220
+ client.write(chunk);
221
+ if (client.writableLength >= maxBufferedBytes) {
222
+ clients.delete(client);
223
+ client.destroy();
224
+ }
225
+ }
226
+ };
227
+
228
+ // src/runtimeErrorsServer.ts
229
+ var EPHEMERAL_PORT = 0;
230
+ var SSE_HEADERS = {
231
+ "content-type": "text/event-stream; charset=utf-8",
232
+ "cache-control": "no-cache, no-transform",
233
+ connection: "keep-alive",
234
+ "x-accel-buffering": "no",
235
+ vary: "Origin"
236
+ };
237
+ var formatEvent = (error) => `event: runtime-error
238
+ id: ${error.id}
239
+ data: ${JSON.stringify(error)}
240
+
241
+ `;
242
+ var firstHeader = (value) => Array.isArray(value) ? value[0] : value;
243
+ var isPortTaken = (error) => typeof error === "object" && error !== null && error.code === "EADDRINUSE";
244
+ var listen = (server, port, host) => new Promise((resolve, reject) => {
245
+ const onError = (error) => reject(error);
246
+ server.once("error", onError);
247
+ server.listen(port, host, () => {
248
+ server.off("error", onError);
249
+ resolve();
250
+ });
251
+ });
252
+ var startRuntimeErrorsServer = async ({
253
+ port = RUNTIME_ERRORS_PORT,
254
+ host = RUNTIME_ERRORS_HOST,
255
+ path = RUNTIME_ERRORS_PATH,
256
+ bufferSize = RUNTIME_ERRORS_BUFFER_SIZE,
257
+ heartbeatIntervalMs = HEARTBEAT_INTERVAL_MS,
258
+ maxClientBufferBytes = MAX_CLIENT_BUFFER_BYTES,
259
+ allowedOrigins = resolveOriginAllowlist()
260
+ } = {}) => {
261
+ const buffer = [];
262
+ const clients = /* @__PURE__ */ new Set();
263
+ const broadcast = (chunk) => writeToClients(clients, chunk, maxClientBufferBytes);
264
+ const replayFrom = (lastEventId) => {
265
+ if (!lastEventId) {
266
+ return buffer;
267
+ }
268
+ const index = buffer.findIndex((error) => error.id === lastEventId);
269
+ return index === -1 ? buffer : buffer.slice(index + 1);
270
+ };
271
+ const onRequest = (request, response) => {
272
+ const requestPath = (request.url ?? "").split("?")[0];
273
+ if (request.method !== "GET" || requestPath !== path) {
274
+ response.writeHead(404, { "content-type": "text/plain" });
275
+ response.end("not found");
276
+ return;
277
+ }
278
+ const origin = firstHeader(request.headers.origin);
279
+ if (origin !== void 0 && !isEditorOrigin(origin, allowedOrigins)) {
280
+ response.writeHead(403, { "content-type": "text/plain", vary: "Origin" });
281
+ response.end("forbidden origin");
282
+ return;
283
+ }
284
+ response.writeHead(200, {
285
+ ...SSE_HEADERS,
286
+ ...origin === void 0 ? {} : { "access-control-allow-origin": origin }
287
+ });
288
+ response.flushHeaders();
289
+ response.write(`retry: ${RECONNECT_DELAY_MS}
290
+
291
+ `);
292
+ for (const error of replayFrom(firstHeader(request.headers["last-event-id"]))) {
293
+ response.write(formatEvent(error));
294
+ }
295
+ clients.add(response);
296
+ request.on("close", () => clients.delete(response));
297
+ };
298
+ const server = createServer(onRequest);
299
+ server.on("connection", (socket) => socket.unref());
300
+ let usingFallbackPort = false;
301
+ try {
302
+ await listen(server, port, host);
303
+ } catch (error) {
304
+ if (!isPortTaken(error) || port === EPHEMERAL_PORT) {
305
+ throw error;
306
+ }
307
+ usingFallbackPort = true;
308
+ await listen(server, EPHEMERAL_PORT, host);
309
+ }
310
+ server.unref();
311
+ server.on("error", (error) => {
312
+ console.error("[wix-code-diagnostics] runtime-errors server error:", error);
313
+ });
314
+ const heartbeat = setInterval(() => broadcast(": ping\n\n"), heartbeatIntervalMs);
315
+ heartbeat.unref?.();
316
+ const address = server.address();
317
+ const boundPort = typeof address === "object" && address !== null ? address.port : port;
318
+ return {
319
+ port: boundPort,
320
+ requestedPort: port,
321
+ usingFallbackPort,
322
+ host,
323
+ publish: (error) => {
324
+ buffer.push(error);
325
+ if (buffer.length > bufferSize) {
326
+ buffer.splice(0, buffer.length - bufferSize);
327
+ }
328
+ broadcast(formatEvent(error));
329
+ },
330
+ close: async () => {
331
+ clearInterval(heartbeat);
332
+ for (const client of clients) {
333
+ client.end();
334
+ }
335
+ clients.clear();
336
+ await new Promise((resolve) => server.close(() => resolve()));
337
+ }
338
+ };
339
+ };
340
+
341
+ // src/plugin.ts
71
342
  var ENV_ENDPOINT = "WIX_CODE_DIAGNOSTICS_ENDPOINT";
72
343
  var ENV_TOKEN = "WIX_CODE_DIAGNOSTICS_TOKEN";
73
- var wixCodeDiagnosticsPlugin = () => {
344
+ var wixCodeDiagnosticsPlugin = ({
345
+ startServer = startRuntimeErrorsServer
346
+ } = {}) => {
74
347
  const endpoint = process.env[ENV_ENDPOINT];
75
348
  const token = process.env[ENV_TOKEN];
76
349
  return {
77
350
  name: "wix-code-diagnostics",
78
351
  hooks: {
79
- "cli:setup"({ emitter }) {
80
- if (!endpoint || !token) {
352
+ "cli:setup"({ cmd, emitter }) {
353
+ if (endpoint && token) {
354
+ emitter.on("cli-error", (ctx) => {
355
+ void reportDiagnostic({
356
+ endpoint,
357
+ token,
358
+ errorType: ctx.type,
359
+ errors: cliErrorToCodeErrors(ctx)
360
+ }).catch((error) => {
361
+ console.error("[wix-code-diagnostics] failed to report diagnostic:", error);
362
+ });
363
+ });
364
+ }
365
+ if (cmd !== "dev") {
81
366
  return;
82
367
  }
83
- emitter.on("cli-error", (ctx) => {
84
- void reportDiagnostic({
85
- endpoint,
86
- token,
87
- errorType: ctx.type,
88
- errors: cliErrorToCodeErrors(ctx)
89
- }).catch((error) => {
90
- console.error("[wix-code-diagnostics] failed to report diagnostic:", error);
91
- });
368
+ const limiter = createRuntimeErrorLimiter();
369
+ const serverPromise = startServer({ port: RUNTIME_ERRORS_PORT }).then((server) => {
370
+ console.log(
371
+ `[wix-code-diagnostics] runtime-errors stream on http://${server.host}:${server.port}${RUNTIME_ERRORS_PATH}`
372
+ );
373
+ if (server.usingFallbackPort) {
374
+ console.warn(
375
+ `[wix-code-diagnostics] port ${server.requestedPort} was taken, so the stream moved to ${server.port}. The editor only looks at ${server.requestedPort}, so it will not receive runtime errors from this dev run.`
376
+ );
377
+ }
378
+ return server;
379
+ }).catch((error) => {
380
+ console.error(
381
+ "[wix-code-diagnostics] failed to start the runtime-errors server:",
382
+ error
383
+ );
384
+ return void 0;
385
+ });
386
+ emitter.on("runtime-error", (payload) => {
387
+ const error = serializeRuntimeError(payload);
388
+ if (!limiter.accept(error)) {
389
+ return;
390
+ }
391
+ void serverPromise.then((server) => server?.publish(error));
92
392
  });
93
393
  }
94
394
  }
95
395
  };
96
396
  };
97
397
  export {
398
+ RUNTIME_ERRORS_HOST,
399
+ RUNTIME_ERRORS_PATH,
400
+ RUNTIME_ERRORS_PORT,
98
401
  cliErrorToCodeErrors,
402
+ createRuntimeErrorLimiter,
99
403
  readAppConfig,
100
404
  reportDiagnostic,
405
+ serializeRuntimeError,
406
+ startRuntimeErrorsServer,
101
407
  wixCodeDiagnosticsPlugin
102
408
  };
@@ -0,0 +1,18 @@
1
+ export interface OriginAllowlist {
2
+ /** Full origins (scheme, host and port), matched exactly. */
3
+ origins: string[];
4
+ /** Bare hostnames, matched exactly, on any scheme and port. */
5
+ hosts: string[];
6
+ /** Hostname suffixes such as `.editor.wix.com`, on any scheme and port. */
7
+ suffixes: string[];
8
+ }
9
+ /**
10
+ * Entries are hostnames (`editor.wix.com`), full origins (`http://localhost:3000`, matched
11
+ * exactly, port and scheme included) or suffix patterns (`*.editor.wix.com`). Anything else —
12
+ * a schemeless `localhost:3000`, say — is ambiguous and is dropped with a warning rather than
13
+ * quietly widened into a host match.
14
+ */
15
+ export declare const parseAllowedOrigins: (value: string | undefined) => OriginAllowlist | undefined;
16
+ export declare const resolveOriginAllowlist: (env?: NodeJS.ProcessEnv) => OriginAllowlist;
17
+ export declare const isEditorOrigin: (origin: string, allowlist: OriginAllowlist) => boolean;
18
+ //# sourceMappingURL=origin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../src/origin.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAYD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,eAAe,GAAG,SA6CjF,CAAC;AAQF,eAAO,MAAM,sBAAsB,GACjC,MAAK,MAAM,CAAC,UAAwB,KACnC,eAAsF,CAAC;AAE1F,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,WAAW,eAAe,KAAG,OAU3E,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { WixCliPlugin } from './types';
2
+ import { startRuntimeErrorsServer } from './runtimeErrorsServer';
3
+ export interface WixCodeDiagnosticsPluginOptions {
4
+ startServer?: typeof startRuntimeErrorsServer;
5
+ }
6
+ export declare const wixCodeDiagnosticsPlugin: ({ startServer, }?: WixCodeDiagnosticsPluginOptions) => WixCliPlugin;
7
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAKjE,MAAM,WAAW,+BAA+B;IAC9C,WAAW,CAAC,EAAE,OAAO,wBAAwB,CAAC;CAC/C;AAED,eAAO,MAAM,wBAAwB,GAAI,mBAEtC,+BAAoC,KAAG,YA4DzC,CAAC"}
@@ -0,0 +1,26 @@
1
+ export interface SerializedRuntimeError {
2
+ id: string;
3
+ name?: string;
4
+ message?: string;
5
+ file?: string;
6
+ line?: number;
7
+ column?: number;
8
+ stack?: string;
9
+ timestamp: number;
10
+ }
11
+ export interface SerializeOptions {
12
+ now?: () => number;
13
+ }
14
+ export declare const serializeRuntimeError: (payload: unknown, { now }?: SerializeOptions) => SerializedRuntimeError;
15
+ export interface RuntimeErrorLimiterOptions {
16
+ dedupWindowMs?: number;
17
+ maxPerWindow?: number;
18
+ rateWindowMs?: number;
19
+ maxTrackedFingerprints?: number;
20
+ }
21
+ export interface RuntimeErrorLimiter {
22
+ accept: (error: SerializedRuntimeError) => boolean;
23
+ trackedFingerprints: () => number;
24
+ }
25
+ export declare const createRuntimeErrorLimiter: ({ dedupWindowMs, maxPerWindow, rateWindowMs, maxTrackedFingerprints, }?: RuntimeErrorLimiterOptions) => RuntimeErrorLimiter;
26
+ //# sourceMappingURL=runtimeError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeError.d.ts","sourceRoot":"","sources":["../src/runtimeError.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAoBD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,qBAAqB,GAChC,SAAS,OAAO,EAChB,UAAoB,gBAAqB,KACxC,sBAgBF,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC;IACnD,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AAKD,eAAO,MAAM,yBAAyB,GAAI,yEAKvC,0BAA+B,KAAG,mBAsCpC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type OriginAllowlist } from './origin';
2
+ import type { SerializedRuntimeError } from './runtimeError';
3
+ export interface RuntimeErrorsServerOptions {
4
+ port?: number;
5
+ host?: string;
6
+ path?: string;
7
+ bufferSize?: number;
8
+ heartbeatIntervalMs?: number;
9
+ maxClientBufferBytes?: number;
10
+ allowedOrigins?: OriginAllowlist;
11
+ }
12
+ export interface RuntimeErrorsServer {
13
+ port: number;
14
+ requestedPort: number;
15
+ usingFallbackPort: boolean;
16
+ host: string;
17
+ publish: (error: SerializedRuntimeError) => void;
18
+ close: () => Promise<void>;
19
+ }
20
+ export declare const startRuntimeErrorsServer: ({ port, host, path, bufferSize, heartbeatIntervalMs, maxClientBufferBytes, allowedOrigins, }?: RuntimeErrorsServerOptions) => Promise<RuntimeErrorsServer>;
21
+ //# sourceMappingURL=runtimeErrorsServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeErrorsServer.d.ts","sourceRoot":"","sources":["../src/runtimeErrorsServer.ts"],"names":[],"mappings":"AAUA,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAExF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACjD,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAiCD,eAAO,MAAM,wBAAwB,GAAU,+FAQ5C,0BAA+B,KAAG,OAAO,CAAC,mBAAmB,CA4F/D,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ export declare const writeToClients: (clients: Set<ServerResponse>, chunk: string, maxBufferedBytes: number) => void;
3
+ //# sourceMappingURL=sseClients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sseClients.d.ts","sourceRoot":"","sources":["../src/sseClients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,eAAO,MAAM,cAAc,GACzB,SAAS,GAAG,CAAC,cAAc,CAAC,EAC5B,OAAO,MAAM,EACb,kBAAkB,MAAM,KACvB,IAQF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/wix-code-diagnostics-plugin",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Wix CLI plugin that forwards CLI build/preview/dev diagnostics to the code-project-orchestrator over HTTP",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -16,7 +16,7 @@
16
16
  "clean": "rm -rf dist",
17
17
  "prebuild": "npm run clean",
18
18
  "build": "tsc && esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.mjs",
19
- "test": "echo \"No tests for plugin package yet\" && exit 0",
19
+ "test": "jest --runInBand",
20
20
  "lint": "echo \"No lint for plugin package yet\" && exit 0",
21
21
  "typecheck": "tsc --noEmit"
22
22
  },
@@ -34,9 +34,12 @@
34
34
  }
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "^18.16.1",
37
+ "@types/jest": "^29.5.14",
38
+ "@types/node": "^24.13.3",
38
39
  "esbuild": "^0.24.0",
40
+ "jest": "^29.7.0",
41
+ "ts-jest": "^29.4.6",
39
42
  "typescript": "^5.9.3"
40
43
  },
41
- "falconPackageHash": "376916cfb639a4a0b35fef139e2add0a3850256e01430aecf316594b"
44
+ "falconPackageHash": "84d246d1a061cd4babed3d240de7dedc22ff063b3922aa4e4b9da3cd"
42
45
  }