angular-intlayer 8.4.4 → 8.4.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 (146) hide show
  1. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs +11 -0
  2. package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs +8 -0
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/cjs/client/index.cjs +28 -1
  5. package/dist/cjs/client/installIntlayer.cjs +77 -1
  6. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionary.cjs +15 -1
  8. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryAsync.cjs +24 -1
  10. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +25 -1
  12. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  13. package/dist/cjs/client/useIntl.cjs +40 -1
  14. package/dist/cjs/client/useIntl.cjs.map +1 -1
  15. package/dist/cjs/client/useIntlayer.cjs +44 -1
  16. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  17. package/dist/cjs/client/useLoadDynamic.cjs +28 -1
  18. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  19. package/dist/cjs/client/useLocale.cjs +60 -1
  20. package/dist/cjs/client/useLocale.cjs.map +1 -1
  21. package/dist/cjs/client/useLocaleStorage.cjs +61 -1
  22. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  23. package/dist/cjs/editor/ContentSelector.component.cjs +38 -1
  24. package/dist/cjs/editor/ContentSelector.component.cjs.map +1 -0
  25. package/dist/cjs/editor/useEditor.cjs +31 -1
  26. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  27. package/dist/cjs/getDictionary.cjs +10 -1
  28. package/dist/cjs/getDictionary.cjs.map +1 -1
  29. package/dist/cjs/getIntlayer.cjs +10 -1
  30. package/dist/cjs/getIntlayer.cjs.map +1 -1
  31. package/dist/cjs/index.cjs +50 -1
  32. package/dist/cjs/markdown/index.cjs +13 -1
  33. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +79 -1
  34. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  35. package/dist/cjs/plugins.cjs +232 -1
  36. package/dist/cjs/plugins.cjs.map +1 -1
  37. package/dist/cjs/renderIntlayerNode.cjs +28 -1
  38. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  39. package/dist/cjs/webpack/index.cjs +4 -1
  40. package/dist/cjs/webpack/mergeConfig.cjs +45 -1
  41. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  42. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs +10 -0
  43. package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs +7 -0
  44. package/dist/esm/client/index.mjs +10 -1
  45. package/dist/esm/client/installIntlayer.mjs +65 -1
  46. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  47. package/dist/esm/client/useDictionary.mjs +13 -1
  48. package/dist/esm/client/useDictionary.mjs.map +1 -1
  49. package/dist/esm/client/useDictionaryAsync.mjs +21 -1
  50. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  51. package/dist/esm/client/useDictionaryDynamic.mjs +22 -1
  52. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  53. package/dist/esm/client/useIntl.mjs +38 -1
  54. package/dist/esm/client/useIntl.mjs.map +1 -1
  55. package/dist/esm/client/useIntlayer.mjs +41 -1
  56. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  57. package/dist/esm/client/useLoadDynamic.mjs +26 -1
  58. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  59. package/dist/esm/client/useLocale.mjs +57 -1
  60. package/dist/esm/client/useLocale.mjs.map +1 -1
  61. package/dist/esm/client/useLocaleStorage.mjs +54 -1
  62. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  63. package/dist/esm/editor/ContentSelector.component.mjs +31 -1
  64. package/dist/esm/editor/ContentSelector.component.mjs.map +1 -0
  65. package/dist/esm/editor/useEditor.mjs +29 -1
  66. package/dist/esm/editor/useEditor.mjs.map +1 -1
  67. package/dist/esm/getDictionary.mjs +8 -1
  68. package/dist/esm/getDictionary.mjs.map +1 -1
  69. package/dist/esm/getIntlayer.mjs +8 -1
  70. package/dist/esm/getIntlayer.mjs.map +1 -1
  71. package/dist/esm/index.mjs +14 -1
  72. package/dist/esm/markdown/index.mjs +3 -1
  73. package/dist/esm/markdown/installIntlayerMarkdown.mjs +68 -1
  74. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  75. package/dist/esm/plugins.mjs +223 -1
  76. package/dist/esm/plugins.mjs.map +1 -1
  77. package/dist/esm/renderIntlayerNode.mjs +26 -1
  78. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  79. package/dist/esm/webpack/index.mjs +3 -1
  80. package/dist/esm/webpack/mergeConfig.mjs +43 -1
  81. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  82. package/dist/types/client/index.d.ts +8 -8
  83. package/dist/types/client/installIntlayer.d.ts +50 -2
  84. package/dist/types/client/installIntlayer.d.ts.map +1 -0
  85. package/dist/types/client/useDictionary.d.ts +10 -2
  86. package/dist/types/client/useDictionary.d.ts.map +1 -0
  87. package/dist/types/client/useDictionaryAsync.d.ts +14 -2
  88. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -0
  89. package/dist/types/client/useDictionaryDynamic.d.ts +17 -2
  90. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
  91. package/dist/types/client/useIntl.d.ts +33 -2
  92. package/dist/types/client/useIntl.d.ts.map +1 -0
  93. package/dist/types/client/useIntlayer.d.ts +38 -2
  94. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  95. package/dist/types/client/useLoadDynamic.d.ts +11 -2
  96. package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
  97. package/dist/types/client/useLocale.d.ts +48 -2
  98. package/dist/types/client/useLocale.d.ts.map +1 -0
  99. package/dist/types/getDictionary.d.ts +9 -2
  100. package/dist/types/getDictionary.d.ts.map +1 -0
  101. package/dist/types/getIntlayer.d.ts +8 -2
  102. package/dist/types/getIntlayer.d.ts.map +1 -0
  103. package/dist/types/index.d.ts +21 -13
  104. package/dist/types/index.d.ts.map +1 -0
  105. package/dist/types/markdown/index.d.ts +1 -1
  106. package/dist/types/markdown/installIntlayerMarkdown.d.ts +36 -2
  107. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
  108. package/dist/types/plugins.d.ts +90 -2
  109. package/dist/types/plugins.d.ts.map +1 -0
  110. package/dist/types/webpack/index.d.ts +2 -5
  111. package/dist/types/webpack/mergeConfig.d.ts +5 -2
  112. package/dist/types/webpack/mergeConfig.d.ts.map +1 -0
  113. package/package.json +8 -8
  114. package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs +0 -9
  115. package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs.map +0 -1
  116. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  117. package/dist/cjs/decorate-B_4qGGx3.cjs +0 -1
  118. package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs +0 -9
  119. package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs.map +0 -1
  120. package/dist/esm/decorate-EVKP5RjP.mjs +0 -1
  121. package/dist/types/getDictionary-DDjZzxAC.d.ts +0 -9
  122. package/dist/types/getDictionary-DDjZzxAC.d.ts.map +0 -1
  123. package/dist/types/getIntlayer-CWM6qsJJ.d.ts +0 -8
  124. package/dist/types/getIntlayer-CWM6qsJJ.d.ts.map +0 -1
  125. package/dist/types/index-Cf8zm5QQ.d.ts +0 -1
  126. package/dist/types/index-D5QAgZ5v.d.ts +0 -22
  127. package/dist/types/index-D5QAgZ5v.d.ts.map +0 -1
  128. package/dist/types/installIntlayer-Ce7kST5N.d.ts +0 -50
  129. package/dist/types/installIntlayer-Ce7kST5N.d.ts.map +0 -1
  130. package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts +0 -36
  131. package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts.map +0 -1
  132. package/dist/types/plugins-C_v3w-vC.d.ts +0 -89
  133. package/dist/types/plugins-C_v3w-vC.d.ts.map +0 -1
  134. package/dist/types/useDictionary-Dq9yu0X_.d.ts +0 -10
  135. package/dist/types/useDictionary-Dq9yu0X_.d.ts.map +0 -1
  136. package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts +0 -14
  137. package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts.map +0 -1
  138. package/dist/types/useIntl-CHizZCR2.d.ts +0 -33
  139. package/dist/types/useIntl-CHizZCR2.d.ts.map +0 -1
  140. package/dist/types/useIntlayer-m3n_upwm.d.ts +0 -38
  141. package/dist/types/useIntlayer-m3n_upwm.d.ts.map +0 -1
  142. package/dist/types/useLoadDynamic-C4pltPcC.d.ts +0 -11
  143. package/dist/types/useLoadDynamic-C4pltPcC.d.ts.map +0 -1
  144. package/dist/types/useLocale-BzfAmXlx.d.ts +0 -48
  145. package/dist/types/useLocale-BzfAmXlx.d.ts.map +0 -1
  146. package/dist/types/webpack/index.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compile,\n getMarkdownMetadata,\n type MarkdownContent,\n} from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\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: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n })\n : () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const 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: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n })\n : html,\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const 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 = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":"maAgCA,MAAM,GAA6B,EAAkB,KAAoB,CACvE,GAAG,EACH,eAAgB,EAAa,EAAY,GAAG,IAAoB,CAC9D,IAAM,EAAW,IAAY,GAE7B,GAAI,EAAU,CACZ,IAAM,EAAW,CAAE,GAAG,EAAO,GAAG,EAAU,CAGpC,EAAgB,GAAO,OAAS,GAAO,UACvC,EAAgB,EAAS,OAAS,EAAS,UAOjD,OALI,GAAiB,IACnB,EAAS,MAAQ,GAAG,EAAc,GAAG,IACrC,EAAS,UAAY,IAAA,IAGhB,EAAY,cAAc,EAA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perComponent","NodeTypes","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport type { MarkdownContent } from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n// Lazy pre-load heavy modules — creates separate code-split chunks\nlet _getMarkdownMetadata: ((s: string) => any) | null = null;\nlet _compile: ((s: string, opts: any) => any) | null = null;\nvoid import('@intlayer/core/markdown').then((m) => {\n _getMarkdownMetadata = m.getMarkdownMetadata;\n _compile = m.compile;\n});\n\nlet _markdownInstall: {\n htmlRuntime: any;\n useMarkdown: () => { renderMarkdown: (s: string, components?: any) => any };\n} | null = null;\nvoid import('./markdown/installIntlayerMarkdown').then((m) => {\n _markdownInstall = m as any;\n});\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = _getMarkdownMetadata?.(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n })\n : () => {\n const { renderMarkdown } = _markdownInstall?.useMarkdown() ?? {\n renderMarkdown: () => node,\n };\n return renderMarkdown(node, components);\n },\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !_compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return _compile(node, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !_compile) return node;\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return _compile(node, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n })\n : html,\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !_compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return _compile(html, { runtime }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const htmlRuntime = _markdownInstall?.htmlRuntime;\n if (!htmlRuntime || !_compile) return String(html);\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return _compile(html, { runtime }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node[NodeTypes.INSERTION] as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":";;;;;;;;;;;AAyBA,IAAI,uBAAoD;AACxD,IAAI,WAAmD;AAClD,OAAO,2BAA2B,MAAM,MAAM;AACjD,wBAAuB,EAAE;AACzB,YAAW,EAAE;EACb;AAEF,IAAI,mBAGO;qCACN,2CAA6C,MAAM,MAAM;AAC5D,oBAAmB;EACnB;;;;AAMF,MAAM,6BAA6B,aAAkB,eAAoB;CACvE,GAAG;CACH,gBAAgB,KAAa,OAAY,GAAG,aAAoB;EAC9D,MAAM,WAAW,YAAY;AAE7B,MAAI,UAAU;GACZ,MAAM,WAAW;IAAE,GAAG;IAAO,GAAG;IAAU;GAG1C,MAAM,gBAAgB,OAAO,SAAS,OAAO;GAC7C,MAAM,gBAAgB,SAAS,SAAS,SAAS;AAEjD,OAAI,iBAAiB,eAAe;AAClC,aAAS,QAAQ,GAAG,cAAc,GAAG;AACrC,aAAS,YAAY;;AAGvB,UAAO,YAAY,cAAc,KAAK,UAAU,GAAG,SAAS;;AAG9D,SAAO,YAAY,cAAc,KAAK,OA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S,YAAY,MAAM,aAAaC,yBAAU;CAC3D,YAAY,MAAwB,UAAU;EAC5C,MAAM,EAAE,SAAS,GAAG,SAAS;EAG7B,MAAM,UAAU,OAAwC,EAAE,KAAK;GAC7D,IAAI,OAAO,KAAKA,yBAAU;AAC1B,OAAI,KACF,QAAO,QAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,WAAW;AAC7C,WAAO,KAAK,QACV,IAAI,OAAO,SAAS,IAAI,SAAS,IAAI,EACrC,OAAO,MAAM,CACd;KACD;AAEJ,UAAO;;AAGT,SAAOH,8CAAmB;GACxB,GAAG;GACH,OAAO;GACP,UAAU;GACX,CAAC;;CAEL;;;;;AAiCD,MAAa,cACX,QACA,WAAoB,SACN;mDAEZ,UAAUC,+BAAc,qBAAqB,eAC7C,WAAWA,+BAAc,qBAAqB,gBAAgB,OAC/D;CACDG;CACAC;8CACa,UAAUJ,+BAAc,qBAAqB,cAAc;CACxEK;CACAC;CACA;CACA;CACA;CACA;CACD"}
