lit-intlayer 9.9.3-canary.1 → 9.9.4

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 (72) hide show
  1. package/dist/cjs/client/IntlayerBinding.cjs +93 -1
  2. package/dist/cjs/client/index.cjs +28 -1
  3. package/dist/cjs/client/installIntlayer.cjs +6 -1
  4. package/dist/cjs/client/useDictionary.cjs +24 -1
  5. package/dist/cjs/client/useDictionaryDynamic.cjs +47 -1
  6. package/dist/cjs/client/useIntlayer.cjs +30 -1
  7. package/dist/cjs/client/useLocale.cjs +90 -1
  8. package/dist/cjs/client/useLocaleStorage.cjs +56 -1
  9. package/dist/cjs/client/useRewriteURL.cjs +48 -1
  10. package/dist/cjs/editor/useEditor.cjs +3 -1
  11. package/dist/cjs/format/index.cjs +19 -1
  12. package/dist/cjs/format/useCompact.cjs +34 -1
  13. package/dist/cjs/format/useCurrency.cjs +34 -1
  14. package/dist/cjs/format/useDate.cjs +52 -1
  15. package/dist/cjs/format/useIntl.cjs +66 -1
  16. package/dist/cjs/format/useList.cjs +34 -1
  17. package/dist/cjs/format/useNumber.cjs +40 -1
  18. package/dist/cjs/format/usePercentage.cjs +34 -1
  19. package/dist/cjs/format/useRelativeTime.cjs +34 -1
  20. package/dist/cjs/format/useUnit.cjs +34 -1
  21. package/dist/cjs/getDictionary.cjs +14 -1
  22. package/dist/cjs/getIntlayer.cjs +14 -1
  23. package/dist/cjs/html/HTMLRenderer.cjs +53 -1
  24. package/dist/cjs/html/index.cjs +8 -1
  25. package/dist/cjs/html/installIntlayerHTML.cjs +90 -1
  26. package/dist/cjs/html/types.cjs +1 -1
  27. package/dist/cjs/index.cjs +41 -1
  28. package/dist/cjs/markdown/MarkdownRenderer.cjs +97 -1
  29. package/dist/cjs/markdown/compiler.cjs +72 -1
  30. package/dist/cjs/markdown/index.cjs +12 -1
  31. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +98 -1
  32. package/dist/cjs/markdown/runtime.cjs +86 -1
  33. package/dist/cjs/plugins.cjs +217 -3
  34. package/dist/cjs/renderIntlayerNode.cjs +29 -1
  35. package/dist/esm/client/IntlayerBinding.mjs +75 -33
  36. package/dist/esm/client/index.mjs +9 -9
  37. package/dist/esm/client/installIntlayer.mjs +1 -1
  38. package/dist/esm/client/useDictionary.mjs +22 -10
  39. package/dist/esm/client/useDictionaryDynamic.mjs +44 -11
  40. package/dist/esm/client/useIntlayer.mjs +28 -10
  41. package/dist/esm/client/useLocale.mjs +71 -19
  42. package/dist/esm/client/useLocaleStorage.mjs +45 -12
  43. package/dist/esm/client/useRewriteURL.mjs +36 -18
  44. package/dist/esm/editor/useEditor.mjs +1 -1
  45. package/dist/esm/format/index.mjs +10 -10
  46. package/dist/esm/format/useCompact.mjs +23 -19
  47. package/dist/esm/format/useCurrency.mjs +23 -19
  48. package/dist/esm/format/useDate.mjs +37 -27
  49. package/dist/esm/format/useIntl.mjs +54 -13
  50. package/dist/esm/format/useList.mjs +23 -19
  51. package/dist/esm/format/useNumber.mjs +29 -19
  52. package/dist/esm/format/usePercentage.mjs +23 -19
  53. package/dist/esm/format/useRelativeTime.mjs +23 -19
  54. package/dist/esm/format/useUnit.mjs +23 -19
  55. package/dist/esm/getDictionary.mjs +11 -6
  56. package/dist/esm/getIntlayer.mjs +11 -6
  57. package/dist/esm/html/HTMLRenderer.mjs +38 -13
  58. package/dist/esm/html/index.mjs +3 -3
  59. package/dist/esm/html/installIntlayerHTML.mjs +82 -13
  60. package/dist/esm/index.mjs +12 -12
  61. package/dist/esm/markdown/MarkdownRenderer.mjs +66 -26
  62. package/dist/esm/markdown/compiler.mjs +68 -22
  63. package/dist/esm/markdown/index.mjs +4 -4
  64. package/dist/esm/markdown/installIntlayerMarkdown.mjs +87 -23
  65. package/dist/esm/markdown/runtime.mjs +58 -28
  66. package/dist/esm/plugins.mjs +156 -106
  67. package/dist/esm/renderIntlayerNode.mjs +17 -17
  68. package/dist/installIntlayer-CCMOc1XT.mjs +174 -0
  69. package/dist/installIntlayer-HB8aIQ-i.js +203 -0
  70. package/package.json +7 -7
  71. package/dist/installIntlayer-CFvvijL7.js +0 -1
  72. package/dist/installIntlayer-CTpPd7yz.mjs +0 -82
