astro-intlayer 9.5.4 → 9.5.6

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.
Files changed (126) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/_virtual/_rolldown/runtime.cjs +28 -0
  3. package/dist/cjs/client/format/index.cjs +57 -0
  4. package/dist/cjs/client/index.cjs +81 -0
  5. package/dist/cjs/client/localeRedirect.cjs +64 -0
  6. package/dist/cjs/client/localeRedirect.cjs.map +1 -0
  7. package/dist/cjs/format/index.cjs +20 -0
  8. package/dist/cjs/format/useCompact.cjs +18 -0
  9. package/dist/cjs/format/useCompact.cjs.map +1 -0
  10. package/dist/cjs/format/useCurrency.cjs +18 -0
  11. package/dist/cjs/format/useCurrency.cjs.map +1 -0
  12. package/dist/cjs/format/useDate.cjs +27 -0
  13. package/dist/cjs/format/useDate.cjs.map +1 -0
  14. package/dist/cjs/format/useIntl.cjs +24 -0
  15. package/dist/cjs/format/useIntl.cjs.map +1 -0
  16. package/dist/cjs/format/useList.cjs +18 -0
  17. package/dist/cjs/format/useList.cjs.map +1 -0
  18. package/dist/cjs/format/useNumber.cjs +21 -0
  19. package/dist/cjs/format/useNumber.cjs.map +1 -0
  20. package/dist/cjs/format/usePercentage.cjs +18 -0
  21. package/dist/cjs/format/usePercentage.cjs.map +1 -0
  22. package/dist/cjs/format/useRelativeTime.cjs +18 -0
  23. package/dist/cjs/format/useRelativeTime.cjs.map +1 -0
  24. package/dist/cjs/format/useUnit.cjs +18 -0
  25. package/dist/cjs/format/useUnit.cjs.map +1 -0
  26. package/dist/cjs/html/index.cjs +33 -0
  27. package/dist/cjs/index.cjs +33 -35
  28. package/dist/cjs/index.cjs.map +1 -1
  29. package/dist/cjs/integration.cjs +77 -0
  30. package/dist/cjs/integration.cjs.map +1 -0
  31. package/dist/cjs/markdown/index.cjs +45 -0
  32. package/dist/cjs/middleware.cjs +103 -0
  33. package/dist/cjs/middleware.cjs.map +1 -0
  34. package/dist/cjs/requestStorage.cjs +24 -0
  35. package/dist/cjs/requestStorage.cjs.map +1 -0
  36. package/dist/cjs/useDictionary.cjs +38 -0
  37. package/dist/cjs/useDictionary.cjs.map +1 -0
  38. package/dist/cjs/useIntlayer.cjs +38 -0
  39. package/dist/cjs/useIntlayer.cjs.map +1 -0
  40. package/dist/cjs/useLocale.cjs +41 -0
  41. package/dist/cjs/useLocale.cjs.map +1 -0
  42. package/dist/cjs/withInertOnChange.cjs +17 -0
  43. package/dist/cjs/withInertOnChange.cjs.map +1 -0
  44. package/dist/esm/client/format/index.mjs +3 -0
  45. package/dist/esm/client/index.mjs +3 -0
  46. package/dist/esm/client/localeRedirect.mjs +62 -0
  47. package/dist/esm/client/localeRedirect.mjs.map +1 -0
  48. package/dist/esm/format/index.mjs +11 -0
  49. package/dist/esm/format/useCompact.mjs +17 -0
  50. package/dist/esm/format/useCompact.mjs.map +1 -0
  51. package/dist/esm/format/useCurrency.mjs +17 -0
  52. package/dist/esm/format/useCurrency.mjs.map +1 -0
  53. package/dist/esm/format/useDate.mjs +26 -0
  54. package/dist/esm/format/useDate.mjs.map +1 -0
  55. package/dist/esm/format/useIntl.mjs +23 -0
  56. package/dist/esm/format/useIntl.mjs.map +1 -0
  57. package/dist/esm/format/useList.mjs +17 -0
  58. package/dist/esm/format/useList.mjs.map +1 -0
  59. package/dist/esm/format/useNumber.mjs +20 -0
  60. package/dist/esm/format/useNumber.mjs.map +1 -0
  61. package/dist/esm/format/usePercentage.mjs +17 -0
  62. package/dist/esm/format/usePercentage.mjs.map +1 -0
  63. package/dist/esm/format/useRelativeTime.mjs +17 -0
  64. package/dist/esm/format/useRelativeTime.mjs.map +1 -0
  65. package/dist/esm/format/useUnit.mjs +17 -0
  66. package/dist/esm/format/useUnit.mjs.map +1 -0
  67. package/dist/esm/html/index.mjs +3 -0
  68. package/dist/esm/index.mjs +30 -36
  69. package/dist/esm/index.mjs.map +1 -1
  70. package/dist/esm/integration.mjs +75 -0
  71. package/dist/esm/integration.mjs.map +1 -0
  72. package/dist/esm/markdown/index.mjs +3 -0
  73. package/dist/esm/middleware.mjs +100 -0
  74. package/dist/esm/middleware.mjs.map +1 -0
  75. package/dist/esm/requestStorage.mjs +21 -0
  76. package/dist/esm/requestStorage.mjs.map +1 -0
  77. package/dist/esm/useDictionary.mjs +37 -0
  78. package/dist/esm/useDictionary.mjs.map +1 -0
  79. package/dist/esm/useIntlayer.mjs +37 -0
  80. package/dist/esm/useIntlayer.mjs.map +1 -0
  81. package/dist/esm/useLocale.mjs +40 -0
  82. package/dist/esm/useLocale.mjs.map +1 -0
  83. package/dist/esm/withInertOnChange.mjs +16 -0
  84. package/dist/esm/withInertOnChange.mjs.map +1 -0
  85. package/dist/types/client/format/index.d.ts +2 -0
  86. package/dist/types/client/index.d.ts +2 -0
  87. package/dist/types/client/localeRedirect.d.ts +26 -0
  88. package/dist/types/client/localeRedirect.d.ts.map +1 -0
  89. package/dist/types/format/index.d.ts +10 -0
  90. package/dist/types/format/useCompact.d.ts +5 -0
  91. package/dist/types/format/useCompact.d.ts.map +1 -0
  92. package/dist/types/format/useCurrency.d.ts +5 -0
  93. package/dist/types/format/useCurrency.d.ts.map +1 -0
  94. package/dist/types/format/useDate.d.ts +8 -0
  95. package/dist/types/format/useDate.d.ts.map +1 -0
  96. package/dist/types/format/useIntl.d.ts +15 -0
  97. package/dist/types/format/useIntl.d.ts.map +1 -0
  98. package/dist/types/format/useList.d.ts +5 -0
  99. package/dist/types/format/useList.d.ts.map +1 -0
  100. package/dist/types/format/useNumber.d.ts +8 -0
  101. package/dist/types/format/useNumber.d.ts.map +1 -0
  102. package/dist/types/format/usePercentage.d.ts +5 -0
  103. package/dist/types/format/usePercentage.d.ts.map +1 -0
  104. package/dist/types/format/useRelativeTime.d.ts +5 -0
  105. package/dist/types/format/useRelativeTime.d.ts.map +1 -0
  106. package/dist/types/format/useUnit.d.ts +5 -0
  107. package/dist/types/format/useUnit.d.ts.map +1 -0
  108. package/dist/types/html/index.d.ts +2 -0
  109. package/dist/types/index.d.ts +13 -6
  110. package/dist/types/index.d.ts.map +1 -1
  111. package/dist/types/integration.d.ts +41 -0
  112. package/dist/types/integration.d.ts.map +1 -0
  113. package/dist/types/markdown/index.d.ts +2 -0
  114. package/dist/types/middleware.d.ts +54 -0
  115. package/dist/types/middleware.d.ts.map +1 -0
  116. package/dist/types/requestStorage.d.ts +22 -0
  117. package/dist/types/requestStorage.d.ts.map +1 -0
  118. package/dist/types/useDictionary.d.ts +29 -0
  119. package/dist/types/useDictionary.d.ts.map +1 -0
  120. package/dist/types/useIntlayer.d.ts +28 -0
  121. package/dist/types/useIntlayer.d.ts.map +1 -0
  122. package/dist/types/useLocale.d.ts +29 -0
  123. package/dist/types/useLocale.d.ts.map +1 -0
  124. package/dist/types/withInertOnChange.d.ts +12 -0
  125. package/dist/types/withInertOnChange.d.ts.map +1 -0
  126. package/package.json +96 -6