@@ -1,2 +1,29 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=({children:e,value:t,additionalProps:n={}})=>e==null?new Proxy({},{get(e,r,i){return r===`value`?t:n&&Object.keys(n).includes(r)?n[r]:Reflect.get(e,r,i)}}):new Proxy(e,{apply(e,n,r){return typeof t==`function`?Reflect.apply(t,n,r):Reflect.apply(e,n,r)},get(e,r,i){return r===`value`?t:r===`toString`?()=>String(t):r===Symbol.toPrimitive?()=>t:n&&Object.keys(n).includes(r)?n[r]:Reflect.get(e,r,i)}});exports.renderIntlayerNode=e;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/renderIntlayerNode.ts
4
+ const renderIntlayerNode = ({ children, value, additionalProps = {} }) => {
5
+ if (children == null) return new Proxy({}, { get(target, prop, receiver) {
6
+ if (prop === "value") return value;
7
+ if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
8
+ return Reflect.get(target, prop, receiver);
9
+ } });
10
+ return new Proxy(children, {
11
+ apply(target, thisArg, argumentsList) {
12
+ if (typeof value === "function") return Reflect.apply(value, thisArg, argumentsList);
13
+ return Reflect.apply(target, thisArg, argumentsList);
14
+ },
15
+ get(target, prop, receiver) {
16
+ if (prop === "value") return value;
17
+ if (prop === "toString") return () => {
18
+ return String(value);
19
+ };
20
+ if (prop === Symbol.toPrimitive) return () => value;
21
+ if (additionalProps && Object.keys(additionalProps).includes(prop)) return additionalProps[prop];
22
+ return Reflect.get(target, prop, receiver);
23
+ }
24
+ });
25
+ };
26
+
27
+ //#endregion
28
+ exports.renderIntlayerNode = renderIntlayerNode;
2
29
  //# sourceMappingURL=renderIntlayerNode.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string, AdditionalProps = {}> = ResolvedEditor<\n T,\n any\n> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // 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":"mEAeA,MAAa,GAEX,CACA,WACA,QACA,kBAAkB,EAAE,IAGhB,GAAY,KACP,IAAI,MAAM,EAAE,CAAS,CAC1B,IAAI,EAAQ,EAAM,EAAU,CAY1B,OAXI,IAAS,QACJ,EAIP,GACA,OAAO,KAAK,EAAgB,CAAC,SAAS,EAAe,CAE9C,EAAgB,GAGlB,QAAQ,IAAI,EAAQ,EAAM,EAAS,EAE7C,CAAC,CAKG,IAAI,MAAM,EAAU,CACzB,MAAM,EAAQ,EAAS,EAAe,CAIpC,OAHI,OAAO,GAAU,WACZ,QAAQ,MAAM,EAAmB,EAAS,EAAc,CAE1D,QAAQ,MAAM,EAAoB,EAAS,EAAc,EAElE,IAAI,EAAQ,EAAM,EAAU,CAuB1B,OAtBI,IAAS,QACJ,EAGL,IAAS,eAGF,OAAO,EAAM,CAIpB,IAAS,OAAO,gBACL,EAIb,GACA,OAAO,KAAK,EAAgB,CAAC,SAAS,EAAe,CAE9C,EAAgB,GAGlB,QAAQ,IAAI,EAAQ,EAAM,EAAS,EAE7C,CAAC"}
