angular-intlayer 6.1.6 → 7.0.0-canary.0

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 (237) hide show
  1. package/dist/cjs/UI/ContentSelector.component.cjs +94 -121
  2. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
  3. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/cjs/client/index.cjs +19 -35
  5. package/dist/cjs/client/installIntlayer.cjs +39 -68
  6. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionary.cjs +13 -36
  8. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryAsync.cjs +23 -48
  10. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +24 -52
  12. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  13. package/dist/cjs/client/useIntlayer.cjs +16 -36
  14. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  15. package/dist/cjs/client/useLoadDynamic.cjs +26 -42
  16. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  17. package/dist/cjs/client/useLocale.cjs +35 -67
  18. package/dist/cjs/client/useLocale.cjs.map +1 -1
  19. package/dist/cjs/client/useLocaleStorage.cjs +61 -0
  20. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
  21. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +41 -63
  22. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
  23. package/dist/cjs/editor/EditedContentRenderer.component.cjs +44 -75
  24. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
  25. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +25 -45
  26. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
  27. package/dist/cjs/editor/communicator.cjs +55 -73
  28. package/dist/cjs/editor/communicator.cjs.map +1 -1
  29. package/dist/cjs/editor/configuration.cjs +21 -54
  30. package/dist/cjs/editor/configuration.cjs.map +1 -1
  31. package/dist/cjs/editor/createSharedComposable.cjs +46 -63
  32. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
  33. package/dist/cjs/editor/dictionariesRecord.cjs +47 -77
  34. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
  35. package/dist/cjs/editor/editedContent.cjs +58 -71
  36. package/dist/cjs/editor/editedContent.cjs.map +1 -1
  37. package/dist/cjs/editor/editorEnabled.cjs +45 -70
  38. package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
  39. package/dist/cjs/editor/editorLocale.cjs +21 -45
  40. package/dist/cjs/editor/editorLocale.cjs.map +1 -1
  41. package/dist/cjs/editor/focusDictionary.cjs +58 -74
  42. package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
  43. package/dist/cjs/editor/index.cjs +9 -38
  44. package/dist/cjs/editor/installIntlayerEditor.cjs +46 -64
  45. package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
  46. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +63 -72
  47. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  48. package/dist/cjs/editor/useCrossFrameState.cjs +108 -88
  49. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  50. package/dist/cjs/editor/useCrossURLPathState.cjs +64 -69
  51. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  52. package/dist/cjs/editor/useEditedContentRenderer.cjs +25 -54
  53. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  54. package/dist/cjs/editor/useEditor.cjs +22 -44
  55. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  56. package/dist/cjs/editor/useIframeClickInterceptor.cjs +38 -59
  57. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  58. package/dist/cjs/getDictionary.cjs +14 -39
  59. package/dist/cjs/getDictionary.cjs.map +1 -1
  60. package/dist/cjs/getIntlayer.cjs +14 -35
  61. package/dist/cjs/getIntlayer.cjs.map +1 -1
  62. package/dist/cjs/index.cjs +32 -31
  63. package/dist/cjs/markdown/index.cjs +6 -23
  64. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +33 -60
  65. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  66. package/dist/cjs/plugins.cjs +77 -108
  67. package/dist/cjs/plugins.cjs.map +1 -1
  68. package/dist/cjs/renderIntlayerNode.cjs +16 -56
  69. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  70. package/dist/cjs/webpack/index.cjs +3 -23
  71. package/dist/cjs/webpack/mergeConfig.cjs +33 -68
  72. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  73. package/dist/esm/UI/ContentSelector.component.mjs +89 -104
  74. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
  75. package/dist/esm/client/index.mjs +9 -8
  76. package/dist/esm/client/installIntlayer.mjs +29 -27
  77. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  78. package/dist/esm/client/useDictionary.mjs +10 -11
  79. package/dist/esm/client/useDictionary.mjs.map +1 -1
  80. package/dist/esm/client/useDictionaryAsync.mjs +18 -12
  81. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  82. package/dist/esm/client/useDictionaryDynamic.mjs +18 -15
  83. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  84. package/dist/esm/client/useIntlayer.mjs +12 -10
  85. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  86. package/dist/esm/client/useLoadDynamic.mjs +23 -17
  87. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  88. package/dist/esm/client/useLocale.mjs +30 -31
  89. package/dist/esm/client/useLocale.mjs.map +1 -1
  90. package/dist/esm/client/useLocaleStorage.mjs +54 -0
  91. package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
  92. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +32 -34
  93. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
  94. package/dist/esm/editor/EditedContentRenderer.component.mjs +38 -49
  95. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
  96. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +19 -18
  97. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
  98. package/dist/esm/editor/communicator.mjs +48 -35
  99. package/dist/esm/editor/communicator.mjs.map +1 -1
  100. package/dist/esm/editor/configuration.mjs +15 -18
  101. package/dist/esm/editor/configuration.mjs.map +1 -1
  102. package/dist/esm/editor/createSharedComposable.mjs +42 -37
  103. package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
  104. package/dist/esm/editor/dictionariesRecord.mjs +38 -38
  105. package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
  106. package/dist/esm/editor/editedContent.mjs +49 -42
  107. package/dist/esm/editor/editedContent.mjs.map +1 -1
  108. package/dist/esm/editor/editorEnabled.mjs +37 -41
  109. package/dist/esm/editor/editorEnabled.mjs.map +1 -1
  110. package/dist/esm/editor/editorLocale.mjs +15 -18
  111. package/dist/esm/editor/editorLocale.mjs.map +1 -1
  112. package/dist/esm/editor/focusDictionary.mjs +50 -45
  113. package/dist/esm/editor/focusDictionary.mjs.map +1 -1
  114. package/dist/esm/editor/index.mjs +3 -7
  115. package/dist/esm/editor/installIntlayerEditor.mjs +40 -26
  116. package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
  117. package/dist/esm/editor/useCrossFrameMessageListener.mjs +58 -46
  118. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  119. package/dist/esm/editor/useCrossFrameState.mjs +104 -62
  120. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  121. package/dist/esm/editor/useCrossURLPathState.mjs +57 -41
  122. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  123. package/dist/esm/editor/useEditedContentRenderer.mjs +21 -33
  124. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  125. package/dist/esm/editor/useEditor.mjs +16 -14
  126. package/dist/esm/editor/useEditor.mjs.map +1 -1
  127. package/dist/esm/editor/useIframeClickInterceptor.mjs +30 -30
  128. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  129. package/dist/esm/getDictionary.mjs +12 -20
  130. package/dist/esm/getDictionary.mjs.map +1 -1
  131. package/dist/esm/getIntlayer.mjs +12 -16
  132. package/dist/esm/getIntlayer.mjs.map +1 -1
  133. package/dist/esm/index.mjs +13 -6
  134. package/dist/esm/markdown/index.mjs +3 -2
  135. package/dist/esm/markdown/installIntlayerMarkdown.mjs +27 -32
  136. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  137. package/dist/esm/plugins.mjs +70 -83
  138. package/dist/esm/plugins.mjs.map +1 -1
  139. package/dist/esm/renderIntlayerNode.mjs +15 -32
  140. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  141. package/dist/esm/webpack/index.mjs +3 -2
  142. package/dist/esm/webpack/mergeConfig.mjs +25 -31
  143. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  144. package/dist/types/UI/ContentSelector.component.d.ts +32 -30
  145. package/dist/types/UI/ContentSelector.component.d.ts.map +1 -1
  146. package/dist/types/client/index.d.ts +8 -8
  147. package/dist/types/client/installIntlayer.d.ts +15 -9
  148. package/dist/types/client/installIntlayer.d.ts.map +1 -1
  149. package/dist/types/client/useDictionary.d.ts +7 -4
  150. package/dist/types/client/useDictionary.d.ts.map +1 -1
  151. package/dist/types/client/useDictionaryAsync.d.ts +7 -3
  152. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  153. package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
  154. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  155. package/dist/types/client/useIntlayer.d.ts +9 -7
  156. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  157. package/dist/types/client/useLoadDynamic.d.ts +4 -1
  158. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  159. package/dist/types/client/useLocale.d.ts +17 -8
  160. package/dist/types/client/useLocale.d.ts.map +1 -1
  161. package/dist/types/client/useLocaleStorage.d.ts +49 -0
  162. package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
  163. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +18 -12
  164. package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
  165. package/dist/types/editor/EditedContentRenderer.component.d.ts +20 -16
  166. package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -1
  167. package/dist/types/editor/EditorSelectorRenderer.component.d.ts +11 -6
  168. package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -1
  169. package/dist/types/editor/communicator.d.ts +14 -9
  170. package/dist/types/editor/communicator.d.ts.map +1 -1
  171. package/dist/types/editor/configuration.d.ts +4 -1
  172. package/dist/types/editor/configuration.d.ts.map +1 -1
  173. package/dist/types/editor/createSharedComposable.d.ts +6 -4
  174. package/dist/types/editor/createSharedComposable.d.ts.map +1 -1
  175. package/dist/types/editor/dictionariesRecord.d.ts +13 -10
  176. package/dist/types/editor/dictionariesRecord.d.ts.map +1 -1
  177. package/dist/types/editor/editedContent.d.ts +13 -10
  178. package/dist/types/editor/editedContent.d.ts.map +1 -1
  179. package/dist/types/editor/editorEnabled.d.ts +12 -8
  180. package/dist/types/editor/editorEnabled.d.ts.map +1 -1
  181. package/dist/types/editor/editorLocale.d.ts +6 -2
  182. package/dist/types/editor/editorLocale.d.ts.map +1 -1
  183. package/dist/types/editor/focusDictionary.d.ts +16 -13
  184. package/dist/types/editor/focusDictionary.d.ts.map +1 -1
  185. package/dist/types/editor/index.d.ts +5 -5
  186. package/dist/types/editor/installIntlayerEditor.d.ts +7 -2
  187. package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -1
  188. package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
  189. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
  190. package/dist/types/editor/useCrossFrameState.d.ts +12 -8
  191. package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
  192. package/dist/types/editor/useCrossURLPathState.d.ts +9 -3
  193. package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
  194. package/dist/types/editor/useEditedContentRenderer.d.ts +15 -11
  195. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
  196. package/dist/types/editor/useEditor.d.ts +4 -1
  197. package/dist/types/editor/useEditor.d.ts.map +1 -1
  198. package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
  199. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
  200. package/dist/types/getDictionary.d.ts +8 -4
  201. package/dist/types/getDictionary.d.ts.map +1 -1
  202. package/dist/types/getIntlayer.d.ts +8 -4
  203. package/dist/types/getIntlayer.d.ts.map +1 -1
  204. package/dist/types/index.d.ts +16 -8
  205. package/dist/types/index.d.ts.map +1 -1
  206. package/dist/types/markdown/index.d.ts +2 -2
  207. package/dist/types/markdown/installIntlayerMarkdown.d.ts +15 -12
  208. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
  209. package/dist/types/plugins.d.ts +29 -23
  210. package/dist/types/plugins.d.ts.map +1 -1
  211. package/dist/types/renderIntlayerNode.d.ts +16 -10
  212. package/dist/types/renderIntlayerNode.d.ts.map +1 -1
  213. package/dist/types/webpack/index.d.ts +2 -2
  214. package/dist/types/webpack/mergeConfig.d.ts +5 -2
  215. package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
  216. package/package.json +43 -49
  217. package/LICENSE +0 -202
  218. package/dist/cjs/client/index.cjs.map +0 -1
  219. package/dist/cjs/client/useLocaleCookie.cjs +0 -60
  220. package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
  221. package/dist/cjs/editor/index.cjs.map +0 -1
  222. package/dist/cjs/index.cjs.map +0 -1
  223. package/dist/cjs/markdown/index.cjs.map +0 -1
  224. package/dist/cjs/webpack/index.cjs.map +0 -1
  225. package/dist/esm/client/index.mjs.map +0 -1
  226. package/dist/esm/client/useLocaleCookie.mjs +0 -24
  227. package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
  228. package/dist/esm/editor/index.mjs.map +0 -1
  229. package/dist/esm/index.mjs.map +0 -1
  230. package/dist/esm/markdown/index.mjs.map +0 -1
  231. package/dist/esm/webpack/index.mjs.map +0 -1
  232. package/dist/types/client/index.d.ts.map +0 -1
  233. package/dist/types/client/useLocaleCookie.d.ts +0 -17
  234. package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
  235. package/dist/types/editor/index.d.ts.map +0 -1
  236. package/dist/types/markdown/index.d.ts.map +0 -1
  237. package/dist/types/webpack/index.d.ts.map +0 -1
