@xeonr/renderer-sdk 1.0.5 → 1.1.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/dist/client.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { RendererCrashKind } from './protocol.js';
1
2
  import type { InitPayload, RendererApiAdapter, RendererConfig, RendererScope, RenderingType } from './types.js';
2
3
  export interface RendererClientOptions {
3
4
  /**
@@ -46,6 +47,8 @@ export declare class RendererClient {
46
47
  private currentApiBaseUrl;
47
48
  private currentPath;
48
49
  private listener;
50
+ private errorListener;
51
+ private rejectionListener;
49
52
  private hashChangeListener;
50
53
  private readyRetryInterval;
51
54
  private readyRetryTimeout;
@@ -130,6 +133,33 @@ export declare class RendererClient {
130
133
  private onHashChanged;
131
134
  private setupHashTracking;
132
135
  private postToHost;
136
+ /**
137
+ * Install window-level crash hooks the moment the client is constructed
138
+ * (i.e. as soon as a renderer touches the SDK). We deliberately do this
139
+ * here — not in a React-only entry point — so that even renderers that
140
+ * forget to wrap their root in `<RendererErrorBoundary>` still report
141
+ * async / global failures to the host.
142
+ *
143
+ * The two hooks cover the failure modes a React boundary can't see:
144
+ * - `window.error` — synchronous throws outside React's tree (raw
145
+ * <script> bugs, event-handler exceptions, image onerror handlers).
146
+ * - `unhandledrejection` — Promise chains with no `.catch()`, which
147
+ * are surprisingly common in fetch-heavy renderers.
148
+ *
149
+ * Both fire-and-forget via `postCrashToHost`; the host decides whether
150
+ * to render the overlay (a single render-time crash usually warrants
151
+ * it, a stray unhandled rejection may not).
152
+ */
153
+ private installCrashHooks;
154
+ /**
155
+ * Forward a crash to the host. Called by the global hooks and by
156
+ * `<RendererErrorBoundary>`; renderers may also call it explicitly if
157
+ * they catch something themselves and want it surfaced (e.g. data-load
158
+ * failure that wipes the UI even though no exception escaped).
159
+ *
160
+ * No-throw: telemetry must never make the underlying crash worse.
161
+ */
162
+ reportCrash(kind: RendererCrashKind, thrown: unknown): void;
133
163
  }
134
164
  export {};
135
165
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,YAAY,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;AACnD,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;AACvD,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;AAChE,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,cAAc;IAC1B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,iBAAiB,CAA0B;IAEnD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,YAAY,CAA8B;IAClD,OAAO,CAAC,oBAAoB,CAA8B;IAC1D,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,WAAW,CAAe;IAElC,OAAO,CAAC,QAAQ,CAAgD;IAChE,OAAO,CAAC,kBAAkB,CAA6B;IACvD,OAAO,CAAC,kBAAkB,CAA+C;IACzE,OAAO,CAAC,iBAAiB,CAA8C;IACvE,OAAO,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UAAU;IAKlB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,iBAAiB;IA0BzB;;;;;;;OAOG;IACH,WAAW,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;CAQ3D"}
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isHostMessage } from './protocol.js';
1
+ import { buildCrashMessage, isHostMessage, postCrashToHost } from './protocol.js';
2
2
  /**
3
3
  * Client SDK for custom renderers running inside a sandboxed iframe.
4
4
  *
@@ -34,6 +34,8 @@ export class RendererClient {
34
34
  currentApiBaseUrl = null;
35
35
  currentPath = '/';
36
36
  listener = null;
37
+ errorListener = null;
38
+ rejectionListener = null;
37
39
  hashChangeListener = null;
38
40
  readyRetryInterval = null;
39
41
  readyRetryTimeout = null;
@@ -199,6 +201,14 @@ export class RendererClient {
199
201
  window.removeEventListener('message', this.listener);
200
202
  this.listener = null;
201
203
  }
204
+ if (this.errorListener) {
205
+ window.removeEventListener('error', this.errorListener);
206
+ this.errorListener = null;
207
+ }
208
+ if (this.rejectionListener) {
209
+ window.removeEventListener('unhandledrejection', this.rejectionListener);
210
+ this.rejectionListener = null;
211
+ }
202
212
  if (this.hashChangeListener) {
203
213
  window.removeEventListener('hashchange', this.hashChangeListener);
204
214
  this.hashChangeListener = null;
@@ -236,6 +246,7 @@ export class RendererClient {
236
246
  this.handleMessage(event.data);
237
247
  };
238
248
  window.addEventListener('message', this.listener);
249
+ this.installCrashHooks();
239
250
  // Tell the host we're ready. We retry on an interval because a fast iframe can
240
251
  // post 'ready' before the host has attached its message listener — the first
241
252
  // ping is lost, the host times out, and the user has to click retry. Pinging
@@ -385,5 +396,65 @@ export class RendererClient {
385
396
  return;
386
397
  window.parent.postMessage(message, this.targetOrigin);
387
398
  }
399
+ /**
400
+ * Install window-level crash hooks the moment the client is constructed
401
+ * (i.e. as soon as a renderer touches the SDK). We deliberately do this
402
+ * here — not in a React-only entry point — so that even renderers that
403
+ * forget to wrap their root in `<RendererErrorBoundary>` still report
404
+ * async / global failures to the host.
405
+ *
406
+ * The two hooks cover the failure modes a React boundary can't see:
407
+ * - `window.error` — synchronous throws outside React's tree (raw
408
+ * <script> bugs, event-handler exceptions, image onerror handlers).
409
+ * - `unhandledrejection` — Promise chains with no `.catch()`, which
410
+ * are surprisingly common in fetch-heavy renderers.
411
+ *
412
+ * Both fire-and-forget via `postCrashToHost`; the host decides whether
413
+ * to render the overlay (a single render-time crash usually warrants
414
+ * it, a stray unhandled rejection may not).
415
+ */
416
+ installCrashHooks() {
417
+ if (typeof window === 'undefined')
418
+ return;
419
+ this.errorListener = (event) => {
420
+ if (this.destroyed)
421
+ return;
422
+ // Prefer event.error for the real stack; fall back to a synthetic
423
+ // shape when the browser only gave us message/filename/lineno
424
+ // (cross-origin scripts strip event.error to null).
425
+ const thrown = event.error ?? {
426
+ name: 'ErrorEvent',
427
+ message: event.message || 'Uncaught error',
428
+ stack: event.filename
429
+ ? `at ${event.filename}:${event.lineno ?? '?'}:${event.colno ?? '?'}`
430
+ : '',
431
+ };
432
+ this.reportCrash('error', thrown);
433
+ };
434
+ window.addEventListener('error', this.errorListener);
435
+ this.rejectionListener = (event) => {
436
+ if (this.destroyed)
437
+ return;
438
+ this.reportCrash('unhandled-rejection', event.reason);
439
+ };
440
+ window.addEventListener('unhandledrejection', this.rejectionListener);
441
+ }
442
+ /**
443
+ * Forward a crash to the host. Called by the global hooks and by
444
+ * `<RendererErrorBoundary>`; renderers may also call it explicitly if
445
+ * they catch something themselves and want it surfaced (e.g. data-load
446
+ * failure that wipes the UI even though no exception escaped).
447
+ *
448
+ * No-throw: telemetry must never make the underlying crash worse.
449
+ */
450
+ reportCrash(kind, thrown) {
451
+ try {
452
+ const msg = buildCrashMessage(kind, thrown);
453
+ postCrashToHost(msg, this.targetOrigin);
454
+ }
455
+ catch {
456
+ // Swallowed on purpose — see above.
457
+ }
458
+ }
388
459
  }
