@iyulab/router 0.7.4 → 0.7.6
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/CHANGELOG.md +155 -0
- package/README.md +16 -9
- package/dist/index.js +400 -370
- package/dist/react.d.ts +83 -2
- package/dist/react.js +20 -15
- package/dist/share-sbAElOI7.js +237 -0
- package/package.json +7 -8
- package/skills/iyulab-router/SKILL.md +123 -0
- package/skills/iyulab-router/references/REFERENCE.md +175 -0
- package/dist/share-CG-3Tbuy.js +0 -224
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.7.6] - 2026-04-02
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Added `skills/` and `CHANGELOG.md` to npm `files` field — both were missing from the published package, making `npx skills add ./node_modules/@iyulab/router` non-functional
|
|
7
|
+
|
|
8
|
+
## [0.7.5] - 2026-04-02
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- `@lit/react` promoted from optional peer dependency to direct dependency — React integration now works without a separate `@lit/react` install
|
|
12
|
+
- Added Agent Skills definition (`skills/iyulab-router`) for AI agent tooling support
|
|
13
|
+
|
|
14
|
+
## [0.7.4] - 2026-03-05
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- `findOutlet()` now searches both shadow DOM and light DOM simultaneously
|
|
18
|
+
|
|
19
|
+
## [0.7.3] - 2026-03-05
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- **Breaking:** Removed `RenderResult` and `FallbackRenderResult` types — `render` function return type is now `unknown`
|
|
23
|
+
- **Breaking:** Moved React dependencies (`react`, `react-dom`, `@lit/react`) to optional peer dependencies — Lit-only projects no longer require a React install
|
|
24
|
+
- Simplified `findOutlet` — removed shadow/light DOM branching and redundant `querySelector` traversal
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- `UOutlet` now dynamically imports `react-dom/client` — prevents import failure in React-free environments
|
|
28
|
+
- Corrected `UErrorPage` error code string mismatches (`OUTLET_NOT_FOUND` → `OUTLET_MISSING`, `RENDER_FAILED` → `CONTENT_RENDER_FAILED`)
|
|
29
|
+
- Fixed edge case in `catchBasepath` where an empty `restPath` was treated as falsy, causing trailing slashes to be dropped
|
|
30
|
+
- Changed `ULink.getBasepath()` fallback from `""` to `"/"` to prevent incorrect path generation on initial access
|
|
31
|
+
- Applied optional chaining in `Router.go()` catch block to prevent property access errors when a primitive value is thrown
|
|
32
|
+
|
|
33
|
+
## [0.7.2] - 2026-02-09
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Updated dependencies to latest versions
|
|
37
|
+
|
|
38
|
+
## [0.7.1] - 2026-02-09
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- Fixed silent failure when passing `<u-outlet>` element directly as `Router` root (#1)
|
|
42
|
+
- `findOutlet()` now recognizes the root element itself as a valid outlet
|
|
43
|
+
- Improved `waitOutlet()` timeout error message with root element context for easier debugging
|
|
44
|
+
|
|
45
|
+
## [0.7.0] - 2026-02-09
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
- `meta` field on `RouteConfig` — attach arbitrary key-value data to any route
|
|
49
|
+
- `RouteContext.meta` — populated at navigation time with metadata merged from the full matched route chain (parent → child order, child overrides parent)
|
|
50
|
+
|
|
51
|
+
## [0.6.2] - 2026-01-21
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
- **Breaking:** Refactored `UOutlet` from `LitElement` to native `HTMLElement` for improved performance and reduced bundle size
|
|
55
|
+
- **Breaking:** `UErrorPage` CSS custom properties renamed: `--route-icon-color` → `--error-icon-color`, `--route-code-color` → `--error-code-color`, `--route-message-color` → `--error-message-color`
|
|
56
|
+
- `ULink` click event handling moved to host element level for better encapsulation
|
|
57
|
+
- `@lit/react` moved from devDependency to dependency for proper React integration
|
|
58
|
+
- `UErrorPage` replaced inline SVG icon imports with emoji icons; SVG asset files removed
|
|
59
|
+
|
|
60
|
+
## [0.6.1] - 2026-01-20
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
- Added `global.d.ts` import to main entry point
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
- Moved click event listener from root element to document level for more reliable event handling
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
- Fixed `UErrorPage` CSS syntax error (trailing semicolon in CSS block)
|
|
70
|
+
- Fixed initial route loading to wait for outlet element readiness before navigation
|
|
71
|
+
|
|
72
|
+
### Removed
|
|
73
|
+
- Removed unused `computedHref` reactive state from `ULink`
|
|
74
|
+
|
|
75
|
+
## [0.6.0] - 2026-01-15
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
- Dedicated `react.ts` export entry providing React-compatible `UOutlet` and `ULink` wrappers
|
|
79
|
+
- `ULink` now supports the `target` attribute, enabling standard browser behavior (e.g. `_blank`)
|
|
80
|
+
|
|
81
|
+
### Changed
|
|
82
|
+
- Renamed custom elements: `ErrorPage` → `UErrorPage`, `Link` → `ULink`, `Outlet` → `UOutlet`
|
|
83
|
+
- Refactored internal module organization
|
|
84
|
+
|
|
85
|
+
## [0.5.3] - 2025-12-04
|
|
86
|
+
|
|
87
|
+
### Changed
|
|
88
|
+
- Removed restriction that prevented re-navigation to the current URL
|
|
89
|
+
|
|
90
|
+
## [0.5.2] - 2025-11-17
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
- `initialLoad` option on `RouterConfig` — controls whether the router navigates to the current URL on initialization
|
|
94
|
+
- `fallback` option on `RouterConfig` — defines a custom render function for error and not-found states
|
|
95
|
+
- `RouteProgressEvent` dispatched during async route loading
|
|
96
|
+
|
|
97
|
+
### Changed
|
|
98
|
+
- Renamed `RouteInfo` to `RouteContext`; added `progress` callback to context for reporting load progress
|
|
99
|
+
- Improved error handling and display in the built-in error page component
|
|
100
|
+
|
|
101
|
+
### Removed
|
|
102
|
+
- Removed `children` from `NonIndexRouteConfig` to simplify the type interface
|
|
103
|
+
- Removed `route` property from the `window` object to reduce global namespace pollution
|
|
104
|
+
|
|
105
|
+
## [0.5.1] - 2025-11-13
|
|
106
|
+
|
|
107
|
+
### Fixed
|
|
108
|
+
- Improved route error handling
|
|
109
|
+
|
|
110
|
+
## [0.5.0] - 2025-11-12
|
|
111
|
+
|
|
112
|
+
### Changed
|
|
113
|
+
- Route `render` functions now support both synchronous and asynchronous return values
|
|
114
|
+
|
|
115
|
+
### Removed
|
|
116
|
+
- Dropped CommonJS build output — ESM only
|
|
117
|
+
|
|
118
|
+
## [0.4.0] - 2025-11-11
|
|
119
|
+
|
|
120
|
+
### Added
|
|
121
|
+
- `destroy()` method on `Router` to cleanly remove event listeners
|
|
122
|
+
- `useIntercept` option on `RouterConfig` — controls whether anchor tag clicks are intercepted for client-side routing
|
|
123
|
+
- Global type declarations (`global.d.ts`)
|
|
124
|
+
|
|
125
|
+
## [0.3.0] - 2025-10-28
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
- **Breaking:** Complete router architecture overhaul
|
|
129
|
+
- **Breaking:** `RouteConfig` split into `IndexRouteConfig` and `PathRouteConfig`
|
|
130
|
+
- **Breaking:** `RouteError` converted to a class; added `NotFoundRouteError`
|
|
131
|
+
- **Breaking:** Route event names changed: `route-start` → `route-begin`, `route-end` → `route-done`
|
|
132
|
+
- Simplified `Outlet` rendering via a unified `renderContent` method
|
|
133
|
+
|
|
134
|
+
### Added
|
|
135
|
+
- Improved `ErrorPage` component styling and usability
|
|
136
|
+
- Unified route rendering using render functions
|
|
137
|
+
|
|
138
|
+
## [0.2.1] - 2025-10-27
|
|
139
|
+
|
|
140
|
+
### Changed
|
|
141
|
+
- Refactored routing mechanism for improved performance
|
|
142
|
+
- Enhanced error handling with custom error pages
|
|
143
|
+
|
|
144
|
+
### Removed
|
|
145
|
+
- Removed `connect()` and `disconnect()` methods from `Router`
|
|
146
|
+
- Removed `notfound` configuration option
|
|
147
|
+
- Removed legacy route progress events
|
|
148
|
+
- added ErrorPage component for error handling
|
|
149
|
+
- added Route events: `route-start`, `route-end`, `route-error`
|
|
150
|
+
- improved TypeScript types and interfaces
|
|
151
|
+
|
|
152
|
+
## [0.1.0] - 2025-04-25
|
|
153
|
+
|
|
154
|
+
### Added
|
|
155
|
+
- Initial release
|
package/README.md
CHANGED
|
@@ -2,15 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
A modern, lightweight client-side router for web applications with support for both Lit and React components.
|
|
4
4
|
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🚀 **Modern URLPattern-based routing** - Uses native URLPattern API for powerful path matching
|
|
8
|
-
- 🔧 **Unified Framework Support** - Works with both Lit and React components using render functions
|
|
9
|
-
- 📱 **Client-Side Navigation** - History API integration with browser back/forward support
|
|
10
|
-
- 🎯 **Nested Routing** - Support for deeply nested route hierarchies with index and path routes
|
|
11
|
-
- 📊 **Route Events** - Track navigation progress with route-begin, route-done, and route-error events
|
|
12
|
-
- ⚠️ **Enhanced Error Handling** - Built-in ErrorPage component with improved styling
|
|
13
|
-
|
|
14
5
|
## Installation
|
|
15
6
|
|
|
16
7
|
```bash
|
|
@@ -95,6 +86,22 @@ const routes: RouteConfig[] = [
|
|
|
95
86
|
];
|
|
96
87
|
```
|
|
97
88
|
|
|
89
|
+
## Skills Usage
|
|
90
|
+
|
|
91
|
+
Install the `iyulab-router` skill to give your AI agent knowledge of this package's API and patterns.
|
|
92
|
+
|
|
93
|
+
**Using GitHub shorthand:**
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx skills add iyulab/node-router
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Using local path (after `npm install`):**
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx skills add ./node_modules/@iyulab/router
|
|
103
|
+
```
|
|
104
|
+
|
|
98
105
|
## Usage Examples
|
|
99
106
|
|
|
100
107
|
### Using with Lit Elements
|