tempo-sdk 0.0.93 → 0.0.99
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/dist/assets/index.js +3 -3
- package/dist/astro/asset-preview-client.js +3 -3
- package/dist/astro.js +2 -2
- package/dist/canvas/astro.js +3 -3
- package/dist/canvas/index.js +36 -7
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +4 -4
- package/dist/canvas/svelte.js +3 -3
- package/dist/canvas/vue.js +3 -3
- package/dist/{chunk-Y7EHQREO.js → chunk-27WT3XUG.js} +2 -2
- package/dist/{chunk-Y7EHQREO.js.map → chunk-27WT3XUG.js.map} +1 -1
- package/dist/{chunk-M7OOVEAR.js → chunk-6HYKKP5N.js} +3 -2
- package/dist/{chunk-M7OOVEAR.js.map → chunk-6HYKKP5N.js.map} +1 -1
- package/dist/{chunk-N5MWY4H6.js → chunk-CYDF4LYJ.js} +2 -2
- package/dist/{chunk-N5MWY4H6.js.map → chunk-CYDF4LYJ.js.map} +1 -1
- package/dist/{chunk-XB6GU4CE.js → chunk-I7VF4ZOV.js} +48 -37
- package/dist/chunk-I7VF4ZOV.js.map +1 -0
- package/dist/{chunk-HNNZM2XM.js → chunk-MIXQVPDH.js} +461 -185
- package/dist/chunk-MIXQVPDH.js.map +1 -0
- package/dist/{chunk-GHNHPVEI.js → chunk-SGTGDLOX.js} +2 -2
- package/dist/{chunk-GHNHPVEI.js.map → chunk-SGTGDLOX.js.map} +1 -1
- package/dist/chunk-T364NBR3.js +1440 -0
- package/dist/chunk-T364NBR3.js.map +1 -0
- package/dist/{chunk-FZVJVL3T.js → chunk-X5DJKVBT.js} +10 -17
- package/dist/chunk-X5DJKVBT.js.map +1 -0
- package/dist/{chunk-CVUNZBRV.js → chunk-ZT7HJ6YU.js} +3 -3
- package/dist/{chunk-3L4RRKC3.js → chunk-ZW26VZHX.js} +42 -3
- package/dist/chunk-ZW26VZHX.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/nextjs/plugin.cjs +1 -1
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +1 -1
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +1 -1
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.js +1 -1
- package/dist/nuxt/runtime/identity.js +1 -1
- package/dist/nuxt.js +1 -1
- package/dist/vue.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3L4RRKC3.js.map +0 -1
- package/dist/chunk-FZVJVL3T.js.map +0 -1
- package/dist/chunk-HNNZM2XM.js.map +0 -1
- package/dist/chunk-LEBVQBDH.js +0 -643
- package/dist/chunk-LEBVQBDH.js.map +0 -1
- package/dist/chunk-XB6GU4CE.js.map +0 -1
- /package/dist/{chunk-CVUNZBRV.js.map → chunk-ZT7HJ6YU.js.map} +0 -0
package/dist/chunk-LEBVQBDH.js
DELETED
|
@@ -1,643 +0,0 @@
|
|
|
1
|
-
// ../../modules/iframe-projection/html/declared-facts.ts
|
|
2
|
-
var SOURCE_ANNOTATED_SELECTOR = "[data-tempo-filepath]";
|
|
3
|
-
function computeDeclaredFacts(targetElement, captureRoot, scopeSelector, portalElements) {
|
|
4
|
-
const observedVersions = {};
|
|
5
|
-
const observedSourceVersions = {};
|
|
6
|
-
const anchorSet = /* @__PURE__ */ new Set();
|
|
7
|
-
const visit = (element) => {
|
|
8
|
-
const filepath = element.getAttribute("data-tempo-filepath");
|
|
9
|
-
if (filepath == null || filepath.length === 0) return;
|
|
10
|
-
const modifiedTsRaw = element.getAttribute("data-tempo-modifiedts");
|
|
11
|
-
if (modifiedTsRaw != null) {
|
|
12
|
-
const modifiedTs = Number(modifiedTsRaw);
|
|
13
|
-
if (!Number.isNaN(modifiedTs)) {
|
|
14
|
-
const existing = observedVersions[filepath];
|
|
15
|
-
if (existing === void 0 || modifiedTs > existing) {
|
|
16
|
-
observedVersions[filepath] = modifiedTs;
|
|
17
|
-
const version = element.getAttribute("data-tempo-source-version");
|
|
18
|
-
if (version != null && version.length > 0) {
|
|
19
|
-
observedSourceVersions[filepath] = version;
|
|
20
|
-
} else {
|
|
21
|
-
delete observedSourceVersions[filepath];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const position = element.getAttribute("data-tempo-position");
|
|
27
|
-
if (position != null && position.length > 0) {
|
|
28
|
-
anchorSet.add(`${filepath} ${position}`);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const walkRoots = [targetElement, ...portalElements];
|
|
32
|
-
for (const root of walkRoots) {
|
|
33
|
-
if (root.matches(SOURCE_ANNOTATED_SELECTOR)) visit(root);
|
|
34
|
-
for (const annotated of root.querySelectorAll(SOURCE_ANNOTATED_SELECTOR)) {
|
|
35
|
-
visit(annotated);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const complete = targetElement === captureRoot;
|
|
39
|
-
return {
|
|
40
|
-
complete,
|
|
41
|
-
scopeSelector: complete ? null : scopeSelector,
|
|
42
|
-
observedVersions,
|
|
43
|
-
observedSourceVersions,
|
|
44
|
-
containedAnchors: Array.from(anchorSet),
|
|
45
|
-
renderError: computeRenderError(captureRoot)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function computeRenderError(captureRoot) {
|
|
49
|
-
const errorElement = captureRoot.matches('[data-render-error="true"]') ? captureRoot : captureRoot.querySelector('[data-render-error="true"]');
|
|
50
|
-
if (!errorElement) return null;
|
|
51
|
-
return {
|
|
52
|
-
message: errorElement.getAttribute("data-render-error-message")
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ../../modules/iframe-projection/shared/capture-perf.ts
|
|
57
|
-
var counters = {
|
|
58
|
-
styleReadCount: 0,
|
|
59
|
-
identityNodesVisited: 0,
|
|
60
|
-
sourceVersionDomScanNodes: 0,
|
|
61
|
-
sourceVersionFiberSerializeNodes: 0,
|
|
62
|
-
sourceVersionFiberReductionNodes: 0,
|
|
63
|
-
sourceVersionFallbackScanNodes: 0
|
|
64
|
-
};
|
|
65
|
-
var producerReferencesByDocument = /* @__PURE__ */ new Map();
|
|
66
|
-
var activeDocumentProducers = 0;
|
|
67
|
-
var activeRootObservers = 0;
|
|
68
|
-
var activeReactCommitSubscriptions = 0;
|
|
69
|
-
function registerDocumentCaptureProducer(document2) {
|
|
70
|
-
const references = producerReferencesByDocument.get(document2) ?? 0;
|
|
71
|
-
if (references === 0) activeDocumentProducers += 1;
|
|
72
|
-
producerReferencesByDocument.set(document2, references + 1);
|
|
73
|
-
activeReactCommitSubscriptions += 1;
|
|
74
|
-
let active = true;
|
|
75
|
-
return () => {
|
|
76
|
-
if (!active) return;
|
|
77
|
-
active = false;
|
|
78
|
-
const current = producerReferencesByDocument.get(document2) ?? 0;
|
|
79
|
-
if (current <= 1) {
|
|
80
|
-
producerReferencesByDocument.delete(document2);
|
|
81
|
-
activeDocumentProducers = Math.max(0, activeDocumentProducers - 1);
|
|
82
|
-
} else {
|
|
83
|
-
producerReferencesByDocument.set(document2, current - 1);
|
|
84
|
-
}
|
|
85
|
-
activeReactCommitSubscriptions = Math.max(
|
|
86
|
-
0,
|
|
87
|
-
activeReactCommitSubscriptions - 1
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function registerCaptureRootObserver() {
|
|
92
|
-
activeRootObservers += 1;
|
|
93
|
-
let active = true;
|
|
94
|
-
return () => {
|
|
95
|
-
if (!active) return;
|
|
96
|
-
active = false;
|
|
97
|
-
activeRootObservers = Math.max(0, activeRootObservers - 1);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function readCaptureProducerCardinality() {
|
|
101
|
-
return {
|
|
102
|
-
activeDocumentProducers,
|
|
103
|
-
activeRootObservers,
|
|
104
|
-
reactCommitSubscriptions: activeReactCommitSubscriptions
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function countCaptureStyleRead() {
|
|
108
|
-
counters.styleReadCount += 1;
|
|
109
|
-
}
|
|
110
|
-
function countIdentityNodeVisited() {
|
|
111
|
-
counters.identityNodesVisited += 1;
|
|
112
|
-
}
|
|
113
|
-
function resetCaptureFlushCounters() {
|
|
114
|
-
counters.styleReadCount = 0;
|
|
115
|
-
counters.identityNodesVisited = 0;
|
|
116
|
-
counters.sourceVersionDomScanNodes = 0;
|
|
117
|
-
counters.sourceVersionFiberSerializeNodes = 0;
|
|
118
|
-
counters.sourceVersionFiberReductionNodes = 0;
|
|
119
|
-
counters.sourceVersionFallbackScanNodes = 0;
|
|
120
|
-
}
|
|
121
|
-
function readCaptureFlushCounters() {
|
|
122
|
-
return { ...counters };
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// ../../modules/iframe-projection/html/displayability.ts
|
|
126
|
-
var IGNORED_CONTENT_TAGS = /* @__PURE__ */ new Set([
|
|
127
|
-
"DATALIST",
|
|
128
|
-
"LINK",
|
|
129
|
-
"META",
|
|
130
|
-
"NOSCRIPT",
|
|
131
|
-
"SCRIPT",
|
|
132
|
-
"STYLE",
|
|
133
|
-
"TEMPLATE"
|
|
134
|
-
]);
|
|
135
|
-
var VISUAL_ASSET_TAGS = /* @__PURE__ */ new Set([
|
|
136
|
-
"AUDIO",
|
|
137
|
-
"CANVAS",
|
|
138
|
-
"EMBED",
|
|
139
|
-
"IFRAME",
|
|
140
|
-
"IMG",
|
|
141
|
-
"INPUT",
|
|
142
|
-
"OBJECT",
|
|
143
|
-
"SELECT",
|
|
144
|
-
"SVG",
|
|
145
|
-
"TEXTAREA",
|
|
146
|
-
"VIDEO"
|
|
147
|
-
]);
|
|
148
|
-
function measureComputedDisplayability(captureRoot, supplementalRoots = []) {
|
|
149
|
-
const doc = captureRoot.ownerDocument;
|
|
150
|
-
const view = doc.defaultView;
|
|
151
|
-
if (!view || !captureRoot.isConnected || supplementalRoots.some(
|
|
152
|
-
(root) => root.ownerDocument !== doc || !root.isConnected
|
|
153
|
-
)) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
const result = {
|
|
157
|
-
version: 1,
|
|
158
|
-
elementCount: 0,
|
|
159
|
-
paintedElementCount: 0,
|
|
160
|
-
nonEmptyTextNodeCount: 0,
|
|
161
|
-
visualAssetCount: 0
|
|
162
|
-
};
|
|
163
|
-
try {
|
|
164
|
-
const rootBlocked = hasBlockingElementInChain(captureRoot, view);
|
|
165
|
-
const rootTextVisible = !rootBlocked && elementHasVisibleComputedVisibility(captureRoot, view);
|
|
166
|
-
for (const child of Array.from(captureRoot.childNodes)) {
|
|
167
|
-
visitNode(child, rootBlocked, rootTextVisible, view, result);
|
|
168
|
-
}
|
|
169
|
-
for (const supplementalRoot of supplementalRoots) {
|
|
170
|
-
visitNode(
|
|
171
|
-
supplementalRoot,
|
|
172
|
-
hasBlockingElementInChain(supplementalRoot.parentElement, view),
|
|
173
|
-
true,
|
|
174
|
-
view,
|
|
175
|
-
result
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
} catch {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
return result;
|
|
182
|
-
}
|
|
183
|
-
function visitNode(node, blockedByAncestor, parentTextVisible, view, result) {
|
|
184
|
-
if (node.nodeType === 3) {
|
|
185
|
-
if (!blockedByAncestor && parentTextVisible && (node.textContent?.trim().length ?? 0) > 0) {
|
|
186
|
-
result.nonEmptyTextNodeCount += 1;
|
|
187
|
-
}
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (node.nodeType !== 1) return;
|
|
191
|
-
const element = node;
|
|
192
|
-
const blocked = blockedByAncestor || elementBlocksSubtree(element, view);
|
|
193
|
-
if (blocked) return;
|
|
194
|
-
const visible = elementHasVisibleComputedVisibility(element, view);
|
|
195
|
-
if (visible) {
|
|
196
|
-
result.elementCount += 1;
|
|
197
|
-
if (elementPaintsOwnPixels(element, view)) {
|
|
198
|
-
result.paintedElementCount = (result.paintedElementCount ?? 0) + 1;
|
|
199
|
-
}
|
|
200
|
-
if (VISUAL_ASSET_TAGS.has(element.tagName)) {
|
|
201
|
-
result.visualAssetCount += 1;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
for (const child of Array.from(element.childNodes)) {
|
|
205
|
-
visitNode(child, false, visible, view, result);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
function elementPaintsOwnPixels(element, view) {
|
|
209
|
-
countCaptureStyleRead();
|
|
210
|
-
const style = view.getComputedStyle(element);
|
|
211
|
-
if (colorCanPaint(style.backgroundColor)) return true;
|
|
212
|
-
if (style.backgroundImage && style.backgroundImage !== "none") return true;
|
|
213
|
-
if (style.boxShadow && style.boxShadow !== "none") return true;
|
|
214
|
-
if (style.outlineStyle !== "none" && parseFloat(style.outlineWidth) > 0 && colorCanPaint(style.outlineColor)) {
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
for (const side of ["Top", "Right", "Bottom", "Left"]) {
|
|
218
|
-
if (style[`border${side}Style`] !== "none" && parseFloat(style[`border${side}Width`]) > 0 && colorCanPaint(style[`border${side}Color`])) {
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
function colorCanPaint(value) {
|
|
225
|
-
const normalized = value.trim().toLowerCase().replace(/ /g, "");
|
|
226
|
-
if (!normalized || normalized === "transparent") return false;
|
|
227
|
-
return !(/^rgba\([^)]*,0(?:\.0+)?\)$/.test(normalized) || /^rgb\([^)]*\/0(?:\.0+)?\)$/.test(normalized));
|
|
228
|
-
}
|
|
229
|
-
function hasBlockingElementInChain(start, view) {
|
|
230
|
-
for (let element = start; element; element = element.parentElement) {
|
|
231
|
-
if (elementBlocksSubtree(element, view)) return true;
|
|
232
|
-
}
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
function elementBlocksSubtree(element, view) {
|
|
236
|
-
if (IGNORED_CONTENT_TAGS.has(element.tagName)) return true;
|
|
237
|
-
if (element.hasAttribute("hidden")) return true;
|
|
238
|
-
if (element.tagName === "DIALOG" && !element.hasAttribute("open")) {
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
241
|
-
if (element.tagName === "INPUT" && element.getAttribute("type")?.trim().toLowerCase() === "hidden") {
|
|
242
|
-
return true;
|
|
243
|
-
}
|
|
244
|
-
countCaptureStyleRead();
|
|
245
|
-
const style = view.getComputedStyle(element);
|
|
246
|
-
const opacity = style.opacity.trim();
|
|
247
|
-
return style.display === "none" || opacity.length > 0 && Number(opacity) <= 0 || style.getPropertyValue("content-visibility") === "hidden";
|
|
248
|
-
}
|
|
249
|
-
function elementHasVisibleComputedVisibility(element, view) {
|
|
250
|
-
countCaptureStyleRead();
|
|
251
|
-
const visibility = view.getComputedStyle(element).visibility;
|
|
252
|
-
return visibility !== "hidden" && visibility !== "collapse";
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// ../../modules/iframe-projection/html/selectors.ts
|
|
256
|
-
function generateSelector(element, root) {
|
|
257
|
-
if (!root) {
|
|
258
|
-
if (element === document.documentElement) return ":root";
|
|
259
|
-
if (element === document.head) return "head";
|
|
260
|
-
if (element === document.body) return "body";
|
|
261
|
-
}
|
|
262
|
-
if (root && element === root) return "";
|
|
263
|
-
const parts = [];
|
|
264
|
-
let current = element;
|
|
265
|
-
const stopAt = root ?? document.documentElement;
|
|
266
|
-
while (current && current !== stopAt) {
|
|
267
|
-
const parent = current.parentElement;
|
|
268
|
-
if (!parent) break;
|
|
269
|
-
const tagName = current.tagName.toLowerCase();
|
|
270
|
-
let index = 1;
|
|
271
|
-
let sibling = current.previousElementSibling;
|
|
272
|
-
while (sibling) {
|
|
273
|
-
if (sibling.tagName === current.tagName) index++;
|
|
274
|
-
sibling = sibling.previousElementSibling;
|
|
275
|
-
}
|
|
276
|
-
let sameTypeSiblings = 0;
|
|
277
|
-
for (const child of parent.children) {
|
|
278
|
-
if (child.tagName === current.tagName) sameTypeSiblings++;
|
|
279
|
-
}
|
|
280
|
-
if (sameTypeSiblings > 1) {
|
|
281
|
-
parts.unshift(`${tagName}:nth-of-type(${index})`);
|
|
282
|
-
} else {
|
|
283
|
-
parts.unshift(tagName);
|
|
284
|
-
}
|
|
285
|
-
current = parent;
|
|
286
|
-
}
|
|
287
|
-
if (parts.length === 0) {
|
|
288
|
-
if (element === document.body) return "body";
|
|
289
|
-
if (element === document.head) return "head";
|
|
290
|
-
return "";
|
|
291
|
-
}
|
|
292
|
-
const path = parts.join(" > ");
|
|
293
|
-
if (root) return `:scope > ${path}`;
|
|
294
|
-
return path;
|
|
295
|
-
}
|
|
296
|
-
function findLowestCommonAncestor(nodes) {
|
|
297
|
-
if (nodes.size === 0) return null;
|
|
298
|
-
const ancestorChains = [];
|
|
299
|
-
for (const node of nodes) {
|
|
300
|
-
const chain = [];
|
|
301
|
-
let current = node instanceof Element ? node : node.parentElement;
|
|
302
|
-
while (current && current !== document) {
|
|
303
|
-
if (current instanceof Element) {
|
|
304
|
-
chain.unshift(current);
|
|
305
|
-
}
|
|
306
|
-
current = current.parentNode;
|
|
307
|
-
}
|
|
308
|
-
if (chain.length > 0) {
|
|
309
|
-
ancestorChains.push(chain);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
if (ancestorChains.length === 0) {
|
|
313
|
-
return document.documentElement;
|
|
314
|
-
}
|
|
315
|
-
let lca = document.documentElement;
|
|
316
|
-
const firstChain = ancestorChains[0];
|
|
317
|
-
const minLength = Math.min(...ancestorChains.map((c) => c.length));
|
|
318
|
-
for (let i = 0; i < minLength; i++) {
|
|
319
|
-
const candidate = firstChain[i];
|
|
320
|
-
if (candidate && ancestorChains.every((chain) => chain[i] === candidate)) {
|
|
321
|
-
lca = candidate;
|
|
322
|
-
} else {
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return lca;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// ../../modules/iframe-projection/html/capture.ts
|
|
330
|
-
function capture(element) {
|
|
331
|
-
return captureWithSupplementalRoots(element, []);
|
|
332
|
-
}
|
|
333
|
-
function captureWithSupplementalRoots(element, supplementalRoots) {
|
|
334
|
-
syncFormStateToAttributes(element);
|
|
335
|
-
const selector = generateSelector(element, element);
|
|
336
|
-
const html = removeScriptTags(element.innerHTML);
|
|
337
|
-
const attributes = captureAttributes(element);
|
|
338
|
-
const documentElementAttributes = element.ownerDocument ? captureAttributes(element.ownerDocument.documentElement) : void 0;
|
|
339
|
-
const bodyAttributes = element.ownerDocument?.body ? captureAttributes(element.ownerDocument.body) : void 0;
|
|
340
|
-
const baseUrl = element.ownerDocument?.baseURI;
|
|
341
|
-
const states = collectElementStates(element);
|
|
342
|
-
const displayability = measureComputedDisplayability(
|
|
343
|
-
element,
|
|
344
|
-
supplementalRoots
|
|
345
|
-
);
|
|
346
|
-
return {
|
|
347
|
-
// Whole-surface one-shot: the element is both the capture root and the
|
|
348
|
-
// serialized scope, so `complete` is true and there is no scope selector.
|
|
349
|
-
declared: computeDeclaredFacts(element, element, "", supplementalRoots),
|
|
350
|
-
...displayability && { displayability },
|
|
351
|
-
dom: {
|
|
352
|
-
selector,
|
|
353
|
-
html,
|
|
354
|
-
attributes,
|
|
355
|
-
documentElementAttributes,
|
|
356
|
-
bodyAttributes
|
|
357
|
-
},
|
|
358
|
-
states,
|
|
359
|
-
baseUrl
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
function syncFormStateToAttributes(root) {
|
|
363
|
-
for (const input of root.querySelectorAll(
|
|
364
|
-
'input[type="checkbox"], input[type="radio"]'
|
|
365
|
-
)) {
|
|
366
|
-
const el = input;
|
|
367
|
-
if (el.checked) {
|
|
368
|
-
el.setAttribute("checked", "");
|
|
369
|
-
} else {
|
|
370
|
-
el.removeAttribute("checked");
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
for (const input of root.querySelectorAll(
|
|
374
|
-
'input:not([type="checkbox"]):not([type="radio"])'
|
|
375
|
-
)) {
|
|
376
|
-
const el = input;
|
|
377
|
-
if (el.value !== el.getAttribute("value")) {
|
|
378
|
-
el.setAttribute("value", el.value);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
for (const textarea of root.querySelectorAll("textarea")) {
|
|
382
|
-
const el = textarea;
|
|
383
|
-
if (el.value !== el.textContent) {
|
|
384
|
-
el.textContent = el.value;
|
|
385
|
-
}
|
|
386
|
-
if (el.hasAttribute("value")) {
|
|
387
|
-
el.removeAttribute("value");
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
for (const select of root.querySelectorAll("select")) {
|
|
391
|
-
const el = select;
|
|
392
|
-
for (const option of el.options) {
|
|
393
|
-
if (option.selected) {
|
|
394
|
-
option.setAttribute("selected", "");
|
|
395
|
-
} else {
|
|
396
|
-
option.removeAttribute("selected");
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
function removeScriptTags(html) {
|
|
402
|
-
return html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "");
|
|
403
|
-
}
|
|
404
|
-
function captureAttributes(element) {
|
|
405
|
-
const attrs = {};
|
|
406
|
-
for (const attr of Array.from(element.attributes)) {
|
|
407
|
-
attrs[attr.name] = attr.value;
|
|
408
|
-
}
|
|
409
|
-
return attrs;
|
|
410
|
-
}
|
|
411
|
-
function collectElementStates(root, options = {}) {
|
|
412
|
-
const { includeDocumentScroll = true } = options;
|
|
413
|
-
const states = [];
|
|
414
|
-
for (const input of root.querySelectorAll("input")) {
|
|
415
|
-
const el = input;
|
|
416
|
-
const isCheckable = el.type === "checkbox" || el.type === "radio";
|
|
417
|
-
const hasNonDefault = isCheckable ? el.checked !== el.defaultChecked : el.value !== el.defaultValue;
|
|
418
|
-
if (hasNonDefault) {
|
|
419
|
-
const selector = generateSelector(el, root);
|
|
420
|
-
if (isCheckable) {
|
|
421
|
-
states.push({ selector, checked: el.checked });
|
|
422
|
-
} else {
|
|
423
|
-
states.push({ selector, value: el.value });
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
for (const textarea of root.querySelectorAll("textarea")) {
|
|
428
|
-
const el = textarea;
|
|
429
|
-
if (el.value !== el.defaultValue) {
|
|
430
|
-
const selector = generateSelector(el, root);
|
|
431
|
-
states.push({ selector, value: el.value });
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
for (const select of root.querySelectorAll("select")) {
|
|
435
|
-
const el = select;
|
|
436
|
-
for (const option of el.options) {
|
|
437
|
-
if (option.selected !== option.defaultSelected) {
|
|
438
|
-
const selector = generateSelector(option, root);
|
|
439
|
-
states.push({ selector, selected: option.selected });
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
states.push({
|
|
444
|
-
selector: "",
|
|
445
|
-
scrollTop: root.scrollTop,
|
|
446
|
-
scrollLeft: root.scrollLeft
|
|
447
|
-
});
|
|
448
|
-
if (includeDocumentScroll) {
|
|
449
|
-
const scrollingEl = root.ownerDocument?.scrollingElement;
|
|
450
|
-
if (scrollingEl && scrollingEl !== root) {
|
|
451
|
-
states.push({
|
|
452
|
-
selector: ":root",
|
|
453
|
-
scrollTop: scrollingEl.scrollTop,
|
|
454
|
-
scrollLeft: scrollingEl.scrollLeft
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
for (const el of root.querySelectorAll("*")) {
|
|
459
|
-
if (el.scrollTop > 0 || el.scrollLeft > 0) {
|
|
460
|
-
const selector = generateSelector(el, root);
|
|
461
|
-
states.push({
|
|
462
|
-
selector,
|
|
463
|
-
scrollTop: el.scrollTop,
|
|
464
|
-
scrollLeft: el.scrollLeft
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return states;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// ../../modules/iframe-projection/html/runtime-mutations-runtime.js
|
|
472
|
-
function installRuntimeMutations(scope) {
|
|
473
|
-
const doc = scope.document;
|
|
474
|
-
const undo = [];
|
|
475
|
-
let active = true;
|
|
476
|
-
const emit = (target, kind, detail) => {
|
|
477
|
-
if (active)
|
|
478
|
-
target.dispatchEvent(
|
|
479
|
-
detail ? new scope.CustomEvent(kind, { bubbles: true, detail }) : new scope.Event(kind, { bubbles: true })
|
|
480
|
-
);
|
|
481
|
-
};
|
|
482
|
-
const form = (target) => {
|
|
483
|
-
if (target instanceof scope.HTMLOptionElement)
|
|
484
|
-
target = target.closest("select");
|
|
485
|
-
if (target && target.isConnected)
|
|
486
|
-
emit(target, "tempo:form-runtime-mutation");
|
|
487
|
-
};
|
|
488
|
-
const css = (target, mutable = false) => {
|
|
489
|
-
const sheet = target instanceof scope.CSSStyleSheet ? target : target.parentStyleSheet;
|
|
490
|
-
if (target === doc || sheet && (sheet.ownerNode?.isConnected || doc.adoptedStyleSheets.includes(sheet)))
|
|
491
|
-
emit(doc, "tempo:css-runtime-mutation", {
|
|
492
|
-
ownerNode: sheet?.ownerNode ?? null,
|
|
493
|
-
sheet: sheet ?? null,
|
|
494
|
-
mutable
|
|
495
|
-
});
|
|
496
|
-
};
|
|
497
|
-
const setter = (proto, key, changed) => {
|
|
498
|
-
if (!proto) return;
|
|
499
|
-
const original = Object.getOwnPropertyDescriptor(proto, key);
|
|
500
|
-
if (!original?.set || !original.configurable) return;
|
|
501
|
-
const set = function(value) {
|
|
502
|
-
const before = original.get?.call(this);
|
|
503
|
-
original.set.call(this, value);
|
|
504
|
-
if (key === "adoptedStyleSheets" || before !== original.get?.call(this))
|
|
505
|
-
changed(this);
|
|
506
|
-
};
|
|
507
|
-
Object.defineProperty(proto, key, { ...original, set });
|
|
508
|
-
undo.push(() => {
|
|
509
|
-
if (Object.getOwnPropertyDescriptor(proto, key)?.set === set)
|
|
510
|
-
Object.defineProperty(proto, key, original);
|
|
511
|
-
});
|
|
512
|
-
};
|
|
513
|
-
const method = (proto, key, changed) => {
|
|
514
|
-
if (!proto) return;
|
|
515
|
-
const original = Object.getOwnPropertyDescriptor(proto, key);
|
|
516
|
-
if (typeof original?.value !== "function" || !original.configurable) return;
|
|
517
|
-
const value = function(...args) {
|
|
518
|
-
const result = original.value.apply(this, args);
|
|
519
|
-
if (result instanceof scope.Promise)
|
|
520
|
-
result.then(
|
|
521
|
-
() => changed(this),
|
|
522
|
-
() => {
|
|
523
|
-
}
|
|
524
|
-
);
|
|
525
|
-
else changed(this);
|
|
526
|
-
return result;
|
|
527
|
-
};
|
|
528
|
-
Object.defineProperty(proto, key, { ...original, value });
|
|
529
|
-
undo.push(() => {
|
|
530
|
-
if (Object.getOwnPropertyDescriptor(proto, key)?.value === value)
|
|
531
|
-
Object.defineProperty(proto, key, original);
|
|
532
|
-
});
|
|
533
|
-
};
|
|
534
|
-
for (const [type, keys] of [
|
|
535
|
-
["HTMLInputElement", ["value", "checked", "valueAsNumber", "valueAsDate"]],
|
|
536
|
-
["HTMLTextAreaElement", ["value"]],
|
|
537
|
-
["HTMLSelectElement", ["value", "selectedIndex"]],
|
|
538
|
-
["HTMLOptionElement", ["selected"]]
|
|
539
|
-
])
|
|
540
|
-
for (const key of keys) setter(scope[type]?.prototype, key, form);
|
|
541
|
-
for (const type of ["HTMLInputElement", "HTMLTextAreaElement"])
|
|
542
|
-
method(scope[type]?.prototype, "setRangeText", form);
|
|
543
|
-
for (const key of ["stepUp", "stepDown"])
|
|
544
|
-
method(scope.HTMLInputElement?.prototype, key, form);
|
|
545
|
-
for (const key of [
|
|
546
|
-
"insertRule",
|
|
547
|
-
"deleteRule",
|
|
548
|
-
"addRule",
|
|
549
|
-
"removeRule",
|
|
550
|
-
"replace",
|
|
551
|
-
"replaceSync"
|
|
552
|
-
])
|
|
553
|
-
method(scope.CSSStyleSheet?.prototype, key, css);
|
|
554
|
-
for (const key of ["insertRule", "deleteRule"])
|
|
555
|
-
method(scope.CSSGroupingRule?.prototype, key, css);
|
|
556
|
-
const declarations = scope.CSSStyleDeclaration?.prototype;
|
|
557
|
-
setter(declarations, "cssText", (target) => {
|
|
558
|
-
if (target.parentRule) css(target.parentRule);
|
|
559
|
-
});
|
|
560
|
-
for (const key of ["setProperty", "removeProperty"])
|
|
561
|
-
method(declarations, key, (target) => {
|
|
562
|
-
if (target.parentRule) css(target.parentRule);
|
|
563
|
-
});
|
|
564
|
-
for (const proto of [
|
|
565
|
-
scope.CSSStyleRule?.prototype,
|
|
566
|
-
scope.CSSKeyframeRule?.prototype
|
|
567
|
-
]) {
|
|
568
|
-
const original = proto && Object.getOwnPropertyDescriptor(proto, "style");
|
|
569
|
-
if (!original?.get || !original.configurable) continue;
|
|
570
|
-
const get = function() {
|
|
571
|
-
css(this, true);
|
|
572
|
-
return original.get.call(this);
|
|
573
|
-
};
|
|
574
|
-
Object.defineProperty(proto, "style", { ...original, get });
|
|
575
|
-
undo.push(() => {
|
|
576
|
-
if (Object.getOwnPropertyDescriptor(proto, "style")?.get === get)
|
|
577
|
-
Object.defineProperty(proto, "style", original);
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
setter(scope.CSSStyleRule?.prototype, "selectorText", css);
|
|
581
|
-
setter(scope.CSSKeyframeRule?.prototype, "keyText", css);
|
|
582
|
-
for (const key of ["appendRule", "deleteRule"])
|
|
583
|
-
method(scope.CSSKeyframesRule?.prototype, key, css);
|
|
584
|
-
setter(scope.MediaList?.prototype, "mediaText", () => css(doc));
|
|
585
|
-
for (const key of ["appendMedium", "deleteMedium"])
|
|
586
|
-
method(scope.MediaList?.prototype, key, () => css(doc));
|
|
587
|
-
setter(scope.Document?.prototype, "adoptedStyleSheets", css);
|
|
588
|
-
setter(scope.StyleSheet?.prototype, "disabled", css);
|
|
589
|
-
method(scope.HTMLFormElement?.prototype, "reset", (target) => {
|
|
590
|
-
for (const element of target.elements) form(element);
|
|
591
|
-
});
|
|
592
|
-
const dispose = () => {
|
|
593
|
-
if (!active) return;
|
|
594
|
-
active = false;
|
|
595
|
-
for (const restore of undo.reverse()) restore();
|
|
596
|
-
};
|
|
597
|
-
return dispose;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// ../../modules/iframe-projection/html/runtime-mutations.ts
|
|
601
|
-
var FORM_RUNTIME_MUTATION = "tempo:form-runtime-mutation";
|
|
602
|
-
var CSS_RUNTIME_MUTATION = "tempo:css-runtime-mutation";
|
|
603
|
-
var owners = /* @__PURE__ */ new WeakMap();
|
|
604
|
-
function observeRuntimeMutations(doc) {
|
|
605
|
-
if (!doc.defaultView) return () => {
|
|
606
|
-
};
|
|
607
|
-
let owner = owners.get(doc);
|
|
608
|
-
if (!owner) {
|
|
609
|
-
owner = { count: 0, stop: installRuntimeMutations(doc.defaultView) };
|
|
610
|
-
owners.set(doc, owner);
|
|
611
|
-
}
|
|
612
|
-
owner.count++;
|
|
613
|
-
let released = false;
|
|
614
|
-
return () => {
|
|
615
|
-
if (released) return;
|
|
616
|
-
released = true;
|
|
617
|
-
if (--owner.count === 0) {
|
|
618
|
-
owner.stop();
|
|
619
|
-
owners.delete(doc);
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
export {
|
|
625
|
-
FORM_RUNTIME_MUTATION,
|
|
626
|
-
CSS_RUNTIME_MUTATION,
|
|
627
|
-
observeRuntimeMutations,
|
|
628
|
-
generateSelector,
|
|
629
|
-
findLowestCommonAncestor,
|
|
630
|
-
registerDocumentCaptureProducer,
|
|
631
|
-
registerCaptureRootObserver,
|
|
632
|
-
readCaptureProducerCardinality,
|
|
633
|
-
countCaptureStyleRead,
|
|
634
|
-
countIdentityNodeVisited,
|
|
635
|
-
resetCaptureFlushCounters,
|
|
636
|
-
readCaptureFlushCounters,
|
|
637
|
-
capture,
|
|
638
|
-
captureWithSupplementalRoots,
|
|
639
|
-
removeScriptTags,
|
|
640
|
-
captureAttributes,
|
|
641
|
-
collectElementStates
|
|
642
|
-
};
|
|
643
|
-
//# sourceMappingURL=chunk-LEBVQBDH.js.map
|