fimo 0.9.0-experimental.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/assets/skills/fimo/SKILL.md +17 -54
  2. package/assets/skills/fimo-cli/SKILL.md +15 -15
  3. package/assets/skills/fimo-cli/references/agent-setup.md +36 -53
  4. package/assets/skills/fimo-cli/references/agents.md +4 -4
  5. package/assets/skills/fimo-cli/references/content.md +2 -2
  6. package/assets/skills/fimo-cli/references/deploy.md +1 -1
  7. package/assets/skills/fimo-cli/references/forms.md +1 -1
  8. package/assets/skills/fimo-cli/references/init.md +16 -24
  9. package/assets/skills/fimo-cli/references/project-vars-and-secrets.md +14 -11
  10. package/assets/skills/fimo-cli/references/projects.md +1 -1
  11. package/assets/skills/fimo-cli/references/support.md +11 -9
  12. package/assets/skills/fimo-cli/references/webhooks.md +3 -1
  13. package/assets/skills/fimo-code/SKILL.md +67 -0
  14. package/assets/skills/fimo-migration/SKILL.md +2 -22
  15. package/assets/skills/fimo-migration/references/content.md +0 -24
  16. package/assets/skills/fimo-migration/references/manifest.md +0 -35
  17. package/assets/skills/fimo-migration/references/qa.md +2 -24
  18. package/assets/skills/fimo-migration/references/workflow.md +1 -12
  19. package/assets/skills/fimo-studio/references/visual-editing.md +3 -5
  20. package/assets/skills/fimo-studio/references/webhooks.md +1 -1
  21. package/dist/build/vite/plugins/translations.d.ts +8 -2
  22. package/dist/build/vite/plugins/translations.js +121 -3
  23. package/dist/cli/bundle.json +2 -2
  24. package/dist/cli/index.js +311 -1209
  25. package/dist/runtime/app/FimoProviders.d.ts +11 -1
  26. package/dist/runtime/app/FimoProviders.js +23 -2
  27. package/dist/runtime/content/client/createContentClient.js +2 -1
  28. package/dist/runtime/i18n/FimoLocaleContext.js +0 -1
  29. package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts +3 -5
  30. package/dist/runtime/primitives/lib/useFimoLiveValue.js +4 -11
  31. package/dist/runtime/primitives/translations.d.ts +27 -1
  32. package/dist/runtime/primitives/translations.js +85 -7
  33. package/dist/runtime/shared/fimo-config.server.js +0 -1
  34. package/dist/runtime/shared/fimo-config.types.d.ts +0 -2
  35. package/dist/scripts/extract-translations.js +11 -16
  36. package/dist/scripts/lib/validation-report.d.ts +0 -1
  37. package/dist/scripts/lib/validation-report.js +0 -3
  38. package/dist/scripts/validate-route-metadata.js +0 -11
  39. package/package.json +4 -84
  40. package/release.json +2 -2
  41. package/scripts/postinstall.mjs +11 -65
  42. package/templates/react-router/AGENTS.md +44 -0
  43. package/templates/react-router/CLAUDE.md +5 -0
  44. package/templates/react-router/package.json +1 -1
  45. package/assets/agents-starter/AGENTS.md +0 -66
  46. package/assets/skills/fimo-migration/references/wrap.md +0 -617
  47. package/dist/runtime/astro/index.d.ts +0 -2
  48. package/dist/runtime/astro/index.js +0 -3
  49. package/dist/runtime/astro/server.d.ts +0 -3
  50. package/dist/runtime/astro/server.js +0 -6
  51. package/dist/runtime/next/FimoNextProviders.d.ts +0 -24
  52. package/dist/runtime/next/FimoNextProviders.js +0 -20
  53. package/dist/runtime/next/FimoNextScripts.d.ts +0 -10
  54. package/dist/runtime/next/FimoNextScripts.js +0 -19
  55. package/dist/runtime/next/index.d.ts +0 -14
  56. package/dist/runtime/next/index.js +0 -14
  57. package/dist/runtime/next/server.d.ts +0 -2
  58. package/dist/runtime/next/server.js +0 -4
  59. package/dist/runtime/nuxt/composables.d.ts +0 -9
  60. package/dist/runtime/nuxt/composables.js +0 -57
  61. package/dist/runtime/nuxt/index.d.ts +0 -3
  62. package/dist/runtime/nuxt/index.js +0 -6
  63. package/dist/runtime/nuxt/server.d.ts +0 -3
  64. package/dist/runtime/nuxt/server.js +0 -6
  65. package/dist/runtime/primitives/labels-hook.d.ts +0 -33
  66. package/dist/runtime/primitives/labels-hook.js +0 -41
  67. package/dist/runtime/primitives/labels-store.d.ts +0 -12
  68. package/dist/runtime/primitives/labels-store.js +0 -60
  69. package/dist/runtime/react/FimoSpaProviders.d.ts +0 -36
  70. package/dist/runtime/react/FimoSpaProviders.js +0 -63
  71. package/dist/runtime/react/index.d.ts +0 -33
  72. package/dist/runtime/react/index.js +0 -39
  73. package/dist/runtime/remix/FimoRemixProviders.d.ts +0 -16
  74. package/dist/runtime/remix/FimoRemixProviders.js +0 -12
  75. package/dist/runtime/remix/FimoRemixScripts.d.ts +0 -10
  76. package/dist/runtime/remix/FimoRemixScripts.js +0 -19
  77. package/dist/runtime/remix/index.d.ts +0 -12
  78. package/dist/runtime/remix/index.js +0 -11
  79. package/dist/runtime/remix/server.d.ts +0 -2
  80. package/dist/runtime/remix/server.js +0 -2
  81. package/dist/runtime/shared/display-routes.d.ts +0 -14
  82. package/dist/runtime/shared/display-routes.js +0 -25
  83. package/dist/runtime/shared/i18n-messages.d.ts +0 -29
  84. package/dist/runtime/shared/i18n-messages.js +0 -79
  85. package/dist/runtime/shared/labels-fetch.pure.d.ts +0 -17
  86. package/dist/runtime/shared/labels-fetch.pure.js +0 -71
  87. package/dist/runtime/shared/labels-fetch.server.d.ts +0 -7
  88. package/dist/runtime/shared/labels-fetch.server.js +0 -97
  89. package/dist/runtime/shared/labels-t.pure.d.ts +0 -2
  90. package/dist/runtime/shared/labels-t.pure.js +0 -10
  91. package/dist/runtime/strapi/client.d.ts +0 -30
  92. package/dist/runtime/strapi/client.js +0 -89
  93. package/dist/runtime/strapi/index.d.ts +0 -5
  94. package/dist/runtime/strapi/index.js +0 -6
  95. package/dist/runtime/strapi/reshape.d.ts +0 -46
  96. package/dist/runtime/strapi/reshape.js +0 -114
  97. package/dist/runtime/svelte/index.d.ts +0 -3
  98. package/dist/runtime/svelte/index.js +0 -7
  99. package/dist/runtime/svelte/server.d.ts +0 -3
  100. package/dist/runtime/svelte/server.js +0 -6
  101. package/dist/runtime/vue/index.d.ts +0 -3
  102. package/dist/runtime/vue/index.js +0 -5
  103. package/dist/runtime/vue/server.d.ts +0 -3
  104. package/dist/runtime/vue/server.js +0 -6
  105. package/dist/runtime/wrapped/FimoFileLink.d.ts +0 -17
  106. package/dist/runtime/wrapped/FimoFileLink.js +0 -19
  107. package/dist/runtime/wrapped/FimoMediaImage.d.ts +0 -14
  108. package/dist/runtime/wrapped/FimoMediaImage.js +0 -20
  109. package/dist/runtime/wrapped/FimoMediaVideo.d.ts +0 -14
  110. package/dist/runtime/wrapped/FimoMediaVideo.js +0 -20
  111. package/dist/runtime/wrapped/FimoRichTextBlock.d.ts +0 -23
  112. package/dist/runtime/wrapped/FimoRichTextBlock.js +0 -22
  113. package/dist/runtime/wrapped/FimoText.d.ts +0 -22
  114. package/dist/runtime/wrapped/FimoText.js +0 -20
  115. package/dist/runtime/wrapped/WrappedContentContext.d.ts +0 -28
  116. package/dist/runtime/wrapped/WrappedContentContext.js +0 -30
  117. package/dist/runtime/wrapped/WrappedProviders.d.ts +0 -33
  118. package/dist/runtime/wrapped/WrappedProviders.js +0 -101
  119. package/dist/runtime/wrapped/dom.d.ts +0 -4
  120. package/dist/runtime/wrapped/dom.js +0 -23
  121. package/dist/runtime/wrapped/server.d.ts +0 -77
  122. package/dist/runtime/wrapped/server.js +0 -237
  123. package/dist/scripts/apply-wrap-templates.d.ts +0 -61
  124. package/dist/scripts/apply-wrap-templates.js +0 -132
  125. package/dist/scripts/apply-wrap.d.ts +0 -46
  126. package/dist/scripts/apply-wrap.js +0 -278
  127. package/dist/scripts/cms/discover.d.ts +0 -2
  128. package/dist/scripts/cms/discover.js +0 -17
  129. package/dist/scripts/cms/example-content.d.ts +0 -33
  130. package/dist/scripts/cms/example-content.js +0 -162
  131. package/dist/scripts/cms/strapi/detect.d.ts +0 -2
  132. package/dist/scripts/cms/strapi/detect.js +0 -186
  133. package/dist/scripts/cms/strapi/index.d.ts +0 -3
  134. package/dist/scripts/cms/strapi/index.js +0 -25
  135. package/dist/scripts/cms/strapi/list-source.d.ts +0 -17
  136. package/dist/scripts/cms/strapi/list-source.js +0 -90
  137. package/dist/scripts/cms/strapi/schema-map.d.ts +0 -9
  138. package/dist/scripts/cms/strapi/schema-map.js +0 -277
  139. package/dist/scripts/cms/strapi/shapes.d.ts +0 -23
  140. package/dist/scripts/cms/strapi/shapes.js +0 -38
  141. package/dist/scripts/cms/strapi/touchpoints.d.ts +0 -31
  142. package/dist/scripts/cms/strapi/touchpoints.js +0 -145
  143. package/dist/scripts/cms/strapi/wire-client.d.ts +0 -15
  144. package/dist/scripts/cms/strapi/wire-client.js +0 -107
  145. package/dist/scripts/cms/strapi/wiring.d.ts +0 -17
  146. package/dist/scripts/cms/strapi/wiring.js +0 -46
  147. package/dist/scripts/cms/types.d.ts +0 -145
  148. package/dist/scripts/cms/types.js +0 -11
  149. package/dist/scripts/detect-framework.d.ts +0 -39
  150. package/dist/scripts/detect-framework.js +0 -133
  151. package/dist/scripts/draft-rows.d.ts +0 -19
  152. package/dist/scripts/draft-rows.js +0 -135
  153. package/dist/scripts/draft-schemas.d.ts +0 -27
  154. package/dist/scripts/draft-schemas.js +0 -188
  155. package/dist/scripts/frameworks/astro/routes.d.ts +0 -3
  156. package/dist/scripts/frameworks/astro/routes.js +0 -55
  157. package/dist/scripts/frameworks/astro/template-style.d.ts +0 -7
  158. package/dist/scripts/frameworks/astro/template-style.js +0 -19
  159. package/dist/scripts/frameworks/discover.d.ts +0 -70
  160. package/dist/scripts/frameworks/discover.js +0 -178
  161. package/dist/scripts/frameworks/next/rewire.d.ts +0 -30
  162. package/dist/scripts/frameworks/next/rewire.js +0 -258
  163. package/dist/scripts/frameworks/next/routes.d.ts +0 -17
  164. package/dist/scripts/frameworks/next/routes.js +0 -134
  165. package/dist/scripts/frameworks/next/wiring.d.ts +0 -33
  166. package/dist/scripts/frameworks/next/wiring.js +0 -186
  167. package/dist/scripts/frameworks/nuxt/routes.d.ts +0 -3
  168. package/dist/scripts/frameworks/nuxt/routes.js +0 -54
  169. package/dist/scripts/frameworks/nuxt/template-style.d.ts +0 -9
  170. package/dist/scripts/frameworks/nuxt/template-style.js +0 -27
  171. package/dist/scripts/frameworks/remix/routes.d.ts +0 -3
  172. package/dist/scripts/frameworks/remix/routes.js +0 -50
  173. package/dist/scripts/frameworks/support.d.ts +0 -75
  174. package/dist/scripts/frameworks/support.js +0 -165
  175. package/dist/scripts/frameworks/sveltekit/routes.d.ts +0 -3
  176. package/dist/scripts/frameworks/sveltekit/routes.js +0 -50
  177. package/dist/scripts/frameworks/sveltekit/template-style.d.ts +0 -9
  178. package/dist/scripts/frameworks/sveltekit/template-style.js +0 -54
  179. package/dist/scripts/frameworks/vite/routes.d.ts +0 -15
  180. package/dist/scripts/frameworks/vite/routes.js +0 -93
  181. package/dist/scripts/frameworks/vite/wiring.d.ts +0 -10
  182. package/dist/scripts/frameworks/vite/wiring.js +0 -99
  183. package/dist/scripts/i18n-namespace.d.ts +0 -27
  184. package/dist/scripts/i18n-namespace.js +0 -155
  185. package/dist/scripts/render-parity/capture.d.ts +0 -56
  186. package/dist/scripts/render-parity/capture.js +0 -366
  187. package/dist/scripts/render-parity/compare.d.ts +0 -59
  188. package/dist/scripts/render-parity/compare.js +0 -0
  189. package/dist/scripts/render-parity/normalize-html.d.ts +0 -13
  190. package/dist/scripts/render-parity/normalize-html.js +0 -223
  191. package/dist/scripts/render-parity/types.d.ts +0 -41
  192. package/dist/scripts/render-parity/types.js +0 -1
  193. package/dist/scripts/scan-wrappable.d.ts +0 -196
  194. package/dist/scripts/scan-wrappable.js +0 -1232
  195. /package/assets/skills/{fimo → fimo-code}/assets/react-router-locales/navigation.tsx +0 -0
  196. /package/assets/skills/{fimo → fimo-code}/assets/react-router-locales/routes.ts +0 -0
  197. /package/assets/skills/{fimo → fimo-code}/references/assets.md +0 -0
  198. /package/assets/skills/{fimo → fimo-code}/references/content.md +0 -0
  199. /package/assets/skills/{fimo → fimo-code}/references/design.md +0 -0
  200. /package/assets/skills/{fimo → fimo-code}/references/forms.md +0 -0
  201. /package/assets/skills/{fimo → fimo-code}/references/labels.md +0 -0
  202. /package/assets/skills/{fimo → fimo-code}/references/locales.md +0 -0
  203. /package/assets/skills/{fimo → fimo-code}/references/setup-plain-vite.md +0 -0
  204. /package/assets/skills/{fimo → fimo-code}/references/setup-react-router.md +0 -0
  205. /package/assets/skills/{fimo → fimo-code}/references/ui.md +0 -0
