@softistx/alxia-react-router 0.0.0-stage → 0.83.1
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/README.md +2085 -2
- package/dist/api-keys/api-keys.d.ts +93 -0
- package/dist/api-keys/api-keys.d.ts.map +1 -0
- package/dist/api-keys/index.d.ts +9 -0
- package/dist/api-keys/index.d.ts.map +1 -0
- package/dist/api-keys/index.js +66 -0
- package/dist/api-keys/index.js.map +10 -0
- package/dist/assets.d.ts +14 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/chunks/index-0786n4qe.js +25 -0
- package/dist/chunks/index-0786n4qe.js.map +10 -0
- package/dist/chunks/index-1nw5yeek.js +169 -0
- package/dist/chunks/index-1nw5yeek.js.map +11 -0
- package/dist/chunks/index-59vhfj6n.js +10 -0
- package/dist/chunks/index-59vhfj6n.js.map +10 -0
- package/dist/chunks/index-5gqcpyyg.js +34 -0
- package/dist/chunks/index-5gqcpyyg.js.map +10 -0
- package/dist/chunks/index-6jf7zpxz.js +119 -0
- package/dist/chunks/index-6jf7zpxz.js.map +11 -0
- package/dist/chunks/index-8as4j8m3.js +340 -0
- package/dist/chunks/index-8as4j8m3.js.map +16 -0
- package/dist/chunks/index-9xv2a8et.js +108 -0
- package/dist/chunks/index-9xv2a8et.js.map +11 -0
- package/dist/chunks/index-ajtvyq35.js +16 -0
- package/dist/chunks/index-ajtvyq35.js.map +10 -0
- package/dist/chunks/index-c55hxgr5.js +124 -0
- package/dist/chunks/index-c55hxgr5.js.map +14 -0
- package/dist/chunks/index-d42p3mdp.js +19 -0
- package/dist/chunks/index-d42p3mdp.js.map +10 -0
- package/dist/chunks/index-gac44rs5.js +42 -0
- package/dist/chunks/index-gac44rs5.js.map +11 -0
- package/dist/chunks/index-j4ktpcke.js +62 -0
- package/dist/chunks/index-j4ktpcke.js.map +10 -0
- package/dist/chunks/index-mscfme4r.js +12 -0
- package/dist/chunks/index-mscfme4r.js.map +10 -0
- package/dist/chunks/index-pghmb2dm.js +30 -0
- package/dist/chunks/index-pghmb2dm.js.map +10 -0
- package/dist/chunks/index-rfr02vg4.js +40 -0
- package/dist/chunks/index-rfr02vg4.js.map +10 -0
- package/dist/chunks/index-sfhshxqz.js +31 -0
- package/dist/chunks/index-sfhshxqz.js.map +10 -0
- package/dist/chunks/index-skwypsjz.js +357 -0
- package/dist/chunks/index-skwypsjz.js.map +12 -0
- package/dist/chunks/index-sxh06ged.js +118 -0
- package/dist/chunks/index-sxh06ged.js.map +11 -0
- package/dist/chunks/index-t2ph23wk.js +96 -0
- package/dist/chunks/index-t2ph23wk.js.map +13 -0
- package/dist/chunks/index-thyabr5n.js +19 -0
- package/dist/chunks/index-thyabr5n.js.map +10 -0
- package/dist/chunks/index-tx36swjx.js +134 -0
- package/dist/chunks/index-tx36swjx.js.map +11 -0
- package/dist/chunks/index-v2z5k640.js +54 -0
- package/dist/chunks/index-v2z5k640.js.map +11 -0
- package/dist/chunks/index-vr82typq.js +23 -0
- package/dist/chunks/index-vr82typq.js.map +11 -0
- package/dist/chunks/index-whj6h5eg.js +9 -0
- package/dist/chunks/index-whj6h5eg.js.map +10 -0
- package/dist/chunks/index-wyypkfdv.js +130 -0
- package/dist/chunks/index-wyypkfdv.js.map +13 -0
- package/dist/chunks/index-xd5aqy3g.js +90 -0
- package/dist/chunks/index-xd5aqy3g.js.map +10 -0
- package/dist/chunks/index-zdbqzcjp.js +97 -0
- package/dist/chunks/index-zdbqzcjp.js.map +12 -0
- package/dist/chunks/index-zyg8amjc.js +23 -0
- package/dist/chunks/index-zyg8amjc.js.map +10 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +215 -0
- package/dist/cli/index.js.map +13 -0
- package/dist/cli/main.d.ts +13 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/reveal.d.ts +18 -0
- package/dist/cli/reveal.d.ts.map +1 -0
- package/dist/cli/template.d.ts +8 -0
- package/dist/cli/template.d.ts.map +1 -0
- package/dist/context.d.ts +104 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/document/index.d.ts +11 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/document/index.js +19 -0
- package/dist/document/index.js.map +9 -0
- package/dist/document/inline-script.d.ts +27 -0
- package/dist/document/inline-script.d.ts.map +1 -0
- package/dist/document/language-store.d.ts +8 -0
- package/dist/document/language-store.d.ts.map +1 -0
- package/dist/document/nonce.d.ts +34 -0
- package/dist/document/nonce.d.ts.map +1 -0
- package/dist/document/page-language.d.ts +39 -0
- package/dist/document/page-language.d.ts.map +1 -0
- package/dist/document/text-direction.d.ts +10 -0
- package/dist/document/text-direction.d.ts.map +1 -0
- package/dist/entry/abort.d.ts +21 -0
- package/dist/entry/abort.d.ts.map +1 -0
- package/dist/entry/create-entry.d.ts +41 -0
- package/dist/entry/create-entry.d.ts.map +1 -0
- package/dist/entry/index.d.ts +8 -0
- package/dist/entry/index.d.ts.map +1 -0
- package/dist/entry/index.js +154 -0
- package/dist/entry/index.js.map +13 -0
- package/dist/entry/root-data.d.ts +27 -0
- package/dist/entry/root-data.d.ts.map +1 -0
- package/dist/entry/whole-page.d.ts +10 -0
- package/dist/entry/whole-page.d.ts.map +1 -0
- package/dist/errors/api-error.d.ts +117 -0
- package/dist/errors/api-error.d.ts.map +1 -0
- package/dist/errors/api-errors.d.ts +122 -0
- package/dist/errors/api-errors.d.ts.map +1 -0
- package/dist/errors/call-failure.d.ts +45 -0
- package/dist/errors/call-failure.d.ts.map +1 -0
- package/dist/errors/catalogue-check.d.ts +24 -0
- package/dist/errors/catalogue-check.d.ts.map +1 -0
- package/dist/errors/catalogue-read.d.ts +33 -0
- package/dist/errors/catalogue-read.d.ts.map +1 -0
- package/dist/errors/catalogue.d.ts +59 -0
- package/dist/errors/catalogue.d.ts.map +1 -0
- package/dist/errors/code-resolver.d.ts +44 -0
- package/dist/errors/code-resolver.d.ts.map +1 -0
- package/dist/errors/cross-site.d.ts +8 -0
- package/dist/errors/cross-site.d.ts.map +1 -0
- package/dist/errors/describe-refusal.d.ts +6 -0
- package/dist/errors/describe-refusal.d.ts.map +1 -0
- package/dist/errors/describe.d.ts +3 -0
- package/dist/errors/describe.d.ts.map +1 -0
- package/dist/errors/fetcher-result.d.ts +33 -0
- package/dist/errors/fetcher-result.d.ts.map +1 -0
- package/dist/errors/field-placement.d.ts +12 -0
- package/dist/errors/field-placement.d.ts.map +1 -0
- package/dist/errors/form-errors.d.ts +8 -0
- package/dist/errors/form-errors.d.ts.map +1 -0
- package/dist/errors/form-refusal.d.ts +25 -0
- package/dist/errors/form-refusal.d.ts.map +1 -0
- package/dist/errors/index.d.ts +21 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +588 -0
- package/dist/errors/index.js.map +26 -0
- package/dist/errors/json-actions.d.ts +38 -0
- package/dist/errors/json-actions.d.ts.map +1 -0
- package/dist/errors/log.d.ts +8 -0
- package/dist/errors/log.d.ts.map +1 -0
- package/dist/errors/message-values.d.ts +11 -0
- package/dist/errors/message-values.d.ts.map +1 -0
- package/dist/errors/messages.d.ts +63 -0
- package/dist/errors/messages.d.ts.map +1 -0
- package/dist/errors/page-path.d.ts +9 -0
- package/dist/errors/page-path.d.ts.map +1 -0
- package/dist/errors/problem-error.d.ts +50 -0
- package/dist/errors/problem-error.d.ts.map +1 -0
- package/dist/errors/provider.d.ts +20 -0
- package/dist/errors/provider.d.ts.map +1 -0
- package/dist/errors/request-id.d.ts +5 -0
- package/dist/errors/request-id.d.ts.map +1 -0
- package/dist/errors/route-error.d.ts +33 -0
- package/dist/errors/route-error.d.ts.map +1 -0
- package/dist/errors/route-refusal.d.ts +20 -0
- package/dist/errors/route-refusal.d.ts.map +1 -0
- package/dist/errors/same-site.d.ts +49 -0
- package/dist/errors/same-site.d.ts.map +1 -0
- package/dist/errors/section-action.d.ts +46 -0
- package/dist/errors/section-action.d.ts.map +1 -0
- package/dist/errors/standard-schema.d.ts +34 -0
- package/dist/errors/standard-schema.d.ts.map +1 -0
- package/dist/errors/submit-form.d.ts +16 -0
- package/dist/errors/submit-form.d.ts.map +1 -0
- package/dist/errors/upstream-headers.d.ts +18 -0
- package/dist/errors/upstream-headers.d.ts.map +1 -0
- package/dist/errors/use-json-fetcher.d.ts +18 -0
- package/dist/errors/use-json-fetcher.d.ts.map +1 -0
- package/dist/fetcher/auth-refusal.d.ts +29 -0
- package/dist/fetcher/auth-refusal.d.ts.map +1 -0
- package/dist/fetcher/index.d.ts +20 -0
- package/dist/fetcher/index.d.ts.map +1 -0
- package/dist/fetcher/index.js +392 -0
- package/dist/fetcher/index.js.map +21 -0
- package/dist/fetcher/section-form.d.ts +24 -0
- package/dist/fetcher/section-form.d.ts.map +1 -0
- package/dist/fetcher/section-reload.d.ts +17 -0
- package/dist/fetcher/section-reload.d.ts.map +1 -0
- package/dist/fetcher/section-save.d.ts +29 -0
- package/dist/fetcher/section-save.d.ts.map +1 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
- package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-done.d.ts +15 -0
- package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
- package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
- package/dist/fetcher/use-form-refusal.d.ts +20 -0
- package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
- package/dist/fetcher/use-row-save.d.ts +32 -0
- package/dist/fetcher/use-row-save.d.ts.map +1 -0
- package/dist/fetcher/use-section-save.d.ts +46 -0
- package/dist/fetcher/use-section-save.d.ts.map +1 -0
- package/dist/fetcher/use-visible-interval.d.ts +24 -0
- package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
- package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
- package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
- package/dist/health.d.ts +21 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/help/check/check.d.ts +35 -0
- package/dist/help/check/check.d.ts.map +1 -0
- package/dist/help/check/index.d.ts +8 -0
- package/dist/help/check/index.d.ts.map +1 -0
- package/dist/help/check/index.js +17 -0
- package/dist/help/check/index.js.map +9 -0
- package/dist/help/check/routes.d.ts +22 -0
- package/dist/help/check/routes.d.ts.map +1 -0
- package/dist/help/guide.d.ts +33 -0
- package/dist/help/guide.d.ts.map +1 -0
- package/dist/help/index.d.ts +16 -0
- package/dist/help/index.d.ts.map +1 -0
- package/dist/help/index.js +192 -0
- package/dist/help/index.js.map +14 -0
- package/dist/help/load.d.ts +39 -0
- package/dist/help/load.d.ts.map +1 -0
- package/dist/help/panel.d.ts +69 -0
- package/dist/help/panel.d.ts.map +1 -0
- package/dist/help/parse-flow.d.ts +27 -0
- package/dist/help/parse-flow.d.ts.map +1 -0
- package/dist/help/react.d.ts +12 -0
- package/dist/help/react.d.ts.map +1 -0
- package/dist/help/resolve.d.ts +24 -0
- package/dist/help/resolve.d.ts.map +1 -0
- package/dist/help/types.d.ts +50 -0
- package/dist/help/types.d.ts.map +1 -0
- package/dist/help/yaml.d.ts +18 -0
- package/dist/help/yaml.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +14 -0
- package/dist/link/index.d.ts +7 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +16 -0
- package/dist/link/index.js.map +10 -0
- package/dist/link/router-link.d.ts +27 -0
- package/dist/link/router-link.d.ts.map +1 -0
- package/dist/lists/connection-page.d.ts +50 -0
- package/dist/lists/connection-page.d.ts.map +1 -0
- package/dist/lists/index.d.ts +13 -0
- package/dist/lists/index.d.ts.map +1 -0
- package/dist/lists/index.js +205 -0
- package/dist/lists/index.js.map +15 -0
- package/dist/lists/newest-first.d.ts +5 -0
- package/dist/lists/newest-first.d.ts.map +1 -0
- package/dist/lists/nodes-of.d.ts +21 -0
- package/dist/lists/nodes-of.d.ts.map +1 -0
- package/dist/lists/or-failed.d.ts +19 -0
- package/dist/lists/or-failed.d.ts.map +1 -0
- package/dist/lists/use-paged-rows.d.ts +40 -0
- package/dist/lists/use-paged-rows.d.ts.map +1 -0
- package/dist/lists/use-same-route-loading.d.ts +8 -0
- package/dist/lists/use-same-route-loading.d.ts.map +1 -0
- package/dist/lists/use-search-change.d.ts +20 -0
- package/dist/lists/use-search-change.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +105 -0
- package/dist/mcp/index.js.map +11 -0
- package/dist/mcp/mcp-relay.d.ts +58 -0
- package/dist/mcp/mcp-relay.d.ts.map +1 -0
- package/dist/mcp/relay.d.ts +38 -0
- package/dist/mcp/relay.d.ts.map +1 -0
- package/dist/media/client/error.d.ts +29 -0
- package/dist/media/client/error.d.ts.map +1 -0
- package/dist/media/client/index.d.ts +8 -0
- package/dist/media/client/index.d.ts.map +1 -0
- package/dist/media/client/index.js +133 -0
- package/dist/media/client/index.js.map +11 -0
- package/dist/media/client/upload.d.ts +32 -0
- package/dist/media/client/upload.d.ts.map +1 -0
- package/dist/media/forward.d.ts +14 -0
- package/dist/media/forward.d.ts.map +1 -0
- package/dist/media/headers.d.ts +11 -0
- package/dist/media/headers.d.ts.map +1 -0
- package/dist/media/index.d.ts +9 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +396 -0
- package/dist/media/index.js.map +16 -0
- package/dist/media/options.d.ts +114 -0
- package/dist/media/options.d.ts.map +1 -0
- package/dist/media/path.d.ts +12 -0
- package/dist/media/path.d.ts.map +1 -0
- package/dist/media/read.d.ts +11 -0
- package/dist/media/read.d.ts.map +1 -0
- package/dist/media/refusal.d.ts +11 -0
- package/dist/media/refusal.d.ts.map +1 -0
- package/dist/media/respond.d.ts +8 -0
- package/dist/media/respond.d.ts.map +1 -0
- package/dist/media/write.d.ts +13 -0
- package/dist/media/write.d.ts.map +1 -0
- package/dist/navigation/index.d.ts +9 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +48 -0
- package/dist/navigation/index.js.map +11 -0
- package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
- package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
- package/dist/navigation/use-route-transition.d.ts +19 -0
- package/dist/navigation/use-route-transition.d.ts.map +1 -0
- package/dist/nonce.d.ts +16 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/oauth/answer.d.ts +33 -0
- package/dist/oauth/answer.d.ts.map +1 -0
- package/dist/oauth/binding.d.ts +43 -0
- package/dist/oauth/binding.d.ts.map +1 -0
- package/dist/oauth/consent.d.ts +134 -0
- package/dist/oauth/consent.d.ts.map +1 -0
- package/dist/oauth/grants.d.ts +88 -0
- package/dist/oauth/grants.d.ts.map +1 -0
- package/dist/oauth/index.d.ts +16 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +207 -0
- package/dist/oauth/index.js.map +12 -0
- package/dist/oauth/model.d.ts +13 -0
- package/dist/oauth/model.d.ts.map +1 -0
- package/dist/oauth/react/index.d.ts +7 -0
- package/dist/oauth/react/index.d.ts.map +1 -0
- package/dist/oauth/react/index.js +99 -0
- package/dist/oauth/react/index.js.map +10 -0
- package/dist/oauth/react/use-consent.d.ts +52 -0
- package/dist/oauth/react/use-consent.d.ts.map +1 -0
- package/dist/oidc/dpop.d.ts +80 -0
- package/dist/oidc/dpop.d.ts.map +1 -0
- package/dist/oidc/errors.d.ts +16 -0
- package/dist/oidc/errors.d.ts.map +1 -0
- package/dist/oidc/flow.d.ts +59 -0
- package/dist/oidc/flow.d.ts.map +1 -0
- package/dist/oidc/index.d.ts +11 -0
- package/dist/oidc/index.d.ts.map +1 -0
- package/dist/oidc/index.js +742 -0
- package/dist/oidc/index.js.map +15 -0
- package/dist/oidc/oidc.d.ts +132 -0
- package/dist/oidc/oidc.d.ts.map +1 -0
- package/dist/oidc/revoke.d.ts +28 -0
- package/dist/oidc/revoke.d.ts.map +1 -0
- package/dist/oidc/seal.d.ts +20 -0
- package/dist/oidc/seal.d.ts.map +1 -0
- package/dist/pwa/build/build-worker.d.ts +41 -0
- package/dist/pwa/build/build-worker.d.ts.map +1 -0
- package/dist/pwa/build/index.d.ts +9 -0
- package/dist/pwa/build/index.d.ts.map +1 -0
- package/dist/pwa/build/index.js +9 -0
- package/dist/pwa/build/index.js.map +9 -0
- package/dist/pwa/build/precache.d.ts +17 -0
- package/dist/pwa/build/precache.d.ts.map +1 -0
- package/dist/pwa/index.d.ts +16 -0
- package/dist/pwa/index.d.ts.map +1 -0
- package/dist/pwa/index.js +110 -0
- package/dist/pwa/index.js.map +12 -0
- package/dist/pwa/model/caching.d.ts +46 -0
- package/dist/pwa/model/caching.d.ts.map +1 -0
- package/dist/pwa/model/clear-app-caches.d.ts +9 -0
- package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
- package/dist/pwa/model/font-precache.d.ts +15 -0
- package/dist/pwa/model/font-precache.d.ts.map +1 -0
- package/dist/pwa/model/manifest.d.ts +80 -0
- package/dist/pwa/model/manifest.d.ts.map +1 -0
- package/dist/pwa/model/precache-list.d.ts +40 -0
- package/dist/pwa/model/precache-list.d.ts.map +1 -0
- package/dist/pwa/model/registration.d.ts +39 -0
- package/dist/pwa/model/registration.d.ts.map +1 -0
- package/dist/pwa/model/start-service-worker.d.ts +24 -0
- package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
- package/dist/pwa/model/storable.d.ts +8 -0
- package/dist/pwa/model/storable.d.ts.map +1 -0
- package/dist/pwa/model/theme-color.d.ts +20 -0
- package/dist/pwa/model/theme-color.d.ts.map +1 -0
- package/dist/pwa/model/update-notice.d.ts +38 -0
- package/dist/pwa/model/update-notice.d.ts.map +1 -0
- package/dist/pwa/model/worker-contract.d.ts +61 -0
- package/dist/pwa/model/worker-contract.d.ts.map +1 -0
- package/dist/pwa/react/index.d.ts +9 -0
- package/dist/pwa/react/index.d.ts.map +1 -0
- package/dist/pwa/react/index.js +75 -0
- package/dist/pwa/react/index.js.map +13 -0
- package/dist/pwa/react/use-online.d.ts +6 -0
- package/dist/pwa/react/use-online.d.ts.map +1 -0
- package/dist/pwa/react/use-service-worker.d.ts +33 -0
- package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
- package/dist/pwa/react/use-update-notice.d.ts +14 -0
- package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
- package/dist/pwa/server/index.d.ts +7 -0
- package/dist/pwa/server/index.d.ts.map +1 -0
- package/dist/pwa/server/index.js +18 -0
- package/dist/pwa/server/index.js.map +10 -0
- package/dist/pwa/server/no-cache.d.ts +22 -0
- package/dist/pwa/server/no-cache.d.ts.map +1 -0
- package/dist/pwa/worker/index.d.ts +9 -0
- package/dist/pwa/worker/index.d.ts.map +1 -0
- package/dist/pwa/worker/index.js +144 -0
- package/dist/pwa/worker/index.js.map +12 -0
- package/dist/pwa/worker/injected.d.ts +15 -0
- package/dist/pwa/worker/injected.d.ts.map +1 -0
- package/dist/pwa/worker/plan.d.ts +65 -0
- package/dist/pwa/worker/plan.d.ts.map +1 -0
- package/dist/pwa/worker/scope.d.ts +18 -0
- package/dist/pwa/worker/scope.d.ts.map +1 -0
- package/dist/pwa/worker/start-worker.d.ts +17 -0
- package/dist/pwa/worker/start-worker.d.ts.map +1 -0
- package/dist/react-router.d.ts +68 -0
- package/dist/react-router.d.ts.map +1 -0
- package/dist/server.d.ts +127 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/session/codes.d.ts +9 -0
- package/dist/session/codes.d.ts.map +1 -0
- package/dist/session/cookies.d.ts +128 -0
- package/dist/session/cookies.d.ts.map +1 -0
- package/dist/session/flow-types.d.ts +235 -0
- package/dist/session/flow-types.d.ts.map +1 -0
- package/dist/session/guard.d.ts +10 -0
- package/dist/session/guard.d.ts.map +1 -0
- package/dist/session/index.d.ts +22 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +1090 -0
- package/dist/session/index.js.map +27 -0
- package/dist/session/land.d.ts +28 -0
- package/dist/session/land.d.ts.map +1 -0
- package/dist/session/link-json.d.ts +22 -0
- package/dist/session/link-json.d.ts.map +1 -0
- package/dist/session/link-land.d.ts +20 -0
- package/dist/session/link-land.d.ts.map +1 -0
- package/dist/session/link-token.d.ts +24 -0
- package/dist/session/link-token.d.ts.map +1 -0
- package/dist/session/link-types.d.ts +142 -0
- package/dist/session/link-types.d.ts.map +1 -0
- package/dist/session/links.d.ts +14 -0
- package/dist/session/links.d.ts.map +1 -0
- package/dist/session/model/index.d.ts +8 -0
- package/dist/session/model/index.d.ts.map +1 -0
- package/dist/session/model/index.js +35 -0
- package/dist/session/model/index.js.map +9 -0
- package/dist/session/model/link-post.d.ts +35 -0
- package/dist/session/model/link-post.d.ts.map +1 -0
- package/dist/session/model/paths.d.ts +24 -0
- package/dist/session/model/paths.d.ts.map +1 -0
- package/dist/session/model/safe-next.d.ts +15 -0
- package/dist/session/model/safe-next.d.ts.map +1 -0
- package/dist/session/model/second-factor.d.ts +16 -0
- package/dist/session/model/second-factor.d.ts.map +1 -0
- package/dist/session/model/site-path.d.ts +10 -0
- package/dist/session/model/site-path.d.ts.map +1 -0
- package/dist/session/model/step-up-answers.d.ts +45 -0
- package/dist/session/model/step-up-answers.d.ts.map +1 -0
- package/dist/session/model/step-up-props.d.ts +22 -0
- package/dist/session/model/step-up-props.d.ts.map +1 -0
- package/dist/session/model/step-up.d.ts +48 -0
- package/dist/session/model/step-up.d.ts.map +1 -0
- package/dist/session/react/index.d.ts +13 -0
- package/dist/session/react/index.d.ts.map +1 -0
- package/dist/session/react/index.js +196 -0
- package/dist/session/react/index.js.map +14 -0
- package/dist/session/react/step-up/answers.d.ts +9 -0
- package/dist/session/react/step-up/answers.d.ts.map +1 -0
- package/dist/session/react/step-up/dialog-props.d.ts +27 -0
- package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
- package/dist/session/react/step-up/index.d.ts +7 -0
- package/dist/session/react/step-up/index.d.ts.map +1 -0
- package/dist/session/react/step-up/pending-runs.d.ts +21 -0
- package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
- package/dist/session/react/step-up/phase.d.ts +8 -0
- package/dist/session/react/step-up/phase.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up.d.ts +51 -0
- package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
- package/dist/session/react/use-code-field.d.ts +37 -0
- package/dist/session/react/use-code-field.d.ts.map +1 -0
- package/dist/session/react/use-link-fragment.d.ts +22 -0
- package/dist/session/react/use-link-fragment.d.ts.map +1 -0
- package/dist/session/react/use-link-param.d.ts +26 -0
- package/dist/session/react/use-link-param.d.ts.map +1 -0
- package/dist/session/react/use-link-post.d.ts +39 -0
- package/dist/session/react/use-link-post.d.ts.map +1 -0
- package/dist/session/react/use-sign-out.d.ts +46 -0
- package/dist/session/react/use-sign-out.d.ts.map +1 -0
- package/dist/session/second-factor.d.ts +22 -0
- package/dist/session/second-factor.d.ts.map +1 -0
- package/dist/session/serialize.d.ts +42 -0
- package/dist/session/serialize.d.ts.map +1 -0
- package/dist/session/sign-in.d.ts +19 -0
- package/dist/session/sign-in.d.ts.map +1 -0
- package/dist/session/signed.d.ts +44 -0
- package/dist/session/signed.d.ts.map +1 -0
- package/dist/session/social-flow.d.ts +22 -0
- package/dist/session/social-flow.d.ts.map +1 -0
- package/dist/session/social-land.d.ts +31 -0
- package/dist/session/social-land.d.ts.map +1 -0
- package/dist/session/social-types.d.ts +136 -0
- package/dist/session/social-types.d.ts.map +1 -0
- package/dist/session/social.d.ts +32 -0
- package/dist/session/social.d.ts.map +1 -0
- package/dist/session/step-up-codes.d.ts +9 -0
- package/dist/session/step-up-codes.d.ts.map +1 -0
- package/dist/session/step-up-signed-out.d.ts +21 -0
- package/dist/session/step-up-signed-out.d.ts.map +1 -0
- package/dist/session/step-up-types.d.ts +127 -0
- package/dist/session/step-up-types.d.ts.map +1 -0
- package/dist/session/step-up.d.ts +17 -0
- package/dist/session/step-up.d.ts.map +1 -0
- package/dist/session/step.d.ts +22 -0
- package/dist/session/step.d.ts.map +1 -0
- package/dist/session/throttle.d.ts +73 -0
- package/dist/session/throttle.d.ts.map +1 -0
- package/dist/session/timed-wait.d.ts +4 -0
- package/dist/session/timed-wait.d.ts.map +1 -0
- package/dist/session/viewer.d.ts +34 -0
- package/dist/session/viewer.d.ts.map +1 -0
- package/dist/subscription/documents.d.ts +3 -0
- package/dist/subscription/documents.d.ts.map +1 -0
- package/dist/subscription/index.d.ts +7 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +359 -0
- package/dist/subscription/index.js.map +14 -0
- package/dist/subscription/proxy.d.ts +54 -0
- package/dist/subscription/proxy.d.ts.map +1 -0
- package/dist/subscription/react/backoff.d.ts +8 -0
- package/dist/subscription/react/backoff.d.ts.map +1 -0
- package/dist/subscription/react/classify.d.ts +15 -0
- package/dist/subscription/react/classify.d.ts.map +1 -0
- package/dist/subscription/react/controller.d.ts +40 -0
- package/dist/subscription/react/controller.d.ts.map +1 -0
- package/dist/subscription/react/fake-timers.d.ts +8 -0
- package/dist/subscription/react/fake-timers.d.ts.map +1 -0
- package/dist/subscription/react/index.d.ts +15 -0
- package/dist/subscription/react/index.d.ts.map +1 -0
- package/dist/subscription/react/index.js +227 -0
- package/dist/subscription/react/index.js.map +17 -0
- package/dist/subscription/react/reconnect.d.ts +9 -0
- package/dist/subscription/react/reconnect.d.ts.map +1 -0
- package/dist/subscription/react/scheduler.d.ts +13 -0
- package/dist/subscription/react/scheduler.d.ts.map +1 -0
- package/dist/subscription/react/timers.d.ts +7 -0
- package/dist/subscription/react/timers.d.ts.map +1 -0
- package/dist/subscription/react/use-live-subscription.d.ts +36 -0
- package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
- package/dist/subscription/react/versions.d.ts +6 -0
- package/dist/subscription/react/versions.d.ts.map +1 -0
- package/dist/subscription/read.d.ts +17 -0
- package/dist/subscription/read.d.ts.map +1 -0
- package/dist/subscription/refusal.d.ts +11 -0
- package/dist/subscription/refusal.d.ts.map +1 -0
- package/dist/subscription/relay.d.ts +16 -0
- package/dist/subscription/relay.d.ts.map +1 -0
- package/dist/vite/bun.d.ts +21 -0
- package/dist/vite/bun.d.ts.map +1 -0
- package/dist/vite/bundle.d.ts +33 -0
- package/dist/vite/bundle.d.ts.map +1 -0
- package/dist/vite/compress.d.ts +18 -0
- package/dist/vite/compress.d.ts.map +1 -0
- package/dist/vite/config.d.ts +33 -0
- package/dist/vite/config.d.ts.map +1 -0
- package/dist/vite/dev.d.ts +28 -0
- package/dist/vite/dev.d.ts.map +1 -0
- package/dist/vite/entry.d.ts +20 -0
- package/dist/vite/entry.d.ts.map +1 -0
- package/dist/vite/hosts.d.ts +16 -0
- package/dist/vite/hosts.d.ts.map +1 -0
- package/dist/vite/index.d.ts +68 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +635 -0
- package/dist/vite/index.js.map +22 -0
- package/dist/vite/inline.d.ts +18 -0
- package/dist/vite/inline.d.ts.map +1 -0
- package/dist/vite/node.d.ts +16 -0
- package/dist/vite/node.d.ts.map +1 -0
- package/dist/vite/preview.d.ts +8 -0
- package/dist/vite/preview.d.ts.map +1 -0
- package/dist/vite/runtime.d.ts +8 -0
- package/dist/vite/runtime.d.ts.map +1 -0
- package/dist/vite/socket.d.ts +75 -0
- package/dist/vite/socket.d.ts.map +1 -0
- package/dist/vite/worker.d.ts +16 -0
- package/dist/vite/worker.d.ts.map +1 -0
- package/dist/with-alxia.d.ts +36 -0
- package/dist/with-alxia.d.ts.map +1 -0
- package/docs/README.md +42 -0
- package/docs/guide/api-keys.md +216 -0
- package/docs/guide/beside-the-pages.md +201 -0
- package/docs/guide/csp-nonce.md +166 -0
- package/docs/guide/customising-the-server.md +324 -0
- package/docs/guide/deploying.md +102 -0
- package/docs/guide/document.md +334 -0
- package/docs/guide/errors.md +1147 -0
- package/docs/guide/fetcher.md +355 -0
- package/docs/guide/getting-started.md +112 -0
- package/docs/guide/help.md +325 -0
- package/docs/guide/how-it-works.md +274 -0
- package/docs/guide/link.md +32 -0
- package/docs/guide/lists.md +225 -0
- package/docs/guide/mcp.md +173 -0
- package/docs/guide/media.md +273 -0
- package/docs/guide/navigation.md +52 -0
- package/docs/guide/oauth.md +342 -0
- package/docs/guide/oidc.md +262 -0
- package/docs/guide/openapi.md +51 -0
- package/docs/guide/pwa.md +670 -0
- package/docs/guide/session.md +2105 -0
- package/docs/guide/subscriptions.md +211 -0
- package/docs/guide/testing.md +42 -0
- package/docs/guide/typing-the-loaders.md +311 -0
- package/docs/guide.md +82 -0
- package/docs/roadmap.md +474 -0
- package/docs/troubleshooting.md +3837 -0
- package/package.json +301 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pwa/model/registration.ts", "../src/pwa/model/update-notice.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { SERVICE_WORKER_URL, SKIP_WAITING } from './worker-contract';\n\n/** What the registration reads of `navigator.serviceWorker`. */\nexport type ServiceWorkerContainerLike = Pick<\n\tServiceWorkerContainer,\n\t'controller' | 'addEventListener' | 'register'\n>;\n\n/**\n * Calls `onWaiting` with each new version that finished installing while an\n * older one controls the page: the one waiting now, and each found later.\n * A first install controls nothing yet, so it offers nothing.\n */\nexport function watchForUpdates(\n\tregistration: ServiceWorkerRegistration,\n\tcontainer: Pick<ServiceWorkerContainerLike, 'controller'>,\n\tonWaiting: (worker: ServiceWorker) => void,\n): void {\n\tconst offer = (worker: ServiceWorker | null) => {\n\t\tif (worker && container.controller) onWaiting(worker);\n\t};\n\toffer(registration.waiting);\n\tregistration.addEventListener('updatefound', () => {\n\t\tconst installing = registration.installing;\n\t\tinstalling?.addEventListener('statechange', () => {\n\t\t\tif (installing.state === 'installed') offer(installing);\n\t\t});\n\t});\n}\n\n/** Moves this page onto a waiting worker: `apply(worker)`. */\nexport type ApplyUpdate = (\n\tworker: Pick<ServiceWorker, 'postMessage' | 'state'>,\n) => void;\n\n/**\n * The one update path of a page, created once: `apply(worker)` activates\n * the waiting worker and reloads once, when it takes control, so the page\n * runs the version its assets came from.\n *\n * - Several tabs: another tab may have activated the worker already. Its\n * `controllerchange` reached this page before anyone asked, so this page\n * did not reload (a form may be half filled); its \"Reload\" then reloads\n * at once, the worker being active.\n * - Clicked twice, or a `controllerchange` after a direct reload: one\n * reload, never two.\n */\nexport function createUpdater(\n\tcontainer: Pick<\n\t\tServiceWorkerContainerLike,\n\t\t'controller' | 'addEventListener'\n\t>,\n\treload: () => void = () => window.location.reload(),\n): ApplyUpdate {\n\tlet requested = false;\n\tlet reloaded = false;\n\tconst reloadOnce = () => {\n\t\tif (reloaded) return;\n\t\treloaded = true;\n\t\treload();\n\t};\n\tcontainer.addEventListener('controllerchange', () => {\n\t\tif (requested) reloadOnce();\n\t});\n\treturn (worker) => {\n\t\tconst active =\n\t\t\tworker.state === 'activating' ||\n\t\t\tworker.state === 'activated' ||\n\t\t\tcontainer.controller === worker;\n\t\tif (active) return reloadOnce();\n\t\trequested = true;\n\t\tworker.postMessage({ type: SKIP_WAITING });\n\t};\n}\n\n/** Runs `run` once the page has loaded: registering never competes with it. */\nexport function afterLoad(run: () => void): void {\n\tif (document.readyState === 'complete') run();\n\telse window.addEventListener('load', run, { once: true });\n}\n\nexport interface RegisterOptions {\n\t/** The worker's path. `SERVICE_WORKER_URL` by default. */\n\turl?: string;\n\t/** The scope it controls. `'/'` by default. */\n\tscope?: string;\n}\n\nlet updater: ApplyUpdate | undefined;\n\n/**\n * Registers the worker and watches for updates, handing each waiting worker\n * to `onWaiting` with the page's one `apply` (`createUpdater`, made on the\n * first call: one per page). A tab coming back to the foreground checks for\n * an update, as a long-lived page otherwise would only on its next full load.\n */\nexport async function registerServiceWorker(\n\tcontainer: ServiceWorkerContainerLike,\n\tonWaiting: (worker: ServiceWorker, apply: ApplyUpdate) => void,\n\toptions: RegisterOptions = {},\n): Promise<ServiceWorkerRegistration> {\n\tupdater ??= createUpdater(container);\n\tconst apply = updater;\n\tconst registration = await container.register(\n\t\toptions.url ?? SERVICE_WORKER_URL,\n\t\t{ scope: options.scope ?? '/' },\n\t);\n\twatchForUpdates(registration, container, (worker) =>\n\t\tonWaiting(worker, apply),\n\t);\n\tdocument.addEventListener('visibilitychange', () => {\n\t\tif (document.visibilityState === 'visible')\n\t\t\tregistration.update().catch(() => {\n\t\t\t\t// Offline, or the server is down: the next check will tell.\n\t\t\t});\n\t});\n\treturn registration;\n}\n",
|
|
6
|
+
"/**\n * The session's \"Later\": the notice stays hidden until the next visit.\n * `sessionStorage` is per origin, so one key serves every app; a second\n * argument of `createUpdateNotice` names another.\n */\nexport const UPDATE_LATER_KEY = 'alxia.update-later';\n\n/** The part of `Storage` the notice reads and writes. */\nexport type NoticeStorage = {\n\tgetItem(key: string): string | null;\n\tsetItem(key: string, value: string): void;\n};\n\n/** What the notice offers while a new version waits. */\nexport type UpdateNotice = {\n\t/** Moves the page onto the new version: the worker's `apply`. */\n\treload: () => void;\n\t/** Hides the notice until the next visit (the tab's session). */\n\tlater: () => void;\n};\n\n/** What `createUpdateNotice` returns: the shape `useSyncExternalStore` takes. */\nexport interface UpdateNoticeStore {\n\t/** A new version waits: `apply` moves the page onto it. */\n\toffer(apply: () => void): void;\n\t/** The notice to show, if any (the same object until it changes). */\n\tcurrent(): UpdateNotice | undefined;\n\t/** Calls `listener` on each change; returns the function that stops it. */\n\tsubscribe(listener: () => void): () => void;\n}\n\n/**\n * The update notice's state: offered by the worker's registration, read by\n * the banners, hidden for the session by \"Later\". `storage` is the session's\n * (`sessionStorage`), which may be missing or throw (private mode, blocked\n * storage): the notice then hides for this page only. It is a function so\n * that nothing reads the global at load.\n */\nexport function createUpdateNotice(\n\tstorage: () => NoticeStorage | undefined,\n\tkey: string = UPDATE_LATER_KEY,\n): UpdateNoticeStore {\n\tlet reload: (() => void) | undefined;\n\tlet laterThisPage = false;\n\tlet notice: UpdateNotice | undefined;\n\tconst listeners = new Set<() => void>();\n\n\tconst later = () => {\n\t\tlaterThisPage = true;\n\t\ttry {\n\t\t\tstorage()?.setItem(key, '1');\n\t\t} catch {\n\t\t\t// No storage: hidden for this page only.\n\t\t}\n\t\trefresh();\n\t};\n\tconst laterAsked = () => {\n\t\tif (laterThisPage) return true;\n\t\ttry {\n\t\t\treturn storage()?.getItem(key) === '1';\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t};\n\tfunction refresh() {\n\t\tnotice = reload && !laterAsked() ? { reload, later } : undefined;\n\t\tfor (const listener of listeners) listener();\n\t}\n\n\treturn {\n\t\toffer(apply) {\n\t\t\treload = apply;\n\t\t\trefresh();\n\t\t},\n\t\tcurrent: () => notice,\n\t\tsubscribe(listener) {\n\t\t\tlisteners.add(listener);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t};\n\t\t},\n\t};\n}\n\n/** `sessionStorage`, or nothing where there is none (the server). */\nexport const sessionStore = (): NoticeStorage | undefined =>\n\ttypeof sessionStorage === 'undefined' ? undefined : sessionStorage;\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": "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",
|
|
9
|
+
"debugId": "824F7298E795FD3C64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/errors/use-json-fetcher.ts
|
|
2
|
+
import { useFetcher } from "react-router";
|
|
3
|
+
function useJsonFetcher2(key, action) {
|
|
4
|
+
const fetcher = useFetcher(key ? { key } : undefined);
|
|
5
|
+
const post = (body, to = action) => fetcher.submit(body, {
|
|
6
|
+
method: "post",
|
|
7
|
+
encType: "application/json",
|
|
8
|
+
...to ? { action: to } : {}
|
|
9
|
+
});
|
|
10
|
+
return { fetcher, post, busy: fetcher.state !== "idle" };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { useJsonFetcher2 };
|
|
14
|
+
|
|
15
|
+
//# debugId=4A99F5857CB639C064756E2164756E21
|
|
16
|
+
//# sourceMappingURL=index-ajtvyq35.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors/use-json-fetcher.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { type FetcherWithComponents, useFetcher } from 'react-router';\n\n/** What a fetcher can post as JSON. */\nexport type JsonBody = Parameters<FetcherWithComponents<unknown>['submit']>[0];\n\n/**\n * A fetcher posting JSON to its page's action (which reads it with\n * `readJson`, and answers `fetcherResult` or the like): `post` sends a\n * body, `busy` while it is in flight. `key` shares the fetcher between the\n * form that posts and the component that reads the answer; `action` posts to\n * another route's action instead (a resource route's, such as a\n * `notifications/poll`). `post` takes the target of one call as its second\n * argument (a list's rows each post to their own record's action).\n */\nexport function useJsonFetcher<Action, Body extends JsonBody = JsonBody>(\n\tkey?: string,\n\taction?: string,\n): {\n\tfetcher: ReturnType<typeof useFetcher<Action>>;\n\tpost(body: Body, to?: string): Promise<void>;\n\tbusy: boolean;\n} {\n\tconst fetcher = useFetcher<Action>(key ? { key } : undefined);\n\tconst post = (body: Body, to = action) =>\n\t\tfetcher.submit(body, {\n\t\t\tmethod: 'post',\n\t\t\tencType: 'application/json',\n\t\t\t...(to ? { action: to } : {}),\n\t\t});\n\treturn { fetcher, post, busy: fetcher.state !== 'idle' };\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAAA;AAcO,SAAS,eAAwD,CACvE,KACA,QAKC;AAAA,EACD,MAAM,UAAU,WAAmB,MAAM,EAAE,IAAI,IAAI,SAAS;AAAA,EAC5D,MAAM,OAAO,CAAC,MAAY,KAAK,WAC9B,QAAQ,OAAO,MAAM;AAAA,IACpB,QAAQ;AAAA,IACR,SAAS;AAAA,OACL,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;AAAA,EAC5B,CAAC;AAAA,EACF,OAAO,EAAE,SAAS,MAAM,MAAM,QAAQ,UAAU,OAAO;AAAA;",
|
|
8
|
+
"debugId": "4A99F5857CB639C064756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// src/document/inline-script.ts
|
|
2
|
+
import { createElement as createElement2 } from "react";
|
|
3
|
+
|
|
4
|
+
// src/document/nonce.ts
|
|
5
|
+
import {
|
|
6
|
+
createContext,
|
|
7
|
+
createElement,
|
|
8
|
+
useContext
|
|
9
|
+
} from "react";
|
|
10
|
+
var KEY = Symbol.for("@softistx/alxia-react-router:document-nonce@1");
|
|
11
|
+
var registry = globalThis;
|
|
12
|
+
registry[KEY] ??= createContext(undefined);
|
|
13
|
+
var NonceContext = registry[KEY];
|
|
14
|
+
function DocumentNonce2({
|
|
15
|
+
nonce,
|
|
16
|
+
children
|
|
17
|
+
}) {
|
|
18
|
+
return createElement(NonceContext, { value: nonce }, children);
|
|
19
|
+
}
|
|
20
|
+
var HEAD_NONCE = 'head script[nonce], head meta[property="csp-nonce"]';
|
|
21
|
+
var documentNonce;
|
|
22
|
+
function useNonce2() {
|
|
23
|
+
const serverNonce = useContext(NonceContext);
|
|
24
|
+
if (typeof document === "undefined")
|
|
25
|
+
return serverNonce;
|
|
26
|
+
documentNonce ??= (document.querySelector(HEAD_NONCE) ?? document.querySelector("script[nonce]"))?.nonce ?? "";
|
|
27
|
+
return documentNonce || undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/document/inline-script.ts
|
|
31
|
+
var BREAKS_OUT = /<\/script|<!--/i;
|
|
32
|
+
function InlineScript2({ code, nonce }) {
|
|
33
|
+
if (BREAKS_OUT.test(code)) {
|
|
34
|
+
throw new TypeError('InlineScript(): the code contains "</script" or "<!--", which ends or confuses the script element; escape it, such as "<\\/script" inside a string');
|
|
35
|
+
}
|
|
36
|
+
const fromDocument = useNonce2();
|
|
37
|
+
return createElement2("script", {
|
|
38
|
+
nonce: nonce ?? fromDocument,
|
|
39
|
+
dangerouslySetInnerHTML: { __html: code }
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function CspNonceMeta2() {
|
|
43
|
+
return createElement2("meta", {
|
|
44
|
+
property: "csp-nonce",
|
|
45
|
+
nonce: useNonce2()
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// src/document/page-language.ts
|
|
49
|
+
import { useSyncExternalStore } from "react";
|
|
50
|
+
|
|
51
|
+
// src/document/language-store.ts
|
|
52
|
+
function createLanguageStore() {
|
|
53
|
+
const listeners = new Set;
|
|
54
|
+
let chosen;
|
|
55
|
+
return {
|
|
56
|
+
subscribe(listener) {
|
|
57
|
+
listeners.add(listener);
|
|
58
|
+
return () => {
|
|
59
|
+
listeners.delete(listener);
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
getSnapshot: () => chosen,
|
|
63
|
+
choose(language) {
|
|
64
|
+
chosen = language;
|
|
65
|
+
for (const listener of listeners)
|
|
66
|
+
listener();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/document/page-language.ts
|
|
72
|
+
function createPageLanguage2(options) {
|
|
73
|
+
const { languages, fallback } = options;
|
|
74
|
+
if (!languages.includes(fallback)) {
|
|
75
|
+
throw new TypeError(`createPageLanguage(): the fallback "${fallback}" is not one of the languages; got ${JSON.stringify(languages)}.`);
|
|
76
|
+
}
|
|
77
|
+
const isBrowser = options.browser ?? (() => typeof document !== "undefined");
|
|
78
|
+
const store = createLanguageStore();
|
|
79
|
+
let last;
|
|
80
|
+
function pageLanguage(language) {
|
|
81
|
+
const supported = languages.find((known) => known === language);
|
|
82
|
+
if (!isBrowser())
|
|
83
|
+
return supported ?? fallback;
|
|
84
|
+
const current = store.getSnapshot() ?? supported;
|
|
85
|
+
if (current)
|
|
86
|
+
last = current;
|
|
87
|
+
const rendered = languages.find((known) => known === globalThis.document?.documentElement.lang);
|
|
88
|
+
return last ?? rendered ?? fallback;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
pageLanguage,
|
|
92
|
+
metaLanguage(matches) {
|
|
93
|
+
const root = matches[0];
|
|
94
|
+
return pageLanguage(root?.loaderData?.language);
|
|
95
|
+
},
|
|
96
|
+
chooseLanguage: store.choose,
|
|
97
|
+
useChosenLanguage: () => useSyncExternalStore(store.subscribe, store.getSnapshot, () => {
|
|
98
|
+
return;
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// src/document/text-direction.ts
|
|
103
|
+
var RTL = new Set([
|
|
104
|
+
"ar",
|
|
105
|
+
"fa",
|
|
106
|
+
"he",
|
|
107
|
+
"ur",
|
|
108
|
+
"ps",
|
|
109
|
+
"yi",
|
|
110
|
+
"dv",
|
|
111
|
+
"ckb",
|
|
112
|
+
"sd",
|
|
113
|
+
"ug",
|
|
114
|
+
"iw",
|
|
115
|
+
"ji"
|
|
116
|
+
]);
|
|
117
|
+
function textDirection2(language) {
|
|
118
|
+
const base = language.split(/[-_]/, 1)[0]?.toLowerCase() ?? "";
|
|
119
|
+
return RTL.has(base) ? "rtl" : "ltr";
|
|
120
|
+
}
|
|
121
|
+
export { DocumentNonce2, useNonce2, InlineScript2, CspNonceMeta2, createPageLanguage2, textDirection2 };
|
|
122
|
+
|
|
123
|
+
//# debugId=39954FFD4E743FC264756E2164756E21
|
|
124
|
+
//# sourceMappingURL=index-c55hxgr5.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/document/inline-script.ts", "../src/document/nonce.ts", "../src/document/page-language.ts", "../src/document/language-store.ts", "../src/document/text-direction.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { createElement, type ReactElement } from 'react';\nimport { useNonce } from './nonce';\n\nconst BREAKS_OUT = /<\\/script|<!--/i;\n\nexport interface InlineScriptProps {\n\t/**\n\t * The script's text, rendered as it is: never escaped, so a `</script`\n\t * or a `<!--` in it is refused (see `InlineScript`).\n\t */\n\tcode: string;\n\t/** The script's nonce; `useNonce()`'s by default. */\n\tnonce?: string | undefined;\n}\n\n/**\n * An inline `<script>` carrying the page's CSP nonce, on the server and in\n * the browser, so hydration finds the attribute it rendered. The code is a\n * constant of the app (a theme's boot script): never put user input in it.\n * With no nonce anywhere, it renders no `nonce` attribute, and the policy\n * must then allow inline scripts some other way.\n *\n * Throws a `TypeError` when the code holds `</script` or `<!--`, which end or\n * confuse the element whatever the nonce: escape them in a string (`<\\/script`).\n */\nexport function InlineScript({ code, nonce }: InlineScriptProps): ReactElement {\n\tif (BREAKS_OUT.test(code)) {\n\t\tthrow new TypeError(\n\t\t\t'InlineScript(): the code contains \"</script\" or \"<!--\", which ends or confuses the script element; escape it, such as \"<\\\\/script\" inside a string',\n\t\t);\n\t}\n\tconst fromDocument = useNonce();\n\treturn createElement('script', {\n\t\tnonce: nonce ?? fromDocument,\n\t\tdangerouslySetInnerHTML: { __html: code },\n\t});\n}\n\n/**\n * `<meta property=\"csp-nonce\" nonce=\"…\">`: the page's nonce for the scripts\n * and styles a library adds at runtime (a UI kit reads it from the DOM).\n */\nexport function CspNonceMeta(): ReactElement {\n\treturn createElement('meta', {\n\t\tproperty: 'csp-nonce',\n\t\tnonce: useNonce(),\n\t});\n}\n",
|
|
6
|
+
"import {\n\tcreateContext,\n\tcreateElement,\n\ttype ReactNode,\n\tuseContext,\n} from 'react';\n\n/**\n * One context per process, whichever copy of this module asks: a package\n * loaded natively that imports `/document` would otherwise get a second\n * context, and its `useNonce()` would never see the entry's `DocumentNonce`.\n * `/document` imports `react` alone, so the few lines of `src/context.ts`'s\n * singleton are written here. The `@1` suffix is the shape of what is stored\n * under the key: a version that changes it bumps the suffix, never the name.\n */\nconst KEY = Symbol.for('@softistx/alxia-react-router:document-nonce@1');\nconst registry = globalThis as Record<symbol, unknown>;\nregistry[KEY] ??= createContext<string | undefined>(undefined);\nconst NonceContext = registry[KEY] as ReturnType<\n\ttypeof createContext<string | undefined>\n>;\n\nexport interface DocumentNonceProps {\n\t/** This response's CSP nonce: `nonceOf(loadContext)` in the entry. */\n\tnonce: string | undefined;\n\tchildren?: ReactNode | undefined;\n}\n\n/**\n * Gives the server render this response's CSP nonce, for `useNonce()` and\n * the components built on it. The entry wraps the router in it, so every\n * boundary reads the nonce, an error page after an action included (it\n * runs no loader). Never put the nonce in loader data: the browser hides\n * it from the page, and loader data would print it in the hydration script\n * and every `.data` answer.\n */\nexport function DocumentNonce({\n\tnonce,\n\tchildren,\n}: DocumentNonceProps): ReactNode {\n\treturn createElement(NonceContext, { value: nonce }, children);\n}\n\nconst HEAD_NONCE = 'head script[nonce], head meta[property=\"csp-nonce\"]';\n\nlet documentNonce: string | undefined;\n\n/**\n * The page's CSP nonce, for what the root renders: an inline script, and\n * React Router's `<Links>`, `<Scripts>` and `<ScrollRestoration>`. On the\n * server, the one `DocumentNonce` provides. In the browser, the one the\n * document carries: React Router's client knows no nonce, and React would\n * find `nonce` on the server's elements and none in its own (a hydration\n * mismatch). It is read from the DOM property of the first script or\n * `csp-nonce` meta in the `<head>` (the browser hides the attribute, not\n * the property), else of the first `script[nonce]` anywhere, once for the\n * document. That first read is cached per module copy, so a test with a\n * DOM keeps it across tests: reset modules, or render the server path with\n * `DocumentNonce`.\n *\n * \"In the browser\" means a global `document`. A server that installs a DOM\n * shim on `globalThis` takes the browser path and finds no nonce: it must not\n * render this hook that way.\n */\nexport function useNonce(): string | undefined {\n\tconst serverNonce = useContext(NonceContext);\n\tif (typeof document === 'undefined') return serverNonce;\n\tdocumentNonce ??=\n\t\t(\n\t\t\tdocument.querySelector<HTMLElement>(HEAD_NONCE) ??\n\t\t\tdocument.querySelector<HTMLElement>('script[nonce]')\n\t\t)?.nonce ?? '';\n\treturn documentNonce || undefined;\n}\n",
|
|
7
|
+
"import { useSyncExternalStore } from 'react';\nimport { createLanguageStore } from './language-store';\n\nexport interface PageLanguageOptions<L extends string> {\n\t/** The languages the app serves. */\n\treadonly languages: readonly L[];\n\t/** The language of a page whose root data gives none; one of `languages`. */\n\treadonly fallback: NoInfer<L>;\n\t/**\n\t * Whether this is a browser. Default: `typeof document !== 'undefined'`,\n\t * a global `document`: a server with a DOM shim on `globalThis` must pass\n\t * `() => false`, or the instance remembers a language across requests.\n\t */\n\treadonly browser?: (() => boolean) | undefined;\n}\n\nexport interface PageLanguage<L extends string> {\n\t/**\n\t * The page's language from the root loader's `language`. In the browser,\n\t * the one picked with `chooseLanguage` wins, and the last one seen stands\n\t * in when the root's data is gone (a failed navigation takes the root's\n\t * with it): the error page keeps the page's language, not the fallback's.\n\t * On the server it remembers nothing, since one module serves every request.\n\t */\n\tpageLanguage(language: string | undefined): L;\n\t/** The page's language in a route's `meta`, from `matches[0].loaderData.language`. */\n\tmetaLanguage(matches: ReadonlyArray<unknown>): L;\n\t/**\n\t * Records the language picked in a language menu: from then on the page's\n\t * language in the browser, until the next document. Re-renders every\n\t * `useChosenLanguage()`.\n\t */\n\tchooseLanguage(language: L): void;\n\t/** The language picked in this document, if any; re-renders on a new pick. */\n\tuseChosenLanguage(): L | undefined;\n}\n\n/**\n * The page's language for a root route: `<html lang>`, a route's `meta`, and\n * the language menu. An instance, not module state: keep one per app, in a\n * module both the root and the routes import.\n */\nexport function createPageLanguage<const L extends string>(\n\toptions: PageLanguageOptions<L>,\n): PageLanguage<L> {\n\tconst { languages, fallback } = options;\n\tif (!languages.includes(fallback)) {\n\t\tthrow new TypeError(\n\t\t\t`createPageLanguage(): the fallback \"${fallback}\" is not one of the languages; got ${JSON.stringify(languages)}.`,\n\t\t);\n\t}\n\tconst isBrowser = options.browser ?? (() => typeof document !== 'undefined');\n\tconst store = createLanguageStore<L>();\n\tlet last: L | undefined;\n\n\tfunction pageLanguage(language: string | undefined): L {\n\t\tconst supported = languages.find((known) => known === language);\n\t\tif (!isBrowser()) return supported ?? fallback;\n\t\tconst current = store.getSnapshot() ?? supported;\n\t\tif (current) last = current;\n\t\t// The root's data never reached the client (a middleware threw): the server rendered `<html lang>` from the request.\n\t\tconst rendered = languages.find(\n\t\t\t(known) => known === globalThis.document?.documentElement.lang,\n\t\t);\n\t\treturn last ?? rendered ?? fallback;\n\t}\n\n\treturn {\n\t\tpageLanguage,\n\t\tmetaLanguage(matches) {\n\t\t\tconst root = matches[0] as\n\t\t\t\t| { loaderData?: { language?: string } }\n\t\t\t\t| undefined;\n\t\t\treturn pageLanguage(root?.loaderData?.language);\n\t\t},\n\t\tchooseLanguage: store.choose,\n\t\tuseChosenLanguage: () =>\n\t\t\tuseSyncExternalStore(store.subscribe, store.getSnapshot, () => undefined),\n\t};\n}\n",
|
|
8
|
+
"/** The picked language and who listens to it: internal to `createPageLanguage`. */\nexport interface LanguageStore<L extends string> {\n\tsubscribe(listener: () => void): () => void;\n\tgetSnapshot(): L | undefined;\n\tchoose(language: L): void;\n}\n\nexport function createLanguageStore<L extends string>(): LanguageStore<L> {\n\tconst listeners = new Set<() => void>();\n\tlet chosen: L | undefined;\n\treturn {\n\t\tsubscribe(listener) {\n\t\t\tlisteners.add(listener);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t};\n\t\t},\n\t\tgetSnapshot: () => chosen,\n\t\tchoose(language) {\n\t\t\tchosen = language;\n\t\t\tfor (const listener of listeners) listener();\n\t\t},\n\t};\n}\n",
|
|
9
|
+
"/**\n * Base languages written right to left. A fixed list: a language is added\n * here when it needs it.\n */\nconst RTL = new Set([\n\t'ar',\n\t'fa',\n\t'he',\n\t'ur',\n\t'ps',\n\t'yi',\n\t'dv',\n\t'ckb',\n\t'sd',\n\t'ug',\n\t// Legacy codes of Hebrew and Yiddish.\n\t'iw',\n\t'ji',\n]);\n\n/**\n * The `dir` of a language tag: `'rtl'` for a right-to-left base language,\n * `'ltr'` for the rest. The base tag is read whatever its case, so `ar-EG`\n * and `AR` are `'rtl'` and `en-US` is `'ltr'`.\n *\n * Known gap: a script subtag is not read, so `az-Arab` (Azerbaijani in the\n * Arabic script) is `'ltr'`, as `az` is.\n */\nexport function textDirection(language: string): 'ltr' | 'rtl' {\n\tconst base = language.split(/[-_]/, 1)[0]?.toLowerCase() ?? '';\n\treturn RTL.has(base) ? 'rtl' : 'ltr';\n}\n"
|
|
10
|
+
],
|
|
11
|
+
"mappings": "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",
|
|
12
|
+
"debugId": "39954FFD4E743FC264756E2164756E21",
|
|
13
|
+
"names": []
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/errors/upstream-headers.ts
|
|
2
|
+
var UNSAFE = /[\r\n\0]/;
|
|
3
|
+
function usableToken(token) {
|
|
4
|
+
return token && !UNSAFE.test(token) ? token : undefined;
|
|
5
|
+
}
|
|
6
|
+
async function extraHeaders(headers, request, args) {
|
|
7
|
+
const values = typeof headers === "function" ? await headers(request, args) : headers;
|
|
8
|
+
const out = new Headers;
|
|
9
|
+
for (const [name, value] of values instanceof Headers ? values.entries() : Object.entries(values ?? {})) {
|
|
10
|
+
if (value !== null && value !== undefined)
|
|
11
|
+
out.set(name, value);
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { usableToken, extraHeaders };
|
|
17
|
+
|
|
18
|
+
//# debugId=7EEB9310B0782C2164756E2164756E21
|
|
19
|
+
//# sourceMappingURL=index-d42p3mdp.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors/upstream-headers.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * What the BFF relays (`/subscription`, `/media`) share to build the headers\n * they send to the API: the app's extra headers, fixed or per request, with\n * a `null` or `undefined` value left out, and the session token guard. It\n * reads values only and imports nothing, like `cross-site.ts`, so each relay\n * stays import-free.\n */\n\n/** Extra headers as an app writes them: a record or a `Headers`. */\nexport type HeaderValues = Record<string, string | null | undefined> | Headers;\n\n/** A token that cannot be put in a header line is no token. */\nconst UNSAFE = /[\\r\\n\\0]/;\n\n/** The token when a header can hold it, else `undefined`. */\nexport function usableToken(\n\ttoken: string | null | undefined,\n): string | undefined {\n\treturn token && !UNSAFE.test(token) ? token : undefined;\n}\n\n/**\n * The app's `headers` option as a `Headers`: a function is called with the\n * request and the route's arguments. It throws when a name or a value is not\n * valid or when the function throws; the caller answers that.\n */\nexport async function extraHeaders<Args>(\n\theaders:\n\t\t| HeaderValues\n\t\t| ((request: Request, args: Args) => HeaderValues | Promise<HeaderValues>)\n\t\t| undefined,\n\trequest: Request,\n\targs: Args,\n): Promise<Headers> {\n\tconst values =\n\t\ttypeof headers === 'function' ? await headers(request, args) : headers;\n\tconst out = new Headers();\n\tfor (const [name, value] of values instanceof Headers\n\t\t? values.entries()\n\t\t: Object.entries(values ?? {})) {\n\t\tif (value !== null && value !== undefined) out.set(name, value);\n\t}\n\treturn out;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAYA,IAAM,SAAS;AAGR,SAAS,WAAW,CAC1B,OACqB;AAAA,EACrB,OAAO,SAAS,CAAC,OAAO,KAAK,KAAK,IAAI,QAAQ;AAAA;AAQxC,eAAe,YAAkB,CACvC,SAIA,SACA,MACmB;AAAA,EACnB,MAAM,SACL,OAAO,YAAY,aAAa,MAAM,QAAQ,SAAS,IAAI,IAAI;AAAA,EAChE,MAAM,MAAM,IAAI;AAAA,EAChB,YAAY,MAAM,UAAU,kBAAkB,UAC3C,OAAO,QAAQ,IACf,OAAO,QAAQ,UAAU,CAAC,CAAC,GAAG;AAAA,IAChC,IAAI,UAAU,QAAQ,UAAU;AAAA,MAAW,IAAI,IAAI,MAAM,KAAK;AAAA,EAC/D;AAAA,EACA,OAAO;AAAA;",
|
|
8
|
+
"debugId": "7EEB9310B0782C2164756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/context.ts
|
|
2
|
+
import { createContext, RouterContextProvider } from "react-router";
|
|
3
|
+
function singleton(name, make) {
|
|
4
|
+
const registry = globalThis;
|
|
5
|
+
const key = Symbol.for(`@softistx/alxia-react-router:${name}@1`);
|
|
6
|
+
registry[key] ??= make();
|
|
7
|
+
return registry[key];
|
|
8
|
+
}
|
|
9
|
+
var shared = singleton("context", () => {
|
|
10
|
+
const missing = Symbol("alxia context missing");
|
|
11
|
+
return { missing, context: createContext(missing) };
|
|
12
|
+
});
|
|
13
|
+
var MISSING = shared.missing;
|
|
14
|
+
var alxiaContext2 = shared.context;
|
|
15
|
+
function alxiaOf2(context) {
|
|
16
|
+
const value = context.get(alxiaContext2);
|
|
17
|
+
if (value === MISSING) {
|
|
18
|
+
throw new Error("alxiaOf(): this request has no alxia context. Serve the React Router app through alxia: add alxia() from @softistx/alxia-react-router/vite to vite.config.ts's plugins, or, with a server of your own, serve the build through reactRouter() from @softistx/alxia-react-router.");
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(RouterContextProvider.prototype, "alxia", {
|
|
23
|
+
configurable: true,
|
|
24
|
+
enumerable: false,
|
|
25
|
+
get() {
|
|
26
|
+
return alxiaOf2(this);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// src/nonce.ts
|
|
31
|
+
function nonceOf2(context) {
|
|
32
|
+
const value = context.get(alxiaContext2);
|
|
33
|
+
if (typeof value !== "object" || value === null || !("nonce" in value)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
return typeof value.nonce === "string" ? value.nonce : undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { alxiaContext2, alxiaOf2, nonceOf2 };
|
|
40
|
+
|
|
41
|
+
//# debugId=73039ED2C247516C64756E2164756E21
|
|
42
|
+
//# sourceMappingURL=index-gac44rs5.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/context.ts", "../src/nonce.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The key under which `reactRouter()` hands every loader, action and\n * middleware the request's alxia context, and the typed way to read it.\n */\nimport type {\n\tAlxia,\n\tAnyAlxia,\n\tContextOf,\n\tRegisteredBase,\n} from '@softistx/alxia';\nimport { createContext, RouterContextProvider } from 'react-router';\nimport type { ReactRouterServer } from './server';\n\n/**\n * One value per process, whichever copy of this module asks: the server\n * build bundles `/entry` and the chunk it shares with `.` (see\n * `vite/inline.ts`), and the server imports `.` outside the bundle.\n *\n * The key is shared across versions of this package. Its name ends in a\n * shape version (`@1`): a version that changes what is stored under it bumps\n * the suffix, so two copies of different shapes never read each other's.\n */\nfunction singleton<T>(name: string, make: () => T): T {\n\tconst registry = globalThis as Record<symbol, unknown>;\n\tconst key = Symbol.for(`@softistx/alxia-react-router:${name}@1`);\n\tregistry[key] ??= make();\n\treturn registry[key] as T;\n}\n\n/**\n * The key `reactRouter()` sets on React Router's context provider, on every\n * request, to what alxia's middlewares built for it, and its default, the\n * \"missing\" sentinel no catch-all replaced. Both are one pair per process,\n * so that a second copy's `alxiaOf` compares with the sentinel the key holds.\n * It lives in this package, so it is one object whichever way the server was\n * built or loaded: a key made in the app's own `app/` folder is copied into\n * React Router's build, and the server that imports it separately sets a\n * different one.\n */\nconst shared = singleton('context', () => {\n\t// `as never` gives the `unique symbol` type without a `declare const`.\n\tconst missing: unique symbol = Symbol('alxia context missing') as never;\n\treturn { missing, context: createContext<unknown>(missing) };\n});\nconst MISSING = shared.missing;\nexport const alxiaContext = shared.context;\n\n/**\n * Names the server whose context `alxiaOf(context)` reads when given no\n * type argument. One React Router build has one server, so it may be\n * declared once, beside it:\n *\n * ```ts\n * // app/server.ts\n * const server = createServer({ configure: (app) => app.use(session) });\n * export default server;\n *\n * declare module '@softistx/alxia-react-router' {\n * interface Register {\n * server: typeof server;\n * }\n * }\n * ```\n *\n * Unregistered here, `alxiaOf(context)` reads the app `@softistx/alxia`'s own\n * `Register` names as its `context`, and `BaseContext` when neither is\n * declared. When both are, this one wins: the server's app is the whole\n * app the pages run behind, the base's context and all `configure` adds.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: an app augments it\nexport interface Register {}\n\n/** The app a server makes, or the app itself. */\nexport type AppOf<Server> =\n\tServer extends ReactRouterServer<infer App> ? App : Server;\n\n/**\n * What `Register` names when it is neither a server nor an app — the\n * module, say, rather than its default export: an app whose context has\n * nothing but this key, so that reading anything of it is a compile error.\n */\nexport type InvalidRegister = Alxia<\n\t{\n\t\treadonly 'Register.server must be typeof server, the default export of createServer()': never;\n\t},\n\t''\n>;\n\n/**\n * The app `alxiaOf` reads for a `Register` interface: its server's, or\n * `InvalidRegister`; with no server, `Core`, the app `@softistx/alxia`'s\n * `Register` names (a fresh one when it names none).\n */\nexport type RegisteredOf<\n\tR,\n\tCore extends AnyAlxia = RegisteredBase,\n> = R extends {\n\treadonly server: infer Server;\n}\n\t? Server extends AnyAlxia | ReactRouterServer<AnyAlxia>\n\t\t? AppOf<Server>\n\t\t: InvalidRegister\n\t: Core;\n\n/** What `alxiaOf` reads with no type argument: the registered server's app, else core's registered app, else a fresh one. */\nexport type RegisteredApp = RegisteredOf<Register>;\n\n/**\n * What alxia's middlewares built for this request, read in a loader, an action or\n * a middleware, typed by the app: the server `Register` names, or the one\n * given as the type argument — `typeof server`, or an app *before* the\n * catch-all. With neither, the app `@softistx/alxia`'s `Register` names, and\n * `BaseContext` when nothing is registered.\n *\n * ```ts\n * export async function loader({ context }: Route.LoaderArgs) {\n * const { user, log } = alxiaOf(context);\n * }\n * ```\n *\n * Throws when the request did not come through `reactRouter()`: under\n * `react-router dev` without the plugin, or a test that calls a loader\n * directly.\n */\nexport function alxiaOf<\n\tApp extends AnyAlxia | ReactRouterServer<AnyAlxia> = RegisteredApp,\n>(context: ProviderLike): AlxiaContextOf<App> {\n\tconst value = context.get(alxiaContext);\n\tif (value === MISSING) {\n\t\tthrow new Error(\n\t\t\t\"alxiaOf(): this request has no alxia context. Serve the React Router app through alxia: add alxia() from @softistx/alxia-react-router/vite to vite.config.ts's plugins, or, with a server of your own, serve the build through reactRouter() from @softistx/alxia-react-router.\",\n\t\t);\n\t}\n\treturn value as AlxiaContextOf<App>;\n}\n\n/**\n * What `alxiaOf` and `nonceOf` read of a provider: its `get`. Not the whole\n * class, which this package gives an `alxia`: the generated route types'\n * `context` is another declaration of it, without one, and must still pass.\n */\nexport type ProviderLike = Pick<Readonly<RouterContextProvider>, 'get'>;\n\n/** What `alxiaOf<App>(context)` returns, and `context.alxia` is for the registered app. */\nexport type AlxiaContextOf<\n\tApp extends AnyAlxia | ReactRouterServer<AnyAlxia> = RegisteredApp,\n> = ContextOf<AppOf<App>> & {\n\t/** The catch-all's route, which every request reaching React Router matched. */\n\treadonly route: string;\n};\n\ndeclare module 'react-router' {\n\tinterface RouterContextProvider {\n\t\t/**\n\t\t * What alxia's middlewares built for this request — `alxiaOf(context)`,\n\t\t * typed by the app `Register` names (`BaseContext` with none):\n\t\t *\n\t\t * ```ts\n\t\t * export async function loader({ context }: LoaderFunctionArgs) {\n\t\t * const { user, server } = context.alxia;\n\t\t * }\n\t\t * ```\n\t\t *\n\t\t * Typed with `react-router`'s own argument types. The generated\n\t\t * `Route.LoaderArgs` reads a second declaration of this class (its\n\t\t * `./internal` types point at react-router's development build), which\n\t\t * no augmentation reaches: read `alxiaOf(context)` there. Throws as\n\t\t * `alxiaOf` does on a request that did not come through\n\t\t * `reactRouter()`. Server-side only: a `clientLoader` has none.\n\t\t */\n\t\treadonly alxia: AlxiaContextOf;\n\t}\n}\n\n// A getter on the prototype rather than a value set on each provider: it\n// reads `alxiaContext`, so it holds exactly when that key is set — a\n// provider React Router copies keeps it — and on a provider no\n// `reactRouter()` filled, a test's, it throws `alxiaOf`'s error rather than\n// reading `undefined`.\nObject.defineProperty(RouterContextProvider.prototype, 'alxia', {\n\tconfigurable: true,\n\tenumerable: false,\n\tget(this: Readonly<RouterContextProvider>) {\n\t\treturn alxiaOf(this);\n\t},\n});\n",
|
|
6
|
+
"/** `nonceOf`: the request's CSP nonce, read from alxia's context if a middleware set one. */\nimport { alxiaContext, type ProviderLike } from './context';\n\n/**\n * This request's CSP nonce, for `entry.server.tsx`: the `nonce` alxia's\n * middlewares put on the context — `secureHeaders({ nonce: true })` from\n * `@softistx/alxia-secure-headers`, or a `derive` of your own — or `undefined` when\n * none did, or when the request did not come through alxia. It reads the\n * key if present: neither package depends on the other.\n *\n * ```tsx\n * const nonce = nonceOf(loadContext);\n * <ServerRouter context={routerContext} url={request.url} nonce={nonce} />\n * ```\n */\nexport function nonceOf(context: ProviderLike): string | undefined {\n\tconst value = context.get(alxiaContext);\n\tif (typeof value !== 'object' || value === null || !('nonce' in value)) {\n\t\treturn undefined;\n\t}\n\treturn typeof value.nonce === 'string' ? value.nonce : undefined;\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";AAUA;AAYA,SAAS,SAAY,CAAC,MAAc,MAAkB;AAAA,EACrD,MAAM,WAAW;AAAA,EACjB,MAAM,MAAM,OAAO,IAAI,gCAAgC,QAAQ;AAAA,EAC/D,SAAS,SAAS,KAAK;AAAA,EACvB,OAAO,SAAS;AAAA;AAajB,IAAM,SAAS,UAAU,WAAW,MAAM;AAAA,EAEzC,MAAM,UAAyB,OAAO,uBAAuB;AAAA,EAC7D,OAAO,EAAE,SAAS,SAAS,cAAuB,OAAO,EAAE;AAAA,CAC3D;AACD,IAAM,UAAU,OAAO;AAChB,IAAM,gBAAe,OAAO;AA+E5B,SAAS,QAEf,CAAC,SAA4C;AAAA,EAC7C,MAAM,QAAQ,QAAQ,IAAI,aAAY;AAAA,EACtC,IAAI,UAAU,SAAS;AAAA,IACtB,MAAM,IAAI,MACT,iRACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA;AA8CR,OAAO,eAAe,sBAAsB,WAAW,SAAS;AAAA,EAC/D,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,GAAG,GAAwC;AAAA,IAC1C,OAAO,SAAQ,IAAI;AAAA;AAErB,CAAC;;;AC1KM,SAAS,QAAO,CAAC,SAA2C;AAAA,EAClE,MAAM,QAAQ,QAAQ,IAAI,aAAY;AAAA,EACtC,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,WAAW,QAAQ;AAAA,IACvE;AAAA,EACD;AAAA,EACA,OAAO,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ;AAAA;",
|
|
9
|
+
"debugId": "73039ED2C247516C64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/oauth/binding.ts
|
|
2
|
+
var CONSENT_PATH2 = "/oauth/consent";
|
|
3
|
+
var CONSENT_COOKIE2 = "__Host-alxia_oauth_request";
|
|
4
|
+
var CONSENT_COOKIE_PLAIN2 = "alxia_oauth_request";
|
|
5
|
+
var CONSENT_REQUEST_HEADER2 = "x-alxia-oauth-request";
|
|
6
|
+
var CONSENT_COOKIE_MAX_AGE2 = 60 * 60;
|
|
7
|
+
var REQUEST_ID = /^[\w-]{1,200}$/;
|
|
8
|
+
var consentCookieName2 = (secure) => secure ? CONSENT_COOKIE2 : CONSENT_COOKIE_PLAIN2;
|
|
9
|
+
function consentRequestOf2(response, origin, path = CONSENT_PATH2) {
|
|
10
|
+
if (response.status < 300 || response.status >= 400)
|
|
11
|
+
return;
|
|
12
|
+
const location = response.headers.get("location");
|
|
13
|
+
if (!location)
|
|
14
|
+
return;
|
|
15
|
+
let url;
|
|
16
|
+
try {
|
|
17
|
+
url = new URL(location, origin);
|
|
18
|
+
} catch {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (url.origin !== new URL(origin).origin || url.pathname !== path) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const id = url.searchParams.get("request_id") ?? "";
|
|
25
|
+
return REQUEST_ID.test(id) ? id : undefined;
|
|
26
|
+
}
|
|
27
|
+
function consentBindingCookie2(id, secure) {
|
|
28
|
+
return [
|
|
29
|
+
`${consentCookieName2(secure)}=${id}`,
|
|
30
|
+
"Path=/",
|
|
31
|
+
`Max-Age=${CONSENT_COOKIE_MAX_AGE2}`,
|
|
32
|
+
"HttpOnly",
|
|
33
|
+
"SameSite=Lax",
|
|
34
|
+
...secure ? ["Secure"] : []
|
|
35
|
+
].join("; ");
|
|
36
|
+
}
|
|
37
|
+
function boundConsentRequest2(request, origin) {
|
|
38
|
+
const wanted = consentCookieName2(new URL(origin ?? request.url).protocol === "https:");
|
|
39
|
+
for (const part of (request.headers.get("cookie") ?? "").split(";")) {
|
|
40
|
+
const at = part.indexOf("=");
|
|
41
|
+
if (at < 0)
|
|
42
|
+
continue;
|
|
43
|
+
if (part.slice(0, at).trim() !== wanted)
|
|
44
|
+
continue;
|
|
45
|
+
const value = part.slice(at + 1).trim();
|
|
46
|
+
if (REQUEST_ID.test(value))
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
function consentBindingOf2(request, header = CONSENT_REQUEST_HEADER2, origin) {
|
|
52
|
+
const requestId = boundConsentRequest2(request, origin);
|
|
53
|
+
return {
|
|
54
|
+
requestId,
|
|
55
|
+
headers: requestId === undefined ? {} : { [header]: requestId }
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { CONSENT_PATH2, CONSENT_COOKIE2, CONSENT_COOKIE_PLAIN2, CONSENT_REQUEST_HEADER2, CONSENT_COOKIE_MAX_AGE2, consentCookieName2, consentRequestOf2, consentBindingCookie2, boundConsentRequest2, consentBindingOf2 };
|
|
60
|
+
|
|
61
|
+
//# debugId=EBB4BC11850F84C664756E2164756E21
|
|
62
|
+
//# sourceMappingURL=index-j4ktpcke.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/oauth/binding.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Binding a pending consent request to the browser that opened it. The\n * relay (`@softistx/alxia-react-router/mcp`) sets the cookie when the API's\n * `/oauth/authorize` sends the browser to the consent page; the consent route\n * (`oauthConsent`) reads it. No import: both entry points share this file.\n */\n\n/** The app's consent page, where the API's `/oauth/authorize` sends the browser. */\nexport const CONSENT_PATH = '/oauth/consent';\n\n/** The cookie over HTTPS (`__Host-`: Secure, Path=/, no Domain). */\nexport const CONSENT_COOKIE = '__Host-alxia_oauth_request';\n\n/** The cookie over plain HTTP (a development server). */\nexport const CONSENT_COOKIE_PLAIN = 'alxia_oauth_request';\n\n/** The header `oauthConsent` hands its `caller` to name the request this browser opened. */\nexport const CONSENT_REQUEST_HEADER = 'x-alxia-oauth-request';\n\n/** Seconds the cookie lives: a pending request is short-lived. */\nexport const CONSENT_COOKIE_MAX_AGE = 60 * 60;\n\n/** What `oauthConsent` hands the `caller` of its options. */\nexport interface ConsentBinding {\n\t/** The request this browser opened, or `undefined`. */\n\treadonly requestId: string | undefined;\n\t/** `{ [header]: requestId }` to forward to the API, empty without a binding. */\n\treadonly headers: Readonly<Record<string, string>>;\n}\n\n// A request id as janus-oauth makes one; anything else is never echoed in a cookie.\nconst REQUEST_ID = /^[\\w-]{1,200}$/;\n\n/** The cookie's name: `__Host-` over HTTPS, a plain one over plain HTTP. */\nexport const consentCookieName = (secure: boolean): string =>\n\tsecure ? CONSENT_COOKIE : CONSENT_COOKIE_PLAIN;\n\n/**\n * The pending request an API answer sends the browser to consent to, or\n * `undefined`. Only a 3xx to `origin`'s own `path` counts (an absolute\n * location or a relative one): an error redirect to a client's `redirect_uri`\n * that ends in `/oauth/consent` names nothing.\n */\nexport function consentRequestOf(\n\tresponse: Response,\n\torigin: string,\n\tpath: string = CONSENT_PATH,\n): string | undefined {\n\tif (response.status < 300 || response.status >= 400) return undefined;\n\tconst location = response.headers.get('location');\n\tif (!location) return undefined;\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(location, origin);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (url.origin !== new URL(origin).origin || url.pathname !== path) {\n\t\treturn undefined;\n\t}\n\tconst id = url.searchParams.get('request_id') ?? '';\n\treturn REQUEST_ID.test(id) ? id : undefined;\n}\n\n/** The `Set-Cookie` value binding request `id` to this browser. */\nexport function consentBindingCookie(id: string, secure: boolean): string {\n\treturn [\n\t\t`${consentCookieName(secure)}=${id}`,\n\t\t'Path=/',\n\t\t`Max-Age=${CONSENT_COOKIE_MAX_AGE}`,\n\t\t'HttpOnly',\n\t\t'SameSite=Lax',\n\t\t...(secure ? ['Secure'] : []),\n\t].join('; ');\n}\n\n/**\n * The request this browser opened, or `undefined`: the binding cookie named\n * by the scheme of `origin` when given (the one the relay wrote it with),\n * else by the request's own scheme.\n */\nexport function boundConsentRequest(\n\trequest: Request,\n\torigin?: string,\n): string | undefined {\n\t// The scheme of `origin` (else of the request) decides. Over HTTPS only the `__Host-` cookie, which a sibling subdomain or a\n\t// plain-HTTP attacker cannot plant; the plain name only over plain HTTP.\n\tconst wanted = consentCookieName(\n\t\tnew URL(origin ?? request.url).protocol === 'https:',\n\t);\n\tfor (const part of (request.headers.get('cookie') ?? '').split(';')) {\n\t\tconst at = part.indexOf('=');\n\t\tif (at < 0) continue;\n\t\tif (part.slice(0, at).trim() !== wanted) continue;\n\t\tconst value = part.slice(at + 1).trim();\n\t\tif (REQUEST_ID.test(value)) return value;\n\t}\n\treturn undefined;\n}\n\n/** The binding of `request`: the id its cookie names, and that id in `header`. */\nexport function consentBindingOf(\n\trequest: Request,\n\theader: string = CONSENT_REQUEST_HEADER,\n\torigin?: string,\n): ConsentBinding {\n\tconst requestId = boundConsentRequest(request, origin);\n\treturn {\n\t\trequestId,\n\t\theaders: requestId === undefined ? {} : { [header]: requestId },\n\t};\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAQO,IAAM,gBAAe;AAGrB,IAAM,kBAAiB;AAGvB,IAAM,wBAAuB;AAG7B,IAAM,0BAAyB;AAG/B,IAAM,0BAAyB,KAAK;AAW3C,IAAM,aAAa;AAGZ,IAAM,qBAAoB,CAAC,WACjC,SAAS,kBAAiB;AAQpB,SAAS,iBAAgB,CAC/B,UACA,QACA,OAAe,eACM;AAAA,EACrB,IAAI,SAAS,SAAS,OAAO,SAAS,UAAU;AAAA,IAAK;AAAA,EACrD,MAAM,WAAW,SAAS,QAAQ,IAAI,UAAU;AAAA,EAChD,IAAI,CAAC;AAAA,IAAU;AAAA,EACf,IAAI;AAAA,EACJ,IAAI;AAAA,IACH,MAAM,IAAI,IAAI,UAAU,MAAM;AAAA,IAC7B,MAAM;AAAA,IACP;AAAA;AAAA,EAED,IAAI,IAAI,WAAW,IAAI,IAAI,MAAM,EAAE,UAAU,IAAI,aAAa,MAAM;AAAA,IACnE;AAAA,EACD;AAAA,EACA,MAAM,KAAK,IAAI,aAAa,IAAI,YAAY,KAAK;AAAA,EACjD,OAAO,WAAW,KAAK,EAAE,IAAI,KAAK;AAAA;AAI5B,SAAS,qBAAoB,CAAC,IAAY,QAAyB;AAAA,EACzE,OAAO;AAAA,IACN,GAAG,mBAAkB,MAAM,KAAK;AAAA,IAChC;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,GAAI,SAAS,CAAC,QAAQ,IAAI,CAAC;AAAA,EAC5B,EAAE,KAAK,IAAI;AAAA;AAQL,SAAS,oBAAmB,CAClC,SACA,QACqB;AAAA,EAGrB,MAAM,SAAS,mBACd,IAAI,IAAI,UAAU,QAAQ,GAAG,EAAE,aAAa,QAC7C;AAAA,EACA,WAAW,SAAS,QAAQ,QAAQ,IAAI,QAAQ,KAAK,IAAI,MAAM,GAAG,GAAG;AAAA,IACpE,MAAM,KAAK,KAAK,QAAQ,GAAG;AAAA,IAC3B,IAAI,KAAK;AAAA,MAAG;AAAA,IACZ,IAAI,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK,MAAM;AAAA,MAAQ;AAAA,IACzC,MAAM,QAAQ,KAAK,MAAM,KAAK,CAAC,EAAE,KAAK;AAAA,IACtC,IAAI,WAAW,KAAK,KAAK;AAAA,MAAG,OAAO;AAAA,EACpC;AAAA,EACA;AAAA;AAIM,SAAS,iBAAgB,CAC/B,SACA,SAAiB,yBACjB,QACiB;AAAA,EACjB,MAAM,YAAY,qBAAoB,SAAS,MAAM;AAAA,EACrD,OAAO;AAAA,IACN;AAAA,IACA,SAAS,cAAc,YAAY,CAAC,IAAI,GAAG,SAAS,UAAU;AAAA,EAC/D;AAAA;",
|
|
8
|
+
"debugId": "EBB4BC11850F84C664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/errors/cross-site.ts
|
|
2
|
+
function isCrossSite(request, origin) {
|
|
3
|
+
const own = origin ?? new URL(request.url).origin;
|
|
4
|
+
const from = request.headers.get("origin");
|
|
5
|
+
const site = request.headers.get("sec-fetch-site");
|
|
6
|
+
return Boolean(from && from !== own || site && site !== "same-origin" && site !== "none");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { isCrossSite };
|
|
10
|
+
|
|
11
|
+
//# debugId=58B4D73CADC8EFA564756E2164756E21
|
|
12
|
+
//# sourceMappingURL=index-mscfme4r.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors/cross-site.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Whether a request comes from another site: an `Origin` that is not\n * `origin` (the app's own, else the request's), or a `Sec-Fetch-Site` that is\n * neither `same-origin` nor `none`. It reads headers only and imports nothing,\n * so `/subscription` can share it with `/errors` and stay import-free.\n */\nexport function isCrossSite(request: Request, origin?: string): boolean {\n\tconst own = origin ?? new URL(request.url).origin;\n\tconst from = request.headers.get('origin');\n\tconst site = request.headers.get('sec-fetch-site');\n\treturn Boolean(\n\t\t(from && from !== own) ||\n\t\t\t(site && site !== 'same-origin' && site !== 'none'),\n\t);\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAMO,SAAS,WAAW,CAAC,SAAkB,QAA0B;AAAA,EACvE,MAAM,MAAM,UAAU,IAAI,IAAI,QAAQ,GAAG,EAAE;AAAA,EAC3C,MAAM,OAAO,QAAQ,QAAQ,IAAI,QAAQ;AAAA,EACzC,MAAM,OAAO,QAAQ,QAAQ,IAAI,gBAAgB;AAAA,EACjD,OAAO,QACL,QAAQ,SAAS,OAChB,QAAQ,SAAS,iBAAiB,SAAS,MAC9C;AAAA;",
|
|
8
|
+
"debugId": "58B4D73CADC8EFA564756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isApiErrorLike2,
|
|
3
|
+
routeError2
|
|
4
|
+
} from "./index-wyypkfdv.js";
|
|
5
|
+
|
|
6
|
+
// src/errors/fetcher-result.ts
|
|
7
|
+
import { data } from "react-router";
|
|
8
|
+
function fetcherRefusal(errors, error, language, route) {
|
|
9
|
+
const refusal = isApiErrorLike2(error) && error.status === 401 ? undefined : errors.apiRefusal(error, language);
|
|
10
|
+
if (!refusal)
|
|
11
|
+
throw routeError2(error, route);
|
|
12
|
+
return refusal;
|
|
13
|
+
}
|
|
14
|
+
async function fetcherResult(errors, language, about, run, options) {
|
|
15
|
+
try {
|
|
16
|
+
return { ok: true, ...about, ...await run() };
|
|
17
|
+
} catch (error) {
|
|
18
|
+
const { message, status } = fetcherRefusal(errors, error, language, options);
|
|
19
|
+
return data({
|
|
20
|
+
ok: false,
|
|
21
|
+
...about,
|
|
22
|
+
error: (isApiErrorLike2(error) ? options?.reword?.(error) : undefined) ?? message
|
|
23
|
+
}, { status });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { fetcherRefusal, fetcherResult };
|
|
28
|
+
|
|
29
|
+
//# debugId=D74C6D167773F20264756E2164756E21
|
|
30
|
+
//# sourceMappingURL=index-pghmb2dm.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors/fetcher-result.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { data } from 'react-router';\nimport { type ApiErrorLike, isApiErrorLike } from './api-error';\nimport type { ApiErrors, ApiRefusal } from './api-errors';\nimport { type RouteErrorOptions, routeError } from './route-error';\n\n/**\n * A fetcher's refusal: the API's (`apiRefusal`), an unreachable API's too,\n * so the page stays where it was. A 401 (the session caller redirects\n * first) or any other failure is thrown, for the error page.\n */\nexport function fetcherRefusal<L extends string>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal'>,\n\terror: unknown,\n\tlanguage: L,\n\troute?: RouteErrorOptions,\n): ApiRefusal {\n\tconst refusal =\n\t\tisApiErrorLike(error) && error.status === 401\n\t\t\t? undefined\n\t\t\t: errors.apiRefusal(error, language);\n\tif (!refusal) throw routeError(error, route);\n\treturn refusal;\n}\n\n/** What `fetcherResult` takes after `run`: `routeError`'s options, and a rewording. */\nexport interface FetcherResultOptions extends RouteErrorOptions {\n\t/**\n\t * Words the refusal of this call: given the caught API error, the message\n\t * to answer, or `undefined` to keep the worded one. The status is the\n\t * refusal's. Called for an API's own refusal only: not for an API it\n\t * cannot reach or any other failure, nor for what is thrown to the error\n\t * page.\n\t */\n\treword?: (error: ApiErrorLike) => string | undefined;\n}\n\n/**\n * Runs the mutation of an action a fetcher posted to: `{ ok: true }` with\n * `about` and the mutation's value, or the refusal (`fetcherRefusal`) as a\n * worded `error`, with its HTTP status, for a toast or a form message.\n */\nexport async function fetcherResult<\n\tL extends string,\n\tAbout extends object,\n\tValue extends object = Record<never, never>,\n>(\n\terrors: Pick<ApiErrors<L>, 'apiRefusal'>,\n\tlanguage: L,\n\tabout: About,\n\trun: () => Promise<Value>,\n\toptions?: FetcherResultOptions,\n) {\n\ttry {\n\t\treturn { ok: true as const, ...about, ...(await run()) };\n\t} catch (error) {\n\t\tconst { message, status } = fetcherRefusal(\n\t\t\terrors,\n\t\t\terror,\n\t\t\tlanguage,\n\t\t\toptions,\n\t\t);\n\t\treturn data(\n\t\t\t{\n\t\t\t\tok: false as const,\n\t\t\t\t...about,\n\t\t\t\terror:\n\t\t\t\t\t(isApiErrorLike(error) ? options?.reword?.(error) : undefined) ??\n\t\t\t\t\tmessage,\n\t\t\t},\n\t\t\t{ status },\n\t\t);\n\t}\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;AAAA;AAUO,SAAS,cAAgC,CAC/C,QACA,OACA,UACA,OACa;AAAA,EACb,MAAM,UACL,gBAAe,KAAK,KAAK,MAAM,WAAW,MACvC,YACA,OAAO,WAAW,OAAO,QAAQ;AAAA,EACrC,IAAI,CAAC;AAAA,IAAS,MAAM,YAAW,OAAO,KAAK;AAAA,EAC3C,OAAO;AAAA;AAoBD,eAAe,aAIrB,CACA,QACA,UACA,OACA,KACA,SACC;AAAA,EACD,IAAI;AAAA,IACH,OAAO,EAAE,IAAI,SAAkB,UAAW,MAAM,IAAI,EAAG;AAAA,IACtD,OAAO,OAAO;AAAA,IACf,QAAQ,SAAS,WAAW,eAC3B,QACA,OACA,UACA,OACD;AAAA,IACA,OAAO,KACN;AAAA,MACC,IAAI;AAAA,SACD;AAAA,MACH,QACE,gBAAe,KAAK,IAAI,SAAS,SAAS,KAAK,IAAI,cACpD;AAAA,IACF,GACA,EAAE,OAAO,CACV;AAAA;AAAA;",
|
|
8
|
+
"debugId": "D74C6D167773F20264756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/pwa/model/worker-contract.ts
|
|
2
|
+
var SERVICE_WORKER_URL2 = "/service-worker.js";
|
|
3
|
+
var OFFLINE_URL2 = "/offline.html";
|
|
4
|
+
var SKIP_WAITING2 = "SKIP_WAITING";
|
|
5
|
+
function defineWorkerContract2(options) {
|
|
6
|
+
const { cachePrefix } = options;
|
|
7
|
+
if (typeof cachePrefix !== "string" || cachePrefix === "") {
|
|
8
|
+
throw new TypeError(`defineWorkerContract(): cachePrefix must be a non-empty name, such as 'my-app'; got '${String(cachePrefix)}'.`);
|
|
9
|
+
}
|
|
10
|
+
if (cachePrefix.endsWith("-")) {
|
|
11
|
+
throw new TypeError(`defineWorkerContract(): cachePrefix must not end with '-', which the contract adds; got '${cachePrefix}'. Use '${cachePrefix.replace(/-+$/, "")}'.`);
|
|
12
|
+
}
|
|
13
|
+
const cacheVersion = options.cacheVersion ?? "v1";
|
|
14
|
+
if (typeof cacheVersion !== "string" || cacheVersion === "" || cacheVersion.includes("-")) {
|
|
15
|
+
throw new TypeError(`defineWorkerContract(): cacheVersion must be a non-empty name without '-', such as 'v2'; got '${String(cacheVersion)}'.`);
|
|
16
|
+
}
|
|
17
|
+
const cacheNames = Object.freeze({
|
|
18
|
+
precache: `${cachePrefix}-precache-${cacheVersion}`,
|
|
19
|
+
assets: `${cachePrefix}-assets-${cacheVersion}`,
|
|
20
|
+
static: `${cachePrefix}-static-${cacheVersion}`
|
|
21
|
+
});
|
|
22
|
+
const current = new Set(Object.values(cacheNames));
|
|
23
|
+
const shape = new RegExp(`^${cachePrefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-[a-z0-9]+-[^-]+$`);
|
|
24
|
+
const owned = (name) => shape.test(name);
|
|
25
|
+
const contract = {
|
|
26
|
+
cachePrefix,
|
|
27
|
+
cacheVersion,
|
|
28
|
+
serviceWorkerUrl: options.serviceWorkerUrl ?? SERVICE_WORKER_URL2,
|
|
29
|
+
offlineUrl: options.offlineUrl ?? OFFLINE_URL2,
|
|
30
|
+
cacheNames,
|
|
31
|
+
obsoleteCaches: (names) => names.filter((name) => owned(name) && !current.has(name)),
|
|
32
|
+
clearableCaches: (names) => names.filter((name) => owned(name) && name !== cacheNames.precache)
|
|
33
|
+
};
|
|
34
|
+
return Object.freeze(contract);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { SERVICE_WORKER_URL2, OFFLINE_URL2, SKIP_WAITING2, defineWorkerContract2 };
|
|
38
|
+
|
|
39
|
+
//# debugId=5CED7E20833AD98364756E2164756E21
|
|
40
|
+
//# sourceMappingURL=index-rfr02vg4.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pwa/model/worker-contract.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * What the service worker and the page agree on: the worker's address, the\n * offline page, the message that applies an update, and the names of the\n * caches the worker owns. Dependency-free: the worker bundles it, with no\n * DOM and no React.\n */\n\n/** Where the build writes the worker; registered with scope `/`. */\nexport const SERVICE_WORKER_URL = '/service-worker.js';\n\n/** The page served when a navigation fails for want of a network. */\nexport const OFFLINE_URL = '/offline.html';\n\n/** The message a page posts to a waiting worker to make it take over. */\nexport const SKIP_WAITING = 'SKIP_WAITING';\n\nexport interface WorkerContractOptions {\n\t/**\n\t * Every Cache Storage cache the worker owns is named\n\t * `<cachePrefix>-<kind>-<version>` (kind: letters and digits; version:\n\t * no `-`); a cache of another shape is never swept.\n\t * Required: two apps on one origin must not share it.\n\t */\n\tcachePrefix: string;\n\t/**\n\t * Bumped when a cache's content changes shape: the next worker deletes\n\t * every cache of the prefix that has another version when it activates.\n\t * `'v1'` by default; not empty, and without a `-`.\n\t */\n\tcacheVersion?: string;\n\t/** `SERVICE_WORKER_URL` by default. */\n\tserviceWorkerUrl?: string;\n\t/** `OFFLINE_URL` by default. */\n\tofflineUrl?: string;\n}\n\nexport type CacheNames = {\n\t/**\n\t * The offline page and the hashed scripts and stylesheets of every route.\n\t * `<prefix>-precache-<version>` is the name Workbox builds from\n\t * `setCacheNameDetails({ prefix, precache: 'precache', suffix: version })`.\n\t */\n\treadonly precache: string;\n\t/** `/assets/*` bundles: hashed names, so cache-first. */\n\treadonly assets: string;\n\t/** Icons, sprites, the logo: stale-while-revalidate. */\n\treadonly static: string;\n};\n\nexport interface WorkerContract {\n\treadonly cachePrefix: string;\n\treadonly cacheVersion: string;\n\treadonly serviceWorkerUrl: string;\n\treadonly offlineUrl: string;\n\treadonly cacheNames: CacheNames;\n\t/** The caches a worker deletes on activate: the prefix's, of another version. */\n\tobsoleteCaches(names: readonly string[]): string[];\n\t/**\n\t * The caches `clearAppCaches()` deletes: all of the prefix's but the\n\t * current precache, which holds the offline page and the app's code, never\n\t * a user's data.\n\t */\n\tclearableCaches(names: readonly string[]): string[];\n}\n\n/** Builds the contract of one app from its cache prefix. */\nexport function defineWorkerContract(\n\toptions: WorkerContractOptions,\n): WorkerContract {\n\tconst { cachePrefix } = options;\n\tif (typeof cachePrefix !== 'string' || cachePrefix === '') {\n\t\tthrow new TypeError(\n\t\t\t`defineWorkerContract(): cachePrefix must be a non-empty name, such as 'my-app'; got '${String(cachePrefix)}'.`,\n\t\t);\n\t}\n\tif (cachePrefix.endsWith('-')) {\n\t\tthrow new TypeError(\n\t\t\t`defineWorkerContract(): cachePrefix must not end with '-', which the contract adds; got '${cachePrefix}'. Use '${cachePrefix.replace(/-+$/, '')}'.`,\n\t\t);\n\t}\n\tconst cacheVersion = options.cacheVersion ?? 'v1';\n\tif (\n\t\ttypeof cacheVersion !== 'string' ||\n\t\tcacheVersion === '' ||\n\t\tcacheVersion.includes('-')\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`defineWorkerContract(): cacheVersion must be a non-empty name without '-', such as 'v2'; got '${String(cacheVersion)}'.`,\n\t\t);\n\t}\n\tconst cacheNames: CacheNames = Object.freeze({\n\t\tprecache: `${cachePrefix}-precache-${cacheVersion}`,\n\t\tassets: `${cachePrefix}-assets-${cacheVersion}`,\n\t\tstatic: `${cachePrefix}-static-${cacheVersion}`,\n\t});\n\tconst current = new Set<string>(Object.values(cacheNames));\n\t// Exactly `<prefix>-<kind>-<version>`: the prefix 'app' must not claim\n\t// 'app-admin-assets-v1' (one segment too many), but still owns a retired\n\t// kind such as 'app-pages-v0'.\n\tconst shape = new RegExp(\n\t\t`^${cachePrefix.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}-[a-z0-9]+-[^-]+$`,\n\t);\n\tconst owned = (name: string) => shape.test(name);\n\tconst contract: WorkerContract = {\n\t\tcachePrefix,\n\t\tcacheVersion,\n\t\tserviceWorkerUrl: options.serviceWorkerUrl ?? SERVICE_WORKER_URL,\n\t\tofflineUrl: options.offlineUrl ?? OFFLINE_URL,\n\t\tcacheNames,\n\t\tobsoleteCaches: (names) =>\n\t\t\tnames.filter((name) => owned(name) && !current.has(name)),\n\t\tclearableCaches: (names) =>\n\t\t\tnames.filter((name) => owned(name) && name !== cacheNames.precache),\n\t};\n\treturn Object.freeze(contract);\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAQO,IAAM,sBAAqB;AAG3B,IAAM,eAAc;AAGpB,IAAM,gBAAe;AAoDrB,SAAS,qBAAoB,CACnC,SACiB;AAAA,EACjB,QAAQ,gBAAgB;AAAA,EACxB,IAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAAA,IAC1D,MAAM,IAAI,UACT,wFAAwF,OAAO,WAAW,KAC3G;AAAA,EACD;AAAA,EACA,IAAI,YAAY,SAAS,GAAG,GAAG;AAAA,IAC9B,MAAM,IAAI,UACT,4FAA4F,sBAAsB,YAAY,QAAQ,OAAO,EAAE,KAChJ;AAAA,EACD;AAAA,EACA,MAAM,eAAe,QAAQ,gBAAgB;AAAA,EAC7C,IACC,OAAO,iBAAiB,YACxB,iBAAiB,MACjB,aAAa,SAAS,GAAG,GACxB;AAAA,IACD,MAAM,IAAI,UACT,iGAAiG,OAAO,YAAY,KACrH;AAAA,EACD;AAAA,EACA,MAAM,aAAyB,OAAO,OAAO;AAAA,IAC5C,UAAU,GAAG,wBAAwB;AAAA,IACrC,QAAQ,GAAG,sBAAsB;AAAA,IACjC,QAAQ,GAAG,sBAAsB;AAAA,EAClC,CAAC;AAAA,EACD,MAAM,UAAU,IAAI,IAAY,OAAO,OAAO,UAAU,CAAC;AAAA,EAIzD,MAAM,QAAQ,IAAI,OACjB,IAAI,YAAY,QAAQ,uBAAuB,MAAM,oBACtD;AAAA,EACA,MAAM,QAAQ,CAAC,SAAiB,MAAM,KAAK,IAAI;AAAA,EAC/C,MAAM,WAA2B;AAAA,IAChC;AAAA,IACA;AAAA,IACA,kBAAkB,QAAQ,oBAAoB;AAAA,IAC9C,YAAY,QAAQ,cAAc;AAAA,IAClC;AAAA,IACA,gBAAgB,CAAC,UAChB,MAAM,OAAO,CAAC,SAAS,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;AAAA,IACzD,iBAAiB,CAAC,UACjB,MAAM,OAAO,CAAC,SAAS,MAAM,IAAI,KAAK,SAAS,WAAW,QAAQ;AAAA,EACpE;AAAA,EACA,OAAO,OAAO,OAAO,QAAQ;AAAA;",
|
|
8
|
+
"debugId": "5CED7E20833AD98364756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/vite/entry.ts
|
|
2
|
+
var NAME = "alxia-react-router";
|
|
3
|
+
var SERVER_BUILD = "virtual:react-router/server-build";
|
|
4
|
+
var PASS_THROUGH = `export * from '${SERVER_BUILD}';
|
|
5
|
+
`;
|
|
6
|
+
function serverEntry({
|
|
7
|
+
file,
|
|
8
|
+
label,
|
|
9
|
+
dev,
|
|
10
|
+
client
|
|
11
|
+
}) {
|
|
12
|
+
const lines = ["// Written by @softistx/alxia-react-router/vite."];
|
|
13
|
+
if (file === undefined) {
|
|
14
|
+
lines.push("import { createServer } from '@softistx/alxia-react-router';", "const server = createServer();");
|
|
15
|
+
} else {
|
|
16
|
+
lines.push(`import server from ${JSON.stringify(file)};`, "if (typeof server?.create !== 'function' || typeof server.start !== 'function') {", ` throw new TypeError(${JSON.stringify(`${NAME}: ${label} must export createServer() from @softistx/alxia-react-router as its default export: export default createServer({ … }).`)});`, "}");
|
|
17
|
+
}
|
|
18
|
+
if (dev) {
|
|
19
|
+
lines.push("export default server.create({", ` build: () => import('${SERVER_BUILD}'),`, "\tmode: 'development',", "});");
|
|
20
|
+
} else {
|
|
21
|
+
lines.push(`import * as build from '${SERVER_BUILD}';`, `export * from '${SERVER_BUILD}';`, "const app = server.create({", "\tbuild,", "\tmode: 'production',", ` client: new URL(${JSON.stringify(client ?? "../client")}, import.meta.url),`, "});", "export default app;", "if (import.meta.main) server.start(app);");
|
|
22
|
+
}
|
|
23
|
+
return `${lines.join(`
|
|
24
|
+
`)}
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { NAME, PASS_THROUGH, serverEntry };
|
|
29
|
+
|
|
30
|
+
//# debugId=D2DA11170DD4DC3D64756E2164756E21
|
|
31
|
+
//# sourceMappingURL=index-sfhshxqz.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vite/entry.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The source of the module the plugin serves in dev and builds as\n * `build/server/index.js`: the server, made into the app with React\n * Router's build, and in a build listening when run.\n */\n\nexport const NAME = 'alxia-react-router';\n\n/** React Router's server build, as its Vite plugin serves it. */\nconst SERVER_BUILD = 'virtual:react-router/server-build';\n\n/** The input when the plugin is disabled: React Router's build alone. */\nexport const PASS_THROUGH = `export * from '${SERVER_BUILD}';\\n`;\n\nexport interface EntryOptions {\n\t/** The server file, absolute, or `undefined` for `createServer()` as it is. */\n\treadonly file: string | undefined;\n\t/** How an error names the file: relative to Vite's root. */\n\treadonly label: string;\n\t/** Under `react-router dev`: the build on every request, no client, no listening. */\n\treadonly dev: boolean;\n\t/** The client build, relative to the built file: `../client`. */\n\treadonly client: string | undefined;\n}\n\nexport function serverEntry({\n\tfile,\n\tlabel,\n\tdev,\n\tclient,\n}: EntryOptions): string {\n\tconst lines = ['// Written by @softistx/alxia-react-router/vite.'];\n\tif (file === undefined) {\n\t\tlines.push(\n\t\t\t\"import { createServer } from '@softistx/alxia-react-router';\",\n\t\t\t'const server = createServer();',\n\t\t);\n\t} else {\n\t\tlines.push(\n\t\t\t`import server from ${JSON.stringify(file)};`,\n\t\t\t\"if (typeof server?.create !== 'function' || typeof server.start !== 'function') {\",\n\t\t\t`\\tthrow new TypeError(${JSON.stringify(\n\t\t\t\t`${NAME}: ${label} must export createServer() from @softistx/alxia-react-router as its default export: export default createServer({ … }).`,\n\t\t\t)});`,\n\t\t\t'}',\n\t\t);\n\t}\n\tif (dev) {\n\t\tlines.push(\n\t\t\t'export default server.create({',\n\t\t\t`\\tbuild: () => import('${SERVER_BUILD}'),`,\n\t\t\t\"\\tmode: 'development',\",\n\t\t\t'});',\n\t\t);\n\t} else {\n\t\tlines.push(\n\t\t\t`import * as build from '${SERVER_BUILD}';`,\n\t\t\t// What a server build exports, beside the app: React Router reads it\n\t\t\t// back to prerender. The server file's other exports stay out of it.\n\t\t\t`export * from '${SERVER_BUILD}';`,\n\t\t\t'const app = server.create({',\n\t\t\t'\\tbuild,',\n\t\t\t\"\\tmode: 'production',\",\n\t\t\t`\\tclient: new URL(${JSON.stringify(client ?? '../client')}, import.meta.url),`,\n\t\t\t'});',\n\t\t\t'export default app;',\n\t\t\t// Run, not imported: prerendering, or a test, imports it.\n\t\t\t'if (import.meta.main) server.start(app);',\n\t\t);\n\t}\n\treturn `${lines.join('\\n')}\\n`;\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAMO,IAAM,OAAO;AAGpB,IAAM,eAAe;AAGd,IAAM,eAAe,kBAAkB;AAAA;AAavC,SAAS,WAAW;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GACwB;AAAA,EACxB,MAAM,QAAQ,CAAC,kDAAkD;AAAA,EACjE,IAAI,SAAS,WAAW;AAAA,IACvB,MAAM,KACL,gEACA,gCACD;AAAA,EACD,EAAE,KAAK;AAAA,IACN,MAAM,KACL,sBAAsB,KAAK,UAAU,IAAI,MACzC,qFACA,wBAAyB,KAAK,UAC7B,GAAG,SAAS,+HACb,OACA,GACD;AAAA;AAAA,EAED,IAAI,KAAK;AAAA,IACR,MAAM,KACL,kCACA,yBAA0B,mBAC1B,0BACA,KACD;AAAA,EACD,EAAE,KAAK;AAAA,IACN,MAAM,KACL,2BAA2B,kBAG3B,kBAAkB,kBAClB,+BACA,YACA,yBACA,oBAAqB,KAAK,UAAU,UAAU,WAAW,wBACzD,OACA,uBAEA,0CACD;AAAA;AAAA,EAED,OAAO,GAAG,MAAM,KAAK;AAAA,CAAI;AAAA;AAAA;",
|
|
8
|
+
"debugId": "D2DA11170DD4DC3D64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|