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 +1,19 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/dictionaryManipulator"),t=require("@intlayer/core/interpreter"),n=require("solid-js");const r=require("./IntlayerProvider.cjs"),i=require("./useDictionary.cjs");var a=async(a,o)=>{let{locale:s}=(0,n.useContext)(r.IntlayerClientContext)??{},c=o??s()??(0,t.resolveInterpreterLocale)(),l=await(0,e.loadDynamicDictionary)(a,c);return i.useDictionary(l,c)};exports.useDictionaryAsync=a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
3
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
4
+ let solid_js = require("solid-js");
5
+ const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
6
+ const require_client_useDictionary = require("./useDictionary.cjs");
7
+ // src/client/useDictionaryAsync.ts
8
+ /**
9
+ * On the server side, Hook that transform a dictionary and return the content
10
+ *
11
+ * If the locale is not provided, it will use the locale from the client context
12
+ */
13
+ var useDictionaryAsync = async (dictionaryPromise, locale) => {
14
+ const { locale: currentLocale } = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
15
+ const localeTarget = locale ?? currentLocale() ?? (0, _intlayer_core_interpreter.resolveInterpreterLocale)();
16
+ const dictionary = await (0, _intlayer_core_dictionaryManipulator.loadDynamicDictionary)(dictionaryPromise, localeTarget);
17
+ return require_client_useDictionary.useDictionary(dictionary, localeTarget);
18
+ };
19
+ exports.useDictionaryAsync = useDictionaryAsync;
@@ -1 +1,82 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/dictionaryManipulator"),t=require("solid-js");const n=require("../getDictionary.cjs"),r=require("../solidCompat.cjs"),i=require("./contentProxy.cjs"),a=require("./IntlayerProvider.cjs"),o=require("./useDictionary.cjs"),s=require("./useLoadDynamic.cjs");var c=e=>e,l=(e,t)=>n.getDictionary(e,t),u=(u,d,f)=>{let p=(0,t.useContext)(a.IntlayerClientContext)??{},m=String(d),h=u,{locale:g,selector:_}=process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?{locale:f,selector:void 0}:(0,e.parseDictionarySelector)(f),v=()=>(0,e.resolveDictionaryRead)({localeOrSelector:f,contextLocale:p.locale?.(),contextVariant:p.variant?.(),dictionaryKey:m}),y=()=>{let t=v(),n=process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?``:(0,e.getDictionarySelectorCacheKey)({...t.selector,metadataOnly:void 0});return{...t,cacheKey:n?`${m}.${t.locale}.${n}`:`${m}.${t.locale}`}},b=(t,n)=>(0,e.resolveDynamicContentAsync)({loaderMap:h,key:m,...t,transform:n}),x=(0,e.getDynamicChunkArgument)(g,_);if(process.env.INTLAYER_DICTIONARY_SELECTOR!==`false`&&(0,e.isQualifiedDynamicLoaderMap)(h)&&h[e.QUALIFIER_DYNAMIC_TYPES_KEY].includes(`item`)&&_?.item===void 0){let e=r.createAsyncValue(v,e=>b(e,_?.metadataOnly?l:c)),a=(0,t.createMemo)(()=>{let t=e();if(!Array.isArray(t))return[];if(_?.metadataOnly)return t;let{locale:r}=v();return t.map(e=>n.getDictionary(e,r))});return r.trackAsyncValue(e),i.createContentProxy(a)}let S=y(),C=(0,e.getPreloadedDictionary)(h,S.locale);C&&s.seedDynamicValue(S,C);let w=s.useLoadDynamic(y,e=>b(e,c).then(t=>{if(t===null)throw Error(`No dynamic dictionary chunk found for key "${m}" and locale "${e.locale}".`);return t}));return o.useDictionary(w,x)};exports.useDictionaryDynamic=u;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
3
+ let solid_js = require("solid-js");
4
+ const require_getDictionary = require("../getDictionary.cjs");
5
+ const require_solidCompat = require("../solidCompat.cjs");
6
+ const require_client_contentProxy = require("./contentProxy.cjs");
7
+ const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
8
+ const require_client_useDictionary = require("./useDictionary.cjs");
9
+ const require_client_useLoadDynamic = require("./useLoadDynamic.cjs");
10
+ // src/client/useDictionaryDynamic.ts
11
+ /**
12
+ * Loaded chunks stay raw (serializable for hydration) and are interpreted
13
+ * inside the component owner. A collection's metadata is plain data, resolved
14
+ * right away — its index holds no dictionary to interpret anyway.
15
+ */
16
+ var keepRawChunk = (dictionary) => dictionary;
17
+ var readChunkMetadata = (dictionary, argument) => require_getDictionary.getDictionary(dictionary, argument);
18
+ /**
19
+ * On the client side, Hook that lazily loads a dictionary and returns its
20
+ * reactive content.
21
+ *
22
+ * The locale, selector and chunk selection are resolved by the shared
23
+ * `resolveDictionaryRead` / `resolveDynamicContentAsync`; this hook only adds
24
+ * Solid's resources and owner-scoped interpretation.
25
+ *
26
+ * If the locale is not provided (directly or through the selector), it will
27
+ * use the locale from the client context.
28
+ */
29
+ var useDictionaryDynamic = (dictionaryPromise, key, localeOrSelector) => {
30
+ const context = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
31
+ const dictionaryKey = String(key);
32
+ const loaderMap = dictionaryPromise;
33
+ const { locale: callLocale, selector: callSelector } = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(localeOrSelector) : {
34
+ locale: localeOrSelector,
35
+ selector: void 0
36
+ };
37
+ const readAccessor = () => (0, _intlayer_core_dictionaryManipulator.resolveDictionaryRead)({
38
+ localeOrSelector,
39
+ contextLocale: context.locale?.(),
40
+ contextVariant: context.variant?.(),
41
+ dictionaryKey
42
+ });
43
+ const sourceAccessor = () => {
44
+ const read = readAccessor();
45
+ const chunkSelectorId = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)({
46
+ ...read.selector,
47
+ metadataOnly: void 0
48
+ }) : "";
49
+ return {
50
+ ...read,
51
+ cacheKey: chunkSelectorId ? `${dictionaryKey}.${read.locale}.${chunkSelectorId}` : `${dictionaryKey}.${read.locale}`
52
+ };
53
+ };
54
+ const loadContent = (read, transform) => (0, _intlayer_core_dictionaryManipulator.resolveDynamicContentAsync)({
55
+ loaderMap,
56
+ key: dictionaryKey,
57
+ ...read,
58
+ transform
59
+ });
60
+ const chunkArgument = (0, _intlayer_core_dictionaryManipulator.getDynamicChunkArgument)(callLocale, callSelector);
61
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && (0, _intlayer_core_dictionaryManipulator.isQualifiedDynamicLoaderMap)(loaderMap) && loaderMap[_intlayer_core_dictionaryManipulator.QUALIFIER_DYNAMIC_TYPES_KEY].includes("item") && callSelector?.item === void 0) {
62
+ const resolvedEntries = require_solidCompat.createAsyncValue(readAccessor, (read) => loadContent(read, callSelector?.metadataOnly ? readChunkMetadata : keepRawChunk));
63
+ const accessor = (0, solid_js.createMemo)(() => {
64
+ const resolved = resolvedEntries();
65
+ if (!Array.isArray(resolved)) return [];
66
+ if (callSelector?.metadataOnly) return resolved;
67
+ const { locale } = readAccessor();
68
+ return resolved.map((dictionary) => require_getDictionary.getDictionary(dictionary, locale));
69
+ });
70
+ require_solidCompat.trackAsyncValue(resolvedEntries);
71
+ return require_client_contentProxy.createContentProxy(accessor);
72
+ }
73
+ const initialSource = sourceAccessor();
74
+ const preloadedDictionary = (0, _intlayer_core_dictionaryManipulator.getPreloadedDictionary)(loaderMap, initialSource.locale);
75
+ if (preloadedDictionary) require_client_useLoadDynamic.seedDynamicValue(initialSource, preloadedDictionary);
76
+ const dictionary = require_client_useLoadDynamic.useLoadDynamic(sourceAccessor, (source) => loadContent(source, keepRawChunk).then((resolved) => {
77
+ if (resolved === null) throw new Error(`No dynamic dictionary chunk found for key "${dictionaryKey}" and locale "${source.locale}".`);
78
+ return resolved;
79
+ }));
80
+ return require_client_useDictionary.useDictionary(dictionary, chunkArgument);
81
+ };
82
+ exports.useDictionaryDynamic = useDictionaryDynamic;
@@ -1 +1,50 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/dictionaryManipulator"),t=require("solid-js");const n=require("../getIntlayer.cjs"),r=require("./contentProxy.cjs"),i=require("./IntlayerProvider.cjs");var a=(a,o)=>{let s=(0,t.useContext)(i.IntlayerClientContext)??{},c=(0,t.createMemo)(()=>{let t=s?.locale?.();return process.env.INTLAYER_DICTIONARY_SELECTOR===`false`?n.getIntlayer(a,o??t):n.getIntlayer(a,(0,e.resolveDictionaryArgument)({localeOrSelector:o,contextLocale:t,contextVariant:s?.variant?.(),dictionaryKey:a}))});return r.createContentProxy(c)};exports.useIntlayer=a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
3
+ let solid_js = require("solid-js");
4
+ const require_getIntlayer = require("../getIntlayer.cjs");
5
+ const require_client_contentProxy = require("./contentProxy.cjs");
6
+ const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
7
+ // src/client/useIntlayer.ts
8
+ /**
9
+ * Solid hook that picks one dictionary by its key and returns its reactive content.
10
+ *
11
+ * The second argument is either a locale or a selector object:
12
+ * - `{ item: 2 }` — collection item (omit `item` to get every item as array)
13
+ * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)
14
+ * - `locale` composes with any selector and overrides the context locale
15
+ *
16
+ * Supports both direct property access and the accessor call form:
17
+ * - `content.myField.value` — reactive when used inside JSX or other Solid reactive contexts
18
+ * - `content()` — backward-compatible accessor form
19
+ *
20
+ * @param key - The unique key of the dictionary to retrieve.
21
+ * @param localeOrSelector - Optional locale or selector.
22
+ * @returns Reactive content accessible via property access or function call.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * import { useIntlayer } from 'solid-intlayer';
27
+ *
28
+ * const MyComponent = () => {
29
+ * const content = useIntlayer('my-dictionary-key');
30
+ * const faq2 = useIntlayer('faq', { item: 2 });
31
+ *
32
+ * return <div>{content.myField.value}</div>;
33
+ * };
34
+ * ```
35
+ */
36
+ var useIntlayer = (key, localeOrSelector) => {
37
+ const context = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
38
+ const accessor = (0, solid_js.createMemo)(() => {
39
+ const currentLocale = context?.locale?.();
40
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false") return require_getIntlayer.getIntlayer(key, (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
41
+ localeOrSelector,
42
+ contextLocale: currentLocale,
43
+ contextVariant: context?.variant?.(),
44
+ dictionaryKey: key
45
+ }));
46
+ return require_getIntlayer.getIntlayer(key, localeOrSelector ?? currentLocale);
47
+ });
48
+ return require_client_contentProxy.createContentProxy(accessor);
49
+ };
50
+ exports.useIntlayer = useIntlayer;
@@ -1 +1,140 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("solid-js");const t=require("../proxyKeys.cjs"),n=require("../solidCompat.cjs");var r=Symbol(`NO_PENDING_PRIMITIVE_FALLBACK`),i=Symbol(`LOADABLE_SETTLED_VALUE`),a=new Map,o=e=>typeof e==`string`?e:e.cacheKey,s=(e,t)=>t.reduce((e,t)=>{if(e!=null)return Reflect.get(Object(e),t)},e),c=(e,t)=>typeof e==`function`?e(t):e,l=(e,t)=>{let n=o(e),r=a.get(n);if(r?.status===`success`)return r.value;if(r?.status===`pending`)return r.promise;let i=c(t,e).then(e=>(a.set(n,{status:`success`,value:e}),e),e=>{throw a.delete(n),e});return a.set(n,{status:`pending`,promise:i}),i},u=(e,t)=>{let n=o(e);a.has(n)||a.set(n,{status:`success`,value:t})},d=(e,t)=>typeof t==`function`?t.bind(e):t,f=e=>e===Symbol.toPrimitive?()=>``:e===Symbol.iterator?()=>({next:()=>({done:!0,value:void 0})}):e===`length`?0:e===t.PROXY_RESERVED_KEYS.toString?()=>``:e===t.PROXY_RESERVED_KEYS.valueOf?()=>void 0:e===t.PROXY_RESERVED_KEYS.value?``:r,p=n=>{let a=o=>new Proxy(()=>void 0,{get(e,c){if(c===t.PROXY_RESERVED_KEYS.promiseThen)return;let l=s(n(),o);if(c===i)return l;if(l!=null)return c===Symbol.toPrimitive?()=>l:d(l,Reflect.get(Object(l),c));let u=f(c);return u===r?a([...o,c]):u},apply(t,r,i){let a=s(n(),o);return typeof a==`function`?Reflect.apply(a,r,i):i.length===0?a??``:p(()=>{let t=s(n(),o);if(typeof t==`function`)return(0,e.untrack)(()=>Reflect.apply(t,r,i))})}});return a([])},m=e=>{if(!(e===null||typeof e!=`object`&&typeof e!=`function`))return e[i]},h=(e,t)=>{let r=n.createAsyncValue(()=>typeof e==`function`?e():e,e=>l(e,t));return n.trackAsyncValue(r),p(r)};exports.createLoadableProxy=p,exports.getDynamicSourceCacheKey=o,exports.loadDynamicValue=l,exports.seedDynamicValue=u,exports.unwrapLoadable=m,exports.useLoadDynamic=h;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let solid_js = require("solid-js");
3
+ const require_proxyKeys = require("../proxyKeys.cjs");
4
+ const require_solidCompat = require("../solidCompat.cjs");
5
+ // src/client/useLoadDynamic.ts
6
+ var NO_PENDING_PRIMITIVE_FALLBACK = Symbol("NO_PENDING_PRIMITIVE_FALLBACK");
7
+ /**
8
+ * Property exposing the settled value behind a loadable proxy, or `undefined`
9
+ * while the chunk is still in flight. See {@link unwrapLoadable}.
10
+ */
11
+ var LOADABLE_SETTLED_VALUE = Symbol("LOADABLE_SETTLED_VALUE");
12
+ /**
13
+ * Module-level cache to dedupe dynamic imports by key. Solid async primitives
14
+ * still own suspense, SSR serialization, hydration, and refetching on source
15
+ * change.
16
+ */
17
+ var cache = /* @__PURE__ */ new Map();
18
+ var getDynamicSourceCacheKey = (source) => typeof source === "string" ? source : source.cacheKey;
19
+ var readValueAtPath = (value, path) => path.reduce((currentValue, property) => {
20
+ if (currentValue === null || currentValue === void 0) return void 0;
21
+ return Reflect.get(Object(currentValue), property);
22
+ }, value);
23
+ var resolveDynamicLoader = (loader, source) => typeof loader === "function" ? loader(source) : loader;
24
+ var loadDynamicValue = (source, loader) => {
25
+ const key = getDynamicSourceCacheKey(source);
26
+ const cachedEntry = cache.get(key);
27
+ if (cachedEntry?.status === "success") return cachedEntry.value;
28
+ if (cachedEntry?.status === "pending") return cachedEntry.promise;
29
+ const promise = resolveDynamicLoader(loader, source).then((value) => {
30
+ cache.set(key, {
31
+ status: "success",
32
+ value
33
+ });
34
+ return value;
35
+ }, (error) => {
36
+ cache.delete(key);
37
+ throw error;
38
+ });
39
+ cache.set(key, {
40
+ status: "pending",
41
+ promise
42
+ });
43
+ return promise;
44
+ };
45
+ /**
46
+ * Records a value that is already available, so the next
47
+ * {@link loadDynamicValue} for this key returns it synchronously.
48
+ *
49
+ * Used for dictionaries a build-tool plugin awaited while their entry point
50
+ * evaluated: the async value resolves without ever entering a pending state,
51
+ * so the loading boundary is not triggered and the first render already has the content.
52
+ *
53
+ * An existing entry is never replaced — an in-flight load owns its key.
54
+ */
55
+ var seedDynamicValue = (source, value) => {
56
+ const key = getDynamicSourceCacheKey(source);
57
+ if (cache.has(key)) return;
58
+ cache.set(key, {
59
+ status: "success",
60
+ value
61
+ });
62
+ };
63
+ var bindPropertyValue = (value, propertyValue) => typeof propertyValue === "function" ? propertyValue.bind(value) : propertyValue;
64
+ var createPendingPrimitiveFallback = (property) => {
65
+ if (property === Symbol.toPrimitive) return () => "";
66
+ if (property === Symbol.iterator) return () => ({ next: () => ({
67
+ done: true,
68
+ value: void 0
69
+ }) });
70
+ if (property === "length") return 0;
71
+ if (property === require_proxyKeys.PROXY_RESERVED_KEYS.toString) return () => "";
72
+ if (property === require_proxyKeys.PROXY_RESERVED_KEYS.valueOf) return () => void 0;
73
+ if (property === require_proxyKeys.PROXY_RESERVED_KEYS.value) return "";
74
+ return NO_PENDING_PRIMITIVE_FALLBACK;
75
+ };
76
+ /**
77
+ * Creates a stable callable proxy that re-reads the Solid async value on each
78
+ * property access. This keeps synchronous Intlayer access (`content.x.value`)
79
+ * safe while the Solid loading boundary owns the actual pending state.
80
+ */
81
+ var createLoadableProxy = (read) => {
82
+ const createProxyAtPath = (path) => {
83
+ const target = () => void 0;
84
+ return new Proxy(target, {
85
+ get(_target, property) {
86
+ if (property === require_proxyKeys.PROXY_RESERVED_KEYS.promiseThen) return void 0;
87
+ const currentValue = readValueAtPath(read(), path);
88
+ if (property === LOADABLE_SETTLED_VALUE) return currentValue;
89
+ if (currentValue !== null && currentValue !== void 0) {
90
+ if (property === Symbol.toPrimitive) return () => currentValue;
91
+ return bindPropertyValue(currentValue, Reflect.get(Object(currentValue), property));
92
+ }
93
+ const primitiveFallback = createPendingPrimitiveFallback(property);
94
+ if (primitiveFallback !== NO_PENDING_PRIMITIVE_FALLBACK) return primitiveFallback;
95
+ return createProxyAtPath([...path, property]);
96
+ },
97
+ apply(_target, thisArgument, argumentsList) {
98
+ const currentValue = readValueAtPath(read(), path);
99
+ if (typeof currentValue !== "function") {
100
+ if (argumentsList.length === 0) return currentValue ?? "";
101
+ return createLoadableProxy(() => {
102
+ const resolvedValue = readValueAtPath(read(), path);
103
+ if (typeof resolvedValue !== "function") return void 0;
104
+ return (0, solid_js.untrack)(() => Reflect.apply(resolvedValue, thisArgument, argumentsList));
105
+ });
106
+ }
107
+ return Reflect.apply(currentValue, thisArgument, argumentsList);
108
+ }
109
+ });
110
+ };
111
+ return createProxyAtPath([]);
112
+ };
113
+ /**
114
+ * Returns the settled value a loadable proxy stands for, or `undefined` while
115
+ * its chunk is in flight — and for any value that is not a loadable proxy.
116
+ *
117
+ * The read stays tracked, so a caller inside a reactive scope re-runs once the
118
+ * chunk lands. Interpreting the settled dictionary rather than the stand-in is
119
+ * what lets `getDictionary` memoize the transform: the stand-in is created per
120
+ * component and its content changes over time, while the settled dictionary is
121
+ * one shared object every component resolves to.
122
+ *
123
+ * @param value - A loadable proxy, or any other value.
124
+ */
125
+ var unwrapLoadable = (value) => {
126
+ if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
127
+ return value[LOADABLE_SETTLED_VALUE];
128
+ };
129
+ var useLoadDynamic = (key, loader) => {
130
+ const keyAccessor = () => typeof key === "function" ? key() : key;
131
+ const asyncValue = require_solidCompat.createAsyncValue(keyAccessor, (resolvedSource) => loadDynamicValue(resolvedSource, loader));
132
+ require_solidCompat.trackAsyncValue(asyncValue);
133
+ return createLoadableProxy(asyncValue);
134
+ };
135
+ exports.createLoadableProxy = createLoadableProxy;
136
+ exports.getDynamicSourceCacheKey = getDynamicSourceCacheKey;
137
+ exports.loadDynamicValue = loadDynamicValue;
138
+ exports.seedDynamicValue = seedDynamicValue;
139
+ exports.unwrapLoadable = unwrapLoadable;
140
+ exports.useLoadDynamic = useLoadDynamic;
@@ -1 +1,52 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built"),t=require("solid-js");const n=require("../solidCompat.cjs"),r=require("./IntlayerProvider.cjs"),i=require("./useLocaleStorage.cjs");var{defaultLocale:a,locales:o}=e.internationalization??{},s=({isCookieEnabled:e,onLocaleChange:s}={})=>{let c=(0,t.useContext)(r.IntlayerClientContext);return n.createChangeEffect(()=>c?.locale?.(),e=>{s&&e!==void 0&&s(e)}),{locale:c?.locale,defaultLocale:a,availableLocales:o,setLocale:t=>{o?.map(String).includes(t)?(c?.setLocale(t),i.setLocaleInStorage(t,e??c?.isCookieEnabled??!0)):console.error(`Locale ${t} is not available`)}}};exports.useLocale=s;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_config_built = require("@intlayer/config/built");
3
+ let solid_js = require("solid-js");
4
+ const require_solidCompat = require("../solidCompat.cjs");
5
+ const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
6
+ const require_client_useLocaleStorage = require("./useLocaleStorage.cjs");
7
+ // src/client/useLocale.ts
8
+ var { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
9
+ /**
10
+ * Solid hook to manage the current locale and related functions.
11
+ *
12
+ * @param props - Optional configuration for locale management.
13
+ * @returns An object containing the current locale (accessor), default locale, available locales, and a function to update the locale.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import { useLocale } from 'solid-intlayer';
18
+ *
19
+ * const LocaleSwitcher = () => {
20
+ * const { locale, setLocale, availableLocales } = useLocale();
21
+ *
22
+ * return (
23
+ * <select value={locale()} onChange={(e) => setLocale(e.target.value)}>
24
+ * <For each={availableLocales}>
25
+ * {(loc) => <option value={loc}>{loc}</option>}
26
+ * </For>
27
+ * </select>
28
+ * );
29
+ * };
30
+ * ```
31
+ */
32
+ var useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
33
+ const context = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext);
34
+ const setLocale = (locale) => {
35
+ if (!availableLocales?.map(String).includes(locale)) {
36
+ console.error(`Locale ${locale} is not available`);
37
+ return;
38
+ }
39
+ context?.setLocale(locale);
40
+ require_client_useLocaleStorage.setLocaleInStorage(locale, isCookieEnabled ?? context?.isCookieEnabled ?? true);
41
+ };
42
+ require_solidCompat.createChangeEffect(() => context?.locale?.(), (currentLocale) => {
43
+ if (onLocaleChange && currentLocale !== void 0) onLocaleChange(currentLocale);
44
+ });
45
+ return {
46
+ locale: context?.locale,
47
+ defaultLocale,
48
+ availableLocales,
49
+ setLocale
50
+ };
51
+ };
52
+ exports.useLocale = useLocale;
@@ -1 +1,19 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built"),t=require("solid-js");const n=require("./IntlayerProvider.cjs");var{defaultLocale:r,locales:i}=e.internationalization,a=()=>{let{locale:e,setLocale:a}=(0,t.useContext)(n.IntlayerClientContext)??{};return{locale:e,defaultLocale:r,availableLocales:i,setLocale:a}};exports.useLocaleBase=a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_config_built = require("@intlayer/config/built");
3
+ let solid_js = require("solid-js");
4
+ const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
5
+ // src/client/useLocaleBase.ts
6
+ var { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization;
7
+ /**
8
+ * On the client side, hook to get the current locale and all related fields
9
+ */
10
+ var useLocaleBase = () => {
11
+ const { locale, setLocale } = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
12
+ return {
13
+ locale,
14
+ defaultLocale,
15
+ availableLocales,
16
+ setLocale
17
+ };
18
+ };
19
+ exports.useLocaleBase = useLocaleBase;
@@ -1 +1,59 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/utils"),t=require("solid-js");var n=e.getCachedLocaleFromStorageClient,r=(0,e.getLocaleFromStorageClient)(e.localeStorageOptions),i=r,a=(t,n)=>(0,e.setLocaleInStorageClient)(t,{...e.localeStorageOptions,isCookieEnabled:n}),o=a,s=n=>(0,t.createMemo)(()=>(0,e.LocaleStorageClient)({...e.localeStorageOptions,isCookieEnabled:n})),c=s;exports.getLocaleInStorage=n,exports.localeCookie=i,exports.localeInStorage=r,exports.setLocaleCookie=o,exports.setLocaleInStorage=a,exports.useLocaleCookie=c,exports.useLocaleStorage=s;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_utils = require("@intlayer/core/utils");
3
+ let solid_js = require("solid-js");
4
+ // src/client/useLocaleStorage.ts
5
+ /**
6
+ * Reads the locale persisted in the browser storage (cookie, localStorage…).
7
+ *
8
+ * Unlike `localeInStorage`, read on first call rather than at import, then
9
+ * cached until the next `setLocaleInStorage`. Never cached on the server.
10
+ */
11
+ var getLocaleInStorage = _intlayer_core_utils.getCachedLocaleFromStorageClient;
12
+ /**
13
+ * Get the locale cookie
14
+ *
15
+ * Read once at import time; marked pure so bundlers drop the read when nothing
16
+ * imports it.
17
+ */
18
+ var localeInStorage = /* @__PURE__ */ (0, _intlayer_core_utils.getLocaleFromStorageClient)(_intlayer_core_utils.localeStorageOptions);
19
+ /**
20
+ * @deprecated Use localeInStorage instead
21
+ *
22
+ * Get the locale cookie
23
+ */
24
+ var localeCookie = localeInStorage;
25
+ /**
26
+ * Set the locale cookie
27
+ */
28
+ var setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorageClient)(locale, {
29
+ ..._intlayer_core_utils.localeStorageOptions,
30
+ isCookieEnabled
31
+ });
32
+ /**
33
+ * @deprecated Use setLocaleInStorage instead
34
+ *
35
+ * Set the locale cookie
36
+ */
37
+ var setLocaleCookie = setLocaleInStorage;
38
+ /**
39
+ * Hook that provides the locale storage and a function to set it
40
+ */
41
+ var useLocaleStorage = (isCookieEnabled) => (0, solid_js.createMemo)(() => (0, _intlayer_core_utils.LocaleStorageClient)({
42
+ ..._intlayer_core_utils.localeStorageOptions,
43
+ isCookieEnabled
44
+ }));
45
+ /**
46
+ * @deprecated Use useLocaleStorage instead
47
+ *
48
+ * For GDPR compliance, use useLocaleStorage instead
49
+ *
50
+ * Hook that provides the locale cookie and a function to set it
51
+ */
52
+ var useLocaleCookie = useLocaleStorage;
53
+ exports.getLocaleInStorage = getLocaleInStorage;
54
+ exports.localeCookie = localeCookie;
55
+ exports.localeInStorage = localeInStorage;
56
+ exports.setLocaleCookie = setLocaleCookie;
57
+ exports.setLocaleInStorage = setLocaleInStorage;
58
+ exports.useLocaleCookie = useLocaleCookie;
59
+ exports.useLocaleStorage = useLocaleStorage;
@@ -1 +1,41 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/core/localization"),t=require("solid-js");const n=require("../solidCompat.cjs");var r=()=>{let[r,i]=(0,t.createSignal)(typeof window<`u`?window.location.pathname:``);return n.onMounted(()=>{if(typeof window>`u`)return;let e=()=>{i(window.location.pathname)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}),()=>(0,e.getPathWithoutLocale)(r())};exports.usePathname=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_core_localization = require("@intlayer/core/localization");
3
+ let solid_js = require("solid-js");
4
+ const require_solidCompat = require("../solidCompat.cjs");
5
+ // src/client/usePathname.ts
6
+ /**
7
+ * Solid hook that returns an accessor containing the current pathname with
8
+ * the locale segment removed.
9
+ *
10
+ * Reacts to browser back/forward navigation via the `popstate` event.
11
+ * Falls back to an empty string during server-side rendering.
12
+ *
13
+ * @returns An accessor containing the current pathname without the locale prefix.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import { usePathname } from 'solid-intlayer';
18
+ *
19
+ * const NavItem = ({ href }: { href: string }) => {
20
+ * const pathname = usePathname();
21
+ * return (
22
+ * <a class={pathname() === href ? 'active' : ''} href={href}>
23
+ * {href}
24
+ * </a>
25
+ * );
26
+ * };
27
+ * ```
28
+ */
29
+ var usePathname = () => {
30
+ const [rawPathname, setRawPathname] = (0, solid_js.createSignal)(typeof window !== "undefined" ? window.location.pathname : "");
31
+ require_solidCompat.onMounted(() => {
32
+ if (typeof window === "undefined") return;
33
+ const handleLocationChange = () => {
34
+ setRawPathname(window.location.pathname);
35
+ };
36
+ window.addEventListener("popstate", handleLocationChange);
37
+ return () => window.removeEventListener("popstate", handleLocationChange);
38
+ });
39
+ return () => (0, _intlayer_core_localization.getPathWithoutLocale)(rawPathname());
40
+ };
41
+ exports.usePathname = usePathname;
@@ -1 +1,21 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built"),t=require("@intlayer/core/localization");const n=require("../solidCompat.cjs"),r=require("./useLocale.cjs");var i=()=>{let{locale:i}=r.useLocale(),a=e.routing?.rewrite;n.createWatchEffect(i,e=>{if(typeof window>`u`||!a)return;let n=window.location.pathname,r=(0,t.getRewritePath)(n,e,a);r&&r!==n&&window.history.replaceState(window.history.state,``,r+window.location.search+window.location.hash)})};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_solidCompat = require("../solidCompat.cjs");
5
+ const require_client_useLocale = require("./useLocale.cjs");
6
+ // src/client/useRewriteURL.ts
7
+ /**
8
+ * Client-side hook to manage URL rewrites in Solid without triggering a router navigation.
9
+ * It uses `window.history.replaceState` to update the URL in the address bar.
10
+ */
11
+ var useRewriteURL = () => {
12
+ const { locale } = require_client_useLocale.useLocale();
13
+ const rewrite = _intlayer_config_built.routing?.rewrite;
14
+ require_solidCompat.createWatchEffect(locale, (loc) => {
15
+ if (typeof window === "undefined" || !rewrite) return;
16
+ const pathname = window.location.pathname;
17
+ const targetPath = (0, _intlayer_core_localization.getRewritePath)(pathname, loc, rewrite);
18
+ if (targetPath && targetPath !== pathname) window.history.replaceState(window.history.state, "", targetPath + window.location.search + window.location.hash);
19
+ });
20
+ };
21
+ exports.useRewriteURL = useRewriteURL;
@@ -1 +1,32 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built"),t=require("@intlayer/core/interpreter"),n=require("solid-js");const r=require("./IntlayerProvider.cjs");var i=i=>{let{locale:a}=(0,n.useContext)(r.IntlayerClientContext)??{};return(0,t.getTranslation)(i,a?.()??e.internationalization.defaultLocale)};exports.useTranslation=i;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_config_built = require("@intlayer/config/built");
3
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
4
+ let solid_js = require("solid-js");
5
+ const require_client_IntlayerProvider = require("./IntlayerProvider.cjs");
6
+ // src/client/useTraduction.ts
7
+ /**
8
+ * On the client side, Hook that picking one dictionary by its id and return the content.
9
+ *
10
+ * If not locale found, it will return the content related to the default locale.
11
+ *
12
+ * Return either the content editor, or the content itself depending on the configuration.
13
+ *
14
+ * Usage:
15
+ *
16
+ * ```tsx
17
+ * const content = useTranslation<string>({
18
+ * en: 'Hello',
19
+ * fr: 'Bonjour',
20
+ * }, 'fr');
21
+ * // 'Bonjour'
22
+ * ```
23
+ *
24
+ * Using TypeScript:
25
+ * - this function will require each locale to be defined if defined in the project configuration.
26
+ * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
27
+ */
28
+ var useTranslation = (languageContent) => {
29
+ const { locale } = (0, solid_js.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
30
+ return (0, _intlayer_core_interpreter.getTranslation)(languageContent, locale?.() ?? _intlayer_config_built.internationalization.defaultLocale);
31
+ };
32
+ exports.useTranslation = useTranslation;
@@ -1 +1,20 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("solid-js/web"),t=require("@intlayer/editor/isEnabled");var n=n=>process.env.INTLAYER_EDITOR_ENABLED===`false`||!t.isEnabled?n.children:(0,e.createComponent)(e.Dynamic,{component:`intlayer-content-selector-wrapper`,get"attr:key-path"(){return JSON.stringify(n.keyPath)},get"attr:dictionary-key"(){return n.dictionaryKey},get children(){return n.children}});exports.ContentSelector=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let solid_js_web = require("solid-js/web");
3
+ let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
4
+ // src/editor/ContentSelector.tsx
5
+ var ContentSelector = (props) => {
6
+ if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !_intlayer_editor_isEnabled.isEnabled) return props.children;
7
+ return (0, solid_js_web.createComponent)(solid_js_web.Dynamic, {
8
+ component: "intlayer-content-selector-wrapper",
9
+ get ["attr:key-path"]() {
10
+ return JSON.stringify(props.keyPath);
11
+ },
12
+ get ["attr:dictionary-key"]() {
13
+ return props.dictionaryKey;
14
+ },
15
+ get children() {
16
+ return props.children;
17
+ }
18
+ });
19
+ };
20
+ exports.ContentSelector = ContentSelector;
@@ -1 +1,8 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useEditor.cjs");var t=({children:t})=>(e.useEditor(),t);exports.EditorProvider=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_editor_useEditor = require("./useEditor.cjs");
3
+ // src/editor/EditorProvider.tsx
4
+ var EditorProvider = ({ children }) => {
5
+ require_editor_useEditor.useEditor();
6
+ return children;
7
+ };
8
+ exports.EditorProvider = EditorProvider;
@@ -1 +1,32 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/editor/isEnabled"),t=require("solid-js");const n=require("../solidCompat.cjs");var r=(r,i)=>{let[a,o]=(0,t.createSignal)();return process.env.INTLAYER_EDITOR_ENABLED===`false`||!e.isEnabled||n.createWatchEffect(()=>({currentDictionaryKey:r(),keyPathJson:JSON.stringify(i()??[])}),({currentDictionaryKey:e,keyPathJson:t})=>{if(!e)return;let n=!1,r=null;return import(`@intlayer/editor`).then(({subscribeToEditedContentSource:i})=>{n||(r=i(e,JSON.parse(t),e=>o(()=>e)))}).catch(()=>{}),()=>{n=!0,r?.()}}),a};exports.createEditedContentSource=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
3
+ let solid_js = require("solid-js");
4
+ const require_solidCompat = require("../solidCompat.cjs");
5
+ // src/editor/createEditedContentSource.ts
6
+ /**
7
+ * Tracks the source string edited in the visual editor for a markdown / html
8
+ * node. The accessor returns `undefined` when the node is not edited (or the
9
+ * editor is off).
10
+ */
11
+ var createEditedContentSource = (dictionaryKey, keyPath) => {
12
+ const [editedSource, setEditedSource] = (0, solid_js.createSignal)();
13
+ if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !_intlayer_editor_isEnabled.isEnabled) return editedSource;
14
+ require_solidCompat.createWatchEffect(() => ({
15
+ currentDictionaryKey: dictionaryKey(),
16
+ keyPathJson: JSON.stringify(keyPath() ?? [])
17
+ }), ({ currentDictionaryKey, keyPathJson }) => {
18
+ if (!currentDictionaryKey) return;
19
+ let isStopped = false;
20
+ let unsubscribe = null;
21
+ import("@intlayer/editor").then(({ subscribeToEditedContentSource }) => {
22
+ if (isStopped) return;
23
+ unsubscribe = subscribeToEditedContentSource(currentDictionaryKey, JSON.parse(keyPathJson), (source) => setEditedSource(() => source));
24
+ }).catch(() => {});
25
+ return () => {
26
+ isStopped = true;
27
+ unsubscribe?.();
28
+ };
29
+ });
30
+ return editedSource;
31
+ };
32
+ exports.createEditedContentSource = createEditedContentSource;