@@ -0,0 +1,22 @@
1
+ import { IntlayerLocals } from "./middleware.js";
2
+ import { DeclaredLocales } from "@intlayer/types/module_augmentation";
3
+ import { AsyncLocalStorage } from "node:async_hooks";
4
+ //#region src/requestStorage.d.ts
5
+ /**
6
+ * `Astro.locals` of the request being rendered, made available to every
7
+ * function running inside the middleware scope — page and component
8
+ * frontmatter, endpoints, nested middleware — without passing `Astro` around.
9
+ */
10
+ export declare const requestStorage: AsyncLocalStorage<{
11
+ intlayer?: IntlayerLocals;
12
+ }>;
13
+ /**
14
+ * Returns the Intlayer locals of the request being rendered, if any.
15
+ */
16
+ export declare const getIntlayerLocals: () => IntlayerLocals | undefined;
17
+ /**
18
+ * Returns the locale of the request being rendered, if any.
19
+ */
20
+ export declare const getRequestLocale: () => DeclaredLocales | undefined;
21
+ //#endregion
22
+ //# sourceMappingURL=requestStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestStorage.d.ts","names":[],"sources":["../../src/requestStorage.ts"],"mappings":";;;;;;;;;qBASa,gBAAc;EACd,WAAA;;;;;qBAMA,yBAAwB;;;;qBAMxB,wBAAuB"}
@@ -0,0 +1,29 @@
1
+ import { DeepTransformContent, WithOnChange } from "vanilla-intlayer";
2
+ import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
3
+ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
4
+ //#region src/useDictionary.d.ts
5
+ /**
6
+ * Transforms an imported dictionary (or qualified dictionary group) and returns
7
+ * its content for the locale of the request being rendered, read from
8
+ * `Astro.locals.intlayer`.
9
+ *
10
+ * The second argument is either a locale or a selector object
11
+ * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
12
+ * over the request locale.
13
+ *
14
+ * Same signature and content shape as the client-side hook this entry resolves
15
+ * to in the browser (`vanilla-intlayer`).
16
+ *
17
+ * @example
18
+ * ```astro
19
+ * ---
20
+ * import { useDictionary } from 'astro-intlayer';
21
+ * import homeContent from '../content/home.content';
22
+ *
23
+ * const { title } = useDictionary(homeContent);
24
+ * ---
25
+ * ```
26
+ */
27
+ export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => WithOnChange<DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>>;
28
+ //#endregion
29
+ //# sourceMappingURL=useDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;qBA0Ca,sBACL,UAAU,aAAa,gCACvB,UACF,gBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,MAClB,aACD,qBACE,kCAAkC,GAAG,IACrC,sBAAsB"}
@@ -0,0 +1,28 @@
1
+ import { DeepTransformContent, WithOnChange } from "vanilla-intlayer";
2
+ import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
3
+ //#region src/useIntlayer.d.ts
4
+ /**
5
+ * Picks one dictionary by its key and returns its content for the locale of
6
+ * the request being rendered, read from `Astro.locals.intlayer`.
7
+ *
8
+ * The second argument is either a locale or a selector object
9
+ * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
10
+ * over the request locale.
11
+ *
12
+ * Same signature and content shape as the client-side hook this entry resolves
13
+ * to in the browser (`vanilla-intlayer`), so a call moves between the
14
+ * frontmatter and a `<script>` unchanged.
15
+ *
16
+ * @example
17
+ * ```astro
18
+ * ---
19
+ * import { useIntlayer } from 'astro-intlayer';
20
+ *
21
+ * const { title, description } = useIntlayer('home');
22
+ * ---
23
+ * <h1>{title}</h1>
24
+ * ```
25
+ */
26
+ export declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => WithOnChange<DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>>;
27
+ //#endregion
28
+ //# sourceMappingURL=useIntlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../src/useIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;qBAuCa,oBACL,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,KAExE,GAAC,mBACa,MAClB,aACD,qBAAqB,yBAAyB,GAAG,IAAI,sBAAsB"}
@@ -0,0 +1,29 @@
1
+ import { UseLocaleProps, UseLocaleProps as UseLocaleProps$1, UseLocaleResult as UseLocaleResult$1 } from "vanilla-intlayer";
2
+ //#region src/useLocale.d.ts
3
+ export type UseLocaleResult = UseLocaleResult$1;
4
+ /**
5
+ * Returns the locale of the request being rendered, read from
6
+ * `Astro.locals.intlayer`, with the configured default and available locales.
7
+ *
8
+ * Falls back to the default locale outside of a request, i.e. when the
9
+ * `astro-intlayer/middleware` did not run.
10
+ *
11
+ * Same shape as the client-side hook this entry resolves to in the browser
12
+ * (`vanilla-intlayer`). A request has no locale to switch, so `setLocale` and
13
+ * `subscribe` are inert here: switch the locale from a `<script>`, where the
14
+ * same import gives the client implementation.
15
+ *
16
+ * @example
17
+ * ```astro
18
+ * ---
19
+ * import { useLocale } from 'astro-intlayer';
20
+ *
21
+ * const { locale, availableLocales } = useLocale();
22
+ * ---
23
+ * <html lang={locale}>
24
+ * ```
25
+ */
26
+ export declare const useLocale: (_props?: UseLocaleProps$1) => UseLocaleResult;
27
+ //#endregion
28
+ export type { UseLocaleProps };
29
+ //# sourceMappingURL=useLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../src/useLocale.ts"],"mappings":";;YAUY,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;qBA0BjB,YAAS,SAAY,qBAAsB"}
@@ -0,0 +1,12 @@
1
+ import { WithOnChange } from "vanilla-intlayer";
2
+ //#region src/withInertOnChange.d.ts
3
+ /**
4
+ * Gives server-rendered content the `.onChange()` of its client counterpart.
5
+ *
6
+ * The locale cannot change during a server render, so the subscription never
7
+ * fires; it only keeps the content shape identical on both sides of the
8
+ * `astro-intlayer` entry.
9
+ */
10
+ export declare const withInertOnChange: <T>(content: T) => WithOnChange<T>;
11
+ //#endregion
12
+ //# sourceMappingURL=withInertOnChange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withInertOnChange.d.ts","names":[],"sources":["../../src/withInertOnChange.ts"],"mappings":";;;;;;;;;qBASa,oBAAqB,GAAC,SAAW,MAAI,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-intlayer",
3
- "version": "9.5.4",
3
+ "version": "9.5.6",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Astro applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -41,9 +41,76 @@
41
41
  "exports": {
42
42
  ".": {
43
43
  "types": "./dist/types/index.d.ts",
44
+ "node": {
45
+ "require": "./dist/cjs/index.cjs",
46
+ "import": "./dist/esm/index.mjs"
47
+ },
48
+ "bun": {
49
+ "require": "./dist/cjs/index.cjs",
50
+ "import": "./dist/esm/index.mjs"
51
+ },
52
+ "deno": {
53
+ "require": "./dist/cjs/index.cjs",
54
+ "import": "./dist/esm/index.mjs"
55
+ },
56
+ "workerd": {
57
+ "require": "./dist/cjs/index.cjs",
58
+ "import": "./dist/esm/index.mjs"
59
+ },
60
+ "worker": {
61
+ "require": "./dist/cjs/index.cjs",
62
+ "import": "./dist/esm/index.mjs"
63
+ },
64
+ "edge-light": {
65
+ "require": "./dist/cjs/index.cjs",
66
+ "import": "./dist/esm/index.mjs"
67
+ },
68
+ "browser": {
69
+ "require": "./dist/cjs/client/index.cjs",
70
+ "import": "./dist/esm/client/index.mjs"
71
+ },
44
72
  "require": "./dist/cjs/index.cjs",
45
73
  "import": "./dist/esm/index.mjs"
46
74
  },
75
+ "./client": {
76
+ "types": "./dist/types/client/index.d.ts",
77
+ "require": "./dist/cjs/client/index.cjs",
78
+ "import": "./dist/esm/client/index.mjs"
79
+ },
80
+ "./client/locale-redirect": {
81
+ "types": "./dist/types/client/localeRedirect.d.ts",
82
+ "require": "./dist/cjs/client/localeRedirect.cjs",
83
+ "import": "./dist/esm/client/localeRedirect.mjs"
84
+ },
85
+ "./integration": {
86
+ "types": "./dist/types/integration.d.ts",
87
+ "require": "./dist/cjs/integration.cjs",
88
+ "import": "./dist/esm/integration.mjs"
89
+ },
90
+ "./middleware": {
91
+ "types": "./dist/types/middleware.d.ts",
92
+ "require": "./dist/cjs/middleware.cjs",
93
+ "import": "./dist/esm/middleware.mjs"
94
+ },
95
+ "./format": {
96
+ "types": "./dist/types/format/index.d.ts",
97
+ "browser": {
98
+ "require": "./dist/cjs/client/format/index.cjs",
99
+ "import": "./dist/esm/client/format/index.mjs"
100
+ },
101
+ "require": "./dist/cjs/format/index.cjs",
102
+ "import": "./dist/esm/format/index.mjs"
103
+ },
104
+ "./html": {
105
+ "types": "./dist/types/html/index.d.ts",
106
+ "require": "./dist/cjs/html/index.cjs",
107
+ "import": "./dist/esm/html/index.mjs"
108
+ },
109
+ "./markdown": {
110
+ "types": "./dist/types/markdown/index.d.ts",
111
+ "require": "./dist/cjs/markdown/index.cjs",
112
+ "import": "./dist/esm/markdown/index.mjs"
113
+ },
47
114
  "./package.json": "./package.json"
48
115
  },