389
460
  //# sourceMappingURL=client.js.map
@@ -1 +1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AC,MAAM,CAAC,CAAC;QACvD,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;OAOG;IACH,WAAW,CAAC,IAAuB,EAAE,MAAe;QACnD,IAAI,CAAC;YACJ,MAAM,GAAG,GAAuB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAChE,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACR,oCAAoC;QACrC,CAAC;IACF,CAAC;CACD"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { RendererClient } from './client.js';
2
2
  export type { RendererClientOptions } from './client.js';
3
3
  export type { RendererConfig, RendererPermission, RendererScope, RendererBucketScope, RendererFolderScope, RendererUploadScope, RendererVirtualFileScope, RenderingType, InitPayload, RendererApiAdapter, } from './types.js';
4
- export { MESSAGE_PREFIX, PROTOCOL_VERSION, isRendererMessage, isHostMessage, isIframeMessage, } from './protocol.js';
5
- export type { HostMessage, HostInitMessage, HostThemeUpdateMessage, HostTokenRefreshMessage, HostGenerateTokenResultMessage, HostHistoryBackMessage, HostHistoryForwardMessage, IframeMessage, IframeReadyMessage, IframeOpenUploadMessage, IframeTokenRequestMessage, IframeCloseMessage, IframeInitAckMessage, IframeGenerateTokenMessage, IframeHistoryPushMessage, IframeHistoryReplaceMessage, RendererMessage, } from './protocol.js';
4
+ export { MESSAGE_PREFIX, PROTOCOL_VERSION, isRendererMessage, isHostMessage, isIframeMessage, buildCrashMessage, postCrashToHost, } from './protocol.js';
5
+ export type { HostMessage, HostInitMessage, HostThemeUpdateMessage, HostTokenRefreshMessage, HostGenerateTokenResultMessage, HostHistoryBackMessage, HostHistoryForwardMessage, IframeMessage, IframeReadyMessage, IframeOpenUploadMessage, IframeTokenRequestMessage, IframeCloseMessage, IframeInitAckMessage, IframeGenerateTokenMessage, IframeHistoryPushMessage, IframeHistoryReplaceMessage, IframeCrashMessage, RendererCrashKind, RendererMessage, } from './protocol.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EACX,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,WAAW,EACX,kBAAkB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,eAAe,GACf,MAAM,eAAe,CAAC;AAEvB,YAAY,EACX,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,sBAAsB,EACtB,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,eAAe,GACf,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,YAAY,EACX,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,WAAW,EACX,kBAAkB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GACf,MAAM,eAAe,CAAC;AAEvB,YAAY,EACX,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,sBAAsB,EACtB,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GACf,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { RendererClient } from './client.js';
2
- export { MESSAGE_PREFIX, PROTOCOL_VERSION, isRendererMessage, isHostMessage, isIframeMessage, } from './protocol.js';
2
+ export { MESSAGE_PREFIX, PROTOCOL_VERSION, isRendererMessage, isHostMessage, isIframeMessage, buildCrashMessage, postCrashToHost, } from './protocol.js';
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAgB7C,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,eAAe,GACf,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAgB7C,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,GACf,MAAM,eAAe,CAAC"}
@@ -70,9 +70,73 @@ export interface IframeHistoryReplaceMessage {
70
70
  type: 'uplim:historyReplace';
71
71
  path: string;
72
72
  }
73
- export type IframeMessage = IframeReadyMessage | IframeOpenUploadMessage | IframeTokenRequestMessage | IframeCloseMessage | IframeInitAckMessage | IframeGenerateTokenMessage | IframeHistoryPushMessage | IframeHistoryReplaceMessage;
73
+ /**
74
+ * Which SDK code path observed the failure. Maps directly to the host's
75
+ * `RendererCrashKind` enum so the wire schema and the telemetry shape
76
+ * stay in sync.
77
+ *
78
+ * - `render` — React tree threw during render/commit; caught by the
79
+ * SDK's mandatory ErrorBoundary at the renderer root. The UI is gone.
80
+ * - `error` — `window.onerror`: synchronous uncaught exception outside
81
+ * React (event handler, top-level script). UI may or may not still
82
+ * be visible.
83
+ * - `unhandled-rejection` — `window.onunhandledrejection`: a Promise
84
+ * rejected with no `.catch()`. Almost always async, often non-fatal,
85
+ * but a useful signal that something is wrong.
86
+ */
87
+ export type RendererCrashKind = 'render' | 'error' | 'unhandled-rejection';
88
+ /**
89
+ * Tells the host the renderer just hit an unhandled exception. The host
90
+ * decides what to render in response (typically an overlay with reload
91
+ * and fallback options); the renderer never paints its own crash screen
92
+ * because (a) styling would be inconsistent with the host UI and (b) a
93
+ * render-time crash may have left the renderer's CSS / DOM unusable.
94
+ *
95
+ * Fields are deliberately string-bounded on the proto side (see
96
+ * `ReportRendererCrashRequest`) — keep payloads under those limits
97
+ * before posting.
98
+ */
99
+ export interface IframeCrashMessage {
100
+ type: 'uplim:crash';
101
+ kind: RendererCrashKind;
102
+ /** Error.name (e.g. `TypeError`). Empty when the source threw a non-Error. */
103
+ name: string;
104
+ /** Error.message — user-facing description of the failure. */
105
+ message: string;
106
+ /** Stack trace if the browser exposed one. May be minified in prod builds. */
107
+ stack: string;
108
+ /** `window.location.href` at the time of the crash, for narrowing down the route. */
109
+ rendererLocation?: string;
110
+ /** Iframe-side wall-clock millis when the crash was observed. */
111
+ reportedAtMs: number;
112
+ }
113
+ export type IframeMessage = IframeReadyMessage | IframeOpenUploadMessage | IframeTokenRequestMessage | IframeCloseMessage | IframeInitAckMessage | IframeGenerateTokenMessage | IframeHistoryPushMessage | IframeHistoryReplaceMessage | IframeCrashMessage;
74
114
  export type RendererMessage = HostMessage | IframeMessage;
75
115
  export declare function isRendererMessage(data: unknown): data is RendererMessage;
76
116
  export declare function isHostMessage(data: unknown): data is HostMessage;
