preact-intlayer 8.9.6 → 8.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  2. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  3. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  4. package/dist/cjs/client/index.cjs +1 -1
  5. package/dist/cjs/client/t.cjs.map +1 -1
  6. package/dist/cjs/client/useContent.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  8. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  10. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  11. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  12. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  13. package/dist/cjs/client/useLocale.cjs.map +1 -1
  14. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  15. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  16. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  17. package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
  18. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  19. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  20. package/dist/cjs/format/useCompact.cjs.map +1 -1
  21. package/dist/cjs/format/useCurrency.cjs.map +1 -1
  22. package/dist/cjs/format/useDate.cjs.map +1 -1
  23. package/dist/cjs/format/useIntl.cjs.map +1 -1
  24. package/dist/cjs/format/useList.cjs.map +1 -1
  25. package/dist/cjs/format/useNumber.cjs.map +1 -1
  26. package/dist/cjs/format/usePercentage.cjs.map +1 -1
  27. package/dist/cjs/format/useRelativeTime.cjs.map +1 -1
  28. package/dist/cjs/format/useUnit.cjs.map +1 -1
  29. package/dist/cjs/getDictionary.cjs.map +1 -1
  30. package/dist/cjs/getIntlayer.cjs.map +1 -1
  31. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  32. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  33. package/dist/cjs/index.cjs +1 -1
  34. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  35. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  36. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  37. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  38. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  39. package/dist/cjs/plugins.cjs +36 -29
  40. package/dist/cjs/plugins.cjs.map +1 -1
  41. package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
  42. package/dist/esm/IntlayerNode.mjs.map +1 -1
  43. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  44. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  45. package/dist/esm/client/index.mjs +1 -1
  46. package/dist/esm/client/t.mjs.map +1 -1
  47. package/dist/esm/client/useContent.mjs.map +1 -1
  48. package/dist/esm/client/useDictionary.mjs.map +1 -1
  49. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  50. package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
  51. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  52. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  53. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  54. package/dist/esm/client/useLocale.mjs.map +1 -1
  55. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  56. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  57. package/dist/esm/client/useTraduction.mjs.map +1 -1
  58. package/dist/esm/editor/ContentSelector.mjs.map +1 -1
  59. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  60. package/dist/esm/editor/useEditor.mjs.map +1 -1
  61. package/dist/esm/format/useCompact.mjs.map +1 -1
  62. package/dist/esm/format/useCurrency.mjs.map +1 -1
  63. package/dist/esm/format/useDate.mjs.map +1 -1
  64. package/dist/esm/format/useIntl.mjs.map +1 -1
  65. package/dist/esm/format/useList.mjs.map +1 -1
  66. package/dist/esm/format/useNumber.mjs.map +1 -1
  67. package/dist/esm/format/usePercentage.mjs.map +1 -1
  68. package/dist/esm/format/useRelativeTime.mjs.map +1 -1
  69. package/dist/esm/format/useUnit.mjs.map +1 -1
  70. package/dist/esm/getDictionary.mjs.map +1 -1
  71. package/dist/esm/getIntlayer.mjs.map +1 -1
  72. package/dist/esm/html/HTMLProvider.mjs.map +1 -1
  73. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  74. package/dist/esm/index.mjs +1 -1
  75. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  76. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  77. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  78. package/dist/esm/markdown/compiler.mjs.map +1 -1
  79. package/dist/esm/markdown/runtime.mjs.map +1 -1
  80. package/dist/esm/plugins.mjs +36 -29
  81. package/dist/esm/plugins.mjs.map +1 -1
  82. package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
  83. package/dist/types/IntlayerNode.d.ts.map +1 -1
  84. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  85. package/dist/types/client/IntlayerProvider.d.ts +1 -2
  86. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  87. package/dist/types/client/useContent.d.ts +1 -2
  88. package/dist/types/client/useContent.d.ts.map +1 -1
  89. package/dist/types/client/useDictionary.d.ts +2 -4
  90. package/dist/types/client/useDictionary.d.ts.map +1 -1
  91. package/dist/types/client/useDictionaryDynamic.d.ts +2 -4
  92. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  93. package/dist/types/client/useLocale.d.ts.map +1 -1
  94. package/dist/types/client/useLocaleBase.d.ts +4 -6
  95. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  96. package/dist/types/client/useLocaleStorage.d.ts +4 -5
  97. package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
  98. package/dist/types/client/useTraduction.d.ts.map +1 -1
  99. package/dist/types/editor/ContentSelector.d.ts.map +1 -1
  100. package/dist/types/editor/EditorProvider.d.ts.map +1 -1
  101. package/dist/types/format/useCompact.d.ts +1 -3
  102. package/dist/types/format/useCompact.d.ts.map +1 -1
  103. package/dist/types/format/useCurrency.d.ts +1 -3
  104. package/dist/types/format/useCurrency.d.ts.map +1 -1
  105. package/dist/types/format/useDate.d.ts.map +1 -1
  106. package/dist/types/format/useIntl.d.ts.map +1 -1
  107. package/dist/types/format/useList.d.ts +1 -3
  108. package/dist/types/format/useList.d.ts.map +1 -1
  109. package/dist/types/format/useNumber.d.ts +1 -3
  110. package/dist/types/format/useNumber.d.ts.map +1 -1
  111. package/dist/types/format/usePercentage.d.ts +1 -3
  112. package/dist/types/format/usePercentage.d.ts.map +1 -1
  113. package/dist/types/format/useRelativeTime.d.ts +1 -3
  114. package/dist/types/format/useRelativeTime.d.ts.map +1 -1
  115. package/dist/types/format/useUnit.d.ts +1 -3
  116. package/dist/types/format/useUnit.d.ts.map +1 -1
  117. package/dist/types/html/HTMLProvider.d.ts.map +1 -1
  118. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  119. package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
  120. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  121. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  122. package/dist/types/markdown/compiler.d.ts.map +1 -1
  123. package/dist/types/markdown/runtime.d.ts.map +1 -1
  124. package/dist/types/plugins.d.ts.map +1 -1
  125. package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
  126. package/package.json +7 -7
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
3
4
  const require_editor_ContentSelector = require('./editor/ContentSelector.cjs');
