@cmssy/next 10.2.0 → 10.3.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.
@@ -13,10 +13,26 @@ interface CmssyEditorProps {
13
13
  forms?: Record<string, CmssyFormDefinition>;
14
14
  data?: Record<string, unknown>;
15
15
  resolvedContent?: Record<string, Record<string, unknown>>;
16
+ appContext?: Record<string, unknown>;
16
17
  }
18
+ /**
19
+ * What the app wants its blocks to see, beyond the content: a signed-in member,
20
+ * a feature flag, the active path. Given a function it is called per request
21
+ * with the page being rendered, which is the useful form - a value fixed at
22
+ * module scope cannot vary by visitor.
23
+ *
24
+ * Whatever it returns lands on `context.app`, untouched, on the deployed page
25
+ * and in the editor alike.
26
+ */
27
+ type CmssyAppContext = Record<string, unknown> | ((args: {
28
+ page: CmssyPageData;
29
+ locale: string;
30
+ path: string[];
31
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>);
17
32
  interface CreateCmssyPageOptions {
18
33
  editor?: ComponentType<CmssyEditorProps>;
19
34
  path?: string;
35
+ appContext?: CmssyAppContext;
20
36
  }
21
37
  interface CatchAllParams {
22
38
  path?: string[];
@@ -45,4 +61,4 @@ declare function createCmssyPage(config: CmssyConfig, blocks: BlockDefinition[],
45
61
  */
46
62
  declare function createCmssyEditPage(config: CmssyConfig, blocks: BlockDefinition[], options?: CreateCmssyPageOptions): ({ params, searchParams, }: CatchAllProps) => Promise<react_jsx_runtime.JSX.Element>;
47
63
 
48
- export { type CmssyEditorProps as C, type CreateCmssyPageOptions as a, createCmssyPage as b, createCmssyEditPage as c };
64
+ export { type CmssyAppContext as C, type CmssyEditorProps as a, type CreateCmssyPageOptions as b, createCmssyEditPage as c, createCmssyPage as d };
@@ -13,10 +13,26 @@ interface CmssyEditorProps {
13
13
  forms?: Record<string, CmssyFormDefinition>;
14
14
  data?: Record<string, unknown>;
15
15
  resolvedContent?: Record<string, Record<string, unknown>>;
16
+ appContext?: Record<string, unknown>;
16
17
  }
18
+ /**
19
+ * What the app wants its blocks to see, beyond the content: a signed-in member,
20
+ * a feature flag, the active path. Given a function it is called per request
21
+ * with the page being rendered, which is the useful form - a value fixed at
22
+ * module scope cannot vary by visitor.
23
+ *
24
+ * Whatever it returns lands on `context.app`, untouched, on the deployed page
25
+ * and in the editor alike.
26
+ */
27
+ type CmssyAppContext = Record<string, unknown> | ((args: {
28
+ page: CmssyPageData;
29
+ locale: string;
30
+ path: string[];
31
+ }) => Record<string, unknown> | Promise<Record<string, unknown>>);
17
32
  interface CreateCmssyPageOptions {
18
33
  editor?: ComponentType<CmssyEditorProps>;
19
34
  path?: string;
35
+ appContext?: CmssyAppContext;
20
36
  }
21
37
  interface CatchAllParams {
22
38
  path?: string[];
@@ -45,4 +61,4 @@ declare function createCmssyPage(config: CmssyConfig, blocks: BlockDefinition[],
45
61
  */
46
62
  declare function createCmssyEditPage(config: CmssyConfig, blocks: BlockDefinition[], options?: CreateCmssyPageOptions): ({ params, searchParams, }: CatchAllProps) => Promise<react_jsx_runtime.JSX.Element>;
47
63
 
48
- export { type CmssyEditorProps as C, type CreateCmssyPageOptions as a, createCmssyPage as b, createCmssyEditPage as c };
64
+ export { type CmssyAppContext as C, type CmssyEditorProps as a, type CreateCmssyPageOptions as b, createCmssyEditPage as c, createCmssyPage as d };
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, defineCmssyConfig, localizeHref, resolveEditorOrigin } from '@cmssy/core';
2
- export { C as CmssyEditorProps, a as CreateCmssyPageOptions } from './index-C4vUxDkk.cjs';
2
+ export { C as CmssyAppContext, a as CmssyEditorProps, b as CreateCmssyPageOptions } from './index-B64zk2X7.cjs';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
5
5
  import '@cmssy/react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, defineCmssyConfig, localizeHref, resolveEditorOrigin } from '@cmssy/core';
2
- export { C as CmssyEditorProps, a as CreateCmssyPageOptions } from './index-C4vUxDkk.js';
2
+ export { C as CmssyAppContext, a as CmssyEditorProps, b as CreateCmssyPageOptions } from './index-B64zk2X7.js';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
5
5
  import '@cmssy/react';
package/dist/server.cjs CHANGED
@@ -100,6 +100,7 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
100
100
  default: defaultLocale,
101
101
  enabled: enabledLocales
102
102
  };
103
+ const appContext = typeof options?.appContext === "function" ? await options.appContext({ page, locale, path: pagePath ?? [] }) : options?.appContext;
103
104
  if (editorActive && Editor) {
104
105
  const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
105
106
  const editorData = await internalServer.resolveEditorBlockData({
@@ -110,7 +111,8 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
110
111
  enabledLocales,
111
112
  forms,
112
113
  isPreview: true,
113
- config
114
+ config,
115
+ appContext
114
116
  });
115
117
  return /* @__PURE__ */ jsxRuntime.jsx(internal$1.CmssyLocaleProvider, { value: localeContext, children: /* @__PURE__ */ jsxRuntime.jsx(
116
118
  Editor,
@@ -122,7 +124,8 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
122
124
  edit: { editorOrigin: bridgeOrigin },
123
125
  forms,
124
126
  data: editorData.data,
125
- resolvedContent: editorData.content
127
+ resolvedContent: editorData.content,
128
+ appContext
126
129
  }
127
130
  ) });
128
131
  }
@@ -148,6 +151,7 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
148
151
  forms,
149
152
  auth,
150
153
  workspace,
154
+ appContext,
151
155
  editMode
152
156
  }
153
157
  ) });
