solid-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 (125) hide show
  1. package/dist/cjs/IntlayerNode.cjs +11 -1
  2. package/dist/cjs/LoadingBoundary.cjs +26 -1
  3. package/dist/cjs/analytics/AnalyticsProvider.cjs +12 -1
  4. package/dist/cjs/analytics/exposureSink.cjs +23 -1
  5. package/dist/cjs/analytics/index.cjs +9 -1
  6. package/dist/cjs/analytics/useAnalytics.cjs +59 -1
  7. package/dist/cjs/analytics/useConversion.cjs +25 -1
  8. package/dist/cjs/analytics/useExperiment.cjs +59 -1
  9. package/dist/cjs/client/IntlayerProvider.cjs +91 -1
  10. package/dist/cjs/client/contentProxy.cjs +32 -1
  11. package/dist/cjs/client/getBrowserLocale.cjs +115 -1
  12. package/dist/cjs/client/index.cjs +35 -1
  13. package/dist/cjs/client/t.cjs +16 -1
  14. package/dist/cjs/client/useContent.cjs +16 -1
  15. package/dist/cjs/client/useDictionary.cjs +51 -1
  16. package/dist/cjs/client/useDictionaryAsync.cjs +19 -1
  17. package/dist/cjs/client/useDictionaryDynamic.cjs +82 -1
  18. package/dist/cjs/client/useIntlayer.cjs +50 -1
  19. package/dist/cjs/client/useLoadDynamic.cjs +140 -1
  20. package/dist/cjs/client/useLocale.cjs +52 -1
  21. package/dist/cjs/client/useLocaleBase.cjs +19 -1
  22. package/dist/cjs/client/useLocaleStorage.cjs +59 -1
  23. package/dist/cjs/client/usePathname.cjs +41 -1
  24. package/dist/cjs/client/useRewriteURL.cjs +21 -1
  25. package/dist/cjs/client/useTraduction.cjs +32 -1
  26. package/dist/cjs/editor/ContentSelector.cjs +20 -1
  27. package/dist/cjs/editor/EditorProvider.cjs +8 -1
  28. package/dist/cjs/editor/createEditedContentSource.cjs +32 -1
  29. package/dist/cjs/editor/useEditor.cjs +38 -1
  30. package/dist/cjs/format/index.cjs +19 -1
  31. package/dist/cjs/format/useCompact.cjs +15 -1
  32. package/dist/cjs/format/useCurrency.cjs +16 -1
  33. package/dist/cjs/format/useDate.cjs +25 -1
  34. package/dist/cjs/format/useIntl.cjs +31 -1
  35. package/dist/cjs/format/useList.cjs +15 -1
  36. package/dist/cjs/format/useNumber.cjs +19 -1
  37. package/dist/cjs/format/usePercentage.cjs +16 -1
  38. package/dist/cjs/format/useRelativeTime.cjs +16 -1
  39. package/dist/cjs/format/useUnit.cjs +15 -1
  40. package/dist/cjs/getDictionary.cjs +17 -1
  41. package/dist/cjs/getIntlayer.cjs +14 -1
  42. package/dist/cjs/html/HTMLProvider.cjs +24 -1
  43. package/dist/cjs/html/HTMLRenderer.cjs +49 -1
  44. package/dist/cjs/html/index.cjs +8 -1
  45. package/dist/cjs/html/types.cjs +1 -1
  46. package/dist/cjs/index.cjs +48 -1
  47. package/dist/cjs/markdown/MarkdownProvider.cjs +47 -1
  48. package/dist/cjs/markdown/MarkdownRenderer.cjs +56 -1
  49. package/dist/cjs/markdown/compiler.cjs +64 -1
  50. package/dist/cjs/markdown/index.cjs +13 -1
  51. package/dist/cjs/markdown/runtime.cjs +48 -1
  52. package/dist/cjs/plugins.cjs +266 -1
  53. package/dist/cjs/proxyKeys.cjs +14 -1
  54. package/dist/cjs/server/index.cjs +3 -1
  55. package/dist/cjs/server/useDictionary.cjs +30 -1
  56. package/dist/cjs/solidCompat.cjs +167 -1
  57. package/dist/cjs/solidElement/renderSolidElement.cjs +34 -1
  58. package/dist/cjs/solidTypes.cjs +1 -1
  59. package/dist/esm/IntlayerNode.mjs +8 -6
  60. package/dist/esm/LoadingBoundary.mjs +19 -6
  61. package/dist/esm/analytics/AnalyticsProvider.mjs +10 -3
  62. package/dist/esm/analytics/exposureSink.mjs +19 -5
  63. package/dist/esm/analytics/index.mjs +5 -5
  64. package/dist/esm/analytics/useAnalytics.mjs +52 -25
  65. package/dist/esm/analytics/useConversion.mjs +22 -6
  66. package/dist/esm/analytics/useExperiment.mjs +50 -22
  67. package/dist/esm/client/IntlayerProvider.mjs +75 -28
  68. package/dist/esm/client/contentProxy.mjs +26 -12
  69. package/dist/esm/client/getBrowserLocale.mjs +106 -71
  70. package/dist/esm/client/index.mjs +14 -14
  71. package/dist/esm/client/t.mjs +13 -7
  72. package/dist/esm/client/useContent.mjs +11 -8
  73. package/dist/esm/client/useDictionary.mjs +47 -25
  74. package/dist/esm/client/useDictionaryAsync.mjs +16 -9
  75. package/dist/esm/client/useDictionaryDynamic.mjs +72 -43
  76. package/dist/esm/client/useIntlayer.mjs +45 -15
  77. package/dist/esm/client/useLoadDynamic.mjs +128 -49
  78. package/dist/esm/client/useLocale.mjs +47 -16
  79. package/dist/esm/client/useLocaleBase.mjs +14 -10
  80. package/dist/esm/client/useLocaleStorage.mjs +51 -10
  81. package/dist/esm/client/usePathname.mjs +37 -12
  82. package/dist/esm/client/useRewriteURL.mjs +17 -11
  83. package/dist/esm/client/useTraduction.mjs +29 -8
  84. package/dist/esm/editor/ContentSelector.mjs +18 -15
  85. package/dist/esm/editor/EditorProvider.mjs +6 -3
  86. package/dist/esm/editor/createEditedContentSource.mjs +28 -17
  87. package/dist/esm/editor/useEditor.mjs +32 -22
  88. package/dist/esm/format/index.mjs +10 -10
  89. package/dist/esm/format/useCompact.mjs +11 -8
  90. package/dist/esm/format/useCurrency.mjs +12 -9
  91. package/dist/esm/format/useDate.mjs +19 -13
  92. package/dist/esm/format/useIntl.mjs +27 -9
  93. package/dist/esm/format/useList.mjs +11 -8
  94. package/dist/esm/format/useNumber.mjs +15 -9
  95. package/dist/esm/format/usePercentage.mjs +12 -9
  96. package/dist/esm/format/useRelativeTime.mjs +12 -9
  97. package/dist/esm/format/useUnit.mjs +11 -8
  98. package/dist/esm/getDictionary.mjs +14 -6
  99. package/dist/esm/getIntlayer.mjs +11 -6
  100. package/dist/esm/html/HTMLProvider.mjs +21 -12
  101. package/dist/esm/html/HTMLRenderer.mjs +44 -17
  102. package/dist/esm/html/index.mjs +3 -3
  103. package/dist/esm/index.mjs +20 -20
  104. package/dist/esm/markdown/MarkdownProvider.mjs +31 -24
  105. package/dist/esm/markdown/MarkdownRenderer.mjs +48 -37
  106. package/dist/esm/markdown/compiler.mjs +59 -23
  107. package/dist/esm/markdown/index.mjs +4 -4
  108. package/dist/esm/markdown/runtime.mjs +40 -13
  109. package/dist/esm/plugins.mjs +205 -156
  110. package/dist/esm/proxyKeys.mjs +7 -2
  111. package/dist/esm/server/useDictionary.mjs +25 -7
  112. package/dist/esm/solidCompat.mjs +146 -39
  113. package/dist/esm/solidElement/renderSolidElement.mjs +22 -19
  114. package/dist/rolldown-runtime-CmQyd0Gu.js +27 -0
  115. package/dist/solid/analytics/useAnalytics.jsx +3 -3
  116. package/dist/solid/analytics/useConversion.js +2 -2
  117. package/dist/solid/analytics/useExperiment.js +3 -3
  118. package/package.json +7 -7
  119. package/dist/esm-YGODKOLP.js +0 -1
  120. package/dist/esm-bdKnuomJ.mjs +0 -256
  121. package/dist/isEnabled-CuTKz0YA.js +0 -1
  122. package/dist/isEnabled-DVKEZ2He.mjs +0 -18
  123. package/dist/rolldown-runtime-BocRIvOZ.js +0 -1
  124. package/dist/solid/esm-1cHk4dPd.js +0 -644
  125. package/dist/solid/isEnabled-C5NUhdhZ.js +0 -100
