angular-intlayer 8.0.0-canary.4 → 8.0.0-canary.6

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 (85) hide show
  1. package/README.md +0 -2
  2. package/dist/cjs/UI/ContentSelector.component.cjs +53 -32
  3. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
  4. package/dist/cjs/_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.cjs +11 -0
  5. package/dist/cjs/_virtual/_@oxc-project_runtime@0.110.0/helpers/decorateMetadata.cjs +8 -0
  6. package/dist/cjs/client/index.cjs +6 -1
  7. package/dist/cjs/client/installIntlayer.cjs +9 -2
  8. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionary.cjs +1 -1
  10. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  11. package/dist/cjs/client/useIntlayer.cjs +1 -1
  12. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  13. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +28 -18
  14. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
  15. package/dist/cjs/editor/EditedContentRenderer.component.cjs +21 -10
  16. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
  17. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +16 -6
  18. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
  19. package/dist/cjs/editor/index.cjs +18 -3
  20. package/dist/cjs/editor/useEditedContentRenderer.cjs +9 -2
  21. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  22. package/dist/cjs/getDictionary.cjs +1 -0
  23. package/dist/cjs/getDictionary.cjs.map +1 -1
  24. package/dist/cjs/getIntlayer.cjs +2 -0
  25. package/dist/cjs/getIntlayer.cjs.map +1 -1
  26. package/dist/cjs/index.cjs +15 -2
  27. package/dist/cjs/markdown/index.cjs +7 -1
  28. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +45 -4
  29. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  30. package/dist/cjs/plugins.cjs +101 -3
  31. package/dist/cjs/plugins.cjs.map +1 -1
  32. package/dist/cjs/renderIntlayerNode.cjs +15 -5
  33. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  34. package/dist/esm/UI/ContentSelector.component.mjs +47 -31
  35. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
  36. package/dist/esm/_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs +10 -0
  37. package/dist/esm/_virtual/_@oxc-project_runtime@0.110.0/helpers/decorateMetadata.mjs +7 -0
  38. package/dist/esm/client/installIntlayer.mjs +3 -1
  39. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  40. package/dist/esm/client/useDictionary.mjs +1 -1
  41. package/dist/esm/client/useDictionary.mjs.map +1 -1
  42. package/dist/esm/client/useIntlayer.mjs +1 -1
  43. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  44. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +22 -17
  45. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
  46. package/dist/esm/editor/EditedContentRenderer.component.mjs +15 -9
  47. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
  48. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +10 -5
  49. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
  50. package/dist/esm/editor/useEditedContentRenderer.mjs +3 -1
  51. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  52. package/dist/esm/getDictionary.mjs +2 -1
  53. package/dist/esm/getDictionary.mjs.map +1 -1
  54. package/dist/esm/getIntlayer.mjs +3 -1
  55. package/dist/esm/getIntlayer.mjs.map +1 -1
  56. package/dist/esm/index.mjs +3 -3
  57. package/dist/esm/markdown/index.mjs +2 -2
  58. package/dist/esm/markdown/installIntlayerMarkdown.mjs +39 -4
  59. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  60. package/dist/esm/plugins.mjs +102 -6
  61. package/dist/esm/plugins.mjs.map +1 -1
  62. package/dist/esm/renderIntlayerNode.mjs +15 -5
  63. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  64. package/dist/types/client/installIntlayer.d.ts +2 -2
  65. package/dist/types/client/useDictionary.d.ts +2 -1
  66. package/dist/types/client/useDictionary.d.ts.map +1 -1
  67. package/dist/types/client/useDictionaryAsync.d.ts +2 -1
  68. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  69. package/dist/types/client/useDictionaryDynamic.d.ts +4 -3
  70. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  71. package/dist/types/client/useIntl.d.ts +2 -2
  72. package/dist/types/client/useIntlayer.d.ts +2 -1
  73. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  74. package/dist/types/client/useLocale.d.ts +5 -5
  75. package/dist/types/client/useLocaleStorage.d.ts +5 -5
  76. package/dist/types/editor/EditedContentRenderer.component.d.ts +2 -2
  77. package/dist/types/editor/useCrossURLPathState.d.ts +3 -3
  78. package/dist/types/getIntlayer.d.ts.map +1 -1
  79. package/dist/types/index.d.ts +3 -3
  80. package/dist/types/markdown/index.d.ts +2 -2
  81. package/dist/types/markdown/installIntlayerMarkdown.d.ts +3 -1
  82. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
  83. package/dist/types/plugins.d.ts +38 -10
  84. package/dist/types/plugins.d.ts.map +1 -1
  85. package/package.json +9 -9
@@ -13,12 +13,25 @@ const require_getDictionary = require('./getDictionary.cjs');
13
13
 
14
14
  exports.INTLAYER_MARKDOWN_TOKEN = require_markdown_installIntlayerMarkdown.INTLAYER_MARKDOWN_TOKEN;
15
15
  exports.INTLAYER_TOKEN = require_client_installIntlayer.INTLAYER_TOKEN;
16
- exports.IntlayerMarkdownService = require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
17
- exports.IntlayerProvider = require_client_installIntlayer.IntlayerProvider;
16
+ Object.defineProperty(exports, 'IntlayerMarkdownService', {
17
+ enumerable: true,
18
+ get: function () {
19
+ return require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
20
+ }
21
+ });
22
+ Object.defineProperty(exports, 'IntlayerProvider', {
23
+ enumerable: true,
24
+ get: function () {
25
+ return require_client_installIntlayer.IntlayerProvider;
26
+ }
27
+ });
18
28
  exports.createIntlayerClient = require_client_installIntlayer.createIntlayerClient;
