tempo-sdk 0.0.94 → 0.0.101
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/README.md +3 -403
- package/dist/assets/editor.d.ts +43 -65
- package/dist/assets/editor.js +1 -573
- package/dist/assets/index.d.ts +11 -61
- package/dist/assets/index.js +1 -338
- package/dist/assets/parser.d.ts +68 -78
- package/dist/assets/parser.js +1 -33
- package/dist/astro/asset-preview-client.d.ts +3 -2
- package/dist/astro/asset-preview-client.js +1 -93
- package/dist/astro/controls.d.ts +1 -3
- package/dist/astro/controls.js +1 -7
- package/dist/astro/document-client.d.ts +5 -6
- package/dist/astro/document-client.js +1 -78
- package/dist/astro/runtime.d.ts +23 -11
- package/dist/astro/runtime.js +1 -86
- package/dist/astro.d.ts +19 -13
- package/dist/astro.js +1 -818
- package/dist/canvas/astro-contract.d.ts +0 -3
- package/dist/canvas/astro-contract.js +1 -9
- package/dist/canvas/astro.d.ts +3 -4
- package/dist/canvas/astro.js +1 -42
- package/dist/canvas/editor.d.ts +187 -183
- package/dist/canvas/editor.js +1 -1094
- package/dist/canvas/flutter-preview.d.ts +0 -1
- package/dist/canvas/flutter-preview.js +1 -9
- package/dist/canvas/index.d.ts +46 -100
- package/dist/canvas/index.js +1 -3897
- package/dist/canvas/interact-projection.d.ts +7 -5
- package/dist/canvas/interact-projection.js +1 -12
- package/dist/canvas/parser.d.ts +10 -303
- package/dist/canvas/parser.js +1 -30
- package/dist/canvas/svelte.d.ts +6 -7
- package/dist/canvas/svelte.js +1 -91
- package/dist/canvas/vue.d.ts +9 -49
- package/dist/canvas/vue.js +1 -264
- package/dist/chunk-FH6TMWFA.js +1 -0
- package/dist/chunk-GQIOB5SV.js +1 -0
- package/dist/chunk-HBQ7FFH7.js +1 -0
- package/dist/chunk-JRJOWLCN.js +1 -0
- package/dist/chunk-M3GN2KUH.js +1 -0
- package/dist/chunk-MPIHFFML.js +1 -0
- package/dist/chunk-N2V6XXRK.js +1 -0
- package/dist/chunk-QNVQ7U2W.js +1 -0
- package/dist/chunk-T5TY3U2H.js +1 -0
- package/dist/chunk-TK37FQAR.js +1 -0
- package/dist/chunk-XO2BSHWM.js +1 -0
- package/dist/chunk-XUSV3KOD.js +1 -0
- package/dist/chunk-YRBEBVG4.js +1 -0
- package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
- package/dist/expo/plugin.cjs +1 -1928
- package/dist/expo/plugin.js +1 -8
- package/dist/expo-babel-plugin.cjs +1 -1928
- package/dist/expo-babel-plugin.d.cts +46 -40
- package/dist/expo-babel-plugin.d.ts +46 -40
- package/dist/expo-babel-plugin.js +1 -8
- package/dist/flutter-preview-path.d.ts +23 -7
- package/dist/flutter-preview-path.js +1 -16
- package/dist/index.d.ts +33 -45
- package/dist/index.js +1 -20
- package/dist/nextjs/plugin.cjs +1 -413
- package/dist/nextjs/plugin.js +1 -7
- package/dist/nextjs-loader.cjs +1 -2277
- package/dist/nextjs.cjs +1 -484
- package/dist/nextjs.d.cts +2 -58
- package/dist/nextjs.d.ts +2 -58
- package/dist/nextjs.js +1 -17
- package/dist/nuxt/runtime/identity.d.ts +2 -4
- package/dist/nuxt/runtime/identity.js +1 -18
- package/dist/nuxt.d.ts +31 -92
- package/dist/nuxt.js +1 -5854
- package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
- package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
- package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
- package/dist/svelte.d.ts +8 -18
- package/dist/svelte.js +1 -917
- package/dist/types-CfUgM2w4.d.ts +57 -0
- package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
- package/dist/vue.d.ts +17 -58
- package/dist/vue.js +1 -1501
- package/package.json +12 -62
- package/dist/assets/editor.js.map +0 -1
- package/dist/assets/index.js.map +0 -1
- package/dist/assets/parser.js.map +0 -1
- package/dist/astro/asset-preview-client.js.map +0 -1
- package/dist/astro/controls.js.map +0 -1
- package/dist/astro/document-client.js.map +0 -1
- package/dist/astro/runtime.js.map +0 -1
- package/dist/astro.js.map +0 -1
- package/dist/canvas/astro-contract.js.map +0 -1
- package/dist/canvas/astro.js.map +0 -1
- package/dist/canvas/editor.js.map +0 -1
- package/dist/canvas/flutter-preview.js.map +0 -1
- package/dist/canvas/index.js.map +0 -1
- package/dist/canvas/interact-projection.js.map +0 -1
- package/dist/canvas/parser.js.map +0 -1
- package/dist/canvas/svelte.js.map +0 -1
- package/dist/canvas/vue.js.map +0 -1
- package/dist/chunk-3W6B75UK.js +0 -455
- package/dist/chunk-3W6B75UK.js.map +0 -1
- package/dist/chunk-5HIIF354.js +0 -67
- package/dist/chunk-5HIIF354.js.map +0 -1
- package/dist/chunk-65B52AR7.js +0 -11
- package/dist/chunk-65B52AR7.js.map +0 -1
- package/dist/chunk-6QGMLNO3.js +0 -8337
- package/dist/chunk-6QGMLNO3.js.map +0 -1
- package/dist/chunk-6SOP4XU6.js +0 -1891
- package/dist/chunk-6SOP4XU6.js.map +0 -1
- package/dist/chunk-AFXE462X.js +0 -1253
- package/dist/chunk-AFXE462X.js.map +0 -1
- package/dist/chunk-BQPKOVI5.js +0 -115
- package/dist/chunk-BQPKOVI5.js.map +0 -1
- package/dist/chunk-CYQE3TLC.js +0 -37
- package/dist/chunk-CYQE3TLC.js.map +0 -1
- package/dist/chunk-DI2ZFAWL.js +0 -14
- package/dist/chunk-DI2ZFAWL.js.map +0 -1
- package/dist/chunk-EGRHWZRV.js +0 -1
- package/dist/chunk-EGRHWZRV.js.map +0 -1
- package/dist/chunk-FGWGY3G3.js +0 -157
- package/dist/chunk-FGWGY3G3.js.map +0 -1
- package/dist/chunk-HOBTDB6G.js +0 -112
- package/dist/chunk-HOBTDB6G.js.map +0 -1
- package/dist/chunk-JVVHU3A7.js +0 -1077
- package/dist/chunk-JVVHU3A7.js.map +0 -1
- package/dist/chunk-KY52JZZL.js +0 -3130
- package/dist/chunk-KY52JZZL.js.map +0 -1
- package/dist/chunk-LEW24RRZ.js +0 -1315
- package/dist/chunk-LEW24RRZ.js.map +0 -1
- package/dist/chunk-MU7S7NU7.js +0 -183
- package/dist/chunk-MU7S7NU7.js.map +0 -1
- package/dist/chunk-OX2YKYSL.js +0 -13
- package/dist/chunk-OX2YKYSL.js.map +0 -1
- package/dist/chunk-OYNR6D7K.js +0 -342
- package/dist/chunk-OYNR6D7K.js.map +0 -1
- package/dist/chunk-PYAJHLXO.js +0 -903
- package/dist/chunk-PYAJHLXO.js.map +0 -1
- package/dist/chunk-REYOX4JT.js +0 -285
- package/dist/chunk-REYOX4JT.js.map +0 -1
- package/dist/chunk-SGN7BDRE.js +0 -16
- package/dist/chunk-SGN7BDRE.js.map +0 -1
- package/dist/chunk-T364NBR3.js +0 -1440
- package/dist/chunk-T364NBR3.js.map +0 -1
- package/dist/chunk-U66QI3EN.js +0 -1524
- package/dist/chunk-U66QI3EN.js.map +0 -1
- package/dist/chunk-VRNJI4Y6.js +0 -2657
- package/dist/chunk-VRNJI4Y6.js.map +0 -1
- package/dist/chunk-WRILG6GR.js +0 -38
- package/dist/chunk-WRILG6GR.js.map +0 -1
- package/dist/chunk-WTXOWQ7N.js +0 -47
- package/dist/chunk-WTXOWQ7N.js.map +0 -1
- package/dist/chunk-YHGUAOBM.js +0 -621
- package/dist/chunk-YHGUAOBM.js.map +0 -1
- package/dist/controls-reader-5MFHYBZZ.js +0 -192
- package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
- package/dist/expo/plugin.cjs.map +0 -1
- package/dist/expo/plugin.js.map +0 -1
- package/dist/expo-babel-plugin.cjs.map +0 -1
- package/dist/expo-babel-plugin.js.map +0 -1
- package/dist/flutter-preview-path.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/nextjs/plugin.cjs.map +0 -1
- package/dist/nextjs/plugin.js.map +0 -1
- package/dist/nextjs-loader.cjs.map +0 -1
- package/dist/nextjs.cjs.map +0 -1
- package/dist/nextjs.js.map +0 -1
- package/dist/nuxt/runtime/identity.js.map +0 -1
- package/dist/nuxt.js.map +0 -1
- package/dist/svelte.js.map +0 -1
- package/dist/types-C8OIU-kc.d.ts +0 -106
- package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
- package/dist/vue.js.map +0 -1
package/dist/chunk-KY52JZZL.js
DELETED
|
@@ -1,3130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FORM_RUNTIME_MUTATION,
|
|
3
|
-
findLowestCommonAncestor,
|
|
4
|
-
generateSelector,
|
|
5
|
-
observeRuntimeMutations,
|
|
6
|
-
removeScriptTags
|
|
7
|
-
} from "./chunk-T364NBR3.js";
|
|
8
|
-
|
|
9
|
-
// ../../modules/iframe-projection/fiber/react-types.ts
|
|
10
|
-
var FiberTag = {
|
|
11
|
-
/** Function component: `function MyComponent(props) { ... }` */
|
|
12
|
-
FunctionComponent: 0,
|
|
13
|
-
/** Class component: `class MyComponent extends React.Component` */
|
|
14
|
-
ClassComponent: 1,
|
|
15
|
-
/**
|
|
16
|
-
* Component not yet determined to be function or class.
|
|
17
|
-
* React resolves this on first render, then updates the tag.
|
|
18
|
-
*/
|
|
19
|
-
IndeterminateComponent: 2,
|
|
20
|
-
/** Root of a React tree (created by createRoot/render) */
|
|
21
|
-
HostRoot: 3,
|
|
22
|
-
/** React Portal: renders children into a different DOM container */
|
|
23
|
-
HostPortal: 4,
|
|
24
|
-
/** DOM element: div, span, button, etc. */
|
|
25
|
-
HostComponent: 5,
|
|
26
|
-
/** Text node: string/number children */
|
|
27
|
-
HostText: 6,
|
|
28
|
-
/** React.Fragment or <>...</> */
|
|
29
|
-
Fragment: 7,
|
|
30
|
-
/** StrictMode, ConcurrentMode, etc. */
|
|
31
|
-
Mode: 8,
|
|
32
|
-
/** Context.Consumer (legacy pattern) */
|
|
33
|
-
ContextConsumer: 9,
|
|
34
|
-
/** Context.Provider */
|
|
35
|
-
ContextProvider: 10,
|
|
36
|
-
/** React.forwardRef wrapper */
|
|
37
|
-
ForwardRef: 11,
|
|
38
|
-
/** React.Profiler for performance measurements */
|
|
39
|
-
Profiler: 12,
|
|
40
|
-
/** React.Suspense boundary */
|
|
41
|
-
SuspenseComponent: 13,
|
|
42
|
-
/** React.memo() wrapper */
|
|
43
|
-
MemoComponent: 14,
|
|
44
|
-
/** Simplified memo (internal optimization) */
|
|
45
|
-
SimpleMemoComponent: 15,
|
|
46
|
-
/** React.lazy() wrapper for code splitting */
|
|
47
|
-
LazyComponent: 16,
|
|
48
|
-
/** Incomplete class component (errored during render) */
|
|
49
|
-
IncompleteClassComponent: 17,
|
|
50
|
-
/** Dehydrated Suspense boundary (server-rendered) */
|
|
51
|
-
DehydratedFragment: 18,
|
|
52
|
-
/** SuspenseList for coordinating reveal order */
|
|
53
|
-
SuspenseListComponent: 19,
|
|
54
|
-
/** Scope component (experimental) */
|
|
55
|
-
ScopeComponent: 21,
|
|
56
|
-
/** Offscreen component (experimental, powers Activity) */
|
|
57
|
-
OffscreenComponent: 22,
|
|
58
|
-
/** Legacy hidden component (deprecated) */
|
|
59
|
-
LegacyHiddenComponent: 23,
|
|
60
|
-
/** Cache component (experimental) */
|
|
61
|
-
CacheComponent: 24,
|
|
62
|
-
/** Tracing marker (experimental) */
|
|
63
|
-
TracingMarkerComponent: 25,
|
|
64
|
-
/** Hoistable elements like <title>, <meta> (React 18.3+) */
|
|
65
|
-
HostHoistable: 26,
|
|
66
|
-
/** Singleton elements like <html>, <head>, <body> (React 18.3+) */
|
|
67
|
-
HostSingleton: 27
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// ../../modules/iframe-projection/fiber/serialize.ts
|
|
71
|
-
function getDisplayName(fiber) {
|
|
72
|
-
const { type, tag } = fiber;
|
|
73
|
-
if (typeof type === "string") {
|
|
74
|
-
return type;
|
|
75
|
-
}
|
|
76
|
-
if (tag === FiberTag.HostText) {
|
|
77
|
-
return "#text";
|
|
78
|
-
}
|
|
79
|
-
const componentName = getComponentDisplayName(type, /* @__PURE__ */ new Set());
|
|
80
|
-
if (componentName) return componentName;
|
|
81
|
-
if (typeof type === "function") return "Anonymous";
|
|
82
|
-
const tagNames = {
|
|
83
|
-
[FiberTag.HostRoot]: "HostRoot",
|
|
84
|
-
[FiberTag.Fragment]: "Fragment",
|
|
85
|
-
[FiberTag.Mode]: "Mode",
|
|
86
|
-
[FiberTag.ContextConsumer]: "Context.Consumer",
|
|
87
|
-
[FiberTag.ContextProvider]: "Context.Provider",
|
|
88
|
-
[FiberTag.Profiler]: "Profiler",
|
|
89
|
-
[FiberTag.SuspenseComponent]: "Suspense",
|
|
90
|
-
[FiberTag.SuspenseListComponent]: "SuspenseList",
|
|
91
|
-
[FiberTag.OffscreenComponent]: "Offscreen"
|
|
92
|
-
};
|
|
93
|
-
return tagNames[tag] || `Unknown(${tag})`;
|
|
94
|
-
}
|
|
95
|
-
function getComponentDisplayName(type, seen) {
|
|
96
|
-
if (typeof type === "function") {
|
|
97
|
-
return type.displayName || type.name || null;
|
|
98
|
-
}
|
|
99
|
-
if (!type || typeof type !== "object" || seen.has(type)) return null;
|
|
100
|
-
seen.add(type);
|
|
101
|
-
if ("displayName" in type && typeof type.displayName === "string" && type.displayName) {
|
|
102
|
-
return type.displayName;
|
|
103
|
-
}
|
|
104
|
-
if ("type" in type && type.type) {
|
|
105
|
-
return getComponentDisplayName(type.type, seen) || "Memo";
|
|
106
|
-
}
|
|
107
|
-
if ("render" in type && type.render) {
|
|
108
|
-
return getComponentDisplayName(type.render, seen) || "ForwardRef";
|
|
109
|
-
}
|
|
110
|
-
if ("_context" in type) {
|
|
111
|
-
const ctx = type._context;
|
|
112
|
-
return ctx.displayName ? `${ctx.displayName}.Provider` : "Context.Provider";
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
function getTag(fiber) {
|
|
117
|
-
return fiber.tag;
|
|
118
|
-
}
|
|
119
|
-
function getProps(fiber) {
|
|
120
|
-
return fiber.memoizedProps;
|
|
121
|
-
}
|
|
122
|
-
function sanitizeProps(props) {
|
|
123
|
-
if (!props) return void 0;
|
|
124
|
-
const result = {};
|
|
125
|
-
let hasProps = false;
|
|
126
|
-
for (const [key, value] of Object.entries(props)) {
|
|
127
|
-
if (key === "children") continue;
|
|
128
|
-
hasProps = true;
|
|
129
|
-
result[key] = sanitizeValue(value);
|
|
130
|
-
}
|
|
131
|
-
return hasProps ? result : void 0;
|
|
132
|
-
}
|
|
133
|
-
function sanitizeValue(value) {
|
|
134
|
-
if (value === null || value === void 0) {
|
|
135
|
-
return value;
|
|
136
|
-
}
|
|
137
|
-
if (typeof value === "function") {
|
|
138
|
-
return "[Function]";
|
|
139
|
-
}
|
|
140
|
-
if (typeof value === "symbol") {
|
|
141
|
-
return `[Symbol:${value.description ?? ""}]`;
|
|
142
|
-
}
|
|
143
|
-
if (value instanceof Element) {
|
|
144
|
-
return `[Element:${value.tagName.toLowerCase()}${value.id ? `#${value.id}` : ""}]`;
|
|
145
|
-
}
|
|
146
|
-
if (value instanceof Node) {
|
|
147
|
-
return `[Node:${value.nodeName}]`;
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(value)) {
|
|
150
|
-
if (value.length <= 10) {
|
|
151
|
-
return value.map(sanitizeValue);
|
|
152
|
-
}
|
|
153
|
-
return `[Array(${value.length})]`;
|
|
154
|
-
}
|
|
155
|
-
if (typeof value === "object") {
|
|
156
|
-
if ("$$typeof" in value) {
|
|
157
|
-
return "[ReactElement]";
|
|
158
|
-
}
|
|
159
|
-
try {
|
|
160
|
-
return JSON.parse(JSON.stringify(value));
|
|
161
|
-
} catch {
|
|
162
|
-
return "[Object]";
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return value;
|
|
166
|
-
}
|
|
167
|
-
function getDomElement(fiber) {
|
|
168
|
-
if (fiber.tag !== FiberTag.HostComponent) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
return fiber.stateNode instanceof Element ? fiber.stateNode : null;
|
|
172
|
-
}
|
|
173
|
-
function* iterateChildren(fiber) {
|
|
174
|
-
let child = fiber.child;
|
|
175
|
-
while (child) {
|
|
176
|
-
yield child;
|
|
177
|
-
child = child.sibling;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
function resolveCommittedFiber(fiber) {
|
|
181
|
-
const alternate = fiber.alternate;
|
|
182
|
-
if (!alternate) {
|
|
183
|
-
return fiber;
|
|
184
|
-
}
|
|
185
|
-
let a = fiber;
|
|
186
|
-
let b = alternate;
|
|
187
|
-
for (; ; ) {
|
|
188
|
-
const parentA = a.return;
|
|
189
|
-
if (!parentA) break;
|
|
190
|
-
const parentB = parentA.alternate;
|
|
191
|
-
if (!parentB) {
|
|
192
|
-
const nextParent = parentA.return;
|
|
193
|
-
if (nextParent) {
|
|
194
|
-
a = nextParent;
|
|
195
|
-
b = nextParent;
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
if (parentA.child === parentB.child) {
|
|
201
|
-
for (let child = parentA.child; child; child = child.sibling) {
|
|
202
|
-
if (child === a) return fiber;
|
|
203
|
-
if (child === b) return alternate;
|
|
204
|
-
}
|
|
205
|
-
throw new Error("Unable to resolve a mounted React fiber");
|
|
206
|
-
}
|
|
207
|
-
if (a.return !== b.return) {
|
|
208
|
-
a = parentA;
|
|
209
|
-
b = parentB;
|
|
210
|
-
} else {
|
|
211
|
-
let found = false;
|
|
212
|
-
for (let child = parentA.child; child; child = child.sibling) {
|
|
213
|
-
if (child === a) {
|
|
214
|
-
found = true;
|
|
215
|
-
a = parentA;
|
|
216
|
-
b = parentB;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
if (child === b) {
|
|
220
|
-
found = true;
|
|
221
|
-
a = parentB;
|
|
222
|
-
b = parentA;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (!found) {
|
|
227
|
-
for (let child = parentB.child; child; child = child.sibling) {
|
|
228
|
-
if (child === a) {
|
|
229
|
-
found = true;
|
|
230
|
-
a = parentB;
|
|
231
|
-
b = parentA;
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
if (child === b) {
|
|
235
|
-
found = true;
|
|
236
|
-
a = parentA;
|
|
237
|
-
b = parentB;
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (!found) {
|
|
243
|
-
throw new Error("React fiber is absent from both parent generations");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (a.alternate !== b) {
|
|
247
|
-
throw new Error("React return fibers are not paired alternates");
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (a.tag !== FiberTag.HostRoot) {
|
|
251
|
-
throw new Error("Unable to resolve an unmounted React fiber");
|
|
252
|
-
}
|
|
253
|
-
const fiberRoot = a.stateNode;
|
|
254
|
-
return fiberRoot?.current === a ? fiber : alternate;
|
|
255
|
-
}
|
|
256
|
-
var TRANSIENT_FIBER_RESOLUTION_ERRORS = /* @__PURE__ */ new Set([
|
|
257
|
-
"Unable to resolve a mounted React fiber",
|
|
258
|
-
"React fiber is absent from both parent generations",
|
|
259
|
-
"React return fibers are not paired alternates",
|
|
260
|
-
"Unable to resolve an unmounted React fiber"
|
|
261
|
-
]);
|
|
262
|
-
function isTransientFiberResolutionError(error) {
|
|
263
|
-
return error instanceof Error && TRANSIENT_FIBER_RESOLUTION_ERRORS.has(error.message);
|
|
264
|
-
}
|
|
265
|
-
var defaultSerialize = (fiber) => ({
|
|
266
|
-
name: getDisplayName(fiber),
|
|
267
|
-
tag: getTag(fiber)
|
|
268
|
-
});
|
|
269
|
-
function serializeTree(fiber, serialize, options = {}) {
|
|
270
|
-
const { maxDepth = Infinity, skipText = true } = options;
|
|
271
|
-
function serializeNode(f, depth) {
|
|
272
|
-
if (depth > maxDepth) return null;
|
|
273
|
-
if (skipText && f.tag === FiberTag.HostText) {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
const nodeData = serialize(f);
|
|
277
|
-
const children = [];
|
|
278
|
-
for (const child of iterateChildren(f)) {
|
|
279
|
-
const serialized = serializeNode(child, depth + 1);
|
|
280
|
-
if (serialized) {
|
|
281
|
-
children.push(serialized);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return { ...nodeData, children };
|
|
285
|
-
}
|
|
286
|
-
return serializeNode(fiber, 0);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// ../../modules/iframe-projection/fiber/capture.ts
|
|
290
|
-
function findFiberKey(element) {
|
|
291
|
-
return Object.keys(element).find(
|
|
292
|
-
(k) => k.startsWith("__reactFiber$") || k.startsWith("__reactInternalInstance$")
|
|
293
|
-
) ?? null;
|
|
294
|
-
}
|
|
295
|
-
function findContainerKey(element) {
|
|
296
|
-
return Object.keys(element).find((k) => k.startsWith("__reactContainer$")) ?? null;
|
|
297
|
-
}
|
|
298
|
-
function getFiberFromElement(element) {
|
|
299
|
-
const fiberKey = findFiberKey(element);
|
|
300
|
-
if (fiberKey) {
|
|
301
|
-
return element[fiberKey] ?? null;
|
|
302
|
-
}
|
|
303
|
-
const containerKey = findContainerKey(element);
|
|
304
|
-
if (containerKey) {
|
|
305
|
-
return element[containerKey] ?? null;
|
|
306
|
-
}
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// ../../modules/iframe-projection/fiber/utils.ts
|
|
311
|
-
function filterTreeInclude(tree, includeTags) {
|
|
312
|
-
if (tree === null) return null;
|
|
313
|
-
if (!includeTags.has(tree.tag)) {
|
|
314
|
-
const filteredChildren = filterChildrenInclude(tree.children, includeTags);
|
|
315
|
-
return filteredChildren.length > 0 ? filteredChildren[0] : null;
|
|
316
|
-
}
|
|
317
|
-
return {
|
|
318
|
-
...tree,
|
|
319
|
-
children: filterChildrenInclude(tree.children, includeTags)
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
function filterChildrenInclude(children, includeTags) {
|
|
323
|
-
const result = [];
|
|
324
|
-
for (const child of children) {
|
|
325
|
-
if (!includeTags.has(child.tag)) {
|
|
326
|
-
const grandchildren = filterChildrenInclude(child.children, includeTags);
|
|
327
|
-
result.push(...grandchildren);
|
|
328
|
-
} else {
|
|
329
|
-
result.push({
|
|
330
|
-
...child,
|
|
331
|
-
children: filterChildrenInclude(child.children, includeTags)
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return result;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ../../modules/iframe-projection/fiber/watch.ts
|
|
339
|
-
function captureTree(options = {}) {
|
|
340
|
-
const { selector, serialize, tags, ...serializeOptions } = options;
|
|
341
|
-
const serializeFn = serialize ?? defaultSerialize;
|
|
342
|
-
const tagSet = tags && tags.length > 0 ? new Set(tags) : null;
|
|
343
|
-
let startFiber = null;
|
|
344
|
-
if (selector) {
|
|
345
|
-
const element = document.querySelector(selector);
|
|
346
|
-
if (element) {
|
|
347
|
-
const rawFiber = getFiberFromElement(element);
|
|
348
|
-
startFiber = rawFiber ? resolveCommittedFiber(rawFiber) : null;
|
|
349
|
-
}
|
|
350
|
-
} else {
|
|
351
|
-
const hook = getHook();
|
|
352
|
-
if (!hook) return null;
|
|
353
|
-
let fiberRoot = null;
|
|
354
|
-
for (const roots of lastCommittedRoots.values()) {
|
|
355
|
-
for (const root of roots) {
|
|
356
|
-
if (root.current) {
|
|
357
|
-
fiberRoot = root;
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
if (fiberRoot) break;
|
|
362
|
-
}
|
|
363
|
-
if (!fiberRoot) {
|
|
364
|
-
for (const [_id, renderer] of hook.renderers ?? []) {
|
|
365
|
-
const roots = renderer.getFiberRoots?.();
|
|
366
|
-
if (roots) {
|
|
367
|
-
for (const root of roots) {
|
|
368
|
-
if (root?.current) {
|
|
369
|
-
fiberRoot = root;
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (fiberRoot) break;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
if (!fiberRoot) return null;
|
|
378
|
-
const rootFiber = fiberRoot.current;
|
|
379
|
-
if (rootFiber && rootFiber.tag === FiberTag.HostRoot && rootFiber.child) {
|
|
380
|
-
startFiber = rootFiber.child;
|
|
381
|
-
} else if (rootFiber) {
|
|
382
|
-
startFiber = rootFiber;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
if (!startFiber) return null;
|
|
386
|
-
let tree = serializeTree(startFiber, serializeFn, serializeOptions);
|
|
387
|
-
if (tree && tagSet && "tag" in tree) {
|
|
388
|
-
const filtered = filterTreeInclude(
|
|
389
|
-
tree,
|
|
390
|
-
tagSet
|
|
391
|
-
);
|
|
392
|
-
tree = filtered;
|
|
393
|
-
}
|
|
394
|
-
return tree;
|
|
395
|
-
}
|
|
396
|
-
var HOOK_MARKER = /* @__PURE__ */ Symbol.for("iframe-projection-fiber-hook");
|
|
397
|
-
var cachedInterface = null;
|
|
398
|
-
var lastCommittedRoots = /* @__PURE__ */ new Map();
|
|
399
|
-
function rememberCommittedRoot(rendererId, root) {
|
|
400
|
-
const roots = lastCommittedRoots.get(rendererId) ?? /* @__PURE__ */ new Set();
|
|
401
|
-
for (const previous of roots) {
|
|
402
|
-
if (previous !== root && previous.containerInfo === root.containerInfo) {
|
|
403
|
-
roots.delete(previous);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
roots.add(root);
|
|
407
|
-
lastCommittedRoots.set(rendererId, roots);
|
|
408
|
-
}
|
|
409
|
-
function getCommittedFiberRoots() {
|
|
410
|
-
return [...lastCommittedRoots.values()].flatMap((roots) => [...roots]);
|
|
411
|
-
}
|
|
412
|
-
function initHook() {
|
|
413
|
-
if (cachedInterface) {
|
|
414
|
-
return cachedInterface;
|
|
415
|
-
}
|
|
416
|
-
const existing = typeof window !== "undefined" ? window.__REACT_DEVTOOLS_GLOBAL_HOOK__ : void 0;
|
|
417
|
-
if (existing && HOOK_MARKER in existing) {
|
|
418
|
-
cachedInterface = existing[HOOK_MARKER];
|
|
419
|
-
return cachedInterface;
|
|
420
|
-
}
|
|
421
|
-
const commitHandlers = /* @__PURE__ */ new Set();
|
|
422
|
-
const injectHandlers = /* @__PURE__ */ new Set();
|
|
423
|
-
const unmountHandlers = /* @__PURE__ */ new Set();
|
|
424
|
-
const createRegistrar = (set) => (handler) => {
|
|
425
|
-
set.add(handler);
|
|
426
|
-
return () => set.delete(handler);
|
|
427
|
-
};
|
|
428
|
-
const callbacks = {
|
|
429
|
-
onCommit: (root, id2, didError) => {
|
|
430
|
-
rememberCommittedRoot(id2, root);
|
|
431
|
-
commitHandlers.forEach((h) => h(root, id2, didError));
|
|
432
|
-
},
|
|
433
|
-
onInject: (renderer, id2) => injectHandlers.forEach((h) => h(renderer, id2)),
|
|
434
|
-
onUnmount: (fiber, id2) => unmountHandlers.forEach((h) => h(fiber, id2))
|
|
435
|
-
};
|
|
436
|
-
let hook;
|
|
437
|
-
if (existing) {
|
|
438
|
-
wrapDevToolsHook(existing, callbacks);
|
|
439
|
-
hook = existing;
|
|
440
|
-
} else {
|
|
441
|
-
hook = createDevToolsHook(callbacks);
|
|
442
|
-
if (typeof window !== "undefined") {
|
|
443
|
-
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
const hookInterface = {
|
|
447
|
-
onCommit: createRegistrar(commitHandlers),
|
|
448
|
-
onInject: createRegistrar(injectHandlers),
|
|
449
|
-
onUnmount: createRegistrar(unmountHandlers),
|
|
450
|
-
hook,
|
|
451
|
-
seedCommittedRoots(roots) {
|
|
452
|
-
for (const [rendererId, root] of roots) {
|
|
453
|
-
rememberCommittedRoot(rendererId, root);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
hook[HOOK_MARKER] = hookInterface;
|
|
458
|
-
cachedInterface = hookInterface;
|
|
459
|
-
return hookInterface;
|
|
460
|
-
}
|
|
461
|
-
function createDevToolsHook(callbacks) {
|
|
462
|
-
const hook = {
|
|
463
|
-
supportsFiber: true,
|
|
464
|
-
renderers: /* @__PURE__ */ new Map(),
|
|
465
|
-
inject(renderer) {
|
|
466
|
-
const id2 = this.renderers.size + 1;
|
|
467
|
-
this.renderers.set(id2, renderer);
|
|
468
|
-
callbacks?.onInject?.(renderer, id2);
|
|
469
|
-
return id2;
|
|
470
|
-
},
|
|
471
|
-
onCommitFiberRoot(rendererId, fiberRoot, _priority, didError) {
|
|
472
|
-
callbacks?.onCommit?.(fiberRoot, rendererId, didError === true);
|
|
473
|
-
},
|
|
474
|
-
onCommitFiberUnmount(rendererId, fiber) {
|
|
475
|
-
callbacks?.onUnmount?.(fiber, rendererId);
|
|
476
|
-
},
|
|
477
|
-
// Required stubs for React compatibility
|
|
478
|
-
checkDCE(_fn) {
|
|
479
|
-
},
|
|
480
|
-
onScheduleFiberRoot() {
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
return hook;
|
|
484
|
-
}
|
|
485
|
-
function wrapDevToolsHook(hook, callbacks) {
|
|
486
|
-
if (callbacks.onInject && typeof hook.inject === "function") {
|
|
487
|
-
const original = hook.inject.bind(hook);
|
|
488
|
-
hook.inject = function(renderer) {
|
|
489
|
-
const id2 = original(renderer);
|
|
490
|
-
callbacks.onInject(renderer, id2);
|
|
491
|
-
return id2;
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
if (callbacks.onCommit) {
|
|
495
|
-
const original = hook.onCommitFiberRoot?.bind(hook);
|
|
496
|
-
hook.onCommitFiberRoot = function(rendererId, fiberRoot, priority, didError) {
|
|
497
|
-
callbacks.onCommit(fiberRoot, rendererId, didError === true);
|
|
498
|
-
original?.(rendererId, fiberRoot, priority, didError);
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
if (callbacks.onUnmount) {
|
|
502
|
-
const original = hook.onCommitFiberUnmount?.bind(hook);
|
|
503
|
-
hook.onCommitFiberUnmount = function(rendererId, fiber) {
|
|
504
|
-
callbacks.onUnmount(fiber, rendererId);
|
|
505
|
-
original?.(rendererId, fiber);
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
function getHook() {
|
|
510
|
-
if (typeof window === "undefined") return null;
|
|
511
|
-
return window.__REACT_DEVTOOLS_GLOBAL_HOOK__ ?? null;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// ../../modules/iframe-projection/fiber/projection-scope.ts
|
|
515
|
-
var PROJECTION_SCOPE_ROLE = "__tempoProjectionScopeRole";
|
|
516
|
-
function role(fiber) {
|
|
517
|
-
const type = fiber?.type;
|
|
518
|
-
return type?.[PROJECTION_SCOPE_ROLE];
|
|
519
|
-
}
|
|
520
|
-
function isOutputInvocation(fiber) {
|
|
521
|
-
const parent = fiber.return;
|
|
522
|
-
return role(parent) === "output" || parent?.tag === FiberTag.MemoComponent && isOutputInvocation(parent);
|
|
523
|
-
}
|
|
524
|
-
function isProjectionScopePlumbing(fiber) {
|
|
525
|
-
return role(fiber) !== void 0 || isOutputInvocation(fiber);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// ../../modules/iframe-projection/combined/projection-pending.ts
|
|
529
|
-
var PROJECTION_PENDING_ATTRIBUTE = "data-tempo-projection-pending";
|
|
530
|
-
var PROJECTION_UNAVAILABLE_ATTRIBUTE = "data-tempo-projection-unavailable";
|
|
531
|
-
function isProjectionPendingOnly(rootElement) {
|
|
532
|
-
return childrenAllCarry(rootElement, PROJECTION_PENDING_ATTRIBUTE);
|
|
533
|
-
}
|
|
534
|
-
function isProjectionUnavailableOnly(rootElement) {
|
|
535
|
-
return childrenAllCarry(rootElement, PROJECTION_UNAVAILABLE_ATTRIBUTE);
|
|
536
|
-
}
|
|
537
|
-
function childrenAllCarry(rootElement, attribute) {
|
|
538
|
-
const children = rootElement.children;
|
|
539
|
-
if (children.length === 0) return false;
|
|
540
|
-
for (let index = 0; index < children.length; index += 1) {
|
|
541
|
-
const child = children[index];
|
|
542
|
-
if (!child || !child.hasAttribute(attribute)) {
|
|
543
|
-
return false;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return true;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// ../../modules/iframe-projection/combined/projection-astro-alpine.ts
|
|
550
|
-
function createAstroAlpineOwnership(key, original) {
|
|
551
|
-
let active = /* @__PURE__ */ new Map();
|
|
552
|
-
const emissions = /* @__PURE__ */ new WeakMap();
|
|
553
|
-
const walk = (node, visit) => {
|
|
554
|
-
visit(node);
|
|
555
|
-
for (const child of node.childNodes) walk(child, visit);
|
|
556
|
-
if (node instanceof HTMLTemplateElement) walk(node.content, visit);
|
|
557
|
-
};
|
|
558
|
-
const source2 = (node) => {
|
|
559
|
-
const token = key(node);
|
|
560
|
-
if (!token) return null;
|
|
561
|
-
if (original(token) === node) return node;
|
|
562
|
-
for (let parent = node; parent; parent = parent.parentNode) {
|
|
563
|
-
if (!(parent instanceof Element)) continue;
|
|
564
|
-
const template = active.get(parent), record = emissions.get(parent);
|
|
565
|
-
if (!template || !record || record.template !== template || !record.tokens.has(token) || record.owners.get(token) !== node)
|
|
566
|
-
continue;
|
|
567
|
-
const owner = original(token);
|
|
568
|
-
return owner ?? null;
|
|
569
|
-
}
|
|
570
|
-
return null;
|
|
571
|
-
};
|
|
572
|
-
return {
|
|
573
|
-
source: source2,
|
|
574
|
-
refresh(templates) {
|
|
575
|
-
const previous = active;
|
|
576
|
-
active = /* @__PURE__ */ new Map();
|
|
577
|
-
const pending = [...templates];
|
|
578
|
-
for (let pass = 0; pass < 32 && pending.length; pass++) {
|
|
579
|
-
let progress = false;
|
|
580
|
-
for (let index = pending.length - 1; index >= 0; index--) {
|
|
581
|
-
const template = pending[index];
|
|
582
|
-
const origin = source2(template);
|
|
583
|
-
if (!(origin instanceof HTMLTemplateElement)) continue;
|
|
584
|
-
pending.splice(index, 1);
|
|
585
|
-
progress = true;
|
|
586
|
-
const roots = template.hasAttribute("x-for") && template._x_lookup instanceof Map ? [...template._x_lookup.values()] : template.hasAttribute("x-if") && template._x_currentIfEl ? [template._x_currentIfEl] : template.hasAttribute("x-teleport") && template._x_teleport && template._x_teleport._x_teleportBack === template ? [template._x_teleport] : [];
|
|
587
|
-
for (const root of roots) {
|
|
588
|
-
if (!(root instanceof Element) || !root.isConnected) continue;
|
|
589
|
-
active.set(root, template);
|
|
590
|
-
if (emissions.get(root)?.template === template && previous.get(root) === template)
|
|
591
|
-
continue;
|
|
592
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
593
|
-
walk(origin.content, (node) => {
|
|
594
|
-
const token = key(node);
|
|
595
|
-
if (token && original(token) === node) tokens.add(token);
|
|
596
|
-
});
|
|
597
|
-
const owners = /* @__PURE__ */ new Map();
|
|
598
|
-
walk(root, (node) => {
|
|
599
|
-
const token = key(node);
|
|
600
|
-
if (token) owners.set(token, owners.has(token) ? null : node);
|
|
601
|
-
});
|
|
602
|
-
emissions.set(root, { template, owners, tokens });
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
if (!progress) break;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// ../../modules/iframe-projection/combined/projection-astro-metadata.ts
|
|
612
|
-
var ASTRO_NODE_ATTRIBUTE = "data-tempo-astro-node";
|
|
613
|
-
function source(value) {
|
|
614
|
-
return !!value && typeof value.filepath === "string" && value.filepath.length > 0 && typeof value.sourceVersion === "string" && value.sourceVersion.length > 0 && Number.isSafeInteger(value.modifiedTs) && value.modifiedTs >= 0;
|
|
615
|
-
}
|
|
616
|
-
function readAstroMarker(node) {
|
|
617
|
-
if (node.nodeType !== 8) return null;
|
|
618
|
-
const match = /^tempo:astro:([bem]):(.*)$/.exec(node.textContent ?? "");
|
|
619
|
-
if (!match) return null;
|
|
620
|
-
try {
|
|
621
|
-
const value = JSON.parse(decodeURIComponent(match[2]));
|
|
622
|
-
if (match[1] === "m" && source(value)) return { kind: "m", value };
|
|
623
|
-
if (typeof value?.occurrence !== "string" || value.occurrence.length === 0)
|
|
624
|
-
return null;
|
|
625
|
-
if (match[1] === "e") return { kind: "e", value };
|
|
626
|
-
if (match[1] === "b" && source(value.source) && Number.isSafeInteger(value.source.position) && value.source.position >= 0 && typeof value.source.name === "string" && (value.definition === null || source(value.definition) && (value.definition.exportName === void 0 || typeof value.definition.exportName === "string")))
|
|
627
|
-
return { kind: "b", value };
|
|
628
|
-
} catch {
|
|
629
|
-
}
|
|
630
|
-
return null;
|
|
631
|
-
}
|
|
632
|
-
var documents = /* @__PURE__ */ new WeakMap();
|
|
633
|
-
function trackAstroSources(document2) {
|
|
634
|
-
const existing = documents.get(document2);
|
|
635
|
-
if (existing) return existing;
|
|
636
|
-
const owners = /* @__PURE__ */ new Map();
|
|
637
|
-
const inertOwners = /* @__PURE__ */ new Map();
|
|
638
|
-
const modules = /* @__PURE__ */ new Map();
|
|
639
|
-
const templates = /* @__PURE__ */ new Set();
|
|
640
|
-
const serverHosts = /* @__PURE__ */ new WeakMap();
|
|
641
|
-
const completed = /* @__PURE__ */ new WeakSet();
|
|
642
|
-
const hostReceipt = (element) => {
|
|
643
|
-
const file = element.getAttribute("data-tempo-filepath");
|
|
644
|
-
const version = element.getAttribute("data-tempo-source-version");
|
|
645
|
-
const position = element.getAttribute("data-tempo-position");
|
|
646
|
-
const modified = element.getAttribute("data-tempo-modifiedts");
|
|
647
|
-
return file && /\.[jt]sx?$/.test(file) && version && position !== null && /^\d+$/.test(position) && modified !== null && /^\d+$/.test(modified) ? JSON.stringify([file, version, position, modified]) : null;
|
|
648
|
-
};
|
|
649
|
-
const acceptServerHosts = (end) => {
|
|
650
|
-
const marker = readAstroMarker(end);
|
|
651
|
-
if (marker?.kind !== "e" || completed.has(end)) return;
|
|
652
|
-
let begin = end.previousSibling;
|
|
653
|
-
while (begin) {
|
|
654
|
-
const candidate = readAstroMarker(begin);
|
|
655
|
-
if (candidate?.kind === "b" && candidate.value.occurrence === marker.value.occurrence)
|
|
656
|
-
break;
|
|
657
|
-
begin = begin.previousSibling;
|
|
658
|
-
}
|
|
659
|
-
if (!begin || owners.get(`b:${marker.value.occurrence}`) !== begin || owners.get(`e:${marker.value.occurrence}`) !== end)
|
|
660
|
-
return;
|
|
661
|
-
completed.add(end);
|
|
662
|
-
const accept = (node) => {
|
|
663
|
-
if (node instanceof Element) {
|
|
664
|
-
const receipt = hostReceipt(node);
|
|
665
|
-
if (receipt) serverHosts.set(node, receipt);
|
|
666
|
-
}
|
|
667
|
-
for (const child of node.childNodes) accept(child);
|
|
668
|
-
};
|
|
669
|
-
for (let node = begin.nextSibling; node && node !== end; node = node.nextSibling)
|
|
670
|
-
accept(node);
|
|
671
|
-
};
|
|
672
|
-
const key = (node) => {
|
|
673
|
-
if (node.nodeType === 1)
|
|
674
|
-
return node.getAttribute(ASTRO_NODE_ATTRIBUTE);
|
|
675
|
-
const marker = readAstroMarker(node);
|
|
676
|
-
return marker && marker.kind !== "m" ? `${marker.kind}:${marker.value.occurrence}` : null;
|
|
677
|
-
};
|
|
678
|
-
const visit = (node, introduced, inert = false) => {
|
|
679
|
-
const token = key(node);
|
|
680
|
-
if (token) {
|
|
681
|
-
if (inert) {
|
|
682
|
-
if (!inertOwners.has(token)) inertOwners.set(token, node);
|
|
683
|
-
else if (inertOwners.get(token) !== node) inertOwners.set(token, null);
|
|
684
|
-
owners.set(token, inertOwners.get(token));
|
|
685
|
-
} else if (!owners.has(token)) {
|
|
686
|
-
owners.set(token, node);
|
|
687
|
-
introduced.add(token);
|
|
688
|
-
} else if (!inertOwners.has(token) && introduced.has(token) && owners.get(token) !== node)
|
|
689
|
-
owners.set(token, null);
|
|
690
|
-
}
|
|
691
|
-
const marker = readAstroMarker(node);
|
|
692
|
-
if (marker?.kind === "m") modules.set(node, marker.value);
|
|
693
|
-
for (const child of node.childNodes) visit(child, introduced, inert);
|
|
694
|
-
if (node instanceof HTMLTemplateElement) {
|
|
695
|
-
templates.add(node);
|
|
696
|
-
visit(
|
|
697
|
-
node.content,
|
|
698
|
-
introduced,
|
|
699
|
-
token !== null && owners.get(token) === node
|
|
700
|
-
);
|
|
701
|
-
}
|
|
702
|
-
acceptServerHosts(node);
|
|
703
|
-
};
|
|
704
|
-
visit(document2, /* @__PURE__ */ new Set());
|
|
705
|
-
const alpine = createAstroAlpineOwnership(key, (token) => owners.get(token));
|
|
706
|
-
alpine.refresh(templates);
|
|
707
|
-
const observe = (records) => {
|
|
708
|
-
if (!records.length) return;
|
|
709
|
-
const introduced = /* @__PURE__ */ new Set();
|
|
710
|
-
for (const record of records)
|
|
711
|
-
for (const node of record.addedNodes) visit(node, introduced);
|
|
712
|
-
for (const [node] of modules) if (!node.isConnected) modules.delete(node);
|
|
713
|
-
alpine.refresh(templates);
|
|
714
|
-
};
|
|
715
|
-
const observer = new MutationObserver(observe);
|
|
716
|
-
observer.observe(document2, { childList: true, subtree: true });
|
|
717
|
-
const flush = () => observe(observer.takeRecords());
|
|
718
|
-
const tracking = {
|
|
719
|
-
owns(node) {
|
|
720
|
-
flush();
|
|
721
|
-
const token = key(node);
|
|
722
|
-
return token !== null && (owners.get(token) === node || alpine.source(node) !== null) || node instanceof Element && serverHosts.has(node) && serverHosts.get(node) === hostReceipt(node);
|
|
723
|
-
},
|
|
724
|
-
hasAstro() {
|
|
725
|
-
flush();
|
|
726
|
-
return owners.size > 0 || modules.size > 0;
|
|
727
|
-
},
|
|
728
|
-
moduleSources() {
|
|
729
|
-
flush();
|
|
730
|
-
return [...modules.values()];
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
documents.set(document2, tracking);
|
|
734
|
-
return tracking;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
// ../../modules/iframe-projection/combined/realm-epoch.ts
|
|
738
|
-
var REALM_DOCUMENT_EPOCH = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
739
|
-
var nextCaptureSequence = 0;
|
|
740
|
-
function nextRealmCaptureSequence() {
|
|
741
|
-
return nextCaptureSequence++;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// ../../modules/iframe-projection/html/pending-hydration.ts
|
|
745
|
-
function hasPendingReactHydration(element) {
|
|
746
|
-
for (let parent = element.parentElement; parent; parent = parent.parentElement) {
|
|
747
|
-
if (parent.localName !== "astro-island") continue;
|
|
748
|
-
if (!/(?:@astrojs\/react|astrojs_react)/.test(
|
|
749
|
-
parent.getAttribute("renderer-url") ?? ""
|
|
750
|
-
))
|
|
751
|
-
continue;
|
|
752
|
-
const key = Object.keys(parent).find(
|
|
753
|
-
(name) => name.startsWith("__reactContainer$")
|
|
754
|
-
);
|
|
755
|
-
const container = key ? parent[key] : null;
|
|
756
|
-
const state = container?.stateNode?.current?.memoizedState;
|
|
757
|
-
if (state?.isDehydrated !== false) return true;
|
|
758
|
-
}
|
|
759
|
-
return false;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// ../../modules/iframe-projection/html/watch-dom.ts
|
|
763
|
-
var DOM_ID_ATTR = "data-dom-id";
|
|
764
|
-
var HOST_LAYER_ID_ATTR = "data-host-layer-id";
|
|
765
|
-
var PROJECTION_ROOT_ATTRIBUTE = "data-tempo-projection-root";
|
|
766
|
-
var idPrefix = REALM_DOCUMENT_EPOCH;
|
|
767
|
-
var idCounter = 0;
|
|
768
|
-
var liveElementIds = /* @__PURE__ */ new WeakMap();
|
|
769
|
-
function nextProjectionId() {
|
|
770
|
-
return `${idPrefix}-${idCounter++}`;
|
|
771
|
-
}
|
|
772
|
-
function seedProjectionIds(sessionId) {
|
|
773
|
-
idPrefix = sessionId;
|
|
774
|
-
}
|
|
775
|
-
function underForeignProjectionRoot(element, root) {
|
|
776
|
-
for (let current = element; current && current !== root; current = current.parentElement) {
|
|
777
|
-
if (current.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) return true;
|
|
778
|
-
}
|
|
779
|
-
return false;
|
|
780
|
-
}
|
|
781
|
-
function projectedElements(scope) {
|
|
782
|
-
const elements = [];
|
|
783
|
-
const stack = [scope];
|
|
784
|
-
while (stack.length > 0) {
|
|
785
|
-
const element = stack.pop();
|
|
786
|
-
if (element.tagName.toLowerCase() === "script") continue;
|
|
787
|
-
elements.push(element);
|
|
788
|
-
if (element !== scope && element.hasAttribute(PROJECTION_ROOT_ATTRIBUTE))
|
|
789
|
-
continue;
|
|
790
|
-
for (let index = element.children.length - 1; index >= 0; index -= 1) {
|
|
791
|
-
stack.push(element.children[index]);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
return elements;
|
|
795
|
-
}
|
|
796
|
-
function cloneProjectionDom(scope) {
|
|
797
|
-
const boundaries = scope.querySelectorAll(`[${PROJECTION_ROOT_ATTRIBUTE}]`);
|
|
798
|
-
if (!boundaries.length) return scope.cloneNode(true);
|
|
799
|
-
const paths = /* @__PURE__ */ new Set();
|
|
800
|
-
for (const boundary of boundaries) {
|
|
801
|
-
for (let parent = boundary.parentElement; parent && !paths.has(parent); parent = parent.parentElement) {
|
|
802
|
-
paths.add(parent);
|
|
803
|
-
if (parent === scope) break;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
const clone = scope.cloneNode(false);
|
|
807
|
-
const pending = [[scope, clone]];
|
|
808
|
-
while (pending.length) {
|
|
809
|
-
const [live, copy] = pending.pop();
|
|
810
|
-
for (const child of Array.from(live.childNodes)) {
|
|
811
|
-
const element = child.nodeType === 1 ? child : null;
|
|
812
|
-
const boundary = element?.hasAttribute(PROJECTION_ROOT_ATTRIBUTE);
|
|
813
|
-
const shallow = !!element && (boundary || paths.has(element));
|
|
814
|
-
const childCopy = child.cloneNode(!shallow);
|
|
815
|
-
copy.appendChild(childCopy);
|
|
816
|
-
if (shallow && !boundary) pending.push([element, childCopy]);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
return clone;
|
|
820
|
-
}
|
|
821
|
-
function assignDomId(element) {
|
|
822
|
-
let id2 = liveElementIds.get(element);
|
|
823
|
-
if (!id2) {
|
|
824
|
-
id2 = nextProjectionId();
|
|
825
|
-
liveElementIds.set(element, id2);
|
|
826
|
-
}
|
|
827
|
-
if (hasPendingReactHydration(element) || hasContentEditableAncestor(element))
|
|
828
|
-
return id2;
|
|
829
|
-
if (element.getAttribute(DOM_ID_ATTR) !== id2) {
|
|
830
|
-
element.setAttribute(DOM_ID_ATTR, id2);
|
|
831
|
-
}
|
|
832
|
-
if (element.getAttribute(HOST_LAYER_ID_ATTR) !== id2) {
|
|
833
|
-
element.setAttribute(HOST_LAYER_ID_ATTR, id2);
|
|
834
|
-
}
|
|
835
|
-
return id2;
|
|
836
|
-
}
|
|
837
|
-
function ensureProjectionDomId(element, root) {
|
|
838
|
-
if (element.nodeType === 3 || element.nodeType === 8) {
|
|
839
|
-
if (readAstroMarker(element)) return null;
|
|
840
|
-
let parent = element.parentElement;
|
|
841
|
-
if (!parent) return readProjectionDomId(element);
|
|
842
|
-
const position = [
|
|
843
|
-
Array.from(parent.childNodes).filter(
|
|
844
|
-
(child) => !readAstroMarker(child) && (!(child instanceof Element) || child.localName !== "script" && !child.hasAttribute("data-tempo-svelte-source-registry"))
|
|
845
|
-
).indexOf(element)
|
|
846
|
-
];
|
|
847
|
-
const rootDomId = root ? ensureProjectionDomId(root) : null;
|
|
848
|
-
const rootParentId = rootDomId && `$projection-root:${rootDomId}`;
|
|
849
|
-
let parentId = parent === root ? rootParentId : ensureProjectionDomId(parent);
|
|
850
|
-
while (!parentId && parent !== root && parent.parentElement) {
|
|
851
|
-
position.unshift(
|
|
852
|
-
Array.from(parent.parentElement.childNodes).filter(
|
|
853
|
-
(child) => !readAstroMarker(child) && (!(child instanceof Element) || child.localName !== "script" && !child.hasAttribute("data-tempo-svelte-source-registry"))
|
|
854
|
-
).indexOf(parent)
|
|
855
|
-
);
|
|
856
|
-
parent = parent.parentElement;
|
|
857
|
-
parentId = parent === root ? rootParentId : ensureProjectionDomId(parent);
|
|
858
|
-
}
|
|
859
|
-
if (!parentId) return null;
|
|
860
|
-
const kind = element.nodeType === 3 ? "text" : "comment";
|
|
861
|
-
const id2 = `${parentId}/${kind}/${position.join("/")}`;
|
|
862
|
-
liveElementIds.set(element, id2);
|
|
863
|
-
return id2;
|
|
864
|
-
}
|
|
865
|
-
if (!(element instanceof Element)) return null;
|
|
866
|
-
return assignDomId(element);
|
|
867
|
-
}
|
|
868
|
-
function readProjectionDomId(element) {
|
|
869
|
-
return liveElementIds.get(element) ?? null;
|
|
870
|
-
}
|
|
871
|
-
function syncProjectionDomIdsToClone(liveRoot, cloneRoot, includeRoot = true) {
|
|
872
|
-
const pending = includeRoot ? [[liveRoot, cloneRoot]] : Array.from(
|
|
873
|
-
liveRoot.children,
|
|
874
|
-
(liveChild, index) => [liveChild, cloneRoot.children[index]]
|
|
875
|
-
);
|
|
876
|
-
while (pending.length > 0) {
|
|
877
|
-
const [live, clone] = pending.pop();
|
|
878
|
-
const id2 = live.tagName.toLowerCase() === "script" ? null : ensureProjectionDomId(live);
|
|
879
|
-
if (id2) {
|
|
880
|
-
clone.setAttribute(DOM_ID_ATTR, id2);
|
|
881
|
-
clone.setAttribute(HOST_LAYER_ID_ATTR, id2);
|
|
882
|
-
} else {
|
|
883
|
-
clone.removeAttribute(DOM_ID_ATTR);
|
|
884
|
-
clone.removeAttribute(HOST_LAYER_ID_ATTR);
|
|
885
|
-
}
|
|
886
|
-
if (live !== liveRoot && live.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) {
|
|
887
|
-
clone.replaceChildren();
|
|
888
|
-
continue;
|
|
889
|
-
}
|
|
890
|
-
for (let index = 0; index < live.children.length; index += 1) {
|
|
891
|
-
const liveChild = live.children[index];
|
|
892
|
-
const cloneChild = clone.children[index];
|
|
893
|
-
if (liveChild && cloneChild) pending.push([liveChild, cloneChild]);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
function isContentEditableRoot(element) {
|
|
898
|
-
return element.getAttribute("contenteditable") !== null;
|
|
899
|
-
}
|
|
900
|
-
function hasContentEditableAncestor(element) {
|
|
901
|
-
let current = element.parentElement;
|
|
902
|
-
while (current) {
|
|
903
|
-
if (current.getAttribute("contenteditable") !== null) {
|
|
904
|
-
return true;
|
|
905
|
-
}
|
|
906
|
-
current = current.parentElement;
|
|
907
|
-
}
|
|
908
|
-
return false;
|
|
909
|
-
}
|
|
910
|
-
function assignDomIdToTree(root, watchedRoot) {
|
|
911
|
-
if (hasContentEditableAncestor(root)) {
|
|
912
|
-
return;
|
|
913
|
-
}
|
|
914
|
-
ensureProjectionDomId(root);
|
|
915
|
-
if (isContentEditableRoot(root)) {
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
if (root !== watchedRoot && root.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) {
|
|
919
|
-
return;
|
|
920
|
-
}
|
|
921
|
-
const stack = [];
|
|
922
|
-
for (let i = root.children.length - 1; i >= 0; i--) {
|
|
923
|
-
stack.push(root.children[i]);
|
|
924
|
-
}
|
|
925
|
-
while (stack.length > 0) {
|
|
926
|
-
const element = stack.pop();
|
|
927
|
-
ensureProjectionDomId(element);
|
|
928
|
-
if (isContentEditableRoot(element)) {
|
|
929
|
-
continue;
|
|
930
|
-
}
|
|
931
|
-
if (element.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)) {
|
|
932
|
-
continue;
|
|
933
|
-
}
|
|
934
|
-
for (let i = element.children.length - 1; i >= 0; i--) {
|
|
935
|
-
stack.push(element.children[i]);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
function watchDom(root, onMutation) {
|
|
940
|
-
const mutatedElements = /* @__PURE__ */ new Set();
|
|
941
|
-
assignDomIdToTree(root, root);
|
|
942
|
-
const retainMutations = (mutations) => {
|
|
943
|
-
const scalarMutations = [];
|
|
944
|
-
const firstAttributeByTarget = /* @__PURE__ */ new WeakMap();
|
|
945
|
-
const firstCharacterDataByTarget = /* @__PURE__ */ new WeakMap();
|
|
946
|
-
for (const mutation of mutations) {
|
|
947
|
-
const concernedParent = mutation.type === "attributes" ? mutation.target.parentElement : mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
948
|
-
if (concernedParent && underForeignProjectionRoot(concernedParent, root))
|
|
949
|
-
continue;
|
|
950
|
-
if (mutation.type === "attributes" && mutation.attributeName !== null) {
|
|
951
|
-
const isProjectionId = mutation.attributeName === DOM_ID_ATTR || mutation.attributeName === HOST_LAYER_ID_ATTR;
|
|
952
|
-
if (isProjectionId) continue;
|
|
953
|
-
const target = mutation.target;
|
|
954
|
-
const byName = firstAttributeByTarget.get(target) ?? /* @__PURE__ */ new Map();
|
|
955
|
-
if (!byName.has(mutation.attributeName)) {
|
|
956
|
-
byName.set(mutation.attributeName, mutation);
|
|
957
|
-
firstAttributeByTarget.set(target, byName);
|
|
958
|
-
scalarMutations.push(mutation);
|
|
959
|
-
}
|
|
960
|
-
} else if (mutation.type === "characterData") {
|
|
961
|
-
if (!firstCharacterDataByTarget.has(mutation.target)) {
|
|
962
|
-
firstCharacterDataByTarget.set(mutation.target, mutation);
|
|
963
|
-
scalarMutations.push(mutation);
|
|
964
|
-
}
|
|
965
|
-
} else {
|
|
966
|
-
scalarMutations.push(mutation);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
let retained = 0;
|
|
970
|
-
for (const mutation of scalarMutations) {
|
|
971
|
-
if (mutation.type === "attributes" && mutation.attributeName !== null && mutation.oldValue === mutation.target.getAttribute(mutation.attributeName)) {
|
|
972
|
-
continue;
|
|
973
|
-
}
|
|
974
|
-
if (mutation.type === "characterData" && mutation.oldValue === mutation.target.textContent) {
|
|
975
|
-
continue;
|
|
976
|
-
}
|
|
977
|
-
retained += 1;
|
|
978
|
-
watcher.mutationRecordCount += 1;
|
|
979
|
-
watcher.projectionMutations.push({
|
|
980
|
-
type: mutation.type,
|
|
981
|
-
target: mutation.target,
|
|
982
|
-
...mutation.type === "attributes" || mutation.type === "characterData" ? { oldValue: mutation.oldValue } : {},
|
|
983
|
-
...mutation.type === "attributes" ? { attributeName: mutation.attributeName } : {},
|
|
984
|
-
...mutation.type === "childList" ? {
|
|
985
|
-
addedNodes: Array.from(mutation.addedNodes),
|
|
986
|
-
removedNodes: Array.from(mutation.removedNodes),
|
|
987
|
-
previousSibling: mutation.previousSibling,
|
|
988
|
-
nextSibling: mutation.nextSibling
|
|
989
|
-
} : {}
|
|
990
|
-
});
|
|
991
|
-
const target = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
992
|
-
if (target && root.contains(target)) {
|
|
993
|
-
mutatedElements.add(target);
|
|
994
|
-
}
|
|
995
|
-
if (mutation.type === "childList") {
|
|
996
|
-
for (const node of mutation.addedNodes) {
|
|
997
|
-
if (node instanceof Element && root.contains(node)) {
|
|
998
|
-
assignDomIdToTree(node, root);
|
|
999
|
-
watcher.addedElementCount += 1;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
if (mutation.target instanceof Element && root.contains(mutation.target)) {
|
|
1003
|
-
mutatedElements.add(mutation.target);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
return retained;
|
|
1008
|
-
};
|
|
1009
|
-
const observer = new MutationObserver((mutations) => {
|
|
1010
|
-
if (retainMutations(mutations) > 0 && mutatedElements.size > 0)
|
|
1011
|
-
onMutation();
|
|
1012
|
-
});
|
|
1013
|
-
observer.observe(root, {
|
|
1014
|
-
childList: true,
|
|
1015
|
-
subtree: true,
|
|
1016
|
-
attributes: true,
|
|
1017
|
-
attributeOldValue: true,
|
|
1018
|
-
characterData: true,
|
|
1019
|
-
characterDataOldValue: true
|
|
1020
|
-
});
|
|
1021
|
-
const watcher = {
|
|
1022
|
-
root,
|
|
1023
|
-
mutatedElements,
|
|
1024
|
-
addedElementCount: 0,
|
|
1025
|
-
mutationRecordCount: 0,
|
|
1026
|
-
projectionMutations: [],
|
|
1027
|
-
takePendingRecords: () => retainMutations(observer.takeRecords()),
|
|
1028
|
-
stop: () => {
|
|
1029
|
-
observer.disconnect();
|
|
1030
|
-
mutatedElements.clear();
|
|
1031
|
-
watcher.mutationRecordCount = 0;
|
|
1032
|
-
watcher.projectionMutations.length = 0;
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
|
-
return watcher;
|
|
1036
|
-
}
|
|
1037
|
-
function flushDomWatcher(watcher) {
|
|
1038
|
-
watcher.addedElementCount = 0;
|
|
1039
|
-
watcher.mutationRecordCount = 0;
|
|
1040
|
-
watcher.projectionMutations.length = 0;
|
|
1041
|
-
if (watcher.mutatedElements.size === 0) {
|
|
1042
|
-
return null;
|
|
1043
|
-
}
|
|
1044
|
-
const lca = findLowestCommonAncestor(watcher.mutatedElements);
|
|
1045
|
-
watcher.mutatedElements.clear();
|
|
1046
|
-
if (lca && !watcher.root.contains(lca) && lca !== watcher.root) {
|
|
1047
|
-
return watcher.root;
|
|
1048
|
-
}
|
|
1049
|
-
return lca;
|
|
1050
|
-
}
|
|
1051
|
-
function drainProjectionDomMutations(watcher) {
|
|
1052
|
-
const retained = watcher.projectionMutations.splice(0);
|
|
1053
|
-
const mutations = [];
|
|
1054
|
-
const firstAttributeByTarget = /* @__PURE__ */ new WeakMap();
|
|
1055
|
-
const firstCharacterDataTargets = /* @__PURE__ */ new WeakSet();
|
|
1056
|
-
for (const mutation of retained) {
|
|
1057
|
-
const attributeName = mutation.attributeName;
|
|
1058
|
-
if (mutation.type === "attributes" && attributeName != null) {
|
|
1059
|
-
const target = mutation.target;
|
|
1060
|
-
const names = firstAttributeByTarget.get(target) ?? /* @__PURE__ */ new Set();
|
|
1061
|
-
if (names.has(attributeName)) continue;
|
|
1062
|
-
names.add(attributeName);
|
|
1063
|
-
firstAttributeByTarget.set(target, names);
|
|
1064
|
-
if (mutation.oldValue === target.getAttribute(attributeName)) {
|
|
1065
|
-
continue;
|
|
1066
|
-
}
|
|
1067
|
-
mutations.push({
|
|
1068
|
-
type: "attributes",
|
|
1069
|
-
target,
|
|
1070
|
-
attributeName
|
|
1071
|
-
});
|
|
1072
|
-
continue;
|
|
1073
|
-
}
|
|
1074
|
-
if (mutation.type === "characterData") {
|
|
1075
|
-
if (firstCharacterDataTargets.has(mutation.target)) continue;
|
|
1076
|
-
firstCharacterDataTargets.add(mutation.target);
|
|
1077
|
-
if (mutation.oldValue === mutation.target.textContent) continue;
|
|
1078
|
-
mutations.push({ type: "characterData", target: mutation.target });
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
mutations.push(mutation);
|
|
1082
|
-
}
|
|
1083
|
-
watcher.mutatedElements.clear();
|
|
1084
|
-
watcher.addedElementCount = 0;
|
|
1085
|
-
watcher.mutationRecordCount = 0;
|
|
1086
|
-
return mutations;
|
|
1087
|
-
}
|
|
1088
|
-
function hasPendingMutations(watcher) {
|
|
1089
|
-
return watcher.mutatedElements.size > 0;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
// ../../modules/iframe-projection/inline-style.ts
|
|
1093
|
-
function splitCssDeclarations(text) {
|
|
1094
|
-
const declarations = [];
|
|
1095
|
-
let start = 0;
|
|
1096
|
-
let quote = "";
|
|
1097
|
-
let comment = false;
|
|
1098
|
-
let depth = 0;
|
|
1099
|
-
for (let i = 0; i < text.length; i++) {
|
|
1100
|
-
const char = text[i];
|
|
1101
|
-
if (comment) {
|
|
1102
|
-
if (char === "*" && text[i + 1] === "/") {
|
|
1103
|
-
comment = false;
|
|
1104
|
-
i++;
|
|
1105
|
-
}
|
|
1106
|
-
continue;
|
|
1107
|
-
}
|
|
1108
|
-
if (char === "\\") {
|
|
1109
|
-
i++;
|
|
1110
|
-
continue;
|
|
1111
|
-
}
|
|
1112
|
-
if (quote) {
|
|
1113
|
-
if (char === quote) quote = "";
|
|
1114
|
-
continue;
|
|
1115
|
-
}
|
|
1116
|
-
if (char === "/" && text[i + 1] === "*") {
|
|
1117
|
-
comment = true;
|
|
1118
|
-
i++;
|
|
1119
|
-
} else if (char === '"' || char === "'") quote = char;
|
|
1120
|
-
else if (char === "(" || char === "[" || char === "{") depth++;
|
|
1121
|
-
else if (char === ")" || char === "]" || char === "}")
|
|
1122
|
-
depth = Math.max(0, depth - 1);
|
|
1123
|
-
else if (char === ";" && depth === 0) {
|
|
1124
|
-
declarations.push(text.slice(start, i));
|
|
1125
|
-
start = i + 1;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
declarations.push(text.slice(start));
|
|
1129
|
-
return declarations;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
// ../../modules/iframe-projection/combined/projection-observed-files.ts
|
|
1133
|
-
var ProjectionObservedFileAccumulator = class {
|
|
1134
|
-
constructor() {
|
|
1135
|
-
this.files = /* @__PURE__ */ new Map();
|
|
1136
|
-
}
|
|
1137
|
-
add(filepath, modifiedTsRaw, sourceVersionRaw) {
|
|
1138
|
-
if (typeof filepath !== "string" || filepath.length === 0) return;
|
|
1139
|
-
const modifiedTs = typeof modifiedTsRaw === "number" ? modifiedTsRaw : typeof modifiedTsRaw === "string" ? Number(modifiedTsRaw) : Number.NaN;
|
|
1140
|
-
if (!Number.isFinite(modifiedTs)) return;
|
|
1141
|
-
const sourceVersion = typeof sourceVersionRaw === "string" && sourceVersionRaw.length > 0 ? sourceVersionRaw : void 0;
|
|
1142
|
-
const current = this.files.get(filepath);
|
|
1143
|
-
if (!current) {
|
|
1144
|
-
this.files.set(filepath, {
|
|
1145
|
-
modifiedTs,
|
|
1146
|
-
sourceVersion
|
|
1147
|
-
});
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
if (modifiedTs > current.modifiedTs) return;
|
|
1151
|
-
if (modifiedTs < current.modifiedTs) {
|
|
1152
|
-
current.modifiedTs = modifiedTs;
|
|
1153
|
-
current.sourceVersion = sourceVersion;
|
|
1154
|
-
return;
|
|
1155
|
-
}
|
|
1156
|
-
if (current.sourceVersion !== sourceVersion)
|
|
1157
|
-
current.sourceVersion = void 0;
|
|
1158
|
-
}
|
|
1159
|
-
merge(files) {
|
|
1160
|
-
if (!files) return;
|
|
1161
|
-
for (const [filepath, fact] of Object.entries(files)) {
|
|
1162
|
-
this.add(filepath, fact.modifiedTs, fact.sourceVersion);
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
addLayerProps(props) {
|
|
1166
|
-
if (!props) return;
|
|
1167
|
-
this.add(
|
|
1168
|
-
props["data-tempo-filepath"],
|
|
1169
|
-
props["data-tempo-modifiedts"],
|
|
1170
|
-
props["data-tempo-source-version"]
|
|
1171
|
-
);
|
|
1172
|
-
}
|
|
1173
|
-
addElement(element) {
|
|
1174
|
-
this.add(
|
|
1175
|
-
element.getAttribute("data-tempo-filepath"),
|
|
1176
|
-
element.getAttribute("data-tempo-modifiedts"),
|
|
1177
|
-
element.getAttribute("data-tempo-source-version")
|
|
1178
|
-
);
|
|
1179
|
-
}
|
|
1180
|
-
snapshot() {
|
|
1181
|
-
return Object.fromEntries(
|
|
1182
|
-
Array.from(this.files, ([filepath, fact]) => [
|
|
1183
|
-
filepath,
|
|
1184
|
-
{
|
|
1185
|
-
modifiedTs: fact.modifiedTs,
|
|
1186
|
-
...fact.sourceVersion !== void 0 ? { sourceVersion: fact.sourceVersion } : {}
|
|
1187
|
-
}
|
|
1188
|
-
])
|
|
1189
|
-
);
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
// ../../modules/iframe-projection/html/watch-state.ts
|
|
1194
|
-
function watchState(root, onStateChange) {
|
|
1195
|
-
const scrolledElements = /* @__PURE__ */ new Set();
|
|
1196
|
-
const changedFormElements = /* @__PURE__ */ new Set();
|
|
1197
|
-
const stopRuntimeMutations = observeRuntimeMutations(root.ownerDocument);
|
|
1198
|
-
const handleScroll = (event) => {
|
|
1199
|
-
const target = event.target;
|
|
1200
|
-
if (target instanceof Element && root.contains(target)) {
|
|
1201
|
-
scrolledElements.add(target);
|
|
1202
|
-
watcher.stateRecordCount += 1;
|
|
1203
|
-
onStateChange();
|
|
1204
|
-
} else if (target === document) {
|
|
1205
|
-
const scrollTarget = document.scrollingElement || document.documentElement;
|
|
1206
|
-
if (scrollTarget) {
|
|
1207
|
-
scrolledElements.add(scrollTarget);
|
|
1208
|
-
watcher.stateRecordCount += 1;
|
|
1209
|
-
onStateChange();
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
};
|
|
1213
|
-
const handleFormChange = (event) => {
|
|
1214
|
-
if (event.target instanceof Element && root.contains(event.target)) {
|
|
1215
|
-
changedFormElements.add(event.target);
|
|
1216
|
-
watcher.projectionFormEvents.set(
|
|
1217
|
-
event.target,
|
|
1218
|
-
event.type === "change" ? "change" : "input"
|
|
1219
|
-
);
|
|
1220
|
-
watcher.stateRecordCount += 1;
|
|
1221
|
-
onStateChange();
|
|
1222
|
-
}
|
|
1223
|
-
};
|
|
1224
|
-
document.addEventListener("scroll", handleScroll, true);
|
|
1225
|
-
document.addEventListener("input", handleFormChange, true);
|
|
1226
|
-
document.addEventListener("change", handleFormChange, true);
|
|
1227
|
-
document.addEventListener(FORM_RUNTIME_MUTATION, handleFormChange, true);
|
|
1228
|
-
const watcher = {
|
|
1229
|
-
root,
|
|
1230
|
-
scrolledElements,
|
|
1231
|
-
changedFormElements,
|
|
1232
|
-
stateRecordCount: 0,
|
|
1233
|
-
projectionFormEvents: /* @__PURE__ */ new Map(),
|
|
1234
|
-
stop: () => {
|
|
1235
|
-
document.removeEventListener("scroll", handleScroll, true);
|
|
1236
|
-
document.removeEventListener("input", handleFormChange, true);
|
|
1237
|
-
document.removeEventListener("change", handleFormChange, true);
|
|
1238
|
-
document.removeEventListener(
|
|
1239
|
-
FORM_RUNTIME_MUTATION,
|
|
1240
|
-
handleFormChange,
|
|
1241
|
-
true
|
|
1242
|
-
);
|
|
1243
|
-
stopRuntimeMutations();
|
|
1244
|
-
scrolledElements.clear();
|
|
1245
|
-
changedFormElements.clear();
|
|
1246
|
-
watcher.stateRecordCount = 0;
|
|
1247
|
-
watcher.projectionFormEvents.clear();
|
|
1248
|
-
}
|
|
1249
|
-
};
|
|
1250
|
-
return watcher;
|
|
1251
|
-
}
|
|
1252
|
-
function flushStateWatcher(watcher) {
|
|
1253
|
-
const { root, scrolledElements, changedFormElements } = watcher;
|
|
1254
|
-
watcher.stateRecordCount = 0;
|
|
1255
|
-
watcher.projectionFormEvents.clear();
|
|
1256
|
-
const states = [];
|
|
1257
|
-
const scrolled = new Set(scrolledElements);
|
|
1258
|
-
const changed = new Set(changedFormElements);
|
|
1259
|
-
scrolledElements.clear();
|
|
1260
|
-
changedFormElements.clear();
|
|
1261
|
-
for (const el of scrolled) {
|
|
1262
|
-
const isDocumentScroll = el === document.scrollingElement || el === document.documentElement;
|
|
1263
|
-
if (!isDocumentScroll && !root.contains(el)) continue;
|
|
1264
|
-
const selector = isDocumentScroll ? ":root" : generateSelector(el, root);
|
|
1265
|
-
states.push({
|
|
1266
|
-
selector,
|
|
1267
|
-
scrollTop: el.scrollTop,
|
|
1268
|
-
scrollLeft: el.scrollLeft
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
1271
|
-
for (const el of changed) {
|
|
1272
|
-
if (!root.contains(el)) continue;
|
|
1273
|
-
if (el instanceof HTMLInputElement) {
|
|
1274
|
-
const isCheckable = el.type === "checkbox" || el.type === "radio";
|
|
1275
|
-
const hasNonDefault = isCheckable ? el.checked !== el.defaultChecked : el.value !== el.defaultValue;
|
|
1276
|
-
if (hasNonDefault) {
|
|
1277
|
-
const selector = generateSelector(el, root);
|
|
1278
|
-
if (isCheckable) {
|
|
1279
|
-
states.push({ selector, checked: el.checked });
|
|
1280
|
-
} else {
|
|
1281
|
-
states.push({ selector, value: el.value });
|
|
1282
|
-
}
|
|
1283
|
-
changedFormElements.add(el);
|
|
1284
|
-
}
|
|
1285
|
-
} else if (el instanceof HTMLTextAreaElement) {
|
|
1286
|
-
if (el.value !== el.defaultValue) {
|
|
1287
|
-
const selector = generateSelector(el, root);
|
|
1288
|
-
states.push({ selector, value: el.value });
|
|
1289
|
-
changedFormElements.add(el);
|
|
1290
|
-
}
|
|
1291
|
-
} else if (el instanceof HTMLSelectElement) {
|
|
1292
|
-
let hasNonDefault = false;
|
|
1293
|
-
for (const option of el.options) {
|
|
1294
|
-
if (option.selected !== option.defaultSelected) {
|
|
1295
|
-
const selector = generateSelector(option, root);
|
|
1296
|
-
states.push({ selector, selected: option.selected });
|
|
1297
|
-
hasNonDefault = true;
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
if (hasNonDefault) {
|
|
1301
|
-
changedFormElements.add(el);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
return states;
|
|
1306
|
-
}
|
|
1307
|
-
function drainProjectionStateEvents(watcher) {
|
|
1308
|
-
const events = [];
|
|
1309
|
-
for (const element of watcher.scrolledElements) {
|
|
1310
|
-
const isDocumentScroll = element === watcher.root.ownerDocument.scrollingElement || element === watcher.root.ownerDocument.documentElement;
|
|
1311
|
-
events.push({
|
|
1312
|
-
element: isDocumentScroll ? watcher.root : element,
|
|
1313
|
-
eventKind: "scroll"
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
|
-
for (const [element, eventKind] of watcher.projectionFormEvents) {
|
|
1317
|
-
events.push({ element, eventKind });
|
|
1318
|
-
}
|
|
1319
|
-
watcher.scrolledElements.clear();
|
|
1320
|
-
watcher.changedFormElements.clear();
|
|
1321
|
-
watcher.projectionFormEvents.clear();
|
|
1322
|
-
watcher.stateRecordCount = 0;
|
|
1323
|
-
return events;
|
|
1324
|
-
}
|
|
1325
|
-
function hasPendingStateChanges(watcher) {
|
|
1326
|
-
return watcher.scrolledElements.size > 0 || watcher.changedFormElements.size > 0;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
// ../../modules/iframe-projection/html/watch-portal.ts
|
|
1330
|
-
var portalIdCounter = 0;
|
|
1331
|
-
var PORTAL_ID_ATTR = "data-projection-portal-id";
|
|
1332
|
-
function getOrAssignPortalId(element) {
|
|
1333
|
-
const existing = element.getAttribute(PORTAL_ID_ATTR);
|
|
1334
|
-
if (existing) return existing;
|
|
1335
|
-
const id2 = `portal-${++portalIdCounter}`;
|
|
1336
|
-
element.setAttribute(PORTAL_ID_ATTR, id2);
|
|
1337
|
-
return id2;
|
|
1338
|
-
}
|
|
1339
|
-
function watchPortal(element, onTrigger, coordinateRoot) {
|
|
1340
|
-
const id2 = getOrAssignPortalId(element);
|
|
1341
|
-
const domWatcher = watchDom(element, onTrigger);
|
|
1342
|
-
const stateWatcher = watchState(element, onTrigger);
|
|
1343
|
-
return {
|
|
1344
|
-
id: id2,
|
|
1345
|
-
element,
|
|
1346
|
-
hasPendingChanges() {
|
|
1347
|
-
return hasPendingMutations(domWatcher) || hasPendingStateChanges(stateWatcher);
|
|
1348
|
-
},
|
|
1349
|
-
pendingRecordCount() {
|
|
1350
|
-
return domWatcher.mutationRecordCount + stateWatcher.stateRecordCount;
|
|
1351
|
-
},
|
|
1352
|
-
takePendingDomRecords: () => domWatcher.takePendingRecords(),
|
|
1353
|
-
clearPendingChanges() {
|
|
1354
|
-
return {
|
|
1355
|
-
dom: drainProjectionDomMutations(domWatcher),
|
|
1356
|
-
state: drainProjectionStateEvents(stateWatcher)
|
|
1357
|
-
};
|
|
1358
|
-
},
|
|
1359
|
-
flush(isInitial = false) {
|
|
1360
|
-
const hasDomChanges = hasPendingMutations(domWatcher);
|
|
1361
|
-
const hasStateChanges = hasPendingStateChanges(stateWatcher);
|
|
1362
|
-
if (!isInitial && !hasDomChanges && !hasStateChanges) {
|
|
1363
|
-
return null;
|
|
1364
|
-
}
|
|
1365
|
-
let targetElement = element;
|
|
1366
|
-
if (!isInitial && hasDomChanges) {
|
|
1367
|
-
const lca = flushDomWatcher(domWatcher);
|
|
1368
|
-
if (lca && element.contains(lca)) {
|
|
1369
|
-
targetElement = lca;
|
|
1370
|
-
}
|
|
1371
|
-
} else {
|
|
1372
|
-
flushDomWatcher(domWatcher);
|
|
1373
|
-
}
|
|
1374
|
-
const states = flushStateWatcher(stateWatcher);
|
|
1375
|
-
const selector = generateSelector(targetElement, element);
|
|
1376
|
-
const html = removeScriptTags(targetElement.outerHTML);
|
|
1377
|
-
const coordinateSpace = coordinateRoot ? capturePortalCoordinateSpace(coordinateRoot, element) : void 0;
|
|
1378
|
-
return {
|
|
1379
|
-
id: id2,
|
|
1380
|
-
selector,
|
|
1381
|
-
html,
|
|
1382
|
-
states,
|
|
1383
|
-
...coordinateSpace && { coordinateSpace }
|
|
1384
|
-
};
|
|
1385
|
-
},
|
|
1386
|
-
resampleCoordinates() {
|
|
1387
|
-
const coordinateSpace = coordinateRoot ? capturePortalCoordinateSpace(coordinateRoot, element) : void 0;
|
|
1388
|
-
if (!coordinateSpace) return null;
|
|
1389
|
-
return {
|
|
1390
|
-
id: id2,
|
|
1391
|
-
selector: "",
|
|
1392
|
-
html: "",
|
|
1393
|
-
states: [],
|
|
1394
|
-
coordinateSpace,
|
|
1395
|
-
coordinatesOnly: true
|
|
1396
|
-
};
|
|
1397
|
-
},
|
|
1398
|
-
stop() {
|
|
1399
|
-
domWatcher.stop();
|
|
1400
|
-
stateWatcher.stop();
|
|
1401
|
-
}
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1404
|
-
function capturePortalCoordinateSpace(root, portal) {
|
|
1405
|
-
const viewport = root.ownerDocument?.defaultView;
|
|
1406
|
-
if (!viewport) return void 0;
|
|
1407
|
-
const rect = root.getBoundingClientRect();
|
|
1408
|
-
return {
|
|
1409
|
-
origin: portal ? choosePortalCoordinateOrigin(rect, portal) : "root",
|
|
1410
|
-
rootViewportLeft: rect.left,
|
|
1411
|
-
rootViewportTop: rect.top,
|
|
1412
|
-
viewportWidth: viewport.innerWidth,
|
|
1413
|
-
viewportHeight: viewport.innerHeight
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
1416
|
-
function choosePortalCoordinateOrigin(rootRect, portal) {
|
|
1417
|
-
const view = portal.ownerDocument.defaultView;
|
|
1418
|
-
return choosePortalRectOrigin(rootRect, measurePortalBounds(portal), {
|
|
1419
|
-
width: view?.innerWidth ?? 0,
|
|
1420
|
-
height: view?.innerHeight ?? 0
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
function choosePortalRectOrigin(rootRect, portalRect, viewport) {
|
|
1424
|
-
const localViewport = {
|
|
1425
|
-
left: 0,
|
|
1426
|
-
top: 0,
|
|
1427
|
-
right: rootRect.width,
|
|
1428
|
-
bottom: rootRect.height
|
|
1429
|
-
};
|
|
1430
|
-
const coversSourceViewport = portalRect.left <= 0 && portalRect.top <= 0 && portalRect.right >= viewport.width && portalRect.bottom >= viewport.height;
|
|
1431
|
-
if (coversSourceViewport) return "viewport";
|
|
1432
|
-
if (rectanglesOverlap(rootRect, portalRect)) return "root";
|
|
1433
|
-
const directScore = visibleArea(portalRect, localViewport);
|
|
1434
|
-
const rebasedScore = visibleArea(
|
|
1435
|
-
{
|
|
1436
|
-
left: portalRect.left - rootRect.left,
|
|
1437
|
-
top: portalRect.top - rootRect.top,
|
|
1438
|
-
right: portalRect.right - rootRect.left,
|
|
1439
|
-
bottom: portalRect.bottom - rootRect.top
|
|
1440
|
-
},
|
|
1441
|
-
localViewport
|
|
1442
|
-
);
|
|
1443
|
-
if (rebasedScore > directScore) return "root";
|
|
1444
|
-
if (directScore > rebasedScore) return "viewport";
|
|
1445
|
-
return "viewport";
|
|
1446
|
-
}
|
|
1447
|
-
function measurePortalBounds(portal) {
|
|
1448
|
-
const ownRect = portal.getBoundingClientRect();
|
|
1449
|
-
if (hasArea(ownRect)) return ownRect;
|
|
1450
|
-
let left = Number.POSITIVE_INFINITY;
|
|
1451
|
-
let top = Number.POSITIVE_INFINITY;
|
|
1452
|
-
let right = Number.NEGATIVE_INFINITY;
|
|
1453
|
-
let bottom = Number.NEGATIVE_INFINITY;
|
|
1454
|
-
for (const descendant of Array.from(portal.querySelectorAll("*"))) {
|
|
1455
|
-
const rect = descendant.getBoundingClientRect();
|
|
1456
|
-
if (!hasArea(rect)) continue;
|
|
1457
|
-
left = Math.min(left, rect.left);
|
|
1458
|
-
top = Math.min(top, rect.top);
|
|
1459
|
-
right = Math.max(right, rect.right);
|
|
1460
|
-
bottom = Math.max(bottom, rect.bottom);
|
|
1461
|
-
}
|
|
1462
|
-
return Number.isFinite(left) ? { left, top, right, bottom } : ownRect;
|
|
1463
|
-
}
|
|
1464
|
-
function hasArea(rect) {
|
|
1465
|
-
return rect.right > rect.left && rect.bottom > rect.top;
|
|
1466
|
-
}
|
|
1467
|
-
function visibleArea(rect, viewport) {
|
|
1468
|
-
const width = Math.max(
|
|
1469
|
-
0,
|
|
1470
|
-
Math.min(rect.right, viewport.right) - Math.max(rect.left, viewport.left)
|
|
1471
|
-
);
|
|
1472
|
-
const height = Math.max(
|
|
1473
|
-
0,
|
|
1474
|
-
Math.min(rect.bottom, viewport.bottom) - Math.max(rect.top, viewport.top)
|
|
1475
|
-
);
|
|
1476
|
-
return width * height;
|
|
1477
|
-
}
|
|
1478
|
-
function rectanglesOverlap(a, b) {
|
|
1479
|
-
return a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
// ../../modules/iframe-projection/combined/css-escape.ts
|
|
1483
|
-
function cssEscape(value) {
|
|
1484
|
-
return globalThis.CSS?.escape ? globalThis.CSS.escape(value) : value.replace(/["\\]/g, "\\$&");
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
// ../../modules/iframe-projection/combined/projection-patch.ts
|
|
1488
|
-
var SOURCE_ANNOTATION_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
1489
|
-
"data-tempo-filepath",
|
|
1490
|
-
"data-tempo-position",
|
|
1491
|
-
"data-tempo-modifiedts",
|
|
1492
|
-
"data-tempo-source-version",
|
|
1493
|
-
// Expression facts describe the same callsite, so they travel, update and
|
|
1494
|
-
// are distrusted exactly like the location stamps.
|
|
1495
|
-
"data-tempo-expr"
|
|
1496
|
-
]);
|
|
1497
|
-
var PROJECTION_ROOT_TARGET_ID = "$projection-root";
|
|
1498
|
-
function captureProjectionMutationPatch(root, mutations, options = {}) {
|
|
1499
|
-
const observedFiles = new ProjectionObservedFileAccumulator();
|
|
1500
|
-
const fallbackRegions = /* @__PURE__ */ new Set();
|
|
1501
|
-
const childListMutations = [];
|
|
1502
|
-
const characterDataTargets = [];
|
|
1503
|
-
const attributes = /* @__PURE__ */ new Map();
|
|
1504
|
-
const metadataTargets = /* @__PURE__ */ new Set();
|
|
1505
|
-
for (const mutation of mutations) {
|
|
1506
|
-
const element = mutationTargetElement(mutation.target);
|
|
1507
|
-
if (!element || element !== root && !root.contains(element)) continue;
|
|
1508
|
-
if (mutation.type === "attributes" && mutation.attributeName) {
|
|
1509
|
-
const isSourceMetadata = SOURCE_ANNOTATION_ATTRIBUTES.has(
|
|
1510
|
-
mutation.attributeName
|
|
1511
|
-
);
|
|
1512
|
-
if (isSourceMetadata) {
|
|
1513
|
-
metadataTargets.add(element);
|
|
1514
|
-
continue;
|
|
1515
|
-
}
|
|
1516
|
-
const names = attributes.get(element) ?? /* @__PURE__ */ new Set();
|
|
1517
|
-
names.add(mutation.attributeName);
|
|
1518
|
-
attributes.set(element, names);
|
|
1519
|
-
continue;
|
|
1520
|
-
}
|
|
1521
|
-
if (mutation.type === "characterData") {
|
|
1522
|
-
characterDataTargets.push(mutation.target);
|
|
1523
|
-
} else {
|
|
1524
|
-
const carriesNoChildDetail = mutation.addedNodes === void 0 && mutation.removedNodes === void 0;
|
|
1525
|
-
if (options.regionalChildLists || carriesNoChildDetail) {
|
|
1526
|
-
fallbackRegions.add(element);
|
|
1527
|
-
} else {
|
|
1528
|
-
childListMutations.push(mutation);
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
const addedElements = coalesceElements(
|
|
1533
|
-
childListMutations.flatMap(
|
|
1534
|
-
(mutation) => Array.from(mutation.addedNodes ?? []).filter(
|
|
1535
|
-
(node) => node instanceof Element && root.contains(node)
|
|
1536
|
-
)
|
|
1537
|
-
)
|
|
1538
|
-
);
|
|
1539
|
-
const removedElements = coalesceElements(
|
|
1540
|
-
childListMutations.flatMap(
|
|
1541
|
-
(mutation) => Array.from(mutation.removedNodes ?? []).filter(
|
|
1542
|
-
(node) => node instanceof Element && !root.contains(node)
|
|
1543
|
-
)
|
|
1544
|
-
)
|
|
1545
|
-
);
|
|
1546
|
-
const coveredByAddedElement = (element) => addedElements.some((added) => added === element || added.contains(element));
|
|
1547
|
-
const placements = [];
|
|
1548
|
-
const removals = [];
|
|
1549
|
-
const metadata = [];
|
|
1550
|
-
for (const removed of removedElements) {
|
|
1551
|
-
const targetId = readProjectionDomId(removed);
|
|
1552
|
-
if (targetId) removals.push({ kind: "remove", targetId });
|
|
1553
|
-
}
|
|
1554
|
-
addedElements.sort(reverseDocumentOrder);
|
|
1555
|
-
for (const added of addedElements) {
|
|
1556
|
-
if (added.tagName.toLowerCase() === "script") continue;
|
|
1557
|
-
const parent = added.parentElement;
|
|
1558
|
-
if (!parent || parent !== root && !root.contains(parent)) continue;
|
|
1559
|
-
const parentId = projectionTargetId(root, parent);
|
|
1560
|
-
const targetId = ensureProjectionDomId(added);
|
|
1561
|
-
if (!parentId || !targetId) {
|
|
1562
|
-
fallbackRegions.add(parent);
|
|
1563
|
-
continue;
|
|
1564
|
-
}
|
|
1565
|
-
const before = added.nextElementSibling;
|
|
1566
|
-
const beforeId = before ? ensureProjectionDomId(before) : null;
|
|
1567
|
-
if (before && !beforeId) {
|
|
1568
|
-
fallbackRegions.add(parent);
|
|
1569
|
-
continue;
|
|
1570
|
-
}
|
|
1571
|
-
const captured = capturePlacedElementWithoutAnnotations(
|
|
1572
|
-
added,
|
|
1573
|
-
observedFiles
|
|
1574
|
-
);
|
|
1575
|
-
placements.push({
|
|
1576
|
-
kind: "place",
|
|
1577
|
-
parentId,
|
|
1578
|
-
targetId,
|
|
1579
|
-
beforeId,
|
|
1580
|
-
html: captured.html,
|
|
1581
|
-
ancestorIds: captureProjectionAncestorIds(root, added)
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
|
-
for (const target of characterDataTargets) {
|
|
1585
|
-
const parent = target.parentElement;
|
|
1586
|
-
if (!parent || coveredByAddedElement(parent)) continue;
|
|
1587
|
-
const targetId = ensureProjectionDomId(target, root);
|
|
1588
|
-
if (targetId)
|
|
1589
|
-
metadata.push({
|
|
1590
|
-
targetId,
|
|
1591
|
-
targetFiberId: targetId,
|
|
1592
|
-
content: target.textContent ?? "",
|
|
1593
|
-
ancestorIds: [
|
|
1594
|
-
ensureProjectionDomId(parent, root),
|
|
1595
|
-
...captureProjectionAncestorIds(root, parent)
|
|
1596
|
-
]
|
|
1597
|
-
});
|
|
1598
|
-
}
|
|
1599
|
-
for (const mutation of childListMutations) {
|
|
1600
|
-
const nodes = [
|
|
1601
|
-
...mutation.addedNodes ?? [],
|
|
1602
|
-
...mutation.removedNodes ?? []
|
|
1603
|
-
];
|
|
1604
|
-
if (nodes.some((node) => !(node instanceof Element))) {
|
|
1605
|
-
const parent = mutation.target instanceof Element ? mutation.target : mutation.target.parentElement;
|
|
1606
|
-
if (parent && !coveredByAddedElement(parent)) fallbackRegions.add(parent);
|
|
1607
|
-
}
|
|
1608
|
-
}
|
|
1609
|
-
for (const element of [...attributes.keys()]) {
|
|
1610
|
-
if (projectionTargetId(root, element)) continue;
|
|
1611
|
-
attributes.delete(element);
|
|
1612
|
-
fallbackRegions.add(widenToIdentifiableRegion(root, element));
|
|
1613
|
-
}
|
|
1614
|
-
for (const region of [...fallbackRegions]) {
|
|
1615
|
-
if (projectionTargetId(root, region)) continue;
|
|
1616
|
-
fallbackRegions.delete(region);
|
|
1617
|
-
fallbackRegions.add(widenToIdentifiableRegion(root, region));
|
|
1618
|
-
}
|
|
1619
|
-
const survivingRegions = coalesceRegions(fallbackRegions);
|
|
1620
|
-
const isInsideRegion = (element) => survivingRegions.some(
|
|
1621
|
-
(region) => region !== element && region.contains(element)
|
|
1622
|
-
);
|
|
1623
|
-
for (const element of attributes.keys()) {
|
|
1624
|
-
if (isInsideRegion(element) || coveredByAddedElement(element)) {
|
|
1625
|
-
attributes.delete(element);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
const regionCaptures = /* @__PURE__ */ new Map();
|
|
1629
|
-
for (const region of survivingRegions) {
|
|
1630
|
-
const captured = captureRegionWithoutAnnotations(region, observedFiles);
|
|
1631
|
-
regionCaptures.set(region, captured);
|
|
1632
|
-
}
|
|
1633
|
-
const allTargets = /* @__PURE__ */ new Set([
|
|
1634
|
-
...survivingRegions,
|
|
1635
|
-
...attributes.keys()
|
|
1636
|
-
]);
|
|
1637
|
-
const ids = /* @__PURE__ */ new Map();
|
|
1638
|
-
for (const element of allTargets) {
|
|
1639
|
-
const id2 = projectionTargetId(root, element);
|
|
1640
|
-
if (id2) ids.set(element, id2);
|
|
1641
|
-
}
|
|
1642
|
-
const pointerEventsNone = /* @__PURE__ */ new Set();
|
|
1643
|
-
const pointerRoots = [
|
|
1644
|
-
...survivingRegions,
|
|
1645
|
-
...addedElements.filter(
|
|
1646
|
-
(element) => !survivingRegions.some(
|
|
1647
|
-
(region) => region === element || region.contains(element)
|
|
1648
|
-
)
|
|
1649
|
-
)
|
|
1650
|
-
];
|
|
1651
|
-
for (const element of pointerRoots) {
|
|
1652
|
-
for (const target of projectedElements(element)) {
|
|
1653
|
-
const id2 = target.getAttribute(DOM_ID_ATTR);
|
|
1654
|
-
if (id2 && target.ownerDocument.defaultView?.getComputedStyle(target).pointerEvents === "none") {
|
|
1655
|
-
pointerEventsNone.add(id2);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
for (const element of attributes.keys()) {
|
|
1660
|
-
const id2 = ids.get(element);
|
|
1661
|
-
if (id2 && element.ownerDocument.defaultView?.getComputedStyle(element).pointerEvents === "none") {
|
|
1662
|
-
pointerEventsNone.add(id2);
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
return {
|
|
1666
|
-
...metadata.length ? { layers: { metadata } } : {},
|
|
1667
|
-
...pointerEventsNone.size > 0 ? { pointerEventsNone: [...pointerEventsNone] } : {},
|
|
1668
|
-
dom: [
|
|
1669
|
-
...removals.filter(
|
|
1670
|
-
(change) => !survivingRegions.some(
|
|
1671
|
-
(region) => region.querySelector(
|
|
1672
|
-
`[${DOM_ID_ATTR}="${cssEscape(change.targetId)}"]`
|
|
1673
|
-
)
|
|
1674
|
-
)
|
|
1675
|
-
),
|
|
1676
|
-
...placements.filter(
|
|
1677
|
-
(change) => !isCoveredTargetId(root, survivingRegions, change.targetId)
|
|
1678
|
-
),
|
|
1679
|
-
...survivingRegions.map(
|
|
1680
|
-
(element) => ({
|
|
1681
|
-
kind: "children",
|
|
1682
|
-
targetId: ids.get(element),
|
|
1683
|
-
html: regionCaptures.get(element).html,
|
|
1684
|
-
ancestorIds: captureProjectionAncestorIds(root, element)
|
|
1685
|
-
})
|
|
1686
|
-
),
|
|
1687
|
-
...Array.from(
|
|
1688
|
-
attributes,
|
|
1689
|
-
([element, names]) => ({
|
|
1690
|
-
kind: "attributes",
|
|
1691
|
-
targetId: ids.get(element),
|
|
1692
|
-
attributes: captureFinalAttributes(element, names),
|
|
1693
|
-
ancestorIds: captureProjectionAncestorIds(root, element)
|
|
1694
|
-
})
|
|
1695
|
-
)
|
|
1696
|
-
],
|
|
1697
|
-
localMetadataTargets: Array.from(metadataTargets),
|
|
1698
|
-
observedFiles: observedFiles.snapshot()
|
|
1699
|
-
};
|
|
1700
|
-
}
|
|
1701
|
-
function captureProjectionStatePatch(root, element, eventKind) {
|
|
1702
|
-
const targetId = ensureProjectionDomId(element);
|
|
1703
|
-
if (!targetId) return null;
|
|
1704
|
-
const ancestorIds = captureProjectionAncestorIds(root, element);
|
|
1705
|
-
if (eventKind === "scroll") {
|
|
1706
|
-
return {
|
|
1707
|
-
targetId,
|
|
1708
|
-
kind: "scroll",
|
|
1709
|
-
scrollTop: element.scrollTop,
|
|
1710
|
-
scrollLeft: element.scrollLeft,
|
|
1711
|
-
ancestorIds
|
|
1712
|
-
};
|
|
1713
|
-
}
|
|
1714
|
-
if (element instanceof HTMLInputElement) {
|
|
1715
|
-
if (element.type === "checkbox" || element.type === "radio") {
|
|
1716
|
-
return {
|
|
1717
|
-
targetId,
|
|
1718
|
-
kind: "checked",
|
|
1719
|
-
checked: element.checked,
|
|
1720
|
-
ancestorIds
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
|
-
return {
|
|
1724
|
-
targetId,
|
|
1725
|
-
kind: "value",
|
|
1726
|
-
value: element.value,
|
|
1727
|
-
selectionStart: element.selectionStart,
|
|
1728
|
-
selectionEnd: element.selectionEnd,
|
|
1729
|
-
ancestorIds
|
|
1730
|
-
};
|
|
1731
|
-
}
|
|
1732
|
-
if (element instanceof HTMLTextAreaElement) {
|
|
1733
|
-
return {
|
|
1734
|
-
targetId,
|
|
1735
|
-
kind: "value",
|
|
1736
|
-
value: element.value,
|
|
1737
|
-
selectionStart: element.selectionStart,
|
|
1738
|
-
selectionEnd: element.selectionEnd,
|
|
1739
|
-
ancestorIds
|
|
1740
|
-
};
|
|
1741
|
-
}
|
|
1742
|
-
if (element instanceof HTMLSelectElement) {
|
|
1743
|
-
const selectedIndices = [];
|
|
1744
|
-
for (let index = 0; index < element.options.length; index += 1) {
|
|
1745
|
-
if (element.options[index]?.selected) selectedIndices.push(index);
|
|
1746
|
-
}
|
|
1747
|
-
return { targetId, kind: "selected", selectedIndices, ancestorIds };
|
|
1748
|
-
}
|
|
1749
|
-
return null;
|
|
1750
|
-
}
|
|
1751
|
-
function captureProjectionPortalRegion(element, removed = false, coordinateRoot) {
|
|
1752
|
-
const portalId = element.getAttribute(PORTAL_ID_ATTR);
|
|
1753
|
-
if (!portalId) return null;
|
|
1754
|
-
if (removed) {
|
|
1755
|
-
return {
|
|
1756
|
-
portal: { kind: "remove", portalId },
|
|
1757
|
-
observedFiles: {},
|
|
1758
|
-
state: []
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
const liveElements = projectedElements(element);
|
|
1762
|
-
for (const live of liveElements) ensureProjectionDomId(live);
|
|
1763
|
-
const clone = cloneProjectionDom(element);
|
|
1764
|
-
syncProjectionDomIdsToClone(element, clone);
|
|
1765
|
-
for (const script of clone.querySelectorAll("script")) script.remove();
|
|
1766
|
-
const observedFiles = new ProjectionObservedFileAccumulator();
|
|
1767
|
-
stripSourceAnnotations(clone, observedFiles, true);
|
|
1768
|
-
const state = [];
|
|
1769
|
-
for (const live of liveElements) {
|
|
1770
|
-
if (live.scrollTop === 0 && live.scrollLeft === 0) continue;
|
|
1771
|
-
const scroll = captureProjectionStatePatch(element, live, "scroll");
|
|
1772
|
-
if (scroll) state.push(scroll);
|
|
1773
|
-
}
|
|
1774
|
-
const coordinateSpace = coordinateRoot ? capturePortalCoordinateSpace(coordinateRoot, element) : void 0;
|
|
1775
|
-
return {
|
|
1776
|
-
portal: {
|
|
1777
|
-
kind: "replace",
|
|
1778
|
-
portalId,
|
|
1779
|
-
html: removeScriptTags(clone.outerHTML),
|
|
1780
|
-
...coordinateSpace && { coordinateSpace }
|
|
1781
|
-
},
|
|
1782
|
-
observedFiles: observedFiles.snapshot(),
|
|
1783
|
-
state
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1786
|
-
function captureProjectionPortalCoordinates(root, element) {
|
|
1787
|
-
const portalId = element.getAttribute(PORTAL_ID_ATTR);
|
|
1788
|
-
const coordinateSpace = capturePortalCoordinateSpace(root, element);
|
|
1789
|
-
if (!portalId || !coordinateSpace) return null;
|
|
1790
|
-
return {
|
|
1791
|
-
kind: "replace",
|
|
1792
|
-
portalId,
|
|
1793
|
-
html: "",
|
|
1794
|
-
coordinateSpace,
|
|
1795
|
-
coordinatesOnly: true
|
|
1796
|
-
};
|
|
1797
|
-
}
|
|
1798
|
-
function mutationTargetElement(target) {
|
|
1799
|
-
return target instanceof Element ? target : target.parentElement;
|
|
1800
|
-
}
|
|
1801
|
-
function projectionTargetId(root, element) {
|
|
1802
|
-
return element === root ? PROJECTION_ROOT_TARGET_ID : ensureProjectionDomId(element);
|
|
1803
|
-
}
|
|
1804
|
-
function coalesceElements(elements) {
|
|
1805
|
-
const unique = Array.from(new Set(elements));
|
|
1806
|
-
return unique.filter(
|
|
1807
|
-
(candidate) => !unique.some((other) => other !== candidate && other.contains(candidate))
|
|
1808
|
-
);
|
|
1809
|
-
}
|
|
1810
|
-
function reverseDocumentOrder(left, right) {
|
|
1811
|
-
if (left === right) return 0;
|
|
1812
|
-
const position = left.compareDocumentPosition(right);
|
|
1813
|
-
if (position & 4) return 1;
|
|
1814
|
-
if (position & 2) return -1;
|
|
1815
|
-
return 0;
|
|
1816
|
-
}
|
|
1817
|
-
function capturePlacedElementWithoutAnnotations(element, observedFiles) {
|
|
1818
|
-
for (const live of projectedElements(element)) ensureProjectionDomId(live);
|
|
1819
|
-
const clone = cloneProjectionDom(element);
|
|
1820
|
-
syncProjectionDomIdsToClone(element, clone);
|
|
1821
|
-
if (clone.tagName.toLowerCase() === "script") {
|
|
1822
|
-
return { html: "" };
|
|
1823
|
-
}
|
|
1824
|
-
for (const script of clone.querySelectorAll("script")) script.remove();
|
|
1825
|
-
stripSourceAnnotations(clone, observedFiles, true);
|
|
1826
|
-
return { html: clone.outerHTML };
|
|
1827
|
-
}
|
|
1828
|
-
function isCoveredTargetId(root, regions, targetId) {
|
|
1829
|
-
const target = targetId === PROJECTION_ROOT_TARGET_ID ? root : root.querySelector(`[${DOM_ID_ATTR}="${cssEscape(targetId)}"]`);
|
|
1830
|
-
return target ? regions.some((region) => region === target || region.contains(target)) : false;
|
|
1831
|
-
}
|
|
1832
|
-
function coalesceRegions(regions) {
|
|
1833
|
-
const candidates = Array.from(regions);
|
|
1834
|
-
return candidates.filter(
|
|
1835
|
-
(candidate) => !candidates.some(
|
|
1836
|
-
(other) => other !== candidate && other.contains(candidate)
|
|
1837
|
-
)
|
|
1838
|
-
);
|
|
1839
|
-
}
|
|
1840
|
-
function captureFinalAttributes(element, names) {
|
|
1841
|
-
return Object.fromEntries(
|
|
1842
|
-
Array.from(names, (name) => [name, element.getAttribute(name)])
|
|
1843
|
-
);
|
|
1844
|
-
}
|
|
1845
|
-
function stripSourceAnnotations(cloneRoot, observedFiles, includeRoot) {
|
|
1846
|
-
for (const registry of cloneRoot.querySelectorAll(
|
|
1847
|
-
"template[data-tempo-svelte-source-registry]"
|
|
1848
|
-
))
|
|
1849
|
-
registry.remove();
|
|
1850
|
-
const comments = cloneRoot.ownerDocument.createTreeWalker(
|
|
1851
|
-
cloneRoot,
|
|
1852
|
-
NodeFilter.SHOW_COMMENT
|
|
1853
|
-
);
|
|
1854
|
-
const markers = [];
|
|
1855
|
-
for (let node = comments.nextNode(); node; node = comments.nextNode())
|
|
1856
|
-
if (readAstroMarker(node)) markers.push(node);
|
|
1857
|
-
for (const node of markers) node.parentNode?.removeChild(node);
|
|
1858
|
-
const hostDomIds = /* @__PURE__ */ new Set();
|
|
1859
|
-
const walker = cloneRoot.ownerDocument.createTreeWalker(
|
|
1860
|
-
cloneRoot,
|
|
1861
|
-
NodeFilter.SHOW_ELEMENT
|
|
1862
|
-
);
|
|
1863
|
-
let copy = includeRoot ? cloneRoot : walker.nextNode();
|
|
1864
|
-
while (copy) {
|
|
1865
|
-
observedFiles.add(
|
|
1866
|
-
copy.getAttribute("data-tempo-filepath"),
|
|
1867
|
-
copy.getAttribute("data-tempo-modifiedts"),
|
|
1868
|
-
copy.getAttribute("data-tempo-source-version")
|
|
1869
|
-
);
|
|
1870
|
-
const domId = copy.getAttribute(DOM_ID_ATTR);
|
|
1871
|
-
if (domId) hostDomIds.add(domId);
|
|
1872
|
-
for (const name of SOURCE_ANNOTATION_ATTRIBUTES) copy.removeAttribute(name);
|
|
1873
|
-
copy = walker.nextNode();
|
|
1874
|
-
}
|
|
1875
|
-
return hostDomIds;
|
|
1876
|
-
}
|
|
1877
|
-
function captureRegionWithoutAnnotations(element, observedFiles) {
|
|
1878
|
-
for (const live of projectedElements(element)) ensureProjectionDomId(live);
|
|
1879
|
-
const clone = cloneProjectionDom(element);
|
|
1880
|
-
syncProjectionDomIdsToClone(element, clone, false);
|
|
1881
|
-
for (const script of clone.querySelectorAll("script")) script.remove();
|
|
1882
|
-
stripSourceAnnotations(clone, observedFiles, false);
|
|
1883
|
-
return { html: clone.innerHTML };
|
|
1884
|
-
}
|
|
1885
|
-
function widenToIdentifiableRegion(root, element) {
|
|
1886
|
-
for (let current = element; current && current !== root; current = current.parentElement) {
|
|
1887
|
-
if (readProjectionDomId(current)) return current;
|
|
1888
|
-
}
|
|
1889
|
-
return root;
|
|
1890
|
-
}
|
|
1891
|
-
function captureProjectionAncestorIds(root, element) {
|
|
1892
|
-
if (element === root) return [];
|
|
1893
|
-
const ids = [];
|
|
1894
|
-
for (let current = element.parentElement; current && current !== root; current = current.parentElement) {
|
|
1895
|
-
const id2 = readProjectionDomId(current);
|
|
1896
|
-
if (id2) {
|
|
1897
|
-
ensureProjectionDomId(current);
|
|
1898
|
-
ids.push(id2);
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
return ids;
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
// ../../modules/iframe-projection/combined/projection-dom-layers.ts
|
|
1905
|
-
var DOM_LAYER_ROOT_ID = "dom:$projection-root";
|
|
1906
|
-
var DOM_LAYER_FIBER_PREFIX = "dom:";
|
|
1907
|
-
function createProjectionDomLayerSerializer() {
|
|
1908
|
-
let nextElementId = 1;
|
|
1909
|
-
const elementIds = /* @__PURE__ */ new WeakMap();
|
|
1910
|
-
const domIdOwners = /* @__PURE__ */ new Map();
|
|
1911
|
-
const identity = {
|
|
1912
|
-
id: /* @__PURE__ */ new WeakMap(),
|
|
1913
|
-
publishedProps: /* @__PURE__ */ new WeakMap(),
|
|
1914
|
-
layerIdForElement(_root, element) {
|
|
1915
|
-
const existing = elementIds.get(element);
|
|
1916
|
-
if (existing) return existing;
|
|
1917
|
-
const id2 = `${DOM_LAYER_FIBER_PREFIX}element:${nextElementId++}`;
|
|
1918
|
-
elementIds.set(element, id2);
|
|
1919
|
-
return id2;
|
|
1920
|
-
},
|
|
1921
|
-
bindableDomIdForElement(root, element) {
|
|
1922
|
-
const domId = ensureProjectionDomId(element);
|
|
1923
|
-
if (!domId) return null;
|
|
1924
|
-
const owner = domIdOwners.get(domId);
|
|
1925
|
-
if (owner === element) return domId;
|
|
1926
|
-
if (!owner || !root.contains(owner)) {
|
|
1927
|
-
domIdOwners.set(domId, element);
|
|
1928
|
-
return domId;
|
|
1929
|
-
}
|
|
1930
|
-
return null;
|
|
1931
|
-
}
|
|
1932
|
-
};
|
|
1933
|
-
return {
|
|
1934
|
-
serializeRoot(root, observedFiles = {}) {
|
|
1935
|
-
return serializeProjectionDomLayerRootWithIdentity(
|
|
1936
|
-
root,
|
|
1937
|
-
observedFiles,
|
|
1938
|
-
identity
|
|
1939
|
-
);
|
|
1940
|
-
},
|
|
1941
|
-
capturePatch(root, targets, observedFiles = {}) {
|
|
1942
|
-
return captureProjectionDomLayerPatchFromTargets(
|
|
1943
|
-
root,
|
|
1944
|
-
targets,
|
|
1945
|
-
observedFiles,
|
|
1946
|
-
identity
|
|
1947
|
-
);
|
|
1948
|
-
}
|
|
1949
|
-
};
|
|
1950
|
-
}
|
|
1951
|
-
var dataDomLayerIdentity = {
|
|
1952
|
-
id: /* @__PURE__ */ new WeakMap(),
|
|
1953
|
-
layerIdForElement: domLayerIdForElement,
|
|
1954
|
-
bindableDomIdForElement: (_root, element) => ensureProjectionDomId(element)
|
|
1955
|
-
};
|
|
1956
|
-
function serializeProjectionDomLayerRootWithIdentity(root, observedFiles, identity) {
|
|
1957
|
-
const observed = new ProjectionObservedFileAccumulator();
|
|
1958
|
-
observed.merge(observedFiles);
|
|
1959
|
-
const tree = serializeDomLayerRootNode(root, identity, observed);
|
|
1960
|
-
return {
|
|
1961
|
-
semantic: { kind: "layers", tree },
|
|
1962
|
-
observedFiles: observed.snapshot()
|
|
1963
|
-
};
|
|
1964
|
-
}
|
|
1965
|
-
function captureProjectionDomLayerPatchFromTargets(root, targets, observedFiles, identity) {
|
|
1966
|
-
const structuralTargets = new Set(
|
|
1967
|
-
targets.structural.filter(
|
|
1968
|
-
(target) => target === root || root.contains(target)
|
|
1969
|
-
)
|
|
1970
|
-
);
|
|
1971
|
-
const metadataTargets = new Set(
|
|
1972
|
-
targets.metadata.filter(
|
|
1973
|
-
(target) => target === root || root.contains(target)
|
|
1974
|
-
)
|
|
1975
|
-
);
|
|
1976
|
-
const regions = Array.from(structuralTargets).filter(
|
|
1977
|
-
(candidate) => !Array.from(structuralTargets).some(
|
|
1978
|
-
(other) => other !== candidate && other.contains(candidate)
|
|
1979
|
-
)
|
|
1980
|
-
);
|
|
1981
|
-
const regionSnapshots = regions.map(
|
|
1982
|
-
(target) => {
|
|
1983
|
-
const observed = new ProjectionObservedFileAccumulator();
|
|
1984
|
-
observed.merge(observedFiles);
|
|
1985
|
-
const tree = target === root ? serializeDomLayerRootNode(root, identity, observed) : serializeDomLayerNode(root, target, identity, observed);
|
|
1986
|
-
return {
|
|
1987
|
-
targetFiberId: layerIdForTarget(root, target, identity),
|
|
1988
|
-
targetId: id(root, target, identity),
|
|
1989
|
-
tree,
|
|
1990
|
-
observedFiles: observed.snapshot()
|
|
1991
|
-
};
|
|
1992
|
-
}
|
|
1993
|
-
);
|
|
1994
|
-
const metadataSnapshots = [];
|
|
1995
|
-
for (const target of metadataTargets) {
|
|
1996
|
-
if (target !== root && regions.some((region) => region === root || region.contains(target))) {
|
|
1997
|
-
continue;
|
|
1998
|
-
}
|
|
1999
|
-
const targetFiberId = layerIdForTarget(root, target, identity);
|
|
2000
|
-
const targetId = id(root, target, identity);
|
|
2001
|
-
const props = captureProjectionDomLayerProps(target);
|
|
2002
|
-
const published = identity.publishedProps;
|
|
2003
|
-
if (published?.has(target) && layerPropsEqual(published.get(target), props))
|
|
2004
|
-
continue;
|
|
2005
|
-
published?.set(target, props);
|
|
2006
|
-
metadataSnapshots.push({ targetFiberId, targetId, props });
|
|
2007
|
-
}
|
|
2008
|
-
if (regionSnapshots.length === 0 && metadataSnapshots.length === 0) {
|
|
2009
|
-
return void 0;
|
|
2010
|
-
}
|
|
2011
|
-
return {
|
|
2012
|
-
...regionSnapshots.length > 0 ? { regions: regionSnapshots } : {},
|
|
2013
|
-
...metadataSnapshots.length > 0 ? { metadata: metadataSnapshots } : {}
|
|
2014
|
-
};
|
|
2015
|
-
}
|
|
2016
|
-
function serializeDomLayerRootNode(root, identity, observedFiles, children) {
|
|
2017
|
-
const name = root.tagName.toLowerCase();
|
|
2018
|
-
const stamps = rootSourceStamps(root);
|
|
2019
|
-
observedFiles?.addLayerProps(stamps);
|
|
2020
|
-
return {
|
|
2021
|
-
kind: "fragment",
|
|
2022
|
-
runtime: "dom",
|
|
2023
|
-
id: id(root, root, identity),
|
|
2024
|
-
key: null,
|
|
2025
|
-
name,
|
|
2026
|
-
domId: null,
|
|
2027
|
-
elementTag: null,
|
|
2028
|
-
...stamps ? { props: stamps } : {},
|
|
2029
|
-
source: {
|
|
2030
|
-
kind: "react-fiber",
|
|
2031
|
-
fiber: {
|
|
2032
|
-
tag: FiberTag.HostRoot,
|
|
2033
|
-
name,
|
|
2034
|
-
id: DOM_LAYER_ROOT_ID
|
|
2035
|
-
}
|
|
2036
|
-
},
|
|
2037
|
-
children: Array.from(root.childNodes).filter(
|
|
2038
|
-
(child) => !(child instanceof Element) || child.localName !== "script" && !child.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)
|
|
2039
|
-
).flatMap(
|
|
2040
|
-
(child) => serializeDomLayerNode(root, child, identity, observedFiles) ?? []
|
|
2041
|
-
)
|
|
2042
|
-
};
|
|
2043
|
-
}
|
|
2044
|
-
function withoutSourceStamps(props) {
|
|
2045
|
-
return Object.fromEntries(
|
|
2046
|
-
Object.entries(props ?? {}).filter(
|
|
2047
|
-
([key]) => !SOURCE_ANNOTATION_ATTRIBUTES.has(key)
|
|
2048
|
-
)
|
|
2049
|
-
);
|
|
2050
|
-
}
|
|
2051
|
-
function firstStampCarrier(root, element) {
|
|
2052
|
-
const filepath = element.getAttribute("data-tempo-filepath");
|
|
2053
|
-
const position = element.getAttribute("data-tempo-position");
|
|
2054
|
-
if (filepath === null || position === null) return true;
|
|
2055
|
-
const quote = (value) => `"${value.replace(/["\\]/g, "\\$&")}"`;
|
|
2056
|
-
const selector = `[data-tempo-filepath=${quote(filepath)}][data-tempo-position=${quote(position)}]`;
|
|
2057
|
-
return root.querySelector(selector) === element;
|
|
2058
|
-
}
|
|
2059
|
-
function rootSourceStamps(root) {
|
|
2060
|
-
const stamps = {};
|
|
2061
|
-
for (const name of SOURCE_ANNOTATION_ATTRIBUTES) {
|
|
2062
|
-
const value = root.getAttribute(name);
|
|
2063
|
-
if (value === null) continue;
|
|
2064
|
-
if (name === "data-tempo-position" || name === "data-tempo-modifiedts") {
|
|
2065
|
-
const numeric = Number(value);
|
|
2066
|
-
if (Number.isFinite(numeric)) stamps[name] = numeric;
|
|
2067
|
-
} else stamps[name] = value;
|
|
2068
|
-
}
|
|
2069
|
-
return Object.keys(stamps).length ? stamps : void 0;
|
|
2070
|
-
}
|
|
2071
|
-
function serializeDomLayerNode(root, element, identity = dataDomLayerIdentity, observedFiles, children) {
|
|
2072
|
-
if (element.nodeType === 3 || element.nodeType === 8) {
|
|
2073
|
-
const kind = element.nodeType === 3 ? "text" : "comment";
|
|
2074
|
-
const domId2 = ensureProjectionDomId(element, root ?? void 0);
|
|
2075
|
-
if (domId2 === null) return null;
|
|
2076
|
-
return {
|
|
2077
|
-
kind,
|
|
2078
|
-
id: domId2,
|
|
2079
|
-
content: element.textContent ?? ""
|
|
2080
|
-
};
|
|
2081
|
-
}
|
|
2082
|
-
if (!(element instanceof Element))
|
|
2083
|
-
throw new Error("Invalid projection child");
|
|
2084
|
-
const domId = identity.bindableDomIdForElement(root ?? element, element);
|
|
2085
|
-
const name = element.tagName.toLowerCase();
|
|
2086
|
-
const props = captureProjectionDomLayerProps(element, observedFiles);
|
|
2087
|
-
const hostProps = root && firstStampCarrier(root, element) ? props : withoutSourceStamps(props);
|
|
2088
|
-
const nodeProps = hostProps && Object.keys(hostProps).length ? hostProps : void 0;
|
|
2089
|
-
identity.publishedProps?.set(element, nodeProps);
|
|
2090
|
-
return {
|
|
2091
|
-
kind: "host",
|
|
2092
|
-
runtime: "dom",
|
|
2093
|
-
id: domId ?? id(root ?? element, element, identity),
|
|
2094
|
-
key: null,
|
|
2095
|
-
name,
|
|
2096
|
-
domId,
|
|
2097
|
-
elementTag: name,
|
|
2098
|
-
props: nodeProps,
|
|
2099
|
-
source: {
|
|
2100
|
-
kind: "react-fiber",
|
|
2101
|
-
fiber: {
|
|
2102
|
-
tag: FiberTag.HostComponent,
|
|
2103
|
-
name,
|
|
2104
|
-
id: identity.layerIdForElement(root ?? element, element)
|
|
2105
|
-
}
|
|
2106
|
-
},
|
|
2107
|
-
// Another root's element ends this root's tree, as the React lane's
|
|
2108
|
-
// serializer does: what it holds is that root's to publish.
|
|
2109
|
-
children: children ?? Array.from(element.childNodes).filter(
|
|
2110
|
-
(child) => !(child instanceof Element) || child.localName !== "script" && !child.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)
|
|
2111
|
-
).flatMap(
|
|
2112
|
-
(child) => serializeDomLayerNode(root, child, identity, observedFiles) ?? []
|
|
2113
|
-
)
|
|
2114
|
-
};
|
|
2115
|
-
}
|
|
2116
|
-
function id(root, element, identity) {
|
|
2117
|
-
const domId = element === root ? null : identity.bindableDomIdForElement(root, element);
|
|
2118
|
-
if (domId !== null) return domId;
|
|
2119
|
-
const existing = identity.id.get(element);
|
|
2120
|
-
if (existing) return existing;
|
|
2121
|
-
const value = nextProjectionId();
|
|
2122
|
-
identity.id.set(element, value);
|
|
2123
|
-
return value;
|
|
2124
|
-
}
|
|
2125
|
-
function layerIdForTarget(root, target, identity) {
|
|
2126
|
-
if (target === root) return DOM_LAYER_ROOT_ID;
|
|
2127
|
-
return identity.layerIdForElement(root, target);
|
|
2128
|
-
}
|
|
2129
|
-
function projectionDomLayerId(domId) {
|
|
2130
|
-
return `${DOM_LAYER_FIBER_PREFIX}${domId}`;
|
|
2131
|
-
}
|
|
2132
|
-
function domLayerIdForElement(root, element) {
|
|
2133
|
-
const domId = ensureProjectionDomId(element);
|
|
2134
|
-
if (domId) return projectionDomLayerId(domId);
|
|
2135
|
-
const path = [];
|
|
2136
|
-
let current = element;
|
|
2137
|
-
while (current && current !== root) {
|
|
2138
|
-
const parent = current.parentElement;
|
|
2139
|
-
if (!parent) break;
|
|
2140
|
-
path.push(Array.from(parent.children).indexOf(current));
|
|
2141
|
-
current = parent;
|
|
2142
|
-
}
|
|
2143
|
-
return `${DOM_LAYER_FIBER_PREFIX}path:${path.reverse().join(".")}`;
|
|
2144
|
-
}
|
|
2145
|
-
function captureProjectionDomLayerProps(element, observedFiles) {
|
|
2146
|
-
const props = {};
|
|
2147
|
-
const locked = element.getAttribute("data-tempo-locked");
|
|
2148
|
-
if (locked === "true" || locked === "") props["data-tempo-locked"] = true;
|
|
2149
|
-
else if (locked === "false") props["data-tempo-locked"] = false;
|
|
2150
|
-
const layoutMode = layoutModeOf(getComputedStyle(element));
|
|
2151
|
-
if (layoutMode) props.layoutMode = layoutMode;
|
|
2152
|
-
const className = element.getAttribute("class");
|
|
2153
|
-
if (className) props.className = className;
|
|
2154
|
-
const style = parseInlineStyle(element.getAttribute("style"));
|
|
2155
|
-
if (style) props.style = style;
|
|
2156
|
-
Object.assign(props, svgLayerAttributes(element));
|
|
2157
|
-
for (const name of SOURCE_ANNOTATION_ATTRIBUTES) {
|
|
2158
|
-
const value = element.getAttribute(name);
|
|
2159
|
-
if (value === null) continue;
|
|
2160
|
-
if (name === "data-tempo-position" || name === "data-tempo-modifiedts") {
|
|
2161
|
-
const numeric = Number(value);
|
|
2162
|
-
if (Number.isFinite(numeric)) props[name] = numeric;
|
|
2163
|
-
} else {
|
|
2164
|
-
props[name] = value;
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
for (const name of [
|
|
2168
|
-
"data-tempo-supports-style",
|
|
2169
|
-
"data-tempo-supports-classname",
|
|
2170
|
-
"data-tempo-supports-children"
|
|
2171
|
-
]) {
|
|
2172
|
-
const value = element.getAttribute(name);
|
|
2173
|
-
if (value === "true" || value === "false") props[name] = value === "true";
|
|
2174
|
-
}
|
|
2175
|
-
for (const name of ["data-tempo-storyboard-root", "data-tempo-hide-fiber"]) {
|
|
2176
|
-
const value = element.getAttribute(name);
|
|
2177
|
-
if (value !== null) props[name] = value !== "false";
|
|
2178
|
-
}
|
|
2179
|
-
observedFiles?.addLayerProps(props);
|
|
2180
|
-
return Object.keys(props).length > 0 ? props : void 0;
|
|
2181
|
-
}
|
|
2182
|
-
function invocationSourceLayerProps(source2, invocation) {
|
|
2183
|
-
const props = {};
|
|
2184
|
-
for (const [name, value] of Object.entries(invocation.literalProps ?? {}))
|
|
2185
|
-
props[`data-tempo-component-prop-${name}`] = JSON.stringify(value);
|
|
2186
|
-
if (invocation.className) props.className = invocation.className;
|
|
2187
|
-
const style = parseInlineStyle(invocation.style ?? null);
|
|
2188
|
-
if (style) props.style = style;
|
|
2189
|
-
if (invocation.locked !== void 0)
|
|
2190
|
-
props["data-tempo-locked"] = invocation.locked;
|
|
2191
|
-
if (invocation.expressions !== void 0)
|
|
2192
|
-
props["data-tempo-expr"] = invocation.expressions;
|
|
2193
|
-
props["data-tempo-filepath"] = source2.filepath;
|
|
2194
|
-
props["data-tempo-position"] = invocation.position;
|
|
2195
|
-
props["data-tempo-modifiedts"] = source2.modifiedTs;
|
|
2196
|
-
props["data-tempo-source-version"] = source2.sourceVersion;
|
|
2197
|
-
return props;
|
|
2198
|
-
}
|
|
2199
|
-
function parseInlineStyle(value) {
|
|
2200
|
-
if (!value) return void 0;
|
|
2201
|
-
const style = {};
|
|
2202
|
-
for (const declaration of splitCssDeclarations(value)) {
|
|
2203
|
-
const separator = declaration.indexOf(":");
|
|
2204
|
-
if (separator < 0) continue;
|
|
2205
|
-
const property = declaration.slice(0, separator).trim();
|
|
2206
|
-
const propertyValue = declaration.slice(separator + 1).trim();
|
|
2207
|
-
if (property && propertyValue) style[property] = propertyValue;
|
|
2208
|
-
}
|
|
2209
|
-
return Object.keys(style).length > 0 ? style : void 0;
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
// ../../modules/iframe-projection/combined/projection-flutter-layers.ts
|
|
2213
|
-
var FLUTTER_ROOT_ATTRIBUTE = "data-tempo-flutter-root";
|
|
2214
|
-
var FLUTTER_VIEW_ATTRIBUTE = "data-tempo-flutter-view";
|
|
2215
|
-
function isFlutterViewRoot(element) {
|
|
2216
|
-
return element.hasAttribute(FLUTTER_ROOT_ATTRIBUTE);
|
|
2217
|
-
}
|
|
2218
|
-
function flutterViewRootOf(element) {
|
|
2219
|
-
return element.closest(`[${FLUTTER_ROOT_ATTRIBUTE}]`);
|
|
2220
|
-
}
|
|
2221
|
-
function flutterHostProps(element) {
|
|
2222
|
-
const viewId = element.getAttribute(FLUTTER_VIEW_ATTRIBUTE);
|
|
2223
|
-
return {
|
|
2224
|
-
"data-tempo-hide-fiber": true,
|
|
2225
|
-
...viewId !== null ? { [FLUTTER_VIEW_ATTRIBUTE]: viewId } : {}
|
|
2226
|
-
};
|
|
2227
|
-
}
|
|
2228
|
-
var hostIdsByHost = /* @__PURE__ */ new WeakMap();
|
|
2229
|
-
function serializeFlutterViewLayers(host, root, observedFiles) {
|
|
2230
|
-
const snapshot = readSnapshot(host);
|
|
2231
|
-
if (!snapshot) return [];
|
|
2232
|
-
const offset = hostOffsetFromRoot(host, root ?? nearestProjectionRoot(host));
|
|
2233
|
-
const nodesById = /* @__PURE__ */ new Map();
|
|
2234
|
-
const childrenOf = /* @__PURE__ */ new Map();
|
|
2235
|
-
for (const node of snapshot.nodes) {
|
|
2236
|
-
if (!isFlutterLayerNode(node)) continue;
|
|
2237
|
-
nodesById.set(node.id, node);
|
|
2238
|
-
}
|
|
2239
|
-
for (const node of nodesById.values()) {
|
|
2240
|
-
const parent = node.parent !== null && nodesById.has(node.parent) ? node.parent : null;
|
|
2241
|
-
const siblings = childrenOf.get(parent) ?? [];
|
|
2242
|
-
siblings.push(node);
|
|
2243
|
-
childrenOf.set(parent, siblings);
|
|
2244
|
-
}
|
|
2245
|
-
const previousIds = hostIdsByHost.get(host) ?? /* @__PURE__ */ new Map();
|
|
2246
|
-
const currentIds = /* @__PURE__ */ new Map();
|
|
2247
|
-
const hostIdFor = (snapshotId) => {
|
|
2248
|
-
const id2 = previousIds.get(snapshotId) ?? nextProjectionId();
|
|
2249
|
-
currentIds.set(snapshotId, id2);
|
|
2250
|
-
return id2;
|
|
2251
|
-
};
|
|
2252
|
-
const serialize = (node) => {
|
|
2253
|
-
const id2 = hostIdFor(node.id);
|
|
2254
|
-
const props = flutterNodeProps(node);
|
|
2255
|
-
observedFiles?.addLayerProps(props);
|
|
2256
|
-
return {
|
|
2257
|
-
kind: "component",
|
|
2258
|
-
runtime: "flutter",
|
|
2259
|
-
id: id2,
|
|
2260
|
-
key: null,
|
|
2261
|
-
name: node.name,
|
|
2262
|
-
domId: null,
|
|
2263
|
-
elementTag: null,
|
|
2264
|
-
...props ? { props } : {},
|
|
2265
|
-
geometry: {
|
|
2266
|
-
x: node.x + offset.x,
|
|
2267
|
-
y: node.y + offset.y,
|
|
2268
|
-
width: node.width,
|
|
2269
|
-
height: node.height,
|
|
2270
|
-
painted: node.painted === true
|
|
2271
|
-
},
|
|
2272
|
-
source: {
|
|
2273
|
-
kind: "react-fiber",
|
|
2274
|
-
fiber: { tag: FiberTag.FunctionComponent, name: node.name, id: id2 }
|
|
2275
|
-
},
|
|
2276
|
-
children: (childrenOf.get(node.id) ?? []).map(serialize)
|
|
2277
|
-
};
|
|
2278
|
-
};
|
|
2279
|
-
const roots = (childrenOf.get(null) ?? []).map(serialize);
|
|
2280
|
-
hostIdsByHost.set(host, currentIds);
|
|
2281
|
-
return roots;
|
|
2282
|
-
}
|
|
2283
|
-
function flutterNodeProps(node) {
|
|
2284
|
-
if (node.position === null) return void 0;
|
|
2285
|
-
return {
|
|
2286
|
-
"data-tempo-filepath": node.file,
|
|
2287
|
-
"data-tempo-position": node.position,
|
|
2288
|
-
...node.modifiedTs !== null ? { "data-tempo-modifiedts": node.modifiedTs } : {}
|
|
2289
|
-
};
|
|
2290
|
-
}
|
|
2291
|
-
function readSnapshot(host) {
|
|
2292
|
-
const attribute = host.getAttribute(FLUTTER_VIEW_ATTRIBUTE);
|
|
2293
|
-
if (attribute === null) return null;
|
|
2294
|
-
const viewId = Number(attribute);
|
|
2295
|
-
if (!Number.isInteger(viewId)) return null;
|
|
2296
|
-
const runtime = host.ownerDocument.defaultView?.__tempoFlutter;
|
|
2297
|
-
const snapshot = runtime?.layers?.get(viewId);
|
|
2298
|
-
if (!snapshot || !Array.isArray(snapshot.nodes)) return null;
|
|
2299
|
-
return snapshot;
|
|
2300
|
-
}
|
|
2301
|
-
function isFlutterLayerNode(value) {
|
|
2302
|
-
if (typeof value !== "object" || value === null) return false;
|
|
2303
|
-
const node = value;
|
|
2304
|
-
return typeof node.id === "string" && (node.parent === null || typeof node.parent === "string") && typeof node.name === "string" && typeof node.file === "string" && [node.x, node.y, node.width, node.height].every(
|
|
2305
|
-
(n) => typeof n === "number" && Number.isFinite(n)
|
|
2306
|
-
);
|
|
2307
|
-
}
|
|
2308
|
-
function nearestProjectionRoot(host) {
|
|
2309
|
-
return host.closest(`[${PROJECTION_ROOT_ATTRIBUTE}]`) ?? host;
|
|
2310
|
-
}
|
|
2311
|
-
function hostOffsetFromRoot(host, root) {
|
|
2312
|
-
if (host === root) return { x: 0, y: 0 };
|
|
2313
|
-
const hostRect = host.getBoundingClientRect();
|
|
2314
|
-
const rootRect = root.getBoundingClientRect();
|
|
2315
|
-
return { x: hostRect.left - rootRect.left, y: hostRect.top - rootRect.top };
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
// ../../modules/iframe-projection/combined/projection-layer-snapshot.ts
|
|
2319
|
-
var SVG_PRESENTATION_ATTRIBUTES = [
|
|
2320
|
-
"fill",
|
|
2321
|
-
"fill-opacity",
|
|
2322
|
-
"fill-rule",
|
|
2323
|
-
"stroke",
|
|
2324
|
-
"stroke-width",
|
|
2325
|
-
"stroke-opacity",
|
|
2326
|
-
"stroke-linecap",
|
|
2327
|
-
"stroke-linejoin",
|
|
2328
|
-
"stroke-dasharray",
|
|
2329
|
-
"stroke-dashoffset",
|
|
2330
|
-
"stroke-miterlimit",
|
|
2331
|
-
"color",
|
|
2332
|
-
"opacity",
|
|
2333
|
-
"clip-path",
|
|
2334
|
-
"mask",
|
|
2335
|
-
"filter"
|
|
2336
|
-
];
|
|
2337
|
-
var SVG_GEOMETRY_ATTRIBUTES = {
|
|
2338
|
-
path: ["d"],
|
|
2339
|
-
rect: ["x", "y", "width", "height", "rx", "ry"],
|
|
2340
|
-
circle: ["cx", "cy", "r"],
|
|
2341
|
-
ellipse: ["cx", "cy", "rx", "ry"],
|
|
2342
|
-
line: ["x1", "y1", "x2", "y2"],
|
|
2343
|
-
polygon: ["points"],
|
|
2344
|
-
polyline: ["points"]
|
|
2345
|
-
};
|
|
2346
|
-
var SVG_LAYER_IDENTITY = ["id", "transform"];
|
|
2347
|
-
var SVG_PICTURE_BOX = [
|
|
2348
|
-
"viewBox",
|
|
2349
|
-
"width",
|
|
2350
|
-
"height",
|
|
2351
|
-
"preserveAspectRatio"
|
|
2352
|
-
];
|
|
2353
|
-
var SVG_OWN_ATTRIBUTES = new Map([
|
|
2354
|
-
["svg", SVG_PICTURE_BOX],
|
|
2355
|
-
["g", SVG_LAYER_IDENTITY],
|
|
2356
|
-
...Object.entries(SVG_GEOMETRY_ATTRIBUTES).map(
|
|
2357
|
-
([tag, geometry]) => [
|
|
2358
|
-
tag,
|
|
2359
|
-
[...SVG_LAYER_IDENTITY, ...geometry]
|
|
2360
|
-
]
|
|
2361
|
-
)
|
|
2362
|
-
]);
|
|
2363
|
-
var SVG_LAYER_ATTRIBUTE_NAMES = /* @__PURE__ */ new Set([
|
|
2364
|
-
...SVG_PRESENTATION_ATTRIBUTES,
|
|
2365
|
-
...[...SVG_OWN_ATTRIBUTES.values()].flat()
|
|
2366
|
-
]);
|
|
2367
|
-
function svgLayerAttributes(element) {
|
|
2368
|
-
const props = {};
|
|
2369
|
-
if (element.namespaceURI !== "http://www.w3.org/2000/svg") return props;
|
|
2370
|
-
const read = (names) => {
|
|
2371
|
-
for (const name of names) {
|
|
2372
|
-
const value = element.getAttribute(name);
|
|
2373
|
-
if (value !== null) props[name] = value;
|
|
2374
|
-
}
|
|
2375
|
-
};
|
|
2376
|
-
read(SVG_PRESENTATION_ATTRIBUTES);
|
|
2377
|
-
read(SVG_OWN_ATTRIBUTES.get(element.localName) ?? []);
|
|
2378
|
-
return props;
|
|
2379
|
-
}
|
|
2380
|
-
function svgLayerAttributesOf(props) {
|
|
2381
|
-
if (!props) return void 0;
|
|
2382
|
-
const picked = Object.entries(props).filter(
|
|
2383
|
-
(entry) => SVG_LAYER_ATTRIBUTE_NAMES.has(entry[0]) && typeof entry[1] === "string"
|
|
2384
|
-
);
|
|
2385
|
-
return picked.length > 0 ? Object.fromEntries(picked) : void 0;
|
|
2386
|
-
}
|
|
2387
|
-
function layerPropsEqual(left, right) {
|
|
2388
|
-
if (left === right) return true;
|
|
2389
|
-
if (!left || !right) return left === right;
|
|
2390
|
-
const leftEntries = Object.entries(left);
|
|
2391
|
-
const rightEntries = Object.entries(right);
|
|
2392
|
-
if (leftEntries.length !== rightEntries.length) return false;
|
|
2393
|
-
for (const [key, value] of leftEntries) {
|
|
2394
|
-
const other = right[key];
|
|
2395
|
-
if (key === "style") {
|
|
2396
|
-
if (!recordEqual(
|
|
2397
|
-
value,
|
|
2398
|
-
other
|
|
2399
|
-
)) {
|
|
2400
|
-
return false;
|
|
2401
|
-
}
|
|
2402
|
-
} else if (value !== other) return false;
|
|
2403
|
-
}
|
|
2404
|
-
return true;
|
|
2405
|
-
}
|
|
2406
|
-
function recordEqual(left, right) {
|
|
2407
|
-
if (left === right) return true;
|
|
2408
|
-
if (!left || !right) return left === right;
|
|
2409
|
-
const keys = Object.keys(left);
|
|
2410
|
-
return keys.length === Object.keys(right).length && keys.every((key) => left[key] === right[key]);
|
|
2411
|
-
}
|
|
2412
|
-
function layoutModeOf(style) {
|
|
2413
|
-
if (/grid/.test(style.display)) return "grid";
|
|
2414
|
-
if (!/flex/.test(style.display)) return void 0;
|
|
2415
|
-
return /^column/.test(style.flexDirection) ? "flex-column" : "flex-row";
|
|
2416
|
-
}
|
|
2417
|
-
var PROJECTION_SCOPE_TARGET = "$projection-scope";
|
|
2418
|
-
function projectionLayerRoots(snapshot) {
|
|
2419
|
-
const semantic = snapshot.semantic;
|
|
2420
|
-
return semantic.kind === "scope" ? semantic.fragment.children : semantic.kind === "layers" && semantic.tree ? [semantic.tree] : [];
|
|
2421
|
-
}
|
|
2422
|
-
var COMPONENT_TAGS = /* @__PURE__ */ new Set([
|
|
2423
|
-
FiberTag.FunctionComponent,
|
|
2424
|
-
FiberTag.ClassComponent,
|
|
2425
|
-
FiberTag.ForwardRef,
|
|
2426
|
-
FiberTag.MemoComponent,
|
|
2427
|
-
FiberTag.SimpleMemoComponent,
|
|
2428
|
-
FiberTag.LazyComponent
|
|
2429
|
-
]);
|
|
2430
|
-
function createProjectionLayerSerializer(watchedRoot, contentsScope = false, includeRoot = false) {
|
|
2431
|
-
const fiberIds = /* @__PURE__ */ new WeakMap();
|
|
2432
|
-
const portalNodeIds = /* @__PURE__ */ new WeakMap();
|
|
2433
|
-
let publishedPortalAncestors = /* @__PURE__ */ new WeakSet();
|
|
2434
|
-
let publishedTargetAncestors = /* @__PURE__ */ new Set();
|
|
2435
|
-
let observedRoot = null;
|
|
2436
|
-
const physicalAggregations = /* @__PURE__ */ new WeakSet();
|
|
2437
|
-
const aggregatesPhysicalTargets = (fiber) => physicalAggregations.has(fiber) || fiber.alternate !== null && physicalAggregations.has(fiber.alternate);
|
|
2438
|
-
const portalNodeId = (node) => {
|
|
2439
|
-
const known = portalNodeIds.get(node);
|
|
2440
|
-
if (known) return known;
|
|
2441
|
-
const value = nextProjectionId();
|
|
2442
|
-
portalNodeIds.set(node, value);
|
|
2443
|
-
return value;
|
|
2444
|
-
};
|
|
2445
|
-
const ids = /* @__PURE__ */ new WeakMap();
|
|
2446
|
-
function id2(fiber) {
|
|
2447
|
-
const node = fiber.tag === FiberTag.HostText && fiber.stateNode instanceof Node ? fiber.stateNode : fiber.tag === FiberTag.HostComponent ? getDomElement(fiber) : null;
|
|
2448
|
-
const domId = node ? ensureProjectionDomId(node, watchedRoot) : null;
|
|
2449
|
-
if (domId !== null) return domId;
|
|
2450
|
-
const direct = ids.get(fiber);
|
|
2451
|
-
if (direct) return direct;
|
|
2452
|
-
const alternate = fiber.alternate ? ids.get(fiber.alternate) : null;
|
|
2453
|
-
if (alternate) {
|
|
2454
|
-
ids.set(fiber, alternate);
|
|
2455
|
-
return alternate;
|
|
2456
|
-
}
|
|
2457
|
-
const value = nextProjectionId();
|
|
2458
|
-
ids.set(fiber, value);
|
|
2459
|
-
if (fiber.alternate) ids.set(fiber.alternate, value);
|
|
2460
|
-
return value;
|
|
2461
|
-
}
|
|
2462
|
-
const fiberId = (fiber) => {
|
|
2463
|
-
const direct = fiberIds.get(fiber);
|
|
2464
|
-
if (direct) return direct;
|
|
2465
|
-
const alternate = fiber.alternate ? fiberIds.get(fiber.alternate) : null;
|
|
2466
|
-
if (alternate) {
|
|
2467
|
-
fiberIds.set(fiber, alternate);
|
|
2468
|
-
return alternate;
|
|
2469
|
-
}
|
|
2470
|
-
const id3 = nextProjectionId();
|
|
2471
|
-
fiberIds.set(fiber, id3);
|
|
2472
|
-
if (fiber.alternate) fiberIds.set(fiber.alternate, id3);
|
|
2473
|
-
return id3;
|
|
2474
|
-
};
|
|
2475
|
-
const knownFiberId = (fiber) => fiberIds.get(fiber) ?? (fiber.alternate ? fiberIds.get(fiber.alternate) : void 0) ?? null;
|
|
2476
|
-
const serialize = (root, observation = false) => {
|
|
2477
|
-
const observedFiles = new ProjectionObservedFileAccumulator();
|
|
2478
|
-
let fiberNodesVisited = 0;
|
|
2479
|
-
let semanticNodesSerialized = 0;
|
|
2480
|
-
const portalOwners = /* @__PURE__ */ new Map();
|
|
2481
|
-
const portalTargets = /* @__PURE__ */ new Map();
|
|
2482
|
-
const emittedNodes = /* @__PURE__ */ new Set();
|
|
2483
|
-
const collectOwnership = (fiber, portal) => {
|
|
2484
|
-
if (fiber !== root && isProjectionRootFiber(fiber)) return;
|
|
2485
|
-
fiberNodesVisited += 1;
|
|
2486
|
-
if (fiber.tag === FiberTag.HostPortal) {
|
|
2487
|
-
portal = fiber;
|
|
2488
|
-
const target = fiber.stateNode?.containerInfo;
|
|
2489
|
-
if (target instanceof Element) {
|
|
2490
|
-
const entries = portalTargets.get(target) ?? [];
|
|
2491
|
-
entries.push(fiber);
|
|
2492
|
-
portalTargets.set(target, entries);
|
|
2493
|
-
}
|
|
2494
|
-
}
|
|
2495
|
-
if (portal) portalOwners.set(fiber, portal);
|
|
2496
|
-
for (let child = fiber.child; child; child = child.sibling)
|
|
2497
|
-
collectOwnership(child, portal);
|
|
2498
|
-
};
|
|
2499
|
-
if (root) collectOwnership(root);
|
|
2500
|
-
else if (watchedRoot) {
|
|
2501
|
-
for (const committed of getCommittedFiberRoots()) {
|
|
2502
|
-
const container = committed.containerInfo;
|
|
2503
|
-
if (!(container instanceof Element) || !watchedRoot.contains(container))
|
|
2504
|
-
continue;
|
|
2505
|
-
let boundary = container;
|
|
2506
|
-
while (boundary && boundary !== watchedRoot && !boundary.hasAttribute(PROJECTION_ROOT_ATTRIBUTE))
|
|
2507
|
-
boundary = boundary.parentElement;
|
|
2508
|
-
if (boundary === watchedRoot) collectOwnership(committed.current);
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
if (observation) observedRoot = root;
|
|
2512
|
-
if (root === observedRoot || root?.alternate === observedRoot || observedRoot?.alternate === root) {
|
|
2513
|
-
publishedPortalAncestors = /* @__PURE__ */ new WeakSet();
|
|
2514
|
-
for (const portals of portalTargets.values())
|
|
2515
|
-
for (const portal of portals)
|
|
2516
|
-
for (let ancestor = portal; ancestor; ancestor = ancestor.return)
|
|
2517
|
-
publishedPortalAncestors.add(ancestor);
|
|
2518
|
-
publishedTargetAncestors = /* @__PURE__ */ new Set();
|
|
2519
|
-
for (const target of portalTargets.keys())
|
|
2520
|
-
for (let node = target; node; node = node.parentNode)
|
|
2521
|
-
publishedTargetAncestors.add(node);
|
|
2522
|
-
}
|
|
2523
|
-
const portalOf = (fiber) => {
|
|
2524
|
-
const known = portalOwners.get(fiber);
|
|
2525
|
-
if (known) return known;
|
|
2526
|
-
for (let owner = fiber.return; owner; owner = owner.return) {
|
|
2527
|
-
if (owner.tag === FiberTag.HostPortal) return owner;
|
|
2528
|
-
if (isProjectionRootFiber(owner)) break;
|
|
2529
|
-
}
|
|
2530
|
-
};
|
|
2531
|
-
const portalRuntime = (fiber, node) => {
|
|
2532
|
-
const portal = portalOf(fiber);
|
|
2533
|
-
return portal ? {
|
|
2534
|
-
...node ? { nodeId: portalNodeId(node) } : {},
|
|
2535
|
-
fiberId: fiberId(fiber),
|
|
2536
|
-
ownerFiberId: fiberId(portal.return ?? portal)
|
|
2537
|
-
} : void 0;
|
|
2538
|
-
};
|
|
2539
|
-
const domChildren = (element, parent, allowed, inheritedPortal) => {
|
|
2540
|
-
const physicalPortal = (parent && portalOf(parent)) ?? inheritedPortal;
|
|
2541
|
-
const annotations = /* @__PURE__ */ new Map();
|
|
2542
|
-
const extras = [];
|
|
2543
|
-
const pending = [];
|
|
2544
|
-
const collect = (fiber, chain) => {
|
|
2545
|
-
if (isProjectionRootFiber(fiber)) return false;
|
|
2546
|
-
if (fiber.tag === FiberTag.HostPortal) {
|
|
2547
|
-
return false;
|
|
2548
|
-
}
|
|
2549
|
-
const node = fiber.tag === FiberTag.HostText ? fiber.stateNode : fiber.tag === FiberTag.HostComponent ? getDomElement(fiber) : null;
|
|
2550
|
-
if (node instanceof Node) {
|
|
2551
|
-
annotations.set(node, { fiber, chain });
|
|
2552
|
-
for (const extra of pending.splice(0)) extra.before = node;
|
|
2553
|
-
return true;
|
|
2554
|
-
}
|
|
2555
|
-
fiberNodesVisited += 1;
|
|
2556
|
-
const included = isProjectionLayerFiber(fiber);
|
|
2557
|
-
const next = included ? [...chain, fiber] : chain;
|
|
2558
|
-
let hasChildren = false;
|
|
2559
|
-
for (let child = fiber.child; child; child = child.sibling)
|
|
2560
|
-
hasChildren = collect(child, next) || hasChildren;
|
|
2561
|
-
if (!hasChildren && included) {
|
|
2562
|
-
const extra = { fiber, chain };
|
|
2563
|
-
extras.push(extra);
|
|
2564
|
-
pending.push(extra);
|
|
2565
|
-
return true;
|
|
2566
|
-
}
|
|
2567
|
-
return hasChildren;
|
|
2568
|
-
};
|
|
2569
|
-
if (parent)
|
|
2570
|
-
for (let child = parent.child; child; child = child.sibling)
|
|
2571
|
-
collect(child, []);
|
|
2572
|
-
for (const portal of portalTargets.get(element) ?? [])
|
|
2573
|
-
for (let child = portal.child; child; child = child.sibling)
|
|
2574
|
-
collect(child, []);
|
|
2575
|
-
const extrasByNode = /* @__PURE__ */ new Map();
|
|
2576
|
-
const trailing = [];
|
|
2577
|
-
for (const extra of extras) {
|
|
2578
|
-
if (!extra.before || extra.before.parentNode !== element)
|
|
2579
|
-
trailing.push(extra);
|
|
2580
|
-
else {
|
|
2581
|
-
const group = extrasByNode.get(extra.before) ?? [];
|
|
2582
|
-
group.push(extra);
|
|
2583
|
-
extrasByNode.set(extra.before, group);
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2586
|
-
const children = [];
|
|
2587
|
-
const components = /* @__PURE__ */ new Map();
|
|
2588
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2589
|
-
const destinationOf = (chain, node) => {
|
|
2590
|
-
for (const component of components.keys()) {
|
|
2591
|
-
if (!chain.includes(component)) components.delete(component);
|
|
2592
|
-
}
|
|
2593
|
-
let destination = children;
|
|
2594
|
-
for (const component of chain) {
|
|
2595
|
-
let nested = components.get(component);
|
|
2596
|
-
if (!nested) {
|
|
2597
|
-
nested = [];
|
|
2598
|
-
components.set(component, nested);
|
|
2599
|
-
const branches2 = visit(component, nested);
|
|
2600
|
-
if (seen.has(component)) {
|
|
2601
|
-
const suffix = node && ensureProjectionDomId(node, watchedRoot) || nextProjectionId();
|
|
2602
|
-
for (const branch of branches2) {
|
|
2603
|
-
destination.push({ ...branch, id: `${branch.id}/${suffix}` });
|
|
2604
|
-
}
|
|
2605
|
-
} else destination.push(...branches2);
|
|
2606
|
-
seen.add(component);
|
|
2607
|
-
}
|
|
2608
|
-
destination = nested;
|
|
2609
|
-
}
|
|
2610
|
-
return destination;
|
|
2611
|
-
};
|
|
2612
|
-
const appendExtra = (extra) => {
|
|
2613
|
-
destinationOf(extra.chain, extra.before).push(
|
|
2614
|
-
...visit(
|
|
2615
|
-
extra.fiber,
|
|
2616
|
-
extra.fiber.tag === FiberTag.HostPortal ? void 0 : []
|
|
2617
|
-
)
|
|
2618
|
-
);
|
|
2619
|
-
};
|
|
2620
|
-
for (const child of Array.from(element.childNodes)) {
|
|
2621
|
-
if (allowed && !allowed.has(child)) continue;
|
|
2622
|
-
if (child instanceof Element && (child.localName === "script" || child.hasAttribute(PROJECTION_ROOT_ATTRIBUTE)))
|
|
2623
|
-
continue;
|
|
2624
|
-
for (const extra of extrasByNode.get(child) ?? []) appendExtra(extra);
|
|
2625
|
-
const annotation = annotations.get(child);
|
|
2626
|
-
const destination = destinationOf(annotation?.chain ?? [], child);
|
|
2627
|
-
let fiber = annotation?.fiber;
|
|
2628
|
-
if (!fiber && child instanceof Element) {
|
|
2629
|
-
const candidate = getFiberFromElement(child);
|
|
2630
|
-
if (candidate) fiber = resolveCommittedFiber(candidate) ?? void 0;
|
|
2631
|
-
}
|
|
2632
|
-
if (fiber?.tag === FiberTag.HostRoot && child instanceof Element) {
|
|
2633
|
-
const serialized = serializeDomLayerNode(
|
|
2634
|
-
null,
|
|
2635
|
-
child,
|
|
2636
|
-
void 0,
|
|
2637
|
-
void 0,
|
|
2638
|
-
domChildren(child, fiber)
|
|
2639
|
-
);
|
|
2640
|
-
if (serialized) destination.push(serialized);
|
|
2641
|
-
} else if (fiber) destination.push(...visit(fiber));
|
|
2642
|
-
else {
|
|
2643
|
-
const isElement = child instanceof Element;
|
|
2644
|
-
if (emittedNodes.has(child)) continue;
|
|
2645
|
-
emittedNodes.add(child);
|
|
2646
|
-
const serialized = serializeDomLayerNode(
|
|
2647
|
-
isElement ? null : watchedRoot ?? null,
|
|
2648
|
-
child,
|
|
2649
|
-
void 0,
|
|
2650
|
-
void 0,
|
|
2651
|
-
isElement ? domChildren(child, void 0, void 0, physicalPortal) : void 0
|
|
2652
|
-
);
|
|
2653
|
-
if (serialized) {
|
|
2654
|
-
const portal = physicalPortal;
|
|
2655
|
-
destination.push(
|
|
2656
|
-
portal ? {
|
|
2657
|
-
...serialized,
|
|
2658
|
-
portal: {
|
|
2659
|
-
nodeId: portalNodeId(child),
|
|
2660
|
-
ownerFiberId: fiberId(portal.return ?? portal)
|
|
2661
|
-
}
|
|
2662
|
-
} : serialized
|
|
2663
|
-
);
|
|
2664
|
-
semanticNodesSerialized += 1;
|
|
2665
|
-
}
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
for (const extra of trailing) appendExtra(extra);
|
|
2669
|
-
return children;
|
|
2670
|
-
};
|
|
2671
|
-
const visit = (fiber, suppliedChildren) => {
|
|
2672
|
-
if (!suppliedChildren) fiberNodesVisited += 1;
|
|
2673
|
-
if (fiber !== root && isProjectionRootFiber(fiber)) return [];
|
|
2674
|
-
if (fiber.tag === FiberTag.HostPortal) return [];
|
|
2675
|
-
if (fiber.tag === FiberTag.HostText && fiber.stateNode instanceof Node && fiber.stateNode.parentElement) {
|
|
2676
|
-
if (emittedNodes.has(fiber.stateNode)) return [];
|
|
2677
|
-
emittedNodes.add(fiber.stateNode);
|
|
2678
|
-
const text = serializeDomLayerNode(
|
|
2679
|
-
watchedRoot ?? null,
|
|
2680
|
-
fiber.stateNode
|
|
2681
|
-
);
|
|
2682
|
-
if (!text) return [];
|
|
2683
|
-
semanticNodesSerialized += 1;
|
|
2684
|
-
const portal2 = portalRuntime(fiber, fiber.stateNode);
|
|
2685
|
-
return [portal2 ? { ...text, portal: portal2 } : text];
|
|
2686
|
-
}
|
|
2687
|
-
const name = getDisplayName(fiber);
|
|
2688
|
-
const kind = projectionKindForTag(fiber.tag);
|
|
2689
|
-
const included = isProjectionLayerFiber(fiber) && !(contentsScope && !includeRoot && fiber === root && getDomElement(fiber) === watchedRoot);
|
|
2690
|
-
const element = kind === "host" ? getDomElement(fiber) : null;
|
|
2691
|
-
if (element?.localName === "script") return [];
|
|
2692
|
-
if (element) {
|
|
2693
|
-
if (emittedNodes.has(element)) return [];
|
|
2694
|
-
emittedNodes.add(element);
|
|
2695
|
-
}
|
|
2696
|
-
const domId = element ? ensureProjectionDomId(element) : null;
|
|
2697
|
-
const props = included ? captureProjectionLayerProps(fiber, element) : void 0;
|
|
2698
|
-
observedFiles.addLayerProps(props);
|
|
2699
|
-
if (element) {
|
|
2700
|
-
observedFiles.addLayerProps(
|
|
2701
|
-
captureProjectionLayerProps(
|
|
2702
|
-
fiber,
|
|
2703
|
-
element,
|
|
2704
|
-
"live-host",
|
|
2705
|
-
props?.layoutMode ?? null
|
|
2706
|
-
)
|
|
2707
|
-
);
|
|
2708
|
-
}
|
|
2709
|
-
const flutterChildren = !suppliedChildren && element && isFlutterViewRoot(element) ? serializeFlutterViewLayers(
|
|
2710
|
-
element,
|
|
2711
|
-
watchedRoot ?? null,
|
|
2712
|
-
observedFiles
|
|
2713
|
-
) : null;
|
|
2714
|
-
if (flutterChildren)
|
|
2715
|
-
semanticNodesSerialized += countNodes(flutterChildren);
|
|
2716
|
-
const children = suppliedChildren ?? flutterChildren ?? (element ? domChildren(element, fiber) : []);
|
|
2717
|
-
if (!suppliedChildren && !element)
|
|
2718
|
-
for (let child = fiber.child; child; child = child.sibling)
|
|
2719
|
-
children.push(...visit(child));
|
|
2720
|
-
if (!included) return children;
|
|
2721
|
-
if (kind === null || kind === "text" || kind === "comment")
|
|
2722
|
-
return children;
|
|
2723
|
-
const source2 = {
|
|
2724
|
-
kind: "react-fiber",
|
|
2725
|
-
fiber: { tag: fiber.tag, name, id: fiberId(fiber) }
|
|
2726
|
-
};
|
|
2727
|
-
const portal = portalRuntime(fiber, element ?? void 0);
|
|
2728
|
-
let node;
|
|
2729
|
-
if (kind === "host") {
|
|
2730
|
-
node = {
|
|
2731
|
-
runtime: "react",
|
|
2732
|
-
kind,
|
|
2733
|
-
id: domId ?? id2(fiber),
|
|
2734
|
-
key: fiber.key == null ? null : String(fiber.key),
|
|
2735
|
-
name,
|
|
2736
|
-
domId,
|
|
2737
|
-
elementTag: name,
|
|
2738
|
-
props,
|
|
2739
|
-
source: source2,
|
|
2740
|
-
...portal ? { portal } : {},
|
|
2741
|
-
children
|
|
2742
|
-
};
|
|
2743
|
-
} else {
|
|
2744
|
-
node = {
|
|
2745
|
-
runtime: "react",
|
|
2746
|
-
kind,
|
|
2747
|
-
id: id2(fiber),
|
|
2748
|
-
key: fiber.key == null ? null : String(fiber.key),
|
|
2749
|
-
name,
|
|
2750
|
-
domId: null,
|
|
2751
|
-
elementTag: null,
|
|
2752
|
-
props,
|
|
2753
|
-
source: source2,
|
|
2754
|
-
...portal ? { portal } : {},
|
|
2755
|
-
children
|
|
2756
|
-
};
|
|
2757
|
-
}
|
|
2758
|
-
semanticNodesSerialized += 1;
|
|
2759
|
-
return [node];
|
|
2760
|
-
};
|
|
2761
|
-
const isScope = contentsScope && (!root || root === observedRoot || root?.alternate === observedRoot || observation);
|
|
2762
|
-
const branches = isScope && (!root || root.tag === FiberTag.HostRoot) && watchedRoot ? domChildren(watchedRoot, root ?? void 0) : root ? visit(root) : [];
|
|
2763
|
-
if (isScope && includeRoot && (!root || root.tag === FiberTag.HostRoot) && watchedRoot) {
|
|
2764
|
-
const node = serializeDomLayerNode(
|
|
2765
|
-
null,
|
|
2766
|
-
watchedRoot,
|
|
2767
|
-
void 0,
|
|
2768
|
-
observedFiles,
|
|
2769
|
-
[...branches]
|
|
2770
|
-
);
|
|
2771
|
-
branches.splice(0, branches.length, ...node ? [node] : []);
|
|
2772
|
-
}
|
|
2773
|
-
for (const [target, portals] of portalTargets) {
|
|
2774
|
-
if (emittedNodes.has(target) || !target.isConnected || target.ownerDocument !== watchedRoot?.ownerDocument)
|
|
2775
|
-
continue;
|
|
2776
|
-
const allowed = /* @__PURE__ */ new Set();
|
|
2777
|
-
for (const [fiber, portal2] of portalOwners) {
|
|
2778
|
-
if (!portals.includes(portal2)) continue;
|
|
2779
|
-
const node = fiber.tag === FiberTag.HostText ? fiber.stateNode : fiber.tag === FiberTag.HostComponent ? getDomElement(fiber) : null;
|
|
2780
|
-
if (node instanceof Node && node.parentNode === target)
|
|
2781
|
-
allowed.add(node);
|
|
2782
|
-
}
|
|
2783
|
-
const portal = portals[0];
|
|
2784
|
-
branches.push({
|
|
2785
|
-
runtime: "dom",
|
|
2786
|
-
kind: "host",
|
|
2787
|
-
id: portalNodeId(target),
|
|
2788
|
-
name: target.localName,
|
|
2789
|
-
key: null,
|
|
2790
|
-
domId: null,
|
|
2791
|
-
elementTag: target.localName,
|
|
2792
|
-
props: {
|
|
2793
|
-
"data-tempo-hide-fiber": true,
|
|
2794
|
-
"data-tempo-supports-style": false,
|
|
2795
|
-
"data-tempo-supports-classname": false,
|
|
2796
|
-
"data-tempo-supports-children": false,
|
|
2797
|
-
layoutMode: target.ownerDocument.defaultView ? layoutModeOf(
|
|
2798
|
-
target.ownerDocument.defaultView.getComputedStyle(target)
|
|
2799
|
-
) : void 0
|
|
2800
|
-
},
|
|
2801
|
-
source: {
|
|
2802
|
-
kind: "react-fiber",
|
|
2803
|
-
fiber: {
|
|
2804
|
-
tag: FiberTag.HostPortal,
|
|
2805
|
-
name: "",
|
|
2806
|
-
id: fiberId(portal)
|
|
2807
|
-
}
|
|
2808
|
-
},
|
|
2809
|
-
portal: {
|
|
2810
|
-
target: true,
|
|
2811
|
-
nodeId: portalNodeId(target),
|
|
2812
|
-
ownerFiberId: fiberId(portal.return ?? portal)
|
|
2813
|
-
},
|
|
2814
|
-
children: domChildren(target, void 0, allowed)
|
|
2815
|
-
});
|
|
2816
|
-
semanticNodesSerialized += 1;
|
|
2817
|
-
emittedNodes.add(target);
|
|
2818
|
-
}
|
|
2819
|
-
let tree;
|
|
2820
|
-
const hiddenWatchedSlot = root !== null && isTempoHiddenFiber(root) && getDomElement(root) === watchedRoot;
|
|
2821
|
-
if (root && branches.some((branch) => branch.portal?.target))
|
|
2822
|
-
physicalAggregations.add(root);
|
|
2823
|
-
if (isScope || !root) {
|
|
2824
|
-
tree = null;
|
|
2825
|
-
} else if (branches.length === 1 && !aggregatesPhysicalTargets(root)) {
|
|
2826
|
-
tree = branches[0] ?? null;
|
|
2827
|
-
} else if (root.tag === FiberTag.HostRoot || branches.length > 1 || aggregatesPhysicalTargets(root)) {
|
|
2828
|
-
const name = getDisplayName(root);
|
|
2829
|
-
tree = {
|
|
2830
|
-
runtime: "react",
|
|
2831
|
-
kind: "fragment",
|
|
2832
|
-
// A nonhidden root already contributes its own physical branch.
|
|
2833
|
-
// This transparent aggregation belongs to the watched observation,
|
|
2834
|
-
// and must not alias that branch's host address.
|
|
2835
|
-
id: root.tag === FiberTag.HostRoot || hiddenWatchedSlot || !aggregatesPhysicalTargets(root) ? id2(root) : `${fiberId(root)}/physical`,
|
|
2836
|
-
key: root.key == null ? null : String(root.key),
|
|
2837
|
-
name,
|
|
2838
|
-
domId: null,
|
|
2839
|
-
elementTag: null,
|
|
2840
|
-
source: {
|
|
2841
|
-
kind: "react-fiber",
|
|
2842
|
-
fiber: { tag: root.tag, name, id: fiberId(root) }
|
|
2843
|
-
},
|
|
2844
|
-
children: branches
|
|
2845
|
-
};
|
|
2846
|
-
semanticNodesSerialized += 1;
|
|
2847
|
-
} else {
|
|
2848
|
-
tree = null;
|
|
2849
|
-
}
|
|
2850
|
-
return {
|
|
2851
|
-
snapshot: {
|
|
2852
|
-
semantic: isScope ? {
|
|
2853
|
-
kind: "scope",
|
|
2854
|
-
fragment: { kind: "fragment", children: branches }
|
|
2855
|
-
} : { kind: "layers", tree },
|
|
2856
|
-
observedFiles: observedFiles.snapshot()
|
|
2857
|
-
},
|
|
2858
|
-
fiberNodesVisited,
|
|
2859
|
-
semanticNodesSerialized
|
|
2860
|
-
};
|
|
2861
|
-
};
|
|
2862
|
-
return {
|
|
2863
|
-
portalClosure(candidate) {
|
|
2864
|
-
if (publishedPortalAncestors.has(candidate) || candidate.alternate && publishedPortalAncestors.has(candidate.alternate))
|
|
2865
|
-
return { required: true, nodesVisited: 0 };
|
|
2866
|
-
const element = getDomElement(candidate);
|
|
2867
|
-
if (element && publishedTargetAncestors.has(element))
|
|
2868
|
-
return { required: true, nodesVisited: 0 };
|
|
2869
|
-
let nodesVisited = 0;
|
|
2870
|
-
const pending = [candidate];
|
|
2871
|
-
while (pending.length) {
|
|
2872
|
-
const fiber = pending.pop();
|
|
2873
|
-
nodesVisited += 1;
|
|
2874
|
-
if (fiber !== candidate && isProjectionRootFiber(fiber)) continue;
|
|
2875
|
-
if (fiber.tag === FiberTag.HostPortal)
|
|
2876
|
-
return { required: true, nodesVisited };
|
|
2877
|
-
for (let child = fiber.child; child; child = child.sibling)
|
|
2878
|
-
pending.push(child);
|
|
2879
|
-
}
|
|
2880
|
-
return { required: false, nodesVisited };
|
|
2881
|
-
},
|
|
2882
|
-
serialize: (root) => serialize(root, true),
|
|
2883
|
-
serializeContents: () => serialize(null, true),
|
|
2884
|
-
fiberId,
|
|
2885
|
-
knownFiberId,
|
|
2886
|
-
serializeRegion(root) {
|
|
2887
|
-
const targetFiberId = fiberId(root);
|
|
2888
|
-
const serialized = serialize(root);
|
|
2889
|
-
const semantic = serialized.snapshot.semantic;
|
|
2890
|
-
return {
|
|
2891
|
-
region: {
|
|
2892
|
-
targetFiberId,
|
|
2893
|
-
...semantic.kind === "scope" ? { scope: semantic.fragment } : {},
|
|
2894
|
-
targetId: semantic.kind === "scope" ? PROJECTION_SCOPE_TARGET : aggregatesPhysicalTargets(root) && root.tag !== FiberTag.HostRoot && !(isTempoHiddenFiber(root) && getDomElement(root) === watchedRoot) ? `${fiberId(root)}/physical` : id2(root),
|
|
2895
|
-
tree: serialized.snapshot.semantic.kind === "layers" ? serialized.snapshot.semantic.tree : null,
|
|
2896
|
-
observedFiles: serialized.snapshot.observedFiles
|
|
2897
|
-
},
|
|
2898
|
-
fiberNodesVisited: serialized.fiberNodesVisited,
|
|
2899
|
-
semanticNodesSerialized: serialized.semanticNodesSerialized
|
|
2900
|
-
};
|
|
2901
|
-
},
|
|
2902
|
-
captureMetadata(root, options) {
|
|
2903
|
-
return {
|
|
2904
|
-
targetFiberId: fiberId(root),
|
|
2905
|
-
targetId: id2(root),
|
|
2906
|
-
props: captureProjectionLayerProps(
|
|
2907
|
-
root,
|
|
2908
|
-
root.tag === FiberTag.HostComponent ? getDomElement(root) : null,
|
|
2909
|
-
options?.sourceAnnotations ?? "fiber",
|
|
2910
|
-
options?.layoutMode
|
|
2911
|
-
)
|
|
2912
|
-
};
|
|
2913
|
-
}
|
|
2914
|
-
};
|
|
2915
|
-
}
|
|
2916
|
-
function isProjectionLayerFiber(fiber) {
|
|
2917
|
-
if (isTempoHiddenFiber(fiber)) return false;
|
|
2918
|
-
const kind = projectionKindForTag(fiber.tag);
|
|
2919
|
-
if (kind === null) return false;
|
|
2920
|
-
if (kind === "host") return true;
|
|
2921
|
-
const sourceKey = projectionFiberSourceKey(fiber);
|
|
2922
|
-
if (!sourceKey) return true;
|
|
2923
|
-
for (let parent = fiber.return; parent; parent = parent.return) {
|
|
2924
|
-
if (isTempoHiddenFiber(parent)) continue;
|
|
2925
|
-
const parentKind = projectionKindForTag(parent.tag);
|
|
2926
|
-
if (parentKind === null) continue;
|
|
2927
|
-
if (parentKind === "host") return true;
|
|
2928
|
-
return projectionFiberSourceKey(parent) !== sourceKey;
|
|
2929
|
-
}
|
|
2930
|
-
return true;
|
|
2931
|
-
}
|
|
2932
|
-
function projectionKindForTag(tag) {
|
|
2933
|
-
if (tag === FiberTag.HostComponent) return "host";
|
|
2934
|
-
if (tag === FiberTag.HostText) return "text";
|
|
2935
|
-
if (COMPONENT_TAGS.has(tag)) return "component";
|
|
2936
|
-
return null;
|
|
2937
|
-
}
|
|
2938
|
-
function ascendToAnnotatedComponentRoot(fiber) {
|
|
2939
|
-
let topmost = fiber;
|
|
2940
|
-
for (let parent = fiber.return; parent; parent = parent.return) {
|
|
2941
|
-
if (parent.tag === FiberTag.HostRoot || parent.tag === FiberTag.HostPortal) {
|
|
2942
|
-
break;
|
|
2943
|
-
}
|
|
2944
|
-
const kind = projectionKindForTag(parent.tag);
|
|
2945
|
-
if (kind === "host") break;
|
|
2946
|
-
if (isTempoHiddenFiber(parent)) break;
|
|
2947
|
-
if (kind === "component") {
|
|
2948
|
-
if (projectionFiberSourceKey(parent) === null) break;
|
|
2949
|
-
topmost = parent;
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
return topmost;
|
|
2953
|
-
}
|
|
2954
|
-
function isProjectionRootFiber(fiber) {
|
|
2955
|
-
const props = getProps(fiber);
|
|
2956
|
-
const dataSet = props?.dataSet;
|
|
2957
|
-
const native = dataSet && typeof dataSet === "object" ? dataSet.tempoProjectionRoot : void 0;
|
|
2958
|
-
const value = native ?? props?.[PROJECTION_ROOT_ATTRIBUTE];
|
|
2959
|
-
return value === true || value === "true";
|
|
2960
|
-
}
|
|
2961
|
-
function isTempoHiddenFiber(fiber) {
|
|
2962
|
-
if (isProjectionScopePlumbing(fiber)) return true;
|
|
2963
|
-
const props = getProps(fiber);
|
|
2964
|
-
const direct = props?.["data-tempo-hide-fiber"];
|
|
2965
|
-
const dataSet = props?.dataSet;
|
|
2966
|
-
const native = dataSet && typeof dataSet === "object" ? dataSet.tempoHideFiber : void 0;
|
|
2967
|
-
const value = native ?? direct;
|
|
2968
|
-
return value === true || value === "true";
|
|
2969
|
-
}
|
|
2970
|
-
function captureProjectionLayerProps(fiber, element, sourceAnnotations = "fiber", layoutMode) {
|
|
2971
|
-
const raw = getProps(fiber);
|
|
2972
|
-
const dataSet = raw?.dataSet && typeof raw.dataSet === "object" ? raw.dataSet : void 0;
|
|
2973
|
-
const read = (flatKey, dataSetKey, authority = "source") => {
|
|
2974
|
-
if (authority === "source" && element && sourceAnnotations === "live-host") {
|
|
2975
|
-
return element.getAttribute(flatKey);
|
|
2976
|
-
}
|
|
2977
|
-
return dataSet && Object.hasOwn(dataSet, dataSetKey) ? dataSet[dataSetKey] : raw?.[flatKey];
|
|
2978
|
-
};
|
|
2979
|
-
const props = {};
|
|
2980
|
-
const putString = (flatKey, dataSetKey) => {
|
|
2981
|
-
const value = read(flatKey, dataSetKey);
|
|
2982
|
-
if (typeof value === "string") props[flatKey] = value;
|
|
2983
|
-
};
|
|
2984
|
-
const putFiniteNumber = (flatKey, dataSetKey) => {
|
|
2985
|
-
const value = read(flatKey, dataSetKey);
|
|
2986
|
-
const numeric = typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number.NaN;
|
|
2987
|
-
if (Number.isFinite(numeric)) props[flatKey] = numeric;
|
|
2988
|
-
};
|
|
2989
|
-
const putBoolean = (flatKey, dataSetKey) => {
|
|
2990
|
-
const value = read(flatKey, dataSetKey, "fiber");
|
|
2991
|
-
if (value === true || value === "true") props[flatKey] = true;
|
|
2992
|
-
if (value === false || value === "false") props[flatKey] = false;
|
|
2993
|
-
};
|
|
2994
|
-
const putPresence = (flatKey, dataSetKey) => {
|
|
2995
|
-
const present = dataSet != null && Object.hasOwn(dataSet, dataSetKey) || raw != null && Object.hasOwn(raw, flatKey);
|
|
2996
|
-
if (present)
|
|
2997
|
-
props[flatKey] = read(flatKey, dataSetKey, "fiber") !== "false";
|
|
2998
|
-
};
|
|
2999
|
-
putString("data-tempo-filepath", "tempoFilepath");
|
|
3000
|
-
const locked = read("data-tempo-locked", "tempoLocked");
|
|
3001
|
-
if (locked === true || locked === "true" || locked === "")
|
|
3002
|
-
props["data-tempo-locked"] = true;
|
|
3003
|
-
else if (locked === false || locked === "false")
|
|
3004
|
-
props["data-tempo-locked"] = false;
|
|
3005
|
-
putFiniteNumber("data-tempo-position", "tempoPosition");
|
|
3006
|
-
putString("data-tempo-source-tag", "tempoSourceTag");
|
|
3007
|
-
putFiniteNumber("data-tempo-modifiedts", "tempoModifiedts");
|
|
3008
|
-
putString("data-tempo-source-version", "tempoSourceVersion");
|
|
3009
|
-
putBoolean("data-tempo-supports-style", "tempoSupportsStyle");
|
|
3010
|
-
putBoolean("data-tempo-supports-classname", "tempoSupportsClassname");
|
|
3011
|
-
putBoolean("data-tempo-supports-children", "tempoSupportsChildren");
|
|
3012
|
-
putString("data-tempo-expr", "tempoExpr");
|
|
3013
|
-
putPresence("data-tempo-storyboard-root", "tempoStoryboardRoot");
|
|
3014
|
-
putString("data-tempo-component-reference", "tempoComponentReference");
|
|
3015
|
-
putString("data-tempo-external-component", "tempoExternalComponent");
|
|
3016
|
-
putString("data-tempo-canvas-declaration", "tempoCanvasDeclaration");
|
|
3017
|
-
putString("data-tempo-storyboard-declaration", "tempoStoryboardDeclaration");
|
|
3018
|
-
putString("data-tempo-storyboard-id", "tempoStoryboardId");
|
|
3019
|
-
if (element) {
|
|
3020
|
-
if (layoutMode === void 0) {
|
|
3021
|
-
layoutMode = layoutModeOf(getComputedStyle(element));
|
|
3022
|
-
}
|
|
3023
|
-
if (layoutMode) props.layoutMode = layoutMode;
|
|
3024
|
-
const className = element.getAttribute("class");
|
|
3025
|
-
if (className !== null && className !== "") props.className = className;
|
|
3026
|
-
const style = parseInlineStyle2(element.getAttribute("style"));
|
|
3027
|
-
if (style) props.style = style;
|
|
3028
|
-
Object.assign(props, svgLayerAttributes(element));
|
|
3029
|
-
} else if (typeof raw?.className === "string") {
|
|
3030
|
-
props.className = raw.className;
|
|
3031
|
-
}
|
|
3032
|
-
if (element && isFlutterViewRoot(element))
|
|
3033
|
-
Object.assign(props, flutterHostProps(element));
|
|
3034
|
-
return Object.keys(props).length > 0 ? props : void 0;
|
|
3035
|
-
}
|
|
3036
|
-
function countNodes(nodes) {
|
|
3037
|
-
let count = 0;
|
|
3038
|
-
for (const node of nodes) count += 1 + countNodes(node.children ?? []);
|
|
3039
|
-
return count;
|
|
3040
|
-
}
|
|
3041
|
-
function parseInlineStyle2(value) {
|
|
3042
|
-
if (!value) return void 0;
|
|
3043
|
-
const style = {};
|
|
3044
|
-
for (const declaration of splitCssDeclarations(value)) {
|
|
3045
|
-
const colon = declaration.indexOf(":");
|
|
3046
|
-
if (colon < 0) continue;
|
|
3047
|
-
const property = declaration.slice(0, colon).trim();
|
|
3048
|
-
const propertyValue = declaration.slice(colon + 1).trim();
|
|
3049
|
-
if (property) style[property] = propertyValue;
|
|
3050
|
-
}
|
|
3051
|
-
return Object.keys(style).length > 0 ? style : void 0;
|
|
3052
|
-
}
|
|
3053
|
-
function projectionFiberSourceKey(fiber) {
|
|
3054
|
-
const props = captureProjectionLayerProps(fiber, null);
|
|
3055
|
-
const filepath = props?.["data-tempo-filepath"];
|
|
3056
|
-
const position = props?.["data-tempo-position"];
|
|
3057
|
-
return filepath && position !== void 0 ? `${filepath}:${position}` : null;
|
|
3058
|
-
}
|
|
3059
|
-
|
|
3060
|
-
export {
|
|
3061
|
-
FiberTag,
|
|
3062
|
-
PROJECTION_SCOPE_ROLE,
|
|
3063
|
-
PROJECTION_PENDING_ATTRIBUTE,
|
|
3064
|
-
PROJECTION_UNAVAILABLE_ATTRIBUTE,
|
|
3065
|
-
isProjectionPendingOnly,
|
|
3066
|
-
isProjectionUnavailableOnly,
|
|
3067
|
-
getDisplayName,
|
|
3068
|
-
getTag,
|
|
3069
|
-
getProps,
|
|
3070
|
-
sanitizeProps,
|
|
3071
|
-
getDomElement,
|
|
3072
|
-
resolveCommittedFiber,
|
|
3073
|
-
isTransientFiberResolutionError,
|
|
3074
|
-
serializeTree,
|
|
3075
|
-
getFiberFromElement,
|
|
3076
|
-
captureTree,
|
|
3077
|
-
getCommittedFiberRoots,
|
|
3078
|
-
initHook,
|
|
3079
|
-
REALM_DOCUMENT_EPOCH,
|
|
3080
|
-
nextRealmCaptureSequence,
|
|
3081
|
-
readAstroMarker,
|
|
3082
|
-
trackAstroSources,
|
|
3083
|
-
DOM_ID_ATTR,
|
|
3084
|
-
PROJECTION_ROOT_ATTRIBUTE,
|
|
3085
|
-
nextProjectionId,
|
|
3086
|
-
seedProjectionIds,
|
|
3087
|
-
underForeignProjectionRoot,
|
|
3088
|
-
projectedElements,
|
|
3089
|
-
cloneProjectionDom,
|
|
3090
|
-
ensureProjectionDomId,
|
|
3091
|
-
readProjectionDomId,
|
|
3092
|
-
syncProjectionDomIdsToClone,
|
|
3093
|
-
watchDom,
|
|
3094
|
-
drainProjectionDomMutations,
|
|
3095
|
-
isFlutterViewRoot,
|
|
3096
|
-
flutterViewRootOf,
|
|
3097
|
-
watchState,
|
|
3098
|
-
drainProjectionStateEvents,
|
|
3099
|
-
PORTAL_ID_ATTR,
|
|
3100
|
-
getOrAssignPortalId,
|
|
3101
|
-
watchPortal,
|
|
3102
|
-
capturePortalCoordinateSpace,
|
|
3103
|
-
cssEscape,
|
|
3104
|
-
ProjectionObservedFileAccumulator,
|
|
3105
|
-
SOURCE_ANNOTATION_ATTRIBUTES,
|
|
3106
|
-
PROJECTION_ROOT_TARGET_ID,
|
|
3107
|
-
captureProjectionMutationPatch,
|
|
3108
|
-
captureProjectionStatePatch,
|
|
3109
|
-
captureProjectionPortalRegion,
|
|
3110
|
-
captureProjectionPortalCoordinates,
|
|
3111
|
-
stripSourceAnnotations,
|
|
3112
|
-
captureRegionWithoutAnnotations,
|
|
3113
|
-
captureProjectionAncestorIds,
|
|
3114
|
-
DOM_LAYER_ROOT_ID,
|
|
3115
|
-
createProjectionDomLayerSerializer,
|
|
3116
|
-
serializeDomLayerNode,
|
|
3117
|
-
captureProjectionDomLayerProps,
|
|
3118
|
-
invocationSourceLayerProps,
|
|
3119
|
-
parseInlineStyle,
|
|
3120
|
-
svgLayerAttributesOf,
|
|
3121
|
-
layerPropsEqual,
|
|
3122
|
-
recordEqual,
|
|
3123
|
-
PROJECTION_SCOPE_TARGET,
|
|
3124
|
-
projectionLayerRoots,
|
|
3125
|
-
createProjectionLayerSerializer,
|
|
3126
|
-
isProjectionLayerFiber,
|
|
3127
|
-
ascendToAnnotatedComponentRoot,
|
|
3128
|
-
isProjectionRootFiber
|
|
3129
|
-
};
|
|
3130
|
-
//# sourceMappingURL=chunk-KY52JZZL.js.map
|