@replohq/sandbox-runtime 1.19.5 → 1.21.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.
Files changed (52) hide show
  1. package/PagePreviewHeightResponder.d.ts +1 -0
  2. package/PagePreviewHeightResponder.js +159 -0
  3. package/_vendor/schemas/comments.d.ts +898 -0
  4. package/_vendor/schemas/commentsOverlayRpc.d.ts +348 -0
  5. package/_vendor/schemas/commentsOverlayRpc.mjs +92 -0
  6. package/_vendor/schemas/generated/comments.d.ts +237 -0
  7. package/_vendor/schemas/generated/commentsOverlayRpc.d.ts +18 -0
  8. package/_vendor/schemas/generated/selectMode.d.ts +3 -1
  9. package/_vendor/schemas/pagePreviewHeight.d.ts +14 -0
  10. package/_vendor/schemas/pagePreviewHeight.mjs +18 -0
  11. package/_vendor/schemas/selectMode.d.ts +113 -0
  12. package/_vendor/schemas/selectMode.mjs +1 -1
  13. package/_vendor/schemas/selectModeIframeRpc.d.ts +226 -0
  14. package/_vendor/schemas/selectModeIframeRpc.mjs +1 -1
  15. package/buildMetadata.js +3 -3
  16. package/chunk-NVOBD46N.mjs +541 -0
  17. package/comments-overlay/CommentsOverlayMount.d.ts +1 -0
  18. package/comments-overlay/CommentsOverlayMount.js +44 -0
  19. package/comments-overlay/LICENSE-THIRD-PARTY.md +45 -0
  20. package/comments-overlay/bridge.d.ts +11 -0
  21. package/comments-overlay/bridge.js +136 -0
  22. package/comments-overlay/capture.d.ts +55 -0
  23. package/comments-overlay/capture.js +250 -0
  24. package/comments-overlay/originGate.d.ts +1 -0
  25. package/comments-overlay/originGate.js +11 -0
  26. package/comments-overlay/overlay.d.ts +52 -0
  27. package/comments-overlay/overlay.js +781 -0
  28. package/comments-overlay/resolve.d.ts +27 -0
  29. package/comments-overlay/resolve.js +201 -0
  30. package/comments-overlay/sourceLookup.d.ts +11 -0
  31. package/comments-overlay/sourceLookup.js +63 -0
  32. package/comments-overlay/textQuote.d.ts +17 -0
  33. package/comments-overlay/textQuote.js +87 -0
  34. package/comments-overlay/vendor/bippy.d.ts +53 -0
  35. package/comments-overlay/vendor/bippy.js +402 -0
  36. package/comments-overlay/vendor/elementAnchors.d.ts +9 -0
  37. package/comments-overlay/vendor/elementAnchors.js +144 -0
  38. package/comments-overlay/vendor/fiberElement.d.ts +21 -0
  39. package/comments-overlay/vendor/fiberElement.js +251 -0
  40. package/comments-overlay/vendor/htmlPreview.d.ts +13 -0
  41. package/comments-overlay/vendor/htmlPreview.js +179 -0
  42. package/comments-overlay/vendor/selector.d.ts +38 -0
  43. package/comments-overlay/vendor/selector.js +372 -0
  44. package/package.json +5 -4
  45. package/pinPreviewViewportUnits.d.ts +4 -0
  46. package/pinPreviewViewportUnits.js +76 -0
  47. package/sandbox-runtime.js +4 -0
  48. package/select-mode/descriptor/elementDescriptor.d.ts +4 -3
  49. package/select-mode/descriptor/elementDescriptor.js +20 -30
  50. package/select-mode/iframeRpcChannel.d.ts +84 -0
  51. package/select-mode/symbolicate.js +25 -7
  52. package/chunk-QTGDSYSU.mjs +0 -249
@@ -134,6 +134,34 @@ export declare function getSelectModeIframeRpcChannel(): import("../_vendor/sche
134
134
  props: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
135
135
  }, import("zod/v4/core").$strip>>>;
