@iyulab/router 0.10.1 → 0.10.2
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 +6 -0
- package/dist/Router.d.ts +4 -1
- package/dist/components/UErrorPage.d.ts +4 -3
- package/dist/components/ULink.d.ts +4 -3
- package/dist/index.d.ts +0 -9
- package/dist/index.js +9 -5
- package/dist/react.d.ts +3 -2
- package/dist/react.js +1 -1
- package/dist/{share-C2LbLiIW.js → share-BUgoWpfZ.js} +2 -2
- package/dist/types/RouteEvent.d.ts +11 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.10.2] - 2026-07-15
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Click interception now reuses the route match computed while deciding whether to intercept an anchor, instead of recomputing it inside `go()` — avoids a duplicate `getRoutes` call per intercepted click
|
|
7
|
+
- Bumped `@types/node`, `@types/react`, `happy-dom`, `vite`, `vite-plugin-dts`, `vitest` devDependencies
|
|
8
|
+
|
|
3
9
|
## [0.10.1] - 2026-07-02
|
|
4
10
|
|
|
5
11
|
### Documentation
|
package/dist/Router.d.ts
CHANGED
|
@@ -29,8 +29,11 @@ export declare class Router {
|
|
|
29
29
|
* 지정한 경로의 클라이언트 라우팅을 수행합니다. 상대경로일 경우 basepath와 조합되어 이동합니다.
|
|
30
30
|
* @param href 이동할 경로
|
|
31
31
|
* @param options 네비게이션 옵션
|
|
32
|
+
* @param routes (internal) 호출자가 이미 계산한 라우트 매칭 결과가 있으면 재사용합니다.
|
|
33
|
+
* `handleRootElementClick`이 가로채기 여부 판단을 위해 미리 계산한 결과를 전달해
|
|
34
|
+
* 동일 pathname에 대한 getRoutes 중복 호출을 피하는 용도입니다. 외부에서 사용하지 마세요.
|
|
32
35
|
*/
|
|
33
|
-
go(href: string, options?: NavigateOptions): Promise<undefined>;
|
|
36
|
+
go(href: string, options?: NavigateOptions, routes?: RouteConfig[]): Promise<undefined>;
|
|
34
37
|
/** 브라우저 히스토리 이벤트가 발생시 라우팅 처리 */
|
|
35
38
|
private handleWindowPopstate;
|
|
36
39
|
/** 클릭 이벤트에서 라우터로 처리할 앵커를 찾아 클라이언트 라우팅 수행 */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
1
|
+
import { LitElement, CSSResult } from 'lit';
|
|
2
2
|
import { RouteError } from '../types/RouteError.js';
|
|
3
|
+
import { TemplateResult } from 'lit-html';
|
|
3
4
|
/**
|
|
4
5
|
* 라우팅 중 발생한 에러 정보를 사용자에게 전달하기 위한 기본 컴포넌트 입니다.
|
|
5
6
|
*/
|
|
@@ -7,10 +8,10 @@ export declare class UErrorPage extends LitElement {
|
|
|
7
8
|
constructor(error?: RouteError);
|
|
8
9
|
/** 표시할 에러 정보 */
|
|
9
10
|
error?: RouteError;
|
|
10
|
-
render():
|
|
11
|
+
render(): TemplateResult<1>;
|
|
11
12
|
/** 기본 에러 정보 반환 */
|
|
12
13
|
private getDefaultError;
|
|
13
14
|
/** 에러 코드에 따른 기본 아이콘 반환 */
|
|
14
15
|
private getErrorIcon;
|
|
15
|
-
static styles:
|
|
16
|
+
static styles: CSSResult;
|
|
16
17
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { LitElement, PropertyValues } from 'lit';
|
|
1
|
+
import { LitElement, PropertyValues, CSSResult } from 'lit';
|
|
2
|
+
import { TemplateResult } from 'lit-html';
|
|
2
3
|
/**
|
|
3
4
|
* - 클라이언트 라우팅을 지원하는 링크 엘리먼트입니다.
|
|
4
5
|
* - 내부 링크는 클라이언트 라우팅을 수행하고, 외부 링크는 브라우저 기본 네비게이션을 사용합니다.
|
|
@@ -40,7 +41,7 @@ export declare class ULink extends LitElement {
|
|
|
40
41
|
connectedCallback(): void;
|
|
41
42
|
disconnectedCallback(): void;
|
|
42
43
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
43
|
-
render():
|
|
44
|
+
render(): TemplateResult<1>;
|
|
44
45
|
/** a 태그에 주입할 href 값을 계산합니다. */
|
|
45
46
|
private compute;
|
|
46
47
|
/**
|
|
@@ -53,5 +54,5 @@ export declare class ULink extends LitElement {
|
|
|
53
54
|
private dispatchPopstate;
|
|
54
55
|
/** basepath를 state에서 꺼내는 헬퍼 */
|
|
55
56
|
private getBasepath;
|
|
56
|
-
static styles:
|
|
57
|
+
static styles: CSSResult;
|
|
57
58
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,3 @@ export * from './types/RouterConfig';
|
|
|
7
7
|
export * from './components/UOutlet';
|
|
8
8
|
export * from './components/ULink';
|
|
9
9
|
export { Router } from './Router';
|
|
10
|
-
|
|
11
|
-
declare global {
|
|
12
|
-
interface WindowEventMap {
|
|
13
|
-
'route-begin': RouteBeginEvent;
|
|
14
|
-
'route-progress': RouteProgressEvent;
|
|
15
|
-
'route-done': RouteDoneEvent;
|
|
16
|
-
'route-error': RouteErrorEvent;
|
|
17
|
-
}
|
|
18
|
-
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isExternalUrl, i as absolutePath, n as __decorate, o as parseUrl, r as __decorateMetadata, s as UOutlet, t as ULink } from "./share-
|
|
1
|
+
import { a as isExternalUrl, i as absolutePath, n as __decorate, o as parseUrl, r as __decorateMetadata, s as UOutlet, t as ULink } from "./share-BUgoWpfZ.js";
|
|
2
2
|
import { LitElement, css, html } from "lit";
|
|
3
3
|
import { customElement, property } from "lit/decorators.js";
|
|
4
4
|
//#region src/types/RouteError.ts
|
|
@@ -403,9 +403,10 @@ var Router = class {
|
|
|
403
403
|
if (anchor.target && anchor.target !== "") return;
|
|
404
404
|
const pathname = new URL(anchor.href).pathname;
|
|
405
405
|
if (this._basepath !== "/" && !pathname.startsWith(this._basepath)) return;
|
|
406
|
-
|
|
406
|
+
const routes = getRoutes(this._routes, pathname);
|
|
407
|
+
if (routes.length === 0) return;
|
|
407
408
|
e.preventDefault();
|
|
408
|
-
await this.go(anchor.href);
|
|
409
|
+
await this.go(anchor.href, void 0, routes);
|
|
409
410
|
} catch {}
|
|
410
411
|
};
|
|
411
412
|
this.destroy();
|
|
@@ -443,8 +444,11 @@ var Router = class {
|
|
|
443
444
|
* 지정한 경로의 클라이언트 라우팅을 수행합니다. 상대경로일 경우 basepath와 조합되어 이동합니다.
|
|
444
445
|
* @param href 이동할 경로
|
|
445
446
|
* @param options 네비게이션 옵션
|
|
447
|
+
* @param routes (internal) 호출자가 이미 계산한 라우트 매칭 결과가 있으면 재사용합니다.
|
|
448
|
+
* `handleRootElementClick`이 가로채기 여부 판단을 위해 미리 계산한 결과를 전달해
|
|
449
|
+
* 동일 pathname에 대한 getRoutes 중복 호출을 피하는 용도입니다. 외부에서 사용하지 마세요.
|
|
446
450
|
*/
|
|
447
|
-
async go(href, options) {
|
|
451
|
+
async go(href, options, routes) {
|
|
448
452
|
if (!options?.isRedirect) this._tracker.reset();
|
|
449
453
|
const requestID = getRandomID();
|
|
450
454
|
this._requestID = requestID;
|
|
@@ -461,7 +465,7 @@ var Router = class {
|
|
|
461
465
|
let title = void 0;
|
|
462
466
|
try {
|
|
463
467
|
outlet = findOutletOrThrow(this._rootElement);
|
|
464
|
-
|
|
468
|
+
routes ??= getRoutes(this._routes, context.pathname);
|
|
465
469
|
if (routes.length === 0) throw new NotFoundError(context.href);
|
|
466
470
|
const lastRoute = routes[routes.length - 1];
|
|
467
471
|
if (lastRoute.path instanceof URLPattern) context.params = lastRoute.path.exec({ pathname: context.pathname })?.pathname.groups || {};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ULink as ULinkElement } from './components/ULink.js';
|
|
2
2
|
import { UOutlet as UOutletElement } from './components/UOutlet.js';
|
|
3
|
+
import { ReactWebComponent } from '@lit/react';
|
|
3
4
|
/**
|
|
4
5
|
* `u-link` 웹 컴포넌트를 React에서 사용할 수 있도록 래핑한 컴포넌트입니다.
|
|
5
6
|
*/
|
|
6
|
-
export declare const ULink:
|
|
7
|
+
export declare const ULink: ReactWebComponent<ULinkElement, {}>;
|
|
7
8
|
/**
|
|
8
9
|
* `u-outlet` 웹 컴포넌트를 React에서 사용할 수 있도록 래핑한 컴포넌트입니다.
|
|
9
10
|
*/
|
|
10
|
-
export declare const UOutlet:
|
|
11
|
+
export declare const UOutlet: ReactWebComponent<UOutletElement, {}>;
|
package/dist/react.js
CHANGED
|
@@ -126,12 +126,12 @@ function catchBasepath(basepath) {
|
|
|
126
126
|
return basepath;
|
|
127
127
|
}
|
|
128
128
|
//#endregion
|
|
129
|
-
//#region \0@oxc-project+runtime@0.
|
|
129
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/decorateMetadata.js
|
|
130
130
|
function __decorateMetadata(k, v) {
|
|
131
131
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
132
132
|
}
|
|
133
133
|
//#endregion
|
|
134
|
-
//#region \0@oxc-project+runtime@0.
|
|
134
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/decorate.js
|
|
135
135
|
function __decorate(decorators, target, key, desc) {
|
|
136
136
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
137
137
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -40,4 +40,15 @@ export declare class RouteErrorEvent extends RouteEvent {
|
|
|
40
40
|
readonly error: RouteError;
|
|
41
41
|
constructor(context: RouteContext, error: RouteError);
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 전역 WindowEventMap에 라우터 이벤트 타입
|
|
45
|
+
*/
|
|
46
|
+
declare global {
|
|
47
|
+
interface WindowEventMap {
|
|
48
|
+
'route-begin': RouteBeginEvent;
|
|
49
|
+
'route-progress': RouteProgressEvent;
|
|
50
|
+
'route-done': RouteDoneEvent;
|
|
51
|
+
'route-error': RouteErrorEvent;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
43
54
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/router",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "A modern client-side router for web applications with support for Lit and React components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@types/node": "^
|
|
63
|
-
"@types/react": "^19.2.
|
|
62
|
+
"@types/node": "^26.1.1",
|
|
63
|
+
"@types/react": "^19.2.17",
|
|
64
64
|
"@types/react-dom": "^19.2.3",
|
|
65
|
-
"happy-dom": "^20.10.
|
|
65
|
+
"happy-dom": "^20.10.6",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
|
-
"vite": "^8.
|
|
68
|
-
"vite-plugin-dts": "^5.0.
|
|
69
|
-
"vitest": "^4.1.
|
|
67
|
+
"vite": "^8.1.4",
|
|
68
|
+
"vite-plugin-dts": "^5.0.3",
|
|
69
|
+
"vitest": "^4.1.10"
|
|
70
70
|
}
|
|
71
71
|
}
|