angular-intlayer 9.0.0-canary.9 → 9.0.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 (195) hide show
  1. package/dist/cjs/UI/IntlayerNode.component.cjs +4 -5
  2. package/dist/cjs/UI/IntlayerNode.component.cjs.map +1 -1
  3. package/dist/cjs/_virtual/{_@oxc-project_runtime@0.127.0/helpers → _@oxc-project_runtime@0.140.0/helpers/esm}/decorate.cjs +2 -2
  4. package/dist/{esm/_virtual/_@oxc-project_runtime@0.127.0/helpers/decorateMetadata.mjs → cjs/_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorateMetadata.cjs} +3 -2
  5. package/dist/cjs/analytics/exposureSink.cjs +27 -0
  6. package/dist/cjs/analytics/exposureSink.cjs.map +1 -0
  7. package/dist/cjs/analytics/index.cjs +9 -0
  8. package/dist/cjs/analytics/useAnalytics.cjs +84 -0
  9. package/dist/cjs/analytics/useAnalytics.cjs.map +1 -0
  10. package/dist/cjs/analytics/useConversion.cjs +36 -0
  11. package/dist/cjs/analytics/useConversion.cjs.map +1 -0
  12. package/dist/cjs/analytics/useExperiment.cjs +69 -0
  13. package/dist/cjs/analytics/useExperiment.cjs.map +1 -0
  14. package/dist/cjs/client/installIntlayer.cjs +9 -4
  15. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  16. package/dist/cjs/client/intlayerToken.cjs +0 -1
  17. package/dist/cjs/client/intlayerToken.cjs.map +1 -1
  18. package/dist/cjs/client/useDictionary.cjs +0 -1
  19. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  20. package/dist/cjs/client/useDictionaryAsync.cjs +0 -1
  21. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  22. package/dist/cjs/client/useDictionaryDynamic.cjs +0 -1
  23. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  24. package/dist/cjs/client/useIntlayer.cjs +0 -1
  25. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  26. package/dist/cjs/client/useLoadDynamic.cjs +0 -1
  27. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  28. package/dist/cjs/client/useLocale.cjs +0 -1
  29. package/dist/cjs/client/useLocale.cjs.map +1 -1
  30. package/dist/cjs/client/useLocaleStorage.cjs +0 -1
  31. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  32. package/dist/cjs/client/usePathname.cjs +0 -1
  33. package/dist/cjs/client/usePathname.cjs.map +1 -1
  34. package/dist/cjs/editor/ContentSelector.component.cjs +5 -6
  35. package/dist/cjs/editor/ContentSelector.component.cjs.map +1 -1
  36. package/dist/cjs/editor/EditorProvider.component.cjs +4 -5
  37. package/dist/cjs/editor/EditorProvider.component.cjs.map +1 -1
  38. package/dist/cjs/editor/useEditor.cjs +0 -1
  39. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  40. package/dist/cjs/esbuild/plugin.cjs +19 -12
  41. package/dist/cjs/esbuild/plugin.cjs.map +1 -1
  42. package/dist/cjs/format/useCompact.cjs +0 -1
  43. package/dist/cjs/format/useCompact.cjs.map +1 -1
  44. package/dist/cjs/format/useCurrency.cjs +0 -1
  45. package/dist/cjs/format/useCurrency.cjs.map +1 -1
  46. package/dist/cjs/format/useDate.cjs +0 -1
  47. package/dist/cjs/format/useDate.cjs.map +1 -1
  48. package/dist/cjs/format/useIntl.cjs +0 -1
  49. package/dist/cjs/format/useIntl.cjs.map +1 -1
  50. package/dist/cjs/format/useList.cjs +0 -1
  51. package/dist/cjs/format/useList.cjs.map +1 -1
  52. package/dist/cjs/format/useNumber.cjs +0 -1
  53. package/dist/cjs/format/useNumber.cjs.map +1 -1
  54. package/dist/cjs/format/usePercentage.cjs +0 -1
  55. package/dist/cjs/format/usePercentage.cjs.map +1 -1
  56. package/dist/cjs/format/useRelativeTime.cjs +0 -1
  57. package/dist/cjs/format/useRelativeTime.cjs.map +1 -1
  58. package/dist/cjs/format/useUnit.cjs +0 -1
  59. package/dist/cjs/format/useUnit.cjs.map +1 -1
  60. package/dist/cjs/getDictionary.cjs +0 -1
  61. package/dist/cjs/getDictionary.cjs.map +1 -1
  62. package/dist/cjs/getIntlayer.cjs +0 -1
  63. package/dist/cjs/getIntlayer.cjs.map +1 -1
  64. package/dist/cjs/html/installIntlayerHTML.cjs +2 -3
  65. package/dist/cjs/html/installIntlayerHTML.cjs.map +1 -1
  66. package/dist/cjs/index.cjs +7 -0
  67. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +2 -3
  68. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  69. package/dist/cjs/plugins.cjs +29 -16
  70. package/dist/cjs/plugins.cjs.map +1 -1
  71. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  72. package/dist/cjs/webpack/mergeConfig.cjs +1 -2
  73. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  74. package/dist/esm/UI/IntlayerNode.component.mjs +2 -2
  75. package/dist/esm/UI/IntlayerNode.component.mjs.map +1 -1
  76. package/dist/esm/_virtual/{_@oxc-project_runtime@0.127.0/helpers → _@oxc-project_runtime@0.140.0/helpers/esm}/decorate.mjs +2 -2
  77. package/dist/{cjs/_virtual/_@oxc-project_runtime@0.127.0/helpers/decorateMetadata.cjs → esm/_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorateMetadata.mjs} +2 -3
  78. package/dist/esm/analytics/exposureSink.mjs +24 -0
  79. package/dist/esm/analytics/exposureSink.mjs.map +1 -0
  80. package/dist/esm/analytics/index.mjs +5 -0
  81. package/dist/esm/analytics/useAnalytics.mjs +82 -0
  82. package/dist/esm/analytics/useAnalytics.mjs.map +1 -0
  83. package/dist/esm/analytics/useConversion.mjs +35 -0
  84. package/dist/esm/analytics/useConversion.mjs.map +1 -0
  85. package/dist/esm/analytics/useExperiment.mjs +68 -0
  86. package/dist/esm/analytics/useExperiment.mjs.map +1 -0
  87. package/dist/esm/client/installIntlayer.mjs +9 -4
  88. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  89. package/dist/esm/client/intlayerToken.mjs.map +1 -1
  90. package/dist/esm/client/useDictionary.mjs.map +1 -1
  91. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  92. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  93. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  94. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  95. package/dist/esm/client/useLocale.mjs.map +1 -1
  96. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  97. package/dist/esm/client/usePathname.mjs.map +1 -1
  98. package/dist/esm/editor/ContentSelector.component.mjs +2 -2
  99. package/dist/esm/editor/ContentSelector.component.mjs.map +1 -1
  100. package/dist/esm/editor/EditorProvider.component.mjs +2 -2
  101. package/dist/esm/editor/EditorProvider.component.mjs.map +1 -1
  102. package/dist/esm/editor/useEditor.mjs.map +1 -1
  103. package/dist/esm/esbuild/plugin.mjs +16 -8
  104. package/dist/esm/esbuild/plugin.mjs.map +1 -1
  105. package/dist/esm/format/useCompact.mjs.map +1 -1
  106. package/dist/esm/format/useCurrency.mjs.map +1 -1
  107. package/dist/esm/format/useDate.mjs.map +1 -1
  108. package/dist/esm/format/useIntl.mjs.map +1 -1
  109. package/dist/esm/format/useList.mjs.map +1 -1
  110. package/dist/esm/format/useNumber.mjs.map +1 -1
  111. package/dist/esm/format/usePercentage.mjs.map +1 -1
  112. package/dist/esm/format/useRelativeTime.mjs.map +1 -1
  113. package/dist/esm/format/useUnit.mjs.map +1 -1
  114. package/dist/esm/getDictionary.mjs.map +1 -1
  115. package/dist/esm/getIntlayer.mjs.map +1 -1
  116. package/dist/esm/html/installIntlayerHTML.mjs +1 -1
  117. package/dist/esm/html/installIntlayerHTML.mjs.map +1 -1
  118. package/dist/esm/index.mjs +4 -1
  119. package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -1
  120. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  121. package/dist/esm/plugins.mjs +30 -17
  122. package/dist/esm/plugins.mjs.map +1 -1
  123. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  124. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  125. package/dist/types/UI/IntlayerNode.component.d.ts +0 -1
  126. package/dist/types/UI/IntlayerNode.component.d.ts.map +1 -1
  127. package/dist/types/analytics/exposureSink.d.ts +32 -0
  128. package/dist/types/analytics/exposureSink.d.ts.map +1 -0
  129. package/dist/types/analytics/index.d.ts +4 -0
  130. package/dist/types/analytics/useAnalytics.d.ts +36 -0
  131. package/dist/types/analytics/useAnalytics.d.ts.map +1 -0
  132. package/dist/types/analytics/useConversion.d.ts +38 -0
  133. package/dist/types/analytics/useConversion.d.ts.map +1 -0
  134. package/dist/types/analytics/useExperiment.d.ts +47 -0
  135. package/dist/types/analytics/useExperiment.d.ts.map +1 -0
  136. package/dist/types/client/installIntlayer.d.ts +2 -4
  137. package/dist/types/client/installIntlayer.d.ts.map +1 -1
  138. package/dist/types/client/intlayerToken.d.ts +1 -3
  139. package/dist/types/client/intlayerToken.d.ts.map +1 -1
  140. package/dist/types/client/useDictionary.d.ts +0 -1
  141. package/dist/types/client/useDictionary.d.ts.map +1 -1
  142. package/dist/types/client/useDictionaryAsync.d.ts +1 -3
  143. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  144. package/dist/types/client/useDictionaryDynamic.d.ts +1 -3
  145. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  146. package/dist/types/client/useIntlayer.d.ts +0 -1
  147. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  148. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  149. package/dist/types/client/useLocale.d.ts +1 -5
  150. package/dist/types/client/useLocale.d.ts.map +1 -1
  151. package/dist/types/client/useLocaleStorage.d.ts +5 -7
  152. package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
  153. package/dist/types/client/usePathname.d.ts +0 -1
  154. package/dist/types/client/usePathname.d.ts.map +1 -1
  155. package/dist/types/editor/ContentSelector.component.d.ts.map +1 -1
  156. package/dist/types/editor/EditorProvider.component.d.ts.map +1 -1
  157. package/dist/types/editor/useEditor.d.ts +1 -3
  158. package/dist/types/editor/useEditor.d.ts.map +1 -1
  159. package/dist/types/esbuild/plugin.d.ts +2 -2
  160. package/dist/types/esbuild/plugin.d.ts.map +1 -1
  161. package/dist/types/format/useCompact.d.ts +2 -5
  162. package/dist/types/format/useCompact.d.ts.map +1 -1
  163. package/dist/types/format/useCurrency.d.ts +2 -5
  164. package/dist/types/format/useCurrency.d.ts.map +1 -1
  165. package/dist/types/format/useDate.d.ts +3 -7
  166. package/dist/types/format/useDate.d.ts.map +1 -1
  167. package/dist/types/format/useIntl.d.ts +1 -3
  168. package/dist/types/format/useIntl.d.ts.map +1 -1
  169. package/dist/types/format/useList.d.ts +5 -8
  170. package/dist/types/format/useList.d.ts.map +1 -1
  171. package/dist/types/format/useNumber.d.ts +2 -5
  172. package/dist/types/format/useNumber.d.ts.map +1 -1
  173. package/dist/types/format/usePercentage.d.ts +2 -5
  174. package/dist/types/format/usePercentage.d.ts.map +1 -1
  175. package/dist/types/format/useRelativeTime.d.ts +2 -5
  176. package/dist/types/format/useRelativeTime.d.ts.map +1 -1
  177. package/dist/types/format/useUnit.d.ts +2 -5
  178. package/dist/types/format/useUnit.d.ts.map +1 -1
  179. package/dist/types/getDictionary.d.ts +0 -1
  180. package/dist/types/getDictionary.d.ts.map +1 -1
  181. package/dist/types/getIntlayer.d.ts +0 -1
  182. package/dist/types/getIntlayer.d.ts.map +1 -1
  183. package/dist/types/html/installIntlayerHTML.d.ts +0 -1
  184. package/dist/types/html/installIntlayerHTML.d.ts.map +1 -1
  185. package/dist/types/index.d.ts +7 -2
  186. package/dist/types/index.d.ts.map +1 -1
  187. package/dist/types/markdown/installIntlayerMarkdown.d.ts +0 -1
  188. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
  189. package/dist/types/plugins.d.ts +0 -1
  190. package/dist/types/plugins.d.ts.map +1 -1
  191. package/dist/types/renderIntlayerNode.d.ts +1 -6
  192. package/dist/types/renderIntlayerNode.d.ts.map +1 -1
  193. package/dist/types/webpack/mergeConfig.d.ts +1 -1
  194. package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
  195. package/package.json +15 -12
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.127.0/helpers/decorateMetadata.cjs');
4
- const require_decorate = require('../_virtual/_@oxc-project_runtime@0.127.0/helpers/decorate.cjs');
2
+ const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorateMetadata.cjs');
3
+ const require_decorate = require('../_virtual/_@oxc-project_runtime@0.140.0/helpers/esm/decorate.cjs');
5
4
  let _angular_core = require("@angular/core");
