@wcstack/router 1.10.3 → 1.11.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/dist/index.d.ts CHANGED
@@ -34,10 +34,20 @@ interface IWcBindableProperty {
34
34
  readonly event: string;
35
35
  readonly getter?: (event: Event) => any;
36
36
  }
37
+ interface IWcBindableInput {
38
+ readonly name: string;
39
+ readonly attribute?: string;
40
+ }
41
+ interface IWcBindableCommand {
42
+ readonly name: string;
43
+ readonly async?: boolean;
44
+ }
37
45
  interface IWcBindable {
38
46
  readonly protocol: "wc-bindable";
39
- readonly version: number;
47
+ readonly version: 1;
40
48
  readonly properties: IWcBindableProperty[];
49
+ readonly inputs?: readonly IWcBindableInput[];
50
+ readonly commands?: readonly IWcBindableCommand[];
41
51
  }
42
52
 
43
53
  /**
@@ -79,8 +89,8 @@ interface IRoute extends IRouteChildContainer {
79
89
  readonly placeHolder: Comment;
80
90
  readonly childNodeArray: Node[];
81
91
  readonly routes: IRoute[];
82
- params: Record<string, string>;
83
- typedParams: Record<string, any>;
92
+ readonly params: Record<string, string>;
93
+ readonly typedParams: Record<string, any>;
84
94
  readonly paramNames: string[];
85
95
  readonly absoluteParamNames: string[];
86
96
  readonly weight: number;
@@ -99,6 +109,7 @@ interface IRoute extends IRouteChildContainer {
99
109
  testAncestorNode(ancestorNode: IRoute): boolean;
100
110
  setParams(params: Record<string, string>, typedParams: Record<string, any>): void;
101
111
  clearParams(): void;
112
+ notifyGuardHandlerLoadFailed(): void;
102
113
  }
103
114
  interface IRouter extends IRouteChildContainer {
104
115
  readonly basename: string;
@@ -129,21 +140,19 @@ declare class Router extends HTMLElement implements IRouter {
129
140
  private _initialized;
130
141
  private _fallbackRoute;
131
142
  private _listeningPopState;
143
+ private _listeningNavigate;
132
144
  private _navigateUrl;
145
+ private _disconnectedDuringInit;
146
+ private _initializing;
133
147
  constructor();
134
148
  /**
135
149
  * Normalize a URL pathname to a route path.
136
- * - ensure leading slash
137
- * - collapse multiple slashes
138
- * - treat trailing file extensions (e.g. .html) as directory root
139
- * - remove trailing slash except root "/"
150
+ * 共通実装は normalizePathname.ts を参照(Link との挙動整合のため)。
140
151
  */
141
152
  private _normalizePathname;
142
153
  /**
143
154
  * Normalize basename.
144
- * - "" or "/" -> ""
145
- * - "/app/" -> "/app"
146
- * - "/app/index.html" -> "/app"
155
+ * 共通実装は normalizePathname.ts を参照。
147
156
  */
148
157
  private _normalizeBasename;
149
158
  private _joinInternalPath;
@@ -192,6 +201,7 @@ declare class Route extends HTMLElement implements IRoute {
192
201
  private _childNodeArray;
193
202
  private _childIndex;
194
203
  private _initialized;
204
+ private _routes;
195
205
  constructor();
196
206
  get routeParentNode(): IRoute | null;
197
207
  get routeChildNodes(): IRoute[];
@@ -222,6 +232,15 @@ declare class Route extends HTMLElement implements IRoute {
222
232
  clearParams(): void;
223
233
  shouldChange(newParams: Record<string, string>): boolean;
224
234
  guardCheck(matchResult: IRouteMatchResult): Promise<void>;
235
+ notifyGuardHandlerLoadFailed(): void;
236
+ /**
237
+ * Shell(Route)の routeParentNode を辿って祖先関係を判定する。
238
+ *
239
+ * 責務の分担:
240
+ * - Route(このクラス)は DOM ツリー上の親子関係(routeParentNode)を管理する。
241
+ * - RouteCore はパスやパラメータといった論理的な親子関係(parentCore)を管理する。
242
+ * DOM ツリーは Shell 層、論理ツリーは Core 層という分離のため、両者を独立に保持する。
243
+ */
225
244
  testAncestorNode(ancestorNode: IRoute): boolean;
226
245
  initialize(routerNode: IRouter, routeParentNode: IRoute | null): void;
227
246
  }
@@ -255,6 +274,7 @@ declare class RouteCore extends EventTarget {
255
274
  private _guardFallbackPath;
256
275
  private _waitForSetGuardHandler;
257
276
  private _resolveSetGuardHandler;
277
+ private _guardHandlerLoadFailed;
258
278
  constructor(target?: EventTarget);
259
279
  get parentCore(): RouteCore | null;
260
280
  set parentCore(value: RouteCore | null);
@@ -281,8 +301,15 @@ declare class RouteCore extends EventTarget {
281
301
  shouldChange(newParams: Record<string, string>): boolean;
282
302
  get guardHandler(): GuardHandler;
283
303
  set guardHandler(value: GuardHandler);
304
+ /**
305
+ * Guardハンドラのロードに失敗したことを通知し、guardCheck の待ちを解除する。
306
+ * 解除後の guardCheck は guardHandler が未設定のため fallback パスへリダイレクトする。
307
+ */
308
+ notifyGuardHandlerLoadFailed(): void;
284
309
  guardCheck(matchResult: IRouteMatchResult): Promise<void>;
285
310
  }
286
311
 
287
- export { Route, RouteCore, Router, bootstrapRouter, getConfig };
312
+ declare const VERSION: string;
313
+
314
+ export { Route, RouteCore, Router, VERSION, bootstrapRouter, getConfig };
288
315
  export type { IWritableConfig, IWritableTagNames, RouteParseOptions };