@cmssy/react 10.2.0 → 10.4.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.cjs CHANGED
@@ -619,7 +619,8 @@ function CmssyEditablePage({
619
619
  category,
620
620
  forms,
621
621
  data,
622
- resolvedContent
622
+ resolvedContent,
623
+ appContext
623
624
  }) {
624
625
  if (!Array.isArray(blocks)) {
625
626
  throw new Error(
@@ -639,7 +640,8 @@ function CmssyEditablePage({
639
640
  category,
640
641
  forms,
641
642
  data,
642
- resolvedContent
643
+ resolvedContent,
644
+ appContext
643
645
  }
644
646
  );
645
647
  }
@@ -653,14 +655,16 @@ function EditableBlocks({
653
655
  category,
654
656
  forms,
655
657
  data,
656
- resolvedContent
658
+ resolvedContent,
659
+ appContext
657
660
  }) {
658
661
  const blockMap = react.useMemo(() => buildBlockMap(blocks), [blocks]);
659
662
  const context = react.useMemo(
660
663
  () => internal.buildBlockContext(locale, defaultLocale, enabledLocales, true, forms, {
661
- page: internal.blockPageOf(page)
664
+ page,
665
+ app: appContext
662
666
  }),
663
- [locale, defaultLocale, enabledLocales, forms, page]
667
+ [locale, defaultLocale, enabledLocales, forms, page, appContext]
664
668
  );
665
669
  const bridgeConfig = react.useMemo(
666
670
  () => ({
package/dist/client.d.cts CHANGED
@@ -46,8 +46,10 @@ 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
+ appContext?: Record<string, unknown>;
49
51
  }
50
- declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
52
+ declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, appContext, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
51
53
 
52
54
  interface CmssyLazyEditorProps {
53
55
  page: CmssyPageData | null;
package/dist/client.d.ts CHANGED
@@ -46,8 +46,10 @@ 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
+ appContext?: Record<string, unknown>;
49
51
  }
50
- declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
52
+ declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, appContext, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
51
53
 
52
54
  interface CmssyLazyEditorProps {
53
55
  page: CmssyPageData | null;
package/dist/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useState, useRef, useEffect, useMemo, createElement } from 'react';
3
3
  import { postToEditor, PROTOCOL_VERSION, parseEditorMessage } from '@cmssy/core';
4
- import { resolveInitialTarget, buildBlockContext, blockPageOf, getBlockContentForLanguage, normalizeRelationContent, asBucket } from '@cmssy/core/internal';
4
+ import { resolveInitialTarget, buildBlockContext, getBlockContentForLanguage, normalizeRelationContent, asBucket } from '@cmssy/core/internal';
5
5
  import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
 
@@ -617,7 +617,8 @@ function CmssyEditablePage({
617
617
  category,
618
618
  forms,
619
619
  data,
620
- resolvedContent
620
+ resolvedContent,
621
+ appContext
621
622
  }) {
622
623
  if (!Array.isArray(blocks)) {
623
624
  throw new Error(
@@ -637,7 +638,8 @@ function CmssyEditablePage({
637
638
  category,
638
639
  forms,
639
640
  data,
640
- resolvedContent
641
+ resolvedContent,
642
+ appContext
641
643
  }
642
644
  );
643
645
  }
@@ -651,14 +653,16 @@ function EditableBlocks({
651
653
  category,
652
654
  forms,
653
655
  data,
654
- resolvedContent
656
+ resolvedContent,
657
+ appContext
655
658
  }) {
656
659
  const blockMap = useMemo(() => buildBlockMap(blocks), [blocks]);
657
660
  const context = useMemo(
658
661
  () => buildBlockContext(locale, defaultLocale, enabledLocales, true, forms, {
659
- page: blockPageOf(page)
662
+ page,
663
+ app: appContext
660
664
  }),
661
- [locale, defaultLocale, enabledLocales, forms, page]
665
+ [locale, defaultLocale, enabledLocales, forms, page, appContext]
662
666
  );
663
667
  const bridgeConfig = useMemo(
664
668
  () => ({
package/dist/index.cjs CHANGED
@@ -261,6 +261,7 @@ async function CmssyServerPage({
261
261
  forms,
262
262
  auth,
263
263
  workspace,
264
+ appContext,
264
265
  editMode
265
266
  }) {
266
267
  if (!page) return null;
@@ -278,7 +279,7 @@ async function CmssyServerPage({
278
279
  enabledLocales,
279
280
  false,
280
281
  forms,
281
- { auth, workspace, page: internal.blockPageOf(page) }
282
+ { auth, workspace, page, app: appContext }
282
283
  );
283
284
  const resolved = await resolveBlocks(
284
285
  page.blocks,
@@ -308,6 +309,7 @@ async function CmssyServerLayout({
308
309
  defaultLocale: defaultLocaleProp,
309
310
  enabledLocales: enabledLocalesProp,
310
311
  config,
312
+ appContext,
311
313
  editMode
312
314
  }) {
313
315
  const { locale, defaultLocale, enabledLocales } = await resolveRenderLocale({
@@ -321,7 +323,14 @@ async function CmssyServerLayout({
321
323
  if (layoutBlocks.length === 0) return null;
322
324
  const map = buildBlockMap(blocks);
323
325
  const loaderMap = buildLoaderMap(blocks);
324
- const context = internal.buildBlockContext(locale, defaultLocale, enabledLocales);
326
+ const context = internal.buildBlockContext(
327
+ locale,
328
+ defaultLocale,
329
+ enabledLocales,
330
+ false,
331
+ void 0,
332
+ { app: appContext }
333
+ );
325
334
  const resolved = await resolveBlocks(
326
335
  layoutBlocks,
327
336
  loaderMap,
package/dist/index.d.cts CHANGED
@@ -27,6 +27,12 @@ interface CmssyServerPageProps {
27
27
  auth?: CmssyBlockAuthContext;
28
28
  /** Workspace identity, exposed via context.workspace. Resolved by createCmssyPage. */
29
29
  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
+ appContext?: Record<string, unknown>;
30
36
  editMode?: boolean;
31
37
  }
32
38
  /**
@@ -34,7 +40,7 @@ interface CmssyServerPageProps {
34
40
  * loader server-side before rendering, so it must be rendered in a server
35
41
  * component tree (as `createCmssyPage` does) - not in a client component.
36
42
  */
37
- declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
43
+ 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>;
38
44
 
39
45
  interface CmssyServerLayoutProps {
40
46
  groups: CmssyLayoutGroup[];
@@ -50,6 +56,12 @@ interface CmssyServerLayoutProps {
50
56
  * Without it the SDK has to guess, and its guess is "en".
51
57
  */
52
58
  config?: CmssyClientConfig;
59
+ /**
60
+ * Anything the app wants its layout blocks to see, exposed as context.app.
61
+ * A header that highlights the active link reads it from here - the SDK does
62
+ * not know the app's routing.
63
+ */
64
+ appContext?: Record<string, unknown>;
53
65
  editMode?: boolean;
54
66
  }
55
67
  /**
@@ -57,7 +69,7 @@ interface CmssyServerLayoutProps {
57
69
  * loader server-side before rendering, so a header block can list categories
58
70
  * the same way a page block can. Must be rendered in a server component tree.
59
71
  */
60
- declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
72
+ declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
61
73
 
62
74
  interface CmssyBlockProps {
63
75
  block: RawBlock;
package/dist/index.d.ts CHANGED
@@ -27,6 +27,12 @@ interface CmssyServerPageProps {
27
27
  auth?: CmssyBlockAuthContext;
28
28
  /** Workspace identity, exposed via context.workspace. Resolved by createCmssyPage. */
29
29
  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
+ appContext?: Record<string, unknown>;
30
36
  editMode?: boolean;
31
37
  }
32
38
  /**
@@ -34,7 +40,7 @@ interface CmssyServerPageProps {
34
40
  * loader server-side before rendering, so it must be rendered in a server
35
41
  * component tree (as `createCmssyPage` does) - not in a client component.
36
42
  */
37
- declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
43
+ 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>;
38
44
 
39
45
  interface CmssyServerLayoutProps {
40
46
  groups: CmssyLayoutGroup[];
@@ -50,6 +56,12 @@ interface CmssyServerLayoutProps {
50
56
  * Without it the SDK has to guess, and its guess is "en".
51
57
  */
52
58
  config?: CmssyClientConfig;
59
+ /**
60
+ * Anything the app wants its layout blocks to see, exposed as context.app.
61
+ * A header that highlights the active link reads it from here - the SDK does
62
+ * not know the app's routing.
63
+ */
64
+ appContext?: Record<string, unknown>;
53
65
  editMode?: boolean;
54
66
  }
55
67
  /**
@@ -57,7 +69,7 @@ interface CmssyServerLayoutProps {
57
69
  * loader server-side before rendering, so a header block can list categories
58
70
  * the same way a page block can. Must be rendered in a server component tree.
59
71
  */
60
- declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
72
+ declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
61
73
 
62
74
  interface CmssyBlockProps {
63
75
  block: RawBlock;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { CmssyRequestError, PROTOCOL_VERSION, createCmssyClient, fields, graphqlRequest, isProtocolCompatible, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
2
- import { buildBlockContext, blockPageOf, getBlockContentForLanguage, normalizeRelationContent, asBucket, resolveSiteLocales, resolveRelationContent } from '@cmssy/core/internal';
2
+ import { buildBlockContext, getBlockContentForLanguage, normalizeRelationContent, asBucket, resolveSiteLocales, resolveRelationContent } from '@cmssy/core/internal';
3
3
  export { buildBlockContext } from '@cmssy/core/internal';
4
4
  import { createElement } from 'react';
5
5
  import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
@@ -260,6 +260,7 @@ async function CmssyServerPage({
260
260
  forms,
261
261
  auth,
262
262
  workspace,
263
+ appContext,
263
264
  editMode
264
265
  }) {
265
266
  if (!page) return null;
@@ -277,7 +278,7 @@ async function CmssyServerPage({
277
278
  enabledLocales,
278
279
  false,
279
280
  forms,
280
- { auth, workspace, page: blockPageOf(page) }
281
+ { auth, workspace, page, app: appContext }
281
282
  );
282
283
  const resolved = await resolveBlocks(
283
284
  page.blocks,
@@ -307,6 +308,7 @@ async function CmssyServerLayout({
307
308
  defaultLocale: defaultLocaleProp,
308
309
  enabledLocales: enabledLocalesProp,
309
310
  config,
311
+ appContext,
310
312
  editMode
311
313
  }) {
312
314
  const { locale, defaultLocale, enabledLocales } = await resolveRenderLocale({
@@ -320,7 +322,14 @@ async function CmssyServerLayout({
320
322
  if (layoutBlocks.length === 0) return null;
321
323
  const map = buildBlockMap(blocks);
322
324
  const loaderMap = buildLoaderMap(blocks);
323
- const context = buildBlockContext(locale, defaultLocale, enabledLocales);
325
+ const context = buildBlockContext(
326
+ locale,
327
+ defaultLocale,
328
+ enabledLocales,
329
+ false,
330
+ void 0,
331
+ { app: appContext }
332
+ );
324
333
  const resolved = await resolveBlocks(
325
334
  layoutBlocks,
326
335
  loaderMap,
@@ -98,7 +98,8 @@ async function resolveEditorBlockData({
98
98
  enabledLocales,
99
99
  forms,
100
100
  isPreview = false,
101
- config
101
+ config,
102
+ appContext
102
103
  }) {
103
104
  if (!page) return { data: {}, content: {} };
104
105
  const loaderMap = buildLoaderMap(blocks);
@@ -108,7 +109,7 @@ async function resolveEditorBlockData({
108
109
  enabledLocales,
109
110
  isPreview,
110
111
  forms,
111
- { page: internal.blockPageOf(page) }
112
+ { page, app: appContext }
112
113
  );
113
114
  const resolved = await resolveBlocks(
114
115
  page.blocks,
@@ -16,8 +16,10 @@ interface ResolveBlockDataOptions {
16
16
  isPreview?: boolean;
17
17
  /** Workspace the relation records are read from. No config, no resolution. */
18
18
  config?: CmssyClientConfig;
19
+ /** Passed to loaders as context.app, exactly as on the deployed page. */
20
+ appContext?: Record<string, unknown>;
19
21
  }
20
- declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
22
+ declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
21
23
  declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
22
24
  interface ResolveLayoutBlockDataOptions {
23
25
  groups: CmssyLayoutGroup[];
@@ -16,8 +16,10 @@ interface ResolveBlockDataOptions {
16
16
  isPreview?: boolean;
17
17
  /** Workspace the relation records are read from. No config, no resolution. */
18
18
  config?: CmssyClientConfig;
19
+ /** Passed to loaders as context.app, exactly as on the deployed page. */
20
+ appContext?: Record<string, unknown>;
19
21
  }
20
- declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
22
+ declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
21
23
  declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
22
24
  interface ResolveLayoutBlockDataOptions {
23
25
  groups: CmssyLayoutGroup[];
@@ -1,4 +1,4 @@
1
- import { buildBlockContext, blockPageOf, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
1
+ import { buildBlockContext, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
2
2
 
3
3
  // src/components/resolve-block-data.ts
4
4
 
@@ -96,7 +96,8 @@ async function resolveEditorBlockData({
96
96
  enabledLocales,
97
97
  forms,
98
98
  isPreview = false,
99
- config
99
+ config,
100
+ appContext
100
101
  }) {
101
102
  if (!page) return { data: {}, content: {} };
102
103
  const loaderMap = buildLoaderMap(blocks);
@@ -106,7 +107,7 @@ async function resolveEditorBlockData({
106
107
  enabledLocales,
107
108
  isPreview,
108
109
  forms,
109
- { page: blockPageOf(page) }
110
+ { page, app: appContext }
110
111
  );
111
112
  const resolved = await resolveBlocks(
112
113
  page.blocks,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "10.2.0",
3
+ "version": "10.4.0",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -71,8 +71,8 @@
71
71
  "vitest": "^2.1.0"
72
72
  },
73
73
  "dependencies": {
74
- "@cmssy/types": "0.30.0",
75
- "@cmssy/core": "10.2.0"
74
+ "@cmssy/types": "0.31.0",
75
+ "@cmssy/core": "10.4.0"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "tsup",