fimo-next 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.
package/dist/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveFimoEditingMetadata } from 'fimo/preview';
|
|
1
2
|
const NEXT_DEVELOPMENT_PHASE = 'phase-development-server';
|
|
2
3
|
const PREVIEW_ORIGINS_ENV = 'FIMO_PREVIEW_ALLOWED_ORIGINS';
|
|
3
4
|
function readPreviewOrigins() {
|
|
@@ -33,7 +34,33 @@ function withConfigTracing(config) {
|
|
|
33
34
|
export function withFimo(applicationConfig) {
|
|
34
35
|
return async (phase, context) => {
|
|
35
36
|
const applied = typeof applicationConfig === 'function' ? await applicationConfig(phase, context) : applicationConfig;
|
|
36
|
-
const
|
|
37
|
+
const editing = resolveFimoEditingMetadata(phase === NEXT_DEVELOPMENT_PHASE ? 'development' : 'production', process.env.FIMO_EDITING_METADATA);
|
|
38
|
+
const compiler = applied.compiler;
|
|
39
|
+
const removeProperties = compiler?.reactRemoveProperties;
|
|
40
|
+
const config = withConfigTracing({
|
|
41
|
+
...applied,
|
|
42
|
+
...(!editing
|
|
43
|
+
? {
|
|
44
|
+
compiler: {
|
|
45
|
+
...compiler,
|
|
46
|
+
reactRemoveProperties: {
|
|
47
|
+
properties: [
|
|
48
|
+
...(removeProperties === true
|
|
49
|
+
? ['^data-test']
|
|
50
|
+
: typeof removeProperties === 'object'
|
|
51
|
+
? (removeProperties.properties ?? [])
|
|
52
|
+
: []),
|
|
53
|
+
'^data-fimo-(source(-context)?|id|richtext|live-edit)$',
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
: {}),
|
|
59
|
+
env: {
|
|
60
|
+
...applied.env,
|
|
61
|
+
FIMO_EDITING_METADATA: String(editing),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
37
64
|
if (phase !== NEXT_DEVELOPMENT_PHASE) {
|
|
38
65
|
return config;
|
|
39
66
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getFimoParts, getFimoSource } from 'fimo/content';
|
|
3
|
+
import { withoutFimoEditingMetadata, isFimoEditingMetadataEnabled } from 'fimo/preview';
|
|
3
4
|
import { Fragment } from 'react';
|
|
4
5
|
/**
|
|
5
6
|
* Server-safe text primitive for Next.js Server Components.
|
|
@@ -11,8 +12,8 @@ export function Text({ value, as, children, ...props }) {
|
|
|
11
12
|
const Component = as || 'span';
|
|
12
13
|
const parts = getFimoParts(value);
|
|
13
14
|
if (parts && parts.length > 1 && !children) {
|
|
14
|
-
return (_jsx(Component, { ...props, children: parts.map((part, index) => part.source ? (_jsx("span", { "data-fimo-source": part.source, children: part.text }, index)) : (_jsx(Fragment, { children: part.text }, index))) }));
|
|
15
|
+
return (_jsx(Component, { ...withoutFimoEditingMetadata(props), children: parts.map((part, index) => part.source ? (_jsx("span", { "data-fimo-source": isFimoEditingMetadataEnabled() ? part.source : undefined, children: part.text }, index)) : (_jsx(Fragment, { children: part.text }, index))) }));
|
|
15
16
|
}
|
|
16
17
|
const text = String(value);
|
|
17
|
-
return (_jsx(Component, { ...props, "data-fimo-source": getFimoSource(value), children: children ? children(text) : text }));
|
|
18
|
+
return (_jsx(Component, { ...withoutFimoEditingMetadata(props), "data-fimo-source": isFimoEditingMetadataEnabled() ? getFimoSource(value) : undefined, children: children ? children(text) : text }));
|
|
18
19
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DateRenderer, ImageRenderer, RichTextRenderer, VideoRenderer } from 'fimo-react/primitives/server';
|
|
3
3
|
import { FIMO_SOURCE, getFimoSource } from 'fimo/content';
|
|
4
|
+
import { withoutFimoEditingMetadata, isFimoEditingMetadataEnabled } from 'fimo/preview';
|
|
4
5
|
export function Boolean({ value, as, children, ...props }) {
|
|
5
6
|
if (!value) {
|
|
6
7
|
return null;
|
|
7
8
|
}
|
|
8
9
|
const Component = as || 'span';
|
|
9
10
|
const booleanValue = value.valueOf();
|
|
10
|
-
return (_jsx(Component, { ...props, "data-fimo-source": value[FIMO_SOURCE], children: children ? children(booleanValue) : String(booleanValue) }));
|
|
11
|
+
return (_jsx(Component, { ...withoutFimoEditingMetadata(props), "data-fimo-source": isFimoEditingMetadataEnabled() ? value[FIMO_SOURCE] : undefined, children: children ? children(booleanValue) : String(booleanValue) }));
|
|
11
12
|
}
|
|
12
13
|
export function Date({ value, ...props }) {
|
|
13
14
|
if (!value) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
17
|
const source = typeof value === 'object' && FIMO_SOURCE in value ? (value[FIMO_SOURCE] ?? undefined) : undefined;
|
|
17
|
-
return _jsx(DateRenderer, { ...props, value: value, source: source });
|
|
18
|
+
return _jsx(DateRenderer, { ...withoutFimoEditingMetadata(props), value: value, source: source });
|
|
18
19
|
}
|
|
19
20
|
/** Renders a `datetime` field: the `dateTime` attribute keeps the whole instant. */
|
|
20
21
|
export function DateTime({ value, ...props }) {
|
|
@@ -22,30 +23,30 @@ export function DateTime({ value, ...props }) {
|
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
25
|
const source = typeof value === 'object' && FIMO_SOURCE in value ? (value[FIMO_SOURCE] ?? undefined) : undefined;
|
|
25
|
-
return _jsx(DateRenderer, { ...props, value: value, source: source, precision: "instant" });
|
|
26
|
+
return _jsx(DateRenderer, { ...withoutFimoEditingMetadata(props), value: value, source: source, precision: "instant" });
|
|
26
27
|
}
|
|
27
28
|
export function Image(props) {
|
|
28
29
|
if (!props.value) {
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
|
-
return _jsx(ImageRenderer, { ...props });
|
|
32
|
+
return _jsx(ImageRenderer, { ...withoutFimoEditingMetadata(props) });
|
|
32
33
|
}
|
|
33
34
|
export function Json({ value, as, children, ...props }) {
|
|
34
35
|
if (value === null || value === undefined) {
|
|
35
36
|
return null;
|
|
36
37
|
}
|
|
37
38
|
const Component = as || 'span';
|
|
38
|
-
return (_jsx(Component, { ...props, "data-fimo-source": getFimoSource(value), children: children ? children(value) : JSON.stringify(value) }));
|
|
39
|
+
return (_jsx(Component, { ...withoutFimoEditingMetadata(props), "data-fimo-source": isFimoEditingMetadataEnabled() ? getFimoSource(value) : undefined, children: children ? children(value) : JSON.stringify(value) }));
|
|
39
40
|
}
|
|
40
41
|
export function RichText({ value, components, ...props }) {
|
|
41
42
|
if (!value) {
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
|
-
return _jsx(RichTextRenderer, { ...props, document: value.content, source: value[FIMO_SOURCE], components: components });
|
|
45
|
+
return (_jsx(RichTextRenderer, { ...withoutFimoEditingMetadata(props), document: value.content, source: value[FIMO_SOURCE], components: components }));
|
|
45
46
|
}
|
|
46
47
|
export function Video(props) {
|
|
47
48
|
if (!props.value) {
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
50
|
-
return _jsx(VideoRenderer, { ...props });
|
|
51
|
+
return _jsx(VideoRenderer, { ...withoutFimoEditingMetadata(props) });
|
|
51
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fimo-next",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-staging.2",
|
|
4
4
|
"description": "Fimo runtime for Next.js projects.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"test:watch": "vitest"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@fimo/tsconfig": "2.
|
|
52
|
+
"@fimo/tsconfig": "2.5.0-staging.2",
|
|
53
53
|
"@tanstack/react-query": "^5.80.6",
|
|
54
54
|
"@types/node": "22.18.6",
|
|
55
55
|
"@types/react": "19.2.14",
|
|
56
56
|
"@types/react-dom": "19.2.3",
|
|
57
|
-
"fimo": "2.
|
|
58
|
-
"fimo-react": "2.
|
|
57
|
+
"fimo": "2.5.0-staging.2",
|
|
58
|
+
"fimo-react": "2.5.0-staging.2",
|
|
59
59
|
"next": "16.3.3",
|
|
60
60
|
"react": "19.2.4",
|
|
61
61
|
"react-dom": "19.2.4",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@tanstack/react-query": "^5.80.6",
|
|
67
|
-
"fimo": "
|
|
67
|
+
"fimo": "2.5.0-staging.2",
|
|
68
68
|
"fimo-react": ">=2.0.1",
|
|
69
69
|
"next": "^15.0.0 || ^16.0.0",
|
|
70
70
|
"react": "^18.2.0 || ^19.0.0",
|