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