@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.
- package/PagePreviewHeightResponder.d.ts +1 -0
- package/PagePreviewHeightResponder.js +159 -0
- package/_vendor/schemas/comments.d.ts +898 -0
- package/_vendor/schemas/commentsOverlayRpc.d.ts +348 -0
- package/_vendor/schemas/commentsOverlayRpc.mjs +92 -0
- package/_vendor/schemas/generated/comments.d.ts +237 -0
- package/_vendor/schemas/generated/commentsOverlayRpc.d.ts +18 -0
- package/_vendor/schemas/generated/selectMode.d.ts +3 -1
- package/_vendor/schemas/pagePreviewHeight.d.ts +14 -0
- package/_vendor/schemas/pagePreviewHeight.mjs +18 -0
- package/_vendor/schemas/selectMode.d.ts +113 -0
- package/_vendor/schemas/selectMode.mjs +1 -1
- package/_vendor/schemas/selectModeIframeRpc.d.ts +226 -0
- package/_vendor/schemas/selectModeIframeRpc.mjs +1 -1
- package/buildMetadata.js +3 -3
- package/chunk-NVOBD46N.mjs +541 -0
- package/comments-overlay/CommentsOverlayMount.d.ts +1 -0
- package/comments-overlay/CommentsOverlayMount.js +44 -0
- package/comments-overlay/LICENSE-THIRD-PARTY.md +45 -0
- package/comments-overlay/bridge.d.ts +11 -0
- package/comments-overlay/bridge.js +136 -0
- package/comments-overlay/capture.d.ts +55 -0
- package/comments-overlay/capture.js +250 -0
- package/comments-overlay/originGate.d.ts +1 -0
- package/comments-overlay/originGate.js +11 -0
- package/comments-overlay/overlay.d.ts +52 -0
- package/comments-overlay/overlay.js +781 -0
- package/comments-overlay/resolve.d.ts +27 -0
- package/comments-overlay/resolve.js +201 -0
- package/comments-overlay/sourceLookup.d.ts +11 -0
- package/comments-overlay/sourceLookup.js +63 -0
- package/comments-overlay/textQuote.d.ts +17 -0
- package/comments-overlay/textQuote.js +87 -0
- package/comments-overlay/vendor/bippy.d.ts +53 -0
- package/comments-overlay/vendor/bippy.js +402 -0
- package/comments-overlay/vendor/elementAnchors.d.ts +9 -0
- package/comments-overlay/vendor/elementAnchors.js +144 -0
- package/comments-overlay/vendor/fiberElement.d.ts +21 -0
- package/comments-overlay/vendor/fiberElement.js +251 -0
- package/comments-overlay/vendor/htmlPreview.d.ts +13 -0
- package/comments-overlay/vendor/htmlPreview.js +179 -0
- package/comments-overlay/vendor/selector.d.ts +38 -0
- package/comments-overlay/vendor/selector.js +372 -0
- package/package.json +5 -4
- package/pinPreviewViewportUnits.d.ts +4 -0
- package/pinPreviewViewportUnits.js +76 -0
- package/sandbox-runtime.js +4 -0
- package/select-mode/descriptor/elementDescriptor.d.ts +4 -3
- package/select-mode/descriptor/elementDescriptor.js +20 -30
- package/select-mode/iframeRpcChannel.d.ts +84 -0
- package/select-mode/symbolicate.js +25 -7
- package/chunk-QTGDSYSU.mjs +0 -249
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PagePreviewHeightResponder(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
pagePreviewHeightRequestSchema,
|
|
5
|
+
PAGE_PREVIEW_MAX_HEIGHT
|
|
6
|
+
} from "./_vendor/schemas/pagePreviewHeight.mjs";
|
|
7
|
+
import { pinPreviewViewportUnits } from "./pinPreviewViewportUnits";
|
|
8
|
+
function startResponder() {
|
|
9
|
+
let parentOrigin = null;
|
|
10
|
+
let scheduledFrame = 0;
|
|
11
|
+
let awaitingMeasurement = false;
|
|
12
|
+
let reportedHeight = null;
|
|
13
|
+
let baselineRootHeight = "auto";
|
|
14
|
+
const measurementStyle = new CSSStyleSheet();
|
|
15
|
+
document.adoptedStyleSheets = [
|
|
16
|
+
...document.adoptedStyleSheets,
|
|
17
|
+
measurementStyle
|
|
18
|
+
];
|
|
19
|
+
const measure = () => {
|
|
20
|
+
scheduledFrame = 0;
|
|
21
|
+
if (!parentOrigin) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const body = document.body;
|
|
25
|
+
pinPreviewViewportUnits({
|
|
26
|
+
width: window.innerWidth,
|
|
27
|
+
height: window.innerHeight
|
|
28
|
+
});
|
|
29
|
+
const height = Math.min(
|
|
30
|
+
PAGE_PREVIEW_MAX_HEIGHT,
|
|
31
|
+
Math.ceil(
|
|
32
|
+
Math.max(
|
|
33
|
+
body.getBoundingClientRect().height,
|
|
34
|
+
body.scrollHeight,
|
|
35
|
+
document.documentElement.scrollHeight
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
baselineRootHeight = getComputedStyle(document.documentElement).height;
|
|
40
|
+
awaitingMeasurement = false;
|
|
41
|
+
if (height > 0) {
|
|
42
|
+
reportedHeight = height;
|
|
43
|
+
window.parent.postMessage(
|
|
44
|
+
{ type: "replo:page-preview-height:update", height },
|
|
45
|
+
parentOrigin
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const schedule = () => {
|
|
50
|
+
if (!parentOrigin || awaitingMeasurement) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
awaitingMeasurement = true;
|
|
54
|
+
window.parent.postMessage(
|
|
55
|
+
{ type: "replo:page-preview-height:reset" },
|
|
56
|
+
parentOrigin
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
const observer = new ResizeObserver(() => {
|
|
60
|
+
if (Math.ceil(document.body.getBoundingClientRect().height) === reportedHeight) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
schedule();
|
|
64
|
+
});
|
|
65
|
+
const mutations = new MutationObserver(schedule);
|
|
66
|
+
const receive = (event) => {
|
|
67
|
+
if (event.source !== window.parent || event.origin === "null") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const message = pagePreviewHeightRequestSchema.safeParse(event.data);
|
|
71
|
+
if (!message.success) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
parentOrigin = event.origin;
|
|
75
|
+
if (message.data.type === "replo:page-preview-height:subscribe") {
|
|
76
|
+
observer.observe(document.body);
|
|
77
|
+
mutations.observe(document.body, {
|
|
78
|
+
childList: true,
|
|
79
|
+
subtree: true,
|
|
80
|
+
attributes: true,
|
|
81
|
+
characterData: true
|
|
82
|
+
});
|
|
83
|
+
schedule();
|
|
84
|
+
} else {
|
|
85
|
+
cancelAnimationFrame(scheduledFrame);
|
|
86
|
+
scheduledFrame = requestAnimationFrame(measure);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
window.addEventListener("message", receive);
|
|
90
|
+
const measureInteraction = () => {
|
|
91
|
+
if (!parentOrigin || awaitingMeasurement) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
cancelAnimationFrame(scheduledFrame);
|
|
95
|
+
scheduledFrame = requestAnimationFrame(() => {
|
|
96
|
+
scheduledFrame = 0;
|
|
97
|
+
if (!parentOrigin) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
measurementStyle.replaceSync(
|
|
101
|
+
`:root { height: ${baselineRootHeight} !important; min-height: 0 !important; max-height: none !important; }`
|
|
102
|
+
);
|
|
103
|
+
let height;
|
|
104
|
+
try {
|
|
105
|
+
height = Math.min(
|
|
106
|
+
PAGE_PREVIEW_MAX_HEIGHT,
|
|
107
|
+
Math.ceil(
|
|
108
|
+
Math.max(
|
|
109
|
+
document.body.scrollHeight,
|
|
110
|
+
document.body.getBoundingClientRect().height
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
} finally {
|
|
115
|
+
measurementStyle.replaceSync("");
|
|
116
|
+
}
|
|
117
|
+
if (height > 0) {
|
|
118
|
+
reportedHeight = height;
|
|
119
|
+
window.parent.postMessage(
|
|
120
|
+
{ type: "replo:page-preview-height:update", height },
|
|
121
|
+
parentOrigin
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const events = [
|
|
127
|
+
"pointerover",
|
|
128
|
+
"pointerout",
|
|
129
|
+
"focusin",
|
|
130
|
+
"focusout",
|
|
131
|
+
"transitionend",
|
|
132
|
+
"animationend"
|
|
133
|
+
];
|
|
134
|
+
for (const event of events) {
|
|
135
|
+
document.addEventListener(event, measureInteraction, true);
|
|
136
|
+
}
|
|
137
|
+
document.addEventListener("load", schedule, true);
|
|
138
|
+
document.addEventListener("toggle", schedule, true);
|
|
139
|
+
return () => {
|
|
140
|
+
cancelAnimationFrame(scheduledFrame);
|
|
141
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
|
|
142
|
+
(sheet) => sheet !== measurementStyle
|
|
143
|
+
);
|
|
144
|
+
observer.disconnect();
|
|
145
|
+
mutations.disconnect();
|
|
146
|
+
window.removeEventListener("message", receive);
|
|
147
|
+
document.removeEventListener("load", schedule, true);
|
|
148
|
+
document.removeEventListener("toggle", schedule, true);
|
|
149
|
+
for (const event of events) {
|
|
150
|
+
document.removeEventListener(event, measureInteraction, true);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function PagePreviewHeightResponder() {
|
|
155
|
+
return /* @__PURE__ */ jsx("template", { ref: startResponder });
|
|
156
|
+
}
|
|
157
|
+
export {
|
|
158
|
+
PagePreviewHeightResponder
|
|
159
|
+
};
|