angular-intlayer 6.1.6 → 7.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/cjs/UI/ContentSelector.component.cjs +94 -121
  2. package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
  3. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/cjs/client/index.cjs +19 -35
  5. package/dist/cjs/client/installIntlayer.cjs +39 -68
  6. package/dist/cjs/client/installIntlayer.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionary.cjs +13 -36
  8. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryAsync.cjs +23 -48
  10. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +24 -52
  12. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  13. package/dist/cjs/client/useIntlayer.cjs +16 -36
  14. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  15. package/dist/cjs/client/useLoadDynamic.cjs +26 -42
  16. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  17. package/dist/cjs/client/useLocale.cjs +35 -67
  18. package/dist/cjs/client/useLocale.cjs.map +1 -1
  19. package/dist/cjs/client/useLocaleStorage.cjs +61 -0
  20. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
  21. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +41 -63
  22. package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
  23. package/dist/cjs/editor/EditedContentRenderer.component.cjs +44 -75
  24. package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
  25. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +25 -45
  26. package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
  27. package/dist/cjs/editor/communicator.cjs +55 -73
  28. package/dist/cjs/editor/communicator.cjs.map +1 -1
  29. package/dist/cjs/editor/configuration.cjs +21 -54
  30. package/dist/cjs/editor/configuration.cjs.map +1 -1
  31. package/dist/cjs/editor/createSharedComposable.cjs +46 -63
  32. package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
  33. package/dist/cjs/editor/dictionariesRecord.cjs +47 -77
  34. package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
  35. package/dist/cjs/editor/editedContent.cjs +58 -71
  36. package/dist/cjs/editor/editedContent.cjs.map +1 -1
  37. package/dist/cjs/editor/editorEnabled.cjs +45 -70
  38. package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
  39. package/dist/cjs/editor/editorLocale.cjs +21 -45
  40. package/dist/cjs/editor/editorLocale.cjs.map +1 -1
  41. package/dist/cjs/editor/focusDictionary.cjs +58 -74
  42. package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
  43. package/dist/cjs/editor/index.cjs +9 -38
  44. package/dist/cjs/editor/installIntlayerEditor.cjs +46 -64
  45. package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
  46. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +63 -72
  47. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
  48. package/dist/cjs/editor/useCrossFrameState.cjs +108 -88
  49. package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
  50. package/dist/cjs/editor/useCrossURLPathState.cjs +64 -69
  51. package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
  52. package/dist/cjs/editor/useEditedContentRenderer.cjs +25 -54
  53. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
  54. package/dist/cjs/editor/useEditor.cjs +22 -44
  55. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  56. package/dist/cjs/editor/useIframeClickInterceptor.cjs +38 -59
  57. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
  58. package/dist/cjs/getDictionary.cjs +14 -39
  59. package/dist/cjs/getDictionary.cjs.map +1 -1
  60. package/dist/cjs/getIntlayer.cjs +14 -35
  61. package/dist/cjs/getIntlayer.cjs.map +1 -1
  62. package/dist/cjs/index.cjs +32 -31
  63. package/dist/cjs/markdown/index.cjs +6 -23
  64. package/dist/cjs/markdown/installIntlayerMarkdown.cjs +33 -60
  65. package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
  66. package/dist/cjs/plugins.cjs +77 -108
  67. package/dist/cjs/plugins.cjs.map +1 -1
  68. package/dist/cjs/renderIntlayerNode.cjs +16 -56
  69. package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
  70. package/dist/cjs/webpack/index.cjs +3 -23
  71. package/dist/cjs/webpack/mergeConfig.cjs +33 -68
  72. package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
  73. package/dist/esm/UI/ContentSelector.component.mjs +89 -104
  74. package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
  75. package/dist/esm/client/index.mjs +9 -8
  76. package/dist/esm/client/installIntlayer.mjs +29 -27
  77. package/dist/esm/client/installIntlayer.mjs.map +1 -1
  78. package/dist/esm/client/useDictionary.mjs +10 -11
  79. package/dist/esm/client/useDictionary.mjs.map +1 -1
  80. package/dist/esm/client/useDictionaryAsync.mjs +18 -12
  81. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  82. package/dist/esm/client/useDictionaryDynamic.mjs +18 -15
  83. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  84. package/dist/esm/client/useIntlayer.mjs +12 -10
  85. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  86. package/dist/esm/client/useLoadDynamic.mjs +23 -17
  87. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  88. package/dist/esm/client/useLocale.mjs +30 -31
  89. package/dist/esm/client/useLocale.mjs.map +1 -1
  90. package/dist/esm/client/useLocaleStorage.mjs +54 -0
  91. package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
  92. package/dist/esm/editor/ContentSelectorWrapper.component.mjs +32 -34
  93. package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
  94. package/dist/esm/editor/EditedContentRenderer.component.mjs +38 -49
  95. package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
  96. package/dist/esm/editor/EditorSelectorRenderer.component.mjs +19 -18
  97. package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
  98. package/dist/esm/editor/communicator.mjs +48 -35
  99. package/dist/esm/editor/communicator.mjs.map +1 -1
  100. package/dist/esm/editor/configuration.mjs +15 -18
  101. package/dist/esm/editor/configuration.mjs.map +1 -1
  102. package/dist/esm/editor/createSharedComposable.mjs +42 -37
  103. package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
  104. package/dist/esm/editor/dictionariesRecord.mjs +38 -38
  105. package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
  106. package/dist/esm/editor/editedContent.mjs +49 -42
  107. package/dist/esm/editor/editedContent.mjs.map +1 -1
  108. package/dist/esm/editor/editorEnabled.mjs +37 -41
  109. package/dist/esm/editor/editorEnabled.mjs.map +1 -1
  110. package/dist/esm/editor/editorLocale.mjs +15 -18
  111. package/dist/esm/editor/editorLocale.mjs.map +1 -1
  112. package/dist/esm/editor/focusDictionary.mjs +50 -45
  113. package/dist/esm/editor/focusDictionary.mjs.map +1 -1
  114. package/dist/esm/editor/index.mjs +3 -7
  115. package/dist/esm/editor/installIntlayerEditor.mjs +40 -26
  116. package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
  117. package/dist/esm/editor/useCrossFrameMessageListener.mjs +58 -46
  118. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
  119. package/dist/esm/editor/useCrossFrameState.mjs +104 -62
  120. package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
  121. package/dist/esm/editor/useCrossURLPathState.mjs +57 -41
  122. package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
  123. package/dist/esm/editor/useEditedContentRenderer.mjs +21 -33
  124. package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
  125. package/dist/esm/editor/useEditor.mjs +16 -14
  126. package/dist/esm/editor/useEditor.mjs.map +1 -1
  127. package/dist/esm/editor/useIframeClickInterceptor.mjs +30 -30
  128. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
  129. package/dist/esm/getDictionary.mjs +12 -20
  130. package/dist/esm/getDictionary.mjs.map +1 -1
  131. package/dist/esm/getIntlayer.mjs +12 -16
  132. package/dist/esm/getIntlayer.mjs.map +1 -1
  133. package/dist/esm/index.mjs +13 -6
  134. package/dist/esm/markdown/index.mjs +3 -2
  135. package/dist/esm/markdown/installIntlayerMarkdown.mjs +27 -32
  136. package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
  137. package/dist/esm/plugins.mjs +70 -83
  138. package/dist/esm/plugins.mjs.map +1 -1
  139. package/dist/esm/renderIntlayerNode.mjs +15 -32
  140. package/dist/esm/renderIntlayerNode.mjs.map +1 -1
  141. package/dist/esm/webpack/index.mjs +3 -2
  142. package/dist/esm/webpack/mergeConfig.mjs +25 -31
  143. package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
  144. package/dist/types/UI/ContentSelector.component.d.ts +32 -30
  145. package/dist/types/UI/ContentSelector.component.d.ts.map +1 -1
  146. package/dist/types/client/index.d.ts +8 -8
  147. package/dist/types/client/installIntlayer.d.ts +15 -9
  148. package/dist/types/client/installIntlayer.d.ts.map +1 -1
  149. package/dist/types/client/useDictionary.d.ts +7 -4
  150. package/dist/types/client/useDictionary.d.ts.map +1 -1
  151. package/dist/types/client/useDictionaryAsync.d.ts +7 -3
  152. package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
  153. package/dist/types/client/useDictionaryDynamic.d.ts +9 -3
  154. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  155. package/dist/types/client/useIntlayer.d.ts +9 -7
  156. package/dist/types/client/useIntlayer.d.ts.map +1 -1
  157. package/dist/types/client/useLoadDynamic.d.ts +4 -1
  158. package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
  159. package/dist/types/client/useLocale.d.ts +17 -8
  160. package/dist/types/client/useLocale.d.ts.map +1 -1
  161. package/dist/types/client/useLocaleStorage.d.ts +49 -0
  162. package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
  163. package/dist/types/editor/ContentSelectorWrapper.component.d.ts +18 -12
  164. package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
  165. package/dist/types/editor/EditedContentRenderer.component.d.ts +20 -16
  166. package/dist/types/editor/EditedContentRenderer.component.d.ts.map +1 -1
  167. package/dist/types/editor/EditorSelectorRenderer.component.d.ts +11 -6
  168. package/dist/types/editor/EditorSelectorRenderer.component.d.ts.map +1 -1
  169. package/dist/types/editor/communicator.d.ts +14 -9
  170. package/dist/types/editor/communicator.d.ts.map +1 -1
  171. package/dist/types/editor/configuration.d.ts +4 -1
  172. package/dist/types/editor/configuration.d.ts.map +1 -1
  173. package/dist/types/editor/createSharedComposable.d.ts +6 -4
  174. package/dist/types/editor/createSharedComposable.d.ts.map +1 -1
  175. package/dist/types/editor/dictionariesRecord.d.ts +13 -10
  176. package/dist/types/editor/dictionariesRecord.d.ts.map +1 -1
  177. package/dist/types/editor/editedContent.d.ts +13 -10
  178. package/dist/types/editor/editedContent.d.ts.map +1 -1
  179. package/dist/types/editor/editorEnabled.d.ts +12 -8
  180. package/dist/types/editor/editorEnabled.d.ts.map +1 -1
  181. package/dist/types/editor/editorLocale.d.ts +6 -2
  182. package/dist/types/editor/editorLocale.d.ts.map +1 -1
  183. package/dist/types/editor/focusDictionary.d.ts +16 -13
  184. package/dist/types/editor/focusDictionary.d.ts.map +1 -1
  185. package/dist/types/editor/index.d.ts +5 -5
  186. package/dist/types/editor/installIntlayerEditor.d.ts +7 -2
  187. package/dist/types/editor/installIntlayerEditor.d.ts.map +1 -1
  188. package/dist/types/editor/useCrossFrameMessageListener.d.ts +7 -2
  189. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -1
  190. package/dist/types/editor/useCrossFrameState.d.ts +12 -8
  191. package/dist/types/editor/useCrossFrameState.d.ts.map +1 -1
  192. package/dist/types/editor/useCrossURLPathState.d.ts +9 -3
  193. package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -1
  194. package/dist/types/editor/useEditedContentRenderer.d.ts +15 -11
  195. package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -1
  196. package/dist/types/editor/useEditor.d.ts +4 -1
  197. package/dist/types/editor/useEditor.d.ts.map +1 -1
  198. package/dist/types/editor/useIframeClickInterceptor.d.ts +5 -2
  199. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -1
  200. package/dist/types/getDictionary.d.ts +8 -4
  201. package/dist/types/getDictionary.d.ts.map +1 -1
  202. package/dist/types/getIntlayer.d.ts +8 -4
  203. package/dist/types/getIntlayer.d.ts.map +1 -1
  204. package/dist/types/index.d.ts +16 -8
  205. package/dist/types/index.d.ts.map +1 -1
  206. package/dist/types/markdown/index.d.ts +2 -2
  207. package/dist/types/markdown/installIntlayerMarkdown.d.ts +15 -12
  208. package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
  209. package/dist/types/plugins.d.ts +29 -23
  210. package/dist/types/plugins.d.ts.map +1 -1
  211. package/dist/types/renderIntlayerNode.d.ts +16 -10
  212. package/dist/types/renderIntlayerNode.d.ts.map +1 -1
  213. package/dist/types/webpack/index.d.ts +2 -2
  214. package/dist/types/webpack/mergeConfig.d.ts +5 -2
  215. package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
  216. package/package.json +43 -49
  217. package/LICENSE +0 -202
  218. package/dist/cjs/client/index.cjs.map +0 -1
  219. package/dist/cjs/client/useLocaleCookie.cjs +0 -60
  220. package/dist/cjs/client/useLocaleCookie.cjs.map +0 -1
  221. package/dist/cjs/editor/index.cjs.map +0 -1
  222. package/dist/cjs/index.cjs.map +0 -1
  223. package/dist/cjs/markdown/index.cjs.map +0 -1
  224. package/dist/cjs/webpack/index.cjs.map +0 -1
  225. package/dist/esm/client/index.mjs.map +0 -1
  226. package/dist/esm/client/useLocaleCookie.mjs +0 -24
  227. package/dist/esm/client/useLocaleCookie.mjs.map +0 -1
  228. package/dist/esm/editor/index.mjs.map +0 -1
  229. package/dist/esm/index.mjs.map +0 -1
  230. package/dist/esm/markdown/index.mjs.map +0 -1
  231. package/dist/esm/webpack/index.mjs.map +0 -1
  232. package/dist/types/client/index.d.ts.map +0 -1
  233. package/dist/types/client/useLocaleCookie.d.ts +0 -17
  234. package/dist/types/client/useLocaleCookie.d.ts.map +0 -1
  235. package/dist/types/editor/index.d.ts.map +0 -1
  236. package/dist/types/markdown/index.d.ts.map +0 -1
  237. package/dist/types/webpack/index.d.ts.map +0 -1