117
+ /**
118
+ * Build an `IframeCrashMessage` from an unknown thrown value. Centralised so
119
+ * the React boundary and the global `error` / `unhandledrejection` hooks all
120
+ * produce identically-shaped payloads regardless of what JS threw at them
121
+ * (strings, objects, DOMExceptions, real Errors, …).
122
+ *
123
+ * Only includes what the iframe is the sole source-of-truth for —
124
+ * `name`, `message`, `stack`, `rendererLocation`, `kind`. UA, viewport,
125
+ * buildHash are deliberately omitted: the parent observes them directly
126
+ * (and trusting the iframe to self-report those opens a small but
127
+ * pointless spoof surface).
128
+ */
129
+ export declare function buildCrashMessage(kind: RendererCrashKind, thrown: unknown): IframeCrashMessage;
130
+ /**
131
+ * Fire-and-forget post of a crash message to the host. Used by both the SDK's
132
+ * global hooks and the React boundary. Falls back silently when called outside
133
+ * an iframe (e.g. SSR tests) so the SDK never throws on `window.parent` being
134
+ * `undefined`.
135
+ *
136
+ * `targetOrigin` defaults to `'*'` — at crash time we deliberately do not
137
+ * filter, because the renderer may have lost the host origin context (e.g.
138
+ * if the crash happened before `init` arrived).
139
+ */
140
+ export declare function postCrashToHost(message: IframeCrashMessage, targetOrigin?: string): void;
77
141
  export declare function isIframeMessage(data: unknown): data is IframeMessage;
78
142
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C,eAAO,MAAM,cAAc,EAAG,QAAiB,CAAC;AAChD,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAM3C,kGAAkG;AAClG,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACrB;AAED,wCAAwC;AACxC,MAAM,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AM,CAAC;CACb;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,qBAAqB,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,iBAAiB,CAAC;IACxB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;CAMrB;AAED,MAAM,MAAM,aAAa,GACtB,kBAAkB,GAClB,uBAAuB,GACvB,yBAAyB,GACzB,kBAAkB,GAClB,oBAAoB,GACpB,0BAA0B,GAC1B,wBAAwB,GACxB,2BAA2B,GAC3B,kBAAkB,CAAC;AAKtB,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,aAAa,CAAC;AAK1D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,eAAe,CAQxE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,WAAW,CAIhE;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,OAAO,GACb,kBAAkB,CAmCpB;AAUD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,EAAE,YAAY,GAAE,MAAY,GAAG,IAAI,CAQ7F;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAGpE"}
package/dist/protocol.js CHANGED
@@ -19,6 +19,97 @@ export function isHostMessage(data) {
19
19
  const t = data.type;
20
20
  return t === 'uplim:init' || t === 'uplim:theme' || t === 'uplim:token' || t === 'uplim:generateTokenResult' || t === 'uplim:historyBack' || t === 'uplim:historyForward';
21
21
  }
