angular-intlayer 5.5.8 → 5.5.10

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 (262) hide show
  1. package/README.md +42 -9
  2. package/dist/cjs/UI/ContentSelector.component.cjs +141 -0
  3. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -0
  4. package/dist/cjs/client/index.cjs +13 -27
  5. package/dist/cjs/client/index.cjs.map +1 -1
  6. package/dist/cjs/client/installIntlayer.cjs +72 -0
  7. package/dist/cjs/client/installIntlayer.cjs.map +1 -0
  8. package/dist/cjs/client/{getDictionary.cjs → useDictionary.cjs} +15 -19
  9. package/dist/cjs/client/useDictionary.cjs.map +1 -0
  10. package/dist/cjs/client/useDictionaryDynamic.cjs +42 -0
  11. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
  12. package/dist/cjs/client/{getBrowserLocale.cjs → useIntlayer.cjs} +17 -11
  13. package/dist/cjs/client/useIntlayer.cjs.map +1 -0
  14. package/dist/cjs/client/{intlayer.service.cjs → useLoadDynamic.cjs} +21 -19
  15. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -0
  16. package/dist/cjs/client/useLocale.cjs +69 -0
  17. package/dist/cjs/client/useLocale.cjs.map +1 -0
  18. package/dist/cjs/client/useLocaleCookie.cjs +60 -0
  19. package/dist/cjs/client/useLocaleCookie.cjs.map +1 -0
  20. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +73 -0
  21. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -0
  22. package/dist/cjs/editor/EditedContentRenderer.component.cjs +77 -0
  23. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -0
  24. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +58 -0
  25. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -0
  26. package/dist/cjs/editor/changedContent.cjs +62 -0
  27. package/dist/cjs/editor/changedContent.cjs.map +1 -0
  28. package/dist/cjs/editor/communicator.cjs +82 -0
  29. package/dist/cjs/editor/communicator.cjs.map +1 -0
  30. package/dist/cjs/editor/configuration.cjs +57 -0
  31. package/dist/cjs/editor/configuration.cjs.map +1 -0
  32. package/dist/cjs/editor/createSharedComposable.cjs +68 -0
  33. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -0
  34. package/dist/cjs/editor/dictionariesRecord.cjs +83 -0
  35. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -0
  36. package/dist/cjs/editor/editedContent.cjs +77 -0
  37. package/dist/cjs/editor/editedContent.cjs.map +1 -0
  38. package/dist/cjs/editor/editorEnabled.cjs +76 -0
  39. package/dist/cjs/editor/editorEnabled.cjs.map +1 -0
  40. package/dist/cjs/editor/editorLocale.cjs +47 -0
  41. package/dist/cjs/editor/editorLocale.cjs.map +1 -0
  42. package/dist/cjs/editor/focusDictionary.cjs +80 -0
  43. package/dist/cjs/editor/focusDictionary.cjs.map +1 -0
  44. package/dist/cjs/editor/index.cjs +38 -0
  45. package/dist/cjs/editor/index.cjs.map +1 -0
  46. package/dist/cjs/editor/installIntlayerEditor.cjs +72 -0
  47. package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -0
  48. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +83 -0
  49. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -0
  50. package/dist/cjs/editor/useCrossFrameState.cjs +95 -0
  51. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -0
  52. package/dist/cjs/editor/useCrossURLPathState.cjs +72 -0
  53. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -0
  54. package/dist/cjs/editor/useEditedContentRenderer.cjs +58 -0
  55. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -0
  56. package/dist/cjs/editor/useEditor.cjs +46 -0
  57. package/dist/cjs/editor/useEditor.cjs.map +1 -0
  58. package/dist/cjs/editor/useIframeClickInterceptor.cjs +62 -0
  59. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -0
  60. package/dist/cjs/getDictionary.cjs +15 -2
  61. package/dist/cjs/getDictionary.cjs.map +1 -1
  62. package/dist/cjs/getIntlayer.cjs +9 -2
  63. package/dist/cjs/getIntlayer.cjs.map +1 -1
  64. package/dist/cjs/markdown/index.cjs +3 -16
  65. package/dist/cjs/markdown/index.cjs.map +1 -1
  66. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +66 -0
  67. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -0
  68. package/dist/cjs/plugins.cjs +27 -18
  69. package/dist/cjs/plugins.cjs.map +1 -1
  70. package/dist/cjs/renderIntlayerNode.cjs +58 -0
  71. package/dist/cjs/renderIntlayerNode.cjs.map +1 -0
  72. package/dist/cjs/{client/getLocale.cjs → webpack/index.cjs} +6 -14
  73. package/dist/cjs/webpack/index.cjs.map +1 -0
  74. package/dist/cjs/webpack/mergeConfig.cjs +83 -0
  75. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -0
  76. package/dist/esm/UI/ContentSelector.component.mjs +126 -0
  77. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -0
  78. package/dist/esm/client/index.mjs +6 -16
  79. package/dist/esm/client/index.mjs.map +1 -1
  80. package/dist/esm/client/installIntlayer.mjs +35 -0
  81. package/dist/esm/client/installIntlayer.mjs.map +1 -0
  82. package/dist/esm/client/useDictionary.mjs +15 -0
  83. package/dist/esm/client/useDictionary.mjs.map +1 -0
  84. package/dist/esm/client/useDictionaryDynamic.mjs +18 -0
  85. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
  86. package/dist/esm/client/useIntlayer.mjs +15 -0
  87. package/dist/esm/client/useIntlayer.mjs.map +1 -0
  88. package/dist/esm/client/useLoadDynamic.mjs +21 -0
  89. package/dist/esm/client/useLoadDynamic.mjs.map +1 -0
  90. package/dist/esm/client/useLocale.mjs +35 -0
  91. package/dist/esm/client/useLocale.mjs.map +1 -0
  92. package/dist/esm/client/useLocaleCookie.mjs +24 -0
  93. package/dist/esm/client/useLocaleCookie.mjs.map +1 -0
  94. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +49 -0
  95. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -0
  96. package/dist/esm/editor/EditedContentRenderer.component.mjs +53 -0
  97. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -0
  98. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +34 -0
  99. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -0
  100. package/dist/esm/editor/changedContent.mjs +36 -0
  101. package/dist/esm/editor/changedContent.mjs.map +1 -0
  102. package/dist/esm/editor/communicator.mjs +46 -0
  103. package/dist/esm/editor/communicator.mjs.map +1 -0
  104. package/dist/esm/editor/configuration.mjs +23 -0
  105. package/dist/esm/editor/configuration.mjs.map +1 -0
  106. package/dist/esm/editor/createSharedComposable.mjs +43 -0
  107. package/dist/esm/editor/createSharedComposable.mjs.map +1 -0
  108. package/dist/esm/editor/dictionariesRecord.mjs +47 -0
  109. package/dist/esm/editor/dictionariesRecord.mjs.map +1 -0
  110. package/dist/esm/editor/editedContent.mjs +51 -0
  111. package/dist/esm/editor/editedContent.mjs.map +1 -0
  112. package/dist/esm/editor/editorEnabled.mjs +50 -0
  113. package/dist/esm/editor/editorEnabled.mjs.map +1 -0
  114. package/dist/esm/editor/editorLocale.mjs +23 -0
  115. package/dist/esm/editor/editorLocale.mjs.map +1 -0
  116. package/dist/esm/editor/focusDictionary.mjs +54 -0
  117. package/dist/esm/editor/focusDictionary.mjs.map +1 -0
  118. package/dist/esm/editor/index.mjs +10 -0
  119. package/dist/esm/editor/index.mjs.map +1 -0
  120. package/dist/esm/editor/installIntlayerEditor.mjs +38 -0
  121. package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -0
  122. package/dist/esm/editor/useCrossFrameMessageListener.mjs +59 -0
  123. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -0
  124. package/dist/esm/editor/useCrossFrameState.mjs +71 -0
  125. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -0
  126. package/dist/esm/editor/useCrossURLPathState.mjs +47 -0
  127. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -0
  128. package/dist/esm/editor/useEditedContentRenderer.mjs +37 -0
  129. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -0
  130. package/dist/esm/editor/useEditor.mjs +22 -0
  131. package/dist/esm/editor/useEditor.mjs.map +1 -0
  132. package/dist/esm/editor/useIframeClickInterceptor.mjs +37 -0
  133. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -0
  134. package/dist/esm/getDictionary.mjs +19 -1
  135. package/dist/esm/getDictionary.mjs.map +1 -1
  136. package/dist/esm/getIntlayer.mjs +14 -2
  137. package/dist/esm/getIntlayer.mjs.map +1 -1
  138. package/dist/esm/markdown/index.mjs +1 -10
  139. package/dist/esm/markdown/index.mjs.map +1 -1
  140. package/dist/esm/markdown/installIntlayerMarkdown.mjs +39 -0
  141. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -0
  142. package/dist/esm/plugins.mjs +27 -17
  143. package/dist/esm/plugins.mjs.map +1 -1
  144. package/dist/esm/renderIntlayerNode.mjs +34 -0
  145. package/dist/esm/renderIntlayerNode.mjs.map +1 -0
  146. package/dist/esm/webpack/index.mjs +2 -0
  147. package/dist/esm/webpack/index.mjs.map +1 -0
  148. package/dist/esm/webpack/mergeConfig.mjs +49 -0
  149. package/dist/esm/webpack/mergeConfig.mjs.map +1 -0
  150. package/dist/types/UI/ContentSelector.component.d.ts +32 -0
  151. package/dist/types/UI/ContentSelector.component.d.ts.map +1 -0
  152. package/dist/types/client/index.d.ts +6 -7
  153. package/dist/types/client/index.d.ts.map +1 -1
  154. package/dist/types/client/installIntlayer.d.ts +17 -0
  155. package/dist/types/client/installIntlayer.d.ts.map +1 -0
  156. package/dist/types/client/useDictionary.d.ts +5 -0
  157. package/dist/types/client/useDictionary.d.ts.map +1 -0
  158. package/dist/types/client/useDictionaryDynamic.d.ts +9 -0
  159. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
  160. package/dist/types/client/useIntlayer.d.ts +10 -0
  161. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  162. package/dist/types/client/useLoadDynamic.d.ts +8 -0
  163. package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
  164. package/dist/types/client/useLocale.d.ts +15 -0
  165. package/dist/types/client/useLocale.d.ts.map +1 -0
  166. package/dist/types/client/useLocaleCookie.d.ts +17 -0
  167. package/dist/types/client/useLocaleCookie.d.ts.map +1 -0
  168. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +19 -0
  169. package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -0
  170. package/dist/types/editor/EditedContentRenderer.component.d.ts +19 -0
  171. package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -0
  172. package/dist/types/editor/EditorSelectorRenderer.component.d.ts +13 -0
  173. package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -0
  174. package/dist/types/editor/changedContent.d.ts +14 -0
  175. package/dist/types/editor/changedContent.d.ts.map +1 -0
  176. package/dist/types/editor/communicator.d.ts +28 -0
  177. package/dist/types/editor/communicator.d.ts.map +1 -0
  178. package/dist/types/editor/configuration.d.ts +2 -0
  179. package/dist/types/editor/configuration.d.ts.map +1 -0
  180. package/dist/types/editor/createSharedComposable.d.ts +14 -0
  181. package/dist/types/editor/createSharedComposable.d.ts.map +1 -0
  182. package/dist/types/editor/dictionariesRecord.d.ts +16 -0
  183. package/dist/types/editor/dictionariesRecord.d.ts.map +1 -0
  184. package/dist/types/editor/editedContent.d.ts +19 -0
  185. package/dist/types/editor/editedContent.d.ts.map +1 -0
  186. package/dist/types/editor/editorEnabled.d.ts +16 -0
  187. package/dist/types/editor/editorEnabled.d.ts.map +1 -0
  188. package/dist/types/editor/editorLocale.d.ts +3 -0
  189. package/dist/types/editor/editorLocale.d.ts.map +1 -0
  190. package/dist/types/editor/focusDictionary.d.ts +24 -0
  191. package/dist/types/editor/focusDictionary.d.ts.map +1 -0
  192. package/dist/types/editor/index.d.ts +5 -0
  193. package/dist/types/editor/index.d.ts.map +1 -0
  194. package/dist/types/editor/installIntlayerEditor.d.ts +18 -0
  195. package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -0
  196. package/dist/types/editor/useCrossFrameMessageListener.d.ts +11 -0
  197. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -0
  198. package/dist/types/editor/useCrossFrameState.d.ts +24 -0
  199. package/dist/types/editor/useCrossFrameState.d.ts.map +1 -0
  200. package/dist/types/editor/useCrossURLPathState.d.ts +16 -0
  201. package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -0
  202. package/dist/types/editor/useEditedContentRenderer.d.ts +17 -0
  203. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -0
  204. package/dist/types/editor/useEditor.d.ts +2 -0
  205. package/dist/types/editor/useEditor.d.ts.map +1 -0
  206. package/dist/types/editor/useIframeClickInterceptor.d.ts +11 -0
  207. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -0
  208. package/dist/types/getDictionary.d.ts +4 -1
  209. package/dist/types/getDictionary.d.ts.map +1 -1
  210. package/dist/types/getIntlayer.d.ts +4 -6
  211. package/dist/types/getIntlayer.d.ts.map +1 -1
  212. package/dist/types/markdown/index.d.ts +1 -4
  213. package/dist/types/markdown/index.d.ts.map +1 -1
  214. package/dist/types/markdown/installIntlayerMarkdown.d.ts +26 -0
  215. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
  216. package/dist/types/plugins.d.ts +0 -9
  217. package/dist/types/plugins.d.ts.map +1 -1
  218. package/dist/types/renderIntlayerNode.d.ts +13 -0
  219. package/dist/types/renderIntlayerNode.d.ts.map +1 -0
  220. package/dist/types/webpack/index.d.ts +2 -0
  221. package/dist/types/webpack/index.d.ts.map +1 -0
  222. package/dist/types/webpack/mergeConfig.d.ts +3 -0
  223. package/dist/types/webpack/mergeConfig.d.ts.map +1 -0
  224. package/package.json +23 -9
  225. package/dist/cjs/client/dictionary.service.cjs +0 -70
  226. package/dist/cjs/client/dictionary.service.cjs.map +0 -1
  227. package/dist/cjs/client/getBrowserLocale.cjs.map +0 -1
  228. package/dist/cjs/client/getDictionary.cjs.map +0 -1
  229. package/dist/cjs/client/getLocale.cjs.map +0 -1
  230. package/dist/cjs/client/intlayer.service.cjs.map +0 -1
  231. package/dist/cjs/client/locale.service.cjs +0 -66
  232. package/dist/cjs/client/locale.service.cjs.map +0 -1
  233. package/dist/cjs/client/t.cjs +0 -32
  234. package/dist/cjs/client/t.cjs.map +0 -1
  235. package/dist/esm/client/dictionary.service.mjs +0 -46
  236. package/dist/esm/client/dictionary.service.mjs.map +0 -1
  237. package/dist/esm/client/getBrowserLocale.mjs +0 -10
  238. package/dist/esm/client/getBrowserLocale.mjs.map +0 -1
  239. package/dist/esm/client/getDictionary.mjs +0 -25
  240. package/dist/esm/client/getDictionary.mjs.map +0 -1
  241. package/dist/esm/client/getLocale.mjs +0 -7
  242. package/dist/esm/client/getLocale.mjs.map +0 -1
  243. package/dist/esm/client/intlayer.service.mjs +0 -19
  244. package/dist/esm/client/intlayer.service.mjs.map +0 -1
  245. package/dist/esm/client/locale.service.mjs +0 -42
  246. package/dist/esm/client/locale.service.mjs.map +0 -1
  247. package/dist/esm/client/t.mjs +0 -8
  248. package/dist/esm/client/t.mjs.map +0 -1
  249. package/dist/types/client/dictionary.service.d.ts +0 -21
  250. package/dist/types/client/dictionary.service.d.ts.map +0 -1
  251. package/dist/types/client/getBrowserLocale.d.ts +0 -6
  252. package/dist/types/client/getBrowserLocale.d.ts.map +0 -1
  253. package/dist/types/client/getDictionary.d.ts +0 -8
  254. package/dist/types/client/getDictionary.d.ts.map +0 -1
  255. package/dist/types/client/getLocale.d.ts +0 -7
  256. package/dist/types/client/getLocale.d.ts.map +0 -1
  257. package/dist/types/client/intlayer.service.d.ts +0 -8
  258. package/dist/types/client/intlayer.service.d.ts.map +0 -1
  259. package/dist/types/client/locale.service.d.ts +0 -12
  260. package/dist/types/client/locale.service.d.ts.map +0 -1
  261. package/dist/types/client/t.d.ts +0 -8
  262. package/dist/types/client/t.d.ts.map +0 -1