@@ -1,43 +1,48 @@
1
1
  import { DestroyRef, inject } from "@angular/core";
2
+
3
+ //#region src/editor/createSharedComposable.ts
4
+ /**
5
+ * Angular replacement for Vue's tryOnScopeDispose
6
+ * Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed
7
+ */
2
8
  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
- }
9
+ try {
10
+ const destroyRef = inject(DestroyRef, { optional: true });
11
+ if (destroyRef) {
12
+ destroyRef.onDestroy(fn);
13
+ return true;
14
+ }
15
+ return false;
16
+ } catch {
17
+ return false;
18
+ }
13
19
  }
20
+ /**
21
+ * Angular equivalent of Vue's createSharedComposable
22
+ * Creates a singleton pattern for services/composables
23
+ */
14
24
  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
25
+ let subscribers = 0;
26
+ let state;
27
+ let cleanupFn;
28
+ const dispose = () => {
29
+ subscribers -= 1;
30
+ if (cleanupFn && subscribers <= 0) {
31
+ cleanupFn();
32
+ state = void 0;
33
+ cleanupFn = void 0;
34
+ }
35
+ };
36
+ return ((...args) => {
37
+ subscribers += 1;
38
+ if (!state) {
39
+ state = composable(...args);
40
+ if (tryOnScopeDispose(dispose)) cleanupFn = dispose;
41
+ } else tryOnScopeDispose(dispose);
42
+ return state;
43
+ });
42
44
  };