@@ -1,11 +1,52 @@
1
- import { LocaleStorageClient as e, getCachedLocaleFromStorageClient as t, getLocaleFromStorageClient as n, localeStorageOptions as r, setLocaleInStorageClient as i } from "@intlayer/core/utils";
2
- import { createMemo as a } from "solid-js";
1
+ import { LocaleStorageClient, getCachedLocaleFromStorageClient, getLocaleFromStorageClient, localeStorageOptions, setLocaleInStorageClient } from "@intlayer/core/utils";
2
+ import { createMemo } from "solid-js";
3
3
  // src/client/useLocaleStorage.ts
4
- var o = t, s = /* @__PURE__ */ n(r), c = s, l = (e, t) => i(e, {
5
- ...r,
6
- isCookieEnabled: t
7
- }), u = l, d = (t) => a(() => e({
8
- ...r,
9
- isCookieEnabled: t
10
- })), f = d;
11
- export { o as getLocaleInStorage, c as localeCookie, s as localeInStorage, u as setLocaleCookie, l as setLocaleInStorage, f as useLocaleCookie, d as useLocaleStorage };
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 = getCachedLocaleFromStorageClient;
11
+ /**
12
+ * Get the locale cookie
13
+ *
14
+ * Read once at import time; marked pure so bundlers drop the read when nothing
15
+ * imports it.
16
+ */
17
+ var localeInStorage = /* @__PURE__ */ getLocaleFromStorageClient(localeStorageOptions);
18
+ /**
19
+ * @deprecated Use localeInStorage instead
20
+ *
21
+ * Get the locale cookie
22
+ */
23
+ var localeCookie = localeInStorage;
24
+ /**
25
+ * Set the locale cookie
26
+ */
27
+ var setLocaleInStorage = (locale, isCookieEnabled) => setLocaleInStorageClient(locale, {
28
+ ...localeStorageOptions,
29
+ isCookieEnabled
30
+ });
31
+ /**
32
+ * @deprecated Use setLocaleInStorage instead
33
+ *
34
+ * Set the locale cookie
35
+ */
36
+ var setLocaleCookie = setLocaleInStorage;
37
+ /**
38
+ * Hook that provides the locale storage and a function to set it
39
+ */
40
+ var useLocaleStorage = (isCookieEnabled) => createMemo(() => LocaleStorageClient({
41
+ ...localeStorageOptions,
42
+ isCookieEnabled
43
+ }));
44
+ /**
45
+ * @deprecated Use useLocaleStorage instead
46
+ *
47
+ * For GDPR compliance, use useLocaleStorage instead
48
+ *
49
+ * Hook that provides the locale cookie and a function to set it
50
+ */
51
+ var useLocaleCookie = useLocaleStorage;
52
+ export { getLocaleInStorage, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage };
@@ -1,15 +1,40 @@
1
- import { getPathWithoutLocale as e } from "@intlayer/core/localization";
2
- import { createSignal as t } from "solid-js";
3
- import { onMounted as n } from "../solidCompat.mjs";
1
+ import { getPathWithoutLocale } from "@intlayer/core/localization";
2
+ import { createSignal } from "solid-js";
3
+ import { onMounted } from "../solidCompat.mjs";
4
4
  // src/client/usePathname.ts
