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,15 +1,5 @@
1
1
  import React from 'react';
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
- }
2
+ export type { DisplayRoute, ParamInfo } from '../shared/display-routes.js';
13
3
  export interface FimoProvidersProps {
14
4
  children?: React.ReactNode;
15
5
  locale?: string;
@@ -11,31 +11,10 @@ import { ViteLifecycles } from '../core/ViteLifecycles.js';
11
11
  import { FimoLocaleProvider } from '../i18n/FimoLocaleContext.js';
12
12
  import { getFimoTextDirection, resolveFimoLocale, toHtmlLang } from '../i18n/locale.js';
13
13
  import { ScreenshotProvider } from '../iframe/ScreenshotProvider.js';
14
+ import { getDisplayRoutes as getDisplayRoutesFromConfig } from '../shared/display-routes.js';
14
15
  import { OptionalTracking } from '../t/OptionalTracking.js';
15
- const titleCase = (seg) => seg
16
- .replace(/[_\-]+/g, ' ')
17
- .replace(/([a-z])([A-Z])/g, '$1 $2')
18
- .split(/\s+/)
19
- .filter(Boolean)
20
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
21
- .join(' ');
22
- const generateRouteName = (path) => {
23
- if (path === '/') {
24
- return 'Home';
25
- }
26
- const firstSegment = path.replace(/^\//, '').split('/')[0];
27
- return titleCase(firstSegment);
28
- };
29
16
  function getDisplayRoutes() {
30
- const configRoutes = fimoConfig.routes ?? {};
31
- return Object.entries(configRoutes)
32
- .filter(([, route]) => route.path)
33
- .map(([id, route]) => ({
34
- id,
35
- path: route.path,
36
- name: route.name || generateRouteName(route.path),
37
- params: route.params,
38
- }));
17
+ return getDisplayRoutesFromConfig(fimoConfig);
39
18
  }
40
19
  function PreviewBridge() {
41
20
  const navigate = useNavigate();
@@ -0,0 +1,2 @@
1
+ export * from './server.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ // fimo/astro — see ./server.js (Astro is server-loader + DOM-attrs based;
2
+ // no client component set in v1).
3
+ export * from './server.js';
@@ -0,0 +1,3 @@
1
+ export * from '../wrapped/server.js';
2
+ export { fimoLabelAttrs, fimoMediaAttrs } from '../wrapped/dom.js';
3
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,6 @@
1
+ // fimo/astro/server — Astro adapter, server surface. The loaders are
2
+ // framework-neutral (Astro needs no React): call them in server-side code
3
+ // (frontmatter / load functions / useAsyncData) and render values with the
4
+ // DOM attribute helpers so edit mode can select the elements.
5
+ export * from '../wrapped/server.js';
6
+ export { fimoLabelAttrs, fimoMediaAttrs } from '../wrapped/dom.js';
@@ -179,6 +179,7 @@ function wrapReference(value, uid, resolve) {
179
179
  function wrapField(field, value, source, resolve) {
180
180
  switch (field.type) {
181
181
  case 'string':
182
+ case 'text':
182
183
  return value != null ? new FimoString(value, source) : value;
183
184
  case 'richtext':
184
185
  return value != null ? new FimoRichText(value, source) : value;
@@ -18,6 +18,7 @@ export type ContentResult<T extends {
18
18
  export interface ContentSchemaField {
19
19
  type?: string;
20
20
  required?: boolean;
21
+ default?: unknown;
21
22
  /** Media fields: multiple assets. */
22
23
  multiple?: boolean;
23
24
  /** Reference fields: to-many. */
@@ -26,6 +27,21 @@ export interface ContentSchemaField {
26
27
  target?: string;
27
28
  /** Polymorphic reference fields: allowed target schema uids. */
28
29
  targets?: readonly string[];
30
+ min?: number;
31
+ max?: number;
32
+ minLength?: number;
33
+ maxLength?: number;
34
+ regex?: string;
35
+ schema?: {
36
+ fields: Readonly<Record<string, ContentSchemaField>>;
37
+ } | {
38
+ oneOf: readonly {
39
+ uid: string;
40
+ label: string;
41
+ description?: string;
42
+ fields: Readonly<Record<string, ContentSchemaField>>;
43
+ }[];
44
+ };
29
45
  }
30
46
  export interface ContentSchema {
31
47
  uid: string;
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
2
3
  import { createContext, useContext } from 'react';
3
4
  const fallbackLocale = {
@@ -0,0 +1,24 @@
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 FimoNextLabels = WrappedLabels;
6
+ export interface FimoNextProvidersProps {
7
+ config: FimoConfig;
8
+ labels?: FimoNextLabels;
9
+ media?: Record<string, WrappedMediaEntry>;
10
+ richText?: Record<string, WrappedRichTextEntry>;
11
+ locale?: string;
12
+ children?: React.ReactNode;
13
+ }
14
+ /**
15
+ * Fimo providers for wrapped Next.js apps — the Next adapter supplies only
16
+ * the navigation hooks; everything else lives in the framework-neutral
17
+ * WrappedProviders. Mount once in the root layout:
18
+ *
19
+ * const config = loadFimoConfig();
20
+ * const labels = await loadFimoLabels();
21
+ * <FimoNextProviders config={config} labels={labels}>{children}</FimoNextProviders>
22
+ */
23
+ export declare function FimoNextProviders(props: FimoNextProvidersProps): import("react/jsx-runtime").JSX.Element;
24
+ //# sourceMappingURL=FimoNextProviders.d.ts.map
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { usePathname, useRouter } from 'next/navigation';
4
+ import { useMemo } from 'react';
5
+ import { WrappedProviders } from '../wrapped/WrappedProviders.js';
6
+ /**
7
+ * Fimo providers for wrapped Next.js apps — the Next adapter supplies only
8
+ * the navigation hooks; everything else lives in the framework-neutral
9
+ * WrappedProviders. Mount once in the root layout:
10
+ *
11
+ * const config = loadFimoConfig();
12
+ * const labels = await loadFimoLabels();
13
+ * <FimoNextProviders config={config} labels={labels}>{children}</FimoNextProviders>
14
+ */
15
+ export function FimoNextProviders(props) {
16
+ const router = useRouter();
17
+ const pathname = usePathname();
18
+ const navigation = useMemo(() => ({ pathname, navigate: (to) => router.push(to) }), [pathname, router]);
19
+ return _jsx(WrappedProviders, { ...props, navigation: navigation });
20
+ }
@@ -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 NEXT_PUBLIC_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 FimoNextScripts(): import("react/jsx-runtime").JSX.Element | null;
10
+ //# sourceMappingURL=FimoNextScripts.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 NEXT_PUBLIC_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 FimoNextScripts() {
11
+ if (process.env.NODE_ENV !== 'development') {
12
+ return null;
13
+ }
14
+ const previewScriptUrl = process.env.NEXT_PUBLIC_FIMO_PREVIEW_SCRIPT_URL;
15
+ if (!previewScriptUrl) {
16
+ return null;
17
+ }
18
+ return _jsx("script", { type: "module", src: previewScriptUrl });
19
+ }
@@ -0,0 +1,14 @@
1
+ export { FimoNextProviders } from './FimoNextProviders.js';
2
+ export type { FimoNextLabels, FimoNextProvidersProps } from './FimoNextProviders.js';
3
+ export { FimoNextScripts } from './FimoNextScripts.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, useTranslations } from '../primitives/labels-hook.js';
12
+ export { Text, Image, Video, RichText } from '../react/index.js';
13
+ export type { FimoConfig } from '../shared/fimo-config.types.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ // fimo/next — the Next.js adapter for wrapped (migrated) sites.
2
+ // Client components; server loaders live in fimo/next/server.
3
+ export { FimoNextProviders } from './FimoNextProviders.js';
4
+ export { FimoNextScripts } from './FimoNextScripts.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
+ // Framework-neutral React surface, re-exported for convenience so wrapped
12
+ // apps import everything from fimo/next.
13
+ export { useLabels, useTranslations } from '../primitives/labels-hook.js';
14
+ export { Text, Image, Video, RichText } from '../react/index.js';
@@ -0,0 +1,2 @@
1
+ export * from '../wrapped/server.js';
2
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,4 @@
1
+ // fimo/next/server — the Next.js adapter's server surface. The loaders are
2
+ // framework-neutral and live in ../wrapped/server.js; this module is the
3
+ // adapter-facing entry so future adapters (fimo/astro) mirror it.
4
+ export * from '../wrapped/server.js';
@@ -0,0 +1,9 @@
1
+ export declare function useFimoLabels(locale?: string): Promise<Record<string, string>>;
2
+ /**
3
+ * Server-loaded, hydration-safe label accessor for `<script setup>`:
4
+ *
5
+ * const t = await useFimoT();
6
+ * <h1 v-bind="fimoLabelAttrs('hero.title')">{{ t('hero.title', 'Fallback') }}</h1>
7
+ */
8
+ export declare function useFimoT(locale?: string): Promise<(key: string, fallback?: string) => string>;
9
+ //# sourceMappingURL=composables.d.ts.map
@@ -0,0 +1,57 @@
1
+ // Nuxt composables over the PURE label-fetch core. Constraints proven by the
2
+ // nuxtship dogfood, in order:
3
+ // - no node builtins anywhere in this module graph (`<script setup>` imports
4
+ // land in the client bundle; named imports from externalized builtins hard-
5
+ // fail `nuxt build`);
6
+ // - no `#app` import (Vite's dep optimizer prebundles node_modules with no
7
+ // knowledge of Nuxt aliases);
8
+ // - no `nuxt/app` import either (server-side the package is a nitro external
9
+ // resolved by raw node, where nuxt/app's internal `#build/*` imports do not
10
+ // exist).
11
+ // So: import only from 'vue', reach the Nuxt app via the current component
12
+ // instance, and hand labels to the client through `nuxtApp.payload.data` —
13
+ // the exact bucket useAsyncData serializes into the page payload.
14
+ import { getCurrentInstance } from 'vue';
15
+ import { fetchLabelDictionary, resolveTenantApiUrl } from '../shared/labels-fetch.pure.js';
16
+ function currentNuxtApp() {
17
+ const instance = getCurrentInstance();
18
+ const vueApp = instance?.appContext?.app;
19
+ return vueApp?.$nuxt ?? vueApp?.config?.globalProperties?.$nuxt ?? instance?.proxy?.$nuxt;
20
+ }
21
+ export async function useFimoLabels(locale = 'en') {
22
+ const key = `__fimo_labels_${locale}`;
23
+ const payloadData = currentNuxtApp()?.payload?.data;
24
+ const cached = payloadData?.[key];
25
+ if (cached) {
26
+ return cached;
27
+ }
28
+ // `typeof window` (not import.meta.server): as a nitro external this module
29
+ // runs as plain node ESM where Nuxt's import.meta flags do not exist.
30
+ if (typeof window !== 'undefined') {
31
+ return {};
32
+ }
33
+ const apiUrl = resolveTenantApiUrl(process.env);
34
+ if (!apiUrl) {
35
+ return {};
36
+ }
37
+ try {
38
+ const { labels } = await fetchLabelDictionary(apiUrl, locale);
39
+ if (payloadData) {
40
+ payloadData[key] = labels;
41
+ }
42
+ return labels;
43
+ }
44
+ catch {
45
+ return {};
46
+ }
47
+ }
48
+ /**
49
+ * Server-loaded, hydration-safe label accessor for `<script setup>`:
50
+ *
51
+ * const t = await useFimoT();
52
+ * <h1 v-bind="fimoLabelAttrs('hero.title')">{{ t('hero.title', 'Fallback') }}</h1>
53
+ */
54
+ export async function useFimoT(locale = 'en') {
55
+ const labels = await useFimoLabels(locale);
56
+ return (key, fallback = '') => labels[key] ?? fallback;
57
+ }
@@ -0,0 +1,3 @@
1
+ export { fimoLabelAttrs, fimoMediaAttrs, FIMO_SOURCE_ATTR } from '../wrapped/dom.js';
2
+ export { useFimoLabels, useFimoT } from './composables.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ // fimo/nuxt — CLIENT-SAFE surface for universal Vue SFCs. Never re-export
2
+ // the server barrel here: a `<script setup>` import lands in the client
3
+ // bundle, and the server loaders read fs/env (the nuxtship dogfood broke
4
+ // `nuxt build` exactly this way). Server routes import fimo/nuxt/server.
5
+ export { fimoLabelAttrs, fimoMediaAttrs, FIMO_SOURCE_ATTR } from '../wrapped/dom.js';
6
+ export { useFimoLabels, useFimoT } from './composables.js';
@@ -0,0 +1,3 @@
1
+ export * from '../wrapped/server.js';
2
+ export { fimoLabelAttrs, fimoMediaAttrs } from '../wrapped/dom.js';
3
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,6 @@
1
+ // fimo/nuxt/server — Nuxt adapter, server surface. The loaders are
2
+ // framework-neutral (Nuxt needs no React): call them in server-side code
3
+ // (frontmatter / load functions / useAsyncData) and render values with the
4
+ // DOM attribute helpers so edit mode can select the elements.
5
+ export * from '../wrapped/server.js';
6
+ export { fimoLabelAttrs, fimoMediaAttrs } from '../wrapped/dom.js';
@@ -0,0 +1,33 @@
1
+ import { FimoString } from './lib/index.js';
2
+ /**
3
+ * Hook to provide a label function (`t`).
4
+ *
5
+ * Returns FimoString with source tracking for inline editing.
6
+ * Use with <Text> component for rendering, or String() for escape hatch.
7
+ *
8
+ * The optional `fallback` renders when the key has no value in the store —
9
+ * used by wrapped (migrated) projects where the original hardcoded string
10
+ * stays in code as a resilience fallback. Template projects keep the
11
+ * single-argument form (labels are DB-owned there).
12
+ *
13
+ * @example
14
+ * const { t } = useLabels();
15
+ *
16
+ * // With Text component (recommended)
17
+ * <Text value={t('welcome')} />
18
+ *
19
+ * // Escape hatch for attributes
20
+ * <input placeholder={String(t('email.placeholder'))} />
21
+ */
22
+ export declare function useLabels(): {
23
+ t: (fullKey: string, fallback?: string) => FimoString;
24
+ locale: string;
25
+ };
26
+ /**
27
+ * Legacy alias for older projects. Prefer useLabels() in new code.
28
+ */
29
+ export declare function useTranslations(): {
30
+ t: (fullKey: string, fallback?: string) => FimoString;
31
+ locale: string;
32
+ };
33
+ //# sourceMappingURL=labels-hook.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ import { useLocale } from '../i18n/FimoLocaleContext.js';
3
+ import { getLabelSnapshot, subscribeLabels } from './labels-store.js';
4
+ import { FimoString } from './lib/index.js';
5
+ /**
6
+ * Hook to provide a label function (`t`).
7
+ *
8
+ * Returns FimoString with source tracking for inline editing.
9
+ * Use with <Text> component for rendering, or String() for escape hatch.
10
+ *
11
+ * The optional `fallback` renders when the key has no value in the store —
12
+ * used by wrapped (migrated) projects where the original hardcoded string
13
+ * stays in code as a resilience fallback. Template projects keep the
14
+ * single-argument form (labels are DB-owned there).
15
+ *
16
+ * @example
17
+ * const { t } = useLabels();
18
+ *
19
+ * // With Text component (recommended)
20
+ * <Text value={t('welcome')} />
21
+ *
22
+ * // Escape hatch for attributes
23
+ * <input placeholder={String(t('email.placeholder'))} />
24
+ */
25
+ export function useLabels() {
26
+ const localeContext = useLocale();
27
+ const labels = useSyncExternalStore(subscribeLabels, getLabelSnapshot, getLabelSnapshot);
28
+ const t = (fullKey, fallback) => {
29
+ const locale = localeContext.locale || labels.defaultLocale || 'en';
30
+ const dictionary = labels.dictionaries[locale] ?? labels.dictionaries[labels.defaultLocale] ?? {};
31
+ const text = dictionary[fullKey] ?? fallback ?? '';
32
+ return new FimoString(text, `__labels.${locale}.${fullKey}.value`);
33
+ };
34
+ return { t, locale: localeContext.locale };
35
+ }
36
+ /**
37
+ * Legacy alias for older projects. Prefer useLabels() in new code.
38
+ */
39
+ export function useTranslations() {
40
+ return useLabels();
41
+ }
@@ -0,0 +1,12 @@
1
+ export interface LabelState {
2
+ dictionaries: Record<string, Record<string, string>>;
3
+ defaultLocale: string;
4
+ signature: string;
5
+ updatedAt: string | null;
6
+ }
7
+ export declare function subscribeLabels(listener: () => void): () => void;
8
+ export declare function getLabelSnapshot(): LabelState;
9
+ export declare function setLabelState(next: LabelState): void;
10
+ export declare function hydrateLabels(bundle: LabelState): void;
11
+ export declare function applyLabelUpdate(payload: unknown): void;
12
+ //# sourceMappingURL=labels-store.d.ts.map
@@ -0,0 +1,60 @@
1
+ // Framework-neutral label store. No Vite virtual modules, no HMR, no React:
2
+ // adapters (fimo/ui via ./translations.ts, fimo/next, ...) hydrate it with
3
+ // their own label source and the hook layer subscribes to it.
4
+ const labelListeners = new Set();
5
+ let labelState = {
6
+ dictionaries: {},
7
+ defaultLocale: 'en',
8
+ signature: '__fimo-labels-uninitialized__',
9
+ updatedAt: null,
10
+ };
11
+ export function subscribeLabels(listener) {
12
+ labelListeners.add(listener);
13
+ return () => {
14
+ labelListeners.delete(listener);
15
+ };
16
+ }
17
+ export function getLabelSnapshot() {
18
+ return labelState;
19
+ }
20
+ export function setLabelState(next) {
21
+ if (next.signature === labelState.signature) {
22
+ return;
23
+ }
24
+ labelState = next;
25
+ for (const listener of labelListeners) {
26
+ listener();
27
+ }
28
+ }
29
+ export function hydrateLabels(bundle) {
30
+ setLabelState(bundle);
31
+ }
32
+ function isRecord(value) {
33
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
34
+ }
35
+ function normalizeDictionaries(value) {
36
+ if (!isRecord(value)) {
37
+ return null;
38
+ }
39
+ const dictionaries = {};
40
+ for (const [locale, labels] of Object.entries(value)) {
41
+ if (!isRecord(labels)) {
42
+ continue;
43
+ }
44
+ dictionaries[locale] = Object.fromEntries(Object.entries(labels).filter((entry) => typeof entry[1] === 'string'));
45
+ }
46
+ return dictionaries;
47
+ }
48
+ export function applyLabelUpdate(payload) {
49
+ if (!isRecord(payload)) {
50
+ return;
51
+ }
52
+ const dictionaries = normalizeDictionaries(payload.dictionaries);
53
+ if (!dictionaries) {
54
+ return;
55
+ }
56
+ const defaultLocale = typeof payload.defaultLocale === 'string' ? payload.defaultLocale : labelState.defaultLocale;
57
+ const signature = typeof payload.signature === 'string' ? payload.signature : JSON.stringify({ dictionaries, defaultLocale });
58
+ const updatedAt = typeof payload.updatedAt === 'string' ? payload.updatedAt : null;
59
+ setLabelState({ dictionaries, defaultLocale, signature, updatedAt });
60
+ }
@@ -9,9 +9,11 @@ import { type RefObject } from 'react';
9
9
  * preview knows to dispatch events instead of falling back to raw DOM writes,
10
10
  * and updates internal state when a mutation arrives.
11
11
  *
12
- * In prod (published app): Vite statically inlines `import.meta.env.DEV`, so
13
- * `useFimoLiveValueProd` is the only implementation linked and the listener
14
- * machinery is dead-code-eliminated.
12
+ * In prod (published app): only `useFimoLiveValueProd` is linked. The dev
13
+ * check must work under any bundler (Vite, webpack, Turbopack) and plain
14
+ * Node SSR: `import.meta.env.DEV` only exists under Vite, and
15
+ * `process.env.NODE_ENV` is statically replaced by Next/webpack — checking
16
+ * both keeps the hook correct across adapters.
15
17
  */
16
18
  declare function useFimoLiveValueDev<T, E extends HTMLElement = HTMLElement>(external: T): {
17
19
  value: T;
@@ -10,9 +10,11 @@ import { useEffect, useRef, useState } from 'react';
10
10
  * preview knows to dispatch events instead of falling back to raw DOM writes,
11
11
  * and updates internal state when a mutation arrives.
12
12
  *
13
- * In prod (published app): Vite statically inlines `import.meta.env.DEV`, so
14
- * `useFimoLiveValueProd` is the only implementation linked and the listener
15
- * machinery is dead-code-eliminated.
13
+ * In prod (published app): only `useFimoLiveValueProd` is linked. The dev
14
+ * check must work under any bundler (Vite, webpack, Turbopack) and plain
15
+ * Node SSR: `import.meta.env.DEV` only exists under Vite, and
16
+ * `process.env.NODE_ENV` is statically replaced by Next/webpack — checking
17
+ * both keeps the hook correct across adapters.
16
18
  */
17
19
  function useFimoLiveValueDev(external) {
18
20
  const ref = useRef(null);
@@ -46,4 +48,9 @@ function useFimoLiveValueProd(external) {
46
48
  const ref = useRef(null);
47
49
  return { value: external, ref };
48
50
  }
49
- export const useFimoLiveValue = (import.meta.env.DEV ? useFimoLiveValueDev : useFimoLiveValueProd);
51
+ // globalThis lookup, not a bare `process` reference: this file is part of the
52
+ // browser-facing runtime surface, which must typecheck without node types
53
+ // (the generated-types gate enforces it).
54
+ const isDevRuntime = import.meta.env?.DEV === true ||
55
+ globalThis.process?.env?.NODE_ENV === 'development';
56
+ export const useFimoLiveValue = (isDevRuntime ? useFimoLiveValueDev : useFimoLiveValueProd);
@@ -1,28 +1,2 @@
1
- import { FimoString } from './lib/index.js';
2
- /**
3
- * Hook to provide a label function (`t`).
4
- *
5
- * Returns FimoString with source tracking for inline editing.
6
- * Use with <Text> component for rendering, or String() for escape hatch.
7
- *
8
- * @example
9
- * const { t } = useLabels();
10
- *
11
- * // With Text component (recommended)
12
- * <Text value={t('welcome')} />
13
- *
14
- * // Escape hatch for attributes
15
- * <input placeholder={String(t('email.placeholder'))} />
16
- */
17
- export declare function useLabels(): {
18
- t: (fullKey: string) => FimoString;
19
- locale: string;
20
- };
21
- /**
22
- * Legacy alias for older projects. Prefer useLabels() in new code.
23
- */
24
- export declare function useTranslations(): {
25
- t: (fullKey: string) => FimoString;
26
- locale: string;
27
- };
1
+ export { useLabels, useTranslations } from './labels-hook.js';
28
2
  //# sourceMappingURL=translations.d.ts.map