45
+
46
+ //#endregion
47
+ export { createSharedComposable, tryOnScopeDispose };
43
48
  //# sourceMappingURL=createSharedComposable.mjs.map
@@ -1 +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,UAAY,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":[]}
1
+ {"version":3,"file":"createSharedComposable.mjs","names":["state: ReturnType<Fn> | undefined","cleanupFn: (() => void) | undefined"],"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":";;;;;;;AAUA,SAAgB,kBAAkB,IAAgB;AAChD,KAAI;EACF,MAAM,aAAa,OAAO,YAAY,EAAE,UAAU,MAAM,CAAC;AACzD,MAAI,YAAY;AACd,cAAW,UAAU,GAAG;AACxB,UAAO;;AAET,SAAO;SACD;AAEN,SAAO;;;;;;;AAQX,MAAa,0BACX,eAC+B;CAC/B,IAAI,cAAc;CAClB,IAAIA;CACJ,IAAIC;CAEJ,MAAM,gBAAgB;AACpB,iBAAe;AACf,MAAI,aAAa,eAAe,GAAG;AACjC,cAAW;AACX,WAAQ;AACR,eAAY;;;AAIhB,UAAa,GAAG,SAAS;AACvB,iBAAe;AACf,MAAI,CAAC,OAAO;AACV,WAAQ,WAAW,GAAG,KAAK;AAE3B,OAAI,kBAAkB,QAAQ,CAC5B,aAAY;QAId,mBAAkB,QAAQ;AAE5B,SAAO"}
@@ -1,47 +1,47 @@
1
- import { effect, signal } from "@angular/core";
2
- import dictionaries from "@intlayer/dictionaries-entry";
3
- import { MessageKey } from "@intlayer/editor";
4
1
  import { createSharedComposable } from "./createSharedComposable.mjs";
