fimo 0.8.0 → 0.9.0-experimental.2

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 (190) hide show
  1. package/assets/content-templates/hooks-template.eta +4 -2
  2. package/assets/content-templates/types-template.eta +66 -1
  3. package/assets/skills/fimo/SKILL.md +1 -1
  4. package/assets/skills/fimo/references/content.md +86 -15
  5. package/assets/skills/fimo-cli/SKILL.md +6 -2
  6. package/assets/skills/fimo-cli/references/content.md +61 -2
  7. package/assets/skills/fimo-cli/references/integrations/firecrawl.md +20 -4
  8. package/assets/skills/fimo-cli/references/integrations.md +5 -1
  9. package/assets/skills/fimo-cli/references/webhooks.md +162 -0
  10. package/assets/skills/fimo-migration/SKILL.md +22 -2
  11. package/assets/skills/fimo-migration/references/content.md +24 -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/SKILL.md +5 -3
  17. package/assets/skills/fimo-studio/references/cms.md +9 -1
  18. package/assets/skills/fimo-studio/references/visual-editing.md +5 -3
  19. package/assets/skills/fimo-studio/references/webhooks.md +42 -0
  20. package/dist/build/vite/plugins/translations.d.ts +2 -8
  21. package/dist/build/vite/plugins/translations.js +3 -121
  22. package/dist/cli/bundle.json +1 -1
  23. package/dist/cli/index.js +1051 -144
  24. package/dist/runtime/app/FimoProviders.d.ts +1 -11
  25. package/dist/runtime/app/FimoProviders.js +2 -23
  26. package/dist/runtime/astro/index.d.ts +2 -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.js +6 -0
  30. package/dist/runtime/content/client/internal.js +1 -0
  31. package/dist/runtime/content/client/types.d.ts +16 -0
  32. package/dist/runtime/i18n/FimoLocaleContext.js +1 -0
  33. package/dist/runtime/next/FimoNextProviders.d.ts +24 -0
  34. package/dist/runtime/next/FimoNextProviders.js +20 -0
  35. package/dist/runtime/next/FimoNextScripts.d.ts +10 -0
  36. package/dist/runtime/next/FimoNextScripts.js +19 -0
  37. package/dist/runtime/next/index.d.ts +14 -0
  38. package/dist/runtime/next/index.js +14 -0
  39. package/dist/runtime/next/server.d.ts +2 -0
  40. package/dist/runtime/next/server.js +4 -0
  41. package/dist/runtime/nuxt/composables.d.ts +9 -0
  42. package/dist/runtime/nuxt/composables.js +57 -0
  43. package/dist/runtime/nuxt/index.d.ts +3 -0
  44. package/dist/runtime/nuxt/index.js +6 -0
  45. package/dist/runtime/nuxt/server.d.ts +3 -0
  46. package/dist/runtime/nuxt/server.js +6 -0
  47. package/dist/runtime/primitives/labels-hook.d.ts +33 -0
  48. package/dist/runtime/primitives/labels-hook.js +41 -0
  49. package/dist/runtime/primitives/labels-store.d.ts +12 -0
  50. package/dist/runtime/primitives/labels-store.js +60 -0
  51. package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts +5 -3
  52. package/dist/runtime/primitives/lib/useFimoLiveValue.js +11 -4
  53. package/dist/runtime/primitives/translations.d.ts +1 -27
  54. package/dist/runtime/primitives/translations.js +7 -85
  55. package/dist/runtime/react/FimoSpaProviders.d.ts +36 -0
  56. package/dist/runtime/react/FimoSpaProviders.js +63 -0
  57. package/dist/runtime/react/index.d.ts +33 -0
  58. package/dist/runtime/react/index.js +39 -0
  59. package/dist/runtime/remix/FimoRemixProviders.d.ts +16 -0
  60. package/dist/runtime/remix/FimoRemixProviders.js +12 -0
  61. package/dist/runtime/remix/FimoRemixScripts.d.ts +10 -0
  62. package/dist/runtime/remix/FimoRemixScripts.js +19 -0
  63. package/dist/runtime/remix/index.d.ts +12 -0
  64. package/dist/runtime/remix/index.js +11 -0
  65. package/dist/runtime/remix/server.d.ts +2 -0
  66. package/dist/runtime/remix/server.js +2 -0
  67. package/dist/runtime/shared/display-routes.d.ts +14 -0
  68. package/dist/runtime/shared/display-routes.js +25 -0
  69. package/dist/runtime/shared/fimo-config.server.js +1 -0
  70. package/dist/runtime/shared/fimo-config.types.d.ts +2 -0
  71. package/dist/runtime/shared/i18n-messages.d.ts +29 -0
  72. package/dist/runtime/shared/i18n-messages.js +79 -0
  73. package/dist/runtime/shared/labels-fetch.pure.d.ts +17 -0
  74. package/dist/runtime/shared/labels-fetch.pure.js +71 -0
  75. package/dist/runtime/shared/labels-fetch.server.d.ts +7 -0
  76. package/dist/runtime/shared/labels-fetch.server.js +97 -0
  77. package/dist/runtime/shared/labels-t.pure.d.ts +2 -0
  78. package/dist/runtime/shared/labels-t.pure.js +10 -0
  79. package/dist/runtime/strapi/client.d.ts +30 -0
  80. package/dist/runtime/strapi/client.js +89 -0
  81. package/dist/runtime/strapi/index.d.ts +5 -0
  82. package/dist/runtime/strapi/index.js +6 -0
  83. package/dist/runtime/strapi/reshape.d.ts +46 -0
  84. package/dist/runtime/strapi/reshape.js +114 -0
  85. package/dist/runtime/svelte/index.d.ts +3 -0
  86. package/dist/runtime/svelte/index.js +7 -0
  87. package/dist/runtime/svelte/server.d.ts +3 -0
  88. package/dist/runtime/svelte/server.js +6 -0
  89. package/dist/runtime/vue/index.d.ts +3 -0
  90. package/dist/runtime/vue/index.js +5 -0
  91. package/dist/runtime/vue/server.d.ts +3 -0
  92. package/dist/runtime/vue/server.js +6 -0
  93. package/dist/runtime/wrapped/FimoFileLink.d.ts +17 -0
  94. package/dist/runtime/wrapped/FimoFileLink.js +19 -0
  95. package/dist/runtime/wrapped/FimoMediaImage.d.ts +14 -0
  96. package/dist/runtime/wrapped/FimoMediaImage.js +20 -0
  97. package/dist/runtime/wrapped/FimoMediaVideo.d.ts +14 -0
  98. package/dist/runtime/wrapped/FimoMediaVideo.js +20 -0
  99. package/dist/runtime/wrapped/FimoRichTextBlock.d.ts +23 -0
  100. package/dist/runtime/wrapped/FimoRichTextBlock.js +22 -0
  101. package/dist/runtime/wrapped/FimoText.d.ts +22 -0
  102. package/dist/runtime/wrapped/FimoText.js +20 -0
  103. package/dist/runtime/wrapped/WrappedContentContext.d.ts +28 -0
  104. package/dist/runtime/wrapped/WrappedContentContext.js +30 -0
  105. package/dist/runtime/wrapped/WrappedProviders.d.ts +33 -0
  106. package/dist/runtime/wrapped/WrappedProviders.js +101 -0
  107. package/dist/runtime/wrapped/dom.d.ts +4 -0
  108. package/dist/runtime/wrapped/dom.js +23 -0
  109. package/dist/runtime/wrapped/server.d.ts +77 -0
  110. package/dist/runtime/wrapped/server.js +237 -0
  111. package/dist/scripts/apply-wrap-templates.d.ts +61 -0
  112. package/dist/scripts/apply-wrap-templates.js +132 -0
  113. package/dist/scripts/apply-wrap.d.ts +46 -0
  114. package/dist/scripts/apply-wrap.js +278 -0
  115. package/dist/scripts/cms/discover.d.ts +2 -0
  116. package/dist/scripts/cms/discover.js +17 -0
  117. package/dist/scripts/cms/example-content.d.ts +33 -0
  118. package/dist/scripts/cms/example-content.js +163 -0
  119. package/dist/scripts/cms/strapi/detect.d.ts +2 -0
  120. package/dist/scripts/cms/strapi/detect.js +186 -0
  121. package/dist/scripts/cms/strapi/index.d.ts +3 -0
  122. package/dist/scripts/cms/strapi/index.js +25 -0
  123. package/dist/scripts/cms/strapi/list-source.d.ts +17 -0
  124. package/dist/scripts/cms/strapi/list-source.js +90 -0
  125. package/dist/scripts/cms/strapi/schema-map.d.ts +9 -0
  126. package/dist/scripts/cms/strapi/schema-map.js +279 -0
  127. package/dist/scripts/cms/strapi/shapes.d.ts +23 -0
  128. package/dist/scripts/cms/strapi/shapes.js +38 -0
  129. package/dist/scripts/cms/strapi/touchpoints.d.ts +31 -0
  130. package/dist/scripts/cms/strapi/touchpoints.js +145 -0
  131. package/dist/scripts/cms/strapi/wire-client.d.ts +15 -0
  132. package/dist/scripts/cms/strapi/wire-client.js +107 -0
  133. package/dist/scripts/cms/strapi/wiring.d.ts +17 -0
  134. package/dist/scripts/cms/strapi/wiring.js +46 -0
  135. package/dist/scripts/cms/types.d.ts +145 -0
  136. package/dist/scripts/cms/types.js +11 -0
  137. package/dist/scripts/detect-framework.d.ts +39 -0
  138. package/dist/scripts/detect-framework.js +133 -0
  139. package/dist/scripts/draft-rows.d.ts +19 -0
  140. package/dist/scripts/draft-rows.js +135 -0
  141. package/dist/scripts/draft-schemas.d.ts +27 -0
  142. package/dist/scripts/draft-schemas.js +188 -0
  143. package/dist/scripts/extract-translations.js +16 -11
  144. package/dist/scripts/frameworks/astro/routes.d.ts +3 -0
  145. package/dist/scripts/frameworks/astro/routes.js +55 -0
  146. package/dist/scripts/frameworks/astro/template-style.d.ts +7 -0
  147. package/dist/scripts/frameworks/astro/template-style.js +19 -0
  148. package/dist/scripts/frameworks/discover.d.ts +70 -0
  149. package/dist/scripts/frameworks/discover.js +178 -0
  150. package/dist/scripts/frameworks/next/rewire.d.ts +30 -0
  151. package/dist/scripts/frameworks/next/rewire.js +258 -0
  152. package/dist/scripts/frameworks/next/routes.d.ts +17 -0
  153. package/dist/scripts/frameworks/next/routes.js +134 -0
  154. package/dist/scripts/frameworks/next/wiring.d.ts +33 -0
  155. package/dist/scripts/frameworks/next/wiring.js +186 -0
  156. package/dist/scripts/frameworks/nuxt/routes.d.ts +3 -0
  157. package/dist/scripts/frameworks/nuxt/routes.js +54 -0
  158. package/dist/scripts/frameworks/nuxt/template-style.d.ts +9 -0
  159. package/dist/scripts/frameworks/nuxt/template-style.js +27 -0
  160. package/dist/scripts/frameworks/remix/routes.d.ts +3 -0
  161. package/dist/scripts/frameworks/remix/routes.js +50 -0
  162. package/dist/scripts/frameworks/support.d.ts +75 -0
  163. package/dist/scripts/frameworks/support.js +165 -0
  164. package/dist/scripts/frameworks/sveltekit/routes.d.ts +3 -0
  165. package/dist/scripts/frameworks/sveltekit/routes.js +50 -0
  166. package/dist/scripts/frameworks/sveltekit/template-style.d.ts +9 -0
  167. package/dist/scripts/frameworks/sveltekit/template-style.js +54 -0
  168. package/dist/scripts/frameworks/vite/routes.d.ts +15 -0
  169. package/dist/scripts/frameworks/vite/routes.js +93 -0
  170. package/dist/scripts/frameworks/vite/wiring.d.ts +10 -0
  171. package/dist/scripts/frameworks/vite/wiring.js +99 -0
  172. package/dist/scripts/i18n-namespace.d.ts +27 -0
  173. package/dist/scripts/i18n-namespace.js +155 -0
  174. package/dist/scripts/lib/validation-report.d.ts +1 -0
  175. package/dist/scripts/lib/validation-report.js +3 -0
  176. package/dist/scripts/render-parity/capture.d.ts +56 -0
  177. package/dist/scripts/render-parity/capture.js +366 -0
  178. package/dist/scripts/render-parity/compare.d.ts +59 -0
  179. package/dist/scripts/render-parity/compare.js +0 -0
  180. package/dist/scripts/render-parity/normalize-html.d.ts +13 -0
  181. package/dist/scripts/render-parity/normalize-html.js +223 -0
  182. package/dist/scripts/render-parity/types.d.ts +41 -0
  183. package/dist/scripts/render-parity/types.js +1 -0
  184. package/dist/scripts/scan-wrappable.d.ts +196 -0
  185. package/dist/scripts/scan-wrappable.js +1232 -0
  186. package/dist/scripts/validate-route-metadata.js +11 -0
  187. package/dist/scripts/validate-schemas.js +42 -1
  188. package/package.json +84 -4
  189. package/release.json +2 -2
  190. package/templates/react-router/package.json +1 -1
