fimo 0.20.0 → 0.21.0-experimental.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/agent-templates/_default/GOAL.md +10 -0
- package/assets/agent-templates/_default/capabilities.yaml +10 -0
- package/assets/content-templates/shared/types.eta +1 -1
- package/assets/skills/fimo-cli/SKILL.md +2 -1
- package/assets/skills/fimo-cli/references/agents.md +136 -36
- package/assets/skills/fimo-cli/references/branches.md +8 -5
- package/assets/skills/fimo-cli/references/deploy.md +11 -2
- package/assets/skills/fimo-cli/references/domains.md +12 -0
- package/assets/skills/fimo-cli/references/forms.md +1 -1
- package/assets/skills/fimo-cli/references/init.md +9 -2
- package/assets/skills/fimo-cli/references/locales.md +1 -1
- package/assets/skills/fimo-cli/references/mcp.md +1 -1
- package/assets/skills/fimo-cli/references/media.md +18 -1
- package/assets/skills/fimo-cli/references/project-vars-and-secrets.md +3 -1
- package/assets/skills/fimo-cli/references/projects.md +7 -7
- package/assets/skills/fimo-code/assets/react-router-locales/navigation.tsx +1 -1
- package/assets/skills/fimo-code/references/assets.md +2 -2
- package/assets/skills/fimo-code/references/best-practices/next.md +1 -1
- package/assets/skills/fimo-code/references/content/schema.md +23 -0
- package/assets/skills/fimo-code/references/forms.md +1 -1
- package/assets/skills/fimo-code/references/frameworks/astro.md +8 -2
- package/assets/skills/fimo-code/references/frameworks/compatibility.md +9 -9
- package/assets/skills/fimo-code/references/frameworks/hosting.md +17 -13
- package/assets/skills/fimo-code/references/frameworks/next/app-router.md +8 -9
- package/assets/skills/fimo-code/references/frameworks/next/locales.md +5 -5
- package/assets/skills/fimo-code/references/frameworks/next/pages-router.md +5 -5
- package/assets/skills/fimo-code/references/frameworks/next.md +41 -32
- package/assets/skills/fimo-code/references/frameworks/react-router.md +10 -7
- package/assets/skills/fimo-code/references/frameworks/sveltekit.md +22 -15
- package/assets/skills/fimo-code/references/frameworks/vite-react.md +7 -5
- package/assets/skills/fimo-code/references/labels.md +4 -4
- package/assets/skills/fimo-code/references/locales.md +2 -2
- package/assets/skills/fimo-code/references/ui.md +4 -4
- package/assets/skills/fimo-migration/SKILL.md +51 -30
- package/assets/skills/fimo-migration/references/frameworks/nextjs.md +12 -15
- package/assets/skills/fimo-migration/references/media.md +12 -8
- package/assets/skills/fimo-migration/references/qa.md +12 -11
- package/assets/skills/fimo-migration/references/workers/content-planner.md +33 -4
- package/assets/skills/fimo-migration/references/workers/validator.md +10 -0
- package/assets/skills/fimo-migration/references/workers.md +19 -10
- package/assets/skills/fimo-migration/references/workflow.md +29 -11
- package/assets/skills/fimo-studio/references/ai-chat.md +1 -1
- package/assets/skills/fimo-studio/references/billing-and-credits.md +18 -1
- package/assets/skills/fimo-studio/references/cms.md +2 -0
- package/assets/skills/fimo-studio/references/preview-and-responsive.md +1 -0
- package/assets/starters/fimo-site/template/src/pages/Contact.tsx +1 -1
- package/assets/starters/fimo-site/template/src/pages/SiteContent.tsx +1 -1
- package/assets/starters/fimo-site/template/src/schemas/HomePage.ts +3 -3
- package/assets/starters/fimo-site/template/src/schemas/HomePage.types.ts +1 -1
- package/dist/build/astro/config.d.ts +13 -2
- package/dist/build/astro/config.js +9 -24
- package/dist/build/next/moved.d.ts +2 -0
- package/dist/build/next/moved.js +2 -0
- package/dist/build/react/router-moved.d.ts +2 -0
- package/dist/build/react/router-moved.js +2 -0
- package/dist/build/react/router-preset-moved.d.ts +2 -0
- package/dist/build/react/router-preset-moved.js +2 -0
- package/dist/build/react/router-routes-moved.d.ts +2 -0
- package/dist/build/react/router-routes-moved.js +2 -0
- package/dist/build/react/ui-moved.d.ts +2 -0
- package/dist/build/react/ui-moved.js +2 -0
- package/dist/build/react/vite-moved.d.ts +2 -0
- package/dist/build/react/vite-moved.js +2 -0
- package/dist/build/sveltekit/config.d.ts +5 -4
- package/dist/build/sveltekit/config.js +6 -15
- package/dist/build/sveltekit/moved.d.ts +13 -0
- package/dist/build/sveltekit/moved.js +3 -0
- package/dist/build/vite/data-id.d.ts +11 -0
- package/dist/build/vite/data-id.js +20 -0
- package/dist/build/vite/plugins/runtime-env.d.ts +1 -1
- package/dist/build/vite/plugins/runtime-env.js +6 -2
- package/dist/build/vite/runtime-env.d.ts +2 -0
- package/dist/build/vite/runtime-env.js +1 -0
- package/dist/cli/bundle.json +1 -1
- package/dist/cli/index.js +115 -110
- package/dist/runtime/content/client/internal.js +1 -1
- package/dist/runtime/content/index.d.ts +6 -1
- package/dist/runtime/content/index.js +6 -0
- package/dist/runtime/i18n/index.d.ts +2 -0
- package/dist/runtime/i18n/index.js +1 -0
- package/dist/runtime/labels/index.d.ts +3 -0
- package/dist/runtime/labels/index.js +2 -0
- package/dist/runtime/preview/index.d.ts +5 -0
- package/dist/runtime/preview/index.js +4 -0
- package/dist/runtime/preview/script.d.ts +3 -0
- package/dist/runtime/preview/script.js +14 -0
- package/dist/runtime/primitives/lib/index.d.ts +2 -0
- package/dist/runtime/primitives/lib/index.js +2 -0
- package/dist/runtime/seo/index.d.ts +0 -8
- package/dist/runtime/seo/index.js +0 -8
- package/dist/runtime/shared/config.d.ts +6 -0
- package/dist/runtime/shared/config.js +4 -0
- package/dist/runtime/shared/local-runtime-env.d.ts +2 -2
- package/dist/runtime/shared/local-runtime-env.js +7 -5
- package/dist/runtime/templates.d.ts +20 -4
- package/dist/runtime/templates.js +60 -18
- package/dist/scripts/extract-translations.js +8 -3
- package/dist/scripts/index.d.ts +3 -0
- package/dist/scripts/index.js +2 -0
- package/dist/scripts/sync-forms.js +21 -9
- package/dist/scripts/sync-schemas.js +129 -21
- package/dist/scripts/validate-schemas.js +63 -2
- package/package.json +72 -71
- package/release.json +2 -2
- package/templates/astro/AGENTS.md +1 -1
- package/templates/astro/astro.config.mjs +1 -1
- package/templates/astro/package.json +4 -2
- package/templates/astro/pnpm-workspace.yaml +6 -2
- package/templates/nextjs/.fimo/config.json +1 -2
- package/templates/nextjs/AGENTS.md +6 -16
- package/templates/nextjs/next.config.ts +4 -2
- package/templates/nextjs/package.json +4 -2
- package/templates/nextjs/pnpm-workspace.yaml +6 -2
- package/templates/nextjs/src/app/layout.tsx +16 -0
- package/templates/nextjs/src/locales.ts +3 -6
- package/templates/react-router/AGENTS.md +1 -1
- package/templates/react-router/package.json +5 -2
- package/templates/react-router/pnpm-workspace.yaml +6 -6
- package/templates/react-router/react-router.config.ts +1 -1
- package/templates/react-router/src/pages/legal/LegalPage.tsx +1 -1
- package/templates/react-router/src/root.tsx +1 -1
- package/templates/react-router/src/vite-env.d.ts +0 -1
- package/templates/react-router/vite.config.ts +1 -1
- package/templates/sveltekit/AGENTS.md +1 -1
- package/templates/sveltekit/package.json +4 -2
- package/templates/sveltekit/pnpm-workspace.yaml +6 -2
- package/templates/sveltekit/src/routes/+layout.server.ts +1 -1
- package/templates/sveltekit/src/routes/+layout.svelte +1 -1
- package/templates/sveltekit/svelte.config.js +1 -1
- package/templates/sveltekit/vite.config.ts +1 -1
- package/assets/sveltekit/components/Boolean.svelte +0 -19
- package/assets/sveltekit/components/Date.svelte +0 -33
- package/assets/sveltekit/components/DateTime.svelte +0 -35
- package/assets/sveltekit/components/FimoProvider.svelte +0 -35
- package/assets/sveltekit/components/Image.svelte +0 -80
- package/assets/sveltekit/components/Json.svelte +0 -18
- package/assets/sveltekit/components/Label.svelte +0 -16
- package/assets/sveltekit/components/Number.svelte +0 -21
- package/assets/sveltekit/components/RichText.svelte +0 -19
- package/assets/sveltekit/components/Text.svelte +0 -30
- package/assets/sveltekit/components/Video.svelte +0 -37
- package/assets/sveltekit/components/index.d.ts +0 -11
- package/assets/sveltekit/components/index.js +0 -11
- package/dist/build/next/config.d.ts +0 -17
- package/dist/build/next/config.js +0 -66
- package/dist/build/sveltekit/data-id.d.ts +0 -3
- package/dist/build/sveltekit/data-id.js +0 -171
- package/dist/build/sveltekit/files/edge.js +0 -68
- package/dist/build/sveltekit/files/serverless.js +0 -42
- package/dist/build/sveltekit/vite.d.ts +0 -12
- package/dist/build/sveltekit/vite.js +0 -14
- package/dist/build/vite/index.d.ts +0 -42
- package/dist/build/vite/index.js +0 -160
- package/dist/build/vite/plugins/content-sync.d.ts +0 -11
- package/dist/build/vite/plugins/content-sync.js +0 -41
- package/dist/build/vite/plugins/data-id.d.ts +0 -12
- package/dist/build/vite/plugins/data-id.js +0 -109
- package/dist/build/vite/plugins/fimo-config.d.ts +0 -12
- package/dist/build/vite/plugins/fimo-config.js +0 -68
- package/dist/build/vite/plugins/overlay.d.ts +0 -3
- package/dist/build/vite/plugins/overlay.js +0 -154
- package/dist/build/vite/plugins/robots.d.ts +0 -10
- package/dist/build/vite/plugins/robots.js +0 -56
- package/dist/build/vite/plugins/seo.d.ts +0 -3
- package/dist/build/vite/plugins/seo.js +0 -112
- package/dist/build/vite/plugins/server-config.d.ts +0 -3
- package/dist/build/vite/plugins/server-config.js +0 -36
- package/dist/build/vite/plugins/sitemap.d.ts +0 -3
- package/dist/build/vite/plugins/sitemap.js +0 -73
- package/dist/build/vite/plugins/translations.d.ts +0 -11
- package/dist/build/vite/plugins/translations.js +0 -601
- package/dist/runtime/app/FimoProviders.d.ts +0 -30
- package/dist/runtime/app/FimoProviders.js +0 -186
- package/dist/runtime/app/FimoScripts.d.ts +0 -14
- package/dist/runtime/app/FimoScripts.js +0 -48
- package/dist/runtime/app/index.d.ts +0 -8
- package/dist/runtime/app/index.js +0 -4
- package/dist/runtime/app/prefetch.d.ts +0 -9
- package/dist/runtime/app/prefetch.js +0 -39
- package/dist/runtime/content/DataSourcesProvider.d.ts +0 -4
- package/dist/runtime/content/DataSourcesProvider.js +0 -63
- package/dist/runtime/content/RefreshContentProvider.d.ts +0 -19
- package/dist/runtime/content/RefreshContentProvider.js +0 -71
- package/dist/runtime/content/client/createContentClient.d.ts +0 -7
- package/dist/runtime/content/client/createContentClient.js +0 -7
- package/dist/runtime/content/client/createSingletonClient.d.ts +0 -5
- package/dist/runtime/content/client/createSingletonClient.js +0 -6
- package/dist/runtime/content/client/react-content-client.d.ts +0 -10
- package/dist/runtime/content/client/react-content-client.js +0 -165
- package/dist/runtime/content/client/react-singleton-client.d.ts +0 -7
- package/dist/runtime/content/client/react-singleton-client.js +0 -38
- package/dist/runtime/content/client/types.d.ts +0 -42
- package/dist/runtime/content/client/types.js +0 -1
- package/dist/runtime/content/client/useQueryLocale.d.ts +0 -2
- package/dist/runtime/content/client/useQueryLocale.js +0 -5
- package/dist/runtime/content/client/vite-runtime.d.ts +0 -3
- package/dist/runtime/content/client/vite-runtime.js +0 -23
- package/dist/runtime/content/utils/retrieve-data-sources.d.ts +0 -29
- package/dist/runtime/content/utils/retrieve-data-sources.js +0 -107
- package/dist/runtime/core/AppErrorBoundary.d.ts +0 -10
- package/dist/runtime/core/AppErrorBoundary.js +0 -27
- package/dist/runtime/core/ViteLifecycles.d.ts +0 -5
- package/dist/runtime/core/ViteLifecycles.js +0 -35
- package/dist/runtime/i18n/FimoLocaleContext.d.ts +0 -9
- package/dist/runtime/i18n/FimoLocaleContext.js +0 -17
- package/dist/runtime/iframe/ConsoleErrorProvider.d.ts +0 -3
- package/dist/runtime/iframe/ConsoleErrorProvider.js +0 -103
- package/dist/runtime/iframe/ScreenshotProvider.d.ts +0 -3
- package/dist/runtime/iframe/ScreenshotProvider.js +0 -60
- package/dist/runtime/iframe/runtime/overlay-hmr.d.ts +0 -2
- package/dist/runtime/iframe/runtime/overlay-hmr.js +0 -27
- package/dist/runtime/iframe/runtime/overlay-runtime.d.ts +0 -2
- package/dist/runtime/iframe/runtime/overlay-runtime.js +0 -103
- package/dist/runtime/index.d.ts +0 -22
- package/dist/runtime/index.js +0 -23
- package/dist/runtime/next/client-runtime.d.ts +0 -3
- package/dist/runtime/next/client-runtime.js +0 -24
- package/dist/runtime/next/client.d.ts +0 -28
- package/dist/runtime/next/client.js +0 -25
- package/dist/runtime/next/facade.d.ts +0 -8
- package/dist/runtime/next/facade.js +0 -34
- package/dist/runtime/next/labels.d.ts +0 -7
- package/dist/runtime/next/labels.js +0 -9
- package/dist/runtime/next/preview.d.ts +0 -13
- package/dist/runtime/next/preview.js +0 -34
- package/dist/runtime/next/primitives/Text.d.ts +0 -10
- package/dist/runtime/next/primitives/Text.js +0 -18
- package/dist/runtime/next/primitives/server.d.ts +0 -11
- package/dist/runtime/next/primitives/server.js +0 -54
- package/dist/runtime/next/provider.d.ts +0 -18
- package/dist/runtime/next/provider.js +0 -39
- package/dist/runtime/next/server-runtime.d.ts +0 -3
- package/dist/runtime/next/server-runtime.js +0 -23
- package/dist/runtime/next/server.d.ts +0 -21
- package/dist/runtime/next/server.js +0 -16
- package/dist/runtime/primitives/index.d.ts +0 -16
- package/dist/runtime/primitives/index.js +0 -17
- package/dist/runtime/react/primitives/contracts.d.ts +0 -94
- package/dist/runtime/react/primitives/contracts.js +0 -1
- package/dist/runtime/react/primitives/editable/Boolean.d.ts +0 -5
- package/dist/runtime/react/primitives/editable/Boolean.js +0 -11
- package/dist/runtime/react/primitives/editable/Date.d.ts +0 -4
- package/dist/runtime/react/primitives/editable/Date.js +0 -12
- package/dist/runtime/react/primitives/editable/DateTime.d.ts +0 -4
- package/dist/runtime/react/primitives/editable/DateTime.js +0 -13
- package/dist/runtime/react/primitives/editable/Image.d.ts +0 -4
- package/dist/runtime/react/primitives/editable/Image.js +0 -10
- package/dist/runtime/react/primitives/editable/Json.d.ts +0 -5
- package/dist/runtime/react/primitives/editable/Json.js +0 -11
- package/dist/runtime/react/primitives/editable/RichText.d.ts +0 -4
- package/dist/runtime/react/primitives/editable/RichText.js +0 -11
- package/dist/runtime/react/primitives/editable/Text.d.ts +0 -20
- package/dist/runtime/react/primitives/editable/Text.js +0 -36
- package/dist/runtime/react/primitives/editable/Video.d.ts +0 -4
- package/dist/runtime/react/primitives/editable/Video.js +0 -10
- package/dist/runtime/react/primitives/renderers/DateRenderer.d.ts +0 -17
- package/dist/runtime/react/primitives/renderers/DateRenderer.js +0 -17
- package/dist/runtime/react/primitives/renderers/ImageRenderer.d.ts +0 -8
- package/dist/runtime/react/primitives/renderers/ImageRenderer.js +0 -31
- package/dist/runtime/react/primitives/renderers/RichTextRenderer.d.ts +0 -12
- package/dist/runtime/react/primitives/renderers/RichTextRenderer.js +0 -135
- package/dist/runtime/react/primitives/renderers/StaticImage.d.ts +0 -35
- package/dist/runtime/react/primitives/renderers/StaticImage.js +0 -58
- package/dist/runtime/react/primitives/renderers/VideoRenderer.d.ts +0 -8
- package/dist/runtime/react/primitives/renderers/VideoRenderer.js +0 -10
- package/dist/runtime/react/useFimoLiveValue.d.ts +0 -20
- package/dist/runtime/react/useFimoLiveValue.js +0 -43
- package/dist/runtime/react-router/active-routes.d.ts +0 -12
- package/dist/runtime/react-router/active-routes.js +0 -60
- package/dist/runtime/react-router/index.d.ts +0 -16
- package/dist/runtime/react-router/index.js +0 -20
- package/dist/runtime/react-router/legacy/routes.d.ts +0 -35
- package/dist/runtime/react-router/legacy/routes.js +0 -86
- package/dist/runtime/react-router/navigation-utils.d.ts +0 -8
- package/dist/runtime/react-router/navigation-utils.js +0 -36
- package/dist/runtime/react-router/navigation.d.ts +0 -12
- package/dist/runtime/react-router/navigation.js +0 -28
- package/dist/runtime/react-router/preset.d.ts +0 -30
- package/dist/runtime/react-router/preset.js +0 -33
- package/dist/runtime/routing/AppResetScrollOnNavigate.d.ts +0 -2
- package/dist/runtime/routing/AppResetScrollOnNavigate.js +0 -12
- package/dist/runtime/routing/AppRoutesProvider.d.ts +0 -25
- package/dist/runtime/routing/AppRoutesProvider.js +0 -112
- package/dist/runtime/seo/buildSeoForPath.d.ts +0 -74
- package/dist/runtime/seo/buildSeoForPath.js +0 -55
- package/dist/runtime/seo/htmlProps.d.ts +0 -13
- package/dist/runtime/seo/htmlProps.js +0 -15
- package/dist/runtime/sveltekit/content.d.ts +0 -25
- package/dist/runtime/sveltekit/content.js +0 -33
- package/dist/runtime/sveltekit/context-contract.d.ts +0 -5
- package/dist/runtime/sveltekit/context-contract.js +0 -2
- package/dist/runtime/sveltekit/context.d.ts +0 -8
- package/dist/runtime/sveltekit/context.js +0 -25
- package/dist/runtime/sveltekit/forms.d.ts +0 -15
- package/dist/runtime/sveltekit/forms.js +0 -15
- package/dist/runtime/sveltekit/index.d.ts +0 -9
- package/dist/runtime/sveltekit/index.js +0 -5
- package/dist/runtime/sveltekit/internal.d.ts +0 -6
- package/dist/runtime/sveltekit/internal.js +0 -12
- package/dist/runtime/sveltekit/labels.d.ts +0 -20
- package/dist/runtime/sveltekit/labels.js +0 -13
- package/dist/runtime/sveltekit/preview.d.ts +0 -28
- package/dist/runtime/sveltekit/preview.js +0 -82
- package/dist/runtime/sveltekit/runtime.d.ts +0 -9
- package/dist/runtime/sveltekit/runtime.js +0 -26
- package/dist/runtime/t/OptionalTracking.d.ts +0 -13
- package/dist/runtime/t/OptionalTracking.js +0 -28
- package/dist/runtime/t/Pageview.d.ts +0 -9
- package/dist/runtime/t/Pageview.js +0 -118
- package/dist/runtime/vite/Label.d.ts +0 -13
- package/dist/runtime/vite/Label.js +0 -16
- package/dist/runtime/vite/primitives/Images.d.ts +0 -4
- package/dist/runtime/vite/primitives/Images.js +0 -12
- package/dist/runtime/vite/translations.d.ts +0 -28
- package/dist/runtime/vite/translations.js +0 -103
- package/templates/nextjs/src/app/(default)/layout.tsx +0 -10
- package/templates/nextjs/src/app/[locale]/layout.tsx +0 -22
- package/templates/nextjs/src/app/[locale]/page.tsx +0 -1
- package/templates/nextjs/src/components/Document.tsx +0 -26
- package/templates/nextjs/src/components/FimoPreviewBridge.tsx +0 -13
- /package/templates/nextjs/src/app/{(default)/page.tsx → page.tsx} +0 -0
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { default as Boolean } from './Boolean.svelte';
|
|
2
|
-
export { default as Date } from './Date.svelte';
|
|
3
|
-
export { default as DateTime } from './DateTime.svelte';
|
|
4
|
-
export { default as FimoProvider } from './FimoProvider.svelte';
|
|
5
|
-
export { default as Image } from './Image.svelte';
|
|
6
|
-
export { default as Json } from './Json.svelte';
|
|
7
|
-
export { default as Label } from './Label.svelte';
|
|
8
|
-
export { default as Number } from './Number.svelte';
|
|
9
|
-
export { default as RichText } from './RichText.svelte';
|
|
10
|
-
export { default as Text } from './Text.svelte';
|
|
11
|
-
export { default as Video } from './Video.svelte';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { default as Boolean } from './Boolean.svelte';
|
|
2
|
-
export { default as Date } from './Date.svelte';
|
|
3
|
-
export { default as DateTime } from './DateTime.svelte';
|
|
4
|
-
export { default as FimoProvider } from './FimoProvider.svelte';
|
|
5
|
-
export { default as Image } from './Image.svelte';
|
|
6
|
-
export { default as Json } from './Json.svelte';
|
|
7
|
-
export { default as Label } from './Label.svelte';
|
|
8
|
-
export { default as Number } from './Number.svelte';
|
|
9
|
-
export { default as RichText } from './RichText.svelte';
|
|
10
|
-
export { default as Text } from './Text.svelte';
|
|
11
|
-
export { default as Video } from './Video.svelte';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface FimoNextConfigContext {
|
|
2
|
-
readonly defaultConfig?: object;
|
|
3
|
-
readonly [key: string]: unknown;
|
|
4
|
-
}
|
|
5
|
-
export type FimoNextConfigFactory<TConfig extends object = object> = (phase: string, context: FimoNextConfigContext) => TConfig | Promise<TConfig>;
|
|
6
|
-
export type FimoNextConfig<TConfig extends object = object> = TConfig | FimoNextConfigFactory<TConfig>;
|
|
7
|
-
/**
|
|
8
|
-
* Wire a Next application to its linked Fimo project.
|
|
9
|
-
*
|
|
10
|
-
* Fills the Fimo runtime env from the local link in `next dev`, `next build`,
|
|
11
|
-
* and `next start` — per key, only when nothing else set it — and, in
|
|
12
|
-
* development only, connects the dev server to Fimo's hosted preview gateway.
|
|
13
|
-
* The platform supplies allowed preview origins at runtime, so applications do
|
|
14
|
-
* not need to know which preview provider Fimo currently uses.
|
|
15
|
-
*/
|
|
16
|
-
export declare function withFimo<TConfig extends object>(applicationConfig: FimoNextConfig<TConfig>): FimoNextConfigFactory<TConfig>;
|
|
17
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { findStaleFimoOverride, resolveLocalRuntimeEnv, staleOverrideMessage, } from '../../runtime/shared/local-runtime-env.js';
|
|
2
|
-
const NEXT_DEVELOPMENT_PHASE = 'phase-development-server';
|
|
3
|
-
// The content runtime reads process.env only, so every phase that runs
|
|
4
|
-
// application code needs the derived env: the dev server, the production build
|
|
5
|
-
// (prerendering + NEXT_PUBLIC_* inlining), and the production server.
|
|
6
|
-
const RUNTIME_ENV_PHASES = new Set([
|
|
7
|
-
NEXT_DEVELOPMENT_PHASE,
|
|
8
|
-
'phase-production-build',
|
|
9
|
-
'phase-production-server',
|
|
10
|
-
]);
|
|
11
|
-
const PREVIEW_ORIGINS_ENV = 'FIMO_PREVIEW_ALLOWED_ORIGINS';
|
|
12
|
-
function readPreviewOrigins() {
|
|
13
|
-
return (process.env[PREVIEW_ORIGINS_ENV] ?? '')
|
|
14
|
-
.split(',')
|
|
15
|
-
.map((origin) => origin.trim())
|
|
16
|
-
.filter(Boolean);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Wire a Next application to its linked Fimo project.
|
|
20
|
-
*
|
|
21
|
-
* Fills the Fimo runtime env from the local link in `next dev`, `next build`,
|
|
22
|
-
* and `next start` — per key, only when nothing else set it — and, in
|
|
23
|
-
* development only, connects the dev server to Fimo's hosted preview gateway.
|
|
24
|
-
* The platform supplies allowed preview origins at runtime, so applications do
|
|
25
|
-
* not need to know which preview provider Fimo currently uses.
|
|
26
|
-
*/
|
|
27
|
-
export function withFimo(applicationConfig) {
|
|
28
|
-
return async (phase, context) => {
|
|
29
|
-
const config = typeof applicationConfig === 'function'
|
|
30
|
-
? await applicationConfig(phase, context)
|
|
31
|
-
: applicationConfig;
|
|
32
|
-
if (!RUNTIME_ENV_PHASES.has(phase)) {
|
|
33
|
-
return config;
|
|
34
|
-
}
|
|
35
|
-
// Next has already loaded `.env*` into `process.env` by the time this runs,
|
|
36
|
-
// so "unset" here means neither the platform, the shell, nor the user's own
|
|
37
|
-
// env files supplied it — only then does the git branch decide, per key.
|
|
38
|
-
const derived = resolveLocalRuntimeEnv({ cwd: process.cwd() });
|
|
39
|
-
if (derived) {
|
|
40
|
-
if (phase === NEXT_DEVELOPMENT_PHASE) {
|
|
41
|
-
const stale = findStaleFimoOverride(process.env, derived);
|
|
42
|
-
if (stale) {
|
|
43
|
-
console.warn(staleOverrideMessage(stale));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
for (const [key, value] of Object.entries(derived.values)) {
|
|
47
|
-
if (!process.env[key]) {
|
|
48
|
-
process.env[key] = value;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (phase !== NEXT_DEVELOPMENT_PHASE) {
|
|
53
|
-
return config;
|
|
54
|
-
}
|
|
55
|
-
const previewOrigins = readPreviewOrigins();
|
|
56
|
-
if (previewOrigins.length === 0) {
|
|
57
|
-
return config;
|
|
58
|
-
}
|
|
59
|
-
const configuredOrigins = config.allowedDevOrigins;
|
|
60
|
-
const allowedDevOrigins = [
|
|
61
|
-
...(Array.isArray(configuredOrigins) ? configuredOrigins : []),
|
|
62
|
-
...previewOrigins,
|
|
63
|
-
].filter((origin, index, origins) => origins.indexOf(origin) === index);
|
|
64
|
-
return { ...config, allowedDevOrigins };
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
|
-
import { getLineColumn } from '../vite/plugins/data-id.js';
|
|
5
|
-
// Native DOM elements are always taggable. Fimo's editable primitives are the
|
|
6
|
-
// only component exception: they forward arbitrary element attributes to the
|
|
7
|
-
// native element they render, so tagging them gives Studio the precise source
|
|
8
|
-
// location without leaking data-fimo-id props into arbitrary user components.
|
|
9
|
-
const TAGGABLE_ELEMENT_TYPES = new Set(['RegularElement', 'SvelteElement']);
|
|
10
|
-
const FIMO_PRIMITIVE_EXPORTS = new Set(['Text', 'Image', 'RichText']);
|
|
11
|
-
const FIMO_COMPONENTS_MODULE = 'fimo/sveltekit/components';
|
|
12
|
-
const EXCLUDED_ID_SEGMENTS = ['/node_modules/', '/.svelte-kit/', 'components/ui/', '.fimo/ui/'];
|
|
13
|
-
export default function svelteDataIdPlugin() {
|
|
14
|
-
let config;
|
|
15
|
-
let compilerLoad;
|
|
16
|
-
// Svelte is owned by the consuming app, never by fimo: resolve the compiler
|
|
17
|
-
// from the project root so tagging parses with the exact Svelte version
|
|
18
|
-
// that later compiles the file.
|
|
19
|
-
function loadCompiler() {
|
|
20
|
-
compilerLoad ??= (async () => {
|
|
21
|
-
try {
|
|
22
|
-
const projectRequire = createRequire(join(config.root, 'package.json'));
|
|
23
|
-
const compilerUrl = pathToFileURL(projectRequire.resolve('svelte/compiler')).href;
|
|
24
|
-
// The require condition can point at a CJS bundle; depending on the
|
|
25
|
-
// named-export lexer, `parse` may only be reachable via `default`.
|
|
26
|
-
const imported = (await import(compilerUrl));
|
|
27
|
-
const compiler = typeof imported.parse === 'function' ? imported : imported.default;
|
|
28
|
-
if (typeof compiler?.parse !== 'function') {
|
|
29
|
-
throw new Error('svelte/compiler does not expose parse()');
|
|
30
|
-
}
|
|
31
|
-
return compiler;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
config.logger.warn(`[fimo] data-fimo-id tagging disabled: svelte/compiler is not resolvable from ${config.root} (${String(error)})`);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
})();
|
|
38
|
-
return compilerLoad;
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
name: 'vite-plugin-svelte-data-id',
|
|
42
|
-
enforce: 'pre',
|
|
43
|
-
configResolved(resolvedConfig) {
|
|
44
|
-
config = resolvedConfig;
|
|
45
|
-
},
|
|
46
|
-
async transform(code, id) {
|
|
47
|
-
if (config.command === 'build') {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
// Query'd sub-requests (`+page.svelte?svelte&type=style…`) carry
|
|
51
|
-
// compiled non-Svelte content and never end with `.svelte`.
|
|
52
|
-
if (!id.endsWith('.svelte')) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
if (EXCLUDED_ID_SEGMENTS.some((segment) => id.includes(segment))) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const compiler = await loadCompiler();
|
|
59
|
-
if (!compiler) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
let parsed;
|
|
63
|
-
try {
|
|
64
|
-
parsed = compiler.parse(code, { modern: true });
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
// Invalid Svelte: leave the file untouched so vite-plugin-svelte
|
|
68
|
-
// reports the real syntax error against the original source.
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const relativePath = id.startsWith(`${config.root}/`) ? id.slice(config.root.length + 1) : id;
|
|
72
|
-
const insertions = [];
|
|
73
|
-
const primitiveComponents = collectFimoPrimitiveComponents(parsed.instance, parsed.module);
|
|
74
|
-
collectInsertions(parsed.fragment, code, relativePath, primitiveComponents, insertions);
|
|
75
|
-
if (insertions.length === 0) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
insertions.sort((a, b) => b.offset - a.offset);
|
|
79
|
-
let transformed = code;
|
|
80
|
-
for (const insertion of insertions) {
|
|
81
|
-
transformed = transformed.slice(0, insertion.offset) + insertion.value + transformed.slice(insertion.offset);
|
|
82
|
-
}
|
|
83
|
-
return { code: transformed, map: null };
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function collectInsertions(node, code, relativePath, primitiveComponents, insertions) {
|
|
88
|
-
if (!node || typeof node !== 'object') {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (Array.isArray(node)) {
|
|
92
|
-
for (const item of node) {
|
|
93
|
-
collectInsertions(item, code, relativePath, primitiveComponents, insertions);
|
|
94
|
-
}
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const element = node;
|
|
98
|
-
if (typeof element.type === 'string' &&
|
|
99
|
-
(TAGGABLE_ELEMENT_TYPES.has(element.type) ||
|
|
100
|
-
(element.type === 'Component' && typeof element.name === 'string' && primitiveComponents.has(element.name))) &&
|
|
101
|
-
typeof element.start === 'number' &&
|
|
102
|
-
typeof element.name === 'string' &&
|
|
103
|
-
!hasExplicitId(element.attributes)) {
|
|
104
|
-
const { line, column } = getLineColumn(code, element.start);
|
|
105
|
-
insertions.push({
|
|
106
|
-
// `start` points at `<`, so this lands right after the tag name — also
|
|
107
|
-
// valid for `<svelte:element>`, whose `name` is the literal pseudo-tag.
|
|
108
|
-
offset: element.start + 1 + element.name.length,
|
|
109
|
-
value: ` data-fimo-id="${relativePath}#${line}-${column}"`,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
for (const [key, child] of Object.entries(node)) {
|
|
113
|
-
// `metadata` is compiler-internal bookkeeping and may hold
|
|
114
|
-
// back-references; `parent` would make the walk cyclic.
|
|
115
|
-
if (key === 'parent' || key === 'metadata') {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
collectInsertions(child, code, relativePath, primitiveComponents, insertions);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function collectFimoPrimitiveComponents(...instances) {
|
|
122
|
-
const names = new Set();
|
|
123
|
-
for (const instance of instances) {
|
|
124
|
-
if (!instance || typeof instance !== 'object') {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const content = instance.content;
|
|
128
|
-
if (!content || typeof content !== 'object') {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
const body = content.body;
|
|
132
|
-
if (!Array.isArray(body)) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
for (const statement of body) {
|
|
136
|
-
if (!statement || typeof statement !== 'object') {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
const declaration = statement;
|
|
140
|
-
const source = declaration.source;
|
|
141
|
-
if (declaration.type !== 'ImportDeclaration' || source?.value !== FIMO_COMPONENTS_MODULE) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (!Array.isArray(declaration.specifiers)) {
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
for (const specifier of declaration.specifiers) {
|
|
148
|
-
if (!specifier || typeof specifier !== 'object') {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const imported = specifier;
|
|
152
|
-
if (imported.type === 'ImportSpecifier' &&
|
|
153
|
-
typeof imported.imported?.name === 'string' &&
|
|
154
|
-
FIMO_PRIMITIVE_EXPORTS.has(imported.imported.name) &&
|
|
155
|
-
typeof imported.local?.name === 'string') {
|
|
156
|
-
names.add(imported.local.name);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return names;
|
|
162
|
-
}
|
|
163
|
-
function hasExplicitId(attributes) {
|
|
164
|
-
if (!Array.isArray(attributes)) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
return attributes.some((attribute) => {
|
|
168
|
-
const attr = attribute;
|
|
169
|
-
return attr.type === 'Attribute' && attr.name === 'data-fimo-id';
|
|
170
|
-
});
|
|
171
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/* eslint-disable n/prefer-global/process --
|
|
2
|
-
Vercel Edge Runtime does not support node:process */
|
|
3
|
-
import { Server } from 'SERVER';
|
|
4
|
-
import { manifest } from 'MANIFEST';
|
|
5
|
-
|
|
6
|
-
const server = new Server(manifest);
|
|
7
|
-
|
|
8
|
-
/** @type {HeadersInit | undefined} */
|
|
9
|
-
let read_headers;
|
|
10
|
-
if (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {
|
|
11
|
-
read_headers = {
|
|
12
|
-
'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* We don't know the origin until we receive a request, but
|
|
18
|
-
* that's guaranteed to happen before we call `read`
|
|
19
|
-
* @type {string}
|
|
20
|
-
*/
|
|
21
|
-
let origin;
|
|
22
|
-
|
|
23
|
-
const initialized = server.init({
|
|
24
|
-
env: /** @type {Record<string, string>} */ (process.env),
|
|
25
|
-
read: async (file) => {
|
|
26
|
-
const url = `${origin}/${file}`;
|
|
27
|
-
const response = await fetch(url, {
|
|
28
|
-
// we need to add a bypass header if the user has deployment protection enabled
|
|
29
|
-
// see https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation
|
|
30
|
-
headers: read_headers
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (!response.ok) {
|
|
34
|
-
if (response.status === 401) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
`Please enable Protection Bypass for Automation: https://svelte.dev/docs/kit/adapter-vercel#Troubleshooting-Deployment-protection`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// belt and braces — not sure how we could end up here
|
|
41
|
-
throw new Error(
|
|
42
|
-
`read(...) failed: could not fetch ${url} (${response.status} ${response.statusText})`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return response.body;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @param {Request} request
|
|
52
|
-
* @param {import('../index.js').RequestContext} context
|
|
53
|
-
*/
|
|
54
|
-
export default async (request, context) => {
|
|
55
|
-
if (!origin) {
|
|
56
|
-
origin = new URL(request.url).origin;
|
|
57
|
-
await initialized;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return server.respond(request, {
|
|
61
|
-
getClientAddress() {
|
|
62
|
-
return /** @type {string} */ (request.headers.get('x-forwarded-for'));
|
|
63
|
-
},
|
|
64
|
-
platform: {
|
|
65
|
-
context
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { createReadableStream } from '@sveltejs/kit/node';
|
|
2
|
-
import { Server } from 'SERVER';
|
|
3
|
-
import { manifest } from 'MANIFEST';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
|
|
6
|
-
const server = new Server(manifest);
|
|
7
|
-
|
|
8
|
-
await server.init({
|
|
9
|
-
env: /** @type {Record<string, string>} */ (process.env),
|
|
10
|
-
read: createReadableStream
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const DATA_SUFFIX = '/__data.json';
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
/**
|
|
17
|
-
* @param {Request} request
|
|
18
|
-
* @returns {Promise<Response>}
|
|
19
|
-
*/
|
|
20
|
-
fetch(request) {
|
|
21
|
-
// If this is an ISR request, the requested pathname is encoded
|
|
22
|
-
// as a search parameter, so we need to extract it
|
|
23
|
-
const url = new URL(request.url);
|
|
24
|
-
let pathname = url.searchParams.get('__pathname');
|
|
25
|
-
|
|
26
|
-
if (pathname) {
|
|
27
|
-
// Optional routes' pathname replacements look like `/foo/$1/bar` which means we could end up with an url like /foo//bar
|
|
28
|
-
pathname = pathname.replace(/\/+/g, '/');
|
|
29
|
-
|
|
30
|
-
url.pathname = pathname + (url.pathname.endsWith(DATA_SUFFIX) ? DATA_SUFFIX : '');
|
|
31
|
-
url.searchParams.delete('__pathname');
|
|
32
|
-
|
|
33
|
-
request = new Request(url, request);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return server.respond(request, {
|
|
37
|
-
getClientAddress() {
|
|
38
|
-
return /** @type {string} */ (request.headers.get('x-forwarded-for'));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { PluginOption } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Narrow SvelteKit build connector. Points dev and production builds at the
|
|
4
|
-
* git branch's Fimo env (`PUBLIC_FIMO_API_URL`, `FIMO_ENV`), and tags native Svelte
|
|
5
|
-
* template elements with deterministic `data-fimo-id="<path>#<line>-<column>"`
|
|
6
|
-
* attributes during `vite dev` so the Fimo preview can map DOM nodes back to
|
|
7
|
-
* source. Explicit `data-fimo-id` attributes are preserved.
|
|
8
|
-
*
|
|
9
|
-
* Usage in the app's vite.config.ts: `plugins: [fimo(), sveltekit()]`.
|
|
10
|
-
*/
|
|
11
|
-
export declare function fimo(): PluginOption[];
|
|
12
|
-
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import runtimeEnvPlugin from '../vite/plugins/runtime-env.js';
|
|
2
|
-
import svelteDataIdPlugin from './data-id.js';
|
|
3
|
-
/**
|
|
4
|
-
* Narrow SvelteKit build connector. Points dev and production builds at the
|
|
5
|
-
* git branch's Fimo env (`PUBLIC_FIMO_API_URL`, `FIMO_ENV`), and tags native Svelte
|
|
6
|
-
* template elements with deterministic `data-fimo-id="<path>#<line>-<column>"`
|
|
7
|
-
* attributes during `vite dev` so the Fimo preview can map DOM nodes back to
|
|
8
|
-
* source. Explicit `data-fimo-id` attributes are preserved.
|
|
9
|
-
*
|
|
10
|
-
* Usage in the app's vite.config.ts: `plugins: [fimo(), sveltekit()]`.
|
|
11
|
-
*/
|
|
12
|
-
export function fimo() {
|
|
13
|
-
return [runtimeEnvPlugin(), svelteDataIdPlugin()];
|
|
14
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { PluginOption } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Whether the project at `root` is a React Router framework-mode app.
|
|
4
|
-
*
|
|
5
|
-
* Gates the one React-Router-specific line in this otherwise
|
|
6
|
-
* framework-neutral plugin, so a future `fimo/next` or plain-Vite project
|
|
7
|
-
* never inherits it. Checks the manifest first: the config file can carry any
|
|
8
|
-
* of four extensions, but framework mode is impossible without
|
|
9
|
-
* `@react-router/dev`.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isReactRouterProject(root: string): boolean;
|
|
12
|
-
export interface FimoViteOptions {
|
|
13
|
-
/**
|
|
14
|
-
* Emit `sitemap.xml` at build (and serve at `/sitemap.xml` in dev). Reads
|
|
15
|
-
* `seo.url` from `.fimo/config.json` as the base URL.
|
|
16
|
-
*
|
|
17
|
-
* Opt-in via `fimo({ sitemap: true })`.
|
|
18
|
-
*/
|
|
19
|
-
sitemap?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Emit `robots.txt` at build (and serve at `/robots.txt` in dev). Defaults
|
|
22
|
-
* to an allow-all robots policy + a `Sitemap:` directive when `seo.url` is
|
|
23
|
-
* set in `.fimo/config.json`.
|
|
24
|
-
*
|
|
25
|
-
* Opt-in via `fimo({ robots: true })`.
|
|
26
|
-
*/
|
|
27
|
-
robots?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Inject SEO meta tags into `index.html` via `transformIndexHtml`. Resolves
|
|
30
|
-
* per-route SEO from `.fimo/config.json#seo` and the matched route.
|
|
31
|
-
*
|
|
32
|
-
* Only applies in projects that have an `index.html` (plain Vite). Conflicts
|
|
33
|
-
* with frameworks that have their own SEO mechanism — React Router's `meta`
|
|
34
|
-
* export, Astro's frontmatter, Next.js's `generateMetadata`. Use those
|
|
35
|
-
* instead via the framework adapter's SEO helpers.
|
|
36
|
-
*
|
|
37
|
-
* Opt-in via `fimo({ seo: true })` — only documented in the plain-Vite recipe.
|
|
38
|
-
*/
|
|
39
|
-
seo?: boolean;
|
|
40
|
-
}
|
|
41
|
-
export declare function fimo(opts?: FimoViteOptions): PluginOption[];
|
|
42
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/build/vite/index.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import contentSyncPlugin from './plugins/content-sync.js';
|
|
4
|
-
import dataIdPlugin from './plugins/data-id.js';
|
|
5
|
-
import fimoConfigPlugin from './plugins/fimo-config.js';
|
|
6
|
-
import overlayPlugin from './plugins/overlay.js';
|
|
7
|
-
import robotsPlugin from './plugins/robots.js';
|
|
8
|
-
import runtimeEnvPlugin from './plugins/runtime-env.js';
|
|
9
|
-
import seoPlugin from './plugins/seo.js';
|
|
10
|
-
import serverConfigPlugin from './plugins/server-config.js';
|
|
11
|
-
import sitemapPlugin from './plugins/sitemap.js';
|
|
12
|
-
import translationsPlugin from './plugins/translations.js';
|
|
13
|
-
// Force-bundle fimo into the SSR build, and let the dev optimizer pre-bundle
|
|
14
|
-
// it for the client. fimo's runtime imports `virtual:fimo-config` /
|
|
15
|
-
// `virtual:translations` / `virtual:fimo-overlay-*` — Vite-only specifiers
|
|
16
|
-
// resolved by sibling plugins — which esbuild can't see.
|
|
17
|
-
//
|
|
18
|
-
// Two places this matters:
|
|
19
|
-
// 1. SSR build: bundle fimo into dist/server (top-level `ssr.noExternal`
|
|
20
|
-
// + per-environment `configEnvironment` for react-router 7.15+, which
|
|
21
|
-
// doesn't merge viteUserConfig.environments.ssr for the default
|
|
22
|
-
// non-serverBundles case). Rollup resolves the virtuals through the
|
|
23
|
-
// plugin container, so SSR needs no special-casing.
|
|
24
|
-
// 2. Dev dep scan + optimization: esbuild chokes on `virtual:` ("Could not
|
|
25
|
-
// resolve 'virtual:fimo-config'"). The previous fix excluded the whole
|
|
26
|
-
// package from optimizeDeps, which served every runtime file as an
|
|
27
|
-
// individual module request (~34 extra round-trips per cold preview
|
|
28
|
-
// load through the sandbox proxy). Instead, externalize just the
|
|
29
|
-
// virtual specifiers — kept BARE (`virtual:fimo-config`, not an
|
|
30
|
-
// `/@id/`-prefixed URL): vite:import-analysis re-transforms optimized
|
|
31
|
-
// dep chunks and resolves bare specifiers through the plugin container,
|
|
32
|
-
// rewriting them to `/@id/` URLs itself. A pre-prefixed path fails that
|
|
33
|
-
// resolve ("Failed to resolve import '/@id/virtual:fimo-config'").
|
|
34
|
-
const REACT_ROUTER_CONFIG_FILES = [
|
|
35
|
-
'react-router.config.ts',
|
|
36
|
-
'react-router.config.js',
|
|
37
|
-
'react-router.config.mjs',
|
|
38
|
-
'react-router.config.cjs',
|
|
39
|
-
];
|
|
40
|
-
/**
|
|
41
|
-
* Whether the project at `root` is a React Router framework-mode app.
|
|
42
|
-
*
|
|
43
|
-
* Gates the one React-Router-specific line in this otherwise
|
|
44
|
-
* framework-neutral plugin, so a future `fimo/next` or plain-Vite project
|
|
45
|
-
* never inherits it. Checks the manifest first: the config file can carry any
|
|
46
|
-
* of four extensions, but framework mode is impossible without
|
|
47
|
-
* `@react-router/dev`.
|
|
48
|
-
*/
|
|
49
|
-
export function isReactRouterProject(root) {
|
|
50
|
-
try {
|
|
51
|
-
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8'));
|
|
52
|
-
if (pkg.devDependencies?.['@react-router/dev'] ?? pkg.dependencies?.['@react-router/dev']) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
// No readable manifest — fall through to the config-file probe.
|
|
58
|
-
}
|
|
59
|
-
return REACT_ROUTER_CONFIG_FILES.some((file) => existsSync(join(root, file)));
|
|
60
|
-
}
|
|
61
|
-
function bundleFimoIntoSsrPlugin() {
|
|
62
|
-
return {
|
|
63
|
-
name: 'vite-plugin-fimo-ssr-bundle',
|
|
64
|
-
config: (userConfig) => ({
|
|
65
|
-
ssr: { noExternal: ['fimo'] },
|
|
66
|
-
optimizeDeps: {
|
|
67
|
-
// Compatibility shim for React Router projects scaffolded before the
|
|
68
|
-
// template set `future.unstable_optimizeDeps`. React Router passes
|
|
69
|
-
// Vite an EMPTY `entries` array without that flag (see
|
|
70
|
-
// getOptimizeDepsEntries in @react-router/dev), so NOTHING is
|
|
71
|
-
// pre-bundled: every dep a route imports is discovered on that
|
|
72
|
-
// route's first visit, and vite answers by re-optimizing and
|
|
73
|
-
// full-reloading the document. In the preview that reads as "links
|
|
74
|
-
// aren't SPA links" — client state lost, plus a transient duplicate
|
|
75
|
-
// React while the new chunks land.
|
|
76
|
-
//
|
|
77
|
-
// Gated on React Router, and assumes sources live in `src/`. The flag
|
|
78
|
-
// supersedes it (it derives entries from the real route table,
|
|
79
|
-
// whatever the appDirectory) and the two merge additively — drop this
|
|
80
|
-
// once no supported project predates the flag.
|
|
81
|
-
...(isReactRouterProject(typeof userConfig.root === 'string' ? userConfig.root : process.cwd())
|
|
82
|
-
? { entries: ['src/**/*.{ts,tsx,js,jsx}'] }
|
|
83
|
-
: {}),
|
|
84
|
-
// Pre-include fimo's scanner-invisible dependency surface. The
|
|
85
|
-
// scanner can't traverse the fimo package (virtual: imports), so deps
|
|
86
|
-
// reached only THROUGH fimo (its react-router adapter subpath, its
|
|
87
|
-
// internal react-query usage, its error boundary) get discovered
|
|
88
|
-
// mid-first-load — vite re-optimizes and 504s the in-flight
|
|
89
|
-
// generation's chunks ("Outdated Optimize Dep") and the app never
|
|
90
|
-
// mounts (blank preview; caught by content/query e2e).
|
|
91
|
-
// react/react-dom/react-router are listed too: the template imports
|
|
92
|
-
// them, but fimo's imports of them are invisible to the scan, so
|
|
93
|
-
// leaving them to discovery makes the first optimize pass depend on
|
|
94
|
-
// which entry the browser happens to request first.
|
|
95
|
-
include: [
|
|
96
|
-
'react',
|
|
97
|
-
'react-dom',
|
|
98
|
-
'react-router',
|
|
99
|
-
'react-error-boundary',
|
|
100
|
-
'fimo/ui',
|
|
101
|
-
'fimo/react-router',
|
|
102
|
-
'@tanstack/react-query',
|
|
103
|
-
],
|
|
104
|
-
rolldownOptions: {
|
|
105
|
-
plugins: [
|
|
106
|
-
{
|
|
107
|
-
name: 'fimo-externalize-virtuals',
|
|
108
|
-
resolveId(id) {
|
|
109
|
-
if (id.startsWith('virtual:')) {
|
|
110
|
-
return {
|
|
111
|
-
id,
|
|
112
|
-
external: true,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
}),
|
|
121
|
-
configEnvironment(name, config) {
|
|
122
|
-
if (name !== 'ssr')
|
|
123
|
-
return;
|
|
124
|
-
const existing = config.resolve?.noExternal;
|
|
125
|
-
const merged = existing === true
|
|
126
|
-
? true
|
|
127
|
-
: Array.isArray(existing)
|
|
128
|
-
? [...existing, 'fimo']
|
|
129
|
-
: existing
|
|
130
|
-
? [existing, 'fimo']
|
|
131
|
-
: ['fimo'];
|
|
132
|
-
return {
|
|
133
|
-
resolve: { noExternal: merged },
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
// NOTE: dataIdPlugin must run before anything else to capture valid line numbers.
|
|
139
|
-
export function fimo(opts = {}) {
|
|
140
|
-
const plugins = [
|
|
141
|
-
runtimeEnvPlugin(),
|
|
142
|
-
bundleFimoIntoSsrPlugin(),
|
|
143
|
-
contentSyncPlugin(),
|
|
144
|
-
serverConfigPlugin(),
|
|
145
|
-
fimoConfigPlugin(),
|
|
146
|
-
dataIdPlugin(),
|
|
147
|
-
translationsPlugin(),
|
|
148
|
-
overlayPlugin(),
|
|
149
|
-
];
|
|
150
|
-
if (opts.sitemap) {
|
|
151
|
-
plugins.push(sitemapPlugin());
|
|
152
|
-
}
|
|
153
|
-
if (opts.robots) {
|
|
154
|
-
plugins.push(robotsPlugin());
|
|
155
|
-
}
|
|
156
|
-
if (opts.seo) {
|
|
157
|
-
plugins.push(seoPlugin());
|
|
158
|
-
}
|
|
159
|
-
return plugins;
|
|
160
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Keeps generated schema + form clients in sync while the Vite dev server is
|
|
4
|
-
* running.
|
|
5
|
-
*
|
|
6
|
-
* Production builds are deliberately read-only. Explicit authoring commands
|
|
7
|
-
* (`fimo validate`, `fimo schemas push`, and `fimo forms push`) own initial
|
|
8
|
-
* generation before a build starts.
|
|
9
|
-
*/
|
|
10
|
-
export default function contentSyncPlugin(): Plugin;
|
|
11
|
-
//# sourceMappingURL=content-sync.d.ts.map
|