5
2
  import { useCrossFrameState } from "./useCrossFrameState.mjs";
3
+ import { effect, signal } from "@angular/core";
4
+ import { MessageKey } from "@intlayer/editor";
5
+ import { getDictionaries } from "@intlayer/dictionaries-entry";
6
+
7
+ //#region src/editor/dictionariesRecord.ts
8
+ /**
9
+ * Singleton instance
10
+ */
6
11
  let instance = null;
7
12
  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;
13
+ if (instance) return instance;
14
+ const localeDictionariesSignal = signal(getDictionaries());
15
+ instance = {
16
+ localeDictionaries: localeDictionariesSignal.asReadonly(),
17
+ setLocaleDictionaries: (newValue) => {
18
+ localeDictionariesSignal.set(newValue ?? {});
19
+ },
20
+ setLocaleDictionary(dictionary) {
21
+ const current = localeDictionariesSignal();
22
+ localeDictionariesSignal.set({
23
+ ...current,
24
+ [dictionary.key]: dictionary
25
+ });
26
+ }
27
+ };
28
+ return instance;
24
29
  };
25
- const installDictionariesRecord = (injector) => {
26
- const client = createDictionaryRecordClient();
30
+ /**
31
+ * Helper to install the provider into the injector
32
+ */
33
+ const installDictionariesRecord = (_injector) => {
34
+ createDictionaryRecordClient();
27
35
  };
28
36
  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
- });
37
+ const client = createDictionaryRecordClient();
38
+ if (!client) throw new Error("DictionariesRecord state not found");
39
+ const [_dictionariesRecord, setDictionariesRecord] = useCrossFrameState(MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
40
+ effect(() => {
41
+ setDictionariesRecord(client.localeDictionaries());
42
+ });
41
43
  });
42
- export {
43
- createDictionaryRecordClient,
44
- installDictionariesRecord,
45
- useDictionariesRecord
46
- };
44
+
45
+ //#endregion
46
+ export { createDictionaryRecordClient, installDictionariesRecord, useDictionariesRecord };
47
47
  //# sourceMappingURL=dictionariesRecord.mjs.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"dictionariesRecord.mjs","names":["instance: DictionariesRecordClient | null"],"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types';\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 dictionaries = getDictionaries();\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":";;;;;;;;;;AAUA,IAAIA,WAA4C;AAUhD,MAAa,qCAAqC;AAChD,KAAI,SAAU,QAAO;CAGrB,MAAM,2BAA2B,OADZ,iBAAiB,CACkC;AAExE,YAAW;EACT,oBAAoB,yBAAyB,YAAY;EAEzD,wBAAwB,aAAa;AACnC,4BAAyB,IAAI,YAAY,EAAE,CAAC;;EAG9C,oBAAoB,YAAY;GAC9B,MAAM,UAAU,0BAA0B;AAC1C,4BAAyB,IAAI;IAC3B,GAAG;KACF,WAAW,MAAM;IACnB,CAAC;;EAEL;AAED,QAAO;;;;;AAMT,MAAa,6BAA6B,cAAwB;AAChD,+BAA8B;;AAMhD,MAAa,wBAAwB,6BAA6B;CAChE,MAAM,SAAS,8BAA8B;AAE7C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,qCAAqC;CAGvD,MAAM,CAAC,qBAAqB,yBAC1B,mBACE,WAAW,sCACX,OACD;AAGH,cAAa;AAEX,wBADiB,OAAO,oBAAoB,CACb;GAC/B;EACF"}
