@measured/puck 0.19.4-canary.f09540db → 0.20.0-canary.167a8f71
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/{chunk-IM42S4YL.mjs → chunk-32MJ3X3H.mjs} +295 -256
- package/dist/chunk-4KAREQPB.mjs +8436 -0
- package/dist/index.css +3 -1
- package/dist/index.d.mts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +1076 -1074
- package/dist/index.mjs +25 -8455
- package/dist/no-external.css +1895 -0
- package/dist/no-external.d.mts +4 -0
- package/dist/no-external.d.ts +4 -0
- package/dist/no-external.js +9315 -0
- package/dist/no-external.mjs +52 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +50 -8
- package/dist/rsc.mjs +5 -1
- package/dist/{walk-tree-DrJNb8b-.d.mts → walk-tree-DrNRq2FV.d.mts} +22 -29
- package/dist/{walk-tree-DrJNb8b-.d.ts → walk-tree-DrNRq2FV.d.ts} +22 -29
- package/package.json +3 -2
|
@@ -84,34 +84,8 @@ var init_react_import = __esm({
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
//
|
|
88
|
-
init_react_import();
|
|
89
|
-
|
|
90
|
-
// components/ServerRender/index.tsx
|
|
91
|
-
init_react_import();
|
|
92
|
-
|
|
93
|
-
// lib/root-droppable-id.ts
|
|
94
|
-
init_react_import();
|
|
95
|
-
var rootAreaId = "root";
|
|
96
|
-
var rootZone = "default-zone";
|
|
97
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
98
|
-
|
|
99
|
-
// lib/data/setup-zone.ts
|
|
100
|
-
init_react_import();
|
|
101
|
-
var setupZone = (data, zoneKey) => {
|
|
102
|
-
if (zoneKey === rootDroppableId) {
|
|
103
|
-
return data;
|
|
104
|
-
}
|
|
105
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
|
106
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
107
|
-
});
|
|
108
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
109
|
-
return newData;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// lib/use-slots.tsx
|
|
87
|
+
// lib/data/walk-tree.ts
|
|
113
88
|
init_react_import();
|
|
114
|
-
import { useMemo } from "react";
|
|
115
89
|
|
|
116
90
|
// lib/data/map-slots.ts
|
|
117
91
|
init_react_import();
|
|
@@ -256,7 +230,66 @@ function mapSlots(item, map, config, recurseSlots = false) {
|
|
|
256
230
|
});
|
|
257
231
|
}
|
|
258
232
|
|
|
233
|
+
// lib/data/walk-tree.ts
|
|
234
|
+
function walkTree(data, config, callbackFn) {
|
|
235
|
+
var _a, _b;
|
|
236
|
+
const walkItem = (item) => {
|
|
237
|
+
return mapSlots(
|
|
238
|
+
item,
|
|
239
|
+
(content, parentId, propName) => {
|
|
240
|
+
var _a2;
|
|
241
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
242
|
+
},
|
|
243
|
+
config,
|
|
244
|
+
true
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
if ("props" in data) {
|
|
248
|
+
return walkItem(data);
|
|
249
|
+
}
|
|
250
|
+
const _data = data;
|
|
251
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
|
252
|
+
const mappedContent = _data.content.map(walkItem);
|
|
253
|
+
return {
|
|
254
|
+
root: walkItem(_data.root),
|
|
255
|
+
content: (_b = callbackFn(mappedContent, {
|
|
256
|
+
parentId: "root",
|
|
257
|
+
propName: "default-zone"
|
|
258
|
+
})) != null ? _b : mappedContent,
|
|
259
|
+
zones: Object.keys(zones).reduce(
|
|
260
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
|
261
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
262
|
+
}),
|
|
263
|
+
{}
|
|
264
|
+
)
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// components/ServerRender/index.tsx
|
|
269
|
+
init_react_import();
|
|
270
|
+
|
|
271
|
+
// lib/root-droppable-id.ts
|
|
272
|
+
init_react_import();
|
|
273
|
+
var rootAreaId = "root";
|
|
274
|
+
var rootZone = "default-zone";
|
|
275
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
276
|
+
|
|
277
|
+
// lib/data/setup-zone.ts
|
|
278
|
+
init_react_import();
|
|
279
|
+
var setupZone = (data, zoneKey) => {
|
|
280
|
+
if (zoneKey === rootDroppableId) {
|
|
281
|
+
return data;
|
|
282
|
+
}
|
|
283
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
284
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
285
|
+
});
|
|
286
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
287
|
+
return newData;
|
|
288
|
+
};
|
|
289
|
+
|
|
259
290
|
// lib/use-slots.tsx
|
|
291
|
+
init_react_import();
|
|
292
|
+
import { useMemo } from "react";
|
|
260
293
|
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
261
294
|
const slotProps = useMemo(() => {
|
|
262
295
|
const mapped = mapSlots(
|
|
@@ -421,221 +454,6 @@ function Render({
|
|
|
421
454
|
);
|
|
422
455
|
}
|
|
423
456
|
|
|
424
|
-
// lib/resolve-all-data.ts
|
|
425
|
-
init_react_import();
|
|
426
|
-
|
|
427
|
-
// lib/resolve-component-data.ts
|
|
428
|
-
init_react_import();
|
|
429
|
-
|
|
430
|
-
// lib/get-changed.ts
|
|
431
|
-
init_react_import();
|
|
432
|
-
import fdeq from "fast-deep-equal";
|
|
433
|
-
var getChanged = (newItem, oldItem) => {
|
|
434
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
435
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
436
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
437
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
438
|
-
[item]: !fdeq(oldItemProps[item], newItemProps[item])
|
|
439
|
-
});
|
|
440
|
-
}, {}) : {};
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
// lib/resolve-component-data.ts
|
|
444
|
-
import fdeq2 from "fast-deep-equal";
|
|
445
|
-
var cache = { lastChange: {} };
|
|
446
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
447
|
-
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
448
|
-
const resolvedItem = __spreadValues({}, item);
|
|
449
|
-
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
450
|
-
const id = "id" in item.props ? item.props.id : "root";
|
|
451
|
-
if (shouldRunResolver) {
|
|
452
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
453
|
-
if (item && fdeq2(item, oldItem)) {
|
|
454
|
-
return { node: resolved, didChange: false };
|
|
455
|
-
}
|
|
456
|
-
const changed = getChanged(item, oldItem);
|
|
457
|
-
if (onResolveStart) {
|
|
458
|
-
onResolveStart(item);
|
|
459
|
-
}
|
|
460
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
461
|
-
changed,
|
|
462
|
-
lastData: oldItem,
|
|
463
|
-
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
464
|
-
trigger
|
|
465
|
-
});
|
|
466
|
-
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
467
|
-
if (Object.keys(readOnly).length) {
|
|
468
|
-
resolvedItem.readOnly = readOnly;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
let itemWithResolvedChildren = yield mapSlots(
|
|
472
|
-
resolvedItem,
|
|
473
|
-
(content) => __async(void 0, null, function* () {
|
|
474
|
-
return yield Promise.all(
|
|
475
|
-
content.map(
|
|
476
|
-
(childItem) => __async(void 0, null, function* () {
|
|
477
|
-
return (yield resolveComponentData(
|
|
478
|
-
childItem,
|
|
479
|
-
config,
|
|
480
|
-
metadata,
|
|
481
|
-
onResolveStart,
|
|
482
|
-
onResolveEnd,
|
|
483
|
-
trigger
|
|
484
|
-
)).node;
|
|
485
|
-
})
|
|
486
|
-
)
|
|
487
|
-
);
|
|
488
|
-
}),
|
|
489
|
-
config
|
|
490
|
-
);
|
|
491
|
-
if (shouldRunResolver && onResolveEnd) {
|
|
492
|
-
onResolveEnd(resolvedItem);
|
|
493
|
-
}
|
|
494
|
-
cache.lastChange[id] = {
|
|
495
|
-
item,
|
|
496
|
-
resolved: itemWithResolvedChildren
|
|
497
|
-
};
|
|
498
|
-
return {
|
|
499
|
-
node: itemWithResolvedChildren,
|
|
500
|
-
didChange: !fdeq2(item, itemWithResolvedChildren)
|
|
501
|
-
};
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
// lib/data/default-data.ts
|
|
505
|
-
init_react_import();
|
|
506
|
-
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
507
|
-
root: data.root || {},
|
|
508
|
-
content: data.content || []
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// lib/data/to-component.ts
|
|
512
|
-
init_react_import();
|
|
513
|
-
var toComponent = (item) => {
|
|
514
|
-
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
515
|
-
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
516
|
-
type: "root"
|
|
517
|
-
});
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
// lib/resolve-all-data.ts
|
|
521
|
-
function resolveAllData(_0, _1) {
|
|
522
|
-
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
523
|
-
var _a;
|
|
524
|
-
const defaultedData = defaultData(data);
|
|
525
|
-
const resolveNode = (_node) => __async(this, null, function* () {
|
|
526
|
-
const node = toComponent(_node);
|
|
527
|
-
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
528
|
-
const resolved = (yield resolveComponentData(
|
|
529
|
-
node,
|
|
530
|
-
config,
|
|
531
|
-
metadata,
|
|
532
|
-
() => {
|
|
533
|
-
},
|
|
534
|
-
() => {
|
|
535
|
-
},
|
|
536
|
-
"force"
|
|
537
|
-
)).node;
|
|
538
|
-
const resolvedDeep = yield mapSlots(
|
|
539
|
-
resolved,
|
|
540
|
-
processContent,
|
|
541
|
-
config
|
|
542
|
-
);
|
|
543
|
-
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
544
|
-
return resolvedDeep;
|
|
545
|
-
});
|
|
546
|
-
const processContent = (content) => __async(this, null, function* () {
|
|
547
|
-
return Promise.all(content.map(resolveNode));
|
|
548
|
-
});
|
|
549
|
-
const processZones = () => __async(this, null, function* () {
|
|
550
|
-
var _a2;
|
|
551
|
-
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
552
|
-
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
553
|
-
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
554
|
-
}));
|
|
555
|
-
return zones;
|
|
556
|
-
});
|
|
557
|
-
const dynamic = {
|
|
558
|
-
root: yield resolveNode(defaultedData.root),
|
|
559
|
-
content: yield processContent(defaultedData.content),
|
|
560
|
-
zones: yield processZones()
|
|
561
|
-
};
|
|
562
|
-
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
563
|
-
const content = defaultedData.zones[zoneKey];
|
|
564
|
-
dynamic.zones[zoneKey] = yield processContent(content);
|
|
565
|
-
}), {});
|
|
566
|
-
return dynamic;
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// lib/transform-props.ts
|
|
571
|
-
init_react_import();
|
|
572
|
-
|
|
573
|
-
// lib/data/walk-tree.ts
|
|
574
|
-
init_react_import();
|
|
575
|
-
function walkTree(data, config, callbackFn) {
|
|
576
|
-
var _a, _b;
|
|
577
|
-
const walkItem = (item) => {
|
|
578
|
-
return mapSlots(
|
|
579
|
-
item,
|
|
580
|
-
(content, parentId, propName) => {
|
|
581
|
-
var _a2;
|
|
582
|
-
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
583
|
-
},
|
|
584
|
-
config,
|
|
585
|
-
true
|
|
586
|
-
);
|
|
587
|
-
};
|
|
588
|
-
if ("props" in data) {
|
|
589
|
-
return walkItem(data);
|
|
590
|
-
}
|
|
591
|
-
const _data = data;
|
|
592
|
-
const zones = (_a = _data.zones) != null ? _a : {};
|
|
593
|
-
const mappedContent = _data.content.map(walkItem);
|
|
594
|
-
return {
|
|
595
|
-
root: walkItem(_data.root),
|
|
596
|
-
content: (_b = callbackFn(mappedContent, {
|
|
597
|
-
parentId: "root",
|
|
598
|
-
propName: "default-zone"
|
|
599
|
-
})) != null ? _b : mappedContent,
|
|
600
|
-
zones: Object.keys(zones).reduce(
|
|
601
|
-
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
|
602
|
-
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
603
|
-
}),
|
|
604
|
-
{}
|
|
605
|
-
)
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// lib/transform-props.ts
|
|
610
|
-
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
611
|
-
const mapItem = (item) => {
|
|
612
|
-
if (propTransforms[item.type]) {
|
|
613
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
614
|
-
props: __spreadValues({
|
|
615
|
-
id: item.props.id
|
|
616
|
-
}, propTransforms[item.type](item.props))
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
return item;
|
|
620
|
-
};
|
|
621
|
-
const defaultedData = defaultData(data);
|
|
622
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
623
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
|
624
|
-
if (propTransforms["root"]) {
|
|
625
|
-
newRoot.props = propTransforms["root"](rootProps);
|
|
626
|
-
}
|
|
627
|
-
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
628
|
-
const updatedData = walkTree(
|
|
629
|
-
dataWithUpdatedRoot,
|
|
630
|
-
config,
|
|
631
|
-
(content) => content.map(mapItem)
|
|
632
|
-
);
|
|
633
|
-
if (!defaultedData.root.props) {
|
|
634
|
-
updatedData.root = updatedData.root.props;
|
|
635
|
-
}
|
|
636
|
-
return updatedData;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
457
|
// lib/migrate.ts
|
|
640
458
|
init_react_import();
|
|
641
459
|
|
|
@@ -871,8 +689,8 @@ var migrations = [
|
|
|
871
689
|
return data;
|
|
872
690
|
},
|
|
873
691
|
// Migrate zones to slots
|
|
874
|
-
(data, config) => {
|
|
875
|
-
var _a;
|
|
692
|
+
(data, config, migrationOptions) => {
|
|
693
|
+
var _a, _b;
|
|
876
694
|
if (!config) return data;
|
|
877
695
|
console.log("Migrating DropZones to slots...");
|
|
878
696
|
const updatedItems = {};
|
|
@@ -880,13 +698,13 @@ var migrations = [
|
|
|
880
698
|
const { indexes } = walkAppState(appState, config);
|
|
881
699
|
const deletedCompounds = [];
|
|
882
700
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
883
|
-
var _a2,
|
|
701
|
+
var _a2, _b2, _c;
|
|
884
702
|
if (zoneType === "dropzone") {
|
|
885
703
|
const [id, slotName] = zoneCompound.split(":");
|
|
886
704
|
const nodeData = indexes.nodes[id].data;
|
|
887
705
|
const componentType = nodeData.type;
|
|
888
706
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
889
|
-
if (((
|
|
707
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
890
708
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
891
709
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
892
710
|
[slotName]: content
|
|
@@ -915,7 +733,49 @@ var migrations = [
|
|
|
915
733
|
);
|
|
916
734
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
917
735
|
});
|
|
918
|
-
|
|
736
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
737
|
+
const unmigratedZonesGrouped = {};
|
|
738
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
739
|
+
var _a2;
|
|
740
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
741
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
742
|
+
if (!content) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
746
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
747
|
+
}
|
|
748
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
749
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
753
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
754
|
+
return content.map((child) => {
|
|
755
|
+
var _a2;
|
|
756
|
+
if (child.props.id !== componentId) {
|
|
757
|
+
return child;
|
|
758
|
+
}
|
|
759
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
760
|
+
if (!migrateFn) {
|
|
761
|
+
return child;
|
|
762
|
+
}
|
|
763
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
764
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
765
|
+
Object.keys(zones).forEach((propName) => {
|
|
766
|
+
var _a3;
|
|
767
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
768
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
769
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
770
|
+
});
|
|
771
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
772
|
+
props: migratedProps
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
919
779
|
const [_, propName] = zoneCompound.split(":");
|
|
920
780
|
throw new Error(
|
|
921
781
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -925,13 +785,192 @@ var migrations = [
|
|
|
925
785
|
return updated.data;
|
|
926
786
|
}
|
|
927
787
|
];
|
|
928
|
-
function migrate(data, config) {
|
|
788
|
+
function migrate(data, config, migrationOptions) {
|
|
929
789
|
return migrations == null ? void 0 : migrations.reduce(
|
|
930
|
-
(acc, migration) => migration(acc, config),
|
|
790
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
931
791
|
data
|
|
932
792
|
);
|
|
933
793
|
}
|
|
934
794
|
|
|
795
|
+
// lib/transform-props.ts
|
|
796
|
+
init_react_import();
|
|
797
|
+
|
|
798
|
+
// lib/data/default-data.ts
|
|
799
|
+
init_react_import();
|
|
800
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
801
|
+
root: data.root || {},
|
|
802
|
+
content: data.content || []
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
// lib/transform-props.ts
|
|
806
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
807
|
+
const mapItem = (item) => {
|
|
808
|
+
if (propTransforms[item.type]) {
|
|
809
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
810
|
+
props: __spreadValues({
|
|
811
|
+
id: item.props.id
|
|
812
|
+
}, propTransforms[item.type](item.props))
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
return item;
|
|
816
|
+
};
|
|
817
|
+
const defaultedData = defaultData(data);
|
|
818
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
819
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
820
|
+
if (propTransforms["root"]) {
|
|
821
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
822
|
+
}
|
|
823
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
824
|
+
const updatedData = walkTree(
|
|
825
|
+
dataWithUpdatedRoot,
|
|
826
|
+
config,
|
|
827
|
+
(content) => content.map(mapItem)
|
|
828
|
+
);
|
|
829
|
+
if (!defaultedData.root.props) {
|
|
830
|
+
updatedData.root = updatedData.root.props;
|
|
831
|
+
}
|
|
832
|
+
return updatedData;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// lib/resolve-all-data.ts
|
|
836
|
+
init_react_import();
|
|
837
|
+
|
|
838
|
+
// lib/resolve-component-data.ts
|
|
839
|
+
init_react_import();
|
|
840
|
+
|
|
841
|
+
// lib/get-changed.ts
|
|
842
|
+
init_react_import();
|
|
843
|
+
import fdeq from "fast-deep-equal";
|
|
844
|
+
var getChanged = (newItem, oldItem) => {
|
|
845
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
846
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
847
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
848
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
849
|
+
[item]: !fdeq(oldItemProps[item], newItemProps[item])
|
|
850
|
+
});
|
|
851
|
+
}, {}) : {};
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
// lib/resolve-component-data.ts
|
|
855
|
+
import fdeq2 from "fast-deep-equal";
|
|
856
|
+
var cache = { lastChange: {} };
|
|
857
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
858
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
859
|
+
const resolvedItem = __spreadValues({}, item);
|
|
860
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
861
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
862
|
+
if (shouldRunResolver) {
|
|
863
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
864
|
+
if (item && fdeq2(item, oldItem)) {
|
|
865
|
+
return { node: resolved, didChange: false };
|
|
866
|
+
}
|
|
867
|
+
const changed = getChanged(item, oldItem);
|
|
868
|
+
if (onResolveStart) {
|
|
869
|
+
onResolveStart(item);
|
|
870
|
+
}
|
|
871
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
872
|
+
changed,
|
|
873
|
+
lastData: oldItem,
|
|
874
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
875
|
+
trigger
|
|
876
|
+
});
|
|
877
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
878
|
+
if (Object.keys(readOnly).length) {
|
|
879
|
+
resolvedItem.readOnly = readOnly;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
let itemWithResolvedChildren = yield mapSlots(
|
|
883
|
+
resolvedItem,
|
|
884
|
+
(content) => __async(void 0, null, function* () {
|
|
885
|
+
return yield Promise.all(
|
|
886
|
+
content.map(
|
|
887
|
+
(childItem) => __async(void 0, null, function* () {
|
|
888
|
+
return (yield resolveComponentData(
|
|
889
|
+
childItem,
|
|
890
|
+
config,
|
|
891
|
+
metadata,
|
|
892
|
+
onResolveStart,
|
|
893
|
+
onResolveEnd,
|
|
894
|
+
trigger
|
|
895
|
+
)).node;
|
|
896
|
+
})
|
|
897
|
+
)
|
|
898
|
+
);
|
|
899
|
+
}),
|
|
900
|
+
config
|
|
901
|
+
);
|
|
902
|
+
if (shouldRunResolver && onResolveEnd) {
|
|
903
|
+
onResolveEnd(resolvedItem);
|
|
904
|
+
}
|
|
905
|
+
cache.lastChange[id] = {
|
|
906
|
+
item,
|
|
907
|
+
resolved: itemWithResolvedChildren
|
|
908
|
+
};
|
|
909
|
+
return {
|
|
910
|
+
node: itemWithResolvedChildren,
|
|
911
|
+
didChange: !fdeq2(item, itemWithResolvedChildren)
|
|
912
|
+
};
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
// lib/data/to-component.ts
|
|
916
|
+
init_react_import();
|
|
917
|
+
var toComponent = (item) => {
|
|
918
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
919
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
920
|
+
type: "root"
|
|
921
|
+
});
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
// lib/resolve-all-data.ts
|
|
925
|
+
function resolveAllData(_0, _1) {
|
|
926
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
927
|
+
var _a;
|
|
928
|
+
const defaultedData = defaultData(data);
|
|
929
|
+
const resolveNode = (_node) => __async(this, null, function* () {
|
|
930
|
+
const node = toComponent(_node);
|
|
931
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
932
|
+
const resolved = (yield resolveComponentData(
|
|
933
|
+
node,
|
|
934
|
+
config,
|
|
935
|
+
metadata,
|
|
936
|
+
() => {
|
|
937
|
+
},
|
|
938
|
+
() => {
|
|
939
|
+
},
|
|
940
|
+
"force"
|
|
941
|
+
)).node;
|
|
942
|
+
const resolvedDeep = yield mapSlots(
|
|
943
|
+
resolved,
|
|
944
|
+
processContent,
|
|
945
|
+
config
|
|
946
|
+
);
|
|
947
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
948
|
+
return resolvedDeep;
|
|
949
|
+
});
|
|
950
|
+
const processContent = (content) => __async(this, null, function* () {
|
|
951
|
+
return Promise.all(content.map(resolveNode));
|
|
952
|
+
});
|
|
953
|
+
const processZones = () => __async(this, null, function* () {
|
|
954
|
+
var _a2;
|
|
955
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
956
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
957
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
958
|
+
}));
|
|
959
|
+
return zones;
|
|
960
|
+
});
|
|
961
|
+
const dynamic = {
|
|
962
|
+
root: yield resolveNode(defaultedData.root),
|
|
963
|
+
content: yield processContent(defaultedData.content),
|
|
964
|
+
zones: yield processZones()
|
|
965
|
+
};
|
|
966
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
967
|
+
const content = defaultedData.zones[zoneKey];
|
|
968
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
969
|
+
}), {});
|
|
970
|
+
return dynamic;
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
|
|
935
974
|
export {
|
|
936
975
|
__spreadValues,
|
|
937
976
|
__spreadProps,
|
|
@@ -949,15 +988,15 @@ export {
|
|
|
949
988
|
walkAppState,
|
|
950
989
|
walkTree,
|
|
951
990
|
setupZone,
|
|
991
|
+
defaultViewports,
|
|
992
|
+
getChanged,
|
|
993
|
+
resolveComponentData,
|
|
994
|
+
defaultAppState,
|
|
952
995
|
useSlots,
|
|
996
|
+
Render,
|
|
953
997
|
SlotRenderPure,
|
|
954
998
|
SlotRender,
|
|
955
|
-
|
|
956
|
-
getChanged,
|
|
957
|
-
resolveComponentData,
|
|
958
|
-
resolveAllData,
|
|
999
|
+
migrate,
|
|
959
1000
|
transformProps,
|
|
960
|
-
|
|
961
|
-
defaultAppState,
|
|
962
|
-
migrate
|
|
1001
|
+
resolveAllData
|
|
963
1002
|
};
|