@multiplatform.one/router 9.16.1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks/index.cjs +17 -19
- package/dist/cjs/hooks/index.native.cjs +31 -0
- package/dist/cjs/hooks/index.native.js +17 -18
- package/dist/cjs/hooks/index.native.js.map +1 -1
- package/dist/cjs/hooks/useUrlState.cjs +175 -180
- package/dist/cjs/hooks/useUrlState.native.cjs +215 -0
- package/dist/cjs/hooks/useUrlState.native.js +187 -196
- package/dist/cjs/hooks/useUrlState.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -11
- package/dist/cjs/index.native.cjs +22 -0
- package/dist/cjs/index.native.js +9 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/index.storybook.cjs +17 -19
- package/dist/cjs/index.storybook.native.cjs +34 -0
- package/dist/cjs/index.storybook.native.js +17 -18
- package/dist/cjs/index.storybook.native.js.map +1 -1
- package/dist/cjs/router/EmptyRouter.cjs +51 -58
- package/dist/cjs/router/EmptyRouter.native.cjs +98 -0
- package/dist/cjs/router/EmptyRouter.native.js +72 -78
- package/dist/cjs/router/EmptyRouter.native.js.map +1 -1
- package/dist/cjs/router/ReactRouter.cjs +72 -87
- package/dist/cjs/router/ReactRouter.native.cjs +119 -0
- package/dist/cjs/router/ReactRouter.native.js +95 -109
- package/dist/cjs/router/ReactRouter.native.js.map +1 -1
- package/dist/cjs/router/binding.cjs +18 -20
- package/dist/cjs/router/binding.native.cjs +35 -0
- package/dist/cjs/router/binding.native.js +18 -19
- package/dist/cjs/router/binding.native.js.map +1 -1
- package/dist/cjs/router/expoRouter.cjs +22 -26
- package/dist/cjs/router/expoRouter.native.cjs +45 -0
- package/dist/cjs/router/expoRouter.native.js +22 -25
- package/dist/cjs/router/expoRouter.native.js.map +1 -1
- package/dist/cjs/router/expoRouterBinding.cjs +35 -39
- package/dist/cjs/router/expoRouterBinding.native.cjs +61 -0
- package/dist/cjs/router/expoRouterBinding.native.js +43 -46
- package/dist/cjs/router/expoRouterBinding.native.js.map +1 -1
- package/dist/cjs/router/index.cjs +17 -19
- package/dist/cjs/router/index.native.cjs +51 -0
- package/dist/cjs/router/index.native.js +28 -29
- package/dist/cjs/router/index.native.js.map +1 -1
- package/dist/cjs/router/index.storybook-expo.cjs +9 -11
- package/dist/cjs/router/index.storybook-expo.native.cjs +20 -0
- package/dist/cjs/router/index.storybook-expo.native.js +9 -10
- package/dist/cjs/router/index.storybook-expo.native.js.map +1 -1
- package/dist/cjs/router/index.storybook.cjs +9 -11
- package/dist/cjs/router/index.storybook.native.cjs +20 -0
- package/dist/cjs/router/index.storybook.native.js +9 -10
- package/dist/cjs/router/index.storybook.native.js.map +1 -1
- package/dist/cjs/router/index.webext.cjs +9 -11
- package/dist/cjs/router/index.webext.native.cjs +20 -0
- package/dist/cjs/router/index.webext.native.js +9 -10
- package/dist/cjs/router/index.webext.native.js.map +1 -1
- package/dist/cjs/router/nativeRouter.cjs +33 -41
- package/dist/cjs/router/nativeRouter.native.cjs +72 -0
- package/dist/cjs/router/nativeRouter.native.js +42 -49
- package/dist/cjs/router/nativeRouter.native.js.map +1 -1
- package/dist/cjs/seam/DomNavigationHost.cjs +138 -150
- package/dist/cjs/seam/DomNavigationHost.native.cjs +233 -0
- package/dist/cjs/seam/DomNavigationHost.native.js +201 -207
- package/dist/cjs/seam/DomNavigationHost.native.js.map +1 -1
- package/dist/cjs/seam/index.cjs +31 -33
- package/dist/cjs/seam/index.native.cjs +47 -0
- package/dist/cjs/seam/index.native.js +31 -32
- package/dist/cjs/seam/index.native.js.map +1 -1
- package/dist/cjs/seam/navigator.cjs +309 -319
- package/dist/cjs/seam/navigator.native.cjs +525 -0
- package/dist/cjs/seam/navigator.native.js +490 -498
- package/dist/cjs/seam/navigator.native.js.map +1 -1
- package/dist/cjs/seam/oneAdapter.cjs +86 -93
- package/dist/cjs/seam/oneAdapter.native.cjs +133 -0
- package/dist/cjs/seam/oneAdapter.native.js +94 -104
- package/dist/cjs/seam/oneAdapter.native.js.map +1 -1
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +9 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/hooks/index.mjs +3 -3
- package/dist/esm/hooks/index.native.js +3 -3
- package/dist/esm/hooks/useUrlState.mjs +160 -161
- package/dist/esm/hooks/useUrlState.mjs.map +1 -1
- package/dist/esm/hooks/useUrlState.native.js +171 -177
- package/dist/esm/hooks/useUrlState.native.js.map +1 -1
- package/dist/esm/index.mjs +5 -4
- package/dist/esm/index.native.js +5 -4
- package/dist/esm/index.storybook.mjs +7 -5
- package/dist/esm/index.storybook.native.js +7 -5
- package/dist/esm/router/EmptyRouter.mjs +35 -38
- package/dist/esm/router/EmptyRouter.mjs.map +1 -1
- package/dist/esm/router/EmptyRouter.native.js +57 -60
- package/dist/esm/router/EmptyRouter.native.js.map +1 -1
- package/dist/esm/router/ReactRouter.mjs +59 -70
- package/dist/esm/router/ReactRouter.mjs.map +1 -1
- package/dist/esm/router/ReactRouter.native.js +82 -93
- package/dist/esm/router/ReactRouter.native.js.map +1 -1
- package/dist/esm/router/binding.mjs +4 -3
- package/dist/esm/router/binding.mjs.map +1 -1
- package/dist/esm/router/binding.native.js +4 -3
- package/dist/esm/router/binding.native.js.map +1 -1
- package/dist/esm/router/expoRouter.mjs +7 -7
- package/dist/esm/router/expoRouter.mjs.map +1 -1
- package/dist/esm/router/expoRouter.native.js +7 -7
- package/dist/esm/router/expoRouter.native.js.map +1 -1
- package/dist/esm/router/expoRouterBinding.mjs +23 -21
- package/dist/esm/router/expoRouterBinding.mjs.map +1 -1
- package/dist/esm/router/expoRouterBinding.native.js +31 -29
- package/dist/esm/router/expoRouterBinding.native.js.map +1 -1
- package/dist/esm/router/index.mjs +2 -2
- package/dist/esm/router/index.native.js +13 -11
- package/dist/esm/router/index.native.js.map +1 -1
- package/dist/esm/router/index.storybook-expo.mjs +1 -2
- package/dist/esm/router/index.storybook-expo.native.js +1 -2
- package/dist/esm/router/index.storybook.mjs +1 -2
- package/dist/esm/router/index.storybook.native.js +1 -2
- package/dist/esm/router/index.webext.mjs +1 -2
- package/dist/esm/router/index.webext.native.js +1 -2
- package/dist/esm/router/nativeRouter.mjs +19 -23
- package/dist/esm/router/nativeRouter.mjs.map +1 -1
- package/dist/esm/router/nativeRouter.native.js +29 -33
- package/dist/esm/router/nativeRouter.native.js.map +1 -1
- package/dist/esm/seam/DomNavigationHost.mjs +125 -133
- package/dist/esm/seam/DomNavigationHost.mjs.map +1 -1
- package/dist/esm/seam/DomNavigationHost.native.js +189 -192
- package/dist/esm/seam/DomNavigationHost.native.js.map +1 -1
- package/dist/esm/seam/index.mjs +2 -2
- package/dist/esm/seam/index.native.js +2 -2
- package/dist/esm/seam/navigator.mjs +292 -298
- package/dist/esm/seam/navigator.mjs.map +1 -1
- package/dist/esm/seam/navigator.native.js +473 -478
- package/dist/esm/seam/navigator.native.js.map +1 -1
- package/dist/esm/seam/oneAdapter.mjs +61 -64
- package/dist/esm/seam/oneAdapter.mjs.map +1 -1
- package/dist/esm/seam/oneAdapter.native.js +70 -77
- package/dist/esm/seam/oneAdapter.native.js.map +1 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/jsx/hooks/index.mjs +3 -3
- package/dist/jsx/hooks/index.native.cjs +31 -0
- package/dist/jsx/hooks/index.native.js +17 -18
- package/dist/jsx/hooks/index.native.js.map +1 -1
- package/dist/jsx/hooks/useUrlState.mjs +160 -161
- package/dist/jsx/hooks/useUrlState.mjs.map +1 -1
- package/dist/jsx/hooks/useUrlState.native.cjs +215 -0
- package/dist/jsx/hooks/useUrlState.native.js +187 -196
- package/dist/jsx/hooks/useUrlState.native.js.map +1 -1
- package/dist/jsx/index.js +5 -4
- package/dist/jsx/index.mjs +5 -4
- package/dist/jsx/index.native.cjs +22 -0
- package/dist/jsx/index.native.js +9 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/index.storybook.mjs +7 -5
- package/dist/jsx/index.storybook.native.cjs +34 -0
- package/dist/jsx/index.storybook.native.js +17 -18
- package/dist/jsx/index.storybook.native.js.map +1 -1
- package/dist/jsx/router/EmptyRouter.mjs +35 -38
- package/dist/jsx/router/EmptyRouter.mjs.map +1 -1
- package/dist/jsx/router/EmptyRouter.native.cjs +98 -0
- package/dist/jsx/router/EmptyRouter.native.js +72 -78
- package/dist/jsx/router/EmptyRouter.native.js.map +1 -1
- package/dist/jsx/router/ReactRouter.mjs +59 -70
- package/dist/jsx/router/ReactRouter.mjs.map +1 -1
- package/dist/jsx/router/ReactRouter.native.cjs +119 -0
- package/dist/jsx/router/ReactRouter.native.js +95 -109
- package/dist/jsx/router/ReactRouter.native.js.map +1 -1
- package/dist/jsx/router/binding.mjs +4 -3
- package/dist/jsx/router/binding.mjs.map +1 -1
- package/dist/jsx/router/binding.native.cjs +35 -0
- package/dist/jsx/router/binding.native.js +18 -19
- package/dist/jsx/router/binding.native.js.map +1 -1
- package/dist/jsx/router/expoRouter.mjs +7 -7
- package/dist/jsx/router/expoRouter.mjs.map +1 -1
- package/dist/jsx/router/expoRouter.native.cjs +45 -0
- package/dist/jsx/router/expoRouter.native.js +22 -25
- package/dist/jsx/router/expoRouter.native.js.map +1 -1
- package/dist/jsx/router/expoRouterBinding.mjs +23 -21
- package/dist/jsx/router/expoRouterBinding.mjs.map +1 -1
- package/dist/jsx/router/expoRouterBinding.native.cjs +61 -0
- package/dist/jsx/router/expoRouterBinding.native.js +43 -46
- package/dist/jsx/router/expoRouterBinding.native.js.map +1 -1
- package/dist/jsx/router/index.mjs +2 -2
- package/dist/jsx/router/index.native.cjs +51 -0
- package/dist/jsx/router/index.native.js +28 -29
- package/dist/jsx/router/index.native.js.map +1 -1
- package/dist/jsx/router/index.storybook-expo.mjs +1 -2
- package/dist/jsx/router/index.storybook-expo.native.cjs +20 -0
- package/dist/jsx/router/index.storybook-expo.native.js +9 -10
- package/dist/jsx/router/index.storybook-expo.native.js.map +1 -1
- package/dist/jsx/router/index.storybook.mjs +1 -2
- package/dist/jsx/router/index.storybook.native.cjs +20 -0
- package/dist/jsx/router/index.storybook.native.js +9 -10
- package/dist/jsx/router/index.storybook.native.js.map +1 -1
- package/dist/jsx/router/index.webext.mjs +1 -2
- package/dist/jsx/router/index.webext.native.cjs +20 -0
- package/dist/jsx/router/index.webext.native.js +9 -10
- package/dist/jsx/router/index.webext.native.js.map +1 -1
- package/dist/jsx/router/nativeRouter.mjs +19 -23
- package/dist/jsx/router/nativeRouter.mjs.map +1 -1
- package/dist/jsx/router/nativeRouter.native.cjs +72 -0
- package/dist/jsx/router/nativeRouter.native.js +42 -49
- package/dist/jsx/router/nativeRouter.native.js.map +1 -1
- package/dist/jsx/seam/DomNavigationHost.mjs +125 -133
- package/dist/jsx/seam/DomNavigationHost.mjs.map +1 -1
- package/dist/jsx/seam/DomNavigationHost.native.cjs +233 -0
- package/dist/jsx/seam/DomNavigationHost.native.js +201 -207
- package/dist/jsx/seam/DomNavigationHost.native.js.map +1 -1
- package/dist/jsx/seam/index.mjs +2 -2
- package/dist/jsx/seam/index.native.cjs +47 -0
- package/dist/jsx/seam/index.native.js +31 -32
- package/dist/jsx/seam/index.native.js.map +1 -1
- package/dist/jsx/seam/navigator.mjs +292 -298
- package/dist/jsx/seam/navigator.mjs.map +1 -1
- package/dist/jsx/seam/navigator.native.cjs +525 -0
- package/dist/jsx/seam/navigator.native.js +490 -498
- package/dist/jsx/seam/navigator.native.js.map +1 -1
- package/dist/jsx/seam/oneAdapter.mjs +61 -64
- package/dist/jsx/seam/oneAdapter.mjs.map +1 -1
- package/dist/jsx/seam/oneAdapter.native.cjs +133 -0
- package/dist/jsx/seam/oneAdapter.native.js +94 -104
- package/dist/jsx/seam/oneAdapter.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +18 -0
- package/dist/jsx/types.native.js +9 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +14 -14
- package/dist/esm/hooks/index.mjs.map +0 -1
- package/dist/esm/hooks/index.native.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/index.storybook.mjs.map +0 -1
- package/dist/esm/index.storybook.native.js.map +0 -1
- package/dist/esm/router/index.mjs.map +0 -1
- package/dist/esm/router/index.storybook-expo.mjs.map +0 -1
- package/dist/esm/router/index.storybook-expo.native.js.map +0 -1
- package/dist/esm/router/index.storybook.mjs.map +0 -1
- package/dist/esm/router/index.storybook.native.js.map +0 -1
- package/dist/esm/router/index.webext.mjs.map +0 -1
- package/dist/esm/router/index.webext.native.js.map +0 -1
- package/dist/esm/seam/index.mjs.map +0 -1
- package/dist/esm/seam/index.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/jsx/hooks/index.mjs.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/index.storybook.mjs.map +0 -1
- package/dist/jsx/router/index.mjs.map +0 -1
- package/dist/jsx/router/index.storybook-expo.mjs.map +0 -1
- package/dist/jsx/router/index.storybook.mjs.map +0 -1
- package/dist/jsx/router/index.webext.mjs.map +0 -1
- package/dist/jsx/seam/index.mjs.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
|
@@ -1,502 +1,497 @@
|
|
|
1
1
|
import { createContext, useContext, useSyncExternalStore } from "react";
|
|
2
|
+
|
|
2
3
|
function _class_call_check(instance, Constructor) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
if (!(instance instanceof Constructor)) {
|
|
5
|
+
throw new TypeError("Cannot call a class as a function");
|
|
6
|
+
}
|
|
6
7
|
}
|
|
7
8
|
function _defineProperties(target, props) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
for (var i = 0; i < props.length; i++) {
|
|
10
|
+
var descriptor = props[i];
|
|
11
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
12
|
+
descriptor.configurable = true;
|
|
13
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
14
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
15
|
+
}
|
|
15
16
|
}
|
|
16
17
|
function _create_class(Constructor, protoProps, staticProps) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
19
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
20
|
+
return Constructor;
|
|
20
21
|
}
|
|
21
22
|
function _define_property(obj, key, value) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
if (key in obj) {
|
|
24
|
+
Object.defineProperty(obj, key, {
|
|
25
|
+
value,
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
obj[key] = value;
|
|
32
|
+
}
|
|
33
|
+
return obj;
|
|
33
34
|
}
|
|
34
35
|
function compileRoute(def) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
...def,
|
|
45
|
-
segments
|
|
46
|
-
};
|
|
36
|
+
var segments = def.pattern.split("/").filter(Boolean).map(function(seg) {
|
|
37
|
+
var m = seg.match(/^\[(\.{3})?(.+)\]$/);
|
|
38
|
+
return m ? { param: m[2] } : { literal: seg };
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
...def,
|
|
42
|
+
segments
|
|
43
|
+
};
|
|
47
44
|
}
|
|
48
45
|
function parseQuery(query) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
46
|
+
var params = {};
|
|
47
|
+
if (!query) return params;
|
|
48
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
49
|
+
try {
|
|
50
|
+
for (var _iterator = query.split("&")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
51
|
+
var pair = _step.value;
|
|
52
|
+
if (!pair) continue;
|
|
53
|
+
var eq = pair.indexOf("=");
|
|
54
|
+
var key = decodeURIComponent(eq === -1 ? pair : pair.slice(0, eq));
|
|
55
|
+
var value = eq === -1 ? "" : decodeURIComponent(pair.slice(eq + 1));
|
|
56
|
+
var prev = params[key];
|
|
57
|
+
if (prev === void 0) params[key] = value;
|
|
58
|
+
else if (Array.isArray(prev)) prev.push(value);
|
|
59
|
+
else params[key] = [prev, value];
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
_didIteratorError = true;
|
|
63
|
+
_iteratorError = err;
|
|
64
|
+
} finally {
|
|
65
|
+
try {
|
|
66
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
67
|
+
_iterator.return();
|
|
68
|
+
}
|
|
69
|
+
} finally {
|
|
70
|
+
if (_didIteratorError) {
|
|
71
|
+
throw _iteratorError;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return params;
|
|
79
76
|
}
|
|
80
77
|
function hrefToString(href) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return leftover.length ? `${path}?${leftover.join("&")}` : path;
|
|
78
|
+
var _href_params;
|
|
79
|
+
if (typeof href === "string") return href;
|
|
80
|
+
var path = href.pathname;
|
|
81
|
+
var leftover = [];
|
|
82
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
83
|
+
try {
|
|
84
|
+
for (var _iterator = Object.entries((_href_params = href.params) !== null && _href_params !== void 0 ? _href_params : {})[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
85
|
+
var [key, raw] = _step.value;
|
|
86
|
+
var value = String(raw);
|
|
87
|
+
var token = `[${key}]`;
|
|
88
|
+
if (path.includes(token)) path = path.replace(token, encodeURIComponent(value));
|
|
89
|
+
else leftover.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
_didIteratorError = true;
|
|
93
|
+
_iteratorError = err;
|
|
94
|
+
} finally {
|
|
95
|
+
try {
|
|
96
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
97
|
+
_iterator.return();
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
if (_didIteratorError) {
|
|
101
|
+
throw _iteratorError;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return leftover.length ? `${path}?${leftover.join("&")}` : path;
|
|
110
106
|
}
|
|
111
107
|
var EMPTY_PARAMS = Object.freeze({});
|
|
112
|
-
var StackNavigator = /* @__PURE__ */
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return StackNavigator2;
|
|
489
|
-
}();
|
|
108
|
+
var StackNavigator = /* @__PURE__ */ (function() {
|
|
109
|
+
"use strict";
|
|
110
|
+
function StackNavigator2() {
|
|
111
|
+
var _this = this;
|
|
112
|
+
_class_call_check(this, StackNavigator2);
|
|
113
|
+
_define_property(this, "routes", []);
|
|
114
|
+
_define_property(this, "host", null);
|
|
115
|
+
_define_property(this, "listeners", /* @__PURE__ */ new Set());
|
|
116
|
+
_define_property(this, "stackTags", []);
|
|
117
|
+
_define_property(this, "paramsByTag", /* @__PURE__ */ new Map());
|
|
118
|
+
_define_property(this, "pathnameByTag", /* @__PURE__ */ new Map());
|
|
119
|
+
_define_property(this, "visitedTags", /* @__PURE__ */ new Set());
|
|
120
|
+
_define_property(this, "loaderDataByTag", /* @__PURE__ */ new Map());
|
|
121
|
+
_define_property(this, "navSeq", 0);
|
|
122
|
+
_define_property(this, "pendingNavigations", []);
|
|
123
|
+
_define_property(this, "generation", 0);
|
|
124
|
+
_define_property(this, "snapshot", {
|
|
125
|
+
pathname: "/",
|
|
126
|
+
tag: "",
|
|
127
|
+
depth: 0,
|
|
128
|
+
canGoBack: false,
|
|
129
|
+
generation: 0
|
|
130
|
+
});
|
|
131
|
+
_define_property(this, "subscribe", function(fn) {
|
|
132
|
+
_this.listeners.add(fn);
|
|
133
|
+
return function() {
|
|
134
|
+
return _this.listeners.delete(fn);
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
_define_property(this, "getSnapshot", function() {
|
|
138
|
+
return _this.snapshot;
|
|
139
|
+
});
|
|
140
|
+
_define_property(this, "push", function(href) {
|
|
141
|
+
void _this.navigate(href, "push");
|
|
142
|
+
});
|
|
143
|
+
_define_property(this, "replace", function(href) {
|
|
144
|
+
void _this.navigate(href, "replace");
|
|
145
|
+
});
|
|
146
|
+
_define_property(this, "back", function() {
|
|
147
|
+
if (!_this.host) {
|
|
148
|
+
console.log("[stack nav] back — no stack host attached, ignored");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
_this.navSeq++;
|
|
152
|
+
_this.host.pop();
|
|
153
|
+
});
|
|
154
|
+
_define_property(this, "setParams", function(params) {
|
|
155
|
+
var _this_paramsByTag_get;
|
|
156
|
+
var top = _this.stackTags.at(-1);
|
|
157
|
+
if (!top) return;
|
|
158
|
+
var prev = (_this_paramsByTag_get = _this.paramsByTag.get(top)) !== null && _this_paramsByTag_get !== void 0 ? _this_paramsByTag_get : {};
|
|
159
|
+
_this.paramsByTag.set(top, {
|
|
160
|
+
...prev,
|
|
161
|
+
...params
|
|
162
|
+
});
|
|
163
|
+
_this.rebuildSnapshot();
|
|
164
|
+
});
|
|
165
|
+
_define_property(this, "syncFromHost", function() {
|
|
166
|
+
if (!_this.host) return;
|
|
167
|
+
_this.navSeq++;
|
|
168
|
+
var model = _this.host.get_navigation_stack();
|
|
169
|
+
var tags = [];
|
|
170
|
+
var count = model.get_n_items();
|
|
171
|
+
for (var i = 0; i < count; i++) {
|
|
172
|
+
var _model_get_item;
|
|
173
|
+
var tag = (_model_get_item = model.get_item(i)) === null || _model_get_item === void 0 ? void 0 : _model_get_item.get_tag();
|
|
174
|
+
if (tag) tags.push(tag);
|
|
175
|
+
}
|
|
176
|
+
if (tags.length > 0) _this.stackTags = tags;
|
|
177
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
178
|
+
try {
|
|
179
|
+
for (var _iterator = _this.stackTags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
180
|
+
var tag1 = _step.value;
|
|
181
|
+
_this.visitedTags.add(tag1);
|
|
182
|
+
}
|
|
183
|
+
} catch (err) {
|
|
184
|
+
_didIteratorError = true;
|
|
185
|
+
_iteratorError = err;
|
|
186
|
+
} finally {
|
|
187
|
+
try {
|
|
188
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
189
|
+
_iterator.return();
|
|
190
|
+
}
|
|
191
|
+
} finally {
|
|
192
|
+
if (_didIteratorError) {
|
|
193
|
+
throw _iteratorError;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
_this.rebuildSnapshot();
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
_create_class(StackNavigator2, [
|
|
201
|
+
{
|
|
202
|
+
key: "isConfigured",
|
|
203
|
+
get: function get() {
|
|
204
|
+
return this.routes.length > 0;
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
/** Register the route manifest. The FIRST route is the root page. */
|
|
209
|
+
key: "configure",
|
|
210
|
+
value: function configure(defs) {
|
|
211
|
+
this.routes = defs.map(compileRoute);
|
|
212
|
+
this.visitedTags = /* @__PURE__ */ new Set();
|
|
213
|
+
this.loaderDataByTag = /* @__PURE__ */ new Map();
|
|
214
|
+
this.pendingNavigations = [];
|
|
215
|
+
var root = defs[0];
|
|
216
|
+
if (root) {
|
|
217
|
+
this.stackTags = [root.tag];
|
|
218
|
+
this.visitedTags.add(root.tag);
|
|
219
|
+
this.pathnameByTag.set(root.tag, root.pattern);
|
|
220
|
+
this.rebuildSnapshot();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
/** Has this route's page been navigated to (⇒ its content may mount)? */
|
|
226
|
+
key: "isVisited",
|
|
227
|
+
value: function isVisited(tag) {
|
|
228
|
+
return tag !== null && this.visitedTags.has(tag);
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
/** The route's last loader result (stable identity until the loader runs
|
|
233
|
+
* again). undefined when the route has no loader / hasn't resolved. */
|
|
234
|
+
key: "loaderSnapshot",
|
|
235
|
+
value: function loaderSnapshot(tag) {
|
|
236
|
+
if (!tag) return void 0;
|
|
237
|
+
return this.loaderDataByTag.get(tag);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
/** Seed a restored route's params/pathname BEFORE the first React render
|
|
242
|
+
* (no host action, no stack mutation). The navigation host applies
|
|
243
|
+
* `initialHref` from its attach EFFECT, which runs after the root page's
|
|
244
|
+
* content already rendered once — a restored route's query params would
|
|
245
|
+
* miss any mount-time state seeding (e.g. a list initializing filters
|
|
246
|
+
* from useLocalSearchParams). Hosts call this while lazily initializing,
|
|
247
|
+
* when no subscribers exist yet, so the rebuild notifies nobody. */
|
|
248
|
+
key: "seedInitialRoute",
|
|
249
|
+
value: function seedInitialRoute(href) {
|
|
250
|
+
var hit = this.match(href);
|
|
251
|
+
if (!hit) return;
|
|
252
|
+
this.setRouteState(hit.route.tag, hit.pathname, hit.params);
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
key: "preload",
|
|
257
|
+
value: (
|
|
258
|
+
/** Resolve a route's loader WITHOUT navigating. For the initial page:
|
|
259
|
+
* entries can `await stackNavigator.preload("/")` during top-level await
|
|
260
|
+
* (where GJS reliably drains promise jobs) so even the root page's first
|
|
261
|
+
* paint has loader data. */
|
|
262
|
+
async function preload(href) {
|
|
263
|
+
var hit = this.match(href);
|
|
264
|
+
if (!(hit === null || hit === void 0 ? void 0 : hit.route.loader)) return;
|
|
265
|
+
try {
|
|
266
|
+
var data = await hit.route.loader({
|
|
267
|
+
path: hit.pathname,
|
|
268
|
+
params: hit.params
|
|
269
|
+
});
|
|
270
|
+
this.loaderDataByTag.set(hit.route.tag, data);
|
|
271
|
+
this.rebuildSnapshot();
|
|
272
|
+
} catch (err) {
|
|
273
|
+
console.error(`[stack nav] preload loader for ${hit.route.tag} failed: ${String(err)}`);
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
/** Bind the live host stack (an Adw.NavigationView widget on GTK, a
|
|
279
|
+
* DomStackAdapter on DOM targets). `initialHref` (state restore) applies
|
|
280
|
+
* as a replace BEFORE queued navigations flush: a deep link that arrived
|
|
281
|
+
* while unattached is fresher intent than a persisted route, so it lands
|
|
282
|
+
* on top. */
|
|
283
|
+
key: "attach",
|
|
284
|
+
value: function attach(host, options) {
|
|
285
|
+
this.host = host;
|
|
286
|
+
this.syncFromHost();
|
|
287
|
+
var initialHref = options === null || options === void 0 ? void 0 : options.initialHref;
|
|
288
|
+
if (initialHref !== void 0) this.replace(initialHref);
|
|
289
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
290
|
+
try {
|
|
291
|
+
for (var _iterator = this.pendingNavigations.splice(0)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
292
|
+
var { href, mode } = _step.value;
|
|
293
|
+
void this.navigate(href, mode);
|
|
294
|
+
}
|
|
295
|
+
} catch (err) {
|
|
296
|
+
_didIteratorError = true;
|
|
297
|
+
_iteratorError = err;
|
|
298
|
+
} finally {
|
|
299
|
+
try {
|
|
300
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
301
|
+
_iterator.return();
|
|
302
|
+
}
|
|
303
|
+
} finally {
|
|
304
|
+
if (_didIteratorError) {
|
|
305
|
+
throw _iteratorError;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: "detach",
|
|
313
|
+
value: function detach() {
|
|
314
|
+
this.host = null;
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
key: "paramsSnapshot",
|
|
319
|
+
value: function paramsSnapshot(tag) {
|
|
320
|
+
var _this_paramsByTag_get;
|
|
321
|
+
if (!tag) return EMPTY_PARAMS;
|
|
322
|
+
return (_this_paramsByTag_get = this.paramsByTag.get(tag)) !== null && _this_paramsByTag_get !== void 0 ? _this_paramsByTag_get : EMPTY_PARAMS;
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
key: "match",
|
|
327
|
+
value: function match(href) {
|
|
328
|
+
var str = hrefToString(href);
|
|
329
|
+
var [path = "", query] = str.split("?");
|
|
330
|
+
var parts = path.split("/").filter(Boolean);
|
|
331
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
332
|
+
try {
|
|
333
|
+
for (var _iterator = this.routes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
334
|
+
var route = _step.value;
|
|
335
|
+
if (route.segments.length !== parts.length) continue;
|
|
336
|
+
var params = parseQuery(query);
|
|
337
|
+
var ok = true;
|
|
338
|
+
for (var i = 0; i < parts.length; i++) {
|
|
339
|
+
var seg = route.segments[i];
|
|
340
|
+
var part = decodeURIComponent(parts[i]);
|
|
341
|
+
if (seg.literal !== void 0) {
|
|
342
|
+
if (seg.literal !== part) {
|
|
343
|
+
ok = false;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
} else if (seg.param !== void 0) {
|
|
347
|
+
params[seg.param] = part;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (ok) return {
|
|
351
|
+
route,
|
|
352
|
+
pathname: path === "" ? "/" : `/${parts.join("/")}`,
|
|
353
|
+
params
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
} catch (err) {
|
|
357
|
+
_didIteratorError = true;
|
|
358
|
+
_iteratorError = err;
|
|
359
|
+
} finally {
|
|
360
|
+
try {
|
|
361
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
362
|
+
_iterator.return();
|
|
363
|
+
}
|
|
364
|
+
} finally {
|
|
365
|
+
if (_didIteratorError) {
|
|
366
|
+
throw _iteratorError;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
key: "navigate",
|
|
375
|
+
value: (
|
|
376
|
+
/** Shared push/replace flow, incl. the loader bridge. When the target
|
|
377
|
+
* route has no loader the whole body runs SYNCHRONOUSLY (an async
|
|
378
|
+
* function only yields at its first await), preserving the original
|
|
379
|
+
* timing. With a loader, the host action waits for the loader to resolve
|
|
380
|
+
* — same contract as One on web, where client navigation completes only
|
|
381
|
+
* after the route's loader data arrived — so the page's first paint has
|
|
382
|
+
* its data (and the lazily-mounted content mounts with it). */
|
|
383
|
+
async function navigate(href, mode) {
|
|
384
|
+
var hit = this.match(href);
|
|
385
|
+
if (!hit) {
|
|
386
|
+
console.log(`[stack nav] ${mode} ${hrefToString(href)} \u2014 no page in the route manifest, ignored`);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (!this.host) {
|
|
390
|
+
this.pendingNavigations.push({
|
|
391
|
+
href,
|
|
392
|
+
mode
|
|
393
|
+
});
|
|
394
|
+
console.log(`[stack nav] ${mode} ${hrefToString(href)} \u2014 queued until a stack host attaches`);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
var { route, pathname, params } = hit;
|
|
398
|
+
var seq = ++this.navSeq;
|
|
399
|
+
if (route.loader) {
|
|
400
|
+
try {
|
|
401
|
+
var data = await route.loader({
|
|
402
|
+
path: pathname,
|
|
403
|
+
params
|
|
404
|
+
});
|
|
405
|
+
if (seq !== this.navSeq) return;
|
|
406
|
+
this.loaderDataByTag.set(route.tag, data);
|
|
407
|
+
} catch (err) {
|
|
408
|
+
if (seq !== this.navSeq) return;
|
|
409
|
+
console.error(`[stack nav] loader for ${route.tag} failed: ${String(err)}`);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
this.visitedTags.add(route.tag);
|
|
413
|
+
this.setRouteState(route.tag, pathname, params);
|
|
414
|
+
if (mode === "replace") {
|
|
415
|
+
var top = this.stackTags.at(-1);
|
|
416
|
+
if (top === route.tag) return;
|
|
417
|
+
if (this.stackTags.length <= 1) {
|
|
418
|
+
this.host.replace_with_tags([...this.stackTags, route.tag]);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
var below = this.stackTags.slice(0, -1).filter(function(tag) {
|
|
422
|
+
return tag !== route.tag;
|
|
423
|
+
});
|
|
424
|
+
this.host.replace_with_tags([...below, route.tag]);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
var idx = this.stackTags.indexOf(route.tag);
|
|
428
|
+
if (idx === -1) {
|
|
429
|
+
this.host.push_by_tag(route.tag);
|
|
430
|
+
} else if (idx < this.stackTags.length - 1) {
|
|
431
|
+
this.host.pop_to_tag(route.tag);
|
|
432
|
+
}
|
|
433
|
+
})
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
key: "setRouteState",
|
|
437
|
+
value: function setRouteState(tag, pathname, params) {
|
|
438
|
+
this.paramsByTag.set(tag, params);
|
|
439
|
+
this.pathnameByTag.set(tag, pathname);
|
|
440
|
+
this.rebuildSnapshot();
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
key: "rebuildSnapshot",
|
|
445
|
+
value: function rebuildSnapshot() {
|
|
446
|
+
var _this_stackTags_at, _ref, _this_pathnameByTag_get;
|
|
447
|
+
var tag = (_this_stackTags_at = this.stackTags.at(-1)) !== null && _this_stackTags_at !== void 0 ? _this_stackTags_at : "";
|
|
448
|
+
var route = this.routes.find(function(r) {
|
|
449
|
+
return r.tag === tag;
|
|
450
|
+
});
|
|
451
|
+
this.generation++;
|
|
452
|
+
this.snapshot = {
|
|
453
|
+
pathname: (_ref = (_this_pathnameByTag_get = this.pathnameByTag.get(tag)) !== null && _this_pathnameByTag_get !== void 0 ? _this_pathnameByTag_get : route === null || route === void 0 ? void 0 : route.pattern) !== null && _ref !== void 0 ? _ref : "/",
|
|
454
|
+
tag,
|
|
455
|
+
depth: this.stackTags.length,
|
|
456
|
+
canGoBack: this.stackTags.length > 1,
|
|
457
|
+
generation: this.generation
|
|
458
|
+
};
|
|
459
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
460
|
+
try {
|
|
461
|
+
for (var _iterator = this.listeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
462
|
+
var fn = _step.value;
|
|
463
|
+
fn();
|
|
464
|
+
}
|
|
465
|
+
} catch (err) {
|
|
466
|
+
_didIteratorError = true;
|
|
467
|
+
_iteratorError = err;
|
|
468
|
+
} finally {
|
|
469
|
+
try {
|
|
470
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
471
|
+
_iterator.return();
|
|
472
|
+
}
|
|
473
|
+
} finally {
|
|
474
|
+
if (_didIteratorError) {
|
|
475
|
+
throw _iteratorError;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
]);
|
|
482
|
+
return StackNavigator2;
|
|
483
|
+
})();
|
|
490
484
|
var stackNavigator = new StackNavigator();
|
|
491
485
|
var RouteTagContext = createContext(null);
|
|
492
486
|
function useNavState() {
|
|
493
|
-
|
|
487
|
+
return useSyncExternalStore(stackNavigator.subscribe, stackNavigator.getSnapshot);
|
|
494
488
|
}
|
|
495
489
|
function useRouteParams() {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
490
|
+
var tag = useContext(RouteTagContext);
|
|
491
|
+
return useSyncExternalStore(stackNavigator.subscribe, function() {
|
|
492
|
+
return stackNavigator.paramsSnapshot(tag);
|
|
493
|
+
});
|
|
500
494
|
}
|
|
495
|
+
|
|
501
496
|
export { RouteTagContext, StackNavigator, hrefToString, stackNavigator, useNavState, useRouteParams };
|
|
502
497
|
//# sourceMappingURL=navigator.native.js.map
|