@@ -1,51 +1,58 @@
1
- import { effect, signal } from "@angular/core";
2
- import { getContentNodeByKeyPath } from "@intlayer/core";
3
- import { MessageKey } from "@intlayer/editor";
4
1
  import { createSharedComposable } from "./createSharedComposable.mjs";
5
2
  import { useCrossFrameState } from "./useCrossFrameState.mjs";
3
+ import { getContentNodeByKeyPath } from "@intlayer/core";
4
+ import { effect, signal } from "@angular/core";
5
+ import { MessageKey } from "@intlayer/editor";
6
+
7
+ //#region src/editor/editedContent.ts
8
+ /**
9
+ * Singleton instance
10
+ */
6
11
  let instance = null;
7
- const INTLAYER_EDITED_CONTENT_SYMBOL = Symbol("EditedContent");
12
+ /**
13
+ * Creates an edited content client
14
+ */
8
15
  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;
16
+ if (instance) return instance;
17
+ const editedContentSignal = signal({});
18
+ instance = {
19
+ editedContent: editedContentSignal.asReadonly(),
20
+ getEditedContentValue: (localDictionaryIdOrKey, keyPath) => {
21
+ const editedContent = editedContentSignal();
22
+ if (!editedContent) return void 0;
23
+ if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return getContentNodeByKeyPath(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
24
+ const filteredDictionariesLocalId = Object.keys(editedContent).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`));
25
+ for (const localDictionaryId of filteredDictionariesLocalId) {
26
+ const contentNode = getContentNodeByKeyPath(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
27
+ if (contentNode) return contentNode;
28
+ }
29
+ },
30
+ setEditedContent: (editedContent) => {
31
+ editedContentSignal.set(editedContent);
32
+ }
33
+ };
34
+ return instance;
23
35
  };
24
- const installEditedContent = (injector) => {
25
- const client = createEditedContentClient();
36
+ /**
37
+ * Helper to install the edited content into the injector
38
+ */
39
+ const installEditedContent = (_injector) => {
40
+ createEditedContentClient();
26
41
  };
27
42
  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;
43
+ const client = createEditedContentClient();
44
+ if (!client) throw new Error("EditedContent state not found");
45
+ const [edited, setEdited] = useCrossFrameState(MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
46
+ effect(() => {
47
+ const newValue = edited();
48
+ client.setEditedContent(newValue ?? {});
49
+ });
50
+ effect(() => {
51
+ setEdited(client.editedContent());
52
+ });
53
+ return client;
45
54
  });
46
- export {
47
- createEditedContentClient,
48
- installEditedContent,
49
- useEditedContent
50
- };
55
+
56
+ //#endregion
57
+ export { createEditedContentClient, installEditedContent, useEditedContent };
51
58
  //# sourceMappingURL=editedContent.mjs.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"editedContent.mjs","names":["instance: EditedContentClient | null"],"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n KeyPath,\n LocalDictionaryId,\n} from '@intlayer/types';\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 localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\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 localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n const editedContent = editedContentSignal();\n\n if (!editedContent) return undefined;\n\n const isDictionaryId =\n localDictionaryIdOrKey.includes(':local:') ||\n localDictionaryIdOrKey.includes(':remote:');\n\n if (isDictionaryId) {\n const currentContent =\n editedContent?.[localDictionaryIdOrKey as LocalDictionaryId]\n ?.content ?? {};\n\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n return contentNode;\n }\n\n const filteredDictionariesLocalId = Object.keys(editedContent).filter(\n (key) => key.startsWith(`${localDictionaryIdOrKey}:`)\n );\n\n for (const localDictionaryId of filteredDictionariesLocalId) {\n const currentContent =\n editedContent?.[localDictionaryId as LocalDictionaryId]?.content ??\n {};\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n if (contentNode) return contentNode;\n }\n\n return undefined;\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":";;;;;;;;;;AA0BA,IAAIA,WAAuC;;;;AAO3C,MAAa,kCAAkC;AAC7C,KAAI,SAAU,QAAO;CAErB,MAAM,sBAAsB,OAAsB,EAAE,CAAC;AAErD,YAAW;EACT,eAAe,oBAAoB,YAAY;EAC/C,wBACE,wBACA,YAC4B;GAC5B,MAAM,gBAAgB,qBAAqB;AAE3C,OAAI,CAAC,cAAe,QAAO;AAM3B,OAHE,uBAAuB,SAAS,UAAU,IAC1C,uBAAuB,SAAS,WAAW,CAS3C,QAFoB,wBAHlB,gBAAgB,yBACZ,WAAW,EAAE,EAEyC,QAAQ;GAKtE,MAAM,8BAA8B,OAAO,KAAK,cAAc,CAAC,QAC5D,QAAQ,IAAI,WAAW,GAAG,uBAAuB,GAAG,CACtD;AAED,QAAK,MAAM,qBAAqB,6BAA6B;IAI3D,MAAM,cAAc,wBAFlB,gBAAgB,oBAAyC,WACzD,EAAE,EACwD,QAAQ;AAEpE,QAAI,YAAa,QAAO;;;EAK5B,mBAAmB,kBAAiC;AAClD,uBAAoB,IAAI,cAAc;;EAEzC;AAED,QAAO;;;;;AAMT,MAAa,wBAAwB,cAAwB;AAC3C,4BAA2B;;AAM7C,MAAa,mBAAmB,6BAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;CAGlD,MAAM,CAAC,QAAQ,aAAa,mBAC1B,WAAW,iCACX,EAAE,CACH;AAGD,cAAa;EACX,MAAM,WAAW,QAAQ;AACzB,SAAO,iBAAiB,YAAY,EAAE,CAAC;GACvC;AAEF,cAAa;AAEX,YADiB,OAAO,eAAe,CACpB;GACnB;AAEF,QAAO;EACP"}
@@ -1,50 +1,46 @@
1
- import { computed, effect, signal } from "@angular/core";
2
- import { MessageKey } from "@intlayer/editor";
3
1
  import { createSharedComposable } from "./createSharedComposable.mjs";
4
2
  import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
3
+ import { computed, effect, signal } from "@angular/core";
4
+ import { MessageKey } from "@intlayer/editor";
5
+
6
+ //#region src/editor/editorEnabled.ts
7
+ /**
8
+ * Singleton instance
9
+ */
5
10
  let instance = null;
6
- const INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol("EditorEnabled");
11
+ /**
12
+ * Creates an editor wrapperEnabled client
13
+ */
7
14
  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;
15
+ if (instance) return instance;
16
+ const wrapperEnabledSignal = signal(false);
17
+ const isInIframeSignal = signal(false);
18
+ const enabledSignal = computed(() => wrapperEnabledSignal() && isInIframeSignal());
19
+ instance = {
20
+ wrapperEnabled: wrapperEnabledSignal.asReadonly(),
21
+ isInIframe: isInIframeSignal.asReadonly(),
22
+ enabled: enabledSignal
23
+ };
24
+ return instance;
20
25
  };
21
- const installEditorEnabled = (injector) => {
22
- const client = createEditorEnabledClient();
26
+ /**
27
+ * Helper to install the editor wrapperEnabled state into the injector
28
+ */
29
+ const installEditorEnabled = (_injector) => {
30
+ createEditorEnabledClient();
23
31
  };
24
32
  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;
33
+ const client = createEditorEnabledClient();
34
+ if (!client) throw new Error("EditorEnabled state not found");
35
+ useCrossFrameMessageListener(`${MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
36
+ client.wrapperEnabled.set(data);
37
+ });
38
+ effect(() => {
39
+ if (typeof window !== "undefined") client.isInIframe.set(window.self !== window.top);
40
+ }, { allowSignalWrites: true });
41
+ return client;
44
42
  });
