@cmssy/react 16.9.1 → 16.10.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 +156 -0
- package/dist/index.d.cts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +155 -2
- package/dist/load-cmssy-route-BjUMTpOJ.d.cts +34 -0
- package/dist/load-cmssy-route-C9FPwUSB.d.ts +34 -0
- package/dist/spa.cjs +639 -0
- package/dist/spa.d.cts +33 -0
- package/dist/spa.d.ts +33 -0
- package/dist/spa.js +636 -0
- package/package.json +12 -2
package/dist/index.cjs
CHANGED
|
@@ -639,6 +639,159 @@ 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
|
+
async function loadCmssyRoute(config, options) {
|
|
727
|
+
const {
|
|
728
|
+
blocks,
|
|
729
|
+
path,
|
|
730
|
+
locale,
|
|
731
|
+
forms,
|
|
732
|
+
appContext,
|
|
733
|
+
previewSecret,
|
|
734
|
+
isPreview = false,
|
|
735
|
+
retry,
|
|
736
|
+
fetch: fetchImpl
|
|
737
|
+
} = options;
|
|
738
|
+
const regions = options.regions ?? internal.layoutRegionIds(config.layout);
|
|
739
|
+
const firstRegion = regions[0] ?? "header";
|
|
740
|
+
const slot = await resolveCmssyLayoutSlot(config, {
|
|
741
|
+
region: firstRegion,
|
|
742
|
+
blocks,
|
|
743
|
+
editMode: false,
|
|
744
|
+
preview: isPreview,
|
|
745
|
+
forms,
|
|
746
|
+
appContext,
|
|
747
|
+
retry,
|
|
748
|
+
...fetchImpl ? { fetch: fetchImpl } : {},
|
|
749
|
+
path: path ?? [],
|
|
750
|
+
...locale === void 0 ? {} : { locale }
|
|
751
|
+
});
|
|
752
|
+
const secret = previewSecret ?? (isPreview ? config.draftSecret : void 0);
|
|
753
|
+
const page = await internal.fetchPage(config, slot.path, {
|
|
754
|
+
...secret ? { previewSecret: secret } : {},
|
|
755
|
+
...retry === void 0 ? {} : { retry },
|
|
756
|
+
...fetchImpl ? { fetch: fetchImpl } : {}
|
|
757
|
+
});
|
|
758
|
+
const shared = {
|
|
759
|
+
blocks,
|
|
760
|
+
locale: slot.locale,
|
|
761
|
+
defaultLocale: slot.defaultLocale,
|
|
762
|
+
enabledLocales: slot.enabledLocales,
|
|
763
|
+
forms,
|
|
764
|
+
isPreview,
|
|
765
|
+
config,
|
|
766
|
+
appContext
|
|
767
|
+
};
|
|
768
|
+
const [pageBlocks, ...layoutBlocks] = await Promise.all([
|
|
769
|
+
resolveEditorBlockData({ ...shared, page }),
|
|
770
|
+
...regions.map(
|
|
771
|
+
(region) => resolveEditorLayoutBlockData({
|
|
772
|
+
...shared,
|
|
773
|
+
groups: slot.groups,
|
|
774
|
+
page: slot.page,
|
|
775
|
+
region
|
|
776
|
+
})
|
|
777
|
+
)
|
|
778
|
+
]);
|
|
779
|
+
return {
|
|
780
|
+
page,
|
|
781
|
+
layouts: slot.groups,
|
|
782
|
+
pageContext: slot.page,
|
|
783
|
+
locale: slot.locale,
|
|
784
|
+
defaultLocale: slot.defaultLocale,
|
|
785
|
+
enabledLocales: slot.enabledLocales,
|
|
786
|
+
path: slot.path,
|
|
787
|
+
blockData: pageBlocks.data,
|
|
788
|
+
blockContent: pageBlocks.content,
|
|
789
|
+
layoutData: Object.fromEntries(
|
|
790
|
+
regions.map((region, index) => [region, layoutBlocks[index]])
|
|
791
|
+
),
|
|
792
|
+
regions
|
|
793
|
+
};
|
|
794
|
+
}
|
|
642
795
|
var MAX_BLOCKS = 50;
|
|
643
796
|
function parseBlockDataRequest(body) {
|
|
644
797
|
if (typeof body !== "object" || body === null) {
|
|
@@ -830,6 +983,8 @@ Object.defineProperty(exports, "buildBlockContext", {
|
|
|
830
983
|
get: function () { return internal.buildBlockContext; }
|
|
831
984
|
});
|
|
832
985
|
exports.CmssyBlock = CmssyBlock;
|
|
986
|
+
exports.CmssyBlocks = CmssyBlocks;
|
|
987
|
+
exports.CmssyLayoutRegion = CmssyLayoutRegion;
|
|
833
988
|
exports.CmssyServerLayout = CmssyServerLayout;
|
|
834
989
|
exports.CmssyServerPage = CmssyServerPage;
|
|
835
990
|
exports.UnknownBlock = UnknownBlock;
|
|
@@ -837,6 +992,7 @@ exports.buildBlockMap = buildBlockMap;
|
|
|
837
992
|
exports.createBlockDataHandler = createBlockDataHandler;
|
|
838
993
|
exports.defineBlock = defineBlock;
|
|
839
994
|
exports.handleBlockDataRequest = handleBlockDataRequest;
|
|
995
|
+
exports.loadCmssyRoute = loadCmssyRoute;
|
|
840
996
|
exports.parseBlockDataRequest = parseBlockDataRequest;
|
|
841
997
|
exports.resolveBlockDataRequest = resolveBlockDataRequest;
|
|
842
998
|
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, l as loadCmssyRoute } from './load-cmssy-route-BjUMTpOJ.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, l as loadCmssyRoute } from './load-cmssy-route-C9FPwUSB.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,159 @@ 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
|
+
async function loadCmssyRoute(config, options) {
|
|
727
|
+
const {
|
|
728
|
+
blocks,
|
|
729
|
+
path,
|
|
730
|
+
locale,
|
|
731
|
+
forms,
|
|
732
|
+
appContext,
|
|
733
|
+
previewSecret,
|
|
734
|
+
isPreview = false,
|
|
735
|
+
retry,
|
|
736
|
+
fetch: fetchImpl
|
|
737
|
+
} = options;
|
|
738
|
+
const regions = options.regions ?? layoutRegionIds(config.layout);
|
|
739
|
+
const firstRegion = regions[0] ?? "header";
|
|
740
|
+
const slot = await resolveCmssyLayoutSlot(config, {
|
|
741
|
+
region: firstRegion,
|
|
742
|
+
blocks,
|
|
743
|
+
editMode: false,
|
|
744
|
+
preview: isPreview,
|
|
745
|
+
forms,
|
|
746
|
+
appContext,
|
|
747
|
+
retry,
|
|
748
|
+
...fetchImpl ? { fetch: fetchImpl } : {},
|
|
749
|
+
path: path ?? [],
|
|
750
|
+
...locale === void 0 ? {} : { locale }
|
|
751
|
+
});
|
|
752
|
+
const secret = previewSecret ?? (isPreview ? config.draftSecret : void 0);
|
|
753
|
+
const page = await fetchPage(config, slot.path, {
|
|
754
|
+
...secret ? { previewSecret: secret } : {},
|
|
755
|
+
...retry === void 0 ? {} : { retry },
|
|
756
|
+
...fetchImpl ? { fetch: fetchImpl } : {}
|
|
757
|
+
});
|
|
758
|
+
const shared = {
|
|
759
|
+
blocks,
|
|
760
|
+
locale: slot.locale,
|
|
761
|
+
defaultLocale: slot.defaultLocale,
|
|
762
|
+
enabledLocales: slot.enabledLocales,
|
|
763
|
+
forms,
|
|
764
|
+
isPreview,
|
|
765
|
+
config,
|
|
766
|
+
appContext
|
|
767
|
+
};
|
|
768
|
+
const [pageBlocks, ...layoutBlocks] = await Promise.all([
|
|
769
|
+
resolveEditorBlockData({ ...shared, page }),
|
|
770
|
+
...regions.map(
|
|
771
|
+
(region) => resolveEditorLayoutBlockData({
|
|
772
|
+
...shared,
|
|
773
|
+
groups: slot.groups,
|
|
774
|
+
page: slot.page,
|
|
775
|
+
region
|
|
776
|
+
})
|
|
777
|
+
)
|
|
778
|
+
]);
|
|
779
|
+
return {
|
|
780
|
+
page,
|
|
781
|
+
layouts: slot.groups,
|
|
782
|
+
pageContext: slot.page,
|
|
783
|
+
locale: slot.locale,
|
|
784
|
+
defaultLocale: slot.defaultLocale,
|
|
785
|
+
enabledLocales: slot.enabledLocales,
|
|
786
|
+
path: slot.path,
|
|
787
|
+
blockData: pageBlocks.data,
|
|
788
|
+
blockContent: pageBlocks.content,
|
|
789
|
+
layoutData: Object.fromEntries(
|
|
790
|
+
regions.map((region, index) => [region, layoutBlocks[index]])
|
|
791
|
+
),
|
|
792
|
+
regions
|
|
793
|
+
};
|
|
794
|
+
}
|
|
642
795
|
var MAX_BLOCKS = 50;
|
|
643
796
|
function parseBlockDataRequest(body) {
|
|
644
797
|
if (typeof body !== "object" || body === null) {
|
|
@@ -773,4 +926,4 @@ function createBlockDataHandler(config, blocks, options = {}) {
|
|
|
773
926
|
};
|
|
774
927
|
}
|
|
775
928
|
|
|
776
|
-
export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, createBlockDataHandler, defineBlock, handleBlockDataRequest, parseBlockDataRequest, resolveBlockDataRequest, resolveCmssyLayout, resolveCmssyLayoutSlot, resolveEditorBlockData, resolveEditorLayoutBlockData };
|
|
929
|
+
export { CmssyBlock, CmssyBlocks, CmssyLayoutRegion, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, createBlockDataHandler, defineBlock, handleBlockDataRequest, loadCmssyRoute, parseBlockDataRequest, resolveBlockDataRequest, resolveCmssyLayout, resolveCmssyLayoutSlot, resolveEditorBlockData, resolveEditorLayoutBlockData };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { 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 = Omit<CmssyConfig, "draftSecret"> & {
|
|
5
|
+
draftSecret?: string;
|
|
6
|
+
};
|
|
7
|
+
interface LoadCmssyRouteOptions {
|
|
8
|
+
blocks: BlockDefinition[];
|
|
9
|
+
path?: string[];
|
|
10
|
+
locale?: string;
|
|
11
|
+
regions?: string[];
|
|
12
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
13
|
+
appContext?: Record<string, unknown>;
|
|
14
|
+
previewSecret?: string;
|
|
15
|
+
isPreview?: boolean;
|
|
16
|
+
retry?: RetryOption;
|
|
17
|
+
fetch?: FetchLike;
|
|
18
|
+
}
|
|
19
|
+
interface CmssyRouteData {
|
|
20
|
+
page: CmssyPageData | null;
|
|
21
|
+
layouts: CmssyLayoutGroup[];
|
|
22
|
+
pageContext: CmssyBlockPage;
|
|
23
|
+
locale: string;
|
|
24
|
+
defaultLocale: string;
|
|
25
|
+
enabledLocales: string[];
|
|
26
|
+
path: string[];
|
|
27
|
+
blockData: Record<string, unknown>;
|
|
28
|
+
blockContent: Record<string, Record<string, unknown>>;
|
|
29
|
+
layoutData: Record<string, EditorBlockData>;
|
|
30
|
+
regions: string[];
|
|
31
|
+
}
|
|
32
|
+
declare function loadCmssyRoute(config: CmssyRouteConfig, options: LoadCmssyRouteOptions): Promise<CmssyRouteData>;
|
|
33
|
+
|
|
34
|
+
export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, loadCmssyRoute as l };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { 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 = Omit<CmssyConfig, "draftSecret"> & {
|
|
5
|
+
draftSecret?: string;
|
|
6
|
+
};
|
|
7
|
+
interface LoadCmssyRouteOptions {
|
|
8
|
+
blocks: BlockDefinition[];
|
|
9
|
+
path?: string[];
|
|
10
|
+
locale?: string;
|
|
11
|
+
regions?: string[];
|
|
12
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
13
|
+
appContext?: Record<string, unknown>;
|
|
14
|
+
previewSecret?: string;
|
|
15
|
+
isPreview?: boolean;
|
|
16
|
+
retry?: RetryOption;
|
|
17
|
+
fetch?: FetchLike;
|
|
18
|
+
}
|
|
19
|
+
interface CmssyRouteData {
|
|
20
|
+
page: CmssyPageData | null;
|
|
21
|
+
layouts: CmssyLayoutGroup[];
|
|
22
|
+
pageContext: CmssyBlockPage;
|
|
23
|
+
locale: string;
|
|
24
|
+
defaultLocale: string;
|
|
25
|
+
enabledLocales: string[];
|
|
26
|
+
path: string[];
|
|
27
|
+
blockData: Record<string, unknown>;
|
|
28
|
+
blockContent: Record<string, Record<string, unknown>>;
|
|
29
|
+
layoutData: Record<string, EditorBlockData>;
|
|
30
|
+
regions: string[];
|
|
31
|
+
}
|
|
32
|
+
declare function loadCmssyRoute(config: CmssyRouteConfig, options: LoadCmssyRouteOptions): Promise<CmssyRouteData>;
|
|
33
|
+
|
|
34
|
+
export { type CmssyRouteConfig as C, type LoadCmssyRouteOptions as L, type CmssyRouteData as a, loadCmssyRoute as l };
|