1
+ {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string, AdditionalProps = {}> = ResolvedEditor<\n T,\n any\n> & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // 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":";;;AAeA,MAAa,sBAEX,EACA,UACA,OACA,kBAAkB,EAAE,OAC6B;AAEjD,KAAI,YAAY,KACd,QAAO,IAAI,MAAM,EAAE,EAAS,EAC1B,IAAI,QAAQ,MAAM,UAAU;AAC1B,MAAI,SAAS,QACX,QAAO;AAGT,MACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC;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 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./mergeConfig.cjs`);exports.mergeConfig=e.mergeConfig;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_webpack_mergeConfig = require('./mergeConfig.cjs');
3
+
4
+ exports.mergeConfig = require_webpack_mergeConfig.mergeConfig;
@@ -1,2 +1,46 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:path`),t=require(`@intlayer/config/node`),n=require(`@intlayer/config/utils`),r=require(`@intlayer/webpack`),i=require(`defu`);const a=a=>{let o=(0,t.getConfiguration)();return(0,i.defu)({resolve:{alias:(0,n.getAlias)({configuration:o,formatter:t=>(0,e.resolve)(t)})},externals:{esbuild:`esbuild`,module:`module`,fs:`fs`,chokidar:`chokidar`,fsevents:`fsevents`},module:{rules:[{test:/\.node$/,loader:`node-loader`},{test:/\.mjs$/,include:[/[\\/]\.intlayer[\\/]/],type:`javascript/auto`,enforce:`pre`,use:{loader:`babel-loader`,options:{presets:[[`@babel/preset-env`,{modules:`commonjs`}]],plugins:[[`@babel/plugin-syntax-import-attributes`,{deprecatedAssert:!0}]]}}}]},plugins:[new r.IntlayerPlugin(o)]},a)};exports.mergeConfig=a;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_path = require("node:path");
4
+ let _intlayer_config_node = require("@intlayer/config/node");
5
+ let _intlayer_config_utils = require("@intlayer/config/utils");
6
+ let _intlayer_webpack = require("@intlayer/webpack");
7
+ let defu = require("defu");
8
+
9
+ //#region src/webpack/mergeConfig.ts
10
+ const mergeConfig = (baseConfig) => {
11
+ const intlayerConfig = (0, _intlayer_config_node.getConfiguration)();
12
+ return (0, defu.defu)({
13
+ resolve: { alias: (0, _intlayer_config_utils.getAlias)({
14
+ configuration: intlayerConfig,
15
+ formatter: (value) => (0, node_path.resolve)(value)
16
+ }) },
17
+ externals: {
18
+ esbuild: "esbuild",
19
+ module: "module",
20
+ fs: "fs",
21
+ chokidar: "chokidar",
22
+ fsevents: "fsevents"
23
+ },
24
+ module: { rules: [{
25
+ test: /\.node$/,
26
+ loader: "node-loader"
27
+ }, {
28
+ test: /\.mjs$/,
29
+ include: [/[\\/]\.intlayer[\\/]/],
30
+ type: "javascript/auto",
31
+ enforce: "pre",
32
+ use: {
33
+ loader: "babel-loader",
34
+ options: {
35
+ presets: [["@babel/preset-env", { modules: "commonjs" }]],
36
+ plugins: [["@babel/plugin-syntax-import-attributes", { deprecatedAssert: true }]]
37
+ }
38
+ }
39
+ }] },
40
+ plugins: [new _intlayer_webpack.IntlayerPlugin(intlayerConfig)]
41
+ }, baseConfig);
42
+ };
43
+
44
+ //#endregion
45
+ exports.mergeConfig = mergeConfig;
2
46
  //# sourceMappingURL=mergeConfig.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeConfig.cjs","names":["IntlayerPlugin"],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\nimport type { Configuration as WebpackConfig } from 'webpack';\n\nexport const mergeConfig = (baseConfig: WebpackConfig): WebpackConfig => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n\n // Fix `import _48DQ2FD8DPGT8SPgqAmt from '../dictionary/app.json' with { type: 'json' };` syntax\n {\n test: /\\.mjs$/,\n include: [/[\\\\/]\\.intlayer[\\\\/]/],\n type: 'javascript/auto',\n enforce: 'pre',\n use: {\n loader: 'babel-loader',\n options: {\n presets: [['@babel/preset-env', { modules: 'commonjs' }]],\n plugins: [\n [\n '@babel/plugin-syntax-import-attributes',\n { deprecatedAssert: true },\n ],\n ],\n },\n },\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as WebpackConfig;\n};\n"],"mappings":"uPAOA,MAAa,EAAe,GAA6C,CACvE,IAAM,GAAA,EAAA,EAAA,mBAAmC,CA+CzC,OAAA,EAAA,EAAA,MA7Ce,CACb,QAAS,CACP,OAAA,EAAA,EAAA,UAAgB,CACd,cAAe,EACf,UAAY,IAAA,EAAA,EAAA,SAA0B,EAAM,CAC7C,CAAC,CACH,CACD,UAAW,CACT,QAAS,UACT,OAAQ,SACR,GAAI,KACJ,SAAU,WACV,SAAU,WACX,CACD,OAAQ,CACN,MAAO,CACL,CACE,KAAM,UACN,OAAQ,cACT,CAGD,CACE,KAAM,SACN,QAAS,CAAC,uBAAuB,CACjC,KAAM,kBACN,QAAS,MACT,IAAK,CACH,OAAQ,eACR,QAAS,CACP,QAAS,CAAC,CAAC,oBAAqB,CAAE,QAAS,WAAY,CAAC,CAAC,CACzD,QAAS,CACP,CACE,yCACA,CAAE,iBAAkB,GAAM,CAC3B,CACF,CACF,CACF,CACF,CACF,CACF,CACD,QAAS,CAAC,IAAIA,EAAAA,eAAe,EAAe,CAAC,CAC9C,CAEmB,EAAW"}
1
+ {"version":3,"file":"mergeConfig.cjs","names":["IntlayerPlugin"],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\nimport type { Configuration as WebpackConfig } from 'webpack';\n\nexport const mergeConfig = (baseConfig: WebpackConfig): WebpackConfig => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n\n // Fix `import _48DQ2FD8DPGT8SPgqAmt from '../dictionary/app.json' with { type: 'json' };` syntax\n {\n test: /\\.mjs$/,\n include: [/[\\\\/]\\.intlayer[\\\\/]/],\n type: 'javascript/auto',\n enforce: 'pre',\n use: {\n loader: 'babel-loader',\n options: {\n presets: [['@babel/preset-env', { modules: 'commonjs' }]],\n plugins: [\n [\n '@babel/plugin-syntax-import-attributes',\n { deprecatedAssert: true },\n ],\n ],\n },\n },\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as WebpackConfig;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,eAAe,eAA6C;CACvE,MAAM,8DAAmC;AA+CzC,uBA7Ce;EACb,SAAS,EACP,4CAAgB;GACd,eAAe;GACf,YAAY,iCAA0B,MAAM;GAC7C,CAAC,EACH;EACD,WAAW;GACT,SAAS;GACT,QAAQ;GACR,IAAI;GACJ,UAAU;GACV,UAAU;GACX;EACD,QAAQ,EACN,OAAO,CACL;GACE,MAAM;GACN,QAAQ;GACT,EAGD;GACE,MAAM;GACN,SAAS,CAAC,uBAAuB;GACjC,MAAM;GACN,SAAS;GACT,KAAK;IACH,QAAQ;IACR,SAAS;KACP,SAAS,CAAC,CAAC,qBAAqB,EAAE,SAAS,YAAY,CAAC,CAAC;KACzD,SAAS,CACP,CACE,0CACA,EAAE,kBAAkB,MAAM,CAC3B,CACF;KACF;IACF;GACF,CACF,EACF;EACD,SAAS,CAAC,IAAIA,iCAAe,eAAe,CAAC;EAC9C,EAEmB,WAAW"}
@@ -0,0 +1,10 @@
1
+ //#region \0@oxc-project+runtime@0.115.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.115.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 +1,10 @@
1
- import{INTLAYER_TOKEN as e,IntlayerProvider as t,createIntlayerClient as n,installIntlayer as r,provideIntlayer as i}from"./installIntlayer.mjs";import{useDictionary as a}from"./useDictionary.mjs";import{useDictionaryAsync as o}from"./useDictionaryAsync.mjs";import{useLoadDynamic as s}from"./useLoadDynamic.mjs";import{useDictionaryDynamic as c}from"./useDictionaryDynamic.mjs";import{useIntl as l}from"./useIntl.mjs";import{isUpdatableNode as u,useIntlayer as d}from"./useIntlayer.mjs";import{useLocale as f}from"./useLocale.mjs";export{e as INTLAYER_TOKEN,t as IntlayerProvider,n as createIntlayerClient,r as installIntlayer,u as isUpdatableNode,i as provideIntlayer,a as useDictionary,o as useDictionaryAsync,c as useDictionaryDynamic,l as useIntl,d as useIntlayer,s as useLoadDynamic,f as useLocale};
1
+ import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer } from "./installIntlayer.mjs";
2
+ import { useDictionary } from "./useDictionary.mjs";
3
+ import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
4
+ import { useLoadDynamic } from "./useLoadDynamic.mjs";
5
+ import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
6
+ import { useIntl } from "./useIntl.mjs";
7
+ import { isUpdatableNode, useIntlayer } from "./useIntlayer.mjs";
8
+ import { useLocale } from "./useLocale.mjs";
9
+
10
+ export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, provideIntlayer, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntl, useIntlayer, useLoadDynamic, useLocale };
@@ -1,2 +1,66 @@
1
- import{t as e}from"../decorate-EVKP5RjP.mjs";import t from"@intlayer/config/built";import{Injectable as n,InjectionToken as r,signal as i}from"@angular/core";const a=new r(`intlayer`);let o=null,s=class{isCookieEnabled=i(!0);_locale=i(t.internationalization?.defaultLocale);locale=this._locale.asReadonly();setLocale=e=>{this._locale.set(e)}};s=e([n({providedIn:`root`})],s);const c=(e,t=!0)=>o||(o=new s,e&&o.setLocale(e),o.isCookieEnabled.set(t),o),l=(e,t=!0)=>({provide:a,useValue:u(e,t)}),u=(e,t=!0)=>c(e,t);export{a as INTLAYER_TOKEN,s as IntlayerProvider,c as createIntlayerClient,u as installIntlayer,l as provideIntlayer};
1
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs";
2
+ import configuration from "@intlayer/config/built";
3
+ import { Injectable, InjectionToken, signal } from "@angular/core";
4
+
5
+ //#region src/client/installIntlayer.ts
6
+ const INTLAYER_TOKEN = new InjectionToken("intlayer");
7
+ /**
8
+ * Singleton instance
9
+ */
10
+ let instance = null;
11
+ let IntlayerProvider = class IntlayerProvider {
12
+ isCookieEnabled = signal(true);
13
+ _locale = signal(configuration.internationalization?.defaultLocale);
14
+ locale = this._locale.asReadonly();
15
+ setLocale = (locale) => {
16
+ this._locale.set(locale);
17
+ };
18
+ };
19
+ IntlayerProvider = __decorate([Injectable({ providedIn: "root" })], IntlayerProvider);
20
+ /**
21
+ * Create and return a single IntlayerProvider instance
22
+ */
23
+ const createIntlayerClient = (locale, isCookieEnabled = true) => {
24
+ if (instance) return instance;
25
+ instance = new IntlayerProvider();
26
+ if (locale) instance.setLocale(locale);
27
+ instance.isCookieEnabled.set(isCookieEnabled);
28
+ return instance;
29
+ };
30
+ /**
31
+ * Provides Intlayer to your Angular application.
32
+ *
33
+ * This function should be used in your application's provider list (e.g., in `app.config.ts`)
34
+ * to initialize the Intlayer service.
35
+ *
36
+ * @param locale - Initial locale to use.
37
+ * @param isCookieEnabled - Whether to store the locale in cookies.
38
+ * @returns A provider configuration for Intlayer.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * // app.config.ts
43
+ * import { ApplicationConfig } from '@angular/core';
44
+ * import { provideIntlayer } from 'angular-intlayer';
45
+ *
46
+ * export const appConfig: ApplicationConfig = {
47
+ * providers: [
48
+ * provideIntlayer({ locale: 'en' }),
49
+ * ],
50
+ * };
51
+ * ```
52
+ */
53
+ const provideIntlayer = (locale, isCookieEnabled = true) => ({
54
+ provide: INTLAYER_TOKEN,
55
+ useValue: installIntlayer(locale, isCookieEnabled)
56
+ });
57
+ /**
58
+ * Helper to install the Intlayer provider.
59
+ */
60
+ const installIntlayer = (locale, isCookieEnabled = true) => {
61
+ return createIntlayerClient(locale, isCookieEnabled);
62
+ };
63
+
64
+ //#endregion
65
+ export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, provideIntlayer };
2
66
  //# sourceMappingURL=installIntlayer.mjs.map
