@reactre/full-compat 0.0.0-stage → 0.0.2
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/LICENSE +202 -0
- package/README.md +46 -2
- package/dist/chunk-11zdy4zv.js +167 -0
- package/dist/chunk-4er1w1vd.js +585 -0
- package/dist/chunk-b3y5xqd8.js +9 -0
- package/dist/chunk-e4yywtvf.js +7281 -0
- package/dist/chunk-ez9na11j.js +6 -0
- package/dist/chunk-m94gb9v9.js +6 -0
- package/dist/chunk-mtd8nnwt.js +6 -0
- package/dist/chunk-skse5h3m.js +277 -0
- package/dist/chunk-v1e4rr21.js +6 -0
- package/dist/core.js +171 -0
- package/dist/features/classes.js +2 -0
- package/dist/features/concurrent.js +2 -0
- package/dist/features/keys.js +2 -0
- package/dist/features/retry.js +2 -0
- package/dist/features/stacks.js +2 -0
- package/dist/features/undo.js +2 -0
- package/dist/features/viewTransitions.js +2 -0
- package/dist/index.js +178 -0
- package/dist/server.browser.js +6 -0
- package/dist/server.edge.js +6 -0
- package/dist/server.js +6 -0
- package/package.json +93 -4
- package/src/core.ts +8 -0
- package/src/features/classes.ts +2 -0
- package/src/features/concurrent.ts +2 -0
- package/src/features/keys.ts +2 -0
- package/src/features/retry.ts +2 -0
- package/src/features/stacks.ts +2 -0
- package/src/features/undo.ts +2 -0
- package/src/features/viewTransitions.ts +2 -0
- package/src/index.ts +11 -0
- package/src/server.browser.ts +3 -0
- package/src/server.edge.ts +3 -0
- package/src/server.ts +3 -0
- package/src/slicing.ts +4 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__installViewTransitions2
|
|
3
|
+
} from "./chunk-e4yywtvf.js";
|
|
4
|
+
|
|
5
|
+
// ../compat/src/features/viewTransitions.ts
|
|
6
|
+
class PseudoElement {
|
|
7
|
+
_scope;
|
|
8
|
+
_selector;
|
|
9
|
+
constructor(pseudo, name) {
|
|
10
|
+
this._scope = document.documentElement;
|
|
11
|
+
this._selector = "::view-transition-" + pseudo + "(" + name + ")";
|
|
12
|
+
}
|
|
13
|
+
animate(keyframes, options) {
|
|
14
|
+
const o = typeof options === "number" ? { duration: options } : { ...options };
|
|
15
|
+
o.pseudoElement = this._selector;
|
|
16
|
+
return this._scope.animate(keyframes, o);
|
|
17
|
+
}
|
|
18
|
+
getAnimations() {
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const a of this._scope.getAnimations({ subtree: true })) {
|
|
21
|
+
const e = a.effect;
|
|
22
|
+
if (e !== null && e.target === this._scope && e.pseudoElement === this._selector)
|
|
23
|
+
out.push(a);
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
getComputedStyle() {
|
|
28
|
+
return getComputedStyle(this._scope, this._selector);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function viewTransitions(core) {
|
|
32
|
+
const { FRAG, TEXT, ACTIVITY, SLOT, BOX, HIDDEN, DEAD, VIEW_TRANSITION } = core;
|
|
33
|
+
const isVT = (f) => f.n === FRAG && f.t === VIEW_TRANSITION;
|
|
34
|
+
const kids = (f) => f.c.length > 1 && f.c[0].n === SLOT ? [...f.c].sort((a, b) => a.k - b.k) : f.c;
|
|
35
|
+
const states = new WeakMap;
|
|
36
|
+
const stateOf = (f) => {
|
|
37
|
+
let s = states.get(f);
|
|
38
|
+
if (s === undefined)
|
|
39
|
+
states.set(f, s = { autoName: null, paired: null, ref: null });
|
|
40
|
+
return s;
|
|
41
|
+
};
|
|
42
|
+
let autoNames = 0;
|
|
43
|
+
let p = null;
|
|
44
|
+
let hostIndex = 0;
|
|
45
|
+
let cancelable = null;
|
|
46
|
+
let contextChanged = false;
|
|
47
|
+
function nameOf(f, props) {
|
|
48
|
+
if (props.name != null && props.name !== "auto")
|
|
49
|
+
return props.name;
|
|
50
|
+
const s = stateOf(f);
|
|
51
|
+
return s.autoName ??= "_" + f.o.prefix + "t_" + (autoNames++).toString(32) + "_";
|
|
52
|
+
}
|
|
53
|
+
function classByType(c, types) {
|
|
54
|
+
if (c == null || typeof c === "string")
|
|
55
|
+
return c;
|
|
56
|
+
let out = null;
|
|
57
|
+
if (types !== null)
|
|
58
|
+
for (const t of types) {
|
|
59
|
+
const m = c[t];
|
|
60
|
+
if (m != null) {
|
|
61
|
+
if (m === "none")
|
|
62
|
+
return "none";
|
|
63
|
+
out = out == null ? m : out + " " + m;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return out == null ? c.default : out;
|
|
67
|
+
}
|
|
68
|
+
let types = null;
|
|
69
|
+
function classOf(def, event) {
|
|
70
|
+
const d = classByType(def, types), e = classByType(event, types);
|
|
71
|
+
return e == null ? d === "auto" ? null : d : e === "auto" ? null : e;
|
|
72
|
+
}
|
|
73
|
+
function measure(el) {
|
|
74
|
+
const rect = el.getBoundingClientRect(), cs = getComputedStyle(el), w = el.ownerDocument.defaultView;
|
|
75
|
+
return {
|
|
76
|
+
rect,
|
|
77
|
+
abs: cs.position === "absolute" || cs.position === "fixed",
|
|
78
|
+
clip: cs.clipPath !== "none" || cs.overflow !== "visible" || cs.filter !== "none" || cs.mask !== "none" || cs.borderRadius !== "0px",
|
|
79
|
+
view: rect.bottom >= 0 && rect.right >= 0 && rect.top <= w.innerHeight && rect.left <= w.innerWidth
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function applyName(f, el, name, cls) {
|
|
83
|
+
name = CSS.escape(name) !== name ? "r-" + btoa(name).replace(/=/g, "") : name;
|
|
84
|
+
p.named.push(el, f, f.p, name, cls);
|
|
85
|
+
setName(el, name, cls);
|
|
86
|
+
}
|
|
87
|
+
function setName(el, name, cls) {
|
|
88
|
+
el.style.viewTransitionName = name;
|
|
89
|
+
if (cls != null)
|
|
90
|
+
el.style.viewTransitionClass = cls;
|
|
91
|
+
const cs = getComputedStyle(el);
|
|
92
|
+
if (cs.display === "inline") {
|
|
93
|
+
const rects = el.getClientRects();
|
|
94
|
+
let n = 0;
|
|
95
|
+
if (rects.length === 1)
|
|
96
|
+
n = 1;
|
|
97
|
+
else
|
|
98
|
+
for (const r of rects)
|
|
99
|
+
if (r.width > 0 && r.height > 0)
|
|
100
|
+
n++;
|
|
101
|
+
if (n === 1) {
|
|
102
|
+
const s = el.style;
|
|
103
|
+
s.display = rects.length === 1 ? "inline-block" : "block";
|
|
104
|
+
s.marginTop = "-" + cs.paddingTop;
|
|
105
|
+
s.marginBottom = "-" + cs.paddingBottom;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function restoreName(el, props) {
|
|
110
|
+
const s = el.style, st = props.style;
|
|
111
|
+
const read = (a, b) => st != null ? Object.hasOwn(st, a) ? st[a] : Object.hasOwn(st, b) ? st[b] : null : null;
|
|
112
|
+
const str = (v) => v == null || typeof v === "boolean" ? "" : ("" + v).trim();
|
|
113
|
+
s.viewTransitionName = str(read("viewTransitionName", "view-transition-name"));
|
|
114
|
+
s.viewTransitionClass = str(read("viewTransitionClass", "view-transition-class"));
|
|
115
|
+
if (s.display === "inline-block") {
|
|
116
|
+
if (st == null)
|
|
117
|
+
s.display = s.margin = "";
|
|
118
|
+
else {
|
|
119
|
+
const v = (x) => x == null || typeof x === "boolean" ? "" : x;
|
|
120
|
+
s.display = v(st.display);
|
|
121
|
+
if (st.margin != null)
|
|
122
|
+
s.margin = st.margin;
|
|
123
|
+
else {
|
|
124
|
+
s.marginTop = v(read("marginTop", "margin-top"));
|
|
125
|
+
s.marginBottom = v(read("marginBottom", "margin-bottom"));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const element = (f) => (f.f & BOX) !== 0 && f.n !== TEXT && f.d.nodeType === 1;
|
|
131
|
+
function applyHosts(f, name, cls, out, stop) {
|
|
132
|
+
hostIndex = 0;
|
|
133
|
+
return applyIn(kids(f), name, cls, out, stop);
|
|
134
|
+
}
|
|
135
|
+
function applyIn(cs, name, cls, out, stop) {
|
|
136
|
+
let view = false;
|
|
137
|
+
for (const c of cs) {
|
|
138
|
+
if (element(c)) {
|
|
139
|
+
const m = measure(c.d);
|
|
140
|
+
if (out !== null)
|
|
141
|
+
out.push(m);
|
|
142
|
+
if (m.view)
|
|
143
|
+
view = true;
|
|
144
|
+
p.start = true;
|
|
145
|
+
applyName(c, c.d, hostIndex === 0 ? name : name + "_" + hostIndex, cls);
|
|
146
|
+
hostIndex++;
|
|
147
|
+
} else if (!(c.f & HIDDEN) && !(isVT(c) && stop) && applyIn(kids(c), name, cls, out, stop))
|
|
148
|
+
view = true;
|
|
149
|
+
}
|
|
150
|
+
return view;
|
|
151
|
+
}
|
|
152
|
+
function restoreIn(cs, stop) {
|
|
153
|
+
for (const c of cs) {
|
|
154
|
+
if (element(c))
|
|
155
|
+
restoreName(c.d, c.p);
|
|
156
|
+
else if (!(c.f & HIDDEN) && !(isVT(c) && stop))
|
|
157
|
+
restoreIn(kids(c), stop);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function event(f, props, cb) {
|
|
161
|
+
if (cb == null)
|
|
162
|
+
return;
|
|
163
|
+
const s = stateOf(f), name = nameOf(f, props);
|
|
164
|
+
s.ref ??= {
|
|
165
|
+
name,
|
|
166
|
+
group: new PseudoElement("group", name),
|
|
167
|
+
imagePair: new PseudoElement("image-pair", name),
|
|
168
|
+
old: new PseudoElement("old", name),
|
|
169
|
+
new: new PseudoElement("new", name)
|
|
170
|
+
};
|
|
171
|
+
p.events.push(cb, s.ref);
|
|
172
|
+
}
|
|
173
|
+
const holds = (f) => isVT(f) || !(f.f & BOX) && f.c.some(holds);
|
|
174
|
+
const anyVT = (f) => isVT(f) || f.c.some(anyVT);
|
|
175
|
+
function own(f) {
|
|
176
|
+
const o = p.old.get(f);
|
|
177
|
+
if (o === undefined)
|
|
178
|
+
return true;
|
|
179
|
+
if (f.f & BOX && o[1] !== f.p)
|
|
180
|
+
return true;
|
|
181
|
+
if ((o[2] ^ f.f) & HIDDEN)
|
|
182
|
+
return true;
|
|
183
|
+
const oc = o[0];
|
|
184
|
+
if (oc.length !== f.c.length)
|
|
185
|
+
return true;
|
|
186
|
+
for (let i = 0;i < oc.length; i++)
|
|
187
|
+
if (oc[i] !== f.c[i])
|
|
188
|
+
return true;
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
function under(f) {
|
|
192
|
+
let any = false;
|
|
193
|
+
for (const c of kids(f))
|
|
194
|
+
if (changed(c))
|
|
195
|
+
any = true;
|
|
196
|
+
return any;
|
|
197
|
+
}
|
|
198
|
+
function changed(f) {
|
|
199
|
+
let c = p.changed.get(f);
|
|
200
|
+
if (c === undefined)
|
|
201
|
+
p.changed.set(f, c = under(f) || own(f));
|
|
202
|
+
return c;
|
|
203
|
+
}
|
|
204
|
+
const hiddenNow = (f) => (f.f & HIDDEN) !== 0;
|
|
205
|
+
function visit(f) {
|
|
206
|
+
const o = p.old.get(f);
|
|
207
|
+
if (o !== undefined) {
|
|
208
|
+
for (const d of o[0])
|
|
209
|
+
if (d.f & DEAD)
|
|
210
|
+
p.ops.push(0, d);
|
|
211
|
+
}
|
|
212
|
+
if (o === undefined) {
|
|
213
|
+
if (holds(f))
|
|
214
|
+
p.start = true;
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if ((o[2] ^ f.f) & HIDDEN && (f.n === ACTIVITY || f.n === FRAG)) {
|
|
218
|
+
if (hiddenNow(f))
|
|
219
|
+
p.ops.push(1, f);
|
|
220
|
+
else if (holds(f))
|
|
221
|
+
p.start = true;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (under(f))
|
|
225
|
+
for (const c of kids(f))
|
|
226
|
+
visit(c);
|
|
227
|
+
else
|
|
228
|
+
p.ops.push(2, f);
|
|
229
|
+
if (isVT(f)) {
|
|
230
|
+
p.props.set(f, f.p);
|
|
231
|
+
p.ops.push(3, f);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function appear(f, isNew) {
|
|
235
|
+
if (f.f & HIDDEN)
|
|
236
|
+
return;
|
|
237
|
+
if (isNew && isVT(f) && f.p.name != null && f.p.name !== "auto") {
|
|
238
|
+
stateOf(f).paired = null;
|
|
239
|
+
(p.appearing ??= new Map).set(f.p.name, stateOf(f));
|
|
240
|
+
}
|
|
241
|
+
for (const c of kids(f))
|
|
242
|
+
appear(c, isNew || !p.old.has(c));
|
|
243
|
+
}
|
|
244
|
+
function exit(d) {
|
|
245
|
+
if (isVT(d)) {
|
|
246
|
+
const props = d.p, name = nameOf(d, props), pair = p.appearing !== null ? p.appearing.get(name) : undefined, cls = classOf(props.default, pair !== undefined ? props.share : props.exit);
|
|
247
|
+
if (cls !== "none") {
|
|
248
|
+
if (applyHosts(d, name, cls, null, false)) {
|
|
249
|
+
if (pair !== undefined) {
|
|
250
|
+
const s = stateOf(d);
|
|
251
|
+
pair.paired = s;
|
|
252
|
+
s.paired = pair;
|
|
253
|
+
p.appearing.delete(name);
|
|
254
|
+
event(d, props, props.onShare);
|
|
255
|
+
} else
|
|
256
|
+
event(d, props, props.onExit);
|
|
257
|
+
} else
|
|
258
|
+
restoreIn(kids(d), false);
|
|
259
|
+
}
|
|
260
|
+
if (p.appearing !== null)
|
|
261
|
+
pairs(d);
|
|
262
|
+
} else if (holds(d))
|
|
263
|
+
for (const c of kids(d))
|
|
264
|
+
exit(c);
|
|
265
|
+
else if (p.appearing !== null)
|
|
266
|
+
pairs(d);
|
|
267
|
+
}
|
|
268
|
+
function pairs(d) {
|
|
269
|
+
const a = p.appearing;
|
|
270
|
+
if (a.size === 0)
|
|
271
|
+
return;
|
|
272
|
+
for (const c of kids(d)) {
|
|
273
|
+
if (c.f & HIDDEN)
|
|
274
|
+
continue;
|
|
275
|
+
if (isVT(c)) {
|
|
276
|
+
const props = c.p, name = props.name;
|
|
277
|
+
if (name != null && name !== "auto") {
|
|
278
|
+
const pair = a.get(name);
|
|
279
|
+
if (pair !== undefined) {
|
|
280
|
+
const cls = classOf(props.default, props.share);
|
|
281
|
+
if (cls !== "none") {
|
|
282
|
+
if (applyHosts(c, name, cls, null, false)) {
|
|
283
|
+
const s = stateOf(c);
|
|
284
|
+
pair.paired = s;
|
|
285
|
+
s.paired = pair;
|
|
286
|
+
event(c, props, props.onShare);
|
|
287
|
+
} else
|
|
288
|
+
restoreIn(kids(c), false);
|
|
289
|
+
}
|
|
290
|
+
a.delete(name);
|
|
291
|
+
if (a.size === 0)
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
pairs(c);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function nested(f) {
|
|
300
|
+
for (const c of kids(f)) {
|
|
301
|
+
if (isVT(c)) {
|
|
302
|
+
const cls = classOf(c.p.default, c.p.update);
|
|
303
|
+
p.updated.delete(c);
|
|
304
|
+
const m = [];
|
|
305
|
+
p.measured.set(c, m);
|
|
306
|
+
if (cls !== "none")
|
|
307
|
+
applyHosts(c, nameOf(c, c.p), cls, m, false);
|
|
308
|
+
} else if (holds(c))
|
|
309
|
+
nested(c);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function measureIn(vt, cs, name, oldName, cls, prev, stop) {
|
|
313
|
+
let view = false;
|
|
314
|
+
for (const c of cs) {
|
|
315
|
+
if (element(c)) {
|
|
316
|
+
const el = c.d;
|
|
317
|
+
if (prev !== null && hostIndex < prev.length) {
|
|
318
|
+
const a = prev[hostIndex], b = measure(el);
|
|
319
|
+
if (a.view || b.view)
|
|
320
|
+
view = true;
|
|
321
|
+
if (!p.updated.has(vt)) {
|
|
322
|
+
const r = a.rect, s = b.rect;
|
|
323
|
+
if (b.clip || r.y !== s.y || r.x !== s.x || r.height !== s.height || r.width !== s.width)
|
|
324
|
+
p.updated.add(vt);
|
|
325
|
+
}
|
|
326
|
+
const sized = b.abs ? !a.abs : a.rect.height !== b.rect.height || a.rect.width !== b.rect.width;
|
|
327
|
+
if (sized)
|
|
328
|
+
p.resized.add(vt);
|
|
329
|
+
} else
|
|
330
|
+
p.resized.add(vt);
|
|
331
|
+
if (p.updated.has(vt))
|
|
332
|
+
applyName(c, el, hostIndex === 0 ? name : name + "_" + hostIndex, cls);
|
|
333
|
+
if (!view || !p.updated.has(vt))
|
|
334
|
+
(cancelable ??= []).push(el, hostIndex === 0 ? oldName : oldName + "_" + hostIndex, c.p);
|
|
335
|
+
hostIndex++;
|
|
336
|
+
} else if (!(c.f & HIDDEN)) {
|
|
337
|
+
if (isVT(c) && stop) {
|
|
338
|
+
if (p.resized.has(c))
|
|
339
|
+
p.resized.add(vt);
|
|
340
|
+
} else if (measureIn(vt, kids(c), name, oldName, cls, prev, stop))
|
|
341
|
+
view = true;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return view;
|
|
345
|
+
}
|
|
346
|
+
function measureNested(f) {
|
|
347
|
+
for (const c of kids(f)) {
|
|
348
|
+
if (isVT(c)) {
|
|
349
|
+
const props = c.p, name = nameOf(c, props), cls = classOf(props.default, props.update);
|
|
350
|
+
hostIndex = 0;
|
|
351
|
+
const view = measureIn(c, kids(c), name, name, cls, p.measured.get(c) ?? null, false);
|
|
352
|
+
p.measured.delete(c);
|
|
353
|
+
if (p.updated.has(c) && view)
|
|
354
|
+
event(c, props, props.onUpdate);
|
|
355
|
+
} else if (holds(c))
|
|
356
|
+
measureNested(c);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function enter(f) {
|
|
360
|
+
if (isVT(f)) {
|
|
361
|
+
const s = stateOf(f), props = f.p, name = nameOf(f, props), cls = classOf(props.default, s.paired ? props.share : props.enter);
|
|
362
|
+
if (cls !== "none") {
|
|
363
|
+
if (applyHosts(f, name, cls, null, false)) {
|
|
364
|
+
appearing(f);
|
|
365
|
+
if (!s.paired)
|
|
366
|
+
event(f, props, props.onEnter);
|
|
367
|
+
} else
|
|
368
|
+
restoreIn(kids(f), false);
|
|
369
|
+
} else
|
|
370
|
+
appearing(f);
|
|
371
|
+
} else if (holds(f))
|
|
372
|
+
for (const c of kids(f))
|
|
373
|
+
enter(c);
|
|
374
|
+
else
|
|
375
|
+
appearing(f);
|
|
376
|
+
}
|
|
377
|
+
function appearing(f) {
|
|
378
|
+
for (const c of kids(f)) {
|
|
379
|
+
if (c.f & HIDDEN)
|
|
380
|
+
continue;
|
|
381
|
+
appearing(c);
|
|
382
|
+
if (isVT(c) && stateOf(c).paired) {
|
|
383
|
+
const props = c.p, cls = classOf(props.default, props.share);
|
|
384
|
+
if (cls !== "none" && !applyHosts(c, props.name, cls, null, false))
|
|
385
|
+
restoreIn(kids(c), false);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function after(f) {
|
|
390
|
+
const o = p.old.get(f);
|
|
391
|
+
if (o === undefined)
|
|
392
|
+
return enter(f);
|
|
393
|
+
if ((f.n === ACTIVITY || f.n === FRAG) && (o[2] | f.f) & HIDDEN) {
|
|
394
|
+
if (!hiddenNow(f))
|
|
395
|
+
o[2] & HIDDEN ? enter(f) : traverse(f);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (!isVT(f))
|
|
399
|
+
return traverse(f);
|
|
400
|
+
const prevChanged = contextChanged, prevCancelable = cancelable;
|
|
401
|
+
cancelable = null;
|
|
402
|
+
contextChanged = false;
|
|
403
|
+
traverse(f);
|
|
404
|
+
if (contextChanged)
|
|
405
|
+
p.updated.add(f);
|
|
406
|
+
const props = f.p, name = nameOf(f, props), oldName = nameOf(f, o[1]), cls = classOf(props.default, props.update);
|
|
407
|
+
let view = false;
|
|
408
|
+
if (cls !== "none") {
|
|
409
|
+
const prev = p.measured.get(f) ?? null;
|
|
410
|
+
p.measured.delete(f);
|
|
411
|
+
hostIndex = 0;
|
|
412
|
+
view = measureIn(f, kids(f), name, oldName, cls, prev, true);
|
|
413
|
+
if (hostIndex !== (prev === null ? 0 : prev.length))
|
|
414
|
+
p.resized.add(f);
|
|
415
|
+
}
|
|
416
|
+
if (p.updated.has(f) && view) {
|
|
417
|
+
event(f, props, props.onUpdate);
|
|
418
|
+
cancelable = prevCancelable;
|
|
419
|
+
} else if (prevCancelable !== null) {
|
|
420
|
+
prevCancelable.push(...cancelable ?? []);
|
|
421
|
+
cancelable = prevCancelable;
|
|
422
|
+
}
|
|
423
|
+
contextChanged = p.resized.has(f) ? true : prevChanged;
|
|
424
|
+
}
|
|
425
|
+
function traverse(f) {
|
|
426
|
+
if (under(f))
|
|
427
|
+
for (const c of kids(f))
|
|
428
|
+
after(c);
|
|
429
|
+
else
|
|
430
|
+
measureNested(f);
|
|
431
|
+
}
|
|
432
|
+
return {
|
|
433
|
+
plan(roots, sv, records) {
|
|
434
|
+
const old = new Map;
|
|
435
|
+
let any = false;
|
|
436
|
+
for (let i = 0;i < sv.length; ) {
|
|
437
|
+
const f = sv[i];
|
|
438
|
+
if (f.n === undefined) {
|
|
439
|
+
i += 4;
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
old.set(f, [sv[i + 3], sv[i + 1], sv[i + 6]]);
|
|
443
|
+
if (isVT(f))
|
|
444
|
+
any = true;
|
|
445
|
+
i += 16;
|
|
446
|
+
if (sv[i - 1] !== null)
|
|
447
|
+
i++;
|
|
448
|
+
}
|
|
449
|
+
p = {
|
|
450
|
+
old,
|
|
451
|
+
changed: new Map,
|
|
452
|
+
ops: [],
|
|
453
|
+
props: new Map,
|
|
454
|
+
appearing: null,
|
|
455
|
+
start: false,
|
|
456
|
+
measured: new Map,
|
|
457
|
+
updated: new Set,
|
|
458
|
+
resized: new Set,
|
|
459
|
+
named: [],
|
|
460
|
+
events: [],
|
|
461
|
+
roots: [...roots],
|
|
462
|
+
canceled: false,
|
|
463
|
+
types: null,
|
|
464
|
+
doc: [...roots].map((r) => r.f.d.nodeType === 9 ? r.f.d : r.f.d.ownerDocument)[0]
|
|
465
|
+
};
|
|
466
|
+
for (const r of roots)
|
|
467
|
+
if (anyVT(r.f))
|
|
468
|
+
any = true;
|
|
469
|
+
if (!any)
|
|
470
|
+
return null;
|
|
471
|
+
for (const r of roots) {
|
|
472
|
+
appear(r.f, false);
|
|
473
|
+
visit(r.f);
|
|
474
|
+
}
|
|
475
|
+
const byNode = new Map;
|
|
476
|
+
for (const f of old.keys())
|
|
477
|
+
if (f.f & BOX)
|
|
478
|
+
byNode.set(f.d, f);
|
|
479
|
+
const placing = (f) => {
|
|
480
|
+
if (f.f & BOX)
|
|
481
|
+
byNode.set(f.d, f);
|
|
482
|
+
for (const c of kids(f))
|
|
483
|
+
placing(c);
|
|
484
|
+
};
|
|
485
|
+
for (const r of roots)
|
|
486
|
+
placing(r.f);
|
|
487
|
+
const fiberOf = (n) => {
|
|
488
|
+
while (n != null && !byNode.has(n))
|
|
489
|
+
n = n.parentNode;
|
|
490
|
+
return n == null ? null : byNode.get(n);
|
|
491
|
+
};
|
|
492
|
+
for (const rec of records) {
|
|
493
|
+
const nodes = rec.type === "childList" ? [...rec.addedNodes, ...rec.removedNodes] : [rec.target];
|
|
494
|
+
for (const n of nodes) {
|
|
495
|
+
let fiber = fiberOf(n);
|
|
496
|
+
if (fiber === null && rec.type === "childList")
|
|
497
|
+
fiber = fiberOf(rec.target);
|
|
498
|
+
for (;fiber !== null; fiber = fiber.r)
|
|
499
|
+
if (isVT(fiber)) {
|
|
500
|
+
if (old.has(fiber))
|
|
501
|
+
p.updated.add(fiber);
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return p;
|
|
507
|
+
},
|
|
508
|
+
before(plan, t) {
|
|
509
|
+
p = plan;
|
|
510
|
+
types = plan.types = t;
|
|
511
|
+
for (let i = 0;i < p.ops.length; i += 2) {
|
|
512
|
+
const f = p.ops[i + 1];
|
|
513
|
+
switch (p.ops[i]) {
|
|
514
|
+
case 0:
|
|
515
|
+
case 1:
|
|
516
|
+
exit(f);
|
|
517
|
+
break;
|
|
518
|
+
case 2:
|
|
519
|
+
nested(f);
|
|
520
|
+
break;
|
|
521
|
+
default: {
|
|
522
|
+
const props = p.props.get(f), cls = classOf(props.default, props.update), m = [];
|
|
523
|
+
p.measured.set(f, m);
|
|
524
|
+
if (cls !== "none")
|
|
525
|
+
applyHosts(f, nameOf(f, f.p), cls, m, true);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
p.appearing = null;
|
|
530
|
+
return p.start;
|
|
531
|
+
},
|
|
532
|
+
after(plan) {
|
|
533
|
+
p = plan;
|
|
534
|
+
types = plan.types;
|
|
535
|
+
const n = p.named;
|
|
536
|
+
for (let i = 0;i < n.length; i += 5)
|
|
537
|
+
if (n[i].style.viewTransitionName === "")
|
|
538
|
+
setName(n[i], n[i + 3], n[i + 4]);
|
|
539
|
+
for (const r of p.roots) {
|
|
540
|
+
contextChanged = false;
|
|
541
|
+
cancelable = null;
|
|
542
|
+
traverse(r.f);
|
|
543
|
+
if (!contextChanged) {
|
|
544
|
+
const c = cancelable;
|
|
545
|
+
const doc = r.f.d.nodeType === 9 ? r.f.d.documentElement : r.f.d.ownerDocument.documentElement;
|
|
546
|
+
if (c !== null)
|
|
547
|
+
for (let i = 0;i < c.length; i += 3) {
|
|
548
|
+
restoreName(c[i], c[i + 2]);
|
|
549
|
+
doc.animate({ opacity: [0, 0], pointerEvents: ["none", "none"] }, { duration: 0, fill: "forwards", pseudoElement: "::view-transition-group(" + c[i + 1] + ")" });
|
|
550
|
+
}
|
|
551
|
+
if (doc.style.viewTransitionName === "") {
|
|
552
|
+
doc.style.viewTransitionName = "none";
|
|
553
|
+
doc.animate({ opacity: [0, 0], pointerEvents: ["none", "none"] }, { duration: 0, fill: "forwards", pseudoElement: "::view-transition-group(root)" });
|
|
554
|
+
doc.animate({ width: [0, 0], height: [0, 0] }, { duration: 0, fill: "forwards", pseudoElement: "::view-transition" });
|
|
555
|
+
}
|
|
556
|
+
p.canceled = true;
|
|
557
|
+
}
|
|
558
|
+
cancelable = null;
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
ready(plan, finished) {
|
|
562
|
+
for (let i = 0;i < plan.events.length; i += 2) {
|
|
563
|
+
const cleanup = plan.events[i](plan.events[i + 1], plan.types ?? []);
|
|
564
|
+
if (cleanup !== undefined)
|
|
565
|
+
finished.finally(cleanup);
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
done(plan) {
|
|
569
|
+
const n = plan.named;
|
|
570
|
+
for (let i = 0;i < n.length; i += 5)
|
|
571
|
+
if (!(n[i + 1].f & DEAD))
|
|
572
|
+
restoreName(n[i], n[i + 2]);
|
|
573
|
+
if (plan.canceled)
|
|
574
|
+
for (const r of plan.roots) {
|
|
575
|
+
const c = r.f.d, body = c.nodeType === 9 ? c.body : c.nodeName === "HTML" ? c.ownerDocument.body : c;
|
|
576
|
+
if (body.style.viewTransitionName === "root")
|
|
577
|
+
body.style.viewTransitionName = "";
|
|
578
|
+
const doc = body.ownerDocument.documentElement;
|
|
579
|
+
if (doc !== null && doc.style.viewTransitionName === "none")
|
|
580
|
+
doc.style.viewTransitionName = "";
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
__installViewTransitions2(viewTransitions);
|