136
136
  siblingSelectors: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
137
+ anchor: import("zod").ZodOptional<import("zod").ZodObject<{
138
+ type: import("zod").ZodLiteral<"element">;
139
+ semanticSelector: import("zod").ZodOptional<import("zod").ZodString>;
140
+ selector: import("zod").ZodString;
141
+ nthOfTypePath: import("zod").ZodString;
142
+ source: import("zod").ZodOptional<import("zod").ZodObject<{
143
+ filePath: import("zod").ZodString;
144
+ componentChain: import("zod").ZodArray<import("zod").ZodString>;
145
+ line: import("zod").ZodOptional<import("zod").ZodNumber>;
146
+ col: import("zod").ZodOptional<import("zod").ZodNumber>;
147
+ }, import("zod/v4/core").$strip>>;
148
+ listKey: import("zod").ZodOptional<import("zod").ZodString>;
149
+ tagName: import("zod").ZodString;
150
+ textPreview: import("zod").ZodString;
151
+ quote: import("zod").ZodOptional<import("zod").ZodObject<{
152
+ exact: import("zod").ZodString;
153
+ prefix: import("zod").ZodString;
154
+ suffix: import("zod").ZodString;
155
+ }, import("zod/v4/core").$strip>>;
156
+ offset: import("zod").ZodObject<{
157
+ x: import("zod").ZodNumber;
158
+ y: import("zod").ZodNumber;
159
+ }, import("zod/v4/core").$strip>;
160
+ context: import("zod").ZodOptional<import("zod").ZodObject<{
161
+ url: import("zod").ZodString;
162
+ locale: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
163
+ }, import("zod/v4/core").$strip>>;
164
+ }, import("zod/v4/core").$strip>>;
137
165
  }, import("zod/v4/core").$strip>;
138
166
  }, import("zod/v4/core").$strip>;
139
167
  outputSchema: import("zod").ZodObject<{
@@ -235,6 +263,34 @@ export declare function getSelectModeIframeRpcChannel(): import("../_vendor/sche
235
263
  props: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
236
264
  }, import("zod/v4/core").$strip>>>;
237
265
  siblingSelectors: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
266
+ anchor: import("zod").ZodOptional<import("zod").ZodObject<{
267
+ type: import("zod").ZodLiteral<"element">;
268
+ semanticSelector: import("zod").ZodOptional<import("zod").ZodString>;
269
+ selector: import("zod").ZodString;
270
+ nthOfTypePath: import("zod").ZodString;
271
+ source: import("zod").ZodOptional<import("zod").ZodObject<{
272
+ filePath: import("zod").ZodString;
273
+ componentChain: import("zod").ZodArray<import("zod").ZodString>;
274
+ line: import("zod").ZodOptional<import("zod").ZodNumber>;
275
+ col: import("zod").ZodOptional<import("zod").ZodNumber>;
276
+ }, import("zod/v4/core").$strip>>;
277
+ listKey: import("zod").ZodOptional<import("zod").ZodString>;
278
+ tagName: import("zod").ZodString;
279
+ textPreview: import("zod").ZodString;
280
+ quote: import("zod").ZodOptional<import("zod").ZodObject<{
281
+ exact: import("zod").ZodString;
282
+ prefix: import("zod").ZodString;
283
+ suffix: import("zod").ZodString;
284
+ }, import("zod/v4/core").$strip>>;
285
+ offset: import("zod").ZodObject<{
286
+ x: import("zod").ZodNumber;
287
+ y: import("zod").ZodNumber;
288
+ }, import("zod/v4/core").$strip>;
289
+ context: import("zod").ZodOptional<import("zod").ZodObject<{
290
+ url: import("zod").ZodString;
291
+ locale: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
292
+ }, import("zod/v4/core").$strip>>;
293
+ }, import("zod/v4/core").$strip>>;
238
294
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
239
295
  kind: import("zod").ZodLiteral<"plan">;
240
296
  planId: import("zod").ZodString;
@@ -424,6 +480,34 @@ export declare function getSelectModeIframeRpcChannel(): import("../_vendor/sche
424
480
  props: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
425
481
  }, import("zod/v4/core").$strip>>>;
426
482
  siblingSelectors: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
483
+ anchor: import("zod").ZodOptional<import("zod").ZodObject<{
484
+ type: import("zod").ZodLiteral<"element">;
485
+ semanticSelector: import("zod").ZodOptional<import("zod").ZodString>;
486
+ selector: import("zod").ZodString;
487
+ nthOfTypePath: import("zod").ZodString;
488
+ source: import("zod").ZodOptional<import("zod").ZodObject<{
489
+ filePath: import("zod").ZodString;
490
+ componentChain: import("zod").ZodArray<import("zod").ZodString>;
491
+ line: import("zod").ZodOptional<import("zod").ZodNumber>;
492
+ col: import("zod").ZodOptional<import("zod").ZodNumber>;
493
+ }, import("zod/v4/core").$strip>>;
494
+ listKey: import("zod").ZodOptional<import("zod").ZodString>;
495
+ tagName: import("zod").ZodString;
496
+ textPreview: import("zod").ZodString;
497
+ quote: import("zod").ZodOptional<import("zod").ZodObject<{
498
+ exact: import("zod").ZodString;
499
+ prefix: import("zod").ZodString;
500
+ suffix: import("zod").ZodString;
501
+ }, import("zod/v4/core").$strip>>;
502
+ offset: import("zod").ZodObject<{
503
+ x: import("zod").ZodNumber;
504
+ y: import("zod").ZodNumber;
505
+ }, import("zod/v4/core").$strip>;
506
+ context: import("zod").ZodOptional<import("zod").ZodObject<{
507
+ url: import("zod").ZodString;
508
+ locale: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
509
+ }, import("zod/v4/core").$strip>>;
510
+ }, import("zod/v4/core").$strip>>;
427
511
  }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