45
- export {
46
- createEditorEnabledClient,
47
- installEditorEnabled,
48
- useEditorEnabled
49
- };
43
+
44
+ //#endregion
45
+ export { createEditorEnabledClient, installEditorEnabled, useEditorEnabled };
50
46
  //# sourceMappingURL=editorEnabled.mjs.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"editorEnabled.mjs","names":["instance: EditorEnabledStateProps | null"],"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import {\n computed,\n effect,\n type Injector,\n type Signal,\n signal,\n} 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":";;;;;;;;;AAuBA,IAAIA,WAA2C;;;;AAO/C,MAAa,kCAAkC;AAC7C,KAAI,SAAU,QAAO;CAErB,MAAM,uBAAuB,OAAO,MAAM;CAC1C,MAAM,mBAAmB,OAAO,MAAM;CACtC,MAAM,gBAAgB,eACd,sBAAsB,IAAI,kBAAkB,CACnD;AAED,YAAW;EACT,gBAAgB,qBAAqB,YAAY;EACjD,YAAY,iBAAiB,YAAY;EACzC,SAAS;EACV;AAED,QAAO;;;;;AAMT,MAAa,wBAAwB,cAAwB;AAC3C,4BAA2B;;AAM7C,MAAa,mBAAmB,6BAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;AAIlD,8BACE,GAAG,WAAW,wBAAwB,SACrC,SAAS;AACR,EAAC,OAAO,eAAuB,IAAI,KAAK;GAE3C;AAGD,cACQ;AACJ,MAAI,OAAO,WAAW,YACpB,CAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,IAAI;IAG9D,EAAE,mBAAmB,MAAM,CAC5B;AAED,QAAO;EACP"}