@@ -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/module_augmentation';\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":"8JAIA,MAAa,EAAiB,IAAI,EAAiC,WAAW,CAK9E,IAAI,EAAoC,KAKjC,EAAA,KAAuB,CAC5B,gBAAkB,EAAO,GAAK,CAC9B,QAAkB,EAChB,EAAc,sBAAsB,cACrC,CAED,OAAyC,KAAK,QAAQ,YAAY,CAElE,UAAa,GAA0B,CACrC,KAAK,QAAQ,IAAI,EAAO,QAZ3B,EAAW,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CAiBF,MAAa,GACX,EACA,EAAkB,KAEd,IAEJ,EAAW,IAAI,EAEX,GACF,EAAS,UAAU,EAAO,CAE5B,EAAS,gBAAgB,IAAI,EAAgB,CAEtC,GA0BI,GACX,EACA,EAAkB,MACd,CACJ,QAAS,EACT,SAAU,EAAgB,EAAQ,EAAgB,CACnD,EAKY,GACX,EACA,EAAkB,KAEH,EAAqB,EAAQ,EAAgB"}
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/module_augmentation';\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"}
@@ -1,2 +1,14 @@
1
- import{getDictionary as e}from"../getDictionary.mjs";import{INTLAYER_TOKEN as t}from"./installIntlayer.mjs";import{computed as n,inject as r}from"@angular/core";const i=(i,a)=>{let o=r(t),s=n(()=>a??o?.locale());return n(()=>e(i,s()))};export{i as useDictionary};
1
+ import { getDictionary } from "../getDictionary.mjs";
2
+ import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
3
+ import { computed, inject } from "@angular/core";
4
+
5
+ //#region src/client/useDictionary.ts
6
+ const useDictionary = (dictionary, locale) => {
7
+ const intlayer = inject(INTLAYER_TOKEN);
8
+ const localeTarget = computed(() => locale ?? intlayer?.locale());
9
+ return computed(() => getDictionary(dictionary, localeTarget()));
10
+ };
11
+
12
+ //#endregion
13
+ export { useDictionary };
2
14
  //# sourceMappingURL=useDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":"iKAOA,MAAa,GACX,EACA,IAC+C,CAC/C,IAAM,EAAW,EAAyB,EAAe,CAEnD,EAAe,MAAe,GAAU,GAAU,QAAQ,CAAC,CAOjE,OAJgB,MACd,EAAgC,EAAY,GAAc,CAAC,CAC5D"}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":";;;;;AAOA,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"}
