@replohq/sandbox-runtime 1.7.9 → 1.7.11

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 (40) hide show
  1. package/_vendor/replo-utils/react/zustand.d.ts +13 -0
  2. package/_vendor/replo-utils/react/zustand.mjs +24 -0
  3. package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +12 -2
  4. package/_vendor/schemas/selectModeIframeRpc.d.ts +66 -4
  5. package/_vendor/schemas/selectModeIframeRpc.mjs +16 -3
  6. package/buildMetadata.js +3 -3
  7. package/package.json +6 -5
  8. package/select-mode/EditorSelection.d.ts +1 -22
  9. package/select-mode/EditorSelection.js +61 -100
  10. package/select-mode/SelectionFrames.d.ts +1 -0
  11. package/select-mode/SelectionFrames.js +58 -0
  12. package/select-mode/annotationFrames.d.ts +13 -0
  13. package/select-mode/annotationFrames.js +31 -1
  14. package/select-mode/descriptor/elementDescriptor.js +1 -1
  15. package/select-mode/displayModeStore.d.ts +0 -2
  16. package/select-mode/displayModeStore.js +11 -30
  17. package/select-mode/hooks/useParentMessaging.js +3 -0
  18. package/select-mode/hooks/useSelectionHover.d.ts +1 -19
  19. package/select-mode/hooks/useSelectionHover.js +37 -49
  20. package/select-mode/hooks/useSelectionInteractions.d.ts +1 -12
  21. package/select-mode/hooks/useSelectionInteractions.js +57 -39
  22. package/select-mode/hooks/useSelectionScrollSync.d.ts +1 -25
  23. package/select-mode/hooks/useSelectionScrollSync.js +48 -40
  24. package/select-mode/iframeRpcChannel.d.ts +24 -1
  25. package/select-mode/inlineEditFeedback.d.ts +6 -0
  26. package/select-mode/inlineEditFeedback.js +47 -0
  27. package/select-mode/isTextEditableElement.d.ts +1 -0
  28. package/select-mode/isTextEditableElement.js +15 -0
  29. package/select-mode/selectModeStore.d.ts +160 -0
  30. package/select-mode/selectModeStore.js +585 -0
  31. package/select-mode/selectionFrame.d.ts +10 -59
  32. package/select-mode/selectionFrame.js +26 -150
  33. package/select-mode/symbolicate.js +4 -0
  34. package/select-mode/tiptapInlineEditor.js +16 -1
  35. package/select-mode/hooks/useCrosshairCursor.d.ts +0 -10
  36. package/select-mode/hooks/useCrosshairCursor.js +0 -23
  37. package/select-mode/hooks/useEditModeStateMachine.d.ts +0 -16
  38. package/select-mode/hooks/useEditModeStateMachine.js +0 -228
  39. package/select-mode/hooks/useSelectModeController.d.ts +0 -11
  40. package/select-mode/hooks/useSelectModeController.js +0 -72
@@ -337,6 +337,28 @@ export declare function getSelectModeIframeRpcChannel(): import("../_vendor/sche
337
337
  }, import("zod/v4/core").$strip>;
338
338
  outputSchema: import("zod").ZodVoid;
339
339
  };
