fimo-react 2.4.1 → 2.5.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.
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { withoutFimoEditingMetadata } from 'fimo/preview';
2
3
  import { FIMO_SOURCE, getFimoSourceContext } from 'fimo/primitives';
3
4
  import { useFimoLiveValue } from '../../useFimoLiveValue.js';
4
5
  import { getFimoSourceAttributes } from '../source-attributes.js';
@@ -8,5 +9,5 @@ export function Boolean({ value, as, children, ...props }) {
8
9
  if (!value) {
9
10
  return null;
10
11
  }
11
- return (_jsx(Component, { ref: ref, ...props, ...getFimoSourceAttributes(value[FIMO_SOURCE], getFimoSourceContext(value)), children: children ? children(liveValue) : String(liveValue) }));
12
+ return (_jsx(Component, { ref: ref, ...withoutFimoEditingMetadata(props), ...getFimoSourceAttributes(value[FIMO_SOURCE], getFimoSourceContext(value)), children: children ? children(liveValue) : String(liveValue) }));
12
13
  }
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { withoutFimoEditingMetadata } from 'fimo/preview';
2
3
  import { getFimoSource, getFimoSourceContext } from 'fimo/primitives';
3
4
  import { useFimoLiveValue } from '../../useFimoLiveValue.js';
4
5
  import { getFimoSourceAttributes } from '../source-attributes.js';
@@ -8,5 +9,5 @@ export function Json({ value, as, children, ...props }) {
8
9
  if (value === null || value === undefined) {
9
10
  return null;
10
11
  }
11
- return (_jsx(Component, { ref: ref, ...props, ...getFimoSourceAttributes(getFimoSource(value), getFimoSourceContext(value)), children: children ? children(liveValue) : JSON.stringify(liveValue) }));
12
+ return (_jsx(Component, { ref: ref, ...withoutFimoEditingMetadata(props), ...getFimoSourceAttributes(getFimoSource(value), getFimoSourceContext(value)), children: children ? children(liveValue) : JSON.stringify(liveValue) }));
12
13
  }
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { withoutFimoEditingMetadata } from 'fimo/preview';
2
3
  import { getFimoParts, getFimoSource, getFimoSourceContext } from 'fimo/primitives';
3
4
  import { Fragment } from 'react';
4
5
  import { useFimoLiveValue } from '../../useFimoLiveValue.js';
@@ -26,11 +27,11 @@ export function Text({ value, as, children, ...props }) {
26
27
  const { value: liveValue, ref } = useFimoLiveValue(String(value));
27
28
  // Composed fimo value with parts — decompose into individually tracked spans
28
29
  if (parts && parts.length > 1 && !children) {
29
- return (_jsx(Component, { ...props, children: parts.map((part, i) => part.source ? (_jsx(TextPart, { part: part }, i)) : (_jsx(Fragment, { children: part.text }, i))) }));
30
+ return (_jsx(Component, { ...withoutFimoEditingMetadata(props), children: parts.map((part, i) => part.source ? (_jsx(TextPart, { part: part }, i)) : (_jsx(Fragment, { children: part.text }, i))) }));
30
31
  }
31
32
  // Use render function if provided, otherwise display raw value
32
33
  const content = children ? children(liveValue) : liveValue;
33
- return (_jsx(Component, { ref: ref, ...props, ...getFimoSourceAttributes(source, context), children: content }));
34
+ return (_jsx(Component, { ref: ref, ...withoutFimoEditingMetadata(props), ...getFimoSourceAttributes(source, context), children: content }));
34
35
  }
