fimo 0.7.0-experimental.1 → 0.7.0-experimental.10

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 (310) hide show
  1. package/assets/content-templates/hooks-template.eta +27 -73
  2. package/assets/content-templates/types-template.eta +1 -4
  3. package/assets/skills/fimo/SKILL.md +2 -2
  4. package/assets/skills/fimo/references/content.md +42 -46
  5. package/assets/skills/fimo/references/locales.md +0 -8
  6. package/assets/skills/fimo/references/setup-react-router.md +2 -2
  7. package/assets/skills/fimo/references/ui.md +1 -1
  8. package/assets/skills/fimo-cli/references/content.md +14 -17
  9. package/assets/skills/fimo-cli/references/locales.md +0 -6
  10. package/assets/skills/fimo-migration/SKILL.md +22 -2
  11. package/assets/skills/fimo-migration/references/content.md +8 -0
  12. package/assets/skills/fimo-migration/references/manifest.md +35 -0
  13. package/assets/skills/fimo-migration/references/qa.md +24 -2
  14. package/assets/skills/fimo-migration/references/workflow.md +12 -1
  15. package/assets/skills/fimo-migration/references/wrap.md +617 -0
  16. package/assets/skills/fimo-studio/references/visual-editing.md +5 -3
  17. package/dist/build/vite/plugins/translations.d.ts +2 -8
  18. package/dist/build/vite/plugins/translations.d.ts.map +1 -1
  19. package/dist/build/vite/plugins/translations.js +3 -121
  20. package/dist/cli/bundle.json +1 -1
  21. package/dist/cli/index.js +20655 -12551
  22. package/dist/runtime/app/FimoProviders.d.ts +1 -11
  23. package/dist/runtime/app/FimoProviders.d.ts.map +1 -1
  24. package/dist/runtime/app/FimoProviders.js +2 -23
  25. package/dist/runtime/astro/index.d.ts +2 -0
  26. package/dist/runtime/astro/index.d.ts.map +1 -0
  27. package/dist/runtime/astro/index.js +3 -0
  28. package/dist/runtime/astro/server.d.ts +3 -0
  29. package/dist/runtime/astro/server.d.ts.map +1 -0
  30. package/dist/runtime/astro/server.js +6 -0
  31. package/dist/runtime/content/utils/retrieve-data-sources.d.ts +0 -1
  32. package/dist/runtime/content/utils/retrieve-data-sources.d.ts.map +1 -1
  33. package/dist/runtime/content/utils/retrieve-data-sources.js +4 -27
  34. package/dist/runtime/i18n/FimoLocaleContext.d.ts.map +1 -1
  35. package/dist/runtime/i18n/FimoLocaleContext.js +1 -0
  36. package/dist/runtime/next/FimoNextProviders.d.ts +24 -0
  37. package/dist/runtime/next/FimoNextProviders.d.ts.map +1 -0
  38. package/dist/runtime/next/FimoNextProviders.js +20 -0
  39. package/dist/runtime/next/FimoNextScripts.d.ts +10 -0
  40. package/dist/runtime/next/FimoNextScripts.d.ts.map +1 -0
  41. package/dist/runtime/next/FimoNextScripts.js +19 -0
  42. package/dist/runtime/next/index.d.ts +14 -0
  43. package/dist/runtime/next/index.d.ts.map +1 -0
  44. package/dist/runtime/next/index.js +14 -0
  45. package/dist/runtime/next/server.d.ts +2 -0
  46. package/dist/runtime/next/server.d.ts.map +1 -0
  47. package/dist/runtime/next/server.js +4 -0
  48. package/dist/runtime/nuxt/composables.d.ts +9 -0
  49. package/dist/runtime/nuxt/composables.d.ts.map +1 -0
  50. package/dist/runtime/nuxt/composables.js +57 -0
  51. package/dist/runtime/nuxt/index.d.ts +3 -0
  52. package/dist/runtime/nuxt/index.d.ts.map +1 -0
  53. package/dist/runtime/nuxt/index.js +6 -0
  54. package/dist/runtime/nuxt/server.d.ts +3 -0
  55. package/dist/runtime/nuxt/server.d.ts.map +1 -0
  56. package/dist/runtime/nuxt/server.js +6 -0
  57. package/dist/runtime/paths/get-fimo-paths.d.ts.map +1 -1
  58. package/dist/runtime/paths/get-fimo-paths.js +5 -15
  59. package/dist/runtime/primitives/labels-hook.d.ts +33 -0
  60. package/dist/runtime/primitives/labels-hook.d.ts.map +1 -0
  61. package/dist/runtime/primitives/labels-hook.js +41 -0
  62. package/dist/runtime/primitives/labels-store.d.ts +12 -0
  63. package/dist/runtime/primitives/labels-store.d.ts.map +1 -0
  64. package/dist/runtime/primitives/labels-store.js +60 -0
  65. package/dist/runtime/primitives/labels-store.test.d.ts +2 -0
  66. package/dist/runtime/primitives/labels-store.test.d.ts.map +1 -0
  67. package/dist/runtime/primitives/labels-store.test.js +66 -0
  68. package/dist/runtime/primitives/lib/primitives.d.ts +2 -2
  69. package/dist/runtime/primitives/lib/primitives.d.ts.map +1 -1
  70. package/dist/runtime/primitives/lib/query.d.ts +3 -5
  71. package/dist/runtime/primitives/lib/query.d.ts.map +1 -1
  72. package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts +5 -3
  73. package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts.map +1 -1
  74. package/dist/runtime/primitives/lib/useFimoLiveValue.js +11 -4
  75. package/dist/runtime/primitives/public-surface.test.js +5 -9
  76. package/dist/runtime/primitives/translations.d.ts +1 -27
  77. package/dist/runtime/primitives/translations.d.ts.map +1 -1
  78. package/dist/runtime/primitives/translations.js +7 -85
  79. package/dist/runtime/react/FimoSpaProviders.d.ts +36 -0
  80. package/dist/runtime/react/FimoSpaProviders.d.ts.map +1 -0
  81. package/dist/runtime/react/FimoSpaProviders.js +63 -0
  82. package/dist/runtime/react/index.d.ts +33 -0
  83. package/dist/runtime/react/index.d.ts.map +1 -0
  84. package/dist/runtime/react/index.js +39 -0
  85. package/dist/runtime/remix/FimoRemixProviders.d.ts +16 -0
  86. package/dist/runtime/remix/FimoRemixProviders.d.ts.map +1 -0
  87. package/dist/runtime/remix/FimoRemixProviders.js +12 -0
  88. package/dist/runtime/remix/FimoRemixScripts.d.ts +10 -0
  89. package/dist/runtime/remix/FimoRemixScripts.d.ts.map +1 -0
  90. package/dist/runtime/remix/FimoRemixScripts.js +19 -0
  91. package/dist/runtime/remix/index.d.ts +12 -0
  92. package/dist/runtime/remix/index.d.ts.map +1 -0
  93. package/dist/runtime/remix/index.js +11 -0
  94. package/dist/runtime/remix/server.d.ts +2 -0
  95. package/dist/runtime/remix/server.d.ts.map +1 -0
  96. package/dist/runtime/remix/server.js +2 -0
  97. package/dist/runtime/seo/buildSeoForPath.d.ts +3 -1
  98. package/dist/runtime/seo/buildSeoForPath.d.ts.map +1 -1
  99. package/dist/runtime/seo/buildSeoForPath.js +1 -4
  100. package/dist/runtime/shared/display-routes.d.ts +14 -0
  101. package/dist/runtime/shared/display-routes.d.ts.map +1 -0
  102. package/dist/runtime/shared/display-routes.js +25 -0
  103. package/dist/runtime/shared/fimo-config.server.d.ts.map +1 -1
  104. package/dist/runtime/shared/fimo-config.server.js +1 -0
  105. package/dist/runtime/shared/fimo-config.types.d.ts +2 -0
  106. package/dist/runtime/shared/fimo-config.types.d.ts.map +1 -1
  107. package/dist/runtime/shared/i18n-messages.d.ts +29 -0
  108. package/dist/runtime/shared/i18n-messages.d.ts.map +1 -0
  109. package/dist/runtime/shared/i18n-messages.js +79 -0
  110. package/dist/runtime/shared/i18n-messages.test.d.ts +2 -0
  111. package/dist/runtime/shared/i18n-messages.test.d.ts.map +1 -0
  112. package/dist/runtime/shared/i18n-messages.test.js +39 -0
  113. package/dist/runtime/shared/labels-fetch.pure.d.ts +17 -0
  114. package/dist/runtime/shared/labels-fetch.pure.d.ts.map +1 -0
  115. package/dist/runtime/shared/labels-fetch.pure.js +71 -0
  116. package/dist/runtime/shared/labels-fetch.server.d.ts +7 -0
  117. package/dist/runtime/shared/labels-fetch.server.d.ts.map +1 -0
  118. package/dist/runtime/shared/labels-fetch.server.js +97 -0
  119. package/dist/runtime/shared/labels-t.pure.d.ts +2 -0
  120. package/dist/runtime/shared/labels-t.pure.d.ts.map +1 -0
  121. package/dist/runtime/shared/labels-t.pure.js +10 -0
  122. package/dist/runtime/strapi/client.d.ts +26 -0
  123. package/dist/runtime/strapi/client.d.ts.map +1 -0
  124. package/dist/runtime/strapi/client.js +88 -0
  125. package/dist/runtime/strapi/client.test.d.ts +2 -0
  126. package/dist/runtime/strapi/client.test.d.ts.map +1 -0
  127. package/dist/runtime/strapi/client.test.js +64 -0
  128. package/dist/runtime/strapi/index.d.ts +5 -0
  129. package/dist/runtime/strapi/index.d.ts.map +1 -0
  130. package/dist/runtime/strapi/index.js +6 -0
  131. package/dist/runtime/strapi/reshape.d.ts +28 -0
  132. package/dist/runtime/strapi/reshape.d.ts.map +1 -0
  133. package/dist/runtime/strapi/reshape.js +79 -0
  134. package/dist/runtime/strapi/reshape.test.d.ts +2 -0
  135. package/dist/runtime/strapi/reshape.test.d.ts.map +1 -0
  136. package/dist/runtime/strapi/reshape.test.js +33 -0
  137. package/dist/runtime/svelte/index.d.ts +3 -0
  138. package/dist/runtime/svelte/index.d.ts.map +1 -0
  139. package/dist/runtime/svelte/index.js +7 -0
  140. package/dist/runtime/svelte/server.d.ts +3 -0
  141. package/dist/runtime/svelte/server.d.ts.map +1 -0
  142. package/dist/runtime/svelte/server.js +6 -0
  143. package/dist/runtime/vue/index.d.ts +3 -0
  144. package/dist/runtime/vue/index.d.ts.map +1 -0
  145. package/dist/runtime/vue/index.js +5 -0
  146. package/dist/runtime/vue/server.d.ts +3 -0
  147. package/dist/runtime/vue/server.d.ts.map +1 -0
  148. package/dist/runtime/vue/server.js +6 -0
  149. package/dist/runtime/wrapped/FimoFileLink.d.ts +17 -0
  150. package/dist/runtime/wrapped/FimoFileLink.d.ts.map +1 -0
  151. package/dist/runtime/wrapped/FimoFileLink.js +19 -0
  152. package/dist/runtime/wrapped/FimoMediaImage.d.ts +14 -0
  153. package/dist/runtime/wrapped/FimoMediaImage.d.ts.map +1 -0
  154. package/dist/runtime/wrapped/FimoMediaImage.js +20 -0
  155. package/dist/runtime/wrapped/FimoMediaVideo.d.ts +14 -0
  156. package/dist/runtime/wrapped/FimoMediaVideo.d.ts.map +1 -0
  157. package/dist/runtime/wrapped/FimoMediaVideo.js +20 -0
  158. package/dist/runtime/wrapped/FimoRichTextBlock.d.ts +23 -0
  159. package/dist/runtime/wrapped/FimoRichTextBlock.d.ts.map +1 -0
  160. package/dist/runtime/wrapped/FimoRichTextBlock.js +22 -0
  161. package/dist/runtime/wrapped/FimoText.d.ts +22 -0
  162. package/dist/runtime/wrapped/FimoText.d.ts.map +1 -0
  163. package/dist/runtime/wrapped/FimoText.js +20 -0
  164. package/dist/runtime/wrapped/WrappedContentContext.d.ts +28 -0
  165. package/dist/runtime/wrapped/WrappedContentContext.d.ts.map +1 -0
  166. package/dist/runtime/wrapped/WrappedContentContext.js +30 -0
  167. package/dist/runtime/wrapped/WrappedProviders.d.ts +33 -0
  168. package/dist/runtime/wrapped/WrappedProviders.d.ts.map +1 -0
  169. package/dist/runtime/wrapped/WrappedProviders.js +101 -0
  170. package/dist/runtime/wrapped/dom.d.ts +4 -0
  171. package/dist/runtime/wrapped/dom.d.ts.map +1 -0
  172. package/dist/runtime/wrapped/dom.js +23 -0
  173. package/dist/runtime/wrapped/dom.test.d.ts +2 -0
  174. package/dist/runtime/wrapped/dom.test.d.ts.map +1 -0
  175. package/dist/runtime/wrapped/dom.test.js +16 -0
  176. package/dist/runtime/wrapped/server.d.ts +77 -0
  177. package/dist/runtime/wrapped/server.d.ts.map +1 -0
  178. package/dist/runtime/wrapped/server.js +237 -0
  179. package/dist/runtime/wrapped/server.test.d.ts +2 -0
  180. package/dist/runtime/wrapped/server.test.d.ts.map +1 -0
  181. package/dist/runtime/wrapped/server.test.js +91 -0
  182. package/dist/scripts/apply-wrap-templates.d.ts +61 -0
  183. package/dist/scripts/apply-wrap-templates.js +132 -0
  184. package/dist/scripts/apply-wrap-templates.test.d.ts +1 -0
  185. package/dist/scripts/apply-wrap-templates.test.js +199 -0
  186. package/dist/scripts/apply-wrap.d.ts +46 -0
  187. package/dist/scripts/apply-wrap.js +278 -0
  188. package/dist/scripts/apply-wrap.test.d.ts +1 -0
  189. package/dist/scripts/apply-wrap.test.js +226 -0
  190. package/dist/scripts/cms/discover.d.ts +2 -0
  191. package/dist/scripts/cms/discover.js +17 -0
  192. package/dist/scripts/cms/example-content.d.ts +32 -0
  193. package/dist/scripts/cms/example-content.js +108 -0
  194. package/dist/scripts/cms/example-content.test.d.ts +1 -0
  195. package/dist/scripts/cms/example-content.test.js +66 -0
  196. package/dist/scripts/cms/strapi/detect.d.ts +2 -0
  197. package/dist/scripts/cms/strapi/detect.js +186 -0
  198. package/dist/scripts/cms/strapi/detect.test.d.ts +1 -0
  199. package/dist/scripts/cms/strapi/detect.test.js +56 -0
  200. package/dist/scripts/cms/strapi/index.d.ts +3 -0
  201. package/dist/scripts/cms/strapi/index.js +25 -0
  202. package/dist/scripts/cms/strapi/list-source.d.ts +17 -0
  203. package/dist/scripts/cms/strapi/list-source.js +90 -0
  204. package/dist/scripts/cms/strapi/list-source.test.d.ts +1 -0
  205. package/dist/scripts/cms/strapi/list-source.test.js +33 -0
  206. package/dist/scripts/cms/strapi/schema-map.d.ts +9 -0
  207. package/dist/scripts/cms/strapi/schema-map.js +149 -0
  208. package/dist/scripts/cms/strapi/schema-map.test.d.ts +1 -0
  209. package/dist/scripts/cms/strapi/schema-map.test.js +91 -0
  210. package/dist/scripts/cms/strapi/touchpoints.d.ts +31 -0
  211. package/dist/scripts/cms/strapi/touchpoints.js +145 -0
  212. package/dist/scripts/cms/strapi/touchpoints.test.d.ts +1 -0
  213. package/dist/scripts/cms/strapi/touchpoints.test.js +62 -0
  214. package/dist/scripts/cms/strapi/wire-client.d.ts +15 -0
  215. package/dist/scripts/cms/strapi/wire-client.js +107 -0
  216. package/dist/scripts/cms/strapi/wire-client.test.d.ts +1 -0
  217. package/dist/scripts/cms/strapi/wire-client.test.js +51 -0
  218. package/dist/scripts/cms/strapi/wiring.d.ts +17 -0
  219. package/dist/scripts/cms/strapi/wiring.js +36 -0
  220. package/dist/scripts/cms/strapi/wiring.test.d.ts +1 -0
  221. package/dist/scripts/cms/strapi/wiring.test.js +27 -0
  222. package/dist/scripts/cms/types.d.ts +117 -0
  223. package/dist/scripts/cms/types.js +11 -0
  224. package/dist/scripts/detect-framework.d.ts +39 -0
  225. package/dist/scripts/detect-framework.js +133 -0
  226. package/dist/scripts/detect-framework.test.d.ts +1 -0
  227. package/dist/scripts/detect-framework.test.js +122 -0
  228. package/dist/scripts/draft-rows.d.ts +19 -0
  229. package/dist/scripts/draft-rows.js +135 -0
  230. package/dist/scripts/draft-rows.test.d.ts +1 -0
  231. package/dist/scripts/draft-rows.test.js +113 -0
  232. package/dist/scripts/draft-schemas.d.ts +27 -0
  233. package/dist/scripts/draft-schemas.js +188 -0
  234. package/dist/scripts/draft-schemas.test.d.ts +1 -0
  235. package/dist/scripts/draft-schemas.test.js +152 -0
  236. package/dist/scripts/extract-translations.js +16 -11
  237. package/dist/scripts/extract-translations.test.d.ts +1 -0
  238. package/dist/scripts/extract-translations.test.js +66 -0
  239. package/dist/scripts/frameworks/astro/routes.d.ts +3 -0
  240. package/dist/scripts/frameworks/astro/routes.js +55 -0
  241. package/dist/scripts/frameworks/astro/template-style.d.ts +7 -0
  242. package/dist/scripts/frameworks/astro/template-style.js +19 -0
  243. package/dist/scripts/frameworks/discover.d.ts +70 -0
  244. package/dist/scripts/frameworks/discover.js +178 -0
  245. package/dist/scripts/frameworks/next/rewire.d.ts +30 -0
  246. package/dist/scripts/frameworks/next/rewire.js +258 -0
  247. package/dist/scripts/frameworks/next/rewire.test.d.ts +1 -0
  248. package/dist/scripts/frameworks/next/rewire.test.js +134 -0
  249. package/dist/scripts/frameworks/next/routes.d.ts +17 -0
  250. package/dist/scripts/frameworks/next/routes.js +134 -0
  251. package/dist/scripts/frameworks/next/routes.test.d.ts +1 -0
  252. package/dist/scripts/frameworks/next/routes.test.js +64 -0
  253. package/dist/scripts/frameworks/next/wiring.d.ts +33 -0
  254. package/dist/scripts/frameworks/next/wiring.js +186 -0
  255. package/dist/scripts/frameworks/next/wiring.test.d.ts +1 -0
  256. package/dist/scripts/frameworks/next/wiring.test.js +174 -0
  257. package/dist/scripts/frameworks/nuxt/routes.d.ts +3 -0
  258. package/dist/scripts/frameworks/nuxt/routes.js +54 -0
  259. package/dist/scripts/frameworks/nuxt/template-style.d.ts +9 -0
  260. package/dist/scripts/frameworks/nuxt/template-style.js +27 -0
  261. package/dist/scripts/frameworks/remix/routes.d.ts +3 -0
  262. package/dist/scripts/frameworks/remix/routes.js +50 -0
  263. package/dist/scripts/frameworks/support.d.ts +75 -0
  264. package/dist/scripts/frameworks/support.js +165 -0
  265. package/dist/scripts/frameworks/support.test.d.ts +1 -0
  266. package/dist/scripts/frameworks/support.test.js +87 -0
  267. package/dist/scripts/frameworks/sveltekit/routes.d.ts +3 -0
  268. package/dist/scripts/frameworks/sveltekit/routes.js +50 -0
  269. package/dist/scripts/frameworks/sveltekit/template-style.d.ts +9 -0
  270. package/dist/scripts/frameworks/sveltekit/template-style.js +54 -0
  271. package/dist/scripts/frameworks/vite/routes.d.ts +15 -0
  272. package/dist/scripts/frameworks/vite/routes.js +93 -0
  273. package/dist/scripts/frameworks/vite/routes.test.d.ts +1 -0
  274. package/dist/scripts/frameworks/vite/routes.test.js +73 -0
  275. package/dist/scripts/frameworks/vite/wiring.d.ts +10 -0
  276. package/dist/scripts/frameworks/vite/wiring.js +99 -0
  277. package/dist/scripts/frameworks/vite/wiring.test.d.ts +1 -0
  278. package/dist/scripts/frameworks/vite/wiring.test.js +88 -0
  279. package/dist/scripts/generated-types.test.js +1 -1
  280. package/dist/scripts/i18n-namespace.d.ts +25 -0
  281. package/dist/scripts/i18n-namespace.js +53 -0
  282. package/dist/scripts/lib/validation-report.d.ts +1 -0
  283. package/dist/scripts/lib/validation-report.js +3 -0
  284. package/dist/scripts/render-parity/capture.d.ts +56 -0
  285. package/dist/scripts/render-parity/capture.js +366 -0
  286. package/dist/scripts/render-parity/capture.test.d.ts +1 -0
  287. package/dist/scripts/render-parity/capture.test.js +306 -0
  288. package/dist/scripts/render-parity/compare.d.ts +59 -0
  289. package/dist/scripts/render-parity/compare.js +0 -0
  290. package/dist/scripts/render-parity/compare.test.d.ts +1 -0
  291. package/dist/scripts/render-parity/compare.test.js +98 -0
  292. package/dist/scripts/render-parity/normalize-html.d.ts +13 -0
  293. package/dist/scripts/render-parity/normalize-html.js +223 -0
  294. package/dist/scripts/render-parity/normalize-html.test.d.ts +1 -0
  295. package/dist/scripts/render-parity/normalize-html.test.js +58 -0
  296. package/dist/scripts/render-parity/types.d.ts +41 -0
  297. package/dist/scripts/render-parity/types.js +1 -0
  298. package/dist/scripts/resolve-routes.js +1 -1
  299. package/dist/scripts/scan-wrappable.d.ts +196 -0
  300. package/dist/scripts/scan-wrappable.js +1227 -0
  301. package/dist/scripts/scan-wrappable.test.d.ts +1 -0
  302. package/dist/scripts/scan-wrappable.test.js +521 -0
  303. package/dist/scripts/sync-schemas.test.js +4 -24
  304. package/dist/scripts/validate-route-metadata.js +11 -0
  305. package/dist/scripts/validate-schemas.test.js +2 -2
  306. package/package.json +92 -5
  307. package/templates/react-router/package.json +7 -10
  308. package/dist/runtime/paths/get-fimo-paths.test.d.ts +0 -2
  309. package/dist/runtime/paths/get-fimo-paths.test.d.ts.map +0 -1
  310. package/dist/runtime/paths/get-fimo-paths.test.js +0 -69
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { FIMO_SOURCE, FimoMedia, type FimoRichTextContent } from '../primitives/lib/index.js';
3
+ export interface WrappedMediaEntry {
4
+ url: string;
5
+ alt?: string;
6
+ name?: string;
7
+ mime?: string;
8
+ width?: number;
9
+ height?: number;
10
+ /** data-fimo-source path, e.g. `WrappedMedia.<entryId>.image` */
11
+ source: string;
12
+ }
13
+ export interface WrappedRichTextEntry {
14
+ content: FimoRichTextContent;
15
+ /** data-fimo-source path, e.g. `WrappedRichText.<entryId>.body` */
16
+ source: string;
17
+ }
18
+ export interface WrappedContentValue {
19
+ media: Record<string, WrappedMediaEntry>;
20
+ richText: Record<string, WrappedRichTextEntry>;
21
+ }
22
+ export declare function WrappedContentProvider({ media, richText, children, }: Partial<WrappedContentValue> & {
23
+ children?: React.ReactNode;
24
+ }): import("react/jsx-runtime").JSX.Element;
25
+ export declare function useWrappedMedia(id: string): FimoMedia | null;
26
+ export declare function useWrappedRichText(id: string): WrappedRichTextEntry | null;
27
+ export { FIMO_SOURCE };
28
+ //# sourceMappingURL=WrappedContentContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WrappedContentContext.d.ts","sourceRoot":"","sources":["../../../src/runtime/wrapped/WrappedContentContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE9F,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CAChD;AAMD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAG/D;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAiB5D;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAG1E;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo } from 'react';
4
+ import { FIMO_SOURCE, FimoMedia } from '../primitives/lib/index.js';
5
+ const emptyValue = { media: {}, richText: {} };
6
+ const WrappedContentContext = createContext(emptyValue);
7
+ export function WrappedContentProvider({ media, richText, children, }) {
8
+ const value = useMemo(() => ({ media: media ?? {}, richText: richText ?? {} }), [media, richText]);
9
+ return _jsx(WrappedContentContext.Provider, { value: value, children: children });
10
+ }
11
+ export function useWrappedMedia(id) {
12
+ const { media } = useContext(WrappedContentContext);
13
+ const entry = media[id];
14
+ if (!entry) {
15
+ return null;
16
+ }
17
+ return new FimoMedia({
18
+ url: entry.url,
19
+ alt: entry.alt ?? '',
20
+ name: entry.name ?? id,
21
+ mime: entry.mime ?? '',
22
+ width: entry.width,
23
+ height: entry.height,
24
+ }, entry.source);
25
+ }
26
+ export function useWrappedRichText(id) {
27
+ const { richText } = useContext(WrappedContentContext);
28
+ return richText[id] ?? null;
29
+ }
30
+ export { FIMO_SOURCE };
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import type { FimoConfig } from '../shared/fimo-config.types.js';
3
+ import { type WrappedMediaEntry, type WrappedRichTextEntry } from './WrappedContentContext.js';
4
+ export interface WrappedLabels {
5
+ dictionaries: Record<string, Record<string, string>>;
6
+ defaultLocale: string;
7
+ locales?: string[];
8
+ updatedAt?: string | null;
9
+ signature: string;
10
+ }
11
+ /** Framework navigation adapter: the ONLY thing an adapter must supply. */
12
+ export interface WrappedNavigation {
13
+ pathname: string | null;
14
+ navigate: (to: string) => void;
15
+ }
16
+ export interface WrappedProvidersProps {
17
+ config: FimoConfig;
18
+ labels?: WrappedLabels;
19
+ media?: Record<string, WrappedMediaEntry>;
20
+ richText?: Record<string, WrappedRichTextEntry>;
21
+ locale?: string;
22
+ navigation: WrappedNavigation;
23
+ children?: React.ReactNode;
24
+ }
25
+ /**
26
+ * Framework-neutral providers for WRAPPED (adopted) apps. Adapters
27
+ * (fimo/next, fimo/remix, ...) supply only the navigation hooks; everything
28
+ * else — label hydration, locale resolution, preview bridge, error boundary —
29
+ * is shared. Content arrives as serializable props from the wrapped server
30
+ * loaders.
31
+ */
32
+ export declare function WrappedProviders({ config, labels, media, richText, locale, navigation, children }: WrappedProvidersProps): import("react/jsx-runtime").JSX.Element;
33
+ //# sourceMappingURL=WrappedProviders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WrappedProviders.d.ts","sourceRoot":"","sources":["../../../src/runtime/wrapped/WrappedProviders.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8D,MAAM,OAAO,CAAC;AAUnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAA0B,KAAK,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvH,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA+DD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,qBAAqB,2CAqDxH"}
@@ -0,0 +1,101 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
+ import { Suspense, useCallback, useEffect, useMemo, useState } from 'react';
5
+ import { ErrorBoundary } from 'react-error-boundary';
6
+ import { DataSourcesProvider } from '../content/DataSourcesProvider.js';
7
+ import { AppErrorBoundary, onError } from '../core/AppErrorBoundary.js';
8
+ import { FimoLocaleProvider } from '../i18n/FimoLocaleContext.js';
9
+ import { getFimoTextDirection, resolveFimoLocale, toHtmlLang } from '../i18n/locale.js';
10
+ import { ScreenshotProvider } from '../iframe/ScreenshotProvider.js';
11
+ import { hydrateLabels } from '../primitives/labels-store.js';
12
+ import { getDisplayRoutes } from '../shared/display-routes.js';
13
+ import { WrappedContentProvider } from './WrappedContentContext.js';
14
+ function toLabelState(labels) {
15
+ return {
16
+ dictionaries: labels.dictionaries,
17
+ defaultLocale: labels.defaultLocale,
18
+ signature: labels.signature,
19
+ updatedAt: labels.updatedAt ?? null,
20
+ };
21
+ }
22
+ function PreviewBridge({ config, navigation }) {
23
+ const { pathname, navigate } = navigation;
24
+ const localeResolution = useMemo(() => resolveFimoLocale({ pathname: pathname ?? undefined }, config), [pathname, config]);
25
+ const sendRoutes = useCallback(() => {
26
+ window.parent.postMessage({ type: 'nav/routes', payload: { routes: getDisplayRoutes(config) } }, '*');
27
+ }, [config]);
28
+ const sendLocationChange = useCallback(() => {
29
+ window.parent.postMessage({
30
+ type: 'nav/locationChange',
31
+ payload: {
32
+ path: pathname,
33
+ routePath: localeResolution.routePath,
34
+ locale: localeResolution.locale,
35
+ },
36
+ }, '*');
37
+ }, [pathname, localeResolution.locale, localeResolution.routePath]);
38
+ useEffect(sendRoutes, [sendRoutes]);
39
+ useEffect(sendLocationChange, [sendLocationChange]);
40
+ useEffect(() => {
41
+ const handleMessage = (event) => {
42
+ const type = event.data?.type;
43
+ const payload = event.data?.payload;
44
+ switch (type) {
45
+ case 'nav/navigate':
46
+ if (payload?.to) {
47
+ navigate(payload.to);
48
+ }
49
+ return;
50
+ case 'nav/read-routes':
51
+ sendRoutes();
52
+ sendLocationChange();
53
+ return;
54
+ }
55
+ };
56
+ window.addEventListener('message', handleMessage);
57
+ return () => {
58
+ window.removeEventListener('message', handleMessage);
59
+ };
60
+ }, [navigate, sendRoutes, sendLocationChange]);
61
+ return null;
62
+ }
63
+ /**
64
+ * Framework-neutral providers for WRAPPED (adopted) apps. Adapters
65
+ * (fimo/next, fimo/remix, ...) supply only the navigation hooks; everything
66
+ * else — label hydration, locale resolution, preview bridge, error boundary —
67
+ * is shared. Content arrives as serializable props from the wrapped server
68
+ * loaders.
69
+ */
70
+ export function WrappedProviders({ config, labels, media, richText, locale, navigation, children }) {
71
+ // Wrapped apps have no QueryClientProvider of their own; ScreenshotProvider
72
+ // (and future data-refresh machinery) need one, so the adapter owns it.
73
+ const [queryClient] = useState(() => new QueryClient());
74
+ useState(() => {
75
+ if (labels) {
76
+ hydrateLabels(toLabelState(labels));
77
+ }
78
+ return null;
79
+ });
80
+ useEffect(() => {
81
+ if (labels) {
82
+ hydrateLabels(toLabelState(labels));
83
+ }
84
+ }, [labels]);
85
+ const pathname = navigation.pathname;
86
+ const localeResolution = useMemo(() => resolveFimoLocale({ pathname: pathname ?? undefined }, config), [pathname, config]);
87
+ const activeLocale = locale ?? localeResolution.locale;
88
+ const activeDir = getFimoTextDirection(activeLocale);
89
+ useEffect(() => {
90
+ if (typeof document === 'undefined') {
91
+ return;
92
+ }
93
+ document.documentElement.lang = toHtmlLang(activeLocale);
94
+ document.documentElement.dir = activeDir;
95
+ }, [activeDir, activeLocale]);
96
+ return (_jsx(ErrorBoundary, { FallbackComponent: AppErrorBoundary, onError: onError, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(FimoLocaleProvider, { value: {
97
+ ...localeResolution,
98
+ locale: activeLocale,
99
+ dir: activeDir,
100
+ }, children: _jsx(WrappedContentProvider, { media: media, richText: richText, children: _jsx(DataSourcesProvider, { children: _jsxs(ScreenshotProvider, { children: [_jsx(PreviewBridge, { config: config, navigation: navigation }), _jsx(Suspense, { children: children })] }) }) }) }) }) }));
101
+ }
@@ -0,0 +1,4 @@
1
+ export declare const FIMO_SOURCE_ATTR = "data-fimo-source";
2
+ export declare function fimoLabelAttrs(key: string, locale?: string): Record<string, string>;
3
+ export declare function fimoMediaAttrs(source: string): Record<string, string>;
4
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/runtime/wrapped/dom.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,SAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEjF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAErE"}
@@ -0,0 +1,23 @@
1
+ // Framework-agnostic DOM contract for wrapped content in NON-React
2
+ // frameworks (Astro templates, Vue SFCs, Svelte components). The edit-mode
3
+ // preview client selects elements by these attributes; rendering the value +
4
+ // attributes is all a template needs:
5
+ //
6
+ // Astro: <h1 {...fimoLabelAttrs('home.title')}>{t('home.title', 'Hello')}</h1>
7
+ // Vue: <h1 v-bind="fimoLabelAttrs('home.title')">{{ t('home.title', 'Hello') }}</h1>
8
+ // Svelte: <h1 {...fimoLabelAttrs('home.title')}>{tv}</h1>
9
+ //
10
+ // Values come from the server loaders (loadFimoT / loadWrappedMedia) — after
11
+ // an edit, the page refetches on reload; live DOM patching is handled by the
12
+ // preview client via these same attributes.
13
+ // NOTE: this must be the literal DOM attribute the preview client queries
14
+ // (`document.querySelectorAll('[data-fimo-source]')`) — NOT the FIMO_SOURCE
15
+ // Symbol from the React primitives: a symbol key vanishes in a template
16
+ // attribute spread and in JSON, silently breaking editability.
17
+ export const FIMO_SOURCE_ATTR = 'data-fimo-source';
18
+ export function fimoLabelAttrs(key, locale = 'en') {
19
+ return { [FIMO_SOURCE_ATTR]: `__labels.${locale}.${key}.value` };
20
+ }
21
+ export function fimoMediaAttrs(source) {
22
+ return { [FIMO_SOURCE_ATTR]: source };
23
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dom.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.test.d.ts","sourceRoot":"","sources":["../../../src/runtime/wrapped/dom.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { fimoLabelAttrs, fimoMediaAttrs } from './dom.js';
3
+ describe('wrapped DOM attrs', () => {
4
+ it('emits the literal data-fimo-source attribute (a symbol key would vanish in template spreads)', () => {
5
+ expect(fimoLabelAttrs('home.hero.title')).toEqual({
6
+ 'data-fimo-source': '__labels.en.home.hero.title.value',
7
+ });
8
+ expect(fimoLabelAttrs('home.hero.title', 'fr')).toEqual({
9
+ 'data-fimo-source': '__labels.fr.home.hero.title.value',
10
+ });
11
+ expect(fimoMediaAttrs('hero.image')).toEqual({ 'data-fimo-source': 'hero.image' });
12
+ });
13
+ it('survives JSON serialization (the shape template engines actually consume)', () => {
14
+ expect(JSON.parse(JSON.stringify(fimoLabelAttrs('k')))).not.toEqual({});
15
+ });
16
+ });
@@ -0,0 +1,77 @@
1
+ import type { FimoNextLabels } from '../next/FimoNextProviders.js';
2
+ import type { FimoConfig } from '../shared/fimo-config.types.js';
3
+ import type { WrappedMediaEntry, WrappedRichTextEntry } from './WrappedContentContext.js';
4
+ export interface FimoServerOptions {
5
+ /** Project root (where fimo-config.json and .env live). Defaults to cwd. */
6
+ rootDir?: string;
7
+ /** Tenant API base URL. Defaults to NEXT_PUBLIC_FIMO_API_URL / VITE_API_URL. */
8
+ apiUrl?: string;
9
+ }
10
+ export declare function loadFimoConfig(rootDir?: string): FimoConfig;
11
+ export declare function loadFimoLabels(options?: FimoServerOptions): Promise<FimoNextLabels>;
12
+ /**
13
+ * Server-component label accessor: `useLabels()` is client-only, and forcing
14
+ * a client wrapper for one aria-label in a server component is not a
15
+ * migration, it is collateral damage. Load once per request scope and read
16
+ * synchronously: `const t = await loadFimoT(); <a aria-label={t('footer.github', 'GitHub')} …`.
17
+ */
18
+ export declare function loadFimoT(options?: FimoServerOptions & {
19
+ locale?: string;
20
+ }): Promise<(key: string, fallback: string) => string>;
21
+ export interface FimoEntry {
22
+ id: string;
23
+ data: Record<string, unknown>;
24
+ }
25
+ /**
26
+ * Fetch published entries of a content type from the public tenant API.
27
+ * Returns [] when the API is unreachable so the wrapped site keeps rendering
28
+ * its fallbacks.
29
+ */
30
+ export declare function fetchEntries(typeName: string, options?: FimoServerOptions & {
31
+ /** The public API returns newest-first; rendering wants source order.
32
+ * Default 'oldest' restores insertion order for migrated collections. */
33
+ order?: 'oldest' | 'newest';
34
+ /** Query filter forwarded to the public API (e.g. { slug: { $in: [...] } }). */
35
+ where?: Record<string, unknown>;
36
+ /** Row cap forwarded to the public API. */
37
+ limit?: number;
38
+ }): Promise<FimoEntry[]>;
39
+ /**
40
+ * Load the WrappedMedia entries (key → media) seeded by the wrap migration.
41
+ * Each entry has a `key` (the FimoMediaImage/Video/FileLink id) and an
42
+ * asset-typed `image` field.
43
+ */
44
+ export declare function loadWrappedMedia(options?: FimoServerOptions): Promise<Record<string, WrappedMediaEntry>>;
45
+ /**
46
+ * Load the WrappedRichText entries (key → TipTap JSON) seeded by the wrap
47
+ * migration for formatted text (bold/italic/underline/links).
48
+ */
49
+ export declare function loadWrappedRichText(options?: FimoServerOptions): Promise<Record<string, WrappedRichTextEntry>>;
50
+ /**
51
+ * Overlay a wrap-migrated collection onto its retained source rows: fetch the
52
+ * Fimo entries matching the source rows' keys, merge field-by-field with the
53
+ * type-matched rule above, and return plain data rows in SOURCE order. The
54
+ * page keeps its original render logic and its original fallback — edits made
55
+ * in Fimo show up, everything else stays byte-identical.
56
+ */
57
+ export declare function wrapCollection<T extends Record<string, unknown>>(typeName: string, sourceRows: readonly T[], options?: FimoServerOptions & {
58
+ keyField?: string;
59
+ }): Promise<T[]>;
60
+ /**
61
+ * Load a locale's messages from Fimo for an EXISTING i18n runtime (next-intl,
62
+ * i18next). Wrap-mode i18n ingestion seeds the app's message store into Fimo
63
+ * labels (flat dot-keys); this fetches them back and un-flattens them into the
64
+ * nested shape the app's own i18n loader expects — so the app keeps its
65
+ * `useTranslations`/`t()` unchanged, now editable from Fimo Studio.
66
+ *
67
+ * Deep-merge over the shipped messages (pass them as `fallback`) so any key
68
+ * not yet in Fimo falls back to the static file instead of showing a missing
69
+ * key. Wire it in the app's message loader, e.g. next-intl `i18n/request.ts`:
70
+ *
71
+ * const messages = await loadFimoMessages(locale, { fallback: staticMessages });
72
+ * return { locale, messages };
73
+ */
74
+ export declare function loadFimoMessages(locale: string, options?: FimoServerOptions & {
75
+ fallback?: Record<string, unknown>;
76
+ }): Promise<Record<string, unknown>>;
77
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/runtime/wrapped/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAMnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAUjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAsB,GAAG,UAAU,CAE1E;AAED,wBAAsB,cAAc,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAI7F;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,OAAO,GAAE,iBAAiB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,CAQpD;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAUD;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAiB,GAAG;IAC3B;8EAC0E;IAC1E,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CACX,GACL,OAAO,CAAC,SAAS,EAAE,CAAC,CA+BtB;AAUD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CA2BlH;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAiB/C;AAqCD;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,SAAS,CAAC,EAAE,EACxB,OAAO,GAAE,iBAAiB,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACtD,OAAO,CAAC,CAAC,EAAE,CAAC,CAoCd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAiB,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,GACvE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAelC"}
@@ -0,0 +1,237 @@
1
+ // Server-only loaders for WRAPPED (adopted) apps — framework-neutral.
2
+ // Content resolves at request time from the public tenant API (no Vite
3
+ // virtual modules, no build plugin). Framework adapters re-export these:
4
+ // fimo/next/server today, fimo/astro tomorrow — same loaders, same shapes.
5
+ import { getConfigServer } from '../shared/fimo-config.server.js';
6
+ import { deepMergeMessages, unflattenMessages } from '../shared/i18n-messages.js';
7
+ import { fetchLabelDictionary, fetchWithTimeout, labelSignature, loadLabelBundle, readProjectEnv, resolveTenantApiUrl, } from '../shared/labels-fetch.server.js';
8
+ export function loadFimoConfig(rootDir = process.cwd()) {
9
+ return getConfigServer(rootDir);
10
+ }
11
+ export async function loadFimoLabels(options = {}) {
12
+ const rootDir = options.rootDir ?? process.cwd();
13
+ const bundle = await loadLabelBundle(rootDir);
14
+ return { ...bundle, signature: labelSignature(bundle) };
15
+ }
16
+ /**
17
+ * Server-component label accessor: `useLabels()` is client-only, and forcing
18
+ * a client wrapper for one aria-label in a server component is not a
19
+ * migration, it is collateral damage. Load once per request scope and read
20
+ * synchronously: `const t = await loadFimoT(); <a aria-label={t('footer.github', 'GitHub')} …`.
21
+ */
22
+ export async function loadFimoT(options = {}) {
23
+ const labels = await loadFimoLabels(options);
24
+ const locale = options.locale ?? labels.defaultLocale;
25
+ const dictionary = labels.dictionaries[locale] ?? labels.dictionaries[labels.defaultLocale] ?? {};
26
+ return (key, fallback) => {
27
+ const value = dictionary[key];
28
+ return typeof value === 'string' && value.length > 0 ? value : fallback;
29
+ };
30
+ }
31
+ async function resolveApiUrl(options) {
32
+ if (options.apiUrl) {
33
+ return options.apiUrl;
34
+ }
35
+ const env = await readProjectEnv(options.rootDir ?? process.cwd());
36
+ return resolveTenantApiUrl(env);
37
+ }
38
+ /**
39
+ * Fetch published entries of a content type from the public tenant API.
40
+ * Returns [] when the API is unreachable so the wrapped site keeps rendering
41
+ * its fallbacks.
42
+ */
43
+ export async function fetchEntries(typeName, options = {}) {
44
+ const apiUrl = await resolveApiUrl(options);
45
+ if (!apiUrl) {
46
+ return [];
47
+ }
48
+ try {
49
+ const url = new URL(`/entries/${typeName}`, apiUrl);
50
+ if (options.where) {
51
+ url.searchParams.set('where', JSON.stringify(options.where));
52
+ }
53
+ if (options.limit) {
54
+ url.searchParams.set('limit', String(options.limit));
55
+ }
56
+ const response = await fetchWithTimeout(url, 4000);
57
+ if (!response.ok) {
58
+ return [];
59
+ }
60
+ const body = (await response.json());
61
+ const rows = Array.isArray(body.data) ? body.data : [];
62
+ const entries = rows
63
+ .filter((row) => Boolean(row) && typeof row === 'object')
64
+ .map((row) => ({
65
+ id: String(row.id ?? row.documentId ?? ''),
66
+ data: (row.data && typeof row.data === 'object' ? row.data : row),
67
+ }))
68
+ .filter((row) => row.id.length > 0);
69
+ return (options.order ?? 'oldest') === 'oldest' ? entries.reverse() : entries;
70
+ }
71
+ catch {
72
+ return [];
73
+ }
74
+ }
75
+ function readString(value) {
76
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
77
+ }
78
+ function readNumber(value) {
79
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
80
+ }
81
+ /**
82
+ * Load the WrappedMedia entries (key → media) seeded by the wrap migration.
83
+ * Each entry has a `key` (the FimoMediaImage/Video/FileLink id) and an
84
+ * asset-typed `image` field.
85
+ */
86
+ export async function loadWrappedMedia(options = {}) {
87
+ const entries = await fetchEntries('WrappedMedia', options);
88
+ const map = {};
89
+ for (const entry of entries) {
90
+ const key = readString(entry.data.key) ?? readString(entry.data.slug);
91
+ const asset = entry.data.image;
92
+ if (!key || !asset || typeof asset !== 'object') {
93
+ continue;
94
+ }
95
+ const assetRecord = asset;
96
+ const url = readString(assetRecord.url);
97
+ if (!url) {
98
+ continue;
99
+ }
100
+ map[key] = {
101
+ url,
102
+ alt: readString(assetRecord.alt) ?? readString(entry.data.alt),
103
+ name: readString(assetRecord.name),
104
+ mime: readString(assetRecord.mime) ?? readString(assetRecord.mimeType),
105
+ width: readNumber(assetRecord.width),
106
+ height: readNumber(assetRecord.height),
107
+ source: `WrappedMedia.${entry.id}.image`,
108
+ };
109
+ }
110
+ return map;
111
+ }
112
+ /**
113
+ * Load the WrappedRichText entries (key → TipTap JSON) seeded by the wrap
114
+ * migration for formatted text (bold/italic/underline/links).
115
+ */
116
+ export async function loadWrappedRichText(options = {}) {
117
+ const entries = await fetchEntries('WrappedRichText', options);
118
+ const map = {};
119
+ for (const entry of entries) {
120
+ const key = readString(entry.data.key) ?? readString(entry.data.slug);
121
+ const body = entry.data.body;
122
+ if (!key || !body || typeof body !== 'object') {
123
+ continue;
124
+ }
125
+ map[key] = {
126
+ content: body,
127
+ source: `WrappedRichText.${entry.id}.body`,
128
+ };
129
+ }
130
+ return map;
131
+ }
132
+ /** Key fields tried, in order, to align a source row with its Fimo entry. */
133
+ const COLLECTION_KEY_FIELDS = ['slug', 'id', 'key', 'name', 'title', 'question'];
134
+ /** Fimo entries fetched per collection: covers rendered windows and small
135
+ * collections entirely; rows beyond it keep rendering their source values. */
136
+ const COLLECTION_FETCH_CAP = 100;
137
+ function collectionKeyField(rows) {
138
+ for (const field of COLLECTION_KEY_FIELDS) {
139
+ if (rows.every((row) => typeof row[field] === 'string' && row[field].length > 0)) {
140
+ return field;
141
+ }
142
+ }
143
+ return null;
144
+ }
145
+ /** A Fimo value replaces its source value only when the SHAPES agree, so a
146
+ * page that rendered strings keeps rendering strings: media envelopes,
147
+ * richtext docs, reference handles, and nulls all fall back to the source
148
+ * value instead of leaking objects into JSX. */
149
+ function preferTypeMatched(fimoValue, sourceValue) {
150
+ if (fimoValue === null || fimoValue === undefined) {
151
+ return sourceValue;
152
+ }
153
+ if (Array.isArray(sourceValue)) {
154
+ if (!Array.isArray(fimoValue)) {
155
+ return sourceValue;
156
+ }
157
+ return fimoValue.every((element) => typeof element === typeof (sourceValue[0] ?? '') && typeof element !== 'object')
158
+ ? fimoValue
159
+ : sourceValue;
160
+ }
161
+ return typeof fimoValue === typeof sourceValue && typeof fimoValue !== 'object' ? fimoValue : sourceValue;
162
+ }
163
+ /**
164
+ * Overlay a wrap-migrated collection onto its retained source rows: fetch the
165
+ * Fimo entries matching the source rows' keys, merge field-by-field with the
166
+ * type-matched rule above, and return plain data rows in SOURCE order. The
167
+ * page keeps its original render logic and its original fallback — edits made
168
+ * in Fimo show up, everything else stays byte-identical.
169
+ */
170
+ export async function wrapCollection(typeName, sourceRows, options = {}) {
171
+ const rows = sourceRows;
172
+ if (rows.length === 0) {
173
+ return [];
174
+ }
175
+ const keyField = options.keyField ?? collectionKeyField(rows);
176
+ if (!keyField) {
177
+ return sourceRows;
178
+ }
179
+ const keys = rows.slice(0, COLLECTION_FETCH_CAP).map((row) => row[keyField]);
180
+ const entries = await fetchEntries(typeName, {
181
+ ...options,
182
+ where: { [keyField]: { $in: keys } },
183
+ limit: keys.length,
184
+ });
185
+ if (entries.length === 0) {
186
+ return sourceRows;
187
+ }
188
+ const byKey = new Map();
189
+ for (const entry of entries) {
190
+ const key = entry.data[keyField];
191
+ if (typeof key === 'string' && !byKey.has(key)) {
192
+ byKey.set(key, entry.data);
193
+ }
194
+ }
195
+ return rows.map((row) => {
196
+ const fimoRow = byKey.get(row[keyField]);
197
+ if (!fimoRow) {
198
+ return row;
199
+ }
200
+ const merged = { ...row };
201
+ for (const field of Object.keys(row)) {
202
+ merged[field] = preferTypeMatched(fimoRow[field], row[field]);
203
+ }
204
+ return merged;
205
+ });
206
+ }
207
+ /**
208
+ * Load a locale's messages from Fimo for an EXISTING i18n runtime (next-intl,
209
+ * i18next). Wrap-mode i18n ingestion seeds the app's message store into Fimo
210
+ * labels (flat dot-keys); this fetches them back and un-flattens them into the
211
+ * nested shape the app's own i18n loader expects — so the app keeps its
212
+ * `useTranslations`/`t()` unchanged, now editable from Fimo Studio.
213
+ *
214
+ * Deep-merge over the shipped messages (pass them as `fallback`) so any key
215
+ * not yet in Fimo falls back to the static file instead of showing a missing
216
+ * key. Wire it in the app's message loader, e.g. next-intl `i18n/request.ts`:
217
+ *
218
+ * const messages = await loadFimoMessages(locale, { fallback: staticMessages });
219
+ * return { locale, messages };
220
+ */
221
+ export async function loadFimoMessages(locale, options = {}) {
222
+ const fallback = options.fallback ?? {};
223
+ const apiUrl = await resolveApiUrl(options);
224
+ if (!apiUrl) {
225
+ return fallback;
226
+ }
227
+ try {
228
+ const { labels } = await fetchLabelDictionary(apiUrl, locale);
229
+ if (Object.keys(labels).length === 0) {
230
+ return fallback;
231
+ }
232
+ return deepMergeMessages(fallback, unflattenMessages(labels));
233
+ }
234
+ catch {
235
+ return fallback;
236
+ }
237
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.test.d.ts","sourceRoot":"","sources":["../../../src/runtime/wrapped/server.test.ts"],"names":[],"mappings":""}