@react-motion-router/core 2.0.0-beta.eb7bb7e → 2.0.0-beta.sha-dfc284b
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/build/MetaData.d.ts +19 -0
- package/build/MotionContext.d.ts +1 -0
- package/build/NavigationBase.d.ts +21 -0
- package/build/RoutePropContext.d.ts +2 -0
- package/build/RouterBase.d.ts +59 -0
- package/build/RouterContext.d.ts +22 -0
- package/build/ScreenBase.d.ts +105 -0
- package/build/ScreenTransitionLayer.d.ts +32 -0
- package/build/ScreenTransitionLayerContext.d.ts +2 -0
- package/build/ScreenTransitionProvider.d.ts +31 -0
- package/build/SharedElement.d.ts +36 -0
- package/build/SharedElementScene.d.ts +17 -0
- package/build/SharedElementSceneContext.d.ts +2 -0
- package/build/SharedElementTransitionLayer.d.ts +29 -0
- package/build/common/constants.d.ts +5 -0
- package/build/common/events.d.ts +38 -0
- package/build/common/hooks.d.ts +7 -0
- package/build/common/types.d.ts +82 -0
- package/build/common/utils.d.ts +14 -0
- package/build/common/utils.js +168 -0
- package/build/common/utils.js.map +1 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +1448 -0
- package/build/index.js.map +1 -0
- package/package.json +2 -2
package/build/index.js
ADDED
|
@@ -0,0 +1,1448 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_web_animations_extension_74b2916c__ from "web-animations-extension";
|
|
3
|
+
/******/ var __webpack_modules__ = ({
|
|
4
|
+
|
|
5
|
+
/***/ 837:
|
|
6
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license React
|
|
10
|
+
* react-jsx-runtime.production.min.js
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/
|
|
17
|
+
var f=__webpack_require__(810),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
|
|
18
|
+
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/***/ }),
|
|
22
|
+
|
|
23
|
+
/***/ 322:
|
|
24
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if (true) {
|
|
29
|
+
module.exports = __webpack_require__(837);
|
|
30
|
+
} else {}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/***/ }),
|
|
34
|
+
|
|
35
|
+
/***/ 174:
|
|
36
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
37
|
+
|
|
38
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
39
|
+
/* harmony export */ "DM": () => (/* binding */ PromiseAllDynamic),
|
|
40
|
+
/* harmony export */ "Ky": () => (/* binding */ isURLPatternSupported),
|
|
41
|
+
/* harmony export */ "Nu": () => (/* binding */ dispatchEvent),
|
|
42
|
+
/* harmony export */ "QN": () => (/* binding */ matchRoute),
|
|
43
|
+
/* harmony export */ "Sy": () => (/* binding */ polyfillNavigation),
|
|
44
|
+
/* harmony export */ "Vo": () => (/* binding */ lazy),
|
|
45
|
+
/* harmony export */ "e1": () => (/* binding */ includesRoute),
|
|
46
|
+
/* harmony export */ "gy": () => (/* binding */ polyfillURLPattern),
|
|
47
|
+
/* harmony export */ "n4": () => (/* binding */ resolveBaseURLFromPattern),
|
|
48
|
+
/* harmony export */ "vi": () => (/* binding */ isNavigationSupported),
|
|
49
|
+
/* harmony export */ "zW": () => (/* binding */ toCamelCase)
|
|
50
|
+
/* harmony export */ });
|
|
51
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(810);
|
|
52
|
+
|
|
53
|
+
function resolveBaseURLFromPattern(pattern, pathname) {
|
|
54
|
+
if (!pattern.endsWith("**"))
|
|
55
|
+
pattern += '**'; // allows us to match nested routes
|
|
56
|
+
const origin = window.location.origin;
|
|
57
|
+
const baseURLMatch = new URLPattern(pattern, origin).exec(pathname, origin);
|
|
58
|
+
if (!baseURLMatch)
|
|
59
|
+
return null;
|
|
60
|
+
const nestedPathnameGroup = baseURLMatch.pathname.groups[1] ?? '';
|
|
61
|
+
// derive concrete baseURL
|
|
62
|
+
return new URL(pathname.replace(nestedPathnameGroup, ''), window.location.origin);
|
|
63
|
+
}
|
|
64
|
+
function matchRoute(pathnamePattern, pathname, baseURLPattern = `${window.location.origin}/`, caseSensitive = true) {
|
|
65
|
+
if (!caseSensitive) {
|
|
66
|
+
pathnamePattern = pathnamePattern.toLowerCase();
|
|
67
|
+
pathname = pathname.toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
const baseURL = resolveBaseURLFromPattern(baseURLPattern, pathname)?.href;
|
|
70
|
+
if (!baseURL)
|
|
71
|
+
return null;
|
|
72
|
+
const match = new URLPattern({ baseURL, pathname: pathnamePattern }).exec({ pathname, baseURL });
|
|
73
|
+
const params = match?.pathname.groups ?? {};
|
|
74
|
+
if (match) {
|
|
75
|
+
return {
|
|
76
|
+
params
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function includesRoute(pathnamePatterns, pathname, baseURL = window.location.origin) {
|
|
82
|
+
return pathnamePatterns.some(({ pattern, caseSensitive }) => matchRoute(pattern, pathname, baseURL, caseSensitive));
|
|
83
|
+
}
|
|
84
|
+
function dispatchEvent(event, target = window) {
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
queueMicrotask(() => resolve(target.dispatchEvent(event)));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function lazy(factory) {
|
|
90
|
+
const Component = (0,react__WEBPACK_IMPORTED_MODULE_0__.lazy)(factory);
|
|
91
|
+
Component.load = async () => {
|
|
92
|
+
Component.module ??= await factory();
|
|
93
|
+
return Component.module;
|
|
94
|
+
};
|
|
95
|
+
return Component;
|
|
96
|
+
}
|
|
97
|
+
function isNavigationSupported() {
|
|
98
|
+
return Boolean(window.navigation);
|
|
99
|
+
}
|
|
100
|
+
function isURLPatternSupported() {
|
|
101
|
+
// @ts-ignore: Property 'UrlPattern' does not exist
|
|
102
|
+
return Boolean(globalThis.URLPattern);
|
|
103
|
+
}
|
|
104
|
+
async function polyfillURLPattern() {
|
|
105
|
+
const { URLPattern } = await import(/*webpackIgnore: true*/ "urlpattern-polyfill");
|
|
106
|
+
// @ts-ignore: Property 'UrlPattern' does not exist
|
|
107
|
+
globalThis.URLPattern = URLPattern;
|
|
108
|
+
}
|
|
109
|
+
async function polyfillNavigation() {
|
|
110
|
+
const { applyPolyfill } = await import(/*webpackIgnore: true*/ "@virtualstate/navigation");
|
|
111
|
+
applyPolyfill({
|
|
112
|
+
history: true,
|
|
113
|
+
interceptEvents: true,
|
|
114
|
+
patch: true,
|
|
115
|
+
persist: true,
|
|
116
|
+
persistState: true
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async function PromiseAllDynamic(values) {
|
|
120
|
+
const awaited = [];
|
|
121
|
+
for (const value of values) {
|
|
122
|
+
awaited.push(await value);
|
|
123
|
+
}
|
|
124
|
+
return awaited;
|
|
125
|
+
}
|
|
126
|
+
function toCamelCase(value) {
|
|
127
|
+
return value.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
/***/ }),
|
|
132
|
+
|
|
133
|
+
/***/ 810:
|
|
134
|
+
/***/ ((module) => {
|
|
135
|
+
|
|
136
|
+
var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
137
|
+
var y = x => () => x
|
|
138
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
139
|
+
|
|
140
|
+
/***/ })
|
|
141
|
+
|
|
142
|
+
/******/ });
|
|
143
|
+
/************************************************************************/
|
|
144
|
+
/******/ // The module cache
|
|
145
|
+
/******/ var __webpack_module_cache__ = {};
|
|
146
|
+
/******/
|
|
147
|
+
/******/ // The require function
|
|
148
|
+
/******/ function __webpack_require__(moduleId) {
|
|
149
|
+
/******/ // Check if module is in cache
|
|
150
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
151
|
+
/******/ if (cachedModule !== undefined) {
|
|
152
|
+
/******/ return cachedModule.exports;
|
|
153
|
+
/******/ }
|
|
154
|
+
/******/ // Create a new module (and put it into the cache)
|
|
155
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
156
|
+
/******/ // no module.id needed
|
|
157
|
+
/******/ // no module.loaded needed
|
|
158
|
+
/******/ exports: {}
|
|
159
|
+
/******/ };
|
|
160
|
+
/******/
|
|
161
|
+
/******/ // Execute the module function
|
|
162
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
163
|
+
/******/
|
|
164
|
+
/******/ // Return the exports of the module
|
|
165
|
+
/******/ return module.exports;
|
|
166
|
+
/******/ }
|
|
167
|
+
/******/
|
|
168
|
+
/************************************************************************/
|
|
169
|
+
/******/ /* webpack/runtime/define property getters */
|
|
170
|
+
/******/ (() => {
|
|
171
|
+
/******/ // define getter functions for harmony exports
|
|
172
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
173
|
+
/******/ for(var key in definition) {
|
|
174
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
175
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
176
|
+
/******/ }
|
|
177
|
+
/******/ }
|
|
178
|
+
/******/ };
|
|
179
|
+
/******/ })();
|
|
180
|
+
/******/
|
|
181
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
182
|
+
/******/ (() => {
|
|
183
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
184
|
+
/******/ })();
|
|
185
|
+
/******/
|
|
186
|
+
/************************************************************************/
|
|
187
|
+
var __webpack_exports__ = {};
|
|
188
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
189
|
+
(() => {
|
|
190
|
+
|
|
191
|
+
// EXPORTS
|
|
192
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
193
|
+
"Tc": () => (/* reexport */ LoadEvent),
|
|
194
|
+
"YU": () => (/* reexport */ MAX_NORM_PROGRESS),
|
|
195
|
+
"SR": () => (/* reexport */ MAX_PROGRESS),
|
|
196
|
+
"dw": () => (/* reexport */ MAX_Z_INDEX),
|
|
197
|
+
"Uy": () => (/* reexport */ MIN_NORM_PROGRESS),
|
|
198
|
+
"yn": () => (/* reexport */ MIN_PROGRESS),
|
|
199
|
+
"vw": () => (/* reexport */ MotionContext),
|
|
200
|
+
"FC": () => (/* reexport */ MotionProgressEndEvent),
|
|
201
|
+
"yx": () => (/* reexport */ MotionProgressEvent),
|
|
202
|
+
"z4": () => (/* reexport */ MotionProgressStartEvent),
|
|
203
|
+
"DC": () => (/* reexport */ NavigationBase),
|
|
204
|
+
"Fh": () => (/* reexport */ NestedRouterContext),
|
|
205
|
+
"DM": () => (/* reexport */ utils/* PromiseAllDynamic */.DM),
|
|
206
|
+
"GW": () => (/* reexport */ RouterBase),
|
|
207
|
+
"_q": () => (/* reexport */ RouterContext),
|
|
208
|
+
"RG": () => (/* reexport */ ScreenBase),
|
|
209
|
+
"rJ": () => (/* reexport */ SharedElement),
|
|
210
|
+
"XP": () => (/* reexport */ TransitionCancelEvent),
|
|
211
|
+
"d7": () => (/* reexport */ TransitionEndEvent),
|
|
212
|
+
"sy": () => (/* reexport */ TransitionStartEvent),
|
|
213
|
+
"Nu": () => (/* reexport */ utils/* dispatchEvent */.Nu),
|
|
214
|
+
"e1": () => (/* reexport */ utils/* includesRoute */.e1),
|
|
215
|
+
"Qv": () => (/* reexport */ isLazyExoticComponent),
|
|
216
|
+
"R1": () => (/* reexport */ isNativeLazyExoticComponent),
|
|
217
|
+
"vi": () => (/* reexport */ utils/* isNavigationSupported */.vi),
|
|
218
|
+
"R_": () => (/* reexport */ isStylableElement),
|
|
219
|
+
"Ky": () => (/* reexport */ utils/* isURLPatternSupported */.Ky),
|
|
220
|
+
"$r": () => (/* reexport */ isValidScreenChild),
|
|
221
|
+
"Vo": () => (/* reexport */ utils/* lazy */.Vo),
|
|
222
|
+
"QN": () => (/* reexport */ utils/* matchRoute */.QN),
|
|
223
|
+
"Sy": () => (/* reexport */ utils/* polyfillNavigation */.Sy),
|
|
224
|
+
"gy": () => (/* reexport */ utils/* polyfillURLPattern */.gy),
|
|
225
|
+
"n4": () => (/* reexport */ utils/* resolveBaseURLFromPattern */.n4),
|
|
226
|
+
"zW": () => (/* reexport */ utils/* toCamelCase */.zW),
|
|
227
|
+
"nc": () => (/* reexport */ useMotion),
|
|
228
|
+
"ev": () => (/* reexport */ useNavigationBase),
|
|
229
|
+
"qr": () => (/* reexport */ useRouteBase),
|
|
230
|
+
"yL": () => (/* reexport */ useRouterBase)
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// EXTERNAL MODULE: ../../node_modules/react/jsx-runtime.js
|
|
234
|
+
var jsx_runtime = __webpack_require__(322);
|
|
235
|
+
// EXTERNAL MODULE: external "react"
|
|
236
|
+
var external_react_ = __webpack_require__(810);
|
|
237
|
+
;// CONCATENATED MODULE: ./src/SharedElementSceneContext.ts
|
|
238
|
+
|
|
239
|
+
const SharedElementSceneContext = (0,external_react_.createContext)(null);
|
|
240
|
+
|
|
241
|
+
;// CONCATENATED MODULE: ./src/SharedElement.tsx
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
class SharedElement extends external_react_.Component {
|
|
246
|
+
ref = (0,external_react_.createRef)();
|
|
247
|
+
static contextType = SharedElementSceneContext;
|
|
248
|
+
componentDidMount() {
|
|
249
|
+
this.scene.addNode(this);
|
|
250
|
+
}
|
|
251
|
+
componentDidUpdate(prevProps) {
|
|
252
|
+
if (this.props.id !== prevProps.id) {
|
|
253
|
+
this.scene.removeNode(prevProps.id.toString());
|
|
254
|
+
this.scene.addNode(this);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
componentWillUnmount() {
|
|
258
|
+
this.scene.removeNode(this.id);
|
|
259
|
+
}
|
|
260
|
+
get styles() {
|
|
261
|
+
if (this.props.config?.styles) {
|
|
262
|
+
return this.props.config.styles;
|
|
263
|
+
}
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
get canTransition() {
|
|
267
|
+
return !this.props.disabled
|
|
268
|
+
&& this.scene.canTransition;
|
|
269
|
+
}
|
|
270
|
+
get scene() {
|
|
271
|
+
return this.context;
|
|
272
|
+
}
|
|
273
|
+
get id() {
|
|
274
|
+
return `shared-element-${this.props.id.toString()}`;
|
|
275
|
+
}
|
|
276
|
+
get transitionType() {
|
|
277
|
+
return this.props.config?.type ?? this.scene.previousScene?.nodes.get(this.id)?.transitionType ?? "morph";
|
|
278
|
+
}
|
|
279
|
+
getBoundingClientRect() {
|
|
280
|
+
return this.ref.current?.firstElementChild?.getBoundingClientRect() ?? new DOMRect();
|
|
281
|
+
}
|
|
282
|
+
clone() {
|
|
283
|
+
if (!this.ref.current)
|
|
284
|
+
return null;
|
|
285
|
+
const deepClone = this.props.config?.deepClone ?? true;
|
|
286
|
+
return this.ref.current.firstElementChild?.cloneNode(deepClone);
|
|
287
|
+
}
|
|
288
|
+
hide() {
|
|
289
|
+
if (!this.ref.current)
|
|
290
|
+
return;
|
|
291
|
+
this.ref.current.style.visibility = 'hidden';
|
|
292
|
+
}
|
|
293
|
+
unhide() {
|
|
294
|
+
if (!this.ref.current)
|
|
295
|
+
return;
|
|
296
|
+
this.ref.current.style.visibility = 'visible';
|
|
297
|
+
}
|
|
298
|
+
render() {
|
|
299
|
+
return ((0,jsx_runtime.jsx)("div", { ref: this.ref, id: this.id, style: { display: "contents" }, children: this.props.children }));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// EXTERNAL MODULE: ./src/common/utils.ts
|
|
304
|
+
var utils = __webpack_require__(174);
|
|
305
|
+
;// CONCATENATED MODULE: ./src/common/events.ts
|
|
306
|
+
|
|
307
|
+
class TransitionStartEvent extends Event {
|
|
308
|
+
constructor() {
|
|
309
|
+
super('transition-start');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
class TransitionCancelEvent extends Event {
|
|
313
|
+
constructor() {
|
|
314
|
+
super('transition-cancel');
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
class TransitionEndEvent extends Event {
|
|
318
|
+
constructor() {
|
|
319
|
+
super('transition-end');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
class MotionProgressStartEvent extends Event {
|
|
323
|
+
constructor() {
|
|
324
|
+
super('motion-progress-start');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
class MotionProgressEvent extends Event {
|
|
328
|
+
progress;
|
|
329
|
+
constructor(progress) {
|
|
330
|
+
super('motion-progress');
|
|
331
|
+
this.progress = progress;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
class MotionProgressEndEvent extends Event {
|
|
335
|
+
constructor() {
|
|
336
|
+
super('motion-progress-end');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
class LoadEvent extends Event {
|
|
340
|
+
#navigationType = "load";
|
|
341
|
+
#userInitiated = false;
|
|
342
|
+
#canIntercept = true;
|
|
343
|
+
#hashChange = false;
|
|
344
|
+
#formData = null;
|
|
345
|
+
#downloadRequest = null;
|
|
346
|
+
#destination;
|
|
347
|
+
#signal;
|
|
348
|
+
#abortable = new AbortController();
|
|
349
|
+
#intercepted = false;
|
|
350
|
+
#thenables = [];
|
|
351
|
+
#transition = null;
|
|
352
|
+
constructor() {
|
|
353
|
+
super('navigate', { cancelable: false, bubbles: false, composed: false });
|
|
354
|
+
const currentEntry = window.navigation.currentEntry;
|
|
355
|
+
if (!currentEntry)
|
|
356
|
+
throw new Error("Current entry is null");
|
|
357
|
+
this.#destination = {
|
|
358
|
+
getState() {
|
|
359
|
+
return currentEntry.getState();
|
|
360
|
+
},
|
|
361
|
+
url: currentEntry.url ?? new URL(window.location.href).href,
|
|
362
|
+
key: currentEntry.key,
|
|
363
|
+
index: currentEntry.index,
|
|
364
|
+
id: currentEntry.id,
|
|
365
|
+
sameDocument: true
|
|
366
|
+
};
|
|
367
|
+
this.#signal = this.#abortable.signal;
|
|
368
|
+
window.navigation.addEventListener('navigate', this.#onNavigate, { signal: this.#signal });
|
|
369
|
+
}
|
|
370
|
+
#onNavigate = (e) => {
|
|
371
|
+
if (e !== this) {
|
|
372
|
+
this.#abortable.abort();
|
|
373
|
+
}
|
|
374
|
+
else if (!this.#thenables.length) {
|
|
375
|
+
window.navigation.removeEventListener('navigate', this.#onNavigate);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
intercept(options) {
|
|
379
|
+
if (this.#intercepted)
|
|
380
|
+
throw new DOMException("Failed to execute 'intercept' on 'NavigateEvent': intercept() may only be called while the navigate event is being dispatched.");
|
|
381
|
+
let finish = null;
|
|
382
|
+
this.#transition = {
|
|
383
|
+
finished: new Promise((resolve) => finish = resolve),
|
|
384
|
+
from: window.navigation.currentEntry,
|
|
385
|
+
navigationType: "load"
|
|
386
|
+
};
|
|
387
|
+
const thenable = options?.handler?.();
|
|
388
|
+
if (thenable)
|
|
389
|
+
this.#thenables.push(thenable);
|
|
390
|
+
if (this.#thenables.length === 1) {
|
|
391
|
+
this.#transition.finished = (0,utils/* PromiseAllDynamic */.DM)(this.#thenables).then(() => {
|
|
392
|
+
this.#intercepted = true;
|
|
393
|
+
window.removeEventListener('navigate', this.#onNavigate);
|
|
394
|
+
finish?.();
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
scroll() {
|
|
399
|
+
throw new Error("Method not implemented.");
|
|
400
|
+
}
|
|
401
|
+
get transition() {
|
|
402
|
+
return this.#transition;
|
|
403
|
+
}
|
|
404
|
+
get navigationType() {
|
|
405
|
+
return this.#navigationType;
|
|
406
|
+
}
|
|
407
|
+
get userInitiated() {
|
|
408
|
+
return this.#userInitiated;
|
|
409
|
+
}
|
|
410
|
+
get canIntercept() {
|
|
411
|
+
return this.#canIntercept;
|
|
412
|
+
}
|
|
413
|
+
get hashChange() {
|
|
414
|
+
return this.#hashChange;
|
|
415
|
+
}
|
|
416
|
+
get formData() {
|
|
417
|
+
return this.#formData;
|
|
418
|
+
}
|
|
419
|
+
get downloadRequest() {
|
|
420
|
+
return this.#downloadRequest;
|
|
421
|
+
}
|
|
422
|
+
get destination() {
|
|
423
|
+
return this.#destination;
|
|
424
|
+
}
|
|
425
|
+
get signal() {
|
|
426
|
+
return this.#signal;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
;// CONCATENATED MODULE: ./src/ScreenTransitionLayerContext.tsx
|
|
431
|
+
|
|
432
|
+
const ScreenTransitionLayerContext = (0,external_react_.createContext)(null);
|
|
433
|
+
|
|
434
|
+
;// CONCATENATED MODULE: ./src/ScreenTransitionProvider.tsx
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
class ScreenTransitionProvider extends external_react_.Component {
|
|
439
|
+
ref = (0,external_react_.createRef)();
|
|
440
|
+
static contextType = ScreenTransitionLayerContext;
|
|
441
|
+
index = 0;
|
|
442
|
+
exiting = false;
|
|
443
|
+
state = {
|
|
444
|
+
zIndex: 'unset',
|
|
445
|
+
};
|
|
446
|
+
onAnimationEnd = () => {
|
|
447
|
+
if (this.ref.current) {
|
|
448
|
+
this.ref.current.style.willChange = 'auto';
|
|
449
|
+
this.ref.current.style.pointerEvents = 'auto';
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
onAnimationStart = () => {
|
|
453
|
+
if (this.ref.current) {
|
|
454
|
+
this.ref.current.style.willChange = 'transform, opacity';
|
|
455
|
+
this.ref.current.style.pointerEvents = 'none';
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
componentDidMount() {
|
|
459
|
+
this.props.navigation.addEventListener('transition-start', this.onAnimationStart);
|
|
460
|
+
this.props.navigation.addEventListener('transition-end', this.onAnimationEnd);
|
|
461
|
+
this.props.navigation.addEventListener('transition-cancel', this.onAnimationEnd);
|
|
462
|
+
}
|
|
463
|
+
componentWillUnmount() {
|
|
464
|
+
this.props.navigation.removeEventListener('transition-start', this.onAnimationStart);
|
|
465
|
+
this.props.navigation.removeEventListener('transition-end', this.onAnimationEnd);
|
|
466
|
+
this.props.navigation.removeEventListener('transition-cancel', this.onAnimationEnd);
|
|
467
|
+
}
|
|
468
|
+
get animationEffect() {
|
|
469
|
+
const animationEffectFactory = this.props.animation;
|
|
470
|
+
const { animation, direction } = this.context;
|
|
471
|
+
const { timeline, playbackRate } = animation;
|
|
472
|
+
const { index, exiting, ref } = this;
|
|
473
|
+
return animationEffectFactory?.({
|
|
474
|
+
ref: ref.current,
|
|
475
|
+
index,
|
|
476
|
+
exiting,
|
|
477
|
+
timeline,
|
|
478
|
+
direction,
|
|
479
|
+
playbackRate
|
|
480
|
+
}) ?? null;
|
|
481
|
+
}
|
|
482
|
+
setZIndex(zIndex) {
|
|
483
|
+
return new Promise(resolve => this.setState({ zIndex }, resolve));
|
|
484
|
+
}
|
|
485
|
+
render() {
|
|
486
|
+
const Element = this.props.renderAs;
|
|
487
|
+
const inert = !this.props.focused ? '' : undefined;
|
|
488
|
+
return ((0,jsx_runtime.jsx)(Element, { id: this.props.id, className: "screen-transition-provider", ref: this.ref, inert, style: {
|
|
489
|
+
gridArea: '1 / 1',
|
|
490
|
+
width: '100%',
|
|
491
|
+
height: '100%',
|
|
492
|
+
transformOrigin: 'center center',
|
|
493
|
+
zIndex: this.state.zIndex
|
|
494
|
+
}, children: this.props.children }));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
;// CONCATENATED MODULE: ./src/RouterContext.ts
|
|
499
|
+
|
|
500
|
+
const NestedRouterContext = (0,external_react_.createContext)(null);
|
|
501
|
+
const RouterContext = (0,external_react_.createContext)(null);
|
|
502
|
+
|
|
503
|
+
;// CONCATENATED MODULE: ./src/RoutePropContext.ts
|
|
504
|
+
|
|
505
|
+
const RoutePropContext = (0,external_react_.createContext)(null);
|
|
506
|
+
|
|
507
|
+
;// CONCATENATED MODULE: ./src/SharedElementScene.ts
|
|
508
|
+
class SharedElementScene {
|
|
509
|
+
id;
|
|
510
|
+
nodes = new Map();
|
|
511
|
+
getScreenRect = () => new DOMRect();
|
|
512
|
+
keepAlive = false;
|
|
513
|
+
previousScene = null;
|
|
514
|
+
canTransition = true; // should be false if page animation already started
|
|
515
|
+
constructor(id) {
|
|
516
|
+
this.id = id;
|
|
517
|
+
}
|
|
518
|
+
addNode(node) {
|
|
519
|
+
if (!node)
|
|
520
|
+
return;
|
|
521
|
+
console.assert(!this.nodes.has(node.id), `Duplicate Shared Element ID: ${node.id} in ${this.id}`);
|
|
522
|
+
this.nodes.set(node.id, node);
|
|
523
|
+
}
|
|
524
|
+
removeNode(_id) {
|
|
525
|
+
this.nodes.delete(_id);
|
|
526
|
+
}
|
|
527
|
+
get xRatio() {
|
|
528
|
+
const screenRect = this.getScreenRect();
|
|
529
|
+
const xRatio = (screenRect.width / window.innerWidth).toFixed(2);
|
|
530
|
+
return parseFloat(xRatio);
|
|
531
|
+
}
|
|
532
|
+
get yRatio() {
|
|
533
|
+
const screenRect = this.getScreenRect();
|
|
534
|
+
const yRatio = (screenRect.height / window.innerHeight).toFixed(2);
|
|
535
|
+
return parseFloat(yRatio);
|
|
536
|
+
}
|
|
537
|
+
get x() {
|
|
538
|
+
return this.getScreenRect().x;
|
|
539
|
+
}
|
|
540
|
+
get y() {
|
|
541
|
+
return this.getScreenRect().y;
|
|
542
|
+
}
|
|
543
|
+
isEmpty() {
|
|
544
|
+
return !Boolean(this.nodes.size);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
;// CONCATENATED MODULE: ./src/ScreenBase.tsx
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
class ScreenBase extends external_react_.Component {
|
|
558
|
+
sharedElementScene;
|
|
559
|
+
#transitionProvider = (0,external_react_.createRef)();
|
|
560
|
+
ref = (0,external_react_.createRef)();
|
|
561
|
+
nestedRouterData;
|
|
562
|
+
static contextType = RouterContext;
|
|
563
|
+
state = {
|
|
564
|
+
focused: false,
|
|
565
|
+
elementType: 'div'
|
|
566
|
+
};
|
|
567
|
+
constructor(props, context) {
|
|
568
|
+
super(props);
|
|
569
|
+
this.sharedElementScene = new SharedElementScene(`${this.id}-shared-element-scene`);
|
|
570
|
+
this.sharedElementScene.getScreenRect = () => this.ref.current?.getBoundingClientRect() || new DOMRect();
|
|
571
|
+
this.nestedRouterData = { parentScreen: this, parentRouter: context };
|
|
572
|
+
}
|
|
573
|
+
setParams(params) {
|
|
574
|
+
params = {
|
|
575
|
+
...this.routeProp.params,
|
|
576
|
+
...params
|
|
577
|
+
};
|
|
578
|
+
const config = this.routeProp.config;
|
|
579
|
+
this.context.screenState.set(this.props.path, { config, params });
|
|
580
|
+
this.forceUpdate();
|
|
581
|
+
}
|
|
582
|
+
setConfig(config) {
|
|
583
|
+
config = {
|
|
584
|
+
...this.routeProp.config,
|
|
585
|
+
...config
|
|
586
|
+
};
|
|
587
|
+
const params = this.routeProp.params;
|
|
588
|
+
this.context.screenState.set(this.props.path, { config, params });
|
|
589
|
+
this.forceUpdate();
|
|
590
|
+
}
|
|
591
|
+
get id() {
|
|
592
|
+
if (this.props.id)
|
|
593
|
+
return this.props.id;
|
|
594
|
+
return this.props.path
|
|
595
|
+
.toLowerCase()
|
|
596
|
+
.replace(/[^\w-]/g, '-') // Remove non-alphanumeric chars
|
|
597
|
+
.replace(/-+/g, '-') // Replace multiple hyphens with a single one
|
|
598
|
+
.replace(/^-|-$/g, ''); // Remove leading and trailing hyphens;
|
|
599
|
+
}
|
|
600
|
+
get focused() {
|
|
601
|
+
return this.state.focused;
|
|
602
|
+
}
|
|
603
|
+
blur() {
|
|
604
|
+
return new Promise(resolve => this.setState({ focused: false }, resolve));
|
|
605
|
+
}
|
|
606
|
+
focus() {
|
|
607
|
+
return new Promise(resolve => this.setState({ focused: true }, resolve));
|
|
608
|
+
}
|
|
609
|
+
async load(signal) {
|
|
610
|
+
let Component = this.props.component;
|
|
611
|
+
let result;
|
|
612
|
+
if ('load' in Component) {
|
|
613
|
+
result = await Component.load();
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
result = { default: Component };
|
|
617
|
+
}
|
|
618
|
+
const navigation = this.context.navigation;
|
|
619
|
+
const route = this.routeProp;
|
|
620
|
+
await this.props.config?.onLoad?.({ navigation, route, signal });
|
|
621
|
+
return result;
|
|
622
|
+
}
|
|
623
|
+
async onExited(signal) {
|
|
624
|
+
await this.routeProp.config.onExited?.({
|
|
625
|
+
route: this.routeProp,
|
|
626
|
+
navigation: this.context.navigation,
|
|
627
|
+
signal
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
async onExit(signal) {
|
|
631
|
+
await this.routeProp.config.onExit?.({
|
|
632
|
+
route: this.routeProp,
|
|
633
|
+
navigation: this.context.navigation,
|
|
634
|
+
signal
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
async onEnter(signal) {
|
|
638
|
+
await this.routeProp.config.onEnter?.({
|
|
639
|
+
route: this.routeProp,
|
|
640
|
+
navigation: this.context.navigation,
|
|
641
|
+
signal
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
async onEntered(signal) {
|
|
645
|
+
await this.routeProp.config.onEntered?.({
|
|
646
|
+
route: this.routeProp,
|
|
647
|
+
navigation: this.context.navigation,
|
|
648
|
+
signal
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
get resolvedPathname() {
|
|
652
|
+
return this.props.resolvedPathname;
|
|
653
|
+
}
|
|
654
|
+
get path() {
|
|
655
|
+
return this.props.path;
|
|
656
|
+
}
|
|
657
|
+
get transitionProvider() {
|
|
658
|
+
return this.#transitionProvider;
|
|
659
|
+
}
|
|
660
|
+
render() {
|
|
661
|
+
const navigation = this.context.navigation;
|
|
662
|
+
const routeProp = this.routeProp;
|
|
663
|
+
const Component = this.props.component;
|
|
664
|
+
const HeaderComponent = routeProp.config.header?.component;
|
|
665
|
+
const FooterComponent = routeProp.config.footer?.component;
|
|
666
|
+
return ((0,jsx_runtime.jsx)(ScreenTransitionProvider, { ref: this.#transitionProvider, renderAs: this.state.elementType, id: `${this.id}-transition-provider`, animation: routeProp.config.animation, navigation: navigation, focused: this.state.focused, children: (0,jsx_runtime.jsx)("div", { id: this.id, ref: this.ref, className: "screen", style: {
|
|
667
|
+
height: '100%',
|
|
668
|
+
width: '100%',
|
|
669
|
+
display: 'flex',
|
|
670
|
+
flexDirection: 'column',
|
|
671
|
+
pointerEvents: 'inherit'
|
|
672
|
+
}, children: (0,jsx_runtime.jsx)(SharedElementSceneContext.Provider, { value: this.sharedElementScene, children: (0,jsx_runtime.jsx)(RoutePropContext.Provider, { value: routeProp, children: (0,jsx_runtime.jsxs)(NestedRouterContext.Provider, { value: this.nestedRouterData, children: [(0,jsx_runtime.jsx)(external_react_.Suspense, { fallback: (0,jsx_runtime.jsx)(ComponentWithRouteProps, { component: routeProp.config.header?.fallback, route: routeProp, navigation: navigation }), children: (0,jsx_runtime.jsx)(ComponentWithRouteProps, { component: HeaderComponent, route: routeProp, navigation: navigation }) }), (0,jsx_runtime.jsx)(external_react_.Suspense, { fallback: (0,jsx_runtime.jsx)(ComponentWithRouteProps, { component: this.props.fallback, route: routeProp, navigation: navigation }), children: (0,jsx_runtime.jsx)(ComponentWithRouteProps, { component: Component, route: routeProp, navigation: navigation }) }), (0,jsx_runtime.jsx)(external_react_.Suspense, { fallback: (0,jsx_runtime.jsx)(ComponentWithRouteProps, { component: routeProp.config.footer?.fallback, route: routeProp, navigation: navigation }), children: (0,jsx_runtime.jsx)(ComponentWithRouteProps, { component: FooterComponent, route: routeProp, navigation: navigation }) })] }) }) }) }) }));
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
function ComponentWithRouteProps({ component, route, navigation }) {
|
|
676
|
+
if (isLazyExoticComponent(component) && component.module?.default) {
|
|
677
|
+
component = component.module.default;
|
|
678
|
+
}
|
|
679
|
+
const Component = component ?? null;
|
|
680
|
+
if ((0,external_react_.isValidElement)(Component)) {
|
|
681
|
+
return (0,external_react_.cloneElement)(Component, {
|
|
682
|
+
navigation,
|
|
683
|
+
route
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
else if (typeof Component === "function" || isNativeLazyExoticComponent(Component)) {
|
|
687
|
+
return ((0,jsx_runtime.jsx)(Component, { navigation: navigation, route: route }));
|
|
688
|
+
}
|
|
689
|
+
return (0,jsx_runtime.jsx)(jsx_runtime.Fragment, { children: Component });
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
;// CONCATENATED MODULE: ./src/common/types.ts
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
function isValidScreenChild(value) {
|
|
696
|
+
if (!(0,external_react_.isValidElement)(value))
|
|
697
|
+
return false;
|
|
698
|
+
return Object.getPrototypeOf(value.type) === ScreenBase;
|
|
699
|
+
}
|
|
700
|
+
var SharedElementTransitionTypeEnum;
|
|
701
|
+
(function (SharedElementTransitionTypeEnum) {
|
|
702
|
+
SharedElementTransitionTypeEnum[SharedElementTransitionTypeEnum["morph"] = 0] = "morph";
|
|
703
|
+
SharedElementTransitionTypeEnum[SharedElementTransitionTypeEnum["fade-through"] = 1] = "fade-through";
|
|
704
|
+
SharedElementTransitionTypeEnum[SharedElementTransitionTypeEnum["fade"] = 2] = "fade";
|
|
705
|
+
SharedElementTransitionTypeEnum[SharedElementTransitionTypeEnum["cross-fade"] = 3] = "cross-fade";
|
|
706
|
+
})(SharedElementTransitionTypeEnum || (SharedElementTransitionTypeEnum = {}));
|
|
707
|
+
function isNativeLazyExoticComponent(value) {
|
|
708
|
+
return typeof value === "object"
|
|
709
|
+
&& value !== null
|
|
710
|
+
&& value.$$typeof === Symbol.for('react.lazy');
|
|
711
|
+
}
|
|
712
|
+
function isLazyExoticComponent(value) {
|
|
713
|
+
return isNativeLazyExoticComponent(value) && 'load' in value;
|
|
714
|
+
}
|
|
715
|
+
function isStylableElement(element) {
|
|
716
|
+
return 'style' in element && element.style instanceof CSSStyleDeclaration;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
;// CONCATENATED MODULE: external "web-animations-extension"
|
|
720
|
+
var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
721
|
+
var y = x => () => x
|
|
722
|
+
const external_web_animations_extension_namespaceObject = x({ ["Animation"]: () => __WEBPACK_EXTERNAL_MODULE_web_animations_extension_74b2916c__.Animation, ["ParallelEffect"]: () => __WEBPACK_EXTERNAL_MODULE_web_animations_extension_74b2916c__.ParallelEffect });
|
|
723
|
+
;// CONCATENATED MODULE: ./src/SharedElementTransitionLayer.tsx
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
class SharedElementTransitionLayer extends external_react_.Component {
|
|
730
|
+
ref = (0,external_react_.createRef)();
|
|
731
|
+
#outgoingScreen = null;
|
|
732
|
+
#incomingScreen = null;
|
|
733
|
+
state = {
|
|
734
|
+
transitioning: false
|
|
735
|
+
};
|
|
736
|
+
set outgoingScreen(outgoingScreen) {
|
|
737
|
+
this.#outgoingScreen = outgoingScreen;
|
|
738
|
+
}
|
|
739
|
+
set incomingScreen(incomingScreen) {
|
|
740
|
+
this.#incomingScreen = incomingScreen;
|
|
741
|
+
}
|
|
742
|
+
get outgoingScreen() {
|
|
743
|
+
return this.#outgoingScreen;
|
|
744
|
+
}
|
|
745
|
+
get incomingScreen() {
|
|
746
|
+
return this.#incomingScreen;
|
|
747
|
+
}
|
|
748
|
+
getKeyframeProperties(element, styleList) {
|
|
749
|
+
const computedStyles = {};
|
|
750
|
+
const computedStyle = window.getComputedStyle(element);
|
|
751
|
+
for (const key of styleList) {
|
|
752
|
+
let transformedKey;
|
|
753
|
+
if (key === "offset")
|
|
754
|
+
transformedKey = "cssOffset";
|
|
755
|
+
else if (key === "float")
|
|
756
|
+
transformedKey = "cssFloat";
|
|
757
|
+
else
|
|
758
|
+
transformedKey = (0,utils/* toCamelCase */.zW)(key);
|
|
759
|
+
computedStyles[transformedKey] = computedStyle.getPropertyValue(key);
|
|
760
|
+
}
|
|
761
|
+
return computedStyles;
|
|
762
|
+
}
|
|
763
|
+
copyStyles(srcElement, cloneElement, styleList) {
|
|
764
|
+
const computedStyles = window.getComputedStyle(srcElement);
|
|
765
|
+
for (const key of styleList) {
|
|
766
|
+
const value = computedStyles.getPropertyValue(key);
|
|
767
|
+
const priority = computedStyles.getPropertyPriority(key);
|
|
768
|
+
cloneElement.style.setProperty(key, value, priority);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
getAnimationEffect(start, end) {
|
|
772
|
+
const keyframeEffects = new Array();
|
|
773
|
+
const startRect = start.instance.getBoundingClientRect();
|
|
774
|
+
const endRect = end.instance.getBoundingClientRect();
|
|
775
|
+
const config = {
|
|
776
|
+
fill: "forwards",
|
|
777
|
+
duration: "auto",
|
|
778
|
+
easing: "ease",
|
|
779
|
+
...start.instance.props.config,
|
|
780
|
+
...end.instance.props.config
|
|
781
|
+
};
|
|
782
|
+
const transitionType = end.instance.transitionType === "fade";
|
|
783
|
+
const startTransform = `translate(${startRect.x}px, ${startRect.y}px)`;
|
|
784
|
+
const endTransform = `translate(${endRect.x}px, ${endRect.y}px)`;
|
|
785
|
+
if (transitionType) {
|
|
786
|
+
keyframeEffects.push(new KeyframeEffect(start.clone, [
|
|
787
|
+
{ transform: startTransform, opacity: 1 },
|
|
788
|
+
{ transform: endTransform, opacity: 0 }
|
|
789
|
+
], config));
|
|
790
|
+
keyframeEffects.push(new KeyframeEffect(end.clone, [
|
|
791
|
+
{ transform: startTransform },
|
|
792
|
+
{ transform: endTransform }
|
|
793
|
+
], config));
|
|
794
|
+
}
|
|
795
|
+
else if (end.instance.transitionType === "fade-through") {
|
|
796
|
+
keyframeEffects.push(new KeyframeEffect(start.clone, [
|
|
797
|
+
{ transform: startTransform, opacity: 1 },
|
|
798
|
+
{ opacity: 0, offset: 0.5 },
|
|
799
|
+
{ transform: endTransform, opacity: 0 }
|
|
800
|
+
], config));
|
|
801
|
+
keyframeEffects.push(new KeyframeEffect(end.clone, [
|
|
802
|
+
{ transform: startTransform, opacity: 0 },
|
|
803
|
+
{ opacity: 0, offset: 0.5 },
|
|
804
|
+
{ transform: endTransform, opacity: 1 }
|
|
805
|
+
], config));
|
|
806
|
+
}
|
|
807
|
+
else if (end.instance.transitionType === "cross-fade") {
|
|
808
|
+
end.clone.style.mixBlendMode = "plus-lighter";
|
|
809
|
+
keyframeEffects.push(new KeyframeEffect(start.clone, [
|
|
810
|
+
{ transform: startTransform, opacity: 1 },
|
|
811
|
+
{ transform: endTransform, opacity: 0 }
|
|
812
|
+
], config));
|
|
813
|
+
keyframeEffects.push(new KeyframeEffect(end.clone, [
|
|
814
|
+
{ transform: startTransform },
|
|
815
|
+
{ transform: endTransform }
|
|
816
|
+
], config));
|
|
817
|
+
}
|
|
818
|
+
else { // morph
|
|
819
|
+
const styleList = Array.from(new Set([...start.instance.styles, ...end.instance.styles]));
|
|
820
|
+
keyframeEffects.push(new KeyframeEffect(end.clone, [
|
|
821
|
+
{
|
|
822
|
+
...Object.fromEntries((start.instance.ref.current?.firstElementChild).attributeStyleMap),
|
|
823
|
+
transform: startTransform,
|
|
824
|
+
width: `${startRect.width}px`,
|
|
825
|
+
height: `${startRect.height}px`,
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
...Object.fromEntries((end.instance.ref.current?.firstElementChild).attributeStyleMap),
|
|
829
|
+
...this.getKeyframeProperties(end.instance.ref.current?.firstElementChild, styleList),
|
|
830
|
+
transform: endTransform,
|
|
831
|
+
width: `${endRect.width}px`,
|
|
832
|
+
height: `${endRect.height}px`,
|
|
833
|
+
}
|
|
834
|
+
], config));
|
|
835
|
+
}
|
|
836
|
+
return new external_web_animations_extension_namespaceObject.ParallelEffect(keyframeEffects);
|
|
837
|
+
}
|
|
838
|
+
get animationEffect() {
|
|
839
|
+
const currentScene = this.outgoingScreen?.current?.sharedElementScene;
|
|
840
|
+
const nextScene = this.incomingScreen?.current?.sharedElementScene;
|
|
841
|
+
if (!currentScene || !nextScene)
|
|
842
|
+
return null;
|
|
843
|
+
if (currentScene === nextScene)
|
|
844
|
+
return null;
|
|
845
|
+
currentScene.previousScene = null;
|
|
846
|
+
nextScene.previousScene = currentScene;
|
|
847
|
+
const parallelEffects = new Array();
|
|
848
|
+
for (const [id, end] of Array.from(nextScene.nodes.entries())) {
|
|
849
|
+
const start = currentScene.nodes.get(id);
|
|
850
|
+
if (start?.canTransition && end.canTransition) {
|
|
851
|
+
const endClone = end.clone();
|
|
852
|
+
const startClone = start.clone();
|
|
853
|
+
if (!startClone)
|
|
854
|
+
continue;
|
|
855
|
+
if (!endClone)
|
|
856
|
+
continue;
|
|
857
|
+
const styleList = Array.from(new Set([...start.styles, ...end.styles, 'width', 'height']));
|
|
858
|
+
if (end.transitionType !== "morph") {
|
|
859
|
+
startClone.id = `${id}-start`;
|
|
860
|
+
startClone.style.position = "absolute";
|
|
861
|
+
if (isStylableElement(start.ref.current?.firstElementChild))
|
|
862
|
+
this.copyStyles(start.ref.current.firstElementChild, startClone, styleList);
|
|
863
|
+
if (isStylableElement(end.ref.current?.firstElementChild))
|
|
864
|
+
this.copyStyles(end.ref.current.firstElementChild, endClone, styleList);
|
|
865
|
+
this.ref.current?.prepend(startClone);
|
|
866
|
+
}
|
|
867
|
+
else if (isStylableElement(start.ref.current?.firstElementChild)) {
|
|
868
|
+
this.copyStyles(start.ref.current.firstElementChild, endClone, styleList);
|
|
869
|
+
}
|
|
870
|
+
endClone.id = `${id}${end.transitionType === "morph" ? '' : '-end'}`;
|
|
871
|
+
endClone.style.position = "absolute";
|
|
872
|
+
this.ref.current?.prepend(endClone);
|
|
873
|
+
start.hide();
|
|
874
|
+
end.hide();
|
|
875
|
+
const onFinish = () => {
|
|
876
|
+
end.unhide();
|
|
877
|
+
endClone.remove();
|
|
878
|
+
startClone.remove();
|
|
879
|
+
};
|
|
880
|
+
this.props.navigation.addEventListener('transition-end', onFinish, { once: true });
|
|
881
|
+
this.props.navigation.addEventListener('transition-cancel', onFinish, { once: true });
|
|
882
|
+
parallelEffects.push(this.getAnimationEffect({ instance: start, clone: startClone }, { instance: end, clone: endClone }));
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return new external_web_animations_extension_namespaceObject.ParallelEffect(parallelEffects);
|
|
886
|
+
}
|
|
887
|
+
render() {
|
|
888
|
+
return ((0,jsx_runtime.jsx)("dialog", { className: "shared-element-layer", ref: this.ref, style: {
|
|
889
|
+
position: 'absolute',
|
|
890
|
+
maxWidth: 'unset',
|
|
891
|
+
maxHeight: 'unset',
|
|
892
|
+
width: '100vw',
|
|
893
|
+
height: '100vh',
|
|
894
|
+
contain: 'strict',
|
|
895
|
+
padding: 0,
|
|
896
|
+
border: 'none',
|
|
897
|
+
backgroundColor: 'transparent',
|
|
898
|
+
isolation: 'isolate'
|
|
899
|
+
}, children: (0,jsx_runtime.jsx)("style", { children: ".shared-element-layer::backdrop {display: none}" }) }));
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
;// CONCATENATED MODULE: ./src/MotionContext.ts
|
|
904
|
+
|
|
905
|
+
const MotionContext = (0,external_react_.createContext)(0);
|
|
906
|
+
|
|
907
|
+
;// CONCATENATED MODULE: ./src/ScreenTransitionLayer.tsx
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
class ScreenTransitionLayer extends external_react_.Component {
|
|
916
|
+
sharedElementTransitionLayer = (0,external_react_.createRef)();
|
|
917
|
+
animation = new external_web_animations_extension_namespaceObject.Animation();
|
|
918
|
+
#direction = "normal";
|
|
919
|
+
#screens = new Array();
|
|
920
|
+
state = {
|
|
921
|
+
gestureNavigating: false,
|
|
922
|
+
progress: 1
|
|
923
|
+
};
|
|
924
|
+
onAnimationFrame() {
|
|
925
|
+
const progress = this.animation.effect?.getComputedTiming().progress;
|
|
926
|
+
if (progress)
|
|
927
|
+
this.onProgress(progress);
|
|
928
|
+
if (this.animation.playState === "running")
|
|
929
|
+
requestAnimationFrame(this.onAnimationFrame.bind(this));
|
|
930
|
+
}
|
|
931
|
+
onTransitionCancel() {
|
|
932
|
+
this.props.navigation.dispatchEvent(new TransitionCancelEvent());
|
|
933
|
+
}
|
|
934
|
+
onTransitionStart() {
|
|
935
|
+
this.props.navigation.dispatchEvent(new TransitionStartEvent());
|
|
936
|
+
this.onAnimationFrame();
|
|
937
|
+
}
|
|
938
|
+
onTransitionEnd() {
|
|
939
|
+
this.props.navigation.dispatchEvent(new TransitionEndEvent());
|
|
940
|
+
}
|
|
941
|
+
onProgress(progress) {
|
|
942
|
+
this.setState({ progress });
|
|
943
|
+
this.props.navigation.dispatchEvent(new MotionProgressEvent(progress));
|
|
944
|
+
}
|
|
945
|
+
get screens() {
|
|
946
|
+
return this.#screens;
|
|
947
|
+
}
|
|
948
|
+
set screens(screens) {
|
|
949
|
+
this.#screens = screens;
|
|
950
|
+
}
|
|
951
|
+
set direction(direction) {
|
|
952
|
+
this.#direction = direction;
|
|
953
|
+
this.animation.effect?.updateTiming({ direction });
|
|
954
|
+
}
|
|
955
|
+
get direction() {
|
|
956
|
+
return this.#direction;
|
|
957
|
+
}
|
|
958
|
+
transition() {
|
|
959
|
+
const effect = new external_web_animations_extension_namespaceObject.ParallelEffect(this.screens.map(screen => {
|
|
960
|
+
return screen.current?.transitionProvider?.current?.animationEffect ?? null;
|
|
961
|
+
}).filter((effect) => effect !== null));
|
|
962
|
+
const sharedElementEffect = this.sharedElementTransitionLayer.current?.animationEffect;
|
|
963
|
+
const duration = effect.getComputedTiming().duration;
|
|
964
|
+
if (sharedElementEffect) {
|
|
965
|
+
sharedElementEffect.updateTiming({
|
|
966
|
+
duration: duration instanceof CSSNumericValue ? duration.to('ms').value : duration
|
|
967
|
+
});
|
|
968
|
+
effect.append(sharedElementEffect);
|
|
969
|
+
this.sharedElementTransitionLayer.current?.ref.current?.showModal();
|
|
970
|
+
}
|
|
971
|
+
this.animation.effect = effect;
|
|
972
|
+
this.animation.play();
|
|
973
|
+
this.onTransitionStart();
|
|
974
|
+
this.animation.oncancel = () => {
|
|
975
|
+
this.sharedElementTransitionLayer.current?.ref.current?.close();
|
|
976
|
+
this.onTransitionCancel();
|
|
977
|
+
this.animation.effect = null;
|
|
978
|
+
};
|
|
979
|
+
this.animation.finished.then(() => {
|
|
980
|
+
this.animation.commitStyles();
|
|
981
|
+
this.onTransitionEnd();
|
|
982
|
+
this.sharedElementTransitionLayer.current?.ref.current?.close();
|
|
983
|
+
this.animation.effect = null;
|
|
984
|
+
});
|
|
985
|
+
return this.animation;
|
|
986
|
+
}
|
|
987
|
+
render() {
|
|
988
|
+
return ((0,jsx_runtime.jsxs)(ScreenTransitionLayerContext.Provider, { value: this, children: [(0,jsx_runtime.jsx)(SharedElementTransitionLayer, { ref: this.sharedElementTransitionLayer, navigation: this.props.navigation }), (0,jsx_runtime.jsx)("div", { className: "screen-transition-layer", style: {
|
|
989
|
+
width: '100%',
|
|
990
|
+
height: '100%',
|
|
991
|
+
display: 'grid',
|
|
992
|
+
'--motion-progress': this.state.progress
|
|
993
|
+
}, children: (0,jsx_runtime.jsx)(MotionContext.Provider, { value: this.state.progress, children: this.props.children }) })] }));
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
;// CONCATENATED MODULE: ./src/RouterBase.tsx
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
class RouterBase extends external_react_.Component {
|
|
1005
|
+
ref = (0,external_react_.createRef)();
|
|
1006
|
+
screenTransitionLayer = (0,external_react_.createRef)();
|
|
1007
|
+
screenState = new Map();
|
|
1008
|
+
parent = null;
|
|
1009
|
+
#child = null;
|
|
1010
|
+
loadDispatched = false;
|
|
1011
|
+
parentScreen = null;
|
|
1012
|
+
static rootRouterRef = null;
|
|
1013
|
+
static contextType = NestedRouterContext;
|
|
1014
|
+
constructor(props, context) {
|
|
1015
|
+
super(props);
|
|
1016
|
+
this.parentScreen = context?.parentScreen ?? null;
|
|
1017
|
+
this.parent = context?.parentRouter ?? null;
|
|
1018
|
+
if (this.parent) {
|
|
1019
|
+
this.parent.child = this;
|
|
1020
|
+
}
|
|
1021
|
+
if (this.isRoot) {
|
|
1022
|
+
RouterBase.rootRouterRef = new WeakRef(this);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
componentDidMount() {
|
|
1026
|
+
if (this.isRoot) {
|
|
1027
|
+
window.navigation.addEventListener('navigate', this.handleNavigationDispatch);
|
|
1028
|
+
}
|
|
1029
|
+
if (!this.loadDispatched) {
|
|
1030
|
+
window.navigation.dispatchEvent(new LoadEvent());
|
|
1031
|
+
this.loadDispatched = true;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
componentWillUnmount() {
|
|
1035
|
+
if (this.isRoot) {
|
|
1036
|
+
window.navigation.removeEventListener('navigate', this.handleNavigationDispatch);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
handleNavigationDispatch = (e) => {
|
|
1040
|
+
if (!this.canIntercept(e))
|
|
1041
|
+
return;
|
|
1042
|
+
let router = this;
|
|
1043
|
+
// travel down router tree to find the correct router
|
|
1044
|
+
while (router.child?.canIntercept(e)) {
|
|
1045
|
+
router = router.child;
|
|
1046
|
+
}
|
|
1047
|
+
router.intercept(e);
|
|
1048
|
+
};
|
|
1049
|
+
getRouterById(routerId, target) {
|
|
1050
|
+
const router = target ?? RouterBase.rootRouterRef?.deref();
|
|
1051
|
+
if (router.id === routerId) {
|
|
1052
|
+
return router ?? null;
|
|
1053
|
+
}
|
|
1054
|
+
else if (router?.child) {
|
|
1055
|
+
return this.getRouterById(routerId, router.child);
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
return null;
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
dispatchEvent(event) {
|
|
1062
|
+
const ref = this.ref.current ?? undefined;
|
|
1063
|
+
return (0,utils/* dispatchEvent */.Nu)(event, ref);
|
|
1064
|
+
}
|
|
1065
|
+
addEventListener(type, listener, options) {
|
|
1066
|
+
return this.ref.current?.addEventListener(type, listener, options);
|
|
1067
|
+
}
|
|
1068
|
+
removeEventListener(type, listener, options) {
|
|
1069
|
+
return this.ref.current?.removeEventListener(type, listener, options);
|
|
1070
|
+
}
|
|
1071
|
+
preloadRoute(pathname) {
|
|
1072
|
+
return new Promise((resolve, reject) => {
|
|
1073
|
+
let found = false;
|
|
1074
|
+
const routes = this.props.children;
|
|
1075
|
+
external_react_.Children.forEach(routes, (route) => {
|
|
1076
|
+
if (found)
|
|
1077
|
+
return; // stop after first
|
|
1078
|
+
if (!(0,external_react_.isValidElement)(route))
|
|
1079
|
+
return;
|
|
1080
|
+
const { path, caseSensitive } = route.props;
|
|
1081
|
+
const baseURLPattern = this.baseURLPattern.pathname;
|
|
1082
|
+
const matchInfo = (0,utils/* matchRoute */.QN)(path, pathname, baseURLPattern, caseSensitive);
|
|
1083
|
+
if (!matchInfo)
|
|
1084
|
+
return;
|
|
1085
|
+
found = true;
|
|
1086
|
+
const config = {
|
|
1087
|
+
...this.screenState.get(path)?.config,
|
|
1088
|
+
...route.props.config
|
|
1089
|
+
};
|
|
1090
|
+
queueMicrotask(async () => {
|
|
1091
|
+
const preloadTasks = [];
|
|
1092
|
+
if ('load' in route.props.component) {
|
|
1093
|
+
preloadTasks.push(route.props.component.load());
|
|
1094
|
+
}
|
|
1095
|
+
if (config?.header?.component && 'load' in config?.header?.component) {
|
|
1096
|
+
preloadTasks.push(config?.header?.component.load());
|
|
1097
|
+
}
|
|
1098
|
+
if (config?.footer?.component && 'load' in config?.footer?.component) {
|
|
1099
|
+
preloadTasks.push(config?.footer?.component.load());
|
|
1100
|
+
}
|
|
1101
|
+
try {
|
|
1102
|
+
await Promise.all(preloadTasks);
|
|
1103
|
+
resolve(found);
|
|
1104
|
+
}
|
|
1105
|
+
catch (e) {
|
|
1106
|
+
reject(e);
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
});
|
|
1110
|
+
if (!found)
|
|
1111
|
+
resolve(false);
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
get id() {
|
|
1115
|
+
if (this.props.id)
|
|
1116
|
+
return this.props.id;
|
|
1117
|
+
const prefix = this.parent ? `${this.parent.id}-` : '';
|
|
1118
|
+
const id = (this.parentScreen?.path ?? 'root')
|
|
1119
|
+
.toLowerCase()
|
|
1120
|
+
.replace(/[^\w-]/g, '-') // Remove non-alphanumeric chars
|
|
1121
|
+
.replace(/-+/g, '-') // Replace multiple hyphens with a single one
|
|
1122
|
+
.replace(/^-|-$/g, ''); // Remove leading and trailing hyphens
|
|
1123
|
+
return `${prefix}${id}`;
|
|
1124
|
+
}
|
|
1125
|
+
get isRoot() {
|
|
1126
|
+
return !this.parent;
|
|
1127
|
+
}
|
|
1128
|
+
get baseURL() {
|
|
1129
|
+
const pathname = this.isRoot ? window.location.pathname : this.parentScreen?.resolvedPathname;
|
|
1130
|
+
const pattern = this.baseURLPattern.pathname;
|
|
1131
|
+
return (0,utils/* resolveBaseURLFromPattern */.n4)(pattern, pathname);
|
|
1132
|
+
}
|
|
1133
|
+
get baseURLPattern() {
|
|
1134
|
+
let baseURL = window.location.origin + "/";
|
|
1135
|
+
const defaultBasePathname = this.isRoot ? new URL(".", document.baseURI).href.replace(baseURL, '') : ".";
|
|
1136
|
+
let basePathname = this.props.config.basePath ?? defaultBasePathname;
|
|
1137
|
+
if (this.parent && this.parentScreen) {
|
|
1138
|
+
const { resolvedPathname = window.location.pathname, path } = this.parentScreen;
|
|
1139
|
+
const parentBaseURL = this.parent.baseURL?.href;
|
|
1140
|
+
const pattern = new URLPattern({ baseURL: parentBaseURL, pathname: path });
|
|
1141
|
+
baseURL = (0,utils/* resolveBaseURLFromPattern */.n4)(pattern.pathname, resolvedPathname).href;
|
|
1142
|
+
}
|
|
1143
|
+
return new URLPattern({ baseURL, pathname: basePathname });
|
|
1144
|
+
}
|
|
1145
|
+
get pathPatterns() {
|
|
1146
|
+
return external_react_.Children.map(this.props.children, (child) => {
|
|
1147
|
+
return { pattern: child.props.path, caseSensitive: Boolean(child.props.caseSensitive) };
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
get mounted() {
|
|
1151
|
+
return Boolean(this.ref.current);
|
|
1152
|
+
}
|
|
1153
|
+
get child() {
|
|
1154
|
+
return this.#child?.deref() ?? null;
|
|
1155
|
+
}
|
|
1156
|
+
set child(child) {
|
|
1157
|
+
const currentChildRouter = this.#child?.deref();
|
|
1158
|
+
if (currentChildRouter
|
|
1159
|
+
&& child?.id !== currentChildRouter?.id
|
|
1160
|
+
&& currentChildRouter?.mounted) {
|
|
1161
|
+
throw new Error("It looks like you have two navigators at the same level. Try simplifying your navigation structure by using a nested router instead.");
|
|
1162
|
+
}
|
|
1163
|
+
if (child)
|
|
1164
|
+
this.#child = new WeakRef(child);
|
|
1165
|
+
else
|
|
1166
|
+
this.#child = null;
|
|
1167
|
+
}
|
|
1168
|
+
render() {
|
|
1169
|
+
if (!this.navigation)
|
|
1170
|
+
return;
|
|
1171
|
+
return ((0,jsx_runtime.jsx)("div", { id: this.id, className: "react-motion-router", style: { width: '100%', height: '100%' }, ref: this.ref, children: (0,jsx_runtime.jsx)(RouterContext.Provider, { value: this, children: (0,jsx_runtime.jsx)(ScreenTransitionLayer, { ref: this.screenTransitionLayer, navigation: this.navigation, children: this.screens }) }) }));
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
;// CONCATENATED MODULE: ./src/MetaData.ts
|
|
1176
|
+
class MetaData {
|
|
1177
|
+
#map = new Map();
|
|
1178
|
+
mutationObserver;
|
|
1179
|
+
constructor() {
|
|
1180
|
+
this.mutationObserver = new MutationObserver(this.observeMutations.bind(this));
|
|
1181
|
+
const { head } = document;
|
|
1182
|
+
this.mutationObserver.observe(head, {
|
|
1183
|
+
childList: true
|
|
1184
|
+
});
|
|
1185
|
+
Array.from(head.querySelectorAll('meta')).forEach(node => {
|
|
1186
|
+
this.mutationObserver.observe(node, {
|
|
1187
|
+
attributes: true
|
|
1188
|
+
});
|
|
1189
|
+
});
|
|
1190
|
+
Array.from(head.querySelectorAll('meta')).forEach(this.metaDataFromNode.bind(this));
|
|
1191
|
+
}
|
|
1192
|
+
get(key) {
|
|
1193
|
+
const metaKey = this.getMetaKey(key);
|
|
1194
|
+
const metaContent = this.#map.get(metaKey);
|
|
1195
|
+
if (!metaContent)
|
|
1196
|
+
return undefined;
|
|
1197
|
+
let content;
|
|
1198
|
+
if (metaContent.includes(',') && metaContent.includes('=')) {
|
|
1199
|
+
content = metaContent.split(/,\s*/).map(keyVal => keyVal.split('='));
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
content = metaContent;
|
|
1203
|
+
}
|
|
1204
|
+
return content;
|
|
1205
|
+
}
|
|
1206
|
+
set(key, content) {
|
|
1207
|
+
const metaKey = this.getMetaKey(key);
|
|
1208
|
+
const metaContent = this.getMetaContent(content);
|
|
1209
|
+
this.#map.set(metaKey, metaContent);
|
|
1210
|
+
this.updateMetaElement(metaKey, metaContent);
|
|
1211
|
+
}
|
|
1212
|
+
has(key) {
|
|
1213
|
+
const metaKey = this.getMetaKey(key);
|
|
1214
|
+
return this.#map.has(metaKey);
|
|
1215
|
+
}
|
|
1216
|
+
delete(key) {
|
|
1217
|
+
const metaKey = this.getMetaKey(key);
|
|
1218
|
+
this.#map.delete(metaKey);
|
|
1219
|
+
document.head.querySelector(`meta[${metaKey}]`)?.remove();
|
|
1220
|
+
}
|
|
1221
|
+
clear() {
|
|
1222
|
+
document.head.querySelectorAll('meta').forEach(node => node.remove());
|
|
1223
|
+
}
|
|
1224
|
+
entries() {
|
|
1225
|
+
return this.#map.entries();
|
|
1226
|
+
}
|
|
1227
|
+
[Symbol.iterator]() {
|
|
1228
|
+
return this.entries();
|
|
1229
|
+
}
|
|
1230
|
+
get size() {
|
|
1231
|
+
return this.#map.size;
|
|
1232
|
+
}
|
|
1233
|
+
observeMutations(mutations) {
|
|
1234
|
+
for (const mutation of mutations) {
|
|
1235
|
+
if (mutation.type === 'attributes') {
|
|
1236
|
+
const node = mutation.target;
|
|
1237
|
+
this.metaDataFromNode(node);
|
|
1238
|
+
}
|
|
1239
|
+
if (mutation.type !== 'childList')
|
|
1240
|
+
return;
|
|
1241
|
+
mutation.removedNodes.forEach((node) => {
|
|
1242
|
+
if (node.nodeName === 'META') {
|
|
1243
|
+
const [type] = Array.from(node.attributes).filter(attribute => attribute.nodeName !== "content");
|
|
1244
|
+
const metaType = [type.nodeName, type.value];
|
|
1245
|
+
const key = metaType.join('=');
|
|
1246
|
+
if (this.#map.has(key)) {
|
|
1247
|
+
this.#map.delete(key);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
mutation.addedNodes.forEach(node => {
|
|
1252
|
+
if (node.nodeName === 'META') {
|
|
1253
|
+
this.metaDataFromNode(node);
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
metaDataFromNode(node) {
|
|
1259
|
+
const [type] = Array.from(node.attributes).filter(attribute => attribute.nodeName !== "content");
|
|
1260
|
+
const [content] = Array.from(node.attributes).filter(attribute => attribute.nodeName === "content");
|
|
1261
|
+
const metaType = [type.nodeName, type.value];
|
|
1262
|
+
const key = metaType.join('=');
|
|
1263
|
+
this.#map.set(key, content?.value);
|
|
1264
|
+
}
|
|
1265
|
+
getMetaKey(key) {
|
|
1266
|
+
let metaKey;
|
|
1267
|
+
if (typeof key === "string") {
|
|
1268
|
+
metaKey = `name=${key}`;
|
|
1269
|
+
}
|
|
1270
|
+
else {
|
|
1271
|
+
metaKey = key.join('=');
|
|
1272
|
+
}
|
|
1273
|
+
return metaKey;
|
|
1274
|
+
}
|
|
1275
|
+
getMetaContent(content) {
|
|
1276
|
+
if (!content)
|
|
1277
|
+
return undefined;
|
|
1278
|
+
let metaContent;
|
|
1279
|
+
if (typeof content === "string") {
|
|
1280
|
+
metaContent = content;
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
metaContent = content.map(contentTuple => contentTuple.join('=')).join(', ');
|
|
1284
|
+
}
|
|
1285
|
+
return metaContent;
|
|
1286
|
+
}
|
|
1287
|
+
updateMetaElement(key, content) {
|
|
1288
|
+
const meta = document.querySelector(`meta[${key}]`) || document.createElement('meta');
|
|
1289
|
+
const metaType = key.split('=');
|
|
1290
|
+
meta.setAttribute(...metaType);
|
|
1291
|
+
if (content)
|
|
1292
|
+
meta.setAttribute('content', content);
|
|
1293
|
+
else
|
|
1294
|
+
meta.removeAttribute('content');
|
|
1295
|
+
if (!meta.parentElement) {
|
|
1296
|
+
document.head.appendChild(meta);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
;// CONCATENATED MODULE: ./src/NavigationBase.ts
|
|
1302
|
+
|
|
1303
|
+
class NavigationBase {
|
|
1304
|
+
router;
|
|
1305
|
+
static rootNavigatorRef = null;
|
|
1306
|
+
metaData = new MetaData();
|
|
1307
|
+
constructor(router) {
|
|
1308
|
+
this.router = router;
|
|
1309
|
+
const rootNavigator = NavigationBase.rootNavigatorRef?.deref();
|
|
1310
|
+
if (!rootNavigator || !rootNavigator.isInDocument)
|
|
1311
|
+
NavigationBase.rootNavigatorRef = new WeakRef(this);
|
|
1312
|
+
}
|
|
1313
|
+
addEventListener(type, listener, options) {
|
|
1314
|
+
this.router.addEventListener(type, listener, options);
|
|
1315
|
+
return () => this.router.removeEventListener(type, listener, options);
|
|
1316
|
+
}
|
|
1317
|
+
removeEventListener(type, listener, options) {
|
|
1318
|
+
return this.router.removeEventListener(type, listener, options);
|
|
1319
|
+
}
|
|
1320
|
+
dispatchEvent(event) {
|
|
1321
|
+
return this.router.dispatchEvent?.(event);
|
|
1322
|
+
}
|
|
1323
|
+
get parent() {
|
|
1324
|
+
return this.router.parent?.navigation ?? null;
|
|
1325
|
+
}
|
|
1326
|
+
get routerId() {
|
|
1327
|
+
return this.router.id;
|
|
1328
|
+
}
|
|
1329
|
+
get baseURL() {
|
|
1330
|
+
return this.router.baseURL;
|
|
1331
|
+
}
|
|
1332
|
+
get baseURLPattern() {
|
|
1333
|
+
return this.router.baseURLPattern;
|
|
1334
|
+
}
|
|
1335
|
+
getNavigatorById(routerId) {
|
|
1336
|
+
return this.router.getRouterById(routerId)?.navigation ?? null;
|
|
1337
|
+
}
|
|
1338
|
+
preloadRoute(path) {
|
|
1339
|
+
const { pathname } = new URL(path, this.baseURL);
|
|
1340
|
+
return this.router.preloadRoute(pathname);
|
|
1341
|
+
}
|
|
1342
|
+
get isInDocument() {
|
|
1343
|
+
return Boolean(document.getElementById(`${this.routerId}`));
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
;// CONCATENATED MODULE: ./src/common/hooks.ts
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
function useNavigationBase() {
|
|
1353
|
+
const router = (0,external_react_.useContext)(RouterContext);
|
|
1354
|
+
if (router) {
|
|
1355
|
+
return router.navigation;
|
|
1356
|
+
}
|
|
1357
|
+
else {
|
|
1358
|
+
throw new Error("Router is null. You may be trying to call useNavigation outside a Router.");
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
function useRouterBase() {
|
|
1362
|
+
return (0,external_react_.useContext)(RouterContext);
|
|
1363
|
+
}
|
|
1364
|
+
function useMotion() {
|
|
1365
|
+
(0,external_react_.useDebugValue)("Motion");
|
|
1366
|
+
return (0,external_react_.useContext)(MotionContext);
|
|
1367
|
+
}
|
|
1368
|
+
function useRouteBase() {
|
|
1369
|
+
const routeProp = (0,external_react_.useContext)(RoutePropContext);
|
|
1370
|
+
if (routeProp) {
|
|
1371
|
+
return routeProp;
|
|
1372
|
+
}
|
|
1373
|
+
else {
|
|
1374
|
+
throw new Error("Router is null. You may be trying to call useRoute outside a Router.");
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
;// CONCATENATED MODULE: ./src/common/constants.ts
|
|
1379
|
+
const MAX_Z_INDEX = 2147483647;
|
|
1380
|
+
const MAX_PROGRESS = 100;
|
|
1381
|
+
const MIN_PROGRESS = 0;
|
|
1382
|
+
const MIN_NORM_PROGRESS = 0;
|
|
1383
|
+
const MAX_NORM_PROGRESS = 1;
|
|
1384
|
+
|
|
1385
|
+
;// CONCATENATED MODULE: ./src/index.ts
|
|
1386
|
+
/// <reference types="urlpattern-polyfill" />
|
|
1387
|
+
document.body.style.position = 'fixed';
|
|
1388
|
+
document.body.style.inset = '0';
|
|
1389
|
+
let root = document.getElementById('root');
|
|
1390
|
+
if (root) {
|
|
1391
|
+
root.style.width = '100%';
|
|
1392
|
+
root.style.height = '100%';
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
|
|
1396
|
+
|
|
1397
|
+
|
|
1398
|
+
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
|
|
1406
|
+
})();
|
|
1407
|
+
|
|
1408
|
+
var __webpack_exports__LoadEvent = __webpack_exports__.Tc;
|
|
1409
|
+
var __webpack_exports__MAX_NORM_PROGRESS = __webpack_exports__.YU;
|
|
1410
|
+
var __webpack_exports__MAX_PROGRESS = __webpack_exports__.SR;
|
|
1411
|
+
var __webpack_exports__MAX_Z_INDEX = __webpack_exports__.dw;
|
|
1412
|
+
var __webpack_exports__MIN_NORM_PROGRESS = __webpack_exports__.Uy;
|
|
1413
|
+
var __webpack_exports__MIN_PROGRESS = __webpack_exports__.yn;
|
|
1414
|
+
var __webpack_exports__MotionContext = __webpack_exports__.vw;
|
|
1415
|
+
var __webpack_exports__MotionProgressEndEvent = __webpack_exports__.FC;
|
|
1416
|
+
var __webpack_exports__MotionProgressEvent = __webpack_exports__.yx;
|
|
1417
|
+
var __webpack_exports__MotionProgressStartEvent = __webpack_exports__.z4;
|
|
1418
|
+
var __webpack_exports__NavigationBase = __webpack_exports__.DC;
|
|
1419
|
+
var __webpack_exports__NestedRouterContext = __webpack_exports__.Fh;
|
|
1420
|
+
var __webpack_exports__PromiseAllDynamic = __webpack_exports__.DM;
|
|
1421
|
+
var __webpack_exports__RouterBase = __webpack_exports__.GW;
|
|
1422
|
+
var __webpack_exports__RouterContext = __webpack_exports__._q;
|
|
1423
|
+
var __webpack_exports__ScreenBase = __webpack_exports__.RG;
|
|
1424
|
+
var __webpack_exports__SharedElement = __webpack_exports__.rJ;
|
|
1425
|
+
var __webpack_exports__TransitionCancelEvent = __webpack_exports__.XP;
|
|
1426
|
+
var __webpack_exports__TransitionEndEvent = __webpack_exports__.d7;
|
|
1427
|
+
var __webpack_exports__TransitionStartEvent = __webpack_exports__.sy;
|
|
1428
|
+
var __webpack_exports__dispatchEvent = __webpack_exports__.Nu;
|
|
1429
|
+
var __webpack_exports__includesRoute = __webpack_exports__.e1;
|
|
1430
|
+
var __webpack_exports__isLazyExoticComponent = __webpack_exports__.Qv;
|
|
1431
|
+
var __webpack_exports__isNativeLazyExoticComponent = __webpack_exports__.R1;
|
|
1432
|
+
var __webpack_exports__isNavigationSupported = __webpack_exports__.vi;
|
|
1433
|
+
var __webpack_exports__isStylableElement = __webpack_exports__.R_;
|
|
1434
|
+
var __webpack_exports__isURLPatternSupported = __webpack_exports__.Ky;
|
|
1435
|
+
var __webpack_exports__isValidScreenChild = __webpack_exports__.$r;
|
|
1436
|
+
var __webpack_exports__lazy = __webpack_exports__.Vo;
|
|
1437
|
+
var __webpack_exports__matchRoute = __webpack_exports__.QN;
|
|
1438
|
+
var __webpack_exports__polyfillNavigation = __webpack_exports__.Sy;
|
|
1439
|
+
var __webpack_exports__polyfillURLPattern = __webpack_exports__.gy;
|
|
1440
|
+
var __webpack_exports__resolveBaseURLFromPattern = __webpack_exports__.n4;
|
|
1441
|
+
var __webpack_exports__toCamelCase = __webpack_exports__.zW;
|
|
1442
|
+
var __webpack_exports__useMotion = __webpack_exports__.nc;
|
|
1443
|
+
var __webpack_exports__useNavigationBase = __webpack_exports__.ev;
|
|
1444
|
+
var __webpack_exports__useRouteBase = __webpack_exports__.qr;
|
|
1445
|
+
var __webpack_exports__useRouterBase = __webpack_exports__.yL;
|
|
1446
|
+
export { __webpack_exports__LoadEvent as LoadEvent, __webpack_exports__MAX_NORM_PROGRESS as MAX_NORM_PROGRESS, __webpack_exports__MAX_PROGRESS as MAX_PROGRESS, __webpack_exports__MAX_Z_INDEX as MAX_Z_INDEX, __webpack_exports__MIN_NORM_PROGRESS as MIN_NORM_PROGRESS, __webpack_exports__MIN_PROGRESS as MIN_PROGRESS, __webpack_exports__MotionContext as MotionContext, __webpack_exports__MotionProgressEndEvent as MotionProgressEndEvent, __webpack_exports__MotionProgressEvent as MotionProgressEvent, __webpack_exports__MotionProgressStartEvent as MotionProgressStartEvent, __webpack_exports__NavigationBase as NavigationBase, __webpack_exports__NestedRouterContext as NestedRouterContext, __webpack_exports__PromiseAllDynamic as PromiseAllDynamic, __webpack_exports__RouterBase as RouterBase, __webpack_exports__RouterContext as RouterContext, __webpack_exports__ScreenBase as ScreenBase, __webpack_exports__SharedElement as SharedElement, __webpack_exports__TransitionCancelEvent as TransitionCancelEvent, __webpack_exports__TransitionEndEvent as TransitionEndEvent, __webpack_exports__TransitionStartEvent as TransitionStartEvent, __webpack_exports__dispatchEvent as dispatchEvent, __webpack_exports__includesRoute as includesRoute, __webpack_exports__isLazyExoticComponent as isLazyExoticComponent, __webpack_exports__isNativeLazyExoticComponent as isNativeLazyExoticComponent, __webpack_exports__isNavigationSupported as isNavigationSupported, __webpack_exports__isStylableElement as isStylableElement, __webpack_exports__isURLPatternSupported as isURLPatternSupported, __webpack_exports__isValidScreenChild as isValidScreenChild, __webpack_exports__lazy as lazy, __webpack_exports__matchRoute as matchRoute, __webpack_exports__polyfillNavigation as polyfillNavigation, __webpack_exports__polyfillURLPattern as polyfillURLPattern, __webpack_exports__resolveBaseURLFromPattern as resolveBaseURLFromPattern, __webpack_exports__toCamelCase as toCamelCase, __webpack_exports__useMotion as useMotion, __webpack_exports__useNavigationBase as useNavigationBase, __webpack_exports__useRouteBase as useRouteBase, __webpack_exports__useRouterBase as useRouterBase };
|
|
1447
|
+
|
|
1448
|
+
//# sourceMappingURL=index.js.map
|