@@ -1,23 +1,20 @@
1
- import { effect, inject } from "@angular/core";
2
- import { MessageKey } from "@intlayer/editor";
3
- import { INTLAYER_TOKEN } from "../client/index.mjs";
4
1
  import { createSharedComposable } from "./createSharedComposable.mjs";
5
2
  import { useCrossFrameState } from "./useCrossFrameState.mjs";
3
+ import { INTLAYER_TOKEN } from "../client/installIntlayer.mjs";
4
+ import { effect, inject } from "@angular/core";
5
+ import { MessageKey } from "@intlayer/editor";
6
+
7
+ //#region src/editor/editorLocale.ts
6
8
  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;
9
+ const client = inject(INTLAYER_TOKEN);
10
+ if (!client) throw new Error("IntlayerEditor state not found");
11
+ const [_data, setData] = useCrossFrameState(MessageKey.INTLAYER_CURRENT_LOCALE);
12
+ effect(() => {
13
+ setData(client.locale());
14
+ });
15
+ return client;
19
16
  });
20
- export {
21
- useEditorLocale
22
- };
17
+
18
+ //#endregion
19
+ export { useEditorLocale };
23
20
  //# sourceMappingURL=editorLocale.mjs.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"editorLocale.mjs","names":[],"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Locale, LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type 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<LocalesValues>(\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 as Locale);\n });\n\n return client;\n});\n"],"mappings":";;;;;;;AAOA,MAAa,kBAAkB,6BAA6B;CAC1D,MAAM,SAAS,OAAyB,eAAe;AAEvD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iCAAiC;CAGnD,MAAM,CAAC,OAAO,WAAW,mBACvB,WAAW,wBACZ;AAGD,cAAa;AAEX,UADiB,OAAO,QAAQ,CACL;GAC3B;AAEF,QAAO;EACP"}
@@ -1,54 +1,59 @@
1
- import { effect, signal } from "@angular/core";
2
- import { MessageKey } from "@intlayer/editor";
3
1
  import { createSharedComposable } from "./createSharedComposable.mjs";
4
2
  import { useCrossFrameState } from "./useCrossFrameState.mjs";
3
+ import { effect, signal } from "@angular/core";
4
+ import { MessageKey } from "@intlayer/editor";
5
+
6
+ //#region src/editor/focusDictionary.ts
7
+ /**
8
+ * Singleton instance
9
+ */
5
10
  let instance = null;
11
+ /**
12
+ * Creates a focus dictionary client
13
+ */
6
14
  const createFocusDictionaryClient = () => {
7
- if (instance) return instance;
8
- const focusedContentSignal = signal(null);
9
- const setFocusedContent = (focussedContent) => {
10
- focusedContentSignal.set(focussedContent);
11
- };
12
- const setFocusedContentKeyPath = (keyPath) => {
13
- const current = focusedContentSignal();
14
- if (!current) return;
15
- setFocusedContent({ ...current, keyPath });
16
- };
17
- instance = {
18
- focusedContent: focusedContentSignal.asReadonly(),
19
- setFocusedContent,
20
- setFocusedContentKeyPath
21
- };
22
- return instance;
15
+ if (instance) return instance;
16
+ const focusedContentSignal = signal(null);
17
+ const setFocusedContent = (focussedContent) => {
18
+ focusedContentSignal.set(focussedContent);
19
+ };
20
+ const setFocusedContentKeyPath = (keyPath) => {
21
+ const current = focusedContentSignal();
22
+ if (!current) return;
23
+ setFocusedContent({
24
+ ...current,
25
+ keyPath
26
+ });
27
+ };
28
+ instance = {
29
+ focusedContent: focusedContentSignal.asReadonly(),
30
+ setFocusedContent,
31
+ setFocusedContentKeyPath
32
+ };
33
+ return instance;
23
34
  };
24
- const installFocusDictionary = (injector) => {
25
- const client = createFocusDictionaryClient();
35
+ /**
36
+ * Helper to install the focus dictionary into the injector
37
+ */
38
+ const installFocusDictionary = (_injector) => {
39
+ createFocusDictionaryClient();
26
40
  };
41
+ /** consumer */
27
42
  const useFocusDictionary = createSharedComposable(() => {
28
- const client = createFocusDictionaryClient();
29
- const [focusedContent, setFocusedContent] = useCrossFrameState(
30
- MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED
31
- );
32
- if (!client) {
33
- throw new Error("FocusDictionary state not found");
34
- }
35
- effect(() => {
36
- const newValue = client.focusedContent();
37
- if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {
38
- setFocusedContent(newValue);
39
- }
40
- });
41
- effect(() => {
42
- const newValue = focusedContent();
43
- if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {
44
- client.setFocusedContent(newValue ?? null);
45
- }
46
- });
47
- return client;
43
+ const client = createFocusDictionaryClient();
44
+ const [focusedContent, setFocusedContent] = useCrossFrameState(MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);
45
+ if (!client) throw new Error("FocusDictionary state not found");
46
+ effect(() => {
47
+ const newValue = client.focusedContent();
48
+ if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) setFocusedContent(newValue);
49
+ });
50
+ effect(() => {
51
+ const newValue = focusedContent();
52
+ if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) client.setFocusedContent(newValue ?? null);
53
+ });
54
+ return client;
48
55
  });
