@astroscope/i18n 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/babel-plugin-C8O9spUS.js +120 -0
  2. package/dist/babel-plugin-C8O9spUS.js.map +1 -0
  3. package/dist/client/directives/idle.d.ts +4 -9
  4. package/dist/client/directives/idle.d.ts.map +1 -0
  5. package/dist/client/directives/idle.js +13 -21
  6. package/dist/client/directives/idle.js.map +1 -0
  7. package/dist/client/directives/load.d.ts +4 -9
  8. package/dist/client/directives/load.d.ts.map +1 -0
  9. package/dist/client/directives/load.js +9 -14
  10. package/dist/client/directives/load.js.map +1 -0
  11. package/dist/client/directives/media.d.ts +4 -9
  12. package/dist/client/directives/media.d.ts.map +1 -0
  13. package/dist/client/directives/media.js +16 -24
  14. package/dist/client/directives/media.js.map +1 -0
  15. package/dist/client/directives/only.d.ts +4 -11
  16. package/dist/client/directives/only.d.ts.map +1 -0
  17. package/dist/client/directives/only.js +9 -14
  18. package/dist/client/directives/only.js.map +1 -0
  19. package/dist/client/directives/utils.d.ts +3 -4
  20. package/dist/client/directives/utils.d.ts.map +1 -0
  21. package/dist/client/directives/utils.js +32 -7
  22. package/dist/client/directives/utils.js.map +1 -0
  23. package/dist/client/directives/visible.d.ts +4 -9
  24. package/dist/client/directives/visible.d.ts.map +1 -0
  25. package/dist/client/directives/visible.js +22 -29
  26. package/dist/client/directives/visible.js.map +1 -0
  27. package/dist/client/translate.d.ts +5 -4
  28. package/dist/client/translate.d.ts.map +1 -0
  29. package/dist/client/translate.js +68 -41
  30. package/dist/client/translate.js.map +1 -0
  31. package/dist/compiler-DjYjJc0V.js +45 -0
  32. package/dist/compiler-DjYjJc0V.js.map +1 -0
  33. package/dist/context-CNd4O0Pf.js +247 -0
  34. package/dist/context-CNd4O0Pf.js.map +1 -0
  35. package/dist/extraction/index.d.ts +12 -17
  36. package/dist/extraction/index.d.ts.map +1 -0
  37. package/dist/extraction/index.js +3 -11
  38. package/dist/i18n-DzmH9JmE.d.ts +79 -0
  39. package/dist/i18n-DzmH9JmE.d.ts.map +1 -0
  40. package/dist/index.d.ts +37 -33
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +163 -148
  43. package/dist/index.js.map +1 -0
  44. package/dist/internal.d.ts +6 -6
  45. package/dist/internal.d.ts.map +1 -0
  46. package/dist/internal.js +2 -10
  47. package/dist/manifest-D883_BIS.js +43 -0
  48. package/dist/manifest-D883_BIS.js.map +1 -0
  49. package/dist/rich-CHisXE-A.js +87 -0
  50. package/dist/rich-CHisXE-A.js.map +1 -0
  51. package/dist/{rich-CQUhdwBc.d.ts → rich-CqNMP3tk.d.ts} +4 -2
  52. package/dist/rich-CqNMP3tk.d.ts.map +1 -0
  53. package/dist/server/translate.d.ts +5 -3
  54. package/dist/server/translate.d.ts.map +1 -0
  55. package/dist/server/translate.js +75 -64
  56. package/dist/server/translate.js.map +1 -0
  57. package/dist/state-DeudhdeT.js +20 -0
  58. package/dist/state-DeudhdeT.js.map +1 -0
  59. package/dist/{types-ChMT6Vbd.d.ts → types-BfyoJsoB.d.ts} +11 -10
  60. package/dist/types-BfyoJsoB.d.ts.map +1 -0
  61. package/dist/types-Bo4jMK8g.d.ts +20 -0
  62. package/dist/types-Bo4jMK8g.d.ts.map +1 -0
  63. package/dist/{types-DNRFj1XA.d.ts → types-C98CcjtN.d.ts} +13 -11
  64. package/dist/types-C98CcjtN.d.ts.map +1 -0
  65. package/dist/url-B8334XSD.js +36 -0
  66. package/dist/url-B8334XSD.js.map +1 -0
  67. package/dist/vite-plugin-DVUlcvEH.js +421 -0
  68. package/dist/vite-plugin-DVUlcvEH.js.map +1 -0
  69. package/package.json +13 -12
  70. package/dist/babel-plugin-GOB6FMZ2.js +0 -119
  71. package/dist/chunk-33JVAFGQ.js +0 -44
  72. package/dist/chunk-4A5BKHFN.js +0 -16
  73. package/dist/chunk-7MSGHEST.js +0 -31
  74. package/dist/chunk-FYKC3DAZ.js +0 -36
  75. package/dist/chunk-LXW5WYBS.js +0 -298
  76. package/dist/chunk-PACQPCSW.js +0 -479
  77. package/dist/chunk-VGPVG5JP.js +0 -73
  78. package/dist/i18n-B--L7OQk.d.ts +0 -76
  79. package/dist/types-B_8vAmvv.d.ts +0 -18
  80. package/dist/types-BeDFfFIL.d.ts +0 -7