@@ -1 +1,93 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/dictionaryManipulator");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;unsubscribeLocale=null;onConnect;onDisconnect;constructor(e,t,n){this.host=e,this.onConnect=t,this.onDisconnect=n,this.host.addController(this)}hostConnected(){let e=t.r();this.unsubscribeLocale=e.subscribe(()=>{this.host.requestUpdate()}),this.onConnect?.()}hostDisconnected(){this.unsubscribeLocale?.(),this.unsubscribeLocale=null,this.onDisconnect?.()}},r=r=>{let i=t.r(),a=new Set,o,s,c,l=!1,u=()=>{if(!l||s!==i.locale||c!==i.variant){l=!0,s=i.locale,c=i.variant;let e=r({contextLocale:i.locale,contextVariant:i.variant},e=>{o={content:e};for(let e of a)e.requestUpdate()});e&&(o=e)}return o};u();let d=new Proxy({},{get(t,r){if(r===`observe`)return e=>(a.add(e),new n(e,()=>{o&&e.requestUpdate()},()=>a.delete(e)),d);if(r===`then`||typeof r==`string`&&r.startsWith(`_$`))return;let i=u();if(!i)return e.loadingContentPlaceholder[r];let s=i.content;return r===Symbol.toPrimitive?()=>s?.[Symbol.toPrimitive]?.()??``:r===`toString`?()=>String(s?.toString?.()??``):s?.[r]}});return d};exports.IntlayerBinding=n,exports.createContentProxy=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/client/IntlayerBinding.ts
5
+ /**
6
+ * `ReactiveController` that keeps a Lit element in sync with Intlayer locale
7
+ * changes and, optionally, async dictionary load events.
8
+ *
9
+ * Registered automatically by `.observe(this)` — you should never need to
10
+ * instantiate it directly.
11
+ *
12
+ * @param host - The Lit element to update.
13
+ * @param onConnect - Called inside `hostConnected` (after locale subscription
14
+ * is set up). Useful for triggering an immediate update
15
+ * when the dictionary is already cached.
16
+ * @param onDisconnect - Called inside `hostDisconnected`. Useful for removing
17
+ * the host from a dictionary's update-host registry.
18
+ */
19
+ var IntlayerBinding = class {
20
+ host;
21
+ unsubscribeLocale = null;
22
+ onConnect;
23
+ onDisconnect;
24
+ constructor(host, onConnect, onDisconnect) {
25
+ this.host = host;
26
+ this.onConnect = onConnect;
27
+ this.onDisconnect = onDisconnect;
28
+ this.host.addController(this);
29
+ }
30
+ hostConnected() {
31
+ const client = require_installIntlayer.getIntlayerClient();
32
+ this.unsubscribeLocale = client.subscribe(() => {
33
+ this.host.requestUpdate();
34
+ });
35
+ this.onConnect?.();
36
+ }
37
+ hostDisconnected() {
38
+ this.unsubscribeLocale?.();
39
+ this.unsubscribeLocale = null;
40
+ this.onDisconnect?.();
41
+ }
42
+ };
43
+ /**
44
+ * Wraps content read for the client's locale and variant (read again whenever
45
+ * either changes) in an {@link IntlayerLitProxy}. Chain `.observe(this)` so
46
+ * the host re-renders on locale changes and once loading content lands; while
47
+ * the first content loads, every access renders `''`. Shared by `useDictionary`,
48
+ * `useIntlayer` and `useDictionaryDynamic`.
49
+ */
50
+ var createContentProxy = (readContent) => {
51
+ const client = require_installIntlayer.getIntlayerClient();
52
+ const hosts = /* @__PURE__ */ new Set();
53
+ let current;
54
+ let readLocale;
55
+ let readVariant;
56
+ let hasRead = false;
57
+ const getContent = () => {
58
+ if (!hasRead || readLocale !== client.locale || readVariant !== client.variant) {
59
+ hasRead = true;
60
+ readLocale = client.locale;
61
+ readVariant = client.variant;
62
+ const settled = readContent({
63
+ contextLocale: client.locale,
64
+ contextVariant: client.variant
65
+ }, (content) => {
66
+ current = { content };
67
+ for (const host of hosts) host.requestUpdate();
68
+ });
69
+ if (settled) current = settled;
70
+ }
71
+ return current;
72
+ };
73
+ getContent();
74
+ const proxy = new Proxy({}, { get(_target, property) {
75
+ if (property === "observe") return (host) => {
76
+ hosts.add(host);
77
+ new IntlayerBinding(host, () => {
78
+ if (current) host.requestUpdate();
79
+ }, () => hosts.delete(host));
80
+ return proxy;
81
+ };
82
+ if (property === "then" || typeof property === "string" && property.startsWith("_$")) return;
83
+ const loaded = getContent();
84
+ if (!loaded) return _intlayer_core_dictionaryManipulator.loadingContentPlaceholder[property];
85
+ const content = loaded.content;
86
+ if (property === Symbol.toPrimitive) return () => content?.[Symbol.toPrimitive]?.() ?? "";
87
+ if (property === "toString") return () => String(content?.toString?.() ?? "");
88
+ return content?.[property];
89
+ } });
90
+ return proxy;
91
+ };
92
+ exports.IntlayerBinding = IntlayerBinding;
93
+ exports.createContentProxy = createContentProxy;
@@ -1 +1,28 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./IntlayerBinding.cjs"),t=require("../../installIntlayer-CFvvijL7.js"),n=require("./useDictionary.cjs"),r=require("./useDictionaryDynamic.cjs"),i=require("./useIntlayer.cjs"),a=require("./useLocale.cjs"),o=require("./useLocaleStorage.cjs"),s=require("./useRewriteURL.cjs");exports.IntlayerBinding=e.IntlayerBinding,exports.IntlayerClient=t.t,exports.LocaleController=a.LocaleController,exports.createContentProxy=e.createContentProxy,exports.createIntlayerClient=t.n,exports.getIntlayerClient=t.r,exports.getLocaleInStorage=o.getLocaleInStorage,exports.installIntlayer=t.i,exports.localeCookie=o.localeCookie,exports.localeInStorage=o.localeInStorage,exports.setLocaleCookie=o.setLocaleCookie,exports.setLocaleInStorage=o.setLocaleInStorage,exports.useDictionary=n.useDictionary,exports.useDictionaryDynamic=r.useDictionaryDynamic,exports.useIntlayer=i.useIntlayer,exports.useLocale=a.useLocale,exports.useLocaleCookie=o.useLocaleCookie,exports.useLocaleStorage=o.useLocaleStorage,exports.useRewriteURL=s.useRewriteURL;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_client_IntlayerBinding = require("./IntlayerBinding.cjs");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ const require_client_useDictionary = require("./useDictionary.cjs");
5
+ const require_client_useDictionaryDynamic = require("./useDictionaryDynamic.cjs");
6
+ const require_client_useIntlayer = require("./useIntlayer.cjs");
7
+ const require_client_useLocale = require("./useLocale.cjs");
8
+ const require_client_useLocaleStorage = require("./useLocaleStorage.cjs");
9
+ const require_client_useRewriteURL = require("./useRewriteURL.cjs");
10
+ exports.IntlayerBinding = require_client_IntlayerBinding.IntlayerBinding;
11
+ exports.IntlayerClient = require_installIntlayer.IntlayerClient;
12
+ exports.LocaleController = require_client_useLocale.LocaleController;
13
+ exports.createContentProxy = require_client_IntlayerBinding.createContentProxy;
14
+ exports.createIntlayerClient = require_installIntlayer.createIntlayerClient;
15
+ exports.getIntlayerClient = require_installIntlayer.getIntlayerClient;
16
+ exports.getLocaleInStorage = require_client_useLocaleStorage.getLocaleInStorage;
17
+ exports.installIntlayer = require_installIntlayer.installIntlayer;
18
+ exports.localeCookie = require_client_useLocaleStorage.localeCookie;
19
+ exports.localeInStorage = require_client_useLocaleStorage.localeInStorage;
20
+ exports.setLocaleCookie = require_client_useLocaleStorage.setLocaleCookie;
21
+ exports.setLocaleInStorage = require_client_useLocaleStorage.setLocaleInStorage;
22
+ exports.useDictionary = require_client_useDictionary.useDictionary;
23
+ exports.useDictionaryDynamic = require_client_useDictionaryDynamic.useDictionaryDynamic;
24
+ exports.useIntlayer = require_client_useIntlayer.useIntlayer;
25
+ exports.useLocale = require_client_useLocale.useLocale;
26
+ exports.useLocaleCookie = require_client_useLocaleStorage.useLocaleCookie;
27
+ exports.useLocaleStorage = require_client_useLocaleStorage.useLocaleStorage;
28
+ exports.useRewriteURL = require_client_useRewriteURL.useRewriteURL;
@@ -1 +1,6 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../installIntlayer-CFvvijL7.js");exports.IntlayerClient=e.t,exports.createIntlayerClient=e.n,exports.getIntlayerClient=e.r,exports.installIntlayer=e.i;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
3
+ exports.IntlayerClient = require_installIntlayer.IntlayerClient;
4
+ exports.createIntlayerClient = require_installIntlayer.createIntlayerClient;
5
+ exports.getIntlayerClient = require_installIntlayer.getIntlayerClient;
6
+ exports.installIntlayer = require_installIntlayer.installIntlayer;
@@ -1 +1,24 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/dictionaryManipulator");const t=require("../getDictionary.cjs"),n=require("./IntlayerBinding.cjs");var r=(r,i)=>n.createContentProxy(({contextLocale:n,contextVariant:a})=>({content:process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?t.getDictionary(r,i??n):t.getDictionary(r,(0,e.resolveDictionaryArgument)({localeOrSelector:i,contextLocale:n,contextVariant:a,dictionaryKey:r.key}))}));exports.useDictionary=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
3
+ const require_getDictionary = require("../getDictionary.cjs");
4
+ const require_client_IntlayerBinding = require("./IntlayerBinding.cjs");
5
+ // src/client/useDictionary.ts
6
+ /**
7
+ * Returns the content for a raw dictionary (or qualified dictionary group),
8
+ * wrapped in an {@link IntlayerLitProxy} so the caller can subscribe to locale
9
+ * changes via a Lit `ReactiveController`.
10
+ *
11
+ * The second argument is either a locale or a selector object (`{ item }`,
12
+ * `{ variant }`, optionally combined with `locale`).
13
+ *
14
+ * @param dictionary - The raw dictionary (or qualified group) object.
15
+ * @param localeOrSelector - Optional locale or selector.
16
+ * @returns An {@link IntlayerLitProxy} with an `.observe()` registration method.
17
+ */
18
+ var useDictionary = (dictionary, localeOrSelector) => require_client_IntlayerBinding.createContentProxy(({ contextLocale, contextVariant }) => ({ content: process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? require_getDictionary.getDictionary(dictionary, (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
19
+ localeOrSelector,
20
+ contextLocale,
21
+ contextVariant,
22
+ dictionaryKey: dictionary.key
23
+ })) : require_getDictionary.getDictionary(dictionary, localeOrSelector ?? contextLocale) }));
24
+ exports.useDictionary = useDictionary;
@@ -1 +1,47 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/dictionaryManipulator");const t=require("../getDictionary.cjs"),n=require("./IntlayerBinding.cjs");var r=(0,e.createDynamicContentStore)((e,n)=>t.getDictionary(e,n)),i=(e,t,i)=>{let a=r.createReader(e,String(t));return n.createContentProxy(({contextLocale:e,contextVariant:t},n)=>a({localeOrSelector:i,contextLocale:e,contextVariant:t},n))};exports.useDictionaryDynamic=i;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
3
+ const require_getDictionary = require("../getDictionary.cjs");
4
+ const require_client_IntlayerBinding = require("./IntlayerBinding.cjs");
5
+ // src/client/useDictionaryDynamic.ts
6
+ /** Content cache shared by every dynamic read of the page. */
7
+ var dynamicContentStore = (0, _intlayer_core_dictionaryManipulator.createDynamicContentStore)((dictionary, argument) => require_getDictionary.getDictionary(dictionary, argument));
8
+ /**
9
+ * Returns the translated content for a lazily-loaded dictionary, wrapped in an
10
+ * {@link IntlayerLitProxy} so the caller can register a Lit `ReactiveController`
11
+ * that keeps the element in sync with both the async bundle load and locale
12
+ * changes.
13
+ *
14
+ * This is the babel-optimized counterpart of `useIntlayer` when
15
+ * `importMode = 'dynamic'` — it accepts the locale-keyed loader map injected
16
+ * by the build plugin, matching the same signature as `react-intlayer` and
17
+ * other framework adapters.
18
+ *
19
+ * While loading, property accesses return the shared loading placeholder,
20
+ * which renders `''`. Chain `.observe(this)` so Lit triggers `requestUpdate()`
21
+ * once the bundle is ready and on every subsequent locale change.
22
+ *
23
+ * The `intlayerLitPlugin` Vite plugin automatically appends
24
+ * `.observe(this)` at build / serve time, so manual chaining is usually
25
+ * unnecessary.
26
+ *
27
+ * @param dictionaryPromise - Locale-keyed loader map, or a qualified loader map.
28
+ * @param key - The dictionary key (used for cache namespacing).
29
+ * @param localeOrSelector - Optional locale or selector.
30
+ * @returns An {@link IntlayerLitProxy} proxy with an `.observe()` method.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * // Typically injected by the babel/SWC optimization plugin:
35
+ * import _hash_dyn from '.intlayer/dynamic_dictionaries/app.mjs';
36
+ * private content = useDictionaryDynamic(_hash_dyn, 'app').observe(this);
37
+ * ```
38
+ */
39
+ var useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
40
+ const readContent = dynamicContentStore.createReader(dictionaryPromise, String(key));
41
+ return require_client_IntlayerBinding.createContentProxy(({ contextLocale, contextVariant }, onLoad) => readContent({
42
+ localeOrSelector,
43
+ contextLocale,
44
+ contextVariant
45
+ }, onLoad));
46
+ };
47
+ exports.useDictionaryDynamic = useDictionaryDynamic;
@@ -1 +1,30 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/dictionaryManipulator");const t=require("../getIntlayer.cjs"),n=require("./IntlayerBinding.cjs");var r=(r,i)=>n.createContentProxy(({contextLocale:n,contextVariant:a})=>({content:process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?t.getIntlayer(r,i??n):t.getIntlayer(r,(0,e.resolveDictionaryArgument)({localeOrSelector:i,contextLocale:n,contextVariant:a,dictionaryKey:r}))}));exports.useIntlayer=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
3
+ const require_getIntlayer = require("../getIntlayer.cjs");
4
+ const require_client_IntlayerBinding = require("./IntlayerBinding.cjs");
5
+ // src/client/useIntlayer.ts
6
+ /**
7
+ * Returns the translated content for the given dictionary key, wrapped in an
8
+ * {@link IntlayerLitProxy} so the caller can subscribe to locale changes via
9
+ * a Lit `ReactiveController`.
10
+ *
11
+ * Matches the same signature as `react-intlayer` and all other framework
12
+ * adapters:
13
+ * ```ts
14
+ * private content = useIntlayer('my-component').observe(this);
15
+ * ```
16
+ *
17
+ * The babel/SWC optimization plugin transforms this at build time into either:
18
+ * - static mode: `useDictionary(_hash)` — synchronous JSON import
19
+ * - dynamic mode: `useDictionaryDynamic(_dyn, 'key')` — lazy locale split
20
+ *
21
+ * In non-optimized builds (dev without babel) the content is read from
22
+ * `getIntlayer`, again whenever the client locale or variant changes.
23
+ */
24
+ var useIntlayer = (key, localeOrSelector) => require_client_IntlayerBinding.createContentProxy(({ contextLocale, contextVariant }) => ({ content: process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? require_getIntlayer.getIntlayer(key, (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
25
+ localeOrSelector,
26
+ contextLocale,
27
+ contextVariant,
28
+ dictionaryKey: key
29
+ })) : require_getIntlayer.getIntlayer(key, localeOrSelector ?? contextLocale) }));
30
+ exports.useIntlayer = useIntlayer;
@@ -1 +1,90 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built");const t=require("../../installIntlayer-CFvvijL7.js"),n=require("./useLocaleStorage.cjs");var r=class{host;_isCookieEnabled;_onLocaleChange;_unsubscribe=null;locale;defaultLocale;availableLocales;constructor(n,r={}){this.host=n,this._isCookieEnabled=r.isCookieEnabled,this._onLocaleChange=r.onLocaleChange;let i=t.r(),{defaultLocale:a,locales:o}=e.internationalization??{};this.locale=i.locale,this.defaultLocale=a,this.availableLocales=o??[],n.addController(this)}setLocale=e=>{if(!this.availableLocales.map(String).includes(e)){console.error(`Locale "${e}" is not available.`);return}let r=t.r();r.setLocale(e),n.setLocaleInStorage(e,this._isCookieEnabled??r.isCookieEnabled??!0),this._onLocaleChange?.(e)};hostConnected(){let e=t.r();this._unsubscribe=e.subscribe(e=>{this.locale=e,this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},i=(e,t={})=>new r(e,t);exports.LocaleController=r,exports.useLocale=i;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_config_built = require("@intlayer/config/built");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ const require_client_useLocaleStorage = require("./useLocaleStorage.cjs");
5
+ // src/client/useLocale.ts
6
+ /**
7
+ * ReactiveController that exposes the current locale and a `setLocale` setter.
8
+ * The host element re-renders whenever the locale changes.
9
+ */
10
+ var LocaleController = class {
11
+ host;
12
+ _isCookieEnabled;
13
+ _onLocaleChange;
14
+ _unsubscribe = null;
15
+ /** The currently active locale. */
16
+ locale;
17
+ /** The application's default locale (from config). */
18
+ defaultLocale;
19
+ /** All available locales (from config). */
20
+ availableLocales;
21
+ constructor(host, props = {}) {
22
+ this.host = host;
23
+ this._isCookieEnabled = props.isCookieEnabled;
24
+ this._onLocaleChange = props.onLocaleChange;
25
+ const client = require_installIntlayer.getIntlayerClient();
26
+ const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
27
+ this.locale = client.locale;
28
+ this.defaultLocale = defaultLocale;
29
+ this.availableLocales = availableLocales ?? [];
30
+ host.addController(this);
31
+ }
32
+ /**
33
+ * Change the application locale.
34
+ * Validates against `availableLocales`, persists to storage, and triggers a re-render.
35
+ */
36
+ setLocale = (newLocale) => {
37
+ if (!this.availableLocales.map(String).includes(newLocale)) {
38
+ console.error(`Locale "${newLocale}" is not available.`);
39
+ return;
40
+ }
41
+ const client = require_installIntlayer.getIntlayerClient();
42
+ client.setLocale(newLocale);
43
+ require_client_useLocaleStorage.setLocaleInStorage(newLocale, this._isCookieEnabled ?? client.isCookieEnabled ?? true);
44
+ this._onLocaleChange?.(newLocale);
45
+ };
46
+ hostConnected() {
47
+ const client = require_installIntlayer.getIntlayerClient();
48
+ this._unsubscribe = client.subscribe((newLocale) => {
49
+ this.locale = newLocale;
50
+ this.host.requestUpdate();
51
+ });
52
+ }
53
+ hostDisconnected() {
54
+ this._unsubscribe?.();
55
+ this._unsubscribe = null;
56
+ }
57
+ };
58
+ /**
59
+ * Reactive hook that provides locale management.
60
+ *
61
+ * Returns a `LocaleController` with:
62
+ * - `locale` — the current locale (updates the host on change)
63
+ * - `defaultLocale` — the config default locale
64
+ * - `availableLocales` — all configured locales
65
+ * - `setLocale(locale)` — switches the app locale
66
+ *
67
+ * @param host - The LitElement (or any ReactiveControllerHost).
68
+ * @param props - Optional configuration.
69
+ * @returns A `LocaleController`.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * class LocaleSwitcher extends LitElement {
74
+ * private locale = useLocale(this);
75
+ *
76
+ * render() {
77
+ * return html`
78
+ * <select @change=${(e: Event) => this.locale.setLocale((e.target as HTMLSelectElement).value as any)}>
79
+ * ${this.locale.availableLocales.map(
80
+ * (loc) => html`<option value=${loc} ?selected=${loc === this.locale.locale}>${loc}</option>`
81
+ * )}
82
+ * </select>
83
+ * `;
84
+ * }
85
+ * }
86
+ * ```
87
+ */
88
+ var useLocale = (host, props = {}) => new LocaleController(host, props);
89
+ exports.LocaleController = LocaleController;
90
+ exports.useLocale = useLocale;
@@ -1 +1,56 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/utils");var t=e.getCachedLocaleFromStorageClient,n=(0,e.getLocaleFromStorageClient)(e.localeStorageOptions),r=n,i=(t,n)=>(0,e.setLocaleInStorageClient)(t,{...e.localeStorageOptions,isCookieEnabled:n}),a=i,o=t=>{let n=(0,e.LocaleStorageClient)({...e.localeStorageOptions,isCookieEnabled:t});return{localeStorage:n.getLocale(),setLocaleStorage:n.setLocale}},s=o;exports.getLocaleInStorage=t,exports.localeCookie=r,exports.localeInStorage=n,exports.setLocaleCookie=a,exports.setLocaleInStorage=i,exports.useLocaleCookie=s,exports.useLocaleStorage=o;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_utils = require("@intlayer/core/utils");
3
+ // src/client/useLocaleStorage.ts
4
+ /**
5
+ * Reads the locale persisted in the browser storage (cookie, localStorage…).
6
+ *
7
+ * Unlike `localeInStorage`, read on first call rather than at import, then
8
+ * cached until the next `setLocaleInStorage`. Never cached on the server.
9
+ */
10
+ var getLocaleInStorage = _intlayer_core_utils.getCachedLocaleFromStorageClient;
11
+ /**
12
+ * Get the current locale from storage (cookie or localStorage).
13
+ *
14
+ * Read once at import time; marked pure so bundlers drop the read when nothing
15
+ * imports it.
16
+ */
17
+ var localeInStorage = /* @__PURE__ */ (0, _intlayer_core_utils.getLocaleFromStorageClient)(_intlayer_core_utils.localeStorageOptions);
18
+ /**
19
+ * @deprecated Use localeInStorage instead.
20
+ */
21
+ var localeCookie = localeInStorage;
22
+ /**
23
+ * Persist the locale to storage (cookie and/or localStorage).
24
+ */
25
+ var setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorageClient)(locale, {
26
+ ..._intlayer_core_utils.localeStorageOptions,
27
+ isCookieEnabled
28
+ });
29
+ /**
30
+ * @deprecated Use setLocaleInStorage instead.
31
+ */
32
+ var setLocaleCookie = setLocaleInStorage;
33
+ /**
34
+ * Returns the current locale from storage and a setter.
35
+ */
36
+ var useLocaleStorage = (isCookieEnabled) => {
37
+ const storage = (0, _intlayer_core_utils.LocaleStorageClient)({
38
+ ..._intlayer_core_utils.localeStorageOptions,
39
+ isCookieEnabled
40
+ });
41
+ return {
42
+ localeStorage: storage.getLocale(),
43
+ setLocaleStorage: storage.setLocale
44
+ };
45
+ };
46
+ /**
47
+ * @deprecated Use useLocaleStorage instead.
48
+ */
49
+ var useLocaleCookie = useLocaleStorage;
50
+ exports.getLocaleInStorage = getLocaleInStorage;
51
+ exports.localeCookie = localeCookie;
52
+ exports.localeInStorage = localeInStorage;
53
+ exports.setLocaleCookie = setLocaleCookie;
54
+ exports.setLocaleInStorage = setLocaleInStorage;
55
+ exports.useLocaleCookie = useLocaleCookie;
56
+ exports.useLocaleStorage = useLocaleStorage;
@@ -1 +1,48 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built"),t=require("@intlayer/core/localization");const n=require("../../installIntlayer-CFvvijL7.js");var r=class{_host;_unsubscribe=null;constructor(e){this._host=e,e.addController(this)}_rewrite(n){let r=e.routing?.rewrite;if(typeof window>`u`||!r)return;let i=window.location.pathname,a=(0,t.getRewritePath)(i,n,r);a&&a!==i&&window.history.replaceState(window.history.state,``,a+window.location.search+window.location.hash)}hostConnected(){let e=n.r();this._rewrite(e.locale),this._unsubscribe=e.subscribe(e=>{this._rewrite(e)})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},i=e=>{new r(e)};exports.useRewriteURL=i;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_config_built = require("@intlayer/config/built");
3
+ let _intlayer_core_localization = require("@intlayer/core/localization");
4
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
5
+ // src/client/useRewriteURL.ts
6
+ /**
7
+ * ReactiveController that keeps the browser URL in sync with the current locale.
8
+ *
9
+ * Uses `window.history.replaceState` to update the address bar without
10
+ * triggering a full navigation.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * class AppShell extends LitElement {
15
+ * private _rewrite = useRewriteURL(this);
16
+ * }
17
+ * ```
18
+ */
19
+ var RewriteURLController = class {
20
+ _host;
21
+ _unsubscribe = null;
22
+ constructor(host) {
23
+ this._host = host;
24
+ host.addController(this);
25
+ }
26
+ _rewrite(locale) {
27
+ const rewrite = _intlayer_config_built.routing?.rewrite;
28
+ if (typeof window === "undefined" || !rewrite) return;
29
+ const pathname = window.location.pathname;
30
+ const targetPath = (0, _intlayer_core_localization.getRewritePath)(pathname, locale, rewrite);
31
+ if (targetPath && targetPath !== pathname) window.history.replaceState(window.history.state, "", targetPath + window.location.search + window.location.hash);
32
+ }
33
+ hostConnected() {
34
+ const client = require_installIntlayer.getIntlayerClient();
35
+ this._rewrite(client.locale);
36
+ this._unsubscribe = client.subscribe((newLocale) => {
37
+ this._rewrite(newLocale);
38
+ });
39
+ }
40
+ hostDisconnected() {
41
+ this._unsubscribe?.();
42
+ this._unsubscribe = null;
43
+ }
44
+ };
45
+ var useRewriteURL = (host) => {
46
+ new RewriteURLController(host);
47
+ };
48
+ exports.useRewriteURL = useRewriteURL;
@@ -1 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../installIntlayer-CFvvijL7.js");exports.useEditor=e.a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
3
+ exports.useEditor = require_installIntlayer.useEditor;
@@ -1 +1,19 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useCompact.cjs"),t=require("./useCurrency.cjs"),n=require("./useDate.cjs"),r=require("./useIntl.cjs"),i=require("./useList.cjs"),a=require("./useNumber.cjs"),o=require("./usePercentage.cjs"),s=require("./useRelativeTime.cjs"),c=require("./useUnit.cjs");exports.useCompact=e.useCompact,exports.useCurrency=t.useCurrency,exports.useDate=n.useDate,exports.useIntl=r.useIntl,exports.useList=i.useList,exports.useNumber=a.useNumber,exports.usePercentage=o.usePercentage,exports.useRelativeTime=s.useRelativeTime,exports.useUnit=c.useUnit;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_format_useCompact = require("./useCompact.cjs");
3
+ const require_format_useCurrency = require("./useCurrency.cjs");
4
+ const require_format_useDate = require("./useDate.cjs");
5
+ const require_format_useIntl = require("./useIntl.cjs");
6
+ const require_format_useList = require("./useList.cjs");
7
+ const require_format_useNumber = require("./useNumber.cjs");
8
+ const require_format_usePercentage = require("./usePercentage.cjs");
9
+ const require_format_useRelativeTime = require("./useRelativeTime.cjs");
10
+ const require_format_useUnit = require("./useUnit.cjs");
11
+ exports.useCompact = require_format_useCompact.useCompact;
12
+ exports.useCurrency = require_format_useCurrency.useCurrency;
13
+ exports.useDate = require_format_useDate.useDate;
14
+ exports.useIntl = require_format_useIntl.useIntl;
15
+ exports.useList = require_format_useList.useList;
16
+ exports.useNumber = require_format_useNumber.useNumber;
17
+ exports.usePercentage = require_format_usePercentage.usePercentage;
18
+ exports.useRelativeTime = require_format_useRelativeTime.useRelativeTime;
19
+ exports.useUnit = require_format_useUnit.useUnit;
@@ -1 +1,34 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>(0,e.compact)(t[0],{...t[1],locale:t[1]?.locale??r.locale}),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>(0,e.compact)(n[0],{...n[1],locale:n[1]?.locale??t}),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.useCompact=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useCompact.ts
5
+ var CompactController = class {
6
+ host;
7
+ _unsubscribe = null;
8
+ value;
9
+ constructor(host) {
10
+ this.host = host;
11
+ const client = require_installIntlayer.getIntlayerClient();
12
+ this.value = (...args) => (0, _intlayer_core_formatters.compact)(args[0], {
13
+ ...args[1],
14
+ locale: args[1]?.locale ?? client.locale
15
+ });
16
+ host.addController(this);
17
+ }
18
+ hostConnected() {
19
+ const client = require_installIntlayer.getIntlayerClient();
20
+ this._unsubscribe = client.subscribe((newLocale) => {
21
+ this.value = (...args) => (0, _intlayer_core_formatters.compact)(args[0], {
22
+ ...args[1],
23
+ locale: args[1]?.locale ?? newLocale
24
+ });
25
+ this.host.requestUpdate();
26
+ });
27
+ }
28
+ hostDisconnected() {
29
+ this._unsubscribe?.();
30
+ this._unsubscribe = null;
31
+ }
32
+ };
33
+ var useCompact = (host) => new CompactController(host);
34
+ exports.useCompact = useCompact;
@@ -1 +1,34 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>(0,e.currency)(t[0],{...t[1],locale:t[1]?.locale??r.locale}),n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>(0,e.currency)(n[0],{...n[1],locale:n[1]?.locale??t}),this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.useCurrency=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useCurrency.ts
5
+ var CurrencyController = class {
6
+ host;
7
+ _unsubscribe = null;
8
+ value;
9
+ constructor(host) {
10
+ this.host = host;
11
+ const client = require_installIntlayer.getIntlayerClient();
12
+ this.value = (...args) => (0, _intlayer_core_formatters.currency)(args[0], {
13
+ ...args[1],
14
+ locale: args[1]?.locale ?? client.locale
15
+ });
16
+ host.addController(this);
17
+ }
18
+ hostConnected() {
19
+ const client = require_installIntlayer.getIntlayerClient();
20
+ this._unsubscribe = client.subscribe((newLocale) => {
21
+ this.value = (...args) => (0, _intlayer_core_formatters.currency)(args[0], {
22
+ ...args[1],
23
+ locale: args[1]?.locale ?? newLocale
24
+ });
25
+ this.host.requestUpdate();
26
+ });
27
+ }
28
+ hostDisconnected() {
29
+ this._unsubscribe?.();
30
+ this._unsubscribe = null;
31
+ }
32
+ };
33
+ var useCurrency = (host) => new CurrencyController(host);
34
+ exports.useCurrency = useCurrency;
@@ -1 +1,52 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/formatters");const t=require("../../installIntlayer-CFvvijL7.js");var n=class{host;_unsubscribe=null;value;constructor(n){this.host=n;let r=t.r();this.value=(...t)=>{let n=typeof t[1]==`string`?{...e.presets[t[1]],locale:r.locale}:{...t[1],locale:t[1]?.locale??r.locale};return(0,e.date)(t[0],n)},n.addController(this)}hostConnected(){let n=t.r();this._unsubscribe=n.subscribe(t=>{this.value=(...n)=>{let r=typeof n[1]==`string`?{...e.presets[n[1]],locale:t}:{...n[1],locale:n[1]?.locale??t};return(0,e.date)(n[0],r)},this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}},r=e=>new n(e);exports.useDate=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_formatters = require("@intlayer/core/formatters");
3
+ const require_installIntlayer = require("../../installIntlayer-HB8aIQ-i.js");
4
+ // src/format/useDate.ts
5
+ /**
6
+ * ReactiveController that provides a locale-bound date formatter.
7
+ */
8
+ var DateController = class {
9
+ host;
10
+ _unsubscribe = null;
11
+ value;
12
+ constructor(host) {
13
+ this.host = host;
14
+ const client = require_installIntlayer.getIntlayerClient();
15
+ this.value = (...args) => {
16
+ const options = typeof args[1] === "string" ? {
17
+ ..._intlayer_core_formatters.presets[args[1]],
18
+ locale: client.locale
19
+ } : {
20
+ ...args[1],
21
+ locale: args[1]?.locale ?? client.locale
22
+ };
23
+ return (0, _intlayer_core_formatters.date)(args[0], options);
24
+ };
25
+ host.addController(this);
26
+ }
27
+ hostConnected() {
28
+ const client = require_installIntlayer.getIntlayerClient();
29
+ this._unsubscribe = client.subscribe((newLocale) => {
30
+ this.value = (...args) => {
31
+ const options = typeof args[1] === "string" ? {
32
+ ..._intlayer_core_formatters.presets[args[1]],
33
+ locale: newLocale
34
+ } : {
35
+ ...args[1],
36
+ locale: args[1]?.locale ?? newLocale
37
+ };
38
+ return (0, _intlayer_core_formatters.date)(args[0], options);
39
+ };
40
+ this.host.requestUpdate();
41
+ });
42
+ }
43
+ hostDisconnected() {
44
+ this._unsubscribe?.();
45
+ this._unsubscribe = null;
46
+ }
47
+ };
48
+ /**
49
+ * Reactive hook that provides a locale-bound date formatter.
50
+ */
51
+ var useDate = (host) => new DateController(host);
52
+ exports.useDate = useDate;