@iyulab/router 0.3.0 → 0.5.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.
@@ -29,7 +29,7 @@ declare interface BaseRouteConfig {
29
29
  * }
30
30
  * ```
31
31
  */
32
- render: (info: RouteInfo) => HTMLElement | ReactElement | TemplateResult<1>;
32
+ render?: (info: RouteInfo) => Promise<RenderResult> | RenderResult;
33
33
  /**
34
34
  * 중첩 라우트
35
35
  */
@@ -94,9 +94,7 @@ export declare class Link extends LitElement {
94
94
  private dispatchHashchange;
95
95
  /** 기본 a 태그의 클릭 이벤트를 막습니다. */
96
96
  private preventClickEvent;
97
- /** 외부 링크인지 확인합니다. */
98
- private checkExternalLink;
99
- /** a 태그의 href 값을 계산합니다. */
97
+ /** a 태그에 주입할 href 값을 계산합니다. */
100
98
  private getAnchorHref;
101
99
  static styles: CSSResult;
102
100
  }
@@ -152,9 +150,11 @@ declare interface PathRouteConfig extends BaseRouteConfig {
152
150
  declare interface RenderOption {
153
151
  id?: string;
154
152
  force?: boolean;
155
- content: HTMLElement | ReactElement | TemplateResult<1>;
153
+ content: RenderResult;
156
154
  }
157
155
 
156
+ declare type RenderResult = HTMLElement | ReactElement | TemplateResult<1>;
157
+
158
158
  /**
159
159
  * 라우트 시작 이벤트
160
160
  */
@@ -286,6 +286,9 @@ export declare interface RouteInfo {
286
286
  hash?: string;
287
287
  }
288
288
 
289
+ /**
290
+ * `lit-element`와 `react-component` 기반의 클라이언트 사이드 라우터
291
+ */
289
292
  export declare class Router {
290
293
  private readonly _rootElement;
291
294
  private readonly _basepath;
@@ -294,29 +297,26 @@ export declare class Router {
294
297
  private _requestID?;
295
298
  /** 현재 라우팅 정보 */
296
299
  private _routeInfo?;
297
- /** 현재 라우팅 시도 카운터 */
298
- private _counter;
299
300
  constructor(config: RouterConfig);
301
+ /** 초기 라우팅 처리, TODO: 제거 */
302
+ private waitConnected;
303
+ /** 객체를 정리하고 이벤트 리스너를 제거합니다. */
304
+ destroy(): void;
305
+ /** 라우터의 기본 경로 반환 */
300
306
  get basepath(): string;
307
+ /** 등록된 라우트 반환 */
301
308
  get routes(): RouteConfig[];
309
+ /** 현재 라우팅 정보 반환 */
302
310
  get routeInfo(): RouteInfo | undefined;
303
311
  /**
304
312
  * 지정한 경로의 클라이언트 라우팅을 수행합니다. 상대경로일 경우 basepath와 조합되어 이동합니다.
305
313
  * @param href 이동할 경로
306
314
  */
307
315
  go(href: string): Promise<void>;
308
- /** 초기 라우팅 처리, TODO: 제거 */
309
- private initiate;
310
316
  /** 브라우저 히스토리 이벤트가 발생시 라우팅 처리 */
311
- private handlePopstate;
312
- /** 라우트를 재설정합니다. */
313
- private setRoutes;
314
- /** URLPattern을 사용하여 경로와 일치하는 라우트들을 자식 라우트까지 포함하여 반환합니다. */
315
- private getRoutes;
316
- /** Outlet 엘리먼트를 찾아 반환합니다. */
317
- private findOutlet;
318
- /** Outlet 엘리먼트를 찾아 반환합니다. 없으면 에러를 던집니다. */
319
- private findOutletOrThrow;
317
+ private handleWindowPopstate;
318
+ /** 클릭 이벤트에서 라우터로 처리할 앵커를 찾아 클라이언트 라우팅 수행 */
319
+ private handleRootClick;
320
320
  }
321
321
 
322
322
  /**
@@ -340,6 +340,11 @@ export declare interface RouterConfig {
340
340
  * - 라우트는 렌더링할 엘리먼트 또는 컴포넌트를 지정합니다.
341
341
  */
342
342
  routes: RouteConfig[];
343
+ /**
344
+ * `a` 태그 클릭 시 클라이언트 라우팅을 수행할지 여부를 설정합니다.
345
+ * @default true
346
+ */
347
+ useIntercept?: boolean;
343
348
  }
344
349
 
345
350
  export declare const ULink: ReactWebComponent<Link, {}>;
@@ -347,3 +352,20 @@ export declare const ULink: ReactWebComponent<Link, {}>;
347
352
  export declare const UOutlet: ReactWebComponent<Outlet, {}>;
348
353
 
349
354
  export { }
355
+
356
+ declare global {
357
+ interface Window {
358
+ route: RouteInfo;
359
+ }
360
+
361
+ interface WindowEventMap {
362
+ 'route-begin': RouteBeginEvent;
363
+ 'route-done': RouteDoneEvent;
364
+ 'route-error': RouteErrorEvent;
365
+ }
366
+
367
+ interface HTMLElementTagNameMap {
368
+ 'u-link': Link;
369
+ 'u-outlet': Outlet;
370
+ }
371
+ }