angular-intlayer 8.1.2 → 8.1.3

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 (168) hide show
  1. package/dist/cjs/UI/ContentSelector.component.cjs +2 -116
  2. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs +1 -11
  4. package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs +1 -8
  5. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  6. package/dist/cjs/client/index.cjs +1 -28
  7. package/dist/cjs/client/installIntlayer.cjs +1 -77
  8. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionary.cjs +1 -15
  10. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  11. package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
  12. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  13. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
  14. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  15. package/dist/cjs/client/useIntl.cjs +1 -40
  16. package/dist/cjs/client/useIntl.cjs.map +1 -1
  17. package/dist/cjs/client/useIntlayer.cjs +1 -44
  18. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  19. package/dist/cjs/client/useLoadDynamic.cjs +1 -28
  20. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  21. package/dist/cjs/client/useLocale.cjs +1 -60
  22. package/dist/cjs/client/useLocale.cjs.map +1 -1
  23. package/dist/cjs/client/useLocaleStorage.cjs +1 -60
  24. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  25. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +2 -51
  26. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
  27. package/dist/cjs/editor/EditedContentRenderer.component.cjs +1 -54
  28. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
  29. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +2 -35
  30. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
  31. package/dist/cjs/editor/communicator.cjs +1 -63
  32. package/dist/cjs/editor/communicator.cjs.map +1 -1
  33. package/dist/cjs/editor/configuration.cjs +1 -22
  34. package/dist/cjs/editor/configuration.cjs.map +1 -1
  35. package/dist/cjs/editor/createSharedComposable.cjs +1 -50
  36. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
  37. package/dist/cjs/editor/dictionariesRecord.cjs +1 -49
  38. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
  39. package/dist/cjs/editor/editedContent.cjs +1 -61
  40. package/dist/cjs/editor/editedContent.cjs.map +1 -1
  41. package/dist/cjs/editor/editorEnabled.cjs +1 -49
  42. package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
  43. package/dist/cjs/editor/editorLocale.cjs +1 -21
  44. package/dist/cjs/editor/editorLocale.cjs.map +1 -1
  45. package/dist/cjs/editor/focusDictionary.cjs +1 -62
  46. package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
  47. package/dist/cjs/editor/index.cjs +1 -25
  48. package/dist/cjs/editor/installIntlayerEditor.cjs +1 -52
  49. package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
  50. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +1 -73
  51. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  52. package/dist/cjs/editor/useCrossFrameState.cjs +1 -114
  53. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  54. package/dist/cjs/editor/useCrossURLPathState.cjs +1 -65
  55. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  56. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -35
  57. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  58. package/dist/cjs/editor/useEditor.cjs +1 -24
  59. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  60. package/dist/cjs/editor/useIframeClickInterceptor.cjs +1 -39
  61. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  62. package/dist/cjs/getDictionary.cjs +1 -17
  63. package/dist/cjs/getDictionary.cjs.map +1 -1
  64. package/dist/cjs/getIntlayer.cjs +1 -18
  65. package/dist/cjs/getIntlayer.cjs.map +1 -1
  66. package/dist/cjs/index.cjs +1 -49
  67. package/dist/cjs/markdown/index.cjs +1 -13
  68. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -79
  69. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  70. package/dist/cjs/plugins.cjs +1 -188
  71. package/dist/cjs/plugins.cjs.map +1 -1
  72. package/dist/cjs/renderIntlayerNode.cjs +1 -28
  73. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  74. package/dist/cjs/webpack/index.cjs +1 -4
  75. package/dist/cjs/webpack/mergeConfig.cjs +1 -44
  76. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  77. package/dist/esm/UI/ContentSelector.component.mjs +2 -109
  78. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
  79. package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +1 -10
  80. package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +1 -7
  81. package/dist/esm/client/index.mjs +1 -10
  82. package/dist/esm/client/installIntlayer.mjs +1 -65
  83. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  84. package/dist/esm/client/useDictionary.mjs +1 -13
  85. package/dist/esm/client/useDictionary.mjs.map +1 -1
  86. package/dist/esm/client/useDictionaryAsync.mjs +1 -21
  87. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  88. package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
  89. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  90. package/dist/esm/client/useIntl.mjs +1 -38
  91. package/dist/esm/client/useIntl.mjs.map +1 -1
  92. package/dist/esm/client/useIntlayer.mjs +1 -41
  93. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  94. package/dist/esm/client/useLoadDynamic.mjs +1 -26
  95. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  96. package/dist/esm/client/useLocale.mjs +1 -57
  97. package/dist/esm/client/useLocale.mjs.map +1 -1
  98. package/dist/esm/client/useLocaleStorage.mjs +1 -53
  99. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  100. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +2 -44
  101. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
  102. package/dist/esm/editor/EditedContentRenderer.component.mjs +1 -47
  103. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
  104. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +2 -28
  105. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
  106. package/dist/esm/editor/communicator.mjs +1 -58
  107. package/dist/esm/editor/communicator.mjs.map +1 -1
  108. package/dist/esm/editor/configuration.mjs +1 -19
  109. package/dist/esm/editor/configuration.mjs.map +1 -1
  110. package/dist/esm/editor/createSharedComposable.mjs +1 -47
  111. package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
  112. package/dist/esm/editor/dictionariesRecord.mjs +1 -45
  113. package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
  114. package/dist/esm/editor/editedContent.mjs +1 -57
  115. package/dist/esm/editor/editedContent.mjs.map +1 -1
  116. package/dist/esm/editor/editorEnabled.mjs +1 -45
  117. package/dist/esm/editor/editorEnabled.mjs.map +1 -1
  118. package/dist/esm/editor/editorLocale.mjs +1 -19
  119. package/dist/esm/editor/editorLocale.mjs.map +1 -1
  120. package/dist/esm/editor/focusDictionary.mjs +1 -58
  121. package/dist/esm/editor/focusDictionary.mjs.map +1 -1
  122. package/dist/esm/editor/index.mjs +1 -6
  123. package/dist/esm/editor/installIntlayerEditor.mjs +1 -49
  124. package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
  125. package/dist/esm/editor/useCrossFrameMessageListener.mjs +1 -71
  126. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  127. package/dist/esm/editor/useCrossFrameState.mjs +1 -112
  128. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  129. package/dist/esm/editor/useCrossURLPathState.mjs +1 -62
  130. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  131. package/dist/esm/editor/useEditedContentRenderer.mjs +1 -26
  132. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  133. package/dist/esm/editor/useEditor.mjs +1 -23
  134. package/dist/esm/editor/useEditor.mjs.map +1 -1
  135. package/dist/esm/editor/useIframeClickInterceptor.mjs +1 -36
  136. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  137. package/dist/esm/getDictionary.mjs +1 -15
  138. package/dist/esm/getDictionary.mjs.map +1 -1
  139. package/dist/esm/getIntlayer.mjs +1 -16
  140. package/dist/esm/getIntlayer.mjs.map +1 -1
  141. package/dist/esm/index.mjs +1 -14
  142. package/dist/esm/markdown/index.mjs +1 -3
  143. package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -68
  144. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  145. package/dist/esm/plugins.mjs +1 -182
  146. package/dist/esm/plugins.mjs.map +1 -1
  147. package/dist/esm/renderIntlayerNode.mjs +1 -26
  148. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  149. package/dist/esm/webpack/index.mjs +1 -3
  150. package/dist/esm/webpack/mergeConfig.mjs +1 -42
  151. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  152. package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
  153. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  154. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +1 -1
  155. package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
  156. package/dist/types/editor/EditorSelectorRenderer.component.d.ts +1 -1
  157. package/dist/types/getDictionary.d.ts +3 -3
  158. package/dist/types/getDictionary.d.ts.map +1 -1
  159. package/dist/types/getIntlayer.d.ts +1 -1
  160. package/dist/types/getIntlayer.d.ts.map +1 -1
  161. package/dist/types/index.d.ts +1 -1
  162. package/dist/types/index.d.ts.map +1 -1
  163. package/dist/types/markdown/installIntlayerMarkdown.d.ts +1 -1
  164. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
  165. package/dist/types/plugins.d.ts +1 -1
  166. package/dist/types/plugins.d.ts.map +1 -1
  167. package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
  168. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"installIntlayerMarkdown.cjs","names":["InjectionToken"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\nimport { compile, type MarkdownRuntime } from '@intlayer/core';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n// Minimal runtime to generate HTML strings\nexport const htmlRuntime: MarkdownRuntime = {\n createElement: (tag: string | any, props: any, ...children: any[]) => {\n if (typeof tag !== 'string') {\n // Handle non-string tags if necessary (e.g. components), or fallback to div\n if (tag === htmlRuntime.Fragment) {\n return children.join('');\n }\n return '';\n }\n\n const attrs = props\n ? Object.entries(props)\n .map(([k, v]) => {\n if (k === 'key' || v === undefined || v === null) return '';\n const key = k === 'className' ? 'class' : k;\n return `${key}=\"${String(v).replace(/\"/g, '&quot;')}\"`;\n })\n .filter(Boolean)\n .join(' ')\n : '';\n\n const childrenStr = children.join('');\n const voidTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ];\n\n if (voidTags.includes(tag)) {\n return `<${tag} ${attrs} />`;\n }\n\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n cloneElement: (element: any, _props: any) => element, // Not really supported for strings\n Fragment: Symbol('Fragment'),\n};\n\n/**\n * Default markdown renderer that converts markdown to HTML string\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n compile(markdown, { runtime: htmlRuntime }) as string;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":";;;;;;;AAQA,MAAa,0BACX,IAAIA,6BAAyC,mBAAmB;AAkBlE,MAAa,cAA+B;CAC1C,gBAAgB,KAAmB,OAAY,GAAG,aAAoB;AACp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["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\nimport type { MarkdownRuntime } from '@intlayer/core/markdown';\nimport { compile } from '@intlayer/core/markdown';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n// Minimal runtime to generate HTML strings\nexport const htmlRuntime: MarkdownRuntime = {\n createElement: (tag: string | any, props: any, ...children: any[]) => {\n if (typeof tag !== 'string') {\n // Handle non-string tags if necessary (e.g. components), or fallback to div\n if (tag === htmlRuntime.Fragment) {\n return children.join('');\n }\n return '';\n }\n\n const attrs = props\n ? Object.entries(props)\n .map(([k, v]) => {\n if (k === 'key' || v === undefined || v === null) return '';\n const key = k === 'className' ? 'class' : k;\n return `${key}=\"${String(v).replace(/\"/g, '&quot;')}\"`;\n })\n .filter(Boolean)\n .join(' ')\n : '';\n\n const childrenStr = children.join('');\n const voidTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ];\n\n if (voidTags.includes(tag)) {\n return `<${tag} ${attrs} />`;\n }\n\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n cloneElement: (element: any, _props: any) => element, // Not really supported for strings\n Fragment: Symbol('Fragment'),\n};\n\n/**\n * Default markdown renderer that converts markdown to HTML string\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n compile(markdown, { runtime: htmlRuntime }) as string;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":"sQASA,MAAa,EACX,IAAIA,EAAAA,eAAyC,mBAAmB,CAkBrD,EAA+B,CAC1C,eAAgB,EAAmB,EAAY,GAAG,IAAoB,CACpE,GAAI,OAAO,GAAQ,SAKjB,OAHI,IAAQ,EAAY,SACf,EAAS,KAAK,GAAG,CAEnB,GAGT,IAAM,EAAQ,EACV,OAAO,QAAQ,EAAM,CAClB,KAAK,CAAC,EAAG,KACJ,IAAM,OAAS,GAAyB,KAAa,GAElD,GADK,IAAM,YAAc,QAAU,EAC5B,IAAI,OAAO,EAAE,CAAC,QAAQ,KAAM,SAAS,CAAC,GACpD,CACD,OAAO,QAAQ,CACf,KAAK,IAAI,CACZ,GAEE,EAAc,EAAS,KAAK,GAAG,CAsBrC,MArBiB,CACf,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,OACA,OACA,QACA,SACA,QACA,MACD,CAEY,SAAS,EAAI,CACjB,IAAI,EAAI,GAAG,EAAM,KAGnB,IAAI,IAAM,EAAQ,IAAI,IAAU,GAAG,GAAG,EAAY,IAAI,EAAI,IAEnE,cAAe,EAAc,IAAgB,EAC7C,SAAU,OAAO,WAAW,CAC7B,CAKK,EAAmD,IAAA,EAAA,EAAA,SAC/C,EAAU,CAAE,QAAS,EAAa,CAAC,CAKhC,GACX,EAAyC,KACrC,CACJ,QAAS,EACT,SAAU,CACR,iBACD,CACF,EAQM,IAAA,EAAA,KAA8B,CACnC,kBAAQ,EAAA,EAAA,QAA0B,EAAyB,CACzD,SAAU,GACX,CAAC,CAEF,eAAe,EAAkB,EAA4C,CAI3E,OAHK,KAAK,iBAGH,KAAK,iBAAiB,eAAe,EAAU,EAAU,CAFvD,qCAVD,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CAiBF,MAAa,OACL,EAAA,EAAA,QAA0B,EAAyB,CAAE,SAAU,GAAM,CAAC,EAGnE,CACL,eAAgB,EACjB"}
@@ -1,189 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
- const require_editor_ContentSelectorWrapper_component = require('./editor/ContentSelectorWrapper.component.cjs');
4
- const require_markdown_installIntlayerMarkdown = require('./markdown/installIntlayerMarkdown.cjs');
5
- const require_renderIntlayerNode = require('./renderIntlayerNode.cjs');
6
- let _intlayer_core = require("@intlayer/core");
7
- let _intlayer_types = require("@intlayer/types");
8
-
9
- //#region src/plugins.ts
10
- /** ---------------------------------------------
11
- * UTILS
12
- * --------------------------------------------- */
13
- const createRuntimeWithOverides = (baseRuntime, overrides) => ({
14
- ...baseRuntime,
15
- createElement: (tag, props, ...children) => {
16
- const override = overrides?.[tag];
17
- if (override) {
18
- const newProps = {
19
- ...props,
20
- ...override
21
- };
22
- const originalClass = props?.class || props?.className;
23
- const overrideClass = override.class || override.className;
24
- if (originalClass && overrideClass) {
25
- newProps.class = `${originalClass} ${overrideClass}`;
26
- newProps.className = void 0;
27
- }
28
- return baseRuntime.createElement(tag, newProps, ...children);
29
- }
30
- return baseRuntime.createElement(tag, props, ...children);
31
- }
32
- });
33
- /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
34
- const intlayerNodePlugins = {
35
- id: "intlayer-node-plugin",
36
- canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
37
- transform: (_node, { children, ...rest }) => require_renderIntlayerNode.renderIntlayerNode({
38
- ...rest,
39
- value: children,
40
- children: () => ({
41
- component: require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent,
42
- props: {
43
- dictionaryKey: rest.dictionaryKey,
44
- keyPath: rest.keyPath
45
- },
46
- children
47
- })
48
- })
49
- };
50
- /** Markdown string plugin. Replaces string node with a component that render the markdown. */
51
- const markdownStringPlugin = {
52
- id: "markdown-string-plugin",
53
- canHandle: (node) => typeof node === "string",
54
- transform: (node, props, deepTransformNode) => {
55
- const { plugins, ...rest } = props;
56
- const metadataNodes = deepTransformNode((0, _intlayer_core.getMarkdownMetadata)(node), {
57
- plugins: [{
58
- id: "markdown-metadata-plugin",
59
- canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
60
- transform: (metadataNode, props) => require_renderIntlayerNode.renderIntlayerNode({
61
- ...props,
62
- value: metadataNode,
63
- children: node
64
- })
65
- }],
66
- dictionaryKey: rest.dictionaryKey,
67
- keyPath: []
68
- });
69
- const render = (components) => require_renderIntlayerNode.renderIntlayerNode({
70
- ...rest,
71
- value: node,
72
- children: () => ({
73
- component: require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent,
74
- props: {
75
- dictionaryKey: rest.dictionaryKey,
76
- keyPath: rest.keyPath,
77
- ...components
78
- },
79
- children: () => {
80
- const { renderMarkdown } = require_markdown_installIntlayerMarkdown.useMarkdown();
81
- return renderMarkdown(node, components);
82
- }
83
- }),
84
- additionalProps: { metadata: metadataNodes }
85
- });
86
- const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
87
- if (prop === "value") return node;
88
- if (prop === "metadata") return metadataNodes;
89
- if (prop === "toString") return () => {
90
- return (0, _intlayer_core.compile)(node, { runtime: components ? createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) : require_markdown_installIntlayerMarkdown.htmlRuntime });
91
- };
92
- if (prop === Symbol.toPrimitive) return () => {
93
- return (0, _intlayer_core.compile)(node, { runtime: components ? createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) : require_markdown_installIntlayerMarkdown.htmlRuntime });
94
- };
95
- if (prop === "use") return (newComponents) => {
96
- const mergedComponents = {
97
- ...components,
98
- ...newComponents
99
- };
100
- return createProxy(render(mergedComponents), mergedComponents);
101
- };
102
- return Reflect.get(target, prop, receiver);
103
- } });
104
- return createProxy(render());
105
- }
106
- };
107
- const markdownPlugin = {
108
- id: "markdown-plugin",
109
- canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types.NodeType.Markdown,
110
- transform: (node, props, deepTransformNode) => {
111
- const newKeyPath = [...props.keyPath, { type: _intlayer_types.NodeType.Markdown }];
112
- const children = node[_intlayer_types.NodeType.Markdown];
113
- return deepTransformNode(children, {
114
- ...props,
115
- children,
116
- keyPath: newKeyPath,
117
- plugins: [markdownStringPlugin, ...props.plugins ?? []]
118
- });
119
- }
120
- };
121
- /** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */
122
- const htmlPlugin = {
123
- id: "html-plugin",
124
- canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types.NodeType.HTML,
125
- transform: (node, props) => {
126
- const html = node[_intlayer_types.NodeType.HTML];
127
- const { plugins, ...rest } = props;
128
- const render = (userComponents) => require_renderIntlayerNode.renderIntlayerNode({
129
- ...rest,
130
- value: html,
131
- children: () => ({
132
- component: require_editor_ContentSelectorWrapper_component.ContentSelectorWrapperComponent,
133
- props: {
134
- dictionaryKey: rest.dictionaryKey,
135
- keyPath: rest.keyPath,
136
- ...userComponents
137
- },
138
- children: html
139
- })
140
- });
141
- const createProxy = (element, components) => new Proxy(element, { get(target, prop, receiver) {
142
- if (prop === "value") return html;
143
- if (prop === "toString") return () => {
144
- if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
145
- return (0, _intlayer_core.compile)(html, { runtime: createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) });
146
- };
147
- if (prop === Symbol.toPrimitive) return () => {
148
- if (!components || typeof components === "object" && Object.keys(components).length === 0) return String(html);
149
- return (0, _intlayer_core.compile)(html, { runtime: createRuntimeWithOverides(require_markdown_installIntlayerMarkdown.htmlRuntime, components) });
150
- };
151
- if (prop === "use") return (userComponents) => {
152
- const mergedComponents = {
153
- ...components,
154
- ...userComponents
155
- };
156
- return createProxy(render(mergedComponents), mergedComponents);
157
- };
158
- return Reflect.get(target, prop, receiver);
159
- } });
160
- return createProxy(render());
161
- }
162
- };
163
- const insertionPlugin = {
164
- id: "insertion-plugin",
165
- canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types.NodeType.Insertion,
166
- transform: (node, props) => {
167
- const { plugins, ...rest } = props;
168
- const render = (args = {}) => {
169
- let text = node.insertion;
170
- if (args) Object.entries(args).forEach(([key, value]) => {
171
- text = text.replace(new RegExp(`{{\\s*${key}\\s*}}`, "g"), String(value));
172
- });
173
- return text;
174
- };
175
- return require_renderIntlayerNode.renderIntlayerNode({
176
- ...rest,
177
- value: render,
178
- children: render
179
- });
180
- }
181
- };
182
-
183
- //#endregion
184
- exports.htmlPlugin = htmlPlugin;
185
- exports.insertionPlugin = insertionPlugin;
186
- exports.intlayerNodePlugins = intlayerNodePlugins;
187
- exports.markdownPlugin = markdownPlugin;
188
- exports.markdownStringPlugin = markdownStringPlugin;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./editor/ContentSelectorWrapper.component.cjs`),t=require(`./markdown/installIntlayerMarkdown.cjs`),n=require(`./renderIntlayerNode.cjs`);let r=require(`@intlayer/core/markdown`),i=require(`@intlayer/types`);const a=(e,t)=>({...e,createElement:(n,r,...i)=>{let a=t?.[n];if(a){let t={...r,...a},o=r?.class||r?.className,s=a.class||a.className;return o&&s&&(t.class=`${o} ${s}`,t.className=void 0),e.createElement(n,t,...i)}return e.createElement(n,r,...i)}}),o={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(t,{children:r,...i})=>n.renderIntlayerNode({...i,value:r,children:()=>({component:e.ContentSelectorWrapperComponent,props:{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},children:r})})},s={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(i,o,s)=>{let{plugins:c,...l}=o,u=s((0,r.getMarkdownMetadata)(i),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(e,t)=>n.renderIntlayerNode({...t,value:e,children:i})}],dictionaryKey:l.dictionaryKey,keyPath:[]}),d=r=>n.renderIntlayerNode({...l,value:i,children:()=>({component:e.ContentSelectorWrapperComponent,props:{dictionaryKey:l.dictionaryKey,keyPath:l.keyPath,...r},children:()=>{let{renderMarkdown:e}=t.useMarkdown();return e(i,r)}}),additionalProps:{metadata:u}}),f=(e,n)=>new Proxy(e,{get(e,o,s){return o===`value`?i:o===`metadata`?u:o===`toString`||o===Symbol.toPrimitive?()=>(0,r.compile)(i,{runtime:n?a(t.htmlRuntime,n):t.htmlRuntime}):o===`use`?e=>{let t={...n,...e};return f(d(t),t)}:Reflect.get(e,o,s)}});return f(d())}},c={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===i.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:i.NodeType.Markdown}],a=e[i.NodeType.Markdown];return n(a,{...t,children:a,keyPath:r,plugins:[s,...t.plugins??[]]})}},l={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===i.NodeType.HTML,transform:(o,s)=>{let c=o[i.NodeType.HTML],{plugins:l,...u}=s,d=t=>n.renderIntlayerNode({...u,value:c,children:()=>({component:e.ContentSelectorWrapperComponent,props:{dictionaryKey:u.dictionaryKey,keyPath:u.keyPath,...t},children:c})}),f=(e,n)=>new Proxy(e,{get(e,i,o){return i===`value`?c:i===`toString`||i===Symbol.toPrimitive?()=>!n||typeof n==`object`&&Object.keys(n).length===0?String(c):(0,r.compile)(c,{runtime:a(t.htmlRuntime,n)}):i===`use`?e=>{let t={...n,...e};return f(d(t),t)}:Reflect.get(e,i,o)}});return f(d())}},u={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===i.NodeType.Insertion,transform:(e,t)=>{let{plugins:r,...i}=t,a=(t={})=>{let n=e.insertion;return t&&Object.entries(t).forEach(([e,t])=>{n=n.replace(RegExp(`{{\\s*${e}\\s*}}`,`g`),String(t))}),n};return n.renderIntlayerNode({...i,value:a,children:a})}};exports.htmlPlugin=l,exports.insertionPlugin=u,exports.intlayerNodePlugins=o,exports.markdownPlugin=c,exports.markdownStringPlugin=s;
189
2
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import {\n compile,\n type DeepTransformContent as DeepTransformContentCore,\n getMarkdownMetadata,\n type HTMLContent,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type InsertionContent,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = 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> =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S;EAG7B,MAAM,UAAU,OAAwC,EAAE,KAAK;GAC7D,IAAI,OAAO,KAAK;AAChB,OAAI,KACF,QAAO,QAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,WAAW;AAC7C,WAAO,KAAK,QACV,IAAI,OAAO,SAAS,IAAI,SAAS,IAAI,EACrC,OAAO,MAAM,CACd;KACD;AAEJ,UAAO;;AAGT,SAAOJ,8CAAmB;GACxB,GAAG;GACH,OAAO;GACP,UAAU;GACX,CAAC;;CAEL"}
1
+ {"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType"],"sources":["../../src/plugins.ts"],"sourcesContent":["import type {\n DeepTransformContent as DeepTransformContentCore,\n IInterpreterPluginState as IInterpreterPluginStateCore,\n Plugins,\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 {\n type DeclaredLocales,\n type KeyPath,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport { ContentSelectorWrapperComponent } from './editor';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = 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"],"mappings":"gVAyBA,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,I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C,GACA,OAAO,GAAe,UACrB,OAAO,KAAK,EAAW,CAAC,SAAW,EAE9B,OAAO,EAAK,EAMrB,EAAA,EAAA,SAAe,EAAM,CACnB,QALc,EACdE,EAAAA,YACA,EACD,CAGA,CAAC,CAIF,IAAS,MAEH,GAAyB,CAC/B,IAAM,EAAmB,CAAE,GAAG,EAAY,GAAG,EAAgB,CAC7D,OAAO,EAAY,EAAO,EAAiB,CAAE,EAAiB,EAI3D,QAAQ,IAAI,EAAQ,EAAM,EAAS,EAE7C,CAAC,CAEJ,OAAO,EAAY,GAAQ,CAAQ,EAEtC,CAgBY,EAA2B,CACtC,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaC,EAAAA,SAAS,UAC1D,WAAY,EAAwB,IAAU,CAC5C,GAAM,CAAE,UAAS,GAAG,GAAS,EAGvB,GAAU,EAAwC,EAAE,GAAK,CAC7D,IAAI,EAAO,EAAK,UAShB,OARI,GACF,OAAO,QAAQ,EAAK,CAAC,SAAS,CAAC,EAAK,KAAW,CAC7C,EAAO,EAAK,QACN,OAAO,SAAS,EAAI,QAAS,IAAI,CACrC,OAAO,EAAM,CACd,EACD,CAEG,GAGT,OAAOJ,EAAAA,mBAAmB,CACxB,GAAG,EACH,MAAO,EACP,SAAU,EACX,CAAC,EAEL"}
@@ -1,29 +1,2 @@
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;
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;
29
2
  //# sourceMappingURL=renderIntlayerNode.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["export type IntlayerNode<T = string, AdditionalProps = {}> = any & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(children, {\n apply(target, thisArg, argumentsList) {\n if (typeof value === 'function') {\n return Reflect.apply(value as Function, thisArg, argumentsList);\n }\n return Reflect.apply(target as Function, thisArg, argumentsList);\n },\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (prop === 'toString') {\n return () => {\n // console.log('renderIntlayerNode toString called for:', value);\n return String(value);\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;AAUA,MAAa,sBAEX,EACA,UACA,OACA,kBAAkB,EAAE,OAC6B;AAEjD,KAAI,YAAY,KACd,QAAO,IAAI,MAAM,EAAE,EAAS,EAC1B,IAAI,QAAQ,MAAM,UAAU;AAC1B,MAAI,SAAS,QACX,QAAO;AAGT,MACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,SAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC;AAKJ,QAAO,IAAI,MAAM,UAAU;EACzB,MAAM,QAAQ,SAAS,eAAe;AACpC,OAAI,OAAO,UAAU,WACnB,QAAO,QAAQ,MAAM,OAAmB,SAAS,cAAc;AAEjE,UAAO,QAAQ,MAAM,QAAoB,SAAS,cAAc;;EAElE,IAAI,QAAQ,MAAM,UAAU;AAC1B,OAAI,SAAS,QACX,QAAO;AAGT,OAAI,SAAS,WACX,cAAa;AAEX,WAAO,OAAO,MAAM;;AAIxB,OAAI,SAAS,OAAO,YAClB,cAAa;AAGf,OACE,mBACA,OAAO,KAAK,gBAAgB,CAAC,SAAS,KAAe,CAErD,QAAO,gBAAgB;AAGzB,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;;EAE7C,CAAC"}
1
+ {"version":3,"file":"renderIntlayerNode.cjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["export type IntlayerNode<T = string, AdditionalProps = {}> = any & {\n value: T;\n} & AdditionalProps;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: any;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n children,\n value,\n additionalProps = {},\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is null or undefined, return a simple object with the value\n if (children == null) {\n return new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n }\n\n // Return a Proxy that pretends to be the original content\n // but also has a .value getter and additional props.\n return new Proxy(children, {\n apply(target, thisArg, argumentsList) {\n if (typeof value === 'function') {\n return Reflect.apply(value as Function, thisArg, argumentsList);\n }\n return Reflect.apply(target as Function, thisArg, argumentsList);\n },\n get(target, prop, receiver) {\n if (prop === 'value') {\n return value;\n }\n\n if (prop === 'toString') {\n return () => {\n // console.log('renderIntlayerNode toString called for:', value);\n return String(value);\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => value;\n }\n\n if (\n additionalProps &&\n Object.keys(additionalProps).includes(prop as string)\n ) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":"mEAUA,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,4 +1 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./mergeConfig.cjs`);exports.mergeConfig=e.mergeConfig;
@@ -1,45 +1,2 @@
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 = require("@intlayer/config");
5
- let _intlayer_webpack = require("@intlayer/webpack");
6
- let defu = require("defu");
7
-
8
- //#region src/webpack/mergeConfig.ts
9
- const mergeConfig = (baseConfig) => {
10
- const intlayerConfig = (0, _intlayer_config.getConfiguration)();
11
- return (0, defu.defu)({
12
- resolve: { alias: (0, _intlayer_config.getAlias)({
13
- configuration: intlayerConfig,
14
- formatter: (value) => (0, node_path.resolve)(value)
15
- }) },
16
- externals: {
17
- esbuild: "esbuild",
18
- module: "module",
19
- fs: "fs",
20
- chokidar: "chokidar",
21
- fsevents: "fsevents"
22
- },
23
- module: { rules: [{
24
- test: /\.node$/,
25
- loader: "node-loader"
26
- }, {
27
- test: /\.mjs$/,
28
- include: [/[\\/]\.intlayer[\\/]/],
29
- type: "javascript/auto",
30
- enforce: "pre",
31
- use: {
32
- loader: "babel-loader",
33
- options: {
34
- presets: [["@babel/preset-env", { modules: "commonjs" }]],
35
- plugins: [["@babel/plugin-syntax-import-attributes", { deprecatedAssert: true }]]
36
- }
37
- }
38
- }] },
39
- plugins: [new _intlayer_webpack.IntlayerPlugin(intlayerConfig)]
40
- }, baseConfig);
41
- };
42
-
43
- //#endregion
44
- exports.mergeConfig = mergeConfig;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.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;
45
2
  //# 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 { getAlias, getConfiguration } from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\n/** @ts-ignore Configuration type exist but raise error */\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,yDAAmC;AA+CzC,uBA7Ce;EACb,SAAS,EACP,sCAAgB;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"}
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';\n/** @ts-ignore Configuration type exist but raise error */\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":"mQAQA,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,105 +1,4 @@
1
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
3
- import { CommonModule } from "@angular/common";
4
- import { Component, EventEmitter, HostListener, Input, Output, ViewChild, computed, signal } from "@angular/core";
5
-
6
- //#region src/UI/ContentSelector.component.ts
7
- var _ref;
8
- const DEFAULT_PRESS_DETECT_DURATION = 250;
9
- let ContentSelectorComponent = class ContentSelectorComponent {
10
- onClickOutside;
11
- pressDuration;
12
- isSelecting;
13
- click = new EventEmitter();
14
- press = new EventEmitter();
15
- containerRef;
16
- isHovered = signal(false);
17
- isSelectingState = signal(false);
18
- pressTimerRef = null;
19
- isSelectingComputed = computed(() => this.isSelecting ?? this.isSelectingState());
20
- isStringSlot = computed(() => {
21
- return true;
22
- });
23
- ngOnInit() {
24
- this.isSelectingState.set(this.isSelecting ?? false);
25
- }
26
- ngOnDestroy() {
27
- this.clearPressTimer();
28
- }
29
- onDocumentMouseDown(event) {
30
- this.handleClickOutside(event);
31
- }
32
- handleOnLongPress() {
33
- this.isSelectingState.set(true);
34
- this.press.emit();
35
- }
36
- startPressTimer() {
37
- this.pressTimerRef = setTimeout(() => {
38
- this.handleOnLongPress();
39
- }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);
40
- }
41
- clearPressTimer() {
42
- if (this.pressTimerRef) {
43
- clearTimeout(this.pressTimerRef);
44
- this.pressTimerRef = null;
45
- }
46
- }
47
- handleMouseDown() {
48
- this.clearPressTimer();
49
- this.startPressTimer();
50
- }
51
- handleMouseUp() {
52
- this.isHovered.set(false);
53
- this.clearPressTimer();
54
- }
55
- handleClickOutside(event) {
56
- if (this.containerRef?.nativeElement && !this.containerRef.nativeElement.contains(event.target)) {
57
- this.isSelectingState.set(false);
58
- this.onClickOutside?.();
59
- }
60
- }
61
- handleClick(e) {
62
- if (this.isSelectingComputed()) {
63
- e.preventDefault();
64
- e.stopPropagation();
65
- }
66
- this.click.emit(e);
67
- }
68
- handleBlur() {
69
- this.isSelectingState.set(false);
70
- }
71
- onMouseEnter() {
72
- this.isHovered.set(true);
73
- }
74
- getContainerStyle() {
75
- return {
76
- display: this.isStringSlot() ? "inline" : "inline-block",
77
- cursor: "pointer",
78
- userSelect: "none",
79
- borderRadius: "0.375rem",
80
- outlineWidth: "2px",
81
- outlineOffset: "4px",
82
- outlineStyle: "solid",
83
- outlineColor: this.isSelectingComputed() || this.isHovered() ? "inherit" : "transparent",
84
- transition: "all 100ms 50ms ease-in-out"
85
- };
86
- }
87
- };
88
- __decorate([Input(), __decorateMetadata("design:type", Function)], ContentSelectorComponent.prototype, "onClickOutside", void 0);
89
- __decorate([Input(), __decorateMetadata("design:type", Number)], ContentSelectorComponent.prototype, "pressDuration", void 0);
90
- __decorate([Input(), __decorateMetadata("design:type", Boolean)], ContentSelectorComponent.prototype, "isSelecting", void 0);
91
- __decorate([Output(), __decorateMetadata("design:type", Object)], ContentSelectorComponent.prototype, "click", void 0);
92
- __decorate([Output(), __decorateMetadata("design:type", Object)], ContentSelectorComponent.prototype, "press", void 0);
93
- __decorate([ViewChild("containerRef", { static: true }), __decorateMetadata("design:type", Object)], ContentSelectorComponent.prototype, "containerRef", void 0);
94
- __decorate([
95
- HostListener("document:mousedown", ["$event"]),
96
- __decorateMetadata("design:type", Function),
97
- __decorateMetadata("design:paramtypes", [typeof (_ref = typeof MouseEvent !== "undefined" && MouseEvent) === "function" ? _ref : Object]),
98
- __decorateMetadata("design:returntype", void 0)
99
- ], ContentSelectorComponent.prototype, "onDocumentMouseDown", null);
100
- ContentSelectorComponent = __decorate([Component({
101
- selector: "app-content-selector",
102
- template: `
1
+ import{__decorateMetadata as e}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";import{__decorate as t}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";import{CommonModule as n}from"@angular/common";import{Component as r,EventEmitter as i,HostListener as a,Input as o,Output as s,ViewChild as c,computed as l,signal as u}from"@angular/core";var d;let f=class{onClickOutside;pressDuration;isSelecting;click=new i;press=new i;containerRef;isHovered=u(!1);isSelectingState=u(!1);pressTimerRef=null;isSelectingComputed=l(()=>this.isSelecting??this.isSelectingState());isStringSlot=l(()=>!0);ngOnInit(){this.isSelectingState.set(this.isSelecting??!1)}ngOnDestroy(){this.clearPressTimer()}onDocumentMouseDown(e){this.handleClickOutside(e)}handleOnLongPress(){this.isSelectingState.set(!0),this.press.emit()}startPressTimer(){this.pressTimerRef=setTimeout(()=>{this.handleOnLongPress()},this.pressDuration??250)}clearPressTimer(){this.pressTimerRef&&=(clearTimeout(this.pressTimerRef),null)}handleMouseDown(){this.clearPressTimer(),this.startPressTimer()}handleMouseUp(){this.isHovered.set(!1),this.clearPressTimer()}handleClickOutside(e){this.containerRef?.nativeElement&&!this.containerRef.nativeElement.contains(e.target)&&(this.isSelectingState.set(!1),this.onClickOutside?.())}handleClick(e){this.isSelectingComputed()&&(e.preventDefault(),e.stopPropagation()),this.click.emit(e)}handleBlur(){this.isSelectingState.set(!1)}onMouseEnter(){this.isHovered.set(!0)}getContainerStyle(){return{display:this.isStringSlot()?`inline`:`inline-block`,cursor:`pointer`,userSelect:`none`,borderRadius:`0.375rem`,outlineWidth:`2px`,outlineOffset:`4px`,outlineStyle:`solid`,outlineColor:this.isSelectingComputed()||this.isHovered()?`inherit`:`transparent`,transition:`all 100ms 50ms ease-in-out`}}};t([o(),e(`design:type`,Function)],f.prototype,`onClickOutside`,void 0),t([o(),e(`design:type`,Number)],f.prototype,`pressDuration`,void 0),t([o(),e(`design:type`,Boolean)],f.prototype,`isSelecting`,void 0),t([s(),e(`design:type`,Object)],f.prototype,`click`,void 0),t([s(),e(`design:type`,Object)],f.prototype,`press`,void 0),t([c(`containerRef`,{static:!0}),e(`design:type`,Object)],f.prototype,`containerRef`,void 0),t([a(`document:mousedown`,[`$event`]),e(`design:type`,Function),e(`design:paramtypes`,[typeof(d=typeof MouseEvent<`u`&&MouseEvent)==`function`?d:Object]),e(`design:returntype`,void 0)],f.prototype,`onDocumentMouseDown`,null),f=t([r({selector:`app-content-selector`,template:`
103
2
  <span
104
3
  #containerRef
105
4
  role="button"
@@ -117,11 +16,5 @@ ContentSelectorComponent = __decorate([Component({
117
16
  >
118
17
  <ng-content></ng-content>
119
18
  </span>
120
- `,
121
- standalone: true,
122
- imports: [CommonModule]
123
- })], ContentSelectorComponent);
124
-
125
- //#endregion
126
- export { ContentSelectorComponent };
19
+ `,standalone:!0,imports:[n]})],f);export{f as ContentSelectorComponent};
127
20
  //# sourceMappingURL=ContentSelector.component.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.component.mjs","names":[],"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n computed,\n type ElementRef,\n EventEmitter,\n HostListener,\n Input,\n type OnDestroy,\n type OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":";;;;;;;AAeA,MAAM,gCAAgC;AA0B/B,qCAAM,yBAAsD;CACjE,AAAS;CACT,AAAS;CACT,AAAS;CAET,AAAU,QAAQ,IAAI,cAA0B;CAChD,AAAU,QAAQ,IAAI,cAAoB;CAE1C,AACA;CAEA,AAAQ,YAAY,OAAO,MAAM;CACjC,AAAQ,mBAAmB,OAAO,MAAM;CACxC,AAAQ,gBAAsD;CAE9D,AAAiB,sBAAsB,eAC/B,KAAK,eAAe,KAAK,kBAAkB,CAClD;CAED,AAAiB,eAAe,eAAe;AAG7C,SAAO;GACP;CAEF,WAAiB;AACf,OAAK,iBAAiB,IAAI,KAAK,eAAe,MAAM;;CAGtD,cAAoB;AAClB,OAAK,iBAAiB;;CAGxB,AACA,oBAAoB,OAAyB;AAC3C,OAAK,mBAAmB,MAAM;;CAGhC,AAAQ,oBAA0B;AAChC,OAAK,iBAAiB,IAAI,KAAK;AAC/B,OAAK,MAAM,MAAM;;CAGnB,AAAQ,kBAAwB;AAC9B,OAAK,gBAAgB,iBAAiB;AACpC,QAAK,mBAAmB;KACvB,KAAK,iBAAiB,8BAA8B;;CAGzD,AAAQ,kBAAwB;AAC9B,MAAI,KAAK,eAAe;AACtB,gBAAa,KAAK,cAAc;AAChC,QAAK,gBAAgB;;;CAIzB,kBAAwB;AACtB,OAAK,iBAAiB;AACtB,OAAK,iBAAiB;;CAGxB,gBAAsB;AACpB,OAAK,UAAU,IAAI,MAAM;AACzB,OAAK,iBAAiB;;CAGxB,AAAQ,mBAAmB,OAAyB;AAClD,MACE,KAAK,cAAc,iBACnB,CAAC,KAAK,aAAa,cAAc,SAAS,MAAM,OAAe,EAC/D;AACA,QAAK,iBAAiB,IAAI,MAAM;AAChC,QAAK,kBAAkB;;;CAI3B,YAAY,GAAqB;AAC/B,MAAI,KAAK,qBAAqB,EAAE;AAC9B,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;AAErB,OAAK,MAAM,KAAK,EAAE;;CAGpB,aAAmB;AACjB,OAAK,iBAAiB,IAAI,MAAM;;CAGlC,eAAqB;AACnB,OAAK,UAAU,IAAI,KAAK;;CAG1B,oBAA4C;AAC1C,SAAO;GACL,SAAS,KAAK,cAAc,GAAG,WAAW;GAC1C,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,KAAK,qBAAqB,IAAI,KAAK,WAAW,GAC1C,YACA;GACN,YAAY;GACb;;;YAzGF,OAAO;YACP,OAAO;YACP,OAAO;YAEP,QAAQ;YACR,QAAQ;YAER,UAAU,gBAAgB,EAAE,QAAQ,MAAM,CAAC;;CAyB3C,aAAa,sBAAsB,CAAC,SAAS,CAAC;;;;;uCAzDhD,UAAU;CACT,UAAU;CACV,UAAU;;;;;;;;;;;;;;;;;;;CAmBV,YAAY;CACZ,SAAS,CAAC,aAAa;CACxB,CAAC"}
1
+ {"version":3,"file":"ContentSelector.component.mjs","names":[],"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n computed,\n type ElementRef,\n EventEmitter,\n HostListener,\n Input,\n type OnDestroy,\n type OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":"2YAyCO,IAAA,EAAA,KAA4D,CACjE,eACA,cACA,YAEA,MAAkB,IAAI,EACtB,MAAkB,IAAI,EAEtB,aAGA,UAAoB,EAAO,GAAM,CACjC,iBAA2B,EAAO,GAAM,CACxC,cAA8D,KAE9D,oBAAuC,MAC/B,KAAK,aAAe,KAAK,kBAAkB,CAClD,CAED,aAAgC,MAGvB,GACP,CAEF,UAAiB,CACf,KAAK,iBAAiB,IAAI,KAAK,aAAe,GAAM,CAGtD,aAAoB,CAClB,KAAK,iBAAiB,CAGxB,oBACoB,EAAyB,CAC3C,KAAK,mBAAmB,EAAM,CAGhC,mBAAkC,CAChC,KAAK,iBAAiB,IAAI,GAAK,CAC/B,KAAK,MAAM,MAAM,CAGnB,iBAAgC,CAC9B,KAAK,cAAgB,eAAiB,CACpC,KAAK,mBAAmB,EACvB,KAAK,eAAiB,IAA8B,CAGzD,iBAAgC,CAC9B,AAEE,KAAK,iBADL,aAAa,KAAK,cAAc,CACX,MAIzB,iBAAwB,CACtB,KAAK,iBAAiB,CACtB,KAAK,iBAAiB,CAGxB,eAAsB,CACpB,KAAK,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,CACxB,CAAC,CAAA,CAAA,EAAA"}
@@ -1,10 +1 @@
1
- //#region \0@oxc-project+runtime@0.112.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 };
1
+ function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}export{e as __decorate};
@@ -1,7 +1 @@
1
- //#region \0@oxc-project+runtime@0.112.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
+ function e(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}export{e as __decorateMetadata};
@@ -1,10 +1 @@
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
+ 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};