astro-intlayer 9.7.0 → 9.7.2
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 +2 -3
- package/dist/cjs/format/useCurrency.cjs +2 -3
- package/dist/cjs/format/useDate.cjs +2 -3
- package/dist/cjs/format/useIntl.cjs +2 -3
- package/dist/cjs/format/useList.cjs +2 -3
- package/dist/cjs/format/useNumber.cjs +2 -3
- package/dist/cjs/format/usePercentage.cjs +2 -3
- package/dist/cjs/format/useRelativeTime.cjs +2 -3
- package/dist/cjs/format/useUnit.cjs +2 -3
- 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/useDictionary.cjs.map +1 -1
- 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 +1 -2
- package/dist/esm/format/useCurrency.mjs +1 -2
- package/dist/esm/format/useDate.mjs +1 -2
- package/dist/esm/format/useIntl.mjs +1 -2
- package/dist/esm/format/useList.mjs +1 -2
- package/dist/esm/format/useNumber.mjs +1 -2
- package/dist/esm/format/usePercentage.mjs +1 -2
- package/dist/esm/format/useRelativeTime.mjs +1 -2
- package/dist/esm/format/useUnit.mjs +1 -2
- 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/useDictionary.mjs.map +1 -1
- 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/index.d.ts +11 -0
- 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 +1 -3
- 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 +1 -3
- 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 +1 -3
- package/dist/types/useDictionary.d.ts.map +1 -1
- package/dist/types/useIntlayer.d.ts +1 -3
- 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 +62 -62
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,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { compact } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useCompact.ts
|
|
5
5
|
const useCompact = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => compact(args[0], {
|
|
@@ -10,6 +10,5 @@ const useCompact = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useCompact };
|
|
15
14
|
//# sourceMappingURL=useCompact.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { currency } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useCurrency.ts
|
|
5
5
|
const useCurrency = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => currency(args[0], {
|
|
@@ -10,6 +10,5 @@ const useCurrency = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useCurrency };
|
|
15
14
|
//# sourceMappingURL=useCurrency.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { date, presets } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useDate.ts
|
|
5
5
|
/**
|
|
6
6
|
* Astro hook that provides a localized date/time formatter bound to the request locale.
|
|
7
7
|
*/
|
|
@@ -19,6 +19,5 @@ const useDate = () => {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
//#endregion
|
|
23
22
|
export { useDate };
|
|
24
23
|
//# sourceMappingURL=useDate.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { bindIntl } from "@intlayer/core/utils";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useIntl.ts
|
|
5
5
|
/**
|
|
6
6
|
* Astro hook that provides a locale-bound `Intl` object.
|
|
7
7
|
*
|
|
@@ -16,6 +16,5 @@ const useIntl = (locale) => {
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
//#endregion
|
|
20
19
|
export { useIntl };
|
|
21
20
|
//# sourceMappingURL=useIntl.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { list } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useList.ts
|
|
5
5
|
const useList = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => list(args[0], {
|
|
@@ -10,6 +10,5 @@ const useList = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useList };
|
|
15
14
|
//# sourceMappingURL=useList.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { number } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useNumber.ts
|
|
5
5
|
/**
|
|
6
6
|
* Astro hook that provides a localized number formatter bound to the request locale.
|
|
7
7
|
*/
|
|
@@ -13,6 +13,5 @@ const useNumber = () => {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
16
|
export { useNumber };
|
|
18
17
|
//# sourceMappingURL=useNumber.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { percentage } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/usePercentage.ts
|
|
5
5
|
const usePercentage = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => percentage(args[0], {
|
|
@@ -10,6 +10,5 @@ const usePercentage = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { usePercentage };
|
|
15
14
|
//# sourceMappingURL=usePercentage.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { relativeTime } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useRelativeTime.ts
|
|
5
5
|
const useRelativeTime = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => relativeTime(args[0], args[1], {
|
|
@@ -10,6 +10,5 @@ const useRelativeTime = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useRelativeTime };
|
|
15
14
|
//# sourceMappingURL=useRelativeTime.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { units } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useUnit.ts
|
|
5
5
|
const useUnit = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => units(args[0], {
|
|
@@ -10,6 +10,5 @@ const useUnit = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useUnit };
|
|
15
14
|
//# sourceMappingURL=useUnit.mjs.map
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import { resolveDictionaryArgument } from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n type DeepTransformContent,\n getDictionary,\n type WithOnChange,\n} from 'vanilla-intlayer';\nimport { getRequestLocale } from './requestStorage';\nimport { withInertOnChange } from './withInertOnChange';\n\n/**\n * Transforms an imported dictionary (or qualified dictionary group) and returns\n * its content for the locale of the request being rendered, read from\n * `Astro.locals.intlayer`.\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence\n * over the request locale.\n *\n * Same signature and content shape as the client-side hook this entry resolves\n * to in the browser (`vanilla-intlayer`).\n *\n * @example\n * ```astro\n * ---\n * import { useDictionary } from 'astro-intlayer';\n * import homeContent from '../content/home.content';\n *\n * const { title } = useDictionary(homeContent);\n * ---\n * ```\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import { resolveDictionaryArgument } from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n type DeepTransformContent,\n getDictionary,\n type WithOnChange,\n} from 'vanilla-intlayer';\nimport { getRequestLocale } from './requestStorage';\nimport { withInertOnChange } from './withInertOnChange';\n\n/**\n * Transforms an imported dictionary (or qualified dictionary group) and returns\n * its content for the locale of the request being rendered, read from\n * `Astro.locals.intlayer`.\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence\n * over the request locale.\n *\n * Same signature and content shape as the client-side hook this entry resolves\n * to in the browser (`vanilla-intlayer`).\n *\n * @example\n * ```astro\n * ---\n * import { useDictionary } from 'astro-intlayer';\n * import homeContent from '../content/home.content';\n *\n * const { title } = useDictionary(homeContent);\n * ---\n * ```\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelectorForGroup<T> =\n DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): WithOnChange<\n DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n >\n> =>\n withInertOnChange(\n getDictionary<T, A>(\n dictionary,\n // Selectors disabled project-wide (build-time flag) ⇒ the argument can\n // only be a locale, so the merge is dropped by the bundler.\n (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? getRequestLocale())) as A\n )\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,iBAKX,YACA,qBAOA,kBACE,cACE,YAGC,QAAQ,IAAI,iCAAiC,UAC1C,0BAA0B;CACxB;CACA,eAAe,iBAAiB;CAChC,eAAe,WAAW;AAC5B,CAAC,IACA,oBAAoB,iBAAiB,CAC5C,CACF"}
|
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,2 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `astro-intlayer` as loaded in the browser — client `<script>` blocks and
|
|
3
|
+
* framework islands.
|
|
4
|
+
*
|
|
5
|
+
* Selected by the `browser` export condition. It mirrors the server entry name
|
|
6
|
+
* for name, resolved to the client implementations of `vanilla-intlayer`, so
|
|
7
|
+
* `useIntlayer('key')` reads the request locale in the frontmatter and the
|
|
8
|
+
* client store in a `<script>` through one import path.
|
|
9
|
+
*
|
|
10
|
+
* The integration and the middleware are server-only and deliberately absent.
|
|
11
|
+
*/
|
|
1
12
|
import { DeepTransformContent, IntlayerNode, UseLocaleProps, UseLocaleResult, WithOnChange, getDictionary, getIntlayer, installIntlayer, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useDictionary, useDictionaryDynamic, useIntlayer, useLocale, useLocaleCookie, useLocaleStorage } from "vanilla-intlayer";
|
|
2
13
|
export { type DeepTransformContent, type IntlayerNode, type UseLocaleProps, type UseLocaleResult, type WithOnChange, getDictionary, getIntlayer, installIntlayer, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useDictionary, useDictionaryDynamic, useIntlayer, useLocale, useLocaleCookie, useLocaleStorage };
|
|
@@ -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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
-
//#region src/emitRewrittenPages.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Emits a copy of every prerendered page at its rewritten ("pretty") URL.
|
|
5
4
|
*
|
|
@@ -18,5 +17,4 @@ import { IntlayerConfig } from "@intlayer/types/config";
|
|
|
18
17
|
* @returns The list of `[from, to]` URL paths that were emitted.
|
|
19
18
|
*/
|
|
20
19
|
export declare const emitRewrittenPages: (configuration: IntlayerConfig, outputDirectoryUrl: URL) => Promise<[from: string, to: string][]>;
|
|
21
|
-
//#endregion
|
|
22
20
|
//# sourceMappingURL=emitRewrittenPages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitRewrittenPages.d.ts","names":[],"sources":["../../src/emitRewrittenPages.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"emitRewrittenPages.d.ts","names":[],"sources":["../../src/emitRewrittenPages.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBAuHa,qBAAkB,eACd,gBAAc,oBACT,QACnB,SAAS,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";qBAGa,sBAAU,MAGJ,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";qBAGa,uBAAW,MAGL,kBAAkB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { date } from "@intlayer/core/formatters";
|
|
2
|
-
//#region src/format/useDate.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Astro hook that provides a localized date/time formatter bound to the request locale.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useDate: () => (...args: Parameters<typeof date>) => string;
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=useDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":";;;;qBAMa,mBAAO,MAGD,kBAAkB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { WrappedIntl } from "@intlayer/core/utils";
|
|
2
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
-
|
|
2
|
+
import { WrappedIntl } from "@intlayer/core/utils";
|
|
4
3
|
/**
|
|
5
4
|
* Astro hook that provides a locale-bound `Intl` object.
|
|
6
5
|
*
|
|
@@ -11,5 +10,4 @@ export declare const useIntl: (locale?: LocalesValues) => {
|
|
|
11
10
|
intl: WrappedIntl;
|
|
12
11
|
subscribe: (callback: (intl: WrappedIntl) => void) => () => void;
|
|
13
12
|
};
|
|
14
|
-
//#endregion
|
|
15
13
|
//# sourceMappingURL=useIntl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../src/format/useIntl.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../src/format/useIntl.ts"],"mappings":";;;;;;;;qBAUa,UAAO,SACT;EAET,MAAM;EACN,YAAY,WAAW,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";qBAGa,mBAAO,MAGD,kBAAkB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { number } from "@intlayer/core/formatters";
|
|
2
|
-
//#region src/format/useNumber.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Astro hook that provides a localized number formatter bound to the request locale.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useNumber: () => (...args: Parameters<typeof number>) => string;
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=useNumber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":";;;;qBAMa,qBAAS,MAGH,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":";qBAGa,yBAAa,MAGP,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";qBAGa,2BAAe,MAGT,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":";qBAGa,mBAAO,MAGD,kBAAkB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { useDictionary } from "./useDictionary.js";
|
|
|
4
4
|
import { useIntlayer } from "./useIntlayer.js";
|
|
5
5
|
import { UseLocaleProps, UseLocaleResult, useLocale } from "./useLocale.js";
|
|
6
6
|
import { AstroIntegration } from "astro";
|
|
7
|
-
//#region src/index.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Astro integration for Intlayer.
|
|
10
9
|
*
|
|
@@ -35,6 +34,5 @@ import { AstroIntegration } from "astro";
|
|
|
35
34
|
* ```
|
|
36
35
|
*/
|
|
37
36
|
export declare const intlayer: () => AstroIntegration;
|
|
38
|
-
//#endregion
|
|
39
37
|
export { type IntlayerLocals, type UseLocaleProps, type UseLocaleResult, intlayer as default, getIntlayerLocals, useDictionary, useIntlayer, useLocale };
|
|
40
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqDa,gBAAe"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AstroIntegration } from "astro";
|
|
2
|
-
//#region src/integration.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Node-only half of the integration, loaded lazily by the `astro-intlayer`
|
|
5
4
|
* entry when a hook runs.
|
|
@@ -37,5 +36,5 @@ export declare const configSetup: ({ command, updateConfig, addMiddleware, injec
|
|
|
37
36
|
* `getLocalizedUrl` (links, hreflang, sitemap) 404 once deployed.
|
|
38
37
|
*/
|
|
39
38
|
export declare const buildDone: ({ dir, logger }: BuildDoneOptions) => Promise<void>;
|
|
40
|
-
|
|
39
|
+
export {};
|
|
41
40
|
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","names":[],"sources":["../../src/integration.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"integration.d.ts","names":[],"sources":["../../src/integration.ts"],"mappings":";;;;;;;;;;KA0CK,qBAAqB,WACxB,YAAY;KAGT,mBAAmB,WACtB,YAAY;;;;;;;;;;;;;;;;;;;qBAqBD,gBAAW,SAAA,cAAA,eAAA,gBAKrB,uBAAqB;;;;;;;qBAsEX,cAAS,KAAA,UAGnB,qBAAmB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
2
1
|
import { MiddlewareHandler } from "astro";
|
|
3
|
-
|
|
2
|
+
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
4
3
|
/**
|
|
5
4
|
* Intlayer state stored in `Astro.locals.intlayer` by the {@link onRequest} middleware.
|
|
6
5
|
*/
|
|
@@ -50,5 +49,4 @@ declare global {
|
|
|
50
49
|
* ```
|
|
51
50
|
*/
|
|
52
51
|
export declare const onRequest: MiddlewareHandler;
|
|
53
|
-
//#endregion
|
|
54
52
|
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../src/middleware.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../src/middleware.ts"],"mappings":";;;;;YAuEY;;EAEV,QAAQ;;EAER,eAAe;;EAEf,kBAAkB;;QAGZ;YACI;cACE;MACR,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmCH,WAAW"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IntlayerLocals } from "./middleware.js";
|
|
2
2
|
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
-
//#region src/requestStorage.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* `Astro.locals` of the request being rendered, made available to every
|
|
7
6
|
* function running inside the middleware scope — page and component
|
|
@@ -18,5 +17,4 @@ export declare const getIntlayerLocals: () => IntlayerLocals | undefined;
|
|
|
18
17
|
* Returns the locale of the request being rendered, if any.
|
|
19
18
|
*/
|
|
20
19
|
export declare const getRequestLocale: () => DeclaredLocales | undefined;
|
|
21
|
-
//#endregion
|
|
22
20
|
//# sourceMappingURL=requestStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestStorage.d.ts","names":[],"sources":["../../src/requestStorage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"requestStorage.d.ts","names":[],"sources":["../../src/requestStorage.ts"],"mappings":";;;;;;;;qBAUa,gBAAc;EACd,WAAA;;;;;qBAMA,yBAAwB;;;;qBAMxB,wBAAuB"}
|