35
36
  function TextPart({ part }) {
36
37
  const { value: liveText, ref } = useFimoLiveValue(part.text);
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { withoutFimoEditingMetadata } from 'fimo/preview';
2
3
  import { FIMO_SOURCE, getFimoSourceContext, resolveImagePresentation } from 'fimo/primitives';
3
4
  import { getFimoSourceAttributes } from '../source-attributes.js';
4
5
  export function ImageRenderer({ value: media, children, quality, unoptimized = false, fit, width, height, alt: altOverride, overrideSrc, srcSet: srcSetOverride, sizes, style, hostSuffixes, elementRef, ...imgProps }) {
@@ -28,5 +29,5 @@ export function ImageRenderer({ value: media, children, quality, unoptimized = f
28
29
  ...style,
29
30
  objectFit: image.objectFit,
30
31
  };
31
- return (_jsx("img", { ref: elementRef, src: image.src, alt: image.alt, width: image.width, height: image.height, style: finalStyle, sizes: image.sizes, srcSet: image.srcSet, ...imgProps, ...sourceAttributes }));
32
+ return (_jsx("img", { ref: elementRef, src: image.src, alt: image.alt, width: image.width, height: image.height, style: finalStyle, sizes: image.sizes, srcSet: image.srcSet, ...withoutFimoEditingMetadata(imgProps), ...sourceAttributes }));
32
33
  }
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { withoutFimoEditingMetadata, isFimoEditingMetadataEnabled } from 'fimo/preview';
2
3
  import { Fragment } from 'react';
3
4
  import { getFimoSourceAttributes } from '../source-attributes.js';
4
5
  function DefaultParagraph({ children }) {
@@ -132,5 +133,5 @@ export function RichTextRenderer({ document, source, context, components, elemen
132
133
  if (!document) {
133
134
  return null;
134
135
  }
135
- return (_jsx("div", { ref: elementRef, ...props, ...getFimoSourceAttributes(source, context), "data-fimo-richtext": "", children: renderNode(document, components, 0) }));
136
+ return (_jsx("div", { ref: elementRef, ...withoutFimoEditingMetadata(props), ...getFimoSourceAttributes(source, context), "data-fimo-richtext": isFimoEditingMetadataEnabled() ? '' : undefined, children: renderNode(document, components, 0) }));
136
137
  }
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { withoutFimoEditingMetadata } from 'fimo/preview';
2
3
  import { resolveImagePresentation } from 'fimo/primitives';
3
4
  /**
4
5
  * Optimized image component for non-schema images.
@@ -54,5 +55,5 @@ export function StaticImage(props) {
54
55
  ...style,
55
56
  objectFit: image.objectFit,
56
57
  };
57
- return (_jsx("img", { src: image.src, alt: image.alt, width: image.width, height: image.height, style: finalStyle, sizes: image.sizes, srcSet: image.srcSet, ...imgProps }));
58
+ return (_jsx("img", { src: image.src, alt: image.alt, width: image.width, height: image.height, style: finalStyle, sizes: image.sizes, srcSet: image.srcSet, ...withoutFimoEditingMetadata(imgProps) }));
58
59
  }
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { withoutFimoEditingMetadata } from 'fimo/preview';
2
3
  import { FIMO_SOURCE, getFimoSourceContext } from 'fimo/primitives';
3
4
  import { getFimoSourceAttributes } from '../source-attributes.js';
4
5
  export function VideoRenderer({ value: media, children, overrideSrc, autoPlay = true, loop = true, muted = true, playsInline = true, style, elementRef, ...videoProps }) {
@@ -8,5 +9,5 @@ export function VideoRenderer({ value: media, children, overrideSrc, autoPlay =
8
9
  return (_jsx("span", { ref: elementRef, ...sourceAttributes, children: children(media) }));
9
10
  }
10
11
  const finalSrc = overrideSrc ?? media.url;
11
- return (_jsx("video", { ref: elementRef, src: finalSrc, width: media.width, height: media.height, autoPlay: autoPlay, loop: loop, muted: muted, playsInline: playsInline, style: style, ...videoProps, ...sourceAttributes }));
12
+ return (_jsx("video", { ref: elementRef, src: finalSrc, width: media.width, height: media.height, autoPlay: autoPlay, loop: loop, muted: muted, playsInline: playsInline, style: style, ...withoutFimoEditingMetadata(videoProps), ...sourceAttributes }));
12
13
  }
@@ -1,5 +1,9 @@
1
+ import { isFimoEditingMetadataEnabled } from 'fimo/preview';
1
2
  const MAX_SOURCE_CONTEXT_MARKER_LENGTH = 4096;
2
3
  export function getFimoSourceAttributes(source, context) {
4
+ if (!isFimoEditingMetadataEnabled()) {
5
+ return { 'data-fimo-source': undefined };
6
+ }
3
7
  let contextMarker;
4
8
  if (context && context.length > 0) {
5
9
  try {
@@ -1,3 +1,4 @@
1
+ import { isFimoEditingMetadataEnabled } from 'fimo/preview';
1
2
  import { useEffect, useRef, useState } from 'react';
2
3
  /**
3
4
  * useFimoLiveValue — mirror a Fimo value into React state so live edits
@@ -23,7 +24,7 @@ export function useFimoLiveValue(external) {
23
24
  }
24
25
  useEffect(() => {
25
26
  const el = ref.current;
26
- if (!el) {
27
+ if (!el || !isFimoEditingMetadataEnabled()) {
27
28
  return;
28
29
  }
29
30
  el.setAttribute('data-fimo-live-edit', '1');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fimo-react",
3
- "version": "2.4.1",
3
+ "version": "2.5.0-staging.2",
4
4
  "description": "Fimo React runtime: content clients, labels, and source-tracked primitives.",
5
5
  "files": [
6
6
  "dist/",
@@ -43,12 +43,12 @@
43
43
  "test:watch": "vitest"
44
44
  },
45
45
  "devDependencies": {
46
- "@fimo/tsconfig": "2.4.1",
46
+ "@fimo/tsconfig": "2.5.0-staging.2",
47
47
  "@tanstack/react-query": "^5.80.6",
48
48
  "@types/node": "22.18.6",
49
49
  "@types/react": "19.2.14",
50
50
  "@types/react-dom": "19.2.3",
51
- "fimo": "2.4.1",
51
+ "fimo": "2.5.0-staging.2",
52
52
  "react": "19.2.4",
53
53
  "react-dom": "19.2.4",
54
54
  "typescript": "7.0.2",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@tanstack/react-query": "^5.80.6",
60
- "fimo": ">=2.0.1",
60
+ "fimo": "2.5.0-staging.2",
61
61
  "react": "^18.2.0 || ^19.0.0",
62
62
  "react-dom": "^18.2.0 || ^19.0.0"
63
63
  },