22
+ // Proto-side limits (see ReportRendererCrashRequest) — clamp before sending so
23
+ // we don't get truncated mid-string by buf.validate and miss the crash entirely.
24
+ const CRASH_NAME_MAX = 256;
25
+ const CRASH_MESSAGE_MAX = 4096;
26
+ const CRASH_STACK_MAX = 32768;
27
+ const CRASH_LOCATION_MAX = 2048;
28
+ function clampString(value, max) {
29
+ if (value.length <= max)
30
+ return value;
31
+ // Reserve a marker so it's obvious in telemetry that we truncated.
32
+ const suffix = '…[truncated]';
33
+ return value.slice(0, max - suffix.length) + suffix;
34
+ }
35
+ /**
36
+ * Build an `IframeCrashMessage` from an unknown thrown value. Centralised so
37
+ * the React boundary and the global `error` / `unhandledrejection` hooks all
38
+ * produce identically-shaped payloads regardless of what JS threw at them
39
+ * (strings, objects, DOMExceptions, real Errors, …).
40
+ *
41
+ * Only includes what the iframe is the sole source-of-truth for —
42
+ * `name`, `message`, `stack`, `rendererLocation`, `kind`. UA, viewport,
43
+ * buildHash are deliberately omitted: the parent observes them directly
44
+ * (and trusting the iframe to self-report those opens a small but
45
+ * pointless spoof surface).
46
+ */
47
+ export function buildCrashMessage(kind, thrown) {
48
+ let name = '';
49
+ let message = '';
50
+ let stack = '';
51
+ if (thrown instanceof Error) {
52
+ name = thrown.name || 'Error';
53
+ message = thrown.message || String(thrown);
54
+ stack = thrown.stack ?? '';
55
+ }
56
+ else if (typeof thrown === 'string') {
57
+ name = 'StringError';
58
+ message = thrown;
59
+ }
60
+ else if (thrown && typeof thrown === 'object') {
61
+ const obj = thrown;
62
+ name = typeof obj.name === 'string' ? obj.name : 'UnknownError';
63
+ message = typeof obj.message === 'string' ? obj.message : safeStringify(thrown);
64
+ stack = typeof obj.stack === 'string' ? obj.stack : '';
65
+ }
66
+ else {
67
+ name = 'UnknownError';
68
+ message = String(thrown);
69
+ }
70
+ let rendererLocation;
71
+ if (typeof window !== 'undefined' && window.location) {
72
+ rendererLocation = clampString(window.location.href, CRASH_LOCATION_MAX);
73
+ }
74
+ return {
75
+ type: 'uplim:crash',
76
+ kind,
77
+ name: clampString(name, CRASH_NAME_MAX),
78
+ message: clampString(message, CRASH_MESSAGE_MAX),
79
+ stack: clampString(stack, CRASH_STACK_MAX),
80
+ rendererLocation,
81
+ reportedAtMs: Date.now(),
82
+ };
83
+ }
84
+ function safeStringify(value) {
85
+ try {
86
+ return JSON.stringify(value);
87
+ }
88
+ catch {
89
+ return String(value);
90
+ }
91
+ }
92
+ /**
93
+ * Fire-and-forget post of a crash message to the host. Used by both the SDK's
94
+ * global hooks and the React boundary. Falls back silently when called outside
95
+ * an iframe (e.g. SSR tests) so the SDK never throws on `window.parent` being
96
+ * `undefined`.
97
+ *
98
+ * `targetOrigin` defaults to `'*'` — at crash time we deliberately do not
99
+ * filter, because the renderer may have lost the host origin context (e.g.
100
+ * if the crash happened before `init` arrived).
101
+ */
102
+ export function postCrashToHost(message, targetOrigin = '*') {
103
+ if (typeof window === 'undefined' || !window.parent || window.parent === window)
104
+ return;
105
+ try {
106
+ window.parent.postMessage(message, targetOrigin);
107
+ }
108
+ catch {
109
+ // postMessage can throw on some browsers if the target origin is bad
110
+ // (cross-origin frame missing). Telemetry is best-effort.
111
+ }
112
+ }
22
113
  export function isIframeMessage(data) {
23
114
  if (!isRendererMessage(data))
24
115
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,mDAAmD;AACnD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,QAAiB,CAAC;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAmH3C,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC9C,OAAO,CACN,OAAO,IAAI,KAAK,QAAQ;QACxB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AC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACF,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,OAA2B,EAAE,eAAuB,GAAG;IACtF,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO;IACxF,IAAI,CAAC;QACJ,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACR,qEAAqE;QACrE,0DAA0D;IAC3D,CAAC;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAa;IAC5C,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { Component, type ErrorInfo, type ReactNode } from 'react';
2
+ /**
3
+ * React error boundary that catches render-time exceptions and forwards
4
+ * them to the host via `uplim:crash`. **Renderers should wrap their root
5
+ * in this component** — the SDK's global window hooks catch async
6
+ * failures, but they cannot catch errors thrown during React render or
7
+ * commit (those abort the tree before bubbling to `window.error`).
8
+ *
9
+ * Deliberately renders **nothing** on crash. The host owns the overlay
10
+ * UI for two reasons:
11
+ * 1. Styling stays consistent with the dashboard chrome — a renderer's
12
+ * CSS may itself be the thing that broke, so painting an inline
13
+ * fallback inside the iframe risks an invisible / unreadable
14
+ * screen.
15
+ * 2. The host's overlay can offer recovery actions the renderer
16
+ * can't, like "open the built-in preview instead" (which involves
17
+ * tearing this iframe down and rendering something else).
18
+ *
19
+ * Renderers may pass a `fallback` if they want a minimal visible
20
+ * placeholder while the host's overlay paints (e.g. so users don't
21
+ * stare at a transparent iframe for a frame), but the host overlay
22
+ * remains the source of truth.
23
+ *
24
+ * Usage:
25
+ *
26
+ * ```tsx
27
+ * import { createRoot } from 'react-dom/client';
28
+ * import { RendererErrorBoundary } from '@xeonr/renderer-sdk/react';
29
+ *
30
+ * createRoot(document.getElementById('root')!).render(
31
+ * <RendererErrorBoundary>
32
+ * <App />
33
+ * </RendererErrorBoundary>
34
+ * );
35
+ * ```
36
+ */
37
+ export interface RendererErrorBoundaryProps {
38
+ children: ReactNode;
39
+ /** Optional inline fallback rendered after the crash is reported. Default: nothing. */
40
+ fallback?: ReactNode;
41
+ /**
42
+ * Optional targetOrigin override for the postMessage. Matches
43
+ * `RendererClientOptions.targetOrigin`. Defaults to `'*'` because at
44
+ * crash time we don't want to gate telemetry on origin matching.
45
+ */
46
+ targetOrigin?: string;
47
+ /** Optional hook called after the host has been notified — useful for sentry / console wiring. */
48
+ onCrash?: (error: unknown, info: ErrorInfo) => void;
49
+ }
50
+ interface State {
51
+ crashed: boolean;
52
+ }
53
+ export declare class RendererErrorBoundary extends Component<RendererErrorBoundaryProps, State> {
54
+ state: State;
55
+ static getDerivedStateFromError(): State;
56
+ componentDidCatch(error: unknown, info: ErrorInfo): void;
57
+ render(): ReactNode;
58
+ }
59
+ export {};
60
+ //# sourceMappingURL=RendererErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RendererErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/react/RendererErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,SAAS,CAAC;IACpB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kGAAkG;IAClG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACpD;AAED,UAAU,KAAK;IACd,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,qBAAsB,SAAQ,SAAS,CAAC,0BAA0B,EAAE,KAAK,CAAC;IACtF,KAAK,EAAE,KAAK,CAAsB;IAElC,MAAM,CAAC,wBAAwB,IAAI,KAAK;IAIxC,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAyBxD,MAAM,IAAI,SAAS;CAMnB"}
@@ -0,0 +1,37 @@
1
+ import { Component } from 'react';
2
+ import { buildCrashMessage, postCrashToHost } from '../protocol.js';
3
+ export class RendererErrorBoundary extends Component {
4
+ state = { crashed: false };
5
+ static getDerivedStateFromError() {
6
+ return { crashed: true };
7
+ }
8
+ componentDidCatch(error, info) {
9
+ // Build the crash payload via the shared helper so global hooks and the
10
+ // boundary produce identical wire shapes.
11
+ const msg = buildCrashMessage('render', error);
12
+ // React stack is more useful than the JS stack for render-time bugs —
13
+ // it points at the component path, not just the throwing function. We
14
+ // append it so server-side logs preserve both.
15
+ if (info?.componentStack) {
16
+ const componentStack = `\n\nReact component stack:\n${info.componentStack}`;
17
+ // Respect the proto's stack limit (32768) — buildCrashMessage already
18
+ // clamped, but we have new content to add, so re-clamp the combined value.
19
+ const combined = (msg.stack ? `${msg.stack}\n` : '') + componentStack;
20
+ msg.stack = combined.length > 32768 ? combined.slice(0, 32768 - 12) + '…[truncated]' : combined;
21
+ }
22
+ postCrashToHost(msg, this.props.targetOrigin ?? '*');
23
+ try {
24
+ this.props.onCrash?.(error, info);
25
+ }
26
+ catch {
27
+ // Best-effort: never let the consumer's handler resurface the crash.
28
+ }
29
+ }
30
+ render() {
31
+ if (this.state.crashed) {
32
+ return this.props.fallback ?? null;
33
+ }
34
+ return this.props.children;
35
+ }
36
+ }
37
+ //# sourceMappingURL=RendererErrorBoundary.js.map
@@ -0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C,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACR,qEAAqE;QACtE,CAAC;IACF,CAAC;IAED,MAAM;QACL,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC5B,CAAC;CACD"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Drop-in replacement for `react-dom/client` that auto-wraps the rendered
3
+ * tree in `<RendererErrorBoundary>`. Used by `@xeonr/renderer-plugin-vite`
4
+ * to rewrite renderer-archive build imports so the boundary is mandatory
5
+ * without renderer authors having to opt in.
6
+ *
7
+ * Renderer authors do NOT need to import this directly — the vite plugin
8
+ * substitutes `react-dom/client` specifiers in renderer source code at
9
+ * build time. If a renderer is built outside the plugin (e.g. a custom
10
+ * pipeline), authors can import from here explicitly instead.
11
+ *
12
+ * Mirrors React 18+ `Root` / `RootOptions` surface; passes everything
13
+ * through unchanged except for `render` and `hydrateRoot`'s initial
14
+ * children, which are wrapped in the boundary so a single render-time
15
+ * crash is forwarded to the host overlay rather than tearing down the
16
+ * iframe silently.
17
+ */
18
+ import { type Root, type RootOptions, type HydrationOptions } from 'react-dom/client';
19
+ import { type ReactNode } from 'react';
20
+ export declare function createRoot(container: Element | DocumentFragment, options?: RootOptions): Root;
21
+ export declare function hydrateRoot(container: Element | Document, initialChildren: ReactNode, options?: HydrationOptions): Root;
22
+ export type { Root, RootOptions, HydrationOptions } from 'react-dom/client';
23
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/react/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAGN,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOtD,wBAAgB,UAAU,CAAC,SAAS,EAAE,OAAO,GAAG,gBAAgB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAK7F;AAED,wBAAgB,WAAW,CAC1B,SAAS,EAAE,OAAO,GAAG,QAAQ,EAC7B,eAAe,EAAE,SAAS,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACxB,IAAI,CAKN;AAKD,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Drop-in replacement for `react-dom/client` that auto-wraps the rendered
3
+ * tree in `<RendererErrorBoundary>`. Used by `@xeonr/renderer-plugin-vite`
4
+ * to rewrite renderer-archive build imports so the boundary is mandatory
5
+ * without renderer authors having to opt in.
6
+ *
7
+ * Renderer authors do NOT need to import this directly — the vite plugin
8
+ * substitutes `react-dom/client` specifiers in renderer source code at
9
+ * build time. If a renderer is built outside the plugin (e.g. a custom
10
+ * pipeline), authors can import from here explicitly instead.
11
+ *
12
+ * Mirrors React 18+ `Root` / `RootOptions` surface; passes everything
13
+ * through unchanged except for `render` and `hydrateRoot`'s initial
14
+ * children, which are wrapped in the boundary so a single render-time
15
+ * crash is forwarded to the host overlay rather than tearing down the
16
+ * iframe silently.
17
+ */
18
+ import { createRoot as origCreateRoot, hydrateRoot as origHydrateRoot, } from 'react-dom/client';
19
+ import { createElement } from 'react';
20
+ import { RendererErrorBoundary } from './RendererErrorBoundary.js';
21
+ function wrap(children) {
22
+ return createElement(RendererErrorBoundary, null, children);
23
+ }
24
+ export function createRoot(container, options) {
25
+ const root = origCreateRoot(container, options);
26
+ const originalRender = root.render.bind(root);
27
+ root.render = (children) => originalRender(wrap(children));
28
+ return root;
29
+ }
30
+ export function hydrateRoot(container, initialChildren, options) {
31
+ const root = origHydrateRoot(container, wrap(initialChildren), options);
32
+ const originalRender = root.render.bind(root);
33
+ root.render = (children) => originalRender(wrap(children));
34
+ return root;
35
+ }
36
+ //# sourceMappingURL=dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.js","sourceRoot":"","sources":["../../src/react/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACN,UAAU,IAAI,cAAc,EAC5B,WAAW,IAAI,eAAe,GAI9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,SAAS,IAAI,CAAC,QAAmB;IAChC,OAAO,aAAa,CAAC,qBAAqB,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,SAAqC,EAAE,OAAqB;IACtF,MAAM,IAAI,GAAG,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,GAAG,CAAC,QAAmB,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,WAAW,CAC1B,SAA6B,EAC7B,eAA0B,EAC1B,OAA0B;IAE1B,MAAM,IAAI,GAAG,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;IACxE,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,MAAM,GAAG,CAAC,QAAmB,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export { useRendererClient } from './useRendererClient.js';
2
2
  export type { UseRendererClientOptions, UseRendererClientResult } from './useRendererClient.js';
3
+ export { RendererErrorBoundary } from './RendererErrorBoundary.js';
4
+ export type { RendererErrorBoundaryProps } from './RendererErrorBoundary.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { useRendererClient } from './useRendererClient.js';
2
+ export { RendererErrorBoundary } from './RendererErrorBoundary.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/types.d.ts CHANGED
@@ -11,6 +11,27 @@ export interface RendererConfig {
11
11
  allowForms?: boolean;
12
12
  allowDownloads?: boolean;
13
13
  };
14
+ /**
15
+ * Extra origins this renderer needs to reach via `fetch` / `XMLHttpRequest`
16
+ * / WebSocket. Surfaced to the browser as additional entries in the CSP
17
+ * `connect-src` directive. The upl.im API + auth hosts are always allowed
18
+ * by the renderer-proxy; only list extras here (e.g. a third-party API
19
+ * the renderer integrates with).
20
+ *
21
+ * Each entry is a fully-qualified origin like `https://api.example.com`
22
+ * or a wildcarded host like `https://*.example.com`. No paths, no
23
+ * trailing slashes. Origins are validated at deploy time.
24
+ */
25
+ connectHosts?: string[];
26
+ /**
27
+ * Short build identifier the build pipeline stamps into config.json
28
+ * (e.g. the renderer-plugin-vite hash of the output directory).
29
+ * Surfaced in crash telemetry as a separate dimension so we can
30
+ * distinguish "crashed in build A" from "crashed in build B" even
31
+ * when both builds share the same archive_upload_id (the developer
32
+ * republished without bumping the archive). Bounded to 64 chars.
33
+ */
34
+ buildHash?: string;
14
35
  }
