@se-studio/core-ui 0.1.0 → 0.1.1

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 (181) hide show
  1. package/README.md +218 -20
  2. package/dist/CmsRendererConfig.d.ts +38 -0
  3. package/dist/CmsRendererConfig.d.ts.map +1 -0
  4. package/dist/CmsRendererConfig.js +2 -0
  5. package/dist/CmsRendererConfig.js.map +1 -0
  6. package/dist/__tests__/setup.d.ts +2 -0
  7. package/dist/__tests__/setup.d.ts.map +1 -0
  8. package/dist/__tests__/setup.js +2 -0
  9. package/dist/__tests__/setup.js.map +1 -0
  10. package/dist/components/AnimationComponent.d.ts +13 -0
  11. package/dist/components/AnimationComponent.d.ts.map +1 -0
  12. package/dist/components/AnimationComponent.js +6 -0
  13. package/dist/components/AnimationComponent.js.map +1 -0
  14. package/dist/components/ClientMonitor.d.ts +2 -3
  15. package/dist/components/ClientMonitor.d.ts.map +1 -0
  16. package/dist/components/ClientMonitor.js +104 -102
  17. package/dist/components/ClientMonitor.js.map +1 -1
  18. package/dist/components/CmsCollection.d.ts +14 -0
  19. package/dist/components/CmsCollection.d.ts.map +1 -0
  20. package/dist/components/CmsCollection.js +26 -0
  21. package/dist/components/CmsCollection.js.map +1 -0
  22. package/dist/components/CmsComponent.d.ts +14 -0
  23. package/dist/components/CmsComponent.d.ts.map +1 -0
  24. package/dist/components/CmsComponent.js +26 -0
  25. package/dist/components/CmsComponent.js.map +1 -0
  26. package/dist/components/CmsContent.d.ts +22 -0
  27. package/dist/components/CmsContent.d.ts.map +1 -0
  28. package/dist/components/CmsContent.js +117 -0
  29. package/dist/components/CmsContent.js.map +1 -0
  30. package/dist/components/CmsDataError.d.ts +14 -0
  31. package/dist/components/CmsDataError.d.ts.map +1 -0
  32. package/dist/components/CmsDataError.js +7 -0
  33. package/dist/components/CmsDataError.js.map +1 -0
  34. package/dist/components/ImageComponent.d.ts +7 -0
  35. package/dist/components/ImageComponent.d.ts.map +1 -0
  36. package/dist/components/ImageComponent.js +14 -0
  37. package/dist/components/ImageComponent.js.map +1 -0
  38. package/dist/components/ImageKitClientVideo.d.ts +10 -0
  39. package/dist/components/ImageKitClientVideo.d.ts.map +1 -0
  40. package/dist/components/ImageKitClientVideo.js +30 -0
  41. package/dist/components/ImageKitClientVideo.js.map +1 -0
  42. package/dist/components/LocalVideo.d.ts +9 -0
  43. package/dist/components/LocalVideo.d.ts.map +1 -0
  44. package/dist/components/LocalVideo.js +31 -0
  45. package/dist/components/LocalVideo.js.map +1 -0
  46. package/dist/components/PictureComponent.d.ts +7 -0
  47. package/dist/components/PictureComponent.d.ts.map +1 -0
  48. package/dist/components/PictureComponent.js +28 -0
  49. package/dist/components/PictureComponent.js.map +1 -0
  50. package/dist/components/Preview.d.ts +2 -3
  51. package/dist/components/Preview.d.ts.map +1 -0
  52. package/dist/components/Preview.js +33 -31
  53. package/dist/components/Preview.js.map +1 -1
  54. package/dist/components/SvgComponent.d.ts +7 -0
  55. package/dist/components/SvgComponent.d.ts.map +1 -0
  56. package/dist/components/SvgComponent.js +8 -0
  57. package/dist/components/SvgComponent.js.map +1 -0
  58. package/dist/components/SvgImageComponent.d.ts +7 -0
  59. package/dist/components/SvgImageComponent.d.ts.map +1 -0
  60. package/dist/components/SvgImageComponent.js +10 -0
  61. package/dist/components/SvgImageComponent.js.map +1 -0
  62. package/dist/components/Video.d.ts +6 -0
  63. package/dist/components/Video.d.ts.map +1 -0
  64. package/dist/components/Video.js +2 -0
  65. package/dist/components/Video.js.map +1 -0
  66. package/dist/components/VideoComponent.d.ts +9 -0
  67. package/dist/components/VideoComponent.d.ts.map +1 -0
  68. package/dist/components/VideoComponent.js +11 -0
  69. package/dist/components/VideoComponent.js.map +1 -0
  70. package/dist/components/Visual.d.ts +30 -0
  71. package/dist/components/Visual.d.ts.map +1 -0
  72. package/dist/components/Visual.js +57 -0
  73. package/dist/components/Visual.js.map +1 -0
  74. package/dist/components/VisualComponent.d.ts +7 -0
  75. package/dist/components/VisualComponent.d.ts.map +1 -0
  76. package/dist/components/VisualComponent.js +19 -0
  77. package/dist/components/VisualComponent.js.map +1 -0
  78. package/dist/elements/RtfOrString.d.ts +13 -0
  79. package/dist/elements/RtfOrString.d.ts.map +1 -0
  80. package/dist/elements/RtfOrString.js +13 -0
  81. package/dist/elements/RtfOrString.js.map +1 -0
  82. package/dist/elements/UtmLink.d.ts +7 -0
  83. package/dist/elements/UtmLink.d.ts.map +1 -0
  84. package/dist/elements/UtmLink.js +24 -0
  85. package/dist/elements/UtmLink.js.map +1 -0
  86. package/dist/elements/UtmLinkOrDiv.d.ts +5 -0
  87. package/dist/elements/UtmLinkOrDiv.d.ts.map +1 -0
  88. package/dist/elements/UtmLinkOrDiv.js +9 -0
  89. package/dist/elements/UtmLinkOrDiv.js.map +1 -0
  90. package/dist/embeddable/BuildEmbed.d.ts +6 -0
  91. package/dist/embeddable/BuildEmbed.d.ts.map +1 -0
  92. package/dist/embeddable/BuildEmbed.js +15 -0
  93. package/dist/embeddable/BuildEmbed.js.map +1 -0
  94. package/dist/embeddable/EmbeddableContext.d.ts +14 -0
  95. package/dist/embeddable/EmbeddableContext.d.ts.map +1 -0
  96. package/dist/embeddable/EmbeddableContext.js +2 -0
  97. package/dist/embeddable/EmbeddableContext.js.map +1 -0
  98. package/dist/embeddable/EmbeddableMaps.d.ts +7 -0
  99. package/dist/embeddable/EmbeddableMaps.d.ts.map +1 -0
  100. package/dist/embeddable/EmbeddableMaps.js +7 -0
  101. package/dist/embeddable/EmbeddableMaps.js.map +1 -0
  102. package/dist/framework/BackgroundMedia.d.ts +11 -0
  103. package/dist/framework/BackgroundMedia.d.ts.map +1 -0
  104. package/dist/framework/BackgroundMedia.js +19 -0
  105. package/dist/framework/BackgroundMedia.js.map +1 -0
  106. package/dist/framework/ColourChange.d.ts +8 -0
  107. package/dist/framework/ColourChange.d.ts.map +1 -0
  108. package/dist/framework/ColourChange.js +13 -0
  109. package/dist/framework/ColourChange.js.map +1 -0
  110. package/dist/framework/ComponentErrorIndicator.d.ts +12 -0
  111. package/dist/framework/ComponentErrorIndicator.d.ts.map +1 -0
  112. package/dist/framework/ComponentErrorIndicator.js +26 -0
  113. package/dist/framework/ComponentErrorIndicator.js.map +1 -0
  114. package/dist/framework/componentErrors.d.ts +11 -0
  115. package/dist/framework/componentErrors.d.ts.map +1 -0
  116. package/dist/framework/componentErrors.js +21 -0
  117. package/dist/framework/componentErrors.js.map +1 -0
  118. package/dist/hooks/useClickTracking.d.ts +19 -0
  119. package/dist/hooks/useClickTracking.d.ts.map +1 -0
  120. package/dist/hooks/useClickTracking.js +19 -0
  121. package/dist/hooks/useClickTracking.js.map +1 -0
  122. package/dist/hooks/useDocumentVisible.d.ts +2 -3
  123. package/dist/hooks/useDocumentVisible.d.ts.map +1 -0
  124. package/dist/hooks/useDocumentVisible.js +15 -18
  125. package/dist/hooks/useDocumentVisible.js.map +1 -1
  126. package/dist/hooks/visibility.d.ts +14 -0
  127. package/dist/hooks/visibility.d.ts.map +1 -0
  128. package/dist/hooks/visibility.js +122 -0
  129. package/dist/hooks/visibility.js.map +1 -0
  130. package/dist/index.d.ts +40 -172
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +28 -1077
  133. package/dist/index.js.map +1 -1
  134. package/dist/rtf/rtf.d.ts +11 -0
  135. package/dist/rtf/rtf.d.ts.map +1 -0
  136. package/dist/rtf/rtf.js +60 -0
  137. package/dist/rtf/rtf.js.map +1 -0
  138. package/dist/utils/UnsupportedWarning.d.ts +7 -0
  139. package/dist/utils/UnsupportedWarning.d.ts.map +1 -0
  140. package/dist/utils/UnsupportedWarning.js +20 -0
  141. package/dist/utils/UnsupportedWarning.js.map +1 -0
  142. package/dist/utils/UnusedChecker.d.ts +12 -0
  143. package/dist/utils/UnusedChecker.d.ts.map +1 -0
  144. package/dist/utils/UnusedChecker.js +53 -0
  145. package/dist/utils/UnusedChecker.js.map +1 -0
  146. package/dist/utils/buildPageMetadata.d.ts +11 -0
  147. package/dist/utils/buildPageMetadata.d.ts.map +1 -0
  148. package/dist/utils/buildPageMetadata.js +45 -0
  149. package/dist/utils/buildPageMetadata.js.map +1 -0
  150. package/dist/utils/cn.d.ts +3 -0
  151. package/dist/utils/cn.d.ts.map +1 -0
  152. package/dist/utils/cn.js +6 -0
  153. package/dist/utils/cn.js.map +1 -0
  154. package/dist/utils/componentUtils.d.ts +26 -0
  155. package/dist/utils/componentUtils.d.ts.map +1 -0
  156. package/dist/utils/componentUtils.js +46 -0
  157. package/dist/utils/componentUtils.js.map +1 -0
  158. package/dist/utils/convertText.d.ts +2 -0
  159. package/dist/utils/convertText.d.ts.map +1 -0
  160. package/dist/utils/convertText.js +33 -0
  161. package/dist/utils/convertText.js.map +1 -0
  162. package/dist/utils/errorHandling.d.ts +10 -0
  163. package/dist/utils/errorHandling.d.ts.map +1 -0
  164. package/dist/utils/errorHandling.js +27 -0
  165. package/dist/utils/errorHandling.js.map +1 -0
  166. package/dist/utils/previewUtils.d.ts +29 -0
  167. package/dist/utils/previewUtils.d.ts.map +1 -0
  168. package/dist/utils/previewUtils.js +24 -0
  169. package/dist/utils/previewUtils.js.map +1 -0
  170. package/dist/utils/visualPositions.d.ts +3 -0
  171. package/dist/utils/visualPositions.d.ts.map +1 -0
  172. package/dist/utils/visualPositions.js +14 -0
  173. package/dist/utils/visualPositions.js.map +1 -0
  174. package/dist/utils/visualSizes.d.ts +5 -0
  175. package/dist/utils/visualSizes.d.ts.map +1 -0
  176. package/dist/utils/visualSizes.js +21 -0
  177. package/dist/utils/visualSizes.js.map +1 -0
  178. package/package.json +13 -14
  179. package/dist/client.d.ts +0 -2
  180. package/dist/client.js +0 -8
  181. package/dist/client.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,1078 +1,29 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { Suspense } from 'react';