49
116
  "main": "dist/cjs/index.cjs",
@@ -51,8 +118,29 @@
51
118
  "types": "dist/types/index.d.ts",
52
119
  "typesVersions": {
53
120
  "*": {
121
+ "client": [
122
+ "./dist/types/client/index.d.ts"
123
+ ],
124
+ "client/locale-redirect": [
125
+ "./dist/types/client/localeRedirect.d.ts"
126
+ ],
127
+ "format": [
128
+ "./dist/types/format/index.d.ts"
129
+ ],
130
+ "html": [
131
+ "./dist/types/html/index.d.ts"
132
+ ],
133
+ "markdown": [
134
+ "./dist/types/markdown/index.d.ts"
135
+ ],
136
+ "middleware": [
137
+ "./dist/types/middleware.d.ts"
138
+ ],
54
139
  "package.json": [
55
140
  "./package.json"
141
+ ],
142
+ "integration": [
143
+ "./dist/types/integration.d.ts"
56
144
  ]
57
145
  }
58
146
  },
@@ -79,13 +167,15 @@
79
167
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
80
168
  },
81
169
  "dependencies": {
82
- "@intlayer/config": "9.5.4",
83
- "@intlayer/core": "9.5.4",
84
- "@intlayer/engine": "9.5.4",
85
- "@intlayer/types": "9.5.4",
86
- "vite-intlayer": "9.5.4"
170
+ "@intlayer/config": "9.5.6",
171
+ "@intlayer/core": "9.5.6",
172
+ "@intlayer/engine": "9.5.6",
173
+ "@intlayer/types": "9.5.6",
174
+ "vanilla-intlayer": "9.5.6",
175
+ "vite-intlayer": "9.5.6"
87
176
  },
88
177
  "devDependencies": {
178
+ "@intlayer/dictionaries-entry": "9.5.6",
89
179
  "@types/node": "^22",
90
180
  "@utils/ts-config": "1.0.4",
91
181
  "@utils/ts-config-types": "1.0.4",