@@ -1,2 +1,22 @@
1
- "use client";import{INTLAYER_TOKEN as e}from"./installIntlayer.mjs";import{useDictionary as t}from"./useDictionary.mjs";import n from"@intlayer/config/built";import{computed as r,inject as i}from"@angular/core";const a=async(a,o)=>{let s=i(e),c=r(()=>o??s?.locale()??n?.internationalization.defaultLocale);return t(await a[c()]?.(),c())};export{a as useDictionaryAsync};
1
+ 'use client';
2
+
3
+ import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
4
+ import { useDictionary } from "./useDictionary.mjs";
5
+ import configuration from "@intlayer/config/built";
6
+ import { computed, inject } from "@angular/core";
7
+
8
+ //#region src/client/useDictionaryAsync.ts
9
+ /**
10
+ * On the server side, Hook that transform a dictionary and return the content
11
+ *
12
+ * If the locale is not provided, it will use the locale from the client context
13
+ */
14
+ const useDictionaryAsync = async (dictionaryPromise, locale) => {
15
+ const intlayer = inject(INTLAYER_TOKEN);
16
+ const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
17
+ return useDictionary(await dictionaryPromise[localeTarget()]?.(), localeTarget());
18
+ };
19
+
20
+ //#endregion
21
+ export { useDictionaryAsync };
2
22
  //# sourceMappingURL=useDictionaryAsync.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } 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 <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 () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"mNAcA,MAAa,EAAqB,MAChC,EACA,IACG,CACH,IAAM,EAAW,EAAyB,EAAe,CAEnD,EAAe,MAEjB,GACA,GAAU,QAAQ,EAClB,GAAe,qBAAqB,cACvC,CAID,OAAO,EAFY,MAAM,EAAkB,GAAc,KAAK,CAE7B,GAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } 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 <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 () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,qBAAqB,OAChC,mBACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAID,QAAO,cAFY,MAAM,kBAAkB,cAAc,KAAK,EAE7B,cAAc,CAAQ"}
