@real-router/core 0.126.12 → 0.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Router-eWMVS_8K.js +2 -0
- package/dist/cjs/Router-eWMVS_8K.js.map +1 -0
- package/dist/cjs/RouterError-B-j6UqeF.js +2 -0
- package/dist/cjs/RouterError-B-j6UqeF.js.map +1 -0
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/helpers.d.ts +47 -0
- package/dist/cjs/helpers.d.ts.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils.d.ts +2 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/esm/Router-nxP6ZBhi.mjs +2 -0
- package/dist/esm/Router-nxP6ZBhi.mjs.map +1 -0
- package/dist/esm/RouterError-4CmDe8Nu.mjs +2 -0
- package/dist/esm/RouterError-4CmDe8Nu.mjs.map +1 -0
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/helpers.d.mts +47 -0
- package/dist/esm/helpers.d.mts.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils.d.mts +2 -1
- package/dist/esm/utils.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-BY8DeXYU.js +0 -2
- package/dist/cjs/Router-BY8DeXYU.js.map +0 -1
- package/dist/cjs/RouterError-CJMrktYx.js +0 -2
- package/dist/cjs/RouterError-CJMrktYx.js.map +0 -1
- package/dist/esm/Router-D-wuqT2v.mjs +0 -2
- package/dist/esm/Router-D-wuqT2v.mjs.map +0 -1
- package/dist/esm/RouterError-BNmwvKoa.mjs +0 -2
- package/dist/esm/RouterError-BNmwvKoa.mjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./ingest-C6HQ7xXf.js"),t=Object.freeze,n=Object.hasOwn,r=Object.keys,i=Object.getPrototypeOf,a=Array.isArray,o=Array.prototype.slice,s=`signal`;function c(t,n){if(t===void 0)return n;let i={};for(let n of r(t)){if(n===`__proto__`)continue;let r=t[n];r!==void 0&&e.a(i,n,r)}if(n!==void 0)for(let t of r(n)){if(t===`__proto__`)continue;let r=n[t];r!==void 0&&e.a(i,t,r)}return i}const l=new Set([`string`,`number`,`boolean`]);function u(e){return l.has(typeof e)}function d(e,t){if(e===t)return!0;if(Array.isArray(e)){let n=e.length;if(!Array.isArray(t))return n===1&&d(e[0],t);if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!d(e[r],t[r]))return!1;return!0}return Array.isArray(t)?t.length===1&&d(e,t[0]):u(e)&&u(t)&&String(e)===String(t)}function f(e,t){let n=r(e),i=r(t);if(n.length!==i.length)return!1;for(let r of n)if(!i.includes(r)||!d(e[r],t[r]))return!1;return!0}function p(e,t,n){if(n.length===0)return!0;let i=r(e),a=r(t);for(let r of n)if(!d(i.includes(r)?e[r]:void 0,a.includes(r)?t[r]:void 0))return!1;return!0}function m(e){return t(e)}function h(e,t,n){return e===void 0?t===void 0||t===n?n:t:c(e,t)}function g(t,n){return h(t,n,e.l)}function _(n,r){let i=h(n,r,e.u);return i===e.u?i:t(i)}function v(n,i){if(n==null||n===i)return i;let a={};for(let t of r(n)){if(t===`__proto__`)continue;let r=n[t];r!==void 0&&e.a(a,t,r)}return t(a)}function y(n){let i={};for(let s of r(n)){if(s===`__proto__`)continue;let r=n[s];r!==void 0&&e.a(i,s,a(r)?t(o.call(r)):r)}return t(i)}function b(n){let i={};for(let t of r(n)){if(t===`__proto__`)continue;let r=n[t];if(r!==void 0){if(t===`segments`){r!==null&&e.a(i,t,y(r));continue}e.a(i,t,r)}}return t(i)}function x(e){return n(e,s)?e.signal:void 0}function S(e,t){return n(e,t)?e[t]:void 0}function C(n){if(n===e.c)return e.c;let i={},a=n;for(let t of r(a))t!==`__proto__`&&t!==s&&e.a(i,t,a[t]);return t(i)}function w(t,n){if(t===void 0)return t;if(t===null)return n;let i;for(let n of r(t)){if(n===`__proto__`)continue;let r=t[n];r!==void 0&&(i??={},e.a(i,n,r))}return i??n}function T(e){if(e==null)return e;let t=i(e);return t===null||t===Object.prototype?{...e}:e}function E(t){return delete t[e.f],t}function D(e,n){if(typeof n!=`object`||!n)return n;try{let e=Array.isArray(n)?[...n]:{...n};return t(E(e))}catch(t){throw TypeError(`[router.constructor] Invalid "${e}": reading it threw.`,{cause:t})}}function O(t){if(!n(t,`__proto__`))return t;let i={};for(let n of r(t))n!==`__proto__`&&e.a(i,n,t[n]);return i}const k=Object.freeze,A=Object.entries,j=Object.values,M=Object.hasOwn,N=new Set(j(e.m)),P=new Set([`code`,`segment`,`path`]),F=new Set([`setCode`,`setErrorInstance`,`setAdditionalFields`,`hasField`,`getField`,`toJSON`]);function I(e){return k(e)}var L=class extends Error{segment;path;code;constructor(t,{message:n,segment:r,path:i,...a}={}){super(n??t),this.name=`RouterError`,this.code=t,this.segment=r,this.path=i;for(let[t,n]of A(a)){if(P.has(t))throw TypeError(`[RouterError] Cannot set reserved property "${t}"`);t!==`__proto__`&&!F.has(t)&&e.a(this,t,n)}}setCode(e){this.code=e,N.has(this.message)&&(this.message=e)}setErrorInstance(t){if(!t)throw TypeError(`[RouterError.setErrorInstance] err parameter is required and must be an Error instance`);this.message=t.message,e.a(this,`cause`,t.cause),this.stack=t.stack??``}setAdditionalFields(t){for(let[n,r]of A(t)){if(P.has(n))throw TypeError(`[RouterError.setAdditionalFields] Cannot set reserved property "${n}"`);n!==`__proto__`&&!F.has(n)&&e.a(this,n,r)}}hasField(e){return M(this,e)}getField(e){return M(this,e)?this[e]:void 0}toJSON(){let t={code:this.code,message:this.message};this.segment!==void 0&&(t.segment=this.segment),this.path!==void 0&&(t.path=this.path);let n=new Set([`code`,`message`,`segment`,`path`,`stack`,`name`]);for(let r in this)M(this,r)&&!n.has(r)&&e.a(t,r,this[r]);return t}};Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return O}});
|
|
2
|
+
//# sourceMappingURL=RouterError-B-j6UqeF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterError-B-j6UqeF.js","names":["freeze","hasOwn","EMPTY_PARAMS","EMPTY_SEARCH","EMPTY_OPTS","UNSAFE_KEY","errorCodes"],"sources":["../../src/helpers.ts","../../src/RouterError.ts"],"sourcesContent":["// packages/core/src/helpers.ts\n\nimport {\n EMPTY_OPTS,\n EMPTY_PARAMS,\n EMPTY_SEARCH,\n UNSAFE_KEY,\n} from \"./constants\";\nimport { putField } from \"./utils/ingest\";\n\nimport type { NavigationOptions, State, TransitionMeta } from \"./types\";\n\n/**\n * Intrinsics captured at module load: `freeze`, `hasOwn`, `objectKeys`.\n *\n * ⚑ A guard is only as strong as the intrinsic it reads WHEN IT RUNS, and an\n * application can re-point any of these AFTER boot — which is what this closes.\n * Measured on the uncaptured form: one naive `Object.hasOwn` polyfill walked\n * straight through five sibling readers while the single captured guard held.\n *\n * ⚠ The limit of what capture buys — and the shim order that defeats it — is\n * stated once, in `guards.ts`. Not restated here (#2091).\n */\nconst freeze = Object.freeze;\nconst hasOwn = Object.hasOwn;\n// ⚑ Captured for the same reason as its two siblings above, and it matters more\n// here than for either: since #1854 this is the OWN-NESS gate for both channels,\n// so an application that re-points `Object.keys` after boot would be re-pointing\n// the guard itself. The dependency door reads through a capture too, held by\n// `ingestDependencies` in `guards.ts` — `dependenciesStore` delegates to it and\n// captures nothing of its own.\nconst objectKeys = Object.keys;\nconst getPrototypeOf = Object.getPrototypeOf;\n// ⚑ Captured for the same reason as the four above, and it is the only one of\n// them that is not an `Object` member — so `captured-intrinsics-authority-1971`,\n// whose scan is scoped to `Object.<name>`, would not have asked for it. It\n// decides whether a slot of the committed `transition` is copied or carried, so\n// a re-pointed `Array.isArray` decides that instead (see\n// {@link adoptForeignSegments}).\nconst isArray = Array.isArray;\n// ⚑ And the COPY is taken with a captured method rather than by asking the\n// object, for the reason the copy exists at all: `entry.slice()` reads a method\n// off the caller's array and `[...entry]` reads its `Symbol.iterator`, so an own\n// property on either shadows the intrinsic and the \"copy\" is then whatever the\n// caller's function returned. Measured on a plain array with an own `slice`:\n// `entry.slice()` answers `[\"HIJACKED\"]`, this answers the real elements.\nconst arraySlice = Array.prototype.slice;\n/**\n * The one `NavigationOptions` key core's entry door withholds from its copy\n * (#1962). Typed as `keyof NavigationOptions` rather than written as a bare\n * literal, so renaming the field is a compile error here instead of a silently\n * preserved `signal` — the spelling is not the thing being named, the FIELD is.\n */\nconst SIGNAL_KEY: keyof NavigationOptions = \"signal\";\n/**\n * The one `TransitionMeta` key whose value is itself a container core owns\n * (#2140) — typed for the same reason as {@link SIGNAL_KEY} above: the FIELD is\n * what is being named, so renaming it in `TransitionMeta` is a compile error\n * here rather than an adoption that silently stops reaching one level down.\n */\nconst SEGMENTS_KEY: keyof TransitionMeta = \"segments\";\n// =============================================================================\n// Default merge — `undefined` ≡ absence (#1550 / #1551)\n// =============================================================================\n\n/**\n * Merges a route default UNDER a value (the value wins), treating `undefined` as\n * **absence on both sides** (#1550 / #1551).\n *\n * When there IS a default, a key survives only when its winning value is\n * defined:\n * - `mergeDefined({ page: \"1\" }, { page: undefined })` → `{ page: \"1\" }` — an\n * explicit `undefined` from the caller does not outrank the default (this is\n * what the path channel always did via `normalizeChannel`, and what the query\n * channel did not, #1550);\n * - `mergeDefined({ q: undefined }, undefined)` → `{}` — a default that itself\n * carries `undefined` behaves exactly like no default entry, instead of\n * leaking an `undefined`-valued own key into the frozen state (#1551).\n *\n * Because the rule lives in the merge rather than in a separately-ordered\n * \"normalize\" stage, it holds for every producer and cannot be reintroduced by\n * whichever side is merged last.\n *\n * Allocation contract: **returns the `value` argument itself** when there is no\n * default, so a caller that freezes or stores the result must copy it first.\n * `undefined` in ⇒ `undefined` out then too, which keeps the matcher's\n * single-bag fallback (`search ?? params`) reachable.\n */\nexport function mergeDefined<T extends Record<string, unknown>>(\n defaultValue: T,\n value: T | undefined,\n): T;\n\nexport function mergeDefined<T extends Record<string, unknown>>(\n defaultValue: T | undefined,\n value: T,\n): T;\n\nexport function mergeDefined<T extends Record<string, unknown>>(\n defaultValue: T | undefined,\n value: T | undefined,\n): T | undefined;\n\nexport function mergeDefined<T extends Record<string, unknown>>(\n defaultValue: T | undefined,\n value: T | undefined,\n): T | undefined {\n if (defaultValue === undefined) {\n return value;\n }\n\n const merged: Record<string, unknown> = {};\n\n // ⚑ `Object.keys`, for the reason `normalizeChannel` above carries (#1854) —\n // and this door is the SIBLING, found by probing it rather than by reasoning\n // from the other one. A route's `defaultParams` / `defaultSearch` is a bag the\n // application still holds and may be Proxy-backed. Measured on the\n // descriptor-reading form: a lying `getOwnPropertyDescriptor` puts an\n // inherited key into `state.params` while `state.path` prints without it —\n // the same state-contradicts-its-own-URL outcome, one function away.\n for (const key of objectKeys(defaultValue)) {\n // Dropped from the published channel, same rule as the entry guard (#1852).\n //\n // ⚠ UNREACHABLE from every current caller, and kept anyway. `defaultValue`\n // reaches this loop from exactly three places — `mergeOwnChannel` and the\n // two `forwardState` hops in `RoutesNamespace` — and all three read it out\n // of `store.config.defaultParams` / `.defaultSearch`, which since #2172 hold\n // core-minted copies that `copyOwnData` already stripped. Measured by\n // coverage rather than argued: the suite does not reach this line.\n //\n // ⚑ It is defence in depth at a boundary, not dead code, and the\n // distinction is the dependency: what makes it unreachable is a guarantee\n // held by ANOTHER function. A fourth caller that hands this loop a bag from\n // somewhere else, or an adoption door that stops dropping the key, makes it\n // live again with no signal here.\n /* v8 ignore next 3 -- @preserve: see above; unreachable via the adoption door, not via this function's own contract */\n if (key === UNSAFE_KEY) {\n continue;\n }\n\n // One read here too: a route default is a bag the app still holds.\n const entry = defaultValue[key];\n\n if (entry !== undefined) {\n putField(merged, key, entry);\n }\n }\n\n if (value !== undefined) {\n // ⚑ `objectKeys`, one spelling across every copy loop in this file.\n //\n // What the spelling buys: `Object.keys` asks `ownKeys` FIRST and consults\n // descriptors only for what that returned. A `for…in` + `hasOwn` pair asks\n // the bag about a key the walk already chose, and on a Proxy that is a trap\n // free to vouch for a key `ownKeys` never listed — #1854.\n //\n // ⚠ Do NOT read that as \"nothing foreign reaches these loops\". This one has a\n // SECOND caller (`#layerChainDefaults`) handing it a raw bag from the caller\n // and from the matcher; the `UNSAFE_KEY` skip below is live because of it,\n // measured. `objectKeys` closes the own-ness question, not the provenance\n // one.\n for (const key of objectKeys(value)) {\n // ⚠ LIVE, and \"dead by construction because `value` always arrives\n // through `normalizeChannel`\" is a REACHABILITY argument — the kind this\n // repository records as having been wrong repeatedly.\n //\n // The second caller is `RoutesNamespace.#layerChainDefaults`, which merges\n // a `forwardTo` hop's own defaults with the caller's bag AND with the\n // MATCHER's bag. Measured on a chain whose hop carries `defaultParams` /\n // `defaultSearch`: the merged record comes back with `__proto__` among its\n // own keys on BOTH directions — including the URL one, where the value is\n // whatever the address bar said — and every `forwardState` interceptor\n // receives it.\n if (key === UNSAFE_KEY) {\n continue;\n }\n\n // ONE read, both decisions from it. Asking and then taking would be two\n // calls into the caller's accessor, and a bag that answers differently\n // between them lands `undefined` in a frozen channel — the same shape\n // {@link adoptForeignBag}'s copy loop names, on the defaulted path.\n const entry = value[key];\n\n // `undefined` means \"I said nothing\", so the default keeps the slot.\n if (entry === undefined) {\n continue;\n }\n\n putField(merged, key, entry);\n }\n }\n\n return merged as T;\n}\n\n// =============================================================================\n// Param value comparison (#1554)\n// =============================================================================\n\n/** The value types a channel prints into (and parses back from) a URL. */\nconst PRINTABLE_TYPES = new Set([\"string\", \"number\", \"boolean\"]);\n\n/** A value the two channels can carry across a URL round-trip. */\nfunction isPrintableScalar(value: unknown): value is string | number | boolean {\n return PRINTABLE_TYPES.has(typeof value);\n}\n\n/**\n * Compares two param / query values for equality **independently of where they\n * came from** (#1554).\n *\n * The two directions produce different value DOMAINS for the same location: the\n * URL direction parses (`?page=2` → `2`, `?a=1&a=2` → `[1, 2]`, a path slot is\n * always a string), the intent direction keeps whatever the caller supplied\n * (`{ page: \"2\" }` stays a string). Both build the SAME `state.path`, so a\n * `===`-based comparison reported a URL-derived state and an intent-derived\n * state on one location as UNEQUAL — an active link rendered inactive.\n *\n * The rule is therefore \"equal when both values print the same query string\":\n * - **scalars** (string / number / boolean) compare by their printed form, so\n * `2 ≡ \"2\"` and `true ≡ \"true\"`;\n * - **arrays** compare element-wise under the same rule, and a **singleton\n * array** compares against a bare scalar (`[\"1\"]` and `1` both print `?a=1`);\n * - everything else (`null`, `undefined`, objects) keeps strict semantics —\n * those print differently (`?a` vs `?a=` vs nothing at all), so tolerating\n * them would equate genuinely different URLs.\n *\n * Value normalization is deliberately NOT done: `state.search` keeps the mixed\n * domain (RFC-4 M2 / §10.14 decision (b)) and comparison is the single place\n * that knows the two domains describe the same location. Unifying the domain\n * itself belongs to the typed search-schema stage.\n */\nexport function areParamValuesEqual(val1: unknown, val2: unknown): boolean {\n if (val1 === val2) {\n return true;\n }\n\n if (Array.isArray(val1)) {\n // ⚑ ONE read of the length (#2085). `Array.isArray` answers TRUE through a\n // Proxy — a reactive array is exactly that shape — so the guard above does\n // not make this slot plain data, and the equality test and the loop bound\n // are two consumers of one answer. It also gives the walk a local bound.\n const length1 = val1.length;\n\n // A singleton array prints exactly like its element (`[\"1\"]` and `1` both\n // print `?a=1`), so compare across the shape instead of rejecting on it.\n if (!Array.isArray(val2)) {\n return length1 === 1 && areParamValuesEqual(val1[0], val2);\n }\n\n if (length1 !== val2.length) {\n return false;\n }\n\n for (let i = 0; i < length1; i++) {\n if (!areParamValuesEqual(val1[i], val2[i])) {\n return false;\n }\n }\n\n return true;\n }\n\n if (Array.isArray(val2)) {\n return val2.length === 1 && areParamValuesEqual(val1, val2[0]);\n }\n\n return (\n isPrintableScalar(val1) &&\n isPrintableScalar(val2) &&\n String(val1) === String(val2)\n );\n}\n\n/**\n * Shallow key/value equality of two param-like records (path params or query),\n * using {@link areParamValuesEqual} per key so array values compare by content.\n *\n * Both readers need the SAME comparison and it is built on the function above,\n * so it lives beside it: `StateNamespace.areStatesEqual` uses it for state\n * IDENTITY (both channels, whole bags — #515 / #478), and `isActiveRoute`'s\n * exact arm for the query half of a LOCATION (#1978).\n *\n * ⚑ Membership is decided by the LIST the count already produced (#1815), never\n * by a second interrogation of the bag. `key in right`, `hasOwn(right, key)` and\n * `propertyIsEnumerable.call(right, key)` are one family — the caller picks the\n * key and the bag is asked about THAT key: `in` through `[[HasProperty]]`, the\n * other two through `[[GetOwnProperty]]`. On a Proxy each is a trap (`has`,\n * `getOwnPropertyDescriptor`) free to vouch for a key `ownKeys` never listed,\n * while `objectKeys` asks `ownKeys` first and consults descriptors only for what\n * it returned. That is the #1854 argument, and it applies here for the same\n * reason: the count is `objectKeys`, so anything that answers a different\n * question can disagree with it, and a bag whose own-enumerable surface is\n * DISJOINT from the other side's then compares equal.\n *\n * ⚠ A linear scan per key, so this is O(n²) in bag width where the `in` form was\n * O(n) — a deliberate trade, and the crossover was measured rather than assumed.\n * Against `in`: 0.9–1.1× up to n = 20, 2.8× at n = 200, 9.6× at n = 1000. A `Set`\n * is the O(n) alternative and was rejected because it costs a FLAT 1.4–1.5×\n * everywhere and 2.5× at n = 1, which is the width these bags actually have.\n * `state.params` is bounded by the route's slots; `state.search` is bounded by\n * the URL, so a query string a browser will carry lands around n = 200, i.e.\n * inside the regime where the two forms are within noise of each other.\n */\nexport function recordsShallowEqual(\n left: Readonly<Record<string, unknown>>,\n right: Readonly<Record<string, unknown>>,\n): boolean {\n const leftKeys = objectKeys(left);\n const rightKeys = objectKeys(right);\n\n if (leftKeys.length !== rightKeys.length) {\n return false;\n }\n\n for (const key of leftKeys) {\n if (\n !rightKeys.includes(key) ||\n !areParamValuesEqual(left[key], right[key])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * {@link recordsShallowEqual} restricted to the slots a route declares: the two\n * bags may carry anything else, and only these keys are compared.\n *\n * `StateNamespace.areStatesEqual` asks this on its default arm, where the route\n * names the path slots and the query channel is out of scope.\n *\n * ⚑ A slot the key list does not vouch for reads as `undefined` — the same\n * value an absent slot has — so a bag carrying the slot as `undefined` compares\n * equal to one omitting it. The whole-bag reader disagrees there by design: it\n * gates on key COUNT, and the two bags have different surfaces.\n */\nexport function slotsShallowEqual(\n left: Readonly<Record<string, unknown>>,\n right: Readonly<Record<string, unknown>>,\n slots: readonly string[],\n): boolean {\n // Above the key lists, not below: a route declaring no slot has nothing to\n // compare, and this must not touch either bag to say so — building the lists\n // first turns an answer into a THROW for a state that omits `params`.\n if (slots.length === 0) {\n return true;\n }\n\n const leftKeys = objectKeys(left);\n const rightKeys = objectKeys(right);\n\n for (const slot of slots) {\n if (\n !areParamValuesEqual(\n leftKeys.includes(slot) ? left[slot] : undefined,\n rightKeys.includes(slot) ? right[slot] : undefined,\n )\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n// =============================================================================\n// State Helpers\n// =============================================================================\n\n/**\n * Freezes the State object's own level — the SHELL, not the state.\n *\n * The name says SHELL because that is the whole depth (#1599): it blocks\n * reassignment of every field the `State` interface declares, and nothing more.\n *\n * **The depth is a POLICY, not this function's job: every object is frozen once,\n * where it is created.** That is deliberate and measured — re-freezing an\n * already-frozen object costs ~8 ns, so a recursive walk would pay per node for\n * work its producers already did. The four producers and what each owns:\n *\n * - `params` — {@link materialize} at the publication boundary, and nowhere else\n * no merge to freeze it, so `pipeline/materialize` does at the publication\n * boundary (#1598), for the frozen and the pending producer alike\n * - `search` — the `EMPTY_SEARCH` singleton, or `admittedSearch`\n * (`channels/modeGate.ts`) on its DROP branch, the one branch that builds a bag\n * the caller did not already freeze\n * - `transition` + nested — `buildTransitionMeta()` (or inline in\n * `navigateToNotFound()`), and {@link adoptForeignTransition} for the one\n * producer whose meta core did not build: the state `systemCommit` is handed\n * from outside, where there IS no origin to have frozen it\n * - the shell — here\n *\n * `state.context` is **intentionally not frozen** — plugins write to it via\n * `claim.write(state, value)` after state creation.\n *\n * The whole matrix is pinned black-box in\n * `tests/functional/error/helpers.test.ts` (\"state immutability across every\n * producer\"), mutationally validated against all four sites. Before #1599 two of\n * them were unguarded: deleting the `canonicalize` freeze left the entire suite\n * green, and the mode gate's freeze was reachable only under a non-`loose` mode\n * with one key dropped AND one admitted.\n *\n * @internal\n */\nexport function freezeStateShell<T extends State>(state: T): T {\n // No `if (!state) return state` guard: `Object.freeze` returns non-objects\n // (incl. null/undefined) unchanged, every caller reaches here with a state in\n // hand (the commit `update` on the table, `materialize`'s publication\n // boundary), and `T extends State` is typed non-null.\n return freeze(state);\n}\n\n/**\n * The shared half of the two channel merges: a route default UNDER a value the\n * PIPELINE minted, with the channel's own `empty` singleton (#1027) reused when\n * neither side has anything — so the hot path allocates zero objects.\n *\n * `undefined` is absence on BOTH sides (`mergeDefined`, #1550 / #1551): an\n * explicitly-`undefined` caller value leaves the default in place, and a default\n * carrying `undefined` behaves like no entry.\n *\n * ⚑ It does NOT freeze and it does NOT copy, and both follow from the ONE thing\n * its callers have in common: `value` is the object `normalizeChannel` returned\n * one line earlier, so nothing outside holds a reference to protect and each\n * channel's own publication rule decides the freeze. A bag that came from\n * somewhere else must go through {@link adoptForeignBag} instead. The two are\n * separate functions because they share no caller, and because the split is\n * already visible in the parameters rather than needing a flag to name it.\n */\nfunction mergeOwnChannel(\n defaultValue: Record<string, unknown> | undefined,\n value: Record<string, unknown> | undefined,\n empty: Readonly<Record<string, never>>,\n): Readonly<Record<string, unknown>> {\n if (defaultValue !== undefined) {\n return mergeDefined(defaultValue, value);\n }\n\n if (value === undefined || value === empty) {\n return empty;\n }\n\n return value;\n}\n\n/**\n * Stage ③ for the PATH channel — and it hands the bag back UNFROZEN.\n *\n * `materialize` owns this freeze, at the publication boundary and nowhere else\n * (#1598 / #1928). A second freeze here would certify nothing a consumer can\n * observe — every `Canonical` that becomes a State is frozen by `materialize`,\n * and the ones that do not become a State are discarded — while splitting the\n * channel into a frozen form on a route with defaults and a live one without.\n * `canonicalize.properties.ts` holds the line: the only frozen thing this stage\n * may hand back on this channel is the shared `EMPTY_PARAMS` singleton.\n *\n * @internal\n */\nexport function mergePathChannel(\n defaultParams: Record<string, unknown> | undefined,\n bag: Record<string, unknown> | undefined,\n): Readonly<Record<string, unknown>> {\n return mergeOwnChannel(defaultParams, bag, EMPTY_PARAMS);\n}\n\n/**\n * Stage ③ for the QUERY channel — and this one DOES freeze, which is the\n * asymmetry with {@link mergePathChannel}.\n *\n * ⚠ **The asymmetry is PERF-GATED, and nothing but that gate holds it.**\n * Correctness does not: with this freeze removed and `freeze(state.search)`\n * added to `materialize` beside `params`, the whole suite is GREEN.\n * `materialize` is below every hop that could publish, so the publication\n * guarantee survives the move.\n *\n * What the move costs is now MEASURED on this shape, and the cited figure was\n * pointing at the wrong arm. Alternating A/B processes, 9 pairs, medians, with\n * an A/A control interleaved (`isActiveRoute-sibling` early-outs above\n * `canonicalize` and must not move — it did not, −0.5 % against a ±0.7 % floor):\n *\n * arm merge (now) materialize delta A/A floor\n * isActiveRoute-exact 215.8 219.3 +1.6 % ±1.6 % noise\n * isActiveRoute-parent 131.5 139.9 +6.3 % ±0.9 % REGRESSION\n * buildPath-params 460.8 444.0 −3.6 % ±0.8 % gain\n * canNavigateTo 781.2 783.4 +0.3 % ±0.4 % noise\n *\n * ⚠ #1598 named `isActiveRoute-exact` at 9.8 %. On this shape that arm is inside\n * the noise floor and the cost has MOVED to `parent` at 6.3 % — which is why the\n * figure had to be re-taken rather than cited: it was measured when the merge\n * froze BOTH channels, and #1928 ended that.\n *\n * The mechanism is the short-circuit below. On `parent` the query bag IS the\n * `EMPTY_SEARCH` singleton, so this function returns it untouched while\n * `materialize` would re-freeze it — the ~8 ns #1598 identified, landing on a\n * different arm than it recorded. `buildPath` never materialises, so under the\n * move it stops paying any freeze at all: that is the −3.6 %, and it is real but\n * does not buy back a render-path predicate.\n *\n * So the split stands, on a measurement rather than on a citation. Numbers are\n * tsx-against-`src`, i.e. comparable to each other, not to a `dist` absolute.\n *\n * @internal\n */\nexport function mergeQueryChannel(\n defaultSearch: Record<string, unknown> | undefined,\n bag: Record<string, unknown> | undefined,\n): Readonly<Record<string, unknown>> {\n const merged = mergeOwnChannel(defaultSearch, bag, EMPTY_SEARCH);\n\n // The singleton is frozen by construction, and re-freezing costs the same\n // ~8 ns the paragraph above is about.\n //\n // ⚑ EQUIVALENT under mutation, and declared rather than left as a silent\n // survivor: replacing this with a plain `freeze(merged)` reds NOTHING in the\n // package suite. It cannot — re-freezing an already-frozen object is a\n // no-op observationally, so only a benchmark can tell the two apart. And one\n // did: this branch is exactly what makes `isActiveRoute-parent` 6.3 % cheaper\n // here than at the publication boundary, because on that arm the bag IS the\n // singleton. Behaviourally equivalent, NOT perf-equivalent — do not\n // \"simplify\" it back on the strength of a green suite.\n return merged === EMPTY_SEARCH ? merged : freeze(merged);\n}\n\n/**\n * Adopts a bag the router does NOT own: strips `undefined`-valued keys, drops\n * `UNSAFE_KEY`, copies, and freezes the copy.\n *\n * The five call sites are `navigateToState` and `systemCommit`, which copy a\n * `State` handed in through a published API (#1792). None of them merges a\n * default — that is the other half of the split described on\n * {@link mergeOwnChannel} — so there is no `defaultValue` parameter to pass\n * `undefined` to five times over.\n *\n * ⚠ Every step here exists because the object is foreign: freezing in place\n * would freeze the caller's own bag, committing it by reference would let the\n * caller mutate a published state, and skipping the key drop would carry an own\n * `__proto__` into it.\n *\n * @internal\n */\nexport function adoptForeignBag(\n value: Record<string, unknown> | undefined,\n empty: Readonly<Record<string, never>>,\n): Readonly<Record<string, unknown>> {\n // ⚠ `null` is here for the reason the FOREIGN in this function's name is:\n // the declared type says the slot is filled, and a bag the router does not\n // own is exactly what is free to disagree — an interceptor spreading a\n // partial result nulls a slot, the same producer `Router`'s codec seam names.\n // Without it `Object.keys` performs `ToObject` and `navigateToState` rejects\n // with a bare `TypeError`, carrying no code to classify (#1822).\n //\n // `== null` is the intent, the spelling `Router` already uses for it: both\n // nullish values mean \"there is no bag\".\n if (value == null || value === empty) {\n return empty;\n }\n\n // ⚑ ONE walk, and the count is the contract (#1952). `objectKeys` materialises\n // the key list before any accessor on the bag runs, so a getter that DEFINES a\n // sibling key mid-walk — `__proto__`, or an `undefined`-valued one — adds a key\n // this loop never visits. A second walk re-asks `ownKeys` and does see it, so\n // with one walk the two guards below answer for the ordinary case only.\n //\n // ⚠ They still answer for it. A bag that CARRIES `__proto__`, or a key whose\n // value is `undefined`, is in the first snapshot like any other, and the\n // guards are what keep it out of a published channel — mutate either and\n // `proto-key-guarantee` / `undefined-as-absent` red (#1792, #1550 / #1551).\n const copy: Record<string, unknown> = {};\n\n for (const key of objectKeys(value)) {\n // Dropped from the published channel, same rule as the entry guard (#1852).\n if (key === UNSAFE_KEY) {\n continue;\n }\n\n // ONE read, then both decisions from it — a second `value[key]` here would\n // be a second call into the caller's accessor, which `read-count-authority`\n // pins and which is the whole hazard this file is about.\n const entry = value[key];\n\n if (entry !== undefined) {\n putField(copy, key, entry);\n }\n }\n\n return freeze(copy);\n}\n\n/**\n * The nested half of {@link adoptForeignTransition}: `segments` and the arrays\n * it holds, which are STATE SHAPE rather than caller values.\n *\n * The line between the two is measured, not preferred. On the pipeline's own\n * arc `buildTransitionMeta` freezes this container AND both of its arrays,\n * while an array sitting in a param SLOT (`params.tags`) comes back from\n * `navigate` as the caller's own object, unfrozen. So every producer already\n * agrees on where a foreign object stops being core's business, and this copies\n * exactly as deep as the declared shape goes.\n *\n * An array is copied rather than frozen in place, for the reason\n * {@link adoptForeignBag} gives for copying at all: freezing it would seal an\n * object the caller still holds. The copy is taken with the captured\n * `arraySlice`, so the caller does not get to decide what its own copy contains.\n */\nfunction adoptForeignSegments(\n value: Record<string, unknown>,\n): Readonly<Record<string, unknown>> {\n const copy: Record<string, unknown> = {};\n\n for (const key of objectKeys(value)) {\n if (key === UNSAFE_KEY) {\n continue;\n }\n\n const entry = value[key];\n\n if (entry !== undefined) {\n putField(\n copy,\n key,\n isArray(entry) ? freeze(arraySlice.call(entry)) : entry,\n );\n }\n }\n\n return freeze(copy);\n}\n\n/**\n * Adopts a `TransitionMeta` the router does NOT own — {@link adoptForeignBag}'s\n * rule applied to BOTH levels the shape declares, because `Object.freeze` is\n * shallow and the level below the meta is a container too (#2140).\n *\n * Its one call site is `EventBusNamespace.systemCommit`, the single door a\n * `State` enters core through from outside.\n *\n * ⚠ It walks the caller's bag ONCE, like its sibling, and the nested slot is\n * adopted from the value that walk already read. Reading `value.segments` again\n * to adopt it would be a second call into a caller accessor — the divergence\n * where the container is judged on one answer and committed from another.\n * `read-count-authority`'s `systemCommit · transition` and\n * `systemCommit · transition.segments` rows are what hold both levels at one.\n *\n * ⚠ Nullish is absence on the nested slot, both spellings, for the reason\n * {@link adoptForeignBag} spells out for its own `== null` guard: written\n * unconditionally the slot would hold that guard's empty answer, which is a\n * SHARED singleton — so `getState().transition.segments` would be the same\n * object as some other state's `params`, under a type that declares\n * `deactivated`, `activated` and `intersection` as required.\n */\nexport function adoptForeignTransition(\n value: Record<string, unknown>,\n): Readonly<Record<string, unknown>> {\n const copy: Record<string, unknown> = {};\n\n for (const key of objectKeys(value)) {\n if (key === UNSAFE_KEY) {\n continue;\n }\n\n const entry = value[key];\n\n if (entry === undefined) {\n continue;\n }\n\n if (key === SEGMENTS_KEY) {\n if (entry !== null) {\n putField(\n copy,\n key,\n adoptForeignSegments(entry as Record<string, unknown>),\n );\n }\n\n continue;\n }\n\n putField(copy, key, entry);\n }\n\n return freeze(copy);\n}\n\n/**\n * Core's own copy of the caller's `NavigationOptions`, made once at the entry\n * door (#1962) — every own enumerable key, minus `signal`, into a frozen record.\n *\n * ⚑ **Every own enumerable key, not the declared ones** — owner decision,\n * 2026-08-30, recorded in `CLAUDE.md` \"Supported Input Shapes\". Curating to \"the\n * declared fields\" is not expensive, it is INEXPRESSIBLE: `NavigationOptions` is\n * extended by module augmentation (`hash` / `hashChange` / `source`, three URL\n * plugins), and augmentation leaves nothing in the emitted JS to normalise\n * against — a curating copy could only hold a list hard-coded when it was\n * written, going stale against the contract in silence.\n *\n * ⚑ `signal` is the one key dropped, and dropping it HERE is what removes the\n * defect rather than moving it: dropping it any later makes whether a plugin\n * receives the app's own object or a copy turn on whether the app happened to\n * pass a signal — a discriminator the plugin never sees. Core reads it once at\n * the entry\n * and carries it as `NavigationContext.externalSignal`, which is the only form\n * the machine may ask about (#1690 / #1717); nothing downstream reads\n * `opts.signal`, so the key has no reader left to lose.\n *\n * ⚠ `UNSAFE_KEY` goes too, and that is the HAND-OUT rule acting on this object\n * rather than a second decision: this copy IS what every plugin hook receives,\n * so an own `\"__proto__\"` on it is a prototype-swap primitive for anything that\n * merges it with `Object.assign` (#1957). Entry and hand-out coincide here, so\n * the drop happens once.\n *\n * ⚠ It reads each key EXACTLY once — the rule `opts-read-once-1817` pins for the\n * named flags, extended by this copy to keys core never names. Every read below\n * the door is then a read of core's own data, so the six hoisted flags cost the\n * caller's accessors nothing at all.\n *\n * ⚠ **A key loop, and the cheaper spread is REFUTED rather than merely\n * disliked.** `{ signal: _, ...rest }` measured 27 ns against this loop's 120\n * on the four-key bag a URL plugin actually sends — and it READS `opts.signal`\n * to exclude it, which is a second call into the caller's accessor. That is\n * exactly what `commit-gate-reads-the-snapshot-1717` counts: it caught the\n * substitution at `readsAtAnnounce` 2 instead of 1. Any spread reads every key,\n * so skipping one WITHOUT reading it is what forces the loop.\n *\n * ⚑ `putField` inside it, then, for the ordinary reason (#1852): the key is the\n * caller's, the target has `Object.prototype` on its chain, and a plain\n * `[[Set]]` under a name like `toString` is divertible by an ambient accessor.\n *\n * ⚠ **Not folded into the channel copy loops, which it nearly repeats.** They\n * differ on `undefined`: a channel drops an `undefined`-valued key because a\n * frozen `state.search` may never expose one (#1550 / #1551), and this one keeps\n * it because `{ replace: undefined }` is what the caller wrote. Folding them\n * needs a skip-set or a flag, and this file carries neither: `mergePathChannel`,\n * `mergeQueryChannel` and `adoptForeignBag` are named copies with different\n * rules, not one with switches (#1928).\n *\n * @internal\n */\n/**\n * The caller's `signal` slot, read OWN and once (#2132).\n *\n * ⚑ The gate the five sibling flags carry inline at the entry — this one needs\n * its own home because it is read somewhere else. The copy deliberately skips\n * `signal` without reading it (#1717), and the entry reads the slot ABOVE the\n * copy by #1817's order, so this read asks the CALLER's object rather than\n * core's, where an inherited `signal` would cancel a navigation nobody asked to\n * cancel.\n *\n * ⚠ Its own function because the branch pushes `executeNavigation` past the\n * cognitive-complexity gate inline — inlining it back reds lint.\n *\n * @internal\n */\nexport function ownSignal(opts: NavigationOptions): AbortSignal | undefined {\n return hasOwn(opts, SIGNAL_KEY) ? opts.signal : undefined;\n}\n\n/**\n * One own-gated flag of `NavigationOptions` (#2132).\n *\n * ⚑ A function rather than five inline ternaries because inline they push\n * `executeNavigation` from 15 to 20 on the cognitive-complexity gate. It returns\n * a VALUE and allocates nothing — the shape the entry's own docblock warns about\n * is a helper returning the whole block, which has to allocate a record.\n */\nexport function ownFlag<K extends keyof NavigationOptions>(\n opts: NavigationOptions,\n key: K,\n): NavigationOptions[K] | undefined {\n return hasOwn(opts, key) ? opts[key] : undefined;\n}\n\nexport function adoptNavigationOptions(\n opts: NavigationOptions,\n): Readonly<NavigationOptions> {\n // `navigate(\"b\")` is the commonest call there is, and the facade substitutes\n // this exact singleton for it — already core's own, already frozen, already\n // empty. Recognising it by identity is the difference between one comparison\n // and a copy plus a freeze (~57 ns measured) on the majority of navigations.\n if (opts === EMPTY_OPTS) {\n return EMPTY_OPTS;\n }\n\n const copy: Record<string, unknown> = {};\n const bag = opts as Record<string, unknown>;\n\n for (const key of objectKeys(bag)) {\n // `signal` is skipped WITHOUT being read — core already holds the entry\n // snapshot, and reading it again here is the very thing #1717 pins.\n if (key === UNSAFE_KEY || key === SIGNAL_KEY) {\n continue;\n }\n\n putField(copy, key, bag[key]);\n }\n\n return freeze(copy);\n}\n\n// =============================================================================\n// Params Helpers\n// =============================================================================\n\n/**\n * Strips `undefined` values from a params object before handoff to the query\n * string engine and state storage.\n *\n * **Why this exists:** `router.navigate(name, { x: undefined })` must not put\n * `x` into the resulting URL (publicly documented contract). The underlying\n * query engine (`search-params`) already does this, but the contract belongs\n * to `@real-router/core` — this function guarantees it at the core boundary\n * so that:\n * - Plugin interceptors on `forwardState` that inject `undefined` values are\n * caught before they reach the engine\n * - `state.params` never contains `undefined` values (roundtrip consistent\n * with URL)\n * - The contract is verifiable at core's own test surface (doesn't depend on\n * engine behavior for regression detection)\n *\n * Single pass. When nothing survives (empty input, or every value `undefined`)\n * it returns the shared frozen `EMPTY_PARAMS` singleton, so the merge's\n * `value === empty` reuse branch (the channel merges) fires and an empty-params\n * navigation allocates zero transient `{}` (#1027); a non-empty input returns a fresh\n * object. Either way reference identity is not preserved across calls, and the\n * result MUST be treated as read-only — callers must not mutate it (the empty\n * case is a shared frozen singleton).\n */\nexport function normalizeChannel<T extends Record<string, unknown>>(\n bag: T,\n empty: Readonly<Record<string, never>>,\n): T;\n\nexport function normalizeChannel(\n bag: undefined,\n empty: Readonly<Record<string, never>>,\n): undefined;\n\nexport function normalizeChannel<T extends Record<string, unknown>>(\n bag: T | undefined,\n empty: Readonly<Record<string, never>>,\n): T | undefined;\n\nexport function normalizeChannel<T extends Record<string, unknown>>(\n bag: T | undefined,\n empty: Readonly<Record<string, never>>,\n): T | undefined {\n if (bag === undefined) {\n return bag;\n }\n\n // ⚠ The OTHER spelling of an absent bag, and it does not get the arm above:\n // `undefined` passes through so a caller can still tell \"no bag\" from \"empty\n // bag\", while `null` arrives only as runtime misuse of a slot the signature\n // types optional. It normalises to the same answer `{}` gets. Without the arm\n // `Object.keys` performs `ToObject`, and the two render-path doors express\n // that one throw differently: `buildPath` lets a bare `TypeError` out, and\n // `isActiveRoute`'s safety net catches it and calls a link to the CURRENT\n // page inactive (#1822).\n //\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- runtime null guard for buildPath(name, null)\n if (bag === null) {\n return empty as unknown as T;\n }\n\n let normalized: Record<string, unknown> | undefined;\n\n // ⚑ `Object.keys`, not `for…in` + `Object.hasOwn` (#1854). `hasOwn` is\n // `[[GetOwnProperty]]`, which on a Proxy is the `getOwnPropertyDescriptor`\n // TRAP — and the caller of `hasOwn` chooses the key, so the trap is asked\n // about one it is free to lie about. The Proxy invariants permit exactly that\n // while the target is extensible and the descriptor is `configurable`.\n // `Object.keys` asks `ownKeys` FIRST and consults descriptors only for keys\n // `ownKeys` already vouched for, so a key the target does not own is never put\n // to the trap.\n //\n // ⚠ Not a hypothetical bag: Svelte 5's `$props()` reports own-ness for a key\n // only its prototype has, on every `RouteView` render (#1853) — nobody wrote a\n // Proxy, the framework did. Measured through this door before the change: an\n // inherited `leaked` reached `state.params` while `state.path` printed without\n // it, i.e. a committed state contradicting its own URL.\n //\n // ⚠ The ambient half is NOT part of this, measured rather than assumed: an\n // enumerable `Object.prototype.x` was already filtered correctly here, because\n // `hasOwn` is honest about an object that does not lie. Only the trap shape\n // was ever admitted.\n //\n // Cost, same-session A/B, medians, noisy at the ±3 ns level: a wash on an\n // empty bag, ~8 ns cheaper at one key, ~equal at three. One read per key\n // either way.\n for (const key of objectKeys(bag)) {\n // ⚑ The key is DROPPED from the published channel, and that is a decision\n // SEPARATE from how the write is performed (#1852). `putField` below closes\n // the ambient-accessor class for every name — `id`, `tab`, `lang` — and this\n // skip closes a different one, on the far side of the contract: a bag core\n // hands BACK carrying an own `\"__proto__\"` is a prototype-swap primitive for\n // any consumer that merges it with `Object.assign` or a `for…in` copy.\n // Measured from a bare URL: `?__proto__` yields `null` and\n // `?__proto__=1&__proto__=2` an array, and the inherited setter accepts both.\n //\n // ⚑ Core's OWN precedent, not a fresh judgement. `getDependenciesApi.getAll()`\n // deletes this key for that reason in those words, and records the asymmetry:\n // a single read hands back a VALUE, a door like this hands back a CONTAINER\n // that someone will merge. `state.params` / `state.search` are the most-merged\n // containers the router publishes.\n //\n // ⚠ The data-preservation argument for carrying it does not survive contact\n // with a consumer either: `Object.assign` DROPS the key even in the safe\n // string case, so \"the user's `?__proto__=1` is kept\" held for exactly one\n // hop and then failed unpredictably rather than here.\n if (key === UNSAFE_KEY) {\n continue;\n }\n\n // ⚑ ONE read per key, and the result is built from it. A test-then-re-read\n // pair here would be a TOCTOU on an object the caller owns: the key is\n // ADMITTED on the first value and USED with the second (#1812).\n const value = bag[key];\n\n if (value !== undefined) {\n // Lazy allocation: an all-empty / all-undefined input costs zero objects.\n normalized ??= {};\n putField(normalized, key, value);\n }\n }\n\n // Reuse the caller's shared singleton when nothing survived so the merge's\n // `value === empty` reuse branch fires (#1027). The two channels have DISTINCT\n // singletons — `EMPTY_PARAMS` and `EMPTY_SEARCH` are separate frozen objects\n // compared by identity — which is why `empty` is a parameter, not a constant\n // read here.\n return (normalized as T | undefined) ?? (empty as unknown as T);\n}\n\n/**\n * CORE's own copy of a caller-owned channel bag — one read per key, and nothing\n * else changed (#2134).\n *\n * ⚑ **Content-preserving, and that is the whole difference from\n * {@link normalizeChannel}.** The strip stays where it is, BELOW the\n * `forwardState` seam. This copy exists for another reason entirely: to make the\n * read a validator judges and the read the pipeline ships the same read. A key\n * that answers `v1` then `v2` is otherwise admitted on one value and printed on\n * the other.\n *\n * ⚠ **Stripping here instead is a measured regression, not a tidier place for\n * the same work.** An `undefined` value is\n * `@real-router/persistent-params-plugin`'s removal marker and it is read at the\n * seam: dropped above it, `navigate(\"b\", { id: \"2\", page: undefined })` leaves\n * `?page=7` on the URL instead of clearing it. #1849 records the same\n * measurement from the other side — eight of that package's cells red on the\n * `normalizeChannel` form.\n *\n * ⚠ **Absence passes through on BOTH spellings.** `{ ...null }` is `{}`, which\n * turns \"no bag\" into \"empty bag\" above the code that tells them apart; each\n * caller's own `?? EMPTY_*` is what resolves it.\n *\n * ⚠ **And so does anything that is not SHAPED like a bag**, which is the guard\n * against laundering: a copy of a string is `{0:\"a\",1:\"b\"}` and a copy of a\n * class instance has lost its prototype, so copying first would hand the\n * validating layer an acceptable object built out of one it refuses. Returned\n * unchanged, such a value reaches that layer as the caller wrote it. Below the\n * seam nothing changes — `normalizeChannel` treats it exactly as it does today.\n * \"Shaped like a bag\" is `Object.prototype` BY IDENTITY, so another realm's\n * plain object is not one; `adopt-channel-authority-2187` owns the row per\n * shape.\n *\n * ⚠ **A caller with no validating door below it must REFUSE what came back by\n * reference rather than write to it (#2187).** Core's own have one and it does\n * the refusing in its own words; a plugin reaching this through\n * `@real-router/core/utils` usually does not, and `adopted.x = 1` after a\n * by-reference input lands on the APPLICATION's object. The return answers \"did\n * I copy this\", and the caller owns what follows from \"no\".\n *\n * The `ownKeys`-first Proxy safety of the spread is the same argument\n * {@link normalizeChannel} makes for its own walk, and is stated there (#2091).\n */\n// ONE signature, not an overload set: `T` is generic over the whole admitted\n// union, so every spelling types itself. An overload set cannot — the arm that\n// admits absence widens the return for callers that never pass it, and adding\n// a narrower arm beside it puts the answer in resolution ORDER. The per-spelling\n// row is in `adopt-channel-authority-2187`.\nexport function adoptChannel<\n T extends Record<string, unknown> | undefined | null,\n>(bag: T): T {\n // Both spellings of \"no bag\" in one term — `== null` matches `null` and\n // `undefined` and nothing else. The two strict comparisons need a disable\n // comment apiece here: the redundant-comparison rule does not resolve `null`\n // against an unresolved type PARAMETER and calls each of them dead.\n if (bag == null) {\n return bag;\n }\n\n // One term, not three: an array answers `Array.prototype` and a string\n // `String.prototype`, so a separate `Array.isArray` or `typeof` would be an\n // unreachable arm. `null` is excluded above because it is the one value that\n // cannot be asked for a prototype at all.\n const proto = getPrototypeOf(bag) as object | null;\n\n return proto === null || proto === Object.prototype ? { ...bag } : bag;\n}\n\n/**\n * Withholds `UNSAFE_KEY` from a bag core BUILT and is about to hand to\n * application code (#1904).\n *\n * `matchPath` parses the query out of the URL itself, and the parser creates\n * that own key deliberately (#855 / #1293) — writing it any other way would\n * swap the parsed object's own prototype. The published channels drop it much\n * further down, at `normalizeChannel`, which leaves two seams ABOVE the drop\n * holding a container core will not publish: a route's `decodeParams`, and\n * every `forwardState` interceptor on the URL direction.\n *\n * ⚑ The reason is the CONSUMER's merge, not core's own write. `putField` stores\n * the name perfectly well; what it cannot make safe is the next hop, where\n * `Object.assign` / a `for…in` copy / `dst[key] = value` reaches the inherited\n * setter and replaces that target's prototype instead of adding an entry —\n * silently, and from a bare URL (`?__proto__` parses to `null`,\n * `?__proto__=1&__proto__=2` to an array; a plain string value is inert). Same\n * rule, same words, as `getDependenciesApi.getAll`: a single read hands back a\n * VALUE, a door like this hands back a CONTAINER someone will merge.\n *\n * ⚠ NOT applied in the parser. Its `defineProperty` write must stay, or the\n * parse itself swaps a prototype — the drop belongs at the door, not at the\n * construction.\n *\n * Returns the input untouched, with no allocation, when the key is absent —\n * which is every ordinary URL, so the common path pays one `hasOwn`.\n */\n/**\n * Remove `UNSAFE_KEY` from an object core JUST allocated for a hand-out (#1957).\n *\n * The sibling of {@link withoutUnsafeKey}, and the split between them is which\n * of the two questions the call site has already answered:\n *\n * - {@link withoutUnsafeKey} is handed a bag it does NOT own, so it gates on\n * `hasOwn` and copies only when it must. That gate is the price of not\n * allocating on a path where the key is almost always absent.\n * - this one is handed the RESULT of a spread core just performed, so there\n * is nothing to copy and nothing to preserve — and the delete is therefore\n * UNCONDITIONAL. `getAll` recorded why (#1823) and the reason generalises:\n * guarding it with `hasOwn` decides nothing (deleting an absent key is a\n * no-op in every observable respect, measured) while putting a re-pointable\n * intrinsic read in front of the one line that neutralises the hazard.\n * Capturing `hasOwn` at module load does not close that either — a shim\n * evaluated BEFORE this module, the ordinary polyfill order, still wins.\n *\n * ⚠ Only ever call this on an object core allocated in the same expression. It\n * MUTATES, and a caller's own bag is not core's to edit.\n *\n * ⚠ That precondition is the CONTRACT and the type cannot express it, so here\n * is what breaking it costs, measured: `delete` on a FROZEN container carrying\n * the key, or on a non-configurable own key, throws\n * `TypeError: Cannot delete property '__proto__'` — every module is strict. An\n * absent key is a no-op even under a freeze, which is why no shipped site can\n * reach the throw by accident (all four hand over a spread made one expression\n * earlier). The throw is the right failure mode rather than a flaw: a silent\n * no-op would leave the key on a published container with nobody the wiser.\n * Not pinned by a test — no public door can hand this a frozen bag, and a\n * functional test may not reach `src` to try.\n *\n * ⚠ The three sites it serves all SPREAD rather than copy key by key, and that\n * is load-bearing (#1852): a spread `[[Define]]`s, while `dst[key] = value`\n * dispatches into whatever `Object.prototype` carries under an ordinary\n * dependency or option name. Using the loop here would turn an already-immune\n * door into a member of that class.\n */\nexport function dropUnsafeKey<T extends object>(fresh: T): T {\n delete (fresh as Record<string, unknown>)[UNSAFE_KEY];\n\n return fresh;\n}\n\n/**\n * One own-enumerable FROZEN copy of a bag the caller owns, named if it throws.\n *\n * ⚑ **The shared half of #2171 and #2172.** Both retire the same decision from\n * #2145 — core stops holding an application container live — at two different\n * doors: `Router`'s option sub-bags and `routesStore`'s route-config tables.\n * The copy rule is one rule, so it lives here rather than twice.\n *\n * ⚑ **The try/catch is the reason this is a function and not a spread.** These\n * reads happen at construction and at registration, and an accessor-backed\n * config is the ordinary lazy spelling — so a throw here is a config fault about\n * a FIELD and is reported as one. `asKey` reports the sibling slot the same way\n * (`Invalid \"queryParams.arrayFormat\": reading it threw`, original as `cause`);\n * naming one field and not the ones beside it would be an asymmetry.\n * `config-aliasing-authority-1958` pins both doors against it.\n *\n * ⚠ Own-enumerable, deliberately — a spread's semantics, which is what\n * `createLimits` and `packages/core/CLAUDE.md` › Supported Input Shapes already\n * specify for these bags. A prototype-chain walk belongs to `queryParams`\n * alone, where layering is the documented feature.\n *\n * ⚠ The parameter is NOT `T extends object`, and that is deliberate rather than\n * loose. Constrained, TypeScript reads the non-object guard below as dead — the\n * declared type carries no primitive and no `null` — and `no-unnecessary-condition`\n * says so. The guard exists because the runtime disagrees with the declared type,\n * which is the entire premise of adopting a caller's value; a constraint that\n * argues the disagreement away would delete the check that handles it.\n *\n * ⚠ `dropUnsafeKey` on the copy, for the reason the freeze one level up gives\n * (#1957): the object is one CORE mints, so the exemption that covered the\n * nested bag — \"it is the caller's, not ours\" — is exactly what these two\n * issues retired. Same treatment `adoptForeignBag` gives a published channel,\n * so every door into a params bag now agrees.\n */\nexport function copyOwnData<T>(field: string, bag: T): T {\n // ⚠ A non-object passes through UNTOUCHED, for the reason the array branch\n // below exists. `{ ...\"abc\" }` is `{ 0: \"a\", 1: \"b\", 2: \"c\" }`, so spreading a\n // string handed to `defaultParams` manufactures a plausible-looking object out\n // of invalid config — and the layer that would have named it sees an object and\n // says nothing. The static type forbids this; the runtime is what actually\n // arrives, which is the whole premise of adopting in the first place.\n if (typeof bag !== \"object\" || bag === null) {\n return bag;\n }\n\n try {\n // ⚠ KIND-preserving, and that is a correctness requirement rather than\n // tidiness. `{ ...[] }` is `{}`, so a plain spread silently turns an array\n // handed to `defaultParams` into an object — and `@real-router/validation-plugin`\n // refuses that field by asking whether it IS an array. Measured: the spread\n // alone moved four cells of that plugin's own coverage table out of \"plugin\n // refuses\" and into \"unreachable\", i.e. core's copy laundered a structurally\n // invalid config past the layer that exists to name it.\n //\n // ⚑ The freeze is HERE rather than at each call site: both callers wanted it,\n // and a third that forgot would hand out a core-minted bag that is writable\n // — the half of the defect that survives copying.\n const copy = Array.isArray(bag) ? [...bag] : { ...bag };\n\n return freeze(dropUnsafeKey(copy)) as T;\n } catch (error) {\n throw new TypeError(\n `[router.constructor] Invalid \"${field}\": reading it threw.`,\n { cause: error },\n );\n }\n}\n\n/**\n * The bag without `UNSAFE_KEY`, or the bag itself when it does not carry one.\n *\n * ⚑ The `hasOwn` gate is what makes this affordable at its two seams — the\n * `forwardState` chain and `matchPath`'s decode — a clean bag is returned BY\n * IDENTITY, so nothing is allocated.\n *\n * ⚠ **Do not rewrite this as a DESCRIPTOR copy.** It is the obvious way to strip\n * a key without invoking the caller's accessors, it was tried, and it is worse\n * on the axis this module exists for: `Object.defineProperties` runs\n * `ToPropertyDescriptor`, which asks `HasProperty` for `get` / `set` / `value` /\n * `writable` — names a data descriptor does not own — so an ambient\n * `Object.prototype.get` makes every copy throw. Measured: `navigate()` then\n * fails silently, the state does not move, and the `TypeError` surfaces only in\n * the fire-and-forget log. Two further costs came with it — the source's\n * `writable` / `configurable` propagate into a copy whose OBJECT is still\n * extensible (so `Object.isFrozen` does not warn a consumer before its merge\n * throws), and a preserved getter means the caller keeps writing into a\n * container the router has already published.\n *\n * ⚠ The read it would have avoided is not core's only one: `normalizeChannel`\n * above reads every key of a caller's bag, so the public doors invoke an\n * accessor either way. What the descriptor form bought was one read out of two.\n */\nexport function withoutUnsafeKey<T extends Record<string, unknown>>(bag: T): T {\n if (!hasOwn(bag, UNSAFE_KEY)) {\n return bag;\n }\n\n const copy: Record<string, unknown> = {};\n\n for (const key of objectKeys(bag)) {\n if (key !== UNSAFE_KEY) {\n // `putField`, not a plain store: the remaining names also come straight\n // out of the URL, so the whole prototype chain is in play for them too.\n putField(copy, key, bag[key]);\n }\n }\n\n return copy as T;\n}\n","// packages/core/src/RouterError.ts\n\nimport { errorCodes, UNSAFE_KEY } from \"./constants\";\nimport { putField } from \"./utils/ingest\";\n\n/** Captured like the deciding seven, but this one BUILDS the guarantee (#2073). */\nconst freeze = Object.freeze;\n\nconst objectEntries = Object.entries;\nconst objectValues = Object.values;\n\n// Pre-compute Set of error code values for O(1) lookup in setCode()\n// This avoids creating array and doing linear search on every setCode() call\n// ⚑ Captured at module load, for the reason `helpers.ts` states over its own\n// three: an application can re-point `Object.hasOwn` after boot, and this one\n// gates a PUBLIC read (#1829). ⚠ The file's four other intrinsic reads are still\n// raw — #1971 owns that sweep, and a point fix here would be the N+1 it exists\n// to prevent; capturing the read this commit ADDS is not the same thing as\n// sweeping the ones it found.\nconst hasOwn = Object.hasOwn;\n\nconst errorCodeValues = new Set(objectValues(errorCodes));\n\n// Reserved built-in properties - throw error if user tries to set these\nconst reservedProperties = new Set([\"code\", \"segment\", \"path\"]);\n\n// Reserved method names - silently ignore attempts to overwrite these\nconst reservedMethods = new Set([\n \"setCode\",\n \"setErrorInstance\",\n \"setAdditionalFields\",\n \"hasField\",\n \"getField\",\n \"toJSON\",\n]);\n\n/**\n * Freeze a `RouterError` at the moment it stops being core's to change — the\n * throw (#1960).\n *\n * ⚑ At the THROW, never in the constructor. `RouterError` publishes three\n * mutators (`setCode`, `setErrorInstance`, `setAdditionalFields`) with worked\n * examples in the wiki, and `rethrowAsRouterError` copies an error and re-codes\n * the copy before throwing it. Freezing on construction was measured: it reds\n * across the tier and concentrates in this class's own suite, because it\n * withdraws published API from errors a CONSUMER builds. Freezing here\n * withdraws exactly one thing — writing to an error core threw at you — which\n * #1606 already established is corruption when the instance is one of the\n * cached, process-shared ones, and which a repository-wide sweep of every\n * `catch` binding found nobody doing.\n *\n * ⚠ Only for errors core CONSTRUCTED. A re-thrown foreign error stays untouched:\n * freezing someone else's object on the way through is the hazard, not the fix.\n */\nexport function freezeThrownError<E extends RouterError>(error: E): E {\n return freeze(error);\n}\n\nexport class RouterError extends Error {\n [key: string]: unknown;\n\n // Using public properties to ensure structural compatibility\n // with the `RouterError` interface in `types/base.ts`\n readonly segment: string | undefined;\n readonly path: string | undefined;\n\n // Note: code appears to be writable but setCode() should be used\n // to properly update both code and message together\n code: string;\n\n /**\n * Creates a new RouterError instance.\n *\n * The options object accepts built-in fields (message, segment, path)\n * and any additional custom fields, which will all be attached to the error instance.\n *\n * @param code - The error code (e.g., \"ROUTE_NOT_FOUND\", \"CANNOT_ACTIVATE\")\n * @param options - Optional configuration object\n * @param options.message - Custom error message (defaults to code if not provided)\n * @param options.segment - The route segment where the error occurred\n * @param options.path - The full path where the error occurred\n *\n * @example\n * ```typescript\n * // Basic error\n * const err1 = new RouterError(\"ROUTE_NOT_FOUND\");\n *\n * // Error with custom message\n * const err2 = new RouterError(\"ERR\", { message: \"Something went wrong\" });\n *\n * // Error with context and custom fields\n * const err3 = new RouterError(\"CANNOT_ACTIVATE\", {\n * message: \"Insufficient permissions\",\n * segment: \"admin\",\n * path: \"/admin/users\",\n * userId: \"123\" // custom field\n * });\n * ```\n */\n constructor(\n code: string,\n {\n message,\n segment,\n path,\n ...rest\n }: {\n [key: string]: unknown;\n message?: string | undefined;\n segment?: string | undefined;\n path?: string | undefined;\n } = {},\n ) {\n super(message ?? code);\n\n // Subclasses don't auto-set `name`; without this `error.name` inherits\n // \"Error\", breaking `error.name === \"RouterError\"` checks at catch sites that\n // can't `instanceof` across bundle boundaries.\n this.name = \"RouterError\";\n\n this.code = code;\n this.segment = segment;\n this.path = path;\n\n // Assign custom fields, checking reserved properties and filtering out reserved method names\n // Issue #39: Throw for reserved properties to match setAdditionalFields behavior\n for (const [key, value] of objectEntries(rest)) {\n if (reservedProperties.has(key)) {\n throw new TypeError(\n `[RouterError] Cannot set reserved property \"${key}\"`,\n );\n }\n\n // ⚑ `UNSAFE_KEY` skipped for the reason the state channels give (#1852):\n // this instance is a container core hands out and `toJSON` serializes, so\n // an own `\"__proto__\"` on it is a prototype-swap primitive for whoever\n // merges or re-parses the error — measured, a guard throwing a plain\n // object put the key into `JSON.stringify(err)`.\n //\n // ⚠ Plain assignment is the alternative that looks equivalent and is\n // worse than losing the key: measured, `new RouterError(\"X\", bag)` swaps\n // the INSTANCE's prototype and `instanceof RouterError` answers `false`.\n // `putField` keeps the instance intact; the skip keeps the key off a\n // container someone will merge.\n if (key !== UNSAFE_KEY && !reservedMethods.has(key)) {\n // ⚑ `putField` (#1852). The target is `this`, whose chain runs\n // `RouterError.prototype → Error.prototype → Object.prototype`, and the\n // key comes from the caller's bag. `reservedProperties` / `reservedMethods`\n // above filter by NAME and therefore cannot see an ambient one: measured,\n // an accessor under a custom field name threw out of the constructor,\n // and a setter left the field non-own while reading back the hijacked\n // value.\n putField(this as unknown as Record<string, unknown>, key, value);\n }\n }\n }\n\n /**\n * Updates the error code and conditionally updates the message.\n *\n * If the current message is one of the standard error code values\n * (e.g., \"ROUTE_NOT_FOUND\", \"SAME_STATES\"), it will be replaced with the new code.\n * This allows keeping error messages in sync with codes when using standard error codes.\n *\n * If the message is custom (not a standard error code), it will be preserved.\n *\n * @param newCode - The new error code to set\n *\n * @example\n * // Message follows code (standard error code as message)\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", { message: \"ROUTE_NOT_FOUND\" });\n * err.setCode(\"CUSTOM_ERROR\"); // message becomes \"CUSTOM_ERROR\"\n *\n * @example\n * // Custom message is preserved\n * const err = new RouterError(\"ERR\", { message: \"Custom error message\" });\n * err.setCode(\"NEW_CODE\"); // message stays \"Custom error message\"\n */\n setCode(newCode: string): void {\n this.code = newCode;\n\n // Only update message if it's a standard error code value (not a custom message)\n if (errorCodeValues.has(this.message)) {\n this.message = newCode;\n }\n }\n\n /**\n * Copies properties from another Error instance to this RouterError.\n *\n * This method updates the message, cause, and stack trace from the provided error.\n * Useful for wrapping native errors while preserving error context.\n *\n * @param err - The Error instance to copy properties from\n * @throws {TypeError} If err is null or undefined\n *\n * @example\n * ```typescript\n * const routerErr = new RouterError(\"TRANSITION_ERR\");\n * try {\n * // some operation that might fail\n * } catch (nativeErr) {\n * routerErr.setErrorInstance(nativeErr);\n * throw routerErr;\n * }\n * ```\n */\n setErrorInstance(err: Error): void {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!err) {\n throw new TypeError(\n \"[RouterError.setErrorInstance] err parameter is required and must be an Error instance\",\n );\n }\n\n this.message = err.message;\n // ⚑ `putField` for THIS slot only, and the set was recounted rather than\n // assumed (#2142 / #1852). `message` and `stack` are already own on every\n // instance — `super(message ?? code)` always passes a string, and the\n // `Error` constructor installs `stack` — so their assignments define own\n // data and cannot reach the chain. `cause` has no own slot unless the\n // constructor was given one, and this class never is.\n //\n // ⚠ Measured on the plain form: an ambient `Object.prototype.cause` setter\n // took the value and left `cause` absent, and a getter-only one made this\n // line THROW — from inside the method that wraps a native failure into the\n // router's own error, so the throw would replace the error being reported.\n putField(this as unknown as Record<string, unknown>, \"cause\", err.cause);\n this.stack = err.stack ?? \"\";\n }\n\n /**\n * Adds custom fields to the error object.\n *\n * This method allows attaching arbitrary data to the error for debugging or logging purposes.\n * All fields become accessible as properties on the error instance and are included in JSON serialization.\n *\n * Reserved method names (setCode, setErrorInstance, setAdditionalFields, hasField, getField, toJSON)\n * are automatically filtered out to prevent accidental overwriting of class methods.\n *\n * @param fields - Object containing custom fields to add to the error\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"CANNOT_ACTIVATE\");\n * err.setAdditionalFields({\n * userId: \"123\",\n * attemptedRoute: \"/admin\",\n * reason: \"insufficient permissions\"\n * });\n *\n * console.log(err.userId); // \"123\"\n * console.log(JSON.stringify(err)); // includes all custom fields\n * ```\n */\n setAdditionalFields(fields: Record<string, unknown>): void {\n // Assign fields, throwing for reserved properties, silently ignoring methods\n for (const [key, value] of objectEntries(fields)) {\n if (reservedProperties.has(key)) {\n throw new TypeError(\n `[RouterError.setAdditionalFields] Cannot set reserved property \"${key}\"`,\n );\n }\n\n // ⚑ `UNSAFE_KEY` skipped, and `putField` rather than assignment, for the\n // reasons the constructor's own field loop states (#1852). Not restated\n // here — one mechanism, one explanation.\n if (key !== UNSAFE_KEY && !reservedMethods.has(key)) {\n // ⚑ `putField` (#1852). The target is `this`, whose chain runs\n // `RouterError.prototype → Error.prototype → Object.prototype`, and the\n // key comes from the caller's bag. `reservedProperties` / `reservedMethods`\n // above filter by NAME and therefore cannot see an ambient one: measured,\n // an accessor under a custom field name threw out of the constructor,\n // and a setter left the field non-own while reading back the hijacked\n // value.\n putField(this as unknown as Record<string, unknown>, key, value);\n }\n }\n }\n\n /**\n * Checks if a custom field exists on the error object.\n *\n * This method checks for both custom fields added via setAdditionalFields()\n * and built-in fields (code, message, segment, etc.).\n *\n * @param key - The field name to check\n * @returns `true` if the field exists, `false` otherwise\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", {\n * segment: \"users\",\n * path: \"/users/7\",\n * });\n * err.setAdditionalFields({ userId: \"123\" });\n *\n * err.hasField(\"code\"); // true\n * err.hasField(\"segment\"); // true\n * err.hasField(\"path\"); // true\n * err.hasField(\"userId\"); // true\n * err.hasField(\"unknown\"); // false\n * ```\n */\n hasField(key: string): boolean {\n // ⚑ `hasOwn`, not `in` (#1829). `in` walks the prototype chain, so this\n // answered `true` for `Object.prototype`'s twelve members and for the\n // class's own six methods — eighteen names for an error carrying ONE field\n // and `toString` / `constructor` are ordinary strings arriving from a config\n // key, a route param name or a serialized payload.\n //\n // ⚠ NOT `toJSON`'s `excludeKeys`, which the issue proposed. Measured against\n // the docstring above: that set excludes `code`, `segment` and `path`,\n // which this method documents as answering `true`. The two functions ask\n // different questions (what to SERIALIZE vs what the error CARRIES), so\n // agreeing on those three is the contract and diverging on `message` /\n // `stack` / `name` is not drift.\n return hasOwn(this, key);\n }\n\n /**\n * Retrieves a custom field value from the error object.\n *\n * This method can access both custom fields and built-in fields.\n * Returns `undefined` if the field doesn't exist.\n *\n * @param key - The field name to retrieve\n * @returns The field value, or `undefined` if it doesn't exist\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ERR\");\n * err.setAdditionalFields({ userId: \"123\", role: \"admin\" });\n *\n * err.getField(\"userId\"); // \"123\"\n * err.getField(\"role\"); // \"admin\"\n * err.getField(\"code\"); // \"ERR\" (built-in field)\n * err.getField(\"unknown\"); // undefined\n * ```\n */\n getField(key: string): unknown {\n // Reachable without `hasField` — a consumer may just read — so the same gate\n // stands here rather than being implied by the predicate (#1829). Before\n // this, `getField(\"toString\")` handed back the native function.\n return hasOwn(this, key) ? this[key] : undefined;\n }\n\n /**\n * Serializes the error to a JSON-compatible object.\n *\n * This method is automatically called by JSON.stringify() and includes:\n * - Built-in fields: code, message, segment (if set), path (if set)\n * - All custom fields added via setAdditionalFields() or constructor\n * - Excludes: stack trace (for security/cleanliness)\n *\n * @returns A plain object representation of the error, suitable for JSON serialization\n *\n * @example\n * ```typescript\n * const err = new RouterError(\"ROUTE_NOT_FOUND\", {\n * message: \"Route not found\",\n * path: \"/admin/users/123\"\n * });\n * err.setAdditionalFields({ userId: \"123\" });\n *\n * JSON.stringify(err);\n * // {\n * // \"code\": \"ROUTE_NOT_FOUND\",\n * // \"message\": \"Route not found\",\n * // \"path\": \"/admin/users/123\",\n * // \"userId\": \"123\"\n * // }\n * ```\n */\n toJSON(): Record<string, unknown> {\n const result: Record<string, unknown> = {\n code: this.code,\n message: this.message,\n };\n\n if (this.segment !== undefined) {\n result.segment = this.segment;\n }\n if (this.path !== undefined) {\n result.path = this.path;\n }\n\n // add all public fields\n // Using Set.has() for O(1) lookup instead of Array.includes() O(n)\n // Overall complexity: O(n) instead of O(n*m)\n const excludeKeys = new Set([\n \"code\",\n \"message\",\n \"segment\",\n \"path\",\n \"stack\",\n // `name` is now an own enumerable prop (constructor sets it to\n // \"RouterError\"); it's class metadata, not a custom field — keep it out of\n // the serialized output (preserves toJSON shape).\n \"name\",\n ]);\n\n for (const key in this) {\n if (hasOwn(this, key) && !excludeKeys.has(key)) {\n // ⚑ `putField` (#1852): `result` is a fresh literal and the keys are the\n // user's own error fields. Measured, a setter under one of them made the\n // field vanish from the serialized output with no error at all.\n putField(result, key, this[key]);\n }\n }\n\n return result;\n }\n}\n"],"mappings":"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"}
|
package/dist/cjs/api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./internals-BGTllfGV.js"),t=require("./ingest-C6HQ7xXf.js"),n=require("./Router-BY8DeXYU.js"),r=require("./RouterError-CJMrktYx.js");function i(e){if(e())throw r.n(new r.t(t.m.ROUTER_DISPOSED))}function a(e){if(e())throw r.n(new r.t(t.m.REENTRANT_TREE_MUTATION,{message:`[router] cannot mutate the route tree from inside a subscribeChanges handler — the mutation would run while a TREE_CHANGED emit is on the stack and the tree must stay atomic. Defer it: queueMicrotask(() => routes.add(...)) or await.`}))}function o(e,t,n){if(t){let r=t===e;if(r||t.startsWith(`${e}.`)){let i=r?``:` (current: "${t}")`;return n.warn(`router.removeRoute`,`Cannot remove route "${e}" — it is currently active${i}. Navigate away first.`),!1}}return!0}function s(e,t){t.warn(`router.removeRoute`,`Route "${e}" removed while navigation is in progress. Removing a route the router is navigating to (or an ancestor of it) fails that navigation. The rejected navigate() promise carries "CANCELLED" while the guard walk is synchronous and "ROUTE_NOT_FOUND" once it has gone async; onTransitionError always reports "ROUTE_NOT_FOUND", and onTransitionCancel never fires. The committed state is not affected either way.`)}function c(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}function l(e,t,n,r){return n&&c(e)!==c(t)?(r.error(`router.setRootPath`,"Cannot change the root PATH while navigation is in progress — it moves every route's path, including the one being navigated to. Wait for navigation to complete. (Changing only the `?`-declared query names is allowed here: it moves no paths.)"),!1):!0}function u(e,t){return!e||(t.error(`router.clearRoutes`,`Cannot clear routes while navigation is in progress. Wait for navigation to complete.`),!1)}const d=Object.freeze,f=Object.keys,p=new WeakMap;function m(o){let s=p.get(o);if(s)return s;let c=e.i(o),u={makeState:(t,r,i,a)=>{e.o(c,`makeState`,t,r);let o=n.D(r);return c.validator?.state.validateMakeStateArgs(t,o,a),c.validator?.navigation.validateSearch(i,`makeState`),c.makeState(t,o,i,a)},forwardState:(e,t,n)=>(c.validator?.routes.validateStateBuilderArgs(e,t,`forwardState`),c.validator?.navigation.validateSearch(n,`forwardState`),c.forwardState(e,t,n)),matchPath:e=>(c.validator?.routes.validateMatchPathArgs(e),c.matchPath(e,c.getOptions())),navigateToState:(e,t)=>(i(c.isDisposed),c.validator?.navigation.validateNavigateToStateArgs(e),t!==void 0&&c.validator?.navigation.validateNavigationOptions(t,`navigateToState`),c.navigateToState(e,t)),setRootPath:e=>(i(c.isDisposed),a(c.treeChanged.isEmitting),c.validator?.routes.validateSetRootPathArgs(e),l(c.getRootPath(),e,c.isTransitioning(),c.logger)?(c.setRootPath(e),!0):!1),getRootPath:c.getRootPath,addEventListener:(e,t)=>(i(c.isDisposed),n.k(e),n.j(t),c.validator?.eventBus.validateListenerArgs(e,t),c.addEventListener(e,t)),buildNavigationState:(t,r={},i={})=>{e.o(c,`buildNavigationState`,t,r);let a=n.D(r);c.validator?.navigation.validateSearch(i,`buildNavigationState`),c.validator?.routes.validateStateBuilderArgs(t,a,`buildNavigationState`);let o=n.T(c.port(),t,a,i,{diagnoseUndeclared:!0});if(c.buildStateResolved(o.name,o.path))return e._(`buildNavigationState`,o.name,o.path,c.port().queryNames(o.name)),n.C(o,n.w(o,c.port()))},getOptions:c.getOptions,getTree:c.getTree,addInterceptor:(e,t)=>{i(c.isDisposed),n.A(e,t);let r=c.interceptors.get(e);r||(r=[],c.interceptors.set(e,r)),r.push(t);let a=!1;return()=>{a||(a=!0,r.splice(r.indexOf(t),1))}},getRouteConfig:e=>{let t=c.routeGetStore();if(t.matcher.hasRoute(e))return t.routeCustomFields[e]},extendRouter:e=>{i(c.isDisposed);let n=f(e);for(let e of n)if(e in o)throw r.n(new r.t(t.m.PLUGIN_CONFLICT,{message:`Cannot extend router: property "${e}" already exists`}));let a=n.map(t=>e[t]),s={keys:n};for(let[e,t]of n.entries())o[t]=a[e];c.routerExtensions.push(s);let l=!1;return()=>{if(l)return;l=!0;for(let e of s.keys)delete o[e];let e=c.routerExtensions.indexOf(s);e!==-1&&c.routerExtensions.splice(e,1)}},emitTransitionError:e=>{i(c.isDisposed),c.emitTransitionError(e)},claimContextNamespace:e=>{if(i(c.isDisposed),typeof e!=`string`||e===``)throw TypeError(`[claimContextNamespace] namespace must be a non-empty string, got ${typeof e==`string`?`an empty string`:typeof e}`);if(c.contextClaimRecords.has(e))throw r.n(new r.t(t.m.CONTEXT_NAMESPACE_ALREADY_CLAIMED,{message:`Cannot claim context namespace: "${e}" is already claimed by another plugin`}));let n={write(r,i){c.contextClaimRecords.get(e)===n&&t.a(r.context,e,i)},release(){c.contextClaimRecords.get(e)===n&&c.contextClaimRecords.delete(e)}};return c.contextClaimRecords.set(e,n),n}},m=d(u);return p.set(o,m),m}const h=Object.freeze,g=Object.keys,_=Object.freeze({replace:!0,revalidate:!0}),v=Object.freeze([]);function y(e,t,r,i){let a=t=>e.has(t);n.x(t.decoders,a),n.x(t.encoders,a),n.x(t.defaultParams,a),n.x(t.defaultSearch,a),n.x(t.forwardMap,a),n.x(t.forwardFnMap,a),n.x(r,a),n.x(t.forwardMap,e=>a(t.forwardMap[e]));let[o,s]=i.getFactories();for(let e of g(s))a(e)&&i.clearCanActivate(e,`both`);for(let e of g(o))a(e)&&i.clearCanDeactivate(e,`both`)}function b(e,t,n,r){let i=n.forwardFnMap[t],a=n.forwardMap[t];i===void 0?a!==void 0&&(e.forwardTo=a):e.forwardTo=i,t in n.defaultParams&&(e.defaultParams=n.defaultParams[t]),t in n.defaultSearch&&(e.defaultSearch=n.defaultSearch[t]),t in n.decoders&&(e.decodeParams=n.decoders[t]),t in n.encoders&&(e.encodeParams=n.encoders[t]);let[o,s]=r;return t in s&&(e.canActivate=s[t]),t in o&&(e.canDeactivate=o[t]),e}function x(e,n,r,i){let a={name:e.name,path:e.path};return b(a,n,r,i),e.children&&t.a(a,`children`,e.children.map(e=>x(e,`${n}.${e.name}`,r,i))),a}function S(e,t,n,r){let i={name:e,path:t};return b(i,e,n,r),h(i)}function C(e,t){let n=new Map,r=e.lifecycleNamespace.getFactories(),i=(a,o)=>{for(let s of a){let a=o?`${o}.${s.name}`:s.name;t(a)&&n.set(a,S(a,s.path,e.config,r)),s.children&&i(s.children,a)}};return i(e.definitions,``),n}function w(e,t){let n=C(e,e=>t.has(e));return h([...n.values()])}function T(e,t,n){let r=n.lifecycleNamespace.getFactories(),i=[],a=(e,t)=>{for(let o of e){let e=t?`${t}.${o.name}`:o.name;i.push(S(e,o.path,n.config,r)),o.children&&a(o.children,e)}};return a(e,t??``),h(i)}function E(e,t){let n=[],r=[];for(let[r,i]of e)t.has(r)||n.push(i);for(let[n,i]of t)e.has(n)||r.push(i);return{removed:h(n),added:h(r)}}function D(e){let t={};return e.forwardTo!==void 0&&(t.forwardTo=e.forwardTo),e.defaultParams!==void 0&&(t.defaultParams=e.defaultParams),e.defaultSearch!==void 0&&(t.defaultSearch=e.defaultSearch),e.encodeParams!==void 0&&(t.encodeParams=e.encodeParams),e.decodeParams!==void 0&&(t.decodeParams=e.decodeParams),h(t)}function O(e,t,r,i){n.a(e,t,r);let a=n.f(e,t,r,i);n.y(a.matcher,a.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(a.pendingCanActivate.keys(),a.pendingCanDeactivate.keys(),!1),n.i(e,a)}function k(e,t){return e.matcher.match(t)?.segments.at(-1)?.fullName}function A(e,t,n,r,i){if(k(e,r.path)!==i){t.revalidateToNotFound(r.path);return}t.systemCommit(n,r,_)}function j(e,t,r,i,a){n.l(t,`addRoute`),n.d(t,`addRoute`),n.o(t,`addRoute`),n.s(t,``,`addRoute`),n.c(t,``,`addRoute`);let o=n.p(t,e.rootPath,e.matcherOptions,r.logger);n.y(o.matcher,o.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(o.pendingCanActivate.keys(),o.pendingCanDeactivate.keys(),!0);let s=n.g(o,e.depsStore);if(e.lifecycleNamespace.clearDefinitionGuards(),n.i(e,o,s),a?.(),i!==void 0){let t=k(e,i.path),a=r.matchPath(i.path,r.getOptions());if(a){if(a.name===i.name)A(e,r,{...a,context:i.context,transition:i.transition},i,t);else{let{toActivate:o}=n.n(a,i,r.getMetaForState);e.lifecycleNamespace.canNavigateTo([],o,a,i)?A(e,r,{...a,transition:i.transition},i,t):r.revalidateToNotFound(i.path)}}else r.revalidateToNotFound(i.path)}}function M(e,t,r){let i=e.definitions,a=n.S(i,t);if(a===void 0)return;let o=r?w(e,a):v;return y(a,e.config,e.routeCustomFields,e.lifecycleNamespace),n.h(e,i),o}function N(e,t){let r=e.matcher.getSegmentsByName(t);if(!r)return;let i=r.at(-1),a=n.I(i),o=e.lifecycleNamespace.getFactories();return x(a,t,e.config,o)}const P=new WeakMap;function F(c){let l=P.get(c);if(l)return l;let d=e.i(c),f=d.routeGetStore(),p=e=>{d.treeChanged.emit(e)},m=h({add:(e,t)=>{i(d.isDisposed),a(d.treeChanged.isEmitting);let r=Array.isArray(e)?e:[e],o=t?.parent,s=n.P(r);if(n.N(s,d.validator),o!==void 0&&d.validator?.routes.validateParentOption(o,f.tree),d.validator?.routes.throwIfInternalRouteInArray(s,`addRoute`),d.validator?.routes.validateAddRouteArgs(s),d.validator?.routes.validateRoutes(s,f,o),O(f,s,o,d.logger),d.treeChanged.listenerCount()>0){let e=T(s,o,f);p(o===void 0?{op:`add`,added:e}:{op:`add`,added:e,parent:o})}},remove:e=>{if(i(d.isDisposed),a(d.treeChanged.isEmitting),d.validator?.routes.validateRemoveRouteArgs(e),d.validator?.routes.throwIfInternalRoute(e,`removeRoute`),n.u(e,`removeRoute`),!o(e,d.getStateName(),d.logger))return;let t=d.treeChanged.listenerCount()>0,r=M(f,e,t);if(r===void 0){d.logger.warn(`router.removeRoute`,`Route "${e}" not found. No changes made.`);return}d.isTransitioning()&&s(e,d.logger),t&&p({op:`remove`,name:e,removedSubtree:r})},update:(e,t)=>{if(i(d.isDisposed),a(d.treeChanged.isEmitting),d.validator?.routes.validateUpdateRouteBasicArgs(e,t),d.validator?.routes.throwIfInternalRoute(e,`updateRoute`),n.u(e,`updateRoute`),d.validator?.routes.validateUpdateRoutePropertyTypes(e,t),d.validator?.routes.validateUpdateRoute(e,t,f),!f.matcher.hasRoute(e))return;d.isTransitioning()&&d.logger.error(`router.updateRoute`,`Updating route "${e}" while navigation is in progress. This may cause unexpected behavior.`);let r=f.lifecycleNamespace,o=n.m(f,r,e,t);if(d.treeChanged.listenerCount()>0){let t=D(o);g(t).length>0&&p({op:`update`,name:e,patch:t})}},clear:()=>{if(i(d.isDisposed),a(d.treeChanged.isEmitting),d.getStateName()!==void 0)throw r.n(new r.t(t.m.ROUTER_NOT_STOPPED,{message:`[router.clear] Cannot clear routes while a state is committed. Use replace(routes) to swap the tree on a running router, or stop() first.`}));if(!u(d.isTransitioning(),d.logger))return;let e=d.treeChanged.listenerCount()>0?h([...C(f,()=>!0).values()]):void 0;n._(f),f.lifecycleNamespace.clearAll(),e!==void 0&&p({op:`clear`,removed:e})},has:e=>(d.validator?.routes.validateRouteName(e,`hasRoute`),f.matcher.hasRoute(e)),get:e=>(d.validator?.routes.validateRouteName(e,`getRoute`),N(f,e)),replace:e=>{i(d.isDisposed),a(d.treeChanged.isEmitting);let t=Array.isArray(e)?e:[e];if(!u(d.isTransitioning(),d.logger))return;let r=n.P(t);n.N(r,d.validator),d.validator?.routes.throwIfInternalRouteInArray(r,`replaceRoutes`),d.validator?.routes.validateAddRouteArgs(r),d.validator?.routes.validateRoutes(r,f);let o=c.getState(),s=d.treeChanged.listenerCount()>0?C(f,()=>!0):void 0;j(f,r,d,o,s===void 0?void 0:()=>{let e=C(f,()=>!0),{removed:t,added:n}=E(s,e);p({op:`replace`,removed:t,added:n})})},subscribeChanges:e=>d.treeChanged.subscribe(e)});return P.set(c,m),m}const I=Object.create,L=Object.hasOwn,R=e=>typeof e==`symbol`?e:String(e);function z(e,t,n,r){if(n===void 0)return;let i=e.dependencies,a=R(t);if(!L(i,a))r?.dependencies.validateDependencyCount(e,`setDependency`);else{let e=i[a];e!==n&&!(Number.isNaN(e)&&Number.isNaN(n))&&r?.dependencies.warnOverwrite(String(a),`setDependency`)}i[a]=n}function B(e,t,r){let i=[],a=e.dependencies;n.F(t,(t,o)=>{L(a,t)?i.push(t):r?.dependencies.validateDependencyCount(e,`setDependencies`),n.E(a,t,o)}),i.length>0&&r?.dependencies.warnBatchOverwrite(i,`setDependencies`)}function V(t){let r=e.i(t);return{get:e=>{r.validator?.dependencies.validateDependencyName(e,`getDependency`);let t=r.dependenciesGetStore(),n=t.dependencies[e];return r.validator?.dependencies.validateDependencyExists(e,t),n},getAll:()=>{let e=r.dependenciesGetStore().dependencies;return n.O({...e})},set:(e,t)=>{i(r.isDisposed),r.validator?.dependencies.validateSetDependencyArgs(e,t,`setDependency`),z(r.dependenciesGetStore(),e,t,r.validator),i(r.isDisposed)},setAll:e=>{i(r.isDisposed);let t=r.dependenciesGetStore();r.validator?.dependencies.validateDependenciesObject(e,`setDependencies`),B(t,e,r.validator),i(r.isDisposed)},remove:e=>{i(r.isDisposed),r.validator?.dependencies.validateDependencyName(e,`removeDependency`);let t=r.dependenciesGetStore(),n=R(e);L(t.dependencies,n)||r.validator?.dependencies.warnRemoveNonExistent(String(n)),delete t.dependencies[n]},reset:()=>{i(r.isDisposed);let e=r.dependenciesGetStore();e.dependencies=I(null)},has:e=>(r.validator?.dependencies.validateDependencyName(e,`hasDependency`),L(r.dependenciesGetStore().dependencies,e))}}function H(t){let r=e.i(t),a=r.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,t){i(r.isDisposed),n.M(e,`addActivateGuard`),r.validator?.routes.validateRouteName(e,`addActivateGuard`),r.validator?.lifecycle.validateHandler(t,`addActivateGuard`),a.addCanActivate(e,t,!1)},addDeactivateGuard(e,t){i(r.isDisposed),n.M(e,`addDeactivateGuard`),r.validator?.routes.validateRouteName(e,`addDeactivateGuard`),r.validator?.lifecycle.validateHandler(t,`addDeactivateGuard`),a.addCanDeactivate(e,t,!1)},removeActivateGuard(e){i(r.isDisposed),n.M(e,`removeActivateGuard`),r.validator?.routes.validateRouteName(e,`removeActivateGuard`),a.clearCanActivate(e,`external`)},removeDeactivateGuard(e){i(r.isDisposed),n.M(e,`removeDeactivateGuard`),r.validator?.routes.validateRouteName(e,`removeDeactivateGuard`),a.clearCanDeactivate(e,`external`)}}}const U=Object.entries,W=Object.hasOwn;function G(i,a,o){let s=e.i(i);if(s.isDisposed())throw r.n(new r.t(t.m.ROUTER_DISPOSED));s.validator?.dependencies.validateCloneArgs(a);let c=s.routeGetStore(),l=n.L(c.tree),u=c.config,d=c.resolvedForwardMap,f=c.routeCustomFields,{options:p,dependencies:m,pluginFactories:h,loggerConfig:g,limits:_,limitKeys:v}=s.getCloneState(),{definition:y,external:b}=c.lifecycleNamespace.getFactoriesByOrigin(),x={...m};a!==void 0&&n.F(a,(e,n)=>{t.a(x,e,n)});let S=o?.logger,C=S?{...g,...S}:g,w=new n.t(l,{...p,...c.matcherOptions?.queryParams!==void 0&&{queryParams:c.matcherOptions.queryParams},logger:C,...v!==void 0&&{limits:Object.fromEntries(v.filter(e=>W(_,e)).map(e=>[e,_[e]]))},...c.matcherOptions?.urlParamsEncoding!==void 0&&{urlParamsEncoding:c.matcherOptions.urlParamsEncoding}},x),T=e.i(w),E=T.routeGetStore(),D=E.lifecycleNamespace;n.b(E.config,u),n.r(E,Object.assign(E.resolvedForwardMap,d)),Object.assign(E.routeCustomFields,f),c.rootPath!==``&&T.setRootPath(c.rootPath);let[O,k]=y,[A,j]=b;for(let[e,t]of U(O))D.addCanDeactivate(e,t,!0);for(let[e,t]of U(k))D.addCanActivate(e,t,!0);let M=H(w);for(let[e,t]of U(A))M.addDeactivateGuard(e,t);for(let[e,t]of U(j))M.addActivateGuard(e,t);let N=new Set(T.getCloneState().pluginFactories),P=h.filter(e=>!N.has(e));return P.length>0&&w.usePlugin(...P),w}exports.cloneRouter=G,exports.getDependenciesApi=V,exports.getLifecycleApi=H,exports.getPluginApi=m,exports.getRoutesApi=F;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./internals-BGTllfGV.js"),t=require("./ingest-C6HQ7xXf.js"),n=require("./Router-eWMVS_8K.js"),r=require("./RouterError-B-j6UqeF.js");function i(e){if(e())throw r.n(new r.t(t.m.ROUTER_DISPOSED))}function a(e){if(e())throw r.n(new r.t(t.m.REENTRANT_TREE_MUTATION,{message:`[router] cannot mutate the route tree from inside a subscribeChanges handler — the mutation would run while a TREE_CHANGED emit is on the stack and the tree must stay atomic. Defer it: queueMicrotask(() => routes.add(...)) or await.`}))}function o(e,t,n){if(t){let r=t===e;if(r||t.startsWith(`${e}.`)){let i=r?``:` (current: "${t}")`;return n.warn(`router.removeRoute`,`Cannot remove route "${e}" — it is currently active${i}. Navigate away first.`),!1}}return!0}function s(e,t){t.warn(`router.removeRoute`,`Route "${e}" removed while navigation is in progress. Removing a route the router is navigating to (or an ancestor of it) fails that navigation. The rejected navigate() promise carries "CANCELLED" while the guard walk is synchronous and "ROUTE_NOT_FOUND" once it has gone async; onTransitionError always reports "ROUTE_NOT_FOUND", and onTransitionCancel never fires. The committed state is not affected either way.`)}function c(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}function l(e,t,n,r){return n&&c(e)!==c(t)?(r.error(`router.setRootPath`,"Cannot change the root PATH while navigation is in progress — it moves every route's path, including the one being navigated to. Wait for navigation to complete. (Changing only the `?`-declared query names is allowed here: it moves no paths.)"),!1):!0}function u(e,t){return!e||(t.error(`router.clearRoutes`,`Cannot clear routes while navigation is in progress. Wait for navigation to complete.`),!1)}const d=Object.freeze,f=Object.keys,p=new WeakMap;function m(o){let s=p.get(o);if(s)return s;let c=e.i(o),u={makeState:(t,n,i,a)=>{e.o(c,`makeState`,t,n);let o=r.r(n);return c.validator?.state.validateMakeStateArgs(t,o,a),c.validator?.navigation.validateSearch(i,`makeState`),c.makeState(t,o,i,a)},forwardState:(e,t,n)=>(c.validator?.routes.validateStateBuilderArgs(e,t,`forwardState`),c.validator?.navigation.validateSearch(n,`forwardState`),c.forwardState(e,t,n)),matchPath:e=>(c.validator?.routes.validateMatchPathArgs(e),c.matchPath(e,c.getOptions())),navigateToState:(e,t)=>(i(c.isDisposed),c.validator?.navigation.validateNavigateToStateArgs(e),t!==void 0&&c.validator?.navigation.validateNavigationOptions(t,`navigateToState`),c.navigateToState(e,t)),setRootPath:e=>(i(c.isDisposed),a(c.treeChanged.isEmitting),c.validator?.routes.validateSetRootPathArgs(e),l(c.getRootPath(),e,c.isTransitioning(),c.logger)?(c.setRootPath(e),!0):!1),getRootPath:c.getRootPath,addEventListener:(e,t)=>(i(c.isDisposed),n.D(e),n.k(t),c.validator?.eventBus.validateListenerArgs(e,t),c.addEventListener(e,t)),buildNavigationState:(t,i={},a={})=>{e.o(c,`buildNavigationState`,t,i);let o=r.r(i);c.validator?.navigation.validateSearch(a,`buildNavigationState`),c.validator?.routes.validateStateBuilderArgs(t,o,`buildNavigationState`);let s=n.T(c.port(),t,o,a,{diagnoseUndeclared:!0});if(c.buildStateResolved(s.name,s.path))return e._(`buildNavigationState`,s.name,s.path,c.port().queryNames(s.name)),n.C(s,n.w(s,c.port()))},getOptions:c.getOptions,getTree:c.getTree,addInterceptor:(e,t)=>{i(c.isDisposed),n.O(e,t);let r=c.interceptors.get(e);r||(r=[],c.interceptors.set(e,r)),r.push(t);let a=!1;return()=>{a||(a=!0,r.splice(r.indexOf(t),1))}},getRouteConfig:e=>{let t=c.routeGetStore();if(t.matcher.hasRoute(e))return t.routeCustomFields[e]},extendRouter:e=>{i(c.isDisposed);let n=f(e);for(let e of n)if(e in o)throw r.n(new r.t(t.m.PLUGIN_CONFLICT,{message:`Cannot extend router: property "${e}" already exists`}));let a=n.map(t=>e[t]),s={keys:n};for(let[e,t]of n.entries())o[t]=a[e];c.routerExtensions.push(s);let l=!1;return()=>{if(l)return;l=!0;for(let e of s.keys)delete o[e];let e=c.routerExtensions.indexOf(s);e!==-1&&c.routerExtensions.splice(e,1)}},emitTransitionError:e=>{i(c.isDisposed),c.emitTransitionError(e)},claimContextNamespace:e=>{if(i(c.isDisposed),typeof e!=`string`||e===``)throw TypeError(`[claimContextNamespace] namespace must be a non-empty string, got ${typeof e==`string`?`an empty string`:typeof e}`);if(c.contextClaimRecords.has(e))throw r.n(new r.t(t.m.CONTEXT_NAMESPACE_ALREADY_CLAIMED,{message:`Cannot claim context namespace: "${e}" is already claimed by another plugin`}));let n={write(r,i){c.contextClaimRecords.get(e)===n&&t.a(r.context,e,i)},release(){c.contextClaimRecords.get(e)===n&&c.contextClaimRecords.delete(e)}};return c.contextClaimRecords.set(e,n),n}},m=d(u);return p.set(o,m),m}const h=Object.freeze,g=Object.keys,_=Object.freeze({replace:!0,revalidate:!0}),v=Object.freeze([]);function y(e,t,r,i){let a=t=>e.has(t);n.x(t.decoders,a),n.x(t.encoders,a),n.x(t.defaultParams,a),n.x(t.defaultSearch,a),n.x(t.forwardMap,a),n.x(t.forwardFnMap,a),n.x(r,a),n.x(t.forwardMap,e=>a(t.forwardMap[e]));let[o,s]=i.getFactories();for(let e of g(s))a(e)&&i.clearCanActivate(e,`both`);for(let e of g(o))a(e)&&i.clearCanDeactivate(e,`both`)}function b(e,t,n,r){let i=n.forwardFnMap[t],a=n.forwardMap[t];i===void 0?a!==void 0&&(e.forwardTo=a):e.forwardTo=i,t in n.defaultParams&&(e.defaultParams=n.defaultParams[t]),t in n.defaultSearch&&(e.defaultSearch=n.defaultSearch[t]),t in n.decoders&&(e.decodeParams=n.decoders[t]),t in n.encoders&&(e.encodeParams=n.encoders[t]);let[o,s]=r;return t in s&&(e.canActivate=s[t]),t in o&&(e.canDeactivate=o[t]),e}function x(e,n,r,i){let a={name:e.name,path:e.path};return b(a,n,r,i),e.children&&t.a(a,`children`,e.children.map(e=>x(e,`${n}.${e.name}`,r,i))),a}function S(e,t,n,r){let i={name:e,path:t};return b(i,e,n,r),h(i)}function C(e,t){let n=new Map,r=e.lifecycleNamespace.getFactories(),i=(a,o)=>{for(let s of a){let a=o?`${o}.${s.name}`:s.name;t(a)&&n.set(a,S(a,s.path,e.config,r)),s.children&&i(s.children,a)}};return i(e.definitions,``),n}function w(e,t){let n=C(e,e=>t.has(e));return h([...n.values()])}function T(e,t,n){let r=n.lifecycleNamespace.getFactories(),i=[],a=(e,t)=>{for(let o of e){let e=t?`${t}.${o.name}`:o.name;i.push(S(e,o.path,n.config,r)),o.children&&a(o.children,e)}};return a(e,t??``),h(i)}function E(e,t){let n=[],r=[];for(let[r,i]of e)t.has(r)||n.push(i);for(let[n,i]of t)e.has(n)||r.push(i);return{removed:h(n),added:h(r)}}function D(e){let t={};return e.forwardTo!==void 0&&(t.forwardTo=e.forwardTo),e.defaultParams!==void 0&&(t.defaultParams=e.defaultParams),e.defaultSearch!==void 0&&(t.defaultSearch=e.defaultSearch),e.encodeParams!==void 0&&(t.encodeParams=e.encodeParams),e.decodeParams!==void 0&&(t.decodeParams=e.decodeParams),h(t)}function O(e,t,r,i){n.a(e,t,r);let a=n.f(e,t,r,i);n.y(a.matcher,a.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(a.pendingCanActivate.keys(),a.pendingCanDeactivate.keys(),!1),n.i(e,a)}function k(e,t){return e.matcher.match(t)?.segments.at(-1)?.fullName}function A(e,t,n,r,i){if(k(e,r.path)!==i){t.revalidateToNotFound(r.path);return}t.systemCommit(n,r,_)}function j(e,t,r,i,a){n.l(t,`addRoute`),n.d(t,`addRoute`),n.o(t,`addRoute`),n.s(t,``,`addRoute`),n.c(t,``,`addRoute`);let o=n.p(t,e.rootPath,e.matcherOptions,r.logger);n.y(o.matcher,o.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(o.pendingCanActivate.keys(),o.pendingCanDeactivate.keys(),!0);let s=n.g(o,e.depsStore);if(e.lifecycleNamespace.clearDefinitionGuards(),n.i(e,o,s),a?.(),i!==void 0){let t=k(e,i.path),a=r.matchPath(i.path,r.getOptions());if(a){if(a.name===i.name)A(e,r,{...a,context:i.context,transition:i.transition},i,t);else{let{toActivate:o}=n.n(a,i,r.getMetaForState);e.lifecycleNamespace.canNavigateTo([],o,a,i)?A(e,r,{...a,transition:i.transition},i,t):r.revalidateToNotFound(i.path)}}else r.revalidateToNotFound(i.path)}}function M(e,t,r){let i=e.definitions,a=n.S(i,t);if(a===void 0)return;let o=r?w(e,a):v;return y(a,e.config,e.routeCustomFields,e.lifecycleNamespace),n.h(e,i),o}function N(e,t){let r=e.matcher.getSegmentsByName(t);if(!r)return;let i=r.at(-1),a=n.P(i),o=e.lifecycleNamespace.getFactories();return x(a,t,e.config,o)}const P=new WeakMap;function F(c){let l=P.get(c);if(l)return l;let d=e.i(c),f=d.routeGetStore(),p=e=>{d.treeChanged.emit(e)},m=h({add:(e,t)=>{i(d.isDisposed),a(d.treeChanged.isEmitting);let r=Array.isArray(e)?e:[e],o=t?.parent,s=n.M(r);if(n.j(s,d.validator),o!==void 0&&d.validator?.routes.validateParentOption(o,f.tree),d.validator?.routes.throwIfInternalRouteInArray(s,`addRoute`),d.validator?.routes.validateAddRouteArgs(s),d.validator?.routes.validateRoutes(s,f,o),O(f,s,o,d.logger),d.treeChanged.listenerCount()>0){let e=T(s,o,f);p(o===void 0?{op:`add`,added:e}:{op:`add`,added:e,parent:o})}},remove:e=>{if(i(d.isDisposed),a(d.treeChanged.isEmitting),d.validator?.routes.validateRemoveRouteArgs(e),d.validator?.routes.throwIfInternalRoute(e,`removeRoute`),n.u(e,`removeRoute`),!o(e,d.getStateName(),d.logger))return;let t=d.treeChanged.listenerCount()>0,r=M(f,e,t);if(r===void 0){d.logger.warn(`router.removeRoute`,`Route "${e}" not found. No changes made.`);return}d.isTransitioning()&&s(e,d.logger),t&&p({op:`remove`,name:e,removedSubtree:r})},update:(e,t)=>{if(i(d.isDisposed),a(d.treeChanged.isEmitting),d.validator?.routes.validateUpdateRouteBasicArgs(e,t),d.validator?.routes.throwIfInternalRoute(e,`updateRoute`),n.u(e,`updateRoute`),d.validator?.routes.validateUpdateRoutePropertyTypes(e,t),d.validator?.routes.validateUpdateRoute(e,t,f),!f.matcher.hasRoute(e))return;d.isTransitioning()&&d.logger.error(`router.updateRoute`,`Updating route "${e}" while navigation is in progress. This may cause unexpected behavior.`);let r=f.lifecycleNamespace,o=n.m(f,r,e,t);if(d.treeChanged.listenerCount()>0){let t=D(o);g(t).length>0&&p({op:`update`,name:e,patch:t})}},clear:()=>{if(i(d.isDisposed),a(d.treeChanged.isEmitting),d.getStateName()!==void 0)throw r.n(new r.t(t.m.ROUTER_NOT_STOPPED,{message:`[router.clear] Cannot clear routes while a state is committed. Use replace(routes) to swap the tree on a running router, or stop() first.`}));if(!u(d.isTransitioning(),d.logger))return;let e=d.treeChanged.listenerCount()>0?h([...C(f,()=>!0).values()]):void 0;n._(f),f.lifecycleNamespace.clearAll(),e!==void 0&&p({op:`clear`,removed:e})},has:e=>(d.validator?.routes.validateRouteName(e,`hasRoute`),f.matcher.hasRoute(e)),get:e=>(d.validator?.routes.validateRouteName(e,`getRoute`),N(f,e)),replace:e=>{i(d.isDisposed),a(d.treeChanged.isEmitting);let t=Array.isArray(e)?e:[e];if(!u(d.isTransitioning(),d.logger))return;let r=n.M(t);n.j(r,d.validator),d.validator?.routes.throwIfInternalRouteInArray(r,`replaceRoutes`),d.validator?.routes.validateAddRouteArgs(r),d.validator?.routes.validateRoutes(r,f);let o=c.getState(),s=d.treeChanged.listenerCount()>0?C(f,()=>!0):void 0;j(f,r,d,o,s===void 0?void 0:()=>{let e=C(f,()=>!0),{removed:t,added:n}=E(s,e);p({op:`replace`,removed:t,added:n})})},subscribeChanges:e=>d.treeChanged.subscribe(e)});return P.set(c,m),m}const I=Object.create,L=Object.hasOwn,R=e=>typeof e==`symbol`?e:String(e);function z(e,t,n,r){if(n===void 0)return;let i=e.dependencies,a=R(t);if(!L(i,a))r?.dependencies.validateDependencyCount(e,`setDependency`);else{let e=i[a];e!==n&&!(Number.isNaN(e)&&Number.isNaN(n))&&r?.dependencies.warnOverwrite(String(a),`setDependency`)}i[a]=n}function B(e,t,r){let i=[],a=e.dependencies;n.N(t,(t,o)=>{L(a,t)?i.push(t):r?.dependencies.validateDependencyCount(e,`setDependencies`),n.E(a,t,o)}),i.length>0&&r?.dependencies.warnBatchOverwrite(i,`setDependencies`)}function V(t){let n=e.i(t);return{get:e=>{n.validator?.dependencies.validateDependencyName(e,`getDependency`);let t=n.dependenciesGetStore(),r=t.dependencies[e];return n.validator?.dependencies.validateDependencyExists(e,t),r},getAll:()=>{let e=n.dependenciesGetStore().dependencies;return r.l({...e})},set:(e,t)=>{i(n.isDisposed),n.validator?.dependencies.validateSetDependencyArgs(e,t,`setDependency`),z(n.dependenciesGetStore(),e,t,n.validator),i(n.isDisposed)},setAll:e=>{i(n.isDisposed);let t=n.dependenciesGetStore();n.validator?.dependencies.validateDependenciesObject(e,`setDependencies`),B(t,e,n.validator),i(n.isDisposed)},remove:e=>{i(n.isDisposed),n.validator?.dependencies.validateDependencyName(e,`removeDependency`);let t=n.dependenciesGetStore(),r=R(e);L(t.dependencies,r)||n.validator?.dependencies.warnRemoveNonExistent(String(r)),delete t.dependencies[r]},reset:()=>{i(n.isDisposed);let e=n.dependenciesGetStore();e.dependencies=I(null)},has:e=>(n.validator?.dependencies.validateDependencyName(e,`hasDependency`),L(n.dependenciesGetStore().dependencies,e))}}function H(t){let r=e.i(t),a=r.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,t){i(r.isDisposed),n.A(e,`addActivateGuard`),r.validator?.routes.validateRouteName(e,`addActivateGuard`),r.validator?.lifecycle.validateHandler(t,`addActivateGuard`),a.addCanActivate(e,t,!1)},addDeactivateGuard(e,t){i(r.isDisposed),n.A(e,`addDeactivateGuard`),r.validator?.routes.validateRouteName(e,`addDeactivateGuard`),r.validator?.lifecycle.validateHandler(t,`addDeactivateGuard`),a.addCanDeactivate(e,t,!1)},removeActivateGuard(e){i(r.isDisposed),n.A(e,`removeActivateGuard`),r.validator?.routes.validateRouteName(e,`removeActivateGuard`),a.clearCanActivate(e,`external`)},removeDeactivateGuard(e){i(r.isDisposed),n.A(e,`removeDeactivateGuard`),r.validator?.routes.validateRouteName(e,`removeDeactivateGuard`),a.clearCanDeactivate(e,`external`)}}}const U=Object.entries,W=Object.hasOwn;function G(i,a,o){let s=e.i(i);if(s.isDisposed())throw r.n(new r.t(t.m.ROUTER_DISPOSED));s.validator?.dependencies.validateCloneArgs(a);let c=s.routeGetStore(),l=n.F(c.tree),u=c.config,d=c.resolvedForwardMap,f=c.routeCustomFields,{options:p,dependencies:m,pluginFactories:h,loggerConfig:g,limits:_,limitKeys:v}=s.getCloneState(),{definition:y,external:b}=c.lifecycleNamespace.getFactoriesByOrigin(),x={...m};a!==void 0&&n.N(a,(e,n)=>{t.a(x,e,n)});let S=o?.logger,C=S?{...g,...S}:g,w=new n.t(l,{...p,...c.matcherOptions?.queryParams!==void 0&&{queryParams:c.matcherOptions.queryParams},logger:C,...v!==void 0&&{limits:Object.fromEntries(v.filter(e=>W(_,e)).map(e=>[e,_[e]]))},...c.matcherOptions?.urlParamsEncoding!==void 0&&{urlParamsEncoding:c.matcherOptions.urlParamsEncoding}},x),T=e.i(w),E=T.routeGetStore(),D=E.lifecycleNamespace;n.b(E.config,u),n.r(E,Object.assign(E.resolvedForwardMap,d)),Object.assign(E.routeCustomFields,f),c.rootPath!==``&&T.setRootPath(c.rootPath);let[O,k]=y,[A,j]=b;for(let[e,t]of U(O))D.addCanDeactivate(e,t,!0);for(let[e,t]of U(k))D.addCanActivate(e,t,!0);let M=H(w);for(let[e,t]of U(A))M.addDeactivateGuard(e,t);for(let[e,t]of U(j))M.addActivateGuard(e,t);let N=new Set(T.getCloneState().pluginFactories),P=h.filter(e=>!N.has(e));return P.length>0&&w.usePlugin(...P),w}exports.cloneRouter=G,exports.getDependenciesApi=V,exports.getLifecycleApi=H,exports.getPluginApi=m,exports.getRoutesApi=F;
|
|
2
2
|
//# sourceMappingURL=api.js.map
|