5
- var r = () => {
6
- let [r, i] = t(typeof window < "u" ? window.location.pathname : "");
7
- return n(() => {
8
- if (typeof window > "u") return;
9
- let e = () => {
10
- i(window.location.pathname);
5
+ /**
6
+ * Solid hook that returns an accessor containing the current pathname with
7
+ * the locale segment removed.
8
+ *
9
+ * Reacts to browser back/forward navigation via the `popstate` event.
10
+ * Falls back to an empty string during server-side rendering.
11
+ *
12
+ * @returns An accessor containing the current pathname without the locale prefix.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { usePathname } from 'solid-intlayer';
17
+ *
18
+ * const NavItem = ({ href }: { href: string }) => {
19
+ * const pathname = usePathname();
20
+ * return (
21
+ * <a class={pathname() === href ? 'active' : ''} href={href}>
22
+ * {href}
23
+ * </a>
24
+ * );
25
+ * };
26
+ * ```
27
+ */
28
+ var usePathname = () => {
29
+ const [rawPathname, setRawPathname] = createSignal(typeof window !== "undefined" ? window.location.pathname : "");
30
+ onMounted(() => {
31
+ if (typeof window === "undefined") return;
32
+ const handleLocationChange = () => {
33
+ setRawPathname(window.location.pathname);
11
34
  };
12
- return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
13
- }), () => e(r());
35
+ window.addEventListener("popstate", handleLocationChange);
36
+ return () => window.removeEventListener("popstate", handleLocationChange);
37
+ });
38
+ return () => getPathWithoutLocale(rawPathname());
14
39
  };
15
- export { r as usePathname };
40
+ export { usePathname };
@@ -1,14 +1,20 @@
1
- import { routing as e } from "@intlayer/config/built";
2
- import { getRewritePath as t } from "@intlayer/core/localization";
3
- import { createWatchEffect as n } from "../solidCompat.mjs";
4
- import { useLocale as r } from "./useLocale.mjs";
1
+ import { routing } from "@intlayer/config/built";
2
+ import { getRewritePath } from "@intlayer/core/localization";
3
+ import { createWatchEffect } from "../solidCompat.mjs";
4
+ import { useLocale } from "./useLocale.mjs";
5
5
  // src/client/useRewriteURL.ts
6
- var i = () => {
7
- let { locale: i } = r(), a = e?.rewrite;
8
- n(i, (e) => {
9
- if (typeof window > "u" || !a) return;
10
- let n = window.location.pathname, r = t(n, e, a);
11
- r && r !== n && window.history.replaceState(window.history.state, "", r + window.location.search + window.location.hash);
6
+ /**
7
+ * Client-side hook to manage URL rewrites in Solid without triggering a router navigation.
8
+ * It uses `window.history.replaceState` to update the URL in the address bar.
9
+ */
10
+ var useRewriteURL = () => {
11
+ const { locale } = useLocale();
12
+ const rewrite = routing?.rewrite;
13
+ createWatchEffect(locale, (loc) => {
14
+ if (typeof window === "undefined" || !rewrite) return;
15
+ const pathname = window.location.pathname;
16
+ const targetPath = getRewritePath(pathname, loc, rewrite);
17
+ if (targetPath && targetPath !== pathname) window.history.replaceState(window.history.state, "", targetPath + window.location.search + window.location.hash);
12
18
  });
13
19
  };
14
- export { i as useRewriteURL };
20
+ export { useRewriteURL };
@@ -1,10 +1,31 @@
1
- import { internationalization as e } from "@intlayer/config/built";
2
- import { getTranslation as t } from "@intlayer/core/interpreter";
3
- import { useContext as n } from "solid-js";
4
- import { IntlayerClientContext as r } from "./IntlayerProvider.mjs";
1
+ import { internationalization } from "@intlayer/config/built";
2
+ import { getTranslation } from "@intlayer/core/interpreter";
3
+ import { useContext } from "solid-js";
4
+ import { IntlayerClientContext } from "./IntlayerProvider.mjs";
5
5
  // src/client/useTraduction.ts
6
- var i = (i) => {
7
- let { locale: a } = n(r) ?? {};
8
- return t(i, a?.() ?? e.defaultLocale);
6
+ /**
7
+ * On the client side, Hook that picking one dictionary by its id and return the content.
8
+ *
9
+ * If not locale found, it will return the content related to the default locale.
10
+ *
11
+ * Return either the content editor, or the content itself depending on the configuration.
12
+ *
13
+ * Usage:
14
+ *
15
+ * ```tsx
16
+ * const content = useTranslation<string>({
17
+ * en: 'Hello',
18
+ * fr: 'Bonjour',
19
+ * }, 'fr');
20
+ * // 'Bonjour'
21
+ * ```
22
+ *
23
+ * Using TypeScript:
24
+ * - this function will require each locale to be defined if defined in the project configuration.
25
+ * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
26
+ */
27
+ var useTranslation = (languageContent) => {
28
+ const { locale } = useContext(IntlayerClientContext) ?? {};
29
+ return getTranslation(languageContent, locale?.() ?? internationalization.defaultLocale);
9
30
  };
10
- export { i as useTranslation };
31
+ export { useTranslation };
@@ -1,16 +1,19 @@
1
- import { Dynamic as e, createComponent as t } from "solid-js/web";
2
- import { isEnabled as n } from "@intlayer/editor/isEnabled";
1
+ import { Dynamic, createComponent } from "solid-js/web";
2
+ import { isEnabled } from "@intlayer/editor/isEnabled";
3
3
  // src/editor/ContentSelector.tsx
4
- var r = (r) => process.env.INTLAYER_EDITOR_ENABLED === "false" || !n ? r.children : t(e, {
5
- component: "intlayer-content-selector-wrapper",
6
- get "attr:key-path"() {
7
- return JSON.stringify(r.keyPath);
8
- },
9
- get "attr:dictionary-key"() {
10
- return r.dictionaryKey;
11
- },
12
- get children() {
13
- return r.children;
14
- }
15
- });
16
- export { r as ContentSelector };
4
+ var ContentSelector = (props) => {
5
+ if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !isEnabled) return props.children;
6
+ return createComponent(Dynamic, {
7
+ component: "intlayer-content-selector-wrapper",
8
+ get ["attr:key-path"]() {
9
+ return JSON.stringify(props.keyPath);
10
+ },
11
+ get ["attr:dictionary-key"]() {
12
+ return props.dictionaryKey;
13
+ },
14
+ get children() {
15
+ return props.children;
16
+ }
17
+ });
18
+ };
19
+ export { ContentSelector };
@@ -1,4 +1,7 @@
1
- import { useEditor as e } from "./useEditor.mjs";
1
+ import { useEditor } from "./useEditor.mjs";
2
2
  // src/editor/EditorProvider.tsx
3
- var t = ({ children: t }) => (e(), t);
4
- export { t as EditorProvider };
3
+ var EditorProvider = ({ children }) => {
4
+ useEditor();
5
+ return children;
6
+ };
7
+ export { EditorProvider };
@@ -1,20 +1,31 @@
1
- import { isEnabled as e } from "@intlayer/editor/isEnabled";
2
- import { createSignal as t } from "solid-js";
3
- import { createWatchEffect as n } from "../solidCompat.mjs";
1
+ import { isEnabled } from "@intlayer/editor/isEnabled";
2
+ import { createSignal } from "solid-js";
3
+ import { createWatchEffect } from "../solidCompat.mjs";
4
4
  // src/editor/createEditedContentSource.ts
5
- var r = (r, i) => {
6
- let [a, o] = t();
7
- return process.env.INTLAYER_EDITOR_ENABLED === "false" || !e || n(() => ({
8
- currentDictionaryKey: r(),
9
- keyPathJson: JSON.stringify(i() ?? [])
10
- }), ({ currentDictionaryKey: e, keyPathJson: t }) => {
11
- if (!e) return;
12
- let n = !1, r = null;
13
- return import("@intlayer/editor").then(({ subscribeToEditedContentSource: i }) => {
14
- n || (r = i(e, JSON.parse(t), (e) => o(() => e)));
15
- }).catch(() => {}), () => {
16
- n = !0, r?.();
5
+ /**
6
+ * Tracks the source string edited in the visual editor for a markdown / html
7
+ * node. The accessor returns `undefined` when the node is not edited (or the
8
+ * editor is off).
9
+ */
10
+ var createEditedContentSource = (dictionaryKey, keyPath) => {
11
+ const [editedSource, setEditedSource] = createSignal();
12
+ if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !isEnabled) return editedSource;
13
+ createWatchEffect(() => ({
14
+ currentDictionaryKey: dictionaryKey(),
15
+ keyPathJson: JSON.stringify(keyPath() ?? [])
16
+ }), ({ currentDictionaryKey, keyPathJson }) => {
17
+ if (!currentDictionaryKey) return;
18
+ let isStopped = false;
19
+ let unsubscribe = null;
20
+ import("@intlayer/editor").then(({ subscribeToEditedContentSource }) => {
21
+ if (isStopped) return;
22
+ unsubscribe = subscribeToEditedContentSource(currentDictionaryKey, JSON.parse(keyPathJson), (source) => setEditedSource(() => source));
23
+ }).catch(() => {});
24
+ return () => {
25
+ isStopped = true;
26
+ unsubscribe?.();
17
27
  };
18
- }), a;
28
+ });
29
+ return editedSource;
19
30
  };
20
- export { r as createEditedContentSource };
31
+ export { createEditedContentSource };
@@ -1,27 +1,37 @@
1
- import { isEnabled as e } from "@intlayer/editor/isEnabled";
2
- import { createSignal as t, onCleanup as n } from "solid-js";
3
- import { useIntlayerContext as r } from "../client/IntlayerProvider.mjs";
4
- import { createWatchEffect as i, onMounted as a } from "../solidCompat.mjs";
1
+ import { isEnabled } from "@intlayer/editor/isEnabled";
2
+ import { createSignal, onCleanup } from "solid-js";
3
+ import { useIntlayerContext } from "../client/IntlayerProvider.mjs";
4
+ import { createWatchEffect, onMounted } from "../solidCompat.mjs";
5
5
  // src/editor/useEditor.tsx
6
- var o = () => {
7
- if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !e) return;
8
- let { locale: o, setLocale: s } = r(), [c, l] = t(null);
9
- a(() => {
10
- import("@intlayer/editor").then(({ initEditorClient: e }) => {
11
- let t = e();
12
- l(t);
6
+ /**
7
+ * Initialises the Intlayer editor client singleton when the editor is enabled.
8
+ * Syncs the current locale from the Intlayer context into the editor manager so
9
+ * the editor always knows which locale the app is displaying.
10
+ */
11
+ var useEditor = () => {
12
+ if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !isEnabled) return;
13
+ const { locale, setLocale } = useIntlayerContext();
14
+ const [manager, setManager] = createSignal(null);
15
+ onMounted(() => {
16
+ import("@intlayer/editor").then(({ initEditorClient }) => {
17
+ const managerInstance = initEditorClient();
18
+ setManager(managerInstance);
13
19
  }).catch(() => {});
14
- }), i(c, (e) => {
15
- if (e) return e.onLocaleChangeRequested(s);
16
- }), i(() => ({
17
- managerInstance: c(),
18
- currentLocale: o()
19
- }), ({ managerInstance: e, currentLocale: t }) => {
20
- e && t && e.currentLocale.set(t);
21
- }), n(() => {
22
- import("@intlayer/editor").then(({ stopEditorClient: e }) => {
23
- e();
20
+ });
21
+ createWatchEffect(manager, (managerInstance) => {
22
+ if (!managerInstance) return;
23
+ return managerInstance.onLocaleChangeRequested(setLocale);
24
+ });
25
+ createWatchEffect(() => ({
26
+ managerInstance: manager(),
27
+ currentLocale: locale()
28
+ }), ({ managerInstance, currentLocale }) => {
29
+ if (managerInstance && currentLocale) managerInstance.currentLocale.set(currentLocale);
30
+ });
31
+ onCleanup(() => {
32
+ import("@intlayer/editor").then(({ stopEditorClient }) => {
33
+ stopEditorClient();
24
34
  }).catch(() => {});
25
35
  });
26
36
  };
27
- export { o as useEditor };
37
+ export { useEditor };
@@ -1,10 +1,10 @@
1
- import { useCompact as e } from "./useCompact.mjs";
2
- import { useCurrency as t } from "./useCurrency.mjs";
3
- import { useDate as n } from "./useDate.mjs";
4
- import { useIntl as r } from "./useIntl.mjs";
5
- import { useList as i } from "./useList.mjs";
6
- import { useNumber as a } from "./useNumber.mjs";
7
- import { usePercentage as o } from "./usePercentage.mjs";
8
- import { useRelativeTime as s } from "./useRelativeTime.mjs";
9
- import { useUnit as c } from "./useUnit.mjs";
10
- export { e as useCompact, t as useCurrency, n as useDate, r as useIntl, i as useList, a as useNumber, o as usePercentage, s as useRelativeTime, c as useUnit };
1
+ import { useCompact } from "./useCompact.mjs";
2
+ import { useCurrency } from "./useCurrency.mjs";
3
+ import { useDate } from "./useDate.mjs";
4
+ import { useIntl } from "./useIntl.mjs";
5
+ import { useList } from "./useList.mjs";
6
+ import { useNumber } from "./useNumber.mjs";
7
+ import { usePercentage } from "./usePercentage.mjs";
8
+ import { useRelativeTime } from "./useRelativeTime.mjs";
9
+ import { useUnit } from "./useUnit.mjs";
10
+ export { useCompact, useCurrency, useDate, useIntl, useList, useNumber, usePercentage, useRelativeTime, useUnit };
@@ -1,11 +1,14 @@
1
- import { compact as e } from "@intlayer/core/formatters";
2
- import { useIntlayerContext as t } from "../client/IntlayerProvider.mjs";
1
+ import { compact } from "@intlayer/core/formatters";
2
+ import { useIntlayerContext } from "../client/IntlayerProvider.mjs";
3
3
  // src/format/useCompact.ts
4
- var n = () => {
5
- let { locale: n } = t();
6
- return (...t) => e(t[0], {
7
- ...t[1],
8
- locale: t[1]?.locale ?? n()
4
+ /**
5
+ * Solid client hook that provides a localized compact number formatter.
6
+ */
7
+ var useCompact = () => {
8
+ const { locale } = useIntlayerContext();
9
+ return (...args) => compact(args[0], {
10
+ ...args[1],
11
+ locale: args[1]?.locale ?? locale()
9
12
  });
10
13
  };
11
- export { n as useCompact };
14
+ export { useCompact };
@@ -1,12 +1,15 @@
1
- import { currency as e } from "@intlayer/core/formatters";
2
- import { useContext as t } from "solid-js";
3
- import { IntlayerClientContext as n } from "../client/IntlayerProvider.mjs";
1
+ import { currency } from "@intlayer/core/formatters";
2
+ import { useContext } from "solid-js";
3
+ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
4
4
  // src/format/useCurrency.ts
5
- var r = () => {
6
- let { locale: r } = t(n);
7
- return (...t) => e(t[0], {
8
- ...t[1],
9
- locale: t[1]?.locale ?? r()
5
+ /**
6
+ * Solid client hook that provides a localized currency formatter.
7
+ */
8
+ var useCurrency = () => {
9
+ const { locale } = useContext(IntlayerClientContext);
10
+ return (...args) => currency(args[0], {
11
+ ...args[1],
12
+ locale: args[1]?.locale ?? locale()
10
13
  });
11
14
  };
12
- export { r as useCurrency };
15
+ export { useCurrency };
@@ -1,18 +1,24 @@
1
- import { date as e, presets as t } from "@intlayer/core/formatters";
2
- import { useContext as n } from "solid-js";
3
- import { IntlayerClientContext as r } from "../client/IntlayerProvider.mjs";
1
+ import { date, presets } from "@intlayer/core/formatters";
2
+ import { useContext } from "solid-js";
3
+ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
4
4
  // src/format/useDate.ts
5
- var i = () => {
6
- let { locale: i } = n(r);
7
- return (...n) => {
8
- let r = typeof n[1] == "string" ? {
9
- ...t[n[1]],
10
- locale: i()
5
+ /**
6
+ * Solid client hook that provides a localized date/time formatter.
7
+ *
8
+ * @returns {(date: Date | string | number, options?: DateProps) => string}
9
+ * A function to format dates into localized strings.
10
+ */
11
+ var useDate = () => {
12
+ const { locale } = useContext(IntlayerClientContext);
13
+ return (...args) => {
14
+ const options = typeof args[1] === "string" ? {
15
+ ...presets[args[1]],
16
+ locale: locale()
11
17
  } : {
12
- ...n[1],
13
- locale: n[1]?.locale ?? i()
18
+ ...args[1],
19
+ locale: args[1]?.locale ?? locale()
14
20
  };
15
- return e(n[0], r);
21
+ return date(args[0], options);
16
22
  };
17
23
  };
18
- export { i as useDate };
24
+ export { useDate };
@@ -1,12 +1,30 @@
1
- import { bindIntl as e } from "@intlayer/core/formatters";
2
- import { createMemo as t, useContext as n } from "solid-js";
3
- import { IntlayerClientContext as r } from "../client/IntlayerProvider.mjs";
1
+ import { bindIntl } from "@intlayer/core/formatters";
2
+ import { createMemo, useContext } from "solid-js";
3
+ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
4
4
  // src/format/useIntl.ts
5
- var i = (i) => {
6
- let a = n(r);
7
- return t(() => {
8
- let t = i ?? a.locale();
9
- return e(t);
5
+ /**
6
+ * Solid client hook that provides a locale-bound `Intl` object.
7
+ *
8
+ * It acts exactly like the native `Intl` object, but acts as a proxy to:
9
+ * 1. Inject the current locale automatically if none is provided.
10
+ * 2. Use the performance-optimized `CachedIntl` under the hood.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const intl = useIntl(); // uses context locale
15
+ *
16
+ * // Standard API, but no need to pass locale as the first argument
17
+ * const formatted = new (intl().NumberFormat)({
18
+ * style: 'currency',
19
+ * currency: 'USD'
20
+ * }).format(123.45);
21
+ * ```
22
+ */
23
+ var useIntl = (locale) => {
24
+ const context = useContext(IntlayerClientContext);
25
+ return createMemo(() => {
26
+ const currentLocale = locale ?? context.locale();
27
+ return bindIntl(currentLocale);
10
28
  });
11
29
  };
12
- export { i as useIntl };
30
+ export { useIntl };
@@ -1,11 +1,14 @@
1
- import { list as e } from "@intlayer/core/formatters";
2
- import { useIntlayerContext as t } from "../client/IntlayerProvider.mjs";
1
+ import { list } from "@intlayer/core/formatters";
2
+ import { useIntlayerContext } from "../client/IntlayerProvider.mjs";
3
3
  // src/format/useList.ts
4
- var n = () => {
5
- let { locale: n } = t();
6
- return (...t) => e(t[0], {
7
- ...t[1],
8
- locale: t[1]?.locale ?? n()
4
+ /**
5
+ * Solid client hook that provides a localized list formatter.
6
+ */
7
+ var useList = () => {
8
+ const { locale } = useIntlayerContext();
9
+ return (...args) => list(args[0], {
10
+ ...args[1],
11
+ locale: args[1]?.locale ?? locale()
9
12
  });
10
13
  };
11
- export { n as useList };
14
+ export { useList };
@@ -1,12 +1,18 @@
1
- import { number as e } from "@intlayer/core/formatters";
2
- import { useContext as t } from "solid-js";
3
- import { IntlayerClientContext as n } from "../client/IntlayerProvider.mjs";
1
+ import { number } from "@intlayer/core/formatters";
2
+ import { useContext } from "solid-js";
3
+ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
4
4
  // src/format/useNumber.ts
5
- var r = () => {
6
- let { locale: r } = t(n);
7
- return (...t) => e(t[0], {
8
- ...t[1],
9
- locale: t[1]?.locale ?? r()
5
+ /**
6
+ * Solid client hook that provides a localized number formatter.
7
+ *
8
+ * @returns {(value: string | number, options?: import("@intlayer/core/formatters").NumberProps) => string}
9
+ * A function to format numbers into localized strings.
10
+ */
11
+ var useNumber = () => {
12
+ const { locale } = useContext(IntlayerClientContext);
13
+ return (...args) => number(args[0], {
14
+ ...args[1],
15
+ locale: args[1]?.locale ?? locale()
10
16
  });
11
17
  };
12
- export { r as useNumber };
18
+ export { useNumber };
@@ -1,12 +1,15 @@
1
- import { percentage as e } from "@intlayer/core/formatters";
2
- import { useContext as t } from "solid-js";
3
- import { IntlayerClientContext as n } from "../client/IntlayerProvider.mjs";
1
+ import { percentage } from "@intlayer/core/formatters";
2
+ import { useContext } from "solid-js";
3
+ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
4
4
  // src/format/usePercentage.ts
5
- var r = () => {
6
- let { locale: r } = t(n);
7
- return (...t) => e(t[0], {
8
- ...t[1],
9
- locale: t[1]?.locale ?? r()
5
+ /**
6
+ * Solid client hook that provides a localized percentage formatter.
7
+ */
8
+ var usePercentage = () => {
9
+ const { locale } = useContext(IntlayerClientContext);
10
+ return (...args) => percentage(args[0], {
11
+ ...args[1],
12
+ locale: args[1]?.locale ?? locale()
10
13
  });
11
14
  };
12
- export { r as usePercentage };
15
+ export { usePercentage };
@@ -1,12 +1,15 @@
1
- import { relativeTime as e } from "@intlayer/core/formatters";
2
- import { useContext as t } from "solid-js";
3
- import { IntlayerClientContext as n } from "../client/IntlayerProvider.mjs";
1
+ import { relativeTime } from "@intlayer/core/formatters";
2
+ import { useContext } from "solid-js";
3
+ import { IntlayerClientContext } from "../client/IntlayerProvider.mjs";
4
4
  // src/format/useRelativeTime.ts
5
- var r = () => {
6
- let { locale: r } = t(n);
7
- return (...t) => e(t[0], t[1], {
8
- ...t[2],
9
- locale: t[2]?.locale ?? r()
5
+ /**
6
+ * Solid client hook that provides a localized relative time formatter.
7
+ */
8
+ var useRelativeTime = () => {
9
+ const { locale } = useContext(IntlayerClientContext);
10
+ return (...args) => relativeTime(args[0], args[1], {
11
+ ...args[2],
12
+ locale: args[2]?.locale ?? locale()
10
13
  });
11
14
  };
12
- export { r as useRelativeTime };
15
+ export { useRelativeTime };
@@ -1,11 +1,14 @@
1
- import { units as e } from "@intlayer/core/formatters";
2
- import { useIntlayerContext as t } from "../client/IntlayerProvider.mjs";
1
+ import { units } from "@intlayer/core/formatters";
2
+ import { useIntlayerContext } from "../client/IntlayerProvider.mjs";
3
3
  // src/format/useUnit.ts
4
- var n = () => {
5
- let { locale: n } = t();
6
- return (...t) => e(t[0], {
7
- ...t[1],
8
- locale: t[1]?.locale ?? n()
4
+ /**
5
+ * Solid client hook that provides a localized unit formatter.
6
+ */
7
+ var useUnit = () => {
8
+ const { locale } = useIntlayerContext();
9
+ return (...args) => units(args[0], {
10
+ ...args[1],
11
+ locale: args[1]?.locale ?? locale()
9
12
  });
10
13
  };
11
- export { n as useUnit };
14
+ export { useUnit };