@replohq/sandbox-runtime 1.17.0 → 1.18.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.
@@ -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 };
@@ -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;
@@ -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;
@@ -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.0",
4
4
  "branch": "HEAD",
5
- "commit": "7d16c9a29182a37625a958569422b94a08b9a627",
6
- "builtAt": "2026-10-20T04:21:24.844Z"
5
+ "commit": "371ae98105e9f99b04918b3dffe40867380cd9ef",
6
+ "builtAt": "2026-10-21T22:33:13.604Z"
7
7
  };