@replohq/sandbox-runtime 1.7.12 → 1.8.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.
@@ -80,4 +80,5 @@ export declare function isNetworkErrorMessage(message: string): boolean;
80
80
  * fallback string or `String(error)`.
81
81
  */
82
82
  export declare function getErrorMessage(error: unknown, fallback?: string): string;
83
+ export declare function appendErrorId(detail: string, errorId: string | null | undefined): string;
83
84
  export {};
@@ -50,6 +50,13 @@ export declare const componentPreviewComponentSchema: z.ZodObject<{
50
50
  path: z.ZodString;
51
51
  name: z.ZodString;
52
52
  }, z.core.$strip>;
53
+ export declare const componentPreviewUsageSchema: z.ZodObject<{
54
+ kind: z.ZodEnum<{
55
+ page: "page";
56
+ layout: "layout";
57
+ }>;
58
+ route: z.ZodString;
59
+ }, z.core.$strip>;
53
60
  export declare const componentPreviewIndexSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
54
61
  status: z.ZodLiteral<"unavailable">;
55
62
  }, z.core.$strip>, z.ZodObject<{
@@ -58,6 +65,13 @@ export declare const componentPreviewIndexSchema: z.ZodDiscriminatedUnion<[z.Zod
58
65
  path: z.ZodString;
59
66
  name: z.ZodString;
60
67
  }, z.core.$strip>>;
68
+ usagesByComponentPath: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
69
+ kind: z.ZodEnum<{
70
+ page: "page";
71
+ layout: "layout";
72
+ }>;
73
+ route: z.ZodString;
74
+ }, z.core.$strip>>>;
61
75
  }, z.core.$strip>], "status">;
62
76
  export declare const componentPreviewSourceFileSchema: z.ZodObject<{
63
77
  path: z.ZodString;
@@ -79,4 +93,6 @@ export declare const componentPreviewPreparationSchema: z.ZodDiscriminatedUnion<
79
93
  pathname: z.ZodString;
80
94
  }, z.core.$strip>, z.ZodObject<{
81
95
  status: z.ZodLiteral<"siteUpdateRequired">;
96
+ }, z.core.$strip>, z.ZodObject<{
97
+ status: z.ZodLiteral<"invalidComponent">;
82
98
  }, z.core.$strip>], "status">;
@@ -86,11 +86,19 @@ var componentPreviewComponentSchema = z.object({
86
86
  path: componentPreviewPathSchema,
87
87
  name: z.string().min(1).max(120)
88
88
  }).describe("ComponentPreviewComponent");
89
+ var componentPreviewUsageSchema = z.object({
90
+ kind: z.enum(["page", "layout"]),
91
+ route: z.string().min(1)
92
+ }).describe("ComponentPreviewUsage");
89
93
  var componentPreviewIndexSchema = z.discriminatedUnion("status", [
90
94
  z.object({ status: z.literal("unavailable") }),
91
95
  z.object({
92
96
  status: z.literal("ready"),
93
- components: z.array(componentPreviewComponentSchema)
97
+ components: z.array(componentPreviewComponentSchema),
98
+ usagesByComponentPath: z.record(
99
+ componentPreviewPathSchema,
100
+ z.array(componentPreviewUsageSchema)
101
+ )
94
102
  })
95
103
  ]).describe("ComponentPreviewIndex");
96
104
  var componentPreviewSourceFileSchema = z.object({
@@ -107,7 +115,8 @@ var componentPreviewPreparationSchema = z.discriminatedUnion("status", [
107
115
  status: z.literal("ready"),
108
116
  pathname: z.string().regex(/^\/[A-Za-z0-9/_-]+$/u)
109
117
  }),
110
- z.object({ status: z.literal("siteUpdateRequired") })
118
+ z.object({ status: z.literal("siteUpdateRequired") }),
119
+ z.object({ status: z.literal("invalidComponent") })
111
120
  ]).describe("ComponentPreviewPreparation");
112
121
 