@@ -1,18 +1,11 @@
1
1
  import { CommonModule } from "@angular/common";
2
- import {
3
- Component,
4
- computed,
5
- EventEmitter,
6
- HostListener,
7
- Input,
8
- Output,
9
- signal,
10
- ViewChild
11
- } from "@angular/core";
2
+ import { Component, EventEmitter, HostListener, Input, Output, ViewChild, computed, signal } from "@angular/core";
3
+
4
+ //#region src/UI/ContentSelector.component.ts
12
5
  const DEFAULT_PRESS_DETECT_DURATION = 250;
13
- @Component({
14
- selector: "app-content-selector",
15
- template: `
6
+ var ContentSelectorComponent = @Component({
7
+ selector: "app-content-selector",
8
+ template: `
16
9
  <span
17
10
  #containerRef
18
11
  role="button"
@@ -31,96 +24,88 @@ const DEFAULT_PRESS_DETECT_DURATION = 250;
31
24
  <ng-content></ng-content>
32
25
  </span>
33
26
  `,
34
- standalone: true,
35
- imports: [CommonModule]
36
- })
37
- class ContentSelectorComponent {
38
- constructor(cdr) {
39
- this.cdr = cdr;
40
- }
41
- @Input() onClickOutside;
42
- @Input() pressDuration;
43
- @Input() isSelecting;
44
- @Output() click = new EventEmitter();
45
- @Output() press = new EventEmitter();
46
- @ViewChild("containerRef", { static: true })
47
- containerRef;
48
- isHovered = signal(false);
49
- isSelectingState = signal(false);
50
- pressTimerRef = null;
51
- isSelectingComputed = computed(
52
- () => this.isSelecting ?? this.isSelectingState()
53
- );
54
- isStringSlot = computed(() => {
55
- return true;
56
- });
57
- ngOnInit() {
58
- this.isSelectingState.set(this.isSelecting ?? false);
59
- }
60
- ngOnDestroy() {
61
- this.clearPressTimer();
62
- }
63
- @HostListener("document:mousedown", ["$event"])
64
- onDocumentMouseDown(event) {
65
- this.handleClickOutside(event);
66
- }
67
- handleOnLongPress() {
68
- this.isSelectingState.set(true);
69
- this.press.emit();
70
- }
71
- startPressTimer() {
72
- this.pressTimerRef = setTimeout(() => {
73
- this.handleOnLongPress();
74
- }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);
75
- }
76
- clearPressTimer() {
77
- if (this.pressTimerRef) {
78
- clearTimeout(this.pressTimerRef);
79
- this.pressTimerRef = null;
80
- }
81
- }
82
- handleMouseDown() {
83
- this.clearPressTimer();
84
- this.startPressTimer();
85
- }
86
- handleMouseUp() {
87
- this.isHovered.set(false);
88
- this.clearPressTimer();
89
- }
90
- handleClickOutside(event) {
91
- if (this.containerRef?.nativeElement && !this.containerRef.nativeElement.contains(event.target)) {
92
- this.isSelectingState.set(false);
93
- this.onClickOutside?.();
94
- }
95
- }
96
- handleClick(e) {
97
- if (this.isSelectingComputed()) {
98
- e.preventDefault();
99
- e.stopPropagation();
100
- }
101
- this.click.emit(e);
102
- }
103
- handleBlur() {
104
- this.isSelectingState.set(false);
105
- }
106
- onMouseEnter() {
107
- this.isHovered.set(true);
108
- }
109
- getContainerStyle() {
110
- return {
111
- display: this.isStringSlot() ? "inline" : "inline-block",
112
- cursor: "pointer",
113
- userSelect: "none",
114
- borderRadius: "0.375rem",
115
- outlineWidth: "2px",
116
- outlineOffset: "4px",
117
- outlineStyle: "solid",
118
- outlineColor: this.isSelectingComputed() || this.isHovered() ? "inherit" : "transparent",
119
- transition: "all 100ms 50ms ease-in-out"
120
- };
121
- }
122
- }
123
- export {
124
- ContentSelectorComponent
27
+ standalone: true,
28
+ imports: [CommonModule]
29
+ }) class {
30
+ @Input() onClickOutside;
31
+ @Input() pressDuration;
32
+ @Input() isSelecting;
33
+ @Output() click = new EventEmitter();
34
+ @Output() press = new EventEmitter();
35
+ @ViewChild("containerRef", { static: true }) containerRef;
36
+ isHovered = signal(false);
37
+ isSelectingState = signal(false);
38
+ pressTimerRef = null;
39
+ isSelectingComputed = computed(() => this.isSelecting ?? this.isSelectingState());
40
+ isStringSlot = computed(() => {
41
+ return true;
42
+ });
43
+ ngOnInit() {
44
+ this.isSelectingState.set(this.isSelecting ?? false);
45
+ }
46
+ ngOnDestroy() {
47
+ this.clearPressTimer();
48
+ }
49
+ @HostListener("document:mousedown", ["$event"]) onDocumentMouseDown(event) {
50
+ this.handleClickOutside(event);
51
+ }
52
+ handleOnLongPress() {
53
+ this.isSelectingState.set(true);
54
+ this.press.emit();
55
+ }
56
+ startPressTimer() {
57
+ this.pressTimerRef = setTimeout(() => {
58
+ this.handleOnLongPress();
59
+ }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);
60
+ }
61
+ clearPressTimer() {
62
+ if (this.pressTimerRef) {
63
+ clearTimeout(this.pressTimerRef);
64
+ this.pressTimerRef = null;
65
+ }
66
+ }
67
+ handleMouseDown() {
68
+ this.clearPressTimer();
69
+ this.startPressTimer();
70
+ }
71
+ handleMouseUp() {
72
+ this.isHovered.set(false);
73
+ this.clearPressTimer();
74
+ }
75
+ handleClickOutside(event) {
76
+ if (this.containerRef?.nativeElement && !this.containerRef.nativeElement.contains(event.target)) {
77
+ this.isSelectingState.set(false);
78
+ this.onClickOutside?.();
79
+ }
80
+ }
81
+ handleClick(e) {
82
+ if (this.isSelectingComputed()) {
83
+ e.preventDefault();
84
+ e.stopPropagation();
85
+ }
86
+ this.click.emit(e);
87
+ }
88
+ handleBlur() {
89
+ this.isSelectingState.set(false);
90
+ }
91
+ onMouseEnter() {
92
+ this.isHovered.set(true);
93
+ }
94
+ getContainerStyle() {
95
+ return {
96
+ display: this.isStringSlot() ? "inline" : "inline-block",
97
+ cursor: "pointer",
98
+ userSelect: "none",
99
+ borderRadius: "0.375rem",
100
+ outlineWidth: "2px",
101
+ outlineOffset: "4px",
102
+ outlineStyle: "solid",
103
+ outlineColor: this.isSelectingComputed() || this.isHovered() ? "inherit" : "transparent",
104
+ transition: "all 100ms 50ms ease-in-out"
105
+ };
106
+ }
125
107
  };
108
+
109
+ //#endregion
110
+ export { ContentSelectorComponent };
126
111
  //# sourceMappingURL=ContentSelector.component.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n ChangeDetectorRef,\n Component,\n computed,\n ElementRef,\n EventEmitter,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n constructor(private cdr: ChangeDetectorRef) {}\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":"AAAA,SAAS,oBAAoB;AAC7B;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,gCAAgC;AAEtC,CAAC,UAAU;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBV,YAAY;AAAA,EACZ,SAAS,CAAC,YAAY;AACxB,CAAC;AACM,MAAM,yBAAsD;AAAA,EAyBjE,YAAoB,KAAwB;AAAxB;AAAA,EAAyB;AAxB7C,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AACT,GAAC,MAAM,EAAE;AAET,GAAC,OAAO,EAAE,QAAQ,IAAI,aAAyB;AAC/C,GAAC,OAAO,EAAE,QAAQ,IAAI,aAAmB;AAEzC,GAAC,UAAU,gBAAgB,EAAE,QAAQ,KAAK,CAAC;AAAA,EAC3C;AAAA,EAEQ,YAAY,OAAO,KAAK;AAAA,EACxB,mBAAmB,OAAO,KAAK;AAAA,EAC/B,gBAAsD;AAAA,EAE7C,sBAAsB;AAAA,IACrC,MAAM,KAAK,eAAe,KAAK,iBAAiB;AAAA,EAClD;AAAA,EAEiB,eAAe,SAAS,MAAM;AAG7C,WAAO;AAAA,EACT,CAAC;AAAA,EAID,WAAiB;AACf,SAAK,iBAAiB,IAAI,KAAK,eAAe,KAAK;AAAA,EACrD;AAAA,EAEA,cAAoB;AAClB,SAAK,gBAAgB;AAAA,EACvB;AAEA,GAAC,aAAa,sBAAsB,CAAC,QAAQ,CAAC;AAAA,EAC9C,oBAAoB,OAAyB;AAC3C,SAAK,mBAAmB,KAAK;AAAA,EAC/B;AAAA,EAEQ,oBAA0B;AAChC,SAAK,iBAAiB,IAAI,IAAI;AAC9B,SAAK,MAAM,KAAK;AAAA,EAClB;AAAA,EAEQ,kBAAwB;AAC9B,SAAK,gBAAgB,WAAW,MAAM;AACpC,WAAK,kBAAkB;AAAA,IACzB,GAAG,KAAK,iBAAiB,6BAA6B;AAAA,EACxD;AAAA,EAEQ,kBAAwB;AAC9B,QAAI,KAAK,eAAe;AACtB,mBAAa,KAAK,aAAa;AAC/B,WAAK,gBAAgB;AAAA,IACvB;AAAA,EACF;AAAA,EAEA,kBAAwB;AACtB,SAAK,gBAAgB;AACrB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,gBAAsB;AACpB,SAAK,UAAU,IAAI,KAAK;AACxB,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEQ,mBAAmB,OAAyB;AAClD,QACE,KAAK,cAAc,iBACnB,CAAC,KAAK,aAAa,cAAc,SAAS,MAAM,MAAc,GAC9D;AACA,WAAK,iBAAiB,IAAI,KAAK;AAC/B,WAAK,iBAAiB;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,YAAY,GAAqB;AAC/B,QAAI,KAAK,oBAAoB,GAAG;AAC9B,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AACA,SAAK,MAAM,KAAK,CAAC;AAAA,EACnB;AAAA,EAEA,aAAmB;AACjB,SAAK,iBAAiB,IAAI,KAAK;AAAA,EACjC;AAAA,EAEA,eAAqB;AACnB,SAAK,UAAU,IAAI,IAAI;AAAA,EACzB;AAAA,EAEA,oBAA4C;AAC1C,WAAO;AAAA,MACL,SAAS,KAAK,aAAa,IAAI,WAAW;AAAA,MAC1C,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,cAAc;AAAA,MACd,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cACE,KAAK,oBAAoB,KAAK,KAAK,UAAU,IACzC,YACA;AAAA,MACN,YAAY;AAAA,IACd;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"ContentSelector.component.mjs","names":[],"sources":["../../../src/UI/ContentSelector.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport {\n Component,\n computed,\n type ElementRef,\n EventEmitter,\n HostListener,\n Input,\n type OnDestroy,\n type OnInit,\n Output,\n signal,\n ViewChild,\n} from '@angular/core';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\n@Component({\n selector: 'app-content-selector',\n template: `\n <span\n #containerRef\n role=\"button\"\n tabindex=\"0\"\n (click)=\"handleClick($event)\"\n (mousedown)=\"handleMouseDown()\"\n (mouseup)=\"handleMouseUp()\"\n (mouseleave)=\"handleMouseUp()\"\n (touchstart)=\"handleMouseDown()\"\n (touchend)=\"handleMouseUp()\"\n (touchcancel)=\"handleMouseUp()\"\n (blur)=\"handleBlur()\"\n (mouseenter)=\"onMouseEnter()\"\n [ngStyle]=\"getContainerStyle()\"\n >\n <ng-content></ng-content>\n </span>\n `,\n standalone: true,\n imports: [CommonModule],\n})\nexport class ContentSelectorComponent implements OnInit, OnDestroy {\n @Input() onClickOutside?: () => void;\n @Input() pressDuration?: number;\n @Input() isSelecting?: boolean;\n\n @Output() click = new EventEmitter<MouseEvent>();\n @Output() press = new EventEmitter<void>();\n\n @ViewChild('containerRef', { static: true })\n containerRef!: ElementRef<HTMLSpanElement>;\n\n private isHovered = signal(false);\n private isSelectingState = signal(false);\n private pressTimerRef: ReturnType<typeof setTimeout> | null = null;\n\n private readonly isSelectingComputed = computed(\n () => this.isSelecting ?? this.isSelectingState()\n );\n\n private readonly isStringSlot = computed(() => {\n // In Angular, we can't easily detect if content is just text\n // This would need to be determined differently or simplified\n return true; // Simplified for now\n });\n\n ngOnInit(): void {\n this.isSelectingState.set(this.isSelecting ?? false);\n }\n\n ngOnDestroy(): void {\n this.clearPressTimer();\n }\n\n @HostListener('document:mousedown', ['$event'])\n onDocumentMouseDown(event: MouseEvent): void {\n this.handleClickOutside(event);\n }\n\n private handleOnLongPress(): void {\n this.isSelectingState.set(true);\n this.press.emit();\n }\n\n private startPressTimer(): void {\n this.pressTimerRef = setTimeout(() => {\n this.handleOnLongPress();\n }, this.pressDuration ?? DEFAULT_PRESS_DETECT_DURATION);\n }\n\n private clearPressTimer(): void {\n if (this.pressTimerRef) {\n clearTimeout(this.pressTimerRef);\n this.pressTimerRef = null;\n }\n }\n\n handleMouseDown(): void {\n this.clearPressTimer();\n this.startPressTimer();\n }\n\n handleMouseUp(): void {\n this.isHovered.set(false);\n this.clearPressTimer();\n }\n\n private handleClickOutside(event: MouseEvent): void {\n if (\n this.containerRef?.nativeElement &&\n !this.containerRef.nativeElement.contains(event.target as Node)\n ) {\n this.isSelectingState.set(false);\n this.onClickOutside?.();\n }\n }\n\n handleClick(e: MouseEvent): void {\n if (this.isSelectingComputed()) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.click.emit(e);\n }\n\n handleBlur(): void {\n this.isSelectingState.set(false);\n }\n\n onMouseEnter(): void {\n this.isHovered.set(true);\n }\n\n getContainerStyle(): { [key: string]: any } {\n return {\n display: this.isStringSlot() ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n this.isSelectingComputed() || this.isHovered()\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n };\n }\n}\n"],"mappings":";;;;AAeA,MAAM,gCAAgC;AA0BtC,IAAa,2BAxBb,CAAC,UAAU;CACT,UAAU;CACV,UAAU;;;;;;;;;;;;;;;;;;;CAmBV,YAAY;CACZ,SAAS,CAAC,aAAa;CACxB,CAAC,CACF,MAAmE;CACjE,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CACT,CAAC,OAAO,CAAC;CAET,CAAC,QAAQ,CAAC,QAAQ,IAAI,cAA0B;CAChD,CAAC,QAAQ,CAAC,QAAQ,IAAI,cAAoB;CAE1C,CAAC,UAAU,gBAAgB,EAAE,QAAQ,MAAM,CAAC,CAC5C;CAEA,AAAQ,YAAY,OAAO,MAAM;CACjC,AAAQ,mBAAmB,OAAO,MAAM;CACxC,AAAQ,gBAAsD;CAE9D,AAAiB,sBAAsB,eAC/B,KAAK,eAAe,KAAK,kBAAkB,CAClD;CAED,AAAiB,eAAe,eAAe;AAG7C,SAAO;GACP;CAEF,WAAiB;AACf,OAAK,iBAAiB,IAAI,KAAK,eAAe,MAAM;;CAGtD,cAAoB;AAClB,OAAK,iBAAiB;;CAGxB,CAAC,aAAa,sBAAsB,CAAC,SAAS,CAAC,CAC/C,oBAAoB,OAAyB;AAC3C,OAAK,mBAAmB,MAAM;;CAGhC,AAAQ,oBAA0B;AAChC,OAAK,iBAAiB,IAAI,KAAK;AAC/B,OAAK,MAAM,MAAM;;CAGnB,AAAQ,kBAAwB;AAC9B,OAAK,gBAAgB,iBAAiB;AACpC,QAAK,mBAAmB;KACvB,KAAK,iBAAiB,8BAA8B;;CAGzD,AAAQ,kBAAwB;AAC9B,MAAI,KAAK,eAAe;AACtB,gBAAa,KAAK,cAAc;AAChC,QAAK,gBAAgB;;;CAIzB,kBAAwB;AACtB,OAAK,iBAAiB;AACtB,OAAK,iBAAiB;;CAGxB,gBAAsB;AACpB,OAAK,UAAU,IAAI,MAAM;AACzB,OAAK,iBAAiB;;CAGxB,AAAQ,mBAAmB,OAAyB;AAClD,MACE,KAAK,cAAc,iBACnB,CAAC,KAAK,aAAa,cAAc,SAAS,MAAM,OAAe,EAC/D;AACA,QAAK,iBAAiB,IAAI,MAAM;AAChC,QAAK,kBAAkB;;;CAI3B,YAAY,GAAqB;AAC/B,MAAI,KAAK,qBAAqB,EAAE;AAC9B,KAAE,gBAAgB;AAClB,KAAE,iBAAiB;;AAErB,OAAK,MAAM,KAAK,EAAE;;CAGpB,aAAmB;AACjB,OAAK,iBAAiB,IAAI,MAAM;;CAGlC,eAAqB;AACnB,OAAK,UAAU,IAAI,KAAK;;CAG1B,oBAA4C;AAC1C,SAAO;GACL,SAAS,KAAK,cAAc,GAAG,WAAW;GAC1C,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,KAAK,qBAAqB,IAAI,KAAK,WAAW,GAC1C,YACA;GACN,YAAY;GACb"}
@@ -1,8 +1,9 @@
1
- export * from "./installIntlayer.mjs";
2
- export * from "./useDictionary.mjs";
3
- export * from "./useDictionaryAsync.mjs";
4
- export * from "./useDictionaryDynamic.mjs";
5
- export * from "./useIntlayer.mjs";
6
- export * from "./useLoadDynamic.mjs";
7
- export * from "./useLocale.mjs";
8
- //# sourceMappingURL=index.mjs.map
1
+ import { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer } from "./installIntlayer.mjs";
2
+ import { useDictionary } from "./useDictionary.mjs";
3
+ import { useDictionaryAsync } from "./useDictionaryAsync.mjs";
4
+ import { useLoadDynamic } from "./useLoadDynamic.mjs";
5
+ import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
6
+ import { isUpdatableNode, useIntlayer } from "./useIntlayer.mjs";
7
+ import { useLocale } from "./useLocale.mjs";
8
+
9
+ export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer, isUpdatableNode, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale };
@@ -1,35 +1,37 @@
1
1
  import { Injectable, InjectionToken, signal } from "@angular/core";
2
2
  import configuration from "@intlayer/config/built";
3
+
4
+ //#region src/client/installIntlayer.ts
3
5
  const INTLAYER_TOKEN = new InjectionToken("intlayer");
6
+ /**
7
+ * Singleton instance
8
+ */
4
9
  let instance = null;
5
- @Injectable({
6
- providedIn: "root"
7
- })
8
- class IntlayerProvider {
9
- _locale = signal(
10
- configuration.internationalization?.defaultLocale
11
- );
12
- locale = this._locale.asReadonly();
13
- setLocale = (locale) => {
14
- this._locale.set(locale);
15
- };
16
- }
17
- const createIntlayerClient = (locale) => {
18
- if (instance) return instance;
19
- instance = new IntlayerProvider();
20
- if (locale) {
21
- instance.setLocale(locale);
22
- }
23
- return instance;
10
+ var IntlayerProvider = @Injectable({ providedIn: "root" }) class {
11
+ isCookieEnabled = signal(true);
12
+ _locale = signal(configuration.internationalization?.defaultLocale);
13
+ locale = this._locale.asReadonly();
14
+ setLocale = (locale) => {
15
+ this._locale.set(locale);
16
+ };
24
17
  };
25
- const installIntlayer = (locale) => {
26
- const client = createIntlayerClient(locale);
27
- return client;
18
+ /**
19
+ * Create and return a single IntlayerProvider instance
20
+ */
21
+ const createIntlayerClient = (locale, isCookieEnabled = true) => {
22
+ if (instance) return instance;
23
+ instance = new IntlayerProvider();
24
+ if (locale) instance.setLocale(locale);
25
+ instance.isCookieEnabled.set(isCookieEnabled);
26
+ return instance;
28
27
  };
29
- export {
30
- INTLAYER_TOKEN,
31
- IntlayerProvider,
32
- createIntlayerClient,
33
- installIntlayer
28
+ /**
29
+ * Helper to install the Intlayer provider
30
+ */
31
+ const installIntlayer = (locale, isCookieEnabled = true) => {
32
+ return createIntlayerClient(locale, isCookieEnabled);
34
33
  };
34
+
35
+ //#endregion
36
+ export { INTLAYER_TOKEN, IntlayerProvider, createIntlayerClient, installIntlayer };
35
37
  //# sourceMappingURL=installIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, signal, Signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n private _locale = signal<Locales>(\n configuration.internationalization?.defaultLocale as Locales\n );\n\n readonly locale: Signal<Locales> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale as Locales);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer provider\n */\nexport const installIntlayer = (locale?: LocalesValues) => {\n const client = createIntlayerClient(locale);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":"AAAA,SAAS,YAAY,gBAAgB,cAAsB;AAC3D,OAAO,mBAAmB;AAGnB,MAAM,iBAAiB,IAAI,eAAiC,UAAU;AAK7E,IAAI,WAAoC;AAExC,CAAC,WAAW;AAAA,EACV,YAAY;AACd,CAAC;AACM,MAAM,iBAAiB;AAAA,EACpB,UAAU;AAAA,IAChB,cAAc,sBAAsB;AAAA,EACtC;AAAA,EAES,SAA0B,KAAK,QAAQ,WAAW;AAAA,EAE3D,YAAY,CAAC,WAA0B;AACrC,SAAK,QAAQ,IAAI,MAAiB;AAAA,EACpC;AACF;AAKO,MAAM,uBAAuB,CAClC,WACqB;AACrB,MAAI,SAAU,QAAO;AAErB,aAAW,IAAI,iBAAiB;AAEhC,MAAI,QAAQ;AACV,aAAS,UAAU,MAAM;AAAA,EAC3B;AAEA,SAAO;AACT;AAKO,MAAM,kBAAkB,CAAC,WAA2B;AACzD,QAAM,SAAS,qBAAqB,MAAM;AAK1C,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"installIntlayer.mjs","names":["instance: IntlayerProvider | null"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer provider\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":";;;;AAIA,MAAa,iBAAiB,IAAI,eAAiC,WAAW;;;;AAK9E,IAAIA,WAAoC;AAKxC,IAAa,mBAHb,CAAC,WAAW,EACV,YAAY,QACb,CAAC,CACF,MAA8B;CAC5B,kBAAkB,OAAO,KAAK;CAC9B,AAAQ,UAAU,OAChB,cAAc,sBAAsB,cACrC;CAED,AAAS,SAAgC,KAAK,QAAQ,YAAY;CAElE,aAAa,WAA0B;AACrC,OAAK,QAAQ,IAAI,OAAO;;;;;;AAO5B,MAAa,wBACX,QACA,kBAAkB,SACG;AACrB,KAAI,SAAU,QAAO;AAErB,YAAW,IAAI,kBAAkB;AAEjC,KAAI,OACF,UAAS,UAAU,OAAO;AAE5B,UAAS,gBAAgB,IAAI,gBAAgB;AAE7C,QAAO;;;;;AAMT,MAAa,mBACX,QACA,kBAAkB,SACf;AAMH,QALe,qBAAqB,QAAQ,gBAAgB"}
@@ -1,15 +1,14 @@
1
- import { computed, inject } from "@angular/core";
2
- import { getDictionary } from "../getDictionary.mjs";
3
1
  import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
2
+ import { getDictionary } from "../getDictionary.mjs";
3
+ import { computed, inject } from "@angular/core";
4
+
5
+ //#region src/client/useDictionary.ts
4
6
  const useDictionary = (dictionary, locale) => {
5
- const intlayer = inject(INTLAYER_TOKEN);
6
- const localeTarget = computed(() => locale ?? intlayer?.locale());
7
- const content = computed(
8
- () => getDictionary(dictionary, localeTarget())
9
- );
10
- return content();
11
- };
12
- export {
13
- useDictionary
7
+ const intlayer = inject(INTLAYER_TOKEN);
8
+ const localeTarget = computed(() => locale ?? intlayer?.locale());
9
+ return computed(() => getDictionary(dictionary, localeTarget()))();
14
10
  };
11
+
12
+ //#endregion
13
+ export { useDictionary };
15
14
  //# sourceMappingURL=useDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport { getDictionary } from '../getDictionary';\nimport { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): DeepTransformContent<T['content']> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content() as DeepTransformContent<T['content']>; // all consumers keep full reactivity\n};\n"],"mappings":"AAAA,SAAS,UAAU,cAAc;AAGjC,SAAS,qBAAqB;AAE9B,SAAS,sBAAwC;AAE1C,MAAM,gBAAgB,CAC3B,YACA,WACuC;AACvC,QAAM,WAAW,OAAyB,cAAc;AAExD,QAAM,eAAe,SAAS,MAAM,UAAU,UAAU,OAAO,CAAC;AAGhE,QAAM,UAAU;AAAA,IAAS,MACvB,cAAgC,YAAY,aAAa,CAAC;AAAA,EAC5D;AAEA,SAAO,QAAQ;AACjB;","names":[]}
1
+ {"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { Dictionary, LocalesValues } from '@intlayer/types';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): DeepTransformContent<T['content']> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content() as DeepTransformContent<T['content']>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;AAMA,MAAa,iBACX,YACA,WACuC;CACvC,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAAe,UAAU,UAAU,QAAQ,CAAC;AAOjE,QAJgB,eACd,cAAgC,YAAY,cAAc,CAAC,CAC5D,EAEe"}
@@ -1,17 +1,23 @@
1
- "use client";
2
- import { computed, inject } from "@angular/core";
3
- import configuration from "@intlayer/config/built";
1
+ 'use client';
2
+
3
+
4
4
  import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
5
5
  import { useDictionary } from "./useDictionary.mjs";
6
+ import { computed, inject } from "@angular/core";
7
+ import configuration from "@intlayer/config/built";
8
+
9
+ //#region src/client/useDictionaryAsync.ts
10
+ /**
11
+ * On the server side, Hook that transform a dictionary and return the content
12
+ *
13
+ * If the locale is not provided, it will use the locale from the client context
14
+ */
6
15
  const useDictionaryAsync = async (dictionaryPromise, locale) => {
7
- const intlayer = inject(INTLAYER_TOKEN);
8
- const localeTarget = computed(
9
- () => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale
10
- );
11
- const dictionary = await dictionaryPromise[localeTarget()]();
12
- return useDictionary(dictionary, localeTarget());
13
- };
14
- export {
15
- useDictionaryAsync
16
+ const intlayer = inject(INTLAYER_TOKEN);
17
+ const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
18
+ return useDictionary(await dictionaryPromise[localeTarget()]?.(), localeTarget());
16
19
  };
20
+
21
+ //#endregion
22
+ export { useDictionaryAsync };
17
23
  //# sourceMappingURL=useDictionaryAsync.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary, LanguageContent } from '@intlayer/core';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: LanguageContent<() => Promise<T>>,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]!();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";AAEA,SAAS,UAAU,cAAc;AACjC,OAAO,mBAAmB;AAG1B,SAAS,sBAAwC;AACjD,SAAS,qBAAqB;AAOvB,MAAM,qBAAqB,OAChC,mBACA,WACG;AACH,QAAM,WAAW,OAAyB,cAAc;AAExD,QAAM,eAAe;AAAA,IACnB,MACE,UACA,UAAU,OAAO,KACjB,eAAe,qBAAqB;AAAA,EACxC;AAEA,QAAM,aAAa,MAAM,kBAAkB,aAAa,CAAC,EAAG;AAE5D,SAAO,cAAc,YAAY,aAAa,CAAQ;AACxD;","names":[]}
1
+ {"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAa,qBAAqB,OAChC,mBACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAID,QAAO,cAFY,MAAM,kBAAkB,cAAc,KAAK,EAE7B,cAAc,CAAQ"}
@@ -1,21 +1,24 @@
1
- "use client";
2
- import { computed, inject } from "@angular/core";
3
- import configuration from "@intlayer/config/built";
1
+ 'use client';
2
+
3
+
4
4
  import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
5
5
  import { useDictionary } from "./useDictionary.mjs";
6
6
  import { useLoadDynamic } from "./useLoadDynamic.mjs";
7
+ import { computed, inject } from "@angular/core";
8
+ import configuration from "@intlayer/config/built";
9
+
10
+ //#region src/client/useDictionaryDynamic.ts
11
+ /**
12
+ * On the server side, Hook that transform a dictionary and return the content
13
+ *
14
+ * If the locale is not provided, it will use the locale from the client context
15
+ */
7
16
  const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
8
- const intlayer = inject(INTLAYER_TOKEN);
9
- const localeTarget = computed(
10
- () => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale
11
- );
12
- const dictionary = useLoadDynamic(
13
- `${String(key)}.${localeTarget()}`,
14
- dictionaryPromise[localeTarget()]()
15
- );
16
- return useDictionary(dictionary, localeTarget());
17
- };
18
- export {
19
- useDictionaryDynamic
17
+ const intlayer = inject(INTLAYER_TOKEN);
18
+ const localeTarget = computed(() => locale ?? intlayer?.locale() ?? configuration?.internationalization.defaultLocale);
19
+ return useDictionary(useLoadDynamic(`${String(key)}.${localeTarget()}`, dictionaryPromise[localeTarget()]?.()), localeTarget());
20
20
  };
21
+
22
+ //#endregion
23
+ export { useDictionaryDynamic };
21
24
  //# sourceMappingURL=useDictionaryDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type {\n Dictionary,\n DictionaryKeys,\n LanguageContent,\n} from '@intlayer/core';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: LanguageContent<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]!()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";AAEA,SAAS,UAAU,cAAc;AACjC,OAAO,mBAAmB;AAO1B,SAAS,sBAAwC;AACjD,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAOxB,MAAM,uBAAuB,CAIlC,mBACA,KACA,WACG;AACH,QAAM,WAAW,OAAyB,cAAc;AAExD,QAAM,eAAe;AAAA,IACnB,MACE,UACA,UAAU,OAAO,KACjB,eAAe,qBAAqB;AAAA,EACxC;AAEA,QAAM,aAAa;AAAA,IACjB,GAAG,OAAO,GAAG,CAAC,IAAI,aAAa,CAAC;AAAA,IAChC,kBAAkB,aAAa,CAAC,EAAG;AAAA,EACrC;AAEA,SAAO,cAAc,YAAY,aAAa,CAAQ;AACxD;","names":[]}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,WAAW,OAAyB,eAAe;CAEzD,MAAM,eAAe,eAEjB,UACA,UAAU,QAAQ,IAClB,eAAe,qBAAqB,cACvC;AAOD,QAAO,cALY,eACjB,GAAG,OAAO,IAAI,CAAC,GAAG,cAAc,IAChC,kBAAkB,cAAc,KAAK,CACtC,EAEgC,cAAc,CAAQ"}
@@ -1,15 +1,17 @@
1
- import { computed, inject } from "@angular/core";
2
- import { getIntlayer } from "../getIntlayer.mjs";
3
1
  import { INTLAYER_TOKEN } from "./installIntlayer.mjs";
2
+ import { getIntlayer } from "../getIntlayer.mjs";
3
+ import { computed, inject } from "@angular/core";
4
+
5
+ //#region src/client/useIntlayer.ts
6
+ /** guard utility - true only for objects generated by `renderIntlayerNode()` */
4
7
  const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
5
8
  const useIntlayer = (key, locale) => {
6
- const intlayer = inject(INTLAYER_TOKEN);
7
- const localeTarget = computed(() => locale ?? intlayer.locale());
8
- const content = computed(() => getIntlayer(key, localeTarget()));
9
- return content();
10
- };
11
- export {
12
- isUpdatableNode,
13
- useIntlayer
9
+ const intlayer = inject(INTLAYER_TOKEN);
10
+ /** which locale should we use right now? */
11
+ const localeTarget = computed(() => locale ?? intlayer.locale());
12
+ return computed(() => getIntlayer(key, localeTarget()))();
14
13
  };
14
+
15
+ //#endregion
16
+ export { isUpdatableNode, useIntlayer };
15
17
  //# sourceMappingURL=useIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { DictionaryKeys } from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { getIntlayer } from '../getIntlayer';\nimport { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() => getIntlayer(key, localeTarget()));\n\n return content() as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >; // all consumers keep full reactivity\n};\n"],"mappings":"AAAA,SAAS,UAAU,cAAc;AAKjC,SAAS,mBAAmB;AAE5B,SAAS,sBAAwC;AAG1C,MAAM,kBAAkB,CAC7B,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;AAE5B,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,WAAW,OAAyB,cAAc;AAGxD,QAAM,eAAe,SAAS,MAAM,UAAU,SAAS,OAAO,CAAC;AAG/D,QAAM,UAAU,SAAS,MAAM,YAAY,KAAK,aAAa,CAAC,CAAC;AAE/D,SAAO,QAAQ;AAGjB;","names":[]}
1
+ {"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): DeepTransformContent<DictionaryRegistryContent<T>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content() as DeepTransformContent<DictionaryRegistryContent<T>>; // all consumers keep full reactivity\n};\n"],"mappings":";;;;;;AAWA,MAAa,mBACX,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;AAEnC,MAAa,eACX,KACA,WACuD;CACvD,MAAM,WAAW,OAAyB,eAAe;;CAGzD,MAAM,eAAe,eAAe,UAAU,SAAS,QAAQ,CAAC;AAMhE,QAFgB,eAAe,YAAkB,KAAK,cAAc,CAAM,CAAC,EAE3D"}
@@ -1,21 +1,27 @@
1
1
  import { signal } from "@angular/core";
2
+
3
+ //#region src/client/useLoadDynamic.ts
4
+ /**
5
+ * A "synchronous" loader for a dynamically‐imported JSON (or anything).
6
+ *
7
+ * - Immediately returns a reactive signal so that Angular can properly track changes.
8
+ * - When the Promise resolves, it replaces the signal's value with the real data.
9
+ */
2
10
  const useLoadDynamic = (key, promise) => {
3
- const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
4
- const container = signal({});
5
- if (!cache.has(key)) {
6
- const p = promise.then((real) => {
7
- container.set(real);
8
- return real;
9
- });
10
- cache.set(key, p);
11
- } else {
12
- cache.get(key).then((real) => {
13
- container.set(real);
14
- });
15
- }
16
- return container();
17
- };
18
- export {
19
- useLoadDynamic
11
+ const cache = useLoadDynamic._cache || (useLoadDynamic._cache = /* @__PURE__ */ new Map());
12
+ const container = signal({});
13
+ if (!cache.has(key)) {
14
+ const p = promise.then((real) => {
15
+ container.set(real);
16
+ return real;
17
+ });
18
+ cache.set(key, p);
19
+ } else cache.get(key)?.then((real) => {
20
+ container.set(real);
21
+ });
22
+ return container();
20
23
  };
24
+
25
+ //#endregion
26
+ export { useLoadDynamic };
21
27
  //# sourceMappingURL=useLoadDynamic.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)!.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"AAAA,SAAS,cAAc;AAQhB,MAAM,iBAAiB,CAC5B,KACA,YACM;AAEN,QAAM,QAAkC,eAAuB,WAC7D,eAAuB,SAAS,oBAAI,IAAI;AAI1C,QAAM,YAAY,OAAO,CAAC,CAAM;AAEhC,MAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AAEnB,UAAM,IAAI,QAAQ,KAAK,CAAC,SAAS;AAE/B,gBAAU,IAAI,IAAI;AAClB,aAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,KAAK,CAAC;AAAA,EAClB,OAAO;AAEL,UAAM,IAAI,GAAG,EAAG,KAAK,CAAC,SAAS;AAC7B,gBAAU,IAAI,IAAI;AAAA,IACpB,CAAC;AAAA,EACH;AAGA,SAAO,UAAU;AACnB;","names":[]}
1
+ {"version":3,"file":"useLoadDynamic.mjs","names":["cache: Map<string, Promise<T>>"],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,kBACX,KACA,YACM;CAEN,MAAMA,QAAkC,eAAuB,WAC9D,AAAC,eAAuB,yBAAS,IAAI,KAAK;CAI3C,MAAM,YAAY,OAAO,EAAE,CAAM;AAEjC,KAAI,CAAC,MAAM,IAAI,IAAI,EAAE;EAEnB,MAAM,IAAI,QAAQ,MAAM,SAAS;AAE/B,aAAU,IAAI,KAAK;AACnB,UAAO;IACP;AACF,QAAM,IAAI,KAAK,EAAE;OAGjB,OAAM,IAAI,IAAI,EAAE,MAAM,SAAS;AAC7B,YAAU,IAAI,KAAK;GACnB;AAIJ,QAAO,WAAW"}