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