113
- export { COMPONENT_PREVIEW_IFRAME_RPC_CHANNEL_ID, COMPONENT_PREVIEW_IFRAME_RPC_CHANNEL_VERSION, COMPONENT_PREVIEW_PARENT_ORIGIN_PARAM, MAX_COMPONENT_PREVIEW_PROPS_BYTES, componentPreviewComponentSchema, componentPreviewIndexSchema, componentPreviewPathSchema, componentPreviewPreparationSchema, componentPreviewProductReferenceSchema, componentPreviewPropNameSchema, componentPreviewPropsSchema, componentPreviewSelectionSchema, componentPreviewSourceFileSchema, componentPreviewSourceSchema, componentPreviewToWebsiteBuilderMethodConfig, websiteBuilderToComponentPreviewMethodConfig };
122
+ export { COMPONENT_PREVIEW_IFRAME_RPC_CHANNEL_ID, COMPONENT_PREVIEW_IFRAME_RPC_CHANNEL_VERSION, COMPONENT_PREVIEW_PARENT_ORIGIN_PARAM, MAX_COMPONENT_PREVIEW_PROPS_BYTES, componentPreviewComponentSchema, componentPreviewIndexSchema, componentPreviewPathSchema, componentPreviewPreparationSchema, componentPreviewProductReferenceSchema, componentPreviewPropNameSchema, componentPreviewPropsSchema, componentPreviewSelectionSchema, componentPreviewSourceFileSchema, componentPreviewSourceSchema, componentPreviewToWebsiteBuilderMethodConfig, componentPreviewUsageSchema, websiteBuilderToComponentPreviewMethodConfig };
@@ -59,6 +59,7 @@ export type ReploAuthenticationErrorConfig = {
59
59
  type: AuthErrorType;
60
60
  userFacingDetails?: ErrorUserFacingDetailsWithMessage;
61
61
  additionalData?: ReploErrorConfig["additionalData"];
62
+ cause?: ReploErrorConfig["cause"];
62
63
  };
63
64
  export declare class ReploAuthenticationError extends ReploError {
64
65
  type: AuthErrorType;
@@ -436,6 +437,12 @@ export declare class IframeRpcChannelTimeoutError extends IframeRpcChannelError
436
437
  timeoutMs: number;
437
438
  });
438
439
  }