340
+ inlineEditFeedbackChanged: {
341
+ inputSchema: import("zod").ZodObject<{
342
+ feedback: import("zod").ZodNullable<import("zod").ZodObject<{
343
+ status: import("zod").ZodEnum<{
344
+ unavailable: "unavailable";
345
+ pending: "pending";
346
+ failed: "failed";
347
+ }>;
348
+ rect: import("zod").ZodObject<{
349
+ x: import("zod").ZodNumber;
350
+ y: import("zod").ZodNumber;
351
+ left: import("zod").ZodNumber;
352
+ top: import("zod").ZodNumber;
353
+ right: import("zod").ZodNumber;
354
+ bottom: import("zod").ZodNumber;
355
+ width: import("zod").ZodNumber;
356
+ height: import("zod").ZodNumber;
357
+ }, import("zod/v4/core").$strip>;
358
+ }, import("zod/v4/core").$strip>>;
359
+ }, import("zod/v4/core").$strip>;
360
+ outputSchema: import("zod").ZodVoid;
361
+ };
340
362
  editorStateUpdate: {
341
363
  inputSchema: import("zod").ZodObject<{
342
364
  activeMarks: import("zod").ZodObject<{
@@ -345,7 +367,8 @@ export declare function getSelectModeIframeRpcChannel(): import("../_vendor/sche
345
367
  underline: import("zod").ZodBoolean;
346
368
  strike: import("zod").ZodBoolean;
347
369
  }, import("zod/v4/core").$strip>;
348
- isEditing: import("zod").ZodBoolean;
370
+ isInlineEditing: import("zod").ZodBoolean;
371
+ isInlineEditPending: import("zod").ZodBoolean;
349
372
  }, import("zod/v4/core").$strip>;
350
373
  outputSchema: import("zod").ZodVoid;
351
374
  };
@@ -0,0 +1,6 @@
1
+ import type { InlineEditFeedback } from "../_vendor/schemas/generated/selectModeIframeRpc";
2
+ export declare function reportInlineEditFeedback({ element, onDisconnected, status, }: {
3
+ element: HTMLElement;
4
+ onDisconnected: () => void;
5
+ status?: InlineEditFeedback["status"];
6
+ }): () => void;
@@ -0,0 +1,47 @@
1
+ import { getWebsiteBuilderRpc } from "./iframeRpcChannel";
2
+ function reportInlineEditFeedback({
3
+ element,
4
+ onDisconnected,
5
+ status = "pending"
6
+ }) {
7
+ let animationFrame = 0;
8
+ let stopped = false;
9
+ let previousRect = "";
10
+ const report = () => {
11
+ if (stopped) return;
12
+ if (!element.isConnected) {
13
+ onDisconnected();
14
+ return;
15
+ }
16
+ const bounds = element.getBoundingClientRect();
17
+ const rect = {
18
+ x: bounds.x,
19
+ y: bounds.y,
20
+ top: bounds.top,
21
+ right: bounds.right,
22
+ bottom: bounds.bottom,
23
+ left: bounds.left,
24
+ width: bounds.width,
25
+ height: bounds.height
26
+ };
27
+ const serializedRect = JSON.stringify(rect);
28
+ if (serializedRect !== previousRect) {
29
+ previousRect = serializedRect;
30
+ getWebsiteBuilderRpc()?.inlineEditFeedbackChanged({
31
+ feedback: { status, rect }
32
+ });
33
+ }
34
+ animationFrame = requestAnimationFrame(report);
35
+ };
36
+ const timer = status === "pending" ? window.setTimeout(report, 150) : null;
37
+ if (status !== "pending") report();
38
+ return () => {
39
+ stopped = true;
40
+ if (timer !== null) clearTimeout(timer);
41
+ cancelAnimationFrame(animationFrame);
42
+ getWebsiteBuilderRpc()?.inlineEditFeedbackChanged({ feedback: null });
43
+ };
44
+ }
45
+ export {
46
+ reportInlineEditFeedback
47
+ };
@@ -0,0 +1 @@
1
+ export declare function isTextEditableElement(element: Element): element is HTMLElement;
@@ -0,0 +1,15 @@
1
+ function isTextEditableElement(element) {
2
+ const tagName = element.tagName.toLowerCase();
3
+ return element instanceof HTMLElement && Boolean(element.textContent?.trim()) && ![
4
+ "input",
5
+ "textarea",
6
+ "select",
7
+ "option",
8
+ "img",
9
+ "video",
10
+ "canvas"
11
+ ].includes(tagName);
12
+ }
13
+ export {
14
+ isTextEditableElement
15
+ };
@@ -0,0 +1,160 @@
1
+ import type { DisplayMode, SelectableData, SelectModeBoundingRect, SelectModeFormatCommand, SelectModeSelectionType } from "../_vendor/schemas/generated/selectMode";
2
+ import type { InlineEditFeedback } from "../_vendor/schemas/generated/selectModeIframeRpc";
3
+ import type { DragCandidate } from "./interactions/selectionGeometry";
4
+ import type { SelectionFrameSpec } from "./selectionFrame";
5
+ import type { SelectModeInteractionSession } from "./selectModeSession";
6
+ import type { InlineTiptapEditor } from "./tiptapInlineEditor";
7
+ export type ActiveMarks = {
8
+ bold: boolean;
9
+ italic: boolean;
10
+ underline: boolean;
11
+ strike: boolean;
12
+ };
13
+ export declare const EMPTY_ACTIVE_MARKS: ActiveMarks;
14
+ type InlineEditRequest = {
15
+ status: "pending";
16
+ editId: string;
17
+ element: HTMLElement;
18
+ timeout: number;
19
+ stopFeedback: () => void;
20
+ } | {
21
+ status: Exclude<InlineEditFeedback["status"], "pending">;
22
+ element: HTMLElement;
23
+ stopFeedback: () => void;
24
+ };
25
+ type LastClick = {
26
+ descriptorPromise: Promise<SelectableData>;
27
+ target: Element;
28
+ time: number;
29
+ };
30
+ interface SelectModeStoreState {
31
+ displayMode: DisplayMode;
32
+ interactionSession: SelectModeInteractionSession;
33
+ selectionFrames: SelectionFrameSpec[];
34
+ isSelectionFrameEditing: boolean;
35
+ lastPointerClientPosition: {
36
+ x: number;
37
+ y: number;
38
+ } | null;
39
+ lastPostedHoverRect: SelectModeBoundingRect | null | undefined;
40
+ hoverSyncAnimationFrameId: number | null;
41
+ lastClick: LastClick | null;
42
+ dragCandidates: DragCandidate[];
43
+ committedSelectionAtPointerDown: Element[];
44
+ dragAnimationFrameId: number | null;
45
+ editingPointerIds: Set<number>;
46
+ scrollSyncAnimationFrameId: number | null;
47
+ inlineEditRequest: InlineEditRequest | null;
48
+ editor: InlineTiptapEditor | null;
49
+ editingElement: HTMLElement | null;
50
+ editId: string | null;
51
+ originalInnerHTML: string | null;
52
+ initialHTML: string | null;
53
+ isCommitting: boolean;
54
+ beginEditingAt: number;
55
+ activeMarks: ActiveMarks;
56
+ actions: {
57
+ reset: () => void;
58
+ setDisplayMode: (displayMode: DisplayMode) => void;
59
+ setSelectionType: ({ selectionType, selectors, }: {
60
+ selectionType: SelectModeSelectionType;
61
+ selectors?: string[];
62
+ }) => void;
63
+ setInteractionSession: (interactionSession: SelectModeInteractionSession) => void;
64
+ resetInteractionSession: () => void;
65
+ postSelectedElementSnapshot: (options?: {
66
+ clearMissing?: boolean;
67
+ }) => boolean;
68
+ showElementSelectionFrames: ({ elements, scrollOffset, }: {
69
+ elements: Element[];
70
+ scrollOffset: {
71
+ left: number;
72
+ top: number;
73
+ };
74
+ }) => void;
75
+ showAreaSelectionFrames: ({ elements, scrollOffset, }: {
76
+ elements: Element[];
77
+ scrollOffset: {
78
+ left: number;
79
+ top: number;
80
+ };
81
+ }) => void;
82
+ hideSelectionFrames: () => void;
83
+ setLastPointerClientPosition: (position: {
84
+ x: number;
85
+ y: number;
86
+ } | null) => void;
87
+ setLastPostedHoverRect: (rect: SelectModeBoundingRect | null | undefined) => void;
88
+ resetHoverRectDedup: () => void;
89
+ setHoverSyncAnimationFrameId: (id: number | null) => void;
90
+ setLastClick: (lastClick: LastClick | null) => void;
91
+ setDragCandidates: (dragCandidates: DragCandidate[]) => void;
92
+ setCommittedSelectionAtPointerDown: (elements: Element[]) => void;
93
+ setDragAnimationFrameId: (id: number | null) => void;
94
+ setScrollSyncAnimationFrameId: (id: number | null) => void;
95
+ beginEditing: ({ element, descriptorPromise, }: {
96
+ element: Element;
97
+ descriptorPromise: Promise<SelectableData>;
98
+ }) => void;
99
+ commitInlineEdit: () => void;
100
+ revertInlineEdit: () => void;
101
+ formatCommand: (command: SelectModeFormatCommand) => void;
102
+ dismissInlineEditRequest: () => void;
103
+ };
104
+ }
105
+ export declare const selectModeStore: import("zustand/traditional").UseBoundStoreWithEqualityFn<import("zustand").StoreApi<SelectModeStoreState>>;
106
+ export declare function useSelectModeStore(): import("zustand/traditional").UseBoundStoreWithEqualityFn<import("zustand").StoreApi<SelectModeStoreState>>;
107
+ export declare const useSelectModeStoreActions: () => {
108
+ reset: () => void;
109
+ setDisplayMode: (displayMode: DisplayMode) => void;
110
+ setSelectionType: ({ selectionType, selectors, }: {
111
+ selectionType: SelectModeSelectionType;
112
+ selectors?: string[];
113
+ }) => void;
114
+ setInteractionSession: (interactionSession: SelectModeInteractionSession) => void;
115
+ resetInteractionSession: () => void;
116
+ postSelectedElementSnapshot: (options?: {
117
+ clearMissing?: boolean;
118
+ }) => boolean;
119
+ showElementSelectionFrames: ({ elements, scrollOffset, }: {
120
+ elements: Element[];
121
+ scrollOffset: {
122
+ left: number;
123
+ top: number;
124
+ };
125
+ }) => void;
126
+ showAreaSelectionFrames: ({ elements, scrollOffset, }: {
127
+ elements: Element[];
128
+ scrollOffset: {
129
+ left: number;
130
+ top: number;
131
+ };
132
+ }) => void;
133
+ hideSelectionFrames: () => void;
134
+ setLastPointerClientPosition: (position: {
135
+ x: number;
136
+ y: number;
137
+ } | null) => void;
138
+ setLastPostedHoverRect: (rect: SelectModeBoundingRect | null | undefined) => void;
139
+ resetHoverRectDedup: () => void;
140
+ setHoverSyncAnimationFrameId: (id: number | null) => void;
141
+ setLastClick: (lastClick: LastClick | null) => void;
142
+ setDragCandidates: (dragCandidates: DragCandidate[]) => void;
143
+ setCommittedSelectionAtPointerDown: (elements: Element[]) => void;
144
+ setDragAnimationFrameId: (id: number | null) => void;
145
+ setScrollSyncAnimationFrameId: (id: number | null) => void;
146
+ beginEditing: ({ element, descriptorPromise, }: {
147
+ element: Element;
148
+ descriptorPromise: Promise<SelectableData>;
149
+ }) => void;
150
+ commitInlineEdit: () => void;
151
+ revertInlineEdit: () => void;
152
+ formatCommand: (command: SelectModeFormatCommand) => void;
153
+ dismissInlineEditRequest: () => void;
154
+ };
155
+ export declare const useDisplayMode: () => DisplayMode;
156
+ export declare const useSelectionFrames: () => SelectionFrameSpec[];
157
+ export declare const useIsSelectionFrameEditing: () => boolean;
158
+ export declare const useEditingElement: () => HTMLElement | null;
159
+ export declare const useInteractionSession: () => SelectModeInteractionSession;
160
+ export {};