@zenithbuild/router 0.7.10 → 0.7.11
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/events.d.ts +7 -1
- package/dist/events.js +10 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/index.d.ts +9 -3
- package/package.json +5 -2
- package/template-core.js +0 -2
package/dist/events.d.ts
CHANGED
|
@@ -4,18 +4,24 @@ type RouteChangeDetail = {
|
|
|
4
4
|
params?: RouteParams;
|
|
5
5
|
matched: boolean;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
7
|
+
export type AdvisoryRoutePolicy = {
|
|
8
8
|
onDeny?: 'stay' | 'redirect' | 'render403' | ((ctx: any) => void);
|
|
9
9
|
defaultLoginPath?: string;
|
|
10
10
|
deny401RedirectToLogin?: boolean;
|
|
11
11
|
forbiddenPath?: string;
|
|
12
12
|
};
|
|
13
|
+
/** @deprecated Use AdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
14
|
+
export type RouteProtectionPolicy = AdvisoryRoutePolicy;
|
|
13
15
|
type RouteEventHandler = (payload: unknown) => void | Promise<void>;
|
|
14
16
|
export declare function onRouteChange(callback: (detail: RouteChangeDetail) => void): () => void;
|
|
15
17
|
export declare function _dispatchRouteChange(detail: RouteChangeDetail): void;
|
|
16
18
|
export declare function _clearSubscribers(): void;
|
|
17
19
|
export declare function _getSubscriberCount(): number;
|
|
20
|
+
export declare function setAdvisoryRoutePolicy(policy: AdvisoryRoutePolicy): void;
|
|
21
|
+
export declare function _getAdvisoryRoutePolicy(): AdvisoryRoutePolicy;
|
|
22
|
+
/** @deprecated Use setAdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
18
23
|
export declare function setRouteProtectionPolicy(policy: RouteProtectionPolicy): void;
|
|
24
|
+
/** @deprecated Use _getAdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
19
25
|
export declare function _getRouteProtectionPolicy(): RouteProtectionPolicy;
|
|
20
26
|
export declare function on(eventName: string, handler: RouteEventHandler): void;
|
|
21
27
|
export declare function off(eventName: string, handler: RouteEventHandler): void;
|
package/dist/events.js
CHANGED
|
@@ -28,8 +28,6 @@ export function _getSubscriberCount() {
|
|
|
28
28
|
const ROUTE_POLICY_KEY = '__zenith_route_protection_policy';
|
|
29
29
|
const ROUTE_EVENT_LISTENERS_KEY = '__zenith_route_event_listeners';
|
|
30
30
|
const ROUTE_EVENT_NAMES = [
|
|
31
|
-
'guard:start',
|
|
32
|
-
'guard:end',
|
|
33
31
|
'route-check:start',
|
|
34
32
|
'route-check:end',
|
|
35
33
|
'route-check:error',
|
|
@@ -70,14 +68,22 @@ function ensureRouteProtectionState() {
|
|
|
70
68
|
}
|
|
71
69
|
return { policy, listeners };
|
|
72
70
|
}
|
|
73
|
-
export function
|
|
71
|
+
export function setAdvisoryRoutePolicy(policy) {
|
|
74
72
|
const state = ensureRouteProtectionState();
|
|
75
73
|
state.policy = Object.assign({}, state.policy, policy);
|
|
76
74
|
getRouteProtectionScope()[ROUTE_POLICY_KEY] = state.policy;
|
|
77
75
|
}
|
|
78
|
-
export function
|
|
76
|
+
export function _getAdvisoryRoutePolicy() {
|
|
79
77
|
return ensureRouteProtectionState().policy;
|
|
80
78
|
}
|
|
79
|
+
/** @deprecated Use setAdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
80
|
+
export function setRouteProtectionPolicy(policy) {
|
|
81
|
+
setAdvisoryRoutePolicy(policy);
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated Use _getAdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
84
|
+
export function _getRouteProtectionPolicy() {
|
|
85
|
+
return _getAdvisoryRoutePolicy();
|
|
86
|
+
}
|
|
81
87
|
export function on(eventName, handler) {
|
|
82
88
|
const eventListeners = ensureRouteProtectionState().listeners[eventName];
|
|
83
89
|
if (eventListeners instanceof Set) {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { createRouter } from "./router.js";
|
|
|
2
2
|
export { zenNavigationShell } from "./navigation-shell.js";
|
|
3
3
|
export { matchRoute } from "./match.js";
|
|
4
4
|
export { navigate, refreshCurrentRoute, back, forward, getCurrentPath } from "./navigate.js";
|
|
5
|
-
export { onRouteChange, on, off, setRouteProtectionPolicy, _getRouteProtectionPolicy, _dispatchRouteEvent } from "./events.js";
|
|
5
|
+
export { onRouteChange, on, off, setAdvisoryRoutePolicy, _getAdvisoryRoutePolicy, setRouteProtectionPolicy, _getRouteProtectionPolicy, _dispatchRouteEvent } from "./events.js";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
// ---------------------------------------------------------------------------
|
|
6
6
|
export { createRouter } from './router.js';
|
|
7
7
|
export { navigate, refreshCurrentRoute, back, forward, getCurrentPath } from './navigate.js';
|
|
8
|
-
export { onRouteChange, on, off, setRouteProtectionPolicy, _getRouteProtectionPolicy, _dispatchRouteEvent } from './events.js';
|
|
8
|
+
export { onRouteChange, on, off, setAdvisoryRoutePolicy, _getAdvisoryRoutePolicy, setRouteProtectionPolicy, _getRouteProtectionPolicy, _dispatchRouteEvent } from './events.js';
|
|
9
9
|
export { zenNavigationShell } from './navigation-shell.js';
|
|
10
10
|
export { matchRoute } from './match.js';
|
package/index.d.ts
CHANGED
|
@@ -56,13 +56,16 @@ export declare function getCurrentPath(): string;
|
|
|
56
56
|
export declare function onRouteChange(listener: (event: any) => void): () => void;
|
|
57
57
|
export declare function matchRoute(routes: any[], path: string): any;
|
|
58
58
|
|
|
59
|
-
export interface
|
|
59
|
+
export interface AdvisoryRoutePolicy {
|
|
60
60
|
onDeny?: "stay" | "redirect" | "render403" | ((ctx: any) => void);
|
|
61
61
|
defaultLoginPath?: string;
|
|
62
62
|
deny401RedirectToLogin?: boolean;
|
|
63
63
|
forbiddenPath?: string;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/** @deprecated Use AdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
67
|
+
export type RouteProtectionPolicy = AdvisoryRoutePolicy;
|
|
68
|
+
|
|
66
69
|
export type NavigationType = "push" | "pop" | "refresh";
|
|
67
70
|
export type NavigationShellPhase = "idle" | "leaving" | "swapping" | "entering";
|
|
68
71
|
|
|
@@ -115,8 +118,6 @@ export interface NavigationLifecyclePayload {
|
|
|
115
118
|
export type RouteEventHandler = (payload: unknown) => void | Promise<void>;
|
|
116
119
|
|
|
117
120
|
export type RouteEventName =
|
|
118
|
-
| "guard:start"
|
|
119
|
-
| "guard:end"
|
|
120
121
|
| "route-check:start"
|
|
121
122
|
| "route-check:end"
|
|
122
123
|
| "route-check:error"
|
|
@@ -133,7 +134,12 @@ export type RouteEventName =
|
|
|
133
134
|
| "navigation:abort"
|
|
134
135
|
| "navigation:error";
|
|
135
136
|
|
|
137
|
+
export declare function setAdvisoryRoutePolicy(policy: AdvisoryRoutePolicy): void;
|
|
138
|
+
export declare function _getAdvisoryRoutePolicy(): AdvisoryRoutePolicy;
|
|
139
|
+
/** @deprecated Use setAdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
136
140
|
export declare function setRouteProtectionPolicy(policy: RouteProtectionPolicy): void;
|
|
141
|
+
/** @deprecated Use _getAdvisoryRoutePolicy. This policy only controls client navigation UX. */
|
|
142
|
+
export declare function _getRouteProtectionPolicy(): RouteProtectionPolicy;
|
|
137
143
|
export declare function on(eventName: RouteEventName, handler: RouteEventHandler): void;
|
|
138
144
|
export declare function off(eventName: RouteEventName, handler: RouteEventHandler): void;
|
|
139
145
|
export declare function zenNavigationShell(ref: { current?: Element | null }, options?: NavigationShellOptions | null): NavigationShellController;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenithbuild/router",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.11",
|
|
4
4
|
"description": "File-based SPA router for Zenith framework with deterministic, compile-time route resolution",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"contract:deps": "node dependency_contract.spec.js",
|
|
57
57
|
"contract:scan": "node contract-scan.mjs",
|
|
58
58
|
"contract:template": "node template-contract.spec.js",
|
|
59
|
-
"test": "npm run contract:deps && npm run contract:scan && npm run contract:template",
|
|
59
|
+
"test": "npm run contract:deps && npm run contract:scan && npm run contract:template && npm run test:legacy",
|
|
60
60
|
"test:legacy": "NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.js",
|
|
61
61
|
"prepublishOnly": "npm run build"
|
|
62
62
|
},
|
|
@@ -65,9 +65,12 @@
|
|
|
65
65
|
},
|
|
66
66
|
"private": false,
|
|
67
67
|
"devDependencies": {
|
|
68
|
+
"@jest/globals": "^30.2.0",
|
|
68
69
|
"@napi-rs/cli": "^2.18.4",
|
|
69
70
|
"@types/bun": "latest",
|
|
70
71
|
"@types/node": "latest",
|
|
72
|
+
"jest": "^30.2.0",
|
|
73
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
71
74
|
"prettier": "^3.7.4",
|
|
72
75
|
"typescript": "^5.7.3"
|
|
73
76
|
}
|
package/template-core.js
CHANGED
|
@@ -12,8 +12,6 @@ const __ZENITH_BASE_PATH__ = normalizeBasePath(
|
|
|
12
12
|
);
|
|
13
13
|
const __ZENITH_ROUTE_EVENT_KEY = "__zenith_route_event_listeners";
|
|
14
14
|
const __ZENITH_ROUTE_EVENT_NAMES = [
|
|
15
|
-
"guard:start",
|
|
16
|
-
"guard:end",
|
|
17
15
|
"route-check:start",
|
|
18
16
|
"route-check:end",
|
|
19
17
|
"route-check:error",
|