fimo 0.12.0-staging.1 → 0.12.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.
Files changed (66) hide show
  1. package/assets/skills/fimo-studio/SKILL.md +3 -1
  2. package/assets/skills/fimo-studio/references/ai-chat.md +1 -1
  3. package/assets/skills/fimo-studio/references/command-palette.md +31 -0
  4. package/dist/cli/bundle.json +1 -1
  5. package/dist/cli/index.js +4 -4
  6. package/dist/runtime/next/client.d.ts +8 -1
  7. package/dist/runtime/next/client.js +8 -1
  8. package/dist/runtime/next/{Text.d.ts → primitives/Text.d.ts} +1 -1
  9. package/dist/runtime/next/{Text.js → primitives/Text.js} +1 -1
  10. package/dist/runtime/next/primitives/server.d.ts +9 -0
  11. package/dist/runtime/next/primitives/server.js +46 -0
  12. package/dist/runtime/next/server.d.ts +3 -1
  13. package/dist/runtime/next/server.js +3 -1
  14. package/dist/runtime/primitives/index.d.ts +10 -10
  15. package/dist/runtime/primitives/index.js +10 -10
  16. package/dist/runtime/primitives/lib/image-optimization.d.ts +10 -1
  17. package/dist/runtime/primitives/lib/image-optimization.js +12 -12
  18. package/dist/runtime/primitives/lib/index.d.ts +0 -1
  19. package/dist/runtime/primitives/lib/index.js +0 -1
  20. package/dist/runtime/react/primitives/contracts.d.ts +56 -0
  21. package/dist/runtime/react/primitives/contracts.js +1 -0
  22. package/dist/runtime/react/primitives/editable/Boolean.d.ts +5 -0
  23. package/dist/runtime/react/primitives/editable/Boolean.js +11 -0
  24. package/dist/runtime/react/primitives/editable/Date.d.ts +4 -0
  25. package/dist/runtime/react/primitives/editable/Date.js +12 -0
  26. package/dist/runtime/react/primitives/editable/Image.d.ts +4 -0
  27. package/dist/runtime/react/primitives/editable/Image.js +10 -0
  28. package/dist/runtime/react/primitives/editable/Json.d.ts +5 -0
  29. package/dist/runtime/react/primitives/editable/Json.js +11 -0
  30. package/dist/runtime/react/primitives/editable/RichText.d.ts +4 -0
  31. package/dist/runtime/react/primitives/editable/RichText.js +11 -0
  32. package/dist/runtime/{primitives/components → react/primitives/editable}/Text.d.ts +3 -6
  33. package/dist/runtime/{primitives/components → react/primitives/editable}/Text.js +2 -1
  34. package/dist/runtime/react/primitives/editable/Video.d.ts +4 -0
  35. package/dist/runtime/react/primitives/editable/Video.js +10 -0
  36. package/dist/runtime/react/primitives/renderers/DateRenderer.d.ts +11 -0
  37. package/dist/runtime/react/primitives/renderers/DateRenderer.js +14 -0
  38. package/dist/runtime/react/primitives/renderers/ImageRenderer.d.ts +8 -0
  39. package/dist/runtime/react/primitives/renderers/ImageRenderer.js +50 -0
  40. package/dist/runtime/react/primitives/renderers/RichTextRenderer.d.ts +11 -0
  41. package/dist/runtime/{primitives/components/RichText.js → react/primitives/renderers/RichTextRenderer.js} +4 -6
  42. package/dist/runtime/{primitives/components → react/primitives/renderers}/StaticImage.d.ts +2 -11
  43. package/dist/runtime/{primitives/components → react/primitives/renderers}/StaticImage.js +5 -3
  44. package/dist/runtime/react/primitives/renderers/VideoRenderer.d.ts +8 -0
  45. package/dist/runtime/react/primitives/renderers/VideoRenderer.js +10 -0
  46. package/dist/runtime/{primitives/lib → react}/useFimoLiveValue.d.ts +3 -3
  47. package/dist/runtime/{primitives/lib → react}/useFimoLiveValue.js +3 -3
  48. package/dist/runtime/vite/primitives/Images.d.ts +4 -0
  49. package/dist/runtime/vite/primitives/Images.js +12 -0
  50. package/dist/runtime/{primitives → vite}/translations.d.ts +1 -1
  51. package/dist/runtime/{primitives → vite}/translations.js +1 -1
  52. package/package.json +1 -1
  53. package/templates/react-router/package.json +1 -1
  54. package/dist/runtime/primitives/components/Boolean.d.ts +0 -29
  55. package/dist/runtime/primitives/components/Boolean.js +0 -33
  56. package/dist/runtime/primitives/components/Date.d.ts +0 -30
  57. package/dist/runtime/primitives/components/Date.js +0 -43
  58. package/dist/runtime/primitives/components/Image.d.ts +0 -72
  59. package/dist/runtime/primitives/components/Image.js +0 -108
  60. package/dist/runtime/primitives/components/Json.d.ts +0 -25
  61. package/dist/runtime/primitives/components/Json.js +0 -29
  62. package/dist/runtime/primitives/components/RichText.d.ts +0 -9
  63. package/dist/runtime/primitives/components/Video.d.ts +0 -31
  64. package/dist/runtime/primitives/components/Video.js +0 -34
  65. package/dist/runtime/primitives/components/index.d.ts +0 -6
  66. package/dist/runtime/primitives/components/index.js +0 -5
