@real-router/svelte 0.19.2 → 0.20.1
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
|
|
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
|
|
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,46 @@ export function buildHref(router, routeName, routeParams, routeSearch, hash) {
|
|
|
159
160
|
return url;
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
|
-
|
|
163
|
+
// ⚑ RESOLVE, then print (#2250). An href is a promise about where the click
|
|
164
|
+
// lands, and the click resolves `forwardTo`. `router.buildPath` alone is
|
|
165
|
+
// class LITERAL by record and answers about the route it was NAMED —
|
|
166
|
+
// INVARIANTS #8 keeps that so a plugin can build a state for an alias
|
|
167
|
+
// without being teleported off it — so the chain is resolved FIRST and
|
|
168
|
+
// `buildPath` prints the target. The door choice belongs here rather than
|
|
169
|
+
// one layer down.
|
|
170
|
+
//
|
|
171
|
+
// ⚠ The `??` preserves the FAILURE shape, it is not a convenience: a name the
|
|
172
|
+
// table does not hold makes the class-① door answer `undefined` where
|
|
173
|
+
// `buildPath` THROWS, and that throw is what `packages/react/INVARIANTS.md`
|
|
174
|
+
// row 3 pins (`Both throw → undefined + console.error`).
|
|
175
|
+
//
|
|
176
|
+
// ⚠ **The fallback is also where the channel guard lands (#1572).** A route's
|
|
177
|
+
// declared query name handed in the PATH bag makes the class-① door throw
|
|
178
|
+
// where `buildPath` answers, so the `??` prints the literal path — the same
|
|
179
|
+
// href this arm has always rendered. Under a URL plugin the guard is not
|
|
180
|
+
// swallowed: `router.buildUrl` throws and the outer `catch` drops the href.
|
|
181
|
+
//
|
|
182
|
+
// ⚠ **The inner `try` keeps this helper's STRUCTURAL contract.** `buildHref`
|
|
183
|
+
// is handed a `Router`-shaped object, not necessarily a registered one, and
|
|
184
|
+
// `getPluginApi` resolves it through `getInternals` — a WeakMap keyed on
|
|
185
|
+
// identity, which REFUSES a test double or a `Proxy` wrapper. Such a router
|
|
186
|
+
// keeps the literal path; the stub-router CONTROL in
|
|
187
|
+
// `packages/react/tests/functional/dom-utils/forwarding-link-href-2250.test.ts`
|
|
188
|
+
// owns that.
|
|
189
|
+
let resolved;
|
|
190
|
+
try {
|
|
191
|
+
// ⚠ **`forwardState`, not `buildNavigationState`.** Both resolve the whole
|
|
192
|
+
// chain, and the href is identical — but the committing door opts into
|
|
193
|
+
// `reportUndeclaredParamKey`, and an href COMMITS NOTHING. That diagnostic
|
|
194
|
+
// is for a state you are about to persist, which is why `canNavigateTo`
|
|
195
|
+
// is silent despite sharing `navigate`'s form (#2248 / #1581).
|
|
196
|
+
const forwarded = getPluginApi(router).forwardState(routeName, routeParams, routeSearch);
|
|
197
|
+
resolved = router.buildPath(forwarded.name, forwarded.params, forwarded.search);
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
resolved = undefined;
|
|
201
|
+
}
|
|
202
|
+
const path = resolved ?? router.buildPath(routeName, routeParams, routeSearch);
|
|
163
203
|
// Symmetric to the buildUrl guard above (#S1 audit, Invariant 12).
|
|
164
204
|
// `router.buildPath` is typed `string`, but defends against:
|
|
165
205
|
// - `""` (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.
|
|
3
|
+
"version": "0.20.1",
|
|
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.132.
|
|
51
|
+
"@real-router/core": "^0.132.1",
|
|
52
52
|
"@real-router/route-utils": "^0.4.0",
|
|
53
53
|
"@real-router/sources": "^0.14.39"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@real-router/browser-plugin": "^0.
|
|
56
|
+
"@real-router/browser-plugin": "^0.23.1",
|
|
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",
|