@@ -1,61 +1,14 @@
1
- import { useSyncExternalStore } from 'react';
1
+ // Vite flavor of the label layer: hydrates the framework-neutral store from
2
+ // the `virtual:translations` module (fimo/vite labels plugin) and wires HMR.
3
+ // Framework-agnostic consumers use ./labels-store.ts + ./labels-hook.ts.
2
4
  import { defaultLocale as bundledDefaultLocale, dictionaries as bundledDictionaries, signature as translationSignature, updatedAt as bundledUpdatedAt, } from 'virtual:translations';
3
- import { useLocale } from '../i18n/FimoLocaleContext.js';
4
- import { FimoString } from './lib/index.js';
5
- const labelListeners = new Set();
6
- let labelState = {
5
+ import { applyLabelUpdate, hydrateLabels } from './labels-store.js';
6
+ hydrateLabels({
7
7
  dictionaries: bundledDictionaries ?? {},
8
8
  defaultLocale: bundledDefaultLocale || 'en',
9
9
  signature: translationSignature,
10
10
  updatedAt: bundledUpdatedAt ?? null,
11
- };
12
- function subscribeLabels(listener) {
13
- labelListeners.add(listener);
14
- return () => {
15
- labelListeners.delete(listener);
16
- };
17
- }
18
- function getLabelSnapshot() {
19
- return labelState;
20
- }
21
- function setLabelState(next) {
22
- if (next.signature === labelState.signature) {
23
- return;
24
- }
25
- labelState = next;
26
- for (const listener of labelListeners) {
27
- listener();
28
- }
29
- }
30
- function isRecord(value) {
31
- return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
32
- }
33
- function normalizeDictionaries(value) {
34
- if (!isRecord(value)) {
35
- return null;
36
- }
37
- const dictionaries = {};
38
- for (const [locale, labels] of Object.entries(value)) {
39
- if (!isRecord(labels)) {
40
- continue;
41
- }
42
- dictionaries[locale] = Object.fromEntries(Object.entries(labels).filter((entry) => typeof entry[1] === 'string'));
43
- }
44
- return dictionaries;
45
- }
46
- function applyLabelUpdate(payload) {
47
- if (!isRecord(payload)) {
48
- return;
49
- }
50
- const dictionaries = normalizeDictionaries(payload.dictionaries);
51
- if (!dictionaries) {
52
- return;
53
- }
54
- const defaultLocale = typeof payload.defaultLocale === 'string' ? payload.defaultLocale : labelState.defaultLocale;
55
- const signature = typeof payload.signature === 'string' ? payload.signature : JSON.stringify({ dictionaries, defaultLocale });
56
- const updatedAt = typeof payload.updatedAt === 'string' ? payload.updatedAt : null;
57
- setLabelState({ dictionaries, defaultLocale, signature, updatedAt });
58
- }
11
+ });
59
12
  // @ts-ignore - import.meta.hot is provided by Vite during development.
