angular-intlayer 7.5.0-canary.0 → 7.5.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 (65) hide show
  1. package/dist/cjs/UI/ContentSelector.component.cjs +15 -15
  2. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
  3. package/dist/cjs/client/installIntlayer.cjs +7 -7
  4. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  5. package/dist/cjs/client/useDictionary.cjs +4 -4
  6. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionaryAsync.cjs +5 -5
  8. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryDynamic.cjs +5 -5
  10. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  11. package/dist/cjs/client/useIntlayer.cjs +4 -4
  12. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  13. package/dist/cjs/client/useLoadDynamic.cjs +2 -2
  14. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  15. package/dist/cjs/client/useLocale.cjs +7 -7
  16. package/dist/cjs/client/useLocale.cjs.map +1 -1
  17. package/dist/cjs/client/useLocaleStorage.cjs +6 -6
  18. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  19. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +12 -12
  20. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
  21. package/dist/cjs/editor/EditedContentRenderer.component.cjs +12 -12
  22. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
  23. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +6 -6
  24. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
  25. package/dist/cjs/editor/communicator.cjs +3 -3
  26. package/dist/cjs/editor/configuration.cjs +7 -7
  27. package/dist/cjs/editor/configuration.cjs.map +1 -1
  28. package/dist/cjs/editor/createSharedComposable.cjs +2 -2
  29. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
  30. package/dist/cjs/editor/dictionariesRecord.cjs +5 -5
  31. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
  32. package/dist/cjs/editor/editedContent.cjs +9 -9
  33. package/dist/cjs/editor/editedContent.cjs.map +1 -1
  34. package/dist/cjs/editor/editorEnabled.cjs +7 -7
  35. package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
  36. package/dist/cjs/editor/editorLocale.cjs +5 -5
  37. package/dist/cjs/editor/editorLocale.cjs.map +1 -1
  38. package/dist/cjs/editor/focusDictionary.cjs +6 -6
  39. package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
  40. package/dist/cjs/editor/installIntlayerEditor.cjs +3 -3
  41. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +4 -4
  42. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  43. package/dist/cjs/editor/useCrossFrameState.cjs +2 -2
  44. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  45. package/dist/cjs/editor/useCrossURLPathState.cjs +4 -4
  46. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  47. package/dist/cjs/editor/useEditedContentRenderer.cjs +6 -6
  48. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  49. package/dist/cjs/editor/useIframeClickInterceptor.cjs +5 -5
  50. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  51. package/dist/cjs/getDictionary.cjs +2 -2
  52. package/dist/cjs/getDictionary.cjs.map +1 -1
  53. package/dist/cjs/getIntlayer.cjs +2 -2
  54. package/dist/cjs/getIntlayer.cjs.map +1 -1
  55. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +5 -5
  56. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  57. package/dist/cjs/plugins.cjs +6 -6
  58. package/dist/cjs/plugins.cjs.map +1 -1
  59. package/dist/cjs/webpack/mergeConfig.cjs +5 -5
  60. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  61. package/dist/types/client/useLocale.d.ts +2 -2
  62. package/dist/types/client/useLocale.d.ts.map +1 -1
  63. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +3 -3
  64. package/dist/types/editor/EditedContentRenderer.component.d.ts +2 -2
  65. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.cjs","names":["useCrossFrameState","MessageKey","DestroyRef","configuration"],"sources":["../../../src/editor/configuration.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { MessageKey } from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useConfiguration = () => {\n const [pushedConfiguration, setConfiguration] =\n useCrossFrameState<IntlayerConfig>(MessageKey.INTLAYER_CONFIGURATION);\n\n // Use Angular's injection context instead of Vue's onMounted\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef) {\n // Execute immediately since Angular doesn't have the same lifecycle hooks\n if (!pushedConfiguration()) {\n setConfiguration(configuration);\n }\n }\n } catch {\n console.warn(\n 'useConfiguration called outside injection context; ' +\n 'configuration may not be synchronized.'\n );\n }\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,yBAAyB;CACpC,MAAM,CAAC,qBAAqB,oBAC1BA,qDAAmCC,6BAAW,uBAAuB;AAGvE,KAAI;AAGF,iCAF0BC,2BAAY,EAAE,UAAU,MAAM,CAAC,EAIvD;OAAI,CAAC,qBAAqB,CACxB,kBAAiBC,gCAAc;;SAG7B;AACN,UAAQ,KACN,4FAED"}
1
+ {"version":3,"file":"configuration.cjs","names":["useCrossFrameState","MessageKey","DestroyRef","configuration"],"sources":["../../../src/editor/configuration.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { MessageKey } from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useConfiguration = () => {\n const [pushedConfiguration, setConfiguration] =\n useCrossFrameState<IntlayerConfig>(MessageKey.INTLAYER_CONFIGURATION);\n\n // Use Angular's injection context instead of Vue's onMounted\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef) {\n // Execute immediately since Angular doesn't have the same lifecycle hooks\n if (!pushedConfiguration()) {\n setConfiguration(configuration);\n }\n }\n } catch {\n console.warn(\n 'useConfiguration called outside injection context; ' +\n 'configuration may not be synchronized.'\n );\n }\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,yBAAyB;CACpC,MAAM,CAAC,qBAAqB,oBAC1BA,qDAAmCC,4BAAW,uBAAuB;AAGvE,KAAI;AAGF,gCAF0BC,0BAAY,EAAE,UAAU,MAAM,CAAC,EAIvD;OAAI,CAAC,qBAAqB,CACxB,kBAAiBC,+BAAc;;SAG7B;AACN,UAAQ,KACN,4FAED"}
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __angular_core = require("@angular/core");
2
+ let _angular_core = require("@angular/core");
3
3
 
4
4
  //#region src/editor/createSharedComposable.ts
5
5
  /**
@@ -8,7 +8,7 @@ let __angular_core = require("@angular/core");
8
8
  */
9
9
  function tryOnScopeDispose(fn) {
10
10
  try {
11
- const destroyRef = (0, __angular_core.inject)(__angular_core.DestroyRef, { optional: true });
11
+ const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
12
12
  if (destroyRef) {
13
13
  destroyRef.onDestroy(fn);
14
14
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"createSharedComposable.cjs","names":["DestroyRef","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,wCAAoBA,2BAAY,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,IAAIC;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
+ {"version":3,"file":"createSharedComposable.cjs","names":["DestroyRef","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,uCAAoBA,0BAAY,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,IAAIC;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,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
3
  const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
- let __angular_core = require("@angular/core");
5
- let __intlayer_editor = require("@intlayer/editor");
4
+ let _angular_core = require("@angular/core");
5
+ let _intlayer_editor = require("@intlayer/editor");
6
6
 
7
7
  //#region src/editor/dictionariesRecord.ts
8
8
  /**
@@ -11,7 +11,7 @@ let __intlayer_editor = require("@intlayer/editor");
11
11
  let instance = null;
12
12
  const createDictionaryRecordClient = () => {
13
13
  if (instance) return instance;
14
- const localeDictionariesSignal = (0, __angular_core.signal)(void 0);
14
+ const localeDictionariesSignal = (0, _angular_core.signal)(void 0);
15
15
  instance = {
16
16
  localeDictionaries: localeDictionariesSignal.asReadonly(),
17
17
  setLocaleDictionaries: (newValue) => {
@@ -36,8 +36,8 @@ const installDictionariesRecord = (_injector) => {
36
36
  const useDictionariesRecord = require_editor_createSharedComposable.createSharedComposable(() => {
37
37
  const client = createDictionaryRecordClient();
38
38
  if (!client) throw new Error("DictionariesRecord state not found");
39
- const [_dictionariesRecord, setDictionariesRecord] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
40
- (0, __angular_core.effect)(() => {
39
+ const [_dictionariesRecord, setDictionariesRecord] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
40
+ (0, _angular_core.effect)(() => {
41
41
  setDictionariesRecord(client.localeDictionaries());
42
42
  });
43
43
  });
@@ -1 +1 @@
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 { 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: (dictionary: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent | undefined>(\n undefined\n );\n\n instance = {\n localeDictionaries:\n localeDictionariesSignal.asReadonly() as Signal<DictionaryContent>,\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.localId!]: 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":";;;;;;;;;;AASA,IAAIA,WAA4C;AAUhD,MAAa,qCAAqC;AAChD,KAAI,SAAU,QAAO;CAErB,MAAM,sDACJ,OACD;AAED,YAAW;EACT,oBACE,yBAAyB,YAAY;EAEvC,wBAAwB,aAAa;AACnC,4BAAyB,IAAI,YAAY,EAAE,CAAC;;EAG9C,oBAAoB,YAAY;GAC9B,MAAM,UAAU,0BAA0B;AAC1C,4BAAyB,IAAI;IAC3B,GAAG;KACF,WAAW,UAAW;IACxB,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
+ {"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 { 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: (dictionary: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent | undefined>(\n undefined\n );\n\n instance = {\n localeDictionaries:\n localeDictionariesSignal.asReadonly() as Signal<DictionaryContent>,\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.localId!]: 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":";;;;;;;;;;AASA,IAAIA,WAA4C;AAUhD,MAAa,qCAAqC;AAChD,KAAI,SAAU,QAAO;CAErB,MAAM,qDACJ,OACD;AAED,YAAW;EACT,oBACE,yBAAyB,YAAY;EAEvC,wBAAwB,aAAa;AACnC,4BAAyB,IAAI,YAAY,EAAE,CAAC;;EAG9C,oBAAoB,YAAY;GAC9B,MAAM,UAAU,0BAA0B;AAC1C,4BAAyB,IAAI;IAC3B,GAAG;KACF,WAAW,UAAW;IACxB,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,4BAAW,sCACX,OACD;AAGH,iCAAa;AAEX,wBADiB,OAAO,oBAAoB,CACb;GAC/B;EACF"}
@@ -1,9 +1,9 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
3
  const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
- let __intlayer_core = require("@intlayer/core");
5
- let __angular_core = require("@angular/core");
6
- let __intlayer_editor = require("@intlayer/editor");
4
+ let _intlayer_core = require("@intlayer/core");
5
+ let _angular_core = require("@angular/core");
6
+ let _intlayer_editor = require("@intlayer/editor");
7
7
 
8
8
  //#region src/editor/editedContent.ts
9
9
  /**
@@ -15,16 +15,16 @@ let instance = null;
15
15
  */
16
16
  const createEditedContentClient = () => {
17
17
  if (instance) return instance;
18
- const editedContentSignal = (0, __angular_core.signal)({});
18
+ const editedContentSignal = (0, _angular_core.signal)({});
19
19
  instance = {
20
20
  editedContent: editedContentSignal.asReadonly(),
21
21
  getEditedContentValue: (localDictionaryIdOrKey, keyPath) => {
22
22
  const editedContent = editedContentSignal();
23
23
  if (!editedContent) return void 0;
24
- if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return (0, __intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
24
+ if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return (0, _intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
25
25
  const filteredDictionariesLocalId = Object.keys(editedContent).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`));
26
26
  for (const localDictionaryId of filteredDictionariesLocalId) {
27
- const contentNode = (0, __intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
27
+ const contentNode = (0, _intlayer_core.getContentNodeByKeyPath)(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
28
28
  if (contentNode) return contentNode;
29
29
  }
30
30
  },
@@ -43,12 +43,12 @@ const installEditedContent = (_injector) => {
43
43
  const useEditedContent = require_editor_createSharedComposable.createSharedComposable(() => {
44
44
  const client = createEditedContentClient();
45
45
  if (!client) throw new Error("EditedContent state not found");
46
- const [edited, setEdited] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
47
- (0, __angular_core.effect)(() => {
46
+ const [edited, setEdited] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
47
+ (0, _angular_core.effect)(() => {
48
48
  const newValue = edited();
49
49
  client.setEditedContent(newValue ?? {});
50
50
  });
51
- (0, __angular_core.effect)(() => {
51
+ (0, _angular_core.effect)(() => {
52
52
  setEdited(client.editedContent());
53
53
  });
54
54
  return client;
@@ -1 +1 @@
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
+ {"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,gDAA4C,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,oDALE,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,0DAFJ,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,4BAAW,iCACX,EAAE,CACH;AAGD,iCAAa;EACX,MAAM,WAAW,QAAQ;AACzB,SAAO,iBAAiB,YAAY,EAAE,CAAC;GACvC;AAEF,iCAAa;AAEX,YADiB,OAAO,eAAe,CACpB;GACnB;AAEF,QAAO;EACP"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
3
  const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
4
- let __angular_core = require("@angular/core");
5
- let __intlayer_editor = require("@intlayer/editor");
4
+ let _angular_core = require("@angular/core");
5
+ let _intlayer_editor = require("@intlayer/editor");
6
6
 
7
7
  //#region src/editor/editorEnabled.ts
8
8
  /**
@@ -14,9 +14,9 @@ let instance = null;
14
14
  */
15
15
  const createEditorEnabledClient = () => {
16
16
  if (instance) return instance;
17
- const wrapperEnabledSignal = (0, __angular_core.signal)(false);
18
- const isInIframeSignal = (0, __angular_core.signal)(false);
19
- const enabledSignal = (0, __angular_core.computed)(() => wrapperEnabledSignal() && isInIframeSignal());
17
+ const wrapperEnabledSignal = (0, _angular_core.signal)(false);
18
+ const isInIframeSignal = (0, _angular_core.signal)(false);
19
+ const enabledSignal = (0, _angular_core.computed)(() => wrapperEnabledSignal() && isInIframeSignal());
20
20
  instance = {
21
21
  wrapperEnabled: wrapperEnabledSignal.asReadonly(),
22
22
  isInIframe: isInIframeSignal.asReadonly(),
@@ -33,10 +33,10 @@ const installEditorEnabled = (_injector) => {
33
33
  const useEditorEnabled = require_editor_createSharedComposable.createSharedComposable(() => {
34
34
  const client = createEditorEnabledClient();
35
35
  if (!client) throw new Error("EditorEnabled state not found");
36
- require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(`${__intlayer_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
36
+ require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(`${_intlayer_editor.MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
37
37
  client.wrapperEnabled.set(data);
38
38
  });
39
- (0, __angular_core.effect)(() => {
39
+ (0, _angular_core.effect)(() => {
40
40
  if (typeof window !== "undefined") client.isInIframe.set(window.self !== window.top);
41
41
  }, { allowSignalWrites: true });
42
42
  return client;
@@ -1 +1 @@
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
+ {"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,iDAA8B,MAAM;CAC1C,MAAM,6CAA0B,MAAM;CACtC,MAAM,kDACE,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,4BAAW,wBAAwB,SACrC,SAAS;AACR,EAAC,OAAO,eAAuB,IAAI,KAAK;GAE3C;AAGD,iCACQ;AACJ,MAAI,OAAO,WAAW,YACpB,CAAC,OAAO,WAAmB,IAAI,OAAO,SAAS,OAAO,IAAI;IAG9D,EAAE,mBAAmB,MAAM,CAC5B;AAED,QAAO;EACP"}
@@ -2,15 +2,15 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
3
  const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
4
  const require_client_installIntlayer = require('../client/installIntlayer.cjs');
5
- let __angular_core = require("@angular/core");
6
- let __intlayer_editor = require("@intlayer/editor");
5
+ let _angular_core = require("@angular/core");
6
+ let _intlayer_editor = require("@intlayer/editor");
7
7
 
8
8
  //#region src/editor/editorLocale.ts
9
9
  const useEditorLocale = require_editor_createSharedComposable.createSharedComposable(() => {
10
- const client = (0, __angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
10
+ const client = (0, _angular_core.inject)(require_client_installIntlayer.INTLAYER_TOKEN);
11
11
  if (!client) throw new Error("IntlayerEditor state not found");
12
- const [_data, setData] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_CURRENT_LOCALE);
13
- (0, __angular_core.effect)(() => {
12
+ const [_data, setData] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_CURRENT_LOCALE);
13
+ (0, _angular_core.effect)(() => {
14
14
  setData(client.locale());
15
15
  });
16
16
  return client;
@@ -1 +1 @@
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"}
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,mCAAkCC,8CAAe;AAEvD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iCAAiC;CAGnD,MAAM,CAAC,OAAO,WAAWC,qDACvBC,4BAAW,wBACZ;AAGD,iCAAa;AAEX,UADiB,OAAO,QAAQ,CACL;GAC3B;AAEF,QAAO;EACP"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
3
  const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
4
- let __angular_core = require("@angular/core");
5
- let __intlayer_editor = require("@intlayer/editor");
4
+ let _angular_core = require("@angular/core");
5
+ let _intlayer_editor = require("@intlayer/editor");
6
6
 
7
7
  //#region src/editor/focusDictionary.ts
8
8
  /**
@@ -14,7 +14,7 @@ let instance = null;
14
14
  */
15
15
  const createFocusDictionaryClient = () => {
16
16
  if (instance) return instance;
17
- const focusedContentSignal = (0, __angular_core.signal)(null);
17
+ const focusedContentSignal = (0, _angular_core.signal)(null);
18
18
  const setFocusedContent = (focussedContent) => {
19
19
  focusedContentSignal.set(focussedContent);
20
20
  };
@@ -42,13 +42,13 @@ const installFocusDictionary = (_injector) => {
42
42
  /** consumer */
43
43
  const useFocusDictionary = require_editor_createSharedComposable.createSharedComposable(() => {
44
44
  const client = createFocusDictionaryClient();
45
- const [focusedContent, setFocusedContent] = require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);
45
+ const [focusedContent, setFocusedContent] = require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);
46
46
  if (!client) throw new Error("FocusDictionary state not found");
47
- (0, __angular_core.effect)(() => {
47
+ (0, _angular_core.effect)(() => {
48
48
  const newValue = client.focusedContent();
49
49
  if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) setFocusedContent(newValue);
50
50
  });
51
- (0, __angular_core.effect)(() => {
51
+ (0, _angular_core.effect)(() => {
52
52
  const newValue = focusedContent();
53
53
  if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) client.setFocusedContent(newValue ?? null);
54
54
  });
@@ -1 +1 @@
1
- {"version":3,"file":"focusDictionary.cjs","names":["instance: FocusDictionaryClient | null","createSharedComposable","useCrossFrameState","MessageKey"],"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,kDAAkD,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,qBAAqBC,mEAA6B;CAC7D,MAAM,SAAS,6BAA6B;CAC5C,MAAM,CAAC,gBAAgB,qBACrBC,qDACEC,6BAAW,iCACZ;AAEH,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,kCAAkC;AAKpD,kCAAa;EACX,MAAM,WAAW,OAAO,gBAAgB;AACxC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,gBAAgB,CAAC,CAC/D,mBAAkB,SAAS;GAE7B;AAGF,kCAAa;EACX,MAAM,WAAW,gBAAgB;AACjC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,OAAO,gBAAgB,CAAC,CACtE,QAAO,kBAAkB,YAAY,KAAK;GAE5C;AAEF,QAAO;EACP"}
1
+ {"version":3,"file":"focusDictionary.cjs","names":["instance: FocusDictionaryClient | null","createSharedComposable","useCrossFrameState","MessageKey"],"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,iDAAkD,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,qBAAqBC,mEAA6B;CAC7D,MAAM,SAAS,6BAA6B;CAC5C,MAAM,CAAC,gBAAgB,qBACrBC,qDACEC,4BAAW,iCACZ;AAEH,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,kCAAkC;AAKpD,iCAAa;EACX,MAAM,WAAW,OAAO,gBAAgB;AACxC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,gBAAgB,CAAC,CAC/D,mBAAkB,SAAS;GAE7B;AAGF,iCAAa;EACX,MAAM,WAAW,gBAAgB;AACjC,MAAI,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,OAAO,gBAAgB,CAAC,CACtE,QAAO,kBAAkB,YAAY,KAAK;GAE5C;AAEF,QAAO;EACP"}
@@ -4,11 +4,11 @@ const require_editor_editorEnabled = require('./editorEnabled.cjs');
4
4
  const require_editor_focusDictionary = require('./focusDictionary.cjs');
5
5
  const require_editor_dictionariesRecord = require('./dictionariesRecord.cjs');
6
6
  const require_editor_editedContent = require('./editedContent.cjs');
7
- let __intlayer_config_built = require("@intlayer/config/built");
8
- __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
7
+ let _intlayer_config_built = require("@intlayer/config/built");
8
+ _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
9
9
 
10
10
  //#region src/editor/installIntlayerEditor.ts
11
- const { editor } = __intlayer_config_built.default;
11
+ const { editor } = _intlayer_config_built.default;
12
12
  const { applicationURL, editorURL, cmsURL } = editor ?? {};
13
13
  const postMessage = (data) => {
14
14
  if (typeof window === "undefined") return;
@@ -2,8 +2,8 @@
2
2
 
3
3
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
4
4
  const require_editor_communicator = require('./communicator.cjs');
5
- let __angular_core = require("@angular/core");
6
- let __intlayer_editor = require("@intlayer/editor");
5
+ let _angular_core = require("@angular/core");
6
+ let _intlayer_editor = require("@intlayer/editor");
7
7
 
8
8
  //#region src/editor/useCrossFrameMessageListener.ts
9
9
  /** Map<key, Set<callback>> */
@@ -32,7 +32,7 @@ const ensureGlobalListener = (allowedOrigins, selfId) => {
32
32
  const { type, data, senderId } = event.data ?? {};
33
33
  if (!type) return;
34
34
  if (senderId === selfId) return;
35
- if (!allowedOrigins || allowedOrigins.includes("*") || allowedOrigins.some((o) => (0, __intlayer_editor.compareUrls)(o, event.origin))) subscribers.get(type)?.forEach((cb) => {
35
+ if (!allowedOrigins || allowedOrigins.includes("*") || allowedOrigins.some((o) => (0, _intlayer_editor.compareUrls)(o, event.origin))) subscribers.get(type)?.forEach((cb) => {
36
36
  cb(data);
37
37
  });
38
38
  });
@@ -52,7 +52,7 @@ const useCrossFrameMessageListener = (key, onEventTriggered) => {
52
52
  if (onEventTriggered) {
53
53
  addSubscriber(key, onEventTriggered);
54
54
  try {
55
- const destroyRef = (0, __angular_core.inject)(__angular_core.DestroyRef, { optional: true });
55
+ const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
56
56
  if (destroyRef) destroyRef.onDestroy(() => removeSubscriber(key, onEventTriggered));
57
57
  } catch {
58
58
  console.warn("useCrossFrameMessageListener called outside injection context; cleanup may not be available.");
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useCommunicator","DestroyRef"],"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nconst addSubscriber = (key: string, cb: AnyFn) => {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n};\n\nconst removeSubscriber = (key: string, cb: AnyFn) => {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n};\n\n/** The one global window listener */\nconst ensureGlobalListener = (\n allowedOrigins: string[] | undefined,\n selfId: string\n) => {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => {\n cb(data);\n });\n }\n });\n windowListenerAttached = true;\n};\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAM,8BAAc,IAAI,KAAyB;;AAGjD,IAAI,yBAAyB;;AAG7B,MAAM,iBAAiB,KAAa,OAAc;CAChD,IAAI,MAAM,YAAY,IAAI,IAAI;AAC9B,KAAI,CAAC,KAAK;AACR,wBAAM,IAAI,KAAK;AACf,cAAY,IAAI,KAAK,IAAI;;AAE3B,KAAI,IAAI,GAAG;;AAGb,MAAM,oBAAoB,KAAa,OAAc;CACnD,MAAM,MAAM,YAAY,IAAI,IAAI;AAChC,KAAI,CAAC,IAAK;AACV,KAAI,OAAO,GAAG;AACd,KAAI,IAAI,SAAS,EAAG,aAAY,OAAO,IAAI;;;AAI7C,MAAM,wBACJ,gBACA,WACG;AACH,KAAI,uBAAwB;AAC5B,QAAO,iBAAiB,YAAY,UAAU;EAC5C,MAAM,EAAE,MAAM,MAAM,aAAa,MAAM,QAAQ,EAAE;AACjD,MAAI,CAAC,KAAM;AACX,MAAI,aAAa,OAAQ;AAGzB,MACE,CAAC,kBACD,eAAe,SAAS,IAAI,IAC5B,eAAe,MAAM,yCAAkB,GAAG,MAAM,OAAO,CAAC,CAGxD,aAAY,IAAI,KAAK,EAAE,SAAS,OAAO;AACrC,MAAG,KAAK;IACR;GAEJ;AACF,0BAAyB;;;;;;;;;;AAY3B,MAAa,gCACX,KACA,qBACG;CAEH,MAAM,EAAE,gBAAgB,aAAa,aAAaA,6CAAiB;AAGnE,sBAAqB,gBAAgB,SAAS;AAG9C,KAAI,kBAAkB;AACpB,gBAAc,KAAK,iBAA0B;AAG7C,MAAI;GACF,MAAM,wCAAoBC,2BAAY,EAAE,UAAU,MAAM,CAAC;AACzD,OAAI,WACF,YAAW,gBACT,iBAAiB,KAAK,iBAA0B,CACjD;UAEG;AAEN,WAAQ,KACN,+FAED;;;CAKL,MAAM,sBAAsB,SAAa;AACvC,cAAY;GAAE,MAAM;GAAK;GAAM;GAAU,CAAC;;AAG5C,QAAO"}
1
+ {"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useCommunicator","DestroyRef"],"sources":["../../../src/editor/useCrossFrameMessageListener.ts"],"sourcesContent":["'use client';\n\nimport { DestroyRef, inject } from '@angular/core';\nimport { compareUrls, type MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\n\n// ---------- module-level singletons ----------\ntype AnyFn = (data: unknown) => void;\n\n/** Map<key, Set<callback>> */\nconst subscribers = new Map<string, Set<AnyFn>>();\n\n/** True once we've attached the single window listener */\nlet windowListenerAttached = false;\n\n/** Helper to add/remove a callback for a key */\nconst addSubscriber = (key: string, cb: AnyFn) => {\n let set = subscribers.get(key);\n if (!set) {\n set = new Set();\n subscribers.set(key, set);\n }\n set.add(cb);\n};\n\nconst removeSubscriber = (key: string, cb: AnyFn) => {\n const set = subscribers.get(key);\n if (!set) return;\n set.delete(cb);\n if (set.size === 0) subscribers.delete(key);\n};\n\n/** The one global window listener */\nconst ensureGlobalListener = (\n allowedOrigins: string[] | undefined,\n selfId: string\n) => {\n if (windowListenerAttached) return;\n window.addEventListener('message', (event) => {\n const { type, data, senderId } = event.data ?? {};\n if (!type) return; // guard malformed messages\n if (senderId === selfId) return; // ignore my own\n\n // origin check\n if (\n !allowedOrigins ||\n allowedOrigins.includes('*') ||\n allowedOrigins.some((o) => compareUrls(o, event.origin))\n ) {\n // broadcast to everyone interested in this key\n subscribers.get(type)?.forEach((cb) => {\n cb(data);\n });\n }\n });\n windowListenerAttached = true;\n};\n// ---------- end module-level code ----------\n\n/**\n * useCrossFrameMessageListener\n *\n * @template S - type of the message payload\n * @param key message type we care about\n * @param onEventTriggered optional callback when a matching message arrives\n * @returns postMessage(data?) helper scoped to this key\n */\nexport const useCrossFrameMessageListener = <S>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void\n) => {\n // Communicator is the same for everyone, so it's fine to call every time.\n const { allowedOrigins, postMessage, senderId } = useCommunicator();\n\n // --- 1. make sure the global listener exists ----\n ensureGlobalListener(allowedOrigins, senderId);\n\n // --- 2. register this caller's callback (if any) ---\n if (onEventTriggered) {\n addSubscriber(key, onEventTriggered as AnyFn);\n\n // Use Angular's DestroyRef for cleanup instead of Vue's onScopeDispose\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(() =>\n removeSubscriber(key, onEventTriggered as AnyFn)\n );\n }\n } catch {\n // If called outside injection context, no cleanup available\n console.warn(\n 'useCrossFrameMessageListener called outside injection context; ' +\n 'cleanup may not be available.'\n );\n }\n }\n\n // --- 3. return a wrapper that tags outgoing messages with our key ---\n const postMessageWrapper = (data?: S) => {\n postMessage({ type: key, data, senderId });\n };\n\n return postMessageWrapper;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAM,8BAAc,IAAI,KAAyB;;AAGjD,IAAI,yBAAyB;;AAG7B,MAAM,iBAAiB,KAAa,OAAc;CAChD,IAAI,MAAM,YAAY,IAAI,IAAI;AAC9B,KAAI,CAAC,KAAK;AACR,wBAAM,IAAI,KAAK;AACf,cAAY,IAAI,KAAK,IAAI;;AAE3B,KAAI,IAAI,GAAG;;AAGb,MAAM,oBAAoB,KAAa,OAAc;CACnD,MAAM,MAAM,YAAY,IAAI,IAAI;AAChC,KAAI,CAAC,IAAK;AACV,KAAI,OAAO,GAAG;AACd,KAAI,IAAI,SAAS,EAAG,aAAY,OAAO,IAAI;;;AAI7C,MAAM,wBACJ,gBACA,WACG;AACH,KAAI,uBAAwB;AAC5B,QAAO,iBAAiB,YAAY,UAAU;EAC5C,MAAM,EAAE,MAAM,MAAM,aAAa,MAAM,QAAQ,EAAE;AACjD,MAAI,CAAC,KAAM;AACX,MAAI,aAAa,OAAQ;AAGzB,MACE,CAAC,kBACD,eAAe,SAAS,IAAI,IAC5B,eAAe,MAAM,wCAAkB,GAAG,MAAM,OAAO,CAAC,CAGxD,aAAY,IAAI,KAAK,EAAE,SAAS,OAAO;AACrC,MAAG,KAAK;IACR;GAEJ;AACF,0BAAyB;;;;;;;;;;AAY3B,MAAa,gCACX,KACA,qBACG;CAEH,MAAM,EAAE,gBAAgB,aAAa,aAAaA,6CAAiB;AAGnE,sBAAqB,gBAAgB,SAAS;AAG9C,KAAI,kBAAkB;AACpB,gBAAc,KAAK,iBAA0B;AAG7C,MAAI;GACF,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,MAAM,CAAC;AACzD,OAAI,WACF,YAAW,gBACT,iBAAiB,KAAK,iBAA0B,CACjD;UAEG;AAEN,WAAQ,KACN,+FAED;;;CAKL,MAAM,sBAAsB,SAAa;AACvC,cAAY;GAAE,MAAM;GAAK;GAAM;GAAU,CAAC;;AAG5C,QAAO"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_communicator = require('./communicator.cjs');
3
3
  const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
4
- let __angular_core = require("@angular/core");
4
+ let _angular_core = require("@angular/core");
5
5
 
6
6
  //#region src/editor/useCrossFrameState.ts
7
7
  const crossFrameStateCache = /* @__PURE__ */ new Map();
@@ -51,7 +51,7 @@ const useCrossFrameState = (key, initialState, options = {
51
51
  * Internal reactive state using Angular signals.
52
52
  * We resolve the initial value here to avoid one extra render (same idea as in the React version).
53
53
  */
54
- const stateSignal = (0, __angular_core.signal)(resolveState(initialState));
54
+ const stateSignal = (0, _angular_core.signal)(resolveState(initialState));
55
55
  const { postMessage, senderId } = require_editor_communicator.useCommunicator();
56
56
  /**
57
57
  * Broadcast the given value if emitting is allowed and the communicator is ready.
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossFrameState.cjs","names":["setState","postState","useCommunicator"],"sources":["../../../src/editor/useCrossFrameState.ts"],"sourcesContent":["import { type Signal, signal } from '@angular/core';\nimport type { MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport type CrossFrameStateOptions = {\n /** Whether to broadcast state changes to other instances (default: true) */\n emit?: boolean;\n /** Whether to listen for state updates from other instances (default: true) */\n receive?: boolean;\n};\n\nconst crossFrameStateCache = new Map<\n string,\n {\n state: Signal<any>;\n setState: (v: any | ((prev: any) => any)) => void;\n postState: () => void;\n }\n>();\n\n/**\n * Utility to resolve either a value or an updater function (mirrors React's `setState`).\n */\nconst resolveState = <S>(\n state: S | ((prev?: S) => S) | undefined,\n prevState?: S\n): S | undefined => {\n if (typeof state === 'function') {\n return (state as (prev?: S) => S)(prevState);\n }\n return state as S;\n};\n\n/**\n * Creates a plain object copy that can be safely serialized\n * for postMessage communication\n */\nconst toSerializable = <T>(obj: T): T => {\n if (obj === null || obj === undefined) return obj;\n // Using parse/stringify for a quick deep clone to remove reactivity\n return JSON.parse(JSON.stringify(obj));\n};\n\n/**\n * Angular replacement for Vue's cross-frame state composable.\n * It synchronises a reactive value across frames/windows via the `postMessage` API.\n *\n * @template S The type of the state being synchronised.\n * @param key Unique key identifying this state channel.\n * @param initialState Initial value (or lazy factory) for the state.\n * @param options Control flags for emitting/receiving updates.\n *\n * @returns `[stateSignal, setState, postState]`\n * - `stateSignal` – Angular `Signal<S | undefined>` holding the current state.\n * - `setState` – Setter with the same API as React's `setState`.\n * - `postState` – Manually broadcast the current state (useful after mutations outside `setState`).\n */\nexport const useCrossFrameState = <S>(\n key: `${MessageKey}`,\n initialState?: S | (() => S),\n options: CrossFrameStateOptions = { emit: true, receive: true }\n): [\n Signal<S | undefined>,\n (v: S | ((prev: S | undefined) => S)) => void,\n () => void,\n] => {\n if (crossFrameStateCache.has(key)) {\n // Return the existing instance\n const { state, setState, postState } = crossFrameStateCache.get(key)!;\n return [state, setState, postState];\n }\n\n const { emit = true, receive = true } = options;\n\n /**\n * Internal reactive state using Angular signals.\n * We resolve the initial value here to avoid one extra render (same idea as in the React version).\n */\n const stateSignal = signal<S | undefined>(resolveState<S>(initialState));\n\n // Get communicator within injection context\n const { postMessage, senderId } = useCommunicator();\n\n /**\n * Broadcast the given value if emitting is allowed and the communicator is ready.\n */\n const broadcastState = (value: S | undefined) => {\n if (\n !emit ||\n typeof postMessage !== 'function' ||\n typeof value === 'undefined'\n )\n return;\n postMessage({\n type: `${key}/post`,\n data: value,\n senderId,\n });\n };\n\n /**\n * Setter that mirrors React's `setState` signature (supports value or updater fn).\n */\n const setState = (valueOrUpdater: S | ((prev: S | undefined) => S)) => {\n const next = resolveState<S>(valueOrUpdater as any, stateSignal());\n const serialised = toSerializable(next);\n stateSignal.set(serialised);\n broadcastState(serialised);\n };\n\n /**\n * Manually broadcast the current state to peers.\n */\n const postState = () => {\n if (typeof postMessage !== 'function') return;\n postMessage({\n type: `${key}/post`,\n data: stateSignal(),\n senderId,\n });\n };\n\n // Emit the initial state (if any) right away so that peers can pick it up.\n broadcastState(stateSignal());\n\n // If we are in receive mode but have no state yet, ask peers for theirs.\n if (\n receive &&\n typeof postMessage === 'function' &&\n typeof stateSignal() === 'undefined'\n ) {\n postMessage({ type: `${key}/get`, senderId });\n }\n\n /* ───────────────────── Incoming messages ───────────────────── */\n\n // 1. Updates posted by other frames\n useCrossFrameMessageListener<S>(\n `${key}/post`,\n receive\n ? (data) => {\n stateSignal.set(data);\n }\n : undefined\n );\n\n // 2. Requests from peers asking for our current value\n const handleGetMessage = (_: unknown, originSenderId?: string) => {\n if (!emit) return;\n if (originSenderId === senderId) return; // Don't respond to our own request\n broadcastState(stateSignal());\n };\n\n useCrossFrameMessageListener(\n `${key}/get`,\n emit ? handleGetMessage : undefined\n );\n\n // Cache this instance\n crossFrameStateCache.set(key, { state: stateSignal, setState, postState });\n\n return [stateSignal as Signal<S | undefined>, setState, postState];\n};\n"],"mappings":";;;;;;AAYA,MAAM,uCAAuB,IAAI,KAO9B;;;;AAKH,MAAM,gBACJ,OACA,cACkB;AAClB,KAAI,OAAO,UAAU,WACnB,QAAQ,MAA0B,UAAU;AAE9C,QAAO;;;;;;AAOT,MAAM,kBAAqB,QAAc;AACvC,KAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAE9C,QAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;;;;;;;;;;;;;;;;AAiBxC,MAAa,sBACX,KACA,cACA,UAAkC;CAAE,MAAM;CAAM,SAAS;CAAM,KAK5D;AACH,KAAI,qBAAqB,IAAI,IAAI,EAAE;EAEjC,MAAM,EAAE,OAAO,sBAAU,2BAAc,qBAAqB,IAAI,IAAI;AACpE,SAAO;GAAC;GAAOA;GAAUC;GAAU;;CAGrC,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS;;;;;CAMxC,MAAM,yCAAoC,aAAgB,aAAa,CAAC;CAGxE,MAAM,EAAE,aAAa,aAAaC,6CAAiB;;;;CAKnD,MAAM,kBAAkB,UAAyB;AAC/C,MACE,CAAC,QACD,OAAO,gBAAgB,cACvB,OAAO,UAAU,YAEjB;AACF,cAAY;GACV,MAAM,GAAG,IAAI;GACb,MAAM;GACN;GACD,CAAC;;;;;CAMJ,MAAM,YAAY,mBAAqD;EAErE,MAAM,aAAa,eADN,aAAgB,gBAAuB,aAAa,CAAC,CAC3B;AACvC,cAAY,IAAI,WAAW;AAC3B,iBAAe,WAAW;;;;;CAM5B,MAAM,kBAAkB;AACtB,MAAI,OAAO,gBAAgB,WAAY;AACvC,cAAY;GACV,MAAM,GAAG,IAAI;GACb,MAAM,aAAa;GACnB;GACD,CAAC;;AAIJ,gBAAe,aAAa,CAAC;AAG7B,KACE,WACA,OAAO,gBAAgB,cACvB,OAAO,aAAa,KAAK,YAEzB,aAAY;EAAE,MAAM,GAAG,IAAI;EAAO;EAAU,CAAC;AAM/C,0EACE,GAAG,IAAI,QACP,WACK,SAAS;AACR,cAAY,IAAI,KAAK;KAEvB,OACL;CAGD,MAAM,oBAAoB,GAAY,mBAA4B;AAChE,MAAI,CAAC,KAAM;AACX,MAAI,mBAAmB,SAAU;AACjC,iBAAe,aAAa,CAAC;;AAG/B,0EACE,GAAG,IAAI,OACP,OAAO,mBAAmB,OAC3B;AAGD,sBAAqB,IAAI,KAAK;EAAE,OAAO;EAAa;EAAU;EAAW,CAAC;AAE1E,QAAO;EAAC;EAAsC;EAAU;EAAU"}
1
+ {"version":3,"file":"useCrossFrameState.cjs","names":["setState","postState","useCommunicator"],"sources":["../../../src/editor/useCrossFrameState.ts"],"sourcesContent":["import { type Signal, signal } from '@angular/core';\nimport type { MessageKey } from '@intlayer/editor';\nimport { useCommunicator } from './communicator';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport type CrossFrameStateOptions = {\n /** Whether to broadcast state changes to other instances (default: true) */\n emit?: boolean;\n /** Whether to listen for state updates from other instances (default: true) */\n receive?: boolean;\n};\n\nconst crossFrameStateCache = new Map<\n string,\n {\n state: Signal<any>;\n setState: (v: any | ((prev: any) => any)) => void;\n postState: () => void;\n }\n>();\n\n/**\n * Utility to resolve either a value or an updater function (mirrors React's `setState`).\n */\nconst resolveState = <S>(\n state: S | ((prev?: S) => S) | undefined,\n prevState?: S\n): S | undefined => {\n if (typeof state === 'function') {\n return (state as (prev?: S) => S)(prevState);\n }\n return state as S;\n};\n\n/**\n * Creates a plain object copy that can be safely serialized\n * for postMessage communication\n */\nconst toSerializable = <T>(obj: T): T => {\n if (obj === null || obj === undefined) return obj;\n // Using parse/stringify for a quick deep clone to remove reactivity\n return JSON.parse(JSON.stringify(obj));\n};\n\n/**\n * Angular replacement for Vue's cross-frame state composable.\n * It synchronises a reactive value across frames/windows via the `postMessage` API.\n *\n * @template S The type of the state being synchronised.\n * @param key Unique key identifying this state channel.\n * @param initialState Initial value (or lazy factory) for the state.\n * @param options Control flags for emitting/receiving updates.\n *\n * @returns `[stateSignal, setState, postState]`\n * - `stateSignal` – Angular `Signal<S | undefined>` holding the current state.\n * - `setState` – Setter with the same API as React's `setState`.\n * - `postState` – Manually broadcast the current state (useful after mutations outside `setState`).\n */\nexport const useCrossFrameState = <S>(\n key: `${MessageKey}`,\n initialState?: S | (() => S),\n options: CrossFrameStateOptions = { emit: true, receive: true }\n): [\n Signal<S | undefined>,\n (v: S | ((prev: S | undefined) => S)) => void,\n () => void,\n] => {\n if (crossFrameStateCache.has(key)) {\n // Return the existing instance\n const { state, setState, postState } = crossFrameStateCache.get(key)!;\n return [state, setState, postState];\n }\n\n const { emit = true, receive = true } = options;\n\n /**\n * Internal reactive state using Angular signals.\n * We resolve the initial value here to avoid one extra render (same idea as in the React version).\n */\n const stateSignal = signal<S | undefined>(resolveState<S>(initialState));\n\n // Get communicator within injection context\n const { postMessage, senderId } = useCommunicator();\n\n /**\n * Broadcast the given value if emitting is allowed and the communicator is ready.\n */\n const broadcastState = (value: S | undefined) => {\n if (\n !emit ||\n typeof postMessage !== 'function' ||\n typeof value === 'undefined'\n )\n return;\n postMessage({\n type: `${key}/post`,\n data: value,\n senderId,\n });\n };\n\n /**\n * Setter that mirrors React's `setState` signature (supports value or updater fn).\n */\n const setState = (valueOrUpdater: S | ((prev: S | undefined) => S)) => {\n const next = resolveState<S>(valueOrUpdater as any, stateSignal());\n const serialised = toSerializable(next);\n stateSignal.set(serialised);\n broadcastState(serialised);\n };\n\n /**\n * Manually broadcast the current state to peers.\n */\n const postState = () => {\n if (typeof postMessage !== 'function') return;\n postMessage({\n type: `${key}/post`,\n data: stateSignal(),\n senderId,\n });\n };\n\n // Emit the initial state (if any) right away so that peers can pick it up.\n broadcastState(stateSignal());\n\n // If we are in receive mode but have no state yet, ask peers for theirs.\n if (\n receive &&\n typeof postMessage === 'function' &&\n typeof stateSignal() === 'undefined'\n ) {\n postMessage({ type: `${key}/get`, senderId });\n }\n\n /* ───────────────────── Incoming messages ───────────────────── */\n\n // 1. Updates posted by other frames\n useCrossFrameMessageListener<S>(\n `${key}/post`,\n receive\n ? (data) => {\n stateSignal.set(data);\n }\n : undefined\n );\n\n // 2. Requests from peers asking for our current value\n const handleGetMessage = (_: unknown, originSenderId?: string) => {\n if (!emit) return;\n if (originSenderId === senderId) return; // Don't respond to our own request\n broadcastState(stateSignal());\n };\n\n useCrossFrameMessageListener(\n `${key}/get`,\n emit ? handleGetMessage : undefined\n );\n\n // Cache this instance\n crossFrameStateCache.set(key, { state: stateSignal, setState, postState });\n\n return [stateSignal as Signal<S | undefined>, setState, postState];\n};\n"],"mappings":";;;;;;AAYA,MAAM,uCAAuB,IAAI,KAO9B;;;;AAKH,MAAM,gBACJ,OACA,cACkB;AAClB,KAAI,OAAO,UAAU,WACnB,QAAQ,MAA0B,UAAU;AAE9C,QAAO;;;;;;AAOT,MAAM,kBAAqB,QAAc;AACvC,KAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAE9C,QAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;;;;;;;;;;;;;;;;AAiBxC,MAAa,sBACX,KACA,cACA,UAAkC;CAAE,MAAM;CAAM,SAAS;CAAM,KAK5D;AACH,KAAI,qBAAqB,IAAI,IAAI,EAAE;EAEjC,MAAM,EAAE,OAAO,sBAAU,2BAAc,qBAAqB,IAAI,IAAI;AACpE,SAAO;GAAC;GAAOA;GAAUC;GAAU;;CAGrC,MAAM,EAAE,OAAO,MAAM,UAAU,SAAS;;;;;CAMxC,MAAM,wCAAoC,aAAgB,aAAa,CAAC;CAGxE,MAAM,EAAE,aAAa,aAAaC,6CAAiB;;;;CAKnD,MAAM,kBAAkB,UAAyB;AAC/C,MACE,CAAC,QACD,OAAO,gBAAgB,cACvB,OAAO,UAAU,YAEjB;AACF,cAAY;GACV,MAAM,GAAG,IAAI;GACb,MAAM;GACN;GACD,CAAC;;;;;CAMJ,MAAM,YAAY,mBAAqD;EAErE,MAAM,aAAa,eADN,aAAgB,gBAAuB,aAAa,CAAC,CAC3B;AACvC,cAAY,IAAI,WAAW;AAC3B,iBAAe,WAAW;;;;;CAM5B,MAAM,kBAAkB;AACtB,MAAI,OAAO,gBAAgB,WAAY;AACvC,cAAY;GACV,MAAM,GAAG,IAAI;GACb,MAAM,aAAa;GACnB;GACD,CAAC;;AAIJ,gBAAe,aAAa,CAAC;AAG7B,KACE,WACA,OAAO,gBAAgB,cACvB,OAAO,aAAa,KAAK,YAEzB,aAAY;EAAE,MAAM,GAAG,IAAI;EAAO;EAAU,CAAC;AAM/C,0EACE,GAAG,IAAI,QACP,WACK,SAAS;AACR,cAAY,IAAI,KAAK;KAEvB,OACL;CAGD,MAAM,oBAAoB,GAAY,mBAA4B;AAChE,MAAI,CAAC,KAAM;AACX,MAAI,mBAAmB,SAAU;AACjC,iBAAe,aAAa,CAAC;;AAG/B,0EACE,GAAG,IAAI,OACP,OAAO,mBAAmB,OAC3B;AAGD,sBAAqB,IAAI,KAAK;EAAE,OAAO;EAAa;EAAU;EAAW,CAAC;AAE1E,QAAO;EAAC;EAAsC;EAAU;EAAU"}
@@ -1,7 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_useCrossFrameState = require('./useCrossFrameState.cjs');
3
- let __angular_core = require("@angular/core");
4
- let __intlayer_editor = require("@intlayer/editor");
3
+ let _angular_core = require("@angular/core");
4
+ let _intlayer_editor = require("@intlayer/editor");
5
5
 
6
6
  //#region src/editor/useCrossURLPathState.ts
7
7
  /**
@@ -10,7 +10,7 @@ let __intlayer_editor = require("@intlayer/editor");
10
10
  * @param opts - Options for controlling emit and receive behavior
11
11
  * @returns A tuple containing [state signal, setState function, forceSync function]
12
12
  */
13
- const useCrossURLPathState = (initial, opts) => require_editor_useCrossFrameState.useCrossFrameState(__intlayer_editor.MessageKey.INTLAYER_URL_CHANGE, initial, opts);
13
+ const useCrossURLPathState = (initial, opts) => require_editor_useCrossFrameState.useCrossFrameState(_intlayer_editor.MessageKey.INTLAYER_URL_CHANGE, initial, opts);
14
14
  /**
15
15
  * Hook for host applications to push URL path changes into the shared state
16
16
  * This also monkey patches history methods to capture navigation events
@@ -26,7 +26,7 @@ const useCrossURLPathSetter = (initial) => {
26
26
  let originalReplaceState;
27
27
  const update = () => setState(window.location.pathname);
28
28
  try {
29
- const destroyRef = (0, __angular_core.inject)(__angular_core.DestroyRef, { optional: true });
29
+ const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
30
30
  if (destroyRef && typeof window !== "undefined") {
31
31
  originalPushState = history.pushState;
32
32
  originalReplaceState = history.replaceState;
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossURLPathState.cjs","names":["useCrossFrameState","MessageKey","originalPushState: typeof history.pushState","originalReplaceState: typeof history.replaceState","DestroyRef"],"sources":["../../../src/editor/useCrossURLPathState.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Hook to create and manage a cross-frame synchronized URL path state\n * @param initial - The initial URL path\n * @param opts - Options for controlling emit and receive behavior\n * @returns A tuple containing [state signal, setState function, forceSync function]\n */\nexport const useCrossURLPathState = (\n initial?: string,\n opts?: Parameters<typeof useCrossFrameState>[2]\n) => useCrossFrameState<string>(MessageKey.INTLAYER_URL_CHANGE, initial, opts);\n\n/**\n * Hook for host applications to push URL path changes into the shared state\n * This also monkey patches history methods to capture navigation events\n * @param initial - The initial URL path\n * @returns A tuple containing [state signal, setState function]\n */\nexport const useCrossURLPathSetter = (initial?: string) => {\n const [state, setState] = useCrossURLPathState(initial, {\n emit: true,\n receive: false,\n });\n\n // Original history methods\n let originalPushState: typeof history.pushState;\n let originalReplaceState: typeof history.replaceState;\n\n // Function to update state with current pathname\n const update = () => setState(window.location.pathname);\n\n // Use Angular's DestroyRef for cleanup instead of Vue lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Save original methods\n originalPushState = history.pushState;\n originalReplaceState = history.replaceState;\n\n /**\n * Wraps a history function to dispatch a custom event when called\n * @param fn - The history function to wrap\n * @returns The wrapped function\n */\n const wrap =\n (fn: typeof history.pushState) =>\n (...args: Parameters<typeof history.pushState>) => {\n fn.apply(history, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n // Patch history methods\n history.pushState = wrap(originalPushState);\n history.replaceState = wrap(originalReplaceState);\n\n // Add event listeners\n window.addEventListener('locationchange', update);\n window.addEventListener('popstate', update);\n window.addEventListener('hashchange', update);\n\n // Initialize immediately\n update();\n\n // Clean up on destroy\n destroyRef.onDestroy(() => {\n window.removeEventListener('locationchange', update);\n window.removeEventListener('popstate', update);\n window.removeEventListener('hashchange', update);\n\n // Restore original history methods\n if (originalPushState) history.pushState = originalPushState;\n if (originalReplaceState) history.replaceState = originalReplaceState;\n });\n }\n } catch {\n console.warn(\n 'useCrossURLPathSetter called outside injection context; ' +\n 'URL path synchronization may not be available.'\n );\n }\n\n return [state, setState] as const;\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,wBACX,SACA,SACGA,qDAA2BC,6BAAW,qBAAqB,SAAS,KAAK;;;;;;;AAQ9E,MAAa,yBAAyB,YAAqB;CACzD,MAAM,CAAC,OAAO,YAAY,qBAAqB,SAAS;EACtD,MAAM;EACN,SAAS;EACV,CAAC;CAGF,IAAIC;CACJ,IAAIC;CAGJ,MAAM,eAAe,SAAS,OAAO,SAAS,SAAS;AAGvD,KAAI;EACF,MAAM,wCAAoBC,2BAAY,EAAE,UAAU,MAAM,CAAC;AAEzD,MAAI,cAAc,OAAO,WAAW,aAAa;AAE/C,uBAAoB,QAAQ;AAC5B,0BAAuB,QAAQ;;;;;;GAO/B,MAAM,QACH,QACA,GAAG,SAA+C;AACjD,OAAG,MAAM,SAAS,KAAK;AACvB,WAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC;;AAIrD,WAAQ,YAAY,KAAK,kBAAkB;AAC3C,WAAQ,eAAe,KAAK,qBAAqB;AAGjD,UAAO,iBAAiB,kBAAkB,OAAO;AACjD,UAAO,iBAAiB,YAAY,OAAO;AAC3C,UAAO,iBAAiB,cAAc,OAAO;AAG7C,WAAQ;AAGR,cAAW,gBAAgB;AACzB,WAAO,oBAAoB,kBAAkB,OAAO;AACpD,WAAO,oBAAoB,YAAY,OAAO;AAC9C,WAAO,oBAAoB,cAAc,OAAO;AAGhD,QAAI,kBAAmB,SAAQ,YAAY;AAC3C,QAAI,qBAAsB,SAAQ,eAAe;KACjD;;SAEE;AACN,UAAQ,KACN,yGAED;;AAGH,QAAO,CAAC,OAAO,SAAS"}
1
+ {"version":3,"file":"useCrossURLPathState.cjs","names":["useCrossFrameState","MessageKey","originalPushState: typeof history.pushState","originalReplaceState: typeof history.replaceState","DestroyRef"],"sources":["../../../src/editor/useCrossURLPathState.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Hook to create and manage a cross-frame synchronized URL path state\n * @param initial - The initial URL path\n * @param opts - Options for controlling emit and receive behavior\n * @returns A tuple containing [state signal, setState function, forceSync function]\n */\nexport const useCrossURLPathState = (\n initial?: string,\n opts?: Parameters<typeof useCrossFrameState>[2]\n) => useCrossFrameState<string>(MessageKey.INTLAYER_URL_CHANGE, initial, opts);\n\n/**\n * Hook for host applications to push URL path changes into the shared state\n * This also monkey patches history methods to capture navigation events\n * @param initial - The initial URL path\n * @returns A tuple containing [state signal, setState function]\n */\nexport const useCrossURLPathSetter = (initial?: string) => {\n const [state, setState] = useCrossURLPathState(initial, {\n emit: true,\n receive: false,\n });\n\n // Original history methods\n let originalPushState: typeof history.pushState;\n let originalReplaceState: typeof history.replaceState;\n\n // Function to update state with current pathname\n const update = () => setState(window.location.pathname);\n\n // Use Angular's DestroyRef for cleanup instead of Vue lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Save original methods\n originalPushState = history.pushState;\n originalReplaceState = history.replaceState;\n\n /**\n * Wraps a history function to dispatch a custom event when called\n * @param fn - The history function to wrap\n * @returns The wrapped function\n */\n const wrap =\n (fn: typeof history.pushState) =>\n (...args: Parameters<typeof history.pushState>) => {\n fn.apply(history, args);\n window.dispatchEvent(new Event('locationchange'));\n };\n\n // Patch history methods\n history.pushState = wrap(originalPushState);\n history.replaceState = wrap(originalReplaceState);\n\n // Add event listeners\n window.addEventListener('locationchange', update);\n window.addEventListener('popstate', update);\n window.addEventListener('hashchange', update);\n\n // Initialize immediately\n update();\n\n // Clean up on destroy\n destroyRef.onDestroy(() => {\n window.removeEventListener('locationchange', update);\n window.removeEventListener('popstate', update);\n window.removeEventListener('hashchange', update);\n\n // Restore original history methods\n if (originalPushState) history.pushState = originalPushState;\n if (originalReplaceState) history.replaceState = originalReplaceState;\n });\n }\n } catch {\n console.warn(\n 'useCrossURLPathSetter called outside injection context; ' +\n 'URL path synchronization may not be available.'\n );\n }\n\n return [state, setState] as const;\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,wBACX,SACA,SACGA,qDAA2BC,4BAAW,qBAAqB,SAAS,KAAK;;;;;;;AAQ9E,MAAa,yBAAyB,YAAqB;CACzD,MAAM,CAAC,OAAO,YAAY,qBAAqB,SAAS;EACtD,MAAM;EACN,SAAS;EACV,CAAC;CAGF,IAAIC;CACJ,IAAIC;CAGJ,MAAM,eAAe,SAAS,OAAO,SAAS,SAAS;AAGvD,KAAI;EACF,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,MAAM,CAAC;AAEzD,MAAI,cAAc,OAAO,WAAW,aAAa;AAE/C,uBAAoB,QAAQ;AAC5B,0BAAuB,QAAQ;;;;;;GAO/B,MAAM,QACH,QACA,GAAG,SAA+C;AACjD,OAAG,MAAM,SAAS,KAAK;AACvB,WAAO,cAAc,IAAI,MAAM,iBAAiB,CAAC;;AAIrD,WAAQ,YAAY,KAAK,kBAAkB;AAC3C,WAAQ,eAAe,KAAK,qBAAqB;AAGjD,UAAO,iBAAiB,kBAAkB,OAAO;AACjD,UAAO,iBAAiB,YAAY,OAAO;AAC3C,UAAO,iBAAiB,cAAc,OAAO;AAG7C,WAAQ;AAGR,cAAW,gBAAgB;AACzB,WAAO,oBAAoB,kBAAkB,OAAO;AACpD,WAAO,oBAAoB,YAAY,OAAO;AAC9C,WAAO,oBAAoB,cAAc,OAAO;AAGhD,QAAI,kBAAmB,SAAQ,YAAY;AAC3C,QAAI,qBAAsB,SAAQ,eAAe;KACjD;;SAEE;AACN,UAAQ,KACN,yGAED;;AAGH,QAAO,CAAC,OAAO,SAAS"}
@@ -1,15 +1,15 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __angular_core = require("@angular/core");
2
+ let _angular_core = require("@angular/core");
3
3
 
4
4
  //#region src/editor/useEditedContentRenderer.ts
5
- const EDITED_CONTENT_ACTIONS_TOKEN = new __angular_core.InjectionToken("editedContentActions");
6
- var EditedContentRendererService = @((0, __angular_core.Injectable)({ providedIn: "root" })) class {
5
+ const EDITED_CONTENT_ACTIONS_TOKEN = new _angular_core.InjectionToken("editedContentActions");
6
+ var EditedContentRendererService = @((0, _angular_core.Injectable)({ providedIn: "root" })) class {
7
7
  /**
8
8
  * Mirrors the React hook one-for-one.
9
9
  */
10
10
  useEditedContentRenderer(dictionaryKey, keyPath, fallback) {
11
- const editedContentContext = (0, __angular_core.inject)(EDITED_CONTENT_ACTIONS_TOKEN, { optional: true });
12
- return (0, __angular_core.computed)(() => {
11
+ const editedContentContext = (0, _angular_core.inject)(EDITED_CONTENT_ACTIONS_TOKEN, { optional: true });
12
+ return (0, _angular_core.computed)(() => {
13
13
  return editedContentContext?.getEditedContentValue(dictionaryKey, keyPath) ?? fallback;
14
14
  });
15
15
  }
@@ -18,7 +18,7 @@ var EditedContentRendererService = @((0, __angular_core.Injectable)({ providedIn
18
18
  * Standalone function that can be used like the Vue composable
19
19
  */
20
20
  const useEditedContentRenderer = (dictionaryKey, keyPath, fallback) => {
21
- return (0, __angular_core.inject)(EditedContentRendererService).useEditedContentRenderer(dictionaryKey, keyPath, fallback);
21
+ return (0, _angular_core.inject)(EditedContentRendererService).useEditedContentRenderer(dictionaryKey, keyPath, fallback);
22
22
  };
23
23
 
24
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useEditedContentRenderer.cjs","names":["InjectionToken"],"sources":["../../../src/editor/useEditedContentRenderer.ts"],"sourcesContent":["import {\n computed,\n Injectable,\n InjectionToken,\n inject,\n type Signal,\n} from '@angular/core';\nimport type { KeyPath } from '@intlayer/types';\n\nexport interface EditedContentActions {\n getEditedContentValue(dictionaryKey: string, keyPath: KeyPath[]): unknown;\n}\n\nexport const EDITED_CONTENT_ACTIONS_TOKEN =\n new InjectionToken<EditedContentActions | null>('editedContentActions');\n\n@Injectable({\n providedIn: 'root',\n})\nexport class EditedContentRendererService {\n /**\n * Mirrors the React hook one-for-one.\n */\n useEditedContentRenderer(\n dictionaryKey: string,\n keyPath: KeyPath[],\n fallback: unknown\n ): Signal<unknown> {\n const editedContentContext = inject(EDITED_CONTENT_ACTIONS_TOKEN, {\n optional: true,\n });\n\n return computed(() => {\n const edited = editedContentContext?.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string | undefined;\n\n return edited ?? fallback;\n });\n }\n}\n\n/**\n * Standalone function that can be used like the Vue composable\n */\nexport const useEditedContentRenderer = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n fallback: unknown\n): Signal<unknown> => {\n const service = inject(EditedContentRendererService);\n return service.useEditedContentRenderer(dictionaryKey, keyPath, fallback);\n};\n"],"mappings":";;;;AAaA,MAAa,+BACX,IAAIA,8BAA4C,uBAAuB;AAKzE,IAAa,+BAHb,iCAAY,EACV,YAAY,QACb,CAAC,EACF,MAA0C;;;;CAIxC,yBACE,eACA,SACA,UACiB;EACjB,MAAM,kDAA8B,8BAA8B,EAChE,UAAU,MACX,CAAC;AAEF,4CAAsB;AAMpB,UALe,sBAAsB,sBACnC,eACA,QACD,IAEgB;IACjB;;;;;;AAON,MAAa,4BACX,eACA,SACA,aACoB;AAEpB,mCADuB,6BAA6B,CACrC,yBAAyB,eAAe,SAAS,SAAS"}
1
+ {"version":3,"file":"useEditedContentRenderer.cjs","names":["InjectionToken"],"sources":["../../../src/editor/useEditedContentRenderer.ts"],"sourcesContent":["import {\n computed,\n Injectable,\n InjectionToken,\n inject,\n type Signal,\n} from '@angular/core';\nimport type { KeyPath } from '@intlayer/types';\n\nexport interface EditedContentActions {\n getEditedContentValue(dictionaryKey: string, keyPath: KeyPath[]): unknown;\n}\n\nexport const EDITED_CONTENT_ACTIONS_TOKEN =\n new InjectionToken<EditedContentActions | null>('editedContentActions');\n\n@Injectable({\n providedIn: 'root',\n})\nexport class EditedContentRendererService {\n /**\n * Mirrors the React hook one-for-one.\n */\n useEditedContentRenderer(\n dictionaryKey: string,\n keyPath: KeyPath[],\n fallback: unknown\n ): Signal<unknown> {\n const editedContentContext = inject(EDITED_CONTENT_ACTIONS_TOKEN, {\n optional: true,\n });\n\n return computed(() => {\n const edited = editedContentContext?.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string | undefined;\n\n return edited ?? fallback;\n });\n }\n}\n\n/**\n * Standalone function that can be used like the Vue composable\n */\nexport const useEditedContentRenderer = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n fallback: unknown\n): Signal<unknown> => {\n const service = inject(EditedContentRendererService);\n return service.useEditedContentRenderer(dictionaryKey, keyPath, fallback);\n};\n"],"mappings":";;;;AAaA,MAAa,+BACX,IAAIA,6BAA4C,uBAAuB;AAKzE,IAAa,+BAHb,gCAAY,EACV,YAAY,QACb,CAAC,EACF,MAA0C;;;;CAIxC,yBACE,eACA,SACA,UACiB;EACjB,MAAM,iDAA8B,8BAA8B,EAChE,UAAU,MACX,CAAC;AAEF,2CAAsB;AAMpB,UALe,sBAAsB,sBACnC,eACA,QACD,IAEgB;IACjB;;;;;;AAON,MAAa,4BACX,eACA,SACA,aACoB;AAEpB,kCADuB,6BAA6B,CACrC,yBAAyB,eAAe,SAAS,SAAS"}
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_editor_createSharedComposable = require('./createSharedComposable.cjs');
3
3
  const require_editor_useCrossFrameMessageListener = require('./useCrossFrameMessageListener.cjs');
4
- let __angular_core = require("@angular/core");
5
- let __intlayer_editor = require("@intlayer/editor");
4
+ let _angular_core = require("@angular/core");
5
+ let _intlayer_editor = require("@intlayer/editor");
6
6
 
7
7
  //#region src/editor/useIframeClickInterceptor.ts
8
8
  /**
@@ -10,12 +10,12 @@ let __intlayer_editor = require("@intlayer/editor");
10
10
  * This allows the parent window to know when the iframe is clicked
11
11
  */
12
12
  const useIframeClickInterceptor = require_editor_createSharedComposable.createSharedComposable(() => {
13
- const postMessage = require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(__intlayer_editor.MessageKey.INTLAYER_IFRAME_CLICKED);
13
+ const postMessage = require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(_intlayer_editor.MessageKey.INTLAYER_IFRAME_CLICKED);
14
14
  const handler = () => {
15
15
  postMessage();
16
16
  };
17
17
  try {
18
- const destroyRef = (0, __angular_core.inject)(__angular_core.DestroyRef, { optional: true });
18
+ const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true });
19
19
  if (destroyRef && typeof window !== "undefined") {
20
20
  window.addEventListener("mousedown", handler);
21
21
  destroyRef.onDestroy(() => window.removeEventListener("mousedown", handler));
@@ -30,7 +30,7 @@ const useIframeClickInterceptor = require_editor_createSharedComposable.createSh
30
30
  */
31
31
  const useIframeClickMerger = require_editor_createSharedComposable.createSharedComposable(() => {
32
32
  useIframeClickInterceptor();
33
- require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(__intlayer_editor.MessageKey.INTLAYER_IFRAME_CLICKED, __intlayer_editor.mergeIframeClick);
33
+ require_editor_useCrossFrameMessageListener.useCrossFrameMessageListener(_intlayer_editor.MessageKey.INTLAYER_IFRAME_CLICKED, _intlayer_editor.mergeIframeClick);
34
34
  });
35
35
 
36
36
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useIframeClickInterceptor.cjs","names":["createSharedComposable","useCrossFrameMessageListener","MessageKey","DestroyRef","mergeIframeClick"],"sources":["../../../src/editor/useIframeClickInterceptor.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ─────────────────────────────────────────────\n 1. \"Interceptor\" – send a postMessage when\n the editor iframe itself is clicked.\n────────────────────────────────────────────── */\n/**\n * Hook that intercepts clicks in the iframe and sends them to the parent window\n * This allows the parent window to know when the iframe is clicked\n */\nexport const useIframeClickInterceptor = createSharedComposable(() => {\n const postMessage = useCrossFrameMessageListener<undefined>(\n MessageKey.INTLAYER_IFRAME_CLICKED\n );\n\n const handler = () => {\n postMessage();\n };\n\n // Use Angular's DestroyRef for cleanup instead of Vue's lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Set up event listener immediately\n window.addEventListener('mousedown', handler);\n\n // Clean up on destroy\n destroyRef.onDestroy(() =>\n window.removeEventListener('mousedown', handler)\n );\n }\n } catch {\n console.warn(\n 'useIframeClickInterceptor called outside injection context; ' +\n 'event listener setup may not be available.'\n );\n }\n});\n\n/**\n * Hook for the parent window to listen for iframe clicks and merge them\n * This makes iframe clicks behave as if they happened in the parent window\n */\nexport const useIframeClickMerger = createSharedComposable(() => {\n useIframeClickInterceptor();\n\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n});\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,4BAA4BA,mEAA6B;CACpE,MAAM,cAAcC,yEAClBC,6BAAW,wBACZ;CAED,MAAM,gBAAgB;AACpB,eAAa;;AAIf,KAAI;EACF,MAAM,wCAAoBC,2BAAY,EAAE,UAAU,MAAM,CAAC;AAEzD,MAAI,cAAc,OAAO,WAAW,aAAa;AAE/C,UAAO,iBAAiB,aAAa,QAAQ;AAG7C,cAAW,gBACT,OAAO,oBAAoB,aAAa,QAAQ,CACjD;;SAEG;AACN,UAAQ,KACN,yGAED;;EAEH;;;;;AAMF,MAAa,uBAAuBH,mEAA6B;AAC/D,4BAA2B;AAE3B,0EACEE,6BAAW,yBACXE,mCACD;EACD"}
1
+ {"version":3,"file":"useIframeClickInterceptor.cjs","names":["createSharedComposable","useCrossFrameMessageListener","MessageKey","DestroyRef","mergeIframeClick"],"sources":["../../../src/editor/useIframeClickInterceptor.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ─────────────────────────────────────────────\n 1. \"Interceptor\" – send a postMessage when\n the editor iframe itself is clicked.\n────────────────────────────────────────────── */\n/**\n * Hook that intercepts clicks in the iframe and sends them to the parent window\n * This allows the parent window to know when the iframe is clicked\n */\nexport const useIframeClickInterceptor = createSharedComposable(() => {\n const postMessage = useCrossFrameMessageListener<undefined>(\n MessageKey.INTLAYER_IFRAME_CLICKED\n );\n\n const handler = () => {\n postMessage();\n };\n\n // Use Angular's DestroyRef for cleanup instead of Vue's lifecycle hooks\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef && typeof window !== 'undefined') {\n // Set up event listener immediately\n window.addEventListener('mousedown', handler);\n\n // Clean up on destroy\n destroyRef.onDestroy(() =>\n window.removeEventListener('mousedown', handler)\n );\n }\n } catch {\n console.warn(\n 'useIframeClickInterceptor called outside injection context; ' +\n 'event listener setup may not be available.'\n );\n }\n});\n\n/**\n * Hook for the parent window to listen for iframe clicks and merge them\n * This makes iframe clicks behave as if they happened in the parent window\n */\nexport const useIframeClickMerger = createSharedComposable(() => {\n useIframeClickInterceptor();\n\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n});\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,4BAA4BA,mEAA6B;CACpE,MAAM,cAAcC,yEAClBC,4BAAW,wBACZ;CAED,MAAM,gBAAgB;AACpB,eAAa;;AAIf,KAAI;EACF,MAAM,uCAAoBC,0BAAY,EAAE,UAAU,MAAM,CAAC;AAEzD,MAAI,cAAc,OAAO,WAAW,aAAa;AAE/C,UAAO,iBAAiB,aAAa,QAAQ;AAG7C,cAAW,gBACT,OAAO,oBAAoB,aAAa,QAAQ,CACjD;;SAEG;AACN,UAAQ,KACN,yGAED;;EAEH;;;;;AAMF,MAAa,uBAAuBH,mEAA6B;AAC/D,4BAA2B;AAE3B,0EACEE,4BAAW,yBACXE,kCACD;EACD"}