@cmssy/react 9.10.0 → 10.1.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 +9 -727
- package/dist/client.d.cts +4 -82
- package/dist/client.d.ts +4 -82
- package/dist/client.js +4 -696
- package/dist/index.cjs +15 -222
- package/dist/index.d.cts +8 -38
- package/dist/index.d.ts +8 -38
- package/dist/index.js +4 -105
- package/dist/internal-server.cjs +166 -0
- package/dist/internal-server.d.cts +37 -0
- package/dist/internal-server.d.ts +37 -0
- package/dist/internal-server.js +161 -0
- package/dist/internal.cjs +19 -0
- package/dist/internal.d.cts +18 -0
- package/dist/internal.d.ts +18 -0
- package/dist/internal.js +16 -0
- package/dist/{registry-Bfq4Pq18.d.cts → registry-zeNh3t6y.d.cts} +2 -6
- package/dist/{registry-Bfq4Pq18.d.ts → registry-zeNh3t6y.d.ts} +2 -6
- package/package.json +12 -2
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@cmssy/core');
|
|
4
|
+
var internal = require('@cmssy/core/internal');
|
|
4
5
|
var react = require('react');
|
|
5
6
|
var blockErrorBoundary = require('@cmssy/react/block-error-boundary');
|
|
6
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
var types = require('@cmssy/types');
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
10
|
|
|
@@ -35,20 +35,6 @@ function blocksToSchemas(blocks) {
|
|
|
35
35
|
}
|
|
36
36
|
return out;
|
|
37
37
|
}
|
|
38
|
-
function blocksToMeta(blocks, defaults = {}) {
|
|
39
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
40
|
-
for (const block of blocks) {
|
|
41
|
-
const category = block.category ?? defaults.category;
|
|
42
|
-
out[block.type] = {
|
|
43
|
-
label: block.label ?? block.type,
|
|
44
|
-
...category ? { category } : {},
|
|
45
|
-
...block.icon ? { icon: block.icon } : {},
|
|
46
|
-
...block.layoutPositions ? { layoutPositions: block.layoutPositions } : {},
|
|
47
|
-
...block.description ? { description: block.description } : {}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return out;
|
|
51
|
-
}
|
|
52
38
|
|
|
53
39
|
// src/components/block-error.ts
|
|
54
40
|
var BLOCK_ERROR_KEY = "__cmssyBlockError";
|
|
@@ -66,9 +52,6 @@ function unregisteredBlockError(type) {
|
|
|
66
52
|
message: `Block type "${type}" is not registered in this site's blocks array.`
|
|
67
53
|
};
|
|
68
54
|
}
|
|
69
|
-
function markBlockError(error) {
|
|
70
|
-
return { [BLOCK_ERROR_KEY]: error };
|
|
71
|
-
}
|
|
72
55
|
function readBlockError(value) {
|
|
73
56
|
if (typeof value !== "object" || value === null) return void 0;
|
|
74
57
|
const marked = value[BLOCK_ERROR_KEY];
|
|
@@ -175,7 +158,7 @@ function renderResolvedBlock(block, map, locale, defaultLocale, options = {}) {
|
|
|
175
158
|
)
|
|
176
159
|
);
|
|
177
160
|
}
|
|
178
|
-
const content = resolvedContent ??
|
|
161
|
+
const content = resolvedContent ?? internal.getBlockContentForLanguage(
|
|
179
162
|
block.content,
|
|
180
163
|
locale,
|
|
181
164
|
defaultLocale,
|
|
@@ -190,8 +173,8 @@ function renderResolvedBlock(block, map, locale, defaultLocale, options = {}) {
|
|
|
190
173
|
editMode,
|
|
191
174
|
children: react.createElement(Component, {
|
|
192
175
|
content,
|
|
193
|
-
style:
|
|
194
|
-
advanced:
|
|
176
|
+
style: internal.asBucket(block.style),
|
|
177
|
+
advanced: internal.asBucket(block.advanced),
|
|
195
178
|
context,
|
|
196
179
|
data
|
|
197
180
|
})
|
|
@@ -201,7 +184,7 @@ function renderResolvedBlock(block, map, locale, defaultLocale, options = {}) {
|
|
|
201
184
|
}
|
|
202
185
|
async function resolveBlocks(blocks, loaderMap, locale, defaultLocale, context, enabledLocales, options) {
|
|
203
186
|
const contents = blocks.map(
|
|
204
|
-
(block) =>
|
|
187
|
+
(block) => internal.getBlockContentForLanguage(
|
|
205
188
|
block.content,
|
|
206
189
|
locale,
|
|
207
190
|
defaultLocale,
|
|
@@ -209,7 +192,7 @@ async function resolveBlocks(blocks, loaderMap, locale, defaultLocale, context,
|
|
|
209
192
|
)
|
|
210
193
|
);
|
|
211
194
|
if (options?.config && options.schemas) {
|
|
212
|
-
await
|
|
195
|
+
await internal.resolveRelationContent(
|
|
213
196
|
options.config,
|
|
214
197
|
blocks.map((block, i) => ({ type: block.type, content: contents[i] })),
|
|
215
198
|
options.schemas,
|
|
@@ -249,7 +232,7 @@ async function resolveRenderLocale({
|
|
|
249
232
|
}) {
|
|
250
233
|
if (locale && defaultLocale) return { locale, defaultLocale, enabledLocales };
|
|
251
234
|
if (config) {
|
|
252
|
-
const site = await
|
|
235
|
+
const site = await internal.resolveSiteLocales(config);
|
|
253
236
|
return {
|
|
254
237
|
locale: locale ?? defaultLocale ?? site.defaultLocale,
|
|
255
238
|
defaultLocale: defaultLocale ?? site.defaultLocale,
|
|
@@ -289,7 +272,7 @@ async function CmssyServerPage({
|
|
|
289
272
|
});
|
|
290
273
|
const map = buildBlockMap(blocks);
|
|
291
274
|
const loaderMap = buildLoaderMap(blocks);
|
|
292
|
-
const context =
|
|
275
|
+
const context = internal.buildBlockContext(
|
|
293
276
|
locale,
|
|
294
277
|
defaultLocale,
|
|
295
278
|
enabledLocales,
|
|
@@ -317,90 +300,6 @@ async function CmssyServerPage({
|
|
|
317
300
|
})
|
|
318
301
|
) });
|
|
319
302
|
}
|
|
320
|
-
function collectBlockData(blocks, resolved, isPreview) {
|
|
321
|
-
const data = {};
|
|
322
|
-
const content = {};
|
|
323
|
-
blocks.forEach((block, index) => {
|
|
324
|
-
const entry = resolved[index];
|
|
325
|
-
if (!entry) return;
|
|
326
|
-
content[block.id] = entry.content;
|
|
327
|
-
if (entry.error && isPreview) {
|
|
328
|
-
data[block.id] = markBlockError(entry.error);
|
|
329
|
-
} else if (entry.data !== void 0) {
|
|
330
|
-
data[block.id] = entry.data;
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
return { data, content };
|
|
334
|
-
}
|
|
335
|
-
async function resolveEditorBlockData({
|
|
336
|
-
page,
|
|
337
|
-
blocks,
|
|
338
|
-
locale,
|
|
339
|
-
defaultLocale,
|
|
340
|
-
enabledLocales,
|
|
341
|
-
forms,
|
|
342
|
-
isPreview = false,
|
|
343
|
-
config
|
|
344
|
-
}) {
|
|
345
|
-
if (!page) return { data: {}, content: {} };
|
|
346
|
-
const loaderMap = buildLoaderMap(blocks);
|
|
347
|
-
const context = core.buildBlockContext(
|
|
348
|
-
locale,
|
|
349
|
-
defaultLocale,
|
|
350
|
-
enabledLocales,
|
|
351
|
-
isPreview,
|
|
352
|
-
forms
|
|
353
|
-
);
|
|
354
|
-
const resolved = await resolveBlocks(
|
|
355
|
-
page.blocks,
|
|
356
|
-
loaderMap,
|
|
357
|
-
locale,
|
|
358
|
-
defaultLocale,
|
|
359
|
-
context,
|
|
360
|
-
enabledLocales,
|
|
361
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
362
|
-
);
|
|
363
|
-
return collectBlockData(page.blocks, resolved, isPreview);
|
|
364
|
-
}
|
|
365
|
-
async function resolveBlockData(options) {
|
|
366
|
-
return (await resolveEditorBlockData(options)).data;
|
|
367
|
-
}
|
|
368
|
-
async function resolveEditorLayoutBlockData({
|
|
369
|
-
groups,
|
|
370
|
-
blocks,
|
|
371
|
-
position,
|
|
372
|
-
locale,
|
|
373
|
-
defaultLocale,
|
|
374
|
-
enabledLocales,
|
|
375
|
-
forms,
|
|
376
|
-
isPreview = false,
|
|
377
|
-
config
|
|
378
|
-
}) {
|
|
379
|
-
const group = groups.find((g) => g.position === position);
|
|
380
|
-
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive).slice().sort((a, b) => a.order - b.order) : [];
|
|
381
|
-
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
382
|
-
const loaderMap = buildLoaderMap(blocks);
|
|
383
|
-
const context = core.buildBlockContext(
|
|
384
|
-
locale,
|
|
385
|
-
defaultLocale,
|
|
386
|
-
enabledLocales,
|
|
387
|
-
isPreview,
|
|
388
|
-
forms
|
|
389
|
-
);
|
|
390
|
-
const resolved = await resolveBlocks(
|
|
391
|
-
layoutBlocks,
|
|
392
|
-
loaderMap,
|
|
393
|
-
locale,
|
|
394
|
-
defaultLocale,
|
|
395
|
-
context,
|
|
396
|
-
enabledLocales,
|
|
397
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
398
|
-
);
|
|
399
|
-
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
400
|
-
}
|
|
401
|
-
async function resolveLayoutBlockData(options) {
|
|
402
|
-
return (await resolveEditorLayoutBlockData(options)).data;
|
|
403
|
-
}
|
|
404
303
|
async function CmssyServerLayout({
|
|
405
304
|
groups,
|
|
406
305
|
blocks,
|
|
@@ -422,7 +321,7 @@ async function CmssyServerLayout({
|
|
|
422
321
|
if (layoutBlocks.length === 0) return null;
|
|
423
322
|
const map = buildBlockMap(blocks);
|
|
424
323
|
const loaderMap = buildLoaderMap(blocks);
|
|
425
|
-
const context =
|
|
324
|
+
const context = internal.buildBlockContext(locale, defaultLocale, enabledLocales);
|
|
426
325
|
const resolved = await resolveBlocks(
|
|
427
326
|
layoutBlocks,
|
|
428
327
|
loaderMap,
|
|
@@ -498,11 +397,11 @@ function CmssyBlock({
|
|
|
498
397
|
)
|
|
499
398
|
);
|
|
500
399
|
}
|
|
501
|
-
const base = resolvedContent ? { ...resolvedContent } :
|
|
400
|
+
const base = resolvedContent ? { ...resolvedContent } : internal.getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
502
401
|
const content = patchedContent ? { ...base, ...patchedContent } : base;
|
|
503
|
-
if (schema)
|
|
504
|
-
const style = patchedStyle ? { ...
|
|
505
|
-
const advanced = patchedAdvanced ? { ...
|
|
402
|
+
if (schema) internal.normalizeRelationContent(content, schema, resolvedContent);
|
|
403
|
+
const style = patchedStyle ? { ...internal.asBucket(block.style), ...patchedStyle } : internal.asBucket(block.style);
|
|
404
|
+
const advanced = patchedAdvanced ? { ...internal.asBucket(block.advanced), ...patchedAdvanced } : internal.asBucket(block.advanced);
|
|
506
405
|
return wrap(
|
|
507
406
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
508
407
|
blockErrorBoundary.BlockErrorBoundary,
|
|
@@ -526,82 +425,18 @@ Object.defineProperty(exports, "CmssyRequestError", {
|
|
|
526
425
|
enumerable: true,
|
|
527
426
|
get: function () { return core.CmssyRequestError; }
|
|
528
427
|
});
|
|
529
|
-
Object.defineProperty(exports, "DEFAULT_CMSSY_API_URL", {
|
|
530
|
-
enumerable: true,
|
|
531
|
-
get: function () { return core.DEFAULT_CMSSY_API_URL; }
|
|
532
|
-
});
|
|
533
|
-
Object.defineProperty(exports, "FORM_QUERY", {
|
|
534
|
-
enumerable: true,
|
|
535
|
-
get: function () { return core.FORM_QUERY; }
|
|
536
|
-
});
|
|
537
|
-
Object.defineProperty(exports, "MODEL_DEFINITIONS_QUERY", {
|
|
538
|
-
enumerable: true,
|
|
539
|
-
get: function () { return core.MODEL_DEFINITIONS_QUERY; }
|
|
540
|
-
});
|
|
541
|
-
Object.defineProperty(exports, "MODEL_RECORDS_QUERY", {
|
|
542
|
-
enumerable: true,
|
|
543
|
-
get: function () { return core.MODEL_RECORDS_QUERY; }
|
|
544
|
-
});
|
|
545
428
|
Object.defineProperty(exports, "PROTOCOL_VERSION", {
|
|
546
429
|
enumerable: true,
|
|
547
430
|
get: function () { return core.PROTOCOL_VERSION; }
|
|
548
431
|
});
|
|
549
|
-
Object.defineProperty(exports, "SITE_CONFIG_QUERY", {
|
|
550
|
-
enumerable: true,
|
|
551
|
-
get: function () { return core.SITE_CONFIG_QUERY; }
|
|
552
|
-
});
|
|
553
|
-
Object.defineProperty(exports, "SUBMIT_FORM_MUTATION", {
|
|
554
|
-
enumerable: true,
|
|
555
|
-
get: function () { return core.SUBMIT_FORM_MUTATION; }
|
|
556
|
-
});
|
|
557
|
-
Object.defineProperty(exports, "buildBlockContext", {
|
|
558
|
-
enumerable: true,
|
|
559
|
-
get: function () { return core.buildBlockContext; }
|
|
560
|
-
});
|
|
561
|
-
Object.defineProperty(exports, "buildLocaleSwitchHref", {
|
|
562
|
-
enumerable: true,
|
|
563
|
-
get: function () { return core.buildLocaleSwitchHref; }
|
|
564
|
-
});
|
|
565
|
-
Object.defineProperty(exports, "collectFormIds", {
|
|
566
|
-
enumerable: true,
|
|
567
|
-
get: function () { return core.collectFormIds; }
|
|
568
|
-
});
|
|
569
432
|
Object.defineProperty(exports, "createCmssyClient", {
|
|
570
433
|
enumerable: true,
|
|
571
434
|
get: function () { return core.createCmssyClient; }
|
|
572
435
|
});
|
|
573
|
-
Object.defineProperty(exports, "fetchLayouts", {
|
|
574
|
-
enumerable: true,
|
|
575
|
-
get: function () { return core.fetchLayouts; }
|
|
576
|
-
});
|
|
577
|
-
Object.defineProperty(exports, "fetchPage", {
|
|
578
|
-
enumerable: true,
|
|
579
|
-
get: function () { return core.fetchPage; }
|
|
580
|
-
});
|
|
581
|
-
Object.defineProperty(exports, "fetchPageById", {
|
|
582
|
-
enumerable: true,
|
|
583
|
-
get: function () { return core.fetchPageById; }
|
|
584
|
-
});
|
|
585
|
-
Object.defineProperty(exports, "fetchPageMeta", {
|
|
586
|
-
enumerable: true,
|
|
587
|
-
get: function () { return core.fetchPageMeta; }
|
|
588
|
-
});
|
|
589
|
-
Object.defineProperty(exports, "fetchPages", {
|
|
590
|
-
enumerable: true,
|
|
591
|
-
get: function () { return core.fetchPages; }
|
|
592
|
-
});
|
|
593
|
-
Object.defineProperty(exports, "fetchSiteConfig", {
|
|
594
|
-
enumerable: true,
|
|
595
|
-
get: function () { return core.fetchSiteConfig; }
|
|
596
|
-
});
|
|
597
436
|
Object.defineProperty(exports, "fields", {
|
|
598
437
|
enumerable: true,
|
|
599
438
|
get: function () { return core.fields; }
|
|
600
439
|
});
|
|
601
|
-
Object.defineProperty(exports, "getBlockContentForLanguage", {
|
|
602
|
-
enumerable: true,
|
|
603
|
-
get: function () { return core.getBlockContentForLanguage; }
|
|
604
|
-
});
|
|
605
440
|
Object.defineProperty(exports, "graphqlRequest", {
|
|
606
441
|
enumerable: true,
|
|
607
442
|
get: function () { return core.graphqlRequest; }
|
|
@@ -610,22 +445,10 @@ Object.defineProperty(exports, "isProtocolCompatible", {
|
|
|
610
445
|
enumerable: true,
|
|
611
446
|
get: function () { return core.isProtocolCompatible; }
|
|
612
447
|
});
|
|
613
|
-
Object.defineProperty(exports, "localizeHref", {
|
|
614
|
-
enumerable: true,
|
|
615
|
-
get: function () { return core.localizeHref; }
|
|
616
|
-
});
|
|
617
|
-
Object.defineProperty(exports, "localizeHtmlLinks", {
|
|
618
|
-
enumerable: true,
|
|
619
|
-
get: function () { return core.localizeHtmlLinks; }
|
|
620
|
-
});
|
|
621
448
|
Object.defineProperty(exports, "normalizeOrigin", {
|
|
622
449
|
enumerable: true,
|
|
623
450
|
get: function () { return core.normalizeOrigin; }
|
|
624
451
|
});
|
|
625
|
-
Object.defineProperty(exports, "normalizeSlug", {
|
|
626
|
-
enumerable: true,
|
|
627
|
-
get: function () { return core.normalizeSlug; }
|
|
628
|
-
});
|
|
629
452
|
Object.defineProperty(exports, "parseEditorMessage", {
|
|
630
453
|
enumerable: true,
|
|
631
454
|
get: function () { return core.parseEditorMessage; }
|
|
@@ -634,43 +457,13 @@ Object.defineProperty(exports, "postToEditor", {
|
|
|
634
457
|
enumerable: true,
|
|
635
458
|
get: function () { return core.postToEditor; }
|
|
636
459
|
});
|
|
637
|
-
Object.defineProperty(exports, "
|
|
638
|
-
enumerable: true,
|
|
639
|
-
get: function () { return core.resolveApiUrl; }
|
|
640
|
-
});
|
|
641
|
-
Object.defineProperty(exports, "resolveForms", {
|
|
642
|
-
enumerable: true,
|
|
643
|
-
get: function () { return core.resolveForms; }
|
|
644
|
-
});
|
|
645
|
-
Object.defineProperty(exports, "resolvePublicUrl", {
|
|
646
|
-
enumerable: true,
|
|
647
|
-
get: function () { return core.resolvePublicUrl; }
|
|
648
|
-
});
|
|
649
|
-
Object.defineProperty(exports, "resolveSiteLocales", {
|
|
650
|
-
enumerable: true,
|
|
651
|
-
get: function () { return core.resolveSiteLocales; }
|
|
652
|
-
});
|
|
653
|
-
Object.defineProperty(exports, "resolveWorkspaceId", {
|
|
654
|
-
enumerable: true,
|
|
655
|
-
get: function () { return core.resolveWorkspaceId; }
|
|
656
|
-
});
|
|
657
|
-
Object.defineProperty(exports, "splitLocaleFromPath", {
|
|
658
|
-
enumerable: true,
|
|
659
|
-
get: function () { return core.splitLocaleFromPath; }
|
|
660
|
-
});
|
|
661
|
-
Object.defineProperty(exports, "evaluateFieldConditionGroup", {
|
|
460
|
+
Object.defineProperty(exports, "buildBlockContext", {
|
|
662
461
|
enumerable: true,
|
|
663
|
-
get: function () { return
|
|
462
|
+
get: function () { return internal.buildBlockContext; }
|
|
664
463
|
});
|
|
665
464
|
exports.CmssyBlock = CmssyBlock;
|
|
666
465
|
exports.CmssyServerLayout = CmssyServerLayout;
|
|
667
466
|
exports.CmssyServerPage = CmssyServerPage;
|
|
668
467
|
exports.UnknownBlock = UnknownBlock;
|
|
669
|
-
exports.blocksToMeta = blocksToMeta;
|
|
670
|
-
exports.blocksToSchemas = blocksToSchemas;
|
|
671
468
|
exports.buildBlockMap = buildBlockMap;
|
|
672
469
|
exports.defineBlock = defineBlock;
|
|
673
|
-
exports.resolveBlockData = resolveBlockData;
|
|
674
|
-
exports.resolveEditorBlockData = resolveEditorBlockData;
|
|
675
|
-
exports.resolveEditorLayoutBlockData = resolveEditorLayoutBlockData;
|
|
676
|
-
exports.resolveLayoutBlockData = resolveLayoutBlockData;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
-
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage,
|
|
3
|
-
import { B as BlockDefinition, a as BlockMap } from './registry-
|
|
4
|
-
export { b as BlockProps, c as
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRequestError, CmssySiteConfig, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, fields, graphqlRequest, isProtocolCompatible, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
+
import { B as BlockDefinition, a as BlockMap } from './registry-zeNh3t6y.cjs';
|
|
4
|
+
export { b as BlockProps, c as buildBlockMap, d as defineBlock } from './registry-zeNh3t6y.cjs';
|
|
6
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
7
|
-
export { FieldCondition, FieldConditionGroup, FieldConditionLogic
|
|
6
|
+
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
|
+
export { buildBlockContext } from '@cmssy/core/internal';
|
|
8
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
|
+
export { EditorBlockData, ResolveBlockDataOptions, ResolveLayoutBlockDataOptions } from './internal-server.cjs';
|
|
8
10
|
import 'react';
|
|
9
11
|
|
|
10
12
|
interface CmssyServerPageProps {
|
|
@@ -34,38 +36,6 @@ interface CmssyServerPageProps {
|
|
|
34
36
|
*/
|
|
35
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>;
|
|
36
38
|
|
|
37
|
-
interface EditorBlockData {
|
|
38
|
-
data: Record<string, unknown>;
|
|
39
|
-
content: Record<string, Record<string, unknown>>;
|
|
40
|
-
}
|
|
41
|
-
interface ResolveBlockDataOptions {
|
|
42
|
-
page: CmssyPageData | null;
|
|
43
|
-
blocks: BlockDefinition[];
|
|
44
|
-
locale: string;
|
|
45
|
-
defaultLocale: string;
|
|
46
|
-
enabledLocales?: string[];
|
|
47
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
48
|
-
isPreview?: boolean;
|
|
49
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
50
|
-
config?: CmssyClientConfig;
|
|
51
|
-
}
|
|
52
|
-
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
53
|
-
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
54
|
-
interface ResolveLayoutBlockDataOptions {
|
|
55
|
-
groups: CmssyLayoutGroup[];
|
|
56
|
-
blocks: BlockDefinition[];
|
|
57
|
-
position: string;
|
|
58
|
-
locale: string;
|
|
59
|
-
defaultLocale: string;
|
|
60
|
-
enabledLocales?: string[];
|
|
61
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
62
|
-
isPreview?: boolean;
|
|
63
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
64
|
-
config?: CmssyClientConfig;
|
|
65
|
-
}
|
|
66
|
-
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
67
|
-
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
68
|
-
|
|
69
39
|
interface CmssyServerLayoutProps {
|
|
70
40
|
groups: CmssyLayoutGroup[];
|
|
71
41
|
blocks: BlockDefinition[];
|
|
@@ -114,4 +84,4 @@ interface UnknownBlockProps {
|
|
|
114
84
|
}
|
|
115
85
|
declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
|
|
116
86
|
|
|
117
|
-
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps,
|
|
87
|
+
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, UnknownBlock, type UnknownBlockProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
-
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage,
|
|
3
|
-
import { B as BlockDefinition, a as BlockMap } from './registry-
|
|
4
|
-
export { b as BlockProps, c as
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRequestError, CmssySiteConfig, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, fields, graphqlRequest, isProtocolCompatible, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
+
import { B as BlockDefinition, a as BlockMap } from './registry-zeNh3t6y.js';
|
|
4
|
+
export { b as BlockProps, c as buildBlockMap, d as defineBlock } from './registry-zeNh3t6y.js';
|
|
6
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
7
|
-
export { FieldCondition, FieldConditionGroup, FieldConditionLogic
|
|
6
|
+
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
|
+
export { buildBlockContext } from '@cmssy/core/internal';
|
|
8
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
|
+
export { EditorBlockData, ResolveBlockDataOptions, ResolveLayoutBlockDataOptions } from './internal-server.js';
|
|
8
10
|
import 'react';
|
|
9
11
|
|
|
10
12
|
interface CmssyServerPageProps {
|
|
@@ -34,38 +36,6 @@ interface CmssyServerPageProps {
|
|
|
34
36
|
*/
|
|
35
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>;
|
|
36
38
|
|
|
37
|
-
interface EditorBlockData {
|
|
38
|
-
data: Record<string, unknown>;
|
|
39
|
-
content: Record<string, Record<string, unknown>>;
|
|
40
|
-
}
|
|
41
|
-
interface ResolveBlockDataOptions {
|
|
42
|
-
page: CmssyPageData | null;
|
|
43
|
-
blocks: BlockDefinition[];
|
|
44
|
-
locale: string;
|
|
45
|
-
defaultLocale: string;
|
|
46
|
-
enabledLocales?: string[];
|
|
47
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
48
|
-
isPreview?: boolean;
|
|
49
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
50
|
-
config?: CmssyClientConfig;
|
|
51
|
-
}
|
|
52
|
-
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
53
|
-
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
54
|
-
interface ResolveLayoutBlockDataOptions {
|
|
55
|
-
groups: CmssyLayoutGroup[];
|
|
56
|
-
blocks: BlockDefinition[];
|
|
57
|
-
position: string;
|
|
58
|
-
locale: string;
|
|
59
|
-
defaultLocale: string;
|
|
60
|
-
enabledLocales?: string[];
|
|
61
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
62
|
-
isPreview?: boolean;
|
|
63
|
-
/** Workspace the relation records are read from. No config, no resolution. */
|
|
64
|
-
config?: CmssyClientConfig;
|
|
65
|
-
}
|
|
66
|
-
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
67
|
-
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
68
|
-
|
|
69
39
|
interface CmssyServerLayoutProps {
|
|
70
40
|
groups: CmssyLayoutGroup[];
|
|
71
41
|
blocks: BlockDefinition[];
|
|
@@ -114,4 +84,4 @@ interface UnknownBlockProps {
|
|
|
114
84
|
}
|
|
115
85
|
declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
|
|
116
86
|
|
|
117
|
-
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps,
|
|
87
|
+
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, UnknownBlock, type UnknownBlockProps };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { CmssyRequestError, PROTOCOL_VERSION, createCmssyClient, fields, graphqlRequest, isProtocolCompatible, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
2
|
+
import { buildBlockContext, getBlockContentForLanguage, normalizeRelationContent, asBucket, resolveSiteLocales, resolveRelationContent } from '@cmssy/core/internal';
|
|
3
|
+
export { buildBlockContext } from '@cmssy/core/internal';
|
|
3
4
|
import { createElement } from 'react';
|
|
4
5
|
import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
|
|
5
6
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
|
-
export { evaluateFieldConditionGroup } from '@cmssy/types';
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
|
|
@@ -34,20 +34,6 @@ function blocksToSchemas(blocks) {
|
|
|
34
34
|
}
|
|
35
35
|
return out;
|
|
36
36
|
}
|
|
37
|
-
function blocksToMeta(blocks, defaults = {}) {
|
|
38
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
39
|
-
for (const block of blocks) {
|
|
40
|
-
const category = block.category ?? defaults.category;
|
|
41
|
-
out[block.type] = {
|
|
42
|
-
label: block.label ?? block.type,
|
|
43
|
-
...category ? { category } : {},
|
|
44
|
-
...block.icon ? { icon: block.icon } : {},
|
|
45
|
-
...block.layoutPositions ? { layoutPositions: block.layoutPositions } : {},
|
|
46
|
-
...block.description ? { description: block.description } : {}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
37
|
|
|
52
38
|
// src/components/block-error.ts
|
|
53
39
|
var BLOCK_ERROR_KEY = "__cmssyBlockError";
|
|
@@ -65,9 +51,6 @@ function unregisteredBlockError(type) {
|
|
|
65
51
|
message: `Block type "${type}" is not registered in this site's blocks array.`
|
|
66
52
|
};
|
|
67
53
|
}
|
|
68
|
-
function markBlockError(error) {
|
|
69
|
-
return { [BLOCK_ERROR_KEY]: error };
|
|
70
|
-
}
|
|
71
54
|
function readBlockError(value) {
|
|
72
55
|
if (typeof value !== "object" || value === null) return void 0;
|
|
73
56
|
const marked = value[BLOCK_ERROR_KEY];
|
|
@@ -316,90 +299,6 @@ async function CmssyServerPage({
|
|
|
316
299
|
})
|
|
317
300
|
) });
|
|
318
301
|
}
|
|
319
|
-
function collectBlockData(blocks, resolved, isPreview) {
|
|
320
|
-
const data = {};
|
|
321
|
-
const content = {};
|
|
322
|
-
blocks.forEach((block, index) => {
|
|
323
|
-
const entry = resolved[index];
|
|
324
|
-
if (!entry) return;
|
|
325
|
-
content[block.id] = entry.content;
|
|
326
|
-
if (entry.error && isPreview) {
|
|
327
|
-
data[block.id] = markBlockError(entry.error);
|
|
328
|
-
} else if (entry.data !== void 0) {
|
|
329
|
-
data[block.id] = entry.data;
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
return { data, content };
|
|
333
|
-
}
|
|
334
|
-
async function resolveEditorBlockData({
|
|
335
|
-
page,
|
|
336
|
-
blocks,
|
|
337
|
-
locale,
|
|
338
|
-
defaultLocale,
|
|
339
|
-
enabledLocales,
|
|
340
|
-
forms,
|
|
341
|
-
isPreview = false,
|
|
342
|
-
config
|
|
343
|
-
}) {
|
|
344
|
-
if (!page) return { data: {}, content: {} };
|
|
345
|
-
const loaderMap = buildLoaderMap(blocks);
|
|
346
|
-
const context = buildBlockContext(
|
|
347
|
-
locale,
|
|
348
|
-
defaultLocale,
|
|
349
|
-
enabledLocales,
|
|
350
|
-
isPreview,
|
|
351
|
-
forms
|
|
352
|
-
);
|
|
353
|
-
const resolved = await resolveBlocks(
|
|
354
|
-
page.blocks,
|
|
355
|
-
loaderMap,
|
|
356
|
-
locale,
|
|
357
|
-
defaultLocale,
|
|
358
|
-
context,
|
|
359
|
-
enabledLocales,
|
|
360
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
361
|
-
);
|
|
362
|
-
return collectBlockData(page.blocks, resolved, isPreview);
|
|
363
|
-
}
|
|
364
|
-
async function resolveBlockData(options) {
|
|
365
|
-
return (await resolveEditorBlockData(options)).data;
|
|
366
|
-
}
|
|
367
|
-
async function resolveEditorLayoutBlockData({
|
|
368
|
-
groups,
|
|
369
|
-
blocks,
|
|
370
|
-
position,
|
|
371
|
-
locale,
|
|
372
|
-
defaultLocale,
|
|
373
|
-
enabledLocales,
|
|
374
|
-
forms,
|
|
375
|
-
isPreview = false,
|
|
376
|
-
config
|
|
377
|
-
}) {
|
|
378
|
-
const group = groups.find((g) => g.position === position);
|
|
379
|
-
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive).slice().sort((a, b) => a.order - b.order) : [];
|
|
380
|
-
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
381
|
-
const loaderMap = buildLoaderMap(blocks);
|
|
382
|
-
const context = buildBlockContext(
|
|
383
|
-
locale,
|
|
384
|
-
defaultLocale,
|
|
385
|
-
enabledLocales,
|
|
386
|
-
isPreview,
|
|
387
|
-
forms
|
|
388
|
-
);
|
|
389
|
-
const resolved = await resolveBlocks(
|
|
390
|
-
layoutBlocks,
|
|
391
|
-
loaderMap,
|
|
392
|
-
locale,
|
|
393
|
-
defaultLocale,
|
|
394
|
-
context,
|
|
395
|
-
enabledLocales,
|
|
396
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
397
|
-
);
|
|
398
|
-
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
399
|
-
}
|
|
400
|
-
async function resolveLayoutBlockData(options) {
|
|
401
|
-
return (await resolveEditorLayoutBlockData(options)).data;
|
|
402
|
-
}
|
|
403
302
|
async function CmssyServerLayout({
|
|
404
303
|
groups,
|
|
405
304
|
blocks,
|
|
@@ -521,4 +420,4 @@ function CmssyBlock({
|
|
|
521
420
|
);
|
|
522
421
|
}
|
|
523
422
|
|
|
524
|
-
export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock,
|
|
423
|
+
export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, defineBlock };
|