@zenithbuild/router 1.0.3 → 1.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenithbuild/router",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "File-based SPA router for Zenith framework with deterministic, compile-time route resolution",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -63,4 +63,4 @@
63
63
  "peerDependencies": {
64
64
  "typescript": "^5"
65
65
  }
66
- }
66
+ }
package/src/index.ts CHANGED
@@ -62,7 +62,8 @@ export {
62
62
  isActive,
63
63
  prefetch,
64
64
  isPrefetched,
65
- generateRuntimeRouterCode
65
+ generateRuntimeRouterCode,
66
+ zenRoute
66
67
  } from "./runtime"
67
68
 
68
69
  // ============================================
package/src/runtime.ts CHANGED
@@ -140,6 +140,25 @@ export async function navigate(to: string, options: NavigateOptions = {}): Promi
140
140
  }
141
141
 
142
142
  export function getRoute(): RouteState { return { ...currentRoute } }
143
+
144
+ /**
145
+ * zenRoute() - Zenith Law: Environment Resolution
146
+ *
147
+ * Canonical primitive for resolving the current route environment.
148
+ * Must be resolved once and execute before state initialization.
149
+ */
150
+ export function zenRoute(): { path: string; slugs: string[] } {
151
+ const path = typeof window !== 'undefined' ? window.location.pathname : currentRoute.path;
152
+ return {
153
+ path,
154
+ slugs: getSlugs(path)
155
+ };
156
+ }
157
+
158
+ function getSlugs(path: string): string[] {
159
+ return path.split('/').filter(Boolean);
160
+ }
161
+
143
162
  export function onRouteChange(listener: RouteListener): () => void {
144
163
  routeListeners.add(listener)
145
164
  return () => { routeListeners.delete(listener) }