@measured/puck-plugin-heading-analyzer 0.19.0-canary.896a6279 → 0.19.0-canary.8e1d7223

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.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) {
@@ -371,45 +485,8 @@ init_react_import();
371
485
  // ../core/reducer/actions/set.ts
372
486
  init_react_import();
373
487
 
374
- // ../core/lib/data/walk-tree.ts
375
- init_react_import();
376
-
377
- // ../core/lib/data/for-each-slot.ts
378
- init_react_import();
379
-
380
- // ../core/lib/data/is-slot.ts
488
+ // ../core/lib/data/walk-app-state.ts
381
489
  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
490
 
414
491
  // ../core/lib/data/for-related-zones.ts
415
492
  init_react_import();
@@ -444,24 +521,159 @@ 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 __spreadProps(__spreadValues({}, data), {
451
- props: Object.entries(data.props).reduce(
452
- (acc, [propKey, propVal]) => {
453
- if (isSlot(propVal)) {
454
- return acc;
455
- }
456
- return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
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
 
463
- // ../core/lib/data/walk-tree.ts
464
- function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
675
+ // ../core/lib/data/walk-app-state.ts
676
+ function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
465
677
  var _a;
466
678
  let newZones = {};
467
679
  const newZoneIndex = {};
@@ -502,10 +714,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
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({}, mappedItem.props);
506
- forEachSlot(
717
+ const newProps = __spreadProps(__spreadValues({}, mapSlots(
507
718
  mappedItem,
508
- (parentId2, slotId, content) => {
719
+ (content, parentId2, slotId) => {
509
720
  const zoneCompound = `${parentId2}:${slotId}`;
510
721
  const [_2, newContent2] = processContent(
511
722
  path,
@@ -514,18 +725,19 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
514
725
  "slot",
515
726
  parentId2
516
727
  );
517
- newProps[slotId] = newContent2;
728
+ return newContent2;
518
729
  },
519
- false,
520
- createIsSlotConfig(config)
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: stripSlots(newItem),
740
+ flatData: flattenNode(newItem, config),
529
741
  path,
530
742
  parentId,
531
743
  zone
@@ -594,7 +806,7 @@ var setAction = (state, action, appStore) => {
594
806
  console.warn(
595
807
  "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
596
808
  );
597
- return walkTree(newState, appStore.config);
809
+ return walkAppState(newState, appStore.config);
598
810
  }
599
811
  return __spreadValues(__spreadValues({}, state), action.state(state));
600
812
  };
@@ -680,18 +892,77 @@ var getIdsForParent = (zoneCompound, state) => {
680
892
  return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
681
893
  };
682
894
 
895
+ // ../core/lib/data/populate-ids.ts
896
+ init_react_import();
897
+
898
+ // ../core/lib/data/walk-tree.ts
899
+ init_react_import();
900
+ function walkTree(data, config, callbackFn) {
901
+ var _a, _b;
902
+ const walkItem = (item) => {
903
+ return mapSlots(
904
+ item,
905
+ (content, parentId, propName) => {
906
+ var _a2;
907
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
908
+ },
909
+ config,
910
+ true
911
+ );
912
+ };
913
+ if ("props" in data) {
914
+ return walkItem(data);
915
+ }
916
+ const _data = data;
917
+ const zones = (_a = _data.zones) != null ? _a : {};
918
+ const mappedContent = _data.content.map(walkItem);
919
+ return {
920
+ root: walkItem(_data.root),
921
+ content: (_b = callbackFn(mappedContent, {
922
+ parentId: "root",
923
+ propName: "default-zone"
924
+ })) != null ? _b : mappedContent,
925
+ zones: Object.keys(zones).reduce(
926
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
927
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
928
+ }),
929
+ {}
930
+ )
931
+ };
932
+ }
933
+
934
+ // ../core/lib/data/populate-ids.ts
935
+ var populateIds = (data, config, override = false) => {
936
+ const id = generateId(data.type);
937
+ return walkTree(
938
+ __spreadProps(__spreadValues({}, data), {
939
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
940
+ }),
941
+ config,
942
+ (contents) => contents.map((item) => {
943
+ const id2 = generateId(item.type);
944
+ return __spreadProps(__spreadValues({}, item), {
945
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
946
+ });
947
+ })
948
+ );
949
+ };
950
+
683
951
  // ../core/reducer/actions/insert.ts
684
952
  function insertAction(state, action, appStore) {
685
953
  const id = action.id || generateId(action.componentType);
686
- const emptyComponentData = {
687
- type: action.componentType,
688
- props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
689
- id
690
- })
691
- };
954
+ const emptyComponentData = populateIds(
955
+ {
956
+ type: action.componentType,
957
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
958
+ id
959
+ })
960
+ },
961
+ appStore.config
962
+ );
692
963
  const [parentId] = action.destinationZone.split(":");
693
964
  const idsInPath = getIdsForParent(action.destinationZone, state);
694
- return walkTree(
965
+ return walkAppState(
695
966
  state,
696
967
  appStore.config,
697
968
  (content, zoneCompound) => {
@@ -729,25 +1000,26 @@ var replaceAction = (state, action, appStore) => {
729
1000
  `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
730
1001
  );
731
1002
  }
732
- return walkTree(
1003
+ const data = populateIds(action.data, appStore.config);
1004
+ return walkAppState(
733
1005
  state,
734
1006
  appStore.config,
735
1007
  (content, zoneCompound) => {
736
1008
  const newContent = [...content];
737
1009
  if (zoneCompound === action.destinationZone) {
738
- newContent[action.destinationIndex] = action.data;
1010
+ newContent[action.destinationIndex] = data;
739
1011
  }
740
1012
  return newContent;
741
1013
  },
742
1014
  (childItem, path) => {
743
1015
  const pathIds = path.map((p) => p.split(":")[0]);
744
- if (childItem.props.id === action.data.props.id) {
745
- return action.data;
1016
+ if (childItem.props.id === data.props.id) {
1017
+ return data;
746
1018
  } else if (childItem.props.id === parentId) {
747
1019
  return childItem;
748
1020
  } else if (idsInPath.indexOf(childItem.props.id) > -1) {
749
1021
  return childItem;
750
- } else if (pathIds.indexOf(action.data.props.id) > -1) {
1022
+ } else if (pathIds.indexOf(data.props.id) > -1) {
751
1023
  return childItem;
752
1024
  }
753
1025
  return null;
@@ -758,7 +1030,7 @@ var replaceAction = (state, action, appStore) => {
758
1030
  // ../core/reducer/actions/replace-root.ts
759
1031
  init_react_import();
760
1032
  var replaceRootAction = (state, action, appStore) => {
761
- return walkTree(
1033
+ return walkAppState(
762
1034
  state,
763
1035
  appStore.config,
764
1036
  (content) => content,
@@ -797,7 +1069,7 @@ function duplicateAction(state, action, appStore) {
797
1069
  id: generateId(item.type)
798
1070
  })
799
1071
  });
800
- const modified = walkTree(
1072
+ const modified = walkAppState(
801
1073
  state,
802
1074
  appStore.config,
803
1075
  (content, zoneCompound) => {
@@ -862,7 +1134,7 @@ var moveAction = (state, action, appStore) => {
862
1134
  if (!item) return state;
863
1135
  const idsInSourcePath = getIdsForParent(action.sourceZone, state);
864
1136
  const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
865
- return walkTree(
1137
+ return walkAppState(
866
1138
  state,
867
1139
  appStore.config,
868
1140
  (content, zoneCompound) => {
@@ -910,7 +1182,6 @@ var reorderAction = (state, action, appStore) => {
910
1182
  init_react_import();
911
1183
  var removeAction = (state, action, appStore) => {
912
1184
  const item = getItem({ index: action.index, zone: action.zone }, state);
913
- const [parentId] = action.zone.split(":");
914
1185
  const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
915
1186
  (acc, [nodeId, nodeData]) => {
916
1187
  const pathIds = nodeData.path.map((p) => p.split(":")[0]);
@@ -921,7 +1192,7 @@ var removeAction = (state, action, appStore) => {
921
1192
  },
922
1193
  [item.props.id]
923
1194
  );
924
- const newState = walkTree(
1195
+ const newState = walkAppState(
925
1196
  state,
926
1197
  appStore.config,
927
1198
  (content, zoneCompound) => {
@@ -929,24 +1200,17 @@ var removeAction = (state, action, appStore) => {
929
1200
  return remove(content, action.index);
930
1201
  }
931
1202
  return content;
932
- },
933
- (childItem, path) => {
934
- const parentIds = path.map((p) => p.split(":")[0]);
935
- if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
936
- return childItem;
937
- }
938
- return null;
939
1203
  }
940
1204
  );
941
1205
  Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
942
- const parentId2 = zoneCompound.split(":")[0];
943
- if (nodesToDelete.includes(parentId2) && newState.data.zones) {
1206
+ const parentId = zoneCompound.split(":")[0];
1207
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
944
1208
  delete newState.data.zones[zoneCompound];
945
1209
  }
946
1210
  });
947
1211
  Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
948
- const parentId2 = zoneCompound.split(":")[0];
949
- if (nodesToDelete.includes(parentId2)) {
1212
+ const parentId = zoneCompound.split(":")[0];
1213
+ if (nodesToDelete.includes(parentId)) {
950
1214
  delete newState.indexes.zones[zoneCompound];
951
1215
  }
952
1216
  });
@@ -1019,14 +1283,14 @@ var setDataAction = (state, action, appStore) => {
1019
1283
  console.warn(
1020
1284
  "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1021
1285
  );
1022
- return walkTree(
1286
+ return walkAppState(
1023
1287
  __spreadProps(__spreadValues({}, state), {
1024
1288
  data: __spreadValues(__spreadValues({}, state.data), action.data)
1025
1289
  }),
1026
1290
  appStore.config
1027
1291
  );
1028
1292
  }
1029
- return walkTree(
1293
+ return walkAppState(
1030
1294
  __spreadProps(__spreadValues({}, state), {
1031
1295
  data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1032
1296
  }),
@@ -1313,7 +1577,7 @@ var createHistorySlice = (set, get) => {
1313
1577
  const { dispatch, history } = get();
1314
1578
  dispatch({
1315
1579
  type: "set",
1316
- state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1580
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1317
1581
  });
1318
1582
  set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1319
1583
  },
@@ -1329,7 +1593,11 @@ var createNodesSlice = (set, get) => ({
1329
1593
  const s = get().nodes;
1330
1594
  const emptyNode = {
1331
1595
  id,
1332
- methods: { sync: () => null },
1596
+ methods: {
1597
+ sync: () => null,
1598
+ hideOverlay: () => null,
1599
+ showOverlay: () => null
1600
+ },
1333
1601
  element: null
1334
1602
  };
1335
1603
  const existingNode = s.nodes[id];
@@ -1366,7 +1634,7 @@ var import_react7 = require("react");
1366
1634
  init_react_import();
1367
1635
  var flattenData = (state, config) => {
1368
1636
  const data = [];
1369
- walkTree(
1637
+ walkAppState(
1370
1638
  state,
1371
1639
  config,
1372
1640
  (content) => content,
@@ -1380,12 +1648,13 @@ var flattenData = (state, config) => {
1380
1648
 
1381
1649
  // ../core/lib/get-changed.ts
1382
1650
  init_react_import();
1651
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1383
1652
  var getChanged = (newItem, oldItem) => {
1384
1653
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1385
1654
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1386
1655
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1387
1656
  return __spreadProps(__spreadValues({}, acc), {
1388
- [item]: oldItemProps[item] !== newItemProps[item]
1657
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1389
1658
  });
1390
1659
  }, {}) : {};
1391
1660
  };
@@ -1503,45 +1772,23 @@ var createFieldsSlice = (_set, _get) => {
1503
1772
  return {
1504
1773
  fields: {},
1505
1774
  loading: false,
1506
- lastResolvedData: {}
1775
+ lastResolvedData: {},
1776
+ id: void 0
1507
1777
  };
1508
1778
  };
1509
1779
 
1510
1780
  // ../core/lib/resolve-component-data.ts
1511
1781
  init_react_import();
1512
-
1513
- // ../core/lib/data/map-slots.ts
1514
- init_react_import();
1515
- function mapSlots(_0, _1) {
1516
- return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1517
- const props = __spreadValues({}, item.props);
1518
- const propKeys = Object.keys(props);
1519
- for (let i = 0; i < propKeys.length; i++) {
1520
- const propKey = propKeys[i];
1521
- const itemType = "type" in item ? item.type : "root";
1522
- if (isSlot2(itemType, propKey, props[propKey])) {
1523
- const content = props[propKey];
1524
- const mappedContent = recursive ? yield Promise.all(
1525
- content.map((item2) => __async(this, null, function* () {
1526
- return yield mapSlots(item2, map, recursive, isSlot2);
1527
- }))
1528
- ) : content;
1529
- props[propKey] = yield map(mappedContent, propKey);
1530
- }
1531
- }
1532
- return __spreadProps(__spreadValues({}, item), { props });
1533
- });
1534
- }
1535
-
1536
- // ../core/lib/resolve-component-data.ts
1537
- var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1782
+ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1538
1783
  var cache = { lastChange: {} };
1539
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
1784
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1540
1785
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1541
- if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
1542
- const id = "id" in item.props ? item.props.id : "root";
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) {
1543
1790
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1544
- if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
1791
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1545
1792
  return { node: resolved, didChange: false };
1546
1793
  }
1547
1794
  const changed = getChanged(item, oldItem);
@@ -1551,49 +1798,45 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
1551
1798
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1552
1799
  changed,
1553
1800
  lastData: oldItem,
1554
- metadata,
1801
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1555
1802
  trigger
1556
1803
  });
1557
- let resolvedItem = __spreadProps(__spreadValues({}, item), {
1558
- props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
1559
- });
1560
- if (recursive) {
1561
- resolvedItem = yield mapSlots(
1562
- resolvedItem,
1563
- (content) => __async(void 0, null, function* () {
1564
- return Promise.all(
1565
- content.map(
1566
- (childItem) => __async(void 0, null, function* () {
1567
- return (yield resolveComponentData(
1568
- childItem,
1569
- config,
1570
- metadata,
1571
- onResolveStart,
1572
- onResolveEnd,
1573
- trigger,
1574
- false
1575
- )).node;
1576
- })
1577
- )
1578
- );
1579
- }),
1580
- false,
1581
- createIsSlotConfig(config)
1582
- );
1583
- }
1804
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1584
1805
  if (Object.keys(readOnly).length) {
1585
1806
  resolvedItem.readOnly = readOnly;
1586
1807
  }
1587
- cache.lastChange[id] = {
1588
- item,
1589
- resolved: resolvedItem
1590
- };
1591
- if (onResolveEnd) {
1592
- onResolveEnd(resolvedItem);
1593
- }
1594
- return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
1595
1808
  }
1596
- return { node: item, didChange: false };
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
+ };
1597
1840
  });
1598
1841
 
1599
1842
  // ../core/lib/data/to-root.ts
@@ -1613,7 +1856,8 @@ var toRoot = (item) => {
1613
1856
  return { props: {}, readOnly };
1614
1857
  };
1615
1858
 
1616
- // ../core/store/index.ts
1859
+ // ../core/store/default-app-state.ts
1860
+ init_react_import();
1617
1861
  var defaultAppState = {
1618
1862
  data: { content: [], root: {}, zones: {} },
1619
1863
  ui: {
@@ -1639,6 +1883,8 @@ var defaultAppState = {
1639
1883
  zones: {}
1640
1884
  }
1641
1885
  };
1886
+
1887
+ // ../core/store/index.ts
1642
1888
  var defaultPageFields = {
1643
1889
  title: { type: "text" }
1644
1890
  };
@@ -1778,7 +2024,7 @@ var createAppStore = (initialAppStore) => create()(
1778
2024
  }),
1779
2025
  resolveAndCommitData: () => __async(void 0, null, function* () {
1780
2026
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1781
- walkTree(
2027
+ walkAppState(
1782
2028
  state,
1783
2029
  config,
1784
2030
  (content) => content,