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/core/errors.ts
CHANGED
|
@@ -1,164 +1,60 @@
|
|
|
1
|
+
import { type ErrorMeta, type ErrorOptions, I18nErrorBase, setErrorMessage } from "i18n-error-base";
|
|
2
|
+
import { inspect } from "inspect-lite";
|
|
3
|
+
import { isThenable } from "maypromise";
|
|
1
4
|
import getTypeName from "type-name";
|
|
2
|
-
import {
|
|
3
|
-
import isPromiseLike from "./_is-promise-like.js";
|
|
4
|
-
import singleton from "./_singleton.js";
|
|
5
|
+
import type { BaseIssue } from "valibot";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* 型
|
|
9
|
-
*
|
|
10
|
-
**************************************************************************************************/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* エラーのオプションです。
|
|
14
|
-
*/
|
|
15
|
-
export type ErrorOptions = Readonly<{
|
|
16
|
-
/**
|
|
17
|
-
* エラーの原因です。
|
|
18
|
-
*/
|
|
19
|
-
cause?: unknown;
|
|
20
|
-
}>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* エラーに紐づくメタデータです。
|
|
24
|
-
*/
|
|
25
|
-
export type ErrorMeta = {
|
|
26
|
-
readonly [prop: string]: unknown;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* soseki におけるエラーのコンストラクターです。
|
|
31
|
-
*/
|
|
32
|
-
export interface ISosekiErrorConstructor {
|
|
33
|
-
new(...args: any): ErrorBase<ErrorMeta | undefined>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 検証エラーの問題点です。
|
|
38
|
-
*/
|
|
39
|
-
export type Issue = BaseIssue<unknown>;
|
|
40
|
-
|
|
41
|
-
/***************************************************************************************************
|
|
42
|
-
*
|
|
43
|
-
* ユーティリティー
|
|
44
|
-
*
|
|
45
|
-
**************************************************************************************************/
|
|
7
|
+
/**************************************************************************************************/
|
|
46
8
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
* @returns エラーコンストラクターと言語ごとのエラーメッセージ作成関数のマップです。
|
|
51
|
-
*/
|
|
52
|
-
function getMessage(): WeakMap<Function | object, Map<string, (error: any) => string>> {
|
|
53
|
-
return singleton("errors__message", () => new WeakMap());
|
|
54
|
-
}
|
|
9
|
+
export type { ErrorMeta, ErrorOptions };
|
|
10
|
+
export { setErrorMessage };
|
|
55
11
|
|
|
56
|
-
|
|
57
|
-
* エラーコンストラクター内でメッセージプロパティーを初期化します。
|
|
58
|
-
*
|
|
59
|
-
* @template TInstance エラーオブジェクトの型です。
|
|
60
|
-
* @param instance エラーオブジェクトです。
|
|
61
|
-
* @param message エラーメッセージです。
|
|
62
|
-
*/
|
|
63
|
-
function initMessage<TInstance extends Error>(
|
|
64
|
-
instance: TInstance,
|
|
65
|
-
message: (error: TInstance) => string,
|
|
66
|
-
): void {
|
|
67
|
-
const reference = instance.constructor;
|
|
68
|
-
const { lang = "en" } = getGlobalConfig();
|
|
69
|
-
const msg = getMessage();
|
|
70
|
-
const store = msg.get(reference);
|
|
71
|
-
const genMessage = store?.get(lang) ?? message;
|
|
72
|
-
instance.message = genMessage(instance);
|
|
73
|
-
}
|
|
12
|
+
/**************************************************************************************************/
|
|
74
13
|
|
|
75
14
|
/**
|
|
76
|
-
*
|
|
15
|
+
* データ検証の過程で検出された具体的な問題点を表す型定義です。
|
|
77
16
|
*
|
|
78
|
-
*
|
|
79
|
-
* @param reference soseki のエラーコンストラクターです。
|
|
80
|
-
* @param message エラーメッセージです。
|
|
81
|
-
* @param lang 言語です。
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* setErrorMessage(
|
|
85
|
-
* TypeError,
|
|
86
|
-
* ({ meta }) => `${meta.expected} を期待しましたが、${meta.actual} を得ました`,
|
|
87
|
-
* "ja",
|
|
88
|
-
* );
|
|
89
|
-
* ```
|
|
17
|
+
* 外部のスキーマ検証ライブラリーである `valibot` の `BaseIssue` を基盤としています。
|
|
90
18
|
*/
|
|
91
|
-
export
|
|
92
|
-
reference: TReference,
|
|
93
|
-
message: (error: InstanceType<TReference>) => string,
|
|
94
|
-
lang: string,
|
|
95
|
-
): void {
|
|
96
|
-
const msg = getMessage();
|
|
97
|
-
let store = msg.get(reference);
|
|
98
|
-
if (store === undefined) {
|
|
99
|
-
store = new Map();
|
|
100
|
-
msg.set(reference, store);
|
|
101
|
-
}
|
|
19
|
+
export type Issue = BaseIssue<unknown>;
|
|
102
20
|
|
|
103
|
-
|
|
104
|
-
}
|
|
21
|
+
/**************************************************************************************************/
|
|
105
22
|
|
|
106
23
|
/**
|
|
107
|
-
*
|
|
24
|
+
* soseki ルーティングライブラリーにおける、すべてのカスタムエラーの頂点に位置する基底クラスです。
|
|
108
25
|
*
|
|
109
|
-
* @
|
|
110
|
-
* @returns 文字列に整形された値です。
|
|
26
|
+
* @template TMeta エラーの発生コンテキストを保持するために紐付けるメタデータオブジェクトの型定義です。
|
|
111
27
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} catch {
|
|
116
|
-
return String(value);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
28
|
+
export class ErrorBase<
|
|
29
|
+
TMeta extends ErrorMeta | undefined = undefined,
|
|
30
|
+
> extends I18nErrorBase<TMeta> {}
|
|
119
31
|
|
|
120
|
-
|
|
121
|
-
*
|
|
122
|
-
* エラークラス
|
|
123
|
-
*
|
|
124
|
-
**************************************************************************************************/
|
|
32
|
+
/**************************************************************************************************/
|
|
125
33
|
|
|
126
34
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* @template TMeta エラーに紐づくメタデータです。
|
|
35
|
+
* プログラムの制御フローにおいて、理論上到達しないはずのコード領域へ侵入した際に付与されるメタデータの型定義です。
|
|
130
36
|
*/
|
|
131
|
-
export
|
|
37
|
+
export type UnreachableErrorMeta = {
|
|
132
38
|
/**
|
|
133
|
-
*
|
|
39
|
+
* 網羅性チェックをすり抜けて、実行時に入り込んできた予期せぬ不正な値です。
|
|
134
40
|
*/
|
|
135
|
-
|
|
41
|
+
readonly value?: unknown;
|
|
42
|
+
};
|
|
136
43
|
|
|
44
|
+
/**
|
|
45
|
+
* `UnreachableError` のインスタンスを初期化する際に渡される引数オブジェクトの型定義です。
|
|
46
|
+
*/
|
|
47
|
+
export type UnreachableErrorArgs = ErrorOptions & {
|
|
137
48
|
/**
|
|
138
|
-
*
|
|
49
|
+
* 網羅性検証において `never` 型となるべき変数を格納した、要素数 1 のタプルまたは空の配列です。
|
|
139
50
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (!("cause" in this) && options && "cause" in options) {
|
|
144
|
-
this.cause = options.cause;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
this.meta = meta;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**************************************************************************************************/
|
|
51
|
+
readonly actual: [never?];
|
|
52
|
+
};
|
|
152
53
|
|
|
153
54
|
/**
|
|
154
|
-
*
|
|
55
|
+
* 網羅性チェックにおいて、プログラムの制御フローが理論上決して到達しないはずの場所に達した場合に投げるエラーです。
|
|
155
56
|
*/
|
|
156
|
-
export class UnreachableError extends ErrorBase<{
|
|
157
|
-
/**
|
|
158
|
-
* 到達しないはずの値です。
|
|
159
|
-
*/
|
|
160
|
-
value?: unknown;
|
|
161
|
-
}> {
|
|
57
|
+
export class UnreachableError extends ErrorBase<UnreachableErrorMeta> {
|
|
162
58
|
static {
|
|
163
59
|
this.prototype.name = "SosekiUnreachableError";
|
|
164
60
|
}
|
|
@@ -166,337 +62,143 @@ export class UnreachableError extends ErrorBase<{
|
|
|
166
62
|
/**
|
|
167
63
|
* `UnreachableError` クラスの新しいインスタンスを初期化します。
|
|
168
64
|
*
|
|
169
|
-
* @param args
|
|
170
|
-
* @param options エラーのオプションです。
|
|
65
|
+
* @param args エラーオプションおよび実行時に混入した実際の値を含む引数オブジェクトです。
|
|
171
66
|
*/
|
|
172
|
-
public constructor(args:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
67
|
+
public constructor(args: UnreachableErrorArgs) {
|
|
68
|
+
const { actual, ...options } = args;
|
|
69
|
+
super(
|
|
70
|
+
actual.length > 0 ? { value: actual[0] } : {},
|
|
71
|
+
(meta) =>
|
|
72
|
+
"value" in meta
|
|
73
|
+
? "Encountered impossible value: " + inspect(meta.value)
|
|
74
|
+
: "Unreachable code reached",
|
|
75
|
+
options,
|
|
76
|
+
);
|
|
179
77
|
}
|
|
180
78
|
}
|
|
181
79
|
|
|
182
80
|
/*#__PURE__*/ setErrorMessage(
|
|
183
81
|
UnreachableError,
|
|
184
|
-
(
|
|
82
|
+
(meta) =>
|
|
185
83
|
"value" in meta
|
|
186
|
-
? "不可能な値に遭遇しました: " +
|
|
187
|
-
: "到達できないコードに到達しました"
|
|
188
|
-
),
|
|
84
|
+
? "不可能な値に遭遇しました: " + inspect(meta.value)
|
|
85
|
+
: "到達できないコードに到達しました",
|
|
189
86
|
"ja",
|
|
190
87
|
);
|
|
191
88
|
|
|
192
89
|
/**************************************************************************************************/
|
|
193
90
|
|
|
194
91
|
/**
|
|
195
|
-
*
|
|
92
|
+
* データ検証の失敗に関連するエラーを集約するための共通基底クラスです。
|
|
196
93
|
*
|
|
197
|
-
* @template TMeta
|
|
94
|
+
* @template TMeta エラーに紐づく、検証結果の問題点などのメタデータ型定義です。
|
|
198
95
|
*/
|
|
199
|
-
export class ValidationErrorBase<
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
*/
|
|
203
|
-
public constructor(options: ErrorOptions | undefined, meta: TMeta) {
|
|
204
|
-
super(options, meta);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**************************************************************************************************/
|
|
209
|
-
|
|
210
|
-
// /**
|
|
211
|
-
// * 入力値検証エラーの基底クラスです。
|
|
212
|
-
// *
|
|
213
|
-
// * @template TMeta エラーに紐づくメタデータです。
|
|
214
|
-
// */
|
|
215
|
-
// export class InvalidInputErrorBase<TMeta extends ErrorMeta> extends ValidationErrorBase<TMeta> {
|
|
216
|
-
// /**
|
|
217
|
-
// * @internal
|
|
218
|
-
// */
|
|
219
|
-
// public constructor(options: ErrorOptions | undefined, meta: TMeta) {
|
|
220
|
-
// super(options, meta);
|
|
221
|
-
// }
|
|
222
|
-
// }
|
|
223
|
-
|
|
224
|
-
/**************************************************************************************************/
|
|
225
|
-
|
|
226
|
-
// /**
|
|
227
|
-
// * 入力値の検証に失敗した場合に投げられるエラーです。
|
|
228
|
-
// */
|
|
229
|
-
// export class InvalidInputError extends InvalidInputErrorBase<{
|
|
230
|
-
// /**
|
|
231
|
-
// * 検証エラーの問題点です。
|
|
232
|
-
// */
|
|
233
|
-
// issues: [Issue, ...Issue[]];
|
|
234
|
-
|
|
235
|
-
// /**
|
|
236
|
-
// * 検証した入力値です。
|
|
237
|
-
// */
|
|
238
|
-
// input: unknown;
|
|
239
|
-
// }> {
|
|
240
|
-
// static {
|
|
241
|
-
// this.prototype.name = "SosekiInvalidInputError";
|
|
242
|
-
// }
|
|
243
|
-
|
|
244
|
-
// /**
|
|
245
|
-
// * `InvalidInputError` クラスの新しいインスタンスを初期化します。
|
|
246
|
-
// *
|
|
247
|
-
// * @param issues 検証エラーの問題点です。
|
|
248
|
-
// * @param input 検証した入力値です。
|
|
249
|
-
// * @param options エラーのオプションです。
|
|
250
|
-
// */
|
|
251
|
-
// public constructor(
|
|
252
|
-
// issues: [Issue, ...Issue[]],
|
|
253
|
-
// input: unknown,
|
|
254
|
-
// options?: ErrorOptions | undefined,
|
|
255
|
-
// ) {
|
|
256
|
-
// super(options, { issues, input });
|
|
257
|
-
// this.message = issues.map(issue => issue.message).join(": ");
|
|
258
|
-
// }
|
|
259
|
-
// }
|
|
96
|
+
export class ValidationErrorBase<
|
|
97
|
+
TMeta extends ErrorMeta | undefined = ErrorMeta | undefined,
|
|
98
|
+
> extends ErrorBase<TMeta> {}
|
|
260
99
|
|
|
261
100
|
/**************************************************************************************************/
|
|
262
101
|
|
|
263
102
|
/**
|
|
264
|
-
*
|
|
103
|
+
* 予期しないデータ構造や型に遭遇した際に付与される、検証エラー情報のメタデータ型定義です。
|
|
265
104
|
*/
|
|
266
|
-
export
|
|
105
|
+
export type UnexpectedValidationErrorMeta = {
|
|
267
106
|
/**
|
|
268
|
-
*
|
|
107
|
+
* スキーマ検証によって不適合と判定された問題点のリストです。最低 1 つ以上の要素を持つことが保証された読み取り専用の配列です。
|
|
269
108
|
*/
|
|
270
|
-
issues: [Issue, ...Issue[]];
|
|
109
|
+
readonly issues: readonly [Issue, ...Issue[]];
|
|
271
110
|
|
|
272
111
|
/**
|
|
273
|
-
*
|
|
112
|
+
* 検証の対象となった、予期しない生の入力値です。
|
|
274
113
|
*/
|
|
275
|
-
value: unknown;
|
|
276
|
-
}
|
|
277
|
-
static {
|
|
278
|
-
this.prototype.name = "SosekiUnexpectedValidationError";
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* `UnexpectedValidationError` クラスの新しいインスタンスを初期化します。
|
|
283
|
-
*
|
|
284
|
-
* @param issues 検証エラーの問題点です。
|
|
285
|
-
* @param value 予期しない値です。
|
|
286
|
-
* @param options エラーのオプションです。
|
|
287
|
-
*/
|
|
288
|
-
public constructor(
|
|
289
|
-
issues: [Issue, ...Issue[]],
|
|
290
|
-
value: unknown,
|
|
291
|
-
options?: ErrorOptions | undefined,
|
|
292
|
-
) {
|
|
293
|
-
super(options, { issues, value });
|
|
294
|
-
this.message = issues.map(issue => issue.message).join(": ");
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**************************************************************************************************/
|
|
114
|
+
readonly value: unknown;
|
|
115
|
+
};
|
|
299
116
|
|
|
300
117
|
/**
|
|
301
|
-
*
|
|
118
|
+
* `UnexpectedValidationError` のインスタンスを初期化する際に渡される引数オブジェクトの型定義です。
|
|
302
119
|
*/
|
|
303
|
-
export
|
|
304
|
-
/**
|
|
305
|
-
* ルートの URL です。
|
|
306
|
-
*/
|
|
307
|
-
url: string;
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* shouldAction 関数です。
|
|
311
|
-
*/
|
|
312
|
-
shouldAction: Function;
|
|
120
|
+
export type UnexpectedValidationErrorArgs = ErrorOptions & UnexpectedValidationErrorMeta;
|
|
313
121
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}> {
|
|
122
|
+
/**
|
|
123
|
+
* スキーマによるデータ構造の検証において、予期しない形式の値に遭遇した場合に投げるエラーです。
|
|
124
|
+
*/
|
|
125
|
+
export class UnexpectedValidationError extends ValidationErrorBase<UnexpectedValidationErrorMeta> {
|
|
319
126
|
static {
|
|
320
|
-
this.prototype.name = "
|
|
127
|
+
this.prototype.name = "SosekiUnexpectedValidationError";
|
|
321
128
|
}
|
|
322
129
|
|
|
323
130
|
/**
|
|
324
|
-
* `
|
|
131
|
+
* `UnexpectedValidationError` クラスの新しいインスタンスを初期化します。
|
|
325
132
|
*
|
|
326
|
-
* @param
|
|
327
|
-
* @param shouldAction shouldAction 関数です。
|
|
328
|
-
* @param returnValue shouldAction が返した値です。
|
|
329
|
-
* @param options エラーのオプションです。
|
|
133
|
+
* @param args エラーオプション、入力値、および検出された不適合箇所の一覧を含む引数オブジェクトです。
|
|
330
134
|
*/
|
|
331
|
-
public constructor(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
super(options, {
|
|
338
|
-
url,
|
|
339
|
-
returnValue,
|
|
340
|
-
shouldAction,
|
|
341
|
-
});
|
|
342
|
-
initMessage(
|
|
343
|
-
this,
|
|
344
|
-
({ meta }) =>
|
|
345
|
-
isPromiseLike(meta.returnValue)
|
|
346
|
-
? "shouldAction must return a boolean value synchronously"
|
|
347
|
-
: `Expected boolean, but got ${getTypeName(meta.returnValue) || "unknown"}`,
|
|
135
|
+
public constructor(args: UnexpectedValidationErrorArgs) {
|
|
136
|
+
const { value, issues, ...options } = args;
|
|
137
|
+
super(
|
|
138
|
+
{ value, issues },
|
|
139
|
+
({ issues }) => issues.map((issue) => issue.message).join(": "),
|
|
140
|
+
options,
|
|
348
141
|
);
|
|
349
142
|
}
|
|
350
143
|
}
|
|
351
144
|
|
|
352
|
-
/*#__PURE__*/ setErrorMessage(
|
|
353
|
-
ActionConditionError,
|
|
354
|
-
({ meta }) =>
|
|
355
|
-
isPromiseLike(meta.returnValue)
|
|
356
|
-
? "shouldAction は同期的に真偽値を返す必要があります"
|
|
357
|
-
: `真偽値を期待しましたが、${getTypeName(meta.returnValue) || "unknown"} を得ました`,
|
|
358
|
-
"ja",
|
|
359
|
-
);
|
|
360
|
-
|
|
361
145
|
/**************************************************************************************************/
|
|
362
146
|
|
|
363
147
|
/**
|
|
364
|
-
*
|
|
148
|
+
* ブラウザー標準の Navigation API が、現在の実行環境でサポートされていない場合に投げるエラーです。
|
|
365
149
|
*/
|
|
366
|
-
export class
|
|
367
|
-
/**
|
|
368
|
-
* ルートの URL です。
|
|
369
|
-
*/
|
|
370
|
-
url: string;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* エラーのリストです。
|
|
374
|
-
*/
|
|
375
|
-
errors: readonly {
|
|
376
|
-
/**
|
|
377
|
-
* action 関数です。
|
|
378
|
-
*/
|
|
379
|
-
readonly action: Function;
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* エラーの原因です。
|
|
383
|
-
*/
|
|
384
|
-
readonly reason: unknown;
|
|
385
|
-
}[];
|
|
386
|
-
}> {
|
|
150
|
+
export class NavigationApiNotSupportedError extends ErrorBase<undefined> {
|
|
387
151
|
static {
|
|
388
|
-
this.prototype.name = "
|
|
152
|
+
this.prototype.name = "SosekiNavigationApiNotSupportedError";
|
|
389
153
|
}
|
|
390
154
|
|
|
391
155
|
/**
|
|
392
|
-
* `
|
|
156
|
+
* `NavigationApiNotSupportedError` クラスの新しいインスタンスを初期化します。
|
|
393
157
|
*
|
|
394
|
-
* @param
|
|
395
|
-
* @param errors エラーのリストです。
|
|
396
|
-
* @param options エラーのオプションです。
|
|
158
|
+
* @param options エラーの共通オプションです。
|
|
397
159
|
*/
|
|
398
|
-
public constructor(
|
|
399
|
-
|
|
400
|
-
errors: readonly {
|
|
401
|
-
/**
|
|
402
|
-
* action 関数です。
|
|
403
|
-
*/
|
|
404
|
-
action: Function;
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* エラーの原因です。
|
|
408
|
-
*/
|
|
409
|
-
reason: unknown;
|
|
410
|
-
}[],
|
|
411
|
-
options?: ErrorOptions | undefined,
|
|
412
|
-
) {
|
|
413
|
-
super(options, {
|
|
414
|
-
url,
|
|
415
|
-
errors,
|
|
416
|
-
});
|
|
417
|
-
initMessage(
|
|
418
|
-
this,
|
|
419
|
-
({ meta }) => `Errors occurred in ${meta.errors.length} action(s)`,
|
|
420
|
-
);
|
|
160
|
+
public constructor(options?: ErrorOptions) {
|
|
161
|
+
super("The Navigation API is not supported in this environment", options);
|
|
421
162
|
}
|
|
422
163
|
}
|
|
423
164
|
|
|
424
165
|
/*#__PURE__*/ setErrorMessage(
|
|
425
|
-
|
|
426
|
-
|
|
166
|
+
NavigationApiNotSupportedError,
|
|
167
|
+
"現在の環境では Navigation API がサポートされていません",
|
|
427
168
|
"ja",
|
|
428
169
|
);
|
|
429
170
|
|
|
430
171
|
/**************************************************************************************************/
|
|
431
172
|
|
|
432
173
|
/**
|
|
433
|
-
*
|
|
174
|
+
* データの再読み込み判定において、不正なデータ型が検出された際に付与されるメタデータの型定義です。
|
|
434
175
|
*/
|
|
435
|
-
export
|
|
176
|
+
export type LoaderConditionErrorMeta = {
|
|
436
177
|
/**
|
|
437
|
-
*
|
|
178
|
+
* エラーが発生した対象ルートの URL パス文字列です。
|
|
438
179
|
*/
|
|
439
|
-
url: string;
|
|
180
|
+
readonly url: string;
|
|
440
181
|
|
|
441
182
|
/**
|
|
442
|
-
*
|
|
183
|
+
* 不正な値を返した対象の `shouldReload` 関数の参照です。
|
|
443
184
|
*/
|
|
444
|
-
|
|
445
|
-
}> {
|
|
446
|
-
static {
|
|
447
|
-
this.prototype.name = "SosekiMultipleRedirectError";
|
|
448
|
-
}
|
|
185
|
+
readonly shouldReload: Function;
|
|
449
186
|
|
|
450
187
|
/**
|
|
451
|
-
* `
|
|
452
|
-
*
|
|
453
|
-
* @param url ルートの URL です。
|
|
454
|
-
* @param redirects リダイレクト先パスのリストです。
|
|
455
|
-
* @param options エラーのオプションです。
|
|
188
|
+
* `shouldReload` 関数が実際に返した、期待値とは異なるオブジェクトやプリミティブ値です。
|
|
456
189
|
*/
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
redirects: readonly string[],
|
|
460
|
-
options?: ErrorOptions | undefined,
|
|
461
|
-
) {
|
|
462
|
-
super(options, {
|
|
463
|
-
url,
|
|
464
|
-
redirects,
|
|
465
|
-
});
|
|
466
|
-
initMessage(
|
|
467
|
-
this,
|
|
468
|
-
({ meta }) => `Multiple redirects detected: ${meta.redirects.join(", ")}`,
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/*#__PURE__*/ setErrorMessage(
|
|
474
|
-
MultipleRedirectError,
|
|
475
|
-
({ meta }) => `複数のリダイレクトが検出されました: ${meta.redirects.join(", ")}`,
|
|
476
|
-
"ja",
|
|
477
|
-
);
|
|
478
|
-
|
|
479
|
-
/**************************************************************************************************/
|
|
190
|
+
readonly returnValue: unknown;
|
|
191
|
+
};
|
|
480
192
|
|
|
481
193
|
/**
|
|
482
|
-
*
|
|
194
|
+
* `LoaderConditionError` のインスタンスを初期化する際に渡される引数オブジェクトの型定義です。
|
|
483
195
|
*/
|
|
484
|
-
export
|
|
485
|
-
/**
|
|
486
|
-
* ルートの URL です。
|
|
487
|
-
*/
|
|
488
|
-
url: string;
|
|
196
|
+
export type LoaderConditionErrorArgs = ErrorOptions & LoaderConditionErrorMeta;
|
|
489
197
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* shouldLoader が返した値です。
|
|
497
|
-
*/
|
|
498
|
-
returnValue: unknown;
|
|
499
|
-
}> {
|
|
198
|
+
/**
|
|
199
|
+
* ユーザーが定義した `shouldReload` 関数が、仕様に準拠した同期的な真偽値ではなく、不正な値を返した場合に投げるエラーです。
|
|
200
|
+
*/
|
|
201
|
+
export class LoaderConditionError extends ErrorBase<LoaderConditionErrorMeta> {
|
|
500
202
|
static {
|
|
501
203
|
this.prototype.name = "SosekiLoaderConditionError";
|
|
502
204
|
}
|
|
@@ -504,84 +206,60 @@ export class LoaderConditionError extends ErrorBase<{
|
|
|
504
206
|
/**
|
|
505
207
|
* `LoaderConditionError` クラスの新しいインスタンスを初期化します。
|
|
506
208
|
*
|
|
507
|
-
* @param
|
|
508
|
-
* @param shouldLoader shouldLoader 関数です。
|
|
509
|
-
* @param returnValue shouldLoader が返した値です。
|
|
510
|
-
* @param options エラーのオプションです。
|
|
209
|
+
* @param args エラーオプション、対象URL、関数の参照、および実際の戻り値を含む引数オブジェクトです。
|
|
511
210
|
*/
|
|
512
|
-
public constructor(
|
|
513
|
-
url
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
shouldLoader,
|
|
522
|
-
});
|
|
523
|
-
initMessage(
|
|
524
|
-
this,
|
|
525
|
-
({ meta }) =>
|
|
526
|
-
isPromiseLike(meta.returnValue)
|
|
527
|
-
? "shouldLoader must return a boolean value synchronously"
|
|
528
|
-
: `Expected boolean, but got ${getTypeName(meta.returnValue) || "unknown"}`,
|
|
211
|
+
public constructor(args: LoaderConditionErrorArgs) {
|
|
212
|
+
const { url, returnValue, shouldReload, ...options } = args;
|
|
213
|
+
super(
|
|
214
|
+
{ url, returnValue, shouldReload },
|
|
215
|
+
({ returnValue }) =>
|
|
216
|
+
isThenable(returnValue)
|
|
217
|
+
? "shouldReload must return a boolean value synchronously"
|
|
218
|
+
: `Expected boolean, but got ${getTypeName(returnValue) || "unknown"}`,
|
|
219
|
+
options,
|
|
529
220
|
);
|
|
530
221
|
}
|
|
531
222
|
}
|
|
532
223
|
|
|
533
224
|
/*#__PURE__*/ setErrorMessage(
|
|
534
225
|
LoaderConditionError,
|
|
535
|
-
({
|
|
536
|
-
|
|
537
|
-
? "
|
|
538
|
-
: `真偽値を期待しましたが、${getTypeName(
|
|
226
|
+
({ returnValue }) =>
|
|
227
|
+
isThenable(returnValue)
|
|
228
|
+
? "shouldReload は同期的に真偽値を返す必要があります"
|
|
229
|
+
: `真偽値を期待しましたが、${getTypeName(returnValue) || "unknown"} を得ました`,
|
|
539
230
|
"ja",
|
|
540
231
|
);
|
|
541
232
|
|
|
542
233
|
/**************************************************************************************************/
|
|
543
234
|
|
|
544
235
|
/**
|
|
545
|
-
*
|
|
236
|
+
* ルーター全体の共通状態 `RouterContext` が、React のコンポーネントツリー内の上位から供給されていない場合に投げるエラーです。
|
|
546
237
|
*/
|
|
547
|
-
export class
|
|
548
|
-
/**
|
|
549
|
-
* 現在のブラウザの UserAgent です。
|
|
550
|
-
*/
|
|
551
|
-
userAgent: string;
|
|
552
|
-
}> {
|
|
238
|
+
export class RouterContextMissingError extends ErrorBase<undefined> {
|
|
553
239
|
static {
|
|
554
|
-
this.prototype.name = "
|
|
240
|
+
this.prototype.name = "SosekiRouterContextMissingError";
|
|
555
241
|
}
|
|
556
242
|
|
|
557
243
|
/**
|
|
558
|
-
* `
|
|
244
|
+
* `RouterContextMissingError` クラスの新しいインスタンスを初期化します。
|
|
559
245
|
*
|
|
560
|
-
* @param options
|
|
246
|
+
* @param options エラーの共通オプションです。
|
|
561
247
|
*/
|
|
562
|
-
public constructor(options?: ErrorOptions
|
|
563
|
-
super(
|
|
564
|
-
userAgent: typeof window !== "undefined"
|
|
565
|
-
? window.navigator.userAgent
|
|
566
|
-
: "unknown",
|
|
567
|
-
});
|
|
568
|
-
initMessage(
|
|
569
|
-
this,
|
|
570
|
-
() => "The Navigation API is not supported in this environment",
|
|
571
|
-
);
|
|
248
|
+
public constructor(options?: ErrorOptions) {
|
|
249
|
+
super("RouterContext not found. Did you forget to wrap your app in <Router />?", options);
|
|
572
250
|
}
|
|
573
251
|
}
|
|
574
252
|
|
|
575
253
|
/*#__PURE__*/ setErrorMessage(
|
|
576
|
-
|
|
577
|
-
|
|
254
|
+
RouterContextMissingError,
|
|
255
|
+
"RouterContext が見つかりません。アプリを <Router /> で囲むのを忘れていませんか?",
|
|
578
256
|
"ja",
|
|
579
257
|
);
|
|
580
258
|
|
|
581
259
|
/**************************************************************************************************/
|
|
582
260
|
|
|
583
261
|
/**
|
|
584
|
-
* RouteContext
|
|
262
|
+
* 個々のルート固有の状態 `RouteContext` が、React のコンポーネントツリー内の上位から供給されていない場合に投げるエラーです。
|
|
585
263
|
*/
|
|
586
264
|
export class RouteContextMissingError extends ErrorBase<undefined> {
|
|
587
265
|
static {
|
|
@@ -591,66 +269,40 @@ export class RouteContextMissingError extends ErrorBase<undefined> {
|
|
|
591
269
|
/**
|
|
592
270
|
* `RouteContextMissingError` クラスの新しいインスタンスを初期化します。
|
|
593
271
|
*
|
|
594
|
-
* @param options
|
|
272
|
+
* @param options エラーの共通オプションです。
|
|
595
273
|
*/
|
|
596
|
-
public constructor(options?: ErrorOptions
|
|
597
|
-
|
|
598
|
-
super(options, undefined);
|
|
599
|
-
initMessage(
|
|
600
|
-
this,
|
|
601
|
-
() => "RouteContext not found. Did you forget to wrap your app in <Router />?",
|
|
602
|
-
);
|
|
274
|
+
public constructor(options?: ErrorOptions) {
|
|
275
|
+
super("RouteContext not found. Did you forget to wrap your app in <Router />?", options);
|
|
603
276
|
}
|
|
604
277
|
}
|
|
605
278
|
|
|
606
279
|
/*#__PURE__*/ setErrorMessage(
|
|
607
280
|
RouteContextMissingError,
|
|
608
|
-
|
|
281
|
+
"RouteContext が見つかりません。アプリを <Router /> で囲むのを忘れていませんか?",
|
|
609
282
|
"ja",
|
|
610
283
|
);
|
|
611
284
|
|
|
612
285
|
/**************************************************************************************************/
|
|
613
286
|
|
|
614
287
|
/**
|
|
615
|
-
*
|
|
288
|
+
* ローダーデータの紛失を通知する際に付与されるメタデータの型定義です。
|
|
616
289
|
*/
|
|
617
|
-
export
|
|
618
|
-
static {
|
|
619
|
-
this.prototype.name = "SosekiRouterContextMissingError";
|
|
620
|
-
}
|
|
621
|
-
|
|
290
|
+
export type LoaderDataNotFoundErrorMeta = {
|
|
622
291
|
/**
|
|
623
|
-
* `
|
|
624
|
-
*
|
|
625
|
-
* @param options エラーのオプションです。
|
|
292
|
+
* データの取得を試みた対象のローダー関数の参照です。未定義の場合は `undefined` となることがあります。
|
|
626
293
|
*/
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
super(options, undefined);
|
|
630
|
-
initMessage(
|
|
631
|
-
this,
|
|
632
|
-
() => "RouterContext not found. Did you forget to wrap your app in <Router />?",
|
|
633
|
-
);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/*#__PURE__*/ setErrorMessage(
|
|
638
|
-
RouterContextMissingError,
|
|
639
|
-
() => "RouterContext が見つかりません。アプリを <Router /> で囲むのを忘れていませんか?",
|
|
640
|
-
"ja",
|
|
641
|
-
);
|
|
294
|
+
readonly loader: Function | undefined;
|
|
295
|
+
};
|
|
642
296
|
|
|
643
|
-
|
|
297
|
+
/**
|
|
298
|
+
* `LoaderDataNotFoundError` のインスタンスを初期化する際に渡される引数オブジェクトの型定義です。
|
|
299
|
+
*/
|
|
300
|
+
export type LoaderDataNotFoundErrorArgs = ErrorOptions & LoaderDataNotFoundErrorMeta;
|
|
644
301
|
|
|
645
302
|
/**
|
|
646
|
-
*
|
|
303
|
+
* ルートに紐づくデータ取得用のローダー関数が正常に処理されたはずであるにもかかわらず、該当するキャッシュデータや応答結果が見つからない場合に投げるエラーです。
|
|
647
304
|
*/
|
|
648
|
-
export class LoaderDataNotFoundError extends ErrorBase<{
|
|
649
|
-
/**
|
|
650
|
-
* データが見つからなかった loader 関数です。
|
|
651
|
-
*/
|
|
652
|
-
loader: Function;
|
|
653
|
-
}> {
|
|
305
|
+
export class LoaderDataNotFoundError extends ErrorBase<LoaderDataNotFoundErrorMeta> {
|
|
654
306
|
static {
|
|
655
307
|
this.prototype.name = "SosekiLoaderDataNotFoundError";
|
|
656
308
|
}
|
|
@@ -658,23 +310,26 @@ export class LoaderDataNotFoundError extends ErrorBase<{
|
|
|
658
310
|
/**
|
|
659
311
|
* `LoaderDataNotFoundError` クラスの新しいインスタンスを初期化します。
|
|
660
312
|
*
|
|
661
|
-
* @param
|
|
662
|
-
* @param options エラーのオプションです。
|
|
313
|
+
* @param args エラーオプションおよび対象ローダー関数の参照を含む引数オブジェクトです。
|
|
663
314
|
*/
|
|
664
|
-
public constructor(
|
|
665
|
-
loader
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
315
|
+
public constructor(args: LoaderDataNotFoundErrorArgs) {
|
|
316
|
+
const { loader, ...options } = args;
|
|
317
|
+
super(
|
|
318
|
+
{ loader },
|
|
319
|
+
({ loader }) =>
|
|
320
|
+
loader
|
|
321
|
+
? `Loader data not found (Function name: ${loader.name || "anonymous"})`
|
|
322
|
+
: "Loader is undefined",
|
|
323
|
+
options,
|
|
672
324
|
);
|
|
673
325
|
}
|
|
674
326
|
}
|
|
675
327
|
|
|
676
328
|
/*#__PURE__*/ setErrorMessage(
|
|
677
329
|
LoaderDataNotFoundError,
|
|
678
|
-
({
|
|
330
|
+
({ loader }) =>
|
|
331
|
+
loader
|
|
332
|
+
? `ローダーデータが見つかりません(関数名: ${loader.name || "匿名"})`
|
|
333
|
+
: "ローダーが未定義です。",
|
|
679
334
|
"ja",
|
|
680
335
|
);
|