@iyulab/router 0.6.1 โ 0.7.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/LICENSE +20 -20
- package/README.md +272 -149
- package/dist/index.d.ts +56 -35
- package/dist/index.js +45 -110
- package/dist/react.d.ts +34 -27
- package/dist/react.js +4 -29
- package/dist/{share-SPj-xl6y.js โ share-B5lysqp2.js} +55 -89
- package/package.json +56 -56
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 iyulab
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 iyulab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,149 +1,272 @@
|
|
|
1
|
-
# @iyulab/router
|
|
2
|
-
|
|
3
|
-
A modern, lightweight client-side router for web applications with support for both Lit and React components.
|
|
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
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @iyulab/router
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Quick Start
|
|
21
|
-
|
|
22
|
-
### Basic Setup
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { Router } from '@iyulab/router';
|
|
26
|
-
import { html } from 'lit';
|
|
27
|
-
|
|
28
|
-
const router = new Router({
|
|
29
|
-
basepath: '/',
|
|
30
|
-
routes: [
|
|
31
|
-
{
|
|
32
|
-
index: true,
|
|
33
|
-
render: () => html`<home-page></home-page>`
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
path: '/user/:id', // URLPattern route
|
|
37
|
-
render: (routeInfo) => html`<user-page .userId=${routeInfo.params.id}></user-page>`
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Mixed Framework Support
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
import React from 'react';
|
|
47
|
-
|
|
48
|
-
const routes = [
|
|
49
|
-
// Lit component
|
|
50
|
-
{
|
|
51
|
-
path: '/lit-page',
|
|
52
|
-
render: (routeInfo) => {
|
|
53
|
-
return html`<my-lit-component .routeInfo=${routeInfo}></my-lit-component>`
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
// React component
|
|
57
|
-
{
|
|
58
|
-
path: '/react-page',
|
|
59
|
-
render: (routeInfo) => {
|
|
60
|
-
return ( <MyComponent></MyComponent> )
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
// HTML element
|
|
64
|
-
{
|
|
65
|
-
path: '/element-page',
|
|
66
|
-
render: (routeInfo) => {
|
|
67
|
-
const element = document.createElement('my-element');
|
|
68
|
-
element.data = routeInfo.params;
|
|
69
|
-
return element;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
];
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Nested Routes
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
import { RouteConfig } from '@iyulab/router';
|
|
79
|
-
|
|
80
|
-
const routes: RouteConfig[] = [
|
|
81
|
-
{
|
|
82
|
-
path: '/dashboard',
|
|
83
|
-
render: () => html`<dashboard-layout><u-outlet></u-outlet></dashboard-layout>`,
|
|
84
|
-
children: [
|
|
85
|
-
{
|
|
86
|
-
index: true, // Matches '/dashboard'
|
|
87
|
-
render: () => html`<dashboard-home></dashboard-home>`
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
path: 'settings', // Matches '/dashboard/settings'
|
|
91
|
-
render: () => html`<dashboard-settings></dashboard-settings>`
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
];
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Usage Examples
|
|
99
|
-
|
|
100
|
-
### Using with Lit Elements
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
import { LitElement, html } from 'lit';
|
|
104
|
-
import { customElement } from 'lit/decorators.js';
|
|
105
|
-
|
|
106
|
-
import "@iyulab/router";
|
|
107
|
-
|
|
108
|
-
@customElement('app-root')
|
|
109
|
-
export class AppRoot extends LitElement {
|
|
110
|
-
render() {
|
|
111
|
-
return html`
|
|
112
|
-
<nav>
|
|
113
|
-
<u-link href="/">Home</u-link>
|
|
114
|
-
<u-link href="/about">About</u-link>
|
|
115
|
-
<u-link href="/user/123">User Profile</u-link>
|
|
116
|
-
</nav>
|
|
117
|
-
<main>
|
|
118
|
-
<u-outlet></u-outlet>
|
|
119
|
-
</main>
|
|
120
|
-
`;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Using with React Components
|
|
126
|
-
|
|
127
|
-
```tsx
|
|
128
|
-
import React from 'react';
|
|
129
|
-
import { UOutlet, ULink } from '@iyulab/router/react';
|
|
130
|
-
|
|
131
|
-
export function AppRoot() {
|
|
132
|
-
return (
|
|
133
|
-
<div>
|
|
134
|
-
<nav>
|
|
135
|
-
<ULink href="/">Home</ULink>
|
|
136
|
-
<ULink href="/about">About</ULink>
|
|
137
|
-
<ULink href="/user/123">User Profile</ULink>
|
|
138
|
-
</nav>
|
|
139
|
-
<main>
|
|
140
|
-
<UOutlet />
|
|
141
|
-
</main>
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
##
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
# @iyulab/router
|
|
2
|
+
|
|
3
|
+
A modern, lightweight client-side router for web applications with support for both Lit and React components.
|
|
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
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @iyulab/router
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### Basic Setup
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Router } from '@iyulab/router';
|
|
26
|
+
import { html } from 'lit';
|
|
27
|
+
|
|
28
|
+
const router = new Router({
|
|
29
|
+
basepath: '/',
|
|
30
|
+
routes: [
|
|
31
|
+
{
|
|
32
|
+
index: true,
|
|
33
|
+
render: () => html`<home-page></home-page>`
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
path: '/user/:id', // URLPattern route
|
|
37
|
+
render: (routeInfo) => html`<user-page .userId=${routeInfo.params.id}></user-page>`
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Mixed Framework Support
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import React from 'react';
|
|
47
|
+
|
|
48
|
+
const routes = [
|
|
49
|
+
// Lit component
|
|
50
|
+
{
|
|
51
|
+
path: '/lit-page',
|
|
52
|
+
render: (routeInfo) => {
|
|
53
|
+
return html`<my-lit-component .routeInfo=${routeInfo}></my-lit-component>`
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
// React component
|
|
57
|
+
{
|
|
58
|
+
path: '/react-page',
|
|
59
|
+
render: (routeInfo) => {
|
|
60
|
+
return ( <MyComponent></MyComponent> )
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
// HTML element
|
|
64
|
+
{
|
|
65
|
+
path: '/element-page',
|
|
66
|
+
render: (routeInfo) => {
|
|
67
|
+
const element = document.createElement('my-element');
|
|
68
|
+
element.data = routeInfo.params;
|
|
69
|
+
return element;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Nested Routes
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { RouteConfig } from '@iyulab/router';
|
|
79
|
+
|
|
80
|
+
const routes: RouteConfig[] = [
|
|
81
|
+
{
|
|
82
|
+
path: '/dashboard',
|
|
83
|
+
render: () => html`<dashboard-layout><u-outlet></u-outlet></dashboard-layout>`,
|
|
84
|
+
children: [
|
|
85
|
+
{
|
|
86
|
+
index: true, // Matches '/dashboard'
|
|
87
|
+
render: () => html`<dashboard-home></dashboard-home>`
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
path: 'settings', // Matches '/dashboard/settings'
|
|
91
|
+
render: () => html`<dashboard-settings></dashboard-settings>`
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Usage Examples
|
|
99
|
+
|
|
100
|
+
### Using with Lit Elements
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { LitElement, html } from 'lit';
|
|
104
|
+
import { customElement } from 'lit/decorators.js';
|
|
105
|
+
|
|
106
|
+
import "@iyulab/router";
|
|
107
|
+
|
|
108
|
+
@customElement('app-root')
|
|
109
|
+
export class AppRoot extends LitElement {
|
|
110
|
+
render() {
|
|
111
|
+
return html`
|
|
112
|
+
<nav>
|
|
113
|
+
<u-link href="/">Home</u-link>
|
|
114
|
+
<u-link href="/about">About</u-link>
|
|
115
|
+
<u-link href="/user/123">User Profile</u-link>
|
|
116
|
+
</nav>
|
|
117
|
+
<main>
|
|
118
|
+
<u-outlet></u-outlet>
|
|
119
|
+
</main>
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Using with React Components
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import React from 'react';
|
|
129
|
+
import { UOutlet, ULink } from '@iyulab/router/react';
|
|
130
|
+
|
|
131
|
+
export function AppRoot() {
|
|
132
|
+
return (
|
|
133
|
+
<div>
|
|
134
|
+
<nav>
|
|
135
|
+
<ULink href="/">Home</ULink>
|
|
136
|
+
<ULink href="/about">About</ULink>
|
|
137
|
+
<ULink href="/user/123">User Profile</ULink>
|
|
138
|
+
</nav>
|
|
139
|
+
<main>
|
|
140
|
+
<UOutlet />
|
|
141
|
+
</main>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Error Handling
|
|
148
|
+
|
|
149
|
+
The router provides comprehensive error handling through `FallbackRouteContext`. When a routing error occurs, the fallback render function receives a context with full error information:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const router = new Router({
|
|
153
|
+
root: document.body,
|
|
154
|
+
basepath: '/',
|
|
155
|
+
routes: [...],
|
|
156
|
+
fallback: {
|
|
157
|
+
title: 'Error',
|
|
158
|
+
render: (ctx) => {
|
|
159
|
+
// ctx.error contains RouteError with code, message, and original error
|
|
160
|
+
const { code, message, original } = ctx.error;
|
|
161
|
+
|
|
162
|
+
if (code === 'NOT_FOUND') {
|
|
163
|
+
return html`<not-found-page .path=${ctx.pathname}></not-found-page>`;
|
|
164
|
+
}
|
|
165
|
+
if (code === 'CONTENT_LOAD_ERROR') {
|
|
166
|
+
return html`<error-page .message=${message}></error-page>`;
|
|
167
|
+
}
|
|
168
|
+
return html`<error-page .error=${ctx.error}></error-page>`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Error types:
|
|
175
|
+
- `NotFoundError` โ No matching route found (code: `NOT_FOUND`)
|
|
176
|
+
- `ContentLoadError` โ Route render function threw an error (code: `CONTENT_LOAD_ERROR`)
|
|
177
|
+
- `ContentRenderError` โ Outlet rendering failed (code: `CONTENT_RENDER_ERROR`)
|
|
178
|
+
|
|
179
|
+
## Route Metadata
|
|
180
|
+
|
|
181
|
+
Routes can carry arbitrary metadata via the `meta` field. When a route matches, metadata from the entire matched route chain is merged (parent โ child order, child overrides parent):
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
const router = new Router({
|
|
185
|
+
root: document.body,
|
|
186
|
+
basepath: '/',
|
|
187
|
+
routes: [
|
|
188
|
+
{
|
|
189
|
+
path: '/admin',
|
|
190
|
+
meta: { requiresAuth: true, layout: 'admin' },
|
|
191
|
+
render: (ctx) => {
|
|
192
|
+
// ctx.meta === { requiresAuth: true, layout: 'admin' }
|
|
193
|
+
return html`<admin-layout><u-outlet></u-outlet></admin-layout>`;
|
|
194
|
+
},
|
|
195
|
+
children: [
|
|
196
|
+
{
|
|
197
|
+
path: 'settings',
|
|
198
|
+
meta: { requiresAuth: true, role: 'superadmin' },
|
|
199
|
+
render: (ctx) => {
|
|
200
|
+
// ctx.meta === { requiresAuth: true, layout: 'admin', role: 'superadmin' }
|
|
201
|
+
return html`<admin-settings></admin-settings>`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Use cases: authentication guards, SEO tags, analytics tracking, layout selection, and more.
|
|
211
|
+
|
|
212
|
+
## Route Events
|
|
213
|
+
|
|
214
|
+
The router dispatches events on the `window` object during navigation:
|
|
215
|
+
|
|
216
|
+
| Event | Type | Description |
|
|
217
|
+
|-------|------|-------------|
|
|
218
|
+
| `route-begin` | `RouteBeginEvent` | Fired when navigation starts |
|
|
219
|
+
| `route-progress` | `RouteProgressEvent` | Fired during async loading (0โ100) |
|
|
220
|
+
| `route-done` | `RouteDoneEvent` | Fired when navigation completes successfully |
|
|
221
|
+
| `route-error` | `RouteErrorEvent` | Fired when a routing error occurs |
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
// Track navigation progress
|
|
225
|
+
window.addEventListener('route-progress', (e: RouteProgressEvent) => {
|
|
226
|
+
progressBar.value = e.progress;
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Log navigation events
|
|
230
|
+
window.addEventListener('route-begin', (e: RouteBeginEvent) => {
|
|
231
|
+
console.log('Navigating to:', e.context.pathname);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
window.addEventListener('route-done', (e: RouteDoneEvent) => {
|
|
235
|
+
analytics.trackPageView(e.context.pathname);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
window.addEventListener('route-error', (e: RouteErrorEvent) => {
|
|
239
|
+
errorTracker.report(e.error);
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## URL Parameters
|
|
244
|
+
|
|
245
|
+
The router supports URLPattern-based parameter matching:
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
const routes: RouteConfig[] = [
|
|
249
|
+
// Required parameter
|
|
250
|
+
{ path: '/user/:id', render: (ctx) => html`<user-page .id=${ctx.params.id}></user-page>` },
|
|
251
|
+
|
|
252
|
+
// Optional parameter
|
|
253
|
+
{ path: '/posts/:category?', render: (ctx) => {
|
|
254
|
+
const category = ctx.params.category || 'all';
|
|
255
|
+
return html`<posts-page .category=${category}></posts-page>`;
|
|
256
|
+
}},
|
|
257
|
+
|
|
258
|
+
// Wildcard (catch-all)
|
|
259
|
+
{ path: '/docs/:path*', render: (ctx) => html`<docs-page .path=${ctx.params.path}></docs-page>` },
|
|
260
|
+
|
|
261
|
+
// Multiple parameters
|
|
262
|
+
{ path: '/org/:orgId/repo/:repoId', render: (ctx) => {
|
|
263
|
+
return html`<repo-page .orgId=${ctx.params.orgId} .repoId=${ctx.params.repoId}></repo-page>`;
|
|
264
|
+
}}
|
|
265
|
+
];
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
When URL parameters change (e.g., navigating from `/user/1` to `/user/2`), leaf routes (without children) automatically re-render since `force` defaults to `true`. For parent routes with children, set `force: true` explicitly if re-rendering is needed on parameter changes.
|
|
269
|
+
|
|
270
|
+
## License
|
|
271
|
+
|
|
272
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,15 @@ declare interface BaseRouteConfig {
|
|
|
60
60
|
* @default false
|
|
61
61
|
*/
|
|
62
62
|
ignoreCase?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* ๋ผ์ฐํธ์ ์ฐ๊ฒฐํ ๋ฉํ๋ฐ์ดํฐ
|
|
65
|
+
* - ์ธ์ฆ, SEO, ๋ถ์ ๋ฑ์ ์ฉ๋๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* { path: '/admin', meta: { requiresAuth: true, role: 'admin' } }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
meta?: Record<string, unknown>;
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
/**
|
|
@@ -145,10 +154,14 @@ export declare class OutletMissingError extends RouteError {
|
|
|
145
154
|
constructor();
|
|
146
155
|
}
|
|
147
156
|
|
|
157
|
+
/** ๋ ๋๋ง ์ต์
*/
|
|
148
158
|
declare interface RenderOption {
|
|
159
|
+
/** ๊ต์ฐจ ๋ ๋๋ง ๋ฐฉ์ง ID */
|
|
149
160
|
id?: string;
|
|
161
|
+
/** ๊ฐ์ ๋ ๋๋ง ์ฌ๋ถ */
|
|
150
162
|
force?: boolean;
|
|
151
|
-
|
|
163
|
+
/** ๋ ๋๋งํ ๊ฐ */
|
|
164
|
+
value: RenderResult;
|
|
152
165
|
}
|
|
153
166
|
|
|
154
167
|
export declare type RenderResult = HTMLElement | ReactElement | TemplateResult<1> | false;
|
|
@@ -233,6 +246,11 @@ export declare interface RouteContext {
|
|
|
233
246
|
* @param value ์งํ ์ํ ๊ฐ (0~100)
|
|
234
247
|
*/
|
|
235
248
|
progress: (value: number) => void;
|
|
249
|
+
/**
|
|
250
|
+
* ๋งค์นญ๋ ๋ผ์ฐํธ ์ฒด์ธ์ ๋ณํฉ๋ ๋ฉํ๋ฐ์ดํฐ
|
|
251
|
+
* - ๋ถ๋ชจ ๋ผ์ฐํธ์์ ์์ ๋ผ์ฐํธ ์์๋ก ๋ณํฉ๋ฉ๋๋ค.
|
|
252
|
+
*/
|
|
253
|
+
meta: Record<string, unknown>;
|
|
236
254
|
}
|
|
237
255
|
|
|
238
256
|
/**
|
|
@@ -297,7 +315,7 @@ export declare class RouteProgressEvent extends RouteEvent {
|
|
|
297
315
|
}
|
|
298
316
|
|
|
299
317
|
/**
|
|
300
|
-
* `lit-element`, `react`๋ฅผ ์ง์ํ๋ ํด๋ผ์ด์ธํธ
|
|
318
|
+
* `lit-element`, `react`๋ฅผ ์ง์ํ๋ SPA ํด๋ผ์ด์ธํธ ๋ผ์ฐํฐ ๊ฐ์ฒด์
๋๋ค.
|
|
301
319
|
*/
|
|
302
320
|
export declare class Router {
|
|
303
321
|
private readonly _rootElement;
|
|
@@ -375,66 +393,69 @@ export declare class ULink extends LitElement {
|
|
|
375
393
|
/** ์ธ๋ถ ๋งํฌ ์ฌ๋ถ */
|
|
376
394
|
private isExternal;
|
|
377
395
|
/**
|
|
378
|
-
*
|
|
379
|
-
*
|
|
396
|
+
* ๋งํฌ ๋์ target ์์ฑ
|
|
397
|
+
*
|
|
398
|
+
* - `_self`: ํ์ฌ ์ฐฝ์์ ๋งํฌ ์ด๊ธฐ (๊ธฐ๋ณธ๊ฐ)
|
|
399
|
+
* - `_blank`: ์ ํญ/์ฐฝ์์ ๋งํฌ ์ด๊ธฐ
|
|
400
|
+
* - `_parent`: ๋ถ๋ชจ ํ๋ ์์์ ๋งํฌ ์ด๊ธฐ
|
|
401
|
+
* - `_top`: ์ต์์ ํ๋ ์์์ ๋งํฌ ์ด๊ธฐ
|
|
380
402
|
*/
|
|
381
403
|
target?: string;
|
|
382
404
|
/**
|
|
383
|
-
*
|
|
405
|
+
* ๋งํฌ ๋์ URL, ๋ค์ ์ฌํญ์ ๋ฐ๋ผ SPA ๋ผ์ฐํ
๋๋ ๋ธ๋ผ์ฐ์ ๋ค๋น๊ฒ์ด์
์ด ๊ฒฐ์ ๋ฉ๋๋ค.
|
|
406
|
+
*
|
|
407
|
+
* - ์์ฑ์ ์ ์ํ์ง ์์ผ๋ฉด ์ค์ ์์ ์ง์ ํ `basepath`๋ก SPA ๋ผ์ฐํ
ํฉ๋๋ค.
|
|
384
408
|
* - http(s)๋ก ์์ํ๋ฉด ์ธ๋ถ ๋งํฌ๋ก ๊ฐ์ฃผํ๊ณ ๋ธ๋ผ์ฐ์ ๋ค๋น๊ฒ์ด์
์ ์ฌ์ฉํฉ๋๋ค.
|
|
385
|
-
* - ์ ๋๊ฒฝ๋ก(/...)
|
|
386
|
-
* - ์๋๊ฒฝ๋ก๋ (basepath + ์๋๊ฒฝ๋ก)๋ก SPA
|
|
387
|
-
* - ?๋ก ์์ํ๋ฉด ํ์ฌ
|
|
388
|
-
* - #์ผ๋ก ์์ํ๋ฉด
|
|
409
|
+
* - ์ ๋๊ฒฝ๋ก(/...)์ ๊ฒฝ์ฐ `basepath`๋ก ์์ํ๋ฉด SPA ๋ผ์ฐํ
ํฉ๋๋ค, ์ด์ธ ๋ธ๋ผ์ฐ์ ๋ค๋น๊ฒ์ด์
์ ์ฌ์ฉํฉ๋๋ค.
|
|
410
|
+
* - ์๋๊ฒฝ๋ก๋ (basepath + ์๋๊ฒฝ๋ก)๋ก ๊ฒฐํฉํ์ฌ SPA ๋ผ์ฐํ
ํฉ๋๋ค.
|
|
411
|
+
* - ?๋ก ์์ํ๋ฉด ํ์ฌ ๊ฒฝ๋ก์ ์ฟผ๋ฆฌ์คํธ๋ง์ ์ถ๊ฐํ์ฌ SPA ๋ผ์ฐํ
ํฉ๋๋ค.
|
|
412
|
+
* - #์ผ๋ก ์์ํ๋ฉด ๋ธ๋ผ์ฐ์ ๊ธฐ๋ณธ ๋์์ ์ฌ์ฉํฉ๋๋ค.
|
|
389
413
|
*/
|
|
390
414
|
href?: string;
|
|
415
|
+
connectedCallback(): void;
|
|
416
|
+
disconnectedCallback(): void;
|
|
391
417
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
392
418
|
render(): TemplateResult_2<1>;
|
|
393
|
-
/** basepath๋ฅผ state์์ ๊บผ๋ด๋ ํฌํผ */
|
|
394
|
-
private getBasepath;
|
|
395
419
|
/** a ํ๊ทธ์ ์ฃผ์
ํ href ๊ฐ์ ๊ณ์ฐํฉ๋๋ค. */
|
|
396
|
-
private
|
|
420
|
+
private compute;
|
|
397
421
|
/**
|
|
398
|
-
* ํด๋ฆญ ๊ฐ๋ก์ฑ๊ธฐ
|
|
422
|
+
* ํด๋ฆญ ๊ฐ๋ก์ฑ๊ธฐ ํธ๋ค๋ฌ
|
|
399
423
|
* - ์ขํด๋ฆญ(0) + ๋ณด์กฐํค ์์(ctrl/meta/shift/alt ์์) + target์ด _self์ผ ๋๋ง SPA ๋ผ์ฐํ
๊ณ ๋ ค
|
|
400
424
|
* - ๊ทธ ์ธ(์คํด๋ฆญ/์ฐํด๋ฆญ/๋ณด์กฐํค/target=_blank ๋ฑ)๋ ๋ธ๋ผ์ฐ์ ๊ธฐ๋ณธ ๋์ ์ ์ง
|
|
401
425
|
*/
|
|
402
|
-
private
|
|
426
|
+
private handleClick;
|
|
403
427
|
/** ํด๋ผ์ด์ธํธ ๋ผ์ฐํ
์ ์ํด popstate ์ด๋ฒคํธ๋ฅผ ๋ฐ์์ํต๋๋ค. */
|
|
404
428
|
private dispatchPopstate;
|
|
429
|
+
/** basepath๋ฅผ state์์ ๊บผ๋ด๋ ํฌํผ */
|
|
430
|
+
private getBasepath;
|
|
405
431
|
static styles: CSSResult;
|
|
406
432
|
}
|
|
407
433
|
|
|
408
434
|
/**
|
|
409
|
-
*
|
|
435
|
+
* LitElement ๋๋ React ์ปดํฌ๋ํธ๋ฅผ ๋ ๋๋งํด์ฃผ๋ ์น์ปดํฌ๋ํธ ์
๋๋ค.
|
|
410
436
|
*/
|
|
411
|
-
export declare class UOutlet extends
|
|
437
|
+
export declare class UOutlet extends HTMLElement {
|
|
438
|
+
/** ๊ต์ฐจ ๋ ๋๋ง ๋ฐฉ์ง id */
|
|
412
439
|
private routeId?;
|
|
413
|
-
|
|
414
|
-
private
|
|
415
|
-
/** ์ธ๋ถ ์คํ์ผ์ ์ ์ฉํ๊ธฐ ์ํด ๋ผ์ดํธ ๋์์ฌ์ฉ ํฉ๋๋ค. */
|
|
416
|
-
protected createRenderRoot(): this;
|
|
417
|
-
/** ์ปดํฌ๋ํธ๊ฐ DOM์ ์ฐ๊ฒฐ๋ ๋ ์ด๊ธฐํ ์์
์ํ */
|
|
418
|
-
connectedCallback(): void;
|
|
419
|
-
render(): TemplateResult<1>;
|
|
440
|
+
/** ์ค์ ๋ ๋๋ง ์ปจํ
์ธ */
|
|
441
|
+
private root?;
|
|
420
442
|
/**
|
|
421
|
-
*
|
|
422
|
-
* - HTMLElement, ReactElement, TemplateResult๋ฅผ ๋ชจ๋ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
|
|
443
|
+
* ์ฃผ์ด์ง ๋ ๋๋ง ์ต์
์ ๋ฐ๋ผ ์ปจํ
์ธ ๋ฅผ ๋ ๋๋งํฉ๋๋ค.
|
|
423
444
|
*/
|
|
424
|
-
|
|
445
|
+
render({ id, value, force }: RenderOption): void;
|
|
425
446
|
/**
|
|
426
|
-
* ๊ธฐ์กด DOM์
|
|
447
|
+
* ๊ธฐ์กด DOM์ ์ญ์ ํ์ฌ, ์ด๊ธฐ ์ํ๋ก ๋๋๋ฆฝ๋๋ค.
|
|
427
448
|
*/
|
|
428
|
-
|
|
449
|
+
reset(): void;
|
|
429
450
|
}
|
|
430
451
|
|
|
431
452
|
export { }
|
|
432
453
|
|
|
433
|
-
declare global {
|
|
434
|
-
interface WindowEventMap {
|
|
435
|
-
'route-begin': RouteBeginEvent;
|
|
436
|
-
'route-progress': RouteProgressEvent;
|
|
437
|
-
'route-done': RouteDoneEvent;
|
|
438
|
-
'route-error': RouteErrorEvent;
|
|
439
|
-
}
|
|
454
|
+
declare global {
|
|
455
|
+
interface WindowEventMap {
|
|
456
|
+
'route-begin': RouteBeginEvent;
|
|
457
|
+
'route-progress': RouteProgressEvent;
|
|
458
|
+
'route-done': RouteDoneEvent;
|
|
459
|
+
'route-error': RouteErrorEvent;
|
|
460
|
+
}
|
|
440
461
|
}
|