3
- import { isSvgData, isSvgImage, processSizes } from '@se-studio/core-data-types';
4
- import Image from 'next/image';
5
- import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
6
- import { BLOCKS, INLINES } from '@contentful/rich-text-types';
7
-
8
- // src/CmsRendererConfig.ts
9
- function createCmsRendererConfig(config) {
10
- return config;
11
- }
12
- function mergeCmsRendererConfig(base, overrides) {
13
- return {
14
- componentMap: overrides.componentMap ?? base.componentMap,
15
- collectionMap: overrides.collectionMap ?? base.collectionMap,
16
- externalComponentMap: overrides.externalComponentMap ?? base.externalComponentMap,
17
- visualComponentRenderer: overrides.visualComponentRenderer ?? base.visualComponentRenderer,
18
- internalLinkRenderer: overrides.internalLinkRenderer ?? base.internalLinkRenderer,
19
- showUnknownTypeErrors: overrides.showUnknownTypeErrors ?? base.showUnknownTypeErrors,
20
- showRenderErrors: overrides.showRenderErrors ?? base.showRenderErrors,
21
- defaultComponentRenderer: overrides.defaultComponentRenderer ?? base.defaultComponentRenderer,
22
- defaultCollectionRenderer: overrides.defaultCollectionRenderer ?? base.defaultCollectionRenderer,
23
- basicLinkRenderer: overrides.basicLinkRenderer ?? base.basicLinkRenderer,
24
- embeddedContentRenderer: overrides.embeddedContentRenderer ?? base.embeddedContentRenderer
25
- };
26
- }
27
- var CollectionTypeError = ({
28
- information,
29
- availableTypes,
30
- showInProduction = false
31
- }) => {
32
- if (!showInProduction && typeof process !== "undefined" && process.env?.NODE_ENV === "production")
33
- return null;
34
- return /* @__PURE__ */ jsxs(
35
- "div",
36
- {
37
- style: {
38
- border: "2px solid orange",
39
- background: "#fff3cd",
40
- padding: "1rem",
41
- margin: "1rem",
42
- borderRadius: "4px"
43
- },
44
- children: [
45
- /* @__PURE__ */ jsx("h3", { style: { color: "#856404", marginBottom: "0.5rem" }, children: "Unknown Collection Type" }),
46
- /* @__PURE__ */ jsxs("div", { style: { fontSize: "0.875rem" }, children: [
47
- /* @__PURE__ */ jsxs("p", { children: [
48
- /* @__PURE__ */ jsx("strong", { children: "Collection Type:" }),
49
- " ",
50
- String(information.collectionType)
51
- ] }),
52
- /* @__PURE__ */ jsxs("p", { children: [
53
- /* @__PURE__ */ jsx("strong", { children: "Collection ID:" }),
54
- " ",
55
- information.id
56
- ] }),
57
- /* @__PURE__ */ jsxs("p", { children: [
58
- /* @__PURE__ */ jsx("strong", { children: "Available Types:" }),
59
- " ",
60
- availableTypes.join(", ")
61
- ] }),
62
- /* @__PURE__ */ jsx("p", { style: { color: "#856404", marginTop: "0.5rem" }, children: "This collection type is not registered in CollectionMap. Using Generic fallback." })
63
- ] })
64
- ]
65
- }
66
- );
67
- };
68
- function CmsCollection({
69
- information,
70
- contentContext,
71
- rendererConfig
72
- }) {
73
- const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
74
- const isDebugTiming = typeof process !== "undefined" && process.env?.DEBUG_TIMING === "true";
75
- const shouldTrack = isDevelopment || isDebugTiming;
76
- const startTime = shouldTrack ? performance.now() : 0;
77
- const startMemory = shouldTrack && typeof process !== "undefined" && process.memoryUsage ? process.memoryUsage() : null;
78
- const {
79
- collectionMap,
80
- showUnknownTypeErrors,
81
- defaultCollectionRenderer: DefaultRenderer
82
- } = rendererConfig;
83
- const Element = collectionMap[information.collectionType];
84
- if (Element) {
85
- const result2 = /* @__PURE__ */ jsx(
86
- Element,
87
- {
88
- information,
89
- contentContext,
90
- rendererConfig
91
- }
92
- );
93
- if (shouldTrack && startMemory) {
94
- const totalDuration = performance.now() - startTime;
95
- if (totalDuration > 10) {
96
- const endMemory = process.memoryUsage();
97
- const heapDelta = (endMemory.heapUsed - startMemory.heapUsed) / 1024 / 1024;
98
- const rssDelta = (endMemory.rss - startMemory.rss) / 1024 / 1024;
99
- let output = `[CmsCollection] ${String(information.collectionType)}: ${totalDuration.toFixed(2)}ms`;
100
- if (Math.abs(heapDelta) > 0.01 || Math.abs(rssDelta) > 0.01) {
101
- output += ` [heap: ${heapDelta >= 0 ? "+" : ""}${heapDelta.toFixed(2)}MB`;
102
- output += `, rss: ${rssDelta >= 0 ? "+" : ""}${rssDelta.toFixed(2)}MB]`;
103
- }
104
- console.log(output);
105
- }
106
- } else if (shouldTrack) {
107
- const totalDuration = performance.now() - startTime;
108
- if (totalDuration > 10) {
109
- console.log(
110
- `[CmsCollection] ${String(information.collectionType)}: ${totalDuration.toFixed(2)}ms`
111
- );
112
- }
113
- }
114
- return result2;
115
- }
116
- console.log(
117
- `Unknown collection type: ${String(information.collectionType)} (ID: ${information.id}). Available types:`,
118
- Object.keys(collectionMap).join(",")
119
- );
120
- const shouldShowError = showUnknownTypeErrors || typeof process !== "undefined" && process.env?.NODE_ENV === "development";
121
- const result = /* @__PURE__ */ jsxs(Fragment, { children: [
122
- shouldShowError && /* @__PURE__ */ jsx(
123
- CollectionTypeError,
124
- {
125
- information,
126
- availableTypes: Object.keys(collectionMap),
127
- showInProduction: showUnknownTypeErrors
128
- }
129
- ),
130
- DefaultRenderer && /* @__PURE__ */ jsx(
131
- DefaultRenderer,
132
- {
133
- information,
134
- contentContext,
135
- rendererConfig
136
- }
137
- )
138
- ] });
139
- if (shouldTrack && startMemory) {
140
- const totalDuration = performance.now() - startTime;
141
- const endMemory = process.memoryUsage();
142
- const heapDelta = (endMemory.heapUsed - startMemory.heapUsed) / 1024 / 1024;
143
- const rssDelta = (endMemory.rss - startMemory.rss) / 1024 / 1024;
144
- let output = `[CmsCollection] ${String(information.collectionType)} (unknown): ${totalDuration.toFixed(2)}ms`;
145
- if (Math.abs(heapDelta) > 0.01 || Math.abs(rssDelta) > 0.01) {
146
- output += ` [heap: ${heapDelta >= 0 ? "+" : ""}${heapDelta.toFixed(2)}MB`;
147
- output += `, rss: ${rssDelta >= 0 ? "+" : ""}${rssDelta.toFixed(2)}MB]`;
148
- }
149
- console.log(output);
150
- } else if (shouldTrack) {
151
- const totalDuration = performance.now() - startTime;
152
- console.log(
153
- `[CmsCollection] ${String(information.collectionType)} (unknown): ${totalDuration.toFixed(2)}ms`
154
- );
155
- }
156
- return result;
157
- }
158
- var ComponentTypeError = ({
159
- information,
160
- availableTypes,
161
- showInProduction = false
162
- }) => {
163
- if (!showInProduction && typeof process !== "undefined" && process.env?.NODE_ENV === "production")
164
- return null;
165
- return /* @__PURE__ */ jsxs(
166
- "div",
167
- {
168
- style: {
169
- border: "2px solid orange",
170
- background: "#fff3cd",
171
- padding: "1rem",
172
- margin: "1rem",
173
- borderRadius: "4px"
174
- },
175
- children: [
176
- /* @__PURE__ */ jsx("h3", { style: { color: "#856404", marginBottom: "0.5rem" }, children: "Unknown Component Type" }),
177
- /* @__PURE__ */ jsxs("div", { style: { fontSize: "0.875rem" }, children: [
178
- /* @__PURE__ */ jsxs("p", { children: [
179
- /* @__PURE__ */ jsx("strong", { children: "Component Type:" }),
180
- " ",
181
- String(information.componentType)
182
- ] }),
183
- /* @__PURE__ */ jsxs("p", { children: [
184
- /* @__PURE__ */ jsx("strong", { children: "Component ID:" }),
185
- " ",
186
- information.id
187
- ] }),
188
- /* @__PURE__ */ jsxs("p", { children: [
189
- /* @__PURE__ */ jsx("strong", { children: "Available Types:" }),
190
- " ",
191
- availableTypes.join(", ")
192
- ] }),
193
- /* @__PURE__ */ jsx("p", { style: { color: "#856404", marginTop: "0.5rem" }, children: "This component type is not registered in ComponentMap. Using Generic fallback." })
194
- ] })
195
- ]
196
- }
197
- );
198
- };
199
- function CmsComponent({
200
- information,
201
- contentContext,
202
- rendererConfig
203
- }) {
204
- const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
205
- const isDebugTiming = typeof process !== "undefined" && process.env?.DEBUG_TIMING === "true";
206
- const shouldTrack = isDevelopment || isDebugTiming;
207
- const startTime = shouldTrack ? performance.now() : 0;
208
- const startMemory = shouldTrack && typeof process !== "undefined" && process.memoryUsage ? process.memoryUsage() : null;
209
- const {
210
- componentMap,
211
- showUnknownTypeErrors,
212
- defaultComponentRenderer: DefaultRenderer
213
- } = rendererConfig;
214
- const Element = componentMap[information.componentType];
215
- if (Element) {
216
- const result2 = /* @__PURE__ */ jsx(
217
- Element,
218
- {
219
- information,
220
- contentContext,
221
- rendererConfig
222
- }
223
- );
224
- if (shouldTrack && startMemory) {
225
- const totalDuration = performance.now() - startTime;
226
- if (totalDuration > 10) {
227
- const endMemory = process.memoryUsage();
228
- const heapDelta = (endMemory.heapUsed - startMemory.heapUsed) / 1024 / 1024;
229
- const rssDelta = (endMemory.rss - startMemory.rss) / 1024 / 1024;
230
- let output = `[CmsComponent] ${String(information.componentType)}: ${totalDuration.toFixed(2)}ms`;
231
- if (Math.abs(heapDelta) > 0.01 || Math.abs(rssDelta) > 0.01) {
232
- output += ` [heap: ${heapDelta >= 0 ? "+" : ""}${heapDelta.toFixed(2)}MB`;
233
- output += `, rss: ${rssDelta >= 0 ? "+" : ""}${rssDelta.toFixed(2)}MB]`;
234
- }
235
- console.log(output);
236
- }
237
- } else if (shouldTrack) {
238
- const totalDuration = performance.now() - startTime;
239
- if (totalDuration > 10) {
240
- console.log(
241
- `[CmsComponent] ${String(information.componentType)}: ${totalDuration.toFixed(2)}ms`
242
- );
243
- }
244
- }
245
- return result2;
246
- }
247
- console.log(
248
- `Unknown component type: ${String(information.componentType)} (ID: ${information.id}). Available types:`,
249
- Object.keys(componentMap).join(",")
250
- );
251
- const shouldShowError = showUnknownTypeErrors || typeof process !== "undefined" && process.env?.NODE_ENV === "development";
252
- const result = /* @__PURE__ */ jsxs(Fragment, { children: [
253
- shouldShowError && /* @__PURE__ */ jsx(
254
- ComponentTypeError,
255
- {
256
- information,
257
- availableTypes: Object.keys(componentMap),
258
- showInProduction: showUnknownTypeErrors
259
- }
260
- ),
261
- DefaultRenderer && /* @__PURE__ */ jsx(
262
- DefaultRenderer,
263
- {
264
- information,
265
- contentContext,
266
- rendererConfig
267
- }
268
- )
269
- ] });
270
- if (shouldTrack && startMemory) {
271
- const totalDuration = performance.now() - startTime;
272
- const endMemory = process.memoryUsage();
273
- const heapDelta = (endMemory.heapUsed - startMemory.heapUsed) / 1024 / 1024;
274
- const rssDelta = (endMemory.rss - startMemory.rss) / 1024 / 1024;
275
- let output = `[CmsComponent] ${String(information.componentType)} (unknown): ${totalDuration.toFixed(2)}ms`;
276
- if (Math.abs(heapDelta) > 0.01 || Math.abs(rssDelta) > 0.01) {
277
- output += ` [heap: ${heapDelta >= 0 ? "+" : ""}${heapDelta.toFixed(2)}MB`;
278
- output += `, rss: ${rssDelta >= 0 ? "+" : ""}${rssDelta.toFixed(2)}MB]`;
279
- }
280
- console.log(output);
281
- } else if (shouldTrack) {
282
- const totalDuration = performance.now() - startTime;
283
- console.log(
284
- `[CmsComponent] ${String(information.componentType)} (unknown): ${totalDuration.toFixed(2)}ms`
285
- );
286
- }
287
- return result;
288
- }
289
- function createContentContext(pageContext, components, currentIndex) {
290
- const current = components[currentIndex];
291
- if (!current) {
292
- throw new Error(`Invalid component index: ${currentIndex}`);
293
- }
294
- const previousContent = currentIndex === 0 ? void 0 : components[currentIndex - 1];
295
- const nextContent = currentIndex === components.length - 1 ? void 0 : components[currentIndex + 1];
296
- return { pageContext, previousContent, current, nextContent };
297
- }
298
- var ContentError = ({
299
- error,
300
- content,
301
- showInProduction = false
302
- }) => {
303
- if (!showInProduction && typeof process !== "undefined" && process.env?.NODE_ENV === "production")
304
- return null;
305
- return /* @__PURE__ */ jsxs(
306
- "div",
307
- {
308
- style: {
309
- margin: "1rem",
310
- borderRadius: "4px",
311
- border: "2px solid red",
312
- background: "#fee",
313
- padding: "1rem"
314
- },
315
- children: [
316
- /* @__PURE__ */ jsx("h3", { style: { marginBottom: "0.5rem", fontSize: "1.125rem", color: "red" }, children: "Content Render Error" }),
317
- /* @__PURE__ */ jsxs("div", { style: { fontSize: "0.875rem" }, children: [
318
- /* @__PURE__ */ jsxs("p", { children: [
319
- /* @__PURE__ */ jsx("strong", { children: "Content Type:" }),
320
- " ",
321
- content.type
322
- ] }),
323
- /* @__PURE__ */ jsxs("p", { children: [
324
- /* @__PURE__ */ jsx("strong", { children: "Content ID:" }),
325
- " ",
326
- content.id
327
- ] }),
328
- /* @__PURE__ */ jsxs("div", { style: { marginTop: "0.75rem" }, children: [
329
- /* @__PURE__ */ jsx("p", { style: { color: "red", fontWeight: "600" }, children: "Error:" }),
330
- /* @__PURE__ */ jsx(
331
- "pre",
332
- {
333
- style: {
334
- overflowX: "auto",
335
- borderRadius: "4px",
336
- border: "1px solid #fcc",
337
- background: "white",
338
- padding: "0.5rem",
339
- fontSize: "0.75rem"
340
- },
341
- children: error.message
342
- }
343
- )
344
- ] })
345
- ] })
346
- ]
347
- }
348
- );
349
- };
350
- var ContentLoadingFallback = ({ content }) => {
351
- const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
352
- if (!isDevelopment) {
353
- return null;
354
- }
355
- return /* @__PURE__ */ jsx(
356
- "div",
357
- {
358
- style: {
359
- margin: "1rem",
360
- borderRadius: "4px",
361
- border: "2px solid #ccc",
362
- background: "#f9f9f9",
363
- padding: "1rem",
364
- minHeight: "2rem",
365
- display: "flex",
366
- alignItems: "center"
367
- },
368
- children: /* @__PURE__ */ jsxs("span", { style: { color: "#666", fontSize: "0.875rem" }, children: [
369
- "Loading ",
370
- content.type,
371
- " (",
372
- content.id,
373
- ")..."
374
- ] })
375
- }
376
- );
377
- };
378
- var SingleContent = ({
379
- context,
380
- rendererConfig
381
- }) => {
382
- const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
383
- const startTime = isDevelopment ? performance.now() : 0;
384
- try {
385
- const { current } = context;
386
- let result;
387
- switch (current.type) {
388
- case "Component":
389
- result = /* @__PURE__ */ jsx(
390
- CmsComponent,
391
- {
392
- information: current,
393
- contentContext: context,
394
- rendererConfig
395
- }
396
- );
397
- break;
398
- case "Collection":
399
- result = /* @__PURE__ */ jsx(
400
- CmsCollection,
401
- {
402
- information: current,
403
- contentContext: context,
404
- rendererConfig
405
- }
406
- );
407
- break;
408
- case "External component": {
409
- const externalComp = current;
410
- const ExternalRenderer = rendererConfig.externalComponentMap?.[externalComp.externalType];
411
- if (ExternalRenderer) {
412
- result = /* @__PURE__ */ jsx(ExternalRenderer, { information: externalComp, contentContext: context });
413
- } else {
414
- console.warn(
415
- `No renderer found for external component type: ${String(externalComp.externalType)}`
416
- );
417
- result = rendererConfig.showUnknownTypeErrors ? /* @__PURE__ */ jsx("div", { children: "External component renderer not implemented" }) : null;
418
- }
419
- break;
420
- }
421
- case "Visual":
422
- if (rendererConfig.visualComponentRenderer) {
423
- result = rendererConfig.visualComponentRenderer({
424
- information: current,
425
- contentContext: context
426
- });
427
- } else {
428
- console.warn("No Visual renderer provided");
429
- result = rendererConfig.showUnknownTypeErrors ? /* @__PURE__ */ jsx("div", { children: "Visual renderer not implemented" }) : null;
430
- }
431
- break;
432
- case "Internal link":
433
- if (rendererConfig.internalLinkRenderer) {
434
- result = rendererConfig.internalLinkRenderer({
435
- information: current,
436
- contentContext: context
437
- });
438
- } else {
439
- console.warn("No Internal link renderer provided");
440
- result = rendererConfig.showUnknownTypeErrors ? /* @__PURE__ */ jsx("div", { children: "Internal link renderer not implemented" }) : null;
441
- }
442
- break;
443
- default: {
444
- const unknownContent = current;
445
- const error = new Error(
446
- `Unknown content type: ${unknownContent.type} (ID: ${unknownContent.id})`
447
- );
448
- console.error(error);
449
- if (rendererConfig.showRenderErrors || typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
450
- result = /* @__PURE__ */ jsx(
451
- ContentError,
452
- {
453
- error,
454
- content: unknownContent,
455
- showInProduction: rendererConfig.showRenderErrors
456
- }
457
- );
458
- } else {
459
- result = null;
460
- }
461
- break;
462
- }
463
- }
464
- if (isDevelopment) {
465
- const duration = performance.now() - startTime;
466
- if (duration > 10) {
467
- const contentType = current.type === "Component" ? current.componentType : current.type === "Collection" ? current.collectionType : current.type;
468
- console.log(`[SingleContent] ${contentType} (${current.id}): ${duration.toFixed(2)}ms`);
469
- }
470
- }
471
- return result;
472
- } catch (error) {
473
- console.error("Error rendering content:", error);
474
- if (rendererConfig.showRenderErrors || typeof process !== "undefined" && process.env?.NODE_ENV === "development") {
475
- return /* @__PURE__ */ jsx(
476
- ContentError,
477
- {
478
- error,
479
- content: context.current,
480
- showInProduction: rendererConfig.showRenderErrors
481
- }
482
- );
483
- }
484
- return null;
485
- }
486
- };
487
- function CmsContent({
488
- pageContext,
489
- contents,
490
- rendererConfig
491
- }) {
492
- const isDevelopment = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
493
- const isDebugTiming = typeof process !== "undefined" && process.env?.DEBUG_TIMING === "true";
494
- const shouldTrack = isDevelopment || isDebugTiming;
495
- const startTime = shouldTrack ? performance.now() : 0;
496
- const startMemory = shouldTrack && typeof process !== "undefined" && process.memoryUsage ? process.memoryUsage() : null;
497
- if (!contents || contents.length === 0) {
498
- return null;
499
- }
500
- if (shouldTrack) {
501
- console.log(`[CmsContent] Rendering ${contents.length} content items`);
502
- }
503
- const result = /* @__PURE__ */ jsx(Fragment, { children: contents.map((content, index) => {
504
- const context = createContentContext(pageContext, contents, index);
505
- return /* @__PURE__ */ jsx(
506
- Suspense,
507
- {
508
- fallback: /* @__PURE__ */ jsx(ContentLoadingFallback, { content }),
509
- children: /* @__PURE__ */ jsx(SingleContent, { context, rendererConfig })
510
- },
511
- `${content.id}-${index}`
512
- );
513
- }) });
514
- if (shouldTrack && startMemory) {
515
- const duration = performance.now() - startTime;
516
- const endMemory = process.memoryUsage();
517
- const heapDelta = (endMemory.heapUsed - startMemory.heapUsed) / 1024 / 1024;
518
- const rssDelta = (endMemory.rss - startMemory.rss) / 1024 / 1024;
519
- let output = `[CmsContent] Rendered ${contents.length} items in ${duration.toFixed(2)}ms`;
520
- if (Math.abs(heapDelta) > 0.01 || Math.abs(rssDelta) > 0.01) {
521
- output += ` [heap: ${heapDelta >= 0 ? "+" : ""}${heapDelta.toFixed(2)}MB`;
522
- output += `, rss: ${rssDelta >= 0 ? "+" : ""}${rssDelta.toFixed(2)}MB]`;
523
- }
524
- console.log(output);
525
- } else if (shouldTrack) {
526
- const duration = performance.now() - startTime;
527
- console.log(`[CmsContent] Rendered ${contents.length} items in ${duration.toFixed(2)}ms`);
528
- }
529
- return result;
530
- }
531
-
532
- // src/components/Visual.ts
533
- function calculateVertical(position) {
534
- switch (position) {
535
- case "Bottom":
536
- return "bottom";
537
- case "Top":
538
- return "top";
539
- default:
540
- return "center";
541
- }
542
- }
543
- function calculateHorizontal(position) {
544
- switch (position) {
545
- case "Left":
546
- return "left";
547
- case "Right":
548
- return "right";
549
- default:
550
- return "center";
551
- }
552
- }
553
- function calculateCropDetails(details) {
554
- const { verticalCropPosition, horizontalCropPosition, dontCrop } = details;
555
- if (dontCrop) {
556
- return { objectFit: "contain" };
557
- }
558
- return {
559
- objectFit: "cover",
560
- objectPosition: `${calculateHorizontal(
561
- horizontalCropPosition
562
- )} ${calculateVertical(verticalCropPosition)}`
563
- };
564
- }
565
- function calculateImagePriority(index) {
566
- if (index === 0) {
567
- return { priority: true, fetchPriority: "high" };
568
- }
569
- return void 0;
570
- }
571
- function calculateRealWidthPercent(visual, baseWidth) {
572
- const widthPercent = visual?.image?.widthPercent ?? visual?.animation?.widthPercent ?? visual?.video?.widthPercent;
573
- if (!widthPercent) {
574
- if (baseWidth) {
575
- return baseWidth;
576
- }
577
- return void 0;
578
- }
579
- if (baseWidth) {
580
- return widthPercent / 100 * (baseWidth / 100) * 100;
581
- }
582
- return widthPercent;
583
- }
584
- function calculateImageWidthStyleVariable(visual, baseWidth) {
585
- const widthPercent = calculateRealWidthPercent(visual, baseWidth);
586
- if (widthPercent === void 0) {
587
- return void 0;
588
- }
589
- return { "--image-width": `${widthPercent}%` };
590
- }
591
- var UnsupportedWarning = ({ children, className, style, showWarnings = true }) => {
592
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "production" || !showWarnings) {
593
- return null;
594
- }
595
- const defaultStyle = {
596
- backgroundColor: "#fff3cd",
597
- border: "2px solid #ff6b6b",
598
- borderRadius: "4px",
599
- padding: "0.75rem 1rem",
600
- margin: "0.5rem 0",
601
- color: "#721c24",
602
- fontWeight: "bold",
603
- fontSize: "0.9rem",
604
- display: "inline-block"
605
- };
606
- const mergedStyle = { ...defaultStyle, ...style };
607
- return /* @__PURE__ */ jsx("div", { className, style: mergedStyle, children });
608
- };
609
- function Animation({
610
- className,
611
- style
612
- }) {
613
- return /* @__PURE__ */ jsx("div", { className, style, children: "Animation Component" });
614
- }
615
- var AnimationComponent_default = Animation;
616
- function calculateSizes(visualSizes) {
617
- if (!visualSizes) {
618
- return "100vw";
619
- }
620
- const result = processSizes(visualSizes)?.breakpoints?.sort((a, b) => a.maxWidth - b.maxWidth).map(({ maxWidth, size }) => `(max-width: ${maxWidth}px) ${size}`) ?? [];
621
- if (visualSizes.defaultSize) {
622
- result.push(visualSizes.defaultSize);
623
- } else if (visualSizes.defaultPixels) {
624
- result.push(`${visualSizes.defaultPixels}px`);
625
- } else {
626
- result.push("100vw");
627
- }
628
- return result.join(",");
629
- }
630
- function PictureComponent({
631
- image,
632
- style,
633
- visualSizes,
634
- ...props
635
- }) {
636
- const cropProperties = calculateCropDetails(image);
637
- return /* @__PURE__ */ jsx(
638
- Image,
639
- {
640
- src: image.src,
641
- width: image.width,
642
- height: image.height,
643
- style: { ...style, ...cropProperties },
644
- alt: image.description ?? image.name,
645
- sizes: calculateSizes(visualSizes),
646
- ...props
647
- }
648
- );
649
- }
650
- var PictureComponent_default = PictureComponent;
651
- function SvgComponent({
652
- image,
653
- className,
654
- style,
655
- ...other
656
- }) {
657
- const cropProperties = calculateCropDetails(image);
658
- return /* @__PURE__ */ jsx(
659
- "div",
660
- {
661
- className,
662
- style: { ...style, ...cropProperties },
663
- dangerouslySetInnerHTML: { __html: image.data },
664
- ...other
665
- }
666
- );
667
- }
668
- var SvgComponent_default = SvgComponent;
669
- function SvgImageComponent({
670
- image,
671
- loading,
672
- priority,
673
- className,
674
- style
675
- }) {
676
- const { svgSrc, name, width, height, description } = image;
677
- const cropProperties = calculateCropDetails(image);
678
- return /* @__PURE__ */ jsx(
679
- Image,
680
- {
681
- src: svgSrc,
682
- alt: description ?? name,
683
- width,
684
- height,
685
- style: { ...style, ...cropProperties },
686
- loading,
687
- className,
688
- unoptimized: true,
689
- priority
690
- }
691
- );
692
- }
693
- var SvgImageComponent_default = SvgImageComponent;
694
- function ImageComponent({
695
- image,
696
- visualSizes,
697
- priority,
698
- ...props
699
- }) {
700
- if (isSvgData(image)) return /* @__PURE__ */ jsx(SvgComponent_default, { image, ...props });
701
- if (isSvgImage(image)) return /* @__PURE__ */ jsx(SvgImageComponent_default, { image, priority, ...props });
702
- return /* @__PURE__ */ jsx(PictureComponent_default, { image, visualSizes, priority, ...props });
703
- }
704
- var ImageComponent_default = ImageComponent;
705
- function VideoComponent({
706
- className,
707
- style
708
- }) {
709
- return /* @__PURE__ */ jsx("div", { className, style, children: "Video Component" });
710
- }
711
- var VideoComponent_default = VideoComponent;
712
- var Visual = ({
713
- visual,
714
- muted,
715
- controls,
716
- autoPlay,
717
- visualSizes,
718
- fullPlayer,
719
- loop,
720
- loopDelay,
721
- analyticsContext,
722
- componentLabel,
723
- ...props
724
- }) => {
725
- const { animation, image, video } = visual;
726
- if (animation) {
727
- return /* @__PURE__ */ jsx(
728
- AnimationComponent_default,
729
- {
730
- animation,
731
- autoPlay,
732
- loop,
733
- loopDelay,
734
- ...props
735
- }
736
- );
737
- }
738
- if (video) {
739
- return /* @__PURE__ */ jsx(
740
- VideoComponent_default,
741
- {
742
- video,
743
- autoPlay,
744
- muted,
745
- controls,
746
- visualSizes,
747
- fullPlayer,
748
- loop,
749
- analyticsContext,
750
- componentLabel,
751
- ...props
752
- }
753
- );
754
- }
755
- if (image) {
756
- return /* @__PURE__ */ jsx(ImageComponent_default, { image, visualSizes, ...props });
757
- }
758
- return /* @__PURE__ */ jsx(UnsupportedWarning, { className: props.className, style: props.style, children: "Not supporting non images yet" });
759
- };
760
-
761
- // src/utils/componentUtils.ts
762
- var developmentMode = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
763
- function extractPropsFromComponentConfig(config, component, context) {
764
- const props = {};
765
- for (const key of config.componentProps) {
766
- if (key in component) {
767
- props[key] = component[key];
768
- }
769
- }
770
- if ("contextProps" in config && config.contextProps && context) {
771
- for (const key of config.contextProps) {
772
- if (key in context) {
773
- props[key] = context[key];
774
- }
775
- }
776
- }
777
- if ("additionalProps" in config && config.additionalProps) {
778
- Object.assign(props, config.additionalProps);
779
- }
780
- if (developmentMode) {
781
- const availableComponentKeys = [
782
- "id",
783
- "index",
784
- "componentType",
785
- "cmsLabel",
786
- "backgroundColour",
787
- "textColour",
788
- "heading",
789
- "preHeading",
790
- "postHeading",
791
- "body",
792
- "visual",
793
- "icon",
794
- "links",
795
- "additionalCopy",
796
- "anchor",
797
- "name",
798
- "parentId",
799
- "parentFieldId",
800
- "backgroundVisual",
801
- "backgroundOverlayOpacity",
802
- "isFirst",
803
- "isLast",
804
- "indexOfType",
805
- "type"
806
- ];
807
- const usedKeys = new Set(config.componentProps);
808
- if ("contextProps" in config && config.contextProps) {
809
- for (const key of config.contextProps) {
810
- usedKeys.add(key);
811
- }
812
- }
813
- const unusedKeys = availableComponentKeys.filter(
814
- (key) => !usedKeys.has(key) && component[key] !== void 0 && component[key] !== null && // Skip commonly unused base properties
815
- ![
816
- "type",
817
- "name",
818
- "parentId",
819
- "parentFieldId",
820
- "anchor",
821
- "backgroundVisual",
822
- "backgroundOverlayOpacity",
823
- "isFirst",
824
- "isLast",
825
- "indexOfType"
826
- ].includes(key)
827
- );
828
- if (unusedKeys.length > 0) {
829
- console.warn(
830
- `Component with config has unused properties:`,
831
- unusedKeys,
832
- "\nConsider adding these to the component prop requirements or marking them as intentionally unused."
833
- );
834
- }
835
- }
836
- return props;
837
- }
838
- function extractPropsFromCollectionConfig(config, collection, context) {
839
- const props = {};
840
- for (const key of config.collectionProps) {
841
- if (key in collection) {
842
- props[key] = collection[key];
843
- }
844
- }
845
- if ("contextProps" in config && config.contextProps && context) {
846
- for (const key of config.contextProps) {
847
- if (key in context) {
848
- props[key] = context[key];
849
- }
850
- }
851
- }
852
- if ("additionalProps" in config && config.additionalProps) {
853
- Object.assign(props, config.additionalProps);
854
- }
855
- if (developmentMode) {
856
- const availableCollectionKeys = [
857
- "id",
858
- "index",
859
- "collectionType",
860
- "cmsLabel",
861
- "backgroundColour",
862
- "textColour",
863
- "heading",
864
- "preHeading",
865
- "postHeading",
866
- "body",
867
- "visual",
868
- "icon",
869
- "links",
870
- "additionalCopy",
871
- "anchor",
872
- "name",
873
- "parentId",
874
- "parentFieldId",
875
- "backgroundVisual",
876
- "backgroundOverlayOpacity",
877
- "isFirst",
878
- "isLast",
879
- "indexOfType",
880
- "type",
881
- "contents"
882
- ];
883
- const usedKeys = new Set(config.collectionProps);
884
- if ("contextProps" in config && config.contextProps) {
885
- for (const key of config.contextProps) {
886
- usedKeys.add(key);
887
- }
888
- }
889
- const unusedKeys = availableCollectionKeys.filter(
890
- (key) => !usedKeys.has(key) && collection[key] !== void 0 && collection[key] !== null && // Skip commonly unused base properties
891
- ![
892
- "type",
893
- "name",
894
- "parentId",
895
- "parentFieldId",
896
- "anchor",
897
- "backgroundVisual",
898
- "backgroundOverlayOpacity",
899
- "isFirst",
900
- "isLast",
901
- "indexOfType"
902
- ].includes(key)
903
- );
904
- if (unusedKeys.length > 0) {
905
- console.warn(
906
- `Collection with config has unused properties:`,
907
- unusedKeys,
908
- "\nConsider adding these to the collection prop requirements or marking them as intentionally unused."
909
- );
910
- }
911
- }
912
- return props;
913
- }
914
- function BuildEmbedFromComponentConfig(Component, componentConfig) {
915
- return ({ information, pageContext }) => {
916
- const props = extractPropsFromComponentConfig(componentConfig, information, pageContext);
917
- return /* @__PURE__ */ jsx(Component, { ...props });
918
- };
919
- }
920
- function BuildEmbedFromCollectionConfig(Collection, collectionConfig) {
921
- return ({ information, pageContext }) => {
922
- const props = extractPropsFromCollectionConfig(collectionConfig, information, pageContext);
923
- return /* @__PURE__ */ jsx(Collection, { ...props });
924
- };
925
- }
926
-
927
- // src/embeddable/EmbeddableMaps.ts
928
- function isComponentEmbeddable(componentType, embeddableMap) {
929
- return componentType in embeddableMap;
930
- }
931
- function isCollectionEmbeddable(collectionType, embeddableMap) {
932
- return collectionType in embeddableMap;
933
- }
934
- function createComplexLinksRenderer(rendererConfig, contentContext) {
935
- return {
936
- [INLINES.EMBEDDED_ENTRY]: (node) => {
937
- const target = node.data.target;
938
- if (target) {
939
- const Renderer = rendererConfig.internalLinkRenderer;
940
- return /* @__PURE__ */ jsx(Renderer, { information: target, contentContext });
941
- }
942
- return /* @__PURE__ */ jsx("pre", { children: `Failed to find inline embedded entry` });
943
- },
944
- [INLINES.HYPERLINK]: (node, children) => {
945
- const href = node.data.uri;
946
- const Renderer = rendererConfig.basicLinkRenderer;
947
- return /* @__PURE__ */ jsx(Renderer, { href, children });
948
- },
949
- [INLINES.ENTRY_HYPERLINK]: (node) => {
950
- const target = node.data.target;
951
- if (target) {
952
- const Renderer = rendererConfig.internalLinkRenderer;
953
- return /* @__PURE__ */ jsx(Renderer, { information: target, contentContext });
954
- }
955
- return /* @__PURE__ */ jsx("pre", { children: `Failed to find inline embedded entry` });
956
- },
957
- [BLOCKS.EMBEDDED_ENTRY]: (node) => {
958
- const target = node.data.target;
959
- if (target) {
960
- const Renderer = rendererConfig.embeddedContentRenderer;
961
- return /* @__PURE__ */ jsx(
962
- Renderer,
963
- {
964
- information: target,
965
- contentContext,
966
- rendererConfig
967
- }
968
- );
969
- }
970
- return /* @__PURE__ */ jsx("pre", { children: `Failed to find block embedded entry` });
971
- },
972
- [BLOCKS.EMBEDDED_ASSET]: (node) => {
973
- const target = node.data.target;
974
- if (target) {
975
- const Renderer = rendererConfig.visualComponentRenderer;
976
- return /* @__PURE__ */ jsx(Renderer, { information: target, contentContext });
977
- }
978
- return /* @__PURE__ */ jsx("pre", { children: `Failed to find block embedded asset` });
979
- }
980
- };
981
- }
982
- function buildOptions(rendererConfig, contentContext) {
983
- const complexLinksRenderer = createComplexLinksRenderer(rendererConfig, contentContext);
984
- return {
985
- renderNode: {
986
- ...complexLinksRenderer
987
- }
988
- };
989
- }
990
- function RTF({
991
- content,
992
- className,
993
- style,
994
- rendererConfig,
995
- contentContext,
996
- ...other
997
- }) {
998
- const options = buildOptions(rendererConfig, contentContext);
999
- return /* @__PURE__ */ jsx("div", { className, style, ...other, children: documentToReactComponents(content, options) });
1000
- }
1001
- var DEFAULT_ALLOWED_UNUSED = /* @__PURE__ */ new Set([
1002
- "componentType",
1003
- "CollectionType",
1004
- "id",
1005
- "type",
1006
- "name",
1007
- "index",
1008
- "indexOfType",
1009
- "isFirst",
1010
- "isLast",
1011
- "anchor",
1012
- "parentId",
1013
- "parentFieldId",
1014
- "backgroundColour",
1015
- "textColour",
1016
- "priority",
1017
- "__typename",
1018
- "cmsLabel",
1019
- "backgroundVisual",
1020
- "backgroundOverlayOpacity"
1021
- ]);
1022
- function getUnusedFields(unused, allowedToBeUnused = DEFAULT_ALLOWED_UNUSED) {
1023
- const fieldsWithValues = Object.entries(unused).filter(([name]) => !allowedToBeUnused.has(name)).filter(([, value]) => typeof value !== "undefined" && value !== null).map(([name]) => name);
1024
- if (fieldsWithValues.length > 0) return fieldsWithValues;
1025
- return void 0;
1026
- }
1027
- var UnusedChecker = ({
1028
- children,
1029
- componentName,
1030
- unused,
1031
- allowedToBeUnused = DEFAULT_ALLOWED_UNUSED,
1032
- showWarnings = true
1033
- }) => {
1034
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "production" || !showWarnings) {
1035
- return /* @__PURE__ */ jsx(Fragment, { children });
1036
- }
1037
- const fields = getUnusedFields(unused, allowedToBeUnused);
1038
- if (fields) {
1039
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1040
- /* @__PURE__ */ jsxs(
1041
- "div",
1042
- {
1043
- style: {
1044
- backgroundColor: "yellow",
1045
- padding: "2rem",
1046
- margin: "1rem 0"
1047
- },
1048
- children: [
1049
- /* @__PURE__ */ jsxs(
1050
- "p",
1051
- {
1052
- style: {
1053
- fontSize: "3rem",
1054
- color: "black",
1055
- margin: "0 0 1rem 0"
1056
- },
1057
- children: [
1058
- "Unused fields in: ",
1059
- componentName
1060
- ]
1061
- }
1062
- ),
1063
- /* @__PURE__ */ jsxs("p", { style: { fontSize: "1.5rem", color: "black", margin: 0 }, children: [
1064
- "Unused fields: ",
1065
- fields.join(", ")
1066
- ] })
1067
- ]
1068
- }
1069
- ),
1070
- children
1071
- ] });
1072
- }
1073
- return /* @__PURE__ */ jsx(Fragment, { children });
1074
- };
1075
-
1076
- export { BuildEmbedFromCollectionConfig, BuildEmbedFromComponentConfig, CmsCollection, CmsComponent, CmsContent, DEFAULT_ALLOWED_UNUSED, RTF, UnsupportedWarning, UnusedChecker, Visual, calculateCropDetails, calculateImagePriority, calculateImageWidthStyleVariable, createCmsRendererConfig, extractPropsFromCollectionConfig, extractPropsFromComponentConfig, isCollectionEmbeddable, isComponentEmbeddable, mergeCmsRendererConfig };
1077
- //# sourceMappingURL=index.js.map
1
+ export { ClientMonitor } from './components/ClientMonitor.js';
2
+ export { CmsCollection } from './components/CmsCollection';
3
+ export { CmsComponent } from './components/CmsComponent';
4
+ export { CmsContent } from './components/CmsContent';
5
+ export { Preview } from './components/Preview.js';
6
+ export { calculateCropDetails, calculateImagePriority, calculateImageWidthStyleVariable, } from './components/Visual';
7
+ export { Visual } from './components/VisualComponent';
8
+ export { RtfOrString } from './elements/RtfOrString';
9
+ export { UtmLink } from './elements/UtmLink';
10
+ export { UtmLinkOrDiv } from './elements/UtmLinkOrDiv';
11
+ export { BuildEmbedFromCollectionConfig, BuildEmbedFromComponentConfig, } from './embeddable/BuildEmbed';
12
+ export { isCollectionEmbeddable, isComponentEmbeddable, } from './embeddable/EmbeddableMaps';
13
+ export { BackgroundMedia } from './framework/BackgroundMedia';
14
+ export { calculateColourChanges } from './framework/ColourChange';
15
+ export { ComponentErrorIndicator } from './framework/ComponentErrorIndicator';
16
+ export { showComponentError, showInlineError } from './framework/componentErrors';
17
+ export { useClickTracking } from './hooks/useClickTracking';
18
+ export { RTF } from './rtf/rtf';
19
+ export { buildPageMetadata } from './utils/buildPageMetadata';
20
+ export { cn } from './utils/cn';
21
+ export { createCollectionProps, createComponentProps, extractCollectionInfo, extractComponentInfo, extractPageContext, } from './utils/componentUtils';
22
+ export { convertText } from './utils/convertText';
23
+ export { handleCmsError } from './utils/errorHandling';
24
+ export { getPreviewAssetIdProps, getPreviewFieldIdProps, getPreviewParentProps, getPreviewProps, } from './utils/previewUtils';
25
+ export { UnsupportedWarning } from './utils/UnsupportedWarning';
26
+ export { DEFAULT_ALLOWED_UNUSED, UnusedChecker } from './utils/UnusedChecker';
27
+ export { calculateHorizontalPositionClassName } from './utils/visualPositions';
28
+ export { calculateVisualSizes } from './utils/visualSizes';
1078
29
  //# sourceMappingURL=index.js.map