60
13
  if (import.meta.hot) {
61
14
  const onLabelsUpdated = (payload) => {
@@ -69,35 +22,4 @@ if (import.meta.hot) {
69
22
  import.meta.hot.off('fimo:labels-updated', onLabelsUpdated);
70
23
  });
71
24
  }
72
- /**
73
- * Hook to provide a label function (`t`).
74
- *
75
- * Returns FimoString with source tracking for inline editing.
76
- * Use with <Text> component for rendering, or String() for escape hatch.
77
- *
78
- * @example
79
- * const { t } = useLabels();
80
- *
81
- * // With Text component (recommended)
82
- * <Text value={t('welcome')} />
83
- *
84
- * // Escape hatch for attributes
85
- * <input placeholder={String(t('email.placeholder'))} />
86
- */
87
- export function useLabels() {
88
- const localeContext = useLocale();
89
- const labels = useSyncExternalStore(subscribeLabels, getLabelSnapshot, getLabelSnapshot);
90
- const t = (fullKey) => {
91
- const locale = localeContext.locale || labels.defaultLocale || 'en';
92
- const dictionary = labels.dictionaries[locale] ?? labels.dictionaries[labels.defaultLocale] ?? {};
93
- const text = dictionary[fullKey] ?? '';
94
- return new FimoString(text, `__labels.${locale}.${fullKey}.value`);
95
- };
96
- return { t, locale: localeContext.locale };
97
- }
98
- /**
99
- * Legacy alias for older projects. Prefer useLabels() in new code.
100
- */
101
- export function useTranslations() {
102
- return useLabels();
103
- }
25
+ export { useLabels, useTranslations } from './labels-hook.js';
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import type { FimoConfig } from '../shared/fimo-config.types.js';
3
+ import type { WrappedMediaEntry, WrappedRichTextEntry } from '../wrapped/WrappedContentContext.js';
4
+ export interface FimoSpaProvidersProps {
5
+ /** The project's fimo-config.json — import it directly: `import config from '../fimo-config.json'`. */
6
+ config: FimoConfig;
7
+ /** Tenant API base URL, e.g. `import.meta.env.VITE_API_URL`. Without it, wrapped values render their inline fallbacks. */
8
+ apiUrl?: string;
9
+ /** Preview client script for Fimo Studio edit mode. Pass only in dev, e.g. `import.meta.env.DEV ? import.meta.env.VITE_FIMO_PREVIEW_SCRIPT_URL : undefined`. */
10
+ previewScriptUrl?: string;
11
+ media?: Record<string, WrappedMediaEntry>;
12
+ richText?: Record<string, WrappedRichTextEntry>;
13
+ locale?: string;
14
+ children?: React.ReactNode;
15
+ }
16
+ /**
17
+ * Fimo providers for wrapped CLIENT-RENDERED React apps (Vite SPAs). There is
18
+ * no server pass to load labels in, so this adapter fetches the dictionary in
19
+ * the browser and hydrates the framework-neutral WrappedProviders; until the
20
+ * fetch resolves (or when it fails), every wrapped value renders its inline
21
+ * fallback — the original hardcoded string. Mount once around the app root:
22
+ *
23
+ * import config from '../fimo-config.json';
24
+ * <FimoSpaProviders
25
+ * config={config}
26
+ * apiUrl={import.meta.env.VITE_API_URL}
27
+ * previewScriptUrl={import.meta.env.DEV ? import.meta.env.VITE_FIMO_PREVIEW_SCRIPT_URL : undefined}
28
+ * >
29
+ * <App />
30
+ * </FimoSpaProviders>
31
+ *
32
+ * Navigation is History-API based (full page load): correct for any SPA
33
+ * router without depending on one.
34
+ */
35
+ export declare function FimoSpaProviders({ config, apiUrl, previewScriptUrl, media, richText, locale, children, }: FimoSpaProvidersProps): import("react/jsx-runtime").JSX.Element;
36
+ //# sourceMappingURL=FimoSpaProviders.d.ts.map
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useState } from 'react';
4
+ import { getFimoDefaultLocale, getFimoLocales } from '../i18n/locale.js';
5
+ import { fetchLabelBundle, serializeBundle } from '../shared/labels-fetch.pure.js';
6
+ import { WrappedProviders } from '../wrapped/WrappedProviders.js';
7
+ /** Browser-safe stable signature (labelSignature uses Buffer, server-only). */
8
+ function bundleSignature(bundle) {
9
+ const serialized = serializeBundle(bundle);
10
+ let hash = 5381;
11
+ for (let i = 0; i < serialized.length; i++) {
12
+ hash = ((hash << 5) + hash + serialized.charCodeAt(i)) | 0;
13
+ }
14
+ return `spa-${hash}`;
15
+ }
16
+ /**
17
+ * Fimo providers for wrapped CLIENT-RENDERED React apps (Vite SPAs). There is
18
+ * no server pass to load labels in, so this adapter fetches the dictionary in
19
+ * the browser and hydrates the framework-neutral WrappedProviders; until the
20
+ * fetch resolves (or when it fails), every wrapped value renders its inline
21
+ * fallback — the original hardcoded string. Mount once around the app root:
22
+ *
23
+ * import config from '../fimo-config.json';
24
+ * <FimoSpaProviders
25
+ * config={config}
26
+ * apiUrl={import.meta.env.VITE_API_URL}
27
+ * previewScriptUrl={import.meta.env.DEV ? import.meta.env.VITE_FIMO_PREVIEW_SCRIPT_URL : undefined}
28
+ * >
29
+ * <App />
30
+ * </FimoSpaProviders>
31
+ *
32
+ * Navigation is History-API based (full page load): correct for any SPA
33
+ * router without depending on one.
34
+ */
35
+ export function FimoSpaProviders({ config, apiUrl, previewScriptUrl, media, richText, locale, children, }) {
36
+ const [labels, setLabels] = useState(undefined);
37
+ useEffect(() => {
38
+ if (!apiUrl) {
39
+ return;
40
+ }
41
+ let cancelled = false;
42
+ const defaultLocale = getFimoDefaultLocale(config);
43
+ fetchLabelBundle(apiUrl, getFimoLocales(config), defaultLocale)
44
+ .then((bundle) => {
45
+ if (!cancelled) {
46
+ setLabels({ ...bundle, signature: bundleSignature(bundle) });
47
+ }
48
+ })
49
+ .catch(() => {
50
+ // Unreachable API: keep rendering the inline fallbacks.
51
+ });
52
+ return () => {
53
+ cancelled = true;
54
+ };
55
+ }, [apiUrl, config]);
56
+ const navigation = useMemo(() => ({
57
+ pathname: typeof window !== 'undefined' ? window.location.pathname : null,
58
+ navigate: (to) => {
59
+ window.location.assign(to);
60
+ },
61
+ }), []);
62
+ return (_jsxs(WrappedProviders, { config: config, labels: labels, media: media, richText: richText, locale: locale, navigation: navigation, children: [previewScriptUrl ? _jsx("script", { type: "module", src: previewScriptUrl }) : null, children] }));
63
+ }
@@ -0,0 +1,33 @@
1
+ export { Text } from '../primitives/components/Text.js';
2
+ export { Image } from '../primitives/components/Image.js';
3
+ export { StaticImage } from '../primitives/components/StaticImage.js';
4
+ export { Video } from '../primitives/components/Video.js';
5
+ export { Date } from '../primitives/components/Date.js';
6
+ export { Boolean } from '../primitives/components/Boolean.js';
7
+ export { RichText } from '../primitives/components/RichText.js';
8
+ export { useLabels, useTranslations } from '../primitives/labels-hook.js';
9
+ export { applyLabelUpdate, getLabelSnapshot, hydrateLabels, subscribeLabels } from '../primitives/labels-store.js';
10
+ export type { LabelState } from '../primitives/labels-store.js';
11
+ export { FimoText } from '../wrapped/FimoText.js';
12
+ export { FimoRichTextBlock } from '../wrapped/FimoRichTextBlock.js';
13
+ export { FimoMediaImage } from '../wrapped/FimoMediaImage.js';
14
+ export { FimoMediaVideo } from '../wrapped/FimoMediaVideo.js';
15
+ export { FimoFileLink } from '../wrapped/FimoFileLink.js';
16
+ export { useWrappedMedia, useWrappedRichText } from '../wrapped/WrappedContentContext.js';
17
+ export type { WrappedMediaEntry, WrappedRichTextEntry } from '../wrapped/WrappedContentContext.js';
18
+ export { FimoSpaProviders } from './FimoSpaProviders.js';
19
+ export type { FimoSpaProvidersProps } from './FimoSpaProviders.js';
20
+ export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoSource, type FimoPart, type FimoRichTextContent, type FimoRichTextNodeProps, type FimoRichTextMarkProps, type FimoRichTextComponents, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, } from '../primitives/lib/index.js';
21
+ export { fimo } from '../primitives/lib/template.js';
22
+ export { useFimoLiveValue } from '../primitives/lib/useFimoLiveValue.js';
23
+ export { DataSourcesProvider } from '../content/DataSourcesProvider.js';
24
+ export { ConsoleErrorProvider } from '../iframe/ConsoleErrorProvider.js';
25
+ export { ScreenshotProvider } from '../iframe/ScreenshotProvider.js';
26
+ export { FimoLocaleProvider, useLocale } from '../i18n/FimoLocaleContext.js';
27
+ export type { FimoLocaleContextValue } from '../i18n/FimoLocaleContext.js';
28
+ export { getFimoDefaultLocale, getFimoLocales, getFimoTextDirection, localizeFimoPath, resolveFimoLocale, toHtmlLang, } from '../i18n/locale.js';
29
+ export type { FimoLocaleResolution } from '../i18n/locale.js';
30
+ export { getDisplayRoutes } from '../shared/display-routes.js';
31
+ export type { DisplayRoute, ParamInfo } from '../shared/display-routes.js';
32
+ export type { FimoConfig, FimoRouteConfig, FimoSEO } from '../shared/fimo-config.types.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,39 @@
1
+ // fimo/react — the framework-agnostic React core of the Fimo runtime.
2
+ // No Vite virtual modules, no react-router, no bundler assumptions:
3
+ // per-framework adapters (fimo/react-router via fimo/ui, fimo/next, ...)
4
+ // build on this surface.
5
+ // Inline-editing components
6
+ export { Text } from '../primitives/components/Text.js';
7
+ export { Image } from '../primitives/components/Image.js';
8
+ export { StaticImage } from '../primitives/components/StaticImage.js';
9
+ export { Video } from '../primitives/components/Video.js';
10
+ export { Date } from '../primitives/components/Date.js';
11
+ export { Boolean } from '../primitives/components/Boolean.js';
12
+ export { RichText } from '../primitives/components/RichText.js';
13
+ // Labels (framework-neutral store + hook; adapters hydrate the store)
14
+ export { useLabels, useTranslations } from '../primitives/labels-hook.js';
15
+ export { applyLabelUpdate, getLabelSnapshot, hydrateLabels, subscribeLabels } from '../primitives/labels-store.js';
16
+ // Wrapped-site primitives (the --apply codemod imports these from fimo/react
17
+ // in Vite React SPAs) + the client-side providers that hydrate them. All are
18
+ // fallback-safe without a provider: FimoText renders its children, media
19
+ // elements render their original src.
20
+ export { FimoText } from '../wrapped/FimoText.js';
21
+ export { FimoRichTextBlock } from '../wrapped/FimoRichTextBlock.js';
22
+ export { FimoMediaImage } from '../wrapped/FimoMediaImage.js';
23
+ export { FimoMediaVideo } from '../wrapped/FimoMediaVideo.js';
24
+ export { FimoFileLink } from '../wrapped/FimoFileLink.js';
25
+ export { useWrappedMedia, useWrappedRichText } from '../wrapped/WrappedContentContext.js';
26
+ export { FimoSpaProviders } from './FimoSpaProviders.js';
27
+ // Source-tracking primitives & utilities
28
+ export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, } from '../primitives/lib/index.js';
29
+ export { fimo } from '../primitives/lib/template.js';
30
+ export { useFimoLiveValue } from '../primitives/lib/useFimoLiveValue.js';
31
+ // Preview/editor bridge providers (postMessage-based, framework-free)
32
+ export { DataSourcesProvider } from '../content/DataSourcesProvider.js';
33
+ export { ConsoleErrorProvider } from '../iframe/ConsoleErrorProvider.js';
34
+ export { ScreenshotProvider } from '../iframe/ScreenshotProvider.js';
35
+ // Locale
36
+ export { FimoLocaleProvider, useLocale } from '../i18n/FimoLocaleContext.js';
37
+ export { getFimoDefaultLocale, getFimoLocales, getFimoTextDirection, localizeFimoPath, resolveFimoLocale, toHtmlLang, } from '../i18n/locale.js';
38
+ // Config + routes
39
+ export { getDisplayRoutes } from '../shared/display-routes.js';
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import type { FimoConfig } from '../shared/fimo-config.types.js';
3
+ import type { WrappedMediaEntry, WrappedRichTextEntry } from '../wrapped/WrappedContentContext.js';
4
+ import { type WrappedLabels } from '../wrapped/WrappedProviders.js';
5
+ export type FimoRemixLabels = WrappedLabels;
6
+ export interface FimoRemixProvidersProps {
7
+ config: FimoConfig;
8
+ labels?: FimoRemixLabels;
9
+ media?: Record<string, WrappedMediaEntry>;
10
+ richText?: Record<string, WrappedRichTextEntry>;
11
+ locale?: string;
12
+ children?: React.ReactNode;
13
+ }
14
+ /** Fimo providers for wrapped Remix apps — mount once in app/root.tsx. */
15
+ export declare function FimoRemixProviders(props: FimoRemixProvidersProps): import("react/jsx-runtime").JSX.Element;
16
+ //# sourceMappingURL=FimoRemixProviders.d.ts.map
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useLocation, useNavigate } from '@remix-run/react';
4
+ import { useMemo } from 'react';
5
+ import { WrappedProviders } from '../wrapped/WrappedProviders.js';
6
+ /** Fimo providers for wrapped Remix apps — mount once in app/root.tsx. */
7
+ export function FimoRemixProviders(props) {
8
+ const location = useLocation();
9
+ const navigate = useNavigate();
10
+ const navigation = useMemo(() => ({ pathname: location.pathname, navigate: (to) => navigate(to) }), [location.pathname, navigate]);
11
+ return _jsx(WrappedProviders, { ...props, navigation: navigation });
12
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Renders the Fimo preview client script in development so the Fimo Studio
3
+ * preview can select/edit elements. Mount inside <head> in the root layout.
4
+ *
5
+ * The script URL comes from FIMO_PREVIEW_SCRIPT_URL (written by
6
+ * `fimo init` for wrapped projects, pointing at `<apiUrl>/preview.js`).
7
+ * Renders nothing in production builds.
8
+ */
9
+ export declare function FimoRemixScripts(): import("react/jsx-runtime").JSX.Element | null;
10
+ //# sourceMappingURL=FimoRemixScripts.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Renders the Fimo preview client script in development so the Fimo Studio
4
+ * preview can select/edit elements. Mount inside <head> in the root layout.
5
+ *
6
+ * The script URL comes from FIMO_PREVIEW_SCRIPT_URL (written by
7
+ * `fimo init` for wrapped projects, pointing at `<apiUrl>/preview.js`).
8
+ * Renders nothing in production builds.
9
+ */
10
+ export function FimoRemixScripts() {
11
+ if (process.env.NODE_ENV !== 'development') {
12
+ return null;
13
+ }
14
+ const previewScriptUrl = process.env.FIMO_PREVIEW_SCRIPT_URL;
15
+ if (!previewScriptUrl) {
16
+ return null;
17
+ }
18
+ return _jsx("script", { type: "module", src: previewScriptUrl });
19
+ }
@@ -0,0 +1,12 @@
1
+ export { FimoRemixProviders } from './FimoRemixProviders.js';
2
+ export type { FimoRemixLabels, FimoRemixProvidersProps } from './FimoRemixProviders.js';
3
+ export { FimoRemixScripts } from './FimoRemixScripts.js';
4
+ export { FimoText } from '../wrapped/FimoText.js';
5
+ export { FimoRichTextBlock } from '../wrapped/FimoRichTextBlock.js';
6
+ export { FimoMediaImage } from '../wrapped/FimoMediaImage.js';
7
+ export { FimoMediaVideo } from '../wrapped/FimoMediaVideo.js';
8
+ export { FimoFileLink } from '../wrapped/FimoFileLink.js';
9
+ export { useWrappedMedia, useWrappedRichText } from '../wrapped/WrappedContentContext.js';
10
+ export type { WrappedMediaEntry, WrappedRichTextEntry } from '../wrapped/WrappedContentContext.js';
11
+ export { useLabels } from '../primitives/labels-hook.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ // fimo/remix — the Remix adapter. Framework-neutral pieces live in
2
+ // ../wrapped and are re-exported; this module only adds the Remix wiring.
3
+ export { FimoRemixProviders } from './FimoRemixProviders.js';
4
+ export { FimoRemixScripts } from './FimoRemixScripts.js';
5
+ export { FimoText } from '../wrapped/FimoText.js';
6
+ export { FimoRichTextBlock } from '../wrapped/FimoRichTextBlock.js';
7
+ export { FimoMediaImage } from '../wrapped/FimoMediaImage.js';
8
+ export { FimoMediaVideo } from '../wrapped/FimoMediaVideo.js';
9
+ export { FimoFileLink } from '../wrapped/FimoFileLink.js';
10
+ export { useWrappedMedia, useWrappedRichText } from '../wrapped/WrappedContentContext.js';
11
+ export { useLabels } from '../primitives/labels-hook.js';
@@ -0,0 +1,2 @@
1
+ export * from '../wrapped/server.js';
2
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,2 @@
1
+ // fimo/remix/server — same framework-neutral loaders as every adapter.
2
+ export * from '../wrapped/server.js';
@@ -0,0 +1,14 @@
1
+ import type { FimoConfig } from './fimo-config.types.js';
2
+ export interface ParamInfo {
3
+ schema: string;
4
+ queryField: string;
5
+ displayField: string;
6
+ }
7
+ export interface DisplayRoute {
8
+ id: string;
9
+ name: string;
10
+ path: string;
11
+ params?: Record<string, ParamInfo>;
12
+ }
13
+ export declare function getDisplayRoutes(config: Pick<FimoConfig, 'routes'> | undefined): DisplayRoute[];
14
+ //# sourceMappingURL=display-routes.d.ts.map
@@ -0,0 +1,25 @@
1
+ const titleCase = (seg) => seg
2
+ .replace(/[_\-]+/g, ' ')
3
+ .replace(/([a-z])([A-Z])/g, '$1 $2')
4
+ .split(/\s+/)
5
+ .filter(Boolean)
6
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
7
+ .join(' ');
8
+ const generateRouteName = (path) => {
9
+ if (path === '/') {
10
+ return 'Home';
11
+ }
12
+ const firstSegment = path.replace(/^\//, '').split('/')[0];
13
+ return titleCase(firstSegment);
14
+ };
15
+ export function getDisplayRoutes(config) {
16
+ const configRoutes = config?.routes ?? {};
17
+ return Object.entries(configRoutes)
18
+ .filter(([, route]) => route.path)
19
+ .map(([id, route]) => ({
20
+ id,
21
+ path: route.path,
22
+ name: route.name || route.label || generateRouteName(route.path),
23
+ params: route.params,
24
+ }));
25
+ }
@@ -20,6 +20,7 @@ export function getConfigServer(rootDir) {
20
20
  i18n: raw.i18n,
21
21
  routes: raw.routes,
22
22
  version: raw.version,
23
+ framework: raw.framework,
23
24
  };
24
25
  }
25
26
  catch {
@@ -57,5 +57,7 @@ export interface FimoConfig {
57
57
  i18n?: FimoI18nConfig;
58
58
  routes?: Record<string, FimoRouteConfig>;
59
59
  version?: string | number;
60
+ /** The project's framework. Absent means the Fimo template (react-router). */
61
+ framework?: 'react-router' | 'next' | string;
60
62
  }
61
63
  //# sourceMappingURL=fimo-config.types.d.ts.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Lossless bridge between a nested i18n message store (next-intl / i18next
3
+ * style: `{ home: { title: "…" } }`) and Fimo's FLAT per-locale label map
4
+ * (`{ "home.title": "…" }`). Ingestion flattens the store into labels;
5
+ * `loadFimoMessages` un-flattens the labels back so the app's own i18n
6
+ * runtime keeps rendering unchanged, now sourced from Fimo.
7
+ *
8
+ * String leaves and nested objects round-trip byte-for-byte, ICU strings
9
+ * (`{count, plural, …}`, `<tag>…</tag>`) kept opaque. Array/number/boolean
10
+ * leaves are rare in message stores and are NOT flattened — they stay in the
11
+ * caller's static base (deep-merged under the Fimo bundle).
12
+ */
13
+ /** Flatten a nested message object to dot-keyed string entries. Non-string
14
+ * leaves (arrays, numbers) are skipped — reported so the caller can note
15
+ * them. Keys already containing a dot are preserved verbatim. */
16
+ export declare function flattenMessages(messages: unknown, prefix?: string): {
17
+ flat: Record<string, string>;
18
+ skipped: string[];
19
+ };
20
+ /** Rebuild the nested message object from a flat dot-keyed map. Inverse of
21
+ * flattenMessages for string leaves. A key whose path collides with an
22
+ * already-set string (e.g. both `a` and `a.b` exist) keeps the deeper
23
+ * object and drops the scalar — message stores never have both. */
24
+ export declare function unflattenMessages(flat: Record<string, string>): Record<string, unknown>;
25
+ /** Deep-merge `override` (Fimo bundle) over `base` (static messages) so keys
26
+ * absent from Fimo fall back to the shipped file instead of next-intl's
27
+ * MISSING_MESSAGE. Objects merge recursively; leaves in `override` win. */
28
+ export declare function deepMergeMessages(base: Record<string, unknown>, override: Record<string, unknown>): Record<string, unknown>;
29
+ //# sourceMappingURL=i18n-messages.d.ts.map
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Lossless bridge between a nested i18n message store (next-intl / i18next
3
+ * style: `{ home: { title: "…" } }`) and Fimo's FLAT per-locale label map
4
+ * (`{ "home.title": "…" }`). Ingestion flattens the store into labels;
5
+ * `loadFimoMessages` un-flattens the labels back so the app's own i18n
6
+ * runtime keeps rendering unchanged, now sourced from Fimo.
7
+ *
8
+ * String leaves and nested objects round-trip byte-for-byte, ICU strings
9
+ * (`{count, plural, …}`, `<tag>…</tag>`) kept opaque. Array/number/boolean
10
+ * leaves are rare in message stores and are NOT flattened — they stay in the
11
+ * caller's static base (deep-merged under the Fimo bundle).
12
+ */
13
+ /** Flatten a nested message object to dot-keyed string entries. Non-string
14
+ * leaves (arrays, numbers) are skipped — reported so the caller can note
15
+ * them. Keys already containing a dot are preserved verbatim. */
16
+ export function flattenMessages(messages, prefix = '') {
17
+ const flat = {};
18
+ const skipped = [];
19
+ if (!messages || typeof messages !== 'object' || Array.isArray(messages)) {
20
+ return { flat, skipped };
21
+ }
22
+ for (const [key, value] of Object.entries(messages)) {
23
+ const path = prefix ? `${prefix}.${key}` : key;
24
+ if (typeof value === 'string') {
25
+ flat[path] = value;
26
+ }
27
+ else if (value && typeof value === 'object' && !Array.isArray(value)) {
28
+ const nested = flattenMessages(value, path);
29
+ Object.assign(flat, nested.flat);
30
+ skipped.push(...nested.skipped);
31
+ }
32
+ else {
33
+ skipped.push(path);
34
+ }
35
+ }
36
+ return { flat, skipped };
37
+ }
38
+ /** Rebuild the nested message object from a flat dot-keyed map. Inverse of
39
+ * flattenMessages for string leaves. A key whose path collides with an
40
+ * already-set string (e.g. both `a` and `a.b` exist) keeps the deeper
41
+ * object and drops the scalar — message stores never have both. */
42
+ export function unflattenMessages(flat) {
43
+ const root = {};
44
+ for (const [flatKey, value] of Object.entries(flat)) {
45
+ const parts = flatKey.split('.');
46
+ let node = root;
47
+ for (let i = 0; i < parts.length - 1; i += 1) {
48
+ const part = parts[i];
49
+ const existing = node[part];
50
+ if (!existing || typeof existing !== 'object' || Array.isArray(existing)) {
51
+ node[part] = {};
52
+ }
53
+ node = node[part];
54
+ }
55
+ node[parts[parts.length - 1]] = value;
56
+ }
57
+ return root;
58
+ }
59
+ /** Deep-merge `override` (Fimo bundle) over `base` (static messages) so keys
60
+ * absent from Fimo fall back to the shipped file instead of next-intl's
61
+ * MISSING_MESSAGE. Objects merge recursively; leaves in `override` win. */
62
+ export function deepMergeMessages(base, override) {
63
+ const out = { ...base };
64
+ for (const [key, value] of Object.entries(override)) {
65
+ const current = out[key];
66
+ if (value &&
67
+ typeof value === 'object' &&
68
+ !Array.isArray(value) &&
69
+ current &&
70
+ typeof current === 'object' &&
71
+ !Array.isArray(current)) {
72
+ out[key] = deepMergeMessages(current, value);
73
+ }
74
+ else {
75
+ out[key] = value;
76
+ }
77
+ }
78
+ return out;
79
+ }
@@ -0,0 +1,17 @@
1
+ export interface LabelBundle {
2
+ dictionaries: Record<string, Record<string, string>>;
3
+ defaultLocale: string;
4
+ locales: string[];
5
+ updatedAt: string | null;
6
+ }
7
+ export declare const API_URL_ENV_KEYS: readonly ["VITE_API_URL", "NEXT_PUBLIC_FIMO_API_URL", "NUXT_PUBLIC_FIMO_API_URL", "PUBLIC_FIMO_API_URL", "FIMO_API_URL"];
8
+ export declare function resolveTenantApiUrl(env: Record<string, string>): string | undefined;
9
+ export declare function serializeBundle(bundle: LabelBundle): string;
10
+ export declare function fetchLabelDictionary(apiUrl: string, locale: string): Promise<{
11
+ locale: string;
12
+ labels: Record<string, string>;
13
+ updatedAt: string | null;
14
+ }>;
15
+ export declare function fetchLabelBundle(apiUrl: string, locales: string[], defaultLocale: string): Promise<LabelBundle>;
16
+ export declare function fetchWithTimeout(url: URL, timeoutMs: number): Promise<Response>;
17
+ //# sourceMappingURL=labels-fetch.pure.d.ts.map
@@ -0,0 +1,71 @@
1
+ // Label fetching, PURE core: fetch/URL/AbortController only — no node
2
+ // builtins, importable from client-bundled code (Nuxt composables, universal
3
+ // SFCs). The node-flavored wrapper (env-file reading, config, signatures)
4
+ // lives in labels-fetch.server.ts.
5
+ // The tenant API base URL env var, in framework flavor order.
6
+ export const API_URL_ENV_KEYS = [
7
+ 'VITE_API_URL',
8
+ 'NEXT_PUBLIC_FIMO_API_URL',
9
+ 'NUXT_PUBLIC_FIMO_API_URL',
10
+ 'PUBLIC_FIMO_API_URL',
11
+ 'FIMO_API_URL',
12
+ ];
13
+ export function resolveTenantApiUrl(env) {
14
+ for (const key of API_URL_ENV_KEYS) {
15
+ if (env[key]) {
16
+ return env[key];
17
+ }
18
+ }
19
+ return undefined;
20
+ }
21
+ export function serializeBundle(bundle) {
22
+ return JSON.stringify({
23
+ dictionaries: bundle.dictionaries,
24
+ defaultLocale: bundle.defaultLocale,
25
+ locales: bundle.locales,
26
+ });
27
+ }
28
+ export async function fetchLabelDictionary(apiUrl, locale) {
29
+ const url = new URL('/labels', apiUrl);
30
+ url.searchParams.set('locale', locale);
31
+ const response = await fetchWithTimeout(url, 4000);
32
+ if (!response.ok) {
33
+ return { locale, labels: {}, updatedAt: null };
34
+ }
35
+ const body = (await response.json());
36
+ if (Array.isArray(body.data)) {
37
+ return {
38
+ locale,
39
+ labels: Object.fromEntries(body.data.map((row) => [row.key, row.value ?? row.defaultValue ?? ''])),
40
+ updatedAt: null,
41
+ };
42
+ }
43
+ return {
44
+ locale,
45
+ labels: body.data?.labels ?? {},
46
+ updatedAt: body.data?.updatedAt ?? null,
47
+ };
48
+ }
49
+ export async function fetchLabelBundle(apiUrl, locales, defaultLocale) {
50
+ const loaded = await Promise.all(locales.map((locale) => fetchLabelDictionary(apiUrl, locale).catch(() => ({ locale, labels: {}, updatedAt: null }))));
51
+ const sortedUpdatedAt = loaded
52
+ .map((entry) => entry.updatedAt)
53
+ .filter((value) => typeof value === 'string')
54
+ .sort();
55
+ return {
56
+ dictionaries: Object.fromEntries(loaded.map((entry) => [entry.locale, entry.labels])),
57
+ defaultLocale,
58
+ locales,
59
+ updatedAt: sortedUpdatedAt[sortedUpdatedAt.length - 1] ?? null,
60
+ };
61
+ }
62
+ export async function fetchWithTimeout(url, timeoutMs) {
63
+ const controller = new AbortController();
64
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
65
+ try {
66
+ return await fetch(url, { signal: controller.signal });
67
+ }
68
+ finally {
69
+ clearTimeout(timeout);
70
+ }
71
+ }
@@ -0,0 +1,7 @@
1
+ import { type LabelBundle } from './labels-fetch.pure.js';
2
+ export { API_URL_ENV_KEYS, fetchLabelBundle, fetchLabelDictionary, fetchWithTimeout, resolveTenantApiUrl, serializeBundle, type LabelBundle, } from './labels-fetch.pure.js';
3
+ export declare function labelSignature(bundle: LabelBundle): string;
4
+ export declare function emptyLabelBundle(rootDir: string): LabelBundle;
5
+ export declare function loadLabelBundle(rootDir: string): Promise<LabelBundle>;
6
+ export declare function readProjectEnv(rootDir: string): Promise<Record<string, string>>;
7
+ //# sourceMappingURL=labels-fetch.server.d.ts.map