@real-router/core 0.139.0 → 0.140.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Router-NcUbf7cb.js → Router-C2cC4TOn.js} +2 -2
- package/dist/cjs/Router-C2cC4TOn.js.map +1 -0
- package/dist/cjs/Router.d.ts.map +1 -1
- package/dist/cjs/api/getDependenciesApi.d.ts.map +1 -1
- package/dist/cjs/api/getPluginApi.d.ts.map +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/dependenciesStore.d.ts +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/RouterValidator.d.ts +37 -7
- package/dist/cjs/types/RouterValidator.d.ts.map +1 -1
- package/dist/cjs/types/api.d.ts +47 -0
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/esm/{Router-BDfDkG7r.mjs → Router-CH2EdcKj.mjs} +2 -2
- package/dist/esm/Router-CH2EdcKj.mjs.map +1 -0
- package/dist/esm/Router.d.mts.map +1 -1
- package/dist/esm/api/getDependenciesApi.d.mts.map +1 -1
- package/dist/esm/api/getPluginApi.d.mts.map +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/dependenciesStore.d.mts +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/types/RouterValidator.d.mts +37 -7
- package/dist/esm/types/RouterValidator.d.mts.map +1 -1
- package/dist/esm/types/api.d.mts +47 -0
- package/dist/esm/types/api.d.mts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-NcUbf7cb.js.map +0 -1
- package/dist/esm/Router-BDfDkG7r.mjs.map +0 -1
|
@@ -7,8 +7,8 @@ import { Limits } from "./types/internal.js";
|
|
|
7
7
|
* sake lives in this module; the edits a caller asks for live in
|
|
8
8
|
* `getDependenciesApi`.
|
|
9
9
|
*
|
|
10
|
-
* ⚠ `limits` is read by
|
|
11
|
-
*
|
|
10
|
+
* ⚠ `limits` is read by `getDependenciesApi` for the count check and handed
|
|
11
|
+
* out as `PluginApi.getResolvedLimits()`.
|
|
12
12
|
*/
|
|
13
13
|
export interface DependenciesStore<Dependencies extends DefaultDependencies = DefaultDependencies> {
|
|
14
14
|
dependencies: Partial<Dependencies>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./RouterError-C-p1yaby.js"),t=require("./Router-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./RouterError-C-p1yaby.js"),t=require("./Router-C2cC4TOn.js"),n=(e=[],n={},r={})=>new t.t(e,n,r),r=Object.freeze,i=new WeakMap,a=e=>{let t=i.get(e);return t||(t=r({navigate:e.navigate,getState:e.getState,isActiveRoute:e.isActiveRoute,canNavigateTo:e.canNavigateTo,subscribe:e.subscribe,subscribeLeave:e.subscribeLeave,isLeaveApproved:e.isLeaveApproved}),i.set(e,t)),t};exports.Router=t.t,exports.RouterError=e.t,exports.UNKNOWN_ROUTE=e.p,exports.constants=e.h,exports.createRouter=n,exports.errorCodes=e.g,exports.events=e._,exports.getNavigator=a,exports.resolveForwardChain=t.v;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* When ctx.validator is null (default), validation is skipped.
|
|
7
7
|
* When ctx.validator is set (by validation plugin), all methods are called.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Parameters that carry a caller-supplied value use `unknown`, to avoid coupling
|
|
10
|
+
* to internal type names. ⚠ That is not a blanket rule: where core already holds
|
|
11
|
+
* the fact the analyser judges, the fact travels — a number, a name, a value —
|
|
12
|
+
* rather than the container it was read from (#2382).
|
|
10
13
|
*/
|
|
11
14
|
export interface RouterValidator {
|
|
12
15
|
/**
|
|
@@ -19,12 +22,24 @@ export interface RouterValidator {
|
|
|
19
22
|
validateShouldUpdateNodeArgs: (name: unknown) => void;
|
|
20
23
|
validateStateBuilderArgs: (name: unknown, params: unknown, caller: string) => void;
|
|
21
24
|
validateAddRouteArgs: (routes: unknown) => void;
|
|
22
|
-
|
|
25
|
+
/**
|
|
26
|
+
* ⚑ Takes no store (#2382). The analyser reads the three facts it judges
|
|
27
|
+
* from `PluginApi`: the path slots and the ONE-HOP forward map come back as
|
|
28
|
+
* frozen values, and the tree is the published one `getTree()` already hands
|
|
29
|
+
* out — no container travels that the curated surface does not.
|
|
30
|
+
*/
|
|
31
|
+
validateRoutes: (routes: unknown[], parentName?: string) => void;
|
|
23
32
|
validateRemoveRouteArgs: (name: unknown) => void;
|
|
24
33
|
validateUpdateRouteBasicArgs: (name: unknown, updates: unknown) => void;
|
|
25
34
|
validateUpdateRoutePropertyTypes: (name: string, updates: unknown) => void;
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
/** Reads the same three facts from `PluginApi` as `validateRoutes` (#2382). */
|
|
36
|
+
validateUpdateRoute: (name: string, updates: unknown) => void;
|
|
37
|
+
/**
|
|
38
|
+
* ⚑ Takes no tree (#2382): the analyser reads it from `PluginApi.getTree()`,
|
|
39
|
+
* which hands out the same object — the tree is published already, so
|
|
40
|
+
* passing it as an argument added a second address and nothing else.
|
|
41
|
+
*/
|
|
42
|
+
validateParentOption: (parent: unknown) => void;
|
|
28
43
|
validateRouteName: (name: unknown, caller: string) => void;
|
|
29
44
|
throwIfInternalRoute: (name: unknown, caller: string) => void;
|
|
30
45
|
throwIfInternalRouteInArray: (routes: unknown[], caller: string) => void;
|
|
@@ -37,7 +52,8 @@ export interface RouterValidator {
|
|
|
37
52
|
*/
|
|
38
53
|
options: {
|
|
39
54
|
validateOptions: (options: unknown, methodName: string) => void;
|
|
40
|
-
|
|
55
|
+
/** Reads the tree from `PluginApi.getTree()`, like `validateParentOption` (#2382). */
|
|
56
|
+
validateResolvedDefaultRoute: (routeName: unknown) => void;
|
|
41
57
|
};
|
|
42
58
|
/**
|
|
43
59
|
* Dependencies validation methods
|
|
@@ -46,8 +62,22 @@ export interface RouterValidator {
|
|
|
46
62
|
validateDependencyName: (name: unknown, caller: string) => void;
|
|
47
63
|
validateSetDependencyArgs: (name: unknown, value: unknown, caller: string) => void;
|
|
48
64
|
validateDependenciesObject: (deps: unknown, caller: string) => void;
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
/**
|
|
66
|
+
* ⚑ Takes the VALUE core read, not the store that holds it (#2382). The
|
|
67
|
+
* question is whether the name resolved to anything, and core has the answer
|
|
68
|
+
* one line earlier: `readDependency` performs exactly that lookup.
|
|
69
|
+
*/
|
|
70
|
+
validateDependencyExists: (name: string, value: unknown) => void;
|
|
71
|
+
/**
|
|
72
|
+
* ⚑ Takes the two NUMBERS it judges, not the store that holds them (#2382).
|
|
73
|
+
* `maxDependencies` arrives already resolved by `createLimits`, which takes
|
|
74
|
+
* this path out of the default-drift #1879 names.
|
|
75
|
+
*
|
|
76
|
+
* ⚠ Both arguments sit inside the optional chain on purpose: with no
|
|
77
|
+
* validator installed the `?.` short-circuits the whole chain, arguments
|
|
78
|
+
* included, so the key count is never walked.
|
|
79
|
+
*/
|
|
80
|
+
validateDependencyCount: (currentCount: number, maxDependencies: number, methodName: string) => void;
|
|
51
81
|
validateCloneArgs: (dependencies: unknown) => void;
|
|
52
82
|
warnOverwrite: (name: string, methodName: string) => void;
|
|
53
83
|
warnBatchOverwrite: (keys: string[], methodName: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterValidator.d.ts","names":[],"sources":["../../../src/types/RouterValidator.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RouterValidator.d.ts","names":[],"sources":["../../../src/types/RouterValidator.ts"],"mappings":";;;;;;;;;;;;;iBAaiB;;;;EAIf;IACE,wBAAwB,gBAAgB;IACxC,wBAAwB;IACxB,4BACE,eACA,iBACA,iBACA;IAEF,+BAA+B;IAC/B,2BACE,eACA,iBACA;IAEF,uBAAuB;;;;;;;IAOvB,iBAAiB,mBAAmB;IACpC,0BAA0B;IAC1B,+BAA+B,eAAe;IAC9C,mCAAmC,cAAc;;IAEjD,sBAAsB,cAAc;;;;;;IAMpC,uBAAuB;IACvB,oBAAoB,eAAe;IACnC,uBAAuB,eAAe;IACtC,8BAA8B,mBAAmB;IACjD,0BAA0B;IAC1B,sBAAsB;IACtB,wBAAwB;;;;;EAM1B;IACE,kBAAkB,kBAAkB;;IAEpC,+BAA+B;;;;;EAMjC;IACE,yBAAyB,eAAe;IACxC,4BACE,eACA,gBACA;IAEF,6BAA6B,eAAe;;;;;;IAM5C,2BAA2B,cAAc;;;;;;;;;;IAUzC,0BACE,sBACA,yBACA;IAEF,oBAAoB;IACpB,gBAAgB,cAAc;IAC9B,qBAAqB,gBAAgB;IACrC,wBAAwB;;;;;EAM1B;IACE,sBAAsB,eAAe;IACrC,6BACE,kBACA;IAEF,qBAAqB;IACrB,0BAA0B;IAC1B,sBAAsB;IACtB,uBAAuB;IACvB,uBAAuB;;;;;EAMzB;IACE,kBAAkB,kBAAkB;IACpC,uBAAuB,eAAe;IACtC,0BAA0B,eAAe;IACzC,gBAAgB,cAAc,cAAc;IAC5C,qBAAqB,cAAc;;;;;EAMrC;IACE,uBAAuB;IACvB,gCAAgC;IAChC,8BAA8B;IAC9B,4BAA4B,kBAAkB;IAC9C,iBAAiB,iBAAiB;;;;;;;;IAQlC,sBAAsB,iBAAiB;;;;;;;;IAQvC,iBAAiB,iBAAiB;IAClC,oBAAoB;;;;;EAMtB;IACE,wBACE,eACA,iBACA;IAEF,6BACE,aACA,aACA;;;;;;;;;;;;IAaF,wBAAwB,mBAAmB;;IAG3C,2BAA2B,mBAAmB;;;;;EAMhD;IACE,uBAAuB,eAAe;IACtC,0BACE,eACA,mBACA"}
|
package/dist/cjs/types/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Params, SearchParams, SimpleState, State, Unsubscribe } from "./base.js";
|
|
2
|
+
import { LimitsConfig } from "./limits.js";
|
|
2
3
|
import { AdoptedOrigins, AnyOptions, DefaultDependencies, GuardFnFactory, Plugin, Route, RouteConfigUpdate, RouterLogger } from "./router.js";
|
|
3
4
|
import { EventMethodMap, EventName } from "./constants.js";
|
|
4
5
|
import { TreeChangedEvent } from "./tree-changed.js";
|
|
@@ -157,6 +158,52 @@ export interface PluginApi {
|
|
|
157
158
|
* cannot grow the registry.
|
|
158
159
|
*/
|
|
159
160
|
getDeclaredQueryNames: (name: string) => readonly string[];
|
|
161
|
+
/**
|
|
162
|
+
* The route's PATH slot names, ancestors included — the registry
|
|
163
|
+
* `buildPath` prints from. Answers `[]` for a route the tree does not hold;
|
|
164
|
+
* a name is not a claim that the route exists.
|
|
165
|
+
*
|
|
166
|
+
* ⚠ Handed out BY REFERENCE and frozen where it lives, with the same caveat as
|
|
167
|
+
* {@link getDeclaredQueryNames}: a held array describes the tree as it was
|
|
168
|
+
* when read, and a rebuild mints a new one (#2255).
|
|
169
|
+
*/
|
|
170
|
+
getUrlParams: (name: string) => readonly string[];
|
|
171
|
+
/**
|
|
172
|
+
* The ONE-HOP forward map — each source route's STRING `forwardTo` target; a
|
|
173
|
+
* callback `forwardTo` is not in it — as a fresh frozen copy per call.
|
|
174
|
+
*
|
|
175
|
+
* ⚠ **One hop, not resolved.** A consumer that checks a PENDING forward for
|
|
176
|
+
* cycles overlays it onto this map and resolves the chain itself. A resolved
|
|
177
|
+
* map collapses each chain to its last hop, so a cycle closing through a
|
|
178
|
+
* source that ALREADY forwards is not constructible there, and the check
|
|
179
|
+
* would miss it silently. `resolveForwardChain` takes exactly this shape.
|
|
180
|
+
*
|
|
181
|
+
* ⚑ A copy, so writing to it reaches nothing — and frozen, so the write does
|
|
182
|
+
* not land either; strict-mode code (every ES module) gets a `TypeError`.
|
|
183
|
+
*/
|
|
184
|
+
getForwardMap: () => Readonly<Record<string, string>>;
|
|
185
|
+
/**
|
|
186
|
+
* The resolved limits: the caller's `limits` over core's defaults, each
|
|
187
|
+
* coerced to a number once at construction. The frozen object core's own
|
|
188
|
+
* dependency-count check reads, handed out by reference.
|
|
189
|
+
*/
|
|
190
|
+
getResolvedLimits: () => Readonly<LimitsConfig>;
|
|
191
|
+
/**
|
|
192
|
+
* The dependency names the router holds, as `Object.keys` lists them —
|
|
193
|
+
* `"__proto__"` included, a symbol key not. A fresh frozen array per call.
|
|
194
|
+
*
|
|
195
|
+
* ⚠ Not `Object.keys(getDependenciesApi(router).getAll())`: that container
|
|
196
|
+
* withholds `"__proto__"`, so a count taken from it comes out one short.
|
|
197
|
+
*/
|
|
198
|
+
getDependencyKeys: () => readonly string[];
|
|
199
|
+
/**
|
|
200
|
+
* Route names carrying a guard added through `addActivateGuard` /
|
|
201
|
+
* `addDeactivateGuard` — deactivate first, each name once, including names
|
|
202
|
+
* the route tree does not hold. A fresh frozen array per call.
|
|
203
|
+
*
|
|
204
|
+
* ⚠ A guard declared on a route definition does not put its name here.
|
|
205
|
+
*/
|
|
206
|
+
getExternalGuardNames: () => readonly string[];
|
|
160
207
|
addEventListener: <E extends EventName>(eventName: E, cb: Plugin[EventMethodMap[E]]) => Unsubscribe;
|
|
161
208
|
/**
|
|
162
209
|
* Builds the State `navigate` would commit, without committing it: resolves
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","names":[],"sources":["../../../src/types/api.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","names":[],"sources":["../../../src/types/api.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;iBA8CiB;EACf,QAAQ,kBAAkB,QAAQ;EAClC,eACE,mBACA,aAAa,QACb,cAAc,iBACX;;;;;;YAOK,cAAc,gBAAgB,2BACxC,MAAM,uBAAuB,OAC1B,MAAM,WAAW,uBAAuB,QACxC,WAAW,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwCtB,sBAAsB;EACrC,QAAQ,OAAO,OAAO,OAAO;EAC7B;;;;;;iBA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