@cmssy/react 16.9.1 → 16.11.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/index.cjs CHANGED
@@ -639,6 +639,184 @@ function CmssyBlock({
639
639
  )
640
640
  );
641
641
  }
642
+ function CmssyBlocks({
643
+ page,
644
+ blocks,
645
+ locale,
646
+ defaultLocale,
647
+ enabledLocales,
648
+ blockData,
649
+ blockContent,
650
+ pageContext,
651
+ forms,
652
+ auth,
653
+ workspace,
654
+ appContext,
655
+ isPreview = false,
656
+ editMode = false
657
+ }) {
658
+ if (!page) return null;
659
+ const blockMap = buildBlockMap(blocks);
660
+ const context = internal.buildBlockContext(
661
+ locale,
662
+ defaultLocale,
663
+ enabledLocales,
664
+ isPreview,
665
+ forms,
666
+ { page: pageContext, auth, workspace, app: appContext }
667
+ );
668
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (page.blocks ?? []).map((block) => /* @__PURE__ */ jsxRuntime.jsx(
669
+ CmssyBlock,
670
+ {
671
+ block,
672
+ blockMap,
673
+ locale,
674
+ defaultLocale,
675
+ context,
676
+ editMode,
677
+ resolvedContent: blockContent?.[block.id],
678
+ data: blockData?.[block.id]
679
+ },
680
+ block.id
681
+ )) });
682
+ }
683
+ function CmssyLayoutRegion({
684
+ groups,
685
+ region,
686
+ blocks,
687
+ locale,
688
+ defaultLocale,
689
+ enabledLocales,
690
+ page,
691
+ blockData,
692
+ blockContent,
693
+ forms,
694
+ appContext,
695
+ isPreview = false,
696
+ editMode = false
697
+ }) {
698
+ const group = groups.find((candidate) => candidate.region === region);
699
+ const regionBlocks = group ? group.blocks.filter((block) => block.isActive !== false).slice().sort((a, b) => (a.order ?? 0) - (b.order ?? 0)) : [];
700
+ if (regionBlocks.length === 0) return null;
701
+ const blockMap = buildBlockMap(blocks);
702
+ const context = internal.buildBlockContext(
703
+ locale,
704
+ defaultLocale,
705
+ enabledLocales,
706
+ isPreview,
707
+ forms,
708
+ { page, app: appContext }
709
+ );
710
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: regionBlocks.map((block) => /* @__PURE__ */ jsxRuntime.jsx(
711
+ CmssyBlock,
712
+ {
713
+ block,
714
+ blockMap,
715
+ locale,
716
+ defaultLocale,
717
+ context,
718
+ layoutRegion: region,
719
+ editMode,
720
+ resolvedContent: blockContent?.[block.id],
721
+ data: blockData?.[block.id]
722
+ },
723
+ block.id
724
+ )) });
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
+ }
751
+ async function loadCmssyRoute(config, options) {
752
+ const {
753
+ blocks,
754
+ path,
755
+ locale,
756
+ forms,
757
+ appContext,
758
+ previewSecret,
759
+ isPreview = false,
760
+ retry,
761
+ fetch: fetchImpl
762
+ } = options;
763
+ const regions = options.regions ?? internal.layoutRegionIds(config.layout);
764
+ const firstRegion = regions[0] ?? "header";
765
+ const slot = await resolveCmssyLayoutSlot(config, {
766
+ region: firstRegion,
767
+ blocks,
768
+ editMode: false,
769
+ preview: isPreview,
770
+ forms,
771
+ appContext,
772
+ retry,
773
+ ...fetchImpl ? { fetch: fetchImpl } : {},
774
+ path: path ?? [],
775
+ ...locale === void 0 ? {} : { locale }
776
+ });
777
+ const secret = previewSecret ?? (isPreview ? config.draftSecret : void 0);
778
+ const page = await internal.fetchPage(config, slot.path, {
779
+ ...secret ? { previewSecret: secret } : {},
780
+ ...retry === void 0 ? {} : { retry },
781
+ ...fetchImpl ? { fetch: fetchImpl } : {}
782
+ });
783
+ const shared = {
784
+ blocks,
785
+ locale: slot.locale,
786
+ defaultLocale: slot.defaultLocale,
787
+ enabledLocales: slot.enabledLocales,
788
+ forms,
789
+ isPreview,
790
+ config,
791
+ appContext
792
+ };
793
+ const [pageBlocks, ...layoutBlocks] = await Promise.all([
794
+ resolveEditorBlockData({ ...shared, page }),
795
+ ...regions.map(
796
+ (region) => resolveEditorLayoutBlockData({
797
+ ...shared,
798
+ groups: slot.groups,
799
+ page: slot.page,
800
+ region
801
+ })
802
+ )
803
+ ]);
804
+ return {
805
+ page,
806
+ layouts: slot.groups,
807
+ pageContext: slot.page,
808
+ locale: slot.locale,
809
+ defaultLocale: slot.defaultLocale,
810
+ enabledLocales: slot.enabledLocales,
811
+ path: slot.path,
812
+ blockData: pageBlocks.data,
813
+ blockContent: pageBlocks.content,
814
+ layoutData: Object.fromEntries(
815
+ regions.map((region, index) => [region, layoutBlocks[index]])
816
+ ),
817
+ regions
818
+ };
819
+ }
642
820
  var MAX_BLOCKS = 50;