49
- export {
50
- createFocusDictionaryClient,
51
- installFocusDictionary,
52
- useFocusDictionary
53
- };
56
+
57
+ //#endregion
58
+ export { createFocusDictionaryClient, installFocusDictionary, useFocusDictionary };
54
59
  //# sourceMappingURL=focusDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, Injector, signal, Signal } from '@angular/core';\nimport type { KeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (injector: Injector) => {\n const client = createFocusDictionaryClient();\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 createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":"AAAA,SAAS,QAAkB,cAAsB;AAEjD,SAAS,kBAAkB;AAC3B,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAiBnC,IAAI,WAAyC;AAKtC,MAAM,8BAA8B,MAAM;AAC/C,MAAI,SAAU,QAAO;AAErB,QAAM,uBAAuB,OAA2B,IAAI;AAE5D,QAAM,oBAAoB,CAAC,oBAAwC;AACjE,yBAAqB,IAAI,eAAe;AAAA,EAC1C;AAEA,QAAM,2BAA2B,CAAC,YAAuB;AACvD,UAAM,UAAU,qBAAqB;AACrC,QAAI,CAAC,QAAS;AACd,sBAAkB,EAAE,GAAG,SAAS,QAAQ,CAAC;AAAA,EAC3C;AAEA,aAAW;AAAA,IACT,gBAAgB,qBAAqB,WAAW;AAAA,IAChD;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,yBAAyB,CAAC,aAAuB;AAC5D,QAAM,SAAS,4BAA4B;AAI7C;AAGO,MAAM,qBAAqB,uBAAuB,MAAM;AAC7D,QAAM,SAAS,4BAA4B;AAC3C,QAAM,CAAC,gBAAgB,iBAAiB,IACtC;AAAA,IACE,WAAW;AAAA,EACb;AAEF,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAIA,SAAO,MAAM;AACX,UAAM,WAAW,OAAO,eAAe;AACvC,QAAI,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,eAAe,CAAC,GAAG;AACjE,wBAAkB,QAAQ;AAAA,IAC5B;AAAA,EACF,CAAC;AAGD,SAAO,MAAM;AACX,UAAM,WAAW,eAAe;AAChC,QAAI,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,OAAO,eAAe,CAAC,GAAG;AACxE,aAAO,kBAAkB,YAAY,IAAI;AAAA,IAC3C;AAAA,EACF,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}
1
+ {"version":3,"file":"focusDictionary.mjs","names":["instance: FocusDictionaryClient | null"],"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (_injector: Injector) => {\n const _client = createFocusDictionaryClient();\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 createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":";;;;;;;;;AAqBA,IAAIA,WAAyC;;;;AAK7C,MAAa,oCAAoC;AAC/C,KAAI,SAAU,QAAO;CAErB,MAAM,uBAAuB,OAA2B,KAAK;CAE7D,MAAM,qBAAqB,oBAAwC;AACjE,uBAAqB,IAAI,gBAAgB;;CAG3C,MAAM,4BAA4B,YAAuB;EACvD,MAAM,UAAU,sBAAsB;AACtC,MAAI,CAAC,QAAS;AACd,oBAAkB;GAAE,GAAG;GAAS;GAAS,CAAC;;AAG5C,YAAW;EACT,gBAAgB,qBAAqB,YAAY;EACjD;EACA;EACD;AAED,QAAO;;;;;AAMT,MAAa,0BAA0B,cAAwB;AAC7C,8BAA6B;;;AAO/C,MAAa,qBAAqB,6BAA6B;CAC7D,MAAM,SAAS,6BAA6B;CAC5C,MAAM,CAAC,gBAAgB,qBACrB,mBACE,WAAW,iCACZ;AAEH,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,kCAAkC;AAKpD,cAAa;EACX,MAAM,WAAW,OAAO,gBAAgB;AACxC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,gBAAgB,CAAC,CAC/D,mBAAkB,SAAS;GAE7B;AAGF,cAAa;EACX,MAAM,WAAW,gBAAgB;AACjC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,OAAO,gBAAgB,CAAC,CACtE,QAAO,kBAAkB,YAAY,KAAK;GAE5C;AAEF,QAAO;EACP"}