soseki 0.0.4 → 0.0.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/LICENSE +21 -0
- package/dist/src/components/browser-router.d.ts +19 -0
- package/dist/src/components/browser-router.d.ts.map +1 -0
- package/dist/src/components/browser-router.jsx +15 -0
- package/dist/src/components/outlet.d.ts +8 -0
- package/dist/src/components/outlet.d.ts.map +1 -0
- package/dist/src/components/outlet.jsx +15 -0
- package/dist/src/components/router.d.ts +21 -0
- package/dist/src/components/router.d.ts.map +1 -0
- package/dist/src/components/router.jsx +138 -0
- package/dist/src/contexts/route-context.d.ts +19 -0
- package/dist/src/contexts/route-context.d.ts.map +1 -0
- package/dist/src/contexts/route-context.js +6 -0
- package/dist/src/contexts/router-context.d.ts +55 -0
- package/dist/src/contexts/router-context.d.ts.map +1 -0
- package/dist/src/contexts/router-context.js +8 -0
- package/dist/src/core/_compare-route-paths.d.ts +11 -0
- package/dist/src/core/_compare-route-paths.d.ts.map +1 -0
- package/dist/src/core/_compare-route-paths.js +92 -0
- package/dist/src/core/_match-route-path.d.ts +22 -0
- package/dist/src/core/_match-route-path.d.ts.map +1 -0
- package/dist/src/core/_match-route-path.js +26 -0
- package/dist/src/core/_process-routes.d.ts +14 -0
- package/dist/src/core/_process-routes.d.ts.map +1 -0
- package/dist/src/core/_process-routes.js +45 -0
- package/dist/src/core/_singleton.d.ts +12 -0
- package/dist/src/core/_singleton.d.ts.map +1 -0
- package/dist/src/core/_singleton.js +18 -0
- package/dist/src/core/_unreachable.d.ts +16 -0
- package/dist/src/core/_unreachable.d.ts.map +1 -0
- package/dist/src/core/_unreachable.js +8 -0
- package/dist/src/core/_valibot.d.ts +25 -0
- package/dist/src/core/_valibot.d.ts.map +1 -0
- package/dist/src/core/_valibot.js +30 -0
- package/dist/src/core/errors.d.ts +182 -0
- package/dist/src/core/errors.d.ts.map +1 -0
- package/dist/src/core/errors.js +166 -0
- package/dist/src/core/expect-history-entry.d.ts +59 -0
- package/dist/src/core/expect-history-entry.d.ts.map +1 -0
- package/dist/src/core/expect-history-entry.js +42 -0
- package/dist/src/core/form-data-to-html-form-element.d.ts +11 -0
- package/dist/src/core/form-data-to-html-form-element.d.ts.map +1 -0
- package/dist/src/core/form-data-to-html-form-element.js +31 -0
- package/dist/src/core/history-entry-id-schema.d.ts +17 -0
- package/dist/src/core/history-entry-id-schema.d.ts.map +1 -0
- package/dist/src/core/history-entry-id-schema.js +9 -0
- package/dist/src/core/history-entry-url-schema.d.ts +18 -0
- package/dist/src/core/history-entry-url-schema.d.ts.map +1 -0
- package/dist/src/core/history-entry-url-schema.js +20 -0
- package/dist/src/core/init-loaders.d.ts +28 -0
- package/dist/src/core/init-loaders.d.ts.map +1 -0
- package/dist/src/core/init-loaders.js +30 -0
- package/dist/src/core/match-routes.d.ts +28 -0
- package/dist/src/core/match-routes.d.ts.map +1 -0
- package/dist/src/core/match-routes.js +31 -0
- package/dist/src/core/readonly-form-data.types.d.ts +74 -0
- package/dist/src/core/readonly-form-data.types.d.ts.map +1 -0
- package/dist/src/core/readonly-url.types.d.ts +164 -0
- package/dist/src/core/readonly-url.types.d.ts.map +1 -0
- package/dist/src/core/redirect-response.d.ts +37 -0
- package/dist/src/core/redirect-response.d.ts.map +1 -0
- package/dist/src/core/redirect-response.js +19 -0
- package/dist/src/core/route-path.d.ts +57 -0
- package/dist/src/core/route-path.d.ts.map +1 -0
- package/dist/src/core/route-path.js +93 -0
- package/dist/src/core/route-request.d.ts +149 -0
- package/dist/src/core/route-request.d.ts.map +1 -0
- package/dist/src/core/route-request.js +41 -0
- package/dist/src/core/route.types.d.ts +296 -0
- package/dist/src/core/route.types.d.ts.map +1 -0
- package/dist/src/core/start-action.d.ts +53 -0
- package/dist/src/core/start-action.d.ts.map +1 -0
- package/dist/src/core/start-action.js +95 -0
- package/dist/src/core/start-loaders.d.ts +63 -0
- package/dist/src/core/start-loaders.d.ts.map +1 -0
- package/dist/src/core/start-loaders.js +138 -0
- package/dist/{core.d.ts → src/core.d.ts} +7 -11
- package/dist/src/core.d.ts.map +1 -0
- package/dist/{core.js → src/core.js} +2 -4
- package/dist/src/engines/engine.types.d.ts +216 -0
- package/dist/src/engines/engine.types.d.ts.map +1 -0
- package/dist/src/engines/navigation-api-engine.d.ts +50 -0
- package/dist/src/engines/navigation-api-engine.d.ts.map +1 -0
- package/dist/src/engines/navigation-api-engine.js +411 -0
- package/dist/src/engines.d.ts +4 -0
- package/dist/src/engines.d.ts.map +1 -0
- package/dist/src/engines.js +1 -0
- package/dist/src/hooks/_use-singleton.d.ts +11 -0
- package/dist/src/hooks/_use-singleton.d.ts.map +1 -0
- package/dist/src/hooks/_use-singleton.js +26 -0
- package/dist/src/hooks/use-action-data.d.ts +17 -0
- package/dist/src/hooks/use-action-data.d.ts.map +1 -0
- package/dist/src/hooks/use-action-data.js +16 -0
- package/dist/src/hooks/use-form-action.d.ts +7 -0
- package/dist/src/hooks/use-form-action.d.ts.map +1 -0
- package/dist/src/hooks/use-form-action.js +9 -0
- package/dist/src/hooks/use-loader-data.d.ts +9 -0
- package/dist/src/hooks/use-loader-data.d.ts.map +1 -0
- package/dist/src/hooks/use-loader-data.js +20 -0
- package/dist/src/hooks/use-navigate.d.ts +53 -0
- package/dist/src/hooks/use-navigate.d.ts.map +1 -0
- package/dist/src/hooks/use-navigate.js +43 -0
- package/dist/{hooks → src/hooks}/use-params.d.ts +2 -2
- package/dist/src/hooks/use-params.d.ts.map +1 -0
- package/dist/{hooks → src/hooks}/use-params.js +1 -1
- package/dist/src/hooks/use-route-context.d.ts +10 -0
- package/dist/src/hooks/use-route-context.d.ts.map +1 -0
- package/dist/src/hooks/use-route-context.js +17 -0
- package/dist/src/hooks/use-router-context.d.ts +12 -0
- package/dist/src/hooks/use-router-context.d.ts.map +1 -0
- package/dist/src/hooks/use-router-context.js +20 -0
- package/dist/src/hooks/use-submit.d.ts +59 -0
- package/dist/src/hooks/use-submit.d.ts.map +1 -0
- package/dist/src/hooks/use-submit.js +38 -0
- package/dist/src/soseki.d.ts +31 -0
- package/dist/src/soseki.d.ts.map +1 -0
- package/dist/src/soseki.js +12 -0
- package/dist/src/utils/redirect.d.ts +11 -0
- package/dist/src/utils/redirect.d.ts.map +1 -0
- package/dist/src/utils/redirect.js +12 -0
- package/package.json +48 -30
- package/src/components/browser-router.tsx +8 -11
- package/src/components/outlet.tsx +3 -2
- package/src/components/router.tsx +139 -145
- package/src/contexts/route-context.ts +6 -5
- package/src/contexts/router-context.ts +36 -19
- package/src/core/_compare-route-paths.ts +48 -34
- package/src/core/_match-route-path.ts +21 -15
- package/src/core/_process-routes.ts +44 -46
- package/src/core/_singleton.ts +13 -38
- package/src/core/_unreachable.ts +12 -7
- package/src/core/_valibot.ts +19 -116
- package/src/core/errors.ts +150 -495
- package/src/core/expect-history-entry.ts +40 -41
- package/src/core/form-data-to-html-form-element.ts +37 -0
- package/src/core/history-entry-id-schema.ts +6 -11
- package/src/core/history-entry-url-schema.ts +25 -18
- package/src/core/init-loaders.ts +35 -57
- package/src/core/match-routes.ts +33 -65
- package/src/core/readonly-form-data.types.ts +48 -28
- package/src/core/readonly-url.types.ts +57 -28
- package/src/core/redirect-response.ts +26 -15
- package/src/core/route-path.ts +114 -0
- package/src/core/route-request.ts +144 -32
- package/src/core/route.types.ts +250 -226
- package/src/core/start-action.ts +164 -0
- package/src/core/start-loaders.ts +190 -212
- package/src/core.ts +8 -15
- package/src/engines/engine.types.ts +204 -166
- package/src/engines/navigation-api-engine.ts +332 -233
- package/src/engines.ts +4 -0
- package/src/hooks/_use-singleton.ts +30 -0
- package/src/hooks/use-action-data.ts +21 -26
- package/src/hooks/use-form-action.ts +4 -5
- package/src/hooks/use-loader-data.ts +16 -18
- package/src/hooks/use-navigate.ts +69 -28
- package/src/hooks/use-params.ts +4 -4
- package/src/hooks/use-route-context.ts +20 -0
- package/src/hooks/use-router-context.ts +25 -0
- package/src/hooks/use-submit.ts +48 -53
- package/src/soseki.ts +27 -34
- package/src/utils/redirect.ts +5 -5
- package/dist/components/action-id.d.ts +0 -19
- package/dist/components/action-id.d.ts.map +0 -1
- package/dist/components/action-id.jsx +0 -14
- package/dist/components/browser-router.d.ts +0 -17
- package/dist/components/browser-router.d.ts.map +0 -1
- package/dist/components/browser-router.jsx +0 -13
- package/dist/components/hidden-input.d.ts +0 -20
- package/dist/components/hidden-input.d.ts.map +0 -1
- package/dist/components/hidden-input.jsx +0 -8
- package/dist/components/outlet.d.ts +0 -8
- package/dist/components/outlet.d.ts.map +0 -1
- package/dist/components/outlet.jsx +0 -15
- package/dist/components/router.d.ts +0 -23
- package/dist/components/router.d.ts.map +0 -1
- package/dist/components/router.jsx +0 -128
- package/dist/contexts/route-context.d.ts +0 -19
- package/dist/contexts/route-context.d.ts.map +0 -1
- package/dist/contexts/route-context.js +0 -6
- package/dist/contexts/router-context.d.ts +0 -46
- package/dist/contexts/router-context.d.ts.map +0 -1
- package/dist/contexts/router-context.js +0 -8
- package/dist/core/_action-id-registry.d.ts +0 -10
- package/dist/core/_action-id-registry.d.ts.map +0 -1
- package/dist/core/_action-id-registry.js +0 -8
- package/dist/core/_capture-stack-trace.d.ts +0 -8
- package/dist/core/_capture-stack-trace.d.ts.map +0 -1
- package/dist/core/_capture-stack-trace.js +0 -12
- package/dist/core/_compare-route-paths.d.ts +0 -11
- package/dist/core/_compare-route-paths.d.ts.map +0 -1
- package/dist/core/_compare-route-paths.js +0 -80
- package/dist/core/_create-html-form-element-form-form-data.d.ts +0 -9
- package/dist/core/_create-html-form-element-form-form-data.d.ts.map +0 -1
- package/dist/core/_create-html-form-element-form-form-data.js +0 -27
- package/dist/core/_encode-pathname.d.ts +0 -10
- package/dist/core/_encode-pathname.d.ts.map +0 -1
- package/dist/core/_encode-pathname.js +0 -16
- package/dist/core/_is-error.d.ts +0 -3
- package/dist/core/_is-error.d.ts.map +0 -1
- package/dist/core/_is-error.js +0 -13
- package/dist/core/_is-promise-like.d.ts +0 -8
- package/dist/core/_is-promise-like.d.ts.map +0 -1
- package/dist/core/_is-promise-like.js +0 -12
- package/dist/core/_match-route-path.d.ts +0 -19
- package/dist/core/_match-route-path.d.ts.map +0 -1
- package/dist/core/_match-route-path.js +0 -22
- package/dist/core/_process-routes.d.ts +0 -9
- package/dist/core/_process-routes.d.ts.map +0 -1
- package/dist/core/_process-routes.js +0 -47
- package/dist/core/_singleton.d.ts +0 -18
- package/dist/core/_singleton.d.ts.map +0 -1
- package/dist/core/_singleton.js +0 -37
- package/dist/core/_unreachable.d.ts +0 -12
- package/dist/core/_unreachable.d.ts.map +0 -1
- package/dist/core/_unreachable.js +0 -8
- package/dist/core/_use-singleton.d.ts +0 -11
- package/dist/core/_use-singleton.d.ts.map +0 -1
- package/dist/core/_use-singleton.js +0 -21
- package/dist/core/_valibot.d.ts +0 -52
- package/dist/core/_valibot.d.ts.map +0 -1
- package/dist/core/_valibot.js +0 -107
- package/dist/core/_weak-id-registry.d.ts +0 -76
- package/dist/core/_weak-id-registry.d.ts.map +0 -1
- package/dist/core/_weak-id-registry.js +0 -67
- package/dist/core/constants.d.ts +0 -5
- package/dist/core/constants.d.ts.map +0 -1
- package/dist/core/constants.js +0 -4
- package/dist/core/data-map.types.d.ts +0 -23
- package/dist/core/data-map.types.d.ts.map +0 -1
- package/dist/core/data-map.types.js +0 -1
- package/dist/core/data-store.types.d.ts +0 -22
- package/dist/core/data-store.types.d.ts.map +0 -1
- package/dist/core/data-store.types.js +0 -1
- package/dist/core/deferred-promise.d.ts +0 -203
- package/dist/core/deferred-promise.d.ts.map +0 -1
- package/dist/core/deferred-promise.js +0 -200
- package/dist/core/errors.d.ts +0 -303
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/errors.js +0 -400
- package/dist/core/expect-history-entry.d.ts +0 -52
- package/dist/core/expect-history-entry.d.ts.map +0 -1
- package/dist/core/expect-history-entry.js +0 -38
- package/dist/core/history-entry-id-schema.d.ts +0 -17
- package/dist/core/history-entry-id-schema.d.ts.map +0 -1
- package/dist/core/history-entry-id-schema.js +0 -9
- package/dist/core/history-entry-url-schema.d.ts +0 -20
- package/dist/core/history-entry-url-schema.d.ts.map +0 -1
- package/dist/core/history-entry-url-schema.js +0 -16
- package/dist/core/init-loaders.d.ts +0 -37
- package/dist/core/init-loaders.d.ts.map +0 -1
- package/dist/core/init-loaders.js +0 -38
- package/dist/core/match-routes.d.ts +0 -31
- package/dist/core/match-routes.d.ts.map +0 -1
- package/dist/core/match-routes.js +0 -54
- package/dist/core/readonly-form-data.types.d.ts +0 -32
- package/dist/core/readonly-form-data.types.d.ts.map +0 -1
- package/dist/core/readonly-url.types.d.ts +0 -135
- package/dist/core/readonly-url.types.d.ts.map +0 -1
- package/dist/core/redirect-response.d.ts +0 -29
- package/dist/core/redirect-response.d.ts.map +0 -1
- package/dist/core/redirect-response.js +0 -17
- package/dist/core/route-request.d.ts +0 -52
- package/dist/core/route-request.d.ts.map +0 -1
- package/dist/core/route-request.js +0 -26
- package/dist/core/route.types.d.ts +0 -309
- package/dist/core/route.types.d.ts.map +0 -1
- package/dist/core/start-actions.d.ts +0 -60
- package/dist/core/start-actions.d.ts.map +0 -1
- package/dist/core/start-actions.js +0 -186
- package/dist/core/start-loaders.d.ts +0 -69
- package/dist/core/start-loaders.d.ts.map +0 -1
- package/dist/core/start-loaders.js +0 -154
- package/dist/core.d.ts.map +0 -1
- package/dist/engines/engine.types.d.ts +0 -190
- package/dist/engines/engine.types.d.ts.map +0 -1
- package/dist/engines/navigation-api-engine.d.ts +0 -48
- package/dist/engines/navigation-api-engine.d.ts.map +0 -1
- package/dist/engines/navigation-api-engine.js +0 -332
- package/dist/hooks/_use-route-context.d.ts +0 -10
- package/dist/hooks/_use-route-context.d.ts.map +0 -1
- package/dist/hooks/_use-route-context.js +0 -17
- package/dist/hooks/_use-router-context.d.ts +0 -10
- package/dist/hooks/_use-router-context.d.ts.map +0 -1
- package/dist/hooks/_use-router-context.js +0 -18
- package/dist/hooks/use-action-data.d.ts +0 -23
- package/dist/hooks/use-action-data.d.ts.map +0 -1
- package/dist/hooks/use-action-data.js +0 -16
- package/dist/hooks/use-form-action.d.ts +0 -7
- package/dist/hooks/use-form-action.d.ts.map +0 -1
- package/dist/hooks/use-form-action.js +0 -10
- package/dist/hooks/use-loader-data.d.ts +0 -11
- package/dist/hooks/use-loader-data.d.ts.map +0 -1
- package/dist/hooks/use-loader-data.js +0 -19
- package/dist/hooks/use-navigate.d.ts +0 -39
- package/dist/hooks/use-navigate.d.ts.map +0 -1
- package/dist/hooks/use-navigate.js +0 -26
- package/dist/hooks/use-params.d.ts.map +0 -1
- package/dist/hooks/use-pathname.d.ts +0 -7
- package/dist/hooks/use-pathname.d.ts.map +0 -1
- package/dist/hooks/use-pathname.js +0 -9
- package/dist/hooks/use-submit.d.ts +0 -66
- package/dist/hooks/use-submit.d.ts.map +0 -1
- package/dist/hooks/use-submit.js +0 -35
- package/dist/soseki.d.ts +0 -42
- package/dist/soseki.d.ts.map +0 -1
- package/dist/soseki.js +0 -19
- package/dist/utils/get-action-id.d.ts +0 -8
- package/dist/utils/get-action-id.d.ts.map +0 -1
- package/dist/utils/get-action-id.js +0 -11
- package/dist/utils/href.d.ts +0 -11
- package/dist/utils/href.d.ts.map +0 -1
- package/dist/utils/href.js +0 -12
- package/dist/utils/redirect.d.ts +0 -11
- package/dist/utils/redirect.d.ts.map +0 -1
- package/dist/utils/redirect.js +0 -12
- package/dist/utils/route-index.d.ts +0 -41
- package/dist/utils/route-index.d.ts.map +0 -1
- package/dist/utils/route-index.js +0 -12
- package/dist/utils/route-route.d.ts +0 -62
- package/dist/utils/route-route.d.ts.map +0 -1
- package/dist/utils/route-route.js +0 -25
- package/dist/utils/set-action-id.d.ts +0 -9
- package/dist/utils/set-action-id.d.ts.map +0 -1
- package/dist/utils/set-action-id.js +0 -12
- package/src/components/action-id.tsx +0 -35
- package/src/components/hidden-input.tsx +0 -39
- package/src/core/_action-id-registry.ts +0 -11
- package/src/core/_capture-stack-trace.ts +0 -12
- package/src/core/_create-html-form-element-form-form-data.ts +0 -32
- package/src/core/_encode-pathname.ts +0 -17
- package/src/core/_is-error.ts +0 -16
- package/src/core/_is-promise-like.ts +0 -14
- package/src/core/_use-singleton.ts +0 -24
- package/src/core/_weak-id-registry.ts +0 -125
- package/src/core/constants.ts +0 -4
- package/src/core/data-map.types.ts +0 -28
- package/src/core/data-store.types.ts +0 -25
- package/src/core/deferred-promise.ts +0 -408
- package/src/core/start-actions.ts +0 -274
- package/src/hooks/_use-route-context.ts +0 -19
- package/src/hooks/_use-router-context.ts +0 -25
- package/src/hooks/use-pathname.ts +0 -10
- package/src/utils/get-action-id.ts +0 -12
- package/src/utils/href.ts +0 -17
- package/src/utils/route-index.ts +0 -70
- package/src/utils/route-route.ts +0 -111
- package/src/utils/set-action-id.ts +0 -14
- /package/dist/{core → src/core}/readonly-form-data.types.js +0 -0
- /package/dist/{core → src/core}/readonly-url.types.js +0 -0
- /package/dist/{core → src/core}/route.types.js +0 -0
- /package/dist/{engines → src/engines}/engine.types.js +0 -0
|
@@ -1,216 +1,254 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NinjaPromise } from "ninja-promise";
|
|
2
|
+
|
|
2
3
|
import type { HistoryEntry } from "../core/expect-history-entry.js";
|
|
4
|
+
import type { HistoryEntryId } from "../core/history-entry-id-schema.js";
|
|
3
5
|
import type { MatchedRoute } from "../core/match-routes.js";
|
|
4
6
|
import type { ReadonlyFormData } from "../core/readonly-form-data.types.js";
|
|
5
7
|
import type { ReadonlyURLSearchParams } from "../core/readonly-url.types.js";
|
|
6
|
-
import type {
|
|
8
|
+
import type { Route, ActionFunction, LoaderFunction } from "../core/route.types.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export type InitEngineArgs = {
|
|
12
|
-
/**
|
|
13
|
-
* 前処理済みのルート定義の配列です。
|
|
14
|
-
*/
|
|
15
|
-
readonly routes: readonly Route[];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 現在の非同期処理を中断するためのシグナルを取得する関数です。
|
|
19
|
-
*/
|
|
20
|
-
readonly getSignal: () => AbortSignal;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* ロケーション ID ごとに管理されているローダーデータのマップです。
|
|
24
|
-
*/
|
|
25
|
-
readonly loaderDataStore: IDataStore<ILoader>;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* ルーターの現在の状態を表す型定義です。
|
|
11
|
+
* ルーターが管理する現在の画面の状態を表す型定義です。
|
|
30
12
|
*/
|
|
31
13
|
export type RouterState = {
|
|
32
14
|
/**
|
|
33
|
-
*
|
|
15
|
+
* 現在のアクティブな履歴エントリーです。
|
|
34
16
|
*/
|
|
35
|
-
|
|
17
|
+
entry: HistoryEntry;
|
|
36
18
|
|
|
37
19
|
/**
|
|
38
|
-
* 現在の URL
|
|
39
|
-
*
|
|
40
|
-
* 最低でも 1 つのマッチしたルートが含まれるタプル形式となります。
|
|
20
|
+
* 現在の URL にマッチしている子から親までの階層的なルートの配列です。
|
|
41
21
|
*/
|
|
42
|
-
|
|
22
|
+
routes: readonly [MatchedRoute, ...MatchedRoute[]];
|
|
43
23
|
};
|
|
44
24
|
|
|
45
25
|
/**
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
export interface IUpdateRouter {
|
|
49
|
-
/**
|
|
50
|
-
* システムの状態を更新します。
|
|
51
|
-
*/
|
|
52
|
-
(): void;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 新しいルーターの状態を受け取り、システムの状態を更新します。
|
|
56
|
-
*
|
|
57
|
-
* @param state 新しいルーターの状態オブジェクトです。
|
|
58
|
-
*/
|
|
59
|
-
(state: RouterState | null): void;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* ルーターエンジンを開始する際に必要な引数の型定義です。
|
|
64
|
-
*/
|
|
65
|
-
export type StartEngineArgs = {
|
|
66
|
-
/**
|
|
67
|
-
* 前処理済みのルート定義の配列です。
|
|
68
|
-
*/
|
|
69
|
-
readonly routes: readonly Route[];
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 状態を更新するためのセッター関数です。
|
|
73
|
-
*/
|
|
74
|
-
readonly update: IUpdateRouter;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 現在の非同期処理を中断するためのシグナルを取得する関数です。
|
|
78
|
-
*/
|
|
79
|
-
readonly getSignal: () => AbortSignal;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* ロケーション ID ごとに管理されているアクションデータのマップです。
|
|
83
|
-
*/
|
|
84
|
-
readonly actionDataStore: IDataStore<IAction>;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* ロケーション ID ごとに管理されているローダーデータのマップです。
|
|
88
|
-
*/
|
|
89
|
-
readonly loaderDataStore: IDataStore<ILoader>;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* エンジンの動作を停止するための関数インターフェースです。
|
|
26
|
+
* 実行中のルーティングエンジンを安全に停止させ、各種イベントリスナーや非同期処理をクリーンアップするための関数インターフェースです。
|
|
94
27
|
*/
|
|
95
28
|
export interface IStopEngine {
|
|
96
|
-
/**
|
|
97
|
-
* 実行中のエンジンを停止し、イベントリスナーの解除などのクリーンアップを行います。
|
|
98
|
-
*/
|
|
99
29
|
(): void;
|
|
100
30
|
}
|
|
101
31
|
|
|
102
32
|
/**
|
|
103
|
-
*
|
|
33
|
+
* ルーティングエンジンに関わる各種引数や戻り値の型をまとめた名前空間です。
|
|
104
34
|
*/
|
|
105
|
-
export
|
|
35
|
+
export namespace IEngine {
|
|
106
36
|
/**
|
|
107
|
-
*
|
|
37
|
+
* ルーター初期化メソッド `init` に渡される引数の型定義です。
|
|
108
38
|
*/
|
|
109
|
-
|
|
39
|
+
export type InitArgs = {
|
|
40
|
+
/**
|
|
41
|
+
* アプリケーションに登録されているすべての正規化済みルートの定義配列です。
|
|
42
|
+
*/
|
|
43
|
+
routes: readonly Route[];
|
|
110
44
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
45
|
+
/**
|
|
46
|
+
* 各履歴エントリーに紐づくローダーの非同期状態を多重管理する、共有データストアへの参照です。
|
|
47
|
+
*/
|
|
48
|
+
loaderDataStore: Map<HistoryEntryId, Map<LoaderFunction, NinjaPromise<unknown>>>;
|
|
115
49
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* 送信対象となる URL クエリーパラメーターです。
|
|
123
|
-
*/
|
|
124
|
-
readonly target: ReadonlyURLSearchParams;
|
|
50
|
+
/**
|
|
51
|
+
* 中断シグナルを取得します。
|
|
52
|
+
*/
|
|
53
|
+
getSignal: () => AbortSignal;
|
|
54
|
+
};
|
|
125
55
|
|
|
126
56
|
/**
|
|
127
|
-
*
|
|
128
|
-
*/
|
|
129
|
-
readonly action: string;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 履歴の追加方法を指定します。
|
|
57
|
+
* ルーター初期化メソッド `init` が返す初期状態の型定義です。
|
|
133
58
|
*
|
|
134
|
-
*
|
|
135
|
-
*/
|
|
136
|
-
readonly history: "replace" | "push";
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* ナビゲーションの移動先を示す型定義です。
|
|
141
|
-
*
|
|
142
|
-
* パス文字列または詳細なパス情報のオブジェクトを受け取ります。
|
|
143
|
-
*/
|
|
144
|
-
export type NavigateTo = string | {
|
|
145
|
-
/**
|
|
146
|
-
* URL のパス名を表します。
|
|
147
|
-
*/
|
|
148
|
-
readonly pathname?: string | undefined;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* URL のクエリーパラメーターを表します。
|
|
59
|
+
* マッチするルートがあればその状態を返し、なければ `null` となります。
|
|
152
60
|
*/
|
|
153
|
-
|
|
61
|
+
export type InitReturn = RouterState | null;
|
|
154
62
|
|
|
155
63
|
/**
|
|
156
|
-
*
|
|
157
|
-
*/
|
|
158
|
-
readonly hash?: string | undefined;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* エンジンの遷移関数に渡される引数の型定義です。
|
|
163
|
-
*/
|
|
164
|
-
export type NavigateArgs = {
|
|
165
|
-
/**
|
|
166
|
-
* 遷移先です。
|
|
167
|
-
*/
|
|
168
|
-
readonly to: NavigateTo;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* 履歴の追加方法を指定します。
|
|
64
|
+
* エンジンの稼働開始メソッド `start` に渡される引数の型定義です。
|
|
172
65
|
*
|
|
173
|
-
*
|
|
174
|
-
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
66
|
+
* ナビゲーションイベントの監視や状態同期に必要な依存関係を集約します。
|
|
67
|
+
*/
|
|
68
|
+
export type StartArgs = {
|
|
69
|
+
/**
|
|
70
|
+
* アプリケーションに登録されているすべての正規化済みルートの定義配列です。
|
|
71
|
+
*/
|
|
72
|
+
routes: readonly Route[];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 各履歴エントリーに紐づくアクションの非同期状態を保持する共有データストアです。
|
|
76
|
+
*/
|
|
77
|
+
actionDataStore: Map<HistoryEntryId, Map<ActionFunction, NinjaPromise<unknown>>>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 各履歴エントリーに紐づくローダーの非同期状態を保持する共有データストアです。
|
|
81
|
+
*/
|
|
82
|
+
loaderDataStore: Map<HistoryEntryId, Map<LoaderFunction, NinjaPromise<unknown>>>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* エンジン内部で遷移が確定した際、新しい状態を Reactに通知して画面の再描画を要求するための更新関数です。
|
|
86
|
+
*
|
|
87
|
+
* 引数なしの呼び出しは、現在の状態を維持したままの強制再レンダリングを意味します。
|
|
88
|
+
*/
|
|
89
|
+
update: {
|
|
90
|
+
/**
|
|
91
|
+
* 現在の状態を維持したまま強制的に再レンダリングします。
|
|
92
|
+
*/
|
|
93
|
+
(): void;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* ルーターの状態を更新します。
|
|
97
|
+
*
|
|
98
|
+
* @param newRouterState 新しいルーターの状態です。
|
|
99
|
+
*/
|
|
100
|
+
(newRouterState: RouterState | null): void;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 中断シグナルを取得します。
|
|
105
|
+
*/
|
|
106
|
+
getSignal: () => AbortSignal;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* エンジンの稼働開始メソッド `start` の戻り値です。
|
|
111
|
+
*
|
|
112
|
+
* 監視イベントのリスナーを解除するためのクリーンアップ関数を返すか、環境によって何も返さない場合があります。
|
|
113
|
+
*/
|
|
114
|
+
export type StartReturn = IStopEngine | void;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* プログラムからのフォーム送信やクエリー更新を行う `submit` メソッドの引数の型定義です。
|
|
118
|
+
*/
|
|
119
|
+
export type SubmitArgs =
|
|
120
|
+
| {
|
|
121
|
+
/**
|
|
122
|
+
* HTTP POST メソッドに相当する、マルチパートまたは URL エンコードされたフォームデータの送信です。
|
|
123
|
+
*/
|
|
124
|
+
type: "FORM_DATA";
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 送信する不変のフォームデータ本体です。
|
|
128
|
+
*/
|
|
129
|
+
target: ReadonlyFormData;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* アクションの送信先となる対象の URL パス文字列です。
|
|
133
|
+
*/
|
|
134
|
+
action: string;
|
|
135
|
+
}
|
|
136
|
+
| {
|
|
137
|
+
/**
|
|
138
|
+
* HTTP GET メソッドに相当する、URL の検索クエリーの更新送信です。
|
|
139
|
+
*/
|
|
140
|
+
type: "URL_SEARCH_PARAMS";
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 更新対象となる検索クエリーパラメータです。
|
|
144
|
+
*/
|
|
145
|
+
target: ReadonlyURLSearchParams;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* クエリーの付与先となる対象の URL パス文字列です。
|
|
149
|
+
*/
|
|
150
|
+
action: string;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 履歴スタックへの追加方法を指定します。
|
|
154
|
+
*
|
|
155
|
+
* - `"push"`: 履歴エントリーの新規追加
|
|
156
|
+
* - `"replace"`: 履歴エントリーの上書き
|
|
157
|
+
*/
|
|
158
|
+
history: "replace" | "push";
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 命令的な画面遷移を行う `navigate` メソッドの引数の型定義です。
|
|
163
|
+
*
|
|
164
|
+
* リンクをクリックした際のアドレス遷移か、ブラウザーの「戻る・進む」に相当する相対移動かで分岐します。
|
|
165
|
+
*/
|
|
166
|
+
export type NavigateArgs =
|
|
167
|
+
| {
|
|
168
|
+
/**
|
|
169
|
+
* 明示的なアドレス指定による前方移動です。
|
|
170
|
+
*/
|
|
171
|
+
type: "LINK";
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 遷移先のアドレス表現の指定です。完全なパス文字列か、部分的なパーツの組み合わせかを選択します。
|
|
175
|
+
*/
|
|
176
|
+
to:
|
|
177
|
+
| {
|
|
178
|
+
/**
|
|
179
|
+
* URL パスで前方移動する形式です。
|
|
180
|
+
*/
|
|
181
|
+
type: "PATH";
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* URL パスです。
|
|
185
|
+
*/
|
|
186
|
+
path: string;
|
|
187
|
+
}
|
|
188
|
+
| {
|
|
189
|
+
/**
|
|
190
|
+
* URL の各コンポーネントを個別に指定する形式です。
|
|
191
|
+
*/
|
|
192
|
+
type: "PARTIAL";
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 最初のスラッシュ `/` から始まる URL のパス部分です。
|
|
196
|
+
*/
|
|
197
|
+
pathname?: string | undefined;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 先頭のクエスチョンマーク `?` を含む URL のクエリー文字列です。
|
|
201
|
+
*/
|
|
202
|
+
search?: string | undefined;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* URL のハッシュ(シャープ記号 `#` を含むフラグメント識別子)です。
|
|
206
|
+
*/
|
|
207
|
+
hash?: string | undefined;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 履歴スタックへの追加方法を指定します。
|
|
212
|
+
*
|
|
213
|
+
* - `"push"`: 履歴エントリーの新規追加
|
|
214
|
+
* - `"replace"`: 履歴エントリーの上書き
|
|
215
|
+
*/
|
|
216
|
+
history: "replace" | "push";
|
|
217
|
+
}
|
|
218
|
+
| {
|
|
219
|
+
/**
|
|
220
|
+
* 履歴スタック内の相対的な位置移動(例: `-1` で1つ戻る、`2` で2つ進む)です。
|
|
221
|
+
*/
|
|
222
|
+
type: "MOVE";
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 履歴を移動させる差分ステップ数です。
|
|
226
|
+
*/
|
|
227
|
+
delta: number;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
182
230
|
|
|
183
231
|
/**
|
|
184
|
-
*
|
|
232
|
+
* ルーティングエンジンのインターフェース定義です。
|
|
185
233
|
*/
|
|
186
234
|
export interface IEngine {
|
|
187
235
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* @param args 状態生成に必要なルート情報やデータマップです。
|
|
191
|
-
* @returns 生成されたルーター状態、またはマッチしなかった場合は `null` を返します。
|
|
236
|
+
* 現在の URL を基にルーターの初期状態を計算し、同期的に取得します。
|
|
192
237
|
*/
|
|
193
|
-
init(args:
|
|
238
|
+
init(args: IEngine.InitArgs): IEngine.InitReturn;
|
|
194
239
|
|
|
195
240
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* @param args エンジンの開始に必要な設定とコールバック関数です。
|
|
199
|
-
* @returns エンジンを停止するための関数を返します。停止処理が不要な場合は何も返しません。
|
|
241
|
+
* エンジンを稼働させ、ブラウザーの履歴変更やナビゲーションイベントの継続的な監視を開始します。
|
|
200
242
|
*/
|
|
201
|
-
start(args:
|
|
243
|
+
start(args: IEngine.StartArgs): IEngine.StartReturn;
|
|
202
244
|
|
|
203
245
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @param args 送信内容と送信先を含む引数です。
|
|
246
|
+
* ユーザーからの意図的なフォームデータまたはクエリーパラメータの送信を検知し、対応するルートのアクションやローダーを起動します。
|
|
207
247
|
*/
|
|
208
|
-
submit(args: SubmitArgs): void;
|
|
248
|
+
submit(args: IEngine.SubmitArgs): void;
|
|
209
249
|
|
|
210
250
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* @param args 遷移先と遷移オプションを含む引数です。
|
|
251
|
+
* プログラムからの命令的なページ遷移を処理します。
|
|
214
252
|
*/
|
|
215
|
-
navigate(args: NavigateArgs): void;
|
|
253
|
+
navigate(args: IEngine.NavigateArgs): void;
|
|
216
254
|
}
|