fimo 0.14.0 → 0.15.0-staging.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/assets/astro/components/Boolean.astro +14 -0
- package/assets/astro/components/Date.astro +23 -0
- package/assets/astro/components/Image.astro +79 -0
- package/assets/astro/components/Json.astro +14 -0
- package/assets/astro/components/RichText.astro +17 -0
- package/assets/astro/components/StaticImage.astro +66 -0
- package/assets/astro/components/Text.astro +23 -0
- package/assets/astro/components/Video.astro +47 -0
- package/assets/astro/components/index.d.ts +8 -0
- package/assets/astro/components/index.js +8 -0
- package/assets/content-templates/shared/server.eta +56 -0
- package/assets/content-templates/sveltekit/content.eta +86 -0
- package/assets/skills/fimo/SKILL.md +13 -4
- package/assets/skills/fimo-cli/SKILL.md +28 -28
- package/assets/skills/fimo-cli/references/account.md +0 -2
- package/assets/skills/fimo-cli/references/agent-setup.md +7 -9
- package/assets/skills/fimo-cli/references/agents.md +0 -2
- package/assets/skills/fimo-cli/references/analytics.md +0 -2
- package/assets/skills/fimo-cli/references/assets.md +2 -4
- package/assets/skills/fimo-cli/references/branches.md +14 -15
- package/assets/skills/fimo-cli/references/content.md +9 -11
- package/assets/skills/fimo-cli/references/credits.md +0 -2
- package/assets/skills/fimo-cli/references/deploy.md +6 -7
- package/assets/skills/fimo-cli/references/describe.md +1 -3
- package/assets/skills/fimo-cli/references/domains.md +0 -2
- package/assets/skills/fimo-cli/references/forms.md +5 -7
- package/assets/skills/fimo-cli/references/history.md +0 -2
- package/assets/skills/fimo-cli/references/init.md +34 -26
- package/assets/skills/fimo-cli/references/integrations/firecrawl.md +0 -2
- package/assets/skills/fimo-cli/references/integrations.md +0 -2
- package/assets/skills/fimo-cli/references/invite.md +0 -2
- package/assets/skills/fimo-cli/references/labels.md +5 -7
- package/assets/skills/fimo-cli/references/locales.md +2 -4
- package/assets/skills/fimo-cli/references/mcp.md +2 -4
- package/assets/skills/fimo-cli/references/media.md +0 -2
- package/assets/skills/fimo-cli/references/preview.md +0 -2
- package/assets/skills/fimo-cli/references/project-vars-and-secrets.md +1 -3
- package/assets/skills/fimo-cli/references/projects.md +1 -3
- package/assets/skills/fimo-cli/references/schedules.md +0 -2
- package/assets/skills/fimo-cli/references/support.md +0 -2
- package/assets/skills/fimo-cli/references/webhooks.md +0 -2
- package/assets/skills/fimo-code/SKILL.md +11 -3
- package/assets/skills/fimo-code/references/assets.md +2 -2
- package/assets/skills/fimo-code/references/content/clients.md +5 -1
- package/assets/skills/fimo-code/references/content.md +3 -1
- package/assets/skills/fimo-code/references/frameworks/astro.md +127 -0
- package/assets/skills/fimo-code/references/frameworks/compatibility.md +19 -0
- package/assets/skills/fimo-code/references/frameworks/hosting.md +15 -3
- package/assets/skills/fimo-code/references/frameworks/react-router.md +37 -209
- package/assets/skills/fimo-code/references/frameworks/sveltekit.md +110 -0
- package/assets/skills/fimo-code/references/frameworks/vite-react.md +35 -166
- package/assets/skills/fimo-code/references/labels.md +16 -6
- package/assets/skills/fimo-code/references/locales.md +3 -1
- package/assets/skills/fimo-code/references/ui.md +19 -15
- package/assets/skills/fimo-migration/SKILL.md +99 -146
- package/assets/skills/fimo-migration/references/frameworks/nextjs.md +26 -0
- package/assets/skills/fimo-migration/references/inventory/coordinator.md +40 -0
- package/assets/skills/fimo-migration/references/inventory/locales/next-intl.md +39 -0
- package/assets/skills/fimo-migration/references/inventory/locales.md +41 -0
- package/assets/skills/fimo-migration/references/workflow.md +3 -2
- package/assets/skills/fimo-migration/scripts/inventory/locales/next-intl.mjs +459 -0
- package/assets/skills/fimo-studio/SKILL.md +1 -1
- package/assets/skills/fimo-studio/references/project-creation.md +10 -18
- package/assets/starters/fimo-site/template/.fimo/agents/content-guide/capabilities.yaml +0 -1
- package/assets/starters/fimo-site/template/.fimo/agents/site-review/capabilities.yaml +0 -1
- package/assets/sveltekit/components/Boolean.svelte +19 -0
- package/assets/sveltekit/components/Date.svelte +33 -0
- package/assets/sveltekit/components/FimoProvider.svelte +35 -0
- package/assets/sveltekit/components/Image.svelte +80 -0
- package/assets/sveltekit/components/Json.svelte +18 -0
- package/assets/sveltekit/components/Label.svelte +16 -0
- package/assets/sveltekit/components/Number.svelte +21 -0
- package/assets/sveltekit/components/RichText.svelte +19 -0
- package/assets/sveltekit/components/Text.svelte +30 -0
- package/assets/sveltekit/components/Video.svelte +37 -0
- package/assets/sveltekit/components/index.d.ts +10 -0
- package/assets/sveltekit/components/index.js +10 -0
- package/dist/build/astro/config.d.ts +4 -0
- package/dist/build/astro/config.js +64 -0
- package/dist/build/next/config.js +16 -0
- package/dist/build/sveltekit/config.d.ts +6 -0
- package/dist/build/sveltekit/config.js +8 -0
- package/dist/build/sveltekit/data-id.d.ts +3 -0
- package/dist/build/sveltekit/data-id.js +171 -0
- package/dist/build/sveltekit/vite.d.ts +13 -0
- package/dist/build/sveltekit/vite.js +15 -0
- package/dist/build/vite/index.js +2 -0
- package/dist/build/vite/plugins/data-id.d.ts +9 -0
- package/dist/build/vite/plugins/data-id.js +6 -1
- package/dist/build/vite/plugins/runtime-env.d.ts +21 -0
- package/dist/build/vite/plugins/runtime-env.js +68 -0
- package/dist/cli/bundle.json +1 -1
- package/dist/cli/index.js +108 -101
- package/dist/runtime/app/FimoProviders.d.ts +1 -1
- package/dist/runtime/app/FimoProviders.js +11 -5
- package/dist/runtime/astro/internal.d.ts +6 -0
- package/dist/runtime/astro/internal.js +16 -0
- package/dist/runtime/astro/preview.d.ts +14 -0
- package/dist/runtime/astro/preview.js +103 -0
- package/dist/runtime/astro/render-rich-text.d.ts +2 -0
- package/dist/runtime/astro/render-rich-text.js +1 -0
- package/dist/runtime/astro/server-runtime.d.ts +3 -0
- package/dist/runtime/astro/server-runtime.js +20 -0
- package/dist/runtime/astro/server.d.ts +15 -0
- package/dist/runtime/astro/server.js +14 -0
- package/dist/runtime/content/client/collection-core.d.ts +2 -17
- package/dist/runtime/content/client/collection-core.js +15 -8
- package/dist/runtime/content/client/core-types.d.ts +96 -0
- package/dist/runtime/content/client/core-types.js +1 -0
- package/dist/runtime/content/client/internal.d.ts +4 -4
- package/dist/runtime/content/client/internal.js +4 -3
- package/dist/runtime/content/client/runtime.d.ts +1 -1
- package/dist/runtime/content/client/server-content-client.d.ts +3 -3
- package/dist/runtime/content/client/server-content-client.js +2 -29
- package/dist/runtime/content/client/singleton-core.d.ts +2 -9
- package/dist/runtime/content/client/singleton-core.js +9 -4
- package/dist/runtime/content/client/types.d.ts +5 -115
- package/dist/runtime/content/index.d.ts +3 -3
- package/dist/runtime/labels/fetch.js +5 -3
- package/dist/runtime/next/client.d.ts +2 -1
- package/dist/runtime/next/facade.d.ts +1 -1
- package/dist/runtime/next/provider.js +1 -1
- package/dist/runtime/next/server-runtime.js +1 -1
- package/dist/runtime/next/server.d.ts +5 -4
- package/dist/runtime/paths/get-fimo-paths.js +8 -3
- package/dist/runtime/preview/bridge.d.ts +8 -0
- package/dist/runtime/preview/bridge.js +20 -0
- package/dist/runtime/preview/location.d.ts +23 -0
- package/dist/runtime/preview/location.js +93 -0
- package/dist/runtime/preview/routes.d.ts +10 -0
- package/dist/runtime/preview/routes.js +29 -0
- package/dist/runtime/primitives/index.d.ts +4 -1
- package/dist/runtime/primitives/index.js +1 -0
- package/dist/runtime/primitives/lib/image-optimization.d.ts +27 -2
- package/dist/runtime/primitives/lib/image-optimization.js +40 -0
- package/dist/runtime/primitives/lib/index.d.ts +1 -1
- package/dist/runtime/primitives/lib/primitives.d.ts +0 -54
- package/dist/runtime/primitives/lib/primitives.js +6 -0
- package/dist/runtime/primitives/lib/render-rich-text.d.ts +3 -0
- package/dist/runtime/primitives/lib/render-rich-text.js +112 -0
- package/dist/runtime/react/primitives/contracts.d.ts +40 -2
- package/dist/runtime/react/primitives/renderers/ImageRenderer.js +15 -34
- package/dist/runtime/react/primitives/renderers/RichTextRenderer.d.ts +2 -1
- package/dist/runtime/react/primitives/renderers/StaticImage.js +13 -30
- package/dist/runtime/routing/AppRoutesProvider.js +20 -8
- package/dist/runtime/shared/env-identity.d.ts +43 -0
- package/dist/runtime/shared/env-identity.js +88 -0
- package/dist/runtime/shared/local-runtime-env.d.ts +65 -0
- package/dist/runtime/shared/local-runtime-env.js +169 -0
- package/dist/runtime/{react-router → shared}/preview-location.d.ts +7 -13
- package/dist/runtime/{react-router → shared}/preview-location.js +26 -27
- package/dist/runtime/sveltekit/content.d.ts +25 -0
- package/dist/runtime/sveltekit/content.js +33 -0
- package/dist/runtime/sveltekit/context-contract.d.ts +5 -0
- package/dist/runtime/sveltekit/context-contract.js +2 -0
- package/dist/runtime/sveltekit/context.d.ts +8 -0
- package/dist/runtime/sveltekit/context.js +25 -0
- package/dist/runtime/sveltekit/index.d.ts +7 -0
- package/dist/runtime/sveltekit/index.js +4 -0
- package/dist/runtime/sveltekit/internal.d.ts +6 -0
- package/dist/runtime/sveltekit/internal.js +12 -0
- package/dist/runtime/sveltekit/labels.d.ts +16 -0
- package/dist/runtime/sveltekit/labels.js +13 -0
- package/dist/runtime/sveltekit/preview.d.ts +19 -0
- package/dist/runtime/sveltekit/preview.js +77 -0
- package/dist/runtime/sveltekit/runtime.d.ts +8 -0
- package/dist/runtime/sveltekit/runtime.js +17 -0
- package/dist/runtime/templates.d.ts +1 -1
- package/dist/runtime/templates.js +1 -1
- package/dist/runtime/vite/Label.d.ts +13 -0
- package/dist/runtime/vite/Label.js +16 -0
- package/dist/scripts/extract-translations.js +103 -43
- package/dist/scripts/sync-forms.js +1 -1
- package/dist/scripts/sync-schemas.js +83 -16
- package/package.json +57 -2
- package/release.json +2 -2
- package/templates/nextjs/AGENTS.md +10 -5
- package/templates/nextjs/_gitignore +1 -0
- package/templates/react-router/AGENTS.md +4 -3
- package/templates/react-router/package.json +1 -1
- package/templates/sveltekit/.fimo/config.json +15 -0
- package/templates/sveltekit/AGENTS.md +36 -0
- package/templates/sveltekit/CLAUDE.md +5 -0
- package/templates/sveltekit/_gitignore +16 -0
- package/templates/sveltekit/package.json +28 -0
- package/templates/sveltekit/pnpm-workspace.yaml +4 -0
- package/templates/sveltekit/src/app.html +11 -0
- package/templates/sveltekit/src/routes/+layout.server.ts +8 -0
- package/templates/sveltekit/src/routes/+layout.svelte +12 -0
- package/templates/sveltekit/src/routes/+page.svelte +48 -0
- package/templates/sveltekit/svelte.config.js +5 -0
- package/templates/sveltekit/tsconfig.json +14 -0
- package/templates/sveltekit/vite.config.ts +5 -0
- /package/assets/content-templates/{form-template.eta → forms/react.eta} +0 -0
- /package/assets/content-templates/{next-client-template.eta → next/client.eta} +0 -0
- /package/assets/content-templates/{next-server-template.eta → next/server.eta} +0 -0
- /package/assets/content-templates/{hooks-template.eta → react/client.eta} +0 -0
- /package/assets/content-templates/{types-template.eta → shared/types.eta} +0 -0
|
@@ -1,101 +1,7 @@
|
|
|
1
1
|
import type { InfiniteData, UseInfiniteQueryResult, UseMutationResult, UseQueryResult, UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import type { Fields, Populate,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* field projection narrowed — the runtime equivalent of the generated
|
|
6
|
-
* `{Uid}Result` alias.
|
|
7
|
-
*/
|
|
8
|
-
export type ContentResult<T extends {
|
|
9
|
-
id: string;
|
|
10
|
-
}, TFields extends Fields<T> | undefined = undefined, TPopulate extends Populate<T> | undefined = undefined> = ProjectedWithPopulate<PopulatedResult<T, TPopulate> & {
|
|
11
|
-
id: string;
|
|
12
|
-
}, TFields, TPopulate>;
|
|
13
|
-
/**
|
|
14
|
-
* The schema definition as written in `src/schemas/<uid>.json`. The factory
|
|
15
|
-
* interprets it directly — the schema is the descriptor, so generated code
|
|
16
|
-
* never transcribes field shapes into a second format that could drift.
|
|
17
|
-
*/
|
|
18
|
-
export interface ContentSchemaField {
|
|
19
|
-
type?: string;
|
|
20
|
-
required?: boolean;
|
|
21
|
-
default?: unknown;
|
|
22
|
-
/** Media fields: multiple assets. */
|
|
23
|
-
multiple?: boolean;
|
|
24
|
-
/** Reference fields: to-many. */
|
|
25
|
-
many?: boolean;
|
|
26
|
-
/** Reference fields: target schema uid (may be this schema's own uid). */
|
|
27
|
-
target?: string;
|
|
28
|
-
/** Polymorphic reference fields: allowed target schema uids. */
|
|
29
|
-
targets?: readonly string[];
|
|
30
|
-
min?: number;
|
|
31
|
-
max?: number;
|
|
32
|
-
minLength?: number;
|
|
33
|
-
maxLength?: number;
|
|
34
|
-
regex?: string;
|
|
35
|
-
schema?: {
|
|
36
|
-
fields: Readonly<Record<string, ContentSchemaField>>;
|
|
37
|
-
} | {
|
|
38
|
-
oneOf: readonly {
|
|
39
|
-
uid: string;
|
|
40
|
-
label: string;
|
|
41
|
-
description?: string;
|
|
42
|
-
fields: Readonly<Record<string, ContentSchemaField>>;
|
|
43
|
-
}[];
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export interface ContentSchema {
|
|
47
|
-
uid: string;
|
|
48
|
-
name?: string;
|
|
49
|
-
isSingleton?: boolean;
|
|
50
|
-
i18n?: {
|
|
51
|
-
enabled?: boolean;
|
|
52
|
-
};
|
|
53
|
-
fields?: Readonly<Record<string, ContentSchemaField>>;
|
|
54
|
-
}
|
|
55
|
-
export interface ContentModuleMeta {
|
|
56
|
-
readonly uid: string;
|
|
57
|
-
readonly pascal: string;
|
|
58
|
-
readonly localized: boolean;
|
|
59
|
-
}
|
|
60
|
-
export interface ContentClientHandle {
|
|
61
|
-
wrapWithSource: (entry: Record<string, any>) => unknown;
|
|
62
|
-
meta: ContentModuleMeta;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A cross-referenced generated module — either a client directly, or a module
|
|
66
|
-
* namespace whose default export is the client. Generated modules for schemas
|
|
67
|
-
* that reference each other form ESM cycles, so the factory only reads
|
|
68
|
-
* properties off a ref lazily at request time, never while the client is
|
|
69
|
-
* being constructed — a namespace import is safe to pass here even mid-cycle.
|
|
70
|
-
*/
|
|
71
|
-
export type ContentModuleRef = ContentClientHandle | {
|
|
72
|
-
default: ContentClientHandle;
|
|
73
|
-
};
|
|
74
|
-
export interface ContentClientConfig {
|
|
75
|
-
schema: ContentSchema;
|
|
76
|
-
/**
|
|
77
|
-
* Every OTHER schema module this schema references, keyed by uid —
|
|
78
|
-
* `references: { Author, Video }` with namespace imports. Self-references
|
|
79
|
-
* resolve internally and never appear here.
|
|
80
|
-
*/
|
|
81
|
-
references?: Readonly<Record<string, ContentModuleRef>>;
|
|
82
|
-
}
|
|
83
|
-
export interface ContentReadOptions<TPopulate> {
|
|
84
|
-
locale?: string;
|
|
85
|
-
populate?: TPopulate;
|
|
86
|
-
localeFallbacks?: boolean;
|
|
87
|
-
}
|
|
88
|
-
export interface CollectionPageInfo {
|
|
89
|
-
readonly limit: number;
|
|
90
|
-
readonly offset: number;
|
|
91
|
-
readonly total: number;
|
|
92
|
-
readonly hasMore: boolean;
|
|
93
|
-
readonly nextOffset: number | null;
|
|
94
|
-
}
|
|
95
|
-
export interface CollectionPage<TItem> {
|
|
96
|
-
readonly items: TItem[];
|
|
97
|
-
readonly pageInfo: CollectionPageInfo;
|
|
98
|
-
}
|
|
2
|
+
import type { Fields, Populate, Query } from '../../primitives/lib/query.js';
|
|
3
|
+
import type { CollectionContentCore, CollectionPage, ContentReadOptions, ContentResult, SingletonContentCore } from './core-types.js';
|
|
4
|
+
export type { CollectionContentCore, CollectionPage, CollectionPageInfo, ContentClientConfig, ContentClientHandle, ContentModuleMeta, ContentModuleRef, ContentReadOptions, ContentResult, ContentSchema, ContentSchemaField, SingletonContentCore, } from './core-types.js';
|
|
99
5
|
export type InfiniteListResult<TItem> = UseInfiniteQueryResult<InfiniteData<CollectionPage<TItem>>, Error> & {
|
|
100
6
|
readonly items: TItem[];
|
|
101
7
|
readonly total: number;
|
|
@@ -105,19 +11,7 @@ export type InfiniteListResult<TItem> = UseInfiniteQueryResult<InfiniteData<Coll
|
|
|
105
11
|
};
|
|
106
12
|
export interface CollectionContentClient<T extends {
|
|
107
13
|
id: string;
|
|
108
|
-
}, TInput> {
|
|
109
|
-
readonly meta: ContentModuleMeta;
|
|
110
|
-
wrapWithSource(entry: Record<string, any>): T;
|
|
111
|
-
getById<TPopulate extends Populate<T> | undefined = undefined>(id: string, options?: ContentReadOptions<TPopulate>): Promise<ContentResult<T, undefined, TPopulate>>;
|
|
112
|
-
getBySlug<TPopulate extends Populate<T> | undefined = undefined>(slug: string, options?: ContentReadOptions<TPopulate>): Promise<ContentResult<T, undefined, TPopulate> | null>;
|
|
113
|
-
getByField<TPopulate extends Populate<T> | undefined = undefined>(fieldName: string, value: string, options?: ContentReadOptions<TPopulate>): Promise<ContentResult<T, undefined, TPopulate> | null>;
|
|
114
|
-
list<TFields extends Fields<T> | undefined = undefined, TPopulate extends Populate<T> | undefined = undefined>(params?: Query<T, TFields, TPopulate>): Promise<CollectionPage<ContentResult<T, TFields, TPopulate>>>;
|
|
115
|
-
get<TFields extends Fields<T> | undefined = undefined, TPopulate extends Populate<T> | undefined = undefined>(params?: Query<T, TFields, TPopulate>): Promise<ContentResult<T, TFields, TPopulate>[]>;
|
|
116
|
-
create(payload: TInput): Promise<T>;
|
|
117
|
-
update(id: string, payload: Partial<TInput>): Promise<T>;
|
|
118
|
-
remove(id: string, options?: {
|
|
119
|
-
locale?: string;
|
|
120
|
-
}): Promise<void>;
|
|
14
|
+
}, TInput extends object> extends CollectionContentCore<T, TInput> {
|
|
121
15
|
useGetById<TPopulate extends Populate<T> | undefined = undefined>(id: string, options?: ContentReadOptions<TPopulate>): UseQueryResult<ContentResult<T, undefined, TPopulate>, Error>;
|
|
122
16
|
useGetBySlug<TPopulate extends Populate<T> | undefined = undefined>(slug: string, options?: ContentReadOptions<TPopulate>): UseQueryResult<ContentResult<T, undefined, TPopulate> | null, Error>;
|
|
123
17
|
useGetByField<TPopulate extends Populate<T> | undefined = undefined>(fieldName: string, value: string, options?: ContentReadOptions<TPopulate>): UseQueryResult<ContentResult<T, undefined, TPopulate> | null, Error>;
|
|
@@ -140,11 +34,7 @@ export interface CollectionContentClient<T extends {
|
|
|
140
34
|
}
|
|
141
35
|
export interface SingletonContentClient<T extends {
|
|
142
36
|
id: string;
|
|
143
|
-
}, TInput> {
|
|
144
|
-
readonly meta: ContentModuleMeta;
|
|
145
|
-
wrapWithSource(entry: Record<string, any>): T;
|
|
146
|
-
get<TPopulate extends Populate<T> | undefined = undefined>(options?: ContentReadOptions<TPopulate>): Promise<ContentResult<T, undefined, TPopulate>>;
|
|
147
|
-
update(payload: Partial<TInput>): Promise<T>;
|
|
37
|
+
}, TInput extends object> extends SingletonContentCore<T, TInput> {
|
|
148
38
|
useGet<TPopulate extends Populate<T> | undefined = undefined>(options?: ContentReadOptions<TPopulate>): UseQueryResult<ContentResult<T, undefined, TPopulate>, Error>;
|
|
149
39
|
useSuspenseGet<TPopulate extends Populate<T> | undefined = undefined>(options?: ContentReadOptions<TPopulate>): UseSuspenseQueryResult<ContentResult<T, undefined, TPopulate>, Error>;
|
|
150
40
|
useUpdate(): UseMutationResult<T, Error, Partial<TInput>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { ContentClientConfig } from './client/core-types.js';
|
|
1
2
|
import type { ContentRuntime } from './client/runtime.js';
|
|
2
|
-
import type { ContentClientConfig } from './client/types.js';
|
|
3
3
|
export declare function createContentCore<T extends {
|
|
4
4
|
id: string;
|
|
5
5
|
}, TInput extends object>(config: ContentClientConfig, runtime: ContentRuntime): import("./index.js").CollectionContentCore<T, TInput>;
|
|
@@ -10,7 +10,7 @@ export type { CollectionContentCore } from './client/collection-core.js';
|
|
|
10
10
|
export type { ContentRuntime } from './client/runtime.js';
|
|
11
11
|
export type { SingletonContentCore } from './client/singleton-core.js';
|
|
12
12
|
export { serializeContent, type SerializedContent, type SerializedMedia } from './serialization.js';
|
|
13
|
-
export type { CollectionPage, CollectionPageInfo, ContentClientConfig, ContentClientHandle, ContentModuleMeta, ContentModuleRef, ContentReadOptions, ContentResult, ContentSchema, ContentSchemaField, } from './client/types.js';
|
|
14
|
-
export { FIMO_PARTS, FIMO_SOURCE, FimoBoolean, FimoDate, FimoMedia, FimoRichText, FimoString, getFimoParts, getFimoSource, hasFimoSource, isFimoDate, isFimoString, type FimoPart, type FimoPolymorphicReference, type FimoReference, type
|
|
13
|
+
export type { CollectionPage, CollectionPageInfo, ContentClientConfig, ContentClientHandle, ContentModuleMeta, ContentModuleRef, ContentReadOptions, ContentResult, ContentSchema, ContentSchemaField, } from './client/core-types.js';
|
|
14
|
+
export { FIMO_PARTS, FIMO_SOURCE, FimoBoolean, FimoDate, FimoMedia, FimoRichText, FimoString, getFimoParts, getFimoSource, hasFimoSource, isFimoDate, isFimoString, type FimoPart, type FimoPolymorphicReference, type FimoReference, type FimoRichTextContent, type FimoSource, } from '../primitives/lib/primitives.js';
|
|
15
15
|
export type { BoolOps, DateOps, Field, Fields, FilterFor, NullOnlyOps, NumberOps, Populate, Populated, PopulatedResult, Projected, ProjectedWithPopulate, Query, ReferenceField, ReferenceMap, ScalarOps, Sort, SortField, StringOps, Where, WithReferences, } from '../primitives/lib/query.js';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -8,7 +8,7 @@ function dictionaryFrom(value) {
|
|
|
8
8
|
function snapshotFrom(body, requestedLocale) {
|
|
9
9
|
if (Array.isArray(body.data)) {
|
|
10
10
|
return {
|
|
11
|
-
locale: requestedLocale,
|
|
11
|
+
locale: requestedLocale ?? 'en',
|
|
12
12
|
labels: Object.fromEntries(body.data.flatMap((row) => {
|
|
13
13
|
if (typeof row.key !== 'string') {
|
|
14
14
|
return [];
|
|
@@ -21,7 +21,7 @@ function snapshotFrom(body, requestedLocale) {
|
|
|
21
21
|
}
|
|
22
22
|
const data = body.data;
|
|
23
23
|
return {
|
|
24
|
-
locale: typeof data?.locale === 'string' && data.locale.trim() ? data.locale : requestedLocale,
|
|
24
|
+
locale: typeof data?.locale === 'string' && data.locale.trim() ? data.locale : (requestedLocale ?? 'en'),
|
|
25
25
|
labels: dictionaryFrom(data?.labels),
|
|
26
26
|
updatedAt: typeof data?.updatedAt === 'string' ? data.updatedAt : null,
|
|
27
27
|
};
|
|
@@ -29,7 +29,9 @@ function snapshotFrom(body, requestedLocale) {
|
|
|
29
29
|
export async function fetchLabels(runtime, { locale: requestedLocale } = {}) {
|
|
30
30
|
const locale = requestedLocale?.trim() || runtime.defaultLocale();
|
|
31
31
|
const url = new URL('/labels', runtime.apiBase());
|
|
32
|
-
|
|
32
|
+
if (locale) {
|
|
33
|
+
url.searchParams.set('locale', locale);
|
|
34
|
+
}
|
|
33
35
|
const response = await runtime.fetch(url, {
|
|
34
36
|
headers: runtime.headers({ Accept: 'application/json' }),
|
|
35
37
|
});
|
|
@@ -17,7 +17,8 @@ export { RichText } from '../react/primitives/editable/RichText.js';
|
|
|
17
17
|
export { StaticImage } from '../react/primitives/renderers/StaticImage.js';
|
|
18
18
|
export { Text } from '../react/primitives/editable/Text.js';
|
|
19
19
|
export { Video } from '../react/primitives/editable/Video.js';
|
|
20
|
-
export type { BoolOps, DateOps, Field, Fields, FilterFor, FimoPart, FimoPolymorphicReference, FimoReference,
|
|
20
|
+
export type { BoolOps, DateOps, Field, Fields, FilterFor, FimoPart, FimoPolymorphicReference, FimoReference, FimoRichTextContent, FimoSource, NullOnlyOps, NumberOps, Populate, Populated, PopulatedResult, Projected, ProjectedWithPopulate, Query, ReferenceField, ReferenceMap, ScalarOps, Sort, SortField, StringOps, Where, WithReferences, } from '../content/index.js';
|
|
21
|
+
export type { FimoRichTextComponents, FimoRichTextMarkProps, FimoRichTextNodeProps, } from '../react/primitives/contracts.js';
|
|
21
22
|
export { FimoProvider, useLabels } from './provider.js';
|
|
22
23
|
export type { FimoProviderProps } from './provider.js';
|
|
23
24
|
export type { Labels, LabelsSnapshot } from '../labels/core.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentClientHandle } from '../content/client/types.js';
|
|
1
|
+
import type { ContentClientHandle } from '../content/client/core-types.js';
|
|
2
2
|
export type NextContentRegistry = Readonly<Record<string, ContentClientHandle>>;
|
|
3
3
|
export interface CreateFimoOptions<TContent extends NextContentRegistry> {
|
|
4
4
|
content: TContent;
|
|
@@ -17,7 +17,7 @@ export function useNextContentLocale(requestedLocale, defaultLocale) {
|
|
|
17
17
|
}
|
|
18
18
|
export function useLabels() {
|
|
19
19
|
const context = useContext(FimoNextContext);
|
|
20
|
-
const locale = context.locale ?? nextClientContentRuntime.defaultLocale();
|
|
20
|
+
const locale = context.locale ?? nextClientContentRuntime.defaultLocale() ?? 'en';
|
|
21
21
|
const snapshot = context.labels?.locale === locale
|
|
22
22
|
? context.labels
|
|
23
23
|
: { locale, labels: {}, updatedAt: null };
|
|
@@ -4,7 +4,7 @@ export const nextServerContentRuntime = {
|
|
|
4
4
|
return requireContentApiUrl(process.env.FIMO_CONTENT_API_URL, 'FIMO_CONTENT_API_URL');
|
|
5
5
|
},
|
|
6
6
|
defaultLocale() {
|
|
7
|
-
return process.env.FIMO_DEFAULT_LOCALE?.trim() ||
|
|
7
|
+
return process.env.FIMO_DEFAULT_LOCALE?.trim() || undefined;
|
|
8
8
|
},
|
|
9
9
|
headers(extra) {
|
|
10
10
|
const headers = { ...extra };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CollectionContentCore, ContentClientConfig, SingletonContentCore } from '../content/client/core-types.js';
|
|
2
2
|
export { StaticImage } from '../react/primitives/renderers/StaticImage.js';
|
|
3
3
|
export { Text } from './primitives/Text.js';
|
|
4
4
|
export { Boolean, Date, Image, Json, RichText, Video } from './primitives/server.js';
|
|
@@ -7,12 +7,13 @@ export type { CreateFimoOptions, NextContentRegistry } from './facade.js';
|
|
|
7
7
|
export { getLabels } from './labels.js';
|
|
8
8
|
export type { GetLabelsOptions } from '../labels/fetch.js';
|
|
9
9
|
export type { Labels, LabelsSnapshot } from '../labels/core.js';
|
|
10
|
+
export type { FimoRichTextComponents, FimoRichTextMarkProps, FimoRichTextNodeProps, } from '../react/primitives/contracts.js';
|
|
10
11
|
export declare function createContentClient<T extends {
|
|
11
12
|
id: string;
|
|
12
|
-
}, TInput extends object>(config: ContentClientConfig):
|
|
13
|
+
}, TInput extends object>(config: ContentClientConfig): CollectionContentCore<T, TInput>;
|
|
13
14
|
export declare function createSingletonClient<T extends {
|
|
14
15
|
id: string;
|
|
15
|
-
}, TInput extends object>(config: ContentClientConfig):
|
|
16
|
-
export type { CollectionContentClient,
|
|
16
|
+
}, TInput extends object>(config: ContentClientConfig): SingletonContentCore<T, TInput>;
|
|
17
|
+
export type { CollectionContentCore as CollectionContentClient, SingletonContentCore as SingletonContentClient, } from '../content/client/core-types.js';
|
|
17
18
|
export * from '../content/index.js';
|
|
18
19
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -6,6 +6,7 @@ import { resolve } from 'node:path';
|
|
|
6
6
|
import { getFimoLocales, localizeFimoPath } from '../i18n/locale.js';
|
|
7
7
|
import { resolveSeoForPath } from '../seo/resolver.js';
|
|
8
8
|
import { getConfigServer } from '../shared/fimo-config.server.js';
|
|
9
|
+
import { resolveLocalRuntimeEnv } from '../shared/local-runtime-env.js';
|
|
9
10
|
const isValidationBuild = !!process.env.FIMO_VALIDATION_BUILD;
|
|
10
11
|
const MAX_FETCH_ATTEMPTS = 3;
|
|
11
12
|
const RETRYABLE_FETCH_STATUSES = new Set([502, 503, 504]);
|
|
@@ -14,7 +15,9 @@ function readEnvValue(rootDir, key) {
|
|
|
14
15
|
if (process.env[key]) {
|
|
15
16
|
return process.env[key];
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
// `.env.local` first — every framework resolves it last, so it wins there
|
|
19
|
+
// and must win here too.
|
|
20
|
+
for (const file of ['.env.local', '.env']) {
|
|
18
21
|
const filePath = resolve(rootDir, file);
|
|
19
22
|
if (!existsSync(filePath)) {
|
|
20
23
|
continue;
|
|
@@ -32,7 +35,9 @@ function readEnvValue(rootDir, key) {
|
|
|
32
35
|
return undefined;
|
|
33
36
|
}
|
|
34
37
|
function resolveApiBaseUrl(rootDir) {
|
|
35
|
-
return readEnvValue(rootDir, 'VITE_API_URL') ??
|
|
38
|
+
return (readEnvValue(rootDir, 'VITE_API_URL') ??
|
|
39
|
+
readEnvValue(rootDir, 'VITE_API_URL_DEV') ??
|
|
40
|
+
resolveLocalRuntimeEnv({ cwd: rootDir })?.tenantApiUrl);
|
|
36
41
|
}
|
|
37
42
|
async function fetchEntries(baseUrl, schema, rootDir, locale) {
|
|
38
43
|
const url = new URL(`${baseUrl.replace(/\/$/, '')}/entries/${schema}`);
|
|
@@ -41,7 +46,7 @@ async function fetchEntries(baseUrl, schema, rootDir, locale) {
|
|
|
41
46
|
url.searchParams.set('limit', '1');
|
|
42
47
|
}
|
|
43
48
|
const headers = {};
|
|
44
|
-
const env = readEnvValue(rootDir, 'FIMO_ENV');
|
|
49
|
+
const env = readEnvValue(rootDir, 'FIMO_ENV') ?? resolveLocalRuntimeEnv({ cwd: rootDir })?.env;
|
|
45
50
|
if (env) {
|
|
46
51
|
headers['X-Fimo-Env'] = env;
|
|
47
52
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Preview communication exists only inside a Studio preview runtime. */
|
|
2
|
+
export declare function isPreviewRuntimeEnabled(previewScriptUrl: unknown): previewScriptUrl is string;
|
|
3
|
+
/**
|
|
4
|
+
* Accept application-owned paths while rejecting protocols, protocol-relative
|
|
5
|
+
* URLs, and backslash variants that URL parsers can normalize to another host.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getSafePreviewNavigationPath(target: unknown, currentOrigin: string): string | null;
|
|
8
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Preview communication exists only inside a Studio preview runtime. */
|
|
2
|
+
export function isPreviewRuntimeEnabled(previewScriptUrl) {
|
|
3
|
+
return typeof previewScriptUrl === 'string' && previewScriptUrl.trim().length > 0;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Accept application-owned paths while rejecting protocols, protocol-relative
|
|
7
|
+
* URLs, and backslash variants that URL parsers can normalize to another host.
|
|
8
|
+
*/
|
|
9
|
+
export function getSafePreviewNavigationPath(target, currentOrigin) {
|
|
10
|
+
if (typeof target !== 'string' || !target.startsWith('/') || target.startsWith('//')) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const resolved = new URL(target, currentOrigin);
|
|
15
|
+
return resolved.origin === currentOrigin ? `${resolved.pathname}${resolved.search}${resolved.hash}` : null;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface PreviewLocationLike {
|
|
2
|
+
pathname: string;
|
|
3
|
+
search?: string;
|
|
4
|
+
hash?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PreviewLocationChange {
|
|
7
|
+
/** Safe workspace focus value; query/hash state stays navigation-only. */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Exact app location used to keep the parent's iframe URL in sync. */
|
|
10
|
+
navigationPath: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PreviewBrowserContext {
|
|
13
|
+
readonly window: Pick<Window, 'location' | 'sessionStorage'>;
|
|
14
|
+
readonly document: Pick<Document, 'referrer'>;
|
|
15
|
+
}
|
|
16
|
+
/** Prefer the immediate embedding document over a potentially stale referrer. */
|
|
17
|
+
export declare function resolvePreviewParentOrigin(referrer: string | undefined, ancestorOrigins: readonly string[] | undefined): string | null;
|
|
18
|
+
/** Resolve and remember the trusted Studio origin across full-page navigation. */
|
|
19
|
+
export declare function getPreviewParentOrigin(browser?: PreviewBrowserContext): string | null;
|
|
20
|
+
/** Keep sandbox credentials and the iframe cache-buster out of app navigation state. */
|
|
21
|
+
export declare function getPreviewLocationPath(location: PreviewLocationLike): string;
|
|
22
|
+
export declare function getPreviewLocationChange(location: PreviewLocationLike): PreviewLocationChange;
|
|
23
|
+
//# sourceMappingURL=location.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const PREVIEW_INTERNAL_QUERY_PARAMS = new Set(['bl_preview_token', 'preview_token', 't']);
|
|
2
|
+
const PREVIEW_PARENT_ORIGIN_STORAGE_KEY = 'fimo-preview-parent-origin';
|
|
3
|
+
let rememberedPreviewParentOrigin;
|
|
4
|
+
const getOrigin = (value) => {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const origin = new URL(value).origin;
|
|
10
|
+
return origin === 'null' ? null : origin;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** Prefer the immediate embedding document over a potentially stale referrer. */
|
|
17
|
+
export function resolvePreviewParentOrigin(referrer, ancestorOrigins) {
|
|
18
|
+
return getOrigin(ancestorOrigins?.[0]) ?? getOrigin(referrer);
|
|
19
|
+
}
|
|
20
|
+
/** Resolve and remember the trusted Studio origin across full-page navigation. */
|
|
21
|
+
export function getPreviewParentOrigin(browser) {
|
|
22
|
+
const browserWindow = browser?.window ?? (typeof window === 'undefined' ? undefined : window);
|
|
23
|
+
const browserDocument = browser?.document ?? (typeof document === 'undefined' ? undefined : document);
|
|
24
|
+
if (!browserWindow) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const storage = readSessionStorage(browserWindow);
|
|
28
|
+
const ancestorOrigin = getOrigin(browserWindow.location.ancestorOrigins?.[0]);
|
|
29
|
+
if (ancestorOrigin) {
|
|
30
|
+
rememberPreviewParentOrigin(ancestorOrigin, storage);
|
|
31
|
+
return ancestorOrigin;
|
|
32
|
+
}
|
|
33
|
+
const rememberedOrigin = readRememberedPreviewParentOrigin(storage);
|
|
34
|
+
if (rememberedOrigin) {
|
|
35
|
+
return rememberedOrigin;
|
|
36
|
+
}
|
|
37
|
+
const referrerOrigin = getOrigin(browserDocument?.referrer);
|
|
38
|
+
if (referrerOrigin) {
|
|
39
|
+
rememberPreviewParentOrigin(referrerOrigin, storage);
|
|
40
|
+
}
|
|
41
|
+
return referrerOrigin;
|
|
42
|
+
}
|
|
43
|
+
function readSessionStorage(browserWindow) {
|
|
44
|
+
try {
|
|
45
|
+
return browserWindow.sessionStorage;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function readRememberedPreviewParentOrigin(storage) {
|
|
52
|
+
if (rememberedPreviewParentOrigin !== undefined) {
|
|
53
|
+
return rememberedPreviewParentOrigin;
|
|
54
|
+
}
|
|
55
|
+
if (!storage) {
|
|
56
|
+
rememberedPreviewParentOrigin = null;
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
rememberedPreviewParentOrigin = getOrigin(storage.getItem(PREVIEW_PARENT_ORIGIN_STORAGE_KEY) ?? undefined);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
rememberedPreviewParentOrigin = null;
|
|
64
|
+
}
|
|
65
|
+
return rememberedPreviewParentOrigin;
|
|
66
|
+
}
|
|
67
|
+
function rememberPreviewParentOrigin(origin, storage) {
|
|
68
|
+
rememberedPreviewParentOrigin = origin;
|
|
69
|
+
if (!storage) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
storage.setItem(PREVIEW_PARENT_ORIGIN_STORAGE_KEY, origin);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Storage availability must not block the preview message channel.
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Keep sandbox credentials and the iframe cache-buster out of app navigation state. */
|
|
80
|
+
export function getPreviewLocationPath(location) {
|
|
81
|
+
const search = new URLSearchParams(location.search ?? '');
|
|
82
|
+
for (const key of PREVIEW_INTERNAL_QUERY_PARAMS) {
|
|
83
|
+
search.delete(key);
|
|
84
|
+
}
|
|
85
|
+
const query = search.toString();
|
|
86
|
+
return `${location.pathname}${query ? `?${query}` : ''}${location.hash ?? ''}`;
|
|
87
|
+
}
|
|
88
|
+
export function getPreviewLocationChange(location) {
|
|
89
|
+
return {
|
|
90
|
+
path: location.pathname,
|
|
91
|
+
navigationPath: getPreviewLocationPath(location),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FimoConfig, FimoRouteConfig } from '../shared/fimo-config.types.js';
|
|
2
|
+
export interface PreviewRoute {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
path: string;
|
|
6
|
+
params?: FimoRouteConfig['params'];
|
|
7
|
+
}
|
|
8
|
+
/** Convert the optional Studio route catalog into the preview protocol shape. */
|
|
9
|
+
export declare function getConfigPreviewRoutes(config: Pick<FimoConfig, 'routes'>): PreviewRoute[];
|
|
10
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const titleCase = (value) => value
|
|
2
|
+
.replace(/[_-]+/g, ' ')
|
|
3
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
4
|
+
.split(/\s+/)
|
|
5
|
+
.filter(Boolean)
|
|
6
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
7
|
+
.join(' ');
|
|
8
|
+
function fallbackRouteName(id, path) {
|
|
9
|
+
if (path === '/') {
|
|
10
|
+
return 'Home';
|
|
11
|
+
}
|
|
12
|
+
return titleCase(id || path.replace(/^\//, '').split('/')[0]);
|
|
13
|
+
}
|
|
14
|
+
/** Convert the optional Studio route catalog into the preview protocol shape. */
|
|
15
|
+
export function getConfigPreviewRoutes(config) {
|
|
16
|
+
return Object.entries(config.routes ?? {}).flatMap(([id, route]) => {
|
|
17
|
+
if (!route.path) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
id,
|
|
23
|
+
name: route.label?.trim() || fallbackRouteName(id, route.path),
|
|
24
|
+
path: route.path,
|
|
25
|
+
...(route.params ? { params: route.params } : {}),
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -5,8 +5,11 @@ export { Date } from '../react/primitives/editable/Date.js';
|
|
|
5
5
|
export { Boolean } from '../react/primitives/editable/Boolean.js';
|
|
6
6
|
export { Json } from '../react/primitives/editable/Json.js';
|
|
7
7
|
export { RichText } from '../react/primitives/editable/RichText.js';
|
|
8
|
+
export { Label } from '../vite/Label.js';
|
|
9
|
+
export type { LabelProps } from '../vite/Label.js';
|
|
8
10
|
export { useLabels, useTranslations } from '../vite/translations.js';
|
|
9
|
-
export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent,
|
|
11
|
+
export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, } from './lib/index.js';
|
|
12
|
+
export type { FimoRichTextComponents, FimoRichTextMarkProps, FimoRichTextNodeProps, } from '../react/primitives/contracts.js';
|
|
10
13
|
export { useFimoLiveValue } from '../react/useFimoLiveValue.js';
|
|
11
14
|
export type { BoolOps, DateOps, Field, Fields, FilterFor, NullOnlyOps, NumberOps, Populate, Populated, PopulatedResult, Projected, ProjectedWithPopulate, Query, ReferenceField, ReferenceMap, ScalarOps, Sort, SortField, StringOps, WithReferences, Where, } from './lib/index.js';
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -9,6 +9,7 @@ export { Boolean } from '../react/primitives/editable/Boolean.js';
|
|
|
9
9
|
export { Json } from '../react/primitives/editable/Json.js';
|
|
10
10
|
export { RichText } from '../react/primitives/editable/RichText.js';
|
|
11
11
|
// Labels
|
|
12
|
+
export { Label } from '../vite/Label.js';
|
|
12
13
|
export { useLabels, useTranslations } from '../vite/translations.js';
|
|
13
14
|
// Primitives & utilities
|
|
14
15
|
export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, } from './lib/index.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
1
|
/** Default host suffixes eligible for Cloudflare Image Resizing optimization. */
|
|
3
2
|
export declare const DEFAULT_IMAGE_HOST_SUFFIXES: readonly ['.fimo.team', '.fimo.ai', '.fimo.site'];
|
|
4
3
|
/**
|
|
@@ -15,6 +14,7 @@ export declare const DEFAULT_IMAGE_DPRS: readonly [1, 2];
|
|
|
15
14
|
*/
|
|
16
15
|
export declare const IMAGE_FIT_VALUES: readonly ['scale-down', 'contain', 'cover', 'crop', 'pad'];
|
|
17
16
|
export type ImageFit = (typeof IMAGE_FIT_VALUES)[number];
|
|
17
|
+
export type ImageObjectFit = 'contain' | 'cover' | 'scale-down';
|
|
18
18
|
/** Clamp quality to valid range [1, 100], defaulting to 85. */
|
|
19
19
|
export declare function clampQuality(quality: number | undefined): number;
|
|
20
20
|
/**
|
|
@@ -24,7 +24,7 @@ export declare function resolveFit(fit: ImageFit | undefined): ImageFit;
|
|
|
24
24
|
/**
|
|
25
25
|
* Map Cloudflare fit mode to CSS object-fit.
|
|
26
26
|
*/
|
|
27
|
-
export declare function toObjectFit(fit: ImageFit):
|
|
27
|
+
export declare function toObjectFit(fit: ImageFit): ImageObjectFit;
|
|
28
28
|
/** Parse value to positive integer, or undefined if invalid. */
|
|
29
29
|
export declare function toPositiveInt(value: string | number | undefined): number | undefined;
|
|
30
30
|
/** Check if URL can be optimized (valid http(s) URL on allowed host). */
|
|
@@ -56,4 +56,29 @@ export declare function computeImageOptimizationConfig(options: {
|
|
|
56
56
|
fit: ImageFit;
|
|
57
57
|
hostSuffixes?: readonly string[];
|
|
58
58
|
}): ImageOptimizationConfig;
|
|
59
|
+
export interface ImagePresentationOptions {
|
|
60
|
+
src: string;
|
|
61
|
+
alt?: string;
|
|
62
|
+
mediaWidth?: number;
|
|
63
|
+
mediaHeight?: number;
|
|
64
|
+
quality?: number;
|
|
65
|
+
fit?: ImageFit;
|
|
66
|
+
unoptimized?: boolean;
|
|
67
|
+
overrideSrc?: string;
|
|
68
|
+
width?: string | number;
|
|
69
|
+
height?: string | number;
|
|
70
|
+
sizes?: string;
|
|
71
|
+
srcSet?: string;
|
|
72
|
+
hostSuffixes?: readonly string[];
|
|
73
|
+
}
|
|
74
|
+
export interface ImagePresentation {
|
|
75
|
+
src: string;
|
|
76
|
+
alt: string | undefined;
|
|
77
|
+
width: number | undefined;
|
|
78
|
+
height: number | undefined;
|
|
79
|
+
sizes: string | undefined;
|
|
80
|
+
srcSet: string | undefined;
|
|
81
|
+
objectFit: ImageObjectFit;
|
|
82
|
+
}
|
|
83
|
+
export declare function resolveImagePresentation(options: ImagePresentationOptions): ImagePresentation;
|
|
59
84
|
//# sourceMappingURL=image-optimization.d.ts.map
|
|
@@ -181,3 +181,43 @@ export function computeImageOptimizationConfig(options) {
|
|
|
181
181
|
transformDpr: renderWidth ? DEFAULT_IMAGE_DPRS[DEFAULT_IMAGE_DPRS.length - 1] : undefined,
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
|
+
export function resolveImagePresentation(options) {
|
|
185
|
+
const quality = clampQuality(options.quality);
|
|
186
|
+
const fit = resolveFit(options.fit);
|
|
187
|
+
const requestedWidth = toPositiveInt(options.width);
|
|
188
|
+
const requestedHeight = toPositiveInt(options.height);
|
|
189
|
+
const width = requestedWidth ?? options.mediaWidth;
|
|
190
|
+
const height = requestedHeight ?? options.mediaHeight;
|
|
191
|
+
const hasSizes = typeof options.sizes === 'string' && options.sizes.trim().length > 0;
|
|
192
|
+
const hasSizingHint = hasSizes || requestedWidth !== undefined || requestedHeight !== undefined;
|
|
193
|
+
const shouldOptimize = options.unoptimized !== true && isOptimizableFimoUrl(options.src, options.hostSuffixes) && hasSizingHint;
|
|
194
|
+
const { generatedSrcSet, transformWidth, transformDpr } = computeImageOptimizationConfig({
|
|
195
|
+
shouldOptimize,
|
|
196
|
+
hasSizesAttr: hasSizes,
|
|
197
|
+
srcSetOverride: options.srcSet,
|
|
198
|
+
originalSrc: options.src,
|
|
199
|
+
mediaWidth: options.mediaWidth,
|
|
200
|
+
renderWidth: width,
|
|
201
|
+
quality,
|
|
202
|
+
fit,
|
|
203
|
+
hostSuffixes: options.hostSuffixes,
|
|
204
|
+
});
|
|
205
|
+
const optimizedSrc = shouldOptimize
|
|
206
|
+
? buildOptimizedUrl(options.src, {
|
|
207
|
+
width: transformWidth,
|
|
208
|
+
quality,
|
|
209
|
+
fit,
|
|
210
|
+
dpr: transformDpr,
|
|
211
|
+
hostSuffixes: options.hostSuffixes,
|
|
212
|
+
})
|
|
213
|
+
: options.src;
|
|
214
|
+
return {
|
|
215
|
+
src: options.overrideSrc ?? optimizedSrc,
|
|
216
|
+
alt: options.alt,
|
|
217
|
+
width,
|
|
218
|
+
height,
|
|
219
|
+
sizes: options.sizes,
|
|
220
|
+
srcSet: options.srcSet ?? generatedSrcSet,
|
|
221
|
+
objectFit: toObjectFit(fit),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent,
|
|
1
|
+
export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, } from './primitives.js';
|
|
2
2
|
export { fimo } from './template.js';
|
|
3
3
|
export type { BoolOps, DateOps, Field, Fields, FilterFor, NullOnlyOps, NumberOps, Populate, Populated, PopulatedResult, ProjectedWithPopulate, Projected, Query, ReferenceField, ReferenceMap, ScalarOps, Sort, SortField, StringOps, Where, WithReferences, } from './query.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|