@replohq/sandbox-runtime 1.17.0 → 1.18.1

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/ClientErrorBoundary.js +26 -0
  2. package/DocumentReadyBeacon.js +5 -1
  3. package/_vendor/schemas/iframeRpcChannel.mjs +3 -541
  4. package/_vendor/schemas/previewHealthIframeRpc.d.ts +159 -0
  5. package/_vendor/schemas/previewHealthIframeRpc.mjs +123 -0
  6. package/_vendor/schemas/selectMode.d.ts +1 -1
  7. package/_vendor/schemas/selectModeIframeRpc.d.ts +5 -5
  8. package/buildMetadata.js +3 -3
  9. package/capturePage.js +5 -1
  10. package/chunk-KRA4LUIR.mjs +541 -0
  11. package/nextErrorFeed.d.ts +30 -0
  12. package/nextErrorFeed.js +64 -0
  13. package/package.json +5 -12
  14. package/previewHealth.d.ts +25 -0
  15. package/previewHealth.js +431 -0
  16. package/sandbox-runtime.js +0 -2
  17. package/select-mode/hooks/useSelectionHover.js +5 -0
  18. package/select-mode/iframeRpcChannel.d.ts +1 -1
  19. package/select-mode/section-canvas/SectionCanvas.js +80 -124
  20. package/select-mode/section-canvas/sectionCanvasStore.d.ts +0 -2
  21. package/select-mode/section-canvas/sectionCanvasStore.js +0 -15
  22. package/NextErrorReporter.d.ts +0 -1
  23. package/NextErrorReporter.js +0 -131
  24. package/_vendor/schemas/componentPreview.d.ts +0 -43
  25. package/_vendor/schemas/componentPreview.mjs +0 -79
  26. package/_vendor/schemas/generated/componentPreview.d.ts +0 -5
  27. package/_vendor/schemas/generated/componentPreview.mjs +0 -1
  28. package/_vendor/schemas/loaderKeys.d.ts +0 -69
  29. package/next/component-preview-client.d.ts +0 -8
  30. package/next/component-preview-client.js +0 -227
  31. package/next/component-preview-href.d.ts +0 -5
  32. package/next/component-preview-href.js +0 -13
  33. package/next/component-preview-props.d.ts +0 -8
  34. package/next/component-preview-props.js +0 -35
  35. package/next/component-preview.d.ts +0 -11
  36. package/next/component-preview.js +0 -83
  37. package/select-mode/section-canvas/sectionGhost.d.ts +0 -5
  38. package/select-mode/section-canvas/sectionGhost.js +0 -23