6
5
 
7
6
  //#region src/UI/IntlayerNode.component.ts
@@ -35,8 +34,8 @@ let IntlayerNodeComponent = class IntlayerNodeComponent {
35
34
  }
36
35
  }
37
36
  };
38
- require_decorate.__decorate([(0, _angular_core.Input)(), require_decorateMetadata.__decorateMetadata("design:type", Object)], IntlayerNodeComponent.prototype, "node", void 0);
39
- IntlayerNodeComponent = require_decorate.__decorate([(0, _angular_core.Component)({
37
+ require_decorate.default([(0, _angular_core.Input)(), require_decorateMetadata.default("design:type", Object)], IntlayerNodeComponent.prototype, "node", void 0);
38
+ IntlayerNodeComponent = require_decorate.default([(0, _angular_core.Component)({
40
39
  selector: "intlayer-node",
41
40
  standalone: true,
42
41
  template: `<ng-container #anchor></ng-container>`,
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerNode.component.cjs","names":["ViewContainerRef","ElementRef","ChangeDetectorRef"],"sources":["../../../src/UI/IntlayerNode.component.ts"],"sourcesContent":["import {\n ChangeDetectorRef,\n Component,\n ElementRef,\n Input,\n inject,\n type OnChanges,\n type SimpleChanges,\n type Type,\n ViewContainerRef,\n} from '@angular/core';\n\n/**\n * A transparent host element that renders Intlayer content nodes.\n *\n * `display: contents` makes the `<intlayer-node>` element invisible in the\n * layout — its children appear as if they were direct children of the parent,\n * so placing this component inside `<h1>`, `<p>`, etc. does not break the\n * document structure.\n *\n * ### Usage\n * ```html\n * <h1><intlayer-node [node]=\"content().title\"></intlayer-node></h1>\n * ```\n */\n@Component({\n selector: 'intlayer-node',\n standalone: true,\n // The ng-content slot is the anchor point for ViewContainerRef.\n // Wrapping text renders directly inside this host thanks to display:contents.\n template: `<ng-container #anchor></ng-container>`,\n // display:contents collapses the host box so it is layout-transparent.\n styles: [`:host { display: contents; }`],\n})\nexport class IntlayerNodeComponent implements OnChanges {\n @Input() node: any;\n\n private vcr = inject(ViewContainerRef);\n private elRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private cdr = inject(ChangeDetectorRef);\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['node']) {\n this.render();\n }\n }\n\n private render() {\n // Clear previously created views / text nodes\n this.vcr.clear();\n const host = this.elRef.nativeElement;\n // Remove any raw text nodes we injected directly on previous renders\n host.childNodes.forEach((n) => {\n if (n.nodeType === Node.TEXT_NODE) n.parentNode?.removeChild(n);\n });\n\n if (!this.node) return;\n\n // The node returned by the Angular plugin is a Proxy whose `.children`\n // property is a function returning component info (editor on) or the raw\n // value (editor off).\n const nodeInfo =\n typeof this.node?.children === 'function'\n ? this.node.children()\n : this.node;\n\n if (nodeInfo?.component && typeof nodeInfo.component !== 'string') {\n // ── Editor enabled path: create the ContentSelectorWrapper component ──\n const componentRef = this.vcr.createComponent(\n nodeInfo.component as Type<any>\n );\n\n if (nodeInfo.props) {\n for (const [key, value] of Object.entries(nodeInfo.props)) {\n (componentRef.instance as any)[key] = value;\n }\n }\n\n if (nodeInfo.children) {\n const content = nodeInfo.children;\n if (typeof content === 'string' || typeof content === 'number') {\n componentRef.location.nativeElement.appendChild(\n document.createTextNode(String(content))\n );\n }\n }\n\n this.cdr.markForCheck();\n } else {\n // ── Editor disabled path: render plain text inside the host ──────────\n const text =\n this.node?.value ?? this.node?.toString?.() ?? String(this.node);\n // Append a text node directly inside the host element.\n // Because the host has `display: contents`, this text is layout-wise a\n // direct child of the surrounding element (e.g. <h1>).\n host.appendChild(document.createTextNode(text));\n }\n }\n}\n"],"mappings":";;;;;;;AAkCO,kCAAM,sBAA2C;CACtD,AAAS;CAET,AAAQ,gCAAaA,+BAAiB;CACtC,AAAQ,kCAAwCC,yBAAW;CAC3D,AAAQ,gCAAaC,gCAAkB;CAEvC,YAAY,SAA8B;AACxC,MAAI,QAAQ,QACV,MAAK,QAAQ;;CAIjB,AAAQ,SAAS;AAEf,OAAK,IAAI,OAAO;EAChB,MAAM,OAAO,KAAK,MAAM;AAExB,OAAK,WAAW,SAAS,MAAM;AAC7B,OAAI,EAAE,aAAa,KAAK,UAAW,GAAE,YAAY,YAAY,EAAE;IAC/D;AAEF,MAAI,CAAC,KAAK,KAAM;EAKhB,MAAM,WACJ,OAAO,KAAK,MAAM,aAAa,aAC3B,KAAK,KAAK,UAAU,GACpB,KAAK;AAEX,MAAI,UAAU,aAAa,OAAO,SAAS,cAAc,UAAU;GAEjE,MAAM,eAAe,KAAK,IAAI,gBAC5B,SAAS,UACV;AAED,OAAI,SAAS,MACX,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,MAAM,CACvD,CAAC,aAAa,SAAiB,OAAO;AAI1C,OAAI,SAAS,UAAU;IACrB,MAAM,UAAU,SAAS;AACzB,QAAI,OAAO,YAAY,YAAY,OAAO,YAAY,SACpD,cAAa,SAAS,cAAc,YAClC,SAAS,eAAe,OAAO,QAAQ,CAAC,CACzC;;AAIL,QAAK,IAAI,cAAc;SAClB;GAEL,MAAM,OACJ,KAAK,MAAM,SAAS,KAAK,MAAM,YAAY,IAAI,OAAO,KAAK,KAAK;AAIlE,QAAK,YAAY,SAAS,eAAe,KAAK,CAAC;;;;uDA5D3C;kFAVC;CACT,UAAU;CACV,YAAY;CAGZ,UAAU;CAEV,QAAQ,CAAC,+BAA+B;CACzC,CAAC"}
1
+ {"version":3,"file":"IntlayerNode.component.cjs","names":["ViewContainerRef","ElementRef","ChangeDetectorRef"],"sources":["../../../src/UI/IntlayerNode.component.ts"],"sourcesContent":["import {\n ChangeDetectorRef,\n Component,\n ElementRef,\n Input,\n inject,\n type OnChanges,\n type SimpleChanges,\n type Type,\n ViewContainerRef,\n} from '@angular/core';\n\n/**\n * A transparent host element that renders Intlayer content nodes.\n *\n * `display: contents` makes the `<intlayer-node>` element invisible in the\n * layout — its children appear as if they were direct children of the parent,\n * so placing this component inside `<h1>`, `<p>`, etc. does not break the\n * document structure.\n *\n * ### Usage\n * ```html\n * <h1><intlayer-node [node]=\"content().title\"></intlayer-node></h1>\n * ```\n */\n@Component({\n selector: 'intlayer-node',\n standalone: true,\n // The ng-content slot is the anchor point for ViewContainerRef.\n // Wrapping text renders directly inside this host thanks to display:contents.\n template: `<ng-container #anchor></ng-container>`,\n // display:contents collapses the host box so it is layout-transparent.\n styles: [`:host { display: contents; }`],\n})\nexport class IntlayerNodeComponent implements OnChanges {\n @Input() node: any;\n\n private vcr = inject(ViewContainerRef);\n private elRef = inject<ElementRef<HTMLElement>>(ElementRef);\n private cdr = inject(ChangeDetectorRef);\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['node']) {\n this.render();\n }\n }\n\n private render() {\n // Clear previously created views / text nodes\n this.vcr.clear();\n const host = this.elRef.nativeElement;\n // Remove any raw text nodes we injected directly on previous renders\n host.childNodes.forEach((n) => {\n if (n.nodeType === Node.TEXT_NODE) n.parentNode?.removeChild(n);\n });\n\n if (!this.node) return;\n\n // The node returned by the Angular plugin is a Proxy whose `.children`\n // property is a function returning component info (editor on) or the raw\n // value (editor off).\n const nodeInfo =\n typeof this.node?.children === 'function'\n ? this.node.children()\n : this.node;\n\n if (nodeInfo?.component && typeof nodeInfo.component !== 'string') {\n // ── Editor enabled path: create the ContentSelectorWrapper component ──\n const componentRef = this.vcr.createComponent(\n nodeInfo.component as Type<any>\n );\n\n if (nodeInfo.props) {\n for (const [key, value] of Object.entries(nodeInfo.props)) {\n (componentRef.instance as any)[key] = value;\n }\n }\n\n if (nodeInfo.children) {\n const content = nodeInfo.children;\n if (typeof content === 'string' || typeof content === 'number') {\n componentRef.location.nativeElement.appendChild(\n document.createTextNode(String(content))\n );\n }\n }\n\n this.cdr.markForCheck();\n } else {\n // ── Editor disabled path: render plain text inside the host ──────────\n const text =\n this.node?.value ?? this.node?.toString?.() ?? String(this.node);\n // Append a text node directly inside the host element.\n // Because the host has `display: contents`, this text is layout-wise a\n // direct child of the surrounding element (e.g. <h1>).\n host.appendChild(document.createTextNode(text));\n }\n }\n}\n"],"mappings":";;;;;;AAkCO,IAAM,wBAAN,MAAM,sBAA2C;CACtD,AAAS;CAET,AAAQ,gCAAaA,8BAAgB;CACrC,AAAQ,kCAAwCC,wBAAU;CAC1D,AAAQ,gCAAaC,+BAAiB;CAEtC,YAAY,SAA8B;EACxC,IAAI,QAAQ,SACV,KAAK,OAAO;CAEhB;CAEA,AAAQ,SAAS;EAEf,KAAK,IAAI,MAAM;EACf,MAAM,OAAO,KAAK,MAAM;EAExB,KAAK,WAAW,SAAS,MAAM;GAC7B,IAAI,EAAE,aAAa,KAAK,WAAW,EAAE,YAAY,YAAY,CAAC;EAChE,CAAC;EAED,IAAI,CAAC,KAAK,MAAM;EAKhB,MAAM,WACJ,OAAO,KAAK,MAAM,aAAa,aAC3B,KAAK,KAAK,SAAS,IACnB,KAAK;EAEX,IAAI,UAAU,aAAa,OAAO,SAAS,cAAc,UAAU;GAEjE,MAAM,eAAe,KAAK,IAAI,gBAC5B,SAAS,SACX;GAEA,IAAI,SAAS,OACX,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,KAAK,GACtD,AAAC,aAAa,SAAiB,OAAO;GAI1C,IAAI,SAAS,UAAU;IACrB,MAAM,UAAU,SAAS;IACzB,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,aAAa,SAAS,cAAc,YAClC,SAAS,eAAe,OAAO,OAAO,CAAC,CACzC;GAEJ;GAEA,KAAK,IAAI,aAAa;EACxB,OAAO;GAEL,MAAM,OACJ,KAAK,MAAM,SAAS,KAAK,MAAM,WAAW,KAAK,OAAO,KAAK,IAAI;GAIjE,KAAK,YAAY,SAAS,eAAe,IAAI,CAAC;EAChD;CACF;AACF;mDA/DS;+EAVE;CACT,UAAU;CACV,YAAY;CAGZ,UAAU;CAEV,QAAQ,CAAC,8BAA8B;AACzC,CAAC"}
@@ -1,5 +1,5 @@
1
1
 
2
- //#region \0@oxc-project+runtime@0.127.0/helpers/decorate.js
2
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/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);
@@ -8,4 +8,4 @@ function __decorate(decorators, target, key, desc) {
8
8
  }
9
9
 
10
10
  //#endregion
11
- exports.__decorate = __decorate;
11
+ exports.default = __decorate;
@@ -1,7 +1,8 @@
1
- //#region \0@oxc-project+runtime@0.127.0/helpers/decorateMetadata.js
1
+
2
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateMetadata.js
2
3
  function __decorateMetadata(k, v) {
3
4
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
5
  }
5
6
 
6
7
  //#endregion
7
- export { __decorateMetadata };
8
+ exports.default = __decorateMetadata;
@@ -0,0 +1,27 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/analytics/exposureSink.ts
4
+ let sink = null;
5
+ /**
6
+ * Installs (or clears) the exposure sink. `useAnalytics` sets this once the
7
+ * analytics client has loaded, and clears it on unmount.
8
+ *
9
+ * @param next - The sink to install, or `null` to clear.
10
+ */
11
+ const setExposureSink = (next) => {
12
+ sink = next;
13
+ };
14
+ /**
15
+ * Forwards a content exposure to the installed sink. A cheap null-check when
16
+ * analytics is not running, so it is safe to call from every node resolution.
17
+ *
18
+ * @param input - The node metadata to report.
19
+ */
20
+ const reportExposure = (input) => {
21
+ sink?.(input);
22
+ };
23
+
24
+ //#endregion
25
+ exports.reportExposure = reportExposure;
26
+ exports.setExposureSink = setExposureSink;
27
+ //# sourceMappingURL=exposureSink.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposureSink.cjs","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types/keyPath';\n\n/**\n * Node metadata reported for a content exposure. Kept dependency-free (types\n * only) so the interpreter hot path in `plugins.ts` never statically imports\n * `@intlayer/analytics` — the package stays optional and tree-shakeable.\n */\nexport type ExposureInput = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: string;\n nodeType?: string;\n};\n\n/** Consumer of exposure reports, installed by `useAnalytics` after init. */\nexport type ExposureSink = (input: ExposureInput) => void;\n\nlet sink: ExposureSink | null = null;\n\n/**\n * Installs (or clears) the exposure sink. `useAnalytics` sets this once the\n * analytics client has loaded, and clears it on unmount.\n *\n * @param next - The sink to install, or `null` to clear.\n */\nexport const setExposureSink = (next: ExposureSink | null): void => {\n sink = next;\n};\n\n/**\n * Forwards a content exposure to the installed sink. A cheap null-check when\n * analytics is not running, so it is safe to call from every node resolution.\n *\n * @param input - The node metadata to report.\n */\nexport const reportExposure = (input: ExposureInput): void => {\n sink?.(input);\n};\n"],"mappings":";;;AAiBA,IAAI,OAA4B;;;;;;;AAQhC,MAAa,mBAAmB,SAAoC;CAClE,OAAO;AACT;;;;;;;AAQA,MAAa,kBAAkB,UAA+B;CAC5D,OAAO,KAAK;AACd"}
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_analytics_useAnalytics = require('./useAnalytics.cjs');
3
+ const require_analytics_useConversion = require('./useConversion.cjs');
4
+ const require_analytics_useExperiment = require('./useExperiment.cjs');
5
+
6
+ exports.provideIntlayerAnalytics = require_analytics_useAnalytics.provideIntlayerAnalytics;
7
+ exports.useAnalytics = require_analytics_useAnalytics.useAnalytics;
8
+ exports.useConversion = require_analytics_useConversion.useConversion;
9
+ exports.useExperiment = require_analytics_useExperiment.useExperiment;
@@ -0,0 +1,84 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_analytics_exposureSink = require('./exposureSink.cjs');
3
+ const require_client_intlayerToken = require('../client/intlayerToken.cjs');
4
+ let _angular_core = require("@angular/core");
5
+ let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
6
+
7
+ //#region src/analytics/useAnalytics.ts
8
+ /**
9
+ * Initializes the Intlayer analytics client singleton when analytics is
10
+ * enabled (mirrors {@link useEditor}). Records an initial page view, keeps the
11
+ * client aware of the current locale, and wires node-level content exposures.
12
+ *
13
+ * Must be called inside an Angular injection context (e.g. a component
14
+ * constructor, `provideAppInitializer`, or `runInInjectionContext`).
15
+ *
16
+ * @param client - The IntlayerProvider instance to sync locale from.
17
+ * When omitted the function injects `INTLAYER_TOKEN` from the DI tree,
18
+ * so it still works when called directly from a component.
19
+ */
20
+ const useAnalytics = (client) => {
21
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !_intlayer_analytics_isEnabled.isEnabled) return;
22
+ const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
23
+ const injector = (0, _angular_core.inject)(_angular_core.Injector);
24
+ const resolvedClient = client ?? (0, _angular_core.inject)(require_client_intlayerToken.INTLAYER_TOKEN, { optional: true });
25
+ const analyticsClient = (0, _angular_core.signal)(null);
26
+ let stopped = false;
27
+ let initialized = false;
28
+ import("@intlayer/analytics").then(({ initAnalyticsClient, buildContentExposure }) => {
29
+ if (stopped) return;
30
+ const clientInstance = initAnalyticsClient();
31
+ initialized = true;
32
+ const currentLocale = resolvedClient?.locale();
33
+ if (currentLocale) clientInstance.setLocale(currentLocale);
34
+ clientInstance.trackPageView({ reason: "initial" });
35
+ require_analytics_exposureSink.setExposureSink((input) => clientInstance.trackContentExposure(buildContentExposure(input)));
36
+ analyticsClient.set(clientInstance);
37
+ }).catch(() => {});
38
+ let previousLocale;
39
+ const effectRef = (0, _angular_core.runInInjectionContext)(injector, () => (0, _angular_core.effect)(() => {
40
+ const clientInstance = analyticsClient();
41
+ const locale = resolvedClient?.locale();
42
+ if (!clientInstance || !locale) return;
43
+ if (previousLocale === void 0) {
44
+ previousLocale = locale;
45
+ return;
46
+ }
47
+ if (previousLocale === locale) return;
48
+ previousLocale = locale;
49
+ clientInstance.setLocale(locale);
50
+ clientInstance.trackPageView({ reason: "locale_change" });
51
+ }));
52
+ destroyRef?.onDestroy(() => {
53
+ stopped = true;
54
+ effectRef.destroy();
55
+ analyticsClient.set(null);
56
+ require_analytics_exposureSink.setExposureSink(null);
57
+ import("@intlayer/analytics").then(({ stopAnalyticsClient }) => {
58
+ if (initialized) stopAnalyticsClient();
59
+ }).catch(() => {});
60
+ });
61
+ };
62
+ /**
63
+ * Angular provider that wires `useAnalytics` into the application
64
+ * initialisation phase via `provideAppInitializer`.
65
+ *
66
+ * `provideIntlayer()` already calls this internally, so you only need this
67
+ * function when you want to manage providers individually.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * // app.config.ts
72
+ * import { provideIntlayer, provideIntlayerAnalytics } from 'angular-intlayer';
73
+ *
74
+ * export const appConfig: ApplicationConfig = {
75
+ * providers: [provideIntlayer(), provideIntlayerAnalytics()],
76
+ * };
77
+ * ```
78
+ */
79
+ const provideIntlayerAnalytics = (client) => (0, _angular_core.provideAppInitializer)(() => useAnalytics(client));
80
+
81
+ //#endregion
82
+ exports.provideIntlayerAnalytics = provideIntlayerAnalytics;
83
+ exports.useAnalytics = useAnalytics;
84
+ //# sourceMappingURL=useAnalytics.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnalytics.cjs","names":["isEnabled","DestroyRef","Injector","INTLAYER_TOKEN"],"sources":["../../../src/analytics/useAnalytics.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n provideAppInitializer,\n runInInjectionContext,\n signal,\n} from '@angular/core';\nimport type { AnalyticsClient } from '@intlayer/analytics';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\n// Import from the standalone token file to avoid a circular dependency:\n// installIntlayer.ts → useAnalytics.ts → ../client → installIntlayer.ts\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client/intlayerToken';\nimport { setExposureSink } from './exposureSink';\n\n/**\n * Initializes the Intlayer analytics client singleton when analytics is\n * enabled (mirrors {@link useEditor}). Records an initial page view, keeps the\n * client aware of the current locale, and wires node-level content exposures.\n *\n * Must be called inside an Angular injection context (e.g. a component\n * constructor, `provideAppInitializer`, or `runInInjectionContext`).\n *\n * @param client - The IntlayerProvider instance to sync locale from.\n * When omitted the function injects `INTLAYER_TOKEN` from the DI tree,\n * so it still works when called directly from a component.\n */\nexport const useAnalytics = (client?: IntlayerProvider | null): void => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const injector = inject(Injector);\n\n // Resolve the client: use the passed-in reference or fall back to injection.\n const resolvedClient =\n client ??\n inject<IntlayerProvider>(INTLAYER_TOKEN, { optional: true } as any);\n\n // `analyticsClient` signal is set once the async import resolves.\n // Using a signal lets an `effect()` react to it becoming available.\n const analyticsClient = signal<AnalyticsClient | null>(null);\n\n // Guard: prevents the async callback from acting after the view is destroyed.\n let stopped = false;\n // Tracks whether initAnalyticsClient actually ran, so teardown never calls\n // stopAnalyticsClient for an init that was cancelled — that would decrement\n // the shared reference count once too many.\n let initialized = false;\n\n import('@intlayer/analytics')\n .then(({ initAnalyticsClient, buildContentExposure }) => {\n if (stopped) return;\n\n const clientInstance = initAnalyticsClient();\n initialized = true;\n\n const currentLocale = resolvedClient?.locale();\n if (currentLocale) clientInstance.setLocale(currentLocale);\n clientInstance.trackPageView({ reason: 'initial' });\n\n // Route node-level exposures (from the interpreter plugins) into the\n // client. Serialization happens here, off the hot render path.\n setExposureSink((input) =>\n clientInstance.trackContentExposure(buildContentExposure(input))\n );\n\n analyticsClient.set(clientInstance);\n })\n .catch(() => {\n /* chunk failed to load — analytics stays a no-op */\n });\n\n // Locale switches are a real signal — record them as page views.\n let previousLocale: string | undefined;\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const clientInstance = analyticsClient();\n const locale = resolvedClient?.locale();\n\n if (!clientInstance || !locale) return;\n\n if (previousLocale === undefined) {\n // First run after init — the initial page view already covered it.\n previousLocale = locale;\n return;\n }\n if (previousLocale === locale) return;\n\n previousLocale = locale;\n clientInstance.setLocale(locale);\n clientInstance.trackPageView({ reason: 'locale_change' });\n })\n );\n\n // Tear down on destroy\n destroyRef?.onDestroy(() => {\n stopped = true;\n effectRef.destroy();\n analyticsClient.set(null);\n setExposureSink(null);\n import('@intlayer/analytics')\n .then(({ stopAnalyticsClient }) => {\n if (initialized) stopAnalyticsClient();\n })\n .catch(() => {});\n });\n};\n\n/**\n * Angular provider that wires `useAnalytics` into the application\n * initialisation phase via `provideAppInitializer`.\n *\n * `provideIntlayer()` already calls this internally, so you only need this\n * function when you want to manage providers individually.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { provideIntlayer, provideIntlayerAnalytics } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [provideIntlayer(), provideIntlayerAnalytics()],\n * };\n * ```\n */\nexport const provideIntlayerAnalytics = (client?: IntlayerProvider | null) =>\n provideAppInitializer(() => useAnalytics(client));\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,MAAa,gBAAgB,WAA2C;CACtE,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACA,yCAAW;CAEtE,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,KAAK,CAAC;CACxD,MAAM,qCAAkBC,sBAAQ;CAGhC,MAAM,iBACJ,oCACyBC,6CAAgB,EAAE,UAAU,KAAK,CAAQ;CAIpE,MAAM,4CAAiD,IAAI;CAG3D,IAAI,UAAU;CAId,IAAI,cAAc;CAElB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,qBAAqB,2BAA2B;EACvD,IAAI,SAAS;EAEb,MAAM,iBAAiB,oBAAoB;EAC3C,cAAc;EAEd,MAAM,gBAAgB,gBAAgB,OAAO;EAC7C,IAAI,eAAe,eAAe,UAAU,aAAa;EACzD,eAAe,cAAc,EAAE,QAAQ,UAAU,CAAC;EAIlD,gDAAiB,UACf,eAAe,qBAAqB,qBAAqB,KAAK,CAAC,CACjE;EAEA,gBAAgB,IAAI,cAAc;CACpC,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;CAGH,IAAI;CACJ,MAAM,qDAAkC,gDACzB;EACX,MAAM,iBAAiB,gBAAgB;EACvC,MAAM,SAAS,gBAAgB,OAAO;EAEtC,IAAI,CAAC,kBAAkB,CAAC,QAAQ;EAEhC,IAAI,mBAAmB,QAAW;GAEhC,iBAAiB;GACjB;EACF;EACA,IAAI,mBAAmB,QAAQ;EAE/B,iBAAiB;EACjB,eAAe,UAAU,MAAM;EAC/B,eAAe,cAAc,EAAE,QAAQ,gBAAgB,CAAC;CAC1D,CAAC,CACH;CAGA,YAAY,gBAAgB;EAC1B,UAAU;EACV,UAAU,QAAQ;EAClB,gBAAgB,IAAI,IAAI;EACxB,+CAAgB,IAAI;EACpB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;GACjC,IAAI,aAAa,oBAAoB;EACvC,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CACnB,CAAC;AACH;;;;;;;;;;;;;;;;;;AAmBA,MAAa,4BAA4B,0DACX,aAAa,MAAM,CAAC"}
@@ -0,0 +1,36 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
3
+
4
+ //#region src/analytics/useConversion.ts
5
+ /**
6
+ * Returns a `trackConversion` callback for content A/B testing. Safe to call
7
+ * from any component: it resolves to a no-op when analytics is disabled or the
8
+ * client has not been initialized yet.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * export class CtaComponent {
13
+ * trackConversion = useConversion();
14
+ *
15
+ * onClick() {
16
+ * this.trackConversion({
17
+ * experimentKey: 'homepage-hero',
18
+ * variant: 'b',
19
+ * goal: 'cta_click',
20
+ * });
21
+ * }
22
+ * }
23
+ * ```
24
+ */
25
+ const useConversion = () => {
26
+ return (params) => {
27
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !_intlayer_analytics_isEnabled.isEnabled) return;
28
+ import("@intlayer/analytics").then(({ getGlobalAnalyticsClient }) => {
29
+ getGlobalAnalyticsClient()?.trackConversion(params);
30
+ }).catch(() => {});
31
+ };
32
+ };
33
+
34
+ //#endregion
35
+ exports.useConversion = useConversion;
36
+ //# sourceMappingURL=useConversion.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversion.cjs","names":["isEnabled"],"sources":["../../../src/analytics/useConversion.ts"],"sourcesContent":["import { isEnabled } from '@intlayer/analytics/isEnabled';\n\n/**\n * Parameters describing a conversion to record.\n */\nexport type ConversionParams = {\n /** The experiment this conversion is attributed to. */\n experimentKey: string;\n /** The variant the session was assigned. */\n variant: string;\n /** The goal reached (e.g. `\"signup\"`, `\"cta_click\"`). */\n goal: string;\n /** Optional numeric value (e.g. revenue). */\n value?: number;\n};\n\n/**\n * Returns a `trackConversion` callback for content A/B testing. Safe to call\n * from any component: it resolves to a no-op when analytics is disabled or the\n * client has not been initialized yet.\n *\n * @example\n * ```ts\n * export class CtaComponent {\n * trackConversion = useConversion();\n *\n * onClick() {\n * this.trackConversion({\n * experimentKey: 'homepage-hero',\n * variant: 'b',\n * goal: 'cta_click',\n * });\n * }\n * }\n * ```\n */\nexport const useConversion = () => {\n return (params: ConversionParams): void => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return;\n }\n\n import('@intlayer/analytics')\n .then(({ getGlobalAnalyticsClient }) => {\n getGlobalAnalyticsClient()?.trackConversion(params);\n })\n .catch(() => {});\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,sBAAsB;CACjC,QAAQ,WAAmC;EACzC,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACA,yCACzD;EAGF,OAAO,sBAAsB,CAC1B,MAAM,EAAE,+BAA+B;GACtC,yBAAyB,CAAC,EAAE,gBAAgB,MAAM;EACpD,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CACnB;AACF"}
@@ -0,0 +1,69 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _angular_core = require("@angular/core");
3
+ let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
4
+
5
+ //#region src/analytics/useExperiment.ts
6
+ /**
7
+ * Assigns this session to a variant of an A/B experiment and records the
8
+ * exposure, scoped to `experimentKey`, so the backend can compute per-variant
9
+ * conversion rates against `useConversion` events.
10
+ *
11
+ * Assignment is deterministic per session (no server round-trip, stable across
12
+ * re-mounts). The exposure is recorded once per call.
13
+ *
14
+ * Must be called inside an Angular injection context (e.g. a component
15
+ * constructor or field initializer).
16
+ *
17
+ * @param experimentKey - Unique key identifying the experiment.
18
+ * @param variants - The candidate variant names; the first one is the control.
19
+ * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).
20
+ * @returns The {@link ExperimentState} for this session.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * export class HeroComponent {
25
+ * experiment = useExperiment('homepage-hero', ['a', 'b']);
26
+ * content = useIntlayer('hero');
27
+ * }
28
+ * ```
29
+ */
30
+ const useExperiment = (experimentKey, variants, weights) => {
31
+ const variant = (0, _angular_core.signal)(variants[0] ?? "");
32
+ const isAssigned = (0, _angular_core.signal)(false);
33
+ if (process.env.INTLAYER_ANALYTICS_ENABLED === "false" || !_intlayer_analytics_isEnabled.isEnabled) return {
34
+ variant: variant.asReadonly(),
35
+ isAssigned: isAssigned.asReadonly()
36
+ };
37
+ const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
38
+ let cancelled = false;
39
+ let initialized = false;
40
+ import("@intlayer/analytics").then(({ initAnalyticsClient }) => {
41
+ if (cancelled) return;
42
+ const client = initAnalyticsClient();
43
+ initialized = true;
44
+ const assigned = client.getVariant(experimentKey, variants, weights);
45
+ variant.set(assigned);
46
+ isAssigned.set(true);
47
+ client.trackContentExposure({
48
+ dictionaryKey: experimentKey,
49
+ keyPath: "",
50
+ nodeType: "experiment",
51
+ experimentKey,
52
+ variant: assigned
53
+ });
54
+ }).catch(() => {});
55
+ destroyRef?.onDestroy(() => {
56
+ cancelled = true;
57
+ import("@intlayer/analytics").then(({ stopAnalyticsClient }) => {
58
+ if (initialized) stopAnalyticsClient();
59
+ }).catch(() => {});
60
+ });
61
+ return {
62
+ variant: variant.asReadonly(),
63
+ isAssigned: isAssigned.asReadonly()
64
+ };
65
+ };
66
+
67
+ //#endregion
68
+ exports.useExperiment = useExperiment;
69
+ //# sourceMappingURL=useExperiment.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExperiment.cjs","names":["isEnabled","DestroyRef"],"sources":["../../../src/analytics/useExperiment.ts"],"sourcesContent":["import { DestroyRef, inject, type Signal, signal } from '@angular/core';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\n\n/**\n * The state of an A/B experiment for the current session.\n */\nexport type ExperimentState = {\n /**\n * The variant assigned to this session. Until assignment resolves (and on\n * the server, or when analytics is disabled), this is the first variant —\n * treat the first variant as the control.\n */\n variant: Signal<string>;\n /**\n * `true` once the variant has been deterministically assigned and its\n * exposure recorded. Useful to defer rendering when a flash of the control\n * variant is not acceptable.\n */\n isAssigned: Signal<boolean>;\n};\n\n/**\n * Assigns this session to a variant of an A/B experiment and records the\n * exposure, scoped to `experimentKey`, so the backend can compute per-variant\n * conversion rates against `useConversion` events.\n *\n * Assignment is deterministic per session (no server round-trip, stable across\n * re-mounts). The exposure is recorded once per call.\n *\n * Must be called inside an Angular injection context (e.g. a component\n * constructor or field initializer).\n *\n * @param experimentKey - Unique key identifying the experiment.\n * @param variants - The candidate variant names; the first one is the control.\n * @param weights - Optional relative weights, one per variant (e.g. `[9, 1]`).\n * @returns The {@link ExperimentState} for this session.\n *\n * @example\n * ```ts\n * export class HeroComponent {\n * experiment = useExperiment('homepage-hero', ['a', 'b']);\n * content = useIntlayer('hero');\n * }\n * ```\n */\nexport const useExperiment = (\n experimentKey: string,\n variants: string[],\n weights?: number[]\n): ExperimentState => {\n const variant = signal(variants[0] ?? '');\n const isAssigned = signal(false);\n\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return {\n variant: variant.asReadonly(),\n isAssigned: isAssigned.asReadonly(),\n };\n }\n\n const destroyRef = inject(DestroyRef, { optional: true });\n\n let cancelled = false;\n let initialized = false;\n\n import('@intlayer/analytics')\n .then(({ initAnalyticsClient }) => {\n if (cancelled) return;\n\n // Ref-counted: guarantees a live client even when this call's import\n // resolves before the provider's. Balanced by stop on destroy.\n const client = initAnalyticsClient();\n initialized = true;\n\n const assigned = client.getVariant(experimentKey, variants, weights);\n variant.set(assigned);\n isAssigned.set(true);\n\n // Experiment-level exposure — the denominator of the conversion rate.\n client.trackContentExposure({\n dictionaryKey: experimentKey,\n keyPath: '',\n nodeType: 'experiment',\n experimentKey,\n variant: assigned,\n });\n })\n .catch(() => {\n /* chunk failed to load — control variant stays in place */\n });\n\n destroyRef?.onDestroy(() => {\n cancelled = true;\n import('@intlayer/analytics')\n .then(({ stopAnalyticsClient }) => {\n if (initialized) stopAnalyticsClient();\n })\n .catch(() => {});\n });\n\n return { variant: variant.asReadonly(), isAssigned: isAssigned.asReadonly() };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,iBACX,eACA,UACA,YACoB;CACpB,MAAM,oCAAiB,SAAS,MAAM,EAAE;CACxC,MAAM,uCAAoB,KAAK;CAE/B,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACA,yCACzD,OAAO;EACL,SAAS,QAAQ,WAAW;EAC5B,YAAY,WAAW,WAAW;CACpC;CAGF,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,KAAK,CAAC;CAExD,IAAI,YAAY;CAChB,IAAI,cAAc;CAElB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;EACjC,IAAI,WAAW;EAIf,MAAM,SAAS,oBAAoB;EACnC,cAAc;EAEd,MAAM,WAAW,OAAO,WAAW,eAAe,UAAU,OAAO;EACnE,QAAQ,IAAI,QAAQ;EACpB,WAAW,IAAI,IAAI;EAGnB,OAAO,qBAAqB;GAC1B,eAAe;GACf,SAAS;GACT,UAAU;GACV;GACA,SAAS;EACX,CAAC;CACH,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;CAEH,YAAY,gBAAgB;EAC1B,YAAY;EACZ,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;GACjC,IAAI,aAAa,oBAAoB;EACvC,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CACnB,CAAC;CAED,OAAO;EAAE,SAAS,QAAQ,WAAW;EAAG,YAAY,WAAW,WAAW;CAAE;AAC9E"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_client_intlayerToken = require('./intlayerToken.cjs');
3
+ const require_analytics_useAnalytics = require('../analytics/useAnalytics.cjs');
3
4
  const require_editor_useEditor = require('../editor/useEditor.cjs');
4
5
 
5
6
  //#region src/client/installIntlayer.ts
@@ -28,10 +29,14 @@ const require_editor_useEditor = require('../editor/useEditor.cjs');
28
29
  */
29
30
  const provideIntlayer = (locale, isCookieEnabled = true) => {
30
31
  const client = installIntlayer(locale, isCookieEnabled);
31
- return [{
32
- provide: require_client_intlayerToken.INTLAYER_TOKEN,
33
- useValue: client
34
- }, require_editor_useEditor.provideIntlayerEditor(client)];
32
+ return [
33
+ {
34
+ provide: require_client_intlayerToken.INTLAYER_TOKEN,
35
+ useValue: client
36
+ },
37
+ require_editor_useEditor.provideIntlayerEditor(client),
38
+ require_analytics_useAnalytics.provideIntlayerAnalytics(client)
39
+ ];
35
40
  };
36
41
  /**
37
42
  * Helper to install the Intlayer provider.
@@ -1 +1 @@
1
- {"version":3,"file":"installIntlayer.cjs","names":["INTLAYER_TOKEN","provideIntlayerEditor","createIntlayerClient"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { provideIntlayerEditor } from '../editor/useEditor';\nimport {\n createIntlayerClient,\n INTLAYER_TOKEN,\n IntlayerProvider,\n} from './intlayerToken';\n\nexport { createIntlayerClient, INTLAYER_TOKEN, IntlayerProvider };\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * Registers the Intlayer locale token **and** automatically starts the Intlayer\n * editor client (when the editor is enabled) via `provideAppInitializer`.\n *\n * This is the recommended way to set up Intlayer in `app.config.ts`.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns An array of Angular providers 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: [provideIntlayer()],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = installIntlayer(locale, isCookieEnabled);\n\n return [\n { provide: INTLAYER_TOKEN, useValue: client },\n provideIntlayerEditor(client),\n ];\n};\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n return createIntlayerClient(locale, isCookieEnabled);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,mBACX,QACA,kBAAkB,SACf;CACH,MAAM,SAAS,gBAAgB,QAAQ,gBAAgB;AAEvD,QAAO,CACL;EAAE,SAASA;EAAgB,UAAU;EAAQ,EAC7CC,+CAAsB,OAAO,CAC9B;;;;;AAMH,MAAa,mBACX,QACA,kBAAkB,SACf;AACH,QAAOC,kDAAqB,QAAQ,gBAAgB"}
1
+ {"version":3,"file":"installIntlayer.cjs","names":["INTLAYER_TOKEN","provideIntlayerEditor","provideIntlayerAnalytics","createIntlayerClient"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { provideIntlayerAnalytics } from '../analytics/useAnalytics';\nimport { provideIntlayerEditor } from '../editor/useEditor';\nimport {\n createIntlayerClient,\n INTLAYER_TOKEN,\n IntlayerProvider,\n} from './intlayerToken';\n\nexport { createIntlayerClient, INTLAYER_TOKEN, IntlayerProvider };\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * Registers the Intlayer locale token **and** automatically starts the Intlayer\n * editor client (when the editor is enabled) via `provideAppInitializer`.\n *\n * This is the recommended way to set up Intlayer in `app.config.ts`.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns An array of Angular providers 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: [provideIntlayer()],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = installIntlayer(locale, isCookieEnabled);\n\n return [\n { provide: INTLAYER_TOKEN, useValue: client },\n provideIntlayerEditor(client),\n provideIntlayerAnalytics(client),\n ];\n};\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n return createIntlayerClient(locale, isCookieEnabled);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,mBACX,QACA,kBAAkB,SACf;CACH,MAAM,SAAS,gBAAgB,QAAQ,eAAe;CAEtD,OAAO;EACL;GAAE,SAASA;GAAgB,UAAU;EAAO;EAC5CC,+CAAsB,MAAM;EAC5BC,wDAAyB,MAAM;CACjC;AACF;;;;AAKA,MAAa,mBACX,QACA,kBAAkB,SACf;CACH,OAAOC,kDAAqB,QAAQ,eAAe;AACrD"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _intlayer_config_built = require("@intlayer/config/built");
4
3
  let _angular_core = require("@angular/core");
5
4
  let _intlayer_config_client = require("@intlayer/config/client");
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerToken.cjs","names":["internationalization","InjectionToken"],"sources":["../../../src/client/intlayerToken.ts"],"sourcesContent":["import { InjectionToken, type Signal, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n internationalization.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n constructor() {\n setIntlayerIdentifier();\n }\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\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"],"mappings":";;;;;;;AAKA,IAAa,mBAAb,MAA8B;CAC5B,4CAAyB,KAAK;CAC9B,AAAQ,oCACNA,4CAAqB,cACtB;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,cAAc;AACZ,sDAAuB;;CAGzB,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;AAI5B,MAAa,iBAAiB,IAAIC,6BAAiC,WAAW;;;;AAK9E,IAAI,WAAoC;;;;AAKxC,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"}
1
+ {"version":3,"file":"intlayerToken.cjs","names":["internationalization","InjectionToken"],"sources":["../../../src/client/intlayerToken.ts"],"sourcesContent":["import { InjectionToken, type Signal, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n internationalization.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n constructor() {\n setIntlayerIdentifier();\n }\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\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"],"mappings":";;;;;;AAKA,IAAa,mBAAb,MAA8B;CAC5B,4CAAyB,IAAI;CAC7B,AAAQ,oCACNA,4CAAqB,aACvB;CAEA,AAAS,SAAgC,KAAK,QAAQ,WAAW;CAEjE,cAAc;EACZ,mDAAsB;CACxB;CAEA,aAAa,WAA0B;EACrC,KAAK,QAAQ,IAAI,MAAM;CACzB;AACF;AAEA,MAAa,iBAAiB,IAAIC,6BAAiC,UAAU;;;;AAK7E,IAAI,WAAoC;;;;AAKxC,MAAa,wBACX,QACA,kBAAkB,SACG;CACrB,IAAI,UAAU,OAAO;CAErB,WAAW,IAAI,iBAAiB;CAEhC,IAAI,QACF,SAAS,UAAU,MAAM;CAE3B,SAAS,gBAAgB,IAAI,eAAe;CAE5C,OAAO;AACT"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_getDictionary = require('../getDictionary.cjs');
4
3
  const require_client_intlayerToken = require('./intlayerToken.cjs');
5
4
  let _angular_core = require("@angular/core");
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n Dictionary,\n DictionarySelector,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular hook that transforms a dictionary (or qualified dictionary group)\n * and returns its reactive content for the given locale or selector.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): Signal<\n DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n >\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n const content = computed(() => {\n const currentLocale = intlayer?.locale();\n\n if (isSelector) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getDictionary(\n dictionary,\n (localeOrSelector ?? currentLocale) as A\n ) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,iBAMX,YACA,qBAMG;CACH,MAAM,qCAAoCA,4CAAe;CAEzD,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;AAmBvB,0CAhB+B;EAC7B,MAAM,gBAAgB,UAAU,QAAQ;AAExC,MAAI,WACF,QAAOC,oCAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAGT,SAAOA,oCACL,YACC,oBAAoB,cACtB;GAGW"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type {\n Dictionary,\n DictionarySelector,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular hook that transforms a dictionary (or qualified dictionary group)\n * and returns its reactive content for the given locale or selector.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): Signal<\n DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n >\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n const content = computed(() => {\n const currentLocale = intlayer?.locale();\n\n if (isSelector) {\n return getDictionary(dictionary, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getDictionary(\n dictionary,\n (localeOrSelector ?? currentLocale) as A\n ) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;;;AAqBA,MAAa,iBAMX,YACA,qBAMG;CACH,MAAM,qCAAoCA,2CAAc;CAExD,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;CAmBvB,yCAhB+B;EAC7B,MAAM,gBAAgB,UAAU,OAAO;EAEvC,IAAI,YACF,OAAOC,oCAAc,YAAY;GAC/B,GAAG;GACH,QAAQ,iBAAiB,UAAU;EACrC,CAAM;EAGR,OAAOA,oCACL,YACC,oBAAoB,aACvB;CACF,CAEa;AACf"}
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
4
  const require_client_intlayerToken = require('./intlayerToken.cjs');
6
5
  const require_client_useDictionary = require('./useDictionary.cjs');
7
6
  let _intlayer_config_built = require("@intlayer/config/built");
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.cjs","names":["INTLAYER_TOKEN","internationalization","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <const T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n const dictionary = await (dictionaryPromise as any)[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAa,qBAAqB,OAChC,mBACA,WACG;CACH,MAAM,qCAAoCA,4CAAe;CAEzD,MAAM,iDACE,UAAU,UAAU,QAAQ,IAAIC,4CAAqB,cAC5D;AAID,QAAOC,2CAAc,MAFK,kBAA0B,cAAc,KAAK,EAEtC,cAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["INTLAYER_TOKEN","internationalization","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <const T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n const dictionary = await (dictionaryPromise as any)[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAa,qBAAqB,OAChC,mBACA,WACG;CACH,MAAM,qCAAoCA,2CAAc;CAExD,MAAM,iDACE,UAAU,UAAU,OAAO,KAAKC,4CAAqB,aAC7D;CAIA,OAAOC,2CAAc,MAFK,kBAA0B,aAAa,EAAE,GAAG,GAErC,aAAa,CAAQ;AACxD"}
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
4
  const require_getDictionary = require('../getDictionary.cjs');
6
5
  const require_client_intlayerToken = require('./intlayerToken.cjs');
7
6
  const require_client_useDictionary = require('./useDictionary.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","internationalization","getDictionary","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = LocalesValues,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ??\n intlayer?.locale() ??\n internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n (dictionaryPromise as any)[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,qCAAoCA,4CAAe;AAEzD,KACE,QAAQ,IAAI,iCAAiC,iFACjB,kBAAkB,EAC9C;EACA,MAAM,EAAE,QAAQ,gBAAgB,+EACS,iBAAiB;EAE1D,MAAM,eACJ,kBACA,UAAU,QAAQ,IAClBC,4CAAqB;EAEvB,MAAM,sCAA4B,OAAU;AAE5C,gFAAoC;GAClC,WAAW;GACX,KAAK,OAAO,IAAI;GAChB,QAAQ;GACR;GACA,YAAY,eAAeC,oCAAc,YAAY,aAAa;GACnE,CAAC,CAAC,MAAM,aAAa,UAAU,IAAI,SAAS,CAAC;AAE9C,2CAAsB,WAAW,CAAQ;;CAG3C,MAAM,SACJ,OAAO,qBAAqB,WACvB,mBACD;CAEN,MAAM,iDACE,UAAU,UAAU,QAAQ,IAAID,4CAAqB,cAC5D;AAOD,QAAOE,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAC/B,kBAA0B,cAAc,KAAK,CAGjB,EAAE,cAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","internationalization","getDictionary","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject, signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport {\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * Lazily loads a dictionary (plain or qualified) and returns its reactive\n * content.\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded.\n *\n * If the locale is not provided (directly or through the selector), it will use\n * the locale from the client context.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = LocalesValues,\n>(\n dictionaryPromise:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryPromise)\n ) {\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(localeOrSelector);\n\n const localeTarget =\n selectorLocale ??\n intlayer?.locale() ??\n internationalization.defaultLocale;\n\n const container = signal<unknown>(undefined);\n\n resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryPromise,\n key: String(key),\n locale: localeTarget,\n selector,\n transform: (dictionary) => getDictionary(dictionary, localeTarget),\n }).then((resolved) => container.set(resolved));\n\n return computed(() => container() as any);\n }\n\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n\n const localeTarget = computed(\n () => locale ?? intlayer?.locale() ?? internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n (dictionaryPromise as any)[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,wBAKX,mBAGA,KACA,qBACG;CACH,MAAM,qCAAoCA,2CAAc;CAExD,IACE,QAAQ,IAAI,iCAAiC,iFACjB,iBAAiB,GAC7C;EACA,MAAM,EAAE,QAAQ,gBAAgB,+EACS,gBAAgB;EAEzD,MAAM,eACJ,kBACA,UAAU,OAAO,KACjBC,4CAAqB;EAEvB,MAAM,sCAA4B,MAAS;EAE3C,8EAAoC;GAClC,WAAW;GACX,KAAK,OAAO,GAAG;GACf,QAAQ;GACR;GACA,YAAY,eAAeC,oCAAc,YAAY,YAAY;EACnE,CAAC,CAAC,CAAC,MAAM,aAAa,UAAU,IAAI,QAAQ,CAAC;EAE7C,yCAAsB,UAAU,CAAQ;CAC1C;CAEA,MAAM,SACJ,OAAO,qBAAqB,WACvB,mBACD;CAEN,MAAM,iDACE,UAAU,UAAU,OAAO,KAAKD,4CAAqB,aAC7D;CAOA,OAAOE,2CALYC,6CACjB,GAAG,OAAO,GAAG,EAAE,GAAG,aAAa,KAC9B,kBAA0B,aAAa,EAAE,GAAG,CAGjB,GAAG,aAAa,CAAQ;AACxD"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_getIntlayer = require('../getIntlayer.cjs');
4
3
  const require_client_intlayerToken = require('./intlayerToken.cjs');
5
4
  let _angular_core = require("@angular/core");
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\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 = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n): Signal<\n DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => {\n const currentLocale = intlayer.locale();\n\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getIntlayer(key, (localeOrSelector ?? currentLocale) as A) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;;AAeA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eAIX,KACA,qBAGG;CACH,MAAM,qCAAoCA,4CAAe;CAEzD,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;AAiBvB,0CAb+B;EAC7B,MAAM,gBAAgB,SAAS,QAAQ;AAEvC,MAAI,WACF,QAAOC,gCAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;GACpC,CAAM;AAGT,SAAOA,gCAAY,KAAM,oBAAoB,cAAoB;GAGrD"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\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 = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n): Signal<\n DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>\n> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n const isSelector =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof localeOrSelector === 'object' &&\n localeOrSelector !== null;\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => {\n const currentLocale = intlayer.locale();\n\n if (isSelector) {\n return getIntlayer(key, {\n ...localeOrSelector,\n locale: localeOrSelector.locale ?? currentLocale,\n } as A) as any;\n }\n\n return getIntlayer(key, (localeOrSelector ?? currentLocale) as A) as any;\n });\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;;AAeA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BnC,MAAa,eAIX,KACA,qBAGG;CACH,MAAM,qCAAoCA,2CAAc;CAExD,MAAM,aACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,qBAAqB,YAC5B,qBAAqB;CAiBvB,yCAb+B;EAC7B,MAAM,gBAAgB,SAAS,OAAO;EAEtC,IAAI,YACF,OAAOC,gCAAY,KAAK;GACtB,GAAG;GACH,QAAQ,iBAAiB,UAAU;EACrC,CAAM;EAGR,OAAOA,gCAAY,KAAM,oBAAoB,aAAmB;CAClE,CAEa;AACf"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _angular_core = require("@angular/core");
4
3
 
5
4
  //#region src/client/useLoadDynamic.ts
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,kBACX,KACA,YACM;CAEN,MAAM,QAAkC,eAAuB,WAC9D,AAAC,eAAuB,yBAAS,IAAI,KAAK;CAI3C,MAAM,sCAAmB,EAAE,CAAM;AAEjC,KAAI,CAAC,MAAM,IAAI,IAAI,EAAE;EAEnB,MAAM,IAAI,QAAQ,MAAM,SAAS;AAE/B,aAAU,IAAI,KAAK;AACnB,UAAO;IACP;AACF,QAAM,IAAI,KAAK,EAAE;OAGjB,OAAM,IAAI,IAAI,EAAE,MAAM,SAAS;AAC7B,YAAU,IAAI,KAAK;GACnB;AAIJ,QAAO,WAAW"}
1
+ {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,kBACX,KACA,YACM;CAEN,MAAM,QAAkC,eAAuB,WAC9D,AAAC,eAAuB,yBAAS,IAAI,IAAI;CAI1C,MAAM,sCAAmB,CAAC,CAAM;CAEhC,IAAI,CAAC,MAAM,IAAI,GAAG,GAAG;EAEnB,MAAM,IAAI,QAAQ,MAAM,SAAS;GAE/B,UAAU,IAAI,IAAI;GAClB,OAAO;EACT,CAAC;EACD,MAAM,IAAI,KAAK,CAAC;CAClB,OAEE,MAAM,IAAI,GAAG,CAAC,EAAE,MAAM,SAAS;EAC7B,UAAU,IAAI,IAAI;CACpB,CAAC;CAIH,OAAO,UAAU;AACnB"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_client_intlayerToken = require('./intlayerToken.cjs');
4
3
  const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
5
4
  let _intlayer_config_built = require("@intlayer/config/built");
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["internationalization","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: Signal<DeclaredLocales>;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(\n () => (intlayer?.locale() ?? defaultLocale) as DeclaredLocales\n );\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,EAAE;CAC5B,MAAM,qCAAoCC,4CAAe;CAGzD,MAAM,2CACG,UAAU,QAAQ,IAAI,cAC9B;CACD,MAAM,2DACE,UAAU,iBAAiB,IAAI,KACtC;CAED,MAAM,aAAa,cAA6B;AAC9C,MAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;AACtD,WAAQ,MAAM,UAAU,UAAU,mBAAmB;AACrD;;AAGF,MAAI,SACF,UAAS,UAAU,UAAU;AAE/B,qDACE,WACA,mBAAmB,wBAAwB,IAAI,KAChD;AACD,mBAAiB,UAA6B;;AAGhD,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocale.cjs","names":["internationalization","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: Signal<DeclaredLocales>;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(\n () => (intlayer?.locale() ?? defaultLocale) as DeclaredLocales\n );\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,aAAa,EACxB,iBACA,mBACkB,CAAC,MAAuB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,CAAC;CAC3B,MAAM,qCAAoCC,2CAAc;CAGxD,MAAM,2CACG,UAAU,OAAO,KAAK,aAC/B;CACA,MAAM,2DACE,UAAU,gBAAgB,KAAK,IACvC;CAEA,MAAM,aAAa,cAA6B;EAC9C,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,IAAI,UACF,SAAS,UAAU,SAAS;EAE9B,mDACE,WACA,mBAAmB,uBAAuB,KAAK,IACjD;EACA,iBAAiB,SAA4B;CAC/C;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _intlayer_core_utils = require("@intlayer/core/utils");
4
3
 
5
4
  //#region src/client/useLocaleStorage.ts
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n localeStorageOptions,\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,0CAAqB;;;;;;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
+ {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n localeStorageOptions,\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,yCAAoB;;;;;;AAM9E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,uEAEuB,QAAQ;CAC7B,GAAGA;CACH;AACF,CAAC;;;;;;AAOH,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,kEACX;CAClB,GAAGA;CACH;AACF,CAAC;;;;;;;;AASH,MAAa,mBAAmB,oBAA8B;CAC5D,MAAM,UAAU,iBAAiB,eAAe;CAEhD,OAAO;EACL,cAAc,QAAQ,UAAU;EAChC,iBAAiB,QAAQ;CAC3B;AACF"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _angular_core = require("@angular/core");
4
3
  let _intlayer_core_localization = require("@intlayer/core/localization");
5
4