19
29
  exports.createIntlayerMarkdownProvider = require_markdown_installIntlayerMarkdown.createIntlayerMarkdownProvider;
20
30
  exports.getDictionary = require_getDictionary.getDictionary;
21
31
  exports.getIntlayer = require_getIntlayer.getIntlayer;
32
+ exports.htmlPlugin = require_plugins.htmlPlugin;
33
+ exports.htmlRuntime = require_markdown_installIntlayerMarkdown.htmlRuntime;
34
+ exports.insertionPlugin = require_plugins.insertionPlugin;
22
35
  exports.installIntlayer = require_client_installIntlayer.installIntlayer;
23
36
  exports.intlayerNodePlugins = require_plugins.intlayerNodePlugins;
24
37
  exports.isUpdatableNode = require_client_useIntlayer.isUpdatableNode;
@@ -1,6 +1,12 @@
1
1
  const require_markdown_installIntlayerMarkdown = require('./installIntlayerMarkdown.cjs');
2
2
 
3
3
  exports.INTLAYER_MARKDOWN_TOKEN = require_markdown_installIntlayerMarkdown.INTLAYER_MARKDOWN_TOKEN;
4
- exports.IntlayerMarkdownService = require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
4
+ Object.defineProperty(exports, 'IntlayerMarkdownService', {
5
+ enumerable: true,
6
+ get: function () {
7
+ return require_markdown_installIntlayerMarkdown.IntlayerMarkdownService;
8
+ }
9
+ });
5
10
  exports.createIntlayerMarkdownProvider = require_markdown_installIntlayerMarkdown.createIntlayerMarkdownProvider;
11
+ exports.htmlRuntime = require_markdown_installIntlayerMarkdown.htmlRuntime;
6
12
  exports.useMarkdown = require_markdown_installIntlayerMarkdown.useMarkdown;
@@ -1,12 +1,46 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.cjs');
3
+ let _intlayer_core = require("@intlayer/core");
2
4
  let _angular_core = require("@angular/core");
3
5
 
4
6
  //#region src/markdown/installIntlayerMarkdown.ts
5
7
  const INTLAYER_MARKDOWN_TOKEN = new _angular_core.InjectionToken("intlayerMarkdown");
8
+ const htmlRuntime = {
9
+ createElement: (tag, props, ...children) => {
10
+ if (typeof tag !== "string") {
11
+ if (tag === htmlRuntime.Fragment) return children.join("");
12
+ return "";
13
+ }
14
+ const attrs = props ? Object.entries(props).map(([k, v]) => {
15
+ if (k === "key" || v === void 0 || v === null) return "";
16
+ return `${k === "className" ? "class" : k}="${String(v).replace(/"/g, """)}"`;
17
+ }).filter(Boolean).join(" ") : "";
18
+ const childrenStr = children.join("");
19
+ if ([
20
+ "area",
21
+ "base",
22
+ "br",
23
+ "col",
24
+ "embed",
25
+ "hr",
26
+ "img",
27
+ "input",
28
+ "link",
29
+ "meta",
30
+ "param",
31
+ "source",
32
+ "track",
33
+ "wbr"
34
+ ].includes(tag)) return `<${tag} ${attrs} />`;
35
+ return `<${tag}${attrs ? ` ${attrs}` : ""}>${childrenStr}</${tag}>`;
36
+ },
37
+ cloneElement: (element, _props) => element,
38
+ Fragment: Symbol("Fragment")
39
+ };
6
40
  /**
7
- * Default markdown renderer that returns the markdown as is
41
+ * Default markdown renderer that converts markdown to HTML string
8
42
  */
9
- const defaultMarkdownRenderer = (markdown) => markdown;
43
+ const defaultMarkdownRenderer = (markdown) => (0, _intlayer_core.compile)(markdown, { runtime: htmlRuntime });
10
44
  /**
11
45
  * Create IntlayerMarkdown provider configuration
12
46
  */
@@ -14,13 +48,14 @@ const createIntlayerMarkdownProvider = (renderMarkdown = defaultMarkdownRenderer
14
48
  provide: INTLAYER_MARKDOWN_TOKEN,
15
49
  useValue: { renderMarkdown }
16
50
  });
