@cmssy/react 11.5.1 → 11.7.0
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/client.d.cts +1 -5
- package/dist/client.d.ts +1 -5
- package/dist/index.d.cts +2 -87
- package/dist/index.d.ts +2 -87
- package/dist/internal-server.d.cts +1 -5
- package/dist/internal-server.d.ts +1 -5
- package/dist/internal.d.cts +0 -6
- package/dist/internal.d.ts +0 -6
- package/dist/{registry-zeNh3t6y.d.cts → registry-fguZApc8.d.cts} +0 -34
- package/dist/{registry-zeNh3t6y.d.ts → registry-fguZApc8.d.ts} +0 -34
- package/package.json +43 -18
package/dist/client.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BlockSchema, BlockMeta, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition } from './registry-
|
|
3
|
+
import { B as BlockDefinition } from './registry-fguZApc8.cjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface EditBridgeConfig {
|
|
@@ -46,7 +46,6 @@ interface CmssyEditablePageProps {
|
|
|
46
46
|
forms?: Record<string, CmssyFormDefinition>;
|
|
47
47
|
data?: Record<string, unknown>;
|
|
48
48
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
49
|
-
/** Same channel the deployed page gets, so the canvas shows the same thing. */
|
|
50
49
|
appContext?: Record<string, unknown>;
|
|
51
50
|
}
|
|
52
51
|
declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, appContext, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
|
|
@@ -60,7 +59,6 @@ interface CmssyLazyEditorProps {
|
|
|
60
59
|
forms?: Record<string, CmssyFormDefinition>;
|
|
61
60
|
data?: Record<string, unknown>;
|
|
62
61
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
63
|
-
/** Forwarded untouched to the block context as `context.app`. */
|
|
64
62
|
appContext?: Record<string, unknown>;
|
|
65
63
|
load: () => Promise<{
|
|
66
64
|
blocks: BlockDefinition[];
|
|
@@ -79,7 +77,6 @@ interface CmssyEditableLayoutProps {
|
|
|
79
77
|
edit: EditBridgeConfig;
|
|
80
78
|
data?: Record<string, unknown>;
|
|
81
79
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
82
|
-
/** Same channel the deployed layout gets, so the canvas shows the same thing. */
|
|
83
80
|
appContext?: Record<string, unknown>;
|
|
84
81
|
}
|
|
85
82
|
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
@@ -93,7 +90,6 @@ interface CmssyLazyLayoutProps {
|
|
|
93
90
|
edit: EditBridgeConfig;
|
|
94
91
|
data?: Record<string, unknown>;
|
|
95
92
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
96
|
-
/** Forwarded untouched to the block context as `context.app`. */
|
|
97
93
|
appContext?: Record<string, unknown>;
|
|
98
94
|
load: () => Promise<{
|
|
99
95
|
blocks: BlockDefinition[];
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BlockSchema, BlockMeta, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition } from './registry-
|
|
3
|
+
import { B as BlockDefinition } from './registry-fguZApc8.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface EditBridgeConfig {
|
|
@@ -46,7 +46,6 @@ interface CmssyEditablePageProps {
|
|
|
46
46
|
forms?: Record<string, CmssyFormDefinition>;
|
|
47
47
|
data?: Record<string, unknown>;
|
|
48
48
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
49
|
-
/** Same channel the deployed page gets, so the canvas shows the same thing. */
|
|
50
49
|
appContext?: Record<string, unknown>;
|
|
51
50
|
}
|
|
52
51
|
declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, appContext, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
|
|
@@ -60,7 +59,6 @@ interface CmssyLazyEditorProps {
|
|
|
60
59
|
forms?: Record<string, CmssyFormDefinition>;
|
|
61
60
|
data?: Record<string, unknown>;
|
|
62
61
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
63
|
-
/** Forwarded untouched to the block context as `context.app`. */
|
|
64
62
|
appContext?: Record<string, unknown>;
|
|
65
63
|
load: () => Promise<{
|
|
66
64
|
blocks: BlockDefinition[];
|
|
@@ -79,7 +77,6 @@ interface CmssyEditableLayoutProps {
|
|
|
79
77
|
edit: EditBridgeConfig;
|
|
80
78
|
data?: Record<string, unknown>;
|
|
81
79
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
82
|
-
/** Same channel the deployed layout gets, so the canvas shows the same thing. */
|
|
83
80
|
appContext?: Record<string, unknown>;
|
|
84
81
|
}
|
|
85
82
|
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
@@ -93,7 +90,6 @@ interface CmssyLazyLayoutProps {
|
|
|
93
90
|
edit: EditBridgeConfig;
|
|
94
91
|
data?: Record<string, unknown>;
|
|
95
92
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
96
|
-
/** Forwarded untouched to the block context as `context.app`. */
|
|
97
93
|
appContext?: Record<string, unknown>;
|
|
98
94
|
load: () => Promise<{
|
|
99
95
|
blocks: BlockDefinition[];
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyConfig, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
2
|
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRequestError, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutPosition, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, fields, graphqlRequest, isProtocolCompatible, layoutPositionValues, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition, a as BlockMap } from './registry-
|
|
4
|
-
export { b as BlockProps, c as buildBlockMap, d as defineBlock } from './registry-
|
|
3
|
+
import { B as BlockDefinition, a as BlockMap } from './registry-fguZApc8.cjs';
|
|
4
|
+
export { b as BlockProps, c as buildBlockMap, d as defineBlock } from './registry-fguZApc8.cjs';
|
|
5
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
6
6
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
7
|
export { buildBlockContext } from '@cmssy/core/internal';
|
|
@@ -14,64 +14,24 @@ interface CmssyServerPageProps {
|
|
|
14
14
|
blocks: BlockDefinition[];
|
|
15
15
|
locale?: string;
|
|
16
16
|
defaultLocale?: string;
|
|
17
|
-
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
18
17
|
enabledLocales?: string[];
|
|
19
|
-
/**
|
|
20
|
-
* The workspace, so the languages can be looked up when they are not passed.
|
|
21
|
-
* Without it the SDK has to guess, and its guess is "en".
|
|
22
|
-
*/
|
|
23
18
|
config?: CmssyClientConfig;
|
|
24
|
-
/** Form definitions referenced by page blocks, exposed via context.forms. */
|
|
25
19
|
forms?: Record<string, CmssyFormDefinition>;
|
|
26
|
-
/** Member auth state, exposed via context.auth. Resolved by createCmssyPage. */
|
|
27
20
|
auth?: CmssyBlockAuthContext;
|
|
28
|
-
/** Workspace identity, exposed via context.workspace. Resolved by createCmssyPage. */
|
|
29
21
|
workspace?: CmssyBlockWorkspace;
|
|
30
|
-
/**
|
|
31
|
-
* Anything the app wants its blocks to see, exposed as context.app and passed
|
|
32
|
-
* through untouched. The escape hatch: a block needing something cmssy does
|
|
33
|
-
* not model is answered here instead of by a new field in the SDK.
|
|
34
|
-
*/
|
|
35
22
|
appContext?: Record<string, unknown>;
|
|
36
23
|
editMode?: boolean;
|
|
37
24
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Async React Server Component (Next.js App Router / RSC). It runs each block's
|
|
40
|
-
* loader server-side before rendering, so it must be rendered in a server
|
|
41
|
-
* component tree (as `createCmssyPage` does) - not in a client component.
|
|
42
|
-
*/
|
|
43
25
|
declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, appContext, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
44
26
|
|
|
45
27
|
interface ResolveCmssyLayoutSlotBase {
|
|
46
28
|
position: string;
|
|
47
29
|
blocks: BlockDefinition[];
|
|
48
|
-
/**
|
|
49
|
-
* Whether to resolve for the edit bridge. A parameter, never a lookup: every
|
|
50
|
-
* way of asking the request is a dynamic API on Next, and one read makes the
|
|
51
|
-
* route uncacheable. Each adapter knows the answer already - from its own
|
|
52
|
-
* request object, or from the route segment.
|
|
53
|
-
*/
|
|
54
30
|
editMode: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Whose layouts to render. Defaults to the routed page, which is what a page
|
|
57
|
-
* with its own header needs; pass `"/"` for the site-wide chrome.
|
|
58
|
-
*/
|
|
59
31
|
page?: string;
|
|
60
32
|
forms?: Record<string, CmssyFormDefinition>;
|
|
61
33
|
appContext?: Record<string, unknown>;
|
|
62
34
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Where the language comes from - one of two, never neither.
|
|
65
|
-
*
|
|
66
|
-
* `path` is the routed segments: the language prefix in them IS the language,
|
|
67
|
-
* and it is also where the page slug comes from. `locale` overrides the
|
|
68
|
-
* language without touching the slug, which is what an always-dynamic adapter
|
|
69
|
-
* wants when the proxy already resolved it into a header.
|
|
70
|
-
*
|
|
71
|
-
* What this deliberately does NOT do is read that header itself. On a cacheable
|
|
72
|
-
* route it is not there to read, and a fallback would render the wrong language
|
|
73
|
-
* while looking like it worked.
|
|
74
|
-
*/
|
|
75
35
|
type CmssyLayoutSlotLocaleSource = {
|
|
76
36
|
path: string[];
|
|
77
37
|
locale?: string;
|
|
@@ -85,67 +45,24 @@ interface CmssyLayoutSlotResolution {
|
|
|
85
45
|
locale: string;
|
|
86
46
|
defaultLocale: string;
|
|
87
47
|
enabledLocales: string[];
|
|
88
|
-
/**
|
|
89
|
-
* The routed segments with the language prefix removed - the page slug. It is
|
|
90
|
-
* returned because every caller needs it next, and resolving it twice is how
|
|
91
|
-
* the three adapters drifted apart in the first place.
|
|
92
|
-
*/
|
|
93
48
|
path: string[];
|
|
94
|
-
/** Edit mode only: the loader data and the server-resolved content. */
|
|
95
49
|
data?: Record<string, unknown>;
|
|
96
50
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
97
|
-
/**
|
|
98
|
-
* Edit mode only, and unchanged: `string | string[]`. The bridge handles a
|
|
99
|
-
* list natively and the default is two origins - collapsing it to the first
|
|
100
|
-
* silently breaks an editor served from the second.
|
|
101
|
-
*/
|
|
102
51
|
editorOrigin?: string | string[];
|
|
103
52
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Everything a layout slot needs, for any framework.
|
|
106
|
-
*
|
|
107
|
-
* Three things have to be right here, and each was got wrong at least once by
|
|
108
|
-
* an app that wrote this by hand:
|
|
109
|
-
*
|
|
110
|
-
* 1. in edit mode the layouts are fetched **with the preview secret** -
|
|
111
|
-
* otherwise you edit the draft header and the editor shows the published
|
|
112
|
-
* one;
|
|
113
|
-
* 2. the language comes from the routed path, not from a request header;
|
|
114
|
-
* 3. the editor gets `resolvedContent` as well as `data` - the canvas renders
|
|
115
|
-
* stored content, where a relation field is raw ids.
|
|
116
|
-
*
|
|
117
|
-
* Rendering stays with the caller: three frameworks, three rendering models.
|
|
118
|
-
* This is the half that is the same in all of them.
|
|
119
|
-
*/
|
|
120
53
|
declare function resolveCmssyLayoutSlot(config: CmssyConfig, options: ResolveCmssyLayoutSlotOptions): Promise<CmssyLayoutSlotResolution>;
|
|
121
54
|
|
|
122
55
|
interface CmssyServerLayoutProps {
|
|
123
56
|
groups: CmssyLayoutGroup[];
|
|
124
57
|
blocks: BlockDefinition[];
|
|
125
58
|
position: string;
|
|
126
|
-
/** The language to render in. Omit it and the workspace's default is used. */
|
|
127
59
|
locale?: string;
|
|
128
60
|
defaultLocale?: string;
|
|
129
|
-
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
130
61
|
enabledLocales?: string[];
|
|
131
|
-
/**
|
|
132
|
-
* The workspace, so the languages can be looked up when they are not passed.
|
|
133
|
-
* Without it the SDK has to guess, and its guess is "en".
|
|
134
|
-
*/
|
|
135
62
|
config?: CmssyClientConfig;
|
|
136
|
-
/**
|
|
137
|
-
* Anything the app wants its layout blocks to see, exposed as context.app.
|
|
138
|
-
* A header that highlights the active link reads it from here - the SDK does
|
|
139
|
-
* not know the app's routing.
|
|
140
|
-
*/
|
|
141
63
|
appContext?: Record<string, unknown>;
|
|
142
64
|
editMode?: boolean;
|
|
143
65
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Async React Server Component. Like CmssyServerPage it runs each block's
|
|
146
|
-
* loader server-side before rendering, so a header block can list categories
|
|
147
|
-
* the same way a page block can. Must be rendered in a server component tree.
|
|
148
|
-
*/
|
|
149
66
|
declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
150
67
|
|
|
151
68
|
interface CmssyBlockProps {
|
|
@@ -156,9 +73,7 @@ interface CmssyBlockProps {
|
|
|
156
73
|
patchedContent?: Record<string, unknown>;
|
|
157
74
|
patchedStyle?: Record<string, unknown>;
|
|
158
75
|
patchedAdvanced?: Record<string, unknown>;
|
|
159
|
-
/** Server-resolved content for this block (locale flattened, relations resolved). */
|
|
160
76
|
resolvedContent?: Record<string, unknown>;
|
|
161
|
-
/** The block's field schema; lets the client render coerce raw relation values. */
|
|
162
77
|
schema?: Record<string, FieldDefinition>;
|
|
163
78
|
editable?: boolean;
|
|
164
79
|
editMode?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyConfig, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
2
|
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRequestError, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutPosition, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, fields, graphqlRequest, isProtocolCompatible, layoutPositionValues, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition, a as BlockMap } from './registry-
|
|
4
|
-
export { b as BlockProps, c as buildBlockMap, d as defineBlock } from './registry-
|
|
3
|
+
import { B as BlockDefinition, a as BlockMap } from './registry-fguZApc8.js';
|
|
4
|
+
export { b as BlockProps, c as buildBlockMap, d as defineBlock } from './registry-fguZApc8.js';
|
|
5
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
6
6
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
7
|
export { buildBlockContext } from '@cmssy/core/internal';
|
|
@@ -14,64 +14,24 @@ interface CmssyServerPageProps {
|
|
|
14
14
|
blocks: BlockDefinition[];
|
|
15
15
|
locale?: string;
|
|
16
16
|
defaultLocale?: string;
|
|
17
|
-
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
18
17
|
enabledLocales?: string[];
|
|
19
|
-
/**
|
|
20
|
-
* The workspace, so the languages can be looked up when they are not passed.
|
|
21
|
-
* Without it the SDK has to guess, and its guess is "en".
|
|
22
|
-
*/
|
|
23
18
|
config?: CmssyClientConfig;
|
|
24
|
-
/** Form definitions referenced by page blocks, exposed via context.forms. */
|
|
25
19
|
forms?: Record<string, CmssyFormDefinition>;
|
|
26
|
-
/** Member auth state, exposed via context.auth. Resolved by createCmssyPage. */
|
|
27
20
|
auth?: CmssyBlockAuthContext;
|
|
28
|
-
/** Workspace identity, exposed via context.workspace. Resolved by createCmssyPage. */
|
|
29
21
|
workspace?: CmssyBlockWorkspace;
|
|
30
|
-
/**
|
|
31
|
-
* Anything the app wants its blocks to see, exposed as context.app and passed
|
|
32
|
-
* through untouched. The escape hatch: a block needing something cmssy does
|
|
33
|
-
* not model is answered here instead of by a new field in the SDK.
|
|
34
|
-
*/
|
|
35
22
|
appContext?: Record<string, unknown>;
|
|
36
23
|
editMode?: boolean;
|
|
37
24
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Async React Server Component (Next.js App Router / RSC). It runs each block's
|
|
40
|
-
* loader server-side before rendering, so it must be rendered in a server
|
|
41
|
-
* component tree (as `createCmssyPage` does) - not in a client component.
|
|
42
|
-
*/
|
|
43
25
|
declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, appContext, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
44
26
|
|
|
45
27
|
interface ResolveCmssyLayoutSlotBase {
|
|
46
28
|
position: string;
|
|
47
29
|
blocks: BlockDefinition[];
|
|
48
|
-
/**
|
|
49
|
-
* Whether to resolve for the edit bridge. A parameter, never a lookup: every
|
|
50
|
-
* way of asking the request is a dynamic API on Next, and one read makes the
|
|
51
|
-
* route uncacheable. Each adapter knows the answer already - from its own
|
|
52
|
-
* request object, or from the route segment.
|
|
53
|
-
*/
|
|
54
30
|
editMode: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Whose layouts to render. Defaults to the routed page, which is what a page
|
|
57
|
-
* with its own header needs; pass `"/"` for the site-wide chrome.
|
|
58
|
-
*/
|
|
59
31
|
page?: string;
|
|
60
32
|
forms?: Record<string, CmssyFormDefinition>;
|
|
61
33
|
appContext?: Record<string, unknown>;
|
|
62
34
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Where the language comes from - one of two, never neither.
|
|
65
|
-
*
|
|
66
|
-
* `path` is the routed segments: the language prefix in them IS the language,
|
|
67
|
-
* and it is also where the page slug comes from. `locale` overrides the
|
|
68
|
-
* language without touching the slug, which is what an always-dynamic adapter
|
|
69
|
-
* wants when the proxy already resolved it into a header.
|
|
70
|
-
*
|
|
71
|
-
* What this deliberately does NOT do is read that header itself. On a cacheable
|
|
72
|
-
* route it is not there to read, and a fallback would render the wrong language
|
|
73
|
-
* while looking like it worked.
|
|
74
|
-
*/
|
|
75
35
|
type CmssyLayoutSlotLocaleSource = {
|
|
76
36
|
path: string[];
|
|
77
37
|
locale?: string;
|
|
@@ -85,67 +45,24 @@ interface CmssyLayoutSlotResolution {
|
|
|
85
45
|
locale: string;
|
|
86
46
|
defaultLocale: string;
|
|
87
47
|
enabledLocales: string[];
|
|
88
|
-
/**
|
|
89
|
-
* The routed segments with the language prefix removed - the page slug. It is
|
|
90
|
-
* returned because every caller needs it next, and resolving it twice is how
|
|
91
|
-
* the three adapters drifted apart in the first place.
|
|
92
|
-
*/
|
|
93
48
|
path: string[];
|
|
94
|
-
/** Edit mode only: the loader data and the server-resolved content. */
|
|
95
49
|
data?: Record<string, unknown>;
|
|
96
50
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
97
|
-
/**
|
|
98
|
-
* Edit mode only, and unchanged: `string | string[]`. The bridge handles a
|
|
99
|
-
* list natively and the default is two origins - collapsing it to the first
|
|
100
|
-
* silently breaks an editor served from the second.
|
|
101
|
-
*/
|
|
102
51
|
editorOrigin?: string | string[];
|
|
103
52
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Everything a layout slot needs, for any framework.
|
|
106
|
-
*
|
|
107
|
-
* Three things have to be right here, and each was got wrong at least once by
|
|
108
|
-
* an app that wrote this by hand:
|
|
109
|
-
*
|
|
110
|
-
* 1. in edit mode the layouts are fetched **with the preview secret** -
|
|
111
|
-
* otherwise you edit the draft header and the editor shows the published
|
|
112
|
-
* one;
|
|
113
|
-
* 2. the language comes from the routed path, not from a request header;
|
|
114
|
-
* 3. the editor gets `resolvedContent` as well as `data` - the canvas renders
|
|
115
|
-
* stored content, where a relation field is raw ids.
|
|
116
|
-
*
|
|
117
|
-
* Rendering stays with the caller: three frameworks, three rendering models.
|
|
118
|
-
* This is the half that is the same in all of them.
|
|
119
|
-
*/
|
|
120
53
|
declare function resolveCmssyLayoutSlot(config: CmssyConfig, options: ResolveCmssyLayoutSlotOptions): Promise<CmssyLayoutSlotResolution>;
|
|
121
54
|
|
|
122
55
|
interface CmssyServerLayoutProps {
|
|
123
56
|
groups: CmssyLayoutGroup[];
|
|
124
57
|
blocks: BlockDefinition[];
|
|
125
58
|
position: string;
|
|
126
|
-
/** The language to render in. Omit it and the workspace's default is used. */
|
|
127
59
|
locale?: string;
|
|
128
60
|
defaultLocale?: string;
|
|
129
|
-
/** All languages enabled on the workspace; exposed to blocks via context.locale.enabled. */
|
|
130
61
|
enabledLocales?: string[];
|
|
131
|
-
/**
|
|
132
|
-
* The workspace, so the languages can be looked up when they are not passed.
|
|
133
|
-
* Without it the SDK has to guess, and its guess is "en".
|
|
134
|
-
*/
|
|
135
62
|
config?: CmssyClientConfig;
|
|
136
|
-
/**
|
|
137
|
-
* Anything the app wants its layout blocks to see, exposed as context.app.
|
|
138
|
-
* A header that highlights the active link reads it from here - the SDK does
|
|
139
|
-
* not know the app's routing.
|
|
140
|
-
*/
|
|
141
63
|
appContext?: Record<string, unknown>;
|
|
142
64
|
editMode?: boolean;
|
|
143
65
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Async React Server Component. Like CmssyServerPage it runs each block's
|
|
146
|
-
* loader server-side before rendering, so a header block can list categories
|
|
147
|
-
* the same way a page block can. Must be rendered in a server component tree.
|
|
148
|
-
*/
|
|
149
66
|
declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
150
67
|
|
|
151
68
|
interface CmssyBlockProps {
|
|
@@ -156,9 +73,7 @@ interface CmssyBlockProps {
|
|
|
156
73
|
patchedContent?: Record<string, unknown>;
|
|
157
74
|
patchedStyle?: Record<string, unknown>;
|
|
158
75
|
patchedAdvanced?: Record<string, unknown>;
|
|
159
|
-
/** Server-resolved content for this block (locale flattened, relations resolved). */
|
|
160
76
|
resolvedContent?: Record<string, unknown>;
|
|
161
|
-
/** The block's field schema; lets the client render coerce raw relation values. */
|
|
162
77
|
schema?: Record<string, FieldDefinition>;
|
|
163
78
|
editable?: boolean;
|
|
164
79
|
editMode?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyFormDefinition, CmssyClientConfig, CmssyLayoutGroup } from '@cmssy/core';
|
|
2
|
-
import { B as BlockDefinition } from './registry-
|
|
2
|
+
import { B as BlockDefinition } from './registry-fguZApc8.cjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
interface EditorBlockData {
|
|
@@ -14,9 +14,7 @@ interface ResolveBlockDataOptions {
|
|
|
14
14
|
enabledLocales?: string[];
|
|
15
15
|
forms?: Record<string, CmssyFormDefinition>;
|
|
16
16
|
isPreview?: boolean;
|
|
17
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
18
17
|
config?: CmssyClientConfig;
|
|
19
|
-
/** Passed to loaders as context.app, exactly as on the deployed page. */
|
|
20
18
|
appContext?: Record<string, unknown>;
|
|
21
19
|
}
|
|
22
20
|
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
@@ -30,9 +28,7 @@ interface ResolveLayoutBlockDataOptions {
|
|
|
30
28
|
enabledLocales?: string[];
|
|
31
29
|
forms?: Record<string, CmssyFormDefinition>;
|
|
32
30
|
isPreview?: boolean;
|
|
33
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
34
31
|
config?: CmssyClientConfig;
|
|
35
|
-
/** Passed to loaders as context.app, exactly as on the deployed layout. */
|
|
36
32
|
appContext?: Record<string, unknown>;
|
|
37
33
|
}
|
|
38
34
|
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyFormDefinition, CmssyClientConfig, CmssyLayoutGroup } from '@cmssy/core';
|
|
2
|
-
import { B as BlockDefinition } from './registry-
|
|
2
|
+
import { B as BlockDefinition } from './registry-fguZApc8.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
interface EditorBlockData {
|
|
@@ -14,9 +14,7 @@ interface ResolveBlockDataOptions {
|
|
|
14
14
|
enabledLocales?: string[];
|
|
15
15
|
forms?: Record<string, CmssyFormDefinition>;
|
|
16
16
|
isPreview?: boolean;
|
|
17
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
18
17
|
config?: CmssyClientConfig;
|
|
19
|
-
/** Passed to loaders as context.app, exactly as on the deployed page. */
|
|
20
18
|
appContext?: Record<string, unknown>;
|
|
21
19
|
}
|
|
22
20
|
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
@@ -30,9 +28,7 @@ interface ResolveLayoutBlockDataOptions {
|
|
|
30
28
|
enabledLocales?: string[];
|
|
31
29
|
forms?: Record<string, CmssyFormDefinition>;
|
|
32
30
|
isPreview?: boolean;
|
|
33
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
34
31
|
config?: CmssyClientConfig;
|
|
35
|
-
/** Passed to loaders as context.app, exactly as on the deployed layout. */
|
|
36
32
|
appContext?: Record<string, unknown>;
|
|
37
33
|
}
|
|
38
34
|
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
package/dist/internal.d.cts
CHANGED
|
@@ -6,13 +6,7 @@ interface CmssyLocaleProviderProps {
|
|
|
6
6
|
value: CmssyLocaleContext;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Exposes the active locale ({@link CmssyLocaleContext}) to client components
|
|
11
|
-
* below it (e.g. `CmssyLink`) so they can build locale-aware hrefs without
|
|
12
|
-
* prop-drilling. Wrap your root layout body with it.
|
|
13
|
-
*/
|
|
14
9
|
declare function CmssyLocaleProvider({ value, children, }: CmssyLocaleProviderProps): react_jsx_runtime.JSX.Element;
|
|
15
|
-
/** Reads the active locale; returns null when no provider is mounted. */
|
|
16
10
|
declare function useCmssyLocale(): CmssyLocaleContext | null;
|
|
17
11
|
|
|
18
12
|
export { CmssyLocaleProvider, type CmssyLocaleProviderProps, useCmssyLocale };
|
package/dist/internal.d.ts
CHANGED
|
@@ -6,13 +6,7 @@ interface CmssyLocaleProviderProps {
|
|
|
6
6
|
value: CmssyLocaleContext;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Exposes the active locale ({@link CmssyLocaleContext}) to client components
|
|
11
|
-
* below it (e.g. `CmssyLink`) so they can build locale-aware hrefs without
|
|
12
|
-
* prop-drilling. Wrap your root layout body with it.
|
|
13
|
-
*/
|
|
14
9
|
declare function CmssyLocaleProvider({ value, children, }: CmssyLocaleProviderProps): react_jsx_runtime.JSX.Element;
|
|
15
|
-
/** Reads the active locale; returns null when no provider is mounted. */
|
|
16
10
|
declare function useCmssyLocale(): CmssyLocaleContext | null;
|
|
17
11
|
|
|
18
12
|
export { CmssyLocaleProvider, type CmssyLocaleProviderProps, useCmssyLocale };
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent } from '@cmssy/core';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* The props a block component receives, derived from the fields it declares:
|
|
6
|
-
*
|
|
7
|
-
* const props = { headline: fields.text({ required: true }) };
|
|
8
|
-
* export function Hero({ content }: BlockProps<typeof props>) { … }
|
|
9
|
-
*
|
|
10
|
-
* Type the component this way and the schema is the only place a field is
|
|
11
|
-
* named. Rename `headline` and the component stops compiling, instead of
|
|
12
|
-
* quietly rendering nothing.
|
|
13
|
-
*/
|
|
14
4
|
interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
15
5
|
content: InferBlockContent<P>;
|
|
16
6
|
style?: Record<string, unknown>;
|
|
@@ -19,20 +9,9 @@ interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
|
19
9
|
data?: D;
|
|
20
10
|
}
|
|
21
11
|
type Identical<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
22
|
-
/** What the component says about the fields the schema declares - nothing else. */
|
|
23
12
|
type SchemaSlice<C, Content> = {
|
|
24
13
|
[K in keyof Content]: K extends keyof C ? C[K] : never;
|
|
25
14
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Rejects a component whose `content` disagrees with the schema about a field
|
|
28
|
-
* the schema declares. Extra keys are fine - a loader may inject content the
|
|
29
|
-
* editor knows nothing about (see `productBlock`) - but a declared field must
|
|
30
|
-
* have the name and the type the schema gives it.
|
|
31
|
-
*
|
|
32
|
-
* Without this, a hand-written content type only had to be *compatible* with the
|
|
33
|
-
* schema, and since every optional field is optional on both sides, a field the
|
|
34
|
-
* component invented was compatible with the one it forgot.
|
|
35
|
-
*/
|
|
36
15
|
type ContentGuard<C, P extends BlockPropsSchema> = Identical<SchemaSlice<C, InferBlockContent<P>>, InferBlockContent<P>> extends true ? unknown : {
|
|
37
16
|
CONTENT_MUST_BE_TYPED_AS_BlockProps_OF_THIS_PROPS: InferBlockContent<P>;
|
|
38
17
|
};
|
|
@@ -47,21 +26,8 @@ interface BlockDefinition {
|
|
|
47
26
|
category?: string;
|
|
48
27
|
icon?: string;
|
|
49
28
|
layoutPositions?: string[];
|
|
50
|
-
/**
|
|
51
|
-
* One-line semantic description of what the block is and when it belongs on a
|
|
52
|
-
* page. Surfaced to the AI page composer to guide block selection and order.
|
|
53
|
-
*/
|
|
54
29
|
description?: string;
|
|
55
30
|
props: Record<string, FieldDefinition>;
|
|
56
|
-
/**
|
|
57
|
-
* Optional server-side data loader. Run by CmssyServerPage during SSR; its
|
|
58
|
-
* result is passed to the component as the `data` prop. Not run in the
|
|
59
|
-
* editor (the component receives `data: undefined` there).
|
|
60
|
-
*
|
|
61
|
-
* The result crosses the server→client boundary when the block component is a
|
|
62
|
-
* Client Component, so it must be RSC-serializable (plain objects, arrays and
|
|
63
|
-
* primitives - no functions, class instances, etc.).
|
|
64
|
-
*/
|
|
65
31
|
loader?: BlockLoader;
|
|
66
32
|
component: ComponentType<{
|
|
67
33
|
content: Record<string, unknown>;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent } from '@cmssy/core';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* The props a block component receives, derived from the fields it declares:
|
|
6
|
-
*
|
|
7
|
-
* const props = { headline: fields.text({ required: true }) };
|
|
8
|
-
* export function Hero({ content }: BlockProps<typeof props>) { … }
|
|
9
|
-
*
|
|
10
|
-
* Type the component this way and the schema is the only place a field is
|
|
11
|
-
* named. Rename `headline` and the component stops compiling, instead of
|
|
12
|
-
* quietly rendering nothing.
|
|
13
|
-
*/
|
|
14
4
|
interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
15
5
|
content: InferBlockContent<P>;
|
|
16
6
|
style?: Record<string, unknown>;
|
|
@@ -19,20 +9,9 @@ interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
|
19
9
|
data?: D;
|
|
20
10
|
}
|
|
21
11
|
type Identical<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
22
|
-
/** What the component says about the fields the schema declares - nothing else. */
|
|
23
12
|
type SchemaSlice<C, Content> = {
|
|
24
13
|
[K in keyof Content]: K extends keyof C ? C[K] : never;
|
|
25
14
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Rejects a component whose `content` disagrees with the schema about a field
|
|
28
|
-
* the schema declares. Extra keys are fine - a loader may inject content the
|
|
29
|
-
* editor knows nothing about (see `productBlock`) - but a declared field must
|
|
30
|
-
* have the name and the type the schema gives it.
|
|
31
|
-
*
|
|
32
|
-
* Without this, a hand-written content type only had to be *compatible* with the
|
|
33
|
-
* schema, and since every optional field is optional on both sides, a field the
|
|
34
|
-
* component invented was compatible with the one it forgot.
|
|
35
|
-
*/
|
|
36
15
|
type ContentGuard<C, P extends BlockPropsSchema> = Identical<SchemaSlice<C, InferBlockContent<P>>, InferBlockContent<P>> extends true ? unknown : {
|
|
37
16
|
CONTENT_MUST_BE_TYPED_AS_BlockProps_OF_THIS_PROPS: InferBlockContent<P>;
|
|
38
17
|
};
|
|
@@ -47,21 +26,8 @@ interface BlockDefinition {
|
|
|
47
26
|
category?: string;
|
|
48
27
|
icon?: string;
|
|
49
28
|
layoutPositions?: string[];
|
|
50
|
-
/**
|
|
51
|
-
* One-line semantic description of what the block is and when it belongs on a
|
|
52
|
-
* page. Surfaced to the AI page composer to guide block selection and order.
|
|
53
|
-
*/
|
|
54
29
|
description?: string;
|
|
55
30
|
props: Record<string, FieldDefinition>;
|
|
56
|
-
/**
|
|
57
|
-
* Optional server-side data loader. Run by CmssyServerPage during SSR; its
|
|
58
|
-
* result is passed to the component as the `data` prop. Not run in the
|
|
59
|
-
* editor (the component receives `data: undefined` there).
|
|
60
|
-
*
|
|
61
|
-
* The result crosses the server→client boundary when the block component is a
|
|
62
|
-
* Client Component, so it must be RSC-serializable (plain objects, arrays and
|
|
63
|
-
* primitives - no functions, class instances, etc.).
|
|
64
|
-
*/
|
|
65
31
|
loader?: BlockLoader;
|
|
66
32
|
component: ComponentType<{
|
|
67
33
|
content: Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/react",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.7.0",
|
|
4
4
|
"description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -24,29 +24,54 @@
|
|
|
24
24
|
"sideEffects": false,
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/index.d.cts",
|
|
33
|
+
"default": "./dist/index.cjs"
|
|
34
|
+
}
|
|
30
35
|
},
|
|
31
36
|
"./client": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./dist/client.d.ts",
|
|
39
|
+
"default": "./dist/client.js"
|
|
40
|
+
},
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./dist/client.d.cts",
|
|
43
|
+
"default": "./dist/client.cjs"
|
|
44
|
+
}
|
|
35
45
|
},
|
|
36
46
|
"./internal": {
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
"import": {
|
|
48
|
+
"types": "./dist/internal.d.ts",
|
|
49
|
+
"default": "./dist/internal.js"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./dist/internal.d.cts",
|
|
53
|
+
"default": "./dist/internal.cjs"
|
|
54
|
+
}
|
|
40
55
|
},
|
|
41
56
|
"./internal-server": {
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./dist/internal-server.d.ts",
|
|
59
|
+
"default": "./dist/internal-server.js"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./dist/internal-server.d.cts",
|
|
63
|
+
"default": "./dist/internal-server.cjs"
|
|
64
|
+
}
|
|
45
65
|
},
|
|
46
66
|
"./block-error-boundary": {
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
"import": {
|
|
68
|
+
"types": "./dist/block-error-boundary.d.ts",
|
|
69
|
+
"default": "./dist/block-error-boundary.js"
|
|
70
|
+
},
|
|
71
|
+
"require": {
|
|
72
|
+
"types": "./dist/block-error-boundary.d.cts",
|
|
73
|
+
"default": "./dist/block-error-boundary.cjs"
|
|
74
|
+
}
|
|
50
75
|
}
|
|
51
76
|
},
|
|
52
77
|
"main": "./dist/index.cjs",
|
|
@@ -71,8 +96,8 @@
|
|
|
71
96
|
"vitest": "^2.1.0"
|
|
72
97
|
},
|
|
73
98
|
"dependencies": {
|
|
74
|
-
"@cmssy/types": "0.
|
|
75
|
-
"@cmssy/core": "11.
|
|
99
|
+
"@cmssy/types": "0.33.0",
|
|
100
|
+
"@cmssy/core": "11.7.0"
|
|
76
101
|
},
|
|
77
102
|
"scripts": {
|
|
78
103
|
"build": "tsup",
|