@@ -1,54 +0,0 @@
1
- import { readdirSync, statSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- const titleCase = (seg) => seg
4
- .replace(/[_\-]+/g, ' ')
5
- .replace(/([a-z])([A-Z])/g, '$1 $2')
6
- .split(/\s+/)
7
- .filter(Boolean)
8
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
9
- .join(' ');
10
- function pushRoute(routes, parts) {
11
- const routePath = `/${parts.join('/')}`.replace(/\/+/g, '/');
12
- const lastStatic = [...parts].reverse().find((part) => !part.startsWith(':'));
13
- routes.push({
14
- id: routePath === '/' ? 'home' : parts.map((part) => part.replace(/^:/, '')).join('-'),
15
- path: routePath,
16
- label: routePath === '/' ? 'Home' : titleCase(lastStatic ?? parts[parts.length - 1] ?? routePath),
17
- });
18
- }
19
- const toSegment = (name) => name.replace(/^\[\.\.\.(.+)\]$/, ':$1').replace(/^\[(.+)\]$/, ':$1');
20
- /** Nuxt file-based routes under pages/ (index.vue maps to the dir path). */
21
- export function discoverNuxtRoutes(pagesDir) {
22
- const routes = [];
23
- const walk = (dir, segments) => {
24
- let entries;
25
- try {
26
- entries = readdirSync(dir);
27
- }
28
- catch {
29
- return;
30
- }
31
- for (const entry of entries) {
32
- const full = join(dir, entry);
33
- let isDir = false;
34
- try {
35
- isDir = statSync(full).isDirectory();
36
- }
37
- catch {
38
- continue;
39
- }
40
- if (isDir) {
41
- walk(full, [...segments, toSegment(entry)]);
42
- continue;
43
- }
44
- if (!entry.endsWith('.vue')) {
45
- continue;
46
- }
47
- const base = entry.replace(/\.vue$/, '');
48
- pushRoute(routes, base === 'index' ? segments : [...segments, toSegment(base)]);
49
- }
50
- };
51
- walk(pagesDir, []);
52
- routes.sort((a, b) => a.path.localeCompare(b.path));
53
- return routes;
54
- }
@@ -1,9 +0,0 @@
1
- import type { TemplateWrapStyle } from '../../apply-wrap-templates.js';
2
- /**
3
- * Nuxt template wraps: the useFimoT composable is client-safe (fimo/nuxt
4
- * never pulls server loaders into the bundle) and transfers the dictionary
5
- * through the Nuxt payload, so a single `<script setup>` line wires a file.
6
- * Options-API scripts have no safe injection point (top-level await needs
7
- * setup) — those files stay agent work.
8
- */
9
- export declare const nuxtTemplateWrapStyle: TemplateWrapStyle;
@@ -1,27 +0,0 @@
1
- /**
2
- * Nuxt template wraps: the useFimoT composable is client-safe (fimo/nuxt
3
- * never pulls server loaders into the bundle) and transfers the dictionary
4
- * through the Nuxt payload, so a single `<script setup>` line wires a file.
5
- * Options-API scripts have no safe injection point (top-level await needs
6
- * setup) — those files stay agent work.
7
- */
8
- export const nuxtTemplateWrapStyle = {
9
- ext: '.vue',
10
- head: "import { useFimoT } from 'fimo/nuxt'\nconst t = await useFimoT()",
11
- headMarker: /useFimoT/,
12
- open: '{{ t(',
13
- close: ') }}',
14
- injectHead: (code, head) => {
15
- // An SFC may carry BOTH <script> and <script setup>: target the setup
16
- // block specifically (top-level await is only legal there).
17
- const setup = code.match(/<script[^>]*\bsetup\b[^>]*>\r?\n?/);
18
- if (setup && setup.index !== undefined) {
19
- const at = setup.index + setup[0].length;
20
- return `${code.slice(0, at)}${head}\n${code.slice(at)}`;
21
- }
22
- if (/<script\b/.test(code)) {
23
- return null;
24
- }
25
- return `<script setup>\n${head}\n</script>\n\n${code}`;
26
- },
27
- };
@@ -1,3 +0,0 @@
1
- import type { DiscoveredRoute } from '../next/routes.js';
2
- /** Remix v2 flat routes under app/routes: dots are slashes, $param is dynamic. */
3
- export declare function discoverRemixRoutes(routesDir: string): DiscoveredRoute[];
@@ -1,50 +0,0 @@
1
- import { readdirSync } from 'node:fs';
2
- const titleCase = (seg) => seg
3
- .replace(/[_\-]+/g, ' ')
4
- .replace(/([a-z])([A-Z])/g, '$1 $2')
5
- .split(/\s+/)
6
- .filter(Boolean)
7
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
8
- .join(' ');
9
- function pushRoute(routes, parts) {
10
- const routePath = `/${parts.join('/')}`.replace(/\/+/g, '/');
11
- const lastStatic = [...parts].reverse().find((part) => !part.startsWith(':'));
12
- routes.push({
13
- id: routePath === '/' ? 'home' : parts.map((part) => part.replace(/^:/, '')).join('-'),
14
- path: routePath,
15
- label: routePath === '/' ? 'Home' : titleCase(lastStatic ?? parts[parts.length - 1] ?? routePath),
16
- });
17
- }
18
- const FILE_EXT = /\.(tsx|jsx|ts|js|mdx)$/;
19
- /** Remix v2 flat routes under app/routes: dots are slashes, $param is dynamic. */
20
- export function discoverRemixRoutes(routesDir) {
21
- const routes = [];
22
- let entries;
23
- try {
24
- entries = readdirSync(routesDir);
25
- }
26
- catch {
27
- return routes;
28
- }
29
- for (const entry of entries) {
30
- if (!FILE_EXT.test(entry)) {
31
- continue;
32
- }
33
- const base = entry.replace(FILE_EXT, '');
34
- if (base === '_index') {
35
- pushRoute(routes, []);
36
- continue;
37
- }
38
- // Pathless layout segments start with _ ; trailing ._index maps to the parent.
39
- const parts = base
40
- .replace(/\._index$/, '')
41
- .split('.')
42
- .filter((seg) => !seg.startsWith('_'))
43
- .map((seg) => (seg.startsWith('$') ? `:${seg.slice(1) || 'splat'}` : seg));
44
- if (parts.length > 0) {
45
- pushRoute(routes, parts);
46
- }
47
- }
48
- routes.sort((a, b) => a.path.localeCompare(b.path));
49
- return routes;
50
- }
@@ -1,75 +0,0 @@
1
- import type { FrameworkDetection } from '../detect-framework.js';
2
- /**
3
- * A host dependency the wrap gates on, with the floor Fimo's runtime requires.
4
- * The floor is honest to the API surface the in-tree runtime actually uses —
5
- * React frameworks gate on `react` 18 (the runtime touches `useSyncExternalStore`),
6
- * Vue/Svelte/Astro on their own framework floor. The version gate is what turns
7
- * an unsupported host into one actionable sentence instead of an npm `ERESOLVE`
8
- * or an install-then-crash.
9
- */
10
- export interface SupportCheck {
11
- pkg: string;
12
- /** Floor, `X.Y.Z`. */
13
- min: string;
14
- label: string;
15
- /** Why this floor exists — shown to the user. */
16
- reason: string;
17
- /** One actionable next step — shown as the error hint. */
18
- remedy: string;
19
- }
20
- /**
21
- * The runtime-floor checks for a detected framework. React-based frameworks all
22
- * gate on `react`; the template frameworks gate on their own package. Frameworks
23
- * with no runtime coupling (or none detected) return [] — nothing to gate.
24
- */
25
- export declare function supportChecksFor(detection: Pick<FrameworkDetection, 'framework' | 'react'>): SupportCheck[];
26
- interface ParsedVersion {
27
- major: number;
28
- minor: number;
29
- patch: number;
30
- /** The original spec, for display. */
31
- raw: string;
32
- }
33
- /**
34
- * The lowest concrete version a spec implies. Handles the shapes seen in real
35
- * package.json / installed manifests: `^18.2.0`, `~3.4`, `>=2.0.0`, `18 || 19`,
36
- * `18.3.1`, ` >= 14.0.0 `, bare `18`. Returns null for anything without a
37
- * numeric floor (`latest`, `*`, `workspace:*`, `catalog:`, a git/file url) — we
38
- * never gate on a version we cannot read.
39
- */
40
- export declare function parseVersionFloor(spec: string): ParsedVersion | null;
41
- /**
42
- * The host's version of `pkg`. Prefers the INSTALLED manifest
43
- * (`node_modules/<pkg>/package.json`) — the ground truth of what will run —
44
- * and falls back to the declared range floor in the host package.json (a fresh
45
- * clone before install). Returns null when neither is readable.
46
- */
47
- export declare function readHostVersion(cwd: string, pkg: string): ParsedVersion | null;
48
- export interface HostSupportViolation {
49
- subject: string;
50
- /** The version we found on the host. */
51
- found: string;
52
- /** The floor Fimo requires. */
53
- min: string;
54
- /** Headline sentence for the error message. */
55
- headline: string;
56
- /** Actionable next step for the error hint. */
57
- remedy: string;
58
- }
59
- export interface HostSupportResult {
60
- ok: boolean;
61
- violations: HostSupportViolation[];
62
- /** Versions read successfully — for the summary line ("React 18.3.1"). */
63
- detected: Array<{
64
- label: string;
65
- version: string;
66
- }>;
67
- }
68
- /**
69
- * Gate the wrap on the host's framework/runtime versions. Silent for supported
70
- * hosts (the common case); returns one violation per below-floor dependency so
71
- * the caller can stop with a clear message. A version we cannot read is never a
72
- * violation — the peer range and the install still catch a genuinely absent dep.
73
- */
74
- export declare function checkHostSupport(cwd: string, detection: Pick<FrameworkDetection, 'framework' | 'react'>): HostSupportResult;
75
- export {};
@@ -1,165 +0,0 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- const REACT_CHECK = {
4
- pkg: 'react',
5
- min: '18.0.0',
6
- label: 'React',
7
- reason: "Fimo's inline-editing runtime uses React 18 APIs (useSyncExternalStore).",
8
- remedy: 'Upgrade React to 18 or newer. The content still migrates on older React; only inline editing needs 18+.',
9
- };
10
- /**
11
- * The runtime-floor checks for a detected framework. React-based frameworks all
12
- * gate on `react`; the template frameworks gate on their own package. Frameworks
13
- * with no runtime coupling (or none detected) return [] — nothing to gate.
14
- */
15
- export function supportChecksFor(detection) {
16
- switch (detection.framework) {
17
- case 'next':
18
- case 'remix':
19
- case 'react-router':
20
- return [REACT_CHECK];
21
- case 'vite':
22
- return detection.react ? [REACT_CHECK] : [];
23
- case 'nuxt':
24
- return [
25
- {
26
- pkg: 'nuxt',
27
- min: '3.0.0',
28
- label: 'Nuxt',
29
- reason: 'Fimo supports Nuxt 3+ (Vue 3). Nuxt 2 is end-of-life.',
30
- remedy: 'Upgrade to Nuxt 3 or newer.',
31
- },
32
- ];
33
- case 'vue':
34
- return [
35
- {
36
- pkg: 'vue',
37
- min: '3.0.0',
38
- label: 'Vue',
39
- reason: 'Fimo supports Vue 3+. Vue 2 is end-of-life.',
40
- remedy: 'Upgrade to Vue 3 or newer.',
41
- },
42
- ];
43
- case 'astro':
44
- return [
45
- {
46
- pkg: 'astro',
47
- min: '4.0.0',
48
- label: 'Astro',
49
- reason: 'Fimo supports Astro 4+.',
50
- remedy: 'Upgrade Astro to 4 or newer.',
51
- },
52
- ];
53
- case 'sveltekit':
54
- return [
55
- {
56
- pkg: '@sveltejs/kit',
57
- min: '2.0.0',
58
- label: 'SvelteKit',
59
- reason: 'Fimo supports SvelteKit 2+.',
60
- remedy: 'Upgrade @sveltejs/kit to 2 or newer.',
61
- },
62
- ];
63
- default:
64
- return [];
65
- }
66
- }
67
- /**
68
- * The lowest concrete version a spec implies. Handles the shapes seen in real
69
- * package.json / installed manifests: `^18.2.0`, `~3.4`, `>=2.0.0`, `18 || 19`,
70
- * `18.3.1`, ` >= 14.0.0 `, bare `18`. Returns null for anything without a
71
- * numeric floor (`latest`, `*`, `workspace:*`, `catalog:`, a git/file url) — we
72
- * never gate on a version we cannot read.
73
- */
74
- export function parseVersionFloor(spec) {
75
- if (!spec) {
76
- return null;
77
- }
78
- // A `||` union — the floor is the lowest branch, i.e. the first token.
79
- const first = spec.split('||')[0];
80
- const match = first.match(/(\d+)(?:\.(\d+))?(?:\.(\d+))?/);
81
- if (!match) {
82
- return null;
83
- }
84
- return {
85
- major: Number(match[1]),
86
- minor: match[2] ? Number(match[2]) : 0,
87
- patch: match[3] ? Number(match[3]) : 0,
88
- raw: spec.trim(),
89
- };
90
- }
91
- function isBelowFloor(found, min) {
92
- const floor = parseVersionFloor(min);
93
- if (!floor) {
94
- return false;
95
- }
96
- if (found.major !== floor.major) {
97
- return found.major < floor.major;
98
- }
99
- if (found.minor !== floor.minor) {
100
- return found.minor < floor.minor;
101
- }
102
- return found.patch < floor.patch;
103
- }
104
- /**
105
- * The host's version of `pkg`. Prefers the INSTALLED manifest
106
- * (`node_modules/<pkg>/package.json`) — the ground truth of what will run —
107
- * and falls back to the declared range floor in the host package.json (a fresh
108
- * clone before install). Returns null when neither is readable.
109
- */
110
- export function readHostVersion(cwd, pkg) {
111
- const installed = join(cwd, 'node_modules', pkg, 'package.json');
112
- if (existsSync(installed)) {
113
- try {
114
- const version = JSON.parse(readFileSync(installed, 'utf8')).version;
115
- const parsed = parseVersionFloor(String(version));
116
- if (parsed) {
117
- return parsed;
118
- }
119
- }
120
- catch {
121
- // fall through to the declared range
122
- }
123
- }
124
- const rootPkg = join(cwd, 'package.json');
125
- if (existsSync(rootPkg)) {
126
- try {
127
- const pkgJson = JSON.parse(readFileSync(rootPkg, 'utf8'));
128
- const spec = { ...pkgJson.dependencies, ...pkgJson.devDependencies }[pkg];
129
- if (spec) {
130
- return parseVersionFloor(String(spec));
131
- }
132
- }
133
- catch {
134
- // unreadable — nothing to gate on
135
- }
136
- }
137
- return null;
138
- }
139
- /**
140
- * Gate the wrap on the host's framework/runtime versions. Silent for supported
141
- * hosts (the common case); returns one violation per below-floor dependency so
142
- * the caller can stop with a clear message. A version we cannot read is never a
143
- * violation — the peer range and the install still catch a genuinely absent dep.
144
- */
145
- export function checkHostSupport(cwd, detection) {
146
- const violations = [];
147
- const detected = [];
148
- for (const check of supportChecksFor(detection)) {
149
- const found = readHostVersion(cwd, check.pkg);
150
- if (!found) {
151
- continue;
152
- }
153
- detected.push({ label: check.label, version: found.raw });
154
- if (isBelowFloor(found, check.min)) {
155
- violations.push({
156
- subject: check.label,
157
- found: found.raw,
158
- min: check.min,
159
- headline: `${check.label} ${found.raw} is below Fimo's floor of ${check.label} ${check.min}. ${check.reason}`,
160
- remedy: check.remedy,
161
- });
162
- }
163
- }
164
- return { ok: violations.length === 0, violations, detected };
165
- }
@@ -1,3 +0,0 @@
1
- import type { DiscoveredRoute } from '../next/routes.js';
2
- /** SvelteKit routes: every directory under src/routes holding a +page file. */
3
- export declare function discoverSvelteKitRoutes(routesDir: string): DiscoveredRoute[];
@@ -1,50 +0,0 @@
1
- import { readdirSync, statSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- const titleCase = (seg) => seg
4
- .replace(/[_\-]+/g, ' ')
5
- .replace(/([a-z])([A-Z])/g, '$1 $2')
6
- .split(/\s+/)
7
- .filter(Boolean)
8
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
9
- .join(' ');
10
- function pushRoute(routes, parts) {
11
- const routePath = `/${parts.join('/')}`.replace(/\/+/g, '/');
12
- const lastStatic = [...parts].reverse().find((part) => !part.startsWith(':'));
13
- routes.push({
14
- id: routePath === '/' ? 'home' : parts.map((part) => part.replace(/^:/, '')).join('-'),
15
- path: routePath,
16
- label: routePath === '/' ? 'Home' : titleCase(lastStatic ?? parts[parts.length - 1] ?? routePath),
17
- });
18
- }
19
- const toSegment = (name) => name.replace(/^\[\.\.\.(.+)\]$/, ':$1').replace(/^\[(.+)\]$/, ':$1');
20
- /** SvelteKit routes: every directory under src/routes holding a +page file. */
21
- export function discoverSvelteKitRoutes(routesDir) {
22
- const routes = [];
23
- const walk = (dir, segments) => {
24
- let entries;
25
- try {
26
- entries = readdirSync(dir);
27
- }
28
- catch {
29
- return;
30
- }
31
- if (entries.some((entry) => /^\+page\.(svelte|md)$/.test(entry))) {
32
- // Route groups (parens) are layout-only segments.
33
- pushRoute(routes, segments.filter((seg) => !seg.startsWith('(')));
34
- }
35
- for (const entry of entries) {
36
- const full = join(dir, entry);
37
- try {
38
- if (statSync(full).isDirectory()) {
39
- walk(full, [...segments, toSegment(entry)]);
40
- }
41
- }
42
- catch {
43
- continue;
44
- }
45
- }
46
- };
47
- walk(routesDir, []);
48
- routes.sort((a, b) => a.path.localeCompare(b.path));
49
- return routes;
50
- }
@@ -1,9 +0,0 @@
1
- import { type TemplateWrapStyle } from '../../apply-wrap-templates.js';
2
- /**
3
- * SvelteKit template wraps. The t binding is deliberately a mode-agnostic
4
- * `const` — a `$derived` flips a legacy component into runes mode (breaking
5
- * its own `$:` statements) and a `$:` reactive runs after init (arrays built
6
- * at init see undefined). Labels only change with a reload in edit mode,
7
- * which the wrap contract accepts.
8
- */
9
- export declare const svelteTemplateWrapStyle: TemplateWrapStyle;
@@ -1,54 +0,0 @@
1
- import { existsSync, writeFileSync } from 'node:fs';
2
- import { basename, dirname, join } from 'node:path';
3
- import { injectIntoInstanceScript } from '../../apply-wrap-templates.js';
4
- import { slugify } from '../../apply-wrap.js';
5
- /**
6
- * SvelteKit template wraps. The t binding is deliberately a mode-agnostic
7
- * `const` — a `$derived` flips a legacy component into runes mode (breaking
8
- * its own `$:` statements) and a `$:` reactive runs after init (arrays built
9
- * at init see undefined). Labels only change with a reload in edit mode,
10
- * which the wrap contract accepts.
11
- */
12
- export const svelteTemplateWrapStyle = {
13
- ext: '.svelte',
14
- head: "import { page } from '$app/stores';\n\timport { makeFimoT } from 'fimo/svelte';\n\tconst t = makeFimoT($page.data.fimoLabels);",
15
- headMarker: /makeFimoT/,
16
- open: '{t(',
17
- close: ')}',
18
- injectHead: (code, head) => injectIntoInstanceScript(code, head, '<script>'),
19
- // Route-convention filenames carry no meaning: scope +page/+layout keys by
20
- // their route directory (src/routes/pricing/+page.svelte -> "pricing").
21
- fileScope: (file) => {
22
- const stem = basename(file).replace(/\.svelte$/, '');
23
- if (!stem.startsWith('+')) {
24
- return null;
25
- }
26
- const dir = basename(dirname(file));
27
- if (!dir || dir === 'routes' || dir === 'src') {
28
- return stem === '+layout' ? 'layout' : 'home';
29
- }
30
- return slugify(dir) || 'home';
31
- },
32
- // The store form reads $page.data.fimoLabels: wire the root server load
33
- // once when the project has none. An existing +layout.server.* is agent
34
- // work (merging into a user load function is judgment, and until then the
35
- // inline fallbacks keep rendering identical).
36
- ensureWiring: (rootDir) => {
37
- const routesDir = join(rootDir, 'src', 'routes');
38
- const existing = ['+layout.server.js', '+layout.server.ts'].some((name) => existsSync(join(routesDir, name)));
39
- if (existing || !existsSync(routesDir)) {
40
- return [];
41
- }
42
- const layoutPath = join(routesDir, '+layout.server.js');
43
- writeFileSync(layoutPath, [
44
- "import { loadFimoLabels } from 'fimo/svelte/server';",
45
- '',
46
- 'export const load = async () => {',
47
- '\tconst labels = await loadFimoLabels();',
48
- '\treturn { fimoLabels: labels.dictionaries[labels.defaultLocale] ?? {} };',
49
- '};',
50
- '',
51
- ].join('\n'));
52
- return ['src/routes/+layout.server.js'];
53
- },
54
- };
@@ -1,15 +0,0 @@
1
- import type { DiscoveredRoute } from '../next/routes.js';
2
- /**
3
- * Route discovery for Vite React SPAs: there is no file convention, so the
4
- * routes live in react-router code. v1 reads LITERAL, ABSOLUTE paths from the
5
- * two mainstream declaration shapes —
6
- *
7
- * <Route path="/pricing" element={…} /> (JSX tree)
8
- * createBrowserRouter([{ path: '/pricing', … }]) (object form)
9
- *
10
- * — in files that import react-router. Relative child paths and index routes
11
- * need the router's nesting semantics to resolve; they (and `*` wildcards)
12
- * stay out of v1: the fimo-config route registry accepts manual entries for
13
- * anything the scan cannot see, and scanned routes only ever ADD to it.
14
- */
15
- export declare function discoverReactRouterDomRoutes(rootDir: string): DiscoveredRoute[];
@@ -1,93 +0,0 @@
1
- import { readdirSync, readFileSync, statSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- const titleCase = (seg) => seg
4
- .replace(/[_\-]+/g, ' ')
5
- .replace(/([a-z])([A-Z])/g, '$1 $2')
6
- .split(/\s+/)
7
- .filter(Boolean)
8
- .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
9
- .join(' ');
10
- const ROUTE_SOURCE = /\.(tsx|jsx|ts|js)$/;
11
- const SKIP_DIRS = new Set(['node_modules', 'dist', 'build', '.git']);
12
- /**
13
- * Route discovery for Vite React SPAs: there is no file convention, so the
14
- * routes live in react-router code. v1 reads LITERAL, ABSOLUTE paths from the
15
- * two mainstream declaration shapes —
16
- *
17
- * <Route path="/pricing" element={…} /> (JSX tree)
18
- * createBrowserRouter([{ path: '/pricing', … }]) (object form)
19
- *
20
- * — in files that import react-router. Relative child paths and index routes
21
- * need the router's nesting semantics to resolve; they (and `*` wildcards)
22
- * stay out of v1: the fimo-config route registry accepts manual entries for
23
- * anything the scan cannot see, and scanned routes only ever ADD to it.
24
- */
25
- export function discoverReactRouterDomRoutes(rootDir) {
26
- const srcDir = join(rootDir, 'src');
27
- const files = [];
28
- const walk = (dir) => {
29
- let entries;
30
- try {
31
- entries = readdirSync(dir);
32
- }
33
- catch {
34
- return;
35
- }
36
- for (const entry of entries) {
37
- if (SKIP_DIRS.has(entry)) {
38
- continue;
39
- }
40
- const full = join(dir, entry);
41
- let isDir = false;
42
- try {
43
- isDir = statSync(full).isDirectory();
44
- }
45
- catch {
46
- continue;
47
- }
48
- if (isDir) {
49
- walk(full);
50
- }
51
- else if (ROUTE_SOURCE.test(entry)) {
52
- files.push(full);
53
- }
54
- }
55
- };
56
- walk(srcDir);
57
- const routes = new Map();
58
- for (const file of files) {
59
- let code;
60
- try {
61
- code = readFileSync(file, 'utf8');
62
- }
63
- catch {
64
- continue;
65
- }
66
- if (!/from\s+['"]react-router(?:-dom)?['"]/.test(code)) {
67
- continue;
68
- }
69
- const paths = [
70
- ...[...code.matchAll(/<Route\b[^>]*\bpath\s*=\s*(?:"([^"]+)"|'([^']+)'|\{\s*(?:"([^"]+)"|'([^']+)')\s*\})/g)],
71
- ...[...code.matchAll(/\bpath\s*:\s*(?:"([^"]+)"|'([^']+)')/g)],
72
- ]
73
- .map((match) => match.slice(1).find(Boolean))
74
- .filter((path) => typeof path === 'string');
75
- for (const raw of paths) {
76
- if (!raw.startsWith('/') || raw.includes('*')) {
77
- continue;
78
- }
79
- const path = raw !== '/' && raw.endsWith('/') ? raw.slice(0, -1) : raw;
80
- if (routes.has(path)) {
81
- continue;
82
- }
83
- const parts = path.split('/').filter(Boolean);
84
- const lastStatic = [...parts].reverse().find((part) => !part.startsWith(':'));
85
- routes.set(path, {
86
- id: path === '/' ? 'home' : parts.map((part) => part.replace(/^:/, '')).join('-'),
87
- path,
88
- label: path === '/' ? 'Home' : titleCase(lastStatic ?? parts[parts.length - 1] ?? path),
89
- });
90
- }
91
- }
92
- return [...routes.values()].sort((a, b) => a.path.localeCompare(b.path));
93
- }
@@ -1,10 +0,0 @@
1
- import type { RootWiringResult } from '../next/wiring.js';
2
- /**
3
- * Vite React SPA root wiring: wrap the root render argument with
4
- * `FimoSpaProviders` (client-side label fetch; inline fallbacks until it
5
- * resolves) and import the project's fimo-config.json. Only the mainstream
6
- * entry shape is touched — a `createRoot(…).render(<JSX/>)` (or legacy
7
- * `ReactDOM.render(<JSX/>, …)`) call whose first argument is a JSX element.
8
- * Anything else bails with the reason and stays agent work via the recipe.
9
- */
10
- export declare function ensureSpaEntryWiring(cwd: string): RootWiringResult;