@@ -0,0 +1,159 @@
1
+ import * as z from "zod";
2
+ export declare const PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_ID: "replo:preview-health-iframe-rpc";
3
+ export declare const PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_VERSION: 1;
4
+ export declare const previewErrorDetailSchema: z.ZodObject<{
5
+ message: z.ZodString;
6
+ name: z.ZodNullable<z.ZodString>;
7
+ stack: z.ZodNullable<z.ZodString>;
8
+ componentStack: z.ZodNullable<z.ZodString>;
9
+ digest: z.ZodNullable<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ export declare const previewHealthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12
+ status: z.ZodLiteral<"ok">;
13
+ }, z.core.$strip>, z.ZodObject<{
14
+ status: z.ZodLiteral<"error">;
15
+ source: z.ZodEnum<{
16
+ boundary: "boundary";
17
+ root: "root";
18
+ build: "build";
19
+ }>;
20
+ error: z.ZodObject<{
21
+ message: z.ZodString;
22
+ name: z.ZodNullable<z.ZodString>;
23
+ stack: z.ZodNullable<z.ZodString>;
24
+ componentStack: z.ZodNullable<z.ZodString>;
25
+ digest: z.ZodNullable<z.ZodString>;
26
+ }, z.core.$strip>;
27
+ }, z.core.$strip>], "status">;
28
+ declare const previewStatusReportSchema: z.ZodObject<{
29
+ route: z.ZodString;
30
+ documentId: z.ZodString;
31
+ seq: z.ZodNumber;
32
+ health: z.ZodDiscriminatedUnion<[z.ZodObject<{
33
+ status: z.ZodLiteral<"ok">;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ status: z.ZodLiteral<"error">;
36
+ source: z.ZodEnum<{
37
+ boundary: "boundary";
38
+ root: "root";
39
+ build: "build";
40
+ }>;
41
+ error: z.ZodObject<{
42
+ message: z.ZodString;
43
+ name: z.ZodNullable<z.ZodString>;
44
+ stack: z.ZodNullable<z.ZodString>;
45
+ componentStack: z.ZodNullable<z.ZodString>;
46
+ digest: z.ZodNullable<z.ZodString>;
47
+ }, z.core.$strip>;
48
+ }, z.core.$strip>], "status">;
49
+ }, z.core.$strip>;
50
+ declare const previewDiagnosticReportSchema: z.ZodObject<{
51
+ route: z.ZodString;
52
+ documentId: z.ZodString;
53
+ diagnostic: z.ZodObject<{
54
+ origin: z.ZodEnum<{
55
+ boundary: "boundary";
56
+ root: "root";
57
+ build: "build";
58
+ runtime: "runtime";
59
+ recoverable: "recoverable";
60
+ console: "console";
61
+ rejection: "rejection";
62
+ }>;
63
+ impact: z.ZodEnum<{
64
+ unknown: "unknown";
65
+ page: "page";
66
+ }>;
67
+ error: z.ZodObject<{
68
+ message: z.ZodString;
69
+ name: z.ZodNullable<z.ZodString>;
70
+ stack: z.ZodNullable<z.ZodString>;
71
+ componentStack: z.ZodNullable<z.ZodString>;
72
+ digest: z.ZodNullable<z.ZodString>;
73
+ }, z.core.$strip>;
74
+ at: z.ZodNumber;
75
+ }, z.core.$strip>;
76
+ }, z.core.$strip>;
77
+ export type PreviewErrorDetail = z.infer<typeof previewErrorDetailSchema>;
78
+ export type PreviewHealth = z.infer<typeof previewHealthSchema>;
79
+ export type PreviewStatusReport = z.infer<typeof previewStatusReportSchema>;
80
+ export type PreviewDiagnosticReport = z.infer<typeof previewDiagnosticReportSchema>;
81
+ export declare const previewHealthToEditorMethodConfig: {
82
+ documentArrived: {
83
+ inputSchema: z.ZodObject<{
84
+ route: z.ZodString;
85
+ }, z.core.$strip>;
86
+ outputSchema: z.ZodVoid;
87
+ };
88
+ statusChanged: {
89
+ inputSchema: z.ZodObject<{
90
+ route: z.ZodString;
91
+ documentId: z.ZodString;
92
+ seq: z.ZodNumber;
93
+ health: z.ZodDiscriminatedUnion<[z.ZodObject<{
94
+ status: z.ZodLiteral<"ok">;
95
+ }, z.core.$strip>, z.ZodObject<{
96
+ status: z.ZodLiteral<"error">;
97
+ source: z.ZodEnum<{
98
+ boundary: "boundary";
99
+ root: "root";
100
+ build: "build";
101
+ }>;
102
+ error: z.ZodObject<{
103
+ message: z.ZodString;
104
+ name: z.ZodNullable<z.ZodString>;
105
+ stack: z.ZodNullable<z.ZodString>;
106
+ componentStack: z.ZodNullable<z.ZodString>;
107
+ digest: z.ZodNullable<z.ZodString>;
108
+ }, z.core.$strip>;
109
+ }, z.core.$strip>], "status">;
110
+ }, z.core.$strip>;
111
+ outputSchema: z.ZodVoid;
112
+ };
113
+ diagnosticRecorded: {
114
+ inputSchema: z.ZodObject<{
115
+ route: z.ZodString;
116
+ documentId: z.ZodString;
117
+ diagnostic: z.ZodObject<{
118
+ origin: z.ZodEnum<{
119
+ boundary: "boundary";
120
+ root: "root";
121
+ build: "build";
122
+ runtime: "runtime";
123
+ recoverable: "recoverable";
124
+ console: "console";
125
+ rejection: "rejection";
126
+ }>;
127
+ impact: z.ZodEnum<{
128
+ unknown: "unknown";
129
+ page: "page";
130
+ }>;
131
+ error: z.ZodObject<{
132
+ message: z.ZodString;
133
+ name: z.ZodNullable<z.ZodString>;
134
+ stack: z.ZodNullable<z.ZodString>;
135
+ componentStack: z.ZodNullable<z.ZodString>;
136
+ digest: z.ZodNullable<z.ZodString>;
137
+ }, z.core.$strip>;
138
+ at: z.ZodNumber;
139
+ }, z.core.$strip>;
140
+ }, z.core.$strip>;
141
+ outputSchema: z.ZodVoid;
142
+ };
143
+ };
144
+ export declare const editorToPreviewHealthMethodConfig: {};
145
+ /**
146
+ * Editor side of a preview iframe's health channel. `report` is the full
147
+ * status from current runtimes and null from older runtimes, which only say
148
+ * ok or error.
149
+ */
150
+ export declare function subscribeToPreviewHealth({ getFrameWindow, onDocumentArrived, onStatus, onDiagnostic, }: {
151
+ getFrameWindow: () => Window | null;
152
+ onDocumentArrived?: () => void;
153
+ onStatus: (update: {
154
+ status: PreviewHealth["status"];
155
+ report: PreviewStatusReport | null;
156
+ }) => void;
157
+ onDiagnostic?: (report: PreviewDiagnosticReport) => void;
158
+ }): () => void;
159
+ export {};
@@ -0,0 +1,123 @@
1
+ import { createIframeRpcChannel } from '../../chunk-KRA4LUIR.mjs';
2
+ import '../../chunk-LIPH4O4F.mjs';
3
+ import '../../chunk-PH3S6LJI.mjs';
4
+ import '../../chunk-FLYEIRFK.mjs';
5
+ import '../../chunk-TESFJQID.mjs';
6
+ import '../../chunk-G3S6ZNPF.mjs';
7
+ import * as z from 'zod';
8
+
9
+ var PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_ID = "replo:preview-health-iframe-rpc";
10
+ var PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_VERSION = 1;
11
+ var previewErrorDetailSchema = z.object({
12
+ message: z.string(),
13
+ name: z.string().nullable(),
14
+ stack: z.string().nullable(),
15
+ componentStack: z.string().nullable(),
16
+ digest: z.string().nullable()
17
+ });
18
+ var previewHealthSchema = z.discriminatedUnion("status", [
19
+ z.object({ status: z.literal("ok") }),
20
+ z.object({
21
+ status: z.literal("error"),
22
+ source: z.enum(["boundary", "root", "build"]),
23
+ error: previewErrorDetailSchema
24
+ })
25
+ ]);
26
+ var previewStatusReportSchema = z.object({
27
+ route: z.string(),
28
+ documentId: z.string(),
29
+ seq: z.number().int().positive(),
30
+ health: previewHealthSchema
31
+ });
32
+ var previewDiagnosticReportSchema = z.object({
33
+ route: z.string(),
34
+ documentId: z.string(),
35
+ diagnostic: z.object({
36
+ origin: z.enum([
37
+ "boundary",
38
+ "root",
39
+ "runtime",
40
+ "recoverable",
41
+ "console",
42
+ "rejection",
43
+ "build"
44
+ ]),
45
+ impact: z.enum(["page", "unknown"]),
46
+ error: previewErrorDetailSchema,
47
+ at: z.number()
48
+ })
49
+ });
50
+ var previewHealthToEditorMethodConfig = {
51
+ documentArrived: {
52
+ inputSchema: z.object({ route: z.string() }),
53
+ outputSchema: z.void()
54
+ },
55
+ statusChanged: {
56
+ inputSchema: previewStatusReportSchema,
57
+ outputSchema: z.void()
58
+ },
59
+ diagnosticRecorded: {
60
+ inputSchema: previewDiagnosticReportSchema,
61
+ outputSchema: z.void()
62
+ }
63
+ };
64
+ var editorToPreviewHealthMethodConfig = {};
65
+ var legacyPreviewStatusMessageSchema = z.object({
66
+ type: z.literal("replo:preview:status"),
67
+ status: z.enum(["ok", "error"]),
68
+ phase: z.literal("document").optional()
69
+ });
70
+ function subscribeToPreviewHealth({
71
+ getFrameWindow,
72
+ onDocumentArrived,
73
+ onStatus,
74
+ onDiagnostic
75
+ }) {
76
+ const isFromFrame = (event) => {
77
+ const frameWindow = getFrameWindow();
78
+ return frameWindow !== null && event.source === frameWindow;
79
+ };
80
+ const channel = createIframeRpcChannel({
81
+ subscriberWindow: window,
82
+ channelIdentifier: PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_ID,
83
+ version: PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_VERSION,
84
+ getTargetWindow: getFrameWindow,
85
+ targetOrigin: "*",
86
+ isExpectedMessage: isFromFrame,
87
+ outgoingMethods: editorToPreviewHealthMethodConfig,
88
+ incomingMethods: previewHealthToEditorMethodConfig,
89
+ handlers: {
90
+ documentArrived: () => {
91
+ onDocumentArrived?.();
92
+ },
93
+ statusChanged: (report) => {
94
+ onStatus({ status: report.health.status, report });
95
+ },
96
+ diagnosticRecorded: (report) => {
97
+ onDiagnostic?.(report);
98
+ }
99
+ }
100
+ });
101
+ const handleLegacyMessage = (event) => {
102
+ if (!isFromFrame(event)) {
103
+ return;
104
+ }
105
+ const message = legacyPreviewStatusMessageSchema.safeParse(event.data);
106
+ if (!message.success) {
107
+ return;
108
+ }
109
+ if (message.data.phase === "document") {
110
+ onDocumentArrived?.();
111
+ return;
112
+ }
113
+ onStatus({ status: message.data.status, report: null });
114
+ };
115
+ const unsubscribe = channel.subscribe();
116
+ window.addEventListener("message", handleLegacyMessage);
117
+ return () => {
118
+ unsubscribe();
119
+ window.removeEventListener("message", handleLegacyMessage);
120
+ };
121
+ }
122
+
123
+ export { PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_ID, PREVIEW_HEALTH_IFRAME_RPC_CHANNEL_VERSION, editorToPreviewHealthMethodConfig, previewErrorDetailSchema, previewHealthSchema, previewHealthToEditorMethodConfig, subscribeToPreviewHealth };
@@ -425,8 +425,8 @@ export declare const selectModeFormatCommandSchema: z.ZodEnum<{
425
425
  export declare const selectModeSelectionTypeSchema: z.ZodEnum<{
426
426
  drag: "drag";
427
427
  area: "area";
428
- none: "none";
429
428
  element: "element";
429
+ none: "none";
430
430
  }>;
431
431
  /**
432
432
  * Parent-side selection state mirrored from messages the iframe posts
@@ -4,9 +4,9 @@ export declare const SELECT_MODE_IFRAME_RPC_CHANNEL_ID: "replo:select-mode-ifram
4
4
  export declare const SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION: 1;
5
5
  export declare const inlineEditFeedbackSchema: z.ZodObject<{
6
6
  status: z.ZodEnum<{
7
+ failed: "failed";
7
8
  pending: "pending";
8
9
  unavailable: "unavailable";
9
- failed: "failed";
10
10
  }>;
11
11
  rect: z.ZodObject<{
12
12
  x: z.ZodNumber;
@@ -485,8 +485,8 @@ export declare const websiteBuilderToPreviewIframeMethodConfig: {
485
485
  selectionType: z.ZodEnum<{
486
486
  drag: "drag";
487
487
  area: "area";
488
- none: "none";
489
488
  element: "element";
489
+ none: "none";
490
490
  }>;
491
491
  selectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
492
492
  }, z.core.$strip>;
@@ -1027,9 +1027,9 @@ export declare const previewIframeToWebsiteBuilderMethodConfig: {
1027
1027
  inputSchema: z.ZodObject<{
1028
1028
  feedback: z.ZodNullable<z.ZodObject<{
1029
1029
  status: z.ZodEnum<{
1030
+ failed: "failed";
1030
1031
  pending: "pending";
1031
1032
  unavailable: "unavailable";
1032
- failed: "failed";
1033
1033
  }>;
1034
1034
  rect: z.ZodObject<{
1035
1035
  x: z.ZodNumber;
@@ -1087,8 +1087,8 @@ export declare const selectModeParentMessageSchema: z.ZodDiscriminatedUnion<[z.Z
1087
1087
  selectionType: z.ZodEnum<{
1088
1088
  drag: "drag";
1089
1089
  area: "area";
1090
- none: "none";
1091
1090
  element: "element";
1091
+ none: "none";
1092
1092
  }>;
1093
1093
  selectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
1094
1094
  }, z.core.$strip>;
@@ -1476,9 +1476,9 @@ export declare const selectModeIframeMessageSchema: z.ZodDiscriminatedUnion<[z.Z
1476
1476
  data: z.ZodObject<{
1477
1477
  feedback: z.ZodNullable<z.ZodObject<{
1478
1478
  status: z.ZodEnum<{
1479
+ failed: "failed";
1479
1480
  pending: "pending";
1480
1481
  unavailable: "unavailable";
1481
- failed: "failed";
1482
1482
  }>;
1483
1483
  rect: z.ZodObject<{
1484
1484
  x: z.ZodNumber;
package/buildMetadata.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const BUILD_METADATA = {
2
2
  "packageName": "@replohq/sandbox-runtime",
3
- "version": "1.17.0",
3
+ "version": "1.18.1",
4
4
  "branch": "HEAD",
5
- "commit": "7d16c9a29182a37625a958569422b94a08b9a627",
6
- "builtAt": "2026-10-20T04:21:24.844Z"
5
+ "commit": "770da909743d238b91a6529e4dc38a079fdfd43a",
6
+ "builtAt": "2026-10-22T00:12:53.373Z"
7
7
  };
package/capturePage.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { snapdom } from "@zumer/snapdom";
2
2
  import { PageCaptureError } from "./_vendor/replo-utils/lib/pageCapture.mjs";
3
3
  import * as z from "zod";
4
+ import { SECTION_CANVAS_ATTRIBUTE } from "./select-mode/section-canvas/sectionCanvasControls";
5
+ import { SELECTION_FRAMES_CONTAINER_ID } from "./select-mode/selectionFrame";
4
6
  const JPEG_QUALITY = 0.8;
5
7
  const VIDEO_FRAME_QUALITY = 0.85;
6
8
  const VIDEO_LOAD_TIMEOUT_MS = 4e3;
@@ -332,7 +334,9 @@ async function capturePage({
332
334
  const raw = await snapdom.toRaw(document.body, {
333
335
  scale: 1,
334
336
  embedFonts: true,
335
- exclude: (element) => offscreenImages.has(element),
337
+ exclude: (element) => {
338
+ return offscreenImages.has(element) || element.id === SELECTION_FRAMES_CONTAINER_ID || element.hasAttribute(SECTION_CANVAS_ATTRIBUTE);
339
+ },
336
340
  plugins: [createStandInsPlugin({ objectFitByFrame, iframeThumbnails })]
337
341
  });
338
342
  const image = new Image();