@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.
@@ -0,0 +1,168 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
2
+ /******/ var __webpack_modules__ = ({
3
+
4
+ /***/ 810:
5
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6
+
7
+ var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
8
+ var y = x => () => x
9
+ module.exports = x({ ["lazy"]: () => __WEBPACK_EXTERNAL_MODULE_react__.lazy });
10
+
11
+ /***/ })
12
+
13
+ /******/ });
14
+ /************************************************************************/
15
+ /******/ // The module cache
16
+ /******/ var __webpack_module_cache__ = {};
17
+ /******/
18
+ /******/ // The require function
19
+ /******/ function __webpack_require__(moduleId) {
20
+ /******/ // Check if module is in cache
21
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
22
+ /******/ if (cachedModule !== undefined) {
23
+ /******/ return cachedModule.exports;
24
+ /******/ }
25
+ /******/ // Create a new module (and put it into the cache)
26
+ /******/ var module = __webpack_module_cache__[moduleId] = {
27
+ /******/ // no module.id needed
28
+ /******/ // no module.loaded needed
29
+ /******/ exports: {}
30
+ /******/ };
31
+ /******/
32
+ /******/ // Execute the module function
33
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
34
+ /******/
35
+ /******/ // Return the exports of the module
36
+ /******/ return module.exports;
37
+ /******/ }
38
+ /******/
39
+ /************************************************************************/
40
+ /******/ /* webpack/runtime/define property getters */
41
+ /******/ (() => {
42
+ /******/ // define getter functions for harmony exports
43
+ /******/ __webpack_require__.d = (exports, definition) => {
44
+ /******/ for(var key in definition) {
45
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
46
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
47
+ /******/ }
48
+ /******/ }
49
+ /******/ };
50
+ /******/ })();
51
+ /******/
52
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
53
+ /******/ (() => {
54
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
55
+ /******/ })();
56
+ /******/
57
+ /************************************************************************/
58
+ var __webpack_exports__ = {};
59
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
60
+ (() => {
61
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
62
+ /* harmony export */ "DM": () => (/* binding */ PromiseAllDynamic),
63
+ /* harmony export */ "Ky": () => (/* binding */ isURLPatternSupported),
64
+ /* harmony export */ "Nu": () => (/* binding */ dispatchEvent),
65
+ /* harmony export */ "QN": () => (/* binding */ matchRoute),
66
+ /* harmony export */ "Sy": () => (/* binding */ polyfillNavigation),
67
+ /* harmony export */ "Vo": () => (/* binding */ lazy),
68
+ /* harmony export */ "e1": () => (/* binding */ includesRoute),
69
+ /* harmony export */ "gy": () => (/* binding */ polyfillURLPattern),
70
+ /* harmony export */ "n4": () => (/* binding */ resolveBaseURLFromPattern),
71
+ /* harmony export */ "vi": () => (/* binding */ isNavigationSupported),
72
+ /* harmony export */ "zW": () => (/* binding */ toCamelCase)
73
+ /* harmony export */ });
74
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(810);
75
+
76
+ function resolveBaseURLFromPattern(pattern, pathname) {
77
+ if (!pattern.endsWith("**"))
78
+ pattern += '**'; // allows us to match nested routes
79
+ const origin = window.location.origin;
80
+ const baseURLMatch = new URLPattern(pattern, origin).exec(pathname, origin);
81
+ if (!baseURLMatch)
82
+ return null;
83
+ const nestedPathnameGroup = baseURLMatch.pathname.groups[1] ?? '';
84
+ // derive concrete baseURL
85
+ return new URL(pathname.replace(nestedPathnameGroup, ''), window.location.origin);
86
+ }
87
+ function matchRoute(pathnamePattern, pathname, baseURLPattern = `${window.location.origin}/`, caseSensitive = true) {
88
+ if (!caseSensitive) {
89
+ pathnamePattern = pathnamePattern.toLowerCase();
90
+ pathname = pathname.toLowerCase();
91
+ }
92
+ const baseURL = resolveBaseURLFromPattern(baseURLPattern, pathname)?.href;
93
+ if (!baseURL)
94
+ return null;
95
+ const match = new URLPattern({ baseURL, pathname: pathnamePattern }).exec({ pathname, baseURL });
96
+ const params = match?.pathname.groups ?? {};
97
+ if (match) {
98
+ return {
99
+ params
100
+ };
101
+ }
102
+ return null;
103
+ }
104
+ function includesRoute(pathnamePatterns, pathname, baseURL = window.location.origin) {
105
+ return pathnamePatterns.some(({ pattern, caseSensitive }) => matchRoute(pattern, pathname, baseURL, caseSensitive));
106
+ }
107
+ function dispatchEvent(event, target = window) {
108
+ return new Promise((resolve) => {
109
+ queueMicrotask(() => resolve(target.dispatchEvent(event)));
110
+ });
111
+ }
112
+ function lazy(factory) {
113
+ const Component = (0,react__WEBPACK_IMPORTED_MODULE_0__.lazy)(factory);
114
+ Component.load = async () => {
115
+ Component.module ??= await factory();
116
+ return Component.module;
117
+ };
118
+ return Component;
119
+ }
120
+ function isNavigationSupported() {
121
+ return Boolean(window.navigation);
122
+ }
123
+ function isURLPatternSupported() {
124
+ // @ts-ignore: Property 'UrlPattern' does not exist
125
+ return Boolean(globalThis.URLPattern);
126
+ }
127
+ async function polyfillURLPattern() {
128
+ const { URLPattern } = await import(/*webpackIgnore: true*/ "urlpattern-polyfill");
129
+ // @ts-ignore: Property 'UrlPattern' does not exist
130
+ globalThis.URLPattern = URLPattern;
131
+ }
132
+ async function polyfillNavigation() {
133
+ const { applyPolyfill } = await import(/*webpackIgnore: true*/ "@virtualstate/navigation");
134
+ applyPolyfill({
135
+ history: true,
136
+ interceptEvents: true,
137
+ patch: true,
138
+ persist: true,
139
+ persistState: true
140
+ });
141
+ }
142
+ async function PromiseAllDynamic(values) {
143
+ const awaited = [];
144
+ for (const value of values) {
145
+ awaited.push(await value);
146
+ }
147
+ return awaited;
148
+ }
149
+ function toCamelCase(value) {
150
+ return value.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
151
+ }
152
+
153
+ })();
154
+
155
+ var __webpack_exports__PromiseAllDynamic = __webpack_exports__.DM;
156
+ var __webpack_exports__dispatchEvent = __webpack_exports__.Nu;
157
+ var __webpack_exports__includesRoute = __webpack_exports__.e1;
158
+ var __webpack_exports__isNavigationSupported = __webpack_exports__.vi;
159
+ var __webpack_exports__isURLPatternSupported = __webpack_exports__.Ky;
160
+ var __webpack_exports__lazy = __webpack_exports__.Vo;
161
+ var __webpack_exports__matchRoute = __webpack_exports__.QN;
162
+ var __webpack_exports__polyfillNavigation = __webpack_exports__.Sy;
163
+ var __webpack_exports__polyfillURLPattern = __webpack_exports__.gy;
164
+ var __webpack_exports__resolveBaseURLFromPattern = __webpack_exports__.n4;
165
+ var __webpack_exports__toCamelCase = __webpack_exports__.zW;
166
+ export { __webpack_exports__PromiseAllDynamic as PromiseAllDynamic, __webpack_exports__dispatchEvent as dispatchEvent, __webpack_exports__includesRoute as includesRoute, __webpack_exports__isNavigationSupported as isNavigationSupported, __webpack_exports__isURLPatternSupported as isURLPatternSupported, __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 };
167
+
168
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common/utils.js","mappings":";;;;;;AAAA,eAAe,YAAY,6BAA6B;AACxD;AACA,qBAAqB,wDAAwD;;;;;;SCF7E;SACA;;SAEA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;;SAEA;SACA;;SAEA;SACA;SACA;;;;;UCtBA;UACA;UACA;UACA;UACA,yCAAyC,wCAAwC;UACjF;UACA;UACA;;;;;UCPA;;;;;;;;;;;;;;;;;;;;;ACA0C;AAGnC,SAAS,yBAAyB,C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,CAAC,UAAU,GAAG,UAAU,CAAC;AACvC,CAAC;AAEM,KAAK,UAAU,kBAAkB;IACpC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,CAAC;IAC3F,aAAa,CAAC;QACV,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,IAAI;KACrB,CAAC,CAAC;AACP,CAAC;AAEM,KAAK,UAAU,iBAAiB,CAAI,MAAoC;IAC3E,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAEM,SAAS,WAAW,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAChE,CAAC","sources":["webpack://@react-motion-router/core/external module \"react\"","webpack://@react-motion-router/core/webpack/bootstrap","webpack://@react-motion-router/core/webpack/runtime/define property getters","webpack://@react-motion-router/core/webpack/runtime/hasOwnProperty shorthand","webpack://@react-motion-router/core/./src/common/utils.ts"],"sourcesContent":["var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }\nvar y = x => () => x\nmodule.exports = x({ [\"lazy\"]: () => __WEBPACK_EXTERNAL_MODULE_react__.lazy });","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { lazy as ReactLazy } from \"react\";\nimport { LazyExoticComponent, MatchedRoute, PathPattern } from \"./types\";\n\nexport function resolveBaseURLFromPattern(pattern: string, pathname: string) {\n if (!pattern.endsWith(\"**\")) pattern += '**'; // allows us to match nested routes\n const origin = window.location.origin;\n const baseURLMatch = new URLPattern(pattern, origin).exec(pathname, origin);\n if (!baseURLMatch) return null;\n\n const nestedPathnameGroup = baseURLMatch.pathname.groups[1] ?? '';\n // derive concrete baseURL\n return new URL(pathname.replace(nestedPathnameGroup, ''), window.location.origin);\n}\n\nexport function matchRoute(\n pathnamePattern: string,\n pathname: string,\n baseURLPattern: string = `${window.location.origin}/`,\n caseSensitive: boolean = true\n): MatchedRoute | null {\n if (!caseSensitive) {\n pathnamePattern = pathnamePattern.toLowerCase();\n pathname = pathname.toLowerCase();\n }\n\n const baseURL = resolveBaseURLFromPattern(baseURLPattern, pathname)?.href;\n if (!baseURL) return null;\n\n const match = new URLPattern({ baseURL, pathname: pathnamePattern }).exec({ pathname, baseURL });\n const params = match?.pathname.groups ?? {};\n if (match) {\n return {\n params\n };\n }\n return null;\n}\n\nexport function includesRoute(pathnamePatterns: PathPattern[], pathname: string, baseURL: string = window.location.origin) {\n return pathnamePatterns.some(({ pattern, caseSensitive }) => matchRoute(pattern, pathname, baseURL, caseSensitive));\n}\n\nexport function dispatchEvent<T>(event: CustomEvent<T> | Event, target: HTMLElement | EventTarget = window) {\n return new Promise<boolean>((resolve) => {\n queueMicrotask(() => resolve(\n target.dispatchEvent(event)\n ));\n });\n}\n\nexport function lazy<T extends React.ComponentType<any>>(\n factory: () => Promise<{ default: T }>\n): LazyExoticComponent<T> {\n const Component = ReactLazy(factory) as LazyExoticComponent<T>;\n Component.load = async () => {\n Component.module ??= await factory();\n return Component.module;\n };\n return Component;\n}\n\nexport function isNavigationSupported() {\n return Boolean(window.navigation);\n}\n\nexport function isURLPatternSupported() {\n // @ts-ignore: Property 'UrlPattern' does not exist \n return Boolean(globalThis.URLPattern);\n}\n\nexport async function polyfillURLPattern() {\n const { URLPattern } = await import(/*webpackIgnore: true*/ \"urlpattern-polyfill\");\n // @ts-ignore: Property 'UrlPattern' does not exist \n globalThis.URLPattern = URLPattern;\n}\n\nexport async function polyfillNavigation() {\n const { applyPolyfill } = await import(/*webpackIgnore: true*/ \"@virtualstate/navigation\");\n applyPolyfill({\n history: true,\n interceptEvents: true,\n patch: true,\n persist: true,\n persistState: true\n });\n}\n\nexport async function PromiseAllDynamic<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]> {\n const awaited = [];\n for (const value of values) {\n awaited.push(await value);\n }\n\n return awaited;\n}\n\nexport function toCamelCase(value: string) {\n return value.replace(/-([a-z])/g, (g) => g[1].toUpperCase())\n}"],"names":[],"sourceRoot":""}
@@ -0,0 +1,11 @@
1
+ export * from './SharedElement';
2
+ export * from './RouterBase';
3
+ export * from './ScreenBase';
4
+ export * from './NavigationBase';
5
+ export * from './MotionContext';
6
+ export * from './RouterContext';
7
+ export * from './common/hooks';
8
+ export * from './common/types';
9
+ export * from './common/events';
10
+ export * from './common/utils';
11
+ export * from './common/constants';