@replohq/sandbox-runtime 1.18.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.
@@ -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
@@ -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>;
@@ -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>;
package/buildMetadata.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const BUILD_METADATA = {
2
2
  "packageName": "@replohq/sandbox-runtime",
3
- "version": "1.18.0",
3
+ "version": "1.18.1",
4
4
  "branch": "HEAD",
5
- "commit": "371ae98105e9f99b04918b3dffe40867380cd9ef",
6
- "builtAt": "2026-10-21T22:33:13.604Z"
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();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@replohq/sandbox-runtime",
3
- "version": "1.18.0",
3
+ "version": "1.18.1",
4
4
  "reploBuild": {
5
5
  "packageName": "@replohq/sandbox-runtime",
6
- "version": "1.18.0",
6
+ "version": "1.18.1",
7
7
  "branch": "HEAD",
8
- "commit": "371ae98105e9f99b04918b3dffe40867380cd9ef",
9
- "builtAt": "2026-10-21T22:33:13.604Z"
8
+ "commit": "770da909743d238b91a6529e4dc38a079fdfd43a",
9
+ "builtAt": "2026-10-22T00:12:53.373Z"
10
10
  },
11
11
  "description": "Replo sandbox runtime — editor integration for agent-built Next.js sites.",
12
12
  "license": "SEE LICENSE IN LICENSE",
@@ -7,6 +7,7 @@ import {
7
7
  } from "../interactions/sectionGeometry";
8
8
  import { getElementBoundingRect } from "../interactions/selectionGeometry";
9
9
  import { isSectionCanvasControl } from "../section-canvas/sectionCanvasControls";
10
+ import { sectionCanvasStore } from "../section-canvas/sectionCanvasStore";
10
11
  import { useDisplayMode, useSelectModeStore } from "../selectModeStore";
11
12
  function useSelectionHover() {
12
13
  const store = useSelectModeStore();
@@ -31,6 +32,10 @@ function useSelectionHover() {
31
32
  getWebsiteBuilderRpc()?.hoverElement({ rect: hoverRect });
32
33
  };
33
34
  const syncCurrentHover = (pointerClientPosition = store.getState().lastPointerClientPosition) => {
35
+ if (sectionCanvasStore.getState().drag) {
36
+ postHoveredElement(null);
37
+ return;
38
+ }
34
39
  const previewSection = store.getState().sectionPreviewElement;
35
40
  if (previewSection) {
36
41
  if (previewSection.isConnected) {
@@ -16,7 +16,6 @@ import {
16
16
  import {
17
17
  getPlacedSections,
18
18
  getSectionGaps,
19
- GHOST_WIDTH_PX,
20
19
  sectionCanvasStore,
21
20
  useSectionCanvasStore
22
21
  } from "./sectionCanvasStore";
@@ -29,10 +28,11 @@ const ACCENT_PRESSED = "#1d4ed8";
29
28
  const PILL_HEIGHT = 22;
30
29
  const PILL_SPREAD = 64;
31
30
  const PILL_HALF_WIDTH = 52;
31
+ const LABEL_HALF_WIDTH = 80;
32
32
  const SECTION_CANVAS_CSS = `
33
33
  [${SECTION_CANVAS_ATTRIBUTE}] button { all: initial; box-sizing: border-box; display: flex; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer !important; color: ${ACCENT}; background: #fff !important; }
34
34
  [${SECTION_CANVAS_ATTRIBUTE}] button * { cursor: inherit !important; }
35
- [${SECTION_CANVAS_ATTRIBUTE}] [data-shape="pill"] { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; border-radius: 4px; background: ${ACCENT} !important; color: #fff !important; font-family: system-ui, -apple-system, sans-serif; font-weight: 600; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2); }
35
+ [${SECTION_CANVAS_ATTRIBUTE}] [data-shape="pill"] { position: absolute; display: flex; align-items: center; transform: translate(-50%, -50%); white-space: nowrap; border-radius: 4px; background: ${ACCENT} !important; color: #fff !important; font-family: system-ui, -apple-system, sans-serif; font-weight: 600; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2); }
36
36
  [${SECTION_CANVAS_ATTRIBUTE}] button[data-shape="pill"]:hover, [${SECTION_CANVAS_ATTRIBUTE}] button[data-shape="pill"]:focus-visible { background: ${ACCENT_PRESSED} !important; color: #fff !important; }
37
37
  [${SECTION_CANVAS_ATTRIBUTE}] button[data-shape="tool"] { border-radius: 4px; gap: 4px; background: transparent !important; color: #fff !important; font-family: system-ui, -apple-system, sans-serif; font-weight: 600; }
38
38
  [${SECTION_CANVAS_ATTRIBUTE}] button[data-shape="tool"][data-grip] { cursor: grab !important; }
@@ -237,73 +237,55 @@ function SectionCanvas() {
237
237
  }
238
238
  );
239
239
  }
240
- let insertMarker = null;
241
- const insertingAt = canvas.insertingAt;
242
- if (typeof insertingAt === "number" && !drag) {
243
- const placed = getPlacedSections({ canvas, elementsByIndex });
244
- const gap = getSectionGaps(placed, canvas.sections.length).find(
245
- (candidate) => candidate.at === insertingAt
240
+ const markedGap = drag ? drag.gap : canvas.insertingAt;
241
+ let gapMarker = null;
242
+ const placed = typeof markedGap === "number" ? getPlacedSections({ canvas, elementsByIndex }) : [];
243
+ const gap = getSectionGaps(placed, canvas.sections.length).find(
244
+ (candidate) => candidate.at === markedGap
245
+ );
246
+ if (gap) {
247
+ const left = Math.max(
248
+ visible.left,
249
+ Math.min(...placed.map(({ box }) => box.left))
246
250
  );
247
- if (gap) {
248
- const left = Math.max(
249
- visible.left,
250
- Math.min(...placed.map(({ box }) => box.left))
251
- );
252
- const right = Math.min(
253
- visible.right,
254
- Math.max(...placed.map(({ box }) => box.right))
255
- );
256
- const y = Math.min(
257
- Math.max(gap.y, PILL_HEIGHT * unit),
258
- window.innerHeight - PILL_HEIGHT * unit
259
- );
260
- insertMarker = /* @__PURE__ */ jsxs(Fragment, { children: [
261
- /* @__PURE__ */ jsx(
262
- "div",
263
- {
264
- style: {
265
- position: "fixed",
266
- left,
267
- width: right - left,
268
- top: y - 1.5 * unit,
269
- height: 3 * unit,
270
- background: ACCENT
271
- }
272
- }
273
- ),
274
- /* @__PURE__ */ jsx(
275
- "div",
276
- {
277
- "data-shape": "pill",
278
- role: "status",
279
- style: {
280
- left: (left + right) / 2,
281
- top: y,
282
- height: PILL_HEIGHT * unit,
283
- padding: `0 ${10 * unit}px`,
284
- fontSize: 11 * unit,
285
- display: "flex",
286
- alignItems: "center"
287
- },
288
- children: "New Section Goes Here"
251
+ const right = Math.min(
252
+ visible.right,
253
+ Math.max(...placed.map(({ box }) => box.right))
254
+ );
255
+ const y = Math.min(
256
+ Math.max(gap.y, PILL_HEIGHT * unit),
257
+ window.innerHeight - PILL_HEIGHT * unit
258
+ );
259
+ gapMarker = /* @__PURE__ */ jsxs(Fragment, { children: [
260
+ /* @__PURE__ */ jsx(
261
+ "div",
262
+ {
263
+ "data-replo-section-drop-line": true,
264
+ style: {
265
+ position: "fixed",
266
+ left,
267
+ width: right - left,
268
+ top: y - 1.5 * unit,
269
+ height: 3 * unit,
270
+ borderRadius: 3 * unit,
271
+ background: ACCENT,
272
+ boxShadow: `0 0 0 ${unit}px #fff`
289
273
  }
290
- )
291
- ] });
292
- }
274
+ }
275
+ ),
276
+ !drag && /* @__PURE__ */ jsx(
277
+ "div",
278
+ {
279
+ "data-shape": "pill",
280
+ role: "status",
281
+ style: pillStyle({ unit, left: (left + right) / 2, top: y }),
282
+ children: "New Section Goes Here"
283
+ }
284
+ )
285
+ ] });
293
286
  }