package/dist/server.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as CmssyEditorProps, a as CreateCmssyPageOptions, c as createCmssyEditPage, b as createCmssyPage } from './index-C4vUxDkk.cjs';
1
+ export { C as CmssyAppContext, a as CmssyEditorProps, b as CreateCmssyPageOptions, c as createCmssyEditPage, d as createCmssyPage } from './index-B64zk2X7.cjs';
2
2
  import { CmssyConfig } from '@cmssy/core';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { C as CmssyEditorProps, a as CreateCmssyPageOptions, c as createCmssyEditPage, b as createCmssyPage } from './index-C4vUxDkk.js';
1
+ export { C as CmssyAppContext, a as CmssyEditorProps, b as CreateCmssyPageOptions, c as createCmssyEditPage, d as createCmssyPage } from './index-B64zk2X7.js';
2
2
  import { CmssyConfig } from '@cmssy/core';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
package/dist/server.js CHANGED
@@ -98,6 +98,7 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
98
98
  default: defaultLocale,
99
99
  enabled: enabledLocales
100
100
  };
101
+ const appContext = typeof options?.appContext === "function" ? await options.appContext({ page, locale, path: pagePath ?? [] }) : options?.appContext;
101
102
  if (editorActive && Editor) {
102
103
  const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
103
104
  const editorData = await resolveEditorBlockData({
@@ -108,7 +109,8 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
108
109
  enabledLocales,
109
110
  forms,
110
111
  isPreview: true,
111
- config
112
+ config,
113
+ appContext
112
114
  });
113
115
  return /* @__PURE__ */ jsx(CmssyLocaleProvider, { value: localeContext, children: /* @__PURE__ */ jsx(
114
116
  Editor,
@@ -120,7 +122,8 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
120
122
  edit: { editorOrigin: bridgeOrigin },
121
123
  forms,
122
124
  data: editorData.data,
123
- resolvedContent: editorData.content
125
+ resolvedContent: editorData.content,
126
+ appContext
124
127
  }
125
128
  ) });
126
129
  }
@@ -146,6 +149,7 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
146
149
  forms,
147
150
  auth,
148
151
  workspace,
152
+ appContext,
149
153
  editMode
150
154
  }
151
155
  ) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "10.2.0",
3
+ "version": "10.3.0",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -65,12 +65,12 @@
65
65
  "tsup": "^8.3.0",
66
66
  "typescript": "^5.6.0",
67
67
  "vitest": "^2.1.0",
68
- "@cmssy/react": "10.2.0"
68
+ "@cmssy/react": "10.3.0"
69
69
  },
70
70
  "dependencies": {
71
- "@cmssy/types": "0.30.0",
71
+ "@cmssy/types": "0.31.0",
72
72
  "server-only": "^0.0.1",
73
- "@cmssy/core": "10.2.0"
73
+ "@cmssy/core": "10.3.0"
74
74
  },
75
75
  "scripts": {
76
76
  "build": "tsup",