intor 2.5.0 → 2.6.0
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 +1 -1
- package/README.md +1 -1
- package/dist/core/export/index.js +1 -0
- package/dist/core/src/client/shared/helpers/get-client-locale.js +5 -20
- package/dist/core/src/client/shared/utils/locale/detect-browser-locale.js +2 -8
- package/dist/core/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
- package/dist/core/src/config/constants/cookie.js +9 -9
- package/dist/core/src/config/constants/routing.js +13 -14
- package/dist/core/src/config/define-intor-config.js +28 -44
- package/dist/core/src/config/resolvers/resolve-cookie-options.js +4 -4
- package/dist/core/src/config/resolvers/resolve-fallback-locales.js +33 -50
- package/dist/core/src/config/resolvers/resolve-routing-options.js +32 -61
- package/dist/core/src/config/validators/validate-default-locale.js +8 -13
- package/dist/core/src/config/validators/validate-id.js +8 -13
- package/dist/core/src/config/validators/validate-supported-locales.js +8 -13
- package/dist/core/src/core/constants/locale-placeholder.js +0 -1
- package/dist/core/src/core/error/intor-error.js +14 -29
- package/dist/core/src/core/locale/canonicalize-locale.js +7 -18
- package/dist/core/src/core/locale/match-locale.js +24 -50
- package/dist/core/src/core/locale/parse-locale.js +12 -22
- package/dist/core/src/core/logger/get-logger.js +26 -31
- package/dist/core/src/core/logger/global-logger-pool.js +4 -4
- package/dist/core/src/core/messages/internal-metadata.js +1 -1
- package/dist/core/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
- package/dist/core/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
- package/dist/core/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
- package/dist/core/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
- package/dist/core/src/core/messages/merge-messages.js +17 -28
- package/dist/core/src/core/messages/utils/is-valid-messages.js +22 -37
- package/dist/core/src/core/messages/utils/nest-object-from-path.js +5 -17
- package/dist/core/src/core/render/create-html-renderer.js +29 -37
- package/dist/core/src/core/render/utils/escape-html.js +1 -6
- package/dist/core/src/core/render/utils/render-attributes.js +6 -11
- package/dist/core/src/core/translator/create-t-rich.js +6 -15
- package/dist/core/src/core/translator/create-translator.js +16 -24
- package/dist/core/src/core/utils/deep-merge.js +24 -42
- package/dist/core/src/core/utils/normalizers/normalize-cache-key.js +14 -40
- package/dist/core/src/core/utils/normalizers/normalize-pathname.js +19 -37
- package/dist/core/src/core/utils/normalizers/normalize-query.js +6 -20
- package/dist/core/src/core/utils/parse-cookie-header.js +11 -18
- package/dist/core/src/core/utils/resolve-loader-options.js +6 -32
- package/dist/core/src/edge/helpers/get-translator.js +14 -20
- package/dist/core/src/edge/translator/init-translator.js +23 -31
- package/dist/core/src/routing/inbound/helpers/resolve-inbound-from-request.js +21 -28
- package/dist/core/src/routing/inbound/resolve-inbound.js +22 -37
- package/dist/core/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
- package/dist/core/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
- package/dist/core/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
- package/dist/core/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
- package/dist/core/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
- package/dist/core/src/routing/locale/get-locale-from-accept-language.js +21 -36
- package/dist/core/src/routing/locale/get-locale-from-host.js +5 -28
- package/dist/core/src/routing/locale/get-locale-from-pathname.js +11 -37
- package/dist/core/src/routing/locale/get-locale-from-query.js +2 -17
- package/dist/core/src/routing/pathname/canonicalize-pathname.js +25 -67
- package/dist/core/src/routing/pathname/localize-pathname.js +12 -30
- package/dist/core/src/routing/pathname/materialize-pathname.js +9 -44
- package/dist/core/src/routing/pathname/standardize-pathname.js +6 -30
- package/dist/core/src/server/helpers/get-translator.js +26 -23
- package/dist/core/src/server/intor/intor.js +20 -25
- package/dist/core/src/server/messages/load-local-messages/cache/messages-pool.js +4 -7
- package/dist/core/src/server/messages/load-local-messages/load-local-messages.js +76 -92
- package/dist/core/src/server/messages/load-local-messages/read-locale-messages/collect-file-entries/collect-file-entries.js +59 -80
- package/dist/core/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/parse-file-entries.js +53 -87
- package/dist/core/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/utils/json-reader.js +3 -6
- package/dist/core/src/server/messages/load-local-messages/read-locale-messages/read-locale-messages.js +23 -35
- package/dist/core/src/server/messages/load-messages.js +56 -69
- package/dist/core/src/server/translator/init-translator.js +28 -30
- package/dist/express/src/adapters/express/create-intor-handler.js +35 -46
- package/dist/express/src/adapters/express/get-translator.js +2 -9
- package/dist/express/src/core/constants/locale-placeholder.js +0 -1
- package/dist/express/src/core/locale/canonicalize-locale.js +7 -18
- package/dist/express/src/core/locale/match-locale.js +24 -50
- package/dist/express/src/core/locale/parse-locale.js +12 -22
- package/dist/express/src/core/utils/normalizers/normalize-pathname.js +19 -37
- package/dist/express/src/core/utils/normalizers/normalize-query.js +6 -20
- package/dist/express/src/core/utils/parse-cookie-header.js +11 -18
- package/dist/express/src/routing/inbound/resolve-inbound.js +22 -37
- package/dist/express/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
- package/dist/express/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
- package/dist/express/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
- package/dist/express/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
- package/dist/express/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
- package/dist/express/src/routing/locale/get-locale-from-accept-language.js +21 -36
- package/dist/express/src/routing/locale/get-locale-from-host.js +5 -28
- package/dist/express/src/routing/locale/get-locale-from-pathname.js +11 -37
- package/dist/express/src/routing/locale/get-locale-from-query.js +2 -17
- package/dist/express/src/routing/pathname/canonicalize-pathname.js +25 -67
- package/dist/express/src/routing/pathname/localize-pathname.js +12 -30
- package/dist/express/src/routing/pathname/materialize-pathname.js +9 -44
- package/dist/express/src/routing/pathname/standardize-pathname.js +6 -30
- package/dist/fastify/src/adapters/fastify/create-intor-handler.js +35 -47
- package/dist/fastify/src/adapters/fastify/get-translator.js +2 -9
- package/dist/fastify/src/adapters/fastify/intor-fastify-plugin.js +29 -38
- package/dist/fastify/src/core/constants/locale-placeholder.js +0 -1
- package/dist/fastify/src/core/locale/canonicalize-locale.js +7 -18
- package/dist/fastify/src/core/locale/match-locale.js +24 -50
- package/dist/fastify/src/core/locale/parse-locale.js +12 -22
- package/dist/fastify/src/core/utils/normalizers/normalize-pathname.js +19 -37
- package/dist/fastify/src/core/utils/normalizers/normalize-query.js +6 -20
- package/dist/fastify/src/core/utils/parse-cookie-header.js +11 -18
- package/dist/fastify/src/routing/inbound/resolve-inbound.js +22 -37
- package/dist/fastify/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
- package/dist/fastify/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
- package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
- package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
- package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
- package/dist/fastify/src/routing/locale/get-locale-from-accept-language.js +21 -36
- package/dist/fastify/src/routing/locale/get-locale-from-host.js +5 -28
- package/dist/fastify/src/routing/locale/get-locale-from-pathname.js +11 -37
- package/dist/fastify/src/routing/locale/get-locale-from-query.js +2 -17
- package/dist/fastify/src/routing/pathname/canonicalize-pathname.js +25 -67
- package/dist/fastify/src/routing/pathname/localize-pathname.js +12 -30
- package/dist/fastify/src/routing/pathname/materialize-pathname.js +9 -44
- package/dist/fastify/src/routing/pathname/standardize-pathname.js +6 -30
- package/dist/hono/src/adapters/hono/create-intor-handler.js +33 -44
- package/dist/hono/src/adapters/hono/get-translator.js +2 -9
- package/dist/hono/src/core/constants/locale-placeholder.js +0 -1
- package/dist/hono/src/core/locale/canonicalize-locale.js +7 -18
- package/dist/hono/src/core/locale/match-locale.js +24 -50
- package/dist/hono/src/core/locale/parse-locale.js +12 -22
- package/dist/hono/src/core/utils/normalizers/normalize-pathname.js +19 -37
- package/dist/hono/src/core/utils/normalizers/normalize-query.js +6 -20
- package/dist/hono/src/core/utils/parse-cookie-header.js +11 -18
- package/dist/hono/src/routing/inbound/resolve-inbound.js +22 -37
- package/dist/hono/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
- package/dist/hono/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
- package/dist/hono/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
- package/dist/hono/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
- package/dist/hono/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
- package/dist/hono/src/routing/locale/get-locale-from-accept-language.js +21 -36
- package/dist/hono/src/routing/locale/get-locale-from-host.js +5 -28
- package/dist/hono/src/routing/locale/get-locale-from-pathname.js +11 -37
- package/dist/hono/src/routing/locale/get-locale-from-query.js +2 -17
- package/dist/hono/src/routing/pathname/canonicalize-pathname.js +25 -67
- package/dist/hono/src/routing/pathname/localize-pathname.js +12 -30
- package/dist/hono/src/routing/pathname/materialize-pathname.js +9 -44
- package/dist/hono/src/routing/pathname/standardize-pathname.js +6 -30
- package/dist/next/export/next/server/index.js +1 -0
- package/dist/next/src/adapters/next/create-intor-handler.js +39 -48
- package/dist/next/src/adapters/next/header-keys.js +9 -0
- package/dist/next/src/adapters/next/link.js +33 -28
- package/dist/next/src/adapters/next/redirect.js +12 -15
- package/dist/next/src/adapters/next/server/get-locale.js +13 -24
- package/dist/next/src/adapters/next/server/get-translator.js +2 -9
- package/dist/next/src/adapters/next/server/intor.js +5 -13
- package/dist/next/src/adapters/next/server/read-intor-url-state.js +13 -0
- package/dist/next/src/adapters/next/use-router.js +47 -66
- package/dist/next/src/client/shared/navigation/execute-navigation.js +20 -38
- package/dist/next/src/client/shared/utils/build-cookie-string.js +18 -27
- package/dist/next/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
- package/dist/next/src/core/constants/locale-placeholder.js +0 -1
- package/dist/next/src/core/locale/canonicalize-locale.js +7 -18
- package/dist/next/src/core/locale/match-locale.js +24 -50
- package/dist/next/src/core/locale/parse-locale.js +12 -22
- package/dist/next/src/core/utils/normalizers/normalize-pathname.js +19 -37
- package/dist/next/src/core/utils/normalizers/normalize-query.js +6 -20
- package/dist/next/src/core/utils/resolve-loader-options.js +6 -29
- package/dist/next/src/policies/shoud-full-reload.js +2 -5
- package/dist/next/src/policies/should-sync-locale.js +1 -4
- package/dist/next/src/routing/inbound/resolve-inbound.js +24 -39
- package/dist/next/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
- package/dist/next/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
- package/dist/next/src/routing/inbound/resolve-pathname/strategies/all.js +13 -29
- package/dist/next/src/routing/inbound/resolve-pathname/strategies/except-default.js +14 -30
- package/dist/next/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
- package/dist/next/src/routing/locale/get-locale-from-accept-language.js +21 -36
- package/dist/next/src/routing/locale/get-locale-from-host.js +5 -28
- package/dist/next/src/routing/locale/get-locale-from-pathname.js +11 -37
- package/dist/next/src/routing/locale/get-locale-from-query.js +2 -17
- package/dist/next/src/routing/outbound/decide-strategy.js +9 -9
- package/dist/next/src/routing/outbound/determine-target.js +28 -44
- package/dist/next/src/routing/outbound/resolve-outbound.js +12 -16
- package/dist/next/src/routing/outbound/utils/derive-host-destination.js +5 -9
- package/dist/next/src/routing/outbound/utils/derive-query-destination.js +4 -7
- package/dist/next/src/routing/outbound/utils/is-external-destination.js +1 -7
- package/dist/next/src/routing/pathname/canonicalize-pathname.js +25 -67
- package/dist/next/src/routing/pathname/localize-pathname.js +12 -30
- package/dist/next/src/routing/pathname/materialize-pathname.js +9 -44
- package/dist/next/src/routing/pathname/standardize-pathname.js +6 -30
- package/dist/react/src/client/react/helpers/use-intor.js +25 -44
- package/dist/react/src/client/react/provider/effects/use-locale-effects.js +20 -25
- package/dist/react/src/client/react/provider/effects/use-messages-effects.js +17 -16
- package/dist/react/src/client/react/provider/intor-provider.js +63 -66
- package/dist/react/src/client/react/provider/use-intor-context.js +4 -4
- package/dist/react/src/client/react/render/create-react-renderer.js +18 -24
- package/dist/react/src/client/react/translator/create-t-rich.js +9 -22
- package/dist/react/src/client/react/translator/use-translator.js +11 -16
- package/dist/react/src/client/shared/messages/create-refetch-messages.js +41 -51
- package/dist/react/src/client/shared/provider/effective-state.js +2 -6
- package/dist/react/src/client/shared/utils/build-cookie-string.js +18 -27
- package/dist/react/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
- package/dist/react/src/client/shared/utils/locale/set-document-locale.js +2 -8
- package/dist/react/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
- package/dist/react/src/core/logger/get-logger.js +26 -31
- package/dist/react/src/core/logger/global-logger-pool.js +4 -4
- package/dist/react/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
- package/dist/react/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
- package/dist/react/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
- package/dist/react/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
- package/dist/react/src/core/messages/merge-messages.js +17 -28
- package/dist/react/src/core/messages/utils/is-valid-messages.js +22 -37
- package/dist/react/src/core/messages/utils/nest-object-from-path.js +5 -17
- package/dist/react/src/core/utils/deep-merge.js +24 -42
- package/dist/react/src/core/utils/resolve-loader-options.js +6 -29
- package/dist/react/src/policies/should-persist-on-first-visit.js +1 -4
- package/dist/svelte/export/svelte/index.js +0 -6
- package/dist/svelte/src/client/shared/messages/create-refetch-messages.js +41 -51
- package/dist/svelte/src/client/shared/provider/effective-state.js +2 -6
- package/dist/svelte/src/client/shared/utils/build-cookie-string.js +18 -27
- package/dist/svelte/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
- package/dist/svelte/src/client/shared/utils/locale/set-document-locale.js +2 -8
- package/dist/svelte/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
- package/dist/svelte/src/client/svelte/provider/create-intor-store.js +59 -63
- package/dist/svelte/src/client/svelte/provider/effects/attach-locale-effects.js +20 -25
- package/dist/svelte/src/client/svelte/provider/effects/attach-messages-effects.js +21 -18
- package/dist/svelte/src/client/svelte/provider/get-intor-context.js +4 -4
- package/dist/svelte/src/client/svelte/translator/use-translator.js +11 -16
- package/dist/svelte/src/core/logger/get-logger.js +26 -31
- package/dist/svelte/src/core/logger/global-logger-pool.js +4 -4
- package/dist/svelte/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
- package/dist/svelte/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
- package/dist/svelte/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
- package/dist/svelte/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
- package/dist/svelte/src/core/messages/merge-messages.js +17 -28
- package/dist/svelte/src/core/messages/utils/is-valid-messages.js +22 -37
- package/dist/svelte/src/core/messages/utils/nest-object-from-path.js +5 -17
- package/dist/svelte/src/core/render/create-html-renderer.js +29 -37
- package/dist/svelte/src/core/render/utils/escape-html.js +1 -6
- package/dist/svelte/src/core/render/utils/render-attributes.js +6 -11
- package/dist/svelte/src/core/translator/create-t-rich.js +6 -15
- package/dist/svelte/src/core/utils/deep-merge.js +24 -42
- package/dist/svelte/src/core/utils/resolve-loader-options.js +6 -29
- package/dist/svelte/src/policies/should-persist-on-first-visit.js +1 -4
- package/dist/svelte-kit/src/adapters/svelte-kit/create-intor-handler.js +37 -57
- package/dist/svelte-kit/src/adapters/svelte-kit/use-navigation.js +29 -27
- package/dist/svelte-kit/src/adapters/svelte-kit/utils/is-svelte-kit-ssg.js +4 -11
- package/dist/svelte-kit/src/client/shared/navigation/execute-navigation.js +19 -37
- package/dist/svelte-kit/src/client/shared/utils/build-cookie-string.js +18 -27
- package/dist/svelte-kit/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
- package/dist/svelte-kit/src/core/constants/locale-placeholder.js +0 -1
- package/dist/svelte-kit/src/core/locale/canonicalize-locale.js +7 -18
- package/dist/svelte-kit/src/core/locale/match-locale.js +24 -50
- package/dist/svelte-kit/src/core/locale/parse-locale.js +12 -22
- package/dist/svelte-kit/src/core/utils/normalizers/normalize-pathname.js +19 -37
- package/dist/svelte-kit/src/core/utils/normalizers/normalize-query.js +6 -20
- package/dist/svelte-kit/src/core/utils/resolve-loader-options.js +6 -29
- package/dist/svelte-kit/src/policies/shoud-full-reload.js +2 -5
- package/dist/svelte-kit/src/policies/should-sync-locale.js +1 -4
- package/dist/svelte-kit/src/routing/inbound/resolve-inbound.js +22 -37
- package/dist/svelte-kit/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
- package/dist/svelte-kit/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
- package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
- package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
- package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
- package/dist/svelte-kit/src/routing/locale/get-locale-from-accept-language.js +21 -36
- package/dist/svelte-kit/src/routing/locale/get-locale-from-host.js +5 -28
- package/dist/svelte-kit/src/routing/locale/get-locale-from-pathname.js +11 -37
- package/dist/svelte-kit/src/routing/locale/get-locale-from-query.js +2 -17
- package/dist/svelte-kit/src/routing/outbound/decide-strategy.js +9 -9
- package/dist/svelte-kit/src/routing/outbound/determine-target.js +28 -44
- package/dist/svelte-kit/src/routing/outbound/resolve-outbound.js +12 -16
- package/dist/svelte-kit/src/routing/outbound/utils/derive-host-destination.js +5 -9
- package/dist/svelte-kit/src/routing/outbound/utils/derive-query-destination.js +4 -7
- package/dist/svelte-kit/src/routing/outbound/utils/is-external-destination.js +1 -7
- package/dist/svelte-kit/src/routing/pathname/canonicalize-pathname.js +25 -67
- package/dist/svelte-kit/src/routing/pathname/localize-pathname.js +12 -30
- package/dist/svelte-kit/src/routing/pathname/materialize-pathname.js +9 -44
- package/dist/svelte-kit/src/routing/pathname/standardize-pathname.js +6 -30
- package/dist/types/export/index.d.ts +1 -1
- package/dist/types/export/index.d.ts.map +1 -1
- package/dist/types/export/next/server/index.d.ts +1 -1
- package/dist/types/export/next/server/index.d.ts.map +1 -1
- package/dist/types/src/adapters/fastify/intor-fastify-plugin.d.ts.map +1 -1
- package/dist/types/src/adapters/next/create-intor-handler.d.ts.map +1 -1
- package/dist/types/src/{core/constants/headers.d.ts → adapters/next/header-keys.d.ts} +3 -2
- package/dist/types/src/adapters/next/header-keys.d.ts.map +1 -0
- package/dist/types/src/adapters/next/server/get-locale.d.ts.map +1 -1
- package/dist/types/src/adapters/next/server/index.d.ts +1 -0
- package/dist/types/src/adapters/next/server/index.d.ts.map +1 -1
- package/dist/types/src/adapters/next/server/read-intor-url-state.d.ts +13 -0
- package/dist/types/src/adapters/next/server/read-intor-url-state.d.ts.map +1 -0
- package/dist/types/src/core/constants/index.d.ts +0 -1
- package/dist/types/src/core/constants/index.d.ts.map +1 -1
- package/dist/types/src/core/constants/locale-placeholder.d.ts +5 -0
- package/dist/types/src/core/constants/locale-placeholder.d.ts.map +1 -1
- package/dist/types/src/core/index.d.ts +1 -1
- package/dist/types/src/core/index.d.ts.map +1 -1
- package/dist/types/src/edge/translator/init-translator.d.ts.map +1 -1
- package/dist/types/src/routing/outbound/decide-strategy.d.ts +1 -1
- package/dist/types/src/routing/outbound/decide-strategy.d.ts.map +1 -1
- package/dist/types/src/server/translator/init-translator.d.ts.map +1 -1
- package/dist/vue/src/client/shared/messages/create-refetch-messages.js +41 -51
- package/dist/vue/src/client/shared/provider/effective-state.js +2 -6
- package/dist/vue/src/client/shared/utils/build-cookie-string.js +18 -27
- package/dist/vue/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
- package/dist/vue/src/client/shared/utils/locale/set-document-locale.js +2 -8
- package/dist/vue/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
- package/dist/vue/src/client/vue/helpers/use-intor.js +20 -42
- package/dist/vue/src/client/vue/provider/effects/use-locale-effects.js +23 -24
- package/dist/vue/src/client/vue/provider/effects/use-messages-effects.js +15 -24
- package/dist/vue/src/client/vue/provider/inject-intor-context.js +4 -4
- package/dist/vue/src/client/vue/provider/intor-provider.js +61 -66
- package/dist/vue/src/client/vue/render/create-vue-renderer.js +18 -24
- package/dist/vue/src/client/vue/translator/create-t-rich.js +5 -17
- package/dist/vue/src/client/vue/translator/trans.js +24 -31
- package/dist/vue/src/client/vue/translator/use-translator.js +12 -17
- package/dist/vue/src/core/logger/get-logger.js +26 -31
- package/dist/vue/src/core/logger/global-logger-pool.js +4 -4
- package/dist/vue/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
- package/dist/vue/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
- package/dist/vue/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
- package/dist/vue/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
- package/dist/vue/src/core/messages/merge-messages.js +17 -28
- package/dist/vue/src/core/messages/utils/is-valid-messages.js +22 -37
- package/dist/vue/src/core/messages/utils/nest-object-from-path.js +5 -17
- package/dist/vue/src/core/utils/deep-merge.js +24 -42
- package/dist/vue/src/core/utils/resolve-loader-options.js +6 -29
- package/dist/vue/src/policies/should-persist-on-first-visit.js +1 -4
- package/package.json +53 -65
- package/dist/next/src/core/constants/headers.js +0 -8
- package/dist/types/src/core/constants/headers.d.ts.map +0 -1
|
@@ -3,37 +3,13 @@ import 'logry';
|
|
|
3
3
|
import 'p-limit';
|
|
4
4
|
import 'intor-translator';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Standardizes a canonical pathname into an internal routing template.
|
|
8
|
-
*
|
|
9
|
-
* Standardized representation:
|
|
10
|
-
* - Prepends the deployment prefix (`basePath`) if defined
|
|
11
|
-
* - Injects the `{locale}` placeholder as the first path segment
|
|
12
|
-
* - Preserves the canonical pathname structure
|
|
13
|
-
*
|
|
14
|
-
* Input must be a canonical pathname.
|
|
15
|
-
*
|
|
16
|
-
* Output is an internal routing template and
|
|
17
|
-
* is not a locale-resolved URL.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* // config.routing.basePath: "/app",
|
|
22
|
-
* standardizePathname("/about", config);
|
|
23
|
-
* // => "/app/{locale}/about"
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
6
|
const standardizePathname = (canonicalPathname, config) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return basePath
|
|
35
|
-
? `${basePath}/${LOCALE_PLACEHOLDER}${canonicalPathname}`
|
|
36
|
-
: `/${LOCALE_PLACEHOLDER}${canonicalPathname}`;
|
|
7
|
+
const { routing } = config;
|
|
8
|
+
const basePath = routing.basePath && routing.basePath !== "/" ? routing.basePath : "";
|
|
9
|
+
if (canonicalPathname === "/") {
|
|
10
|
+
return basePath ? `${basePath}/${LOCALE_PLACEHOLDER}` : `/${LOCALE_PLACEHOLDER}`;
|
|
11
|
+
}
|
|
12
|
+
return basePath ? `${basePath}/${LOCALE_PLACEHOLDER}${canonicalPathname}` : `/${LOCALE_PLACEHOLDER}${canonicalPathname}`;
|
|
37
13
|
};
|
|
38
14
|
|
|
39
15
|
export { standardizePathname };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./shared-types";
|
|
2
|
-
export { type IntorErrorOptions, IntorError, INTOR_ERROR_CODE, type IntorErrorCode, matchLocale, mergeMessages, type MergeMessagesOptions, type MergeMessagesEvent, } from "../src/core";
|
|
2
|
+
export { type IntorErrorOptions, IntorError, INTOR_ERROR_CODE, type IntorErrorCode, matchLocale, mergeMessages, type MergeMessagesOptions, type MergeMessagesEvent, LOCALE_PLACEHOLDER, } from "../src/core";
|
|
3
3
|
export { defineIntorConfig } from "../src/config";
|
|
4
4
|
export { localizePathname, type LocalizedPathname, type InboundResult, type InboundContext, resolveInboundFromRequest, } from "../src/routing";
|
|
5
5
|
export { getClientLocale } from "../src/client";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../export/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAC;AAK/B,OAAO,EAEL,KAAK,iBAAiB,EACtB,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,EAGnB,WAAW,EAGX,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../export/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAC;AAK/B,OAAO,EAEL,KAAK,iBAAiB,EACtB,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,EAGnB,WAAW,EAGX,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAGvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKlD,OAAO,EAEL,gBAAgB,EAChB,KAAK,iBAAiB,EAGtB,KAAK,aAAa,EAClB,KAAK,cAAc,EAGnB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKhD,YAAY,EACV,UAAU,EAGV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EAGd,cAAc,EACd,aAAa,EACb,YAAY,GACb,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "../../shared-types";
|
|
2
|
-
export { intor, getLocale, getTranslator, } from "../../../src/adapters/next/server";
|
|
2
|
+
export { intor, getLocale, getTranslator, readIntorUrlState, } from "../../../src/adapters/next/server";
|
|
3
3
|
export type { IntorValue, IntorOptions, GetTranslatorParams, } from "../../../src/server";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../export/next/server/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,KAAK,EACL,SAAS,EACT,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../export/next/server/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,KAAK,EACL,SAAS,EACT,aAAa,EACb,iBAAiB,GAClB,MAAM,mCAAmC,CAAC;AAE3C,YAAY,EACV,UAAU,EACV,YAAY,EACZ,mBAAmB,GACpB,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intor-fastify-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/fastify/intor-fastify-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAmB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAIxD;;;;;;;GAOG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"intor-fastify-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/fastify/intor-fastify-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAmB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAIxD;;;;;;;GAOG;AACH,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CACrD,mBAAmB,EACnB,QAAQ,GAAG,OAAO,GAAG,iBAAiB,CACvC;IACC,MAAM,EAAE,WAAW,CAAC;IAEpB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoDD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,kDAE7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-intor-handler.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/next/create-intor-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"create-intor-handler.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/next/create-intor-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,IACvB,SAAS,WAAW,2BA6DlD"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const INTOR_HEADER_KEYS: {
|
|
2
2
|
readonly LOCALE: "x-intor-locale";
|
|
3
3
|
readonly LOCALE_SOURCE: "x-intor-locale-source";
|
|
4
4
|
readonly PATHNAME: "x-intor-pathname";
|
|
5
|
+
readonly SEARCH: "x-intor-search";
|
|
5
6
|
readonly REDIRECTED: "x-intor-redirected";
|
|
6
7
|
};
|
|
7
|
-
//# sourceMappingURL=
|
|
8
|
+
//# sourceMappingURL=header-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-keys.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/next/header-keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB;;;;;;CAMpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-locale.d.ts","sourceRoot":"","sources":["../../../../../../src/adapters/next/server/get-locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"get-locale.d.ts","sourceRoot":"","sources":["../../../../../../src/adapters/next/server/get-locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK9D;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAU,EAAE,SAAS,aAAa,GAAG,aAAa,EACtE,QAAQ,WAAW,KAClB,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAmBvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/adapters/next/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/adapters/next/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the current request's Intor URL state.
|
|
3
|
+
*
|
|
4
|
+
* - Resolves locale, pathname, and search from the execution context.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function readIntorUrlState(): Promise<{
|
|
9
|
+
locale: string | null;
|
|
10
|
+
pathname: string;
|
|
11
|
+
search: string;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=read-intor-url-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-intor-url-state.d.ts","sourceRoot":"","sources":["../../../../../../src/adapters/next/server/read-intor-url-state.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAsB,iBAAiB;;;;GAQtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-placeholder.d.ts","sourceRoot":"","sources":["../../../../../src/core/constants/locale-placeholder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locale-placeholder.d.ts","sourceRoot":"","sources":["../../../../../src/core/constants/locale-placeholder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { LOCALE_PLACEHOLDER
|
|
1
|
+
export { LOCALE_PLACEHOLDER } from "./constants";
|
|
2
2
|
export { type IntorErrorOptions, IntorError, INTOR_ERROR_CODE, type IntorErrorCode, } from "./error";
|
|
3
3
|
export { deepMerge, resolveLoaderOptions, parseCookieHeader, normalizePathname, normalizeCacheKey, normalizeQuery, type NormalizedQuery, } from "./utils";
|
|
4
4
|
export { matchLocale } from "./locale";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKjD,OAAO,EACL,KAAK,iBAAiB,EACtB,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,GACpB,MAAM,SAAS,CAAC;AAKjB,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,iBAAiB,EAGjB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAKtD,OAAO,EAEL,kBAAkB,EAGlB,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAGvB,eAAe,EACf,kBAAkB,EAGlB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EAGnB,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,UAAU,CAAC;AAKlB,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,WAAW,GACZ,MAAM,cAAc,CAAC;AAKtB,YAAY,EAEV,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,MAAM,EAGN,SAAS,EACT,WAAW,EACX,cAAc,EAGd,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EAGP,cAAc,EAGd,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAGhB,YAAY,GACb,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-translator.d.ts","sourceRoot":"","sources":["../../../../../src/edge/translator/init-translator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB,UAAU,
|
|
1
|
+
{"version":3,"file":"init-translator.d.ts","sourceRoot":"","sources":["../../../../../src/edge/translator/init-translator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB,UAAU,qBAAsB,SAAQ,IAAI,CAC1C,sBAAsB,EACtB,QAAQ,GAAG,QAAQ,GAAG,UAAU,CACjC;IACC,KAAK,EAAE,YAAY,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CA6BrC"}
|
|
@@ -4,5 +4,5 @@ export type OutboundStrategy = "external" | "client" | "reload";
|
|
|
4
4
|
/**
|
|
5
5
|
* Decide how a resolved navigation target should be executed.
|
|
6
6
|
*/
|
|
7
|
-
export declare function decideStrategy(config: IntorResolvedConfig, target: OutboundTarget): OutboundStrategy;
|
|
7
|
+
export declare function decideStrategy(config: IntorResolvedConfig, target: OutboundTarget, currentLocale: string): OutboundStrategy;
|
|
8
8
|
//# sourceMappingURL=decide-strategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decide-strategy.d.ts","sourceRoot":"","sources":["../../../../../src/routing/outbound/decide-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhE;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"decide-strategy.d.ts","sourceRoot":"","sources":["../../../../../src/routing/outbound/decide-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhE;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,MAAM,GACpB,gBAAgB,CAalB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-translator.d.ts","sourceRoot":"","sources":["../../../../../src/server/translator/init-translator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEpE,MAAM,WAAW,qBACf,
|
|
1
|
+
{"version":3,"file":"init-translator.d.ts","sourceRoot":"","sources":["../../../../../src/server/translator/init-translator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEpE,MAAM,WAAW,qBACf,SACE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,QAAQ,CAAC,EAC7C,IAAI,CAAC,sBAAsB,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IAChE,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAmCrC"}
|
|
@@ -4,57 +4,47 @@ import { loadRemoteMessages } from '../../../core/messages/load-remote-messages/
|
|
|
4
4
|
import { mergeMessages } from '../../../core/messages/merge-messages.js';
|
|
5
5
|
import 'intor-translator';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
// Clear loading state only if this request is still the active one
|
|
52
|
-
if (controller === currentController &&
|
|
53
|
-
!currentController.signal.aborted) {
|
|
54
|
-
onLoadingEnd?.();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
7
|
+
const createRefetchMessages = ({
|
|
8
|
+
config,
|
|
9
|
+
onLoadingStart,
|
|
10
|
+
onLoadingEnd,
|
|
11
|
+
onMessages
|
|
12
|
+
}) => {
|
|
13
|
+
let controller = null;
|
|
14
|
+
return async function refetchMessages(newLocale) {
|
|
15
|
+
const loader = resolveLoaderOptions(config);
|
|
16
|
+
if (!loader || loader.mode !== "remote") return;
|
|
17
|
+
const { namespaces, concurrency, url, headers } = loader;
|
|
18
|
+
controller?.abort();
|
|
19
|
+
const currentController = new AbortController();
|
|
20
|
+
controller = currentController;
|
|
21
|
+
onLoadingStart?.();
|
|
22
|
+
try {
|
|
23
|
+
const loadedMessages = await loadRemoteMessages({
|
|
24
|
+
locale: newLocale,
|
|
25
|
+
fallbackLocales: config.fallbackLocales[newLocale] || [],
|
|
26
|
+
...namespaces !== void 0 ? { namespaces } : {},
|
|
27
|
+
...concurrency !== void 0 ? { concurrency } : {},
|
|
28
|
+
fetch: globalThis.fetch,
|
|
29
|
+
url,
|
|
30
|
+
...headers !== void 0 ? { headers } : {},
|
|
31
|
+
signal: currentController.signal,
|
|
32
|
+
loggerOptions: config.logger
|
|
33
|
+
});
|
|
34
|
+
if (controller === currentController && !currentController.signal.aborted) {
|
|
35
|
+
onMessages?.(
|
|
36
|
+
mergeMessages(config.messages, loadedMessages, {
|
|
37
|
+
config,
|
|
38
|
+
locale: newLocale
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
} finally {
|
|
43
|
+
if (controller === currentController && !currentController.signal.aborted) {
|
|
44
|
+
onLoadingEnd?.();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
58
48
|
};
|
|
59
49
|
|
|
60
50
|
export { createRefetchMessages };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
// runtime > external > config
|
|
2
|
-
// Always resolves to a non-null message object.
|
|
3
1
|
function resolveEffectiveMessages(runtime, external, configMessages) {
|
|
4
|
-
|
|
2
|
+
return runtime ?? external ?? configMessages ?? {};
|
|
5
3
|
}
|
|
6
|
-
// external > internal
|
|
7
|
-
// Loading is active if either source is truthy
|
|
8
4
|
function resolveEffectiveIsLoading(external, internal) {
|
|
9
|
-
|
|
5
|
+
return !!external || internal;
|
|
10
6
|
}
|
|
11
7
|
|
|
12
8
|
export { resolveEffectiveIsLoading, resolveEffectiveMessages };
|
|
@@ -1,31 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a serialized cookie string.
|
|
3
|
-
*/
|
|
4
1
|
const buildCookieString = (cookieOptions, value) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
// Add Secure flag if not explicitly disabled
|
|
25
|
-
if (secure !== false) {
|
|
26
|
-
parts.push(`Secure`);
|
|
27
|
-
}
|
|
28
|
-
return parts.join("; ");
|
|
2
|
+
const { name, maxAge, path, domain, sameSite, secure } = cookieOptions;
|
|
3
|
+
const parts = [`${name}=${encodeURIComponent(value)}`];
|
|
4
|
+
if (maxAge !== void 0) {
|
|
5
|
+
const expires = new Date(Date.now() + maxAge * 1e3).toUTCString();
|
|
6
|
+
parts.push(`expires=${expires}`, `max-age=${maxAge}`);
|
|
7
|
+
}
|
|
8
|
+
parts.push(`path=${path ?? "/"}`);
|
|
9
|
+
if (domain) {
|
|
10
|
+
parts.push(`domain=${domain}`);
|
|
11
|
+
}
|
|
12
|
+
if (sameSite) {
|
|
13
|
+
const normalized = sameSite.charAt(0).toUpperCase() + sameSite.slice(1).toLowerCase();
|
|
14
|
+
parts.push(`SameSite=${normalized}`);
|
|
15
|
+
}
|
|
16
|
+
if (secure !== false) {
|
|
17
|
+
parts.push(`Secure`);
|
|
18
|
+
}
|
|
19
|
+
return parts.join("; ");
|
|
29
20
|
};
|
|
30
21
|
|
|
31
22
|
export { buildCookieString };
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the locale value from the browser cookie.
|
|
3
|
-
*
|
|
4
|
-
* This function relies on `document.cookie`.
|
|
5
|
-
*/
|
|
6
1
|
function getLocaleFromCookie(cookieName) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return undefined;
|
|
13
|
-
return decodeURIComponent(entry.slice(cookieName.length + 1));
|
|
2
|
+
if (typeof document === "undefined") return void 0;
|
|
3
|
+
const cookies = document.cookie.split(";").map((c) => c.trim());
|
|
4
|
+
const entry = cookies.find((c) => c.startsWith(`${cookieName}=`));
|
|
5
|
+
if (!entry) return void 0;
|
|
6
|
+
return decodeURIComponent(entry.slice(cookieName.length + 1));
|
|
14
7
|
}
|
|
15
8
|
|
|
16
9
|
export { getLocaleFromCookie };
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set the document language attribute.
|
|
3
|
-
*
|
|
4
|
-
* This function relies on `document.documentElement.lang`.
|
|
5
|
-
*/
|
|
6
1
|
function setDocumentLocale(locale) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
document.documentElement.lang = locale;
|
|
2
|
+
if (typeof document === "undefined") return;
|
|
3
|
+
document.documentElement.lang = locale;
|
|
10
4
|
}
|
|
11
5
|
|
|
12
6
|
export { setDocumentLocale };
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { buildCookieString } from '../build-cookie-string.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Persist locale to a cookie.
|
|
5
|
-
*
|
|
6
|
-
* This function relies on `document.cookie`.
|
|
7
|
-
*/
|
|
8
3
|
const setLocaleCookie = (cookieOptions, locale) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// Build and apply the cookie string
|
|
12
|
-
document.cookie = buildCookieString(cookieOptions, locale);
|
|
4
|
+
if (typeof document === "undefined") return;
|
|
5
|
+
document.cookie = buildCookieString(cookieOptions, locale);
|
|
13
6
|
};
|
|
14
7
|
|
|
15
8
|
export { setLocaleCookie };
|
|
@@ -1,49 +1,27 @@
|
|
|
1
1
|
import { ref, onMounted } from 'vue';
|
|
2
2
|
import { getClientLocale } from 'intor';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Client-side Intor runtime helper.
|
|
6
|
-
*
|
|
7
|
-
* Manages locale state and dynamic message loading
|
|
8
|
-
* in pure client-side (SPA) environments.
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
4
|
function useIntor(config, loader) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
messages.value = loaded;
|
|
34
|
-
isLoading.value = false;
|
|
35
|
-
};
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
// Initial load
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
onMounted(() => onLocaleChange(locale));
|
|
40
|
-
return {
|
|
41
|
-
config,
|
|
42
|
-
locale,
|
|
43
|
-
messages,
|
|
44
|
-
isLoading,
|
|
45
|
-
onLocaleChange,
|
|
46
|
-
};
|
|
5
|
+
const locale = getClientLocale(config);
|
|
6
|
+
const messages = ref(config.messages || {});
|
|
7
|
+
const isLoading = ref(true);
|
|
8
|
+
let activeLocale = locale;
|
|
9
|
+
const onLocaleChange = async (newLocale) => {
|
|
10
|
+
activeLocale = newLocale;
|
|
11
|
+
isLoading.value = true;
|
|
12
|
+
const loaded = await loader(config, newLocale);
|
|
13
|
+
if (activeLocale !== newLocale) return;
|
|
14
|
+
messages.value = loaded;
|
|
15
|
+
isLoading.value = false;
|
|
16
|
+
};
|
|
17
|
+
onMounted(() => onLocaleChange(locale));
|
|
18
|
+
return {
|
|
19
|
+
config,
|
|
20
|
+
locale,
|
|
21
|
+
messages,
|
|
22
|
+
isLoading,
|
|
23
|
+
onLocaleChange
|
|
24
|
+
};
|
|
47
25
|
}
|
|
48
26
|
|
|
49
27
|
export { useIntor };
|
|
@@ -8,31 +8,30 @@ import { setLocaleCookie } from '../../../shared/utils/locale/set-locale-cookie.
|
|
|
8
8
|
import { setDocumentLocale } from '../../../shared/utils/locale/set-document-locale.js';
|
|
9
9
|
|
|
10
10
|
function useLocaleEffects(config, locale) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
11
|
+
const { cookie, routing } = config;
|
|
12
|
+
let isFirstSync = true;
|
|
13
|
+
watch(
|
|
14
|
+
locale,
|
|
15
|
+
(currentLocale) => {
|
|
16
|
+
setDocumentLocale(currentLocale);
|
|
17
|
+
if (isFirstSync) {
|
|
18
|
+
isFirstSync = false;
|
|
19
|
+
const localeCookie = getLocaleFromCookie(cookie.name);
|
|
20
|
+
const isFirstVisit = !localeCookie;
|
|
21
|
+
if (shouldPersistOnFirstVisit(
|
|
22
|
+
isFirstVisit,
|
|
23
|
+
routing.inbound.firstVisit.persist
|
|
24
|
+
) && cookie.persist) {
|
|
25
|
+
setLocaleCookie(cookie, currentLocale);
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (cookie.persist) {
|
|
30
|
+
setLocaleCookie(cookie, currentLocale);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{ immediate: true }
|
|
34
|
+
);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
export { useLocaleEffects };
|
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
import { watch } from 'vue';
|
|
2
2
|
import { createRefetchMessages } from '../../../shared/messages/create-refetch-messages.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Attach message refetch side effects based on locale changes.
|
|
6
|
-
*
|
|
7
|
-
* - Skips initial run
|
|
8
|
-
* - Aborts previous in-flight requests automatically
|
|
9
|
-
* - Acts as a side-effect boundary (no state returned)
|
|
10
|
-
*/
|
|
11
4
|
function useMessagesEffects(config, locale, runtimeMessages, internalIsLoading) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
void refetchMessages(newLocale);
|
|
28
|
-
});
|
|
5
|
+
const refetchMessages = createRefetchMessages({
|
|
6
|
+
config,
|
|
7
|
+
onLoadingStart: () => {
|
|
8
|
+
internalIsLoading.value = true;
|
|
9
|
+
},
|
|
10
|
+
onLoadingEnd: () => {
|
|
11
|
+
internalIsLoading.value = false;
|
|
12
|
+
},
|
|
13
|
+
onMessages: (messages) => {
|
|
14
|
+
runtimeMessages.value = messages;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
watch(locale, (newLocale) => {
|
|
18
|
+
void refetchMessages(newLocale);
|
|
19
|
+
});
|
|
29
20
|
}
|
|
30
21
|
|
|
31
22
|
export { useMessagesEffects };
|
|
@@ -2,10 +2,10 @@ import { inject } from 'vue';
|
|
|
2
2
|
import { IntorContextKey } from './intor-provider.js';
|
|
3
3
|
|
|
4
4
|
function injectIntorContext() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const context = inject(IntorContextKey);
|
|
6
|
+
if (!context)
|
|
7
|
+
throw new Error("injectIntorContext must be used within IntorProvider");
|
|
8
|
+
return context;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export { injectIntorContext };
|