angular-intlayer 6.1.6-canary.0 → 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,83 +1,53 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var dictionariesRecord_exports = {};
30
- __export(dictionariesRecord_exports, {
31
- createDictionaryRecordClient: () => createDictionaryRecordClient,
32
- installDictionariesRecord: () => installDictionariesRecord,
33
- useDictionariesRecord: () => useDictionariesRecord
34
- });
35
- module.exports = __toCommonJS(dictionariesRecord_exports);
36
- var import_core = require("@angular/core");
37
- var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
38
- var import_editor = require("@intlayer/editor");
39
- var import_createSharedComposable = require('./createSharedComposable.cjs');
40
- var import_useCrossFrameState = require('./useCrossFrameState.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
+ const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
+ let __angular_core = require("@angular/core");
5
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
6
+ let __intlayer_editor = require("@intlayer/editor");
7
+ __intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
8
+ let __intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
9
+ __intlayer_dictionaries_entry = require_rolldown_runtime.__toESM(__intlayer_dictionaries_entry);
10
+
11
+ //#region src/editor/dictionariesRecord.ts
12
+ /**
13
+ * Singleton instance
14
+ */
41
15
  let instance = null;
42
16
  const createDictionaryRecordClient = () => {
43
- if (instance) return instance;
44
- const localeDictionariesSignal = (0, import_core.signal)(import_dictionaries_entry.default);
45
- instance = {
46
- localeDictionaries: localeDictionariesSignal.asReadonly(),
47
- setLocaleDictionaries: (newValue) => {
48
- localeDictionariesSignal.set(newValue ?? {});
49
- },
50
- setLocaleDictionary(dictionary) {
51
- const current = localeDictionariesSignal();
52
- localeDictionariesSignal.set({
53
- ...current,
54
- [dictionary.key]: dictionary
55
- });
56
- }
57
- };
58
- return instance;
17
+ if (instance) return instance;
18
+ const localeDictionariesSignal = (0, __angular_core.signal)((0, __intlayer_dictionaries_entry.getDictionaries)());
19
+ instance = {
20
+ localeDictionaries: localeDictionariesSignal.asReadonly(),
21
+ setLocaleDictionaries: (newValue) => {
22
+ localeDictionariesSignal.set(newValue ?? {});
23
+ },
24
+ setLocaleDictionary(dictionary) {
25
+ const current = localeDictionariesSignal();
26
+ localeDictionariesSignal.set({
27
+ ...current,
28
+ [dictionary.key]: dictionary
29
+ });
30
+ }
31
+ };
32
+ return instance;
59
33
  };
60
- const installDictionariesRecord = (injector) => {
61
- const client = createDictionaryRecordClient();
34
+ /**
35
+ * Helper to install the provider into the injector
36
+ */
37
+ const installDictionariesRecord = (_injector) => {
38
+ createDictionaryRecordClient();
62
39
  };
63
- const useDictionariesRecord = (0, import_createSharedComposable.createSharedComposable)(() => {
64
- const client = createDictionaryRecordClient();
65
- if (!client) {
66
- throw new Error("DictionariesRecord state not found");
67
- }
68
- const [_dictionariesRecord, setDictionariesRecord] = (0, import_useCrossFrameState.useCrossFrameState)(
69
- import_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,
70
- void 0
71
- );
72
- (0, import_core.effect)(() => {
73
- const newValue = client.localeDictionaries();
74
- setDictionariesRecord(newValue);
75
- });
76
- });
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- createDictionaryRecordClient,
80
- installDictionariesRecord,
81
- useDictionariesRecord
40
+ const useDictionariesRecord = require_editor_createSharedComposable.createSharedComposable(() => {
41
+ const client = createDictionaryRecordClient();
42
+ if (!client) throw new Error("DictionariesRecord state not found");
43
+ const [_dictionariesRecord, setDictionariesRecord] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
44
+ (0, __angular_core.effect)(() => {
45
+ setDictionariesRecord(client.localeDictionaries());
46
+ });
82
47
  });
48
+
49
+ //#endregion
50
+ exports.createDictionaryRecordClient = createDictionaryRecordClient;
51
+ exports.installDictionariesRecord = installDictionariesRecord;
52
+ exports.useDictionariesRecord = useDictionariesRecord;
83
53
  //# sourceMappingURL=dictionariesRecord.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,gCAAyB;AACzB,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAKnC,IAAI,WAA4C;AAUzC,MAAM,+BAA+B,MAAM;AAChD,MAAI,SAAU,QAAO;AAErB,QAAM,+BAA2B,oBAA0B,0BAAAA,OAAY;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,4BAAwB,sDAAuB,MAAM;AAChE,QAAM,SAAS,6BAA6B;AAE5C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAEA,QAAM,CAAC,qBAAqB,qBAAqB,QAC/C;AAAA,IACE,yBAAW;AAAA,IACX;AAAA,EACF;AAGF,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,mBAAmB;AAC3C,0BAAsB,QAAQ;AAAA,EAChC,CAAC;AACH,CAAC;","names":["dictionaries"]}
1
+ {"version":3,"file":"dictionariesRecord.cjs","names":["instance: DictionariesRecordClient | null","createSharedComposable","useCrossFrameState","MessageKey"],"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,0GADgC,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,wBAAwBC,mEAA6B;CAChE,MAAM,SAAS,8BAA8B;AAE7C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,qCAAqC;CAGvD,MAAM,CAAC,qBAAqB,yBAC1BC,qDACEC,6BAAW,sCACX,OACD;AAGH,kCAAa;AAEX,wBADiB,OAAO,oBAAoB,CACb;GAC/B;EACF"}
@@ -1,77 +1,64 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var editedContent_exports = {};
20
- __export(editedContent_exports, {
21
- createEditedContentClient: () => createEditedContentClient,
22
- installEditedContent: () => installEditedContent,
23
- useEditedContent: () => useEditedContent
24
- });
25
- module.exports = __toCommonJS(editedContent_exports);
26
- var import_core = require("@angular/core");
27
- var import_core2 = require("@intlayer/core");
28
- var import_editor = require("@intlayer/editor");
29
- var import_createSharedComposable = require('./createSharedComposable.cjs');
30
- var import_useCrossFrameState = require('./useCrossFrameState.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
+ const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
+ let __intlayer_core = require("@intlayer/core");
5
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
6
+ let __angular_core = require("@angular/core");
7
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
8
+ let __intlayer_editor = require("@intlayer/editor");
9
+ __intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
10
+
11
+ //#region src/editor/editedContent.ts
12
+ /**
13
+ * Singleton instance
14
+ */
31
15
  let instance = null;
32
- const INTLAYER_EDITED_CONTENT_SYMBOL = Symbol("EditedContent");
16
+ /**
17
+ * Creates an edited content client
18
+ */
33
19
  const createEditedContentClient = () => {
34
- if (instance) return instance;
35
- const editedContentSignal = (0, import_core.signal)({});
36
- instance = {
37
- editedContent: editedContentSignal.asReadonly(),
38
- getEditedContentValue: (dictionaryKey, keyPath) => {
39
- const content = editedContentSignal()?.[dictionaryKey]?.content;
40
- if (!content) return void 0;
41
- return (0, import_core2.getContentNodeByKeyPath)(content, keyPath);
42
- },
43
- setEditedContent: (editedContent) => {
44
- editedContentSignal.set(editedContent);
45
- }
46
- };
47
- return instance;
20
+ if (instance) return instance;
21
+ const editedContentSignal = (0, __angular_core.signal)({});
22
+ instance = {
23
+ editedContent: editedContentSignal.asReadonly(),
24
+ getEditedContentValue: (localDictionaryIdOrKey, keyPath) => {
25
+ const editedContent = editedContentSignal();
26
+ if (!editedContent) return void 0;
27
+ if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return (0, __intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
28
+ const filteredDictionariesLocalId = Object.keys(editedContent).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`));
29
+ for (const localDictionaryId of filteredDictionariesLocalId) {
30
+ const contentNode = (0, __intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
31
+ if (contentNode) return contentNode;
32
+ }
33
+ },
34
+ setEditedContent: (editedContent) => {
35
+ editedContentSignal.set(editedContent);
36
+ }
37
+ };
38
+ return instance;
48
39
  };
49
- const installEditedContent = (injector) => {
50
- const client = createEditedContentClient();
40
+ /**
41
+ * Helper to install the edited content into the injector
42
+ */
43
+ const installEditedContent = (_injector) => {
44
+ createEditedContentClient();
51
45
  };
52
- const useEditedContent = (0, import_createSharedComposable.createSharedComposable)(() => {
53
- const client = createEditedContentClient();
54
- if (!client) {
55
- throw new Error("EditedContent state not found");
56
- }
57
- const [edited, setEdited] = (0, import_useCrossFrameState.useCrossFrameState)(
58
- import_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,
59
- {}
60
- );
61
- (0, import_core.effect)(() => {
62
- const newValue = edited();
63
- client.setEditedContent(newValue ?? {});
64
- });
65
- (0, import_core.effect)(() => {
66
- const newValue = client.editedContent();
67
- setEdited(newValue);
68
- });
69
- return client;
70
- });
71
- // Annotate the CommonJS export names for ESM import in node:
72
- 0 && (module.exports = {
73
- createEditedContentClient,
74
- installEditedContent,
75
- useEditedContent
46
+ const useEditedContent = require_editor_createSharedComposable.createSharedComposable(() => {
47
+ const client = createEditedContentClient();
48
+ if (!client) throw new Error("EditedContent state not found");
49
+ const [edited, setEdited] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
50
+ (0, __angular_core.effect)(() => {
51
+ const newValue = edited();
52
+ client.setEditedContent(newValue ?? {});
53
+ });
54
+ (0, __angular_core.effect)(() => {
55
+ setEdited(client.editedContent());
56
+ });
57
+ return client;
76
58
  });
59
+
60
+ //#endregion
61
+ exports.createEditedContentClient = createEditedContentClient;
62
+ exports.installEditedContent = installEditedContent;
63
+ exports.useEditedContent = useEditedContent;
77
64
  //# sourceMappingURL=editedContent.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiD;AAEjD,IAAAA,eAAwC;AACxC,oBAA2B;AAC3B,oCAAuC;AACvC,gCAAmC;AAgBnC,IAAI,WAAuC;AAE3C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,0BAAsB,oBAAsB,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,iBAAO,sCAAwB,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,uBAAmB,sDAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,CAAC,QAAQ,SAAS,QAAI;AAAA,IAC1B,yBAAW;AAAA,IACX,CAAC;AAAA,EACH;AAGA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO;AACxB,WAAO,iBAAiB,YAAY,CAAC,CAAC;AAAA,EACxC,CAAC;AAED,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,cAAc;AACtC,cAAU,QAAQ;AAAA,EACpB,CAAC;AAED,SAAO;AACT,CAAC;","names":["import_core"]}
1
+ {"version":3,"file":"editedContent.cjs","names":["instance: EditedContentClient | null","createSharedComposable","useCrossFrameState","MessageKey"],"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,iDAA4C,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,qDALE,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,2DAFJ,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,mBAAmBC,mEAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;CAGlD,MAAM,CAAC,QAAQ,aAAaC,qDAC1BC,6BAAW,iCACX,EAAE,CACH;AAGD,kCAAa;EACX,MAAM,WAAW,QAAQ;AACzB,SAAO,iBAAiB,YAAY,EAAE,CAAC;GACvC;AAEF,kCAAa;AAEX,YADiB,OAAO,eAAe,CACpB;GACnB;AAEF,QAAO;EACP"}
@@ -1,76 +1,51 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var editorEnabled_exports = {};
20
- __export(editorEnabled_exports, {
21
- createEditorEnabledClient: () => createEditorEnabledClient,
22
- installEditorEnabled: () => installEditorEnabled,
23
- useEditorEnabled: () => useEditorEnabled
24
- });
25
- module.exports = __toCommonJS(editorEnabled_exports);
26
- var import_core = require("@angular/core");
27
- var import_editor = require("@intlayer/editor");
28
- var import_createSharedComposable = require('./createSharedComposable.cjs');
29
- var import_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
+ const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
4
+ let __angular_core = require("@angular/core");
5
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
6
+ let __intlayer_editor = require("@intlayer/editor");
7
+ __intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
8
+
9
+ //#region src/editor/editorEnabled.ts
10
+ /**
11
+ * Singleton instance
12
+ */
30
13
  let instance = null;
31
- const INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol("EditorEnabled");
14
+ /**
15
+ * Creates an editor wrapperEnabled client
16
+ */
32
17
  const createEditorEnabledClient = () => {
33
- if (instance) return instance;
34
- const wrapperEnabledSignal = (0, import_core.signal)(false);
35
- const isInIframeSignal = (0, import_core.signal)(false);
36
- const enabledSignal = (0, import_core.computed)(
37
- () => wrapperEnabledSignal() && isInIframeSignal()
38
- );
39
- instance = {
40
- wrapperEnabled: wrapperEnabledSignal.asReadonly(),
41
- isInIframe: isInIframeSignal.asReadonly(),
42
- enabled: enabledSignal
43
- };
44
- return instance;
18
+ if (instance) return instance;
19
+ const wrapperEnabledSignal = (0, __angular_core.signal)(false);
20
+ const isInIframeSignal = (0, __angular_core.signal)(false);
21
+ const enabledSignal = (0, __angular_core.computed)(() => wrapperEnabledSignal() && isInIframeSignal());
22
+ instance = {
23
+ wrapperEnabled: wrapperEnabledSignal.asReadonly(),
24
+ isInIframe: isInIframeSignal.asReadonly(),
25
+ enabled: enabledSignal
26
+ };
27
+ return instance;
45
28
  };
46
- const installEditorEnabled = (injector) => {
47
- const client = createEditorEnabledClient();
29
+ /**
30
+ * Helper to install the editor wrapperEnabled state into the injector
31
+ */
32
+ const installEditorEnabled = (_injector) => {
33
+ createEditorEnabledClient();
48
34
  };
49
- const useEditorEnabled = (0, import_createSharedComposable.createSharedComposable)(() => {
50
- const client = createEditorEnabledClient();
51
- if (!client) {
52
- throw new Error("EditorEnabled state not found");
53
- }
54
- (0, import_useCrossFrameMessageListener.useCrossFrameMessageListener)(
55
- `${import_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`,
56
- (data) => {
57
- client.wrapperEnabled.set(data);
58
- }
59
- );
60
- (0, import_core.effect)(
61
- () => {
62
- if (typeof window !== "undefined") {
63
- client.isInIframe.set(window.self !== window.top);
64
- }
65
- },
66
- { allowSignalWrites: true }
67
- );
68
- return client;
69
- });
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- createEditorEnabledClient,
73
- installEditorEnabled,
74
- useEditorEnabled
35
+ const useEditorEnabled = require_editor_createSharedComposable.createSharedComposable(() => {
36
+ const client = createEditorEnabledClient();
37
+ if (!client) throw new Error("EditorEnabled state not found");
38
+ require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(`${__intlayer_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
39
+ client.wrapperEnabled.set(data);
40
+ });
41
+ (0, __angular_core.effect)(() => {
42
+ if (typeof window !== "undefined") client.isInIframe.set(window.self !== window.top);
43
+ }, { allowSignalWrites: true });
44
+ return client;
75
45
  });
46
+
47
+ //#endregion
48
+ exports.createEditorEnabledClient = createEditorEnabledClient;
49
+ exports.installEditorEnabled = installEditorEnabled;
50
+ exports.useEditorEnabled = useEditorEnabled;
76
51
  //# sourceMappingURL=editorEnabled.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2D;AAC3D,oBAA2B;AAC3B,oCAAuC;AACvC,0CAA6C;AAc7C,IAAI,WAA2C;AAE/C,MAAM,iCAAiC,OAAO,eAAe;AAKtD,MAAM,4BAA4B,MAAM;AAC7C,MAAI,SAAU,QAAO;AAErB,QAAM,2BAAuB,oBAAO,KAAK;AACzC,QAAM,uBAAmB,oBAAO,KAAK;AACrC,QAAM,oBAAgB;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,uBAAmB,sDAAuB,MAAM;AAC3D,QAAM,SAAS,0BAA0B;AAEzC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAGA;AAAA,IACE,GAAG,yBAAW,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.cjs","names":["instance: EditorEnabledStateProps | null","createSharedComposable","MessageKey"],"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,kDAA8B,MAAM;CAC1C,MAAM,8CAA0B,MAAM;CACtC,MAAM,mDACE,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,mBAAmBC,mEAA6B;CAC3D,MAAM,SAAS,2BAA2B;AAE1C,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC;AAIlD,0EACE,GAAGC,6BAAW,wBAAwB,SACrC,SAAS;AACR,EAAC,OAAO,eAAuB,IAAI,KAAK;GAE3C;AAGD,kCACQ;AACJ,MAAI,OAAO,WAAW,YACpB,CAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,IAAI;IAG9D,EAAE,mBAAmB,MAAM,CAC5B;AAED,QAAO;EACP"}
@@ -1,47 +1,23 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var editorLocale_exports = {};
20
- __export(editorLocale_exports, {
21
- useEditorLocale: () => useEditorLocale
22
- });
23
- module.exports = __toCommonJS(editorLocale_exports);
24
- var import_core = require("@angular/core");
25
- var import_editor = require("@intlayer/editor");
26
- var import_client = require('../client/index.cjs');
27
- var import_createSharedComposable = require('./createSharedComposable.cjs');
28
- var import_useCrossFrameState = require('./useCrossFrameState.cjs');
29
- const useEditorLocale = (0, import_createSharedComposable.createSharedComposable)(() => {
30
- const client = (0, import_core.inject)(import_client.INTLAYER_TOKEN);
31
- if (!client) {
32
- throw new Error("IntlayerEditor state not found");
33
- }
34
- const [_data, setData] = (0, import_useCrossFrameState.useCrossFrameState)(
35
- import_editor.MessageKey.INTLAYER_CURRENT_LOCALE
36
- );
37
- (0, import_core.effect)(() => {
38
- const newValue = client.locale();
39
- setData(newValue);
40
- });
41
- return client;
42
- });
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- useEditorLocale
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
+ const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
+ const require_client_installIntlayer = require('../client/installIntlayer.cjs');
5
+ let __angular_core = require("@angular/core");
6
+ __angular_core = require_rolldown_runtime.__toESM(__angular_core);
7
+ let __intlayer_editor = require("@intlayer/editor");
8
+ __intlayer_editor = require_rolldown_runtime.__toESM(__intlayer_editor);
9
+
10
+ //#region src/editor/editorLocale.ts
11
+ const useEditorLocale = require_editor_createSharedComposable.createSharedComposable(() => {
12
+ const client = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
13
+ if (!client) throw new Error("IntlayerEditor state not found");
14
+ const [_data, setData] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_CURRENT_LOCALE);
15
+ (0, __angular_core.effect)(() => {
16
+ setData(client.locale());
17
+ });
18
+ return client;
46
19
  });
20
+
21
+ //#endregion
22
+ exports.useEditorLocale = useEditorLocale;
47
23
  //# sourceMappingURL=editorLocale.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAE/B,oBAA2B;AAC3B,oBAAiD;AACjD,oCAAuC;AACvC,gCAAmC;AAE5B,MAAM,sBAAkB,sDAAuB,MAAM;AAC1D,QAAM,aAAS,oBAAyB,4BAAc;AAEtD,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,QAAM,CAAC,OAAO,OAAO,QAAI;AAAA,IACvB,yBAAW;AAAA,EACb;AAGA,0BAAO,MAAM;AACX,UAAM,WAAW,OAAO,OAAO;AAC/B,YAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,SAAO;AACT,CAAC;","names":[]}
1
+ {"version":3,"file":"editorLocale.cjs","names":["createSharedComposable","INTLAYER_TOKEN","useCrossFrameState","MessageKey"],"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,kBAAkBA,mEAA6B;CAC1D,MAAM,oCAAkCC,8CAAe;AAEvD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iCAAiC;CAGnD,MAAM,CAAC,OAAO,WAAWC,qDACvBC,6BAAW,wBACZ;AAGD,kCAAa;AAEX,UADiB,OAAO,QAAQ,CACL;GAC3B;AAEF,QAAO;EACP"}