17
- var IntlayerMarkdownService = @((0, _angular_core.Injectable)({ providedIn: "root" })) class {
51
+ let IntlayerMarkdownService = class IntlayerMarkdownService {
18
52
  markdownProvider = (0, _angular_core.inject)(INTLAYER_MARKDOWN_TOKEN, { optional: true });
19
53
  renderMarkdown(markdown, overrides) {
20
54
  if (!this.markdownProvider) return markdown;
21
55
  return this.markdownProvider.renderMarkdown(markdown, overrides);
22
56
  }
23
57
  };
58
+ IntlayerMarkdownService = require_decorate.__decorate([(0, _angular_core.Injectable)({ providedIn: "root" })], IntlayerMarkdownService);
24
59
  /**
25
60
  * Function to inject markdown provider
26
61
  */
@@ -32,7 +67,13 @@ const useMarkdown = () => {
32
67
 
33
68
  //#endregion
34
69
  exports.INTLAYER_MARKDOWN_TOKEN = INTLAYER_MARKDOWN_TOKEN;
35
- exports.IntlayerMarkdownService = IntlayerMarkdownService;
70
+ Object.defineProperty(exports, 'IntlayerMarkdownService', {
71
+ enumerable: true,
72
+ get: function () {
73
+ return IntlayerMarkdownService;
74
+ }
75
+ });
36
76
  exports.createIntlayerMarkdownProvider = createIntlayerMarkdownProvider;
77
+ exports.htmlRuntime = htmlRuntime;
37
78
  exports.useMarkdown = useMarkdown;
38
79
  //# sourceMappingURL=installIntlayerMarkdown.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"installIntlayerMarkdown.cjs","names":["InjectionToken"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n/**\n * Default markdown renderer that returns the markdown as is\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n markdown;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":";;;;AAOA,MAAa,0BACX,IAAIA,6BAAyC,mBAAmB;;;;AAoBlE,MAAM,2BAAmD,aACvD;;;;AAKF,MAAa,kCACX,iBAAyC,6BACrC;CACJ,SAAS;CACT,UAAU,EACR,gBACD;CACF;AAQD,IAAa,0BAHb,gCAAY,EACV,YAAY,QACb,CAAC,EACF,MAAqC;CACnC,AAAQ,6CAA0B,yBAAyB,EACzD,UAAU,MACX,CAAC;CAEF,eAAe,UAAkB,WAA4C;AAC3E,MAAI,CAAC,KAAK,iBACR,QAAO;AAET,SAAO,KAAK,iBAAiB,eAAe,UAAU,UAAU;;;;;;AAOpE,MAAa,oBAA8C;CACzD,MAAM,6CAA0B,yBAAyB,EAAE,UAAU,MAAM,CAAC;AAE5E,KAAI,CAAC,iBACH,QAAO,EACL,gBAAgB,yBACjB;AAGH,QAAO"}
1
+ {"version":3,"file":"installIntlayerMarkdown.cjs","names":["InjectionToken"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\nimport { compile, type MarkdownRuntime } from '@intlayer/core';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n// Minimal runtime to generate HTML strings\nexport const htmlRuntime: MarkdownRuntime = {\n createElement: (tag: string | any, props: any, ...children: any[]) => {\n if (typeof tag !== 'string') {\n // Handle non-string tags if necessary (e.g. components), or fallback to div\n if (tag === htmlRuntime.Fragment) {\n return children.join('');\n }\n return '';\n }\n\n const attrs = props\n ? Object.entries(props)\n .map(([k, v]) => {\n if (k === 'key' || v === undefined || v === null) return '';\n const key = k === 'className' ? 'class' : k;\n return `${key}=\"${String(v).replace(/\"/g, '&quot;')}\"`;\n })\n .filter(Boolean)\n .join(' ')\n : '';\n\n const childrenStr = children.join('');\n const voidTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ];\n\n if (voidTags.includes(tag)) {\n return `<${tag} ${attrs} />`;\n }\n\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n cloneElement: (element: any, _props: any) => element, // Not really supported for strings\n Fragment: Symbol('Fragment'),\n};\n\n/**\n * Default markdown renderer that converts markdown to HTML string\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n compile(markdown, { runtime: htmlRuntime }) as string;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":";;;;;;AAQA,MAAa,0BACX,IAAIA,6BAAyC,mBAAmB;AAkBlE,MAAa,cAA+B;CAC1C,gBAAgB,KAAmB,OAAY,GAAG,aAAoB;AACpE,MAAI,OAAO,QAAQ,UAAU;AAE3B,OAAI,QAAQ,YAAY,SACtB,QAAO,SAAS,KAAK,GAAG;AAE1B,UAAO;;EAGT,MAAM,QAAQ,QACV,OAAO,QAAQ,MAAM,CAClB,KAAK,CAAC,GAAG,OAAO;AACf,OAAI,MAAM,SAAS,MAAM,UAAa,MAAM,KAAM,QAAO;AAEzD,UAAO,GADK,MAAM,cAAc,UAAU,EAC5B,IAAI,OAAO,EAAE,CAAC,QAAQ,MAAM,SAAS,CAAC;IACpD,CACD,OAAO,QAAQ,CACf,KAAK,IAAI,GACZ;EAEJ,MAAM,cAAc,SAAS,KAAK,GAAG;AAkBrC,MAjBiB;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAEY,SAAS,IAAI,CACxB,QAAO,IAAI,IAAI,GAAG,MAAM;AAG1B,SAAO,IAAI,MAAM,QAAQ,IAAI,UAAU,GAAG,GAAG,YAAY,IAAI,IAAI;;CAEnE,eAAe,SAAc,WAAgB;CAC7C,UAAU,OAAO,WAAW;CAC7B;;;;AAKD,MAAM,2BAAmD,yCAC/C,UAAU,EAAE,SAAS,aAAa,CAAC;;;;AAK7C,MAAa,kCACX,iBAAyC,6BACrC;CACJ,SAAS;CACT,UAAU,EACR,gBACD;CACF;AAQM,oCAAM,wBAAwB;CACnC,AAAQ,6CAA0B,yBAAyB,EACzD,UAAU,MACX,CAAC;CAEF,eAAe,UAAkB,WAA4C;AAC3E,MAAI,CAAC,KAAK,iBACR,QAAO;AAET,SAAO,KAAK,iBAAiB,eAAe,UAAU,UAAU;;;qFAZxD,EACV,YAAY,QACb,CAAC;;;;AAiBF,MAAa,oBAA8C;CACzD,MAAM,6CAA0B,yBAAyB,EAAE,UAAU,MAAM,CAAC;AAE5E,KAAI,CAAC,iBACH,QAAO,EACL,gBAAgB,yBACjB;AAGH,QAAO"}
@@ -6,6 +6,29 @@ let _intlayer_core = require("@intlayer/core");
6
6
  let _intlayer_types = require("@intlayer/types");
7
7
 
8
8
  //#region src/plugins.ts
9
+ /** ---------------------------------------------
10
+ * UTILS
11
+ * --------------------------------------------- */
12
+ const createRuntimeWithOverides = (baseRuntime, overrides) => ({
13
+ ...baseRuntime,
14
+ createElement: (tag, props, ...children) => {
15
+ const override = overrides?.[tag];
16
+ if (override) {
17
+ const newProps = {
18
+ ...props,
19
+ ...override
20
+ };
21
+ const originalClass = props?.class || props?.className;
22
+ const overrideClass = override.class || override.className;
23
+ if (originalClass && overrideClass) {
24
+ newProps.class = `${originalClass} ${overrideClass}`;
25
+ newProps.className = void 0;
26
+ }
27
+ return baseRuntime.createElement(tag, newProps, ...children);
28
+ }
29
+ return baseRuntime.createElement(tag, props, ...children);
30
+ }
31
+ });
9
32
  /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
10
33
  const intlayerNodePlugins = {
11
34
  id: "intlayer-node-plugin",
@@ -59,13 +82,25 @@ const markdownStringPlugin = {
59
82
  }),
60
83
  additionalProps: { metadata: metadataNodes }
61
84
  });
62
- const element = render();
63
- return new Proxy(element, { get(target, prop, receiver) {
85
+ const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
64
86
  if (prop === "value") return node;
65
87
  if (prop === "metadata") return metadataNodes;
66
- if (prop === "use") return (components) => render(components);
88
+ if (prop === "toString") return () => {
89
+ return (0, _intlayer_core.compile)(node, { runtime: components ? createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) : require_markdown_installIntlayerMarkdown.htmlRuntime });
90
+ };
91
+ if (prop === Symbol.toPrimitive) return () => {
92
+ return (0, _intlayer_core.compile)(node, { runtime: components ? createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) : require_markdown_installIntlayerMarkdown.htmlRuntime });
93
+ };
94
+ if (prop === "use") return (newComponents) => {
95
+ const mergedComponents = {
96
+ ...components,
97
+ ...newComponents
98
+ };
99
+ return createProxy(render(mergedComponents), mergedComponents);
100
+ };
67
101
  return Reflect.get(target, prop, receiver);
68
102
  } });