294
287
  let dragLayer = null;
295
288
  if (drag?.isActive && activeBox) {
296
- const placed = getPlacedSections({ canvas, elementsByIndex });
297
- const gap = drag.gap === null ? null : getSectionGaps(placed, canvas.sections.length).find((candidate) => {
298
- return candidate.at === drag.gap;
299
- });
300
- const lineLeft = Math.min(...placed.map(({ box }) => box.left));
301
- const lineRight = Math.max(...placed.map(({ box }) => box.right));
302
- const ghostWidth = GHOST_WIDTH_PX * unit;
303
- const ghostHeight = Math.min(
304
- (activeBox.bottom - activeBox.top) / (activeBox.right - activeBox.left) * ghostWidth,
305
- ghostWidth * 0.75
306
- );
307
289
  dragLayer = /* @__PURE__ */ jsxs(Fragment, { children: [
308
290
  /* @__PURE__ */ jsx(
309
291
  "div",
@@ -320,61 +302,26 @@ function SectionCanvas() {
320
302
  }
321
303
  }
322
304
  ),
323
- gap && /* @__PURE__ */ jsx(
324
- "div",
325
- {
326
- "data-replo-section-drop-line": true,
327
- style: {
328
- position: "fixed",
329
- left: lineLeft,
330
- width: lineRight - lineLeft,
331
- top: Math.min(
332
- Math.max(gap.y, 3 * unit),
333
- window.innerHeight - 3 * unit
334
- ) - 1.5 * unit,
335
- height: 3 * unit,
336
- borderRadius: 3 * unit,
337
- background: ACCENT,
338
- boxShadow: `0 0 0 ${unit}px #fff`
339
- }
340
- }
341
- ),
342
305
  /* @__PURE__ */ jsx(
343
306
  "div",
344
307
  {
308
+ "data-shape": "pill",
345
309
  style: {
346
- position: "fixed",
347
- left: drag.x + 14 * unit + ghostWidth > window.innerWidth ? drag.x - 14 * unit - ghostWidth : drag.x + 14 * unit,
348
- top: Math.min(
349
- drag.y + 14 * unit,
350
- window.innerHeight - ghostHeight - 8 * unit
351
- ),
352
- width: ghostWidth,
353
- height: ghostHeight,
310
+ ...pillStyle({
311
+ unit,
312
+ left: Math.min(
313
+ Math.max(drag.x, LABEL_HALF_WIDTH * unit),
314
+ window.innerWidth - LABEL_HALF_WIDTH * unit
315
+ ),
316
+ top: drag.y + 20 * unit + PILL_HEIGHT * unit > window.innerHeight ? drag.y - 20 * unit : drag.y + 20 * unit
317
+ }),
318
+ maxWidth: 2 * LABEL_HALF_WIDTH * unit,
319
+ display: "block",
320
+ lineHeight: `${PILL_HEIGHT * unit}px`,
354
321
  overflow: "hidden",
355
- borderRadius: 6 * unit,
356
- background: "#fff",
357
- boxShadow: `0 ${8 * unit}px ${24 * unit}px rgba(15, 23, 42, 0.25), 0 0 0 ${unit}px rgba(15, 23, 42, 0.12)`,
358
- opacity: 0.95,
359
- display: "flex",
360
- alignItems: "center",
361
- justifyContent: "center",
362
- font: `500 ${12 * unit}px/1.3 system-ui, sans-serif`,
363
- color: "#3f3f46"
322
+ textOverflow: "ellipsis"
364
323
  },
365
- children: drag.ghostSrc ? /* @__PURE__ */ jsx(
366
- "img",
367
- {
368
- src: drag.ghostSrc,
369
- alt: "",
370
- style: {
371
- display: "block",
372
- width: "100%",
373
- height: "auto",
374
- alignSelf: "flex-start"
375
- }
376
- }
377
- ) : activeSection?.label ?? "Section"
324
+ children: activeSection?.label ?? "Section"
378
325
  }
379
326
  )
380
327
  ] });
