@zenithbuild/router 1.0.6 → 1.3.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/package.json CHANGED
@@ -1,66 +1,66 @@
1
1
  {
2
- "name": "@zenithbuild/router",
3
- "version": "1.0.6",
4
- "description": "File-based SPA router for Zenith framework with deterministic, compile-time route resolution",
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "./src/index.ts",
8
- "files": [
9
- "src",
10
- "dist",
11
- "tsconfig.json",
12
- "index.js",
13
- "index.d.ts",
14
- "zenith-router.node"
15
- ],
16
- "napi": {
17
- "name": "zenith-router",
18
- "package": {
19
- "name": "@zenithbuild/router"
20
- }
21
- },
22
- "exports": {
23
- ".": "./src/index.ts",
24
- "./manifest": "./src/manifest.ts",
25
- "./runtime": "./src/runtime.ts",
26
- "./navigation": "./src/navigation/index.ts",
27
- "./types": "./src/types.ts"
28
- },
29
- "keywords": [
30
- "zenith",
31
- "router",
32
- "spa",
33
- "file-based-routing",
34
- "compile-time"
35
- ],
36
- "author": "Zenith Team",
37
- "repository": {
38
- "type": "git",
39
- "url": "git+ssh://git@github.com/zenithbuild/zenith-router.git"
40
- },
41
- "scripts": {
42
- "format": "prettier --write \"**/*.ts\"",
43
- "format:check": "prettier --check \"**/*.ts\"",
44
- "typecheck": "tsc --noEmit",
45
- "build": "napi build --release",
46
- "build:debug": "napi build",
47
- "release": "bun run scripts/release.ts",
48
- "release:dry": "bun run scripts/release.ts --dry-run",
49
- "release:patch": "bun run scripts/release.ts --bump=patch",
50
- "release:minor": "bun run scripts/release.ts --bump=minor",
51
- "release:major": "bun run scripts/release.ts --bump=major"
52
- },
53
- "publishConfig": {
54
- "access": "public"
55
- },
56
- "private": false,
57
- "devDependencies": {
58
- "@napi-rs/cli": "^2.18.4",
59
- "@types/bun": "latest",
60
- "@types/node": "latest",
61
- "prettier": "^3.7.4"
62
- },
63
- "peerDependencies": {
64
- "typescript": "^5"
2
+ "name": "@zenithbuild/router",
3
+ "version": "1.3.0",
4
+ "description": "File-based SPA router for Zenith framework with deterministic, compile-time route resolution",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./src/index.ts",
8
+ "files": [
9
+ "src",
10
+ "dist",
11
+ "tsconfig.json",
12
+ "index.js",
13
+ "index.d.ts",
14
+ "zenith-router.node"
15
+ ],
16
+ "napi": {
17
+ "name": "zenith-router",
18
+ "package": {
19
+ "name": "@zenithbuild/router"
65
20
  }
66
- }
21
+ },
22
+ "exports": {
23
+ ".": "./src/index.ts",
24
+ "./manifest": "./src/manifest.ts",
25
+ "./runtime": "./src/runtime.ts",
26
+ "./navigation": "./src/navigation/index.ts",
27
+ "./types": "./src/types.ts"
28
+ },
29
+ "keywords": [
30
+ "zenith",
31
+ "router",
32
+ "spa",
33
+ "file-based-routing",
34
+ "compile-time"
35
+ ],
36
+ "author": "Zenith Team",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+ssh://git@github.com/zenithbuild/zenith-router.git"
40
+ },
41
+ "scripts": {
42
+ "format": "prettier --write \"**/*.ts\"",
43
+ "format:check": "prettier --check \"**/*.ts\"",
44
+ "typecheck": "tsc --noEmit",
45
+ "build": "napi build --release",
46
+ "build:debug": "napi build",
47
+ "release": "bun run scripts/release.ts",
48
+ "release:dry": "bun run scripts/release.ts --dry-run",
49
+ "release:patch": "bun run scripts/release.ts --bump=patch",
50
+ "release:minor": "bun run scripts/release.ts --bump=minor",
51
+ "release:major": "bun run scripts/release.ts --bump=major"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "private": false,
57
+ "devDependencies": {
58
+ "@napi-rs/cli": "^2.18.4",
59
+ "@types/bun": "latest",
60
+ "@types/node": "latest",
61
+ "prettier": "^3.7.4"
62
+ },
63
+ "peerDependencies": {
64
+ "typescript": "^5"
65
+ }
66
+ }
@@ -12,7 +12,7 @@ type Props = {
12
12
  type?: string
13
13
  ping?: string
14
14
  referrerPolicy?: string
15
- class?: string
15
+ className?: string
16
16
  id?: string
17
17
  title?: string
18
18
  ariaLabel?: string
@@ -24,6 +24,13 @@ type Props = {
24
24
  onClick?: (event?: MouseEvent) => void | boolean
25
25
  }
26
26
 
27
+ // Declare props as compile-time identifiers
28
+ const {
29
+ href, target, rel, download, hreflang, type, ping,
30
+ referrerPolicy, id, title, ariaLabel, role, tabIndex,
31
+ preload, exact, onClick, className
32
+ } = props<Props>()
33
+
27
34
  /**
28
35
  * Handle link click - prevents default and uses SPA navigation
29
36
  * Respects target="_blank" and other standard anchor behaviors
@@ -87,19 +94,17 @@ function handleClick(event, el) {
87
94
 
88
95
  // Only navigate if path is different (idempotent navigation)
89
96
  if (normalizedHref !== currentPath) {
90
- console.log('[ZenLink] Navigating to:', linkHref)
91
97
  // Navigate using SPA router
92
98
  if (window.__zenith_router && window.__zenith_router.navigate) {
93
- console.log('[ZenLink] Using router.navigate')
94
99
  window.__zenith_router.navigate(linkHref)
95
100
  } else {
96
- console.log('[ZenLink] Using fallback history API')
97
101
  // Fallback to history API
98
102
  window.history.pushState(null, '', linkHref)
99
103
  window.dispatchEvent(new PopStateEvent('popstate'))
100
104
  }
101
105
  } else {
102
- console.log('[ZenLink] Already on route:', linkHref, '- skipping navigation')
106
+ // Already on route
107
+
103
108
  }
104
109
  }
105
110
 
@@ -113,9 +118,9 @@ function handleMouseEnter(event, el) {
113
118
  }
114
119
 
115
120
  const shouldPreload = typeof preload !== 'undefined' ? preload : false
116
- console.log('[ZenLink] handleMouseEnter called, preload:', shouldPreload)
121
+
117
122
  if (!shouldPreload) {
118
- console.log('[ZenLink] Preload disabled, returning early')
123
+
119
124
  return
120
125
  }
121
126
 
@@ -129,18 +134,15 @@ function handleMouseEnter(event, el) {
129
134
  return
130
135
  }
131
136
 
132
- console.log('[ZenLink] Prefetch triggered on hover:', linkHref)
137
+
133
138
 
134
139
  // Prefetch the route
135
140
  if (window.__zenith_router && window.__zenith_router.prefetch) {
136
- console.log('[ZenLink] Calling router.prefetch for:', linkHref)
137
- window.__zenith_router.prefetch(linkHref).then(() => {
138
- console.log('[ZenLink] Prefetch complete for:', linkHref)
139
- }).catch((error) => {
141
+ window.__zenith_router.prefetch(linkHref).catch((error) => {
140
142
  console.warn('[ZenLink] Prefetch failed for:', linkHref, error)
141
143
  })
142
144
  } else {
143
- console.warn('[ZenLink] Router prefetch not available')
145
+ // console.warn('[ZenLink] Router prefetch not available')
144
146
  }
145
147
  }
146
148
 
@@ -222,7 +224,7 @@ function ensureAttributes(el) {
222
224
 
223
225
  <a
224
226
  href="{ href }"
225
- class="zen-link { class }"
227
+ class="zen-link { className }"
226
228
  onclick="handleClick"
227
229
  onmouseenter="handleMouseEnter"
228
230
  style="cursor: pointer;"