4
5
  const require_IntlayerNode = require('./IntlayerNode.cjs');
5
6
  const require_preactElement_renderPreactElement = require('./preactElement/renderPreactElement.cjs');
@@ -9,13 +10,14 @@ let _intlayer_core_markdown = require("@intlayer/core/markdown");
9
10
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
10
11
  _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType);
11
12
  let preact = require("preact");
12
- let preact_compat = require("preact/compat");
13
13
  let preact_jsx_runtime = require("preact/jsx-runtime");
14
14
 
15
15
  //#region src/plugins.tsx
16
- const LazyMarkdownMetadataRenderer = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownMetadataRenderer })));
17
- const LazyMarkdownRendererPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({ default: m.MarkdownRendererPlugin })));
18
- const LazyHTMLRenderer = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? null : (0, preact_compat.lazy)(() => Promise.resolve().then(() => require("./html/HTMLRenderer.cjs")).then((m) => ({ default: m.HTMLRenderer })));
16
+ const markdownRendererModulePromise = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] !== "false" ? Promise.resolve().then(() => require("./markdown/MarkdownRendererPlugin.cjs")).then((m) => ({
17
+ MarkdownRendererPlugin: m.MarkdownRendererPlugin,
18
+ MarkdownMetadataRenderer: m.MarkdownMetadataRenderer
19
+ })) : null;
20
+ const htmlRendererModulePromise = process.env["INTLAYER_NODE_TYPE_HTML"] !== "false" ? Promise.resolve().then(() => require("./html/HTMLRenderer.cjs")).then((m) => m.HTMLRenderer) : null;
19
21
  /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
20
22
  const intlayerNodePlugins = {
21
23
  id: "intlayer-node-plugin",
@@ -110,6 +112,20 @@ const insertionPlugin = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false"
110
112
  return result;
111
113
  }
112
114
  };
115
+ const MarkdownSuspenseRenderer = ({ children, ...props }) => {
116
+ const { MarkdownRendererPlugin } = require_client_useLoadDynamic.useLoadDynamic("preact-markdown-renderer", markdownRendererModulePromise);
117
+ return (0, preact.h)(MarkdownRendererPlugin, {
118
+ ...props,
119
+ children
120
+ });
121
+ };
122
+ const MarkdownMetadataSuspenseRenderer = ({ children, ...props }) => {
123
+ const { MarkdownMetadataRenderer } = require_client_useLoadDynamic.useLoadDynamic("preact-markdown-renderer", markdownRendererModulePromise);
124
+ return (0, preact.h)(MarkdownMetadataRenderer, {
125
+ ...props,
126
+ children
127
+ });
128
+ };
113
129
  /** Markdown string plugin. Replaces string node with a component that render the markdown. */
114
130
  const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
115
131
  id: "markdown-string-plugin",
@@ -125,21 +141,15 @@ const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "fal
125
141
  value: metadataNode,
126
142
  children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
127
143
  ...rest,
128
- children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
129
- fallback: node,
130
- children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(LazyMarkdownMetadataRenderer, {
131
- ...rest,
132
- metadataKeyPath: props.keyPath,
133
- children: node
134
- })
135
- })
136
- }) : /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
137
- fallback: node,
138
- children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(LazyMarkdownMetadataRenderer, {
144
+ children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(MarkdownMetadataSuspenseRenderer, {
139
145
  ...rest,
140
146
  metadataKeyPath: props.keyPath,
141
147
  children: node
142
148
  })
149
+ }) : /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(MarkdownMetadataSuspenseRenderer, {
150
+ ...rest,
151
+ metadataKeyPath: props.keyPath,
152
+ children: node
143
153
  })
144
154
  })
145
155
  }],
@@ -151,21 +161,15 @@ const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "fal
151
161
  value: node,
152
162
  children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(require_editor_ContentSelector.ContentSelector, {
153
163
  ...rest,
154
- children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
155
- fallback: node,
156
- children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(LazyMarkdownRendererPlugin, {
157
- ...rest,
158
- components,
159
- children: node
160
- })
161
- })
162
- }) : /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(preact_compat.Suspense, {
163
- fallback: node,
164
- children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(LazyMarkdownRendererPlugin, {
164
+ children: /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(MarkdownSuspenseRenderer, {
165
165
  ...rest,
166
166
  components,
167
167
  children: node
168
168
  })
169
+ }) : /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(MarkdownSuspenseRenderer, {
170
+ ...rest,
171
+ components,
172
+ children: node
169
173
  }),
170
174
  additionalProps: { metadata: metadataNodes }
171
175
  });
@@ -199,6 +203,9 @@ const markdownPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ?
199
203
  });
200
204
  }
201
205
  };
206
+ const HTMLSuspenseRenderer = (props) => {
207
+ return (0, preact.h)(require_client_useLoadDynamic.useLoadDynamic("preact-html-renderer", htmlRendererModulePromise), props);
208
+ };
202
209
  /** HTML plugin. Replaces node with a function that takes components => VNode. */