@@ -397,7 +344,7 @@ function SectionCanvas() {
397
344
  onPointerDown: (event) => event.stopPropagation(),
398
345
  children: [
399
346
  /* @__PURE__ */ jsx("style", { children: SECTION_CANVAS_CSS }),
400
- insertMarker,
347
+ gapMarker,
401
348
  overlay,
402
349
  dragLayer
403
350
  ]
@@ -406,6 +353,19 @@ function SectionCanvas() {
406
353
  document.body
407
354
  );
408
355
  }
356
+ function pillStyle({
357
+ unit,
358
+ left,
359
+ top
360
+ }) {
361
+ return {
362
+ left,
363
+ top,
364
+ height: PILL_HEIGHT * unit,
365
+ padding: `0 ${10 * unit}px`,
366
+ fontSize: 11 * unit
367
+ };
368
+ }
409
369
  function SectionControls({
410
370
  index,
411
371
  label,
@@ -435,6 +395,8 @@ function SectionControls({
435
395
  ),
436
396
  visible.right - PILL_HALF_WIDTH * unit - spread
437
397
  );
398
+ const outlineLeft = Math.max(box.left, visible.left);
399
+ const outlineRight = Math.min(box.right, visible.right);
438
400
  const toolbarTop = Math.max(box.top, 0) + TOOLBAR_INSET * unit;
439
401
  const textButton = {
440
402
  height: size,
@@ -447,9 +409,9 @@ function SectionControls({
447
409
  {
448
410
  style: {
449
411
  position: "fixed",
450
- left: box.left,
412
+ left: outlineLeft,
451
413
  top: box.top,
452
- width: box.right - box.left,
414
+ width: outlineRight - outlineLeft,
453
415
  height: box.bottom - box.top,
454
416
  boxSizing: "border-box",
455
417
  border: `${2 * unit}px solid ${ACCENT}`,
@@ -471,13 +433,7 @@ function SectionControls({
471
433
  type: "button",
472
434
  "data-shape": "pill",
473
435
  "aria-label": `Add Section ${edge} ${label}`,
474
- style: {
475
- left,
476
- top,
477
- height: pillHeight,
478
- padding: `0 ${10 * unit}px`,
479
- fontSize: 11 * unit
480
- },
436
+ style: pillStyle({ unit, left, top }),
481
437
  onClick: () => actions.request({ type: "insert", at }),
482
438
  children: "Add Section"
483
439
  },
@@ -489,7 +445,7 @@ function SectionControls({
489
445
  style: {
490
446
  position: "fixed",
491
447
  top: toolbarTop,
492
- right: window.innerWidth - Math.min(box.right, visible.right) + TOOLBAR_INSET * unit,
448
+ right: window.innerWidth - outlineRight + TOOLBAR_INSET * unit,
493
449
  display: "flex",
494
450
  gap: 2 * unit,
495
451
  padding: 2 * unit,
@@ -7,7 +7,6 @@ export type SectionDrag = {
7
7
  x: number;
8
8
  y: number;
9
9
  isActive: boolean;
10
- ghostSrc: string | null;
11
10
  gap: number | null;
12
11
  };
13
12
  type PendingMove = {
@@ -52,7 +51,6 @@ type SectionCanvasStoreState = {
52
51
  }) => void;
53
52
  };
54
53
  };
55
- export declare const GHOST_WIDTH_PX = 240;
56
54
  /** On-screen sections in page order, with their boxes. */
57
55
  export declare function getPlacedSections(state: Pick<SectionCanvasStoreState, "canvas" | "elementsByIndex">): {
58
56
  section: import("../../_vendor/schemas/generated/selectModeIframeRpc").SectionCanvasSection;
@@ -8,9 +8,7 @@ import {
8
8
  startOptimisticSectionMove
9
9
  } from "./optimisticSectionMove";
10
10
  import { findSectionElements } from "./sectionElements";
11
- import { captureSectionGhost } from "./sectionGhost";
12
11
  const DRAG_THRESHOLD_PX = 4;
13
- const GHOST_WIDTH_PX = 240;
14
12
  let resolveToken = 0;
15
13
  let moveCounter = 0;
16
14
  function sameSections(previous, next) {
@@ -164,7 +162,6 @@ const sectionCanvasStore = createShallowStore(
164
162
  getWebsiteBuilderRpc()?.sectionCanvasRequest({ request });
165
163
  },
166
164
  beginDrag: ({ index, pointerId, x, y }) => {
167
- const elements = get().elementsByIndex.get(index) ?? [];
168
165
  set({
169
166
  drag: {
170
167
  index,
@@ -174,20 +171,9 @@ const sectionCanvasStore = createShallowStore(
174
171
  x,
175
172
  y,
176
173
  isActive: false,
177
- ghostSrc: null,
178
174
  gap: null
179
175
  }
180
176
  });
181
- const scale = get().canvas?.previewScale ?? 1;
182
- void captureSectionGhost({
183
- elements,
184
- width: GHOST_WIDTH_PX / scale
185
- }).then((ghostSrc) => {
186
- const drag = get().drag;
187
- if (ghostSrc && drag?.pointerId === pointerId && drag.index === index) {
188
- set({ drag: { ...drag, ghostSrc } });
189
- }
190
- });
191
177
  },
192
178
  updateDrag: ({ x, y }) => {
193
179
  const state = get();
@@ -267,7 +253,6 @@ function useSectionCanvasStore(selector) {
267
253
  return useShallowStore(sectionCanvasStore, selector);
268
254
  }
269
255
  export {
270
- GHOST_WIDTH_PX,
271
256
  getPlacedSections,
272
257
  getSectionGaps,
273
258
  sectionCanvasStore,
@@ -1,5 +0,0 @@
1
- /** A small picture of a section to drag around, or null when it can't be drawn. */
2
- export declare function captureSectionGhost({ elements, width, }: {
3
- elements: readonly HTMLElement[];
4
- width: number;
5
- }): Promise<string | null>;
@@ -1,23 +0,0 @@
1
- "use client";
2
- async function captureSectionGhost({
3
- elements,
4
- width
5
- }) {
6
- const element = elements.find((candidate) => candidate.isConnected);
7
- if (!element) {
8
- return null;
9
- }
10
- const rect = element.getBoundingClientRect();
11
- if (rect.width === 0 || rect.height === 0) {
12
- return null;
13
- }
14
- try {
15
- const { snapdom } = await import("@zumer/snapdom");
16
- return await snapdom.toRaw(element, { width, embedFonts: false });
17
- } catch {
18
- return null;
19
- }
20
- }
21
- export {
22
- captureSectionGhost
23
- };