@cmssy/react 16.10.0 → 16.11.1

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/index.cjs CHANGED
@@ -723,6 +723,31 @@ function CmssyLayoutRegion({
723
723
  block.id
724
724
  )) });
725
725
  }
726
+ function defineCmssyRouteConfig(config) {
727
+ const org = config.org?.trim() ?? "";
728
+ const workspaceSlug = config.workspaceSlug?.trim() ?? "";
729
+ const missing = [
730
+ ...org ? [] : ["org"],
731
+ ...workspaceSlug ? [] : ["workspaceSlug"]
732
+ ];
733
+ if (missing.length > 0) {
734
+ throw new Error(
735
+ `cmssy: defineCmssyRouteConfig is missing ${missing.join(" and ")}. Both name a public workspace, so a browser build can carry them - read them from import.meta.env if they differ per environment.`
736
+ );
737
+ }
738
+ if (typeof window !== "undefined") {
739
+ const carried = [
740
+ ...config.draftSecret === void 0 ? [] : ["draftSecret"],
741
+ ...config.devToken === void 0 ? [] : ["devToken"]
742
+ ];
743
+ if (carried.length > 0) {
744
+ throw new Error(
745
+ `cmssy: ${carried.join(" and ")} reached the browser. Anyone loading the page can read a value in the bundle: a draft secret opens every unpublished draft in the workspace, and a devToken is an API credential that writes to it. Keep both on a server build (@cmssy/next, @cmssy/astro or Vite SSR) and leave them out of a client-side config.`
746
+ );
747
+ }
748
+ }
749
+ return { ...config, org, workspaceSlug };
750
+ }
726
751
  async function loadCmssyRoute(config, options) {
727
752
  const {
728
753
  blocks,
@@ -991,6 +1016,7 @@ exports.UnknownBlock = UnknownBlock;
991
1016
  exports.buildBlockMap = buildBlockMap;
992
1017
  exports.createBlockDataHandler = createBlockDataHandler;
993
1018
  exports.defineBlock = defineBlock;
1019
+ exports.defineCmssyRouteConfig = defineCmssyRouteConfig;
994
1020
  exports.handleBlockDataRequest = handleBlockDataRequest;
995
1021
  exports.loadCmssyRoute = loadCmssyRoute;
996
1022
  exports.parseBlockDataRequest = parseBlockDataRequest;
package/dist/index.d.cts CHANGED
@@ -7,7 +7,7 @@ export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy
7
7
  export { buildBlockContext } from '@cmssy/core/internal';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
  import { ReactElement, ComponentType } from 'react';
10
- export { C as CmssyRouteConfig, a as CmssyRouteData, L as LoadCmssyRouteOptions, l as loadCmssyRoute } from './load-cmssy-route-BjUMTpOJ.cjs';
10
+ export { C as CmssyRouteConfig, a as CmssyRouteData, L as LoadCmssyRouteOptions, d as defineCmssyRouteConfig, l as loadCmssyRoute } from './load-cmssy-route-DsAVTbis.cjs';
11
11
  export { CmssyBlockDataHandlerOptions, CmssyBlockDataRequest, CmssyBlockDataRequestBlock, CmssyBlockDataRequestPage, CmssyBlockDataResult, ResolveBlockDataRequestOptions, createBlockDataHandler, handleBlockDataRequest, parseBlockDataRequest, resolveBlockDataRequest } from './internal-server.cjs';
12
12
 
13
13
  interface CmssyServerPageProps {
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy
7
7
  export { buildBlockContext } from '@cmssy/core/internal';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
  import { ReactElement, ComponentType } from 'react';
10
- export { C as CmssyRouteConfig, a as CmssyRouteData, L as LoadCmssyRouteOptions, l as loadCmssyRoute } from './load-cmssy-route-C9FPwUSB.js';
10
+ export { C as CmssyRouteConfig, a as CmssyRouteData, L as LoadCmssyRouteOptions, d as defineCmssyRouteConfig, l as loadCmssyRoute } from './load-cmssy-route-NxeXEvZS.js';
11
11
  export { CmssyBlockDataHandlerOptions, CmssyBlockDataRequest, CmssyBlockDataRequestBlock, CmssyBlockDataRequestPage, CmssyBlockDataResult, ResolveBlockDataRequestOptions, createBlockDataHandler, handleBlockDataRequest, parseBlockDataRequest, resolveBlockDataRequest } from './internal-server.js';
12
12
 
13
13
  interface CmssyServerPageProps {
package/dist/index.js CHANGED
@@ -723,6 +723,31 @@ function CmssyLayoutRegion({
723
723
  block.id
724
724
  )) });
725
725
  }
726
+ function defineCmssyRouteConfig(config) {
727
+ const org = config.org?.trim() ?? "";
728
+ const workspaceSlug = config.workspaceSlug?.trim() ?? "";
729
+ const missing = [
730
+ ...org ? [] : ["org"],
731
+ ...workspaceSlug ? [] : ["workspaceSlug"]
732
+ ];
733
+ if (missing.length > 0) {
734
+ throw new Error(
735
+ `cmssy: defineCmssyRouteConfig is missing ${missing.join(" and ")}. Both name a public workspace, so a browser build can carry them - read them from import.meta.env if they differ per environment.`
736
+ );
737
+ }
738
+ if (typeof window !== "undefined") {
739
+ const carried = [
740
+ ...config.draftSecret === void 0 ? [] : ["draftSecret"],
741
+ ...config.devToken === void 0 ? [] : ["devToken"]
742
+ ];
743
+ if (carried.length > 0) {
744
+ throw new Error(
745
+ `cmssy: ${carried.join(" and ")} reached the browser. Anyone loading the page can read a value in the bundle: a draft secret opens every unpublished draft in the workspace, and a devToken is an API credential that writes to it. Keep both on a server build (@cmssy/next, @cmssy/astro or Vite SSR) and leave them out of a client-side config.`
746
+ );
747
+ }
748
+ }
749
+ return { ...config, org, workspaceSlug };
750
+ }
726
751
  async function loadCmssyRoute(config, options) {
727
752
  const {
728
753
  blocks,
@@ -926,4 +951,4 @@ function createBlockDataHandler(config, blocks, options = {}) {
926
951
  };
927
952
  }
928
953
 
929
- export { CmssyBlock, CmssyBlocks, CmssyLayoutRegion, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, createBlockDataHandler, defineBlock, handleBlockDataRequest, loadCmssyRoute, parseBlockDataRequest, resolveBlockDataRequest, resolveCmssyLayout, resolveCmssyLayoutSlot, resolveEditorBlockData, resolveEditorLayoutBlockData };
954
+ export { CmssyBlock, CmssyBlocks, CmssyLayoutRegion, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, createBlockDataHandler, defineBlock, defineCmssyRouteConfig, handleBlockDataRequest, loadCmssyRoute, parseBlockDataRequest, resolveBlockDataRequest, resolveCmssyLayout, resolveCmssyLayoutSlot, resolveEditorBlockData, resolveEditorLayoutBlockData };
@@ -1,9 +1,10 @@
1
- import { CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, CmssyFormDefinition, RetryOption, FetchLike } from '@cmssy/core';
1
+ import { CmssyLayout, CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, CmssyFormDefinition, RetryOption, FetchLike } from '@cmssy/core';
2
2
  import { E as EditorBlockData, B as BlockDefinition } from './resolve-block-data-Bkracpae.cjs';
3
3
 
4
- type CmssyRouteConfig = Omit<CmssyConfig, "draftSecret"> & {
4
+ type CmssyRouteConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>, "draftSecret"> & {
5
5
  draftSecret?: string;
6
6
  };
7
+ declare function defineCmssyRouteConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyRouteConfig<L>): CmssyRouteConfig<L>;
7
8
  interface LoadCmssyRouteOptions {
8
9
  blocks: BlockDefinition[];
9
10
  path?: string[];
@@ -31,4 +32,4 @@ interface CmssyRouteData {
31
32
  }
32
33
  declare function loadCmssyRoute(config: CmssyRouteConfig, options: LoadCmssyRouteOptions): Promise<CmssyRouteData>;
33
34
 
34
- export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, loadCmssyRoute as l };
35
+ export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, defineCmssyRouteConfig as d, loadCmssyRoute as l };
@@ -1,9 +1,10 @@
1
- import { CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, CmssyFormDefinition, RetryOption, FetchLike } from '@cmssy/core';
1
+ import { CmssyLayout, CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, CmssyFormDefinition, RetryOption, FetchLike } from '@cmssy/core';
2
2
  import { E as EditorBlockData, B as BlockDefinition } from './resolve-block-data-Bkracpae.js';
3
3
 
4
- type CmssyRouteConfig = Omit<CmssyConfig, "draftSecret"> & {
4
+ type CmssyRouteConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>, "draftSecret"> & {
5
5
  draftSecret?: string;
6
6
  };
7
+ declare function defineCmssyRouteConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyRouteConfig<L>): CmssyRouteConfig<L>;
7
8
  interface LoadCmssyRouteOptions {
8
9
  blocks: BlockDefinition[];
9
10
  path?: string[];
@@ -31,4 +32,4 @@ interface CmssyRouteData {
31
32
  }
32
33
  declare function loadCmssyRoute(config: CmssyRouteConfig, options: LoadCmssyRouteOptions): Promise<CmssyRouteData>;
33
34
 
34
- export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, loadCmssyRoute as l };
35
+ export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, defineCmssyRouteConfig as d, loadCmssyRoute as l };
package/dist/spa.cjs CHANGED
@@ -254,6 +254,31 @@ async function resolveCmssyLayoutSlot(config, options) {
254
254
  }
