soseki 0.0.5 → 0.0.7
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 +47 -40
- 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
package/src/engines.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 初期化前(未初期化状態)であることを安全に判定するための、値が空の内部専用ユニークオブジェクトです。
|
|
5
|
+
*/
|
|
6
|
+
const nil = {};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* コンポーネントのライフサイクルにおいて、渡されたファクトリー関数を最初のレンダリング時に一度だけ実行し、その結果を以降の再レンダリング間で永続的に共有・保持するためのカスタムフックです。
|
|
10
|
+
*
|
|
11
|
+
* `React.useMemo` と異なり、React の内部都合によるキャッシュの不意な破棄・再計算が発生しないことが保証されます。
|
|
12
|
+
*
|
|
13
|
+
* @template T ファクトリー関数が生成するオブジェクトの型定義です。
|
|
14
|
+
* @param fn 初回レンダリング時にのみ呼び出される、オブジェクト生成用の初期化関数です。
|
|
15
|
+
* @returns 初回実行時に生成され、保持され続けている型 `T` のシングルトンインスタンスを返します。
|
|
16
|
+
*/
|
|
17
|
+
export default function useSingleton<T>(fn: () => T): T {
|
|
18
|
+
// 生成されたオブジェクトをコンポーネントの生存期間中保持するために useRef を使用します。
|
|
19
|
+
// 初期値として、未初期化の目印である nil オブジェクトを型アサーションして流し込みます。
|
|
20
|
+
const ref = React.useRef<T>(nil as T);
|
|
21
|
+
|
|
22
|
+
// 参照している中身がマッピングされたオブジェクト(nil)のままであれば、まだ一度も初期化されていないと判定します。
|
|
23
|
+
if (ref.current === nil) {
|
|
24
|
+
// 初期化関数を実行し、生成された実体を現在の参照へと上書きします。
|
|
25
|
+
// この処理は初回のレンダリングパスの中で完全に同期的に実行されます。
|
|
26
|
+
ref.current = fn();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return ref.current;
|
|
30
|
+
}
|
|
@@ -1,37 +1,32 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { NinjaPromise } from "ninja-promise";
|
|
2
|
+
|
|
2
3
|
import type RedirectResponse from "../core/redirect-response.js";
|
|
3
|
-
import
|
|
4
|
-
import useRouterContext from "./
|
|
4
|
+
import useRouteContext from "./use-route-context.js";
|
|
5
|
+
import useRouterContext from "./use-router-context.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 結果が `RedirectResponse` の場合は `undefined` を返し、それ以外の場合はそのままの型を返します。
|
|
8
|
+
* アクション関数の戻り値の型から、リダイレクト応答を除外して正規化するユーティリティー型です。
|
|
10
9
|
*
|
|
11
|
-
*
|
|
10
|
+
* アクションがリダイレクトを返した場合、フレームワークの内部仕様によって実際の値は `undefined` に置換されるため、型定義においてもその挙動を忠実に表現します。
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
type $InferResult<TResult> = TResult extends RedirectResponse
|
|
15
|
-
? undefined
|
|
16
|
-
: TResult;
|
|
12
|
+
type ActionResult<TResult> = TResult extends RedirectResponse ? undefined : TResult;
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
15
|
+
* 現在の階層のルートに紐づくアクション関数の最新の実行結果を購読・取得するためのカスタムフックです。
|
|
20
16
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @template TAction 対象となるアクションの型です。
|
|
24
|
-
* @param action データを取得したいアクションの定義です。
|
|
25
|
-
* @returns アクションの実行結果を含む `DeferredPromise` を返します。データが存在しない場合は `undefined` を返します。
|
|
17
|
+
* @template TData アクション関数そのものの型、またはアクションが返すことが期待されるデータ構造の型定義です。関数型が渡された場合は、自動的にその戻り値の型(推論結果)が解凍されます。
|
|
18
|
+
* @returns アクションが実行済み、または実行中であれば結果を内包した `NinjaPromise` を返し、一度も実行されていないか対象のアクションが存在しない場合は `undefined` を返します。
|
|
26
19
|
*/
|
|
27
|
-
export default function useActionData<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} = router;
|
|
35
|
-
return actionDataStore.get(currentEntry.id)?.get(action);
|
|
20
|
+
export default function useActionData<TData = unknown>():
|
|
21
|
+
| NinjaPromise<
|
|
22
|
+
ActionResult<Awaited<TData extends (...args: any) => infer TReturn ? TReturn : TData>>
|
|
23
|
+
>
|
|
24
|
+
| undefined {
|
|
25
|
+
const { action } = useRouteContext();
|
|
26
|
+
const actionData = useRouterContext((router) => {
|
|
27
|
+
const { currentEntry, actionDataStore } = router;
|
|
28
|
+
return actionDataStore.get(currentEntry.id)?.get(action!);
|
|
36
29
|
});
|
|
30
|
+
|
|
31
|
+
return actionData satisfies NinjaPromise<unknown> | undefined as NinjaPromise<any> | undefined;
|
|
37
32
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import useRouteContext from "./
|
|
1
|
+
import useRouteContext from "./use-route-context.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 現在の階層のルートに紐づく、動的パラメーターが具現化された実際の URL パス文字列を取得するカスタムフックです。
|
|
5
5
|
*
|
|
6
|
-
* @returns
|
|
6
|
+
* @returns 現在のルートに対応する具現化済みの URL パス文字列(例: `"/items/123"`)を返します。
|
|
7
7
|
*/
|
|
8
8
|
export default function useFormAction(): string {
|
|
9
|
-
|
|
10
|
-
return urlPath;
|
|
9
|
+
return useRouteContext().urlPath;
|
|
11
10
|
}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { NinjaPromise } from "ninja-promise";
|
|
2
|
+
|
|
2
3
|
import { LoaderDataNotFoundError } from "../core/errors.js";
|
|
3
|
-
import
|
|
4
|
-
import useRouterContext from "./
|
|
4
|
+
import useRouteContext from "./use-route-context.js";
|
|
5
|
+
import useRouterContext from "./use-router-context.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* 現在の階層のルートに紐づくローダー関数の実行結果を購読・取得するためのカスタムフックです。
|
|
8
9
|
*
|
|
9
|
-
* @template
|
|
10
|
-
* @
|
|
11
|
-
* @returns ローダーの実行結果を含む `DeferredPromise` を返します。
|
|
10
|
+
* @template TData ローダー関数そのものの型、またはローダーが返すことが期待されるデータ構造の型定義です。関数型が渡された場合は、自動的にその非同期戻り値の型(非同期の解凍結果)が推論されます。
|
|
11
|
+
* @returns ローダーの実行状態を管理している `NinjaPromise` を返します。
|
|
12
12
|
*/
|
|
13
|
-
export default function useLoaderData<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = router;
|
|
21
|
-
return loaderDataStore.get(currentEntry.id)?.get(loader);
|
|
13
|
+
export default function useLoaderData<TData = unknown>(): NinjaPromise<
|
|
14
|
+
Awaited<TData extends (...args: any) => infer TReturn ? TReturn : TData>
|
|
15
|
+
> {
|
|
16
|
+
const { loader } = useRouteContext();
|
|
17
|
+
const loaderData = useRouterContext((router) => {
|
|
18
|
+
const { currentEntry, loaderDataStore } = router;
|
|
19
|
+
return loaderDataStore.get(currentEntry.id)?.get(loader!);
|
|
22
20
|
});
|
|
23
21
|
if (!loaderData) {
|
|
24
|
-
throw new LoaderDataNotFoundError(loader);
|
|
22
|
+
throw new LoaderDataNotFoundError({ loader });
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
return loaderData
|
|
25
|
+
return loaderData satisfies NinjaPromise<unknown> as NinjaPromise<any>;
|
|
28
26
|
}
|
|
@@ -1,64 +1,105 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import type {} from "../engines/engine.types.js";
|
|
4
|
+
import useRouterContext from "./use-router-context.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 遷移先のアドレスを指定するための表現型です。
|
|
8
|
+
*
|
|
9
|
+
* 完全な URL パス文字列か、またはパスの各コンポーネントを部分的にパッチするためのオブジェクトのいずれかを受け入れます。
|
|
10
|
+
*/
|
|
11
|
+
export type NavigateTo =
|
|
12
|
+
| string
|
|
13
|
+
| {
|
|
14
|
+
/**
|
|
15
|
+
* 遷移先のドメイン以下のリクエストパス(例: `"/dashboard"`)です。
|
|
16
|
+
*/
|
|
17
|
+
readonly pathname?: string | undefined;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 遷移先に付与する検索クエリー文字列(例: `"?id=foo"`)です。
|
|
21
|
+
*/
|
|
22
|
+
readonly search?: string | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 遷移先に付与するハッシュフラグメント(例: `"#profile"`)です。
|
|
26
|
+
*/
|
|
27
|
+
readonly hash?: string | undefined;
|
|
28
|
+
};
|
|
4
29
|
|
|
5
30
|
/**
|
|
6
|
-
*
|
|
31
|
+
* 画面遷移の挙動をカスタマイズするためのオプション型です。
|
|
7
32
|
*/
|
|
8
33
|
export type NavigateOptions = {
|
|
9
34
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `true` の場合は現在のエントリーを置換し、`false` または未定義の場合は新しいエントリーを追加します。
|
|
35
|
+
* 履歴スタックへの追加方法を制御します。`true` の場合は現在の履歴を上書きし、`false` または省略時は新規追加します。
|
|
13
36
|
*/
|
|
14
37
|
readonly replace?: boolean | undefined;
|
|
15
38
|
};
|
|
16
39
|
|
|
17
40
|
/**
|
|
18
|
-
*
|
|
41
|
+
* プログラムから命令的に画面遷移を実行する、`NavigateFunction` 関数のオーバーロードインターフェース定義です。
|
|
19
42
|
*/
|
|
20
|
-
export interface
|
|
43
|
+
export interface NavigateFunction {
|
|
21
44
|
/**
|
|
22
|
-
*
|
|
45
|
+
* 指定されたアドレスへ画面を遷移させます。
|
|
23
46
|
*
|
|
24
|
-
* @param to
|
|
25
|
-
* @param options
|
|
47
|
+
* @param to 遷移先の対象となるデータ表現です。
|
|
48
|
+
* @param options 履歴のスタック方法などを制御するオプションです。
|
|
26
49
|
*/
|
|
27
|
-
(to: NavigateTo, options?: NavigateOptions
|
|
50
|
+
(to: NavigateTo, options?: NavigateOptions): void;
|
|
28
51
|
|
|
29
52
|
/**
|
|
30
|
-
*
|
|
53
|
+
* ブラウザーのセッション履歴スタック内を、現在地を基準に相対移動させます。
|
|
31
54
|
*
|
|
32
|
-
* @param delta
|
|
55
|
+
* @param delta 移動する履歴のステップ数(例: `-1` で1つ戻る、`1` で1つ進む)です。
|
|
33
56
|
*/
|
|
34
57
|
(delta: number): void;
|
|
35
58
|
}
|
|
36
59
|
|
|
37
60
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* コンポーネント内でこのフックを使用することで、ボタンのクリックイベントなどで任意のパスへ移動できるようになります。
|
|
61
|
+
* リンクなどを介さない、ボタンのクリックハンドラーや非同期処理の完了時などから、プログラムによって命令的に画面遷移や履歴移動をトリガーするための関数を取得するカスタムフックです。
|
|
41
62
|
*
|
|
42
|
-
* @returns
|
|
63
|
+
* @returns `NavigateFunction` 関数です。
|
|
43
64
|
*/
|
|
44
|
-
export default function useNavigate():
|
|
45
|
-
const
|
|
65
|
+
export default function useNavigate(): NavigateFunction {
|
|
66
|
+
const routerNavigate = useRouterContext((router) => router.navigate);
|
|
67
|
+
|
|
68
|
+
// レンダリング毎に関数の参照が変わって子コンポーネントが不要に再描画されるのを防ぐため、useCallback でラップします。
|
|
46
69
|
return React.useCallback(
|
|
47
70
|
function navigate(...args: [NavigateTo, options?: NavigateOptions | undefined] | [number]) {
|
|
48
71
|
if (typeof args[0] === "number") {
|
|
49
72
|
const [delta] = args;
|
|
50
|
-
|
|
73
|
+
|
|
74
|
+
return routerNavigate({
|
|
75
|
+
type: "MOVE",
|
|
76
|
+
delta,
|
|
77
|
+
});
|
|
51
78
|
}
|
|
52
79
|
|
|
53
80
|
const [to, options = {}] = args;
|
|
54
81
|
const { replace = false } = options;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
82
|
+
const history = replace ? "replace" : "push";
|
|
83
|
+
if (typeof to === "string") {
|
|
84
|
+
return routerNavigate({
|
|
85
|
+
to: {
|
|
86
|
+
path: to,
|
|
87
|
+
type: "PATH",
|
|
88
|
+
},
|
|
89
|
+
type: "LINK",
|
|
90
|
+
history,
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
return routerNavigate({
|
|
94
|
+
to: {
|
|
95
|
+
...to,
|
|
96
|
+
type: "PARTIAL",
|
|
97
|
+
},
|
|
98
|
+
type: "LINK",
|
|
99
|
+
history,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
61
102
|
},
|
|
62
|
-
[
|
|
103
|
+
[routerNavigate],
|
|
63
104
|
);
|
|
64
105
|
}
|
package/src/hooks/use-params.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import useRouteContext from "./
|
|
1
|
+
import type { RoutePathParams } from "../core/route.types.js";
|
|
2
|
+
import useRouteContext from "./use-route-context.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 現在のルートにマッチしたパスパラメーターを取得するためのカスタムフックです。
|
|
6
6
|
*
|
|
7
7
|
* @returns 現在のパスパラメーターを含むオブジェクトを返します。
|
|
8
8
|
*/
|
|
9
|
-
export default function useParams<TPath extends string = string>():
|
|
10
|
-
return useRouteContext().params as
|
|
9
|
+
export default function useParams<TPath extends string = string>(): RoutePathParams<TPath> {
|
|
10
|
+
return useRouteContext().params as RoutePathParams<TPath>;
|
|
11
11
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import RouteContext, { type RouteContextValue } from "../contexts/route-context.js";
|
|
4
|
+
import { RouteContextMissingError } from "../core/errors.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* React のコンポーネントツリーから、現在の階層に紐づいているルートの文脈情報を安全に取得するためのカスタムフックです。
|
|
8
|
+
*
|
|
9
|
+
* コンテキストが供給されていない状況を検知した場合はエラーを投げます。
|
|
10
|
+
*
|
|
11
|
+
* @returns 現在の階層で確定している型 `RouteContextValue` のルートコンテキストデータを返します。
|
|
12
|
+
*/
|
|
13
|
+
export default function useRouteContext(): RouteContextValue {
|
|
14
|
+
const routeContext = React.use(RouteContext);
|
|
15
|
+
if (!routeContext) {
|
|
16
|
+
throw new RouteContextMissingError();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return routeContext;
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import RouterContext, { type RouterRef } from "../contexts/router-context.js";
|
|
4
|
+
import { RouterContextMissingError } from "../core/errors.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* グローバルなルーターの状態)ら、必要なデータの一部(スライス)をセレクター関数を介して選択的・効率的に購読するためのカスタムフックです。
|
|
8
|
+
*
|
|
9
|
+
* ルーターコンポーネントの配下で実行されていない場合はエラーを投げます。
|
|
10
|
+
*
|
|
11
|
+
* @template TSlice セレクター関数によって抽出される、コンポーネントが必要とする部分データの型定義です。
|
|
12
|
+
* @param selector ルーターの内部実体を受け取り、必要なプロパティーや状態を抽出して返す純粋関数です。
|
|
13
|
+
* @returns 選択され、外部ストアと同期された最新のスライスデータを返します。
|
|
14
|
+
*/
|
|
15
|
+
export default function useRouterContext<TSlice>(
|
|
16
|
+
selector: (router: RouterRef["current"]) => TSlice,
|
|
17
|
+
): TSlice {
|
|
18
|
+
const routerContext = React.use(RouterContext);
|
|
19
|
+
if (!routerContext) {
|
|
20
|
+
throw new RouterContextMissingError();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { routerRef, subscribe } = routerContext;
|
|
24
|
+
return React.useSyncExternalStore(subscribe, () => selector(routerRef.current));
|
|
25
|
+
}
|
package/src/hooks/use-submit.ts
CHANGED
|
@@ -1,111 +1,106 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
|
|
2
3
|
import type { ReadonlyFormData } from "../core/readonly-form-data.types.js";
|
|
3
4
|
import type { ReadonlyURLSearchParams } from "../core/readonly-url.types.js";
|
|
4
|
-
import type { IAction } from "../core/route.types.js";
|
|
5
|
-
import useRouterContext from "./_use-router-context.js";
|
|
6
5
|
import useFormAction from "./use-form-action.js";
|
|
6
|
+
import useRouterContext from "./use-router-context.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* GET
|
|
9
|
+
* クエリーパラメーター送信(HTTP GET 相当)のサブミット処理をカスタマイズするためのオプション型です。
|
|
10
10
|
*/
|
|
11
11
|
export type SubmitGetOptions = {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* 送信先(遷移先)のベースとなる URL パスを明示的に上書き指定します。省略時は現在のフォームアクションパスが使用されます。
|
|
14
14
|
*/
|
|
15
15
|
readonly action?: string | undefined;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* 履歴スタックへの追加方法を制御します。`true` の場合は現在の履歴を上書きし、`false` または省略時は新規追加します。
|
|
19
19
|
*/
|
|
20
20
|
readonly replace?: boolean | undefined;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* POST
|
|
24
|
+
* フォームデータ送信(HTTP POST 相当)のサブミット処理をカスタマイズするためのオプション型です。
|
|
25
25
|
*/
|
|
26
26
|
export type SubmitPostOptions = {
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 送信先(アクション実行先)の URL パスを明示的に上書き指定します。省略時は現在のフォームアクションパスが使用されます。
|
|
29
29
|
*/
|
|
30
30
|
readonly action?: string | undefined;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 実行するアクションの定義です。
|
|
34
|
-
*/
|
|
35
|
-
readonly actionId?: IAction | undefined;
|
|
36
31
|
};
|
|
37
32
|
|
|
38
33
|
/**
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
export type SubmitOptions = SubmitGetOptions | SubmitPostOptions;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* データを送信するための関数インターフェースです。
|
|
34
|
+
* プログラムから命令的にデータ送信および画面遷移を実行する、`submit` 関数のオーバーロードインターフェース定義です。
|
|
45
35
|
*/
|
|
46
|
-
export interface
|
|
36
|
+
export interface SubmitFunction {
|
|
47
37
|
/**
|
|
48
|
-
*
|
|
38
|
+
* 不変のフォームデータを引き渡して、HTTP POST 相当のアクション処理をトリガーします。
|
|
49
39
|
*
|
|
50
|
-
* @param target
|
|
51
|
-
* @param options
|
|
40
|
+
* @param target 送信するフォームデータです。
|
|
41
|
+
* @param options POST 送信用のオプションです。
|
|
52
42
|
*/
|
|
53
|
-
(target: ReadonlyFormData, options?: SubmitPostOptions
|
|
43
|
+
(target: ReadonlyFormData, options?: SubmitPostOptions): void;
|
|
54
44
|
|
|
55
45
|
/**
|
|
56
|
-
*
|
|
46
|
+
* 不変のクエリーパラメーターを引き渡して、HTTP GET 相当の検索条件の更新をトリガーします。
|
|
57
47
|
*
|
|
58
|
-
* @param target
|
|
59
|
-
* @param options
|
|
48
|
+
* @param target 送信する検索クエリーです。
|
|
49
|
+
* @param options GET 送信用のオプションです。
|
|
60
50
|
*/
|
|
61
|
-
(target: ReadonlyURLSearchParams, options?: SubmitGetOptions
|
|
51
|
+
(target: ReadonlyURLSearchParams, options?: SubmitGetOptions): void;
|
|
62
52
|
|
|
63
53
|
/**
|
|
64
|
-
*
|
|
54
|
+
* 内部実装および包括的なユースケースに対応する汎用シグニチャーです。
|
|
65
55
|
*
|
|
66
|
-
* @param target
|
|
67
|
-
* @param options
|
|
56
|
+
* @param target 送信愛用です。
|
|
57
|
+
* @param options オプションです。
|
|
68
58
|
*/
|
|
69
|
-
(
|
|
59
|
+
(
|
|
60
|
+
target: ReadonlyURLSearchParams | ReadonlyFormData,
|
|
61
|
+
options?: SubmitGetOptions | SubmitPostOptions,
|
|
62
|
+
): void;
|
|
70
63
|
}
|
|
71
64
|
|
|
72
65
|
/**
|
|
73
|
-
*
|
|
66
|
+
* ユーザーのクリックイベントや、特定のロジックに基づくタイミングで、プログラムから宣言的・命令的にサブミット処理(データ送信および遷移)を実行するための関数を取得するカスタムフックです。
|
|
74
67
|
*
|
|
75
|
-
*
|
|
68
|
+
* 渡されたペイロードが `FormData` であるか `URLSearchParams` であるかをランタイムで自動判定し、適切なルーティングエンジンメソッドへと送信されます。
|
|
69
|
+
*
|
|
70
|
+
* @returns 依存関係が最適化され、同一参照が保証された `submit` 関数を返します。
|
|
76
71
|
*/
|
|
77
|
-
export default function useSubmit():
|
|
72
|
+
export default function useSubmit(): SubmitFunction {
|
|
78
73
|
const formAction = useFormAction();
|
|
79
|
-
const
|
|
74
|
+
const routerSubmit = useRouterContext((router) => router.submit);
|
|
75
|
+
|
|
76
|
+
// レンダリング毎に関数の参照が変わって子コンポーネントが不要に再描画されるのを防ぐため、useCallback でラップします。
|
|
80
77
|
return React.useCallback(
|
|
81
78
|
function submit(target, options = {}) {
|
|
82
79
|
if (target instanceof FormData) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
// 分岐 1: データ実体がフォームデータである場合 = 副作用を伴うデータ変更処理(POST / Action 契機)
|
|
81
|
+
|
|
82
|
+
const { action = formAction } = options as SubmitPostOptions;
|
|
83
|
+
|
|
84
|
+
// エンジンに対して「FORM_DATA」タイプとしてのサブミットタスクを発行します。
|
|
85
|
+
return routerSubmit({
|
|
86
|
+
type: "FORM_DATA",
|
|
88
87
|
target,
|
|
89
88
|
action,
|
|
90
|
-
actionId,
|
|
91
89
|
});
|
|
92
90
|
} else {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return
|
|
91
|
+
// 分岐 2: データ実体がクエリーパラメーターである場合 = 読み取り専用の条件更新処理(GET / Loader 契機)
|
|
92
|
+
|
|
93
|
+
const { action = formAction, replace } = options as SubmitGetOptions;
|
|
94
|
+
|
|
95
|
+
return routerSubmit({
|
|
96
|
+
type: "URL_SEARCH_PARAMS",
|
|
98
97
|
target: target as URLSearchParams,
|
|
99
98
|
action,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
: "push",
|
|
99
|
+
// replace の真偽値に基づき、ブラウザー履歴の追加方法(push / replace)を明示的にマッピングします。
|
|
100
|
+
history: replace ? "replace" : "push",
|
|
103
101
|
});
|
|
104
102
|
}
|
|
105
103
|
},
|
|
106
|
-
[
|
|
107
|
-
call,
|
|
108
|
-
formAction,
|
|
109
|
-
],
|
|
104
|
+
[routerSubmit, formAction],
|
|
110
105
|
);
|
|
111
106
|
}
|
package/src/soseki.ts
CHANGED
|
@@ -1,46 +1,55 @@
|
|
|
1
|
-
export type * from "./components/action-id.jsx";
|
|
2
|
-
export { default as ActionId } from "./components/action-id.jsx";
|
|
3
|
-
|
|
4
1
|
export type * from "./components/browser-router.jsx";
|
|
5
2
|
export { default as BrowserRouter } from "./components/browser-router.jsx";
|
|
6
3
|
|
|
7
|
-
export type * from "./components/hidden-input.jsx";
|
|
8
|
-
export { default as HiddenInput } from "./components/hidden-input.jsx";
|
|
9
|
-
|
|
10
4
|
export type * from "./components/outlet.jsx";
|
|
11
5
|
export { default as Outlet } from "./components/outlet.jsx";
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
/**************************************************************************************************/
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
Issue,
|
|
11
|
+
UnreachableErrorArgs,
|
|
12
|
+
UnreachableErrorMeta,
|
|
13
|
+
LoaderConditionErrorArgs,
|
|
14
|
+
LoaderConditionErrorMeta,
|
|
15
|
+
LoaderDataNotFoundErrorArgs,
|
|
16
|
+
LoaderDataNotFoundErrorMeta,
|
|
17
|
+
UnexpectedValidationErrorArgs,
|
|
18
|
+
UnexpectedValidationErrorMeta,
|
|
19
|
+
} from "./core/errors.js";
|
|
17
20
|
export {
|
|
18
|
-
ActionConditionError,
|
|
19
|
-
ActionExecutionError,
|
|
20
21
|
ErrorBase,
|
|
22
|
+
setErrorMessage,
|
|
23
|
+
UnreachableError,
|
|
24
|
+
ValidationErrorBase,
|
|
21
25
|
LoaderConditionError,
|
|
22
|
-
|
|
23
|
-
NavigationApiNotSupportedError,
|
|
26
|
+
LoaderDataNotFoundError,
|
|
24
27
|
RouteContextMissingError,
|
|
25
28
|
RouterContextMissingError,
|
|
26
|
-
setErrorMessage,
|
|
27
29
|
UnexpectedValidationError,
|
|
28
|
-
|
|
29
|
-
ValidationErrorBase,
|
|
30
|
+
NavigationApiNotSupportedError,
|
|
30
31
|
} from "./core/errors.js";
|
|
31
32
|
|
|
32
33
|
export type * from "./core/readonly-form-data.types.js";
|
|
33
34
|
|
|
34
35
|
export type * from "./core/readonly-url.types.js";
|
|
35
36
|
|
|
37
|
+
export type * from "./core/redirect-response.js";
|
|
38
|
+
export { default as RedirectResponse } from "./core/redirect-response.js";
|
|
39
|
+
|
|
36
40
|
export type * from "./core/route-request.js";
|
|
37
41
|
export { default as RouteRequest } from "./core/route-request.js";
|
|
38
42
|
|
|
39
43
|
export type * from "./core/route.types.js";
|
|
40
44
|
|
|
45
|
+
/**************************************************************************************************/
|
|
46
|
+
|
|
41
47
|
export type * from "./hooks/use-action-data.js";
|
|
42
48
|
export { default as useActionData } from "./hooks/use-action-data.js";
|
|
43
49
|
|
|
50
|
+
export type * from "./hooks/use-form-action.js";
|
|
51
|
+
export { default as useFormAction } from "./hooks/use-form-action.js";
|
|
52
|
+
|
|
44
53
|
export type * from "./hooks/use-loader-data.js";
|
|
45
54
|
export { default as useLoaderData } from "./hooks/use-loader-data.js";
|
|
46
55
|
|
|
@@ -50,26 +59,10 @@ export { default as useNavigate } from "./hooks/use-navigate.js";
|
|
|
50
59
|
export type * from "./hooks/use-params.js";
|
|
51
60
|
export { default as useParams } from "./hooks/use-params.js";
|
|
52
61
|
|
|
53
|
-
export type * from "./hooks/use-pathname.js";
|
|
54
|
-
export { default as usePathname } from "./hooks/use-pathname.js";
|
|
55
|
-
|
|
56
62
|
export type * from "./hooks/use-submit.js";
|
|
57
63
|
export { default as useSubmit } from "./hooks/use-submit.js";
|
|
58
64
|
|
|
59
|
-
|
|
60
|
-
export { default as getActionId } from "./utils/get-action-id.js";
|
|
61
|
-
|
|
62
|
-
export type * from "./utils/href.js";
|
|
63
|
-
export { default as href } from "./utils/href.js";
|
|
65
|
+
/**************************************************************************************************/
|
|
64
66
|
|
|
65
67
|
export type * from "./utils/redirect.js";
|
|
66
68
|
export { default as redirect } from "./utils/redirect.js";
|
|
67
|
-
|
|
68
|
-
export type * from "./utils/route-index.js";
|
|
69
|
-
export { default as index } from "./utils/route-index.js";
|
|
70
|
-
|
|
71
|
-
export type * from "./utils/route-route.js";
|
|
72
|
-
export { default as route } from "./utils/route-route.js";
|
|
73
|
-
|
|
74
|
-
export type * from "./utils/set-action-id.js";
|
|
75
|
-
export { default as setActionId } from "./utils/set-action-id.js";
|
package/src/utils/redirect.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import RedirectResponse from "../core/redirect-response.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 指定された URL パスへのリダイレクトを表すレスポンスオブジェクトを作成します。
|
|
5
5
|
*
|
|
6
6
|
* アクションの中で、別のページへ遷移させるために使用されます。
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
8
|
+
* @param destination リダイレクト先の URL パスです。
|
|
9
|
+
* @returns 作成された `RedirectResponse` オブジェクトです。
|
|
10
10
|
*/
|
|
11
|
-
export default function redirect(
|
|
12
|
-
return new RedirectResponse(
|
|
11
|
+
export default function redirect(destination: string): RedirectResponse {
|
|
12
|
+
return new RedirectResponse(destination);
|
|
13
13
|
}
|