@@ -0,0 +1,35 @@
1
+ import { computed, inject } from "@angular/core";
2
+ import configuration from "@intlayer/config/built";
3
+ import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
4
+ import { useLocaleCookie } from "./useLocaleCookie.mjs";
5
+ const useLocale = ({ onLocaleChange } = {}) => {
6
+ const { defaultLocale, locales: availableLocales } = configuration?.internationalization ?? {};
7
+ const intlayer = inject(INTLAYER_TOKEN);
8
+ const { setLocaleCookie } = useLocaleCookie();
9
+ const locale = computed(() => intlayer?.locale() ?? defaultLocale);
10
+ const setLocale = (newLocale) => {
11
+ if (!availableLocales?.map(String).includes(newLocale)) {
12
+ console.error(`Locale ${newLocale} is not available`);
13
+ return;
14
+ }
15
+ if (intlayer) {
16
+ intlayer.setLocale(newLocale);
17
+ }
18
+ setLocaleCookie(newLocale);
19
+ onLocaleChange?.(newLocale);
20
+ };
21
+ return {
22
+ locale,
23
+ // Current locale
24
+ defaultLocale,
25
+ // Principal locale defined in config
26
+ availableLocales,
27
+ // List of the available locales defined in config
28
+ setLocale
29
+ // Function to set the locale
30
+ };
31
+ };
32
+ export {
33
+ useLocale
34
+ };
35
+ //# sourceMappingURL=useLocale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\nimport { useLocaleCookie } from './useLocaleCookie';\n\ntype useLocaleProps = {\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, composable to get the current locale and all related fields\n */\nexport const useLocale = ({ onLocaleChange }: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n const { setLocaleCookie } = useLocaleCookie();\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleCookie(newLocale);\n onLocaleChange?.(newLocale);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":"AAAA,SAAS,UAAU,cAAc;AACjC,OAAO,mBAAmB;AAE1B,SAAS,sBAAwC;AACjD,SAAS,uBAAuB;AASzB,MAAM,YAAY,CAAC,EAAE,eAAe,IAAoB,CAAC,MAAM;AACpE,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,eAAe,wBAAwB,CAAC;AAC1C,QAAM,WAAW,OAAyB,cAAc;AACxD,QAAM,EAAE,gBAAgB,IAAI,gBAAgB;AAG5C,QAAM,SAAS,SAAS,MAAM,UAAU,OAAO,KAAK,aAAa;AAEjE,QAAM,YAAY,CAAC,cAA6B;AAC9C,QAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAAS,SAAS,GAAG;AACtD,cAAQ,MAAM,UAAU,SAAS,mBAAmB;AACpD;AAAA,IACF;AAEA,QAAI,UAAU;AACZ,eAAS,UAAU,SAAS;AAAA,IAC9B;AACA,oBAAgB,SAAS;AACzB,qBAAiB,SAAS;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,24 @@
1
+ import configuration from "@intlayer/config/built";
2
+ import Cookies from "js-cookie";
3
+ const { cookieName } = configuration.middleware;
4
+ const cookieAttributes = {
5
+ path: "/",
6
+ expires: void 0,
7
+ domain: void 0,
8
+ secure: false,
9
+ sameSite: "strict"
10
+ };
11
+ const localeCookie = Cookies.get(cookieName);
12
+ const setLocaleCookie = (locale) => {
13
+ Cookies.set(cookieName, locale, cookieAttributes);
14
+ };
15
+ const useLocaleCookie = () => ({
16
+ localeCookie,
17
+ setLocaleCookie
18
+ });
19
+ export {
20
+ localeCookie,
21
+ setLocaleCookie,
22
+ useLocaleCookie
23
+ };
24
+ //# sourceMappingURL=useLocaleCookie.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\n\nimport Cookies from 'js-cookie';\n\nconst { cookieName } = configuration.middleware;\n\nconst cookieAttributes: Cookies.CookieAttributes = {\n path: '/',\n expires: undefined,\n domain: undefined,\n secure: false,\n sameSite: 'strict',\n};\n\n/**\n * Get the locale cookie\n */\nexport const localeCookie = Cookies.get(cookieName) as unknown as\n | LocalesValues\n | undefined;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleCookie = (locale: LocalesValues) => {\n Cookies.set(cookieName, locale, cookieAttributes);\n};\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = () => ({\n localeCookie,\n setLocaleCookie,\n});\n"],"mappings":"AAAA,OAAO,mBAAmB;AAG1B,OAAO,aAAa;AAEpB,MAAM,EAAE,WAAW,IAAI,cAAc;AAErC,MAAM,mBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ;AAKO,MAAM,eAAe,QAAQ,IAAI,UAAU;AAO3C,MAAM,kBAAkB,CAAC,WAA0B;AACxD,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
@@ -0,0 +1,49 @@
1
+ import { CommonModule } from "@angular/common";
2
+ import { Component, Input, computed } from "@angular/core";
3
+ import { isSameKeyPath } from "@intlayer/core";
4
+ import { ContentSelectorComponent } from "../UI/ContentSelector.component.mjs";
5
+ import { useEditorEnabled } from "./editorEnabled.mjs";
6
+ import { useFocusDictionary } from "./focusDictionary.mjs";
7
+ import { useEditor } from "./useEditor.mjs";
8
+ @Component({
9
+ selector: "app-content-selector-wrapper",
10
+ standalone: true,
11
+ imports: [CommonModule, ContentSelectorComponent],
12
+ template: `
13
+ <app-content-selector
14
+ *ngIf="enabled()"
15
+ (press)="handleSelect()"
16
+ [isSelecting]="isSelected()"
17
+ >
18
+ <ng-content></ng-content>
19
+ </app-content-selector>
20
+ <ng-content *ngIf="!enabled()"></ng-content>
21
+ `
22
+ })
23
+ class ContentSelectorWrapperComponent {
24
+ @Input() dictionaryKey;
25
+ @Input() keyPath;
26
+ // pull in the editor state & focus API
27
+ focusDictionary = useFocusDictionary();
28
+ editorEnabled = useEditorEnabled();
29
+ constructor() {
30
+ useEditor();
31
+ }
32
+ // compute whether this node is the current focus
33
+ isSelected = computed(() => {
34
+ const focusedContent = this.focusDictionary.focusedContent();
35
+ return focusedContent?.dictionaryKey === this.dictionaryKey && (focusedContent.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath);
36
+ });
37
+ enabled = computed(() => this.editorEnabled.enabled());
38
+ // when the selector is clicked, update focus
39
+ handleSelect() {
40
+ this.focusDictionary.setFocusedContent({
41
+ dictionaryKey: this.dictionaryKey,
42
+ keyPath: this.keyPath
43
+ });
44
+ }
45
+ }
46
+ export {
47
+ ContentSelectorWrapperComponent
48
+ };
49
+ //# sourceMappingURL=ContentSelectorWrapper.component.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input, computed } from '@angular/core';\nimport { isSameKeyPath, type NodeProps } from '@intlayer/core';\nimport { ContentSelectorComponent } from '../UI/ContentSelector.component';\nimport { useEditorEnabled } from './editorEnabled';\nimport { useFocusDictionary } from './focusDictionary';\nimport { useEditor } from './useEditor';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface ContentSelectorWrapperProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n imports: [CommonModule, ContentSelectorComponent],\n template: `\n <app-content-selector\n *ngIf=\"enabled()\"\n (press)=\"handleSelect()\"\n [isSelecting]=\"isSelected()\"\n >\n <ng-content></ng-content>\n </app-content-selector>\n <ng-content *ngIf=\"!enabled()\"></ng-content>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n // pull in the editor state & focus API\n private focusDictionary = useFocusDictionary();\n private editorEnabled = useEditorEnabled();\n\n constructor() {\n useEditor();\n }\n\n // compute whether this node is the current focus\n isSelected = computed(() => {\n const focusedContent = this.focusDictionary.focusedContent();\n return (\n focusedContent?.dictionaryKey === this.dictionaryKey &&\n (focusedContent.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent.keyPath ?? [], this.keyPath)\n );\n });\n\n enabled = computed(() => this.editorEnabled.enabled());\n\n // when the selector is clicked, update focus\n handleSelect() {\n this.focusDictionary.setFocusedContent({\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n });\n }\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAC7B,SAAS,WAAW,OAAO,gBAAgB;AAC3C,SAAS,qBAAqC;AAC9C,SAAS,gCAAgC;AACzC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAU1B,CAAC,UAAU;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS,CAAC,cAAc,wBAAwB;AAAA,EAChD,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUZ,CAAC;AACM,MAAM,gCAAgC;AAC3C,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AAAA;AAAA,EAGD,kBAAkB,mBAAmB;AAAA,EACrC,gBAAgB,iBAAiB;AAAA,EAEzC,cAAc;AACZ,cAAU;AAAA,EACZ;AAAA;AAAA,EAGA,aAAa,SAAS,MAAM;AAC1B,UAAM,iBAAiB,KAAK,gBAAgB,eAAe;AAC3D,WACE,gBAAgB,kBAAkB,KAAK,kBACtC,eAAe,SAAS,UAAU,KAAK,KACxC,cAAc,eAAe,WAAW,CAAC,GAAG,KAAK,OAAO;AAAA,EAE5D,CAAC;AAAA,EAED,UAAU,SAAS,MAAM,KAAK,cAAc,QAAQ,CAAC;AAAA;AAAA,EAGrD,eAAe;AACb,SAAK,gBAAgB,kBAAkB;AAAA,MACrC,eAAe,KAAK;AAAA,MACpB,SAAS,KAAK;AAAA,IAChB,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,53 @@
1
+ import { CommonModule } from "@angular/common";
2
+ import { Component, Input, computed, signal } from "@angular/core";
3
+ import { getContent } from "@intlayer/core";
4
+ import { useEditedContentRenderer } from "./useEditedContentRenderer.mjs";
5
+ @Component({
6
+ selector: "app-edited-content-renderer",
7
+ standalone: true,
8
+ imports: [CommonModule],
9
+ template: ` <span [innerHTML]="renderedContent()"></span> `
10
+ })
11
+ class EditedContentRendererComponent {
12
+ @Input() dictionaryKey;
13
+ @Input() keyPath;
14
+ @Input() locale;
15
+ fallback = signal("");
16
+ rawContent = computed(() => {
17
+ return useEditedContentRenderer(
18
+ this.dictionaryKey,
19
+ this.keyPath,
20
+ this.fallback
21
+ );
22
+ });
23
+ /**
24
+ * Object → getContent → string, same as the React version.
25
+ */
26
+ renderedContent = computed(() => {
27
+ const rawContentValue = this.rawContent();
28
+ if (typeof rawContentValue === "object" && rawContentValue !== null) {
29
+ const transformed = getContent(
30
+ rawContentValue,
31
+ {
32
+ dictionaryKey: this.dictionaryKey,
33
+ keyPath: this.keyPath
34
+ },
35
+ this.locale
36
+ );
37
+ if (typeof transformed !== "string") {
38
+ console.error(
39
+ `Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(
40
+ transformed
41
+ )}`
42
+ );
43
+ return this.fallback();
44
+ }
45
+ return transformed;
46
+ }
47
+ return rawContentValue();
48
+ });
49
+ }
50
+ export {
51
+ EditedContentRendererComponent
52
+ };
53
+ //# sourceMappingURL=EditedContentRenderer.component.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/EditedContentRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input, computed, signal } from '@angular/core';\nimport type { Locales } from '@intlayer/config/client';\nimport { ContentNode, getContent, type KeyPath } from '@intlayer/core';\nimport { useEditedContentRenderer } from './useEditedContentRenderer';\n\nexport interface EditedContentRendererProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: Locales;\n}\n\n@Component({\n selector: 'app-edited-content-renderer',\n standalone: true,\n imports: [CommonModule],\n template: ` <span [innerHTML]=\"renderedContent()\"></span> `,\n})\nexport class EditedContentRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: KeyPath[];\n @Input() locale?: Locales;\n\n private fallback = signal('');\n\n private rawContent = computed(() => {\n return useEditedContentRenderer(\n this.dictionaryKey,\n this.keyPath,\n this.fallback\n );\n });\n\n /**\n * Object → getContent → string, same as the React version.\n */\n renderedContent = computed(() => {\n const rawContentValue = this.rawContent();\n\n if (typeof rawContentValue === 'object' && rawContentValue !== null) {\n const transformed = getContent(\n rawContentValue as ContentNode,\n {\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n },\n this.locale\n );\n\n if (typeof transformed !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(\n transformed\n )}`\n );\n return this.fallback();\n }\n return transformed;\n }\n\n return rawContentValue() as string;\n });\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAC7B,SAAS,WAAW,OAAO,UAAU,cAAc;AAEnD,SAAsB,kBAAgC;AACtD,SAAS,gCAAgC;AAQzC,CAAC,UAAU;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS,CAAC,YAAY;AAAA,EACtB,UAAU;AACZ,CAAC;AACM,MAAM,+BAA+B;AAC1C,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AAAA,EAED,WAAW,OAAO,EAAE;AAAA,EAEpB,aAAa,SAAS,MAAM;AAClC,WAAO;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF,CAAC;AAAA;AAAA;AAAA;AAAA,EAKD,kBAAkB,SAAS,MAAM;AAC/B,UAAM,kBAAkB,KAAK,WAAW;AAExC,QAAI,OAAO,oBAAoB,YAAY,oBAAoB,MAAM;AACnE,YAAM,cAAc;AAAA,QAClB;AAAA,QACA;AAAA,UACE,eAAe,KAAK;AAAA,UACpB,SAAS,KAAK;AAAA,QAChB;AAAA,QACA,KAAK;AAAA,MACP;AAEA,UAAI,OAAO,gBAAgB,UAAU;AACnC,gBAAQ;AAAA,UACN,kDAAkD,OAAO,WAAW,4BAA4B,KAAK;AAAA,YACnG;AAAA,UACF,CAAC;AAAA,QACH;AACA,eAAO,KAAK,SAAS;AAAA,MACvB;AACA,aAAO;AAAA,IACT;AAEA,WAAO,gBAAgB;AAAA,EACzB,CAAC;AACH;","names":[]}
@@ -0,0 +1,34 @@
1
+ import { CommonModule } from "@angular/common";
2
+ import { Component, Input } from "@angular/core";
3
+ import { ContentSelectorWrapperComponent } from "./ContentSelectorWrapper.component.mjs";
4
+ import { EditedContentRendererComponent } from "./EditedContentRenderer.component.mjs";
5
+ @Component({
6
+ selector: "app-editor-selector-renderer",
7
+ standalone: true,
8
+ imports: [
9
+ CommonModule,
10
+ ContentSelectorWrapperComponent,
11
+ EditedContentRendererComponent
12
+ ],
13
+ template: `
14
+ <app-content-selector-wrapper
15
+ [dictionaryKey]="dictionaryKey"
16
+ [keyPath]="keyPath"
17
+ >
18
+ <app-edited-content-renderer
19
+ [dictionaryKey]="dictionaryKey"
20
+ [keyPath]="keyPath"
21
+ >
22
+ <ng-content></ng-content>
23
+ </app-edited-content-renderer>
24
+ </app-content-selector-wrapper>
25
+ `
26
+ })
27
+ class EditorSelectorRendererComponent {
28
+ @Input() dictionaryKey;
29
+ @Input() keyPath;
30
+ }
31
+ export {
32
+ EditorSelectorRendererComponent
33
+ };
34
+ //# sourceMappingURL=EditorSelectorRenderer.component.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/EditorSelectorRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input } from '@angular/core';\nimport { type NodeProps } from '@intlayer/core';\nimport { ContentSelectorWrapperComponent } from './ContentSelectorWrapper.component';\nimport { EditedContentRendererComponent } from './EditedContentRenderer.component';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface EditorSelectorRendererProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-editor-selector-renderer',\n standalone: true,\n imports: [\n CommonModule,\n ContentSelectorWrapperComponent,\n EditedContentRendererComponent,\n ],\n template: `\n <app-content-selector-wrapper\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <app-edited-content-renderer\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <ng-content></ng-content>\n </app-edited-content-renderer>\n </app-content-selector-wrapper>\n `,\n})\nexport class EditorSelectorRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAC7B,SAAS,WAAW,aAAa;AAEjC,SAAS,uCAAuC;AAChD,SAAS,sCAAsC;AAU/C,CAAC,UAAU;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaZ,CAAC;AACM,MAAM,gCAAgC;AAC3C,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AACX;","names":[]}
@@ -0,0 +1,36 @@
1
+ import { signal } from "@angular/core";
2
+ let instance = null;
3
+ const INTLAYER_CHANGED_CONTENT_SYMBOL = Symbol("intlayerChangedContent");
4
+ const createChangedContentClient = () => {
5
+ if (instance) return instance;
6
+ const stateSignal = signal({});
7
+ const setChangedContent = (dictionaryKey, newValue) => {
8
+ const currentState = stateSignal();
9
+ stateSignal.set({
10
+ ...currentState,
11
+ [dictionaryKey]: {
12
+ ...currentState[dictionaryKey] ?? { key: dictionaryKey, content: {} },
13
+ content: newValue
14
+ }
15
+ });
16
+ };
17
+ instance = {
18
+ get content() {
19
+ return stateSignal();
20
+ },
21
+ setContent: setChangedContent
22
+ };
23
+ return instance;
24
+ };
25
+ const installChangedContent = (injector) => {
26
+ const client = createChangedContentClient();
27
+ };
28
+ const useChangedContent = () => {
29
+ return createChangedContentClient();
30
+ };
31
+ export {
32
+ createChangedContentClient,
33
+ installChangedContent,
34
+ useChangedContent
35
+ };
36
+ //# sourceMappingURL=changedContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/changedContent.ts"],"sourcesContent":["import { Injector, signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/core';\n\n/**\n * Singleton instance\n */\nlet instance: ChangedContent | null = null;\n\nconst INTLAYER_CHANGED_CONTENT_SYMBOL = Symbol('intlayerChangedContent');\n\ntype ChangedContent = {\n content: Record<Dictionary['key'], Dictionary>;\n setContent: (key: Dictionary['key'], newValue: Dictionary['content']) => void;\n};\n\nexport const createChangedContentClient = () => {\n if (instance) return instance;\n\n const stateSignal = signal<ChangedContent['content']>({});\n\n /**\n * Sets the content for a specific dictionary\n * @param dictionaryKey - The key of the dictionary to update\n * @param newValue - The new content to set\n */\n const setChangedContent = (\n dictionaryKey: Dictionary['key'],\n newValue: Dictionary['content']\n ) => {\n const currentState = stateSignal();\n stateSignal.set({\n ...currentState,\n [dictionaryKey]: {\n ...(currentState[dictionaryKey] ?? { key: dictionaryKey, content: {} }),\n content: newValue,\n } as Dictionary,\n });\n };\n\n instance = {\n get content() {\n return stateSignal();\n },\n setContent: setChangedContent,\n };\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer provider into the injector\n */\nexport const installChangedContent = (injector: Injector) => {\n const client = createChangedContentClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createChangedContentClient\n};\n\nexport const useChangedContent = () => {\n return createChangedContentClient();\n};\n"],"mappings":"AAAA,SAAmB,cAAc;AAMjC,IAAI,WAAkC;AAEtC,MAAM,kCAAkC,OAAO,wBAAwB;AAOhE,MAAM,6BAA6B,MAAM;AAC9C,MAAI,SAAU,QAAO;AAErB,QAAM,cAAc,OAAkC,CAAC,CAAC;AAOxD,QAAM,oBAAoB,CACxB,eACA,aACG;AACH,UAAM,eAAe,YAAY;AACjC,gBAAY,IAAI;AAAA,MACd,GAAG;AAAA,MACH,CAAC,aAAa,GAAG;AAAA,QACf,GAAI,aAAa,aAAa,KAAK,EAAE,KAAK,eAAe,SAAS,CAAC,EAAE;AAAA,QACrE,SAAS;AAAA,MACX;AAAA,IACF,CAAC;AAAA,EACH;AAEA,aAAW;AAAA,IACT,IAAI,UAAU;AACZ,aAAO,YAAY;AAAA,IACrB;AAAA,IACA,YAAY;AAAA,EACd;AAEA,SAAO;AACT;AAKO,MAAM,wBAAwB,CAAC,aAAuB;AAC3D,QAAM,SAAS,2BAA2B;AAI5C;AAEO,MAAM,oBAAoB,MAAM;AACrC,SAAO,2BAA2B;AACpC;","names":[]}
@@ -0,0 +1,46 @@
1
+ import configuration from "@intlayer/config/built";
2
+ import { v4 as uuid } from "uuid";
3
+ const { editor } = configuration;
4
+ const defaultValue = {
5
+ postMessage: () => null,
6
+ allowedOrigins: [
7
+ editor?.applicationURL,
8
+ editor?.editorURL,
9
+ editor?.cmsURL
10
+ ],
11
+ senderId: ""
12
+ };
13
+ let instance = null;
14
+ const INTLAYER_COMMUNICATOR_SYMBOL = Symbol("Communicator");
15
+ const createCommunicator = (options = { postMessage: () => null }) => {
16
+ if (instance) return instance;
17
+ instance = {
18
+ ...defaultValue,
19
+ ...options,
20
+ senderId: uuid()
21
+ };
22
+ return instance;
23
+ };
24
+ const installCommunicator = (injector, options = { postMessage: () => null }) => {
25
+ const client = createCommunicator(options);
26
+ };
27
+ const useCommunicator = () => {
28
+ try {
29
+ const communicator = createCommunicator();
30
+ return communicator || defaultValue;
31
+ } catch (error) {
32
+ console.warn(
33
+ "useCommunicator: Error accessing communicator. Returning default communicator."
34
+ );
35
+ return {
36
+ postMessage: () => null,
37
+ senderId: ""
38
+ };
39
+ }
40
+ };
41
+ export {
42
+ createCommunicator,
43
+ installCommunicator,
44
+ useCommunicator
45
+ };
46
+ //# sourceMappingURL=communicator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/communicator.ts"],"sourcesContent":["import { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { v4 as uuid } from 'uuid';\n\n/**\n * Interface defining a cross-frame communicator\n */\nexport type Communicator = {\n postMessage: typeof window.postMessage;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Configuration options for the communicator\n */\nexport type CommunicatorOptions = Omit<Communicator, 'senderId'>;\n\nconst { editor } = configuration;\n\n/**\n * Default values for the communicator\n */\nconst defaultValue: Communicator = {\n postMessage: () => null,\n allowedOrigins: [\n editor?.applicationURL,\n editor?.editorURL,\n editor?.cmsURL,\n ] as string[],\n senderId: '',\n};\n\n/**\n * Singleton instance\n */\nlet instance: Communicator | null = null;\n\nconst INTLAYER_COMMUNICATOR_SYMBOL = Symbol('Communicator');\n\n/**\n * Creates a communicator client\n * @param options - Options for configuring the communicator\n */\nexport const createCommunicator = (\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n if (instance) return instance;\n\n instance = {\n ...defaultValue,\n ...options,\n senderId: uuid(),\n };\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer communicator into the injector\n */\nexport const installCommunicator = (\n injector: Injector,\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n const client = createCommunicator(options);\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createCommunicator\n};\n\n/**\n * Hook to access the communicator\n * @returns The communicator instance\n */\nexport const useCommunicator = (): Communicator => {\n try {\n const communicator = createCommunicator();\n return communicator || defaultValue;\n } catch (error) {\n console.warn(\n 'useCommunicator: Error accessing communicator. Returning default communicator.'\n );\n return {\n postMessage: () => null,\n senderId: '',\n };\n }\n};\n"],"mappings":"AACA,OAAO,mBAAmB;AAC1B,SAAS,MAAM,YAAY;AAgB3B,MAAM,EAAE,OAAO,IAAI;AAKnB,MAAM,eAA6B;AAAA,EACjC,aAAa,MAAM;AAAA,EACnB,gBAAgB;AAAA,IACd,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAAA,EACA,UAAU;AACZ;AAKA,IAAI,WAAgC;AAEpC,MAAM,+BAA+B,OAAO,cAAc;AAMnD,MAAM,qBAAqB,CAChC,UAA+B,EAAE,aAAa,MAAM,KAAK,MACtD;AACH,MAAI,SAAU,QAAO;AAErB,aAAW;AAAA,IACT,GAAG;AAAA,IACH,GAAG;AAAA,IACH,UAAU,KAAK;AAAA,EACjB;AAEA,SAAO;AACT;AAKO,MAAM,sBAAsB,CACjC,UACA,UAA+B,EAAE,aAAa,MAAM,KAAK,MACtD;AACH,QAAM,SAAS,mBAAmB,OAAO;AAI3C;AAMO,MAAM,kBAAkB,MAAoB;AACjD,MAAI;AACF,UAAM,eAAe,mBAAmB;AACxC,WAAO,gBAAgB;AAAA,EACzB,SAAS,OAAO;AACd,YAAQ;AAAA,MACN;AAAA,IACF;AACA,WAAO;AAAA,MACL,aAAa,MAAM;AAAA,MACnB,UAAU;AAAA,IACZ;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,23 @@
1
+ import { DestroyRef, inject } from "@angular/core";
2
+ import configuration from "@intlayer/config/built";
3
+ import { MessageKey } from "@intlayer/editor";
4
+ import { useCrossFrameState } from "./useCrossFrameState.mjs";
5
+ const useConfiguration = () => {
6
+ const [pushedConfiguration, setConfiguration] = useCrossFrameState(MessageKey.INTLAYER_CONFIGURATION);
7
+ try {
8
+ const destroyRef = inject(DestroyRef, { optional: true });
9
+ if (destroyRef) {
10
+ if (!pushedConfiguration()) {
11
+ setConfiguration(configuration);
12
+ }
13
+ }
14
+ } catch {
15
+ console.warn(
16
+ "useConfiguration called outside injection context; configuration may not be synchronized."
17
+ );
18
+ }
19
+ };
20
+ export {
21
+ useConfiguration
22
+ };
23
+ //# sourceMappingURL=configuration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/configuration.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { IntlayerConfig } from '@intlayer/config/client';\nimport { MessageKey } from '@intlayer/editor';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useConfiguration = () => {\n const [pushedConfiguration, setConfiguration] =\n useCrossFrameState<IntlayerConfig>(MessageKey.INTLAYER_CONFIGURATION);\n\n // Use Angular's injection context instead of Vue's onMounted\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef) {\n // Execute immediately since Angular doesn't have the same lifecycle hooks\n if (!pushedConfiguration()) {\n setConfiguration(configuration);\n }\n }\n } catch {\n console.warn(\n 'useConfiguration called outside injection context; ' +\n 'configuration may not be synchronized.'\n );\n }\n};\n"],"mappings":"AAAA,SAAS,YAAY,cAAc;AACnC,OAAO,mBAAmB;AAE1B,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAE5B,MAAM,mBAAmB,MAAM;AACpC,QAAM,CAAC,qBAAqB,gBAAgB,IAC1C,mBAAmC,WAAW,sBAAsB;AAGtE,MAAI;AACF,UAAM,aAAa,OAAO,YAAY,EAAE,UAAU,KAAK,CAAC;AAExD,QAAI,YAAY;AAEd,UAAI,CAAC,oBAAoB,GAAG;AAC1B,yBAAiB,aAAa;AAAA,MAChC;AAAA,IACF;AAAA,EACF,QAAQ;AACN,YAAQ;AAAA,MACN;AAAA,IAEF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,43 @@
1
+ import { DestroyRef, inject } from "@angular/core";
2
+ function tryOnScopeDispose(fn) {
3
+ try {
4
+ const destroyRef = inject(DestroyRef, { optional: true });
5
+ if (destroyRef) {
6
+ destroyRef.onDestroy(fn);
7
+ return true;
8
+ }
9
+ return false;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }
14
+ const createSharedComposable = (composable) => {
15
+ let subscribers = 0;
16
+ let state;
17
+ let cleanupFn;
18
+ const dispose = () => {
19
+ subscribers -= 1;
20
+ if (cleanupFn && subscribers <= 0) {
21
+ cleanupFn();
22
+ state = void 0;
23
+ cleanupFn = void 0;
24
+ }
25
+ };
26
+ return (...args) => {
27
+ subscribers += 1;
28
+ if (!state) {
29
+ state = composable(...args);
30
+ if (tryOnScopeDispose(dispose)) {
31
+ cleanupFn = dispose;
32
+ }
33
+ } else {
34
+ tryOnScopeDispose(dispose);
35
+ }
36
+ return state;
37
+ };
38
+ };
39
+ export {
40
+ createSharedComposable,
41
+ tryOnScopeDispose
42
+ };
43
+ //# sourceMappingURL=createSharedComposable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/createSharedComposable.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\n\ntype AnyFn = (...args: any[]) => any;\n\nexport type SharedComposableReturn<T extends AnyFn = AnyFn> = T;\n\n/**\n * Angular replacement for Vue's tryOnScopeDispose\n * Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed\n */\nexport function tryOnScopeDispose(fn: () => void) {\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(fn);\n return true;\n }\n return false;\n } catch {\n // If called outside injection context, return false\n return false;\n }\n}\n\n/**\n * Angular equivalent of Vue's createSharedComposable\n * Creates a singleton pattern for services/composables\n */\nexport const createSharedComposable = <Fn extends AnyFn>(\n composable: Fn\n): SharedComposableReturn<Fn> => {\n let subscribers = 0;\n let state: ReturnType<Fn> | undefined;\n let cleanupFn: (() => void) | undefined;\n\n const dispose = () => {\n subscribers -= 1;\n if (cleanupFn && subscribers <= 0) {\n cleanupFn();\n state = undefined;\n cleanupFn = undefined;\n }\n };\n\n return <Fn>((...args) => {\n subscribers += 1;\n if (!state) {\n state = composable(...args);\n // Set up cleanup when the first subscriber is destroyed\n if (tryOnScopeDispose(dispose)) {\n cleanupFn = dispose;\n }\n } else {\n // For additional subscribers, just set up their individual cleanup\n tryOnScopeDispose(dispose);\n }\n return state;\n });\n};\n"],"mappings":"AAAA,SAAS,YAAY,cAAc;AAU5B,SAAS,kBAAkB,IAAgB;AAChD,MAAI;AACF,UAAM,aAAa,OAAO,YAAY,EAAE,UAAU,KAAK,CAAC;AACxD,QAAI,YAAY;AACd,iBAAW,UAAU,EAAE;AACvB,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,QAAQ;AAEN,WAAO;AAAA,EACT;AACF;AAMO,MAAM,yBAAyB,CACpC,eAC+B;AAC/B,MAAI,cAAc;AAClB,MAAI;AACJ,MAAI;AAEJ,QAAM,UAAU,MAAM;AACpB,mBAAe;AACf,QAAI,aAAa,eAAe,GAAG;AACjC,gBAAU;AACV,cAAQ;AACR,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAY,IAAI,SAAS;AACvB,mBAAe;AACf,QAAI,CAAC,OAAO;AACV,cAAQ,WAAW,GAAG,IAAI;AAE1B,UAAI,kBAAkB,OAAO,GAAG;AAC9B,oBAAY;AAAA,MACd;AAAA,IACF,OAAO;AAEL,wBAAkB,OAAO;AAAA,IAC3B;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,47 @@
1
+ import { effect, signal } from "@angular/core";
2
+ import dictionaries from "@intlayer/dictionaries-entry";
3
+ import { MessageKey } from "@intlayer/editor";
4
+ import { createSharedComposable } from "./createSharedComposable.mjs";
5
+ import { useCrossFrameState } from "./useCrossFrameState.mjs";
6
+ let instance = null;
7
+ const createDictionaryRecordClient = () => {
8
+ if (instance) return instance;
9
+ const localeDictionariesSignal = signal(dictionaries);
10
+ instance = {
11
+ localeDictionaries: localeDictionariesSignal.asReadonly(),
12
+ setLocaleDictionaries: (newValue) => {
13
+ localeDictionariesSignal.set(newValue ?? {});
14
+ },
15
+ setLocaleDictionary(dictionary) {
16
+ const current = localeDictionariesSignal();
17
+ localeDictionariesSignal.set({
18
+ ...current,
19
+ [dictionary.key]: dictionary
20
+ });
21
+ }
22
+ };
23
+ return instance;
24
+ };
25
+ const installDictionariesRecord = (injector) => {
26
+ const client = createDictionaryRecordClient();
27
+ };
28
+ const useDictionariesRecord = createSharedComposable(() => {
29
+ const client = createDictionaryRecordClient();
30
+ if (!client) {
31
+ throw new Error("DictionariesRecord state not found");
32
+ }
33
+ const [_dictionariesRecord, setDictionariesRecord] = useCrossFrameState(
34
+ MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,
35
+ void 0
36
+ );
37
+ effect(() => {
38
+ const newValue = client.localeDictionaries();
39
+ setDictionariesRecord(newValue);
40
+ });
41
+ });
42
+ export {
43
+ createDictionaryRecordClient,
44
+ installDictionariesRecord,
45
+ useDictionariesRecord
46
+ };
47
+ //# sourceMappingURL=dictionariesRecord.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Singleton instance\n */\nlet instance: DictionariesRecordClient | null = null;\n\nexport type DictionaryContent = Record<Dictionary['key'], Dictionary>;\n\ntype DictionariesRecordClient = {\n localeDictionaries: Signal<DictionaryContent>;\n setLocaleDictionaries: (newValue: DictionaryContent) => void;\n setLocaleDictionary: (d: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent>(dictionaries);\n\n instance = {\n localeDictionaries: localeDictionariesSignal.asReadonly(),\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.key]: dictionary,\n });\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the provider into the injector\n */\nexport const installDictionariesRecord = (injector: Injector) => {\n const client = createDictionaryRecordClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createDictionaryRecordClient\n};\n\nexport const useDictionariesRecord = createSharedComposable(() => {\n const client = createDictionaryRecordClient();\n\n if (!client) {\n throw new Error('DictionariesRecord state not found');\n }\n\n const [_dictionariesRecord, setDictionariesRecord] =\n useCrossFrameState<DictionaryContent>(\n MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,\n undefined\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.localeDictionaries();\n setDictionariesRecord(newValue); // its undefined but shouldnt\n });\n});\n"],"mappings":"AAAA,SAAS,QAAkB,cAAsB;AAEjD,OAAO,kBAAkB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAKnC,IAAI,WAA4C;AAUzC,MAAM,+BAA+B,MAAM;AAChD,MAAI,SAAU,QAAO;AAErB,QAAM,2BAA2B,OAA0B,YAAY;AAEvE,aAAW;AAAA,IACT,oBAAoB,yBAAyB,WAAW;AAAA,IAExD,uBAAuB,CAAC,aAAa;AACnC,+BAAyB,IAAI,YAAY,CAAC,CAAC;AAAA,IAC7C;AAAA,IAEA,oBAAoB,YAAY;AAC9B,YAAM,UAAU,yBAAyB;AACzC,+BAAyB,IAAI;AAAA,QAC3B,GAAG;AAAA,QACH,CAAC,WAAW,GAAG,GAAG;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,4BAA4B,CAAC,aAAuB;AAC/D,QAAM,SAAS,6BAA6B;AAI9C;AAEO,MAAM,wBAAwB,uBAAuB,MAAM;AAChE,QAAM,SAAS,6BAA6B;AAE5C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAEA,QAAM,CAAC,qBAAqB,qBAAqB,IAC/C;AAAA,IACE,WAAW;AAAA,IACX;AAAA,EACF;AAGF,SAAO,MAAM;AACX,UAAM,WAAW,OAAO,mBAAmB;AAC3C,0BAAsB,QAAQ;AAAA,EAChC,CAAC;AACH,CAAC;","names":[]}
@@ -0,0 +1,51 @@
1
+ import { effect, signal } from "@angular/core";
2
+ import { getContentNodeByKeyPath } from "@intlayer/core";
3
+ import { MessageKey } from "@intlayer/editor";
4
+ import { createSharedComposable } from "./createSharedComposable.mjs";
5
+ import { useCrossFrameState } from "./useCrossFrameState.mjs";
6
+ let instance = null;
7
+ const INTLAYER_EDITED_CONTENT_SYMBOL = Symbol("EditedContent");
8
+ const createEditedContentClient = () => {
9
+ if (instance) return instance;
10
+ const editedContentSignal = signal({});
11
+ instance = {
12
+ editedContent: editedContentSignal.asReadonly(),
13
+ getEditedContentValue: (dictionaryKey, keyPath) => {
14
+ const content = editedContentSignal()?.[dictionaryKey]?.content;
15
+ if (!content) return void 0;
16
+ return getContentNodeByKeyPath(content, keyPath);
17
+ },
18
+ setEditedContent: (editedContent) => {
19
+ editedContentSignal.set(editedContent);
20
+ }
21
+ };
22
+ return instance;
23
+ };
24
+ const installEditedContent = (injector) => {
25
+ const client = createEditedContentClient();
26
+ };
27
+ const useEditedContent = createSharedComposable(() => {
28
+ const client = createEditedContentClient();
29
+ if (!client) {
30
+ throw new Error("EditedContent state not found");
31
+ }
32
+ const [edited, setEdited] = useCrossFrameState(
33
+ MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,
34
+ {}
35
+ );
36
+ effect(() => {
37
+ const newValue = edited();
38
+ client.setEditedContent(newValue ?? {});
39
+ });
40
+ effect(() => {
41
+ const newValue = client.editedContent();
42
+ setEdited(newValue);
43
+ });
44
+ return client;
45
+ });
46
+ export {
47
+ createEditedContentClient,
48
+ installEditedContent,
49
+ useEditedContent
50
+ };
51
+ //# sourceMappingURL=editedContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { ContentNode, Dictionary, KeyPath } from '@intlayer/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type EditedContent = Record<Dictionary['key'], Dictionary>;\n\ntype EditedContentClient = {\n editedContent: Signal<EditedContent>;\n setEditedContent: (editedContent: EditedContent) => void;\n getEditedContentValue: (\n dictionaryKey: Dictionary['key'],\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditedContentClient | null = null;\n\nconst INTLAYER_EDITED_CONTENT_SYMBOL = Symbol('EditedContent');\n\n/**\n * Creates an edited content client\n */\nexport const createEditedContentClient = () => {\n if (instance) return instance;\n\n const editedContentSignal = signal<EditedContent>({});\n\n instance = {\n editedContent: editedContentSignal.asReadonly(),\n getEditedContentValue: (\n dictionaryKey: Dictionary['key'],\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n const content = editedContentSignal()?.[dictionaryKey]?.content;\n if (!content) return undefined;\n\n return getContentNodeByKeyPath(content, keyPath);\n },\n setEditedContent: (editedContent: EditedContent) => {\n editedContentSignal.set(editedContent);\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the edited content into the injector\n */\nexport const installEditedContent = (injector: Injector) => {\n const client = createEditedContentClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditedContentClient\n};\n\nexport const useEditedContent = createSharedComposable(() => {\n const client = createEditedContentClient();\n\n if (!client) {\n throw new Error('EditedContent state not found');\n }\n\n const [edited, setEdited] = useCrossFrameState<EditedContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,\n {}\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = edited();\n client.setEditedContent(newValue ?? {});\n });\n\n effect(() => {\n const newValue = client.editedContent();\n setEdited(newValue);\n });\n\n return client;\n});\n"],"mappings":"AAAA,SAAS,QAAkB,cAAsB;AAEjD,SAAS,+BAA+B;AACxC,SAAS,kBAAkB;AAC3B,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAgBnC,IAAI,WAAuC;AAE3C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,sBAAsB,OAAsB,CAAC,CAAC;AAEpD,aAAW;AAAA,IACT,eAAe,oBAAoB,WAAW;AAAA,IAC9C,uBAAuB,CACrB,eACA,YAC4B;AAC5B,YAAM,UAAU,oBAAoB,IAAI,aAAa,GAAG;AACxD,UAAI,CAAC,QAAS,QAAO;AAErB,aAAO,wBAAwB,SAAS,OAAO;AAAA,IACjD;AAAA,IACA,kBAAkB,CAAC,kBAAiC;AAClD,0BAAoB,IAAI,aAAa;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,uBAAuB,CAAC,aAAuB;AAC1D,QAAM,SAAS,0BAA0B;AAI3C;AAEO,MAAM,mBAAmB,uBAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,CAAC,QAAQ,SAAS,IAAI;AAAA,IAC1B,WAAW;AAAA,IACX,CAAC;AAAA,EACH;AAGA,SAAO,MAAM;AACX,UAAM,WAAW,OAAO;AACxB,WAAO,iBAAiB,YAAY,CAAC,CAAC;AAAA,EACxC,CAAC;AAED,SAAO,MAAM;AACX,UAAM,WAAW,OAAO,cAAc;AACtC,cAAU,QAAQ;AAAA,EACpB,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}
@@ -0,0 +1,50 @@
1
+ import { computed, effect, signal } from "@angular/core";
2
+ import { MessageKey } from "@intlayer/editor";
3
+ import { createSharedComposable } from "./createSharedComposable.mjs";
4
+ import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
5
+ let instance = null;
6
+ const INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol("EditorEnabled");
7
+ const createEditorEnabledClient = () => {
8
+ if (instance) return instance;
9
+ const wrapperEnabledSignal = signal(false);
10
+ const isInIframeSignal = signal(false);
11
+ const enabledSignal = computed(
12
+ () => wrapperEnabledSignal() && isInIframeSignal()
13
+ );
14
+ instance = {
15
+ wrapperEnabled: wrapperEnabledSignal.asReadonly(),
16
+ isInIframe: isInIframeSignal.asReadonly(),
17
+ enabled: enabledSignal
18
+ };
19
+ return instance;
20
+ };
21
+ const installEditorEnabled = (injector) => {
22
+ const client = createEditorEnabledClient();
23
+ };
24
+ const useEditorEnabled = createSharedComposable(() => {
25
+ const client = createEditorEnabledClient();
26
+ if (!client) {
27
+ throw new Error("EditorEnabled state not found");
28
+ }
29
+ useCrossFrameMessageListener(
30
+ `${MessageKey.INTLAYER_EDITOR_ENABLED}/post`,
31
+ (data) => {
32
+ client.wrapperEnabled.set(data);
33
+ }
34
+ );
35
+ effect(
36
+ () => {
37
+ if (typeof window !== "undefined") {
38
+ client.isInIframe.set(window.self !== window.top);
39
+ }
40
+ },
41
+ { allowSignalWrites: true }
42
+ );
43
+ return client;
44
+ });
45
+ export {
46
+ createEditorEnabledClient,
47
+ installEditorEnabled,
48
+ useEditorEnabled
49
+ };
50
+ //# sourceMappingURL=editorEnabled.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import { computed, effect, Injector, signal, Signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ------------------------------------------------------------------ */\n/* public type – identical to the React version */\n/* ------------------------------------------------------------------ */\nexport type EditorEnabledStateProps = {\n wrapperEnabled: Signal<boolean>;\n isInIframe: Signal<boolean>;\n enabled: Signal<boolean>;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditorEnabledStateProps | null = null;\n\nconst INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol('EditorEnabled');\n\n/**\n * Creates an editor wrapperEnabled client\n */\nexport const createEditorEnabledClient = () => {\n if (instance) return instance;\n\n const wrapperEnabledSignal = signal(false);\n const isInIframeSignal = signal(false);\n const enabledSignal = computed(\n () => wrapperEnabledSignal() && isInIframeSignal()\n );\n\n instance = {\n wrapperEnabled: wrapperEnabledSignal.asReadonly(),\n isInIframe: isInIframeSignal.asReadonly(),\n enabled: enabledSignal,\n };\n\n return instance;\n};\n\n/**\n * Helper to install the editor wrapperEnabled state into the injector\n */\nexport const installEditorEnabled = (injector: Injector) => {\n const client = createEditorEnabledClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditorEnabledClient\n};\n\nexport const useEditorEnabled = createSharedComposable(() => {\n const client = createEditorEnabledClient();\n\n if (!client) {\n throw new Error('EditorEnabled state not found');\n }\n\n // Listen for the iframe parent if the editor send a message `INTLAYER_EDITOR_ENABLED`\n useCrossFrameMessageListener<boolean>(\n `${MessageKey.INTLAYER_EDITOR_ENABLED}/post`,\n (data) => {\n (client.wrapperEnabled as any).set(data);\n }\n );\n\n // Use effect to set up the iframe check immediately\n effect(\n () => {\n if (typeof window !== 'undefined') {\n (client.isInIframe as any).set(window.self !== window.top);\n }\n },\n { allowSignalWrites: true }\n );\n\n return client;\n});\n"],"mappings":"AAAA,SAAS,UAAU,QAAkB,cAAsB;AAC3D,SAAS,kBAAkB;AAC3B,SAAS,8BAA8B;AACvC,SAAS,oCAAoC;AAc7C,IAAI,WAA2C;AAE/C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,uBAAuB,OAAO,KAAK;AACzC,QAAM,mBAAmB,OAAO,KAAK;AACrC,QAAM,gBAAgB;AAAA,IACpB,MAAM,qBAAqB,KAAK,iBAAiB;AAAA,EACnD;AAEA,aAAW;AAAA,IACT,gBAAgB,qBAAqB,WAAW;AAAA,IAChD,YAAY,iBAAiB,WAAW;AAAA,IACxC,SAAS;AAAA,EACX;AAEA,SAAO;AACT;AAKO,MAAM,uBAAuB,CAAC,aAAuB;AAC1D,QAAM,SAAS,0BAA0B;AAI3C;AAEO,MAAM,mBAAmB,uBAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAGA;AAAA,IACE,GAAG,WAAW,uBAAuB;AAAA,IACrC,CAAC,SAAS;AACR,MAAC,OAAO,eAAuB,IAAI,IAAI;AAAA,IACzC;AAAA,EACF;AAGA;AAAA,IACE,MAAM;AACJ,UAAI,OAAO,WAAW,aAAa;AACjC,QAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,GAAG;AAAA,MAC3D;AAAA,IACF;AAAA,IACA,EAAE,mBAAmB,KAAK;AAAA,EAC5B;AAEA,SAAO;AACT,CAAC;","names":[]}
@@ -0,0 +1,23 @@
1
+ import { effect, inject } from "@angular/core";
2
+ import { MessageKey } from "@intlayer/editor";
3
+ import { INTLAYER_TOKEN } from "../client/index.mjs";
4
+ import { createSharedComposable } from "./createSharedComposable.mjs";
5
+ import { useCrossFrameState } from "./useCrossFrameState.mjs";
6
+ const useEditorLocale = createSharedComposable(() => {
7
+ const client = inject(INTLAYER_TOKEN);
8
+ if (!client) {
9
+ throw new Error("IntlayerEditor state not found");
10
+ }
11
+ const [_data, setData] = useCrossFrameState(
12
+ MessageKey.INTLAYER_CURRENT_LOCALE
13
+ );
14
+ effect(() => {
15
+ const newValue = client.locale();
16
+ setData(newValue);
17
+ });
18
+ return client;
19
+ });
20
+ export {
21
+ useEditorLocale
22
+ };
23
+ //# sourceMappingURL=editorLocale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport type { Locales } from '@intlayer/config/client';\nimport { MessageKey } from '@intlayer/editor';\nimport { INTLAYER_TOKEN, IntlayerProvider } from '../client';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = createSharedComposable(() => {\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (!client) {\n throw new Error('IntlayerEditor state not found');\n }\n\n const [_data, setData] = useCrossFrameState<Locales>(\n MessageKey.INTLAYER_CURRENT_LOCALE\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.locale();\n setData(newValue);\n });\n\n return client;\n});\n"],"mappings":"AAAA,SAAS,QAAQ,cAAc;AAE/B,SAAS,kBAAkB;AAC3B,SAAS,sBAAwC;AACjD,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAE5B,MAAM,kBAAkB,uBAAuB,MAAM;AAC1D,QAAM,SAAS,OAAyB,cAAc;AAEtD,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,QAAM,CAAC,OAAO,OAAO,IAAI;AAAA,IACvB,WAAW;AAAA,EACb;AAGA,SAAO,MAAM;AACX,UAAM,WAAW,OAAO,OAAO;AAC/B,YAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}