@@ -9,7 +9,14 @@ export type { CollectionContentClient, InfiniteListResult, SingletonContentClien
9
9
  export { createContentCore, createSingletonCore } from '../content/index.js';
10
10
  export type { CollectionContentCore, CollectionPage, CollectionPageInfo, ContentClientConfig, ContentClientHandle, ContentModuleMeta, ContentModuleRef, ContentReadOptions, ContentResult, ContentRuntime, ContentSchema, ContentSchemaField, SingletonContentCore, } from '../content/index.js';
11
11
  export { FIMO_PARTS, FIMO_SOURCE, FimoBoolean, FimoDate, FimoMedia, FimoRichText, FimoString, getFimoParts, getFimoSource, hasFimoSource, isFimoDate, isFimoString, } from '../content/index.js';
12
- export { Text } from '../primitives/components/Text.js';
12
+ export { Boolean } from '../react/primitives/editable/Boolean.js';
13
+ export { Date } from '../react/primitives/editable/Date.js';
14
+ export { Image } from '../react/primitives/editable/Image.js';
15
+ export { Json } from '../react/primitives/editable/Json.js';
16
+ export { RichText } from '../react/primitives/editable/RichText.js';
17
+ export { StaticImage } from '../react/primitives/renderers/StaticImage.js';
18
+ export { Text } from '../react/primitives/editable/Text.js';
19
+ export { Video } from '../react/primitives/editable/Video.js';
13
20
  export type { BoolOps, DateOps, Field, Fields, FilterFor, FimoPart, FimoPolymorphicReference, FimoReference, FimoRichTextComponents, FimoRichTextContent, FimoRichTextMarkProps, FimoRichTextNodeProps, FimoSource, NullOnlyOps, NumberOps, Populate, Populated, PopulatedResult, Projected, ProjectedWithPopulate, Query, ReferenceField, ReferenceMap, ScalarOps, Sort, SortField, StringOps, Where, WithReferences, } from '../content/index.js';
14
21
  export { FimoNextProvider } from './provider.js';
15
22
  export type { FimoNextProviderProps } from './provider.js';
@@ -11,5 +11,12 @@ export function createSingletonClient(config) {
11
11
  }
12
12
  export { createContentCore, createSingletonCore } from '../content/index.js';
13
13
  export { FIMO_PARTS, FIMO_SOURCE, FimoBoolean, FimoDate, FimoMedia, FimoRichText, FimoString, getFimoParts, getFimoSource, hasFimoSource, isFimoDate, isFimoString, } from '../content/index.js';
14
- export { Text } from '../primitives/components/Text.js';
14
+ export { Boolean } from '../react/primitives/editable/Boolean.js';
15
+ export { Date } from '../react/primitives/editable/Date.js';
16
+ export { Image } from '../react/primitives/editable/Image.js';
17
+ export { Json } from '../react/primitives/editable/Json.js';
18
+ export { RichText } from '../react/primitives/editable/RichText.js';
19
+ export { StaticImage } from '../react/primitives/renderers/StaticImage.js';
20
+ export { Text } from '../react/primitives/editable/Text.js';
21
+ export { Video } from '../react/primitives/editable/Video.js';
15
22
  export { FimoNextProvider } from './provider.js';
@@ -1,5 +1,5 @@
1
1
  import { type ElementType } from 'react';
2
- import type { TextProps } from '../primitives/components/Text.js';
2
+ import type { TextProps } from '../../react/primitives/contracts.js';
3
3
  /**
4
4
  * Server-safe text primitive for Next.js Server Components.
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Fragment } from 'react';
3
- import { getFimoParts, getFimoSource } from '../content/index.js';
3
+ import { getFimoParts, getFimoSource } from '../../content/index.js';
4
4
  /**
5
5
  * Server-safe text primitive for Next.js Server Components.
6
6
  *
@@ -0,0 +1,9 @@
1
+ import { type ElementType } from 'react';
2
+ import type { BooleanProps, DateProps, ImageProps, JsonProps, RichTextProps, VideoProps } from '../../react/primitives/contracts.js';
3
+ export declare function Boolean<T extends ElementType = 'span'>({ value, as, children, ...props }: BooleanProps<T>): import("react/jsx-runtime").JSX.Element | null;
4
+ export declare function Date({ value, ...props }: DateProps): import("react/jsx-runtime").JSX.Element | null;
5
+ export declare function Image(props: ImageProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export declare function Json<T extends ElementType = 'span'>({ value, as, children, ...props }: JsonProps<T>): import("react/jsx-runtime").JSX.Element | null;
7
+ export declare function RichText({ value, components, ...props }: RichTextProps): import("react/jsx-runtime").JSX.Element | null;
8
+ export declare function Video(props: VideoProps): import("react/jsx-runtime").JSX.Element | null;
9
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FIMO_SOURCE, getFimoSource } from '../../content/index.js';
3
+ import { DateRenderer } from '../../react/primitives/renderers/DateRenderer.js';
4
+ import { ImageRenderer } from '../../react/primitives/renderers/ImageRenderer.js';
5
+ import { RichTextRenderer } from '../../react/primitives/renderers/RichTextRenderer.js';
6
+ import { VideoRenderer } from '../../react/primitives/renderers/VideoRenderer.js';
7
+ export function Boolean({ value, as, children, ...props }) {
8
+ if (!value) {
9
+ return null;
10
+ }
11
+ const Component = as || 'span';
12
+ const booleanValue = value.valueOf();
13
+ return (_jsx(Component, { ...props, "data-fimo-source": value[FIMO_SOURCE], children: children ? children(booleanValue) : String(booleanValue) }));
14
+ }
15
+ export function Date({ value, ...props }) {
16
+ if (!value) {
17
+ return null;
18
+ }
19
+ const source = typeof value === 'object' && FIMO_SOURCE in value ? (value[FIMO_SOURCE] ?? undefined) : undefined;
20
+ return _jsx(DateRenderer, { ...props, value: value, source: source });
21
+ }
22
+ export function Image(props) {
23
+ if (!props.value) {
24
+ return null;
25
+ }
26
+ return _jsx(ImageRenderer, { ...props });
27
+ }
28
+ export function Json({ value, as, children, ...props }) {
29
+ if (value === null || value === undefined) {
30
+ return null;
31
+ }
32
+ const Component = as || 'span';
33
+ return (_jsx(Component, { ...props, "data-fimo-source": getFimoSource(value), children: children ? children(value) : JSON.stringify(value) }));
34
+ }
35
+ export function RichText({ value, components, ...props }) {
36
+ if (!value) {
37
+ return null;
38
+ }
39
+ return _jsx(RichTextRenderer, { ...props, document: value.content, source: value[FIMO_SOURCE], components: components });
40
+ }
41
+ export function Video(props) {
42
+ if (!props.value) {
43
+ return null;
44
+ }
45
+ return _jsx(VideoRenderer, { ...props });
46
+ }
@@ -1,5 +1,7 @@
1
1
  import type { CollectionContentClient, ContentClientConfig, SingletonContentClient } from '../content/client/types.js';
2
- export { Text } from './Text.js';
2
+ export { StaticImage } from '../react/primitives/renderers/StaticImage.js';
3
+ export { Text } from './primitives/Text.js';
4
+ export { Boolean, Date, Image, Json, RichText, Video } from './primitives/server.js';
3
5
  export declare function createContentClient<T extends {
4
6
  id: string;
5
7
  }, TInput extends object>(config: ContentClientConfig): CollectionContentClient<T, TInput>;
@@ -1,6 +1,8 @@
1
1
  import { createServerContentClient, createServerSingletonClient } from '../content/client/server-content-client.js';
2
2
  import { nextServerContentRuntime } from './server-runtime.js';
3
- export { Text } from './Text.js';
3
+ export { StaticImage } from '../react/primitives/renderers/StaticImage.js';
4
+ export { Text } from './primitives/Text.js';
5
+ export { Boolean, Date, Image, Json, RichText, Video } from './primitives/server.js';
4
6
  export function createContentClient(config) {
5
7
  return createServerContentClient(config, nextServerContentRuntime);
6
8
  }
@@ -1,12 +1,12 @@
1
- export { Text } from './components/Text.js';
2
- export { Image } from './components/Image.js';
3
- export { StaticImage } from './components/StaticImage.js';
4
- export { Video } from './components/Video.js';
5
- export { Date } from './components/Date.js';
6
- export { Boolean } from './components/Boolean.js';
7
- export { Json } from './components/Json.js';
8
- export { RichText } from './components/RichText.js';
9
- export { useLabels, useTranslations } from './translations.js';
10
- export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent, type FimoRichTextNodeProps, type FimoRichTextMarkProps, type FimoRichTextComponents, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, useFimoLiveValue, } from './lib/index.js';
1
+ export { Text } from '../react/primitives/editable/Text.js';
2
+ export { Image, StaticImage } from '../vite/primitives/Images.js';
3
+ export { Video } from '../react/primitives/editable/Video.js';
4
+ export { Date } from '../react/primitives/editable/Date.js';
5
+ export { Boolean } from '../react/primitives/editable/Boolean.js';
6
+ export { Json } from '../react/primitives/editable/Json.js';
7
+ export { RichText } from '../react/primitives/editable/RichText.js';
8
+ export { useLabels, useTranslations } from '../vite/translations.js';
9
+ export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent, type FimoRichTextNodeProps, type FimoRichTextMarkProps, type FimoRichTextComponents, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, } from './lib/index.js';
10
+ export { useFimoLiveValue } from '../react/useFimoLiveValue.js';
11
11
  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
12
  //# sourceMappingURL=index.d.ts.map
@@ -1,15 +1,15 @@
1
1
  // Fimo UI — components and primitives for source-tracked inline editing
2
2
  // This module is auto-synced and should not be modified by agents or users.
3
3
  // Components
4
- export { Text } from './components/Text.js';
5
- export { Image } from './components/Image.js';
6
- export { StaticImage } from './components/StaticImage.js';
7
- export { Video } from './components/Video.js';
8
- export { Date } from './components/Date.js';
9
- export { Boolean } from './components/Boolean.js';
10
- export { Json } from './components/Json.js';
11
- export { RichText } from './components/RichText.js';
4
+ export { Text } from '../react/primitives/editable/Text.js';
5
+ export { Image, StaticImage } from '../vite/primitives/Images.js';
6
+ export { Video } from '../react/primitives/editable/Video.js';
7
+ export { Date } from '../react/primitives/editable/Date.js';
8
+ export { Boolean } from '../react/primitives/editable/Boolean.js';
9
+ export { Json } from '../react/primitives/editable/Json.js';
10
+ export { RichText } from '../react/primitives/editable/RichText.js';
12
11
  // Labels
13
- export { useLabels, useTranslations } from './translations.js';
12
+ export { useLabels, useTranslations } from '../vite/translations.js';
14
13
  // Primitives & utilities
15
- export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, useFimoLiveValue, } from './lib/index.js';
14
+ export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, } from './lib/index.js';
15
+ export { useFimoLiveValue } from '../react/useFimoLiveValue.js';
@@ -1,4 +1,11 @@
1
1
  import type { ComponentPropsWithoutRef } from 'react';
2
+ /** Default host suffixes eligible for Cloudflare Image Resizing optimization. */
3
+ export declare const DEFAULT_IMAGE_HOST_SUFFIXES: readonly [".fimo.team", ".fimo.ai", ".fimo.site"];
4
+ /**
5
+ * Get allowed host suffixes from env or use defaults.
6
+ * Env format: comma-separated suffixes, e.g. ".fimo.team,.fimo.ai,.fimo.site"
7
+ */
8
+ export declare function parseImageHostSuffixes(value: string | undefined): readonly string[];
2
9
  export declare const DEFAULT_IMAGE_QUALITY = 85;
3
10
  export declare const DEFAULT_IMAGE_FIT: "scale-down";
4
11
  export declare const DEFAULT_IMAGE_DPRS: readonly [1, 2];
@@ -21,7 +28,7 @@ export declare function toObjectFit(fit: ImageFit): NonNullable<ComponentPropsWi
21
28
  /** Parse value to positive integer, or undefined if invalid. */
22
29
  export declare function toPositiveInt(value: string | number | undefined): number | undefined;
23
30
  /** Check if URL can be optimized (valid http(s) URL on allowed host). */
24
- export declare function isOptimizableFimoUrl(value: string): value is string;
31
+ export declare function isOptimizableFimoUrl(value: string, hostSuffixes?: readonly string[]): value is string;
25
32
  /**
26
33
  * Build optimized URL with Cloudflare Image Resizing query params.
27
34
  * Adds: w (width), q (quality), fit, f (format=auto), dpr.
@@ -31,6 +38,7 @@ export declare function buildOptimizedUrl(src: string, options: {
31
38
  quality: number;
32
39
  fit: ImageFit;
33
40
  dpr?: number;
41
+ hostSuffixes?: readonly string[];
34
42
  }): string;
35
43
  export type ImageOptimizationConfig = {
36
44
  generatedSrcSet?: string;
@@ -46,5 +54,6 @@ export declare function computeImageOptimizationConfig(options: {
46
54
  renderWidth: number | undefined;
47
55
  quality: number;
48
56
  fit: ImageFit;
57
+ hostSuffixes?: readonly string[];
49
58
  }): ImageOptimizationConfig;
50
59
  //# sourceMappingURL=image-optimization.d.ts.map
@@ -1,14 +1,12 @@
1
1
  /** Default host suffixes eligible for Cloudflare Image Resizing optimization. */
2
- const DEFAULT_IMAGE_HOST_SUFFIXES = ['.fimo.team', '.fimo.ai', '.fimo.site'];
2
+ export const DEFAULT_IMAGE_HOST_SUFFIXES = ['.fimo.team', '.fimo.ai', '.fimo.site'];
3
3
  /**
4
4
  * Get allowed host suffixes from env or use defaults.
5
5
  * Env format: comma-separated suffixes, e.g. ".fimo.team,.fimo.ai,.fimo.site"
6
6
  */
7
- function getImageHostSuffixes() {
8
- // @ts-ignore - meta.env is a vite injected variable
9
- const envHosts = import.meta.env.VITE_FIMO_IMAGE_HOSTS;
10
- if (typeof envHosts === 'string' && envHosts.trim().length > 0) {
11
- return envHosts.split(',').map((s) => s.trim());
7
+ export function parseImageHostSuffixes(value) {
8
+ if (typeof value === 'string' && value.trim().length > 0) {
9
+ return value.split(',').map((suffix) => suffix.trim());
12
10
  }
13
11
  return DEFAULT_IMAGE_HOST_SUFFIXES;
14
12
  }
@@ -91,14 +89,14 @@ function parseHttpUrl(value) {
91
89
  }
92
90
  }
93
91
  /** Check if hostname is eligible for Cloudflare optimization. */
94
- function isAllowedHost(hostname) {
92
+ function isAllowedHost(hostname, hostSuffixes) {
95
93
  const host = hostname.toLowerCase();
96
- return getImageHostSuffixes().some((suffix) => host.endsWith(suffix));
94
+ return hostSuffixes.some((suffix) => host.endsWith(suffix.toLowerCase()));
97
95
  }
98
96
  /** Check if URL can be optimized (valid http(s) URL on allowed host). */
99
- export function isOptimizableFimoUrl(value) {
97
+ export function isOptimizableFimoUrl(value, hostSuffixes = DEFAULT_IMAGE_HOST_SUFFIXES) {
100
98
  const url = parseHttpUrl(value);
101
- return Boolean(url && isAllowedHost(url.hostname));
99
+ return Boolean(url && isAllowedHost(url.hostname, hostSuffixes));
102
100
  }
103
101
  /**
104
102
  * Build optimized URL with Cloudflare Image Resizing query params.
@@ -106,7 +104,7 @@ export function isOptimizableFimoUrl(value) {
106
104
  */
107
105
  export function buildOptimizedUrl(src, options) {
108
106
  const parsed = parseHttpUrl(src);
109
- if (!parsed || !isAllowedHost(parsed.hostname)) {
107
+ if (!parsed || !isAllowedHost(parsed.hostname, options.hostSuffixes ?? DEFAULT_IMAGE_HOST_SUFFIXES)) {
110
108
  return src;
111
109
  }
112
110
  const transformed = new URL(parsed.toString());
@@ -152,7 +150,7 @@ function buildWidthSrcSet(src, options, widths) {
152
150
  .join(', ');
153
151
  }
154
152
  export function computeImageOptimizationConfig(options) {
155
- const { shouldOptimize, hasSizesAttr, srcSetOverride, originalSrc, mediaWidth, renderWidth, quality, fit } = options;
153
+ const { shouldOptimize, hasSizesAttr, srcSetOverride, originalSrc, mediaWidth, renderWidth, quality, fit, hostSuffixes, } = options;
156
154
  if (!shouldOptimize || srcSetOverride != null) {
157
155
  return {
158
156
  generatedSrcSet: undefined,
@@ -166,6 +164,7 @@ export function computeImageOptimizationConfig(options) {
166
164
  generatedSrcSet: buildWidthSrcSet(originalSrc, {
167
165
  quality,
168
166
  fit,
167
+ hostSuffixes,
169
168
  }, responsiveWidths),
170
169
  transformWidth: responsiveWidths[responsiveWidths.length - 1] ?? renderWidth,
171
170
  transformDpr: undefined,
@@ -176,6 +175,7 @@ export function computeImageOptimizationConfig(options) {
176
175
  width: renderWidth,
177
176
  quality,
178
177
  fit,
178
+ hostSuffixes,
179
179
  }),
180
180
  transformWidth: renderWidth,
181
181
  transformDpr: renderWidth ? DEFAULT_IMAGE_DPRS[DEFAULT_IMAGE_DPRS.length - 1] : undefined,
@@ -1,5 +1,4 @@
1
1
  export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent, type FimoRichTextNodeProps, type FimoRichTextMarkProps, type FimoRichTextComponents, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, } from './primitives.js';
2
2
  export { fimo } from './template.js';
3
- export { useFimoLiveValue } from './useFimoLiveValue.js';
4
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';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
1
  // Fimo - Source tracking for inline editing
2
2
  export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, } from './primitives.js';
3
3
  export { fimo } from './template.js';
4
- export { useFimoLiveValue } from './useFimoLiveValue.js';
@@ -0,0 +1,56 @@
1
+ import type { ComponentPropsWithoutRef, ElementType, ReactNode } from 'react';
2
+ import type { ImageFit } from '../../primitives/lib/image-optimization.js';
3
+ import type { FimoBoolean, FimoDate, FimoMedia, FimoRichText, FimoRichTextComponents, FimoString } from '../../primitives/lib/index.js';
4
+ export type BooleanProps<T extends ElementType = 'span'> = {
5
+ value: FimoBoolean;
6
+ as?: T;
7
+ children?: (value: boolean) => ReactNode;
8
+ } & Omit<ComponentPropsWithoutRef<T>, 'value' | 'as' | 'children'>;
9
+ export interface DateProps {
10
+ value: FimoDate | FimoString | Date | string;
11
+ children?: (date: Date) => ReactNode;
12
+ className?: string;
13
+ }
14
+ export interface BaseImageProps extends Omit<ComponentPropsWithoutRef<'img'>, 'src' | 'alt' | 'children'> {
15
+ quality?: number;
16
+ fit?: ImageFit;
17
+ unoptimized?: boolean;
18
+ overrideSrc?: string;
19
+ hostSuffixes?: readonly string[];
20
+ }
21
+ export interface ImageProps extends BaseImageProps {
22
+ value: FimoMedia;
23
+ alt?: string;
24
+ children?: (media: FimoMedia) => ReactNode;
25
+ }
26
+ export type JsonProps<T extends ElementType = 'span'> = {
27
+ value: unknown;
28
+ as?: T;
29
+ children?: (value: unknown) => ReactNode;
30
+ } & Omit<ComponentPropsWithoutRef<T>, 'value' | 'as' | 'children'>;
31
+ export interface RichTextProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
32
+ value: FimoRichText | null | undefined;
33
+ components?: FimoRichTextComponents;
34
+ }
35
+ export type StaticImageProps = Omit<ComponentPropsWithoutRef<'img'>, 'children'> & {
36
+ /** Image quality (1-100). Defaults to 85. */
37
+ quality?: number;
38
+ /** Resize fit mode. Also maps to CSS object-fit. Defaults to 'scale-down'. */
39
+ fit?: ImageFit;
40
+ /** Skip optimization and use the original URL. */
41
+ unoptimized?: boolean;
42
+ hostSuffixes?: readonly string[];
43
+ };
44
+ export type TextProps<T extends ElementType = 'span'> = {
45
+ value: unknown;
46
+ as?: T;
47
+ children?: (value: string) => ReactNode;
48
+ } & Omit<ComponentPropsWithoutRef<T>, 'value' | 'as' | 'children'>;
49
+ export interface BaseVideoProps extends Omit<ComponentPropsWithoutRef<'video'>, 'src' | 'children'> {
50
+ overrideSrc?: string;
51
+ }
52
+ export interface VideoProps extends BaseVideoProps {
53
+ value: FimoMedia;
54
+ children?: (media: FimoMedia) => ReactNode;
55
+ }
56
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { type ElementType } from 'react';
2
+ import type { BooleanProps } from '../contracts.js';
3
+ export type { BooleanProps } from '../contracts.js';
4
+ export declare function Boolean<T extends ElementType = 'span'>({ value, as, children, ...props }: BooleanProps<T>): import("react/jsx-runtime").JSX.Element | null;
5
+ //# sourceMappingURL=Boolean.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FIMO_SOURCE } from '../../../primitives/lib/index.js';
3
+ import { useFimoLiveValue } from '../../useFimoLiveValue.js';
4
+ export function Boolean({ value, as, children, ...props }) {
5
+ const Component = as || 'span';
6
+ const { value: liveValue, ref } = useFimoLiveValue(value ? value.valueOf() : false);
7
+ if (!value) {
8
+ return null;
9
+ }
10
+ return (_jsx(Component, { ref: ref, ...props, "data-fimo-source": value[FIMO_SOURCE], children: children ? children(liveValue) : String(liveValue) }));
11
+ }
@@ -0,0 +1,4 @@
1
+ import type { DateProps } from '../contracts.js';
2
+ export type { DateProps } from '../contracts.js';
3
+ export declare function Date({ value, ...props }: DateProps): import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=Date.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FIMO_SOURCE } from '../../../primitives/lib/index.js';
3
+ import { useFimoLiveValue } from '../../useFimoLiveValue.js';
4
+ import { DateRenderer } from '../renderers/DateRenderer.js';
5
+ export function Date({ value, ...props }) {
6
+ const { value: liveValue, ref } = useFimoLiveValue(value ?? null);
7
+ if (!liveValue) {
8
+ return null;
9
+ }
10
+ const source = typeof value === 'object' && FIMO_SOURCE in value ? (value[FIMO_SOURCE] ?? undefined) : undefined;
11
+ return _jsx(DateRenderer, { ...props, value: liveValue, source: source, elementRef: ref });
12
+ }
@@ -0,0 +1,4 @@
1
+ import type { ImageProps } from '../contracts.js';
2
+ export type { BaseImageProps, ImageProps } from '../contracts.js';
3
+ export declare function Image({ value: media, ...props }: ImageProps): import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=Image.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useFimoLiveValue } from '../../useFimoLiveValue.js';
3
+ import { ImageRenderer } from '../renderers/ImageRenderer.js';
4
+ export function Image({ value: media, ...props }) {
5
+ const { value: liveMedia, ref } = useFimoLiveValue(media ?? null);
6
+ if (!liveMedia) {
7
+ return null;
8
+ }
9
+ return _jsx(ImageRenderer, { ...props, value: liveMedia, elementRef: ref });
10
+ }
@@ -0,0 +1,5 @@
1
+ import { type ElementType } from 'react';
2
+ import type { JsonProps } from '../contracts.js';
3
+ export type { JsonProps } from '../contracts.js';
4
+ export declare function Json<T extends ElementType = 'span'>({ value, as, children, ...props }: JsonProps<T>): import("react/jsx-runtime").JSX.Element | null;
5
+ //# sourceMappingURL=Json.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getFimoSource } from '../../../primitives/lib/index.js';
3
+ import { useFimoLiveValue } from '../../useFimoLiveValue.js';
4
+ export function Json({ value, as, children, ...props }) {
5
+ const Component = as || 'span';
6
+ const { value: liveValue, ref } = useFimoLiveValue(value);
7
+ if (value === null || value === undefined) {
8
+ return null;
9
+ }
10
+ return (_jsx(Component, { ref: ref, ...props, "data-fimo-source": getFimoSource(value), children: children ? children(liveValue) : JSON.stringify(liveValue) }));
11
+ }
@@ -0,0 +1,4 @@
1
+ import type { RichTextProps } from '../contracts.js';
2
+ export type { RichTextProps } from '../contracts.js';
3
+ export declare function RichText({ value, components, ...props }: RichTextProps): import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=RichText.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { FIMO_SOURCE } from '../../../primitives/lib/index.js';
3
+ import { useFimoLiveValue } from '../../useFimoLiveValue.js';
4
+ import { RichTextRenderer } from '../renderers/RichTextRenderer.js';
5
+ export function RichText({ value, components, ...props }) {
6
+ const { value: liveContent, ref } = useFimoLiveValue(value?.content ?? null);
7
+ if (!value) {
8
+ return null;
9
+ }
10
+ return (_jsx(RichTextRenderer, { ...props, document: liveContent, source: value[FIMO_SOURCE], components: components, elementRef: ref }));
11
+ }
@@ -1,9 +1,6 @@
1
- import { type ComponentPropsWithoutRef, type ElementType, type ReactNode } from 'react';
2
- export type TextProps<T extends ElementType = 'span'> = {
3
- value: unknown;
4
- as?: T;
5
- children?: (value: string) => ReactNode;
6
- } & Omit<ComponentPropsWithoutRef<T>, 'value' | 'as' | 'children'>;
1
+ import { type ElementType } from 'react';
2
+ import type { TextProps } from '../contracts.js';
3
+ export type { TextProps } from '../contracts.js';
7
4
  /**
8
5
  * Text component for rendering text with source tracking
9
6
  *
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Fragment } from 'react';
3
- import { getFimoParts, getFimoSource, useFimoLiveValue } from '../lib/index.js';
3
+ import { getFimoParts, getFimoSource } from '../../../primitives/lib/index.js';
4
+ import { useFimoLiveValue } from '../../useFimoLiveValue.js';
4
5
  /**
5
6
  * Text component for rendering text with source tracking
6
7
  *
@@ -0,0 +1,4 @@
1
+ import type { VideoProps } from '../contracts.js';
2
+ export type { BaseVideoProps, VideoProps } from '../contracts.js';
3
+ export declare function Video({ value: media, ...props }: VideoProps): import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=Video.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useFimoLiveValue } from '../../useFimoLiveValue.js';
3
+ import { VideoRenderer } from '../renderers/VideoRenderer.js';
4
+ export function Video({ value: media, ...props }) {
5
+ const { value: liveMedia, ref } = useFimoLiveValue(media ?? null);
6
+ if (!liveMedia) {
7
+ return null;
8
+ }
9
+ return _jsx(VideoRenderer, { ...props, value: liveMedia, elementRef: ref });
10
+ }
@@ -0,0 +1,11 @@
1
+ import { type ReactNode, type Ref } from 'react';
2
+ import type { FimoDate, FimoString } from '../../../primitives/lib/index.js';
3
+ export interface DateRendererProps {
4
+ value: FimoDate | FimoString | Date | string | number;
5
+ source: string | undefined;
6
+ children?: (date: Date) => ReactNode;
7
+ className?: string;
8
+ elementRef?: Ref<HTMLTimeElement>;
9
+ }
10
+ export declare function DateRenderer({ value, source, children, className, elementRef }: DateRendererProps): import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=DateRenderer.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function DateRenderer({ value, source, children, className, elementRef }) {
3
+ const rawValue = value instanceof String ? value.toString() : value;
4
+ const dateValue = new globalThis.Date(rawValue);
5
+ const isoDate = dateValue.toISOString().split('T')[0];
6
+ const content = children
7
+ ? children(dateValue)
8
+ : dateValue.toLocaleDateString(undefined, {
9
+ year: 'numeric',
10
+ month: 'short',
11
+ day: 'numeric',
12
+ });
13
+ return (_jsx("time", { ref: elementRef, dateTime: isoDate, className: className, "data-fimo-source": source, children: content }));
14
+ }
@@ -0,0 +1,8 @@
1
+ import { type RefObject } from 'react';
2
+ import type { ImageProps } from '../contracts.js';
3
+ interface ImageRendererProps extends ImageProps {
4
+ elementRef?: RefObject<HTMLElement | null>;
5
+ }
6
+ export declare function ImageRenderer({ value: media, children, quality, unoptimized, fit, width, height, alt: altOverride, overrideSrc, srcSet: srcSetOverride, sizes, style, hostSuffixes, elementRef, ...imgProps }: ImageRendererProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=ImageRenderer.d.ts.map
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { buildOptimizedUrl, clampQuality, computeImageOptimizationConfig, isOptimizableFimoUrl, resolveFit, toObjectFit, toPositiveInt, } from '../../../primitives/lib/image-optimization.js';
3
+ import { FIMO_SOURCE } from '../../../primitives/lib/primitives.js';
4
+ export function ImageRenderer({ value: media, children, quality, unoptimized = false, fit, width, height, alt: altOverride, overrideSrc, srcSet: srcSetOverride, sizes, style, hostSuffixes, elementRef, ...imgProps }) {
5
+ const mediaSource = media[FIMO_SOURCE];
6
+ if (children) {
7
+ return (_jsx("span", { ref: elementRef, "data-fimo-source": mediaSource, children: children(media) }));
8
+ }
9
+ const normalizedQuality = clampQuality(quality);
10
+ const normalizedFit = resolveFit(fit);
11
+ const requestedWidth = toPositiveInt(width);
12
+ const requestedHeight = toPositiveInt(height);
13
+ const displayWidth = requestedWidth ?? media.width;
14
+ const displayHeight = requestedHeight ?? media.height;
15
+ const originalSrc = media.url;
16
+ const resolvedAlt = altOverride ?? media.alt;
17
+ const hasSizesAttr = typeof sizes === 'string' && sizes.trim().length > 0;
18
+ const hasSizingHint = hasSizesAttr || requestedWidth !== undefined || requestedHeight !== undefined;
19
+ const canOptimizeSource = !unoptimized && isOptimizableFimoUrl(originalSrc, hostSuffixes);
20
+ const shouldOptimize = canOptimizeSource && hasSizingHint;
21
+ const { generatedSrcSet, transformWidth, transformDpr } = computeImageOptimizationConfig({
22
+ shouldOptimize,
23
+ hasSizesAttr,
24
+ srcSetOverride,
25
+ originalSrc,
26
+ mediaWidth: media.width,
27
+ renderWidth: displayWidth,
28
+ quality: normalizedQuality,
29
+ fit: normalizedFit,
30
+ hostSuffixes,
31
+ });
32
+ const finalSrcSet = srcSetOverride ?? generatedSrcSet;
33
+ const optimizedSrc = shouldOptimize
34
+ ? buildOptimizedUrl(originalSrc, {
35
+ width: transformWidth,
36
+ quality: normalizedQuality,
37
+ fit: normalizedFit,
38
+ dpr: transformDpr,
39
+ hostSuffixes,
40
+ })
41
+ : originalSrc;
42
+ const finalSrc = overrideSrc ?? optimizedSrc;
43
+ const finalStyle = style?.objectFit
44
+ ? style
45
+ : {
46
+ ...style,
47
+ objectFit: toObjectFit(normalizedFit),
48
+ };
49
+ return (_jsx("img", { ref: elementRef, src: finalSrc, alt: resolvedAlt, width: displayWidth, height: displayHeight, style: finalStyle, sizes: sizes, srcSet: finalSrcSet, ...imgProps, "data-fimo-source": mediaSource }));
50
+ }
@@ -0,0 +1,11 @@
1
+ import { type ComponentPropsWithoutRef, type Ref } from 'react';
2
+ import type { FimoRichTextComponents, FimoRichTextContent } from '../../../primitives/lib/index.js';
3
+ interface RichTextRendererProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
4
+ document: FimoRichTextContent | null | undefined;
5
+ source: string | undefined;
6
+ components?: FimoRichTextComponents;
7
+ elementRef?: Ref<HTMLDivElement>;
8
+ }
9
+ export declare function RichTextRenderer({ document, source, components, elementRef, ...props }: RichTextRendererProps): import("react/jsx-runtime").JSX.Element | null;
10
+ export {};
11
+ //# sourceMappingURL=RichTextRenderer.d.ts.map