@measured/puck-plugin-heading-analyzer 0.19.0-canary.a967ca42 → 0.19.0-canary.af1dc891
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +322 -146
- package/dist/index.mjs +322 -146
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -153,6 +153,120 @@ var require_classnames = __commonJS({
|
|
153
153
|
}
|
154
154
|
});
|
155
155
|
|
156
|
+
// ../../node_modules/flat/index.js
|
157
|
+
var require_flat = __commonJS({
|
158
|
+
"../../node_modules/flat/index.js"(exports2, module2) {
|
159
|
+
"use strict";
|
160
|
+
init_react_import();
|
161
|
+
module2.exports = flatten3;
|
162
|
+
flatten3.flatten = flatten3;
|
163
|
+
flatten3.unflatten = unflatten2;
|
164
|
+
function isBuffer(obj) {
|
165
|
+
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
166
|
+
}
|
167
|
+
function keyIdentity(key) {
|
168
|
+
return key;
|
169
|
+
}
|
170
|
+
function flatten3(target, opts) {
|
171
|
+
opts = opts || {};
|
172
|
+
const delimiter = opts.delimiter || ".";
|
173
|
+
const maxDepth = opts.maxDepth;
|
174
|
+
const transformKey = opts.transformKey || keyIdentity;
|
175
|
+
const output = {};
|
176
|
+
function step(object, prev, currentDepth) {
|
177
|
+
currentDepth = currentDepth || 1;
|
178
|
+
Object.keys(object).forEach(function(key) {
|
179
|
+
const value = object[key];
|
180
|
+
const isarray = opts.safe && Array.isArray(value);
|
181
|
+
const type = Object.prototype.toString.call(value);
|
182
|
+
const isbuffer = isBuffer(value);
|
183
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
184
|
+
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
185
|
+
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
|
186
|
+
return step(value, newKey, currentDepth + 1);
|
187
|
+
}
|
188
|
+
output[newKey] = value;
|
189
|
+
});
|
190
|
+
}
|
191
|
+
step(target);
|
192
|
+
return output;
|
193
|
+
}
|
194
|
+
function unflatten2(target, opts) {
|
195
|
+
opts = opts || {};
|
196
|
+
const delimiter = opts.delimiter || ".";
|
197
|
+
const overwrite = opts.overwrite || false;
|
198
|
+
const transformKey = opts.transformKey || keyIdentity;
|
199
|
+
const result = {};
|
200
|
+
const isbuffer = isBuffer(target);
|
201
|
+
if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
|
202
|
+
return target;
|
203
|
+
}
|
204
|
+
function getkey(key) {
|
205
|
+
const parsedKey = Number(key);
|
206
|
+
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
207
|
+
}
|
208
|
+
function addKeys(keyPrefix, recipient, target2) {
|
209
|
+
return Object.keys(target2).reduce(function(result2, key) {
|
210
|
+
result2[keyPrefix + delimiter + key] = target2[key];
|
211
|
+
return result2;
|
212
|
+
}, recipient);
|
213
|
+
}
|
214
|
+
function isEmpty(val) {
|
215
|
+
const type = Object.prototype.toString.call(val);
|
216
|
+
const isArray = type === "[object Array]";
|
217
|
+
const isObject = type === "[object Object]";
|
218
|
+
if (!val) {
|
219
|
+
return true;
|
220
|
+
} else if (isArray) {
|
221
|
+
return !val.length;
|
222
|
+
} else if (isObject) {
|
223
|
+
return !Object.keys(val).length;
|
224
|
+
}
|
225
|
+
}
|
226
|
+
target = Object.keys(target).reduce(function(result2, key) {
|
227
|
+
const type = Object.prototype.toString.call(target[key]);
|
228
|
+
const isObject = type === "[object Object]" || type === "[object Array]";
|
229
|
+
if (!isObject || isEmpty(target[key])) {
|
230
|
+
result2[key] = target[key];
|
231
|
+
return result2;
|
232
|
+
} else {
|
233
|
+
return addKeys(
|
234
|
+
key,
|
235
|
+
result2,
|
236
|
+
flatten3(target[key], opts)
|
237
|
+
);
|
238
|
+
}
|
239
|
+
}, {});
|
240
|
+
Object.keys(target).forEach(function(key) {
|
241
|
+
const split = key.split(delimiter).map(transformKey);
|
242
|
+
let key1 = getkey(split.shift());
|
243
|
+
let key2 = getkey(split[0]);
|
244
|
+
let recipient = result;
|
245
|
+
while (key2 !== void 0) {
|
246
|
+
if (key1 === "__proto__") {
|
247
|
+
return;
|
248
|
+
}
|
249
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
250
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
251
|
+
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
|
252
|
+
return;
|
253
|
+
}
|
254
|
+
if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
|
255
|
+
recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
256
|
+
}
|
257
|
+
recipient = recipient[key1];
|
258
|
+
if (split.length > 0) {
|
259
|
+
key1 = getkey(split.shift());
|
260
|
+
key2 = getkey(split[0]);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
recipient[key1] = unflatten2(target[key], opts);
|
264
|
+
});
|
265
|
+
return result;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
});
|
269
|
+
|
156
270
|
// ../../node_modules/fast-deep-equal/index.js
|
157
271
|
var require_fast_deep_equal = __commonJS({
|
158
272
|
"../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
|
@@ -374,43 +488,6 @@ init_react_import();
|
|
374
488
|
// ../core/lib/data/walk-app-state.ts
|
375
489
|
init_react_import();
|
376
490
|
|
377
|
-
// ../core/lib/data/for-each-slot.ts
|
378
|
-
init_react_import();
|
379
|
-
|
380
|
-
// ../core/lib/data/is-slot.ts
|
381
|
-
init_react_import();
|
382
|
-
var isSlot = (prop) => {
|
383
|
-
var _a, _b;
|
384
|
-
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
385
|
-
};
|
386
|
-
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
387
|
-
var _a, _b;
|
388
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
389
|
-
if (!configForComponent) return isSlot(propValue);
|
390
|
-
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
391
|
-
};
|
392
|
-
|
393
|
-
// ../core/lib/data/for-each-slot.ts
|
394
|
-
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
395
|
-
const props = item.props || {};
|
396
|
-
const propKeys = Object.keys(props);
|
397
|
-
for (let i = 0; i < propKeys.length; i++) {
|
398
|
-
const propKey = propKeys[i];
|
399
|
-
const itemType = "type" in item ? item.type : "root";
|
400
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
401
|
-
const content = props[propKey];
|
402
|
-
cb(props.id, propKey, content);
|
403
|
-
if (recursive) {
|
404
|
-
content.forEach(
|
405
|
-
(childItem) => __async(void 0, null, function* () {
|
406
|
-
return forEachSlot(childItem, cb, true, isSlot2);
|
407
|
-
})
|
408
|
-
);
|
409
|
-
}
|
410
|
-
}
|
411
|
-
}
|
412
|
-
};
|
413
|
-
|
414
491
|
// ../core/lib/data/for-related-zones.ts
|
415
492
|
init_react_import();
|
416
493
|
|
@@ -444,19 +521,154 @@ function forRelatedZones(item, data, cb, path = []) {
|
|
444
521
|
});
|
445
522
|
}
|
446
523
|
|
524
|
+
// ../core/lib/data/map-slots.ts
|
525
|
+
init_react_import();
|
526
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
527
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
528
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
529
|
+
var walkField = ({
|
530
|
+
value,
|
531
|
+
fields,
|
532
|
+
map,
|
533
|
+
propKey = "",
|
534
|
+
propPath = "",
|
535
|
+
id = "",
|
536
|
+
config,
|
537
|
+
recurseSlots = false
|
538
|
+
}) => {
|
539
|
+
var _a, _b, _c;
|
540
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
541
|
+
const content = value || [];
|
542
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
543
|
+
var _a2;
|
544
|
+
const componentConfig = config.components[el.type];
|
545
|
+
if (!componentConfig) {
|
546
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
547
|
+
}
|
548
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
549
|
+
return walkField({
|
550
|
+
value: el,
|
551
|
+
fields: fields2,
|
552
|
+
map,
|
553
|
+
id: el.props.id,
|
554
|
+
config,
|
555
|
+
recurseSlots
|
556
|
+
});
|
557
|
+
}) : content;
|
558
|
+
if (containsPromise(mappedContent)) {
|
559
|
+
return Promise.all(mappedContent);
|
560
|
+
}
|
561
|
+
return map(mappedContent, id, propPath, fields[propKey], propPath);
|
562
|
+
}
|
563
|
+
if (value && typeof value === "object") {
|
564
|
+
if (Array.isArray(value)) {
|
565
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
566
|
+
if (!arrayFields) return value;
|
567
|
+
const newValue = value.map(
|
568
|
+
(el, idx) => walkField({
|
569
|
+
value: el,
|
570
|
+
fields: arrayFields,
|
571
|
+
map,
|
572
|
+
propKey,
|
573
|
+
propPath: `${propPath}[${idx}]`,
|
574
|
+
id,
|
575
|
+
config,
|
576
|
+
recurseSlots
|
577
|
+
})
|
578
|
+
);
|
579
|
+
if (containsPromise(newValue)) {
|
580
|
+
return Promise.all(newValue);
|
581
|
+
}
|
582
|
+
return newValue;
|
583
|
+
} else if ("$$typeof" in value) {
|
584
|
+
return value;
|
585
|
+
} else {
|
586
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
587
|
+
return walkObject({
|
588
|
+
value,
|
589
|
+
fields: objectFields,
|
590
|
+
map,
|
591
|
+
id,
|
592
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
593
|
+
config,
|
594
|
+
recurseSlots
|
595
|
+
});
|
596
|
+
}
|
597
|
+
}
|
598
|
+
return value;
|
599
|
+
};
|
600
|
+
var walkObject = ({
|
601
|
+
value,
|
602
|
+
fields,
|
603
|
+
map,
|
604
|
+
id,
|
605
|
+
getPropPath,
|
606
|
+
config,
|
607
|
+
recurseSlots
|
608
|
+
}) => {
|
609
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
610
|
+
const opts = {
|
611
|
+
value: v,
|
612
|
+
fields,
|
613
|
+
map,
|
614
|
+
propKey: k,
|
615
|
+
propPath: getPropPath(k),
|
616
|
+
id,
|
617
|
+
config,
|
618
|
+
recurseSlots
|
619
|
+
};
|
620
|
+
const newValue = walkField(opts);
|
621
|
+
if (isPromise(newValue)) {
|
622
|
+
return newValue.then((resolvedValue) => ({
|
623
|
+
[k]: resolvedValue
|
624
|
+
}));
|
625
|
+
}
|
626
|
+
return {
|
627
|
+
[k]: newValue
|
628
|
+
};
|
629
|
+
}, {});
|
630
|
+
if (containsPromise(newProps)) {
|
631
|
+
return Promise.all(newProps).then(flatten);
|
632
|
+
}
|
633
|
+
return flatten(newProps);
|
634
|
+
};
|
635
|
+
function mapSlots(item, map, config, recurseSlots = false) {
|
636
|
+
var _a, _b, _c, _d;
|
637
|
+
const itemType = "type" in item ? item.type : "root";
|
638
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
639
|
+
const newProps = walkObject({
|
640
|
+
value: (_b = item.props) != null ? _b : {},
|
641
|
+
fields: (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {},
|
642
|
+
map,
|
643
|
+
id: item.props ? (_d = item.props.id) != null ? _d : "root" : "root",
|
644
|
+
getPropPath: (k) => k,
|
645
|
+
config,
|
646
|
+
recurseSlots
|
647
|
+
});
|
648
|
+
if (isPromise(newProps)) {
|
649
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
650
|
+
props: resolvedProps
|
651
|
+
}));
|
652
|
+
}
|
653
|
+
return __spreadProps(__spreadValues({}, item), {
|
654
|
+
props: newProps
|
655
|
+
});
|
656
|
+
}
|
657
|
+
|
658
|
+
// ../core/lib/data/flatten-node.ts
|
659
|
+
init_react_import();
|
660
|
+
var import_flat = __toESM(require_flat());
|
661
|
+
|
447
662
|
// ../core/lib/data/strip-slots.ts
|
448
663
|
init_react_import();
|
449
|
-
var stripSlots = (data) => {
|
450
|
-
return
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
},
|
458
|
-
{ id: data.props.id }
|
459
|
-
)
|
664
|
+
var stripSlots = (data, config) => {
|
665
|
+
return mapSlots(data, () => null, config);
|
666
|
+
};
|
667
|
+
|
668
|
+
// ../core/lib/data/flatten-node.ts
|
669
|
+
var flattenNode = (node, config) => {
|
670
|
+
return __spreadProps(__spreadValues({}, node), {
|
671
|
+
props: (0, import_flat.flatten)(stripSlots(node, config).props)
|
460
672
|
});
|
461
673
|
};
|
462
674
|
|
@@ -502,10 +714,9 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
502
714
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
503
715
|
if (!mappedItem) return item;
|
504
716
|
const id = mappedItem.props.id;
|
505
|
-
const newProps = __spreadValues({},
|
506
|
-
forEachSlot(
|
717
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
507
718
|
mappedItem,
|
508
|
-
(parentId2, slotId
|
719
|
+
(content, parentId2, slotId) => {
|
509
720
|
const zoneCompound = `${parentId2}:${slotId}`;
|
510
721
|
const [_2, newContent2] = processContent(
|
511
722
|
path,
|
@@ -514,18 +725,19 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
514
725
|
"slot",
|
515
726
|
parentId2
|
516
727
|
);
|
517
|
-
|
728
|
+
return newContent2;
|
518
729
|
},
|
519
|
-
|
520
|
-
|
521
|
-
|
730
|
+
config
|
731
|
+
).props), {
|
732
|
+
id
|
733
|
+
});
|
522
734
|
processRelatedZones(item, id, path);
|
523
735
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
524
736
|
const thisZoneCompound = path[path.length - 1];
|
525
737
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
526
738
|
newNodeIndex[id] = {
|
527
739
|
data: newItem,
|
528
|
-
flatData:
|
740
|
+
flatData: flattenNode(newItem, config),
|
529
741
|
path,
|
530
742
|
parentId,
|
531
743
|
zone
|
@@ -685,56 +897,17 @@ init_react_import();
|
|
685
897
|
|
686
898
|
// ../core/lib/data/walk-tree.ts
|
687
899
|
init_react_import();
|
688
|
-
|
689
|
-
// ../core/lib/data/map-slots.ts
|
690
|
-
init_react_import();
|
691
|
-
function mapSlotsAsync(_0, _1) {
|
692
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
693
|
-
const props = __spreadValues({}, item.props);
|
694
|
-
const propKeys = Object.keys(props);
|
695
|
-
for (let i = 0; i < propKeys.length; i++) {
|
696
|
-
const propKey = propKeys[i];
|
697
|
-
const itemType = "type" in item ? item.type : "root";
|
698
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
699
|
-
const content = props[propKey];
|
700
|
-
const mappedContent = recursive ? yield Promise.all(
|
701
|
-
content.map((item2) => __async(this, null, function* () {
|
702
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
703
|
-
}))
|
704
|
-
) : content;
|
705
|
-
props[propKey] = yield map(mappedContent, propKey);
|
706
|
-
}
|
707
|
-
}
|
708
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
709
|
-
});
|
710
|
-
}
|
711
|
-
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
712
|
-
var _a, _b;
|
713
|
-
const props = __spreadValues({}, item.props);
|
714
|
-
const propKeys = Object.keys(props);
|
715
|
-
for (let i = 0; i < propKeys.length; i++) {
|
716
|
-
const propKey = propKeys[i];
|
717
|
-
const itemType = "type" in item ? item.type : "root";
|
718
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
719
|
-
const content = props[propKey];
|
720
|
-
const mappedContent = content.map((item2) => {
|
721
|
-
return mapSlotsSync(item2, map, isSlot2);
|
722
|
-
});
|
723
|
-
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
724
|
-
}
|
725
|
-
}
|
726
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
727
|
-
}
|
728
|
-
|
729
|
-
// ../core/lib/data/walk-tree.ts
|
730
900
|
function walkTree(data, config, callbackFn) {
|
731
901
|
var _a, _b;
|
732
|
-
const isSlot2 = createIsSlotConfig(config);
|
733
902
|
const walkItem = (item) => {
|
734
|
-
return
|
903
|
+
return mapSlots(
|
735
904
|
item,
|
736
|
-
(content, parentId, propName) =>
|
737
|
-
|
905
|
+
(content, parentId, propName) => {
|
906
|
+
var _a2;
|
907
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
908
|
+
},
|
909
|
+
config,
|
910
|
+
true
|
738
911
|
);
|
739
912
|
};
|
740
913
|
if ("props" in data) {
|
@@ -763,7 +936,7 @@ var populateIds = (data, config, override = false) => {
|
|
763
936
|
const id = generateId(data.type);
|
764
937
|
return walkTree(
|
765
938
|
__spreadProps(__spreadValues({}, data), {
|
766
|
-
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({
|
939
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
767
940
|
}),
|
768
941
|
config,
|
769
942
|
(contents) => contents.map((item) => {
|
@@ -1420,7 +1593,11 @@ var createNodesSlice = (set, get) => ({
|
|
1420
1593
|
const s = get().nodes;
|
1421
1594
|
const emptyNode = {
|
1422
1595
|
id,
|
1423
|
-
methods: {
|
1596
|
+
methods: {
|
1597
|
+
sync: () => null,
|
1598
|
+
hideOverlay: () => null,
|
1599
|
+
showOverlay: () => null
|
1600
|
+
},
|
1424
1601
|
element: null
|
1425
1602
|
};
|
1426
1603
|
const existingNode = s.nodes[id];
|
@@ -1471,12 +1648,13 @@ var flattenData = (state, config) => {
|
|
1471
1648
|
|
1472
1649
|
// ../core/lib/get-changed.ts
|
1473
1650
|
init_react_import();
|
1651
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1474
1652
|
var getChanged = (newItem, oldItem) => {
|
1475
1653
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1476
1654
|
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1477
1655
|
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1478
1656
|
return __spreadProps(__spreadValues({}, acc), {
|
1479
|
-
[item]: oldItemProps[item]
|
1657
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1480
1658
|
});
|
1481
1659
|
}, {}) : {};
|
1482
1660
|
};
|
@@ -1601,14 +1779,16 @@ var createFieldsSlice = (_set, _get) => {
|
|
1601
1779
|
|
1602
1780
|
// ../core/lib/resolve-component-data.ts
|
1603
1781
|
init_react_import();
|
1604
|
-
var
|
1782
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1605
1783
|
var cache = { lastChange: {} };
|
1606
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace"
|
1784
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1607
1785
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1608
|
-
|
1609
|
-
|
1786
|
+
const resolvedItem = __spreadValues({}, item);
|
1787
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1788
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1789
|
+
if (shouldRunResolver) {
|
1610
1790
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1611
|
-
if (item && (0,
|
1791
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1612
1792
|
return { node: resolved, didChange: false };
|
1613
1793
|
}
|
1614
1794
|
const changed = getChanged(item, oldItem);
|
@@ -1621,46 +1801,42 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1621
1801
|
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1622
1802
|
trigger
|
1623
1803
|
});
|
1624
|
-
|
1625
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1626
|
-
});
|
1627
|
-
if (recursive) {
|
1628
|
-
resolvedItem = yield mapSlotsAsync(
|
1629
|
-
resolvedItem,
|
1630
|
-
(content) => __async(void 0, null, function* () {
|
1631
|
-
return Promise.all(
|
1632
|
-
content.map(
|
1633
|
-
(childItem) => __async(void 0, null, function* () {
|
1634
|
-
return (yield resolveComponentData(
|
1635
|
-
childItem,
|
1636
|
-
config,
|
1637
|
-
metadata,
|
1638
|
-
onResolveStart,
|
1639
|
-
onResolveEnd,
|
1640
|
-
trigger,
|
1641
|
-
false
|
1642
|
-
)).node;
|
1643
|
-
})
|
1644
|
-
)
|
1645
|
-
);
|
1646
|
-
}),
|
1647
|
-
false,
|
1648
|
-
createIsSlotConfig(config)
|
1649
|
-
);
|
1650
|
-
}
|
1804
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1651
1805
|
if (Object.keys(readOnly).length) {
|
1652
1806
|
resolvedItem.readOnly = readOnly;
|
1653
1807
|
}
|
1654
|
-
cache.lastChange[id] = {
|
1655
|
-
item,
|
1656
|
-
resolved: resolvedItem
|
1657
|
-
};
|
1658
|
-
if (onResolveEnd) {
|
1659
|
-
onResolveEnd(resolvedItem);
|
1660
|
-
}
|
1661
|
-
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
1662
1808
|
}
|
1663
|
-
|
1809
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1810
|
+
resolvedItem,
|
1811
|
+
(content) => __async(void 0, null, function* () {
|
1812
|
+
return yield Promise.all(
|
1813
|
+
content.map(
|
1814
|
+
(childItem) => __async(void 0, null, function* () {
|
1815
|
+
return (yield resolveComponentData(
|
1816
|
+
childItem,
|
1817
|
+
config,
|
1818
|
+
metadata,
|
1819
|
+
onResolveStart,
|
1820
|
+
onResolveEnd,
|
1821
|
+
trigger
|
1822
|
+
)).node;
|
1823
|
+
})
|
1824
|
+
)
|
1825
|
+
);
|
1826
|
+
}),
|
1827
|
+
config
|
1828
|
+
);
|
1829
|
+
if (shouldRunResolver && onResolveEnd) {
|
1830
|
+
onResolveEnd(resolvedItem);
|
1831
|
+
}
|
1832
|
+
cache.lastChange[id] = {
|
1833
|
+
item,
|
1834
|
+
resolved: itemWithResolvedChildren
|
1835
|
+
};
|
1836
|
+
return {
|
1837
|
+
node: itemWithResolvedChildren,
|
1838
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
1839
|
+
};
|
1664
1840
|
});
|
1665
1841
|
|
1666
1842
|
// ../core/lib/data/to-root.ts
|
package/dist/index.mjs
CHANGED
@@ -146,6 +146,120 @@ var require_classnames = __commonJS({
|
|
146
146
|
}
|
147
147
|
});
|
148
148
|
|
149
|
+
// ../../node_modules/flat/index.js
|
150
|
+
var require_flat = __commonJS({
|
151
|
+
"../../node_modules/flat/index.js"(exports, module) {
|
152
|
+
"use strict";
|
153
|
+
init_react_import();
|
154
|
+
module.exports = flatten3;
|
155
|
+
flatten3.flatten = flatten3;
|
156
|
+
flatten3.unflatten = unflatten2;
|
157
|
+
function isBuffer(obj) {
|
158
|
+
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
159
|
+
}
|
160
|
+
function keyIdentity(key) {
|
161
|
+
return key;
|
162
|
+
}
|
163
|
+
function flatten3(target, opts) {
|
164
|
+
opts = opts || {};
|
165
|
+
const delimiter = opts.delimiter || ".";
|
166
|
+
const maxDepth = opts.maxDepth;
|
167
|
+
const transformKey = opts.transformKey || keyIdentity;
|
168
|
+
const output = {};
|
169
|
+
function step(object, prev, currentDepth) {
|
170
|
+
currentDepth = currentDepth || 1;
|
171
|
+
Object.keys(object).forEach(function(key) {
|
172
|
+
const value = object[key];
|
173
|
+
const isarray = opts.safe && Array.isArray(value);
|
174
|
+
const type = Object.prototype.toString.call(value);
|
175
|
+
const isbuffer = isBuffer(value);
|
176
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
177
|
+
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
178
|
+
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
|
179
|
+
return step(value, newKey, currentDepth + 1);
|
180
|
+
}
|
181
|
+
output[newKey] = value;
|
182
|
+
});
|
183
|
+
}
|
184
|
+
step(target);
|
185
|
+
return output;
|
186
|
+
}
|
187
|
+
function unflatten2(target, opts) {
|
188
|
+
opts = opts || {};
|
189
|
+
const delimiter = opts.delimiter || ".";
|
190
|
+
const overwrite = opts.overwrite || false;
|
191
|
+
const transformKey = opts.transformKey || keyIdentity;
|
192
|
+
const result = {};
|
193
|
+
const isbuffer = isBuffer(target);
|
194
|
+
if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
|
195
|
+
return target;
|
196
|
+
}
|
197
|
+
function getkey(key) {
|
198
|
+
const parsedKey = Number(key);
|
199
|
+
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
200
|
+
}
|
201
|
+
function addKeys(keyPrefix, recipient, target2) {
|
202
|
+
return Object.keys(target2).reduce(function(result2, key) {
|
203
|
+
result2[keyPrefix + delimiter + key] = target2[key];
|
204
|
+
return result2;
|
205
|
+
}, recipient);
|
206
|
+
}
|
207
|
+
function isEmpty(val) {
|
208
|
+
const type = Object.prototype.toString.call(val);
|
209
|
+
const isArray = type === "[object Array]";
|
210
|
+
const isObject = type === "[object Object]";
|
211
|
+
if (!val) {
|
212
|
+
return true;
|
213
|
+
} else if (isArray) {
|
214
|
+
return !val.length;
|
215
|
+
} else if (isObject) {
|
216
|
+
return !Object.keys(val).length;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
target = Object.keys(target).reduce(function(result2, key) {
|
220
|
+
const type = Object.prototype.toString.call(target[key]);
|
221
|
+
const isObject = type === "[object Object]" || type === "[object Array]";
|
222
|
+
if (!isObject || isEmpty(target[key])) {
|
223
|
+
result2[key] = target[key];
|
224
|
+
return result2;
|
225
|
+
} else {
|
226
|
+
return addKeys(
|
227
|
+
key,
|
228
|
+
result2,
|
229
|
+
flatten3(target[key], opts)
|
230
|
+
);
|
231
|
+
}
|
232
|
+
}, {});
|
233
|
+
Object.keys(target).forEach(function(key) {
|
234
|
+
const split = key.split(delimiter).map(transformKey);
|
235
|
+
let key1 = getkey(split.shift());
|
236
|
+
let key2 = getkey(split[0]);
|
237
|
+
let recipient = result;
|
238
|
+
while (key2 !== void 0) {
|
239
|
+
if (key1 === "__proto__") {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
243
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
244
|
+
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
|
248
|
+
recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
249
|
+
}
|
250
|
+
recipient = recipient[key1];
|
251
|
+
if (split.length > 0) {
|
252
|
+
key1 = getkey(split.shift());
|
253
|
+
key2 = getkey(split[0]);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
recipient[key1] = unflatten2(target[key], opts);
|
257
|
+
});
|
258
|
+
return result;
|
259
|
+
}
|
260
|
+
}
|
261
|
+
});
|
262
|
+
|
149
263
|
// ../../node_modules/fast-deep-equal/index.js
|
150
264
|
var require_fast_deep_equal = __commonJS({
|
151
265
|
"../../node_modules/fast-deep-equal/index.js"(exports, module) {
|
@@ -362,43 +476,6 @@ init_react_import();
|
|
362
476
|
// ../core/lib/data/walk-app-state.ts
|
363
477
|
init_react_import();
|
364
478
|
|
365
|
-
// ../core/lib/data/for-each-slot.ts
|
366
|
-
init_react_import();
|
367
|
-
|
368
|
-
// ../core/lib/data/is-slot.ts
|
369
|
-
init_react_import();
|
370
|
-
var isSlot = (prop) => {
|
371
|
-
var _a, _b;
|
372
|
-
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
373
|
-
};
|
374
|
-
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
375
|
-
var _a, _b;
|
376
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
377
|
-
if (!configForComponent) return isSlot(propValue);
|
378
|
-
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
379
|
-
};
|
380
|
-
|
381
|
-
// ../core/lib/data/for-each-slot.ts
|
382
|
-
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
383
|
-
const props = item.props || {};
|
384
|
-
const propKeys = Object.keys(props);
|
385
|
-
for (let i = 0; i < propKeys.length; i++) {
|
386
|
-
const propKey = propKeys[i];
|
387
|
-
const itemType = "type" in item ? item.type : "root";
|
388
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
389
|
-
const content = props[propKey];
|
390
|
-
cb(props.id, propKey, content);
|
391
|
-
if (recursive) {
|
392
|
-
content.forEach(
|
393
|
-
(childItem) => __async(void 0, null, function* () {
|
394
|
-
return forEachSlot(childItem, cb, true, isSlot2);
|
395
|
-
})
|
396
|
-
);
|
397
|
-
}
|
398
|
-
}
|
399
|
-
}
|
400
|
-
};
|
401
|
-
|
402
479
|
// ../core/lib/data/for-related-zones.ts
|
403
480
|
init_react_import();
|
404
481
|
|
@@ -432,19 +509,154 @@ function forRelatedZones(item, data, cb, path = []) {
|
|
432
509
|
});
|
433
510
|
}
|
434
511
|
|
512
|
+
// ../core/lib/data/map-slots.ts
|
513
|
+
init_react_import();
|
514
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
515
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
516
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
517
|
+
var walkField = ({
|
518
|
+
value,
|
519
|
+
fields,
|
520
|
+
map,
|
521
|
+
propKey = "",
|
522
|
+
propPath = "",
|
523
|
+
id = "",
|
524
|
+
config,
|
525
|
+
recurseSlots = false
|
526
|
+
}) => {
|
527
|
+
var _a, _b, _c;
|
528
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
529
|
+
const content = value || [];
|
530
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
531
|
+
var _a2;
|
532
|
+
const componentConfig = config.components[el.type];
|
533
|
+
if (!componentConfig) {
|
534
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
535
|
+
}
|
536
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
537
|
+
return walkField({
|
538
|
+
value: el,
|
539
|
+
fields: fields2,
|
540
|
+
map,
|
541
|
+
id: el.props.id,
|
542
|
+
config,
|
543
|
+
recurseSlots
|
544
|
+
});
|
545
|
+
}) : content;
|
546
|
+
if (containsPromise(mappedContent)) {
|
547
|
+
return Promise.all(mappedContent);
|
548
|
+
}
|
549
|
+
return map(mappedContent, id, propPath, fields[propKey], propPath);
|
550
|
+
}
|
551
|
+
if (value && typeof value === "object") {
|
552
|
+
if (Array.isArray(value)) {
|
553
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
554
|
+
if (!arrayFields) return value;
|
555
|
+
const newValue = value.map(
|
556
|
+
(el, idx) => walkField({
|
557
|
+
value: el,
|
558
|
+
fields: arrayFields,
|
559
|
+
map,
|
560
|
+
propKey,
|
561
|
+
propPath: `${propPath}[${idx}]`,
|
562
|
+
id,
|
563
|
+
config,
|
564
|
+
recurseSlots
|
565
|
+
})
|
566
|
+
);
|
567
|
+
if (containsPromise(newValue)) {
|
568
|
+
return Promise.all(newValue);
|
569
|
+
}
|
570
|
+
return newValue;
|
571
|
+
} else if ("$$typeof" in value) {
|
572
|
+
return value;
|
573
|
+
} else {
|
574
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
575
|
+
return walkObject({
|
576
|
+
value,
|
577
|
+
fields: objectFields,
|
578
|
+
map,
|
579
|
+
id,
|
580
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
581
|
+
config,
|
582
|
+
recurseSlots
|
583
|
+
});
|
584
|
+
}
|
585
|
+
}
|
586
|
+
return value;
|
587
|
+
};
|
588
|
+
var walkObject = ({
|
589
|
+
value,
|
590
|
+
fields,
|
591
|
+
map,
|
592
|
+
id,
|
593
|
+
getPropPath,
|
594
|
+
config,
|
595
|
+
recurseSlots
|
596
|
+
}) => {
|
597
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
598
|
+
const opts = {
|
599
|
+
value: v,
|
600
|
+
fields,
|
601
|
+
map,
|
602
|
+
propKey: k,
|
603
|
+
propPath: getPropPath(k),
|
604
|
+
id,
|
605
|
+
config,
|
606
|
+
recurseSlots
|
607
|
+
};
|
608
|
+
const newValue = walkField(opts);
|
609
|
+
if (isPromise(newValue)) {
|
610
|
+
return newValue.then((resolvedValue) => ({
|
611
|
+
[k]: resolvedValue
|
612
|
+
}));
|
613
|
+
}
|
614
|
+
return {
|
615
|
+
[k]: newValue
|
616
|
+
};
|
617
|
+
}, {});
|
618
|
+
if (containsPromise(newProps)) {
|
619
|
+
return Promise.all(newProps).then(flatten);
|
620
|
+
}
|
621
|
+
return flatten(newProps);
|
622
|
+
};
|
623
|
+
function mapSlots(item, map, config, recurseSlots = false) {
|
624
|
+
var _a, _b, _c, _d;
|
625
|
+
const itemType = "type" in item ? item.type : "root";
|
626
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
627
|
+
const newProps = walkObject({
|
628
|
+
value: (_b = item.props) != null ? _b : {},
|
629
|
+
fields: (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {},
|
630
|
+
map,
|
631
|
+
id: item.props ? (_d = item.props.id) != null ? _d : "root" : "root",
|
632
|
+
getPropPath: (k) => k,
|
633
|
+
config,
|
634
|
+
recurseSlots
|
635
|
+
});
|
636
|
+
if (isPromise(newProps)) {
|
637
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
638
|
+
props: resolvedProps
|
639
|
+
}));
|
640
|
+
}
|
641
|
+
return __spreadProps(__spreadValues({}, item), {
|
642
|
+
props: newProps
|
643
|
+
});
|
644
|
+
}
|
645
|
+
|
646
|
+
// ../core/lib/data/flatten-node.ts
|
647
|
+
init_react_import();
|
648
|
+
var import_flat = __toESM(require_flat());
|
649
|
+
|
435
650
|
// ../core/lib/data/strip-slots.ts
|
436
651
|
init_react_import();
|
437
|
-
var stripSlots = (data) => {
|
438
|
-
return
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
},
|
446
|
-
{ id: data.props.id }
|
447
|
-
)
|
652
|
+
var stripSlots = (data, config) => {
|
653
|
+
return mapSlots(data, () => null, config);
|
654
|
+
};
|
655
|
+
|
656
|
+
// ../core/lib/data/flatten-node.ts
|
657
|
+
var flattenNode = (node, config) => {
|
658
|
+
return __spreadProps(__spreadValues({}, node), {
|
659
|
+
props: (0, import_flat.flatten)(stripSlots(node, config).props)
|
448
660
|
});
|
449
661
|
};
|
450
662
|
|
@@ -490,10 +702,9 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
490
702
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
491
703
|
if (!mappedItem) return item;
|
492
704
|
const id = mappedItem.props.id;
|
493
|
-
const newProps = __spreadValues({},
|
494
|
-
forEachSlot(
|
705
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
495
706
|
mappedItem,
|
496
|
-
(parentId2, slotId
|
707
|
+
(content, parentId2, slotId) => {
|
497
708
|
const zoneCompound = `${parentId2}:${slotId}`;
|
498
709
|
const [_2, newContent2] = processContent(
|
499
710
|
path,
|
@@ -502,18 +713,19 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
502
713
|
"slot",
|
503
714
|
parentId2
|
504
715
|
);
|
505
|
-
|
716
|
+
return newContent2;
|
506
717
|
},
|
507
|
-
|
508
|
-
|
509
|
-
|
718
|
+
config
|
719
|
+
).props), {
|
720
|
+
id
|
721
|
+
});
|
510
722
|
processRelatedZones(item, id, path);
|
511
723
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
512
724
|
const thisZoneCompound = path[path.length - 1];
|
513
725
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
514
726
|
newNodeIndex[id] = {
|
515
727
|
data: newItem,
|
516
|
-
flatData:
|
728
|
+
flatData: flattenNode(newItem, config),
|
517
729
|
path,
|
518
730
|
parentId,
|
519
731
|
zone
|
@@ -673,56 +885,17 @@ init_react_import();
|
|
673
885
|
|
674
886
|
// ../core/lib/data/walk-tree.ts
|
675
887
|
init_react_import();
|
676
|
-
|
677
|
-
// ../core/lib/data/map-slots.ts
|
678
|
-
init_react_import();
|
679
|
-
function mapSlotsAsync(_0, _1) {
|
680
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
681
|
-
const props = __spreadValues({}, item.props);
|
682
|
-
const propKeys = Object.keys(props);
|
683
|
-
for (let i = 0; i < propKeys.length; i++) {
|
684
|
-
const propKey = propKeys[i];
|
685
|
-
const itemType = "type" in item ? item.type : "root";
|
686
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
687
|
-
const content = props[propKey];
|
688
|
-
const mappedContent = recursive ? yield Promise.all(
|
689
|
-
content.map((item2) => __async(this, null, function* () {
|
690
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
691
|
-
}))
|
692
|
-
) : content;
|
693
|
-
props[propKey] = yield map(mappedContent, propKey);
|
694
|
-
}
|
695
|
-
}
|
696
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
697
|
-
});
|
698
|
-
}
|
699
|
-
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
700
|
-
var _a, _b;
|
701
|
-
const props = __spreadValues({}, item.props);
|
702
|
-
const propKeys = Object.keys(props);
|
703
|
-
for (let i = 0; i < propKeys.length; i++) {
|
704
|
-
const propKey = propKeys[i];
|
705
|
-
const itemType = "type" in item ? item.type : "root";
|
706
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
707
|
-
const content = props[propKey];
|
708
|
-
const mappedContent = content.map((item2) => {
|
709
|
-
return mapSlotsSync(item2, map, isSlot2);
|
710
|
-
});
|
711
|
-
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
712
|
-
}
|
713
|
-
}
|
714
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
715
|
-
}
|
716
|
-
|
717
|
-
// ../core/lib/data/walk-tree.ts
|
718
888
|
function walkTree(data, config, callbackFn) {
|
719
889
|
var _a, _b;
|
720
|
-
const isSlot2 = createIsSlotConfig(config);
|
721
890
|
const walkItem = (item) => {
|
722
|
-
return
|
891
|
+
return mapSlots(
|
723
892
|
item,
|
724
|
-
(content, parentId, propName) =>
|
725
|
-
|
893
|
+
(content, parentId, propName) => {
|
894
|
+
var _a2;
|
895
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
896
|
+
},
|
897
|
+
config,
|
898
|
+
true
|
726
899
|
);
|
727
900
|
};
|
728
901
|
if ("props" in data) {
|
@@ -751,7 +924,7 @@ var populateIds = (data, config, override = false) => {
|
|
751
924
|
const id = generateId(data.type);
|
752
925
|
return walkTree(
|
753
926
|
__spreadProps(__spreadValues({}, data), {
|
754
|
-
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({
|
927
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
755
928
|
}),
|
756
929
|
config,
|
757
930
|
(contents) => contents.map((item) => {
|
@@ -1408,7 +1581,11 @@ var createNodesSlice = (set, get) => ({
|
|
1408
1581
|
const s = get().nodes;
|
1409
1582
|
const emptyNode = {
|
1410
1583
|
id,
|
1411
|
-
methods: {
|
1584
|
+
methods: {
|
1585
|
+
sync: () => null,
|
1586
|
+
hideOverlay: () => null,
|
1587
|
+
showOverlay: () => null
|
1588
|
+
},
|
1412
1589
|
element: null
|
1413
1590
|
};
|
1414
1591
|
const existingNode = s.nodes[id];
|
@@ -1459,12 +1636,13 @@ var flattenData = (state, config) => {
|
|
1459
1636
|
|
1460
1637
|
// ../core/lib/get-changed.ts
|
1461
1638
|
init_react_import();
|
1639
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1462
1640
|
var getChanged = (newItem, oldItem) => {
|
1463
1641
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1464
1642
|
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1465
1643
|
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1466
1644
|
return __spreadProps(__spreadValues({}, acc), {
|
1467
|
-
[item]: oldItemProps[item]
|
1645
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1468
1646
|
});
|
1469
1647
|
}, {}) : {};
|
1470
1648
|
};
|
@@ -1589,14 +1767,16 @@ var createFieldsSlice = (_set, _get) => {
|
|
1589
1767
|
|
1590
1768
|
// ../core/lib/resolve-component-data.ts
|
1591
1769
|
init_react_import();
|
1592
|
-
var
|
1770
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1593
1771
|
var cache = { lastChange: {} };
|
1594
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace"
|
1772
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1595
1773
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1596
|
-
|
1597
|
-
|
1774
|
+
const resolvedItem = __spreadValues({}, item);
|
1775
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1776
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1777
|
+
if (shouldRunResolver) {
|
1598
1778
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1599
|
-
if (item && (0,
|
1779
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1600
1780
|
return { node: resolved, didChange: false };
|
1601
1781
|
}
|
1602
1782
|
const changed = getChanged(item, oldItem);
|
@@ -1609,46 +1789,42 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1609
1789
|
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1610
1790
|
trigger
|
1611
1791
|
});
|
1612
|
-
|
1613
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1614
|
-
});
|
1615
|
-
if (recursive) {
|
1616
|
-
resolvedItem = yield mapSlotsAsync(
|
1617
|
-
resolvedItem,
|
1618
|
-
(content) => __async(void 0, null, function* () {
|
1619
|
-
return Promise.all(
|
1620
|
-
content.map(
|
1621
|
-
(childItem) => __async(void 0, null, function* () {
|
1622
|
-
return (yield resolveComponentData(
|
1623
|
-
childItem,
|
1624
|
-
config,
|
1625
|
-
metadata,
|
1626
|
-
onResolveStart,
|
1627
|
-
onResolveEnd,
|
1628
|
-
trigger,
|
1629
|
-
false
|
1630
|
-
)).node;
|
1631
|
-
})
|
1632
|
-
)
|
1633
|
-
);
|
1634
|
-
}),
|
1635
|
-
false,
|
1636
|
-
createIsSlotConfig(config)
|
1637
|
-
);
|
1638
|
-
}
|
1792
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1639
1793
|
if (Object.keys(readOnly).length) {
|
1640
1794
|
resolvedItem.readOnly = readOnly;
|
1641
1795
|
}
|
1642
|
-
cache.lastChange[id] = {
|
1643
|
-
item,
|
1644
|
-
resolved: resolvedItem
|
1645
|
-
};
|
1646
|
-
if (onResolveEnd) {
|
1647
|
-
onResolveEnd(resolvedItem);
|
1648
|
-
}
|
1649
|
-
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
1650
1796
|
}
|
1651
|
-
|
1797
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1798
|
+
resolvedItem,
|
1799
|
+
(content) => __async(void 0, null, function* () {
|
1800
|
+
return yield Promise.all(
|
1801
|
+
content.map(
|
1802
|
+
(childItem) => __async(void 0, null, function* () {
|
1803
|
+
return (yield resolveComponentData(
|
1804
|
+
childItem,
|
1805
|
+
config,
|
1806
|
+
metadata,
|
1807
|
+
onResolveStart,
|
1808
|
+
onResolveEnd,
|
1809
|
+
trigger
|
1810
|
+
)).node;
|
1811
|
+
})
|
1812
|
+
)
|
1813
|
+
);
|
1814
|
+
}),
|
1815
|
+
config
|
1816
|
+
);
|
1817
|
+
if (shouldRunResolver && onResolveEnd) {
|
1818
|
+
onResolveEnd(resolvedItem);
|
1819
|
+
}
|
1820
|
+
cache.lastChange[id] = {
|
1821
|
+
item,
|
1822
|
+
resolved: itemWithResolvedChildren
|
1823
|
+
};
|
1824
|
+
return {
|
1825
|
+
node: itemWithResolvedChildren,
|
1826
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
1827
|
+
};
|
1652
1828
|
});
|
1653
1829
|
|
1654
1830
|
// ../core/lib/data/to-root.ts
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
3
|
-
"version": "0.19.0-canary.
|
3
|
+
"version": "0.19.0-canary.af1dc891",
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"dist"
|
26
26
|
],
|
27
27
|
"devDependencies": {
|
28
|
-
"@measured/puck": "^0.19.0-canary.
|
28
|
+
"@measured/puck": "^0.19.0-canary.af1dc891",
|
29
29
|
"@types/react": "^19.0.1",
|
30
30
|
"@types/react-dom": "^19.0.2",
|
31
31
|
"eslint": "^7.32.0",
|