15
36
  export type RendererPermission = 'createFolder' | 'openUpload';
16
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,CAAC,CAAC;IACX,uDAAuD;IACvD,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACnC,OAAO,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,cAAc,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACF;AAED,MAAM,MAAM,kBAAkB,GAC3B,cAAc,GACd,YAAY,CAAC;AAEhB;;;GAGG;AACH,MAAM,MAAM,aAAa,GACtB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,wBAAwB,CAAC;AAE5B,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACjB;AA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IAClB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GACtB,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,CAAC;AAEnB;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,uBAAuB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CAC5C;AAED,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC3B,wBAAwB;IACxB,OAAO,EAAE,CAAC,CAAC;IACX,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,cAAc,EAAE,MAAM,CAAC;IACvB,0BAA0B;IAC1B,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,mCAAmC;IACnC,UAAU,EAAE,WAAW,GAAG,QAAQ,CAAC;IACnC,+CAA+C;IAC/C,KAAK,EAAE,aAAa,CAAC;IACrB,4DAA4D;IAC5D,aAAa,EAAE,aAAa,CAAC;IAC7B,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,MAAM,EAAE,cAAc,CAAC;IACvB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeonr/renderer-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "description": "SDK for building custom renderers for upl.im integrations",
@@ -15,6 +15,10 @@
15
15
  "default": "./dist/react/index.js",
16
16
  "types": "./dist/react/index.d.ts"
17
17
  },
18
+ "./react/dom": {
19
+ "default": "./dist/react/dom.js",
20
+ "types": "./dist/react/dom.d.ts"
21
+ },
18
22
  "./protocol": {
19
23
  "default": "./dist/protocol.js",
20
24
  "types": "./dist/protocol.d.ts"
@@ -25,16 +29,22 @@
25
29
  }
26
30
  },
27
31
  "peerDependencies": {
28
- "react": ">=18.0.0"
32
+ "react": ">=18.0.0",
33
+ "react-dom": ">=18.0.0"
29
34
  },
30
35
  "peerDependenciesMeta": {
31
36
  "react": {
32
37
  "optional": true
38
+ },
39
+ "react-dom": {
40
+ "optional": true
33
41
  }
34
42
  },
35
43
  "devDependencies": {
36
44
  "@types/react": "^19.0.0",
45
+ "@types/react-dom": "^19.0.0",
37
46
  "react": "^19.0.0",
47
+ "react-dom": "^19.0.0",
38
48
  "typescript": "^5.8.3"
39
49
  },