@@ -1,3 +1,4 @@
1
+ //#region src/shared/rich.d.ts
1
2
  /**
2
3
  * Component callbacks for rich text rendering.
3
4
  * Each key maps to a function that wraps children in a component.
@@ -11,5 +12,6 @@
11
12
  * ```
12
13
  */
13
14
  type RichComponents<T = unknown> = Record<string, (children: (string | T)[]) => T>;
14
-
15
- export type { RichComponents as R };
15
+ //#endregion
16
+ export { RichComponents as t };
17
+ //# sourceMappingURL=rich-CqNMP3tk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-CqNMP3tk.d.ts","names":[],"sources":["../src/shared/rich.ts"],"mappings":";;AAiBA;;;;;;;;;;;KAAY,cAAA,gBAA8B,MAAA,UAAgB,QAAA,YAAoB,CAAA,QAAS,CAAA"}
@@ -1,6 +1,7 @@
1
- import { R as RichComponents } from '../rich-CQUhdwBc.js';
2
- import { T as TranslationMeta, a as TranslateFunction } from '../types-DNRFj1XA.js';
1
+ import { t as RichComponents } from "../rich-CqNMP3tk.js";
2
+ import { a as TranslationMeta, i as TranslateFunction } from "../types-C98CcjtN.js";
3
3
 
4
+ //#region src/server/translate.d.ts
4
5
  /**
5
6
  * Get the current locale from request context.
6
7
  * Returns defaultLocale if called outside a request (e.g. during build).
@@ -34,5 +35,6 @@ declare const t: TranslateFunction;
34
35
  * ```
35
36
  */
36
37
  declare function rich<T = unknown>(key: string, meta?: TranslationMeta | string | undefined, components?: RichComponents<T> | undefined, values?: Record<string, unknown> | undefined): (string | T)[];
37
-
38
+ //#endregion
38
39
  export { getLocale, rich, t };
40
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.d.ts","names":[],"sources":["../../src/server/translate.ts"],"mappings":";;;;;;AAmCA;;iBAAgB,SAAA;;AAAS;AAYzB;;;;AAwCuB;cAxCV,CAAA,EAAG,iBAwCO;;;;;;;;;;;;;;;;;;;;iBAqBP,IAAA,cACd,GAAA,UACA,IAAA,GAAO,eAAA,uBACP,UAAA,GAAa,cAAA,CAAe,CAAA,eAC5B,MAAA,GAAS,MAAA,0CACE,CAAA"}
@@ -1,71 +1,82 @@
1
- import {
2
- getContext,
3
- i18n
4
- } from "../chunk-LXW5WYBS.js";
5
- import {
6
- normalizeMeta,
7
- partsToNodes
8
- } from "../chunk-VGPVG5JP.js";
9
- import {
10
- compileMessage,
11
- formatMessageToParts
12
- } from "../chunk-33JVAFGQ.js";
13
- import "../chunk-FYKC3DAZ.js";
14
-
15
- // src/server/translate.ts
16
- var fallbackCache = /* @__PURE__ */ new Map();
1
+ import { r as i18n, t as getContext } from "../context-CNd4O0Pf.js";
2
+ import { r as formatMessageToParts, t as compileMessage } from "../compiler-DjYjJc0V.js";
3
+ import { n as normalizeMeta, t as partsToNodes } from "../rich-CHisXE-A.js";
4
+ //#region src/server/translate.ts
5
+ const fallbackCache = /* @__PURE__ */ new Map();
6
+ /**
7
+ * Apply fallback behavior when translation is missing
8
+ */
17
9
  function applyFallback(key, meta, fallback) {
18
- if (typeof fallback === "function") {
19
- return fallback(key, meta);
20
- }
21
- switch (fallback) {
22
- case "key":
23
- return key;
24
- case "fallback":
25
- return meta.fallback || key;
26
- case "throw":
27
- throw new Error(`Missing translation for key: ${key}`);
28
- default:
29
- return meta.fallback || key;
30
- }
10
+ if (typeof fallback === "function") return fallback(key, meta);
11
+ switch (fallback) {
12
+ case "key": return key;
13
+ case "fallback": return meta.fallback || key;
14
+ case "throw": throw new Error(`Missing translation for key: ${key}`);
15
+ default: return meta.fallback || key;
16
+ }
31
17
  }
