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
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 与えられた値が `PromiseLike` であるかどうかを判定します。
|
|
3
|
-
*
|
|
4
|
-
* @param value 判定対象の値です。
|
|
5
|
-
* @returns 値が `then` メソッドを持つオブジェクトである場合は `true`、それ以外は `false` を返します。
|
|
6
|
-
*/
|
|
7
|
-
export default function isPromiseLike<T = unknown>(value: unknown): value is PromiseLike<T>;
|
|
8
|
-
//# sourceMappingURL=_is-promise-like.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_is-promise-like.d.ts","sourceRoot":"","sources":["../../src/core/_is-promise-like.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAO1F"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 与えられた値が `PromiseLike` であるかどうかを判定します。
|
|
3
|
-
*
|
|
4
|
-
* @param value 判定対象の値です。
|
|
5
|
-
* @returns 値が `then` メソッドを持つオブジェクトである場合は `true`、それ以外は `false` を返します。
|
|
6
|
-
*/
|
|
7
|
-
export default function isPromiseLike(value) {
|
|
8
|
-
return (value !== null
|
|
9
|
-
&& typeof value === "object"
|
|
10
|
-
// @ts-expect-error
|
|
11
|
-
&& typeof value["then"] === "function");
|
|
12
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PathParams, Route } from "./route.types.js";
|
|
2
|
-
/**
|
|
3
|
-
* パスマッチングの結果を表す型定義です。
|
|
4
|
-
*/
|
|
5
|
-
export type MatchPathResult = {
|
|
6
|
-
/**
|
|
7
|
-
* パスから抽出されたパラメーターのキーと値のペアです。
|
|
8
|
-
*/
|
|
9
|
-
params: PathParams;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* 指定されたルートの正規表現パターンを使用して、パス名がマッチするかどうかを判定します。
|
|
13
|
-
*
|
|
14
|
-
* @param route 判定対象となる前処理済みのルートオブジェクトです。
|
|
15
|
-
* @param pathname マッチングを行う対象のパス名(URL のパス部分)です。
|
|
16
|
-
* @returns マッチした場合はパラメーターを含むオブジェクトを返し、マッチしない場合は `null` を返します。
|
|
17
|
-
*/
|
|
18
|
-
export default function matchPath(route: Pick<Route, "paramKeys" | "pathPattern">, pathname: string): MatchPathResult | null;
|
|
19
|
-
//# sourceMappingURL=_match-route-path.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_match-route-path.d.ts","sourceRoot":"","sources":["../../src/core/_match-route-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAAC,EAC/C,QAAQ,EAAE,MAAM,GACf,eAAe,GAAG,IAAI,CAgBxB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 指定されたルートの正規表現パターンを使用して、パス名がマッチするかどうかを判定します。
|
|
3
|
-
*
|
|
4
|
-
* @param route 判定対象となる前処理済みのルートオブジェクトです。
|
|
5
|
-
* @param pathname マッチングを行う対象のパス名(URL のパス部分)です。
|
|
6
|
-
* @returns マッチした場合はパラメーターを含むオブジェクトを返し、マッチしない場合は `null` を返します。
|
|
7
|
-
*/
|
|
8
|
-
export default function matchPath(route, pathname) {
|
|
9
|
-
const matches = route.pathPattern.exec(pathname);
|
|
10
|
-
if (!matches) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const params = {};
|
|
14
|
-
for (let i = 0, value; i < route.paramKeys.length; i++) {
|
|
15
|
-
value = matches[i + 1];
|
|
16
|
-
if (value !== undefined) {
|
|
17
|
-
// route.paramKeys のインデックスと matches のキャプチャーグループを対応させます。
|
|
18
|
-
params[route.paramKeys[i]] = value;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return { params };
|
|
22
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Route, RouteDefinition } from "./route.types.js";
|
|
2
|
-
/**
|
|
3
|
-
* ルート定義の配列を再帰的に処理し、実行時に適した `Route` オブジェクトの配列に変換します。
|
|
4
|
-
*
|
|
5
|
-
* @param routes 変換前のルート定義の配列です。
|
|
6
|
-
* @returns 前処理が施された `Route` オブジェクトの配列を返します。
|
|
7
|
-
*/
|
|
8
|
-
export default function processRoutes(routes: readonly RouteDefinition[]): readonly Route[];
|
|
9
|
-
//# sourceMappingURL=_process-routes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_process-routes.d.ts","sourceRoot":"","sources":["../../src/core/_process-routes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA4C/D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,KAAK,EAAE,CAE1F"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { parse } from "regexparam";
|
|
2
|
-
import compareRoutePaths from "./_compare-route-paths.js";
|
|
3
|
-
import encodePathname from "./_encode-pathname.js";
|
|
4
|
-
/**
|
|
5
|
-
* パスのプレフィックスを考慮しながら再帰的にルートを変換する内部実装です。
|
|
6
|
-
*
|
|
7
|
-
* @param defs 処理対象のルート定義の配列です。
|
|
8
|
-
* @param prefix 親ルートから引き継いだパスのプレフィックスです。
|
|
9
|
-
* @returns 変換後のルート配列です。
|
|
10
|
-
*/
|
|
11
|
-
function processRoutesImpl(routes, prefix = "") {
|
|
12
|
-
return routes
|
|
13
|
-
.map(route => {
|
|
14
|
-
const path = encodePathname(prefix + "/" + route.path);
|
|
15
|
-
const isIndex = !route.children;
|
|
16
|
-
const { keys: paramKeys, pattern: pathPattern, } = parse(path,
|
|
17
|
-
// インデックスルートでないとき loose オプションを `true` にして子ルートに対してもマッチするようにします。
|
|
18
|
-
!isIndex);
|
|
19
|
-
return {
|
|
20
|
-
path,
|
|
21
|
-
index: isIndex,
|
|
22
|
-
children: route.children
|
|
23
|
-
? processRoutesImpl(route.children, path)
|
|
24
|
-
: [],
|
|
25
|
-
component: route.component,
|
|
26
|
-
dataFuncs: (route.dataFunctions || []).map(f => ({
|
|
27
|
-
action: f.action,
|
|
28
|
-
loader: f.loader,
|
|
29
|
-
// 未定義の場合は常に true を返すデフォルト関数を設定します。
|
|
30
|
-
shouldAction: f.shouldAction || (a => a.defaultShouldAction),
|
|
31
|
-
shouldReload: f.shouldReload || (a => a.defaultShouldReload),
|
|
32
|
-
})),
|
|
33
|
-
paramKeys,
|
|
34
|
-
pathPattern,
|
|
35
|
-
};
|
|
36
|
-
})
|
|
37
|
-
.sort((a, b) => compareRoutePaths(a.path, b.path));
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* ルート定義の配列を再帰的に処理し、実行時に適した `Route` オブジェクトの配列に変換します。
|
|
41
|
-
*
|
|
42
|
-
* @param routes 変換前のルート定義の配列です。
|
|
43
|
-
* @returns 前処理が施された `Route` オブジェクトの配列を返します。
|
|
44
|
-
*/
|
|
45
|
-
export default function processRoutes(routes) {
|
|
46
|
-
return processRoutesImpl(routes);
|
|
47
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
/**
|
|
3
|
-
* シングルトンインスタンスを管理するためのグローバルなキャッシュマップです。
|
|
4
|
-
*/
|
|
5
|
-
var soseki__singleton: Map<unknown, any> | undefined;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* 指定されたキーに基づいて値を一意に保持するシングルトンパターンを提供します。
|
|
9
|
-
*
|
|
10
|
-
* 初回実行時に生成された値をキャッシュし、以降の呼び出しではその値を返します。
|
|
11
|
-
*
|
|
12
|
-
* @template T 生成される値の型です。
|
|
13
|
-
* @param key インスタンスを識別するためのユニークなキーです。
|
|
14
|
-
* @param fn インスタンスを生成するためのファクトリー関数です。
|
|
15
|
-
* @returns キャッシュされた値、または非同期の場合はその解決値を返します。
|
|
16
|
-
*/
|
|
17
|
-
export default function singleton<T>(key: unknown, fn: (...args: any) => T): T | Awaited<T>;
|
|
18
|
-
//# sourceMappingURL=_singleton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_singleton.d.ts","sourceRoot":"","sources":["../../src/core/_singleton.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,iBAAiB,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;CACtD;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAyB1F"}
|
package/dist/core/_singleton.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import isPromiseLike from "./_is-promise-like.js";
|
|
2
|
-
/**
|
|
3
|
-
* 指定されたキーに基づいて値を一意に保持するシングルトンパターンを提供します。
|
|
4
|
-
*
|
|
5
|
-
* 初回実行時に生成された値をキャッシュし、以降の呼び出しではその値を返します。
|
|
6
|
-
*
|
|
7
|
-
* @template T 生成される値の型です。
|
|
8
|
-
* @param key インスタンスを識別するためのユニークなキーです。
|
|
9
|
-
* @param fn インスタンスを生成するためのファクトリー関数です。
|
|
10
|
-
* @returns キャッシュされた値、または非同期の場合はその解決値を返します。
|
|
11
|
-
*/
|
|
12
|
-
export default function singleton(key, fn) {
|
|
13
|
-
const cache = globalThis.soseki__singleton || (globalThis.soseki__singleton = new Map());
|
|
14
|
-
if (cache.has(key)) {
|
|
15
|
-
return cache.get(key);
|
|
16
|
-
}
|
|
17
|
-
let returns = fn();
|
|
18
|
-
if (isPromiseLike(returns)) {
|
|
19
|
-
const promise = (async () => {
|
|
20
|
-
try {
|
|
21
|
-
const value = await returns;
|
|
22
|
-
cache.set(key, value);
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
catch (ex) {
|
|
26
|
-
// エラーが発生した場合はキャッシュを削除し、エラーを投げます。
|
|
27
|
-
cache.delete(key);
|
|
28
|
-
throw ex;
|
|
29
|
-
}
|
|
30
|
-
})();
|
|
31
|
-
cache.set(key, promise);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
cache.set(key, returns);
|
|
35
|
-
}
|
|
36
|
-
return cache.get(key);
|
|
37
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 網羅性チェックを行うためのユーティリティー関数です。
|
|
3
|
-
*/
|
|
4
|
-
declare function unreachable(): never;
|
|
5
|
-
/**
|
|
6
|
-
* 網羅性チェックを行うためのユーティリティー関数です。`never` 型の変数に予期せぬ値が代入された場合にエラーを投げます。
|
|
7
|
-
*
|
|
8
|
-
* @param value `never` 型の変数です。ここには到達しないはずの値が入ります。
|
|
9
|
-
*/
|
|
10
|
-
declare function unreachable(value: never): never;
|
|
11
|
-
export default unreachable;
|
|
12
|
-
//# sourceMappingURL=_unreachable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_unreachable.d.ts","sourceRoot":"","sources":["../../src/core/_unreachable.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,iBAAS,WAAW,IAAI,KAAK,CAAC;AAE9B;;;;GAIG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;AAQ1C,eAAe,WAAW,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import captureStackTrace from "./_capture-stack-trace.js";
|
|
2
|
-
import { UnreachableError } from "./errors.js";
|
|
3
|
-
function unreachable(...args) {
|
|
4
|
-
const error = new UnreachableError(args);
|
|
5
|
-
captureStackTrace(error, unreachable);
|
|
6
|
-
throw error;
|
|
7
|
-
}
|
|
8
|
-
export default unreachable;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* コンポーネントのライフサイクルを通じて、初期化関数 (`fn`) を一度だけ実行し、その結果を保持し続けるカスタムフックです。
|
|
3
|
-
*
|
|
4
|
-
* `useMemo` と異なり、依存配列が存在しないため、再レンダリングやフックの呼び出し順序に関係なく、最初のレンダリング時にのみ初期化が実行されることを保証します。
|
|
5
|
-
*
|
|
6
|
-
* @template T 初期化関数が返す値の型です。
|
|
7
|
-
* @param fn 一度だけ実行される初期化関数です。引数は取りません。
|
|
8
|
-
* @returns 初期化関数が返した、シングルトンとして保持される値です。
|
|
9
|
-
*/
|
|
10
|
-
export default function useSingleton<T>(fn: () => T): T;
|
|
11
|
-
//# sourceMappingURL=_use-singleton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_use-singleton.d.ts","sourceRoot":"","sources":["../../src/core/_use-singleton.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAOtD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
/**
|
|
3
|
-
* 初期化が一度だけ実行されることを保証するための特殊なシンボルです。`ref.current` の初期値として使用され、値がまだ設定されていない状態を示します。
|
|
4
|
-
*/
|
|
5
|
-
const NONE = Symbol.for("soseki/none");
|
|
6
|
-
/**
|
|
7
|
-
* コンポーネントのライフサイクルを通じて、初期化関数 (`fn`) を一度だけ実行し、その結果を保持し続けるカスタムフックです。
|
|
8
|
-
*
|
|
9
|
-
* `useMemo` と異なり、依存配列が存在しないため、再レンダリングやフックの呼び出し順序に関係なく、最初のレンダリング時にのみ初期化が実行されることを保証します。
|
|
10
|
-
*
|
|
11
|
-
* @template T 初期化関数が返す値の型です。
|
|
12
|
-
* @param fn 一度だけ実行される初期化関数です。引数は取りません。
|
|
13
|
-
* @returns 初期化関数が返した、シングルトンとして保持される値です。
|
|
14
|
-
*/
|
|
15
|
-
export default function useSingleton(fn) {
|
|
16
|
-
const ref = React.useRef(NONE);
|
|
17
|
-
if (ref.current === NONE) {
|
|
18
|
-
ref.current = fn();
|
|
19
|
-
}
|
|
20
|
-
return ref.current;
|
|
21
|
-
}
|
package/dist/core/_valibot.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { type InferOutput, type RawTransformAction, safeParse } from "valibot";
|
|
2
|
-
/***************************************************************************************************
|
|
3
|
-
*
|
|
4
|
-
* 共通の型
|
|
5
|
-
*
|
|
6
|
-
**************************************************************************************************/
|
|
7
|
-
/**
|
|
8
|
-
* Valibot のスキーマの基底型を抽出するための型定義です。
|
|
9
|
-
*/
|
|
10
|
-
type BaseSchema = typeof safeParse extends (schema: infer TSchema, ...args: any) => any ? TSchema : never;
|
|
11
|
-
/***************************************************************************************************
|
|
12
|
-
*
|
|
13
|
-
* 再エクスポート
|
|
14
|
-
*
|
|
15
|
-
**************************************************************************************************/
|
|
16
|
-
export { brand, minValue, nullable, number, object, pipe, safeInteger, string, union, url, uuid, } from "valibot";
|
|
17
|
-
export type { InferInput, InferOutput } from "valibot";
|
|
18
|
-
/***************************************************************************************************
|
|
19
|
-
*
|
|
20
|
-
* transform
|
|
21
|
-
*
|
|
22
|
-
**************************************************************************************************/
|
|
23
|
-
/**
|
|
24
|
-
* 入力値を変換するアクションを作成します。例外が投げられた場合は Issue として登録します。
|
|
25
|
-
*
|
|
26
|
-
* @template TInput 入力値の型です。
|
|
27
|
-
* @template TOutput 出力値の型です。
|
|
28
|
-
* @param operation 変換処理を行う関数です。
|
|
29
|
-
* @returns Valibot の RawTransformAction オブジェクトです。
|
|
30
|
-
*/
|
|
31
|
-
export declare function transform<TInput, TOutput>(operation: (input: TInput) => TOutput): RawTransformAction<TInput, TOutput>;
|
|
32
|
-
/***************************************************************************************************
|
|
33
|
-
*
|
|
34
|
-
* parse
|
|
35
|
-
*
|
|
36
|
-
**************************************************************************************************/
|
|
37
|
-
/***************************************************************************************************
|
|
38
|
-
*
|
|
39
|
-
* expect
|
|
40
|
-
*
|
|
41
|
-
**************************************************************************************************/
|
|
42
|
-
/**
|
|
43
|
-
* 指定されたスキーマに従って入力を検証し、失敗した場合は UnexpectedValidationError を投げます。
|
|
44
|
-
*
|
|
45
|
-
* @template TSchema 使用するスキーマの型です。
|
|
46
|
-
* @param schema 検証に使用する Valibot スキーマです。
|
|
47
|
-
* @param input 検証対象の入力値です。
|
|
48
|
-
* @returns 検証に成功した出力値です。
|
|
49
|
-
* @throws 検証に失敗した場合、UnexpectedValidationError を投げます。
|
|
50
|
-
*/
|
|
51
|
-
export declare function expect<const TSchema extends BaseSchema>(schema: TSchema, input: unknown): InferOutput<TSchema>;
|
|
52
|
-
//# sourceMappingURL=_valibot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_valibot.d.ts","sourceRoot":"","sources":["../../src/core/_valibot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAgB,KAAK,kBAAkB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAK7F;;;;oGAIoG;AAEpG;;GAEG;AACH,KAAK,UAAU,GAAG,OAAO,SAAS,SAAS,CAAC,MAAM,EAAE,MAAM,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,GAAG,OAAO,GAC7F,KAAK,CAAC;AAEV;;;;oGAIoG;AAEpG,OAAO,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,EACJ,WAAW,EACX,MAAM,EACN,KAAK,EACL,GAAG,EACH,IAAI,GACL,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;oGAIoG;AAEpG;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EACvC,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GACpC,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAyBrC;AAED;;;;oGAIoG;AAkCpG;;;;oGAIoG;AAEpG;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,EACrD,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,GACb,WAAW,CAAC,OAAO,CAAC,CAStB"}
|
package/dist/core/_valibot.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { rawTransform, safeParse } from "valibot";
|
|
2
|
-
import captureStackTrace from "./_capture-stack-trace.js";
|
|
3
|
-
import isError from "./_is-error.js";
|
|
4
|
-
import { UnexpectedValidationError } from "./errors.js";
|
|
5
|
-
/***************************************************************************************************
|
|
6
|
-
*
|
|
7
|
-
* 再エクスポート
|
|
8
|
-
*
|
|
9
|
-
**************************************************************************************************/
|
|
10
|
-
export { brand, minValue, nullable, number, object, pipe, safeInteger, string, union, url, uuid, } from "valibot";
|
|
11
|
-
/***************************************************************************************************
|
|
12
|
-
*
|
|
13
|
-
* transform
|
|
14
|
-
*
|
|
15
|
-
**************************************************************************************************/
|
|
16
|
-
/**
|
|
17
|
-
* 入力値を変換するアクションを作成します。例外が投げられた場合は Issue として登録します。
|
|
18
|
-
*
|
|
19
|
-
* @template TInput 入力値の型です。
|
|
20
|
-
* @template TOutput 出力値の型です。
|
|
21
|
-
* @param operation 変換処理を行う関数です。
|
|
22
|
-
* @returns Valibot の RawTransformAction オブジェクトです。
|
|
23
|
-
*/
|
|
24
|
-
export function transform(operation) {
|
|
25
|
-
return rawTransform(({ dataset, addIssue, NEVER }) => {
|
|
26
|
-
const input = dataset.value;
|
|
27
|
-
try {
|
|
28
|
-
return operation(input);
|
|
29
|
-
}
|
|
30
|
-
catch (ex) {
|
|
31
|
-
let message;
|
|
32
|
-
if (isError(ex)) {
|
|
33
|
-
message = `${ex.name}: ${ex.message}`;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
try {
|
|
37
|
-
message = JSON.stringify(ex);
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
message = String(ex);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
addIssue({
|
|
44
|
-
input,
|
|
45
|
-
message,
|
|
46
|
-
});
|
|
47
|
-
return NEVER;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/***************************************************************************************************
|
|
52
|
-
*
|
|
53
|
-
* parse
|
|
54
|
-
*
|
|
55
|
-
**************************************************************************************************/
|
|
56
|
-
// /**
|
|
57
|
-
// * バリデーションエラーを生成するためのコンストラクター型インターフェースです。
|
|
58
|
-
// */
|
|
59
|
-
// export interface IParseErrorConstructor {
|
|
60
|
-
// new(issues: [Issue, ...Issue[]], input: unknown): ValidationErrorBase<ErrorMeta>;
|
|
61
|
-
// }
|
|
62
|
-
// /**
|
|
63
|
-
// * 指定されたスキーマに従って入力を検証し、失敗した場合は指定されたエラーを投げます。
|
|
64
|
-
// *
|
|
65
|
-
// * @template TSchema 使用するスキーマの型です。
|
|
66
|
-
// * @param schema 検証に使用する Valibot スキーマです。
|
|
67
|
-
// * @param input 検証対象の入力値です。
|
|
68
|
-
// * @param Error バリデーション失敗時に投げるエラークラスです。デフォルトは InvalidInputError です。
|
|
69
|
-
// * @returns 検証に成功した出力値です。
|
|
70
|
-
// * @throws 検証に失敗した場合、指定された Error を投げます。
|
|
71
|
-
// */
|
|
72
|
-
// export function parse<const TSchema extends BaseSchema>(
|
|
73
|
-
// schema: TSchema,
|
|
74
|
-
// input: unknown,
|
|
75
|
-
// Error: IParseErrorConstructor = InvalidInputError,
|
|
76
|
-
// ): InferOutput<TSchema> {
|
|
77
|
-
// const result = safeParse(schema, input);
|
|
78
|
-
// if (result.success) {
|
|
79
|
-
// return result.output;
|
|
80
|
-
// }
|
|
81
|
-
// const error = new Error(result.issues, input);
|
|
82
|
-
// captureStackTrace(error, parse);
|
|
83
|
-
// throw error;
|
|
84
|
-
// }
|
|
85
|
-
/***************************************************************************************************
|
|
86
|
-
*
|
|
87
|
-
* expect
|
|
88
|
-
*
|
|
89
|
-
**************************************************************************************************/
|
|
90
|
-
/**
|
|
91
|
-
* 指定されたスキーマに従って入力を検証し、失敗した場合は UnexpectedValidationError を投げます。
|
|
92
|
-
*
|
|
93
|
-
* @template TSchema 使用するスキーマの型です。
|
|
94
|
-
* @param schema 検証に使用する Valibot スキーマです。
|
|
95
|
-
* @param input 検証対象の入力値です。
|
|
96
|
-
* @returns 検証に成功した出力値です。
|
|
97
|
-
* @throws 検証に失敗した場合、UnexpectedValidationError を投げます。
|
|
98
|
-
*/
|
|
99
|
-
export function expect(schema, input) {
|
|
100
|
-
const result = safeParse(schema, input);
|
|
101
|
-
if (result.success) {
|
|
102
|
-
return result.output;
|
|
103
|
-
}
|
|
104
|
-
const error = new UnexpectedValidationError(result.issues, input);
|
|
105
|
-
captureStackTrace(error, expect);
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 識別子(ID)の型エイリアスです。
|
|
3
|
-
*
|
|
4
|
-
* ID は増分カウンターを36進数エンコードしたものです。
|
|
5
|
-
*/
|
|
6
|
-
export type Id = string;
|
|
7
|
-
/**
|
|
8
|
-
* `WeakIdRegistry` クラスは、オブジェクトに対する ID の割り当てと管理を行います。
|
|
9
|
-
*
|
|
10
|
-
* オブジェクト自体は `WeakMap` と `WeakRef` を使用して保持されるため、参照がなくなったオブジェクトはガベージコレクション(GC)の対象になります。
|
|
11
|
-
*
|
|
12
|
-
* @template TValue ID を割り当てる対象となるオブジェクトの型です。`object` 型のサブタイプである必要があります。
|
|
13
|
-
*/
|
|
14
|
-
export default class WeakIdRegistry<TValue extends object> {
|
|
15
|
-
/**
|
|
16
|
-
* ID 生成のための内部カウンターです。BigInt を使用することで、非常に大きな数値まで ID を生成できます。
|
|
17
|
-
*/
|
|
18
|
-
private counter;
|
|
19
|
-
/**
|
|
20
|
-
* オブジェクト (関数を含む) から、割り当てられた ID へのマッピングを保持する `WeakMap` です。
|
|
21
|
-
*
|
|
22
|
-
* `WeakMap` を使用することで、キーであるオブジェクトが他の場所から参照されなくなった場合、このマッピングも自動的に破棄され、GC が可能になります。
|
|
23
|
-
*/
|
|
24
|
-
private readonly v2id;
|
|
25
|
-
/**
|
|
26
|
-
* ID から、対応するオブジェクトへの弱い参照 (`WeakRef`) のマッピングを保持する `Map` です。
|
|
27
|
-
*
|
|
28
|
-
* オブジェクト自体が GC される可能性があるため、`WeakRef` を使用しています。
|
|
29
|
-
*/
|
|
30
|
-
private readonly id2v;
|
|
31
|
-
/**
|
|
32
|
-
* オブジェクトが GC されたときに実行されるコールバックを登録するための `FinalizationRegistry` です。
|
|
33
|
-
*
|
|
34
|
-
* オブジェクトが GC されると、登録された ID がコールバックに渡され、その ID に対応するエントリーを `id2v` マップから削除するために使用されます。
|
|
35
|
-
*/
|
|
36
|
-
private readonly gc;
|
|
37
|
-
/**
|
|
38
|
-
* `WeakIdRegistry` クラスの新しいインスタンスを作成します。
|
|
39
|
-
*/
|
|
40
|
-
constructor();
|
|
41
|
-
/**
|
|
42
|
-
* 指定されたオブジェクトに一意の ID を割り当てて登録します。
|
|
43
|
-
*
|
|
44
|
-
* すでに ID が割り当てられているオブジェクトであれば、既存の ID を返します。
|
|
45
|
-
*
|
|
46
|
-
* @param value ID を割り当てる対象のオブジェクトです。
|
|
47
|
-
* @returns 割り当てられた、または既存の一意の ID です。
|
|
48
|
-
*/
|
|
49
|
-
set(value: TValue): Id;
|
|
50
|
-
/**
|
|
51
|
-
* 指定されたオブジェクトに ID が割り当てられているかどうかを確認します。
|
|
52
|
-
*
|
|
53
|
-
* @param value 確認するオブジェクトです。
|
|
54
|
-
* @returns ID が割り当てられていれば `true`、そうでなければ `false` を返します。
|
|
55
|
-
*/
|
|
56
|
-
has(value: TValue): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* 指定されたオブジェクトに対応する ID を取得します。
|
|
59
|
-
*
|
|
60
|
-
* オブジェクトが未登録の場合は `undefined` を返します。
|
|
61
|
-
*
|
|
62
|
-
* @param value 取得したい ID のオブジェクトです。
|
|
63
|
-
* @returns 対応する ID、またはオブジェクトが未登録の場合は `undefined` を返します。
|
|
64
|
-
*/
|
|
65
|
-
get(value: TValue): Id | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* 指定された ID に対応するオブジェクトを取得します。
|
|
68
|
-
*
|
|
69
|
-
* オブジェクトが既に GC されている場合は `undefined` を返します。
|
|
70
|
-
*
|
|
71
|
-
* @param id 取得したいオブジェクトの ID です。
|
|
72
|
-
* @returns 対応するオブジェクト、またはオブジェクトが GC されている場合は `undefined` を返します。
|
|
73
|
-
*/
|
|
74
|
-
get(id: Id): TValue | undefined;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=_weak-id-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_weak-id-registry.d.ts","sourceRoot":"","sources":["../../src/core/_weak-id-registry.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,EAAE,GAAG,MAAM,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc,CAAC,MAAM,SAAS,MAAM;IACvD;;OAEG;IACH,OAAO,CAAC,OAAO,CAAS;IAExB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsB;IAE3C;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;IAEhD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA2B;IAE9C;;OAEG;;IAUH;;;;;;;OAOG;IACI,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE;IAsB7B;;;;;OAKG;IACI,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIlC;;;;;;;OAOG;IACI,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,GAAG,SAAS;IAEzC;;;;;;;OAOG;IACI,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,GAAG,SAAS;CAWvC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import unreachable from "./_unreachable.js";
|
|
2
|
-
/**
|
|
3
|
-
* `WeakIdRegistry` クラスは、オブジェクトに対する ID の割り当てと管理を行います。
|
|
4
|
-
*
|
|
5
|
-
* オブジェクト自体は `WeakMap` と `WeakRef` を使用して保持されるため、参照がなくなったオブジェクトはガベージコレクション(GC)の対象になります。
|
|
6
|
-
*
|
|
7
|
-
* @template TValue ID を割り当てる対象となるオブジェクトの型です。`object` 型のサブタイプである必要があります。
|
|
8
|
-
*/
|
|
9
|
-
export default class WeakIdRegistry {
|
|
10
|
-
/**
|
|
11
|
-
* `WeakIdRegistry` クラスの新しいインスタンスを作成します。
|
|
12
|
-
*/
|
|
13
|
-
constructor() {
|
|
14
|
-
this.counter = 0n;
|
|
15
|
-
this.v2id = new WeakMap();
|
|
16
|
-
this.id2v = new Map();
|
|
17
|
-
this.gc = new FinalizationRegistry(id => {
|
|
18
|
-
this.id2v.delete(id);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* 指定されたオブジェクトに一意の ID を割り当てて登録します。
|
|
23
|
-
*
|
|
24
|
-
* すでに ID が割り当てられているオブジェクトであれば、既存の ID を返します。
|
|
25
|
-
*
|
|
26
|
-
* @param value ID を割り当てる対象のオブジェクトです。
|
|
27
|
-
* @returns 割り当てられた、または既存の一意の ID です。
|
|
28
|
-
*/
|
|
29
|
-
set(value) {
|
|
30
|
-
if (!this.v2id.has(value)) {
|
|
31
|
-
const id = (this.counter++).toString(36);
|
|
32
|
-
this.v2id.set(value, id);
|
|
33
|
-
this.id2v.set(id, new WeakRef(value));
|
|
34
|
-
// `FinalizationRegistry` にオブジェクトとそれに対応する ID を登録します。
|
|
35
|
-
// これにより、オブジェクトが GC されたときに `id2v` からエントリーが削除されます。
|
|
36
|
-
this.gc.register(value, id);
|
|
37
|
-
return id;
|
|
38
|
-
}
|
|
39
|
-
const id = this.v2id.get(value);
|
|
40
|
-
switch (typeof id) {
|
|
41
|
-
case "string":
|
|
42
|
-
return id;
|
|
43
|
-
default:
|
|
44
|
-
// `id` は必ず文字列になるはずです。
|
|
45
|
-
unreachable(id);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 指定されたオブジェクトに ID が割り当てられているかどうかを確認します。
|
|
50
|
-
*
|
|
51
|
-
* @param value 確認するオブジェクトです。
|
|
52
|
-
* @returns ID が割り当てられていれば `true`、そうでなければ `false` を返します。
|
|
53
|
-
*/
|
|
54
|
-
has(value) {
|
|
55
|
-
return this.v2id.has(value);
|
|
56
|
-
}
|
|
57
|
-
get(idOrValue) {
|
|
58
|
-
if (typeof idOrValue === "string") {
|
|
59
|
-
const id = idOrValue;
|
|
60
|
-
return this.id2v.get(id)?.deref();
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const value = idOrValue;
|
|
64
|
-
return this.v2id.get(value);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
package/dist/core/constants.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAA4B,CAAC"}
|
package/dist/core/constants.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type DeferredPromise from "./deferred-promise.js";
|
|
2
|
-
import type { IAction, ILoader } from "./route.types.js";
|
|
3
|
-
/**
|
|
4
|
-
* 読み取り専用のデータマップを表すインターフェースです。
|
|
5
|
-
*
|
|
6
|
-
* ルートに関連付けられたアクションやローダーの関数をキーとし、その実行結果を値として保持します。
|
|
7
|
-
*
|
|
8
|
-
* @template TDataFunction アクションまたはローダーの型定義です。デフォルトは `IAction | ILoader` です。
|
|
9
|
-
* @template TData 遅延評価されるプロミスの型定義です。デフォルトは `DeferredPromise<unknown>` です。
|
|
10
|
-
*/
|
|
11
|
-
export interface IReadonlyDataMap<TDataFunction extends IAction | ILoader = IAction | ILoader, TData = DeferredPromise<unknown>> extends ReadonlyMap<TDataFunction, TData> {
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* 書き込み可能なデータマップを表すインターフェースです。
|
|
15
|
-
*
|
|
16
|
-
* ルートに関連付けられたアクションやローダーの関数をキーとし、その実行結果を値として保持・操作します。
|
|
17
|
-
*
|
|
18
|
-
* @template TDataFunction アクションまたはローダーの型定義です。デフォルトは `IAction | ILoader` です。
|
|
19
|
-
* @template TData 遅延評価されるプロミスの型定義です。デフォルトは `DeferredPromise<unknown>` です。
|
|
20
|
-
*/
|
|
21
|
-
export interface IDataMap<TDataFunction extends IAction | ILoader = IAction | ILoader, TData = DeferredPromise<unknown>> extends Map<TDataFunction, TData> {
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=data-map.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-map.types.d.ts","sourceRoot":"","sources":["../../src/core/data-map.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB,CAC/B,aAAa,SAAS,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EAC3D,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAChC,SAAQ,WAAW,CAAC,aAAa,EAAE,KAAK,CAAC;CAAG;AAE9C;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ,CACvB,aAAa,SAAS,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EAC3D,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAChC,SAAQ,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|