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,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export { getPreviewLocationChange, getPreviewLocationPath } from '../preview/location.js';
|
|
3
|
-
export interface ParamInfo {
|
|
4
|
-
schema: string;
|
|
5
|
-
queryField: string;
|
|
6
|
-
displayField: string;
|
|
7
|
-
}
|
|
8
|
-
export interface DisplayRoute {
|
|
9
|
-
id: string;
|
|
10
|
-
name: string;
|
|
11
|
-
path: string;
|
|
12
|
-
params?: Record<string, ParamInfo>;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The routes the running app can actually navigate to right now.
|
|
16
|
-
*
|
|
17
|
-
* Studio gates preview navigation on this list, so it must come from the
|
|
18
|
-
* router that is currently loaded rather than the build-time config: after a
|
|
19
|
-
* merge, config metadata can describe a page whose route module has not
|
|
20
|
-
* reached this iframe yet. Names and params still come from config, which is
|
|
21
|
-
* where authored metadata lives. Falls back to config when the framework
|
|
22
|
-
* manifest is unreadable (SSR pass, non-framework mode).
|
|
23
|
-
*/
|
|
24
|
-
export declare function getDisplayRoutes(frameworkManifest: unknown): DisplayRoute[];
|
|
25
|
-
export interface FimoProvidersProps {
|
|
26
|
-
children?: React.ReactNode;
|
|
27
|
-
locale?: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function FimoProviders({ children, locale }: FimoProvidersProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
//# sourceMappingURL=FimoProviders.d.ts.map
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { QueryClient, QueryClientContext, QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
-
import { Suspense, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
4
|
-
import { ErrorBoundary } from 'react-error-boundary';
|
|
5
|
-
import { UNSAFE_FrameworkContext, useLocation, useNavigate } from 'react-router';
|
|
6
|
-
// @ts-ignore - virtual module provided by fimoConfigPlugin in fimo/vite
|
|
7
|
-
import fimoConfig from 'virtual:fimo-config';
|
|
8
|
-
import { DataSourcesProvider } from '../content/DataSourcesProvider.js';
|
|
9
|
-
import { RefreshContentProvider } from '../content/RefreshContentProvider.js';
|
|
10
|
-
import { AppErrorBoundary, onError } from '../core/AppErrorBoundary.js';
|
|
11
|
-
import { ViteLifecycles } from '../core/ViteLifecycles.js';
|
|
12
|
-
import { FimoLocaleProvider } from '../i18n/FimoLocaleContext.js';
|
|
13
|
-
import { getFimoTextDirection, resolveFimoLocale, toHtmlLang } from '../i18n/locale.js';
|
|
14
|
-
import { ScreenshotProvider } from '../iframe/ScreenshotProvider.js';
|
|
15
|
-
import { getSafePreviewNavigationPath, isPreviewRuntimeEnabled } from '../preview/bridge.js';
|
|
16
|
-
import { getPreviewLocationChange, getPreviewParentOrigin } from '../preview/location.js';
|
|
17
|
-
import { getActiveRouterRoutes } from '../react-router/active-routes.js';
|
|
18
|
-
import { matchFimoRoute } from '../routes/index.js';
|
|
19
|
-
import { OptionalTracking } from '../t/OptionalTracking.js';
|
|
20
|
-
export { getPreviewLocationChange, getPreviewLocationPath } from '../preview/location.js';
|
|
21
|
-
const titleCase = (seg) => seg
|
|
22
|
-
.replace(/[_-]+/g, ' ')
|
|
23
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
24
|
-
.split(/\s+/)
|
|
25
|
-
.filter(Boolean)
|
|
26
|
-
.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
27
|
-
.join(' ');
|
|
28
|
-
const generateRouteName = (path) => {
|
|
29
|
-
if (path === '/') {
|
|
30
|
-
return 'Home';
|
|
31
|
-
}
|
|
32
|
-
const firstSegment = path.replace(/^\//, '').split('/')[0];
|
|
33
|
-
return titleCase(firstSegment);
|
|
34
|
-
};
|
|
35
|
-
function getConfigDisplayRoutes() {
|
|
36
|
-
const configRoutes = fimoConfig.routes ?? {};
|
|
37
|
-
return Object.entries(configRoutes)
|
|
38
|
-
.filter(([, route]) => route.path)
|
|
39
|
-
.map(([id, route]) => ({
|
|
40
|
-
id,
|
|
41
|
-
path: route.path,
|
|
42
|
-
name: route.name || generateRouteName(route.path),
|
|
43
|
-
params: route.params,
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
function getCanonicalRoutePath(path) {
|
|
47
|
-
return resolveFimoLocale({ pathname: path }, fimoConfig).routePath;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* The locale a pathname renders.
|
|
51
|
-
*
|
|
52
|
-
* The declared route decides it. A route that declares no `:locale` segment is
|
|
53
|
-
* app-owned and renders the default locale whatever its first segment spells,
|
|
54
|
-
* which is what stops `/fr` from switching the page to French when `fr` is
|
|
55
|
-
* really an entry slug under a top-level `/:slug` route.
|
|
56
|
-
*
|
|
57
|
-
* Only a URL that no declared route answers falls back to the compatibility
|
|
58
|
-
* prefix resolver. Existing apps can still rely on that inference while new
|
|
59
|
-
* route-owned integrations pass an explicit locale to `FimoProviders`.
|
|
60
|
-
*/
|
|
61
|
-
function getRouteLocale(pathname) {
|
|
62
|
-
return (matchFimoRoute(pathname, fimoConfig)?.locale ?? resolveFimoLocale({ pathname }, fimoConfig).locale);
|
|
63
|
-
}
|
|
64
|
-
function hasReadableFrameworkManifest(manifest) {
|
|
65
|
-
return Boolean(manifest &&
|
|
66
|
-
typeof manifest === 'object' &&
|
|
67
|
-
'routes' in manifest &&
|
|
68
|
-
manifest.routes &&
|
|
69
|
-
typeof manifest.routes === 'object');
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* The routes the running app can actually navigate to right now.
|
|
73
|
-
*
|
|
74
|
-
* Studio gates preview navigation on this list, so it must come from the
|
|
75
|
-
* router that is currently loaded rather than the build-time config: after a
|
|
76
|
-
* merge, config metadata can describe a page whose route module has not
|
|
77
|
-
* reached this iframe yet. Names and params still come from config, which is
|
|
78
|
-
* where authored metadata lives. Falls back to config when the framework
|
|
79
|
-
* manifest is unreadable (SSR pass, non-framework mode).
|
|
80
|
-
*/
|
|
81
|
-
export function getDisplayRoutes(frameworkManifest) {
|
|
82
|
-
const configRoutes = getConfigDisplayRoutes();
|
|
83
|
-
if (!hasReadableFrameworkManifest(frameworkManifest)) {
|
|
84
|
-
return configRoutes;
|
|
85
|
-
}
|
|
86
|
-
const configByPath = new Map(configRoutes.map((route) => [getCanonicalRoutePath(route.path), route]));
|
|
87
|
-
return getActiveRouterRoutes(frameworkManifest).map((route) => {
|
|
88
|
-
const metadata = configByPath.get(getCanonicalRoutePath(route.path));
|
|
89
|
-
return {
|
|
90
|
-
id: metadata?.id ?? route.id,
|
|
91
|
-
path: route.path,
|
|
92
|
-
name: metadata?.name ?? generateRouteName(route.path),
|
|
93
|
-
...(metadata?.params ? { params: metadata.params } : {}),
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Studio's window into the running app. Framework-neutral on purpose: it
|
|
99
|
-
* speaks only postMessage (`nav/routes`, `nav/locationChange`, `nav/navigate`,
|
|
100
|
-
* `nav/read-routes`) and reads routes through the `readRoutes` callback, so a
|
|
101
|
-
* future non-React-Router runtime reuses it by supplying its own reader.
|
|
102
|
-
*/
|
|
103
|
-
function PreviewBridge({ readRoutes, locale }) {
|
|
104
|
-
const navigate = useNavigate();
|
|
105
|
-
const location = useLocation();
|
|
106
|
-
const sendRoutes = useCallback(() => {
|
|
107
|
-
// Read at send time: the router can change its route table in place
|
|
108
|
-
// during HMR, so an explicit nav/read-routes must see the current state.
|
|
109
|
-
window.parent.postMessage({ type: 'nav/routes', payload: { routes: readRoutes() } }, getPreviewParentOrigin() ?? '*');
|
|
110
|
-
}, [readRoutes]);
|
|
111
|
-
// `locale` is a dependency on purpose: an app that settles a new locale
|
|
112
|
-
// without moving the pathname still has to tell Studio about it.
|
|
113
|
-
const sendLocationChange = useCallback(() => {
|
|
114
|
-
const parentOrigin = getPreviewParentOrigin();
|
|
115
|
-
window.parent.postMessage({ type: 'nav/locationChange', payload: getPreviewLocationChange(location, locale, parentOrigin) }, parentOrigin ?? '*');
|
|
116
|
-
}, [location.hash, location.pathname, location.search, locale]);
|
|
117
|
-
useEffect(sendRoutes, [sendRoutes]);
|
|
118
|
-
useEffect(sendLocationChange, [sendLocationChange]);
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
const handleMessage = (event) => {
|
|
121
|
-
const parentOrigin = getPreviewParentOrigin();
|
|
122
|
-
if (event.source !== window.parent || !parentOrigin || event.origin !== parentOrigin) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const type = event.data?.type;
|
|
126
|
-
const payload = event.data?.payload;
|
|
127
|
-
switch (type) {
|
|
128
|
-
case 'nav/navigate':
|
|
129
|
-
{
|
|
130
|
-
const target = getSafePreviewNavigationPath(payload?.to, window.location.origin);
|
|
131
|
-
if (target) {
|
|
132
|
-
navigate(target);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return;
|
|
136
|
-
case 'nav/read-routes':
|
|
137
|
-
sendRoutes();
|
|
138
|
-
sendLocationChange();
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
window.addEventListener('message', handleMessage);
|
|
143
|
-
return () => {
|
|
144
|
-
window.removeEventListener('message', handleMessage);
|
|
145
|
-
};
|
|
146
|
-
}, [navigate, sendRoutes, sendLocationChange]);
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
function EnsureQueryClient({ children }) {
|
|
150
|
-
const existingQueryClient = useContext(QueryClientContext);
|
|
151
|
-
const fallbackQueryClientRef = useRef(null);
|
|
152
|
-
if (existingQueryClient) {
|
|
153
|
-
return _jsx(_Fragment, { children: children });
|
|
154
|
-
}
|
|
155
|
-
const fallbackQueryClient = fallbackQueryClientRef.current ?? (fallbackQueryClientRef.current = new QueryClient());
|
|
156
|
-
return _jsx(QueryClientProvider, { client: fallbackQueryClient, children: children });
|
|
157
|
-
}
|
|
158
|
-
export function FimoProviders({ children, locale }) {
|
|
159
|
-
const location = useLocation();
|
|
160
|
-
// The React-Router-specific part of the bridge, isolated here: the live
|
|
161
|
-
// route table lives on the framework context's manifest, which React Router
|
|
162
|
-
// may update in place during HMR — hence reading it per render/send instead
|
|
163
|
-
// of caching. A different framework runtime would swap this reader only.
|
|
164
|
-
const frameworkContext = useContext(UNSAFE_FrameworkContext);
|
|
165
|
-
const readRoutes = useCallback(() => getDisplayRoutes(frameworkContext?.manifest), [frameworkContext?.manifest]);
|
|
166
|
-
const routes = readRoutes();
|
|
167
|
-
const localeResolution = useMemo(() => resolveFimoLocale({ pathname: location.pathname }, fimoConfig), [location.pathname]);
|
|
168
|
-
// The app is authoritative: an explicit `locale` wins over anything Fimo can
|
|
169
|
-
// infer, and inference itself goes through the declared route contract.
|
|
170
|
-
const activeLocale = useMemo(() => locale ?? getRouteLocale(location.pathname), [locale, location.pathname]);
|
|
171
|
-
const activeDir = getFimoTextDirection(activeLocale);
|
|
172
|
-
// @ts-ignore - import.meta.env is provided by Vite and React Router.
|
|
173
|
-
const previewEnabled = isPreviewRuntimeEnabled(import.meta.env.VITE_PREVIEW_SCRIPT_URL);
|
|
174
|
-
useEffect(() => {
|
|
175
|
-
if (typeof document === 'undefined') {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
document.documentElement.lang = toHtmlLang(activeLocale);
|
|
179
|
-
document.documentElement.dir = activeDir;
|
|
180
|
-
}, [activeDir, activeLocale]);
|
|
181
|
-
return (_jsx(ErrorBoundary, { FallbackComponent: AppErrorBoundary, onError: onError, children: _jsx(EnsureQueryClient, { children: _jsx(FimoLocaleProvider, { value: {
|
|
182
|
-
...localeResolution,
|
|
183
|
-
locale: activeLocale,
|
|
184
|
-
dir: activeDir,
|
|
185
|
-
}, children: _jsx(DataSourcesProvider, { children: _jsx(ScreenshotProvider, { children: _jsx(ViteLifecycles, { children: _jsxs(RefreshContentProvider, { children: [previewEnabled ? _jsx(PreviewBridge, { readRoutes: readRoutes, locale: activeLocale }) : null, _jsx(OptionalTracking, { routes: routes }), _jsx(Suspense, { children: children })] }) }) }) }) }) }) }));
|
|
186
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import 'virtual:fimo-overlay-hmr';
|
|
2
|
-
/**
|
|
3
|
-
* Renders extra <script> tags in <head>:
|
|
4
|
-
* - Dev overlay runtime (window.error / unhandledrejection bridge to parent)
|
|
5
|
-
* - JSON-LD Schema.org Organization + WebSite (when seo.siteName + seo.url set)
|
|
6
|
-
* - Preview script (when VITE_PREVIEW_SCRIPT_URL is set, e.g. iframe preview mode)
|
|
7
|
-
*
|
|
8
|
-
* The overlay runtime is embedded inline via the `virtual:fimo-overlay-runtime`
|
|
9
|
-
* module (resolved by `overlayPlugin` in `fimo/vite`). The previous approach
|
|
10
|
-
* used `transformIndexHtml`, which doesn't fire in react-router framework mode
|
|
11
|
-
* since framework mode bypasses `index.html` entirely.
|
|
12
|
-
*/
|
|
13
|
-
export declare function FimoScripts(): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
//# sourceMappingURL=FimoScripts.d.ts.map
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// @ts-ignore - virtual module provided by fimoConfigPlugin in fimo/vite
|
|
3
|
-
import rawConfig from 'virtual:fimo-config';
|
|
4
|
-
// @ts-ignore - virtual module provided by overlayPlugin in fimo/vite; empty in prod
|
|
5
|
-
import overlayRuntime from 'virtual:fimo-overlay-runtime';
|
|
6
|
-
// @ts-ignore - side-effect import; vite-served so import.meta.hot works inside
|
|
7
|
-
import 'virtual:fimo-overlay-hmr';
|
|
8
|
-
const config = rawConfig;
|
|
9
|
-
const runtime = overlayRuntime;
|
|
10
|
-
function buildSiteSchemas() {
|
|
11
|
-
const seo = config.seo;
|
|
12
|
-
if (!seo?.siteName || !seo?.url) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
const organization = {
|
|
16
|
-
'@context': 'https://schema.org',
|
|
17
|
-
'@type': 'Organization',
|
|
18
|
-
name: seo.siteName,
|
|
19
|
-
url: seo.url,
|
|
20
|
-
};
|
|
21
|
-
if (seo.favicon) {
|
|
22
|
-
organization.logo = seo.favicon;
|
|
23
|
-
}
|
|
24
|
-
const website = {
|
|
25
|
-
'@context': 'https://schema.org',
|
|
26
|
-
'@type': 'WebSite',
|
|
27
|
-
name: seo.siteName,
|
|
28
|
-
url: seo.url,
|
|
29
|
-
};
|
|
30
|
-
return [organization, website];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Renders extra <script> tags in <head>:
|
|
34
|
-
* - Dev overlay runtime (window.error / unhandledrejection bridge to parent)
|
|
35
|
-
* - JSON-LD Schema.org Organization + WebSite (when seo.siteName + seo.url set)
|
|
36
|
-
* - Preview script (when VITE_PREVIEW_SCRIPT_URL is set, e.g. iframe preview mode)
|
|
37
|
-
*
|
|
38
|
-
* The overlay runtime is embedded inline via the `virtual:fimo-overlay-runtime`
|
|
39
|
-
* module (resolved by `overlayPlugin` in `fimo/vite`). The previous approach
|
|
40
|
-
* used `transformIndexHtml`, which doesn't fire in react-router framework mode
|
|
41
|
-
* since framework mode bypasses `index.html` entirely.
|
|
42
|
-
*/
|
|
43
|
-
export function FimoScripts() {
|
|
44
|
-
// @ts-ignore - import.meta.env is a Vite feature
|
|
45
|
-
const previewScriptUrl = import.meta.env.VITE_PREVIEW_SCRIPT_URL;
|
|
46
|
-
const siteSchemas = buildSiteSchemas();
|
|
47
|
-
return (_jsxs(_Fragment, { children: [runtime ? _jsx("script", { type: "module", dangerouslySetInnerHTML: { __html: runtime } }) : null, previewScriptUrl ? _jsx("script", { src: previewScriptUrl, defer: true }) : null, siteSchemas.map((schema, index) => (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(schema) } }, index)))] }));
|
|
48
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { FimoProviders } from './FimoProviders.js';
|
|
2
|
-
export { FimoScripts } from './FimoScripts.js';
|
|
3
|
-
export { useLocale } from '../i18n/FimoLocaleContext.js';
|
|
4
|
-
export { localizeFimoPath, resolveFimoLocale } from '../i18n/locale.js';
|
|
5
|
-
export type { DisplayRoute, FimoProvidersProps, ParamInfo } from './FimoProviders.js';
|
|
6
|
-
export type { FimoLocaleContextValue } from '../i18n/FimoLocaleContext.js';
|
|
7
|
-
export type { FimoLocaleResolution } from '../i18n/locale.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function resolveFimoLocaleForUrl(url: string): import("./index.js").FimoLocaleResolution;
|
|
2
|
-
/**
|
|
3
|
-
* Fetch route data for SEO meta resolution.
|
|
4
|
-
*
|
|
5
|
-
* Only entry params are fetched: a locale param is resolved from the URL and
|
|
6
|
-
* never corresponds to a CMS schema, so it must not produce a request.
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveMetaEntries(url: string): Promise<Record<string, unknown> | undefined>;
|
|
9
|
-
//# sourceMappingURL=prefetch.d.ts.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// @ts-ignore - virtual module provided by fimoConfigPlugin in fimo/vite
|
|
2
|
-
import fimoConfig from 'virtual:fimo-config';
|
|
3
|
-
import { resolveFimoLocale } from '../i18n/locale.js';
|
|
4
|
-
import { matchFimoRoute } from '../routes/index.js';
|
|
5
|
-
export function resolveFimoLocaleForUrl(url) {
|
|
6
|
-
return resolveFimoLocale(url, fimoConfig);
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Fetch route data for SEO meta resolution.
|
|
10
|
-
*
|
|
11
|
-
* Only entry params are fetched: a locale param is resolved from the URL and
|
|
12
|
-
* never corresponds to a CMS schema, so it must not produce a request.
|
|
13
|
-
*/
|
|
14
|
-
export async function resolveMetaEntries(url) {
|
|
15
|
-
// @ts-ignore – import.meta.env is a Vite feature, replaced at build time for both client and SSR
|
|
16
|
-
const base = import.meta.env.VITE_API_URL;
|
|
17
|
-
if (!base) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
const match = matchFimoRoute(url, fimoConfig);
|
|
21
|
-
if (!match || match.contract.entryParams.length === 0) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
const data = {};
|
|
25
|
-
await Promise.all(match.contract.entryParams.map(async (param) => {
|
|
26
|
-
const value = match.entryParams[param.name];
|
|
27
|
-
if (!value) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const entryUrl = new URL(`${base}/entries/${param.schema}/field/${encodeURIComponent(param.queryField)}/${encodeURIComponent(value)}`);
|
|
31
|
-
entryUrl.searchParams.set('locale', match.locale);
|
|
32
|
-
const res = await fetch(entryUrl);
|
|
33
|
-
if (res.ok) {
|
|
34
|
-
const json = await res.json();
|
|
35
|
-
data[param.name] = json.data;
|
|
36
|
-
}
|
|
37
|
-
}));
|
|
38
|
-
return Object.keys(data).length > 0 ? data : undefined;
|
|
39
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect } from 'react';
|
|
3
|
-
import { retrieveVisibleDataSources } from './utils/retrieve-data-sources.js';
|
|
4
|
-
const VISIBLE_TRANSLATIONS_SELECTORS = 'h1, h2, h3, nav a, button';
|
|
5
|
-
const MAX_VISIBLE_TRANSLATIONS_ITEMS = 20;
|
|
6
|
-
const MAX_TEXT_LENGTH = 60;
|
|
7
|
-
function isInViewport(el) {
|
|
8
|
-
const rect = el.getBoundingClientRect();
|
|
9
|
-
return (rect.bottom > 0 &&
|
|
10
|
-
rect.top < window.innerHeight &&
|
|
11
|
-
rect.right > 0 &&
|
|
12
|
-
rect.left < window.innerWidth &&
|
|
13
|
-
rect.width > 0 &&
|
|
14
|
-
rect.height > 0);
|
|
15
|
-
}
|
|
16
|
-
function extractVisibleTranslations() {
|
|
17
|
-
const elements = document.querySelectorAll(VISIBLE_TRANSLATIONS_SELECTORS);
|
|
18
|
-
const seen = new Set();
|
|
19
|
-
const items = [];
|
|
20
|
-
for (const el of elements) {
|
|
21
|
-
if (items.length >= MAX_VISIBLE_TRANSLATIONS_ITEMS)
|
|
22
|
-
break;
|
|
23
|
-
if (!isInViewport(el))
|
|
24
|
-
continue;
|
|
25
|
-
const raw = el.textContent?.trim();
|
|
26
|
-
if (!raw)
|
|
27
|
-
continue;
|
|
28
|
-
// Deduplicate (e.g. nav repeated in header + footer)
|
|
29
|
-
const key = `${el.tagName.toLowerCase()}:${raw}`;
|
|
30
|
-
if (seen.has(key))
|
|
31
|
-
continue;
|
|
32
|
-
seen.add(key);
|
|
33
|
-
const text = raw.length > MAX_TEXT_LENGTH ? raw.slice(0, MAX_TEXT_LENGTH) + '…' : raw;
|
|
34
|
-
items.push({ tag: el.tagName.toLowerCase(), text });
|
|
35
|
-
}
|
|
36
|
-
return items;
|
|
37
|
-
}
|
|
38
|
-
export function DataSourcesProvider({ children }) {
|
|
39
|
-
const sendDataSources = useCallback(() => {
|
|
40
|
-
const dataSources = retrieveVisibleDataSources();
|
|
41
|
-
window.parent.postMessage({ type: 'content/send-visible', payload: { dataSources } }, '*');
|
|
42
|
-
}, []);
|
|
43
|
-
const sendVisibleTranslations = useCallback(() => {
|
|
44
|
-
const visibleTranslations = extractVisibleTranslations();
|
|
45
|
-
window.parent.postMessage({ type: 'content/send-visible-translations', payload: { visibleTranslations } }, '*');
|
|
46
|
-
}, []);
|
|
47
|
-
// Handle data requests from parent
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
const handleMessage = (event) => {
|
|
50
|
-
if (event.data?.type === 'content/read-visible') {
|
|
51
|
-
sendDataSources();
|
|
52
|
-
}
|
|
53
|
-
if (event.data?.type === 'content/read-visible-translations') {
|
|
54
|
-
sendVisibleTranslations();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
window.addEventListener('message', handleMessage);
|
|
58
|
-
return () => {
|
|
59
|
-
window.removeEventListener('message', handleMessage);
|
|
60
|
-
};
|
|
61
|
-
}, [sendDataSources, sendVisibleTranslations]);
|
|
62
|
-
return _jsx(_Fragment, { children: children });
|
|
63
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { FC, PropsWithChildren } from 'react';
|
|
2
|
-
interface ContentRefreshPayload {
|
|
3
|
-
changes?: Array<{
|
|
4
|
-
contentType?: string;
|
|
5
|
-
documentId?: string;
|
|
6
|
-
id?: string;
|
|
7
|
-
locale?: string;
|
|
8
|
-
}>;
|
|
9
|
-
contentType?: string;
|
|
10
|
-
documentId?: string;
|
|
11
|
-
id?: string;
|
|
12
|
-
locale?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function normalizeContentQueryRoot(contentType: string): string;
|
|
15
|
-
export declare function getContentRefreshPayload(data: unknown): ContentRefreshPayload | null;
|
|
16
|
-
export declare function shouldInvalidateContentQuery(queryKey: readonly unknown[], payload: ContentRefreshPayload | null): boolean;
|
|
17
|
-
export declare const RefreshContentProvider: FC<PropsWithChildren>;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=RefreshContentProvider.d.ts.map
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
export function normalizeContentQueryRoot(contentType) {
|
|
5
|
-
return contentType
|
|
6
|
-
.split(/[^a-zA-Z0-9]+/)
|
|
7
|
-
.filter(Boolean)
|
|
8
|
-
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
9
|
-
.join('');
|
|
10
|
-
}
|
|
11
|
-
export function getContentRefreshPayload(data) {
|
|
12
|
-
if (!data || typeof data !== 'object') {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const payload = data.payload ?? data;
|
|
16
|
-
if (!payload || typeof payload !== 'object') {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return payload;
|
|
20
|
-
}
|
|
21
|
-
function getContentTypes(payload) {
|
|
22
|
-
if (!payload) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
const contentTypes = new Set();
|
|
26
|
-
if (payload.contentType) {
|
|
27
|
-
contentTypes.add(payload.contentType);
|
|
28
|
-
}
|
|
29
|
-
for (const change of payload.changes ?? []) {
|
|
30
|
-
if (change.contentType) {
|
|
31
|
-
contentTypes.add(change.contentType);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return [...contentTypes];
|
|
35
|
-
}
|
|
36
|
-
export function shouldInvalidateContentQuery(queryKey, payload) {
|
|
37
|
-
const contentTypes = getContentTypes(payload);
|
|
38
|
-
if (contentTypes.length === 0) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
const queryRoots = new Set(contentTypes.flatMap((contentType) => [contentType, normalizeContentQueryRoot(contentType)]));
|
|
42
|
-
return queryRoots.has(String(queryKey[0]));
|
|
43
|
-
}
|
|
44
|
-
export const RefreshContentProvider = ({ children }) => {
|
|
45
|
-
const queryClient = useQueryClient();
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
const invalidateContent = (payload) => {
|
|
48
|
-
void queryClient.invalidateQueries({
|
|
49
|
-
predicate(query) {
|
|
50
|
-
return shouldInvalidateContentQuery(query.queryKey, payload);
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const onMessage = (e) => {
|
|
55
|
-
if (e.data?.type === 'content/refresh') {
|
|
56
|
-
invalidateContent(getContentRefreshPayload(e.data));
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const hot = import.meta.hot;
|
|
60
|
-
const onContentUpdated = (payload) => {
|
|
61
|
-
invalidateContent(getContentRefreshPayload(payload));
|
|
62
|
-
};
|
|
63
|
-
window.addEventListener('message', onMessage);
|
|
64
|
-
hot?.on('fimo:content-updated', onContentUpdated);
|
|
65
|
-
return () => {
|
|
66
|
-
window.removeEventListener('message', onMessage);
|
|
67
|
-
hot?.off('fimo:content-updated', onContentUpdated);
|
|
68
|
-
};
|
|
69
|
-
}, [queryClient]);
|
|
70
|
-
return _jsx(_Fragment, { children: children });
|
|
71
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SOURCE_TRACKED_QUERY_OPTIONS } from './react-content-client.js';
|
|
2
|
-
import type { ContentClientConfig, CollectionContentClient } from './types.js';
|
|
3
|
-
export { SOURCE_TRACKED_QUERY_OPTIONS };
|
|
4
|
-
export declare function createContentClient<T extends {
|
|
5
|
-
id: string;
|
|
6
|
-
}, TInput extends object>(config: ContentClientConfig): CollectionContentClient<T, TInput>;
|
|
7
|
-
//# sourceMappingURL=createContentClient.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createReactContentClient, SOURCE_TRACKED_QUERY_OPTIONS } from './react-content-client.js';
|
|
2
|
-
import { useQueryLocale } from './useQueryLocale.js';
|
|
3
|
-
import { viteContentRuntime } from './vite-runtime.js';
|
|
4
|
-
export { SOURCE_TRACKED_QUERY_OPTIONS };
|
|
5
|
-
export function createContentClient(config) {
|
|
6
|
-
return createReactContentClient(config, viteContentRuntime, (requested, fallback) => useQueryLocale(requested, fallback));
|
|
7
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ContentClientConfig, SingletonContentClient } from './types.js';
|
|
2
|
-
export declare function createSingletonClient<T extends {
|
|
3
|
-
id: string;
|
|
4
|
-
}, TInput extends object>(config: ContentClientConfig): SingletonContentClient<T, TInput>;
|
|
5
|
-
//# sourceMappingURL=createSingletonClient.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createReactSingletonClient } from './react-singleton-client.js';
|
|
2
|
-
import { useQueryLocale } from './useQueryLocale.js';
|
|
3
|
-
import { viteContentRuntime } from './vite-runtime.js';
|
|
4
|
-
export function createSingletonClient(config) {
|
|
5
|
-
return createReactSingletonClient(config, viteContentRuntime, (requested, fallback) => useQueryLocale(requested, fallback));
|
|
6
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ContentRuntime } from './runtime.js';
|
|
2
|
-
import type { CollectionContentClient, ContentClientConfig } from './types.js';
|
|
3
|
-
export declare const SOURCE_TRACKED_QUERY_OPTIONS: {
|
|
4
|
-
readonly structuralSharing: false;
|
|
5
|
-
};
|
|
6
|
-
export type UseContentLocale = (requestedLocale: string | undefined, defaultLocale: string) => string;
|
|
7
|
-
export declare function createReactContentClient<T extends {
|
|
8
|
-
id: string;
|
|
9
|
-
}, TInput extends object>(config: ContentClientConfig, runtime: ContentRuntime, useContentLocale: UseContentLocale): CollectionContentClient<T, TInput>;
|
|
10
|
-
//# sourceMappingURL=react-content-client.d.ts.map
|