@@ -1,2 +1,23 @@
1
- "use client";import{INTLAYER_TOKEN as e}from"./installIntlayer.mjs";import{useDictionary as t}from"./useDictionary.mjs";import{useLoadDynamic as n}from"./useLoadDynamic.mjs";import r from"@intlayer/config/built";import{computed as i,inject as a}from"@angular/core";const o=(o,s,c)=>{let l=a(e),u=i(()=>c??l?.locale()??r?.internationalization.defaultLocale);return t(n(`${String(s)}.${u()}`,o[u()]?.()),u())};export{o as useDictionaryDynamic};
1
+ 'use client';
2
+
3
+ import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
4
+ import { useDictionary } from "./useDictionary.mjs";
5
+ import { useLoadDynamic } from "./useLoadDynamic.mjs";
6
+ import configuration from "@intlayer/config/built";
7
+ import { computed, inject } from "@angular/core";
8
+
9
+ //#region src/client/useDictionaryDynamic.ts
10
+ /**
11
+ * On the server side, Hook that transform a dictionary and return the content
12
+ *
13
+ * If the locale is not provided, it will use the locale from the client context
14
+ */
15
+ const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
16
+ const intlayer = inject(INTLAYER_TOKEN);
17
+ const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
18
+ return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
19
+ };
20
+
21
+ //#endregion
22
+ export { useDictionaryDynamic };
2
23
  //# sourceMappingURL=useDictionaryDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"yQAeA,MAAa,GAIX,EACA,EACA,IACG,CACH,IAAM,EAAW,EAAyB,EAAe,CAEnD,EAAe,MAEjB,GACA,GAAU,QAAQ,EAClB,GAAe,qBAAqB,cACvC,CAOD,OAAO,EALY,EACjB,GAAG,OAAO,EAAI,CAAC,GAAG,GAAc,GAChC,EAAkB,GAAc,KAAK,CACtC,CAEgC,GAAc,CAAQ"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAChC,kBAAkB,cAAc,KAAK,CACtC,EAEgC,cAAc,CAAQ"}