440
+ export declare class IframeRpcChannelTargetUnavailableError extends IframeRpcChannelError {
441
+ constructor({ callType, method, }: {
442
+ callType: "notify" | "request" | "response";
443
+ method?: string;
444
+ });
445
+ }
439
446
  export declare class IframeRpcChannelRemoteError extends IframeRpcChannelError {
440
447
  constructor({ method, message }: {
441
448
  method: string;
@@ -12,6 +12,13 @@ export type ComponentPreviewIndex = {
12
12
  } | {
13
13
  status: "ready";
14
14
  components: ComponentPreviewComponent[];
15
+ usagesByComponentPath: {
16
+ [x: string]: ComponentPreviewUsage[];
17
+ };
18
+ };
19
+ export type ComponentPreviewUsage = {
20
+ kind: "page" | "layout";
21
+ route: string;
15
22
  };
16
23
  export type ComponentPreviewSourceFile = {
17
24
  path: string;
@@ -27,4 +34,6 @@ export type ComponentPreviewPreparation = {
27
34
  pathname: string;
28
35
  } | {
29
36
  status: "siteUpdateRequired";
37
+ } | {
38
+ status: "invalidComponent";
30
39
  };
@@ -53,6 +53,27 @@ export type SelectModeDefinedStyle = {
53
53
  raw: string;
54
54
  resolved: string;
55
55
  };
56
+ export type SelectModeImageScope = {
57
+ kind: "all";
58
+ } | {
59
+ kind: "media";
60
+ media: string;
61
+ };
62
+ export type SelectModeImageSource = {
63
+ srcSet: string;
64
+ sizes: string;
65
+ media: string;
66
+ type: string;
67
+ previewUrl: string | null;
68
+ };
69
+ export type SelectModeImage = {
70
+ src: string;
71
+ currentSrc: string;
72
+ srcSet: string;
73
+ sizes: string;
74
+ previewUrl: string | null;
75
+ sources: SelectModeImageSource[];
76
+ };
56
77
  export type SelectedElement = {
57
78
  kind: "react-element";
58
79
  selector: string;
@@ -62,6 +83,7 @@ export type SelectedElement = {
62
83
  rect: SelectModeBoundingRect;
63
84
  textMetrics: SelectModeTextMetrics | null;
64
85
  outerHTML: string;
86
+ image?: SelectModeImage;
65
87
  definedStyles: SelectModeDefinedStyle[];
66
88
  inheritedStyles: {
67
89
  [x: string]: string;
@@ -85,6 +107,9 @@ export type SelectablePlanPayload = {
85
107
  export type SelectableDataPayload = SelectablePlanPayload;
86
108
  export type SelectableData = SelectedElement | SelectablePlanData;
87
109
  export type SelectModeOptimisticUpdatePayload = {
110
+ kind: "image";
111
+ image: SelectModeImage;
112
+ } | {
88
113
  kind: "css";
89
114
  fontSource?: "google" | "site";
90
115
  property: string;
@@ -116,6 +116,17 @@ var IframeRpcChannelTimeoutError = class extends IframeRpcChannelError {
116
116
  });
117
117
  }
118
118
  };
119
+ var IframeRpcChannelTargetUnavailableError = class extends IframeRpcChannelError {
120
+ constructor({
121
+ callType,
122
+ method
123
+ }) {
124
+ super({
125
+ message: method ? `RPC target window was unavailable for '${method}'` : "RPC target window was unavailable for a response",
126
+ additionalData: { callType, method }
127
+ });
128
+ }
129
+ };
119
130
  var IframeRpcChannelRemoteError = class extends IframeRpcChannelError {
120
131
  constructor({ method, message }) {
121
132
  super({
@@ -247,8 +258,8 @@ function createIframeRpcChannel(options) {
247
258
  const pendingRequests = /* @__PURE__ */ new Map();
248
259
  let subscriberCount = 0;
249
260
  let handlerMeta;
250
- const postMessage = (call2) => {
251
- getTargetWindow()?.postMessage(
261
+ const postMessage = (call2, targetWindow = getTargetWindow()) => {
262
+ targetWindow?.postMessage(
252
263
  {
253
264
  channelIdentifier,
254
265
  version,
@@ -368,9 +379,6 @@ function createIframeRpcChannel(options) {
368
379
  pendingRequest.resolve(parsedOutput.data);
369
380
  };
370
381
  const handleMessage = (event) => {
371
- if (!isExpectedMessage(event)) {
372
- return;
373
- }
374
382
  const parsedMetadata = z.object({
375
383
  channelIdentifier: z.literal(channelIdentifier),
376
384
  version: z.literal(version)
@@ -378,6 +386,15 @@ function createIframeRpcChannel(options) {
378
386
  if (!parsedMetadata.success) {
379
387
  return;
380
388
  }
389
+ if (!isExpectedMessage(event)) {
390
+ defaultLogger.error("[iframeRpcChannel] Dropping unexpected message", {
391
+ channelIdentifier,
392
+ version,
393
+ origin: event.origin,
394
+ hasSource: Boolean(event.source)
395
+ });
396
+ return;
397
+ }
381
398
  const parsedCall = iframeRpcCallSchema.safeParse(event.data);
382
399
  if (!parsedCall.success) {
383
400
  return;
@@ -464,6 +481,15 @@ function createIframeRpcChannel(options) {
464
481
  new IframeRpcChannelUnsubscribedError({ method })
465
482
  );
466
483
  }
484
+ const targetWindow = getTargetWindow();
485
+ if (!targetWindow) {
486
+ return Promise.reject(
487
+ new IframeRpcChannelTargetUnavailableError({
488
+ callType: "request",
489
+ method
490
+ })
491
+ );
492
+ }
467
493
  const id = randomUUID();
468
494
  const timeoutMs = definition.timeoutMs ?? 3e4;
469
495
  return new Promise(
@@ -480,12 +506,21 @@ function createIframeRpcChannel(options) {
480
506
  reject,
481
507
  timeoutId
482
508
  });
483
- postMessage({
484
- type: "request",
485
- id,
486
- method,
487
- data: parsedInput.data
488
- });
509
+ try {
510
+ postMessage(
511
+ {
512
+ type: "request",
513
+ id,
514
+ method,
515
+ data: parsedInput.data
516
+ },
517
+ targetWindow
518
+ );
519
+ } catch (error) {
520
+ clearTimeout(timeoutId);
521
+ pendingRequests.delete(id);
522
+ reject(error);
523
+ }
489
524
  }
490
525
  );
491
526
  };
@@ -98,6 +98,33 @@ export declare function transformPoint({ point, offset, scale, }: {
98
98
  scale?: number;
99
99
  }): SelectModeClickPosition;
100
100
  export declare function getIframeOffset(iframe: HTMLIFrameElement | null): RectOffset;
101
+ export declare const selectModeImageScopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
102
+ kind: z.ZodLiteral<"all">;
103
+ }, z.core.$strip>, z.ZodObject<{
104
+ kind: z.ZodLiteral<"media">;
105
+ media: z.ZodString;
106
+ }, z.core.$strip>], "kind">;
107
+ export declare const selectModeImageSourceSchema: z.ZodObject<{
108
+ srcSet: z.ZodString;
109
+ sizes: z.ZodString;
110
+ media: z.ZodString;
111
+ type: z.ZodString;
112
+ previewUrl: z.ZodNullable<z.ZodString>;
113
+ }, z.core.$strip>;
114
+ export declare const selectModeImageSchema: z.ZodObject<{
115
+ src: z.ZodString;
116
+ currentSrc: z.ZodString;
117
+ srcSet: z.ZodString;
118
+ sizes: z.ZodString;
119
+ previewUrl: z.ZodNullable<z.ZodString>;
120
+ sources: z.ZodArray<z.ZodObject<{
121
+ srcSet: z.ZodString;
122
+ sizes: z.ZodString;
123
+ media: z.ZodString;
124
+ type: z.ZodString;
125
+ previewUrl: z.ZodNullable<z.ZodString>;
126
+ }, z.core.$strip>>;
127
+ }, z.core.$strip>;
101
128
  export declare const selectedElementSchema: z.ZodObject<{
102
129
  kind: z.ZodLiteral<"react-element">;
103
130
  selector: z.ZodString;
@@ -120,6 +147,20 @@ export declare const selectedElementSchema: z.ZodObject<{
120
147
  lineHeight: z.ZodNumber;
121
148
  }, z.core.$strip>>;
122
149
  outerHTML: z.ZodString;
150
+ image: z.ZodOptional<z.ZodObject<{
151
+ src: z.ZodString;
152
+ currentSrc: z.ZodString;
153
+ srcSet: z.ZodString;
154
+ sizes: z.ZodString;
155
+ previewUrl: z.ZodNullable<z.ZodString>;
156
+ sources: z.ZodArray<z.ZodObject<{
157
+ srcSet: z.ZodString;
158
+ sizes: z.ZodString;
159
+ media: z.ZodString;
160
+ type: z.ZodString;
161
+ previewUrl: z.ZodNullable<z.ZodString>;
162
+ }, z.core.$strip>>;
163
+ }, z.core.$strip>>;
123
164
  definedStyles: z.ZodDefault<z.ZodArray<z.ZodObject<{
124
165
  property: z.ZodString;
125
166
  variant: z.ZodNullable<z.ZodObject<{
@@ -204,6 +245,20 @@ export declare const selectableDataSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
204
245
  lineHeight: z.ZodNumber;
205
246
  }, z.core.$strip>>;
206
247
  outerHTML: z.ZodString;
248
+ image: z.ZodOptional<z.ZodObject<{
249
+ src: z.ZodString;
250
+ currentSrc: z.ZodString;
251
+ srcSet: z.ZodString;
252
+ sizes: z.ZodString;
253
+ previewUrl: z.ZodNullable<z.ZodString>;
254
+ sources: z.ZodArray<z.ZodObject<{
255
+ srcSet: z.ZodString;
256
+ sizes: z.ZodString;
257
+ media: z.ZodString;
258
+ type: z.ZodString;
259
+ previewUrl: z.ZodNullable<z.ZodString>;
260
+ }, z.core.$strip>>;
261
+ }, z.core.$strip>>;
207
262
  definedStyles: z.ZodDefault<z.ZodArray<z.ZodObject<{
208
263
  property: z.ZodString;
209
264
  variant: z.ZodNullable<z.ZodObject<{
@@ -274,6 +329,22 @@ export declare function readSelectablePayload(rawPayload: string | null): {
274
329
  planId: string;
275
330
  } | null;
276
331
  export declare const selectModeOptimisticUpdatePayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
332
+ kind: z.ZodLiteral<"image">;
333
+ image: z.ZodObject<{
334
+ src: z.ZodString;
335
+ currentSrc: z.ZodString;
336
+ srcSet: z.ZodString;
337
+ sizes: z.ZodString;
338
+ previewUrl: z.ZodNullable<z.ZodString>;
339
+ sources: z.ZodArray<z.ZodObject<{
340
+ srcSet: z.ZodString;
341
+ sizes: z.ZodString;
342
+ media: z.ZodString;
343
+ type: z.ZodString;
344
+ previewUrl: z.ZodNullable<z.ZodString>;
345
+ }, z.core.$strip>>;
346
+ }, z.core.$strip>;
347
+ }, z.core.$strip>, z.ZodObject<{
277
348
  kind: z.ZodLiteral<"css">;
278
349
  fontSource: z.ZodOptional<z.ZodEnum<{
279
350
  google: "google";
@@ -366,6 +437,20 @@ export declare const selectModeSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodOb
366
437
  lineHeight: z.ZodNumber;
367
438
  }, z.core.$strip>>;
368
439
  outerHTML: z.ZodString;
440
+ image: z.ZodOptional<z.ZodObject<{
441
+ src: z.ZodString;
442
+ currentSrc: z.ZodString;
443
+ srcSet: z.ZodString;
444
+ sizes: z.ZodString;
445
+ previewUrl: z.ZodNullable<z.ZodString>;
446
+ sources: z.ZodArray<z.ZodObject<{
447
+ srcSet: z.ZodString;
448
+ sizes: z.ZodString;
449
+ media: z.ZodString;
450
+ type: z.ZodString;
451
+ previewUrl: z.ZodNullable<z.ZodString>;
452
+ }, z.core.$strip>>;
453
+ }, z.core.$strip>>;
369
454
  definedStyles: z.ZodDefault<z.ZodArray<z.ZodObject<{
370
455
  property: z.ZodString;
371
456
  variant: z.ZodNullable<z.ZodObject<{
@@ -451,6 +536,20 @@ export declare const selectModeSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodOb
451
536
  lineHeight: z.ZodNumber;
452
537
  }, z.core.$strip>>;
453
538
  outerHTML: z.ZodString;
539
+ image: z.ZodOptional<z.ZodObject<{
540
+ src: z.ZodString;
541
+ currentSrc: z.ZodString;
542
+ srcSet: z.ZodString;
543
+ sizes: z.ZodString;
544
+ previewUrl: z.ZodNullable<z.ZodString>;
545
+ sources: z.ZodArray<z.ZodObject<{
546
+ srcSet: z.ZodString;
547
+ sizes: z.ZodString;
548
+ media: z.ZodString;
549
+ type: z.ZodString;
550
+ previewUrl: z.ZodNullable<z.ZodString>;
551
+ }, z.core.$strip>>;
552
+ }, z.core.$strip>>;
454
553
  definedStyles: z.ZodDefault<z.ZodArray<z.ZodObject<{
455
554
  property: z.ZodString;
456
555
  variant: z.ZodNullable<z.ZodObject<{
@@ -1,4 +1,4 @@
1
- export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeDefinedStyleSchema, selectModeFiberChainEntrySchema, selectModeFormatCommandSchema, selectModeInlineTextStatusSchema, selectModeOptimisticUpdatePayloadSchema, selectModeSelectionRectSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeStyleAtRuleSchema, selectModeStyleVariantSchema, selectModeTextMetricsSchema, selectModeTiptapActiveMarksSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData, transformSelectedElement } from '../../chunk-4T7WSMC3.mjs';
1
+ export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeDefinedStyleSchema, selectModeFiberChainEntrySchema, selectModeFormatCommandSchema, selectModeImageSchema, selectModeImageScopeSchema, selectModeImageSourceSchema, selectModeInlineTextStatusSchema, selectModeOptimisticUpdatePayloadSchema, selectModeSelectionRectSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeStyleAtRuleSchema, selectModeStyleVariantSchema, selectModeTextMetricsSchema, selectModeTiptapActiveMarksSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData, transformSelectedElement } from '../../chunk-XWNBKE63.mjs';
2
2
  import '../../chunk-JUKCUPQ6.mjs';
3
3
  import '../../chunk-FLYEIRFK.mjs';
4
4
  import '../../chunk-TESFJQID.mjs';