@real-router/core 0.156.0 → 0.157.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/README.md +3 -0
- package/dist/cjs/Router-WmGPinsJ.js +2 -0
- package/dist/cjs/Router-WmGPinsJ.js.map +1 -0
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/helpers-CJZd3DYU.js +2 -0
- package/dist/cjs/helpers-CJZd3DYU.js.map +1 -0
- package/dist/cjs/helpers.d.ts +26 -0
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals-BIFri00a.js +2 -0
- package/dist/cjs/internals-BIFri00a.js.map +1 -0
- package/dist/cjs/pipeline/port.d.ts +17 -3
- package/dist/cjs/pipeline/port.d.ts.map +1 -1
- package/dist/cjs/types/RouterValidator.d.ts +18 -12
- package/dist/cjs/types/RouterValidator.d.ts.map +1 -1
- package/dist/cjs/types/router.d.ts +8 -0
- package/dist/cjs/types/router.d.ts.map +1 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/validation.d.ts +2 -1
- package/dist/cjs/validation.js +1 -1
- package/dist/esm/Router-Bq4eRDf_.mjs +2 -0
- package/dist/esm/Router-Bq4eRDf_.mjs.map +1 -0
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/helpers-CrMwAJNl.mjs +2 -0
- package/dist/esm/helpers-CrMwAJNl.mjs.map +1 -0
- package/dist/esm/helpers.d.mts +26 -0
- package/dist/esm/helpers.d.mts.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internals-3GJCFPcw.mjs +2 -0
- package/dist/esm/{internals-D-5hS0qt.mjs.map → internals-3GJCFPcw.mjs.map} +1 -1
- package/dist/esm/pipeline/port.d.mts +17 -3
- package/dist/esm/pipeline/port.d.mts.map +1 -1
- package/dist/esm/types/RouterValidator.d.mts +18 -12
- package/dist/esm/types/RouterValidator.d.mts.map +1 -1
- package/dist/esm/types/router.d.mts +8 -0
- package/dist/esm/types/router.d.mts.map +1 -1
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.d.mts +2 -1
- package/dist/esm/validation.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-TI0TlO7k.js +0 -2
- package/dist/cjs/Router-TI0TlO7k.js.map +0 -1
- package/dist/cjs/RouterError-aGkUvcJJ.js +0 -2
- package/dist/cjs/RouterError-aGkUvcJJ.js.map +0 -1
- package/dist/cjs/helpers-DdpDlqWS.js +0 -2
- package/dist/cjs/helpers-DdpDlqWS.js.map +0 -1
- package/dist/cjs/internals-BZATS0c4.js +0 -2
- package/dist/cjs/internals-BZATS0c4.js.map +0 -1
- package/dist/esm/Router-BmEfUCfN.mjs +0 -2
- package/dist/esm/Router-BmEfUCfN.mjs.map +0 -1
- package/dist/esm/RouterError-DyPeuufj.mjs +0 -2
- package/dist/esm/RouterError-DyPeuufj.mjs.map +0 -1
- package/dist/esm/helpers-BXXeSrT8.mjs +0 -2
- package/dist/esm/helpers-BXXeSrT8.mjs.map +0 -1
- package/dist/esm/internals-D-5hS0qt.mjs +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=Object.freeze({ROUTER_NOT_STARTED:`NOT_STARTED`,NO_START_PATH_OR_STATE:`NO_START_PATH_OR_STATE`,ROUTER_ALREADY_STARTED:`ALREADY_STARTED`,ROUTE_NOT_FOUND:`ROUTE_NOT_FOUND`,SAME_STATES:`SAME_STATES`,CANNOT_DEACTIVATE:`CANNOT_DEACTIVATE`,CANNOT_ACTIVATE:`CANNOT_ACTIVATE`,TRANSITION_ERR:`TRANSITION_ERR`,TRANSITION_CANCELLED:`CANCELLED`,ROUTER_DISPOSED:`DISPOSED`,PLUGIN_CONFLICT:`PLUGIN_CONFLICT`,CONTEXT_NAMESPACE_ALREADY_CLAIMED:`CONTEXT_NAMESPACE_ALREADY_CLAIMED`,REENTRANT_NAVIGATION:`REENTRANT_NAVIGATION`,REENTRANT_TREE_MUTATION:`REENTRANT_TREE_MUTATION`,ROUTER_NOT_STOPPED:`NOT_STOPPED`,WRONG_CHANNEL:`WRONG_CHANNEL`}),t=`@@router/UNKNOWN_ROUTE`,n=`__proto__`,r=Object.freeze({UNKNOWN_ROUTE:t}),i=Object.freeze({ROUTER_START:`onStart`,ROUTER_STOP:`onStop`,TRANSITION_START:`onTransitionStart`,TRANSITION_LEAVE_APPROVE:`onTransitionLeaveApprove`,TRANSITION_CANCEL:`onTransitionCancel`,TRANSITION_SUCCESS:`onTransitionSuccess`,TRANSITION_ERROR:`onTransitionError`}),a=Object.freeze({ROUTER_START:`$start`,ROUTER_STOP:`$stop`,TRANSITION_START:`$$start`,TRANSITION_LEAVE_APPROVE:`$$leaveApprove`,TRANSITION_CANCEL:`$$cancel`,TRANSITION_SUCCESS:`$$success`,TRANSITION_ERROR:`$$error`}),o=Object.freeze({maxDependencies:100,maxPlugins:50,maxListeners:1e4,warnListeners:1e3,maxLifecycleHandlers:200}),s=Object.freeze({}),c=Object.freeze({}),l=Object.freeze({}),u=Object.freeze({deactivated:Object.freeze([]),activated:Object.freeze([]),intersection:``}),d=Object.freeze({phase:`activating`,reason:`success`,segments:u}),f=new WeakSet,p=new WeakSet;function m(e){f.add(e)}function h(e){f.has(e)&&p.add(e)}function g(e){return p.has(e)}const _=Object.create,v=Object.entries;function y(){return _(null)}function b(e){return{...e}}const x=Object.defineProperty,S=Object.hasOwn;function C(e){return S(e,`__proto__`)&&x(e,n,{value:e[n],writable:!0,enumerable:!1,configurable:!0}),e}function w(e,t,n){t in e&&!S(e,t)?x(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function T(e,t){for(let[n,r]of v(t))w(e,n,r)}const E=Object.freeze,D=Object.entries,O=Object.values,k=Object.hasOwn,A=new Set(O(e)),j=new Set([`code`,`segment`,`path`]),M=new Set([`setCode`,`setErrorInstance`,`setAdditionalFields`,`hasField`,`getField`,`toJSON`]);function N(e){return m(e),E(e)}var P=class extends Error{segment;path;code;constructor(e,{message:t,segment:n,path:r,...i}={}){super(t??e),this.name=`RouterError`,this.code=e,this.segment=n,this.path=r;for(let[e,t]of D(i)){if(j.has(e))throw L.type`Cannot set reserved property "${e}"`;e!==`__proto__`&&!M.has(e)&&w(this,e,t)}}setCode(e){this.code=e,A.has(this.message)&&(this.message=e)}setErrorInstance(e){if(!e)throw R.type`err parameter is required and must be an Error instance`;this.message=e.message,w(this,`cause`,e.cause),this.stack=e.stack??``}setAdditionalFields(e){for(let[t,n]of D(e)){if(j.has(t))throw z.type`Cannot set reserved property "${t}"`;t!==`__proto__`&&!M.has(t)&&w(this,t,n)}}hasField(e){return k(this,e)}getField(e){return k(this,e)?this[e]:void 0}toJSON(){let e={code:this.code,message:this.message};this.segment!==void 0&&(e.segment=this.segment),this.path!==void 0&&(e.path=this.path);let t=new Set([`code`,`message`,`segment`,`path`,`stack`,`name`]);for(let n in this)k(this,n)&&!t.has(n)&&w(e,n,this[n]);return e}};const F=(e,t)=>{let n=e[0];for(let[r,i]of t.entries())n+=String(i)+e[r+1];return n};function I(e,t){let n=t===void 0||t===``?`[${e}] `:`[${e}.${t}] `,r=(e,t)=>n+F(e,t),i=e=>((t,...n)=>Array.isArray(t)?e(r(t,n)):(n,...i)=>e(r(n,i),t));return{type:i((e,t)=>TypeError(e,t)),plain:i((e,t)=>Error(e,t)),ref:(e,...t)=>ReferenceError(r(e,t)),range:(e,...t)=>RangeError(r(e,t)),code:(e,t)=>(n,...i)=>N(new P(e,{...t,message:r(n,i)}))}}const L=I(`RouterError`),R=I(`RouterError`,`setErrorInstance`),z=I(`RouterError`,`setAdditionalFields`),B={plain:(e,...t)=>Error(`Internal error (please report): ${F(e,t)}`)};export{i as S,t as _,C as a,e as b,b as c,h as d,o as f,c as g,s as h,I as i,w as l,l as m,N as n,T as o,d as p,B as r,y as s,P as t,g as u,n as v,a as x,r as y};
|
|
2
|
-
//# sourceMappingURL=RouterError-DyPeuufj.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RouterError-DyPeuufj.mjs","names":["objectEntries","hasOwn","errorCodes","UNKNOWN_ROUTE","UNSAFE_KEY","constants","plugins","events","DEFAULT_LIMITS","EMPTY_PARAMS","EMPTY_SEARCH","EMPTY_OPTS","FROZEN_EMPTY_SEGMENTS","DEFAULT_TRANSITION","built","ends","recordConstruction","error","recordNavigationEnd","value","isNavigationEnd","objectCreate","objectEntries$1","emptyRecord","publishRecord","source","defineProperty","hasOwn$1","concealUnsafeKey","record","putField","key","target","copyFields","freeze","objectEntries","objectValues","hasOwn","errorCodeValues","reservedProperties","reservedMethods","freezeThrownError","RouterError","rest","message","code","segment","path","newCode","err","fields","result","excludeKeys","interpolate","text","strings","index","values","raiser","head","door","receiver","flavour","first","build","options","atRouterError","atSetErrorInstance","atSetAdditionalFields","internalDefect"],"sources":["../../src/constants.ts","../../src/navigationEnds.ts","../../src/utils/ingest.ts","../../src/RouterError.ts"],"sourcesContent":["// packages/core/src/constants.ts\n\nimport type {\n EventToNameMap,\n EventToPluginMap,\n ErrorCodeToValueMap,\n ErrorCodeKeys,\n ErrorCodeValues,\n TransitionMeta,\n} from \"./types\";\n\nexport type ConstantsKeys = \"UNKNOWN_ROUTE\";\n\nexport type Constants = Readonly<Record<ConstantsKeys, string>>;\n\n// =============================================================================\n// Error Codes (migrated from router-error)\n// =============================================================================\n\nexport type ErrorCodes = Record<ErrorCodeKeys, ErrorCodeValues>;\n\n/**\n * Error codes for router operations.\n * Used to identify specific failure scenarios in navigation and lifecycle.\n * Frozen to prevent accidental modifications.\n */\nexport const errorCodes: ErrorCodeToValueMap = Object.freeze({\n ROUTER_NOT_STARTED: \"NOT_STARTED\", // navigate() called before start()\n NO_START_PATH_OR_STATE: \"NO_START_PATH_OR_STATE\", // start() without initial route\n ROUTER_ALREADY_STARTED: \"ALREADY_STARTED\", // start() called twice\n ROUTE_NOT_FOUND: \"ROUTE_NOT_FOUND\", // Navigation to non-existent route\n SAME_STATES: \"SAME_STATES\", // Navigate to current route without reload\n CANNOT_DEACTIVATE: \"CANNOT_DEACTIVATE\", // canDeactivate guard blocked navigation\n CANNOT_ACTIVATE: \"CANNOT_ACTIVATE\", // canActivate guard blocked navigation\n TRANSITION_ERR: \"TRANSITION_ERR\", // Generic transition failure\n TRANSITION_CANCELLED: \"CANCELLED\", // Navigation cancelled by user or new navigation\n ROUTER_DISPOSED: \"DISPOSED\", // Router has been disposed\n PLUGIN_CONFLICT: \"PLUGIN_CONFLICT\", // Plugin tried to extend router with already-existing property\n CONTEXT_NAMESPACE_ALREADY_CLAIMED: \"CONTEXT_NAMESPACE_ALREADY_CLAIMED\", // Plugin tried to claim a context namespace already owned by another plugin\n REENTRANT_NAVIGATION: \"REENTRANT_NAVIGATION\", // a navigation (the navigate family, or start() restarting the router) called synchronously from inside a navigation core has not finished with (banned — defer it)\n REENTRANT_TREE_MUTATION: \"REENTRANT_TREE_MUTATION\", // a tree mutator — route-CRUD or setRootPath (#1751) — called synchronously from inside a subscribeChanges handler (banned — use await/async/queueMicrotask)\n ROUTER_NOT_STOPPED: \"NOT_STOPPED\", // clear() called while a state is committed — tear down with stop() first, or swap the tree with replace() (#1612)\n WRONG_CHANNEL: \"WRONG_CHANNEL\", // a declared query key was supplied in the path channel (`params`) instead of `search` (#1572)\n});\n\n/**\n * General router constants.\n * Special route names and identifiers.\n */\nexport const UNKNOWN_ROUTE = \"@@router/UNKNOWN_ROUTE\";\n\n/**\n * The one key the router will not copy into a state channel (#1792), and — at\n * `getDependenciesApi.getAll` — will not hand back out of a container either.\n *\n * `__proto__` is the only ACCESSOR among `Object.prototype`'s twelve own\n * members, so `target[key] = value` for that one name reaches the inherited\n * setter: no own key is created, the value vanishes with no error and no log,\n * and an OBJECT value replaces the target's prototype instead.\n *\n * ⚠ Core REFUSES it nowhere — not at a door, not at registration. It is dropped\n * where core copies into a CHANNEL and kept everywhere else, because a route's\n * custom fields and a plugin's context namespace are not containers a consumer\n * merges.\n *\n * ⚠ A `grep` for this constant does not find the sites carrying the opposite\n * contract: they go through `putField` (#1852), which keeps every name.\n *\n * The rule this serves, the doors exempt from it and the level it closes are\n * `INVARIANTS.md` — *Supported input shapes*, *WRITE* (#1852) and *HAND-OUT*\n * (#1957), with `handed-out-containers-1957.test.ts` as the authority. They are\n * deliberately not restated here: this docblock carried a second copy of that\n * section, and the two had already diverged.\n */\nexport const UNSAFE_KEY = \"__proto__\";\n\nexport const constants: Constants = Object.freeze({\n UNKNOWN_ROUTE,\n});\n\n/**\n * Plugin method names.\n * Maps to methods that plugins can implement to hook into router lifecycle.\n */\nexport const plugins: EventToPluginMap = Object.freeze({\n ROUTER_START: \"onStart\", // Plugin method called when router starts\n ROUTER_STOP: \"onStop\", // Plugin method called when router stops\n TRANSITION_START: \"onTransitionStart\", // Plugin method called when navigation begins\n TRANSITION_LEAVE_APPROVE: \"onTransitionLeaveApprove\", // Plugin method called when deactivation guards pass\n TRANSITION_CANCEL: \"onTransitionCancel\", // Plugin method called when navigation cancelled\n TRANSITION_SUCCESS: \"onTransitionSuccess\", // Plugin method called when navigation succeeds\n TRANSITION_ERROR: \"onTransitionError\", // Plugin method called when navigation fails\n});\n\n/**\n * Event names for router event system.\n * Used with addEventListener/removeEventListener for reactive subscriptions.\n */\nexport const events: EventToNameMap = Object.freeze({\n ROUTER_START: \"$start\", // Emitted when router.start() succeeds\n ROUTER_STOP: \"$stop\", // Emitted when router.stop() is called\n TRANSITION_START: \"$$start\", // Emitted when navigation begins\n TRANSITION_LEAVE_APPROVE: \"$$leaveApprove\", // Emitted when deactivation guards pass\n TRANSITION_CANCEL: \"$$cancel\", // Emitted when navigation is cancelled\n TRANSITION_SUCCESS: \"$$success\", // Emitted when navigation completes successfully\n TRANSITION_ERROR: \"$$error\", // Emitted when navigation fails\n});\n\nexport const DEFAULT_LIMITS = Object.freeze({\n maxDependencies: 100,\n maxPlugins: 50,\n maxListeners: 10_000,\n warnListeners: 1000,\n maxLifecycleHandlers: 200,\n} as const);\n\nexport const EMPTY_PARAMS: Readonly<Record<string, never>> = Object.freeze({});\n\n/**\n * Shared frozen empty query bag reused for `State.search` when a navigation\n * carries no query params — the search-channel twin of {@link EMPTY_PARAMS}\n * (RFC-4 M2 / #1548). Lets `makeState` reuse one frozen `{}` (zero transient\n * allocation, #1027) instead of minting an object per query-less state.\n */\nexport const EMPTY_SEARCH: Readonly<Record<string, never>> = Object.freeze({});\n\n/**\n * Shared frozen empty `NavigationOptions`, substituted by the facade when a\n * caller passes none — the options-channel twin of {@link EMPTY_PARAMS}.\n *\n * ⚑ It lives here rather than in `Router.ts` so the entry door can recognise it\n * by IDENTITY (#1962). `navigate(\"b\")` is the commonest call in the library, and\n * matching this singleton is what keeps the door's cost on it to one comparison\n * instead of a copy nobody asked for.\n */\n/**\n * The options bag the facade substitutes when the caller passes none.\n *\n * ⚠ **An ordinary `{}`, and the flags read off it are own-gated at the read\n * instead (#2132).** This object reaches the entry unchanged, so an ambient\n * `Object.prototype.signal` would answer here with no caller bag in the picture\n * at all — core acting on an option nobody supplied. A prototype-less singleton\n * closes that structurally and was measured too expensive: `Object.create(null)`\n * puts it in V8's dictionary mode, and every downstream read of the bag becomes\n * a hash lookup — **+7.6 %** per navigation on this path, **+39.6 %** on the one\n * that copies. The gates cost **+2.9 %** / **+3.0 %**.\n */\nexport const EMPTY_OPTS: Readonly<Record<string, never>> = Object.freeze({});\n\nconst FROZEN_EMPTY_SEGMENTS = Object.freeze({\n deactivated: Object.freeze([]) as unknown as string[],\n activated: Object.freeze([]) as unknown as string[],\n intersection: \"\",\n});\n\nexport const DEFAULT_TRANSITION = Object.freeze({\n phase: \"activating\",\n reason: \"success\",\n segments: FROZEN_EMPTY_SEGMENTS,\n}) as TransitionMeta;\n","// packages/core/src/navigationEnds.ts\n\n/**\n * The values core has handed out as the END of a navigation: what its signal\n * was aborted with, and what its promise rejected with.\n *\n * A guard or a `subscribeLeave` listener receives one of them only by waiting\n * on that navigation's work — a request bound to its signal and deduplicated\n * across navigations, or its promise — so `handleGuardError` and\n * `leaveFailure` ask this to tell such a value from a quiet cancel the\n * application raised (#933, #2786), which is a value it made.\n *\n * ⚑ Only a value core BUILT is recorded, and `freezeThrownError` marks it so.\n * An end the application handed in — the reason of a caller's `opts.signal`\n * (#943), a quiet cancel a guard or a listener threw — is one it holds apart\n * from any navigation, and may raise again as its own quiet cancel: one\n * `RouterError` thrown from every guard, the reason of a signal it passed to\n * an earlier navigation. `abort-dispatch-authority-2778.test.ts` holds that every\n * `TRANSITION_CANCELLED` core builds passes through `freezeThrownError`.\n *\n * ⚑ An abort site records what the signal holds once aborted — what a request\n * bound to it rejects with. Every raw abort of a navigation's controller\n * records it — `abort-dispatch-authority-2778.test.ts` holds that.\n */\nconst built = new WeakSet<object>();\nconst ends = new WeakSet<object>();\n\nexport function recordConstruction(error: object): void {\n built.add(error);\n}\n\nexport function recordNavigationEnd(value: unknown): void {\n // A primitive is never built, so it is never recorded either.\n if (built.has(value as object)) {\n ends.add(value as object);\n }\n}\n\nexport function isNavigationEnd(value: unknown): boolean {\n return ends.has(value as object);\n}\n","// packages/core/src/utils/ingest.ts\n//\n// One discipline for the records core BUILDS under a key it did not CHOOSE.\n//\n// Two halves, and they answer different questions — a reader who takes them for\n// one primitive will draw the wrong conclusion from either:\n//\n// `emptyRecord` / `publishRecord` (#1825) — a record with no prototype for the\n// BUILD, handed out plain. Used where the record is core's alone:\n// `buildParamMeta`, the segment-meta walk.\n// `putField` / `copyFields` (#1852) — a guarded WRITE for the records that\n// cannot be prototype-less because they are published, read on every render,\n// or belong to someone else. Used across core and, through\n// `@real-router/core/utils`, by four plugins.\n// ⚠ The site COUNTS deliberately do not live here. This comment carried\n// \"twenty-one in core, fourteen across four plugins\" and both halves were\n// wrong (22 and 13, measured) — a second copy of a number `CLAUDE.md`\n// already calls descriptive-not-contract. The count lives in `CLAUDE.md`\n// (\"The WRITE side of the same rule\"); the CONTRACT is the derived set in\n// `tests/functional/computed-key-write-authority-1852.test.ts`.\n//\n// ⚠ Neither decides whether a key is PUBLISHED. `__proto__` stays out of\n// `state.params` / `state.search` by a separate skip at the channel copy sites\n// in `helpers.ts`, and stays IN a route's custom fields and a plugin's context\n// namespace, because those are not containers a consumer merges. See `putField`'s\n// docblock for that split.\n//\n// `concealUnsafeKey` (#1957) is the one member of this file that DOES decide\n// that — for exactly one record, `buildMeta`'s, which core both hands out\n// and reads back by key. It withholds the name from ENUMERATION rather than\n// removing it, because removing it is a measured behaviour loss there. The\n// doors that only hand a container OUT drop the key instead\n// (`dropUnsafeKey`, `helpers.ts`).\n//\n// ⚠ The rest are WRITE-side primitives only, and the boundary is deliberate. A\n// READ-side primitive that walks a caller's prototype chain was written here,\n// wired, measured — and removed: `CLAUDE.md` \"Supported Input Shapes\" settles\n// that axis already (\"own enumerable properties only\", owner decision\n// 2026-08-18), and core is the layer that DEGRADES on a violation while\n// `@real-router/validation-plugin` is the layer that reports it. A primitive\n// that honoured inherited keys would have made core contradict its own canon,\n// and it additionally admitted the ambient `Object.prototype` — the #1840\n// class, introduced by the fix.\n//\n// So what is left is the half the canon does not cover: what happens when core\n// writes into a record of its own under a key it did not choose.\n\nimport { UNSAFE_KEY } from \"../constants\";\n\n/** Captured like the deciding seven, but this one BUILDS the guarantee (#2072). */\nconst objectCreate = Object.create;\n\nconst objectEntries = Object.entries;\n\n/**\n * The target discipline: a record with NO prototype.\n *\n * ⚑ This one line closes two axes at once, which is why it is a primitive and\n * not an idiom. #1856 tabulates them as a structural trade — a key-by-key copy\n * fixes `\"__proto__\"` but turns a `[[DefineOwnProperty]]` into a `[[Set]]`, so\n * an ambient accessor starts throwing — and calls the conflict unavoidable. It\n * is unavoidable only while the target inherits from `Object.prototype`:\n *\n * - `\"__proto__\"` (#1825, #1794, #1809) is an ordinary key here, because the\n * magic accessor lives on `Object.prototype` and this object has none.\n * - an ambient accessor named `id` / `page` / `tab` (#1852) cannot hijack the\n * write for the same reason. #1852 notes the key's provenance is\n * irrelevant — `SegmentMatcher` writes a name from the ROUTE TABLE and\n * throws just the same — so a name-based skip cannot close it and this can.\n */\nexport function emptyRecord<V>(): Record<string, V> {\n return objectCreate(null) as Record<string, V>;\n}\n\n/**\n * Hand a privately-built record out with the ORDINARY prototype, keeping every\n * own key — including a literal `\"__proto__\"`.\n *\n * Discovered by measurement, not designed: wiring `emptyRecord` into\n * `buildParamMeta` alone reds **21** existing tests, all of the shape\n * `expected { id: 'url' } to strictly equal { id: 'url' }` — identical content,\n * different prototype, because `toStrictEqual` compares prototypes and\n * `paramTypeMap` is published through `getPluginApi(router).getTree()`. A\n * prototype-less record is not a drop-in at a published surface.\n *\n * The spread is what makes this work rather than undo it: it\n * `[[DefineOwnProperty]]`s, so an own `\"__proto__\"` carried on the private\n * record lands as an ordinary own key here (measured: own keys\n * `[\"__proto__\",\"keep\"]`, value intact, prototype back to `Object.prototype`).\n * Writing that same key into a fresh `{}` with `[[Set]]` loses it entirely\n * (measured: own keys `[]`) — which is the defect the private record exists to\n * avoid.\n *\n * So the rule is: **build private, publish plain.** The window in which the\n * ambient-accessor hazard (#1852) could bite is the build, and the build never\n * touches `Object.prototype`.\n */\nexport function publishRecord<V>(source: Record<string, V>): Record<string, V> {\n return { ...source };\n}\n\n/**\n * Captured at module load for the reason `helpers.ts` gives for `freeze` /\n * `hasOwn` / `objectKeys`: this is the operation {@link putField} writes\n * through, so a guard reading it late would be reading whatever an application\n * had re-pointed it to.\n */\nconst defineProperty = Object.defineProperty;\nconst hasOwn = Object.hasOwn;\n\n/**\n * Withhold `UNSAFE_KEY` from ENUMERATION on a record core hands out AND reads\n * back by key (#1957).\n *\n * ⚑ The hazard is the CONSUMER's merge, not core's own write. `Object.assign`\n * and a `for…in` copy `[[Set]]` each own ENUMERABLE key on the TARGET, where\n * `Object.prototype`'s `\"__proto__\"` accessor replaces that target's prototype\n * instead of adding an entry.\n *\n * ⚠ A SPREAD is NOT in that list. `{ ...source }` performs `CreateDataProperty`,\n * i.e. `[[DefineOwnProperty]]`, which never reaches an inherited accessor —\n * measured on the poisoned bag, on a null-prototype carrier and through a\n * pass-through Proxy, a spread swaps in none of the three. The list is exactly\n * `Object.assign` or a `for…in` copy (#1823), and the hazard is that narrow.\n *\n * So the SOURCE's own prototype decides nothing either — measured, an\n * `Object.create(null)` source swaps the target exactly the same — and the only\n * two fixes are removing the key or removing it from enumeration.\n *\n * ⚠ **Dropping is not a milder fix here, it is a WRONG one.** The route-meta\n * record is core's working table: `segmentParamsEqual` reads `meta[segmentName]`\n * on every navigation, so with the entry gone the read reaches the INHERITED\n * accessor and answers `Object.prototype` — an object, whose `Object.keys` is\n * `[]`, so the segment reports \"params unchanged\". Measured end to end on a\n * route named `__proto__`: `/p/1` → `/p/2` activates `[\"__proto__\"]` today and\n * `[]` with the entry deleted. Core accepts that name (#1801), so the loss is\n * real and silent.\n *\n * Non-enumerable keeps the read exact for core AND for a consumer asking by\n * key, while `Object.assign` / a spread / `for…in` skip it — measured, all\n * three.\n *\n * ⚠ NOT applied by {@link publishRecord} itself. Its other caller is\n * `buildParamMeta`, whose map core ENUMERATES (`Object.keys` in\n * `segmentParamsEqual`, `for…in` in `hasAnyParam`) and which is not a swap\n * primitive anyway: a param's value is the string `\"url\"` / `\"query\"`, and the\n * inherited setter ignores primitives.\n *\n * Returns the input untouched, with no descriptor write, when the key is absent\n * — which is every ordinary route.\n */\nexport function concealUnsafeKey<V>(\n record: Record<string, V>,\n): Record<string, V> {\n if (!hasOwn(record, UNSAFE_KEY)) {\n return record;\n }\n\n defineProperty(record, UNSAFE_KEY, {\n value: record[UNSAFE_KEY],\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return record;\n}\n\n/**\n * Write one field of a record core BUILDS under a key it did not choose.\n *\n * ⚑ The rule this exists to enforce: **a caller's object contributes DATA, and\n * nothing else.** No trap, no accessor, no inherited member of a bag handed to\n * the router may change what the router ends up holding — which is what\n * \"treat it as a pure dictionary\" means on the WRITE side. `Object.keys` and\n * the one-read-per-key discipline (#1854 / #1899) already say it on the read\n * side; this is the other half.\n *\n * Plain `target[key] = value` cannot say it. `[[Set]]` walks the prototype\n * chain first, so a key that resolves to an accessor or a non-writable data\n * property up there is HIJACKED — the write dispatches into application code\n * (or is silently dropped in sloppy mode, and throws in a module). The key's\n * provenance is irrelevant: `SegmentMatcher` writes a name straight off the\n * ROUTE TABLE, so `id` / `tab` / `page` are as exposed as `__proto__` (#1852),\n * and a name-based skip therefore cannot close it.\n *\n * `Object.defineProperty` CAN say it — it ignores the chain entirely — but it\n * measures ~100 ns per field against ~0 for a store, which is why #1852 priced\n * it as unaffordable on a path that runs per navigation and per `<Link>`\n * render.\n *\n * So the write is guarded rather than replaced: **ask the chain first, and pay\n * only where it answers.** In a pristine environment `in` answers `false` for\n * every name an application routes under, so the store is taken and nothing is\n * paid. It covers both halves of the hazard, which a `__proto__` name test does\n * not: an accessor (getter-only THROWS, getter+setter silently diverts the\n * value) and a **non-writable** data property. Verified on all four shapes plus\n * the overwrite cases.\n *\n * ⚠ It asks `key in target`, NOT `key in Object.prototype`, and the difference\n * is the whole robustness of the primitive rather than a style choice. The\n * cheaper form is right only while every target is a fresh `{}`, i.e. while its\n * chain IS `Object.prototype` — measured, a target inheriting the accessor from\n * anywhere else walks straight past that predicate and throws. Asking the\n * object\n * being written to cannot be wrong for any target. Measured cost of the\n * difference, measured when the two forms were compared directly: a wash on\n * every arc, bought for a predicate with no precondition. ⚠ Those figures\n * predate both the `!hasOwn` term and the restored channel skips, and the\n * number\n * that supersedes them is below — the whole guard sits under the noise floor,\n * so\n * the choice between the two predicates cannot be visible in it.\n *\n * ⚑ **`&& !hasOwn`, and that second term is not an optimisation — it is what\n * keeps this a guarded WRITE instead of a redefinition.** When the key is\n * already an OWN property of the target, `[[Set]]` finds it and never consults\n * the chain, so a plain store is both safe AND semantically right there.\n * `defineProperty` is not: it replaces the whole DESCRIPTOR with this\n * function's\n * fixed one, and that has three measured consequences.\n *\n * - It **throws where a plain store works**: a `configurable: false` own key\n * (a sealed target, an array's `length`) refuses `defineProperty` while\n * accepting an assignment.\n * - It **silently unlocks**: an own `writable: false` key was overwritten and\n * came back writable, and an own `enumerable: false` key came back\n * enumerable — a \"guarded write\" that also removes the guard.\n * - It **changed a shipped shape**, which is how this was caught rather than\n * reasoned about. `RouterError`'s own `stack` is a non-enumerable accessor;\n * `wrapSyncError` passes `stack` through here, so every error built from a\n * thrown one gained an own enumerable `stack`. `Object.keys(err)` changed,\n * and two errors differing only in stack stopped comparing equal under\n * `isDeepStrictEqual` / `toEqual`. The two arms of `rethrowAsRouterError`\n * disagreed with each other, because one of them assigns.\n *\n * `in` answers `false` for a fresh bag's new key and short-circuits, so\n * `hasOwn`\n * runs only on the rare branch it disambiguates. ⚠ That short-circuit does NOT\n * leave the hot path untouched — one dictionary lookup per written field is the\n * price, and it is measured below.\n *\n * ⚠ The alternative that looks equivalent and is not: a prototype-less target.\n * It also closes the axis, and it costs far MORE, because the price is not on\n * the write at all — V8 puts such an object in dictionary mode, so every later\n * READ of the bag pays. Re-measured on the SHIPPED tree rather than carried\n * over from an earlier one: `buildPath` goes **+65.4 %** (one path slot) and\n * **+36.2 %** (slot + query). `{ __proto__: null }` as a literal is no better\n * (76 ns vs 70 ns for `Object.create(null)`, against 7.5 ns plain).\n *\n * ⚑ **The guard COSTS, and \"not measurable\" is a resolution artefact.** Medians\n * of five floor at an A/A of 5-6 %, which hides it; on a quiet machine this\n * harness floors at 0.1-1.7 %, and at that resolution the cost is plain.\n * Same-session A/B, ALTERNATING PROCESSES (two\n * copies of the module in one process is not a valid A/B), medians of 20 pairs,\n * against the SHIPPED bundle rather than `src`, each arc's own A/A floor in\n * brackets:\n *\n * buildPath, splat param 232.4 -> 260.3 ns +12.0 % (0.7 %)\n * isActiveRoute, exact 117.5 -> 125.4 ns +6.8 % (0.1 %)\n * matchPath, path params 664.0 -> 693.8 ns +4.5 % (0.8 %)\n * buildPath, static 97.5 -> 99.2 ns +1.7 % (1.7 %)\n * buildPath, one path slot 145.0 -> 140.5 ns -3.1 % (1.0 %)\n * isActiveRoute, sibling 38.4 -> 38.3 ns -0.3 % (0.3 %)\n *\n * Isolated by building the tree with the predicate replaced by `false`: it is\n * worth -6.1 % on the splat arc and -7.5 % on the exact one, i.e. the whole of\n * the regression there; the rest of `matchPath`'s is `withoutUnsafeKey`\n * (#1904), -2.1 %.\n *\n * ⚠ The old claim was less a bad measurement than a measurement of the WRONG\n * ARCS. `warm-params` and the sibling arm genuinely do not move — those are the\n * two it sampled — while the splat and exact arms do. Sampling what does not\n * move and generalising to \"not measurable\" is the same trap the reachability\n * arguments elsewhere in this file are written against.\n *\n * The price is ACCEPTED, deliberately, and three cheaper forms were measured\n * and rejected before accepting it:\n *\n * - asking a captured `Object.prototype` instead of the target, so the `in`\n * receiver is monomorphic: every arc inside the A/A floor. The cost is the\n * dictionary lookup, not who is asked.\n * - a prototype-less accumulator in `normalizeChannel` published through\n * `publishRecord`: **+134 % … +284 %** — the dictionary-mode price above,\n * now measured end to end rather than argued.\n * - an optimistic plain store repaired afterwards (`hasOwn` + `try`/`catch`):\n * -3.5 % and -2.8 % on two arcs but **+8.3 %** on a third, and it re-opens\n * the descriptor question `&& !hasOwn(target, key)` exists to close.\n *\n * ⚠ **CodSpeed reports this change at -13.83 %, and that is not the shipped\n * cost.** The gap is measured, not assumed. The suite runs\n * `tsx tests/benchmarks/run.ts` — against `src`, unbundled — so its flamegraph\n * carries ESM module-namespace getter frames (`get (ingest.ts)`, 2.67 % of one\n * arc) that the bundle does not have: `grep -c 'get: ()' dist/esm/index.mjs` is\n * 0. `Simulation` mode additionally over-counts instructions a superscalar CPU\n * hides. On the worst-reported arc the sign inverts — -17.25 % simulated,\n * -3.1 % (i.e. FASTER) in the bundle.\n *\n * A prototype-less channel additionally changes a PUBLISHED shape:\n * `state.params` would stop inheriting from `Object.prototype`, which reds\n * tests across **17 packages**, none of them for a behavioural reason.\n *\n * ⚠ **The package count is the half that holds; the TEST count is not restated,\n * because it moves with the tier while the shape does not.** Published as \"263\n * in 15\", corrected to 352/17 by a full-monorepo run, and 374/17 when re-run on\n * 2026-09-04 — three figures, one answer. Re-run the mutation rather than trust\n * a number here: make the two channel singletons and the channel accumulators\n * `Object.create(null)` and run the monorepo. It was never a question of which\n * sites to mutate, because 17 came back every time.\n *\n * The qualitative half is the load-bearing one: the failures are\n * `AssertionError`, none are thrown; they are `toStrictEqual` cells plus a\n * handful of explicit prototype pins; and NO `toEqual` / `toMatchObject` cell\n * moves, which is the internal control that only the prototype axis shifted.\n *\n * ⚑ `defineProperty` also makes `__proto__` an ordinary own key rather than a\n * write that swaps the target's prototype — which is why the `claim.write`\n * (#1191), `assignParam` (#855) and custom-field (#1788) special cases could be\n * replaced by this one primitive instead of kept beside it.\n *\n * ⚠ **It does NOT decide whether that key is PUBLISHED, and the two questions\n * were briefly conflated here.** The channel copy sites in `helpers.ts` still\n * drop `__proto__` before it reaches `state.params` / `state.search`, and that\n * skip is orthogonal to this primitive: a bag core hands BACK carrying the key\n * is a prototype-swap primitive for any consumer that merges it with\n * `Object.assign` — measured, `?__proto__` alone yields `null` and\n * `?__proto__=1&__proto__=2` an array, and the inherited setter accepts both.\n * `getDependenciesApi.getAll()` deletes the same key for the same reason and in\n * those words. Where the record does NOT escape to a merging consumer — a\n * route's custom fields, a plugin's context namespace — the key stays as data,\n * which is what #1788 and #1191 are about.\n */\nexport function putField<V>(\n target: Record<string, V>,\n key: string,\n value: V,\n): void {\n if (key in target && !hasOwn(target, key)) {\n defineProperty(target, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n } else {\n target[key] = value;\n }\n}\n\n/**\n * {@link putField} for a whole source record — what `Object.assign` would do,\n * without the hazard.\n *\n * ⚑ It exists because `Object.assign` IS the hazard, written in a form a census\n * keyed on `dst[key] = value` cannot see. It copies with `[[Set]]`, one key at\n * a\n * time, so every argument in {@link putField}'s docblock applies to it verbatim\n * — and it is the reason this class needed a second look after the obvious\n * sweep: the matcher's junction walk builds `childParams` with a computed-key\n * literal (safe: that DEFINES) and then commits it with `Object.assign` (not).\n * Measured with an ambient setter under a route's own param name, the route\n * still MATCHED and `state.params` came back empty — the URL's parameter gone,\n * with no error anywhere.\n *\n * `Object.entries` for the walk: it hands back the value it already read, so\n * there is exactly ONE read per key and no window for a drifting accessor\n * between the test and the use (#1899). It is also the idiom the sibling copy\n * loops use.\n *\n * ⚠ **Two things it does NOT buy, both measured.**\n *\n * - It is **not** a filter against a lying Proxy source. `ownKeys` is asked\n * first, so a key that list does not contain cannot appear — but a source\n * whose `ownKeys` DOES name a phantom and whose descriptor trap calls it\n * enumerable gets that phantom copied, identically to `Object.assign`. The\n * #1854 protection is narrower than \"the trap is never consulted\".\n * - It is **not** a drop-in for `Object.assign`. `Object.entries` is\n * string-keyed, so own enumerable SYMBOL entries are dropped where\n * `Object.assign` copies them. That matches core's stated policy for the\n * channels (\"symbols are dropped, always\") and is a real behaviour difference\n * from `Object.assign` at one call site (`persistent-params`' factory). ⚠ It also disagrees with `publishRecord`\n * two functions up, which spreads and therefore keeps symbols — the same\n * internal split `helpers.ts` records as the #1792 defect.\n */\nexport function copyFields<V>(\n target: Record<string, V>,\n source: Record<string, V>,\n): void {\n for (const [key, value] of objectEntries(source)) {\n putField(target, key, value);\n }\n}\n","// packages/core/src/RouterError.ts\n\nimport { errorCodes, UNSAFE_KEY } from \"./constants\";\nimport { recordConstruction } from \"./navigationEnds\";\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 *\n * ⚑ It also records the error as one core built: `navigationEnds.ts` keeps a\n * navigation's end only when core built it.\n */\nexport function freezeThrownError<E extends RouterError>(error: E): E {\n recordConstruction(error);\n\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 atRouterError.type`Cannot set reserved property \"${key}\"`;\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 atSetErrorInstance.type`err parameter is required and must be an Error instance`;\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 atSetAdditionalFields.type`Cannot set reserved property \"${key}\"`;\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\n/**\n * A receiver a reader can IMPORT, plus this package's own name for a refusal no\n * call reaches (#1845). The door beside it is an unconstrained `string`, so the\n * type is not the guard — `message-prefix-authority-1845` judges the argument.\n */\nexport type Receiver =\n \"router\" | \"RouterError\" | \"cloneRouter\" | \"validation-plugin\";\n\ntype Tag<E extends Error> = (\n strings: TemplateStringsArray,\n ...values: unknown[]\n) => E;\n\n/** One member per constructor the refusal surface holds. */\nexport interface Raiser {\n /**\n * ⚠ `type` and `plain` also take `ErrorOptions` and RETURN the tag, because\n * `cause` cannot be attached afterwards: measured, the constructor defines it\n * non-enumerable and an assignment defines it enumerable.\n */\n type: Tag<TypeError> & ((options: ErrorOptions) => Tag<TypeError>);\n plain: Tag<Error> & ((options: ErrorOptions) => Tag<Error>);\n ref: Tag<ReferenceError>;\n range: Tag<RangeError>;\n /**\n * A coded `RouterError`, frozen for the throw (#1960) — so a site using this\n * flavour needs no `freezeThrownError` of its own. `fields` carries the bag's\n * other entries; `message` is not among them, since the template writes it.\n */\n code: (\n code: string,\n fields?: Readonly<Record<string, unknown>>,\n ) => Tag<RouterError>;\n}\n\n/** A refusal unreachable from caller input: no bracket, an explicit marker. */\nexport interface InternalDefect {\n plain: Tag<Error>;\n}\n\nconst interpolate = (\n strings: TemplateStringsArray,\n values: readonly unknown[],\n): string => {\n let text = strings[0];\n\n for (const [index, value] of values.entries()) {\n text += String(value) + strings[index + 1];\n }\n\n return text;\n};\n\n/**\n * Build the refusals of one door, so the head is written once per module rather\n * than once per throw (#2487).\n *\n * ```ts\n * const at = raiser(\"router\", \"buildPath\");\n *\n * throw at.type`Missing required param '${name}'`;\n * throw at.code(errorCodes.ROUTE_NOT_FOUND, { routeName })`No route '${routeName}'`;\n * ```\n *\n * ⚠ It RETURNS the error rather than throwing it, so the site keeps `throw` —\n * which greps, narrows types natively, and leaves room to tag the error between\n * construction and throw, as the search-params config fault does.\n *\n * ⚠ Omit `door` only where several doors reach one raiser; a head that names a\n * door the caller never called is the defect this exists to remove.\n */\nexport function raiser(receiver: Receiver, door?: string): Raiser {\n // An empty door reads as the bare form rather than printing `[router.]`, a\n // head that looks like a door without naming one.\n const head =\n door === undefined || door === \"\"\n ? `[${receiver}] `\n : `[${receiver}.${door}] `;\n const message = (\n strings: TemplateStringsArray,\n values: readonly unknown[],\n ): string => head + interpolate(strings, values);\n\n const flavour = <E extends Error>(\n build: (text: string, options?: ErrorOptions) => E,\n ): Tag<E> & ((options: ErrorOptions) => Tag<E>) =>\n ((\n first: TemplateStringsArray | ErrorOptions,\n ...values: readonly unknown[]\n ) =>\n Array.isArray(first)\n ? build(message(first as TemplateStringsArray, values))\n : (strings: TemplateStringsArray, ...rest: readonly unknown[]) =>\n build(message(strings, rest), first as ErrorOptions)) as Tag<E> &\n ((options: ErrorOptions) => Tag<E>);\n\n return {\n type: flavour((text, options) => new TypeError(text, options)),\n plain: flavour((text, options) => new Error(text, options)),\n ref: (strings, ...values) => new ReferenceError(message(strings, values)),\n range: (strings, ...values) => new RangeError(message(strings, values)),\n code:\n (code, fields) =>\n (strings, ...values) =>\n freezeThrownError(\n new RouterError(code, {\n ...fields,\n message: message(strings, values),\n }),\n ),\n };\n}\nconst atRouterError = raiser(\"RouterError\");\nconst atSetErrorInstance = raiser(\"RouterError\", \"setErrorInstance\");\nconst atSetAdditionalFields = raiser(\"RouterError\", \"setAdditionalFields\");\n\n/**\n * A defect a caller cannot provoke. Unbracketed on purpose: there is no door to\n * name, and a marker is greppable where a bare sentence is not (#1845).\n */\nexport const internalDefect: InternalDefect = {\n plain: (strings, ...values) =>\n new Error(\n `Internal error (please report): ${interpolate(strings, values)}`,\n ),\n};\n"],"mappings":"AA0BA,MAAaE,EAAkC,OAAO,OAAO,CAC3D,mBAAoB,cACpB,uBAAwB,yBACxB,uBAAwB,kBACxB,gBAAiB,kBACjB,YAAa,cACb,kBAAmB,oBACnB,gBAAiB,kBACjB,eAAgB,iBAChB,qBAAsB,YACtB,gBAAiB,WACjB,gBAAiB,kBACjB,kCAAmC,oCACnC,qBAAsB,uBACtB,wBAAyB,0BACzB,mBAAoB,cACpB,cAAe,eACjB,CAAC,EAMYC,EAAgB,yBAyBhBC,EAAa,YAEbC,EAAuB,OAAO,OAAO,CAChD,eACF,CAAC,EAMYC,EAA4B,OAAO,OAAO,CACrD,aAAc,UACd,YAAa,SACb,iBAAkB,oBAClB,yBAA0B,2BAC1B,kBAAmB,qBACnB,m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ACJC,IAAS,IAAA,IAAaA,IAAS,GAC3B,IAAIC,EAAS,IACb,IAAIA,EAAS,GAAGD,EAAK,IACrBhB,GACJ,EACA,IACWe,EAAON,EAAYE,EAASE,CAAM,EAEzCK,EACJ,KAGE,EACA,GAAGL,IAEH,MAAM,QAAQM,CAAK,EACfC,EAAMpB,EAAQmB,EAA+BN,CAAM,CAAC,GACnD,EAA+B,GAAGd,IACjCqB,EAAMpB,EAAQW,EAASZ,CAAI,EAAGoB,CAAqB,GAG7D,MAAO,CACL,KAAMD,GAAS,EAAM,IAAgB,UAAUR,EAAMW,CAAO,CAAC,EAC7D,MAAOH,GAAS,EAAM,IAAgB,MAAMR,EAAMW,CAAO,CAAC,EAC1D,KAAM,EAAS,GAAGR,IAAe,eAAeb,EAAQW,EAASE,CAAM,CAAC,EACxE,OAAQ,EAAS,GAAGA,IAAe,WAAWb,EAAQW,EAASE,CAAM,CAAC,EACtE,MACG,EAAM,KACN,EAAS,GAAGA,IACXhB,EACE,IAAIC,EAAYG,EAAM,CACpB,GAAGK,EACH,QAASN,EAAQW,EAASE,CAAM,CAClC,CAAC,CACH,CACN,CACF,CACA,MAAMS,EAAgBR,EAAO,aAAa,EACpCS,EAAqBT,EAAO,cAAe,kBAAkB,EAC7DU,EAAwBV,EAAO,cAAe,qBAAqB,EAM5DW,EAAiC,CAC5C,OAAQ,EAAS,GAAGZ,IACd,MACF,mCAAmCJ,EAAYE,EAASE,CAAM,GAChE,CACJ,E"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{g as e,h as t,i as n,l as r,m as i,v as a}from"./RouterError-DyPeuufj.mjs";const o=n(`router`),s=Object.freeze,c=Object.hasOwn,l=Object.keys,u=Object.getPrototypeOf,d=Array.isArray,f=Array.prototype.slice,p=`signal`;function m(e,t){if(e===void 0)return t;let n={};for(let t of l(e)){if(t===`__proto__`)continue;let i=e[t];i!==void 0&&r(n,t,i)}if(t!==void 0)for(let e of l(t)){if(e===`__proto__`)continue;let i=t[e];i!==void 0&&r(n,e,i)}return n}const h=new Set([`string`,`number`,`boolean`]);function g(e){return h.has(typeof e)}function _(e,t){if(e===t)return!0;if(Array.isArray(e)){let n=e.length;if(!Array.isArray(t))return n===1&&_(e[0],t);if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!_(e[r],t[r]))return!1;return!0}return Array.isArray(t)?t.length===1&&_(e,t[0]):g(e)&&g(t)&&String(e)===String(t)}function v(e,t){let n=l(e),r=l(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!_(e[i],t[i]))return!1;return!0}function y(e,t,n){if(n.length===0)return!0;let r=l(e),i=l(t);for(let a of n)if(!_(r.includes(a)?e[a]:void 0,i.includes(a)?t[a]:void 0))return!1;return!0}function b(e){return s(e)}function x(e,t,n){return e===void 0?t===void 0||t===n?n:t:m(e,t)}function S(e,n){return x(e,n,t)}function C(t,n){let r=x(t,n,e);return r===e?r:s(r)}function w(e,t){if(e==null||e===t)return t;let n={};for(let t of l(e)){if(t===`__proto__`)continue;let i=e[t];i!==void 0&&r(n,t,i)}return s(n)}function T(e){let t={};for(let n of l(e)){if(n===`__proto__`)continue;let i=e[n];i!==void 0&&r(t,n,d(i)?s(f.call(i)):i)}return s(t)}function E(e){let t={};for(let n of l(e)){if(n===`__proto__`)continue;let i=e[n];i!==void 0&&(n===`segments`?i!==null&&r(t,n,T(i)):r(t,n,i))}return s(t)}function D(e){return c(e,p)?e.signal:void 0}function O(e,t){return c(e,t)?e[t]:void 0}function k(e){if(e===i)return i;let t={},n=e;for(let e of l(n))e!==`__proto__`&&e!==p&&r(t,e,n[e]);return s(t)}function A(e,t){if(e===void 0)return e;if(e===null)return t;let n;for(let t of l(e)){if(t===`__proto__`)continue;let i=e[t];i!==void 0&&(n??={},r(n,t,i))}return n??t}function j(e){if(e==null)return e;let t=u(e);return!Array.isArray(e)&&(t===null||t===Object.prototype)?{...e}:e}function M(e){return delete e[a],e}function N(e,t){if(typeof t!=`object`||!t)return t;try{let e=Array.isArray(t)?[...t]:{...t};return s(M(e))}catch(t){throw o.type({cause:t})`Invalid "${e}": reading it threw.`}}function P(e){if(!c(e,`__proto__`))return e;let t={};for(let n of l(e))n!==`__proto__`&&r(t,n,e[n]);return t}export{P as _,_ as a,b as c,C as d,A as f,y as g,v as h,k as i,m as l,D as m,w as n,N as o,O as p,E as r,M as s,j as t,S as u};
|
|
2
|
-
//# sourceMappingURL=helpers-BXXeSrT8.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-BXXeSrT8.mjs","names":["EMPTY_SEARCH","EMPTY_PARAMS","raiser","putField","EMPTY_OPTS","UNSAFE_KEY","atRouter","freeze","hasOwn","objectKeys","getPrototypeOf","isArray","arraySlice","SIGNAL_KEY","mergeDefined","defaultValue","value","merged","key","entry","PRINTABLE_TYPES","isPrintableScalar","areParamValuesEqual","val1","val2","length1","i","recordsShallowEqual","leftKeys","left","rightKeys","right","slotsShallowEqual","slots","slot","freezeStateShell","state","mergeOwnChannel","empty","mergePathChannel","defaultParams","bag","mergeQueryChannel","defaultSearch","adoptForeignBag","copy","adoptForeignSegments","adoptForeignTransition","ownSignal","opts","ownFlag","adoptNavigationOptions","normalizeChannel","normalized","adoptChannel","proto","dropUnsafeKey","fresh","copyOwnData","error","field","withoutUnsafeKey"],"sources":["../../src/helpers.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 { raiser } from \"./RouterError\";\nimport { putField } from \"./utils/ingest\";\n\nimport type { NavigationOptions, State, TransitionMeta } from \"./types\";\n\n/** One binding per door this module refuses behind (#2487). */\nconst atRouter = raiser(\"router\");\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 an object `normalizeChannel` returned,\n * so nothing outside holds a reference to protect and each channel's own\n * publication rule decides the freeze. PROVENANCE is the guarantee, not\n * proximity — the query bag is minted on the line above its use in\n * `canonicalize`, the path bag two hundred lines above its own, and both are\n * equally core's. 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 // ⚑ `Array.isArray` is NOT an unreachable arm, and the copy is why it matters\n // (#2282). The prototype read below goes through a `Proxy`'s trap, so an array\n // can present itself as plain — and the `true` branch SPREADS it, turning a\n // non-bag into a genuine `{0:…,1:…}`. Every shape check downstream then asks\n // what the value IS and finds nothing wrong, because the laundering already\n // happened. `IsArray` unwraps proxies to the target, so it survives the lie.\n //\n // `null` is excluded above because it is the one value that cannot be asked\n // for a prototype at all.\n const proto = getPrototypeOf(bag) as object | null;\n\n return !Array.isArray(bag) && (proto === null || proto === Object.prototype)\n ? { ...bag }\n : 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 atRouter.type({\n cause: error,\n })`Invalid \"${field}\": reading it threw.`;\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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,EAEvC,IAAK,IAAM3B,KAAOT,EAAWgC,CAAG,EAC1BvB,IAAA,aAGFf,EAAS0C,EAAM3B,EAAKuB,EAAIvB,EAAI,EAIhC,OAAO2B,CACT,C"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as e,c as t,i as n,n as r,s as i,t as a}from"./RouterError-DyPeuufj.mjs";const o=Object.hasOwn;function s(e,t){if(t.length!==0&&e!=null)for(let n of t){if(!o(e,n))continue;let t;try{t=e[n]}catch{return}if(t!==void 0)return n}}function c(e,t,r,i,a,o){let c=s(r,i);if(c!==void 0)throw n(`router`,e).type`${u(t,c,typeof a==`function`?a():a,o)}`}function l(e,t,n,r){c(e,t,n,r,"the `params` bag this call is about to ship — the channel check above it read a different value, so the caller's object answered differently between the two reads")}function u(e,t,n="the `params` argument",r="Pass it in `search` instead"){return`Route "${e}" declares \`${t}\` as a query param, but it was given in ${n} — the path channel. ${r}; the two channels are separate since RFC-4 M2 and the router never moves a key between them.`}const d=e=>e===58||e===42;function f(e){let t=[],n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===47&&(t.push(e.slice(n,r)),n=r+1);return t.push(e.slice(n)),t}function p(e){let t=e.length;if(t===0)return{kind:`static`,text:``};if(!d(e.charCodeAt(0))){for(let n=0;n<t;n+=1){let r=e.charCodeAt(n);if(r===60||r===62)return{error:`constraint-removed`};if(d(r)&&n+1<t)return{error:`fused-marker`}}return e.charCodeAt(t-1)===63?{error:`name-less`}:{kind:`static`,text:e}}let n=e.charCodeAt(0)===42,r=1;for(;r<t;){let t=e.charCodeAt(r);if(t===60||t===62||t===63)break;r+=1}let i=e.slice(1,r);return i.length===0?{error:`name-less`}:d(i.charCodeAt(i.length-1))?{error:`trailing-marker`}:r<t?e.charCodeAt(r)===63?{error:`optional-removed`}:{error:`constraint-removed`}:n?{kind:`splat`,name:i}:{kind:`param`,name:i}}function m(e){for(let t of f(e)){let e=p(t);if(`error`in e)return e.error}}function ee(e){let t=f(e);for(let e=0;e<t.length;e+=1){let n=p(t[e]);if(`error`in n){if(n.error===`optional-removed`){let n=t[e],r=[...t];return r[e]=n.slice(0,n.indexOf(`?`)),{code:`optional-removed`,segment:n,withoutSegment:t.filter((t,n)=>n!==e).join(`/`),requiredForm:r.join(`/`)}}return n.error===`constraint-removed`?{code:`constraint-removed`,segment:t[e]}:void 0}}}const h=/[<>]/u;function g(e){for(let t=0;t<e.length;t+=1){if(e.codePointAt(t)!==63)continue;let n=t+1<e.length?e.codePointAt(t+1):-1;if(n!==-1&&n!==47&&n!==63&&n!==60)return t}return-1}const _=Object.freeze([]),v=Object.freeze({}),te=Object.freeze({urlParams:_,queryParams:_,paramTypeMap:v,pathPattern:``});function y(e,t,n){for(let r of f(e)){if(r.length===0)continue;let e=p(r);`error`in e||e.kind===`static`||(t.push(e.name),n[e.name]=`url`)}}function b(e){let n=[],r=[],a=i(),o=g(e);if(o!==-1){let t=e.slice(o+1).split(`&`);for(let e of t){let t=e.trim();t.length>0&&(r.push(t),a[t]=`query`)}e=e.slice(0,o)}return y(e,n,a),x(n,r,t(a),e)}function x(e,t,n,r){return{urlParams:e.length===0?_:e,queryParams:t.length===0?_:t,paramTypeMap:e.length===0&&t.length===0?v:n,pathPattern:r}}const S=/^[A-Z_a-z][\w-]*$/,C=/\S/,w=1e4;function T(e,t){if(e===``)throw n(`router`,t).type`Route name cannot be empty`}function E(e,t){if(!C.test(e))throw n(`router`,t).type`Route name cannot contain only whitespace`}function ne(e,t){if(e.length>w)throw n(`router`,t).type`Route name exceeds maximum length of ${w} characters`}function D(e,t){if(e.includes(`.`))throw n(`router`,t).type`Route name "${e}" cannot contain dots. Use children array or { parent } option in addRoute() instead.`}function re(e,t){if(!S.test(e))throw n(`router`,t).type`Invalid route name "${e}". Name must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens.`}function O(e,t){return n(`router`,e).type`${t}`}function k(e,t,n,r){let i=new Set;for(let a of e){if(i.has(a))throw O(n,`Invalid path for route "${t}": duplicate parameter name ':${a}' in "${r}" (a param name must be unique within a route — the second binding would overwrite the first)`);i.add(a)}}function A(e,t,n,r){for(let i of e)if(h.test(i))throw O(n,`Invalid path for route "${t}": invalid query-param name "${i}" in "${r}" (a query-param name cannot contain '<' or '>' — it would never round-trip; rename the query param)`)}function j(e){let t=!0,n=!1;for(let r of e)if(r===`/`)t=!0;else if(t&&=(n=r===`:`||r===`*`,!1),!n&&r.codePointAt(0)>=128)return!0;return!1}function M(e,t,n){switch(e){case`name-less`:case`trailing-marker`:return`Invalid path for route "${t}": parameter marker (':' or '*') without a name in "${n}"`;case`fused-marker`:return`Invalid path for route "${t}": parameter marker (':' or '*') must begin a segment, but "${n}" fuses one to a static prefix (use a boundary marker like "/a/:b")`}}function N(e,t){return e.code===`optional-removed`?`Invalid path for route "${t}": optional params are not supported — "${e.segment}". Declare two sibling routes instead: "${e.withoutSegment}" and "${e.requiredForm}" (the route hierarchy already expresses optionality)`:`Invalid path for route "${t}": regex constraints are not supported — '<' and '>' are reserved in path segments ("${e.segment}"). Match the segment as a plain string and validate the value in a guard (canActivate) or app code`}function P(e,t,n,r){if(typeof e!=`string`){let t;throw t=e===null?`null`:Array.isArray(e)?`array`:typeof e,O(n,`Route path must be a string, got ${t}`)}if(e===``)return;if(/\s/.test(e))throw O(n,`Invalid path for route "${t}": whitespace not allowed in "${e}"`);if(!/^([/?~]|[^/]+$)/.test(e))throw O(n,`Route "${t}" has invalid path format: "${e}". Path should start with '/', '~', '?' or be a relative segment.`);if(e.includes(`//`))throw O(n,`Invalid path for route "${t}": double slashes not allowed in "${e}"`);let{pathPattern:i,urlParams:a,queryParams:o}=b(e);k(a,t,n,e),A(o,t,n,e);let s=ee(i);if(s!==void 0)throw O(n,N(s,t));let c=m(i);if(c!==void 0)throw O(n,M(c,t,e));if(j(i))throw O(n,`Invalid path for route "${t}": non-ASCII static segment in "${e}" — match compares static segments raw and rejects non-ASCII input, so this route would never match. Percent-encode it (e.g. '/caf%C3%A9') or use a param`);let l=r&&r.paramMeta.urlParams.length>0;if(e.startsWith(`~`)&&l)throw O(n,`Absolute path "${e}" cannot be used under parent route with URL parameters`)}const F=Object.getOwnPropertyDescriptor,I=Object.keys,L=Object.getPrototypeOf;function R(e){if(e===null)return`null`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`){let e=t.name;if(typeof e==`string`&&e!==``&&e!==`Object`)return e}}catch{}return`object`}return typeof e}function z(e){for(let t of I(e)){let n=F(e,t);if(n&&(n.get||n.set))return!0}return!1}function B(e,t){if(!e||typeof e!=`object`)throw n(`router`,t).type`Route must be an object, got ${R(e)}`;let r=L(e);if(r!==Object.prototype&&r!==null)throw n(`router`,t).type`Route must be a plain object, got ${R(e)}`;if(z(e))throw n(`router`,t).type`Route must not have getters or setters`}function V(e,t,r,i){if(typeof t!=`function`)throw n(`router`,i).type`Route "${r}" ${e} must be a function`}function H(e,t,n,r){t!==void 0&&V(e,t,n,r)}function U(e,t){if(typeof e.name!=`string`)throw n(`router`,t).type`Route name must be a string, got ${R(e.name)}`;let r=e.name;T(r,t),E(r,t),ne(r,t),!r.startsWith(`@@`)&&(D(r,t),re(r,t))}function W(e,t){if(!t.includes(`.`))return e.children.get(t);let n=e;for(let e of t.split(`.`))if(n=n.children.get(e),!n)return;return n}function G(e,t,r){if(W(e,t))throw n(`router`,r).plain`Route "${t}" already exists`}function K(e,t,r){if(e.has(t))throw n(`router`,r).plain`Duplicate route "${t}" in batch`;e.add(t)}function q(e,t,r,i){let a=t===``?e:W(e,t);if(a){for(let e of a.children.values())if(e.path===r)throw n(`router`,i).plain`Path "${r}" is already defined`}}function J(e,t,r,i){let a=e.get(t);if(a?.has(r))throw n(`router`,i).plain`Path "${r}" is already defined`;a?a.add(r):e.set(t,new Set([r]))}function Y(e,t,r,i=``,a,o){B(e,t);let s=e;U(s,t),P(s.path,s.name,t,r);let c=s.name,l=i?`${i}.${c}`:c;H(`encodeParams`,s.encodeParams,l,t),H(`decodeParams`,s.decodeParams,l,t),r&&l&&G(r,l,t),a&&K(a,l,t);let u=s.path,d=i;if(r&&q(r,d,u,t),o&&J(o,d,u,t),s.children!==void 0){if(!Array.isArray(s.children))throw n(`router`,t).type`Route "${c}" children must be an array, got ${R(s.children)}`;for(let e of s.children)Y(e,t,r,l,a,o)}}const X=new WeakMap,Z=Symbol.for(`real-router.router`);function ie(e){try{return e?.[Z]===!0}catch{return!1}}function ae(e){let t=X.get(e);if(!t)throw TypeError(ie(e)?"[real-router] This IS a router, but not one this copy of @real-router/core built. Core identifies a router by object identity, so it is either wrapped in a Proxy (Vue `reactive()` / Pinia — store it with `markRaw`), or your dependency tree holds two copies of @real-router/core — dedupe it to one.":`[real-router] Invalid router instance — not found in internals registry`);return t}function oe(e,t,n,r){c(t,n,r,e.getDeclaredQueryNames(n))}function se(t){if(t())throw r(new a(e.ROUTER_DISPOSED,{message:`[router] this router is disposed — dispose() is terminal`}))}function Q(e,t){X.set(e,t),Object.defineProperty(e,Z,{value:!0})}function $(e,t,n,r){let i=t;for(let t of e){let e=i,n=r===void 0?e:(...t)=>r(e(...t));i=(...e)=>t(n,...e)}return i(...n)}const ce={start:`start`,forwardState:`forwardState`},le={PLUGIN_AFTER_START:`PLUGIN_AFTER_START`},ue={"buildPath:params":`buildPath:params`,"buildPathResolved:params":`buildPathResolved:params`,"canNavigateTo:entry":`canNavigateTo:entry`,"canNavigateTo:params":`canNavigateTo:params`,"navigate:entry":`navigate:entry`,"navigate:params":`navigate:params`,"addRoute:batch":`addRoute:batch`,"replaceRoutes:batch":`replaceRoutes:batch`,"removeRoute:entry":`removeRoute:entry`,"updateRoute:entry":`updateRoute:entry`,"hasRoute:entry":`hasRoute:entry`,"getRoute:entry":`getRoute:entry`,"forwardState:entry":`forwardState:entry`,"buildNavigationState:state":`buildNavigationState:state`,"addActivateGuard:entry":`addActivateGuard:entry`,"addDeactivateGuard:entry":`addDeactivateGuard:entry`,"removeActivateGuard:entry":`removeActivateGuard:entry`,"removeDeactivateGuard:entry":`removeDeactivateGuard:entry`};function de(e,t,...n){let r=e.get(t);if(r===void 0)return;let i=r.length;for(let e=0;e<i&&e<r.length;e++)r[e](...n)}function fe(e,t,n){return((...r)=>{let i=n.get(e);return!i||i.length===0?t(...r):$(i,t,r)})}function pe(e,t,n,r,i){return(a,o,s)=>{let c=n.get(e);return!c||c.length===0?t(a,o,s):$(c,t,i(a,o,s),r)}}export{s as C,l as S,h as _,pe as a,f as b,de as c,V as d,Y as f,te as g,T as h,fe as i,se as l,D as m,ue as n,ae as o,B as p,ce as r,Q as s,le as t,oe as u,b as v,u as w,c as x,p as y};
|
|
2
|
-
//# sourceMappingURL=internals-D-5hS0qt.mjs.map
|