203
210
  const htmlPlugin = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
204
211
  id: "html-plugin",
@@ -210,15 +217,15 @@ const htmlPlugin = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? _intlaye
210
217
  const render = (userComponents) => require_IntlayerNode.renderIntlayerNode({
211
218
  ...rest,
212
219
  value: html,
213
- children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? (0, preact.h)(require_editor_ContentSelector.ContentSelector, { ...rest }, (0, preact.h)(preact_compat.Suspense, { fallback: html }, (0, preact.h)(LazyHTMLRenderer, {
220
+ children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && _intlayer_config_built.editor.enabled ? (0, preact.h)(require_editor_ContentSelector.ContentSelector, { ...rest }, (0, preact.h)(HTMLSuspenseRenderer, {
214
221
  ...rest,
215
222
  html,
216
223
  userComponents
217
- }))) : (0, preact.h)(preact_compat.Suspense, { fallback: html }, (0, preact.h)(LazyHTMLRenderer, {
224
+ })) : (0, preact.h)(HTMLSuspenseRenderer, {
218
225
  ...rest,
219
226
  html,
220
227
  userComponents
221
- }))
228
+ })
222
229
  });
223
230
  const element = render();
224
231
  return new Proxy(element, { get(target, prop) {
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","editor","ContentSelector","fallbackPlugin","renderPreactElement","Fragment","NodeTypes","func","Suspense","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst LazyMarkdownMetadataRenderer = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false'\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return node;\n if (prop === Symbol.toPrimitive) return () => node;\n if (prop === 'toString') return () => node;\n if (prop === 'valueOf') return () => node;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(node);\n }\n if (prop === 'metadata') return metadataNodes;\n if (prop === 'use')\n return (components?: any) => render(components);\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return html;\n if (prop === Symbol.toPrimitive) return () => html;\n if (prop === 'toString') return () => html;\n if (prop === 'valueOf') return () => html;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(html);\n }\n if (prop === 'use')\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAM,+BACJ,QAAQ,IAAI,mCAAmC,UAC3C,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,0BACZ,EAAE,CACJ;AAGP,MAAM,6BACJ,QAAQ,IAAI,mCAAmC,UAC3C,0EAEE,0CAA4C,MAAM,OAAO,EACvD,SAAS,EAAE,wBACZ,EAAE,CACJ;AAGP,MAAM,mBACJ,QAAQ,IAAI,+BAA+B,UACvC,0EAEE,4BAA8B,MAAM,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CACzE;;AAYP,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLA,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,QAAQ,IAAI,+BAA+B,WAAWC,8BAAO,UAC3D,0CAACC,gDAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;GAEnB,EADf,KAAK,SACU,GAElB,KAAK;EAEV,CAAC;CACL;;AAcD,MAAa,oBACX,QAAQ,IAAI,sCAAsC,UAC9CC,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGLH,wCAAmB;EACjB,GAAG;EACH,OAA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AW,YAAY,OAAO,OAAO,KAAK,KAAK;;GAE5D,IAAI,SAAS,OACX,QAAQ,mBACN,OAAO,eAAe;GAC1B,OAAO,QAAQ,IAAI,QAAQ,KAAK;KAEnC,CAEW;;CAEf;AAmCP,MAAM,+BAAe,IAAI,KAAwB;;;;;AAMjD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAUC,4CAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,SAAS,EAC5B,OAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;oDAEZ,UAAUA,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,OACjD;EACDC;+CACa,UAAUD,4CAAqB,cAAc;EAC1DE;+CACa,UAAUF,4CAAqB,cAAc;EAC1DG;EACAC;EAEA;EACA;EACA;EACA;EACA;EACD;CAED,aAAa,IAAI,UAAU,QAAQ;CAEnC,OAAO"}
1
+ {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","editor","ContentSelector","fallbackPlugin","renderPreactElement","Fragment","NodeTypes","func","useLoadDynamic","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, type FunctionComponent, h, type VNode } from 'preact';\nimport { useLoadDynamic } from './client/useLoadDynamic';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_HTML'] !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false'\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\nconst MarkdownSuspenseRenderer: FunctionComponent<Record<string, any>> = ({\n children,\n ...props\n}) => {\n const { MarkdownRendererPlugin } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownRendererPlugin as any, { ...props, children });\n};\n\nconst MarkdownMetadataSuspenseRenderer: FunctionComponent<\n Record<string, any>\n> = ({ children, ...props }) => {\n const { MarkdownMetadataRenderer } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownMetadataRenderer as any, { ...props, children });\n};\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return node;\n if (prop === Symbol.toPrimitive) return () => node;\n if (prop === 'toString') return () => node;\n if (prop === 'valueOf') return () => node;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(node);\n }\n if (prop === 'metadata') return metadataNodes;\n if (prop === 'use')\n return (components?: any) => render(components);\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\nconst HTMLSuspenseRenderer: FunctionComponent<Record<string, any>> = (\n props\n) => {\n const HTMLRenderer = useLoadDynamic(\n 'preact-html-renderer',\n htmlRendererModulePromise!\n );\n return h(HTMLRenderer as any, props);\n};\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, { ...rest, html, userComponents })\n )\n : h(HTMLSuspenseRenderer, { ...rest, html, userComponents }),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return html;\n if (prop === Symbol.toPrimitive) return () => html;\n if (prop === 'toString') return () => html;\n if (prop === 'valueOf') return () => html;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(html);\n }\n if (prop === 'use')\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAM,gCACJ,QAAQ,IAAI,mCAAmC,+CAC3C,0CAA4C,MAAM,OAAO;CACvD,wBAAwB,EAAE;CAC1B,0BAA0B,EAAE;AAC9B,EAAE,IACF;AAEN,MAAM,4BACJ,QAAQ,IAAI,+BAA+B,+CACvC,4BAA8B,MAAM,MAAM,EAAE,YAAY,IACxD;;AAWN,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLA,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,QAAQ,IAAI,+BAA+B,WAAWC,8BAAO,UAC3D,0CAACC,gDAAD;GAAiB,GAAI;GAAM,KAAK,KAAK;EAEpB,GADd,KAAK,QACS,IAEjB,KAAK;CAEX,CAAC;AACL;;AAcA,MAAa,oBACX,QAAQ,IAAI,sCAAsC,UAC9CC,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;CAEtB,YACE,MACA,EACE,SACA,GAAG,WAGLH,wCAAmB;EACjB,GAAG;EACH,OAAO;EACP,UACE,QAAQ,IAAI,+BAA+B,WAC3CC,8BAAO,UACL,4CAACC,gDAAD;GAAiB,GAAI;aAClBE,8DAAoB,IAAI;EACV,KAEjBA,8DAAoB,IAAI;CAE9B,CAAC;AACL;;;;AAuBN,MAAM,WAAW,UAA+B;CAC9C,OACE,UAAU,QACV,UAAU,UACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;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ACX,QAAQ,mBACN,OAAO,cAAc;GACzB,OAAO,QAAQ,IAAI,QAAQ,IAAI;EACjC,EACF,CAEW;CACb;AACF;AAmCN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAoB,SACN;CAEd,MAAM,WAAW,GADK,UAAUO,4CAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAGlC,MAAM,UAAU;oDAEZ,UAAUA,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,MAClD;EACAC;+CACa,UAAUD,4CAAqB,aAAa;EACzDE;+CACa,UAAUF,4CAAqB,aAAa;EACzDG;EACAC;EAEA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderPreactElement.cjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB,YAA6B;CAC/D,IAAI,YAAY,QAAQ,OAAO,YAAY,UACzC,OAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;EAEhC,IAAI,MAAM,QAAQ,SAAS,EAAE;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,MAAoB,CACzC;GAED,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;KAAgB;IACtD;SACI,IAAI,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,SAAuB;GACjE,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,cAAc;KAAE;IACvD;;EAGH,OAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,EAAE;IAAE;GAC1C;;CAOH,MAAM,EAAE,MAAM,UAJO,uBACnB,QAGkC;CAGpC,iCACG,QAAgB,QACjB,OACA,GAAI,MAAM,SACX"}
1
+ {"version":3,"file":"renderPreactElement.cjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB,YAA6B;CAC/D,IAAI,YAAY,QAAQ,OAAO,YAAY,UACzC,OAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;EAEhC,IAAI,MAAM,QAAQ,QAAQ,GAAG;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,KAAmB,CACzC;GAEA,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;IAAe;GACtD;EACF,OAAO,IAAI,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,QAAsB;GAChE,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,aAAa;IAAE;GACvD;EACF;EAEA,OAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,CAAC;GAAE;EAC1C;CACF;CAMA,MAAM,EAAE,MAAM,UAJO,uBACnB,OAGiC;CAGnC,iCACG,QAAgB,QACjB,OACA,GAAI,MAAM,QACZ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerNode.mjs","names":[],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChildren,\n Fragment,\n h,\n isValidElement,\n type VNode,\n} from 'preact';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = ResolvedEditor<T, VNode> & {\n value: T;\n} & AdditionalProps &\n T;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: ComponentChildren;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid VNode, wrap it in a fragment\n const element: VNode<any> = isValidElement(children)\n ? children\n : h(Fragment, {}, children);\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as VNode, {\n get(target, prop, receiver) {\n if (prop === 'value') return value;\n if (prop === Symbol.toPrimitive) return () => value ?? '';\n if (prop === 'toString') return () => String(value ?? '');\n if (prop === 'valueOf') return () => value;\n\n // Additional Props take precedence\n if (additionalProps && prop in additionalProps) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n // Delegate native methods/properties to the underlying value\n if (\n value !== null &&\n value !== undefined &&\n typeof prop === 'string' &&\n prop !== 'constructor' &&\n !(prop in target) // Prevents overwriting VNode internals (type, props, key)\n ) {\n const valObj = Object(value); // Safely boxes primitives (e.g., 50 -> Number object)\n if (prop in valObj) {\n const valProp = valObj[prop];\n return typeof valProp === 'function' ? valProp.bind(value) : valProp;\n }\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;AAwBA,MAAa,sBAEX,EACA,UACA,OACA,sBACiD;CAEjD,MAAM,UAAsB,eAAe,SAAS,GAChD,WACA,EAAE,UAAU,EAAE,EAAE,SAAS;CAI7B,OAAO,IAAI,MAAM,SAAkB,EACjC,IAAI,QAAQ,MAAM,UAAU;EAC1B,IAAI,SAAS,SAAS,OAAO;EAC7B,IAAI,SAAS,OAAO,aAAa,aAAa,SAAS;EACvD,IAAI,SAAS,YAAY,aAAa,OAAO,SAAS,GAAG;EACzD,IAAI,SAAS,WAAW,aAAa;EAGrC,IAAI,mBAAmB,QAAQ,iBAC7B,OAAO,gBAAgB;EAIzB,IACE,UAAU,QACV,UAAU,UACV,OAAO,SAAS,YAChB,SAAS,iBACT,EAAE,QAAQ,SACV;GACA,MAAM,SAAS,OAAO,MAAM;GAC5B,IAAI,QAAQ,QAAQ;IAClB,MAAM,UAAU,OAAO;IACvB,OAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,MAAM,GAAG;;;EAIjE,OAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC"}
1
+ {"version":3,"file":"IntlayerNode.mjs","names":[],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChildren,\n Fragment,\n h,\n isValidElement,\n type VNode,\n} from 'preact';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = ResolvedEditor<T, VNode> & {\n value: T;\n} & AdditionalProps &\n T;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: ComponentChildren;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid VNode, wrap it in a fragment\n const element: VNode<any> = isValidElement(children)\n ? children\n : h(Fragment, {}, children);\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as VNode, {\n get(target, prop, receiver) {\n if (prop === 'value') return value;\n if (prop === Symbol.toPrimitive) return () => value ?? '';\n if (prop === 'toString') return () => String(value ?? '');\n if (prop === 'valueOf') return () => value;\n\n // Additional Props take precedence\n if (additionalProps && prop in additionalProps) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n // Delegate native methods/properties to the underlying value\n if (\n value !== null &&\n value !== undefined &&\n typeof prop === 'string' &&\n prop !== 'constructor' &&\n !(prop in target) // Prevents overwriting VNode internals (type, props, key)\n ) {\n const valObj = Object(value); // Safely boxes primitives (e.g., 50 -> Number object)\n if (prop in valObj) {\n const valProp = valObj[prop];\n return typeof valProp === 'function' ? valProp.bind(value) : valProp;\n }\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;AAwBA,MAAa,sBAEX,EACA,UACA,OACA,sBACiD;CAEjD,MAAM,UAAsB,eAAe,QAAQ,IAC/C,WACA,EAAE,UAAU,CAAC,GAAG,QAAQ;CAI5B,OAAO,IAAI,MAAM,SAAkB,EACjC,IAAI,QAAQ,MAAM,UAAU;EAC1B,IAAI,SAAS,SAAS,OAAO;EAC7B,IAAI,SAAS,OAAO,aAAa,aAAa,SAAS;EACvD,IAAI,SAAS,YAAY,aAAa,OAAO,SAAS,EAAE;EACxD,IAAI,SAAS,WAAW,aAAa;EAGrC,IAAI,mBAAmB,QAAQ,iBAC7B,OAAO,gBAAgB;EAIzB,IACE,UAAU,QACV,UAAU,UACV,OAAO,SAAS,YAChB,SAAS,iBACT,EAAE,QAAQ,SACV;GACA,MAAM,SAAS,OAAO,KAAK;GAC3B,IAAI,QAAQ,QAAQ;IAClB,MAAM,UAAU,OAAO;IACvB,OAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,KAAK,IAAI;GAC/D;EACF;EAEA,OAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;CAC3C,EACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type { FunctionalComponent, JSX } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: JSX.MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;AAGA,MAAM,gCAAgC;AAWtC,MAAa,mBAA8D,EACzE,UACA,SAAS,UACT,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,SAAS,OAAuB,KAAK;CAC3C,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,gBAAgB;CACzE,MAAM,gBAAgB,OAA6C,KAAK;CACxE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;EAC9B,oBAAoB,KAAK;EACzB,UAAU;;CAGZ,MAAM,wBAAwB;EAC5B,cAAc,UAAU,iBAAiB;GACvC,mBAAmB;KAClB,cAAc;;CAGnB,MAAM,wBAAwB;EAC5B,IAAI,cAAc,SAAS;GACzB,aAAa,cAAc,QAAQ;GACnC,cAAc,UAAU;;;CAI5B,MAAM,wBAAwB;EAC5B,iBAAiB;EACjB,iBAAiB;;CAGnB,MAAM,yBAAyB;EAC7B,aAAa,KAAK;EAClB,WAAW;;CAGb,MAAM,sBAAsB;EAC1B,IAAI,WAAW;GACb,aAAa,MAAM;GACnB,aAAa;;EAEf,iBAAiB;;CAInB,MAAM,qBAAqB,aACxB,UAAsB;EACrB,IAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,OAAe,EAAE;GACpE,oBAAoB,MAAM;GAC1B,cAAc;;IAGlB,CAAC,WAAW,CACb;CAED,gBAAgB;EAEd,SAAS,iBAAiB,aAAa,mBAAmB;EAE1D,aAAa;GAEX,SAAS,oBAAoB,aAAa,mBAAmB;;IAG9D,CAAC,mBAAmB,CAAC;CAExB,MAAM,iBAAwD,MAAM;EAClE,IAAI,kBAAkB;GACpB,EAAE,gBAAgB;GAClB,EAAE,iBAAiB;;;CAIvB,MAAM,qBAAqB;EAEzB,oBAAoB,MAAM;;CAG5B,OACE,oBAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;GACb;EACD,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;EACI"}
1
+ {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type { FunctionalComponent, JSX } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: JSX.MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;AAGA,MAAM,gCAAgC;AAWtC,MAAa,mBAA8D,EACzE,UACA,SAAS,UACT,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,SAAS,OAAuB,IAAI;CAC1C,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,eAAe;CACxE,MAAM,gBAAgB,OAA6C,IAAI;CACvE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;EAC9B,oBAAoB,IAAI;EACxB,SAAS;CACX;CAEA,MAAM,wBAAwB;EAC5B,cAAc,UAAU,iBAAiB;GACvC,kBAAkB;EACpB,GAAG,aAAa;CAClB;CAEA,MAAM,wBAAwB;EAC5B,IAAI,cAAc,SAAS;GACzB,aAAa,cAAc,OAAO;GAClC,cAAc,UAAU;EAC1B;CACF;CAEA,MAAM,wBAAwB;EAC5B,gBAAgB;EAChB,gBAAgB;CAClB;CAEA,MAAM,yBAAyB;EAC7B,aAAa,IAAI;EACjB,UAAU;CACZ;CAEA,MAAM,sBAAsB;EAC1B,IAAI,WAAW;GACb,aAAa,KAAK;GAClB,YAAY;EACd;EACA,gBAAgB;CAClB;CAGA,MAAM,qBAAqB,aACxB,UAAsB;EACrB,IAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;GACpE,oBAAoB,KAAK;GACzB,aAAa;EACf;CACF,GACA,CAAC,UAAU,CACb;CAEA,gBAAgB;EAEd,SAAS,iBAAiB,aAAa,kBAAkB;EAEzD,aAAa;GAEX,SAAS,oBAAoB,aAAa,kBAAkB;EAE9D;CACF,GAAG,CAAC,kBAAkB,CAAC;CAEvB,MAAM,iBAAwD,MAAM;EAClE,IAAI,kBAAkB;GACpB,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB;CACF;CAEA,MAAM,qBAAqB;EAEzB,oBAAoB,KAAK;CAC3B;CAEA,OACE,oBAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;EACd;EACA,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;CACG;AAEV"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect, useState } from 'preact/hooks';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n isCookieEnabled,\n}) => {\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n defaultLocale as LocalesValues\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;CAClB,CAAC;;;;AAKF,MAAa,2BAA2B,WAAW,sBAAsB,IAAI,EAAE;;;;AAa/E,MAAa,2BAER,EACH,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,sBACI;CACJ,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnD,wBAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,oBAAoB,SAFxC,cAAc,mBAAmB,qBAAqB,oBAIvD;CAED,gBAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,WAAW;IAE7B;EAAC;EAAY;EAAe;EAAiB,CAAC;CAEjD,gBAAgB;EACd,uBAAuB;IACtB,EAAE,CAAC;CAEN,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,UAAU,KAAK,UAAU,UAAU,EAAE;EAEvD,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;GACtD,QAAQ,MAAM,UAAU,UAAU,mBAAmB;GACrD;;EAGF,iBAAiB,UAAU;EAC3B,mBAAmB,WAAW,mBAAmB,KAAK;;CAGxD,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iBAAiB,eAAe,cAAc,cAAc;CAElE,OACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA8D,EACzE,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,oBAAC,gBAAD,EAAkB,GACjB,SACuB"}
1
+ {"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect, useState } from 'preact/hooks';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n isCookieEnabled,\n}) => {\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n defaultLocale as LocalesValues\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,wBAAwB,cAA6B;CAChE,QAAQ,mBAAmB,sBAAsB;CACjD,iBAAiB;AACnB,CAAC;;;;AAKD,MAAa,2BAA2B,WAAW,qBAAqB,KAAK,CAAC;;;;AAa9E,MAAa,2BAER,EACH,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,sBACI;CACJ,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnD,wBAAwB,CAAC;CAK3B,MAAM,CAAC,eAAe,oBAAoB,SAFxC,cAAc,mBAAmB,qBAAqB,mBAIxD;CAEA,gBAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B,GAAG;EAAC;EAAY;EAAe;CAAgB,CAAC;CAEhD,gBAAgB;EACd,sBAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mBAAmB,WAAW,mBAAmB,IAAI;CACvD;CAEA,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iBAAiB,eAAe,cAAc,aAAa;CAEjE,OACE,oBAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;EACF;EAEC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA8D,EACzE,UACA,GAAG,YAEH,qBAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,oBAAC,gBAAD,CAAiB,IAChB,QACsB"}
@@ -1,9 +1,9 @@
1
+ import { useLoadDynamic } from "./useLoadDynamic.mjs";
1
2
  import { localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./useLocaleStorage.mjs";
2
3
  import { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext } from "./IntlayerProvider.mjs";
3
4
  import { t } from "./t.mjs";
4
5
  import { useDictionary } from "./useDictionary.mjs";
5
6
  import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
6
- import { useLoadDynamic } from "./useLoadDynamic.mjs";
7
7
  import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
8
8
  import { useIntlayer } from "./useIntlayer.mjs";
9
9
  import { useLocale } from "./useLocale.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"t.mjs","names":[],"sources":["../../../src/client/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: Locale\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAGzE,OAAO,eAAwB,kBAFV,UAAU,cAE+B"}
1
+ {"version":3,"file":"t.mjs","names":[],"sources":["../../../src/client/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: Locale\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CAGxE,OAAO,eAAwB,kBAFV,UAAU,aAE8B;AAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"useContent.mjs","names":[],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAW,eAAe;CAIlC,OAAO;EACL;EACA,SAJc,eAAe,gBAItB;EACP,GAAG;EACJ"}
1
+ {"version":3,"file":"useContent.mjs","names":[],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAW,cAAc;CAIjC,OAAO;EACL;EACA,SAJc,eAAe,eAIvB;EACN,GAAG;CACL;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,OAAO,cAAc;EAGnB,OAAO,cAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC,WAAW;EAAK;EAAe;EAAO,CAAC"}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CAExE,OAAO,cAAc;EAGnB,OAAO,cAAoB,YAFN,UAAU,aAEyB;CAC1D,GAAG;EAAC,WAAW;EAAK;EAAe;CAAM,CAAC;AAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,MAAM,eAAe,cACb,UAAU,iBAAiB,qBAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;CAUD,OAAO,cAAc,MARI,QACvB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CAExE,MAAM,eAAe,cACb,UAAU,iBAAiB,qBAAqB,eACtD,CAAC,eAAe,MAAM,CACxB;CAUA,OAAO,cAAc,MARI,QACvB,YACG,MAAM,kBACL,gBACE,GACN,CAAC,mBAAmB,YAAY,CAClC,GAEiC,YAAY;AAC/C"}
@@ -1,6 +1,6 @@
1
+ import { useLoadDynamic } from "./useLoadDynamic.mjs";
1
2
  import { IntlayerClientContext } from "./IntlayerProvider.mjs";
2
3
  import { useDictionary } from "./useDictionary.mjs";
3
- import { useLoadDynamic } from "./useLoadDynamic.mjs";
4
4
  import { useContext, useMemo } from "preact/hooks";
5
5
 
6
6
  //#region src/client/useDictionaryDynamic.ts
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CACzE,MAAM,eAAe,cACb,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;CAOD,OAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGf,EAAE,aAAa"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CACxE,MAAM,eAAe,cACb,UAAU,eAChB,CAAC,eAAe,MAAM,CACxB;CAOA,OAAO,cALY,eACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBACjB,kBAA0B,gBAAgB,CAGf,GAAG,YAAY;AAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Preact hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'preact-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getIntlayer<T, L>(key, localeTarget as L) as DeepTransformContent<\n DictionaryRegistryContent<T>\n >;\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,eACX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;CAEzE,OAAO,cAAc;EAInB,OAAO,YAAkB,KAHJ,UAAU,cAGiB;IAG/C;EAAC;EAAK;EAAe;EAAO,CAAC"}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Preact hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'preact-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getIntlayer<T, L>(key, localeTarget as L) as DeepTransformContent<\n DictionaryRegistryContent<T>\n >;\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,eACX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CAExE,OAAO,cAAc;EAInB,OAAO,YAAkB,KAHJ,UAAU,aAGgB;CAGjD,GAAG;EAAC;EAAK;EAAe;CAAM,CAAC;AACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.mjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":";AAEA,MAAM,mBAAsB,YAAwB;CAClD,IAAI,SAAiB;CACrB,IAAI;CACJ,MAAM,YAAY,QAAQ,MACvB,MAAM;EACL,SAAS;EACT,SAAS;KAEV,MAAM;EACL,SAAS;EACT,SAAS;GAEZ;CAED,OAAO,EACL,OAAO;EACL,IAAI,WAAW,WAAW,MAAM;EAChC,IAAI,WAAW,SAAS,MAAM;EAC9B,OAAO;IAEV;;AAGH,MAAM,wBAAQ,IAAI,KAAiD;AAEnE,MAAa,kBAAqB,KAAa,YAA2B;CACxE,IAAI,CAAC,MAAM,IAAI,IAAI,EACjB,MAAM,IAAI,KAAK,gBAAgB,QAAQ,CAAC;CAG1C,OAAQ,MAAM,IAAI,IAAI,CAAyC,MAAM"}
1
+ {"version":3,"file":"useLoadDynamic.mjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":";AAEA,MAAM,mBAAsB,YAAwB;CAClD,IAAI,SAAiB;CACrB,IAAI;CACJ,MAAM,YAAY,QAAQ,MACvB,MAAM;EACL,SAAS;EACT,SAAS;CACX,IACC,MAAM;EACL,SAAS;EACT,SAAS;CACX,CACF;CAEA,OAAO,EACL,OAAO;EACL,IAAI,WAAW,WAAW,MAAM;EAChC,IAAI,WAAW,SAAS,MAAM;EAC9B,OAAO;CACT,EACF;AACF;AAEA,MAAM,wBAAQ,IAAI,IAAgD;AAElE,MAAa,kBAAqB,KAAa,YAA2B;CACxE,IAAI,CAAC,MAAM,IAAI,GAAG,GAChB,MAAM,IAAI,KAAK,gBAAgB,OAAO,CAAC;CAGzC,OAAQ,MAAM,IAAI,GAAG,EAA0C,KAAK;AACtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,sBAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;GACnD,QAAQ,MAAM,UAAU,OAAO,mBAAmB;GAClD;;EAGF,eAAe,OAAO;EAEtB,mBACE,QACA,mBAAmB,0BAA0B,KAC9C;EAED,iBAAiB,OAA0B;;CAG7C,OAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,aAAa,EACxB,iBACA,mBACkB,CAAC,MAAuB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9B,wBAAwB,CAAC;CAE3B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,2BACf,WAAW,qBAAqB,KAAK,CAAC;CAE1C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAAS,MAAM,GAAG;GACnD,QAAQ,MAAM,UAAU,OAAO,kBAAkB;GACjD;EACF;EAEA,eAAe,MAAM;EAErB,mBACE,QACA,mBAAmB,0BAA0B,IAC/C;EAEA,iBAAiB,MAAyB;CAC5C;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext) ?? {};\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;AAIA,MAAM,EAAE,eAAe,SAAS,qBAAqB;;;;AAKrD,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,cAAc,WAAW,sBAAsB,IAAI,EAAE;CAErE,OAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocaleBase.mjs","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext) ?? {};\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;AAIA,MAAM,EAAE,eAAe,SAAS,qBAAqB;;;;AAKrD,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,cAAc,WAAW,qBAAqB,KAAK,CAAC;CAEpE,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.mjs","names":["setLocaleInStorageCore"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'preact/hooks';\n\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = useLocaleStorage;\n"],"mappings":";;;;;;;;AAYA,MAAa,kBAAkB,2BAA2B,qBAAqB;;;;;;AAM/E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,oBAEAA,yBAAuB,QAAQ;CAC7B,GAAG;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,oBAC/B,cAEI,oBAAoB;CAClB,GAAG;CACH;CACD,CAAC,EACJ,CAAC,gBAAgB,CAClB;;;;;;;;AASH,MAAa,kBAAkB"}
1
+ {"version":3,"file":"useLocaleStorage.mjs","names":["setLocaleInStorageCore"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'preact/hooks';\n\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = useLocaleStorage;\n"],"mappings":";;;;;;;;AAYA,MAAa,kBAAkB,2BAA2B,oBAAoB;;;;;;AAM9E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,oBAEAA,yBAAuB,QAAQ;CAC7B,GAAG;CACH;AACF,CAAC;;;;;;AAOH,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,oBAC/B,cAEI,oBAAoB;CAClB,GAAG;CACH;AACF,CAAC,GACH,CAAC,eAAe,CAClB;;;;;;;;AASF,MAAa,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTraduction.mjs","names":[],"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACY;CACZ,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAE1D,OAAO,cACC,eAAe,iBAAiB,OAAO,EAC7C,CAAC,iBAAiB,OAAO,CAC1B"}
1
+ {"version":3,"file":"useTraduction.mjs","names":[],"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACY;CACZ,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,cACC,eAAe,iBAAiB,MAAM,GAC5C,CAAC,iBAAiB,MAAM,CAC1B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !isEnabled ||\n typeof window === 'undefined'\n )\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":";;;;;AAoBA,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;CAC5C,gBAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,aACD,OAAO,WAAW,aAElB;EACF,OAAO,oBAAoB,MAAM,EAAE,6BAA6B;GAC9D,wBAAwB;IACxB;IACD,CAAC,UAAU,CAAC;CAEf,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD,OAAO;CAGT,OACE,oBAAC,qCAAD;EACE,YAAU,KAAK,UAAU,QAAQ;EACjC,kBAAgB;EAEf;EACiC"}
1
+ {"version":3,"file":"ContentSelector.mjs","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !isEnabled ||\n typeof window === 'undefined'\n )\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":";;;;;AAoBA,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;CAC5C,gBAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,aACD,OAAO,WAAW,aAElB;EACF,OAAO,oBAAoB,MAAM,EAAE,6BAA6B;GAC9D,uBAAuB;EACzB,CAAC;CACH,GAAG,CAAC,SAAS,CAAC;CAEd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD,OAAO;CAGT,OACE,oBAAC,qCAAD;EACE,YAAU,KAAK,UAAU,OAAO;EAChC,kBAAgB;EAEf;CACgC;AAEvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorProvider.mjs","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["import type { ComponentChild, FunctionComponent } from 'preact';\nimport { useEditor } from './useEditor';\n\nexport const EditorProvider: FunctionComponent<{\n children?: ComponentChild;\n}> = ({ children }) => {\n useEditor();\n\n return children;\n};\n"],"mappings":";;;AAGA,MAAa,kBAEP,EAAE,eAAe;CACrB,WAAW;CAEX,OAAO"}
1
+ {"version":3,"file":"EditorProvider.mjs","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["import type { ComponentChild, FunctionComponent } from 'preact';\nimport { useEditor } from './useEditor';\n\nexport const EditorProvider: FunctionComponent<{\n children?: ComponentChild;\n}> = ({ children }) => {\n useEditor();\n\n return children;\n};\n"],"mappings":";;;AAGA,MAAa,kBAEP,EAAE,eAAe;CACrB,UAAU;CAEV,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !locale ||\n !managerRef.current\n )\n return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAC1D,MAAM,aAAa,OAAkC,KAAK;CAE1D,gBAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD;EAEF,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;GAClC,WAAW,UAAU;GAErB,IAAI,QAAQ,QAAQ,cAAc,IAAI,OAAiB;IACvD;EAEF,aAAa;GACX,WAAW,UAAU;GACrB,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;IACxD,kBAAkB;KAClB;;IAEH,EAAE,CAAC;CAEN,gBAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,UACD,CAAC,WAAW,SAEZ;EAEF,WAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !locale ||\n !managerRef.current\n )\n return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CACzD,MAAM,aAAa,OAAkC,IAAI;CAEzD,gBAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD;EAEF,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,iBAAiB;GACjC,WAAW,UAAU;GAErB,IAAI,QAAQ,QAAQ,cAAc,IAAI,MAAgB;EACxD,CAAC;EAED,aAAa;GACX,WAAW,UAAU;GACrB,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;IACxD,iBAAiB;GACnB,CAAC;EACH;CACF,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,UACD,CAAC,WAAW,SAEZ;EAEF,WAAW,QAAQ,cAAc,IAAI,MAAgB;CACvD,GAAG,CAAC,MAAM,CAAC;AACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAE1D,OAAO,aACJ,GAAG,SACF,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCompact.mjs","names":[],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,QAAQ,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAE1D,OAAO,aACJ,GAAG,SACF,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCurrency.mjs","names":[],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,SAAS,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,sBAAsB,IAAI,EAAE;CAE1D,QAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useDate.mjs","names":[],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,QAAQ,GAAG,SACT,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC;AACL"}