@inlang/paraglide-js 2.20.1 → 2.21.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/dist/bundler-plugins/rolldown.d.ts +1 -1
- package/dist/bundler-plugins/rollup.d.ts +1 -1
- package/dist/bundler-plugins/vite.d.ts +1 -1
- package/dist/cli/defaults.d.ts.map +1 -1
- package/dist/cli/steps/initialize-inlang-project.d.ts.map +1 -1
- package/dist/cli/steps/update-ts-config.d.ts.map +1 -1
- package/dist/cli/steps/update-ts-config.js.map +1 -1
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js.map +1 -1
- package/dist/compiler/compile-bundle.d.ts.map +1 -1
- package/dist/compiler/compile-message.d.ts.map +1 -1
- package/dist/compiler/compile-pattern.d.ts.map +1 -1
- package/dist/compiler/compile-project.d.ts.map +1 -1
- package/dist/compiler/compile.bench.js.map +1 -1
- package/dist/compiler/compiler-options.d.ts +5 -0
- package/dist/compiler/compiler-options.d.ts.map +1 -1
- package/dist/compiler/emit-ts-declarations.d.ts.map +1 -1
- package/dist/compiler/emit-ts-declarations.interop.test.d.ts +2 -0
- package/dist/compiler/emit-ts-declarations.interop.test.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.interop.test.js +62 -0
- package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.js +150 -0
- package/dist/compiler/emit-ts-declarations.js.map +1 -1
- package/dist/compiler/emit-ts-declarations.test.d.ts +2 -0
- package/dist/compiler/emit-ts-declarations.test.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.test.js +181 -0
- package/dist/compiler/emit-ts-declarations.test.js.map +1 -0
- package/dist/compiler/resolve-tsc-js-path.d.ts +10 -0
- package/dist/compiler/resolve-tsc-js-path.d.ts.map +1 -0
- package/dist/compiler/resolve-tsc-js-path.js +23 -0
- package/dist/compiler/resolve-tsc-js-path.js.map +1 -0
- package/dist/compiler/runtime/check-locale.d.ts +3 -3
- package/dist/compiler/runtime/check-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
- package/dist/compiler/runtime/create-runtime.js +10 -3
- package/dist/compiler/runtime/create-runtime.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +5 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.js +28 -4
- package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js +115 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.d.ts +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +33 -2
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request.d.ts +36 -4
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-url.d.ts +1 -1
- package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -1
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts +1 -1
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -1
- package/dist/compiler/runtime/get-locale.d.ts +36 -3
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/get-text-direction.d.ts +1 -1
- package/dist/compiler/runtime/get-text-direction.d.ts.map +1 -1
- package/dist/compiler/runtime/get-url-origin.d.ts +10 -2
- package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-href.d.ts +3 -3
- package/dist/compiler/runtime/localize-href.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-url.d.ts +4 -4
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
- package/dist/compiler/runtime/set-locale.d.ts +19 -5
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/set-locale.js +2 -0
- package/dist/compiler/runtime/set-locale.js.map +1 -1
- package/dist/compiler/runtime/should-redirect.d.ts +29 -29
- package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
- package/dist/compiler/runtime/strategy.d.ts +36 -36
- package/dist/compiler/runtime/strategy.d.ts.map +1 -1
- package/dist/compiler/runtime/track-message-call.d.ts +1 -1
- package/dist/compiler/runtime/track-message-call.d.ts.map +1 -1
- package/dist/compiler/runtime/type-definitions.d.ts +144 -43
- package/dist/compiler/runtime/type-definitions.d.ts.map +1 -1
- package/dist/compiler/runtime/type.test.js +12 -0
- package/dist/compiler/runtime/type.test.js.map +1 -1
- package/dist/compiler/runtime/variables.d.ts +60 -60
- package/dist/compiler/runtime/variables.d.ts.map +1 -1
- package/dist/compiler/server/create-server-file.js.map +1 -1
- package/dist/compiler/server/middleware.d.ts +1 -1
- package/dist/compiler/server/middleware.d.ts.map +1 -1
- package/dist/services/codegen/quotes.d.ts.map +1 -1
- package/dist/services/env-variables/create-index-file.d.ts +8 -0
- package/dist/services/env-variables/create-index-file.d.ts.map +1 -1
- package/dist/services/env-variables/create-index-file.js.map +1 -1
- package/dist/services/env-variables/index.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/file-watching/tracked-fs.js.map +1 -1
- package/dist/services/logger/index.d.ts.map +1 -1
- package/dist/services/logger/index.js.map +1 -1
- package/dist/utilities/detect-json-formatting.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -1,10 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
export function extractLocaleFromRequestWithStrategies(request: Request, strategies: typeof strategy, url?: string | URL): Locale;
|
|
1
|
+
import { strategy } from "./variables.js";
|
|
3
2
|
export type ExtractLocaleFromRequestOptions = {
|
|
4
3
|
/**
|
|
5
4
|
* - Effective request URL to use for route matching and locale detection with the URL strategy.
|
|
6
5
|
*/
|
|
7
|
-
effectiveRequestUrl?: string | URL
|
|
6
|
+
effectiveRequestUrl?: string | URL;
|
|
8
7
|
};
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {object} ExtractLocaleFromRequestOptions
|
|
10
|
+
* @property {string | URL} [effectiveRequestUrl] - Effective request URL to use for route matching and locale detection with the URL strategy.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Extracts a locale from a request.
|
|
14
|
+
*
|
|
15
|
+
* Use the function on the server to extract the locale
|
|
16
|
+
* from a request.
|
|
17
|
+
*
|
|
18
|
+
* The function goes through the strategies in the order
|
|
19
|
+
* they are defined. If a strategy returns an invalid locale,
|
|
20
|
+
* it will fall back to the next strategy.
|
|
21
|
+
*
|
|
22
|
+
* Note: Custom server strategies are not supported in this synchronous version.
|
|
23
|
+
* Use `extractLocaleFromRequestAsync` if you need custom server strategies with async getLocale methods.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const locale = extractLocaleFromRequest(request);
|
|
27
|
+
*
|
|
28
|
+
* @param {Request} request
|
|
29
|
+
* @param {ExtractLocaleFromRequestOptions} [options]
|
|
30
|
+
* @returns {Locale}
|
|
31
|
+
*/
|
|
32
|
+
export declare const extractLocaleFromRequest: (request: Request, options?: ExtractLocaleFromRequestOptions) => Locale;
|
|
33
|
+
/**
|
|
34
|
+
* Extracts a locale from a request using the provided strategy order.
|
|
35
|
+
*
|
|
36
|
+
* @param {Request} request
|
|
37
|
+
* @param {typeof strategy} strategies
|
|
38
|
+
* @param {string | URL} [url]
|
|
39
|
+
* @returns {Locale}
|
|
40
|
+
*/
|
|
41
|
+
export declare const extractLocaleFromRequestWithStrategies: (request: Request, strategies: typeof strategy, url?: string | URL) => Locale;
|
|
10
42
|
//# sourceMappingURL=extract-locale-from-request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-request.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract-locale-from-request.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-request.js"],"names":[],"mappings":"AAIA,OAAO,EAIN,QAAQ,EAIR,MAAM,gBAAgB,CAAC;AAGrB,YAAkB,+BAA+B,GACjD;;;;IAA0B,mBAAmB,AAA7C,CACF,EADa,MAAM,GAAG,GAAG,CACzB;CAAA,CAAA;AAHD;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,wBAAwB,YAJ1B,OAAO,YACP,+BAA+B,KAC7B,MAYZ,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC,YALxC,OAAO,cACP,OAAO,QAAQ,QACf,MAAM,GAAG,GAAG,KACV,MA+CZ,CAAC"}
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* @param {URL|string} url - The full URL from which to extract the locale.
|
|
9
9
|
* @returns {Locale|undefined} The extracted locale, or undefined if no locale is found.
|
|
10
10
|
*/
|
|
11
|
-
export function extractLocaleFromUrl(url: URL | string): Locale | undefined;
|
|
11
|
+
export declare function extractLocaleFromUrl(url: URL | string): Locale | undefined;
|
|
12
12
|
//# sourceMappingURL=extract-locale-from-url.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-locale-from-url.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-url.js"],"names":[],"mappings":"AAkBA;;;;;;;;;GASG;AACH,
|
|
1
|
+
{"version":3,"file":"extract-locale-from-url.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-url.js"],"names":[],"mappings":"AAkBA;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAH7B,GAAG,GAAC,MAGyB,GAF3B,MAAM,GAAC,SAAS,CAmC5B"}
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
* @returns {URL[]} Array of URL objects representing all localized variants.
|
|
42
42
|
* The order follows each input URL with all its locale variants before moving to the next URL.
|
|
43
43
|
*/
|
|
44
|
-
export function generateStaticLocalizedUrls(urls: (string | URL)[]): URL[];
|
|
44
|
+
export declare function generateStaticLocalizedUrls(urls: (string | URL)[]): URL[];
|
|
45
45
|
//# sourceMappingURL=generate-static-localized-urls.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-static-localized-urls.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/generate-static-localized-urls.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,
|
|
1
|
+
{"version":3,"file":"generate-static-localized-urls.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/generate-static-localized-urls.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EANrC,CAAC,MAAM,GAAG,GAAG,CAAC,EAMuB,GAHnC,GAAG,EAAE,CAmFjB"}
|
|
@@ -1,10 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current locale.
|
|
3
|
+
*
|
|
4
|
+
* The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.)
|
|
5
|
+
* in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage
|
|
6
|
+
* which is set by the `paraglideMiddleware()`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://paraglidejs.com/strategy - Configure locale detection strategies
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* if (getLocale() === 'de') {
|
|
12
|
+
* console.log('Germany 🇩🇪');
|
|
13
|
+
* } else if (getLocale() === 'nl') {
|
|
14
|
+
* console.log('Netherlands 🇳🇱');
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @returns {Locale} The current locale.
|
|
18
|
+
*/
|
|
19
|
+
export declare let getLocale: () => Locale;
|
|
1
20
|
/**
|
|
2
21
|
* Resolve locale for a given URL using route-aware strategies.
|
|
3
22
|
*
|
|
4
23
|
* @param {string | URL} url
|
|
5
24
|
* @returns {Locale}
|
|
6
25
|
*/
|
|
7
|
-
export function getLocaleForUrl(url: string | URL): Locale;
|
|
8
|
-
|
|
9
|
-
|
|
26
|
+
export declare function getLocaleForUrl(url: string | URL): Locale;
|
|
27
|
+
/**
|
|
28
|
+
* Overwrite the `getLocale()` function.
|
|
29
|
+
*
|
|
30
|
+
* Use this function to overwrite how the locale is resolved. This is useful
|
|
31
|
+
* for custom locale resolution or advanced use cases like SSG with concurrent rendering.
|
|
32
|
+
*
|
|
33
|
+
* @see https://paraglidejs.com/strategy
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* overwriteGetLocale(() => {
|
|
37
|
+
* return Cookies.get('locale') ?? baseLocale
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* @param {() => Locale} fn - The new implementation for `getLocale()`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const overwriteGetLocale: (fn: () => Locale) => void;
|
|
10
43
|
//# sourceMappingURL=get-locale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.js"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,IAAI,SAAS,QAFP,MAsCZ,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAHxB,MAAM,GAAG,GAGe,GAFtB,MAAM,CAmBlB;AAiED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,OAFpB,MAAM,MAAM,SAItB,CAAC"}
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
* @param {string} [locale] - Target locale. If not provided, uses `getLocale()`
|
|
13
13
|
* @returns {"ltr" | "rtl"}
|
|
14
14
|
*/
|
|
15
|
-
export function getTextDirection(locale?: string): "ltr" | "rtl";
|
|
15
|
+
export declare function getTextDirection(locale?: string): "ltr" | "rtl";
|
|
16
16
|
//# sourceMappingURL=get-text-direction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-text-direction.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-text-direction.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;GAaG;AACH,
|
|
1
|
+
{"version":3,"file":"get-text-direction.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-text-direction.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,AAHpC,CACA,EADQ,MAG0C,GAFxC,KAAK,GAAG,KAAK,CAoBzB"}
|
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @type {() => string}
|
|
9
9
|
*/
|
|
10
|
-
export let getUrlOrigin: () => string;
|
|
11
|
-
|
|
10
|
+
export declare let getUrlOrigin: () => string;
|
|
11
|
+
/**
|
|
12
|
+
* Overwrite the getUrlOrigin function.
|
|
13
|
+
*
|
|
14
|
+
* Use this function in server environments to
|
|
15
|
+
* define how the URL origin is resolved.
|
|
16
|
+
*
|
|
17
|
+
* @param {() => string} fn - The new implementation for `getUrlOrigin()`.
|
|
18
|
+
*/
|
|
19
|
+
export declare let overwriteGetUrlOrigin: (fn: () => string) => void;
|
|
12
20
|
//# sourceMappingURL=get-url-origin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-url-origin.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,
|
|
1
|
+
{"version":3,"file":"get-url-origin.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,IAAI,YAAY,EAFb,MAAM,MASf,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,IAAI,qBAAqB,OAFrB,MAAM,MAAM,SAItB,CAAC"}
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
* @param {Locale} [options.locale] - Target locale. If not provided, uses `getLocale()`
|
|
39
39
|
* @returns {string} The localized href, relative if input was relative
|
|
40
40
|
*/
|
|
41
|
-
export function localizeHref(href: string, options?: {
|
|
42
|
-
locale?:
|
|
41
|
+
export declare function localizeHref(href: string, options?: {
|
|
42
|
+
locale?: Locale;
|
|
43
43
|
}): string;
|
|
44
44
|
/**
|
|
45
45
|
* High-level URL de-localization function optimized for client-side UI usage.
|
|
@@ -81,5 +81,5 @@ export function localizeHref(href: string, options?: {
|
|
|
81
81
|
* @param {string} href - The href to de-localize (can be relative or absolute)
|
|
82
82
|
* @returns {string} The de-localized href, relative if input was relative
|
|
83
83
|
*/
|
|
84
|
-
export function deLocalizeHref(href: string): string;
|
|
84
|
+
export declare function deLocalizeHref(href: string): string;
|
|
85
85
|
//# sourceMappingURL=localize-href.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize-href.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-href.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,
|
|
1
|
+
{"version":3,"file":"localize-href.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-href.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,YAAY,CAAC,IAAI,EALtB,MAKsB,EAAE,OAAO,AAJvC,CAEA,EADA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;CAEuC,GAF7B,MAAM,CAyBlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAHxB,MAGwB,GAFtB,MAAM,CAclB"}
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
* @param {Locale} [options.locale] - Target locale. If not provided, uses getLocale()
|
|
43
43
|
* @returns {URL} The localized URL, always absolute
|
|
44
44
|
*/
|
|
45
|
-
export function localizeUrl(url: string | URL, options?: {
|
|
46
|
-
locale?:
|
|
45
|
+
export declare function localizeUrl(url: string | URL, options?: {
|
|
46
|
+
locale?: Locale;
|
|
47
47
|
}): URL;
|
|
48
48
|
/**
|
|
49
49
|
* Low-level URL de-localization function, primarily used in server contexts.
|
|
@@ -84,7 +84,7 @@ export function localizeUrl(url: string | URL, options?: {
|
|
|
84
84
|
* @param {string | URL} url - The URL to de-localize. If string, must be absolute.
|
|
85
85
|
* @returns {URL} The de-localized URL, always absolute
|
|
86
86
|
*/
|
|
87
|
-
export function deLocalizeUrl(url: string | URL): URL;
|
|
87
|
+
export declare function deLocalizeUrl(url: string | URL): URL;
|
|
88
88
|
/**
|
|
89
89
|
* Aggregates named groups from various parts of the URLPattern match result.
|
|
90
90
|
*
|
|
@@ -92,5 +92,5 @@ export function deLocalizeUrl(url: string | URL): URL;
|
|
|
92
92
|
* @param {any} match - The URLPattern match result object.
|
|
93
93
|
* @returns {Record<string, string | null | undefined>} An object containing all named groups from the match.
|
|
94
94
|
*/
|
|
95
|
-
export function aggregateGroups(match: any): Record<string, string | null | undefined>;
|
|
95
|
+
export declare function aggregateGroups(match: any): Record<string, string | null | undefined>;
|
|
96
96
|
//# sourceMappingURL=localize-url.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize-url.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-url.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,
|
|
1
|
+
{"version":3,"file":"localize-url.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-url.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,WAAW,CAAC,GAAG,EALpB,MAAM,GAAG,GAKW,EAAE,OAAO,AAJrC,CAEA,EADA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;CAEqC,GAF3B,GAAG,CA2Df;AAsCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAHtB,MAAM,GAAG,GAGa,GAFpB,GAAG,CAwCf;AAiJD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAH1B,GAG0B,GAFxB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAarD"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export type SetLocaleFn = (newLocale: Locale, options?: {
|
|
2
|
+
reload?: boolean;
|
|
3
|
+
}) => void | Promise<void>;
|
|
1
4
|
/**
|
|
2
5
|
* @typedef {(newLocale: Locale, options?: { reload?: boolean }) => void | Promise<void>} SetLocaleFn
|
|
3
6
|
*/
|
|
@@ -22,9 +25,20 @@
|
|
|
22
25
|
*
|
|
23
26
|
* @type {SetLocaleFn}
|
|
24
27
|
*/
|
|
25
|
-
export let setLocale: SetLocaleFn;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
export declare let setLocale: SetLocaleFn;
|
|
29
|
+
/**
|
|
30
|
+
* Overwrite the `setLocale()` function.
|
|
31
|
+
*
|
|
32
|
+
* Use this function to overwrite how the locale is set. For example,
|
|
33
|
+
* modify a cookie, env variable, or a user's preference.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* overwriteSetLocale((newLocale) => {
|
|
37
|
+
* // set the locale in a cookie
|
|
38
|
+
* return Cookies.set('locale', newLocale)
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* @param {SetLocaleFn} fn
|
|
42
|
+
*/
|
|
43
|
+
export declare const overwriteSetLocale: (fn: SetLocaleFn) => void;
|
|
30
44
|
//# sourceMappingURL=set-locale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/set-locale.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/set-locale.js"],"names":[],"mappings":"AAkCG,YAAuF,WAAW,GAAxF,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAa;AADrG;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,IAAI,SAAS,EAFV,WA8GT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,OAFpB,WAAW,SAIrB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getLocale } from "./get-locale.js";
|
|
2
|
+
import { clearLocaleCookieCache } from "./extract-locale-from-cookie.js";
|
|
2
3
|
import { localizeUrl } from "./localize-url.js";
|
|
3
4
|
import { customClientStrategies, isCustomStrategy } from "./strategy.js";
|
|
4
5
|
import { cookieDomain, cookieMaxAge, cookieName, getStrategyForUrl, isServer, localStorageKey, strategy, TREE_SHAKE_COOKIE_STRATEGY_USED, TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED, TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED, TREE_SHAKE_URL_STRATEGY_USED, } from "./variables.js";
|
|
@@ -82,6 +83,7 @@ export let setLocale = (newLocale, options) => {
|
|
|
82
83
|
document.cookie = cookieDomain
|
|
83
84
|
? `${cookieString}; domain=${cookieDomain}`
|
|
84
85
|
: cookieString;
|
|
86
|
+
clearLocaleCookieCache();
|
|
85
87
|
}
|
|
86
88
|
else if (strat === "baseLocale") {
|
|
87
89
|
// nothing to be set here. baseLocale is only a fallback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-locale.js","sourceRoot":"","sources":["../../../src/compiler/runtime/set-locale.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,+BAA+B,EAC/B,wCAAwC,EACxC,sCAAsC,EACtC,4BAA4B,GAC5B,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,EAAE;IACxC,IAAI,WAAW,EAAE,CAAC;QACjB,+CAA+C;QAC/C,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,WAAW,CAAC;IACpC,CAAC;SAAM,CAAC;QACP,4CAA4C;QAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;AACF,CAAC,CAAC;AAEF;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,IAAI,SAAS,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;IAC7C,MAAM,mBAAmB,GAAG;QAC3B,MAAM,EAAE,IAAI;QACZ,GAAG,OAAO;KACV,CAAC;IACF,wBAAwB;IACxB,0DAA0D;IAC1D,iCA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,31 @@
|
|
|
1
|
+
export type ShouldRedirectServerInput = {
|
|
2
|
+
request: Request;
|
|
3
|
+
/**
|
|
4
|
+
* - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
|
|
5
|
+
*/
|
|
6
|
+
effectiveRequestUrl?: string | URL;
|
|
7
|
+
locale?: Locale;
|
|
8
|
+
};
|
|
9
|
+
export type ShouldRedirectClientInput = {
|
|
10
|
+
request?: undefined;
|
|
11
|
+
url?: string | URL;
|
|
12
|
+
locale?: Locale;
|
|
13
|
+
};
|
|
14
|
+
export type ShouldRedirectInput = ShouldRedirectServerInput | ShouldRedirectClientInput;
|
|
15
|
+
export type ShouldRedirectResult = {
|
|
16
|
+
/**
|
|
17
|
+
* - Indicates whether the consumer should perform a redirect.
|
|
18
|
+
*/
|
|
19
|
+
shouldRedirect: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* - Locale resolved using the configured strategies.
|
|
22
|
+
*/
|
|
23
|
+
locale: Locale;
|
|
24
|
+
/**
|
|
25
|
+
* - Destination URL when a redirect is required.
|
|
26
|
+
*/
|
|
27
|
+
redirectUrl: URL | undefined;
|
|
28
|
+
};
|
|
1
29
|
/**
|
|
2
30
|
* @typedef {object} ShouldRedirectServerInput
|
|
3
31
|
* @property {Request} request
|
|
@@ -69,33 +97,5 @@
|
|
|
69
97
|
* @param {ShouldRedirectInput} [input]
|
|
70
98
|
* @returns {Promise<ShouldRedirectResult>}
|
|
71
99
|
*/
|
|
72
|
-
export function shouldRedirect(input?: ShouldRedirectInput): Promise<ShouldRedirectResult>;
|
|
73
|
-
export type ShouldRedirectServerInput = {
|
|
74
|
-
request: Request;
|
|
75
|
-
/**
|
|
76
|
-
* - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
|
|
77
|
-
*/
|
|
78
|
-
effectiveRequestUrl?: string | URL | undefined;
|
|
79
|
-
locale?: string | undefined;
|
|
80
|
-
};
|
|
81
|
-
export type ShouldRedirectClientInput = {
|
|
82
|
-
request?: undefined;
|
|
83
|
-
url?: string | URL | undefined;
|
|
84
|
-
locale?: string | undefined;
|
|
85
|
-
};
|
|
86
|
-
export type ShouldRedirectInput = ShouldRedirectServerInput | ShouldRedirectClientInput;
|
|
87
|
-
export type ShouldRedirectResult = {
|
|
88
|
-
/**
|
|
89
|
-
* - Indicates whether the consumer should perform a redirect.
|
|
90
|
-
*/
|
|
91
|
-
shouldRedirect: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* - Locale resolved using the configured strategies.
|
|
94
|
-
*/
|
|
95
|
-
locale: Locale;
|
|
96
|
-
/**
|
|
97
|
-
* - Destination URL when a redirect is required.
|
|
98
|
-
*/
|
|
99
|
-
redirectUrl: URL | undefined;
|
|
100
|
-
};
|
|
100
|
+
export declare function shouldRedirect(input?: ShouldRedirectInput): Promise<ShouldRedirectResult>;
|
|
101
101
|
//# sourceMappingURL=should-redirect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-redirect.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/should-redirect.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"should-redirect.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/should-redirect.js"],"names":[],"mappings":"AAQG,YAAkB,yBAAyB,GAC3C;IAAoB,OAAO,EAAhB,OAAO,CAClB;;;;IAA0B,mBAAmB,AAA7C,CACA,EADW,MAAM,GAAG,GAAG,CACvB;IAAoB,MAAM,AAA1B,CAEA,EAFW,MAAM,CAEjB;CAAA,CAAA;AAAA,YAAkB,yBAAyB,GAC3C;IAAuB,OAAO,AAA9B,CACA,EADW,SAAS,CACpB;IAA0B,GAAG,AAA7B,CACA,EADW,MAAM,GAAG,GAAG,CACvB;IAAoB,MAAM,AAA1B,CAEA,EAFW,MAAM,CAEjB;CAAA,CAAA;AAAA,YAAiE,mBAAmB,GAA1E,yBAAyB,GAAG,yBAAyB,CAAqB;AAEpF,YAAkB,oBAAoB,GACtC;;;;IAAoB,cAAc,EAAvB,OAAO,CAClB;;;;IAAmB,MAAM,EAAd,MAAM,CACjB;;;;IAA4B,WAAW,EAA5B,GAAG,GAAG,SAAS,CAC5B;CAAA,CAAA;AAjBD;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAsB,cAAc,CAAC,KAAK,AAHvC,CACA,EADQ,mBAGoC,GAFlC,OAAO,CAAC,oBAAoB,CAAC,CAqBzC"}
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage"} BuiltInStrategy
|
|
3
|
+
*/
|
|
4
|
+
export type BuiltInStrategy = "cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage";
|
|
5
|
+
export type CustomStrategy = `custom_${string}`;
|
|
6
|
+
export type Strategy = BuiltInStrategy | CustomStrategy;
|
|
7
|
+
export type Strategies = Array<Strategy>;
|
|
8
|
+
export type CustomServerStrategyHandler = {
|
|
9
|
+
getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined);
|
|
10
|
+
};
|
|
11
|
+
export type CustomClientStrategyHandler = {
|
|
12
|
+
getLocale: () => Promise<string | undefined> | (string | undefined);
|
|
13
|
+
setLocale: (locale: string) => Promise<void> | void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {`custom_${string}`} CustomStrategy
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {BuiltInStrategy | CustomStrategy} Strategy
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Array<Strategy>} Strategies
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {{ getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined) }} CustomServerStrategyHandler
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{ getLocale: () => Promise<string|undefined> | (string | undefined), setLocale: (locale: string) => Promise<void> | void }} CustomClientStrategyHandler
|
|
29
|
+
*/
|
|
30
|
+
/** @type {Map<string, CustomServerStrategyHandler>} */
|
|
31
|
+
export declare const customServerStrategies: Map<string, CustomServerStrategyHandler>;
|
|
32
|
+
/** @type {Map<string, CustomClientStrategyHandler>} */
|
|
33
|
+
export declare const customClientStrategies: Map<string, CustomClientStrategyHandler>;
|
|
1
34
|
/**
|
|
2
35
|
* Checks if the given strategy is a custom strategy.
|
|
3
36
|
*
|
|
@@ -5,7 +38,7 @@
|
|
|
5
38
|
* Must be a string that starts with "custom-" followed by alphanumeric characters, hyphens, or underscores.
|
|
6
39
|
* @returns {boolean} Returns true if it is a custom strategy, false otherwise.
|
|
7
40
|
*/
|
|
8
|
-
export function isCustomStrategy(strategy: unknown): boolean;
|
|
41
|
+
export declare function isCustomStrategy(strategy: unknown): boolean;
|
|
9
42
|
/**
|
|
10
43
|
* Defines a custom strategy that is executed on the server.
|
|
11
44
|
*
|
|
@@ -16,7 +49,7 @@ export function isCustomStrategy(strategy: unknown): boolean;
|
|
|
16
49
|
* the method getLocale.
|
|
17
50
|
* @returns {void}
|
|
18
51
|
*/
|
|
19
|
-
export function defineCustomServerStrategy(strategy: string, handler: CustomServerStrategyHandler): void;
|
|
52
|
+
export declare function defineCustomServerStrategy(strategy: string, handler: CustomServerStrategyHandler): void;
|
|
20
53
|
/**
|
|
21
54
|
* Defines a custom strategy that is executed on the client.
|
|
22
55
|
*
|
|
@@ -27,38 +60,5 @@ export function defineCustomServerStrategy(strategy: string, handler: CustomServ
|
|
|
27
60
|
* methods getLocale and setLocale.
|
|
28
61
|
* @returns {void}
|
|
29
62
|
*/
|
|
30
|
-
export function defineCustomClientStrategy(strategy: string, handler: CustomClientStrategyHandler): void;
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage"} BuiltInStrategy
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* @typedef {`custom_${string}`} CustomStrategy
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* @typedef {BuiltInStrategy | CustomStrategy} Strategy
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* @typedef {Array<Strategy>} Strategies
|
|
42
|
-
*/
|
|
43
|
-
/**
|
|
44
|
-
* @typedef {{ getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined) }} CustomServerStrategyHandler
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* @typedef {{ getLocale: () => Promise<string|undefined> | (string | undefined), setLocale: (locale: string) => Promise<void> | void }} CustomClientStrategyHandler
|
|
48
|
-
*/
|
|
49
|
-
/** @type {Map<string, CustomServerStrategyHandler>} */
|
|
50
|
-
export const customServerStrategies: Map<string, CustomServerStrategyHandler>;
|
|
51
|
-
/** @type {Map<string, CustomClientStrategyHandler>} */
|
|
52
|
-
export const customClientStrategies: Map<string, CustomClientStrategyHandler>;
|
|
53
|
-
export type BuiltInStrategy = "cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage";
|
|
54
|
-
export type CustomStrategy = `custom_${string}`;
|
|
55
|
-
export type Strategy = BuiltInStrategy | CustomStrategy;
|
|
56
|
-
export type Strategies = Array<Strategy>;
|
|
57
|
-
export type CustomServerStrategyHandler = {
|
|
58
|
-
getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined);
|
|
59
|
-
};
|
|
60
|
-
export type CustomClientStrategyHandler = {
|
|
61
|
-
getLocale: () => Promise<string | undefined> | (string | undefined);
|
|
62
|
-
setLocale: (locale: string) => Promise<void> | void;
|
|
63
|
-
};
|
|
63
|
+
export declare function defineCustomClientStrategy(strategy: string, handler: CustomClientStrategyHandler): void;
|
|
64
64
|
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/strategy.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/strategy.js"],"names":[],"mappings":"AAAA;;GAEG;AADA,YAAqG,eAAe,GAA1G,QAAQ,GAAG,YAAY,GAAG,gBAAgB,GAAG,KAAK,GAAG,mBAAmB,GAAG,cAAc,CAAiB;AAIpH,YAA8B,cAAc,GAAlC,UAAU,MAAM,EAAE,CAAgB;AAI5C,YAA4C,QAAQ,GAA1C,eAAe,GAAG,cAAc,CAAU;AAIpD,YAA2B,UAAU,GAA3B,KAAK,CAAC,QAAQ,CAAC,CAAY;AAIrC,YAAoG,2BAA2B,GAArH;IAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,CAA6B;AAI/H,YAAsI,2BAA2B,GAAvJ;IAAE,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,GAAC,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE,CAA6B;AAjBpK;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,EADxB,GAAG,CAAC,MAAM,EAAE,2BAA2B,CACH,CAAC;AAChD,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,EADxB,GAAG,CAAC,MAAM,EAAE,2BAA2B,CACH,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAJ9B,OAI8B,GAF5B,OAAO,CAMnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EALxC,MAKwC,EAAE,OAAO,EAJjD,2BAIiD,GAF/C,IAAI,CAUhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EALxC,MAKwC,EAAE,OAAO,EAJjD,2BAIiD,GAF/C,IAAI,CAUhB"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* @param {string} safeModuleId
|
|
3
3
|
* @param {Locale} locale
|
|
4
4
|
*/
|
|
5
|
-
export function trackMessageCall(safeModuleId: string, locale: Locale): void;
|
|
5
|
+
export declare function trackMessageCall(safeModuleId: string, locale: Locale): void;
|
|
6
6
|
//# sourceMappingURL=track-message-call.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track-message-call.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/track-message-call.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH
|
|
1
|
+
{"version":3,"file":"track-message-call.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/track-message-call.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAHlC,MAGkC,EAAE,MAAM,EAF1C,MAE0C,QAQpD"}
|