astro-intlayer 9.6.0 → 9.7.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/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/cjs/client/format/index.cjs +9 -9
- package/dist/cjs/client/index.cjs +13 -13
- package/dist/cjs/client/localeRedirect.cjs +1 -2
- package/dist/cjs/emitRewrittenPages.cjs +1 -2
- package/dist/cjs/format/index.cjs +9 -9
- package/dist/cjs/format/useCompact.cjs +3 -6
- package/dist/cjs/format/useCompact.cjs.map +1 -1
- package/dist/cjs/format/useCurrency.cjs +3 -6
- package/dist/cjs/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/format/useDate.cjs +3 -6
- package/dist/cjs/format/useDate.cjs.map +1 -1
- package/dist/cjs/format/useIntl.cjs +5 -8
- package/dist/cjs/format/useIntl.cjs.map +1 -1
- package/dist/cjs/format/useList.cjs +3 -6
- package/dist/cjs/format/useList.cjs.map +1 -1
- package/dist/cjs/format/useNumber.cjs +3 -6
- package/dist/cjs/format/useNumber.cjs.map +1 -1
- package/dist/cjs/format/usePercentage.cjs +3 -6
- package/dist/cjs/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/format/useRelativeTime.cjs +3 -6
- package/dist/cjs/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/format/useUnit.cjs +3 -6
- package/dist/cjs/format/useUnit.cjs.map +1 -1
- package/dist/cjs/html/index.cjs +5 -5
- package/dist/cjs/index.cjs +5 -6
- package/dist/cjs/integration.cjs +2 -3
- package/dist/cjs/markdown/index.cjs +7 -7
- package/dist/cjs/middleware.cjs +3 -4
- package/dist/cjs/requestStorage.cjs +1 -2
- package/dist/cjs/useDictionary.cjs +3 -4
- package/dist/cjs/useIntlayer.cjs +3 -4
- package/dist/cjs/useLocale.cjs +2 -3
- package/dist/cjs/withInertOnChange.cjs +1 -2
- package/dist/esm/client/localeRedirect.mjs +1 -2
- package/dist/esm/emitRewrittenPages.mjs +1 -2
- package/dist/esm/format/useCompact.mjs +2 -5
- package/dist/esm/format/useCompact.mjs.map +1 -1
- package/dist/esm/format/useCurrency.mjs +2 -5
- package/dist/esm/format/useCurrency.mjs.map +1 -1
- package/dist/esm/format/useDate.mjs +2 -5
- package/dist/esm/format/useDate.mjs.map +1 -1
- package/dist/esm/format/useIntl.mjs +4 -7
- package/dist/esm/format/useIntl.mjs.map +1 -1
- package/dist/esm/format/useList.mjs +2 -5
- package/dist/esm/format/useList.mjs.map +1 -1
- package/dist/esm/format/useNumber.mjs +2 -5
- package/dist/esm/format/useNumber.mjs.map +1 -1
- package/dist/esm/format/usePercentage.mjs +2 -5
- package/dist/esm/format/usePercentage.mjs.map +1 -1
- package/dist/esm/format/useRelativeTime.mjs +2 -5
- package/dist/esm/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/format/useUnit.mjs +2 -5
- package/dist/esm/format/useUnit.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/integration.mjs +1 -2
- package/dist/esm/middleware.mjs +1 -2
- package/dist/esm/requestStorage.mjs +1 -2
- package/dist/esm/useDictionary.mjs +1 -2
- package/dist/esm/useIntlayer.mjs +1 -2
- package/dist/esm/useLocale.mjs +1 -2
- package/dist/esm/withInertOnChange.mjs +1 -2
- package/dist/types/client/localeRedirect.d.ts +0 -2
- package/dist/types/client/localeRedirect.d.ts.map +1 -1
- package/dist/types/emitRewrittenPages.d.ts +0 -2
- package/dist/types/emitRewrittenPages.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +0 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +0 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +0 -2
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useIntl.d.ts +2 -4
- package/dist/types/format/useIntl.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +0 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +0 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +0 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +0 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +0 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/integration.d.ts +1 -2
- package/dist/types/integration.d.ts.map +1 -1
- package/dist/types/middleware.d.ts +0 -2
- package/dist/types/middleware.d.ts.map +1 -1
- package/dist/types/requestStorage.d.ts +0 -2
- package/dist/types/requestStorage.d.ts.map +1 -1
- package/dist/types/useDictionary.d.ts +0 -2
- package/dist/types/useDictionary.d.ts.map +1 -1
- package/dist/types/useIntlayer.d.ts +0 -2
- package/dist/types/useIntlayer.d.ts.map +1 -1
- package/dist/types/useLocale.d.ts +0 -2
- package/dist/types/useLocale.d.ts.map +1 -1
- package/dist/types/withInertOnChange.d.ts +0 -2
- package/dist/types/withInertOnChange.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let vanilla_intlayer_markdown = require("vanilla-intlayer/markdown");
|
|
3
3
|
|
|
4
|
-
Object.defineProperty(exports,
|
|
4
|
+
Object.defineProperty(exports, "compileMarkdown", {
|
|
5
5
|
enumerable: true,
|
|
6
6
|
get: function () {
|
|
7
7
|
return vanilla_intlayer_markdown.compileMarkdown;
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
|
-
Object.defineProperty(exports,
|
|
10
|
+
Object.defineProperty(exports, "installIntlayerMarkdown", {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
13
|
return vanilla_intlayer_markdown.installIntlayerMarkdown;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
Object.defineProperty(exports,
|
|
16
|
+
Object.defineProperty(exports, "installIntlayerMarkdownDynamic", {
|
|
17
17
|
enumerable: true,
|
|
18
18
|
get: function () {
|
|
19
19
|
return vanilla_intlayer_markdown.installIntlayerMarkdownDynamic;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
Object.defineProperty(exports,
|
|
22
|
+
Object.defineProperty(exports, "parseMarkdown", {
|
|
23
23
|
enumerable: true,
|
|
24
24
|
get: function () {
|
|
25
25
|
return vanilla_intlayer_markdown.parseMarkdown;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
Object.defineProperty(exports,
|
|
28
|
+
Object.defineProperty(exports, "renderMarkdown", {
|
|
29
29
|
enumerable: true,
|
|
30
30
|
get: function () {
|
|
31
31
|
return vanilla_intlayer_markdown.renderMarkdown;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
Object.defineProperty(exports,
|
|
34
|
+
Object.defineProperty(exports, "useMarkdown", {
|
|
35
35
|
enumerable: true,
|
|
36
36
|
get: function () {
|
|
37
37
|
return vanilla_intlayer_markdown.useMarkdown;
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
Object.defineProperty(exports,
|
|
40
|
+
Object.defineProperty(exports, "useMarkdownRenderer", {
|
|
41
41
|
enumerable: true,
|
|
42
42
|
get: function () {
|
|
43
43
|
return vanilla_intlayer_markdown.useMarkdownRenderer;
|
package/dist/cjs/middleware.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const require_requestStorage = require(
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_requestStorage = require("./requestStorage.cjs");
|
|
4
4
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
5
5
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
6
|
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
7
7
|
let vite_intlayer_web_proxy_handler = require("vite-intlayer/web-proxy-handler");
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// src/middleware.ts
|
|
10
10
|
/**
|
|
11
11
|
* Whether `astro dev` is serving the app. Vite inlines `import.meta.env.DEV`
|
|
12
12
|
* into the server bundle; the optional chain keeps the module loadable where
|
|
@@ -98,6 +98,5 @@ const onRequest = async (context, next) => {
|
|
|
98
98
|
return proxyOutcome ? withProxyHeaders(response, proxyOutcome.headers) : response;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
//#endregion
|
|
102
101
|
exports.onRequest = onRequest;
|
|
103
102
|
//# sourceMappingURL=middleware.cjs.map
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
let node_async_hooks = require("node:async_hooks");
|
|
3
3
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/requestStorage.ts
|
|
6
6
|
/**
|
|
7
7
|
* `Astro.locals` of the request being rendered, made available to every
|
|
8
8
|
* function running inside the middleware scope — page and component
|
|
@@ -19,7 +19,6 @@ const getIntlayerLocals = () => requestStorage.getStore()?.intlayer;
|
|
|
19
19
|
const getRequestLocale = () => getIntlayerLocals()?.locale;
|
|
20
20
|
(0, _intlayer_core_interpreter.registerAmbientLocaleResolver)(getRequestLocale);
|
|
21
21
|
|
|
22
|
-
//#endregion
|
|
23
22
|
exports.getIntlayerLocals = getIntlayerLocals;
|
|
24
23
|
exports.getRequestLocale = getRequestLocale;
|
|
25
24
|
exports.requestStorage = requestStorage;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_requestStorage = require(
|
|
3
|
-
const require_withInertOnChange = require(
|
|
2
|
+
const require_requestStorage = require("./requestStorage.cjs");
|
|
3
|
+
const require_withInertOnChange = require("./withInertOnChange.cjs");
|
|
4
4
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
5
5
|
let vanilla_intlayer = require("vanilla-intlayer");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/useDictionary.ts
|
|
8
8
|
/**
|
|
9
9
|
* Transforms an imported dictionary (or qualified dictionary group) and returns
|
|
10
10
|
* its content for the locale of the request being rendered, read from
|
|
@@ -33,6 +33,5 @@ const useDictionary = (dictionary, localeOrSelector) => require_withInertOnChang
|
|
|
33
33
|
dictionaryKey: dictionary.key
|
|
34
34
|
}) : localeOrSelector ?? require_requestStorage.getRequestLocale()));
|
|
35
35
|
|
|
36
|
-
//#endregion
|
|
37
36
|
exports.useDictionary = useDictionary;
|
|
38
37
|
//# sourceMappingURL=useDictionary.cjs.map
|
package/dist/cjs/useIntlayer.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_requestStorage = require(
|
|
3
|
-
const require_withInertOnChange = require(
|
|
2
|
+
const require_requestStorage = require("./requestStorage.cjs");
|
|
3
|
+
const require_withInertOnChange = require("./withInertOnChange.cjs");
|
|
4
4
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
5
5
|
let vanilla_intlayer = require("vanilla-intlayer");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/useIntlayer.ts
|
|
8
8
|
/**
|
|
9
9
|
* Picks one dictionary by its key and returns its content for the locale of
|
|
10
10
|
* the request being rendered, read from `Astro.locals.intlayer`.
|
|
@@ -33,6 +33,5 @@ const useIntlayer = (key, localeOrSelector) => require_withInertOnChange.withIne
|
|
|
33
33
|
dictionaryKey: key
|
|
34
34
|
}) : localeOrSelector ?? require_requestStorage.getRequestLocale()));
|
|
35
35
|
|
|
36
|
-
//#endregion
|
|
37
36
|
exports.useIntlayer = useIntlayer;
|
|
38
37
|
//# sourceMappingURL=useIntlayer.cjs.map
|
package/dist/cjs/useLocale.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_requestStorage = require(
|
|
2
|
+
const require_requestStorage = require("./requestStorage.cjs");
|
|
3
3
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/useLocale.ts
|
|
6
6
|
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization;
|
|
7
7
|
/**
|
|
8
8
|
* Returns the locale of the request being rendered, read from
|
|
@@ -36,6 +36,5 @@ const useLocale = (_props = {}) => ({
|
|
|
36
36
|
subscribe: () => () => {}
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
39
|
exports.useLocale = useLocale;
|
|
41
40
|
//# sourceMappingURL=useLocale.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/withInertOnChange.ts
|
|
3
3
|
/**
|
|
4
4
|
* Gives server-rendered content the `.onChange()` of its client counterpart.
|
|
5
5
|
*
|
|
@@ -12,6 +12,5 @@ const withInertOnChange = (content) => {
|
|
|
12
12
|
return content;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
//#endregion
|
|
16
15
|
exports.withInertOnChange = withInertOnChange;
|
|
17
16
|
//# sourceMappingURL=withInertOnChange.cjs.map
|
|
@@ -2,7 +2,7 @@ import { getLocalizedUrl, isProxyStorageLocaleEnabled, resolveProxyMode } from "
|
|
|
2
2
|
import { internationalization, routing } from "@intlayer/config/built";
|
|
3
3
|
import { getLocaleFromStorageClient } from "@intlayer/core/utils";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/client/localeRedirect.ts
|
|
6
6
|
/**
|
|
7
7
|
* Locale explicitly carried by a URL — path prefix, or `?locale=` in
|
|
8
8
|
* `search-params` mode. `undefined` when the URL is unlocalized, which in
|
|
@@ -57,6 +57,5 @@ const redirectToStoredLocale = () => {
|
|
|
57
57
|
if (target) window.location.replace(target);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
//#endregion
|
|
61
60
|
export { getStoredLocaleRedirect, redirectToStoredLocale };
|
|
62
61
|
//# sourceMappingURL=localeRedirect.mjs.map
|
|
@@ -3,7 +3,7 @@ import { dirname, join, relative, sep } from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { getCanonicalPath, getRewriteRules, resolveLocalizedPath } from "@intlayer/core/localization";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/emitRewrittenPages.ts
|
|
7
7
|
/**
|
|
8
8
|
* Recursively lists every `.html` file contained in a directory.
|
|
9
9
|
*/
|
|
@@ -96,6 +96,5 @@ const emitRewrittenPages = async (configuration, outputDirectoryUrl) => {
|
|
|
96
96
|
return emittedPages;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
//#endregion
|
|
100
99
|
export { emitRewrittenPages };
|
|
101
100
|
//# sourceMappingURL=emitRewrittenPages.mjs.map
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { compact } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useCompact.ts
|
|
7
5
|
const useCompact = () => {
|
|
8
|
-
const locale = getRequestLocale()
|
|
6
|
+
const locale = getRequestLocale();
|
|
9
7
|
return (...args) => compact(args[0], {
|
|
10
8
|
...args[1],
|
|
11
9
|
locale: args[1]?.locale ?? locale
|
|
12
10
|
});
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
//#endregion
|
|
16
13
|
export { useCompact };
|
|
17
14
|
//# sourceMappingURL=useCompact.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\nexport const useCompact = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;AAGA,MAAa,mBAAmB;CAC9B,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SACT,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { currency } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useCurrency.ts
|
|
7
5
|
const useCurrency = () => {
|
|
8
|
-
const locale = getRequestLocale()
|
|
6
|
+
const locale = getRequestLocale();
|
|
9
7
|
return (...args) => currency(args[0], {
|
|
10
8
|
...args[1],
|
|
11
9
|
locale: args[1]?.locale ?? locale
|
|
12
10
|
});
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
//#endregion
|
|
16
13
|
export { useCurrency };
|
|
17
14
|
//# sourceMappingURL=useCurrency.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\nexport const useCurrency = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;AAGA,MAAa,oBAAoB;CAC/B,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SACT,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { date, presets } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useDate.ts
|
|
7
5
|
/**
|
|
8
6
|
* Astro hook that provides a localized date/time formatter bound to the request locale.
|
|
9
7
|
*/
|
|
10
8
|
const useDate = () => {
|
|
11
|
-
const locale = getRequestLocale()
|
|
9
|
+
const locale = getRequestLocale();
|
|
12
10
|
return (...args) => {
|
|
13
11
|
const options = typeof args[1] === "string" ? {
|
|
14
12
|
...presets[args[1]],
|
|
@@ -21,6 +19,5 @@ const useDate = () => {
|
|
|
21
19
|
};
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
//#endregion
|
|
25
22
|
export { useDate };
|
|
26
23
|
//# sourceMappingURL=useDate.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useDate.mjs","names":[],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date, presets } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\n/**\n * Astro hook that provides a localized date/time formatter bound to the request locale.\n */\nexport const useDate = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale }\n : { ...args[1], locale: args[1]?.locale ?? locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;AAMA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAG,QAAQ,KAAK;GAAK;EAAO,IAC9B;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,EAAE,EAAE,UAAU;EAAO;EAEtD,OAAO,KAAK,KAAK,IAAI,OAAqC;CAC5D;AACF"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { bindIntl } from "@intlayer/core/utils";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useIntl.ts
|
|
7
5
|
/**
|
|
8
6
|
* Astro hook that provides a locale-bound `Intl` object.
|
|
9
7
|
*
|
|
10
|
-
* It uses the request locale on the server, falling back to the
|
|
11
|
-
* default locale.
|
|
8
|
+
* It uses the request locale on the server, falling back to the stored
|
|
9
|
+
* locale in the browser, then to the default locale.
|
|
12
10
|
*/
|
|
13
11
|
const useIntl = (locale) => {
|
|
14
|
-
const currentLocale = locale ?? getRequestLocale()
|
|
12
|
+
const currentLocale = locale ?? getRequestLocale();
|
|
15
13
|
return {
|
|
16
14
|
intl: bindIntl(currentLocale),
|
|
17
15
|
subscribe: () => () => {}
|
|
18
16
|
};
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
//#endregion
|
|
22
19
|
export { useIntl };
|
|
23
20
|
//# sourceMappingURL=useIntl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getRequestLocale } from '../requestStorage';\n\n/**\n * Astro hook that provides a locale-bound `Intl` object.\n *\n * It uses the request locale on the server, falling back to the stored\n * locale in the browser, then to the default locale.\n */\nexport const useIntl = (\n locale?: LocalesValues\n): {\n intl: WrappedIntl;\n subscribe: (callback: (intl: WrappedIntl) => void) => () => void;\n} => {\n const currentLocale = locale ?? getRequestLocale();\n const intl = bindIntl(currentLocale);\n\n return {\n intl,\n subscribe: () => () => {},\n };\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,WACX,WAIG;CACH,MAAM,gBAAgB,UAAU,iBAAiB;CAGjD,OAAO;EACL,MAHW,SAAS,aAGjB;EACH,uBAAuB,CAAC;CAC1B;AACF"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { list } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useList.ts
|
|
7
5
|
const useList = () => {
|
|
8
|
-
const locale = getRequestLocale()
|
|
6
|
+
const locale = getRequestLocale();
|
|
9
7
|
return (...args) => list(args[0], {
|
|
10
8
|
...args[1],
|
|
11
9
|
locale: args[1]?.locale ?? locale
|
|
12
10
|
});
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
//#endregion
|
|
16
13
|
export { useList };
|
|
17
14
|
//# sourceMappingURL=useList.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\nexport const useList = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;AAGA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { number } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useNumber.ts
|
|
7
5
|
/**
|
|
8
6
|
* Astro hook that provides a localized number formatter bound to the request locale.
|
|
9
7
|
*/
|
|
10
8
|
const useNumber = () => {
|
|
11
|
-
const locale = getRequestLocale()
|
|
9
|
+
const locale = getRequestLocale();
|
|
12
10
|
return (...args) => number(args[0], {
|
|
13
11
|
...args[1],
|
|
14
12
|
locale: args[1]?.locale ?? locale
|
|
15
13
|
});
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
//#endregion
|
|
19
16
|
export { useNumber };
|
|
20
17
|
//# sourceMappingURL=useNumber.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\n/**\n * Astro hook that provides a localized number formatter bound to the request locale.\n */\nexport const useNumber = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;AAMA,MAAa,kBAAkB;CAC7B,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SACT,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { percentage } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/usePercentage.ts
|
|
7
5
|
const usePercentage = () => {
|
|
8
|
-
const locale = getRequestLocale()
|
|
6
|
+
const locale = getRequestLocale();
|
|
9
7
|
return (...args) => percentage(args[0], {
|
|
10
8
|
...args[1],
|
|
11
9
|
locale: args[1]?.locale ?? locale
|
|
12
10
|
});
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
//#endregion
|
|
16
13
|
export { usePercentage };
|
|
17
14
|
//# sourceMappingURL=usePercentage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\nexport const usePercentage = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;AAGA,MAAa,sBAAsB;CACjC,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SACT,WAAW,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { relativeTime } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useRelativeTime.ts
|
|
7
5
|
const useRelativeTime = () => {
|
|
8
|
-
const locale = getRequestLocale()
|
|
6
|
+
const locale = getRequestLocale();
|
|
9
7
|
return (...args) => relativeTime(args[0], args[1], {
|
|
10
8
|
...args[2],
|
|
11
9
|
locale: args[2]?.locale ?? locale
|
|
12
10
|
});
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
//#endregion
|
|
16
13
|
export { useRelativeTime };
|
|
17
14
|
//# sourceMappingURL=useRelativeTime.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\nexport const useRelativeTime = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;AAGA,MAAa,wBAAwB;CACnC,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SACT,aAAa,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { units } from "@intlayer/core/formatters";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
const { defaultLocale } = internationalization;
|
|
4
|
+
// src/format/useUnit.ts
|
|
7
5
|
const useUnit = () => {
|
|
8
|
-
const locale = getRequestLocale()
|
|
6
|
+
const locale = getRequestLocale();
|
|
9
7
|
return (...args) => units(args[0], {
|
|
10
8
|
...args[1],
|
|
11
9
|
locale: args[1]?.locale ?? locale
|
|
12
10
|
});
|
|
13
11
|
};
|
|
14
12
|
|
|
15
|
-
//#endregion
|
|
16
13
|
export { useUnit };
|
|
17
14
|
//# sourceMappingURL=useUnit.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { getRequestLocale } from '../requestStorage';\n\nexport const useUnit = () => {\n const locale = getRequestLocale();\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;AAGA,MAAa,gBAAgB;CAC3B,MAAM,SAAS,iBAAiB;CAEhC,QAAQ,GAAG,SACT,MAAM,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,EAAE,EAAE,UAAU;CAC7B,CAAC;AACL"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { useDictionary } from "./useDictionary.mjs";
|
|
|
3
3
|
import { useIntlayer } from "./useIntlayer.mjs";
|
|
4
4
|
import { useLocale } from "./useLocale.mjs";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/index.ts
|
|
7
7
|
/**
|
|
8
8
|
* Package self-reference to the Node-only half of the integration.
|
|
9
9
|
*
|
|
@@ -62,6 +62,5 @@ const intlayer = () => ({
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
//#endregion
|
|
66
65
|
export { intlayer as default, intlayer, getIntlayerLocals, useDictionary, useIntlayer, useLocale };
|
|
67
66
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/integration.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { getAlias } from "@intlayer/config/utils";
|
|
|
7
7
|
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
8
8
|
import { INTLAYER_NO_EXTERNAL_PATTERN, intlayer } from "vite-intlayer";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/integration.ts
|
|
11
11
|
/**
|
|
12
12
|
* Keeps the intlayer packages out of Node's native module loader in *every*
|
|
13
13
|
* Vite environment Astro renders from.
|
|
@@ -70,6 +70,5 @@ const buildDone = async ({ dir, logger }) => {
|
|
|
70
70
|
if (emittedPages.length > 0) logger.info(`Emitted ${emittedPages.length} rewritten page(s): ${emittedPages.map(([from, to]) => `${from} \u2192 ${to}`).join(", ")}`);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
//#endregion
|
|
74
73
|
export { buildDone, configSetup };
|
|
75
74
|
//# sourceMappingURL=integration.mjs.map
|
package/dist/esm/middleware.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { getLocaleFromRequest, resolveProxyMode } from "@intlayer/core/localizat
|
|
|
3
3
|
import * as builtConfiguration from "@intlayer/config/built";
|
|
4
4
|
import { createIntlayerWebProxyHandler } from "vite-intlayer/web-proxy-handler";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/middleware.ts
|
|
7
7
|
/**
|
|
8
8
|
* Whether `astro dev` is serving the app. Vite inlines `import.meta.env.DEV`
|
|
9
9
|
* into the server bundle; the optional chain keeps the module loadable where
|
|
@@ -95,6 +95,5 @@ const onRequest = async (context, next) => {
|
|
|
95
95
|
return proxyOutcome ? withProxyHeaders(response, proxyOutcome.headers) : response;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
//#endregion
|
|
99
98
|
export { onRequest };
|
|
100
99
|
//# sourceMappingURL=middleware.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { registerAmbientLocaleResolver } from "@intlayer/core/interpreter";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/requestStorage.ts
|
|
5
5
|
/**
|
|
6
6
|
* `Astro.locals` of the request being rendered, made available to every
|
|
7
7
|
* function running inside the middleware scope — page and component
|
|
@@ -18,6 +18,5 @@ const getIntlayerLocals = () => requestStorage.getStore()?.intlayer;
|
|
|
18
18
|
const getRequestLocale = () => getIntlayerLocals()?.locale;
|
|
19
19
|
registerAmbientLocaleResolver(getRequestLocale);
|
|
20
20
|
|
|
21
|
-
//#endregion
|
|
22
21
|
export { getIntlayerLocals, getRequestLocale, requestStorage };
|
|
23
22
|
//# sourceMappingURL=requestStorage.mjs.map
|
|
@@ -3,7 +3,7 @@ import { withInertOnChange } from "./withInertOnChange.mjs";
|
|
|
3
3
|
import { resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
4
4
|
import { getDictionary } from "vanilla-intlayer";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useDictionary.ts
|
|
7
7
|
/**
|
|
8
8
|
* Transforms an imported dictionary (or qualified dictionary group) and returns
|
|
9
9
|
* its content for the locale of the request being rendered, read from
|
|
@@ -32,6 +32,5 @@ const useDictionary = (dictionary, localeOrSelector) => withInertOnChange(getDic
|
|
|
32
32
|
dictionaryKey: dictionary.key
|
|
33
33
|
}) : localeOrSelector ?? getRequestLocale()));
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { useDictionary };
|
|
37
36
|
//# sourceMappingURL=useDictionary.mjs.map
|
package/dist/esm/useIntlayer.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { withInertOnChange } from "./withInertOnChange.mjs";
|
|
|
3
3
|
import { resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
4
4
|
import { getIntlayer } from "vanilla-intlayer";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useIntlayer.ts
|
|
7
7
|
/**
|
|
8
8
|
* Picks one dictionary by its key and returns its content for the locale of
|
|
9
9
|
* the request being rendered, read from `Astro.locals.intlayer`.
|
|
@@ -32,6 +32,5 @@ const useIntlayer = (key, localeOrSelector) => withInertOnChange(getIntlayer(key
|
|
|
32
32
|
dictionaryKey: key
|
|
33
33
|
}) : localeOrSelector ?? getRequestLocale()));
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
export { useIntlayer };
|
|
37
36
|
//# sourceMappingURL=useIntlayer.mjs.map
|
package/dist/esm/useLocale.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "./requestStorage.mjs";
|
|
2
2
|
import { internationalization } from "@intlayer/config/built";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useLocale.ts
|
|
5
5
|
const { defaultLocale, locales: availableLocales } = internationalization;
|
|
6
6
|
/**
|
|
7
7
|
* Returns the locale of the request being rendered, read from
|
|
@@ -35,6 +35,5 @@ const useLocale = (_props = {}) => ({
|
|
|
35
35
|
subscribe: () => () => {}
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
//#endregion
|
|
39
38
|
export { useLocale };
|
|
40
39
|
//# sourceMappingURL=useLocale.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/withInertOnChange.ts
|
|
2
2
|
/**
|
|
3
3
|
* Gives server-rendered content the `.onChange()` of its client counterpart.
|
|
4
4
|
*
|
|
@@ -11,6 +11,5 @@ const withInertOnChange = (content) => {
|
|
|
11
11
|
return content;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
14
|
export { withInertOnChange };
|
|
16
15
|
//# sourceMappingURL=withInertOnChange.mjs.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/client/localeRedirect.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Computes where a prerendered page should send the visitor so it matches the
|
|
4
3
|
* locale they stored (cookie, localStorage or sessionStorage, per
|
|
@@ -22,5 +21,4 @@ export declare const getStoredLocaleRedirect: (url: URL, isDevServer: boolean) =
|
|
|
22
21
|
* already names a locale, so a redirected page does not redirect again.
|
|
23
22
|
*/
|
|
24
23
|
export declare const redirectToStoredLocale: () => void;
|
|
25
|
-
//#endregion
|
|
26
24
|
//# sourceMappingURL=localeRedirect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeRedirect.d.ts","names":[],"sources":["../../../src/client/localeRedirect.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeRedirect.d.ts","names":[],"sources":["../../../src/client/localeRedirect.ts"],"mappings":";;;;;;;;;;;;;;;qBAwCa,0BAAuB,KAC7B,KAAG;;;;;;;qBAoCG"}
|