255
255
 
256
256
  // src/components/load-cmssy-route.ts
257
+ function defineCmssyRouteConfig(config) {
258
+ const org = config.org?.trim() ?? "";
259
+ const workspaceSlug = config.workspaceSlug?.trim() ?? "";
260
+ const missing = [
261
+ ...org ? [] : ["org"],
262
+ ...workspaceSlug ? [] : ["workspaceSlug"]
263
+ ];
264
+ if (missing.length > 0) {
265
+ throw new Error(
266
+ `cmssy: defineCmssyRouteConfig is missing ${missing.join(" and ")}. Both name a public workspace, so a browser build can carry them - read them from import.meta.env if they differ per environment.`
267
+ );
268
+ }
269
+ if (typeof window !== "undefined") {
270
+ const carried = [
271
+ ...config.draftSecret === void 0 ? [] : ["draftSecret"],
272
+ ...config.devToken === void 0 ? [] : ["devToken"]
273
+ ];
274
+ if (carried.length > 0) {
275
+ throw new Error(
276
+ `cmssy: ${carried.join(" and ")} reached the browser. Anyone loading the page can read a value in the bundle: a draft secret opens every unpublished draft in the workspace, and a devToken is an API credential that writes to it. Keep both on a server build (@cmssy/next, @cmssy/astro or Vite SSR) and leave them out of a client-side config.`
277
+ );
278
+ }
279
+ }
280
+ return { ...config, org, workspaceSlug };
281
+ }
257
282
  async function loadCmssyRoute(config, options) {
258
283
  const {
259
284
  blocks,
@@ -636,4 +661,5 @@ function CmssyRoute({
636
661
  }
637
662
 
638
663
  exports.CmssyRoute = CmssyRoute;
664
+ exports.defineCmssyRouteConfig = defineCmssyRouteConfig;
639
665
  exports.useCmssyRoute = useCmssyRoute;
package/dist/spa.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { L as LoadCmssyRouteOptions, C as CmssyRouteConfig, a as CmssyRouteData } from './load-cmssy-route-BjUMTpOJ.cjs';
3
+ import { L as LoadCmssyRouteOptions, C as CmssyRouteConfig, a as CmssyRouteData } from './load-cmssy-route-DsAVTbis.cjs';
4
+ export { d as defineCmssyRouteConfig } from './load-cmssy-route-DsAVTbis.cjs';
4
5
  import '@cmssy/core';
5
6
  import './resolve-block-data-Bkracpae.cjs';
6
7
 
@@ -30,4 +31,4 @@ interface CmssyRouteProps extends UseCmssyRouteOptions {
30
31
  }
31
32
  declare function CmssyRoute({ config, children, fallback, notFound, renderError, ...options }: CmssyRouteProps): react_jsx_runtime.JSX.Element;
32
33
 
33
- export { CmssyRoute, type CmssyRouteProps, type CmssyRouteRenderProps, type CmssyRouteState, type UseCmssyRouteOptions, useCmssyRoute };
34
+ export { CmssyRoute, CmssyRouteConfig, CmssyRouteData, type CmssyRouteProps, type CmssyRouteRenderProps, type CmssyRouteState, type UseCmssyRouteOptions, useCmssyRoute };
package/dist/spa.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { L as LoadCmssyRouteOptions, C as CmssyRouteConfig, a as CmssyRouteData } from './load-cmssy-route-C9FPwUSB.js';
3
+ import { L as LoadCmssyRouteOptions, C as CmssyRouteConfig, a as CmssyRouteData } from './load-cmssy-route-NxeXEvZS.js';
4
+ export { d as defineCmssyRouteConfig } from './load-cmssy-route-NxeXEvZS.js';
4
5
  import '@cmssy/core';
5
6
  import './resolve-block-data-Bkracpae.js';
6
7
 
@@ -30,4 +31,4 @@ interface CmssyRouteProps extends UseCmssyRouteOptions {
30
31
  }
31
32
  declare function CmssyRoute({ config, children, fallback, notFound, renderError, ...options }: CmssyRouteProps): react_jsx_runtime.JSX.Element;
32
33
 
33
- export { CmssyRoute, type CmssyRouteProps, type CmssyRouteRenderProps, type CmssyRouteState, type UseCmssyRouteOptions, useCmssyRoute };
34
+ export { CmssyRoute, CmssyRouteConfig, CmssyRouteData, type CmssyRouteProps, type CmssyRouteRenderProps, type CmssyRouteState, type UseCmssyRouteOptions, useCmssyRoute };
package/dist/spa.js CHANGED
@@ -252,6 +252,31 @@ async function resolveCmssyLayoutSlot(config, options) {
252
252
  }
253
253
 
254
254
  // src/components/load-cmssy-route.ts
255
+ function defineCmssyRouteConfig(config) {
256
+ const org = config.org?.trim() ?? "";
257
+ const workspaceSlug = config.workspaceSlug?.trim() ?? "";
258
+ const missing = [
259
+ ...org ? [] : ["org"],
260
+ ...workspaceSlug ? [] : ["workspaceSlug"]
261
+ ];
262
+ if (missing.length > 0) {
263
+ throw new Error(
264
+ `cmssy: defineCmssyRouteConfig is missing ${missing.join(" and ")}. Both name a public workspace, so a browser build can carry them - read them from import.meta.env if they differ per environment.`
265
+ );
266
+ }
267
+ if (typeof window !== "undefined") {
268
+ const carried = [
269
+ ...config.draftSecret === void 0 ? [] : ["draftSecret"],
270
+ ...config.devToken === void 0 ? [] : ["devToken"]
271
+ ];
272
+ if (carried.length > 0) {
273
+ throw new Error(
274
+ `cmssy: ${carried.join(" and ")} reached the browser. Anyone loading the page can read a value in the bundle: a draft secret opens every unpublished draft in the workspace, and a devToken is an API credential that writes to it. Keep both on a server build (@cmssy/next, @cmssy/astro or Vite SSR) and leave them out of a client-side config.`
275
+ );
276
+ }
277
+ }
278
+ return { ...config, org, workspaceSlug };
279
+ }
255
280
  async function loadCmssyRoute(config, options) {
256
281
  const {
257
282
  blocks,
@@ -633,4 +658,4 @@ function CmssyRoute({
633
658
  return /* @__PURE__ */ jsx(Fragment, { children: children({ data, Blocks, Region }) });
634
659
  }
635
660
 
636
- export { CmssyRoute, useCmssyRoute };
661
+ export { CmssyRoute, defineCmssyRouteConfig, useCmssyRoute };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "16.10.0",
3
+ "version": "16.11.1",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -107,7 +107,7 @@
107
107
  },
108
108
  "dependencies": {
109
109
  "@cmssy/types": "0.49.0",
110
- "@cmssy/core": "16.10.0"
110
+ "@cmssy/core": "16.11.1"
111
111
  },
112
112
  "scripts": {
113
113
  "build": "tsup",