angular-intlayer 8.5.2 → 8.6.1

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 (66) hide show
  1. package/dist/cjs/UI/IntlayerNode.component.cjs +2 -2
  2. package/dist/cjs/_virtual/{_@oxc-project_runtime@0.115.0 → _@oxc-project_runtime@0.122.0}/helpers/decorate.cjs +1 -1
  3. package/dist/cjs/_virtual/{_@oxc-project_runtime@0.115.0 → _@oxc-project_runtime@0.122.0}/helpers/decorateMetadata.cjs +1 -1
  4. package/dist/cjs/client/useLocaleStorage.cjs +3 -3
  5. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  6. package/dist/cjs/editor/ContentSelector.component.cjs +2 -2
  7. package/dist/cjs/editor/EditorProvider.component.cjs +2 -2
  8. package/dist/cjs/html/installIntlayerHTML.cjs +1 -1
  9. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -1
  10. package/dist/cjs/plugins.cjs +9 -10
  11. package/dist/cjs/plugins.cjs.map +1 -1
  12. package/dist/cjs/renderIntlayerNode.cjs +1 -2
  13. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  14. package/dist/esm/UI/IntlayerNode.component.mjs +2 -2
  15. package/dist/esm/_virtual/{_@oxc-project_runtime@0.115.0 → _@oxc-project_runtime@0.122.0}/helpers/decorate.mjs +1 -1
  16. package/dist/esm/_virtual/{_@oxc-project_runtime@0.115.0 → _@oxc-project_runtime@0.122.0}/helpers/decorateMetadata.mjs +1 -1
  17. package/dist/esm/client/useLocaleStorage.mjs +4 -4
  18. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  19. package/dist/esm/editor/ContentSelector.component.mjs +2 -2
  20. package/dist/esm/editor/EditorProvider.component.mjs +2 -2
  21. package/dist/esm/html/installIntlayerHTML.mjs +1 -1
  22. package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -1
  23. package/dist/esm/plugins.mjs +10 -11
  24. package/dist/esm/plugins.mjs.map +1 -1
  25. package/dist/esm/renderIntlayerNode.mjs +1 -2
  26. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  27. package/dist/types/client/installIntlayer.d.ts +3 -3
  28. package/dist/types/client/installIntlayer.d.ts.map +1 -1
  29. package/dist/types/client/intlayerToken.d.ts +2 -2
  30. package/dist/types/client/intlayerToken.d.ts.map +1 -1
  31. package/dist/types/client/useDictionaryAsync.d.ts +2 -2
  32. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  33. package/dist/types/client/useDictionaryDynamic.d.ts +4 -4
  34. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  35. package/dist/types/client/useLocale.d.ts +5 -5
  36. package/dist/types/client/useLocale.d.ts.map +1 -1
  37. package/dist/types/client/useLocaleStorage.d.ts +5 -5
  38. package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
  39. package/dist/types/editor/useEditor.d.ts +2 -2
  40. package/dist/types/editor/useEditor.d.ts.map +1 -1
  41. package/dist/types/format/useCompact.d.ts +4 -4
  42. package/dist/types/format/useCompact.d.ts.map +1 -1
  43. package/dist/types/format/useCurrency.d.ts +4 -4
  44. package/dist/types/format/useCurrency.d.ts.map +1 -1
  45. package/dist/types/format/useDate.d.ts +6 -6
  46. package/dist/types/format/useDate.d.ts.map +1 -1
  47. package/dist/types/format/useIntl.d.ts +2 -2
  48. package/dist/types/format/useIntl.d.ts.map +1 -1
  49. package/dist/types/format/useList.d.ts +4 -4
  50. package/dist/types/format/useList.d.ts.map +1 -1
  51. package/dist/types/format/useNumber.d.ts +4 -4
  52. package/dist/types/format/useNumber.d.ts.map +1 -1
  53. package/dist/types/format/usePercentage.d.ts +4 -4
  54. package/dist/types/format/usePercentage.d.ts.map +1 -1
  55. package/dist/types/format/useRelativeTime.d.ts +4 -4
  56. package/dist/types/format/useRelativeTime.d.ts.map +1 -1
  57. package/dist/types/format/useUnit.d.ts +4 -4
  58. package/dist/types/format/useUnit.d.ts.map +1 -1
  59. package/dist/types/getDictionary.d.ts +2 -2
  60. package/dist/types/getDictionary.d.ts.map +1 -1
  61. package/dist/types/plugins.d.ts.map +1 -1
  62. package/package.json +10 -10
  63. package/dist/cjs/@intlayer/editor/src/isEnabled.cjs +0 -10
  64. package/dist/cjs/@intlayer/editor/src/isEnabled.cjs.map +0 -1
  65. package/dist/esm/@intlayer/editor/src/isEnabled.mjs +0 -8
  66. package/dist/esm/@intlayer/editor/src/isEnabled.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs');