103
+ return createProxy(render());
69
104
  }
70
105
  };
71
106
  const markdownPlugin = {
@@ -82,8 +117,71 @@ const markdownPlugin = {
82
117
  });
83
118
  }
84
119
  };
120
+ /** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */
121
+ const htmlPlugin = {
122
+ id: "html-plugin",
123
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types.NodeType.HTML,
124
+ transform: (node, props) => {
125
+ const html = node[_intlayer_types.NodeType.HTML];
126
+ const { plugins, ...rest } = props;
127
+ const render = (userComponents) => require_renderIntlayerNode.renderIntlayerNode({
128
+ ...rest,
129
+ value: html,
130
+ children: () => ({
131
+ component: require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent,
132
+ props: {
133
+ dictionaryKey: rest.dictionaryKey,
134
+ keyPath: rest.keyPath,
135
+ ...userComponents
136
+ },
137
+ children: html
138
+ })
139
+ });
140
+ const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
141
+ if (prop === "value") return html;
142
+ if (prop === "toString") return () => {
143
+ if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
144
+ return (0, _intlayer_core.compile)(html, { runtime: createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) });
145
+ };
146
+ if (prop === Symbol.toPrimitive) return () => {
147
+ if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
148
+ return (0, _intlayer_core.compile)(html, { runtime: createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) });
149
+ };
150
+ if (prop === "use") return (userComponents) => {
151
+ const mergedComponents = {
152
+ ...components,
153
+ ...userComponents
154
+ };
155
+ return createProxy(render(mergedComponents), mergedComponents);
156
+ };
157
+ return Reflect.get(target, prop, receiver);
158
+ } });
159
+ return createProxy(render());
160
+ }
161
+ };
162
+ const insertionPlugin = {
163
+ id: "insertion-plugin",
164
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types.NodeType.Insertion,
165
+ transform: (node, props) => {
166
+ const { plugins, ...rest } = props;
167
+ const render = (args = {}) => {
168
+ let text = node.insertion;
169
+ if (args) Object.entries(args).forEach(([key, value]) => {
170
+ text = text.replace(new RegExp(`{{\\s*${key}\\s*}}`, "g"), String(value));
171
+ });
172
+ return text;
173
+ };
174
+ return require_renderIntlayerNode.renderIntlayerNode({
175
+ ...rest,
176
+ value: render,
177
+ children: render
178
+ });
179
+ }
180
+ };
85
181
 
86
182
  //#endregion
183
+ exports.htmlPlugin = htmlPlugin;
184
+ exports.insertionPlugin = insertionPlugin;
87
185
  exports.intlayerNodePlugins = intlayerNodePlugins;
88
186
  exports.markdownPlugin = markdownPlugin;
89
187
  exports.markdownStringPlugin = markdownStringPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","useMarkdown","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLCond,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\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: ContentSelectorWrapperComponent,\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 ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\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, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? {\n use: (components: any) => any;\n metadata: DeepTransformContent<U>;\n } & any\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T, S, L> = HTMLCond<T, S, L>;\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}\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 = IInterpreterPluginStateCore & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n"],"mappings":";;;;;;;;;AAiCA,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,GAAG,WAChCA,8CAAmB;EACjB,GAAG;EACH,OAAO;EACP,iBAAiB;GACf,WAAWC;GACX,OAAO;IACL,eAAe,KAAK;IACpB,SAAS,KAAK;IACf;GACS;GACX;EACF,CAAC;CACL;;AAWD,MAAa,uBAAgC;CAC3C,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS;CACrC,YAAY,MAAc,OAAO,sBAAsB;EACrD,MAAM,EACJ,SACA,GAAG,SACD;EAoBJ,MAAM,gBAAgB,0DAlBe,KAAK,EAkBQ;GAChD,SAAS,CAjBsB;IAC/B,IAAI;IACJ,YAAY,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;IACH,YAAY,cAAc,UACxBD,8CAAmB;KACjB,GAAG;KACH,OAAO;KACP,UAAU;KACX,CAAC;IACL,CAI2B;GAC1B,eAAe,KAAK;GACpB,SAAS,EAAE;GACZ,CAAC;EAEF,MAAM,UAAU,eACdA,8CAAmB;GACjB,GAAG;GACH,OAAO;GACP,iBAAiB;IACf,WAAWC;IACX,OAAO;KACL,eAAe,KAAK;KACpB,SAAS,KAAK;KACd,GAAG;KACJ;IACD,gBAAgB;KACd,MAAM,EAAE,mBAAmBC,sDAAa;AACxC,YAAO,eAAe,MAAM,WAAW;;IAE1C;GACD,iBAAiB,EACf,UAAU,eACX;GACF,CAAC;EAEJ,MAAM,UAAU,QAAQ;AAExB,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAET,OAAI,SAAS,WACX,QAAO;AAGT,OAAI,SAAS,MACX,SAAQ,eAAqB,OAAO,WAAW;AAGjD,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE7C,CAAC;;CAEL;AAaD,MAAa,iBAA0B;CACrC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAaC,yBAAS;CAC1D,YAAY,MAAuB,OAAO,sBAAsB;EAC9D,MAAM,aAAwB,CAC5B,GAAG,MAAM,SACT,EACE,MAAMA,yBAAS,UAChB,CACF;EAED,MAAM,WAAW,KAAKA,yBAAS;AAE/B,SAAO,kBAAkB,UAAU;GACjC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,EAAE,CAAE;GAC1D,CAAC;;CAEL"}
1
+ {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n compile,\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLContent,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type InsertionContent,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\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: ContentSelectorWrapperComponent,\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 ...props,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\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 runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) 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 [NodeType.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 === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.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 [NodeType.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 === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.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: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\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 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 runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) 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 runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) 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 [NodeType.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 === NodeType.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.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 = IInterpreterPluginStateCore & {\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"],"mappings":"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"}
@@ -6,11 +6,21 @@ const renderIntlayerNode = ({ children, value, additionalProps = {} }) => {
6
6
  if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
7
7
  return Reflect.get(target, prop, receiver);
8
8
  } });
9
- return new Proxy(children, { get(target, prop, receiver) {
10
- if (prop === "value") return value;
11
- if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
12
- return Reflect.get(target, prop, receiver);
13
- } });
9
+ return new Proxy(children, {
10
+ apply(target, thisArg, argumentsList) {
11
+ if (typeof value === "function") return Reflect.apply(value, thisArg, argumentsList);
12
+ return Reflect.apply(target, thisArg, argumentsList);
13
+ },
14
+ get(target, prop, receiver) {
15
+ if (prop === "value") return value;
16
+ if (prop === "toString") return () => {
17
+ return String(value);
18
+ };
19
+ if (prop === Symbol.toPrimitive) return () => value;
20
+ if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
21
+ return Reflect.get(target, prop, receiver);
22
+ }
23
+ });
14
24
  };
15
25
 
16
26
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["export type IntlayerNode<T = string, AdditionalProps = {}> = any & {\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 // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(children, {\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"],"mappings":";;AAUA,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;AAKJ,QAAO,IAAI,MAAM,UAAU,EACzB,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"}
1
+ {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["export type IntlayerNode<T = string, AdditionalProps = {}> = any & {\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 // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(children, {\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":";;AAUA,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;AAKJ,QAAO,IAAI,MAAM,UAAU;EACzB,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,38 +1,18 @@
1
+ import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorateMetadata.mjs";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
1
3
  import { CommonModule } from "@angular/common";
2
4
  import { Component, EventEmitter, HostListener, Input, Output, ViewChild, computed, signal } from "@angular/core";
3
5
 
4
6
  //#region src/UI/ContentSelector.component.ts
7
+ var _ref;
5
8
  const DEFAULT_PRESS_DETECT_DURATION = 250;
6
- var ContentSelectorComponent = @Component({
7
- selector: "app-content-selector",
8
- template: `
9
- <span
10
- #containerRef
11
- role="button"
12
- tabindex="0"
13
- (click)="handleClick($event)"
14
- (mousedown)="handleMouseDown()"
15
- (mouseup)="handleMouseUp()"
16
- (mouseleave)="handleMouseUp()"
17
- (touchstart)="handleMouseDown()"
18
- (touchend)="handleMouseUp()"
19
- (touchcancel)="handleMouseUp()"
20
- (blur)="handleBlur()"
21
- (mouseenter)="onMouseEnter()"
22
- [ngStyle]="getContainerStyle()"
23
- >
24
- <ng-content></ng-content>
25
- </span>
26
- `,
27
- standalone: true,
28
- imports: [CommonModule]
29
- }) class {
30
- @Input() onClickOutside;
31
- @Input() pressDuration;
32
- @Input() isSelecting;
33
- @Output() click = new EventEmitter();
34
- @Output() press = new EventEmitter();
35
- @ViewChild("containerRef", { static: true }) containerRef;
9
+ let ContentSelectorComponent = class ContentSelectorComponent {
10
+ onClickOutside;
11
+ pressDuration;
12
+ isSelecting;
13
+ click = new EventEmitter();
14
+ press = new EventEmitter();
15
+ containerRef;
36
16
  isHovered = signal(false);
37
17
  isSelectingState = signal(false);
38
18
  pressTimerRef = null;
@@ -46,7 +26,7 @@ var ContentSelectorComponent = @Component({
46
26
  ngOnDestroy() {
47
27
  this.clearPressTimer();
48
28
  }
49
- @HostListener("document:mousedown", ["$event"]) onDocumentMouseDown(event) {
29
+ onDocumentMouseDown(event) {
50
30
  this.handleClickOutside(event);
51
31
  }
52
32
  handleOnLongPress() {
@@ -105,6 +85,42 @@ var ContentSelectorComponent = @Component({
105
85
  };
106
86
  }
107
87
  };
88
+ __decorate([Input(), __decorateMetadata("design:type", Function)], ContentSelectorComponent.prototype, "onClickOutside", void 0);
89
+ __decorate([Input(), __decorateMetadata("design:type", Number)], ContentSelectorComponent.prototype, "pressDuration", void 0);
90
+ __decorate([Input(), __decorateMetadata("design:type", Boolean)], ContentSelectorComponent.prototype, "isSelecting", void 0);
91
+ __decorate([Output(), __decorateMetadata("design:type", Object)], ContentSelectorComponent.prototype, "click", void 0);
92
+ __decorate([Output(), __decorateMetadata("design:type", Object)], ContentSelectorComponent.prototype, "press", void 0);
93
+ __decorate([ViewChild("containerRef", { static: true }), __decorateMetadata("design:type", Object)], ContentSelectorComponent.prototype, "containerRef", void 0);
94
+ __decorate([
95
+ HostListener("document:mousedown", ["$event"]),
96
+ __decorateMetadata("design:type", Function),
97
+ __decorateMetadata("design:paramtypes", [typeof (_ref = typeof MouseEvent !== "undefined" && MouseEvent) === "function" ? _ref : Object]),
98
+ __decorateMetadata("design:returntype", void 0)
99
+ ], ContentSelectorComponent.prototype, "onDocumentMouseDown", null);
100
+ ContentSelectorComponent = __decorate([Component({
101
+ selector: "app-content-selector",
102
+ template: `
103
+ <span
104
+ #containerRef
105
+ role="button"
106
+ tabindex="0"
107
+ (click)="handleClick($event)"
108
+ (mousedown)="handleMouseDown()"
109
+ (mouseup)="handleMouseUp()"
110
+ (mouseleave)="handleMouseUp()"
111
+ (touchstart)="handleMouseDown()"
112
+ (touchend)="handleMouseUp()"
113
+ (touchcancel)="handleMouseUp()"
114
+ (blur)="handleBlur()"
115
+ (mouseenter)="onMouseEnter()"
116
+ [ngStyle]="getContainerStyle()"
117
+ >
118
+ <ng-content></ng-content>
119
+ </span>
120
+ `,
121
+ standalone: true,
122
+ imports: [CommonModule]
123
+ })], ContentSelectorComponent);
108
124
 
109
125
  //#endregion
110
126
  export { ContentSelectorComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.component.mjs","names":[],"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n computed,\n type ElementRef,\n EventEmitter,\n HostListener,\n Input,\n type OnDestroy,\n type OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? '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 this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":";;;;AAeA,MAAM,gCAAgC;AA0BtC,IAAa,2BAxBb,CAAC,UAAU;CACT,UAAU;CACV,UAAU;;;;;;;;;;;;;;;;;;;CAmBV,YAAY;CACZ,SAAS,CAAC,aAAa;CACxB,CAAC,CACF,MAAmE;CACjE,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CAET,CAAC,QAAQ,CAAC,QAAQ,IAAI,cAA0B;CAChD,CAAC,QAAQ,CAAC,QAAQ,IAAI,cAAoB;CAE1C,CAAC,UAAU,gBAAgB,EAAE,QAAQ,MAAM,CAAC,CAC5C;CAEA,AAAQ,YAAY,OAAO,MAAM;CACjC,AAAQ,mBAAmB,OAAO,MAAM;CACxC,AAAQ,gBAAsD;CAE9D,AAAiB,sBAAsB,eAC/B,KAAK,eAAe,KAAK,kBAAkB,CAClD;CAED,AAAiB,eAAe,eAAe;AAG7C,SAAO;GACP;CAEF,WAAiB;AACf,OAAK,iBAAiB,IAAI,KAAK,eAAe,MAAM;;CAGtD,cAAoB;AAClB,OAAK,iBAAiB;;CAGxB,CAAC,aAAa,sBAAsB,CAAC,SAAS,CAAC,CAC/C,oBAAoB,OAAyB;AAC3C,OAAK,mBAAmB,MAAM;;CAGhC,AAAQ,oBAA0B;AAChC,OAAK,iBAAiB,IAAI,KAAK;AAC/B,OAAK,MAAM,MAAM;;CAGnB,AAAQ,kBAAwB;AAC9B,OAAK,gBAAgB,iBAAiB;AACpC,QAAK,mBAAmB;KACvB,KAAK,iBAAiB,8BAA8B;;CAGzD,AAAQ,kBAAwB;AAC9B,MAAI,KAAK,eAAe;AACtB,gBAAa,KAAK,cAAc;AAChC,QAAK,gBAAgB;;;CAIzB,kBAAwB;AACtB,OAAK,iBAAiB;AACtB,OAAK,iBAAiB;;CAGxB,gBAAsB;AACpB,OAAK,UAAU,IAAI,MAAM;AACzB,OAAK,iBAAiB;;CAGxB,AAAQ,mBAAmB,OAAyB;AAClD,MACE,KAAK,cAAc,iBACnB,CAAC,KAAK,aAAa,cAAc,SAAS,MAAM,OAAe,EAC/D;AACA,QAAK,iBAAiB,IAAI,MAAM;AAChC,QAAK,kBAAkB;;;CAI3B,YAAY,GAAqB;AAC/B,MAAI,KAAK,qBAAqB,EAAE;AAC9B,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;AAErB,OAAK,MAAM,KAAK,EAAE;;CAGpB,aAAmB;AACjB,OAAK,iBAAiB,IAAI,MAAM;;CAGlC,eAAqB;AACnB,OAAK,UAAU,IAAI,KAAK;;CAG1B,oBAA4C;AAC1C,SAAO;GACL,SAAS,KAAK,cAAc,GAAG,WAAW;GAC1C,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,KAAK,qBAAqB,IAAI,KAAK,WAAW,GAC1C,YACA;GACN,YAAY;GACb"}
1
+ {"version":3,"file":"ContentSelector.component.mjs","names":[],"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n computed,\n type ElementRef,\n EventEmitter,\n HostListener,\n Input,\n type OnDestroy,\n type OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? '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 this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":";;;;;;;AAeA,MAAM,gCAAgC;AA0B/B,qCAAM,yBAAsD;CACjE,AAAS;CACT,AAAS;CACT,AAAS;CAET,AAAU,QAAQ,IAAI,cAA0B;CAChD,AAAU,QAAQ,IAAI,cAAoB;CAE1C,AACA;CAEA,AAAQ,YAAY,OAAO,MAAM;CACjC,AAAQ,mBAAmB,OAAO,MAAM;CACxC,AAAQ,gBAAsD;CAE9D,AAAiB,sBAAsB,eAC/B,KAAK,eAAe,KAAK,kBAAkB,CAClD;CAED,AAAiB,eAAe,eAAe;AAG7C,SAAO;GACP;CAEF,WAAiB;AACf,OAAK,iBAAiB,IAAI,KAAK,eAAe,MAAM;;CAGtD,cAAoB;AAClB,OAAK,iBAAiB;;CAGxB,AACA,oBAAoB,OAAyB;AAC3C,OAAK,mBAAmB,MAAM;;CAGhC,AAAQ,oBAA0B;AAChC,OAAK,iBAAiB,IAAI,KAAK;AAC/B,OAAK,MAAM,MAAM;;CAGnB,AAAQ,kBAAwB;AAC9B,OAAK,gBAAgB,iBAAiB;AACpC,QAAK,mBAAmB;KACvB,KAAK,iBAAiB,8BAA8B;;CAGzD,AAAQ,kBAAwB;AAC9B,MAAI,KAAK,eAAe;AACtB,gBAAa,KAAK,cAAc;AAChC,QAAK,gBAAgB;;;CAIzB,kBAAwB;AACtB,OAAK,iBAAiB;AACtB,OAAK,iBAAiB;;CAGxB,gBAAsB;AACpB,OAAK,UAAU,IAAI,MAAM;AACzB,OAAK,iBAAiB;;CAGxB,AAAQ,mBAAmB,OAAyB;AAClD,MACE,KAAK,cAAc,iBACnB,CAAC,KAAK,aAAa,cAAc,SAAS,MAAM,OAAe,EAC/D;AACA,QAAK,iBAAiB,IAAI,MAAM;AAChC,QAAK,kBAAkB;;;CAI3B,YAAY,GAAqB;AAC/B,MAAI,KAAK,qBAAqB,EAAE;AAC9B,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;AAErB,OAAK,MAAM,KAAK,EAAE;;CAGpB,aAAmB;AACjB,OAAK,iBAAiB,IAAI,MAAM;;CAGlC,eAAqB;AACnB,OAAK,UAAU,IAAI,KAAK;;CAG1B,oBAA4C;AAC1C,SAAO;GACL,SAAS,KAAK,cAAc,GAAG,WAAW;GAC1C,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,KAAK,qBAAqB,IAAI,KAAK,WAAW,GAC1C,YACA;GACN,YAAY;GACb;;;YAzGF,OAAO;YACP,OAAO;YACP,OAAO;YAEP,QAAQ;YACR,QAAQ;YAER,UAAU,gBAAgB,EAAE,QAAQ,MAAM,CAAC;;CAyB3C,aAAa,sBAAsB,CAAC,SAAS,CAAC;;;;;uCAzDhD,UAAU;CACT,UAAU;CACV,UAAU;;;;;;;;;;;;;;;;;;;CAmBV,YAAY;CACZ,SAAS,CAAC,aAAa;CACxB,CAAC"}
@@ -0,0 +1,10 @@
1
+ //#region \0@oxc-project+runtime@0.110.0/helpers/decorate.js
2
+ function __decorate(decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ }
8
+
9
+ //#endregion
10
+ export { __decorate };
@@ -0,0 +1,7 @@
1
+ //#region \0@oxc-project+runtime@0.110.0/helpers/decorateMetadata.js
2
+ function __decorateMetadata(k, v) {
3
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
+ }
5
+
6
+ //#endregion
7
+ export { __decorateMetadata };
@@ -1,3 +1,4 @@
1
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.110.0/helpers/decorate.mjs";
1
2
  import { Injectable, InjectionToken, signal } from "@angular/core";
2
3
  import configuration from "@intlayer/config/built";
3
4
 
@@ -7,7 +8,7 @@ const INTLAYER_TOKEN = new InjectionToken("intlayer");
7
8
  * Singleton instance
8
9
  */
9
10
  let instance = null;
10
- var IntlayerProvider = @Injectable({ providedIn: "root" }) class {
11
+ let IntlayerProvider = class IntlayerProvider {
11
12
  isCookieEnabled = signal(true);
12
13
  _locale = signal(configuration.internationalization?.defaultLocale);
13
14
  locale = this._locale.asReadonly();
@@ -15,6 +16,7 @@ var IntlayerProvider = @Injectable({ providedIn: "root" }) class {
15
16
  this._locale.set(locale);
16
17
  };
17
18
  };
19
+ IntlayerProvider = __decorate([Injectable({ providedIn: "root" })], IntlayerProvider);
18
20
  /**
19
21
  * Create and return a single IntlayerProvider instance
20
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":";;;;AAIA,MAAa,iBAAiB,IAAI,eAAiC,WAAW;;;;AAK9E,IAAI,WAAoC;AAKxC,IAAa,mBAHb,CAAC,WAAW,EACV,YAAY,QACb,CAAC,CACF,MAA8B;CAC5B,kBAAkB,OAAO,KAAK;CAC9B,AAAQ,UAAU,OAChB,cAAc,sBAAsB,cACrC;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;;;;AAO5B,MAAa,wBACX,QACA,kBAAkB,SACG;AACrB,KAAI,SAAU,QAAO;AAErB,YAAW,IAAI,kBAAkB;AAEjC,KAAI,OACF,UAAS,UAAU,OAAO;AAE5B,UAAS,gBAAgB,IAAI,gBAAgB;AAE7C,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,mBACX,QACA,kBAAkB,UACd;CACJ,SAAS;CACT,UAAU,gBAAgB,QAAQ,gBAAgB;CACnD;;;;AAKD,MAAa,mBACX,QACA,kBAAkB,SACf;AAMH,QALe,qBAAqB,QAAQ,gBAAgB"}
1
+ {"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":";;;;;AAIA,MAAa,iBAAiB,IAAI,eAAiC,WAAW;;;;AAK9E,IAAI,WAAoC;AAKjC,6BAAM,iBAAiB;CAC5B,kBAAkB,OAAO,KAAK;CAC9B,AAAQ,UAAU,OAChB,cAAc,sBAAsB,cACrC;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;+BAZ3B,WAAW,EACV,YAAY,QACb,CAAC;;;;AAiBF,MAAa,wBACX,QACA,kBAAkB,SACG;AACrB,KAAI,SAAU,QAAO;AAErB,YAAW,IAAI,kBAAkB;AAEjC,KAAI,OACF,UAAS,UAAU,OAAO;AAE5B,UAAS,gBAAgB,IAAI,gBAAgB;AAE7C,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,mBACX,QACA,kBAAkB,UACd;CACJ,SAAS;CACT,UAAU,gBAAgB,QAAQ,gBAAgB;CACnD;;;;AAKD,MAAa,mBACX,QACA,kBAAkB,SACf;AAMH,QALe,qBAAqB,QAAQ,gBAAgB"}
@@ -6,7 +6,7 @@ import { computed, inject } from "@angular/core";
6
6
  const useDictionary = (dictionary, locale) => {
7
7
  const intlayer = inject(INTLAYER_TOKEN);
8
8
  const localeTarget = computed(() => locale ?? intlayer?.locale());
9
- return computed(() => getDictionary(dictionary, localeTarget()))();
9
+ return computed(() => getDictionary(dictionary, localeTarget()));
10
10
  };
11
11
 
12
12
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { Dictionary, LocalesValues } from '@intlayer/types';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): DeepTransformContent<T['content']> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content() as DeepTransformContent<T['content']>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;AAMA,MAAa,iBACX,YACA,WACuC;CACvC,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAAe,UAAU,UAAU,QAAQ,CAAC;AAOjE,QAJgB,eACd,cAAgC,YAAY,cAAc,CAAC,CAC5D,EAEe"}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary, LocalesValues } from '@intlayer/types';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<T['content']>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;AAMA,MAAa,iBACX,YACA,WAC+C;CAC/C,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAAe,UAAU,UAAU,QAAQ,CAAC;AAOjE,QAJgB,eACd,cAAgC,YAAY,cAAc,CAAC,CAC5D"}
@@ -34,7 +34,7 @@ const useIntlayer = (key, locale) => {
34
34
  const intlayer = inject(INTLAYER_TOKEN);
35
35
  /** which locale should we use right now? */
36
36
  const localeTarget = computed(() => locale ?? intlayer.locale());
37
- return computed(() => getIntlayer(key, localeTarget()))();
37
+ return computed(() => getIntlayer(key, localeTarget()));
38
38
  };
39
39
 
40
40
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\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 * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<DictionaryRegistryContent<T>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content() as DeepTransformContent<DictionaryRegistryContent<T>>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eACX,KACA,WACuD;CACvD,MAAM,WAAW,OAAyB,eAAe;;CAGzD,MAAM,eAAe,eAAe,UAAU,SAAS,QAAQ,CAAC;AAMhE,QAFgB,eAAe,YAAkB,KAAK,cAAc,CAAM,CAAC,EAE3D"}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\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 * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eACX,KACA,WAC+D;CAC/D,MAAM,WAAW,OAAyB,eAAe;;CAGzD,MAAM,eAAe,eAAe,UAAU,SAAS,QAAQ,CAAC;AAMhE,QAFgB,eAAe,YAAkB,KAAK,cAAc,CAAM,CAAC"}