@real-router/svelte 0.19.1 → 0.20.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.
@@ -78,7 +78,7 @@ export declare function anchorTargetsAnotherContext(element: Element | null | un
78
78
  *
79
79
  * - Prefers the URL plugin's `buildUrl` (browser-plugin, navigation-plugin,
80
80
  * hash-plugin) when present.
81
- * - Falls back to `router.buildPath` for runtimes without a URL plugin
81
+ * - Falls back to the core's resolving door for runtimes without a URL plugin
82
82
  * (memory-plugin, console UIs, NativeScript). In that fallback the hash
83
83
  * is appended manually so the rendered href is still correct.
84
84
  * - The optional 4th argument is the decoded hash fragment (no leading "#";
@@ -1,3 +1,4 @@
1
+ import { getPluginApi } from "@real-router/core/api";
1
2
  import { putField } from "@real-router/core/utils";
2
3
  /**
3
4
  * Intrinsics captured at module load (#1971).
@@ -127,7 +128,7 @@ function encodeFragmentInline(decoded) {
127
128
  *
128
129
  * - Prefers the URL plugin's `buildUrl` (browser-plugin, navigation-plugin,
129
130
  * hash-plugin) when present.
130
- * - Falls back to `router.buildPath` for runtimes without a URL plugin
131
+ * - Falls back to the core's resolving door for runtimes without a URL plugin
131
132
  * (memory-plugin, console UIs, NativeScript). In that fallback the hash
132
133
  * is appended manually so the rendered href is still correct.
133
134
  * - The optional 4th argument is the decoded hash fragment (no leading "#";
@@ -159,7 +160,39 @@ export function buildHref(router, routeName, routeParams, routeSearch, hash) {
159
160
  return url;
160
161
  }
161
162
  }
162
- const path = router.buildPath(routeName, routeParams, routeSearch);
163
+ // ⚑ The RESOLVING door, not `router.buildPath` (#2250). An href is a promise
164
+ // about where the click lands, and the click resolves `forwardTo`.
165
+ // `buildPath` is class LITERAL by record and answers about the route it was
166
+ // NAMED — INVARIANTS #8 keeps that so a plugin can build a state for an alias
167
+ // without being teleported off it, so the door choice belongs here rather
168
+ // than one layer down.
169
+ //
170
+ // ⚠ The `??` preserves the FAILURE shape, it is not a convenience: a name the
171
+ // table does not hold makes the class-① door answer `undefined` where
172
+ // `buildPath` THROWS, and that throw is what `packages/react/INVARIANTS.md`
173
+ // row 3 pins (`Both throw → undefined + console.error`).
174
+ //
175
+ // ⚠ **The fallback is also where the channel guard lands (#1572).** A route's
176
+ // declared query name handed in the PATH bag makes the class-① door throw
177
+ // where `buildPath` answers, so the `??` prints the literal path — the same
178
+ // href this arm has always rendered. Under a URL plugin the guard is not
179
+ // swallowed: `router.buildUrl` throws and the outer `catch` drops the href.
180
+ //
181
+ // ⚠ **The inner `try` keeps this helper's STRUCTURAL contract.** `buildHref`
182
+ // is handed a `Router`-shaped object, not necessarily a registered one, and
183
+ // `getPluginApi` resolves it through `getInternals` — a WeakMap keyed on
184
+ // identity, which REFUSES a test double or a `Proxy` wrapper. Such a router
185
+ // keeps the literal path; the stub-router CONTROL in
186
+ // `packages/react/tests/functional/dom-utils/forwarding-link-href-2250.test.ts`
187
+ // owns that.
188
+ let resolved;
189
+ try {
190
+ resolved = getPluginApi(router).buildNavigationState(routeName, routeParams, routeSearch)?.path;
191
+ }
192
+ catch {
193
+ resolved = undefined;
194
+ }
195
+ const path = resolved ?? router.buildPath(routeName, routeParams, routeSearch);
163
196
  // Symmetric to the buildUrl guard above (#S1 audit, Invariant 12).
164
197
  // `router.buildPath` is typed `string`, but defends against:
165
198
  // - `""` (empty string) — would render `<a href="">`, which resolves
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/svelte",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "description": "Svelte 5 integration for Real-Router",
6
6
  "svelte": "./dist/index.js",
@@ -48,12 +48,12 @@
48
48
  "license": "MIT",
49
49
  "sideEffects": false,
50
50
  "dependencies": {
51
- "@real-router/core": "^0.131.0",
51
+ "@real-router/core": "^0.132.0",
52
52
  "@real-router/route-utils": "^0.4.0",
53
- "@real-router/sources": "^0.14.38"
53
+ "@real-router/sources": "^0.14.39"
54
54
  },
55
55
  "devDependencies": {
56
- "@real-router/browser-plugin": "^0.22.18",
56
+ "@real-router/browser-plugin": "^0.23.0",
57
57
  "@sveltejs/package": "2.5.8",
58
58
  "@sveltejs/vite-plugin-svelte": "7.3.0",
59
59
  "@testing-library/jest-dom": "~6.9.1",