40
50
  "scripts": {
package/src/client.ts CHANGED
@@ -6,8 +6,10 @@ import type {
6
6
  HostGenerateTokenResultMessage,
7
7
  IframeHistoryPushMessage,
8
8
  IframeHistoryReplaceMessage,
9
+ IframeCrashMessage,
10
+ RendererCrashKind,
9
11
  } from './protocol.js';
10
- import { isHostMessage } from './protocol.js';
12
+ import { buildCrashMessage, isHostMessage, postCrashToHost } from './protocol.js';
11
13
  import type { InitPayload, RendererApiAdapter, RendererConfig, RendererScope, RenderingType } from './types.js';
12
14
 
13
15
  export interface RendererClientOptions {
@@ -61,6 +63,8 @@ export class RendererClient {
61
63
  private currentPath: string = '/';
62
64
 
63
65
  private listener: ((event: MessageEvent) => void) | null = null;
66
+ private errorListener: ((event: ErrorEvent) => void) | null = null;
67
+ private rejectionListener: ((event: PromiseRejectionEvent) => void) | null = null;
64
68
  private hashChangeListener: (() => void) | null = null;
65
69
  private readyRetryInterval: ReturnType<typeof setInterval> | null = null;
66
70
  private readyRetryTimeout: ReturnType<typeof setTimeout> | null = null;
@@ -250,6 +254,14 @@ export class RendererClient {
250
254
  window.removeEventListener('message', this.listener);
251
255
  this.listener = null;
252
256
  }
257
+ if (this.errorListener) {
258
+ window.removeEventListener('error', this.errorListener);
259
+ this.errorListener = null;
260
+ }
261
+ if (this.rejectionListener) {
262
+ window.removeEventListener('unhandledrejection', this.rejectionListener);
263
+ this.rejectionListener = null;
264
+ }
253
265
  if (this.hashChangeListener) {
254
266
  window.removeEventListener('hashchange', this.hashChangeListener);
255
267
  this.hashChangeListener = null;
@@ -287,6 +299,8 @@ export class RendererClient {
287
299
 
288
300
  window.addEventListener('message', this.listener);
289
301
 
302
+ this.installCrashHooks();
303
+
290
304
  // Tell the host we're ready. We retry on an interval because a fast iframe can
291
305
  // post 'ready' before the host has attached its message listener — the first
292
306
  // ping is lost, the host times out, and the user has to click retry. Pinging
@@ -452,4 +466,64 @@ export class RendererClient {
452
466
  if (this.destroyed) return;
453
467
  window.parent.postMessage(message, this.targetOrigin);
454
468
  }
469
+
470
+ /**
471
+ * Install window-level crash hooks the moment the client is constructed
472
+ * (i.e. as soon as a renderer touches the SDK). We deliberately do this
473
+ * here — not in a React-only entry point — so that even renderers that
474
+ * forget to wrap their root in `<RendererErrorBoundary>` still report
475
+ * async / global failures to the host.
476
+ *
477
+ * The two hooks cover the failure modes a React boundary can't see:
478
+ * - `window.error` — synchronous throws outside React's tree (raw
479
+ * <script> bugs, event-handler exceptions, image onerror handlers).
480
+ * - `unhandledrejection` — Promise chains with no `.catch()`, which
481
+ * are surprisingly common in fetch-heavy renderers.
482
+ *
483
+ * Both fire-and-forget via `postCrashToHost`; the host decides whether
484
+ * to render the overlay (a single render-time crash usually warrants
485
+ * it, a stray unhandled rejection may not).
486
+ */
487
+ private installCrashHooks(): void {
488
+ if (typeof window === 'undefined') return;
489
+
490
+ this.errorListener = (event: ErrorEvent) => {
491
+ if (this.destroyed) return;
492
+ // Prefer event.error for the real stack; fall back to a synthetic
493
+ // shape when the browser only gave us message/filename/lineno
494
+ // (cross-origin scripts strip event.error to null).
495
+ const thrown = event.error ?? {
496
+ name: 'ErrorEvent',
497
+ message: event.message || 'Uncaught error',
498
+ stack: event.filename
499
+ ? `at ${event.filename}:${event.lineno ?? '?'}:${event.colno ?? '?'}`
500
+ : '',
501
+ };
502
+ this.reportCrash('error', thrown);
503
+ };
504
+ window.addEventListener('error', this.errorListener);
505
+
506
+ this.rejectionListener = (event: PromiseRejectionEvent) => {
507
+ if (this.destroyed) return;
508
+ this.reportCrash('unhandled-rejection', event.reason);
509
+ };
510
+ window.addEventListener('unhandledrejection', this.rejectionListener);
511
+ }
512
+
513
+ /**
514
+ * Forward a crash to the host. Called by the global hooks and by
515
+ * `<RendererErrorBoundary>`; renderers may also call it explicitly if
516
+ * they catch something themselves and want it surfaced (e.g. data-load
517
+ * failure that wipes the UI even though no exception escaped).
518
+ *
519
+ * No-throw: telemetry must never make the underlying crash worse.
520
+ */
521
+ reportCrash(kind: RendererCrashKind, thrown: unknown): void {
522
+ try {
523
+ const msg: IframeCrashMessage = buildCrashMessage(kind, thrown);
524
+ postCrashToHost(msg, this.targetOrigin);
525
+ } catch {
526
+ // Swallowed on purpose — see above.
527
+ }
528
+ }
455
529
  }
package/src/index.ts CHANGED
@@ -20,6 +20,8 @@ export {
20
20
  isRendererMessage,
21
21
  isHostMessage,
22
22
  isIframeMessage,
23
+ buildCrashMessage,
24
+ postCrashToHost,
23
25
  } from './protocol.js';
24
26
 
25
27
  export type {
@@ -39,5 +41,7 @@ export type {
39
41
  IframeGenerateTokenMessage,
40
42
  IframeHistoryPushMessage,
41
43
  IframeHistoryReplaceMessage,
44
+ IframeCrashMessage,
45
+ RendererCrashKind,
42
46
  RendererMessage,
43
47
  } from './protocol.js';
package/src/protocol.ts CHANGED
@@ -104,6 +104,53 @@ export interface IframeHistoryReplaceMessage {
104
104
  path: string;
105
105
  }
106
106
 
107
+ /**
108
+ * Which SDK code path observed the failure. Maps directly to the host's
109
+ * `RendererCrashKind` enum so the wire schema and the telemetry shape
110
+ * stay in sync.
111
+ *
112
+ * - `render` — React tree threw during render/commit; caught by the
113
+ * SDK's mandatory ErrorBoundary at the renderer root. The UI is gone.
114
+ * - `error` — `window.onerror`: synchronous uncaught exception outside
115
+ * React (event handler, top-level script). UI may or may not still
116
+ * be visible.
117
+ * - `unhandled-rejection` — `window.onunhandledrejection`: a Promise
118
+ * rejected with no `.catch()`. Almost always async, often non-fatal,
119
+ * but a useful signal that something is wrong.
120
+ */
121
+ export type RendererCrashKind = 'render' | 'error' | 'unhandled-rejection';
122
+
123
+ /**
124
+ * Tells the host the renderer just hit an unhandled exception. The host
125
+ * decides what to render in response (typically an overlay with reload
126
+ * and fallback options); the renderer never paints its own crash screen
127
+ * because (a) styling would be inconsistent with the host UI and (b) a
128
+ * render-time crash may have left the renderer's CSS / DOM unusable.
129
+ *
130
+ * Fields are deliberately string-bounded on the proto side (see
131
+ * `ReportRendererCrashRequest`) — keep payloads under those limits
132
+ * before posting.
133
+ */
134
+ export interface IframeCrashMessage {
135
+ type: 'uplim:crash';
136
+ kind: RendererCrashKind;
137
+ /** Error.name (e.g. `TypeError`). Empty when the source threw a non-Error. */
138
+ name: string;
139
+ /** Error.message — user-facing description of the failure. */
140
+ message: string;
141
+ /** Stack trace if the browser exposed one. May be minified in prod builds. */
142
+ stack: string;
143
+ /** `window.location.href` at the time of the crash, for narrowing down the route. */
144
+ rendererLocation?: string;
145
+ /** Iframe-side wall-clock millis when the crash was observed. */
146
+ reportedAtMs: number;
147
+ // NOTE: things the parent can observe for itself (user agent, viewport,
148
+ // buildHash from the rendererConfig the host already holds) are
149
+ // captured host-side in useRendererBridge — we don't trust the iframe
150
+ // to populate them. The iframe only sends what *only* it can know:
151
+ // the crash facts.
152
+ }
153
+
107
154
  export type IframeMessage =
108
155
  | IframeReadyMessage
109
156
  | IframeOpenUploadMessage
@@ -112,7 +159,8 @@ export type IframeMessage =
112
159
  | IframeInitAckMessage
113
160
  | IframeGenerateTokenMessage
114
161
  | IframeHistoryPushMessage
115
- | IframeHistoryReplaceMessage;
162
+ | IframeHistoryReplaceMessage
163
+ | IframeCrashMessage;
116
164
 
117
165
  // ---------------------------------------------------------------------------
118
166
  // Union type for any message
@@ -138,6 +186,100 @@ export function isHostMessage(data: unknown): data is HostMessage {
138
186
  return t === 'uplim:init' || t === 'uplim:theme' || t === 'uplim:token' || t === 'uplim:generateTokenResult' || t === 'uplim:historyBack' || t === 'uplim:historyForward';
139
187
  }
140
188
 
189
+ // Proto-side limits (see ReportRendererCrashRequest) — clamp before sending so
190
+ // we don't get truncated mid-string by buf.validate and miss the crash entirely.
191
+ const CRASH_NAME_MAX = 256;
192
+ const CRASH_MESSAGE_MAX = 4096;
193
+ const CRASH_STACK_MAX = 32768;
194
+ const CRASH_LOCATION_MAX = 2048;
195
+
196
+ function clampString(value: string, max: number): string {
197
+ if (value.length <= max) return value;
198
+ // Reserve a marker so it's obvious in telemetry that we truncated.
199
+ const suffix = '…[truncated]';
200
+ return value.slice(0, max - suffix.length) + suffix;
201
+ }
202
+
203
+ /**
204
+ * Build an `IframeCrashMessage` from an unknown thrown value. Centralised so
205
+ * the React boundary and the global `error` / `unhandledrejection` hooks all
206
+ * produce identically-shaped payloads regardless of what JS threw at them
207
+ * (strings, objects, DOMExceptions, real Errors, …).
208
+ *
209
+ * Only includes what the iframe is the sole source-of-truth for —
210
+ * `name`, `message`, `stack`, `rendererLocation`, `kind`. UA, viewport,
211
+ * buildHash are deliberately omitted: the parent observes them directly
212
+ * (and trusting the iframe to self-report those opens a small but
213
+ * pointless spoof surface).
214
+ */
215
+ export function buildCrashMessage(
216
+ kind: RendererCrashKind,
217
+ thrown: unknown,
218
+ ): IframeCrashMessage {
219
+ let name = '';
220
+ let message = '';
221
+ let stack = '';
222
+ if (thrown instanceof Error) {
223
+ name = thrown.name || 'Error';
224
+ message = thrown.message || String(thrown);
225
+ stack = thrown.stack ?? '';
226
+ } else if (typeof thrown === 'string') {
227
+ name = 'StringError';
228
+ message = thrown;
229
+ } else if (thrown && typeof thrown === 'object') {
230
+ const obj = thrown as { name?: unknown; message?: unknown; stack?: unknown };
231
+ name = typeof obj.name === 'string' ? obj.name : 'UnknownError';
232
+ message = typeof obj.message === 'string' ? obj.message : safeStringify(thrown);
233
+ stack = typeof obj.stack === 'string' ? obj.stack : '';
234
+ } else {
235
+ name = 'UnknownError';
236
+ message = String(thrown);
237
+ }
238
+
239
+ let rendererLocation: string | undefined;
240
+ if (typeof window !== 'undefined' && window.location) {
241
+ rendererLocation = clampString(window.location.href, CRASH_LOCATION_MAX);
242
+ }
243
+
244
+ return {
245
+ type: 'uplim:crash',
246
+ kind,
247
+ name: clampString(name, CRASH_NAME_MAX),
248
+ message: clampString(message, CRASH_MESSAGE_MAX),
249
+ stack: clampString(stack, CRASH_STACK_MAX),
250
+ rendererLocation,
251
+ reportedAtMs: Date.now(),
252
+ };
253
+ }
254
+
255
+ function safeStringify(value: unknown): string {
256
+ try {
257
+ return JSON.stringify(value);
258
+ } catch {
259
+ return String(value);
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Fire-and-forget post of a crash message to the host. Used by both the SDK's
265
+ * global hooks and the React boundary. Falls back silently when called outside
266
+ * an iframe (e.g. SSR tests) so the SDK never throws on `window.parent` being
267
+ * `undefined`.
268
+ *
269
+ * `targetOrigin` defaults to `'*'` — at crash time we deliberately do not
270
+ * filter, because the renderer may have lost the host origin context (e.g.
271
+ * if the crash happened before `init` arrived).
272
+ */
273
+ export function postCrashToHost(message: IframeCrashMessage, targetOrigin: string = '*'): void {
274
+ if (typeof window === 'undefined' || !window.parent || window.parent === window) return;
275
+ try {
276
+ window.parent.postMessage(message, targetOrigin);
277
+ } catch {
278
+ // postMessage can throw on some browsers if the target origin is bad
279
+ // (cross-origin frame missing). Telemetry is best-effort.
280
+ }
281
+ }
282
+
141
283
  export function isIframeMessage(data: unknown): data is IframeMessage {
142
284
  if (!isRendererMessage(data)) return false;
143
285
  return !isHostMessage(data);
@@ -0,0 +1,95 @@
1
+ import { Component, type ErrorInfo, type ReactNode } from 'react';
2
+ import { buildCrashMessage, postCrashToHost } from '../protocol.js';
3
+
4
+ /**
5
+ * React error boundary that catches render-time exceptions and forwards
6
+ * them to the host via `uplim:crash`. **Renderers should wrap their root
7
+ * in this component** — the SDK's global window hooks catch async
8
+ * failures, but they cannot catch errors thrown during React render or
9
+ * commit (those abort the tree before bubbling to `window.error`).
10
+ *
11
+ * Deliberately renders **nothing** on crash. The host owns the overlay
12
+ * UI for two reasons:
13
+ * 1. Styling stays consistent with the dashboard chrome — a renderer's
14
+ * CSS may itself be the thing that broke, so painting an inline
15
+ * fallback inside the iframe risks an invisible / unreadable
16
+ * screen.
17
+ * 2. The host's overlay can offer recovery actions the renderer
18
+ * can't, like "open the built-in preview instead" (which involves
19
+ * tearing this iframe down and rendering something else).
20
+ *
21
+ * Renderers may pass a `fallback` if they want a minimal visible
22
+ * placeholder while the host's overlay paints (e.g. so users don't
23
+ * stare at a transparent iframe for a frame), but the host overlay
24
+ * remains the source of truth.
25
+ *
26
+ * Usage:
27
+ *
28
+ * ```tsx
29
+ * import { createRoot } from 'react-dom/client';
30
+ * import { RendererErrorBoundary } from '@xeonr/renderer-sdk/react';
31
+ *
32
+ * createRoot(document.getElementById('root')!).render(
33
+ * <RendererErrorBoundary>
34
+ * <App />
35
+ * </RendererErrorBoundary>
36
+ * );
37
+ * ```
38
+ */
39
+ export interface RendererErrorBoundaryProps {
40
+ children: ReactNode;
41
+ /** Optional inline fallback rendered after the crash is reported. Default: nothing. */
42
+ fallback?: ReactNode;
43
+ /**
44
+ * Optional targetOrigin override for the postMessage. Matches
45
+ * `RendererClientOptions.targetOrigin`. Defaults to `'*'` because at
46
+ * crash time we don't want to gate telemetry on origin matching.
47
+ */
48
+ targetOrigin?: string;
49
+ /** Optional hook called after the host has been notified — useful for sentry / console wiring. */
50
+ onCrash?: (error: unknown, info: ErrorInfo) => void;
51
+ }
52
+
53
+ interface State {
54
+ crashed: boolean;
55
+ }
56
+
57
+ export class RendererErrorBoundary extends Component<RendererErrorBoundaryProps, State> {
58
+ state: State = { crashed: false };
59
+
60
+ static getDerivedStateFromError(): State {
61
+ return { crashed: true };
62
+ }
63
+
64
+ componentDidCatch(error: unknown, info: ErrorInfo): void {
65
+ // Build the crash payload via the shared helper so global hooks and the
66
+ // boundary produce identical wire shapes.
67
+ const msg = buildCrashMessage('render', error);
68
+
69
+ // React stack is more useful than the JS stack for render-time bugs —
70
+ // it points at the component path, not just the throwing function. We
71
+ // append it so server-side logs preserve both.
72
+ if (info?.componentStack) {
73
+ const componentStack = `\n\nReact component stack:\n${info.componentStack}`;
74
+ // Respect the proto's stack limit (32768) — buildCrashMessage already
75
+ // clamped, but we have new content to add, so re-clamp the combined value.
76
+ const combined = (msg.stack ? `${msg.stack}\n` : '') + componentStack;
77
+ msg.stack = combined.length > 32768 ? combined.slice(0, 32768 - 12) + '…[truncated]' : combined;
78
+ }
79
+
80
+ postCrashToHost(msg, this.props.targetOrigin ?? '*');
81
+
82
+ try {
83
+ this.props.onCrash?.(error, info);
84
+ } catch {
85
+ // Best-effort: never let the consumer's handler resurface the crash.
86
+ }
87
+ }
88
+
89
+ render(): ReactNode {
90
+ if (this.state.crashed) {
91
+ return this.props.fallback ?? null;
92
+ }
93
+ return this.props.children;
94
+ }
95
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Drop-in replacement for `react-dom/client` that auto-wraps the rendered
3
+ * tree in `<RendererErrorBoundary>`. Used by `@xeonr/renderer-plugin-vite`
4
+ * to rewrite renderer-archive build imports so the boundary is mandatory
5
+ * without renderer authors having to opt in.
6
+ *
7
+ * Renderer authors do NOT need to import this directly — the vite plugin
8
+ * substitutes `react-dom/client` specifiers in renderer source code at
9
+ * build time. If a renderer is built outside the plugin (e.g. a custom
10
+ * pipeline), authors can import from here explicitly instead.
11
+ *
12
+ * Mirrors React 18+ `Root` / `RootOptions` surface; passes everything
13
+ * through unchanged except for `render` and `hydrateRoot`'s initial
14
+ * children, which are wrapped in the boundary so a single render-time
15
+ * crash is forwarded to the host overlay rather than tearing down the
16
+ * iframe silently.
17
+ */
18
+ import {
19
+ createRoot as origCreateRoot,
20
+ hydrateRoot as origHydrateRoot,
21
+ type Root,
22
+ type RootOptions,
23
+ type HydrationOptions,
24
+ } from 'react-dom/client';
25
+ import { createElement, type ReactNode } from 'react';
26
+ import { RendererErrorBoundary } from './RendererErrorBoundary.js';
27
+
28
+ function wrap(children: ReactNode): ReactNode {
29
+ return createElement(RendererErrorBoundary, null, children);
30
+ }
31
+
32
+ export function createRoot(container: Element | DocumentFragment, options?: RootOptions): Root {
33
+ const root = origCreateRoot(container, options);
34
+ const originalRender = root.render.bind(root);
35
+ root.render = (children: ReactNode) => originalRender(wrap(children));
36
+ return root;
37
+ }
38
+
39
+ export function hydrateRoot(
40
+ container: Element | Document,
41
+ initialChildren: ReactNode,
42
+ options?: HydrationOptions,
43
+ ): Root {
44
+ const root = origHydrateRoot(container, wrap(initialChildren), options);
45
+ const originalRender = root.render.bind(root);
46
+ root.render = (children: ReactNode) => originalRender(wrap(children));
47
+ return root;
48
+ }
49
+
50
+ // Re-export every remaining symbol from `react-dom/client` so renderers
51
+ // importing other named bindings (e.g. `Root` type) continue to work
52
+ // after the specifier rewrite.
53
+ export type { Root, RootOptions, HydrationOptions } from 'react-dom/client';
@@ -1,2 +1,4 @@
1
1
  export { useRendererClient } from './useRendererClient.js';
2
2
  export type { UseRendererClientOptions, UseRendererClientResult } from './useRendererClient.js';
3
+ export { RendererErrorBoundary } from './RendererErrorBoundary.js';
4
+ export type { RendererErrorBoundaryProps } from './RendererErrorBoundary.js';
package/src/types.ts CHANGED
@@ -11,6 +11,27 @@ export interface RendererConfig {
11
11
  allowForms?: boolean;
12
12
  allowDownloads?: boolean;
13
13
  };
14
+ /**
15
+ * Extra origins this renderer needs to reach via `fetch` / `XMLHttpRequest`
16
+ * / WebSocket. Surfaced to the browser as additional entries in the CSP
17
+ * `connect-src` directive. The upl.im API + auth hosts are always allowed
18
+ * by the renderer-proxy; only list extras here (e.g. a third-party API
19
+ * the renderer integrates with).
20
+ *
21
+ * Each entry is a fully-qualified origin like `https://api.example.com`
22
+ * or a wildcarded host like `https://*.example.com`. No paths, no
23
+ * trailing slashes. Origins are validated at deploy time.
24
+ */
25
+ connectHosts?: string[];
26
+ /**
27
+ * Short build identifier the build pipeline stamps into config.json
28
+ * (e.g. the renderer-plugin-vite hash of the output directory).
29
+ * Surfaced in crash telemetry as a separate dimension so we can
30
+ * distinguish "crashed in build A" from "crashed in build B" even
31
+ * when both builds share the same archive_upload_id (the developer
32
+ * republished without bumping the archive). Bounded to 64 chars.
33
+ */
34
+ buildHash?: string;
14
35
  }
15
36
 
16
37
  export type RendererPermission =