@@ -1,2 +1,39 @@
1
- import{IntlayerProvider as e}from"./installIntlayer.mjs";import{computed as t,inject as n}from"@angular/core";import{bindIntl as r}from"@intlayer/core/formatters";const i=i=>{let a=n(e);return t(()=>r(i??a.locale()))};export{i as useIntl};
1
+ import { IntlayerProvider } from "./installIntlayer.mjs";
2
+ import { computed, inject } from "@angular/core";
3
+ import { bindIntl } from "@intlayer/core/formatters";
4
+
5
+ //#region src/client/useIntl.ts
6
+ /**
7
+ * Angular composable that provides a locale-bound `Intl` object.
8
+ *
9
+ * It acts exactly like the native `Intl` object, but acts as a proxy to:
10
+ * 1. Inject the current locale automatically if none is provided.
11
+ * 2. Use the performance-optimized `CachedIntl` under the hood.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { Component, computed } from '@angular/core';
16
+ * import { useIntl } from 'angular-intlayer';
17
+ *
18
+ * @Component({ ... })
19
+ * export class MyComponent {
20
+ * intl = useIntl();
21
+ * formattedPrice = computed(() =>
22
+ * new this.intl().NumberFormat({
23
+ * style: 'currency',
24
+ * currency: 'USD'
25
+ * }).format(123.45)
26
+ * );
27
+ * }
28
+ * ```
29
+ */
30
+ const useIntl = (locale) => {
31
+ const intlayer = inject(IntlayerProvider);
32
+ return computed(() => {
33
+ return bindIntl(locale ?? intlayer.locale());
34
+ });
35
+ };
36
+
37
+ //#endregion
38
+ export { useIntl };
2
39
  //# sourceMappingURL=useIntl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed<WrappedIntl>(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":"mKA6BA,MAAa,EAAW,GAA2B,CACjD,IAAM,EAAW,EAAO,EAAiB,CAEzC,OAAO,MAGE,EAFe,GAAU,EAAS,QAAQ,CAEnB,CAC9B"}