428
512
  kind: import("zod").ZodLiteral<"plan">;
429
513
  planId: import("zod").ZodString;
@@ -229,13 +229,17 @@ async function symbolicateSelectedElement(selectedElement) {
229
229
  });
230
230
  }
231
231
  }
232
- let sourceLocation = selectedElement.sourceLocation;
233
- if (fiberChain.length === 0 && sourceLocation && isLikelyCompiledLocation(sourceLocation)) {
234
- const captured = sourceLocation;
232
+ const capturedSourceLocation = selectedElement.sourceLocation;
233
+ let sourceLocation = capturedSourceLocation;
234
+ const symbolicatedCapture = {
235
+ location: null
236
+ };
237
+ if (sourceLocation && isLikelyCompiledLocation(sourceLocation)) {
235
238
  targets.push({
236
- location: captured,
239
+ location: sourceLocation,
237
240
  apply: (next) => {
238
241
  sourceLocation = next;
242
+ symbolicatedCapture.location = next;
239
243
  }
240
244
  });
241
245
  }
@@ -249,13 +253,27 @@ async function symbolicateSelectedElement(selectedElement) {
249
253
  const frame = extractResolvedFrame(resolved[index] ?? null);
250
254
  target.apply(applyResolved({ original: target.location, frame }));
251
255
  }
252
- if (fiberChain.length > 0) {
253
- sourceLocation = findUserSourceLocation(fiberChain) ?? fiberChain[0].sourceLocation;
256
+ if (!isUserSourceLocation(sourceLocation)) {
257
+ sourceLocation = findUserSourceLocation(fiberChain) ?? sourceLocation ?? fiberChain[0]?.sourceLocation;
254
258
  }
259
+ const anchor = selectedElement.anchor;
260
+ const anchorSource = anchor?.source;
261
+ const resolvedCapture = anchorSource && anchorSource.filePath === capturedSourceLocation?.filePath && anchorSource.line === capturedSourceLocation.lineNumber ? symbolicatedCapture.location : null;
255
262
  return {
256
263
  ...selectedElement,
257
264
  sourceLocation,
258
- fiberChain
265
+ fiberChain,
266
+ ...anchor && anchorSource && resolvedCapture ? {
267
+ anchor: {
268
+ ...anchor,
269
+ source: {
270
+ ...anchorSource,
271
+ filePath: resolvedCapture.filePath,
272
+ line: resolvedCapture.lineNumber,
273
+ col: resolvedCapture.columnNumber
274
+ }
275
+ }
276
+ } : {}
259
277
  };
260
278
  }
261
279
  export {
@@ -1,249 +0,0 @@
1
- import { exhaustiveSwitch } from './chunk-THOBCJJA.mjs';
2
- import * as z from 'zod';
3
-
4
- function parseJsonOrNull(json) {
5
- try {
6
- return JSON.parse(json);
7
- } catch {
8
- return null;
9
- }
10
- }
11
-
12
- function parseSchemaOrNull(value, schema) {
13
- const parseResult = schema.safeParse(value);
14
- return parseResult.success ? parseResult.data : null;
15
- }
16
- var SELECT_MODE_SELECTABLE_ATTRIBUTE = "data-replo-selectable";
17
- var SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE = "data-replo-selectable-payload";
18
- var displayModeSchema = z.enum(["browse", "selection"]).describe("DisplayMode");
19
- var selectModeInlineTextStatusSchema = z.enum(["editable", "dynamic", "translated"]).nullable().describe("SelectModeInlineTextStatus");
20
- var selectModeTextMetricsSchema = z.object({
21
- tightWidth: z.number(),
22
- lineCount: z.number(),
23
- lineHeight: z.number()
24
- }).describe("SelectModeTextMetrics");
25
- var selectModeClickPositionSchema = z.object({
26
- x: z.number(),
27
- y: z.number()
28
- }).describe("SelectModeClickPosition");
29
- var selectModeSourceLocationSchema = z.object({
30
- filePath: z.string(),
31
- lineNumber: z.number(),
32
- columnNumber: z.number().optional(),
33
- componentName: z.string().optional()
34
- }).describe("SelectModeSourceLocation");
35
- var selectModeFiberChainEntrySchema = z.object({
36
- sourceLocation: selectModeSourceLocationSchema,
37
- tagName: z.string().optional(),
38
- componentName: z.string().optional(),
39
- props: z.record(z.string(), z.unknown()).optional()
40
- }).describe("SelectModeFiberChainEntry");
41
- var selectModeBoundingRectSchema = z.object({
42
- x: z.number(),
43
- y: z.number(),
44
- left: z.number(),
45
- top: z.number(),
46
- right: z.number(),
47
- bottom: z.number(),
48
- width: z.number(),
49
- height: z.number()
50
- }).describe("SelectModeBoundingRect");
51
- var selectModeHoverRectSchema = selectModeBoundingRectSchema.extend({ isSection: z.boolean().optional() }).describe("SelectModeHoverRect");
52
- var selectModeSelectionRectSchema = z.object({
53
- id: z.string(),
54
- rect: selectModeBoundingRectSchema
55
- }).describe("SelectModeSelectionRect");
56
- var selectModeStyleAtRuleSchema = z.object({
57
- type: z.string(),
58
- text: z.string()
59
- }).describe("SelectModeStyleAtRule");
60
- var selectModeStyleVariantSchema = z.object({
61
- atRules: z.array(selectModeStyleAtRuleSchema),
62
- pseudo: z.string().nullable()
63
- }).describe("SelectModeStyleVariant");
64
- var selectModeDefinedStyleSchema = z.object({
65
- property: z.string(),
66
- variant: selectModeStyleVariantSchema.nullable(),
67
- className: z.string().nullable(),
68
- raw: z.string(),
69
- resolved: z.string()
70
- }).describe("SelectModeDefinedStyle");
71
- function transformRect({
72
- rect,
73
- offset,
74
- scale = 1
75
- }) {
76
- return {
77
- x: rect.x * scale + offset.left,
78
- y: rect.y * scale + offset.top,
79
- left: rect.left * scale + offset.left,
80
- right: rect.right * scale + offset.left,
81
- top: rect.top * scale + offset.top,
82
- bottom: rect.bottom * scale + offset.top,
83
- width: rect.width * scale,
84
- height: rect.height * scale
85
- };
86
- }
87
- function transformPoint({
88
- point,
89
- offset,
90
- scale = 1
91
- }) {
92
- return {
93
- x: point.x * scale + offset.left,
94
- y: point.y * scale + offset.top
95
- };
96
- }
97
- function getIframeOffset(iframe) {
98
- if (!iframe) {
99
- return { left: 0, top: 0 };
100
- }
101
- const iframeRect = iframe.getBoundingClientRect();
102
- return { left: iframeRect.left, top: iframeRect.top };
103
- }
104
- var selectModeImageScopeSchema = z.discriminatedUnion("kind", [
105
- z.object({ kind: z.literal("all") }),
106
- z.object({ kind: z.literal("media"), media: z.string() })
107
- ]).describe("SelectModeImageScope");
108
- var selectModeImageSourceSchema = z.object({
109
- srcSet: z.string(),
110
- sizes: z.string(),
111
- media: z.string(),
112
- type: z.string(),
113
- previewUrl: z.string().nullable()
114
- }).describe("SelectModeImageSource");
115
- var selectModeImageSchema = z.object({
116
- src: z.string(),
117
- currentSrc: z.string(),
118
- srcSet: z.string(),
119
- sizes: z.string(),
120
- previewUrl: z.string().nullable(),
121
- sources: z.array(selectModeImageSourceSchema)
122
- }).describe("SelectModeImage");
123
- var selectModeVideoSchema = z.object({
124
- src: z.string(),
125
- currentSrc: z.string()
126
- }).describe("SelectModeVideo");
127
- var selectedElementSchema = z.object({
128
- kind: z.literal("react-element"),
129
- selector: z.string(),
130
- section: z.object({ selector: z.string() }).optional(),
131
- tagName: z.string(),
132
- elementType: z.string(),
133
- textContent: z.string().nullable(),
134
- sectionLabel: z.string().optional(),
135
- rect: selectModeBoundingRectSchema,
136
- textMetrics: selectModeTextMetricsSchema.nullable(),
137
- outerHTML: z.string(),
138
- image: selectModeImageSchema.optional(),
139
- video: selectModeVideoSchema.optional(),
140
- definedStyles: z.array(selectModeDefinedStyleSchema).default([]),
141
- authoredStyles: z.record(z.string(), z.string()).default({}).describe(
142
- "Authored CSS value of the winning declaration per control property, custom properties expanded (e.g. 1.5rem for text-2xl at a wide viewport)."
143
- ),
144
- inheritedStyles: z.record(z.string(), z.string()).default({}),
145
- clickPosition: selectModeClickPositionSchema,
146
- sourceLocation: selectModeSourceLocationSchema.optional(),
147
- fiberChain: z.array(selectModeFiberChainEntrySchema).default([]),
148
- siblingSelectors: z.array(z.string()).default([])
149
- }).describe("SelectedElement");
150
- var selectablePlanDataSchema = z.object({
151
- kind: z.literal("plan"),
152
- planId: z.string(),
153
- label: z.string(),
154
- rect: selectModeBoundingRectSchema
155
- }).describe("SelectablePlanData");
156
- var selectablePlanPayloadSchema = selectablePlanDataSchema.omit({ rect: true }).describe("SelectablePlanPayload");
157
- var selectableDataPayloadSchema = z.discriminatedUnion("kind", [selectablePlanPayloadSchema]).describe("SelectableDataPayload");
158
- var selectableDataSchema = z.discriminatedUnion("kind", [selectedElementSchema, selectablePlanDataSchema]).describe("SelectableData");
159
- function isSelectedSection(data) {
160
- return data.kind === "react-element" && data.selector === data.section?.selector;
161
- }
162
- function transformSelectedElement({
163
- element,
164
- offset,
165
- scale = 1
166
- }) {
167
- return {
168
- ...element,
169
- rect: transformRect({ rect: element.rect, offset, scale }),
170
- clickPosition: transformPoint({
171
- point: element.clickPosition,
172
- offset,
173
- scale
174
- })
175
- };
176
- }
177
- function transformSelectableData({
178
- data,
179
- offset
180
- }) {
181
- return exhaustiveSwitch(
182
- data,
183
- "kind"
184
- )({
185
- "react-element": (element) => transformSelectedElement({ element, offset }),
186
- plan: (plan) => ({
187
- ...plan,
188
- rect: transformRect({ rect: plan.rect, offset })
189
- })
190
- });
191
- }
192
- function readSelectablePayload(rawPayload) {
193
- if (!rawPayload) {
194
- return null;
195
- }
196
- const parsedPayload = parseJsonOrNull(rawPayload);
197
- if (!parsedPayload) {
198
- return null;
199
- }
200
- return parseSchemaOrNull(parsedPayload, selectableDataPayloadSchema);
201
- }
202
- var selectModeOptimisticUpdatePayloadSchema = z.discriminatedUnion("kind", [
203
- z.object({
204
- kind: z.literal("image"),
205
- image: selectModeImageSchema
206
- }),
207
- z.object({
208
- kind: z.literal("css"),
209
- fontSource: z.enum(["google", "site"]).optional(),
210
- property: z.string(),
211
- value: z.string().nullable()
212
- }),
213
- z.object({
214
- kind: z.literal("content"),
215
- innerHTML: z.string()
216
- }),
217
- z.object({
218
- kind: z.literal("attribute"),
219
- name: z.string(),
220
- value: z.string()
221
- })
222
- ]).describe("SelectModeOptimisticUpdatePayload");
223
- var selectModeTiptapActiveMarksSchema = z.object({
224
- bold: z.boolean(),
225
- italic: z.boolean(),
226
- underline: z.boolean(),
227
- strike: z.boolean()
228
- }).describe("SelectModeTiptapActiveMarks");
229
- var selectModeFormatCommandSchema = z.enum(["toggleBold", "toggleItalic", "toggleUnderline", "toggleStrike"]).describe("SelectModeFormatCommand");
230
- var selectModeSelectionTypeSchema = z.enum(["none", "element", "area", "drag"]).describe("SelectModeSelectionType");
231
- var selectModeSelectionSchema = z.discriminatedUnion("type", [
232
- z.object({ type: z.literal("none") }),
233
- z.object({
234
- type: z.literal("element"),
235
- data: selectableDataSchema
236
- }),
237
- z.object({
238
- type: z.literal("area"),
239
- rect: selectModeBoundingRectSchema,
240
- items: z.array(selectableDataSchema)
241
- }),
242
- z.object({
243
- type: z.literal("drag"),
244
- dragRect: selectModeBoundingRectSchema,
245
- selectionRects: z.array(selectModeSelectionRectSchema)
246
- })
247
- ]).describe("SelectModeSelection");
248
-
249
- export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, isSelectedSection, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeDefinedStyleSchema, selectModeFiberChainEntrySchema, selectModeFormatCommandSchema, selectModeHoverRectSchema, selectModeImageSchema, selectModeImageScopeSchema, selectModeImageSourceSchema, selectModeInlineTextStatusSchema, selectModeOptimisticUpdatePayloadSchema, selectModeSelectionRectSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeStyleAtRuleSchema, selectModeStyleVariantSchema, selectModeTextMetricsSchema, selectModeTiptapActiveMarksSchema, selectModeVideoSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData, transformSelectedElement };