18
+ /**
19
+ * Get the current locale from request context.
20
+ * Returns defaultLocale if called outside a request (e.g. during build).
21
+ */
32
22
  function getLocale() {
33
- const ctx = getContext();
34
- return ctx?.locale ?? i18n.getConfig().defaultLocale;
23
+ return getContext()?.locale ?? i18n.getConfig().defaultLocale;
35
24
  }
36
- var t = ((key, meta, values) => {
37
- const normalizedMeta = meta ? normalizeMeta(meta) : { fallback: "" };
38
- const ctx = getContext();
39
- if (!ctx) {
40
- const defaultLocale = i18n.getConfig().defaultLocale;
41
- const fallbackStr = normalizedMeta.fallback || key;
42
- const cacheKey = `${defaultLocale}:${fallbackStr}`;
43
- let compiled2 = fallbackCache.get(cacheKey);
44
- if (!compiled2) {
45
- compiled2 = compileMessage(defaultLocale, fallbackStr);
46
- fallbackCache.set(cacheKey, compiled2);
47
- }
48
- return compiled2(values);
49
- }
50
- const compiled = ctx.translations[key];
51
- if (!compiled) {
52
- const fallbackValue = applyFallback(key, normalizedMeta, ctx.fallback);
53
- const compiledFallback = compileMessage(ctx.locale, fallbackValue);
54
- ctx.translations[key] = compiledFallback;
55
- return compiledFallback(values);
56
- }
57
- return compiled(values);
25
+ /**
26
+ * Server-side translate function
27
+ *
28
+ * Call patterns:
29
+ * - Development: t('key', 'fallback') or t('key', 'fallback', values)
30
+ * - Production: t('key') or t('key', undefined, values)
31
+ */
32
+ const t = ((key, meta, values) => {
33
+ const normalizedMeta = meta ? normalizeMeta(meta) : { fallback: "" };
34
+ const ctx = getContext();
35
+ if (!ctx) {
36
+ const defaultLocale = i18n.getConfig().defaultLocale;
37
+ const fallbackStr = normalizedMeta.fallback || key;
38
+ const cacheKey = `${defaultLocale}:${fallbackStr}`;
39
+ let compiled = fallbackCache.get(cacheKey);
40
+ if (!compiled) {
41
+ compiled = compileMessage(defaultLocale, fallbackStr);
42
+ fallbackCache.set(cacheKey, compiled);
43
+ }
44
+ return compiled(values);
45
+ }
46
+ const compiled = ctx.translations[key];
47
+ if (!compiled) {
48
+ const fallbackValue = applyFallback(key, normalizedMeta, ctx.fallback);
49
+ const compiledFallback = compileMessage(ctx.locale, fallbackValue);
50
+ ctx.translations[key] = compiledFallback;
51
+ return compiledFallback(values);
52
+ }
53
+ return compiled(values);
58
54
  });
55
+ /**
56
+ * Server-side rich text translation function
57
+ *
58
+ * Parses MF2 markup syntax and applies component callbacks to wrap content.
59
+ * Works with any JSX runtime (Astro, React during SSR, etc.).
60
+ *
61
+ * @param key - Translation key
62
+ * @param meta - Fallback string or meta object with fallback (used as message template)
63
+ * @param components - Map of tag names to component callbacks
64
+ * @param values - Runtime interpolation values (ICU MessageFormat)
65
+ *
66
+ * @example
67
+ * ```tsx
68
+ * rich('tos', 'Read our {#link}Terms{/link}', {
69
+ * link: (children) => <a href="/tos">{children}</a>
70
+ * })
71
+ * // Returns: ['Read our ', <a href="/tos">Terms</a>]
72
+ * ```
73
+ */
59
74
  function rich(key, meta, components, values) {
60
- const normalizedMeta = meta ? normalizeMeta(meta) : { fallback: "" };
61
- const ctx = getContext();
62
- const locale = ctx?.locale ?? i18n.getConfig().defaultLocale;
63
- const raw = ctx?.rawTranslations[key] ?? normalizedMeta.fallback ?? key;
64
- const parts = formatMessageToParts(locale, raw, values);
65
- return partsToNodes(parts, components ?? {});
75
+ const normalizedMeta = meta ? normalizeMeta(meta) : { fallback: "" };
76
+ const ctx = getContext();
77
+ return partsToNodes(formatMessageToParts(ctx?.locale ?? i18n.getConfig().defaultLocale, ctx?.rawTranslations[key] ?? normalizedMeta.fallback ?? key, values), components ?? {});
66
78
  }
67
- export {
68
- getLocale,
69
- rich,
70
- t
71
- };
79
+ //#endregion
80
+ export { getLocale, rich, t };
81
+
82
+ //# sourceMappingURL=translate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translate.js","names":[],"sources":["../../src/server/translate.ts"],"sourcesContent":["import { compileMessage, formatMessageToParts } from '../shared/compiler.js';\nimport { normalizeMeta } from '../shared/meta.js';\nimport { type RichComponents, partsToNodes } from '../shared/rich.js';\nimport type { CompiledTranslation, TranslateFunction, TranslationMeta } from '../shared/types.js';\nimport { getContext } from './context.js';\nimport { i18n } from './i18n.js';\nimport type { FallbackBehavior } from './types.js';\n\n// cache for fallbacks compiled outside request context (e.g. during build)\nconst fallbackCache = new Map<string, CompiledTranslation>();\n\n/**\n * Apply fallback behavior when translation is missing\n */\nfunction applyFallback(key: string, meta: TranslationMeta, fallback: FallbackBehavior): string {\n if (typeof fallback === 'function') {\n return fallback(key, meta);\n }\n\n switch (fallback) {\n case 'key':\n return key;\n case 'fallback':\n return meta.fallback || key;\n case 'throw':\n throw new Error(`Missing translation for key: ${key}`);\n default:\n return meta.fallback || key;\n }\n}\n\n/**\n * Get the current locale from request context.\n * Returns defaultLocale if called outside a request (e.g. during build).\n */\nexport function getLocale(): string {\n const ctx = getContext();\n return ctx?.locale ?? i18n.getConfig().defaultLocale;\n}\n\n/**\n * Server-side translate function\n *\n * Call patterns:\n * - Development: t('key', 'fallback') or t('key', 'fallback', values)\n * - Production: t('key') or t('key', undefined, values)\n */\nexport const t: TranslateFunction = ((\n key: string,\n meta?: TranslationMeta | string,\n values?: Record<string, unknown>,\n): string => {\n const normalizedMeta: TranslationMeta = meta ? normalizeMeta(meta) : { fallback: '' };\n\n const ctx = getContext();\n\n if (!ctx) {\n // no context = probably during build or outside request\n // use cached compiled fallback to avoid recompiling on every call\n const defaultLocale = i18n.getConfig().defaultLocale;\n const fallbackStr = normalizedMeta.fallback || key;\n const cacheKey = `${defaultLocale}:${fallbackStr}`;\n let compiled = fallbackCache.get(cacheKey);\n\n if (!compiled) {\n compiled = compileMessage(defaultLocale, fallbackStr);\n fallbackCache.set(cacheKey, compiled);\n }\n\n return compiled(values);\n }\n\n const compiled = ctx.translations[key];\n\n if (!compiled) {\n // translation missing, apply fallback\n const fallbackValue = applyFallback(key, normalizedMeta, ctx.fallback);\n\n // compile and cache the fallback for consistency\n const compiledFallback = compileMessage(ctx.locale, fallbackValue);\n\n ctx.translations[key] = compiledFallback;\n\n return compiledFallback(values);\n }\n\n return compiled(values);\n}) as TranslateFunction;\n\n/**\n * Server-side rich text translation function\n *\n * Parses MF2 markup syntax and applies component callbacks to wrap content.\n * Works with any JSX runtime (Astro, React during SSR, etc.).\n *\n * @param key - Translation key\n * @param meta - Fallback string or meta object with fallback (used as message template)\n * @param components - Map of tag names to component callbacks\n * @param values - Runtime interpolation values (ICU MessageFormat)\n *\n * @example\n * ```tsx\n * rich('tos', 'Read our {#link}Terms{/link}', {\n * link: (children) => <a href=\"/tos\">{children}</a>\n * })\n * // Returns: ['Read our ', <a href=\"/tos\">Terms</a>]\n * ```\n */\nexport function rich<T = unknown>(\n key: string,\n meta?: TranslationMeta | string | undefined,\n components?: RichComponents<T> | undefined,\n values?: Record<string, unknown> | undefined,\n): (string | T)[] {\n const normalizedMeta: TranslationMeta = meta ? normalizeMeta(meta) : { fallback: '' };\n\n const ctx = getContext();\n const locale = ctx?.locale ?? i18n.getConfig().defaultLocale;\n\n // get raw translation string - prefer from context, then fallback\n const raw = ctx?.rawTranslations[key] ?? normalizedMeta.fallback ?? key;\n\n const parts = formatMessageToParts(locale, raw, values);\n\n return partsToNodes(parts, components ?? {});\n}\n"],"mappings":";;;;AASA,MAAM,gCAAgB,IAAI,IAAiC;;;;AAK3D,SAAS,cAAc,KAAa,MAAuB,UAAoC;CAC7F,IAAI,OAAO,aAAa,YACtB,OAAO,SAAS,KAAK,IAAI;CAG3B,QAAQ,UAAR;EACE,KAAK,OACH,OAAO;EACT,KAAK,YACH,OAAO,KAAK,YAAY;EAC1B,KAAK,SACH,MAAM,IAAI,MAAM,gCAAgC,KAAK;EACvD,SACE,OAAO,KAAK,YAAY;CAC5B;AACF;;;;;AAMA,SAAgB,YAAoB;CAElC,OADY,WACH,CAAC,EAAE,UAAU,KAAK,UAAU,CAAC,CAAC;AACzC;;;;;;;;AASA,MAAa,MACX,KACA,MACA,WACW;CACX,MAAM,iBAAkC,OAAO,cAAc,IAAI,IAAI,EAAE,UAAU,GAAG;CAEpF,MAAM,MAAM,WAAW;CAEvB,IAAI,CAAC,KAAK;EAGR,MAAM,gBAAgB,KAAK,UAAU,CAAC,CAAC;EACvC,MAAM,cAAc,eAAe,YAAY;EAC/C,MAAM,WAAW,GAAG,cAAc,GAAG;EACrC,IAAI,WAAW,cAAc,IAAI,QAAQ;EAEzC,IAAI,CAAC,UAAU;GACb,WAAW,eAAe,eAAe,WAAW;GACpD,cAAc,IAAI,UAAU,QAAQ;EACtC;EAEA,OAAO,SAAS,MAAM;CACxB;CAEA,MAAM,WAAW,IAAI,aAAa;CAElC,IAAI,CAAC,UAAU;EAEb,MAAM,gBAAgB,cAAc,KAAK,gBAAgB,IAAI,QAAQ;EAGrE,MAAM,mBAAmB,eAAe,IAAI,QAAQ,aAAa;EAEjE,IAAI,aAAa,OAAO;EAExB,OAAO,iBAAiB,MAAM;CAChC;CAEA,OAAO,SAAS,MAAM;AACxB;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,KACd,KACA,MACA,YACA,QACgB;CAChB,MAAM,iBAAkC,OAAO,cAAc,IAAI,IAAI,EAAE,UAAU,GAAG;CAEpF,MAAM,MAAM,WAAW;CAQvB,OAAO,aAFO,qBALC,KAAK,UAAU,KAAK,UAAU,CAAC,CAAC,eAGnC,KAAK,gBAAgB,QAAQ,eAAe,YAAY,KAEpB,MAExB,GAAG,cAAc,CAAC,CAAC;AAC7C"}
@@ -0,0 +1,20 @@
1
+ //#region src/client/state.ts
2
+ let warnedMissingState = false;
3
+ /**
4
+ * Read the client i18n state injected by <I18nScript />.
5
+ *
6
+ * Returns undefined and logs an actionable error (once) when the script was not
7
+ * rendered — without it window.__i18n__ is undefined and translations cannot load.
8
+ */
9
+ function getI18nState() {
10
+ const state = window.__i18n__;
11
+ if (!state && !warnedMissingState) {
12
+ warnedMissingState = true;
13
+ console.error("[@astroscope/i18n] window.__i18n__ is not defined — translations will not work on the client. Render <I18nScript /> in your page <head> (before any hydrated islands) and make sure the i18n middleware is configured.");
14
+ }
15
+ return state;
16
+ }
17
+ //#endregion
18
+ export { getI18nState as t };
19
+
20
+ //# sourceMappingURL=state-DeudhdeT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-DeudhdeT.js","names":[],"sources":["../src/client/state.ts"],"sourcesContent":["import type { I18nClientState } from '../shared/types.js';\nimport './types.js';\n\nlet warnedMissingState = false;\n\n/**\n * Read the client i18n state injected by <I18nScript />.\n *\n * Returns undefined and logs an actionable error (once) when the script was not\n * rendered — without it window.__i18n__ is undefined and translations cannot load.\n */\nexport function getI18nState(): I18nClientState | undefined {\n const state = window.__i18n__;\n\n if (!state && !warnedMissingState) {\n warnedMissingState = true;\n\n console.error(\n '[@astroscope/i18n] window.__i18n__ is not defined — translations will not work on the client. ' +\n 'Render <I18nScript /> in your page <head> (before any hydrated islands) and make sure the i18n middleware is configured.',\n );\n }\n\n return state;\n}\n"],"mappings":";AAGA,IAAI,qBAAqB;;;;;;;AAQzB,SAAgB,eAA4C;CAC1D,MAAM,QAAQ,OAAO;CAErB,IAAI,CAAC,SAAS,CAAC,oBAAoB;EACjC,qBAAqB;EAErB,QAAQ,MACN,wNAEF;CACF;CAEA,OAAO;AACT"}
@@ -1,13 +1,13 @@
1
- import { T as TranslationMeta } from './types-DNRFj1XA.js';
1
+ import { a as TranslationMeta } from "./types-C98CcjtN.js";
2
2
 
3
+ //#region src/extraction/types.d.ts
3
4
  /**
4
5
  * Deduplicated translation key with all file locations (used in manifest)
5
6
  */
6
7
  type ExtractedKey = {
7
- key: string;
8
- meta: TranslationMeta;
9
- /** All locations where this key is used (file:line format) */
10
- files: string[];
8
+ key: string;
9
+ meta: TranslationMeta; /** All locations where this key is used (file:line format) */
10
+ files: string[];
11
11
  };
12
12
  /**
13
13
  * Chunk-to-keys mapping produced by Vite plugin
@@ -22,9 +22,10 @@ type ImportsManifest = Record<string, string[]>;
22
22
  * Full extraction manifest
23
23
  */
24
24
  type ExtractionManifest = {
25
- keys: ExtractedKey[];
26
- chunks: ChunkManifest;
27
- imports: ImportsManifest;
25
+ keys: ExtractedKey[];
26
+ chunks: ChunkManifest;
27
+ imports: ImportsManifest;
28
28
  };
29
-
30
- export type { ChunkManifest as C, ExtractionManifest as E, ExtractedKey as a };
29
+ //#endregion
30
+ export { ExtractedKey as n, ExtractionManifest as r, ChunkManifest as t };
31
+ //# sourceMappingURL=types-BfyoJsoB.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BfyoJsoB.d.ts","names":[],"sources":["../src/extraction/types.ts"],"mappings":";;;;;AAmBO;KAJK,YAAA;EACV,GAAA;EACA,IAAA,EAAM,eAAe,EAQW;EANhC,KAAA;AAAA;;;;KAMU,aAAA,GAAgB,MAAM;AAWlC;;;;AAAA,KALY,eAAA,GAAkB,MAAM;;;;KAKxB,kBAAA;EACV,IAAA,EAAM,YAAA;EACN,MAAA,EAAQ,aAAA;EACR,OAAA,EAAS,eAAA;AAAA"}
@@ -0,0 +1,20 @@
1
+ //#region src/integration/types.d.ts
2
+ /**
3
+ * Consistency check level for translation keys.
4
+ * Controls behavior when the same key has different fallbacks/variables across files.
5
+ *
6
+ * - 'error' (default): Fail the build
7
+ * - 'warn': Log a warning but continue
8
+ * - 'off': Disable consistency checking
9
+ */
10
+ type ConsistencyCheckLevel = 'off' | 'warn' | 'error';
11
+ interface I18nOptions {
12
+ /**
13
+ * How to handle inconsistent translation keys (same key with different fallbacks/variables).
14
+ * @default 'error'
15
+ */
16
+ consistency?: ConsistencyCheckLevel | undefined;
17
+ }
18
+ //#endregion
19
+ export { I18nOptions as n, ConsistencyCheckLevel as t };
20
+ //# sourceMappingURL=types-Bo4jMK8g.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-Bo4jMK8g.d.ts","names":[],"sources":["../src/integration/types.ts"],"mappings":";;AAQA;;;;AAAiC;AAEjC;;KAFY,qBAAA;AAAA,UAEK,WAAA;EAKoB;;;;EAAnC,WAAA,GAAc,qBAAqB;AAAA"}
@@ -1,17 +1,18 @@
1
+ //#region src/shared/types.d.ts
1
2
  /**
2
3
  * Variable definition for documentation
3
4
  */
4
5
  type VariableDef = {
5
- fallback?: string | undefined;
6
- description?: string | undefined;
6
+ fallback?: string | undefined;
7
+ description?: string | undefined;
7
8
  };
8
9
  /**
9
10
  * Metadata for a translation key - extracted at build time
10
11
  */
11
12
  type TranslationMeta = {
12
- fallback: string;
13
- variables?: Record<string, VariableDef> | undefined;
14
- description?: string | undefined;
13
+ fallback: string;
14
+ variables?: Record<string, VariableDef> | undefined;
15
+ description?: string | undefined;
15
16
  };
16
17
  /**
17
18
  * Compiled translation ready for runtime use
@@ -29,10 +30,10 @@ type RawTranslations = Record<string, string>;
29
30
  * Client-side i18n state injected into window.__i18n__
30
31
  */
31
32
  type I18nClientState = {
32
- locale: string;
33
- hashes: Record<string, string>;
34
- translations: Record<string, string>;
35
- imports: Record<string, string[]>;
33
+ locale: string;
34
+ hashes: Record<string, string>;
35
+ translations: Record<string, string>;
36
+ imports: Record<string, string[]>;
36
37
  };
37
38
  /**
38
39
  * Translate function
@@ -47,5 +48,6 @@ type I18nClientState = {
47
48
  * t('cart.total', { fallback: 'Total: {amount}' }, { amount: '$49.99' })
48
49
  */
49
50
  type TranslateFunction = (key: string, meta: TranslationMeta | string, values?: Record<string, unknown> | undefined) => string;
50
-
51
- export type { CompiledTranslations as C, I18nClientState as I, RawTranslations as R, TranslationMeta as T, TranslateFunction as a };
51
+ //#endregion
52
+ export { TranslationMeta as a, TranslateFunction as i, I18nClientState as n, RawTranslations as r, CompiledTranslations as t };
53
+ //# sourceMappingURL=types-C98CcjtN.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-C98CcjtN.d.ts","names":[],"sources":["../src/shared/types.ts"],"mappings":";;AAGA;;KAAY,WAAA;EACV,QAAA;EACA,WAAW;AAAA;;;;KAMD,eAAA;EACV,QAAA;EACA,SAAA,GAAY,MAAM,SAAS,WAAA;EAC3B,WAAA;AAAA;;AAAW;AAMb;KAAY,mBAAA,IAAuB,MAA4C,GAAnC,MAAM;;;AAA6B;KAKnE,oBAAA,GAAuB,MAAM,SAAS,mBAAA;;;;KAKtC,eAAA,GAAkB,MAAM;AAApC;;;AAAA,KAKY,eAAA;EACV,MAAA;EACA,MAAA,EAAQ,MAAA;EACR,YAAA,EAAc,MAAA;EACd,OAAA,EAAS,MAAA;AAAA;;;;;;;;;;;;;KAeC,iBAAA,IACV,GAAA,UACA,IAAA,EAAM,eAAA,WACN,MAAA,GAAS,MAAM"}
@@ -0,0 +1,36 @@
1
+ //#region src/shared/url.ts
2
+ /**
3
+ * Convert a Vite chunk ID to a clean chunk name
4
+ * Strips the _astro/ prefix that Vite adds
5
+ *
6
+ * @example
7
+ * chunkIdToName('_astro/Cart.C_sxtxbl') // → 'Cart.C_sxtxbl'
8
+ * chunkIdToName('Cart.C_sxtxbl') // → 'Cart.C_sxtxbl'
9
+ */
10
+ function chunkIdToName(chunkId) {
11
+ return chunkId.replace(/^_astro\//, "");
12
+ }
13
+ /**
14
+ * Extract chunk name from a component URL
15
+ * Used by client directives to get the hash lookup key
16
+ *
17
+ * @example
18
+ * componentUrlToChunkName('/_astro/Cart.C_sxtxbl.js') // → 'Cart.C_sxtxbl'
19
+ */
20
+ function componentUrlToChunkName(componentUrl) {
21
+ return componentUrl.replace(/^\/_astro\//, "").replace(/\.js$/, "");
22
+ }
23
+ /**
24
+ * Build the URL path for fetching a translation chunk
25
+ *
26
+ * @example
27
+ * buildI18nChunkUrl('en', '_astro/Cart.C_sxtxbl', 'bzh6rx')
28
+ * // → '/_i18n/en/Cart.C_sxtxbl.bzh6rx.js'
29
+ */
30
+ function buildI18nChunkUrl(locale, chunkId, hash) {
31
+ return `/_i18n/${locale}/${chunkIdToName(chunkId)}.${hash}.js`;
32
+ }
33
+ //#endregion
34
+ export { chunkIdToName as n, componentUrlToChunkName as r, buildI18nChunkUrl as t };
35
+
36
+ //# sourceMappingURL=url-B8334XSD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-B8334XSD.js","names":[],"sources":["../src/shared/url.ts"],"sourcesContent":["/**\n * Convert a Vite chunk ID to a clean chunk name\n * Strips the _astro/ prefix that Vite adds\n *\n * @example\n * chunkIdToName('_astro/Cart.C_sxtxbl') // → 'Cart.C_sxtxbl'\n * chunkIdToName('Cart.C_sxtxbl') // → 'Cart.C_sxtxbl'\n */\nexport function chunkIdToName(chunkId: string): string {\n return chunkId.replace(/^_astro\\//, '');\n}\n\n/**\n * Extract chunk name from a component URL\n * Used by client directives to get the hash lookup key\n *\n * @example\n * componentUrlToChunkName('/_astro/Cart.C_sxtxbl.js') // → 'Cart.C_sxtxbl'\n */\nexport function componentUrlToChunkName(componentUrl: string): string {\n return componentUrl.replace(/^\\/_astro\\//, '').replace(/\\.js$/, '');\n}\n\n/**\n * Build the URL path for fetching a translation chunk\n *\n * @example\n * buildI18nChunkUrl('en', '_astro/Cart.C_sxtxbl', 'bzh6rx')\n * // → '/_i18n/en/Cart.C_sxtxbl.bzh6rx.js'\n */\nexport function buildI18nChunkUrl(locale: string, chunkId: string, hash: string): string {\n return `/_i18n/${locale}/${chunkIdToName(chunkId)}.${hash}.js`;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,cAAc,SAAyB;CACrD,OAAO,QAAQ,QAAQ,aAAa,EAAE;AACxC;;;;;;;;AASA,SAAgB,wBAAwB,cAA8B;CACpE,OAAO,aAAa,QAAQ,eAAe,EAAE,CAAC,CAAC,QAAQ,SAAS,EAAE;AACpE;;;;;;;;AASA,SAAgB,kBAAkB,QAAgB,SAAiB,MAAsB;CACvF,OAAO,UAAU,OAAO,GAAG,cAAc,OAAO,EAAE,GAAG,KAAK;AAC5D"}