1
+ {"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed<WrappedIntl>(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,WAAW,WAA2B;CACjD,MAAM,WAAW,OAAO,iBAAiB;AAEzC,QAAO,eAA4B;AAGjC,SAAO,SAFe,UAAU,SAAS,QAAQ,CAEnB;GAC9B"}
@@ -1,2 +1,42 @@
1
- import{getIntlayer as e}from"../getIntlayer.mjs";import{INTLAYER_TOKEN as t}from"./installIntlayer.mjs";import{computed as n,inject as r}from"@angular/core";const i=e=>!!e&&typeof e==`object`&&typeof e.__update==`function`,a=(i,a)=>{let o=r(t),s=n(()=>a??o.locale());return n(()=>e(i,s()))};export{i as isUpdatableNode,a as useIntlayer};
1
+ import { getIntlayer } from "../getIntlayer.mjs";
2
+ import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
3
+ import { computed, inject } from "@angular/core";
4
+
5
+ //#region src/client/useIntlayer.ts
6
+ /** guard utility - true only for objects generated by `renderIntlayerNode()` */
7
+ const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
8
+ /**
9
+ * Angular hook that picks one dictionary by its key and returns its reactive content.
10
+ *
11
+ * It utilizes Angular signals to provide deep reactivity, ensuring your components
12
+ * update automatically when the locale changes.
13
+ *
14
+ * @param key - The unique key of the dictionary to retrieve.
15
+ * @param locale - Optional locale to override the current context locale.
16
+ * @returns The transformed dictionary content.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { Component } from '@angular/core';
21
+ * import { useIntlayer } from 'angular-intlayer';
22
+ *
23
+ * @Component({
24
+ * standalone: true,
25
+ * selector: 'app-my-component',
26
+ * template: `<div>{{ content().myField.value }}</div>`,
27
+ * })
28
+ * export class MyComponent {
29
+ * content = useIntlayer('my-dictionary-key');
30
+ * }
31
+ * ```
32
+ */
33
+ const useIntlayer = (key, locale) => {
34
+ const intlayer = inject(INTLAYER_TOKEN);
35
+ /** which locale should we use right now? */
36
+ const localeTarget = computed(() => locale ?? intlayer.locale());
37
+ return computed(() => getIntlayer(key, localeTarget()));
38
+ };
39
+
40
+ //#endregion
41
+ export { isUpdatableNode, useIntlayer };
2
42
  //# sourceMappingURL=useIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionaryKeys, DictionaryRegistryContent, LocalesValues } 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 = <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":"6JAOA,MAAa,EACX,GAEA,CAAC,CAAC,GACF,OAAO,GAAQ,UACf,OAAQ,EAAY,UAAa,WA2BtB,GACX,EACA,IAC+D,CAC/D,IAAM,EAAW,EAAyB,EAAe,CAGnD,EAAe,MAAe,GAAU,EAAS,QAAQ,CAAC,CAMhE,OAFgB,MAAe,EAAkB,EAAK,GAAc,CAAM,CAAC"}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionaryKeys, DictionaryRegistryContent, LocalesValues } 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 = <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":";;;;;;AAOA,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"}
@@ -1,2 +1,27 @@
1
- import{signal as e}from"@angular/core";const t=(n,r)=>{let i=t._cache||=new Map,a=e({});if(i.has(n))i.get(n)?.then(e=>{a.set(e)});else{let e=r.then(e=>(a.set(e),e));i.set(n,e)}return a()};export{t as useLoadDynamic};
1
+ import { signal } from "@angular/core";
2
+
3
+ //#region src/client/useLoadDynamic.ts
4
+ /**
5
+ * A "synchronous" loader for a dynamically‐imported JSON (or anything).
6
+ *
7
+ * - Immediately returns a reactive signal so that Angular can properly track changes.
8
+ * - When the Promise resolves, it replaces the signal's value with the real data.
9
+ */
10
+ const useLoadDynamic = (key, promise) => {
11
+ const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
12
+ const container = signal({});
13
+ if (!cache.has(key)) {
14
+ const p = promise.then((real) => {
15
+ container.set(real);
16
+ return real;
17
+ });
18
+ cache.set(key, p);
19
+ } else cache.get(key)?.then((real) => {
20
+ container.set(real);
21
+ });
22
+ return container();
23
+ };
24
+
25
+ //#endregion
26
+ export { useLoadDynamic };
2
27
  //# sourceMappingURL=useLoadDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.mjs","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":"uCAQA,MAAa,GACX,EACA,IACM,CAEN,IAAM,EAAkC,AACvC,EAAwB,SAAS,IAAI,IAIhC,EAAY,EAAO,EAAE,CAAM,CAEjC,GAAK,EAAM,IAAI,EAAI,CAUjB,EAAM,IAAI,EAAI,EAAE,KAAM,GAAS,CAC7B,EAAU,IAAI,EAAK,EACnB,KAZiB,CAEnB,IAAM,EAAI,EAAQ,KAAM,IAEtB,EAAU,IAAI,EAAK,CACZ,GACP,CACF,EAAM,IAAI,EAAK,EAAE,CASnB,OAAO,GAAW"}
1
+ {"version":3,"file":"useLoadDynamic.mjs","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,YAAY,OAAO,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"}