643
821
  function parseBlockDataRequest(body) {
644
822
  if (typeof body !== "object" || body === null) {
@@ -830,13 +1008,17 @@ Object.defineProperty(exports, "buildBlockContext", {
830
1008
  get: function () { return internal.buildBlockContext; }
831
1009
  });
832
1010
  exports.CmssyBlock = CmssyBlock;
1011
+ exports.CmssyBlocks = CmssyBlocks;
1012
+ exports.CmssyLayoutRegion = CmssyLayoutRegion;
833
1013
  exports.CmssyServerLayout = CmssyServerLayout;
834
1014
  exports.CmssyServerPage = CmssyServerPage;
835
1015
  exports.UnknownBlock = UnknownBlock;
836
1016
  exports.buildBlockMap = buildBlockMap;
837
1017
  exports.createBlockDataHandler = createBlockDataHandler;
838
1018
  exports.defineBlock = defineBlock;
1019
+ exports.defineCmssyRouteConfig = defineCmssyRouteConfig;
839
1020
  exports.handleBlockDataRequest = handleBlockDataRequest;
1021
+ exports.loadCmssyRoute = loadCmssyRoute;
840
1022
  exports.parseBlockDataRequest = parseBlockDataRequest;
841
1023
  exports.resolveBlockDataRequest = resolveBlockDataRequest;
842
1024
  exports.resolveCmssyLayout = resolveCmssyLayout;
package/dist/index.d.cts CHANGED
@@ -7,6 +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, d as defineCmssyRouteConfig, l as loadCmssyRoute } from './load-cmssy-route-DsAVTbis.cjs';
10
11
  export { CmssyBlockDataHandlerOptions, CmssyBlockDataRequest, CmssyBlockDataRequestBlock, CmssyBlockDataRequestPage, CmssyBlockDataResult, ResolveBlockDataRequestOptions, createBlockDataHandler, handleBlockDataRequest, parseBlockDataRequest, resolveBlockDataRequest } from './internal-server.cjs';
11
12
 
12
13
  interface CmssyServerPageProps {
@@ -101,6 +102,41 @@ interface CmssyServerLayoutProps {
101
102
  }
102
103
  declare function CmssyServerLayout({ groups, blocks, region, page, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, preview, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
103
104
 
105
+ interface CmssyBlocksProps {
106
+ page: CmssyPageData | null;
107
+ blocks: BlockDefinition[];
108
+ locale: string;
109
+ defaultLocale: string;
110
+ enabledLocales?: string[];
111
+ blockData?: Record<string, unknown>;
112
+ blockContent?: Record<string, Record<string, unknown>>;
113
+ pageContext?: CmssyBlockPage;
114
+ forms?: Record<string, CmssyFormDefinition>;
115
+ auth?: CmssyBlockAuthContext;
116
+ workspace?: CmssyBlockWorkspace;
117
+ appContext?: Record<string, unknown>;
118
+ isPreview?: boolean;
119
+ editMode?: boolean;
120
+ }
121
+ declare function CmssyBlocks({ page, blocks, locale, defaultLocale, enabledLocales, blockData, blockContent, pageContext, forms, auth, workspace, appContext, isPreview, editMode, }: CmssyBlocksProps): react_jsx_runtime.JSX.Element | null;
122
+
123
+ interface CmssyLayoutRegionProps {
124
+ groups: CmssyLayoutGroup[];
125
+ region: string;
126
+ blocks: BlockDefinition[];
127
+ locale: string;
128
+ defaultLocale: string;
129
+ enabledLocales?: string[];
130
+ page?: CmssyBlockPage;
131
+ blockData?: Record<string, unknown>;
132
+ blockContent?: Record<string, Record<string, unknown>>;
133
+ forms?: Record<string, CmssyFormDefinition>;
134
+ appContext?: Record<string, unknown>;
135
+ isPreview?: boolean;
136
+ editMode?: boolean;
137
+ }
138
+ declare function CmssyLayoutRegion({ groups, region, blocks, locale, defaultLocale, enabledLocales, page, blockData, blockContent, forms, appContext, isPreview, editMode, }: CmssyLayoutRegionProps): react_jsx_runtime.JSX.Element | null;
139
+
104
140
  interface CmssyBlockProps {
105
141
  block: RawBlock;
106
142
  locale: string;
@@ -124,4 +160,4 @@ interface UnknownBlockProps {
124
160
  }
125
161
  declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
126
162
 
127
- export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, type CmssyLayoutEditableProps, type CmssyLayoutResolution, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, LayoutBlockPage, type ResolveCmssyLayoutOptions, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayout, resolveCmssyLayoutSlot };
163
+ export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyBlocks, type CmssyBlocksProps, type CmssyLayoutEditableProps, CmssyLayoutRegion, type CmssyLayoutRegionProps, type CmssyLayoutResolution, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, LayoutBlockPage, type ResolveCmssyLayoutOptions, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayout, resolveCmssyLayoutSlot };
package/dist/index.d.ts CHANGED
@@ -7,6 +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, d as defineCmssyRouteConfig, l as loadCmssyRoute } from './load-cmssy-route-NxeXEvZS.js';
10
11
  export { CmssyBlockDataHandlerOptions, CmssyBlockDataRequest, CmssyBlockDataRequestBlock, CmssyBlockDataRequestPage, CmssyBlockDataResult, ResolveBlockDataRequestOptions, createBlockDataHandler, handleBlockDataRequest, parseBlockDataRequest, resolveBlockDataRequest } from './internal-server.js';
11
12
 
12
13
  interface CmssyServerPageProps {
@@ -101,6 +102,41 @@ interface CmssyServerLayoutProps {
101
102
  }
102
103
  declare function CmssyServerLayout({ groups, blocks, region, page, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, preview, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
103
104
 
105
+ interface CmssyBlocksProps {
106
+ page: CmssyPageData | null;
107
+ blocks: BlockDefinition[];
108
+ locale: string;
109
+ defaultLocale: string;
110
+ enabledLocales?: string[];
111
+ blockData?: Record<string, unknown>;
112
+ blockContent?: Record<string, Record<string, unknown>>;
113
+ pageContext?: CmssyBlockPage;
114
+ forms?: Record<string, CmssyFormDefinition>;
115
+ auth?: CmssyBlockAuthContext;
116
+ workspace?: CmssyBlockWorkspace;
117
+ appContext?: Record<string, unknown>;
118
+ isPreview?: boolean;
119
+ editMode?: boolean;
120
+ }
121
+ declare function CmssyBlocks({ page, blocks, locale, defaultLocale, enabledLocales, blockData, blockContent, pageContext, forms, auth, workspace, appContext, isPreview, editMode, }: CmssyBlocksProps): react_jsx_runtime.JSX.Element | null;
122
+
123
+ interface CmssyLayoutRegionProps {
124
+ groups: CmssyLayoutGroup[];
125
+ region: string;
126
+ blocks: BlockDefinition[];
127
+ locale: string;
128
+ defaultLocale: string;
129
+ enabledLocales?: string[];
130
+ page?: CmssyBlockPage;
131
+ blockData?: Record<string, unknown>;
132
+ blockContent?: Record<string, Record<string, unknown>>;
133
+ forms?: Record<string, CmssyFormDefinition>;
134
+ appContext?: Record<string, unknown>;
135
+ isPreview?: boolean;
136
+ editMode?: boolean;
137
+ }
138
+ declare function CmssyLayoutRegion({ groups, region, blocks, locale, defaultLocale, enabledLocales, page, blockData, blockContent, forms, appContext, isPreview, editMode, }: CmssyLayoutRegionProps): react_jsx_runtime.JSX.Element | null;
139
+
104
140
  interface CmssyBlockProps {
105
141
  block: RawBlock;
106
142
  locale: string;
@@ -124,4 +160,4 @@ interface UnknownBlockProps {
124
160
  }
125
161
  declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
126
162
 
127
- export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, type CmssyLayoutEditableProps, type CmssyLayoutResolution, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, LayoutBlockPage, type ResolveCmssyLayoutOptions, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayout, resolveCmssyLayoutSlot };
163
+ export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyBlocks, type CmssyBlocksProps, type CmssyLayoutEditableProps, CmssyLayoutRegion, type CmssyLayoutRegionProps, type CmssyLayoutResolution, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, LayoutBlockPage, type ResolveCmssyLayoutOptions, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayout, resolveCmssyLayoutSlot };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { blocksToSchemas, resolveEditorOrigin, verifyCmssyEditToken, CMSSY_EDIT_TOKEN_HEADER } from '@cmssy/core';
2
2
  export { CmssyRequestError, PROTOCOL_VERSION, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
3
- import { buildBlockContext, fetchLayouts, normalizeBlockContent, asBucket, resolveSiteLocales as resolveSiteLocales$1, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
3
+ import { buildBlockContext, fetchLayouts, normalizeBlockContent, asBucket, layoutRegionIds, fetchPage, resolveSiteLocales as resolveSiteLocales$1, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
4
4
  export { buildBlockContext } from '@cmssy/core/internal';
5
5
  import { createElement } from 'react';
6
6
  import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
@@ -639,6 +639,184 @@ function CmssyBlock({
639
639
  )
640
640
  );
641
641
  }
642
+ function CmssyBlocks({
643
+ page,
644
+ blocks,
645
+ locale,
646
+ defaultLocale,
647
+ enabledLocales,
648
+ blockData,
649
+ blockContent,
650
+ pageContext,
651
+ forms,
652
+ auth,
653
+ workspace,
654
+ appContext,
655
+ isPreview = false,
656
+ editMode = false
657
+ }) {
658
+ if (!page) return null;
659
+ const blockMap = buildBlockMap(blocks);
660
+ const context = buildBlockContext(
661
+ locale,
662
+ defaultLocale,
663
+ enabledLocales,
664
+ isPreview,
665
+ forms,
666
+ { page: pageContext, auth, workspace, app: appContext }
667
+ );
668
+ return /* @__PURE__ */ jsx(Fragment, { children: (page.blocks ?? []).map((block) => /* @__PURE__ */ jsx(
669
+ CmssyBlock,
670
+ {
671
+ block,
672
+ blockMap,
673
+ locale,
674
+ defaultLocale,
675
+ context,
676
+ editMode,
677
+ resolvedContent: blockContent?.[block.id],
678
+ data: blockData?.[block.id]
679
+ },
680
+ block.id
681
+ )) });
682
+ }
683
+ function CmssyLayoutRegion({
684
+ groups,
685
+ region,
686
+ blocks,
687
+ locale,
688
+ defaultLocale,
689
+ enabledLocales,
690
+ page,
691
+ blockData,
692
+ blockContent,
693
+ forms,
694
+ appContext,
695
+ isPreview = false,
696
+ editMode = false
697
+ }) {
698
+ const group = groups.find((candidate) => candidate.region === region);
699
+ const regionBlocks = group ? group.blocks.filter((block) => block.isActive !== false).slice().sort((a, b) => (a.order ?? 0) - (b.order ?? 0)) : [];
700
+ if (regionBlocks.length === 0) return null;
701
+ const blockMap = buildBlockMap(blocks);
702
+ const context = buildBlockContext(
703
+ locale,
704
+ defaultLocale,
705
+ enabledLocales,
706
+ isPreview,
707
+ forms,
708
+ { page, app: appContext }
709
+ );
710
+ return /* @__PURE__ */ jsx(Fragment, { children: regionBlocks.map((block) => /* @__PURE__ */ jsx(
711
+ CmssyBlock,
712
+ {
713
+ block,
714
+ blockMap,
715
+ locale,
716
+ defaultLocale,
717
+ context,
718
+ layoutRegion: region,
719
+ editMode,
720
+ resolvedContent: blockContent?.[block.id],
721
+ data: blockData?.[block.id]
722
+ },
723
+ block.id
724
+ )) });
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
+ }
751
+ async function loadCmssyRoute(config, options) {
752
+ const {
753
+ blocks,
754
+ path,
755
+ locale,
756
+ forms,
757
+ appContext,
758
+ previewSecret,
759
+ isPreview = false,
760
+ retry,
761
+ fetch: fetchImpl
762
+ } = options;
763
+ const regions = options.regions ?? layoutRegionIds(config.layout);
764
+ const firstRegion = regions[0] ?? "header";
765
+ const slot = await resolveCmssyLayoutSlot(config, {
766
+ region: firstRegion,
767
+ blocks,
768
+ editMode: false,
769
+ preview: isPreview,
770
+ forms,
771
+ appContext,
772
+ retry,
773
+ ...fetchImpl ? { fetch: fetchImpl } : {},
774
+ path: path ?? [],
775
+ ...locale === void 0 ? {} : { locale }
776
+ });
777
+ const secret = previewSecret ?? (isPreview ? config.draftSecret : void 0);
778
+ const page = await fetchPage(config, slot.path, {
779
+ ...secret ? { previewSecret: secret } : {},
780
+ ...retry === void 0 ? {} : { retry },
781
+ ...fetchImpl ? { fetch: fetchImpl } : {}
782
+ });
783
+ const shared = {
784
+ blocks,
785
+ locale: slot.locale,
786
+ defaultLocale: slot.defaultLocale,
787
+ enabledLocales: slot.enabledLocales,
788
+ forms,
789
+ isPreview,
790
+ config,
791
+ appContext
792
+ };
793
+ const [pageBlocks, ...layoutBlocks] = await Promise.all([
794
+ resolveEditorBlockData({ ...shared, page }),
795
+ ...regions.map(
796
+ (region) => resolveEditorLayoutBlockData({
797
+ ...shared,
798
+ groups: slot.groups,
799
+ page: slot.page,
800
+ region
801
+ })
802
+ )
803
+ ]);
804
+ return {
805
+ page,
806
+ layouts: slot.groups,
807
+ pageContext: slot.page,
808
+ locale: slot.locale,
809
+ defaultLocale: slot.defaultLocale,
810
+ enabledLocales: slot.enabledLocales,
811
+ path: slot.path,
812
+ blockData: pageBlocks.data,
813
+ blockContent: pageBlocks.content,
814
+ layoutData: Object.fromEntries(
815
+ regions.map((region, index) => [region, layoutBlocks[index]])
816
+ ),
817
+ regions
818
+ };
819
+ }
642
820
  var MAX_BLOCKS = 50;
643
821
  function parseBlockDataRequest(body) {
644
822
  if (typeof body !== "object" || body === null) {
@@ -773,4 +951,4 @@ function createBlockDataHandler(config, blocks, options = {}) {
773
951
  };
774
952
  }
775
953
 
776
- export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, createBlockDataHandler, defineBlock, handleBlockDataRequest, 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 };
@@ -0,0 +1,35 @@
1
+ import { CmssyLayout, CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, CmssyFormDefinition, RetryOption, FetchLike } from '@cmssy/core';
2
+ import { E as EditorBlockData, B as BlockDefinition } from './resolve-block-data-Bkracpae.cjs';
3
+
4
+ type CmssyRouteConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>, "draftSecret"> & {
5
+ draftSecret?: string;
6
+ };
7
+ declare function defineCmssyRouteConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyRouteConfig<L>): CmssyRouteConfig<L>;
8
+ interface LoadCmssyRouteOptions {
9
+ blocks: BlockDefinition[];
10
+ path?: string[];
11
+ locale?: string;
12
+ regions?: string[];
13
+ forms?: Record<string, CmssyFormDefinition>;
14
+ appContext?: Record<string, unknown>;
15
+ previewSecret?: string;
16
+ isPreview?: boolean;
17
+ retry?: RetryOption;
18
+ fetch?: FetchLike;
19
+ }
20
+ interface CmssyRouteData {
21
+ page: CmssyPageData | null;
22
+ layouts: CmssyLayoutGroup[];
23
+ pageContext: CmssyBlockPage;
24
+ locale: string;
25
+ defaultLocale: string;
26
+ enabledLocales: string[];
27
+ path: string[];
28
+ blockData: Record<string, unknown>;
29
+ blockContent: Record<string, Record<string, unknown>>;
30
+ layoutData: Record<string, EditorBlockData>;
31
+ regions: string[];
32
+ }
33
+ declare function loadCmssyRoute(config: CmssyRouteConfig, options: LoadCmssyRouteOptions): Promise<CmssyRouteData>;
34
+
35
+ export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, defineCmssyRouteConfig as d, loadCmssyRoute as l };
@@ -0,0 +1,35 @@
1
+ import { CmssyLayout, CmssyConfig, CmssyPageData, CmssyLayoutGroup, CmssyBlockPage, CmssyFormDefinition, RetryOption, FetchLike } from '@cmssy/core';
2
+ import { E as EditorBlockData, B as BlockDefinition } from './resolve-block-data-Bkracpae.js';
3
+
4
+ type CmssyRouteConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>, "draftSecret"> & {
5
+ draftSecret?: string;
6
+ };
7
+ declare function defineCmssyRouteConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyRouteConfig<L>): CmssyRouteConfig<L>;
8
+ interface LoadCmssyRouteOptions {
9
+ blocks: BlockDefinition[];
10
+ path?: string[];
11
+ locale?: string;
12
+ regions?: string[];
13
+ forms?: Record<string, CmssyFormDefinition>;
14
+ appContext?: Record<string, unknown>;
15
+ previewSecret?: string;
16
+ isPreview?: boolean;
17
+ retry?: RetryOption;
18
+ fetch?: FetchLike;
19
+ }
20
+ interface CmssyRouteData {
21
+ page: CmssyPageData | null;
22
+ layouts: CmssyLayoutGroup[];
23
+ pageContext: CmssyBlockPage;
24
+ locale: string;
25
+ defaultLocale: string;
26
+ enabledLocales: string[];
27
+ path: string[];
28
+ blockData: Record<string, unknown>;
29
+ blockContent: Record<string, Record<string, unknown>>;
30
+ layoutData: Record<string, EditorBlockData>;
31
+ regions: string[];
32
+ }
33
+ declare function loadCmssyRoute(config: CmssyRouteConfig, options: LoadCmssyRouteOptions): Promise<CmssyRouteData>;
34
+
35
+ export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, defineCmssyRouteConfig as d, loadCmssyRoute as l };