4
- const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
3
+ const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.cjs');
4
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs');
5
5
  let _angular_core = require("@angular/core");
6
6
 
7
7
  //#region src/UI/IntlayerNode.component.ts
@@ -1,5 +1,5 @@
1
1
 
2
- //#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
2
+ //#region \0@oxc-project+runtime@0.122.0/helpers/decorate.js
3
3
  function __decorate(decorators, target, key, desc) {
4
4
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5
5
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1,5 +1,5 @@
1
1
 
2
- //#region \0@oxc-project+runtime@0.115.0/helpers/decorateMetadata.js
2
+ //#region \0@oxc-project+runtime@0.122.0/helpers/decorateMetadata.js
3
3
  function __decorateMetadata(k, v) {
4
4
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5
5
  }
@@ -10,7 +10,7 @@ let _intlayer_core_utils = require("@intlayer/core/utils");
10
10
  /**
11
11
  * Get the locale cookie
12
12
  */
13
- const localeInStorage = (0, _intlayer_core_utils.getLocaleFromStorage)(_intlayer_core_localization.localeStorageOptions);
13
+ const localeInStorage = (0, _intlayer_core_utils.getLocaleFromStorageClient)(_intlayer_core_localization.localeStorageOptions);
14
14
  /**
15
15
  * @deprecated Use localeInStorage instead
16
16
  *
@@ -20,7 +20,7 @@ const localeCookie = localeInStorage;
20
20
  /**
21
21
  * Set the locale cookie
22
22
  */
23
- const setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorage)(locale, {
23
+ const setLocaleInStorage = (locale, isCookieEnabled) => (0, _intlayer_core_utils.setLocaleInStorageClient)(locale, {
24
24
  ..._intlayer_core_localization.localeStorageOptions,
25
25
  isCookieEnabled
26
26
  });
@@ -33,7 +33,7 @@ const setLocaleCookie = setLocaleInStorage;
33
33
  /**
34
34
  * Hook that provides the locale storage and a function to set it
35
35
  */
36
- const useLocaleStorage = (isCookieEnabled) => (0, _intlayer_core_utils.LocaleStorage)({
36
+ const useLocaleStorage = (isCookieEnabled) => (0, _intlayer_core_utils.LocaleStorageClient)({
37
37
  ..._intlayer_core_localization.localeStorageOptions,
38
38
  isCookieEnabled
39
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(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 LocaleStorage({\n ...localeStorageOptions,\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 = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,iEAAuCA,iDAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,iEAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,4DACjB;CACZ,GAAGA;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
1
+ {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"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';\n\n/**\n * Get the locale cookie\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 LocaleStorageClient({\n ...localeStorageOptions,\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 = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,uEAA6CA,iDAAqB;;;;;;AAM/E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,uEAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,kEACX;CAClB,GAAGA;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs');
4
- const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
3
+ const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.cjs');
4
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs');
5
5
  let _angular_core = require("@angular/core");
6
6
 
7
7
  //#region src/editor/ContentSelector.component.ts
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs');
4
- const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
3
+ const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.cjs');
4
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs');
5
5
  const require_editor_useEditor = require('./useEditor.cjs');
6
6
  let _angular_core = require("@angular/core");
7
7
 
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
3
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs');
4
4
  let _angular_core = require("@angular/core");
5
5
 
6
6
  //#region src/html/installIntlayerHTML.ts
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_decorate = require('../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs');
3
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.cjs');
4
4
  let _intlayer_core_markdown = require("@intlayer/core/markdown");
5
5
  let _angular_core = require("@angular/core");
6
6
 
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_renderIntlayerNode = require('./renderIntlayerNode.cjs');
4
- const require_isEnabled = require('./@intlayer/editor/src/isEnabled.cjs');
5
4
  const require_editor_ContentSelector_component = require('./editor/ContentSelector.component.cjs');
6
5
  let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
7
6
  let _intlayer_config_built = require("@intlayer/config/built");
@@ -39,14 +38,14 @@ const createRuntimeWithOverides = (baseRuntime, overrides) => ({
39
38
  }
40
39
  });
41
40
  /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
42
- const intlayerNodePlugins = {
41
+ const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
43
42
  id: "intlayer-node-plugin",
44
43
  canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
45
44
  transform: (_node, { children, ...rest }) => require_renderIntlayerNode.renderIntlayerNode({
46
45
  ...rest,
47
46
  value: children,
48
47
  children: () => ({
49
- component: require_isEnabled.isEnabled ? require_editor_ContentSelector_component.ContentSelectorWrapperComponent : children,
48
+ component: _intlayer_config_built.default.editor.enabled ? require_editor_ContentSelector_component.ContentSelectorWrapperComponent : children,
50
49
  props: {
51
50
  dictionaryKey: rest.dictionaryKey,
52
51
  keyPath: rest.keyPath
@@ -56,7 +55,7 @@ const intlayerNodePlugins = {
56
55
  })
57
56
  };
58
57
  /** Markdown string plugin. Replaces string node with a component that render the markdown. */
59
- const markdownStringPlugin = {
58
+ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
60
59
  id: "markdown-string-plugin",
61
60
  canHandle: (node) => typeof node === "string",
62
61
  transform: (node, props, deepTransformNode) => {
@@ -77,7 +76,7 @@ const markdownStringPlugin = {
77
76
  const render = (components) => require_renderIntlayerNode.renderIntlayerNode({
78
77
  ...rest,
79
78
  value: node,
80
- children: require_isEnabled.isEnabled ? () => ({
79
+ children: _intlayer_config_built.default.editor.enabled ? () => ({
81
80
  component: require_editor_ContentSelector_component.ContentSelectorWrapperComponent,
82
81
  props: {
83
82
  dictionaryKey: rest.dictionaryKey,
@@ -119,7 +118,7 @@ const markdownStringPlugin = {
119
118
  return createProxy(render());
120
119
  }
121
120
  };
122
- const markdownPlugin = {
121
+ const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
123
122
  id: "markdown-plugin",
124
123
  canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.MARKDOWN,
125
124
  transform: (node, props, deepTransformNode) => {
@@ -134,7 +133,7 @@ const markdownPlugin = {
134
133
  }
135
134
  };
136
135
  /** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */
137
- const htmlPlugin = {
136
+ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
138
137
  id: "html-plugin",
139
138
  canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.HTML,
140
139
  transform: (node, props) => {
@@ -143,7 +142,7 @@ const htmlPlugin = {
143
142
  const render = (userComponents) => require_renderIntlayerNode.renderIntlayerNode({
144
143
  ...rest,
145
144
  value: html,
146
- children: require_isEnabled.isEnabled ? () => ({
145
+ children: _intlayer_config_built.default.editor.enabled ? () => ({
147
146
  component: require_editor_ContentSelector_component.ContentSelectorWrapperComponent,
148
147
  props: {
149
148
  dictionaryKey: rest.dictionaryKey,
@@ -179,7 +178,7 @@ const htmlPlugin = {
179
178
  return createProxy(render());
180
179
  }
181
180
  };
182
- const insertionPlugin = {
181
+ const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? _intlayer_core_interpreter.fallbackPlugin : {
183
182
  id: "insertion-plugin",
184
183
  canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
185
184
  transform: (node, props) => {
@@ -213,7 +212,7 @@ const getPlugins = (locale, fallback = true) => [
213
212
  markdownPlugin,
214
213
  htmlPlugin,
215
214
  insertionPlugin
216
- ];
215
+ ].filter(Boolean);
217
216
 
218
217
  //#endregion
219
218
  exports.getPlugins = getPlugins;
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","isEnabled","ContentSelectorWrapperComponent","compile","NodeTypes","configuration","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport type { MarkdownContent } from '@intlayer/core/markdown';\nimport { compile, getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } 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 { isEnabled } from '../../@intlayer/editor/src/isEnabled';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\nlet _markdownInstall: {\n htmlRuntime: any;\n useMarkdown: () => { renderMarkdown: (s: string, components?: any) => any };\n} | null = null;\nvoid import('./markdown/installIntlayerMarkdown').then((m) => {\n _markdownInstall = m as any;\n});\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\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: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: isEnabled ? ContentSelectorWrapperComponent : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\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: node,\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 ...rest,\n value: node,\n children: isEnabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n })\n : () => {\n const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\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\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: isEnabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n })\n : html,\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node[NodeTypes.INSERTION] as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-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 angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Angular 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 translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":";;;;;;;;;;;;;AA0BA,IAAI,mBAGO;qCACN,2CAA6C,MAAM,MAAM;AAC5D,oBAAmB;EACnB;;;;AAMF,MAAM,6BAA6B,aAAkB,eAAoB;CACvE,GAAG;CACH,gBAAgB,KAAa,OAAY,GAAG,aAAoB;EAC9D,MAAM,WAAW,YAAY;AAE7B,MAAI,UAAU;GACZ,MAAM,WAAW;IAAE,GAAG;IAAO,GAAG;IAAU;GAG1C,MAAM,gBAAgB,OAAO,SAAS,OAAO;GAC7C,MAAM,gBAAgB,SAAS,SAAS,SAAS;AAEjD,OAAI,iBAAiB,eAAe;AAClC,aAAS,QAAQ,GAAG,cAAc,GAAG;AACrC,aAAS,YAAY;;AAGvB,UAAO,YAAY,cAAc,KAAK,UAA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AAwB,UAAU;EAC5C,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,OAAwC,EAAE,KAAK;GAC7D,IAAI,OAAO,KAAKA,yBAAU;AAC1B,OAAI,KACF,QAAO,QAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,WAAW;AAC7C,WAAO,KAAK,QACV,IAAI,OAAO,SAAS,IAAI,SAAS,IAAI,EACrC,OAAO,MAAM,CACd;KACD;AAEJ,UAAO;;AAGT,SAAOJ,8CAAmB;GACxB,GAAG;GACH,OAAO;GACP,UAAU;GACX,CAAC;;CAEL;;;;;AAiCD,MAAa,cACX,QACA,WAAoB,SACN;mDAEZ,UAAUK,+BAAc,qBAAqB,eAC7C,WAAWA,+BAAc,qBAAqB,gBAAgB,OAC/D;CACDC;CACAC;8CACa,UAAUF,+BAAc,qBAAqB,cAAc;CACxEG;CACAC;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"plugins.cjs","names":["fallbackPlugin","renderIntlayerNode","configuration","ContentSelectorWrapperComponent","compile","NodeTypes","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration 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 translationPlugin,\n} from '@intlayer/core/interpreter';\nimport type { MarkdownContent } from '@intlayer/core/markdown';\nimport { compile, getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } 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 { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\nlet _markdownInstall: {\n htmlRuntime: any;\n useMarkdown: () => { renderMarkdown: (s: string, components?: any) => any };\n} | null = null;\nvoid import('./markdown/installIntlayerMarkdown').then((m) => {\n _markdownInstall = m as any;\n});\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins =\n process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === 'false'\n ? fallbackPlugin\n : {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\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: node,\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 ...rest,\n value: node,\n children: configuration.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } =\n _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n })\n : () => {\n const { renderMarkdown } =\n _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...newComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\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\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\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\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: configuration.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n })\n : html,\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = {\n ...components,\n ...userComponents,\n };\n return createProxy(\n render(mergedComponents),\n mergedComponents\n );\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\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) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node[NodeTypes.INSERTION] as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n };\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-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 angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Angular 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 [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n ].filter(Boolean) as Plugins[];\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAI,mBAGO;qCACN,2CAA6C,MAAM,MAAM;AAC5D,oBAAmB;EACnB;;;;AAMF,MAAM,6BAA6B,aAAkB,eAAoB;CACvE,GAAG;CACH,gBAAgB,KAAa,OAAY,GAAG,aAAoB;EAC9D,MAAM,WAAW,YAAY;AAE7B,MAAI,UAAU;GACZ,MAAM,WAAW;IAAE,GAAG;IAAO,GAAG;IAAU;GAG1C,MAAM,gBAAgB,OAAO,SAAS,OAAO;GAC7C,MAAM,gBAAgB,SAAS,SAAS,SAAS;AAEjD,OAAI,iBAAiB,eAAe;AAClC,aAAS,QAAQ,GAAG,cAAc,GAAG;AACrC,aAAS,YAAY;;AAGvB,UAAO,YAAY,cAAc,KAAK,UAAU,GAAG,SAAS;;AAG9D,SAAO,YAAY,cAAc,KAAK,OAAO,GAAG,SAAS;;CAE5D;;AAiBD,MAAa,sBACX,QAAQ,IAAI,qCAAqC,UAC7CA,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAChCC,8CAAmB;EACjB,GAAG;EACH,OAAO;EACP,iBAAiB;GACf,WAAWC,+BAAc,OAAO,UAC5BC,2EACA;GACJ,OAAO;IACL,eAAe,KAAK;IACpB,SAAS,KAAK;IACf;GACS;GACX;EACF,CAAC;CACL;;AAWP,MAAa,uBACX,QAAQ,IAAI,gCAAgC,UACxCH,4CACA;CACE,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS;CACrC,YAAY,MAAc,OAAO,sBAAsB;EACrD,MAAM,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MAAa,cACX,QACA,WAAoB,SAEpB;mDAEI,UAAUC,+BAAc,qBAAqB,eAC7C,WAAWA,+BAAc,qBAAqB,gBAAgB,OAC/D;CACDI;CACAC;8CACa,UAAUL,+BAAc,qBAAqB,cAAc;CACxEM;CACAC;CACA;CACA;CACA;CACA;CACD,CAAC,OAAO,QAAQ"}
@@ -7,8 +7,7 @@ const renderIntlayerNode = ({ children, value, additionalProps = {} }) => {
7
7
  if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
8
8
  return Reflect.get(target, prop, receiver);
9
9
  } });
10
- const target = typeof children === "object" || typeof children === "function" ? children : {};
11
- return new Proxy(target, {
10
+ return new Proxy(typeof children === "object" || typeof children === "function" ? children : {}, {
12
11
  apply(target, thisArg, argumentsList) {
13
12
  if (typeof value === "function") return Reflect.apply(value, thisArg, argumentsList);
14
13
  return Reflect.apply(target, thisArg, argumentsList);
@@ -1 +1 @@
1
- {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string, AdditionalProps = {}> = ResolvedEditor<\n T,\n any\n> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // Proxy target must be an object or function; wrap primitives\n const target =\n typeof children === 'object' || typeof children === 'function'\n ? children\n : ({} as any);\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(target, {\n apply(target, thisArg, argumentsList) {\n if (typeof value === 'function') {\n return Reflect.apply(value as Function, thisArg, argumentsList);\n }\n return Reflect.apply(target as Function, thisArg, argumentsList);\n },\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (prop === 'toString') {\n return () => {\n // console.log('renderIntlayerNode toString called for:', value);\n return String(value);\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;AAeA,MAAa,sBAEX,EACA,UACA,OACA,kBAAkB,EAAE,OAC6B;AAEjD,KAAI,YAAY,KACd,QAAO,IAAI,MAAM,EAAE,EAAS,EAC1B,IAAI,QAAQ,MAAM,UAAU;AAC1B,MAAI,SAAS,QACX,QAAO;AAGT,MACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC;CAIJ,MAAM,SACJ,OAAO,aAAa,YAAY,OAAO,aAAa,aAChD,WACC,EAAE;AAIT,QAAO,IAAI,MAAM,QAAQ;EACvB,MAAM,QAAQ,SAAS,eAAe;AACpC,OAAI,OAAO,UAAU,WACnB,QAAO,QAAQ,MAAM,OAAmB,SAAS,cAAc;AAEjE,UAAO,QAAQ,MAAM,QAAoB,SAAS,cAAc;;EAElE,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,WACX,cAAa;AAEX,WAAO,OAAO,MAAM;;AAIxB,OAAI,SAAS,OAAO,YAClB,cAAa;AAGf,OACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;;EAE7C,CAAC"}
1
+ {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string, AdditionalProps = {}> = ResolvedEditor<\n T,\n any\n> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // Proxy target must be an object or function; wrap primitives\n const target =\n typeof children === 'object' || typeof children === 'function'\n ? children\n : ({} as any);\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(target, {\n apply(target, thisArg, argumentsList) {\n if (typeof value === 'function') {\n return Reflect.apply(value as Function, thisArg, argumentsList);\n }\n return Reflect.apply(target as Function, thisArg, argumentsList);\n },\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (prop === 'toString') {\n return () => {\n // console.log('renderIntlayerNode toString called for:', value);\n return String(value);\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;AAeA,MAAa,sBAEX,EACA,UACA,OACA,kBAAkB,EAAE,OAC6B;AAEjD,KAAI,YAAY,KACd,QAAO,IAAI,MAAM,EAAE,EAAS,EAC1B,IAAI,QAAQ,MAAM,UAAU;AAC1B,MAAI,SAAS,QACX,QAAO;AAGT,MACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC;AAWJ,QAAO,IAAI,MANT,OAAO,aAAa,YAAY,OAAO,aAAa,aAChD,WACC,EAAE,EAIgB;EACvB,MAAM,QAAQ,SAAS,eAAe;AACpC,OAAI,OAAO,UAAU,WACnB,QAAO,QAAQ,MAAM,OAAmB,SAAS,cAAc;AAEjE,UAAO,QAAQ,MAAM,QAAoB,SAAS,cAAc;;EAElE,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,WACX,cAAa;AAEX,WAAO,OAAO,MAAM;;AAIxB,OAAI,SAAS,OAAO,YAClB,cAAa;AAGf,OACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;;EAE7C,CAAC"}
@@ -1,5 +1,5 @@
1
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs";
2
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
1
+ import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.mjs";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.mjs";
3
3
  import { ChangeDetectorRef, Component, ElementRef, Input, ViewContainerRef, inject } from "@angular/core";
4
4
 
5
5
  //#region src/UI/IntlayerNode.component.ts
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
1
+ //#region \0@oxc-project+runtime@0.122.0/helpers/decorate.js
2
2
  function __decorate(decorators, target, key, desc) {
3
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.115.0/helpers/decorateMetadata.js
1
+ //#region \0@oxc-project+runtime@0.122.0/helpers/decorateMetadata.js
2
2
  function __decorateMetadata(k, v) {
3
3
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { localeStorageOptions } from "@intlayer/core/localization";
2
- import { LocaleStorage, getLocaleFromStorage, setLocaleInStorage as setLocaleInStorage$1 } from "@intlayer/core/utils";
2
+ import { LocaleStorageClient, getLocaleFromStorageClient, setLocaleInStorageClient } from "@intlayer/core/utils";
3
3
 
4
4
  //#region src/client/useLocaleStorage.ts
5
5
  /**
@@ -8,7 +8,7 @@ import { LocaleStorage, getLocaleFromStorage, setLocaleInStorage as setLocaleInS
8
8
  /**
9
9
  * Get the locale cookie
10
10
  */
11
- const localeInStorage = getLocaleFromStorage(localeStorageOptions);
11
+ const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);
12
12
  /**
13
13
  * @deprecated Use localeInStorage instead
14
14
  *
@@ -18,7 +18,7 @@ const localeCookie = localeInStorage;
18
18
  /**
19
19
  * Set the locale cookie
20
20
  */
21
- const setLocaleInStorage = (locale, isCookieEnabled) => setLocaleInStorage$1(locale, {
21
+ const setLocaleInStorage = (locale, isCookieEnabled) => setLocaleInStorageClient(locale, {
22
22
  ...localeStorageOptions,
23
23
  isCookieEnabled
24
24
  });
@@ -31,7 +31,7 @@ const setLocaleCookie = setLocaleInStorage;
31
31
  /**
32
32
  * Hook that provides the locale storage and a function to set it
33
33
  */
34
- const useLocaleStorage = (isCookieEnabled) => LocaleStorage({
34
+ const useLocaleStorage = (isCookieEnabled) => LocaleStorageClient({
35
35
  ...localeStorageOptions,
36
36
  isCookieEnabled
37
37
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.mjs","names":["setLocaleInStorageCore"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(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 LocaleStorage({\n ...localeStorageOptions,\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 = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAa,kBAAkB,qBAAqB,qBAAqB;;;;;;AAMzE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,oBAEAA,qBAAuB,QAAQ;CAC7B,GAAG;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,oBAC/B,cAAc;CACZ,GAAG;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
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';\n\n/**\n * Get the locale cookie\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 LocaleStorageClient({\n ...localeStorageOptions,\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 = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;AAcA,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,oBAAoB;CAClB,GAAG;CACH;CACD,CAAC;;;;;;;;AASJ,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,gBAAgB;AAEjD,QAAO;EACL,cAAc,QAAQ,WAAW;EACjC,iBAAiB,QAAQ;EAC1B"}
@@ -1,5 +1,5 @@
1
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs";
2
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
1
+ import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.mjs";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.mjs";
3
3
  import { CUSTOM_ELEMENTS_SCHEMA, Component, Input } from "@angular/core";
4
4
 
5
5
  //#region src/editor/ContentSelector.component.ts
@@ -1,5 +1,5 @@
1
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs";
2
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
1
+ import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.mjs";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.mjs";
3
3
  import { useEditor } from "./useEditor.mjs";
4
4
  import { Component } from "@angular/core";
5
5
 
@@ -1,4 +1,4 @@
1
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
1
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.mjs";
2
2
  import { Injectable, InjectionToken, inject } from "@angular/core";
3
3
 
4
4
  //#region src/html/installIntlayerHTML.ts
@@ -1,4 +1,4 @@
1
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
1
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.mjs";
2
2
  import { compile } from "@intlayer/core/markdown";
3
3
  import { Injectable, InjectionToken, inject } from "@angular/core";
4
4
 
@@ -1,7 +1,6 @@
1
1
  import { renderIntlayerNode } from "./renderIntlayerNode.mjs";
2
- import { isEnabled } from "./@intlayer/editor/src/isEnabled.mjs";
3
2
  import { ContentSelectorWrapperComponent } from "./editor/ContentSelector.component.mjs";
4
- import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, nestedPlugin, translationPlugin } from "@intlayer/core/interpreter";
3
+ import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, translationPlugin } from "@intlayer/core/interpreter";
5
4
  import configuration from "@intlayer/config/built";
6
5
  import { compile, getMarkdownMetadata } from "@intlayer/core/markdown";
7
6
  import * as NodeTypes from "@intlayer/types/nodeType";
@@ -35,14 +34,14 @@ const createRuntimeWithOverides = (baseRuntime, overrides) => ({
35
34
  }
36
35
  });
37
36
  /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
38
- const intlayerNodePlugins = {
37
+ const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === "false" ? fallbackPlugin : {
39
38
  id: "intlayer-node-plugin",
40
39
  canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
41
40
  transform: (_node, { children, ...rest }) => renderIntlayerNode({
42
41
  ...rest,
43
42
  value: children,
44
43
  children: () => ({
45
- component: isEnabled ? ContentSelectorWrapperComponent : children,
44
+ component: configuration.editor.enabled ? ContentSelectorWrapperComponent : children,
46
45
  props: {
47
46
  dictionaryKey: rest.dictionaryKey,
48
47
  keyPath: rest.keyPath
@@ -52,7 +51,7 @@ const intlayerNodePlugins = {
52
51
  })
53
52
  };
54
53
  /** Markdown string plugin. Replaces string node with a component that render the markdown. */
55
- const markdownStringPlugin = {
54
+ const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
56
55
  id: "markdown-string-plugin",
57
56
  canHandle: (node) => typeof node === "string",
58
57
  transform: (node, props, deepTransformNode) => {
@@ -73,7 +72,7 @@ const markdownStringPlugin = {
73
72
  const render = (components) => renderIntlayerNode({
74
73
  ...rest,
75
74
  value: node,
76
- children: isEnabled ? () => ({
75
+ children: configuration.editor.enabled ? () => ({
77
76
  component: ContentSelectorWrapperComponent,
78
77
  props: {
79
78
  dictionaryKey: rest.dictionaryKey,
@@ -115,7 +114,7 @@ const markdownStringPlugin = {
115
114
  return createProxy(render());
116
115
  }
117
116
  };
118
- const markdownPlugin = {
117
+ const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? fallbackPlugin : {
119
118
  id: "markdown-plugin",
120
119
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.MARKDOWN,
121
120
  transform: (node, props, deepTransformNode) => {
@@ -130,7 +129,7 @@ const markdownPlugin = {
130
129
  }
131
130
  };
132
131
  /** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */
133
- const htmlPlugin = {
132
+ const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? fallbackPlugin : {
134
133
  id: "html-plugin",
135
134
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.HTML,
136
135
  transform: (node, props) => {
@@ -139,7 +138,7 @@ const htmlPlugin = {
139
138
  const render = (userComponents) => renderIntlayerNode({
140
139
  ...rest,
141
140
  value: html,
142
- children: isEnabled ? () => ({
141
+ children: configuration.editor.enabled ? () => ({
143
142
  component: ContentSelectorWrapperComponent,
144
143
  props: {
145
144
  dictionaryKey: rest.dictionaryKey,
@@ -175,7 +174,7 @@ const htmlPlugin = {
175
174
  return createProxy(render());
176
175
  }
177
176
  };
178
- const insertionPlugin = {
177
+ const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? fallbackPlugin : {
179
178
  id: "insertion-plugin",
180
179
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
181
180
  transform: (node, props) => {
@@ -209,7 +208,7 @@ const getPlugins = (locale, fallback = true) => [
209
208
  markdownPlugin,
210
209
  htmlPlugin,
211
210
  insertionPlugin
212
- ];
211
+ ].filter(Boolean);
213
212
 
214
213
  //#endregion
215
214
  export { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin };