@measured/puck-plugin-heading-analyzer 0.19.0-canary.a281c342 → 0.19.0-canary.a60c81eb
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/README.md +1 -1
- package/dist/index.d.mts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +974 -637
- package/dist/index.mjs +974 -637
- package/package.json +3 -3
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) {
|
@@ -356,26 +470,16 @@ init_react_import();
|
|
356
470
|
// ../core/reducer/index.ts
|
357
471
|
init_react_import();
|
358
472
|
|
359
|
-
// ../core/reducer/
|
473
|
+
// ../core/reducer/actions/set.ts
|
360
474
|
init_react_import();
|
361
475
|
|
362
|
-
// ../core/lib/
|
476
|
+
// ../core/lib/data/walk-app-state.ts
|
363
477
|
init_react_import();
|
364
|
-
var insert = (list, index, item) => {
|
365
|
-
const result = Array.from(list || []);
|
366
|
-
result.splice(index, 0, item);
|
367
|
-
return result;
|
368
|
-
};
|
369
478
|
|
370
|
-
// ../core/lib/
|
479
|
+
// ../core/lib/data/for-related-zones.ts
|
371
480
|
init_react_import();
|
372
|
-
var remove = (list, index) => {
|
373
|
-
const result = Array.from(list);
|
374
|
-
result.splice(index, 1);
|
375
|
-
return result;
|
376
|
-
};
|
377
481
|
|
378
|
-
// ../core/lib/
|
482
|
+
// ../core/lib/get-zone-id.ts
|
379
483
|
init_react_import();
|
380
484
|
|
381
485
|
// ../core/lib/root-droppable-id.ts
|
@@ -384,133 +488,7 @@ var rootAreaId = "root";
|
|
384
488
|
var rootZone = "default-zone";
|
385
489
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
386
490
|
|
387
|
-
// ../core/lib/setup-zone.ts
|
388
|
-
var setupZone = (data, zoneKey) => {
|
389
|
-
if (zoneKey === rootDroppableId) {
|
390
|
-
return data;
|
391
|
-
}
|
392
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
393
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
394
|
-
});
|
395
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
396
|
-
return newData;
|
397
|
-
};
|
398
|
-
|
399
|
-
// ../core/lib/get-item.ts
|
400
|
-
init_react_import();
|
401
|
-
function getItem(selector, state) {
|
402
|
-
var _a, _b;
|
403
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
404
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
405
|
-
}
|
406
|
-
|
407
|
-
// ../core/lib/generate-id.ts
|
408
|
-
init_react_import();
|
409
|
-
|
410
|
-
// ../../node_modules/uuid/dist/esm-node/index.js
|
411
|
-
init_react_import();
|
412
|
-
|
413
|
-
// ../../node_modules/uuid/dist/esm-node/rng.js
|
414
|
-
init_react_import();
|
415
|
-
import crypto from "crypto";
|
416
|
-
var rnds8Pool = new Uint8Array(256);
|
417
|
-
var poolPtr = rnds8Pool.length;
|
418
|
-
function rng() {
|
419
|
-
if (poolPtr > rnds8Pool.length - 16) {
|
420
|
-
crypto.randomFillSync(rnds8Pool);
|
421
|
-
poolPtr = 0;
|
422
|
-
}
|
423
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
424
|
-
}
|
425
|
-
|
426
|
-
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
427
|
-
init_react_import();
|
428
|
-
var byteToHex = [];
|
429
|
-
for (let i = 0; i < 256; ++i) {
|
430
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
431
|
-
}
|
432
|
-
function unsafeStringify(arr, offset = 0) {
|
433
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
434
|
-
}
|
435
|
-
|
436
|
-
// ../../node_modules/uuid/dist/esm-node/v4.js
|
437
|
-
init_react_import();
|
438
|
-
|
439
|
-
// ../../node_modules/uuid/dist/esm-node/native.js
|
440
|
-
init_react_import();
|
441
|
-
import crypto2 from "crypto";
|
442
|
-
var native_default = {
|
443
|
-
randomUUID: crypto2.randomUUID
|
444
|
-
};
|
445
|
-
|
446
|
-
// ../../node_modules/uuid/dist/esm-node/v4.js
|
447
|
-
function v4(options, buf, offset) {
|
448
|
-
if (native_default.randomUUID && !buf && !options) {
|
449
|
-
return native_default.randomUUID();
|
450
|
-
}
|
451
|
-
options = options || {};
|
452
|
-
const rnds = options.random || (options.rng || rng)();
|
453
|
-
rnds[6] = rnds[6] & 15 | 64;
|
454
|
-
rnds[8] = rnds[8] & 63 | 128;
|
455
|
-
if (buf) {
|
456
|
-
offset = offset || 0;
|
457
|
-
for (let i = 0; i < 16; ++i) {
|
458
|
-
buf[offset + i] = rnds[i];
|
459
|
-
}
|
460
|
-
return buf;
|
461
|
-
}
|
462
|
-
return unsafeStringify(rnds);
|
463
|
-
}
|
464
|
-
var v4_default = v4;
|
465
|
-
|
466
|
-
// ../core/lib/generate-id.ts
|
467
|
-
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
468
|
-
|
469
|
-
// ../core/lib/walk-tree.ts
|
470
|
-
init_react_import();
|
471
|
-
|
472
|
-
// ../core/lib/for-each-slot.ts
|
473
|
-
init_react_import();
|
474
|
-
|
475
|
-
// ../core/lib/is-slot.ts
|
476
|
-
init_react_import();
|
477
|
-
var isSlot = (prop) => {
|
478
|
-
var _a, _b;
|
479
|
-
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
480
|
-
};
|
481
|
-
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
482
|
-
var _a, _b;
|
483
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
484
|
-
if (!configForComponent) return isSlot(propValue);
|
485
|
-
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
486
|
-
};
|
487
|
-
|
488
|
-
// ../core/lib/for-each-slot.ts
|
489
|
-
var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
|
490
|
-
const props = item.props || {};
|
491
|
-
const propKeys = Object.keys(props);
|
492
|
-
for (let i = 0; i < propKeys.length; i++) {
|
493
|
-
const propKey = propKeys[i];
|
494
|
-
const itemType = "type" in item ? item.type : "root";
|
495
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
496
|
-
const content = props[propKey];
|
497
|
-
yield cb(props.id, propKey, content);
|
498
|
-
if (recursive) {
|
499
|
-
content.forEach(
|
500
|
-
(childItem) => __async(void 0, null, function* () {
|
501
|
-
return yield forEachSlot(childItem, cb, true, isSlot2);
|
502
|
-
})
|
503
|
-
);
|
504
|
-
}
|
505
|
-
}
|
506
|
-
}
|
507
|
-
});
|
508
|
-
|
509
|
-
// ../core/lib/for-related-zones.ts
|
510
|
-
init_react_import();
|
511
|
-
|
512
491
|
// ../core/lib/get-zone-id.ts
|
513
|
-
init_react_import();
|
514
492
|
var getZoneId = (zoneCompound) => {
|
515
493
|
if (!zoneCompound) {
|
516
494
|
return [];
|
@@ -521,36 +499,169 @@ var getZoneId = (zoneCompound) => {
|
|
521
499
|
return [rootDroppableId, zoneCompound];
|
522
500
|
};
|
523
501
|
|
524
|
-
// ../core/lib/for-related-zones.ts
|
502
|
+
// ../core/lib/data/for-related-zones.ts
|
525
503
|
function forRelatedZones(item, data, cb, path = []) {
|
526
504
|
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
527
505
|
const [parentId] = getZoneId(zoneCompound);
|
528
506
|
if (parentId === item.props.id) {
|
529
|
-
const newPath = [...path, zoneCompound];
|
530
|
-
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
531
507
|
cb(path, zoneCompound, content);
|
532
508
|
}
|
533
509
|
});
|
534
510
|
}
|
535
511
|
|
536
|
-
// ../core/lib/
|
512
|
+
// ../core/lib/data/map-slots.ts
|
537
513
|
init_react_import();
|
538
|
-
var
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
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
|
549
643
|
});
|
644
|
+
}
|
645
|
+
|
646
|
+
// ../core/lib/data/flatten-node.ts
|
647
|
+
init_react_import();
|
648
|
+
var import_flat = __toESM(require_flat());
|
649
|
+
|
650
|
+
// ../core/lib/data/strip-slots.ts
|
651
|
+
init_react_import();
|
652
|
+
var stripSlots = (data, config) => {
|
653
|
+
return mapSlots(data, () => null, config);
|
550
654
|
};
|
551
655
|
|
552
|
-
// ../core/lib/
|
553
|
-
|
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)
|
660
|
+
});
|
661
|
+
};
|
662
|
+
|
663
|
+
// ../core/lib/data/walk-app-state.ts
|
664
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
554
665
|
var _a;
|
555
666
|
let newZones = {};
|
556
667
|
const newZoneIndex = {};
|
@@ -591,11 +702,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
591
702
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
592
703
|
if (!mappedItem) return item;
|
593
704
|
const id = mappedItem.props.id;
|
594
|
-
|
595
|
-
const newProps = __spreadValues({}, mappedItem.props);
|
596
|
-
forEachSlot(
|
705
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
597
706
|
mappedItem,
|
598
|
-
(parentId2, slotId
|
707
|
+
(content, parentId2, slotId) => {
|
599
708
|
const zoneCompound = `${parentId2}:${slotId}`;
|
600
709
|
const [_2, newContent2] = processContent(
|
601
710
|
path,
|
@@ -604,17 +713,19 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
604
713
|
"slot",
|
605
714
|
parentId2
|
606
715
|
);
|
607
|
-
|
716
|
+
return newContent2;
|
608
717
|
},
|
609
|
-
|
610
|
-
|
611
|
-
|
718
|
+
config
|
719
|
+
).props), {
|
720
|
+
id
|
721
|
+
});
|
722
|
+
processRelatedZones(item, id, path);
|
612
723
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
613
724
|
const thisZoneCompound = path[path.length - 1];
|
614
725
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
615
726
|
newNodeIndex[id] = {
|
616
727
|
data: newItem,
|
617
|
-
flatData:
|
728
|
+
flatData: flattenNode(newItem, config),
|
618
729
|
path,
|
619
730
|
parentId,
|
620
731
|
zone
|
@@ -663,7 +774,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
663
774
|
return __spreadProps(__spreadValues({}, state), {
|
664
775
|
data: {
|
665
776
|
root,
|
666
|
-
// root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
|
667
777
|
content: processedContent,
|
668
778
|
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
669
779
|
},
|
@@ -674,26 +784,175 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
674
784
|
});
|
675
785
|
}
|
676
786
|
|
677
|
-
// ../core/reducer/
|
678
|
-
var
|
787
|
+
// ../core/reducer/actions/set.ts
|
788
|
+
var setAction = (state, action, appStore) => {
|
789
|
+
if (typeof action.state === "object") {
|
790
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
791
|
+
if (action.state.indexes) {
|
792
|
+
return newState;
|
793
|
+
}
|
794
|
+
console.warn(
|
795
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
796
|
+
);
|
797
|
+
return walkAppState(newState, appStore.config);
|
798
|
+
}
|
799
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
800
|
+
};
|
801
|
+
|
802
|
+
// ../core/reducer/actions/insert.ts
|
803
|
+
init_react_import();
|
804
|
+
|
805
|
+
// ../core/lib/data/insert.ts
|
806
|
+
init_react_import();
|
807
|
+
var insert = (list, index, item) => {
|
808
|
+
const result = Array.from(list || []);
|
809
|
+
result.splice(index, 0, item);
|
810
|
+
return result;
|
811
|
+
};
|
812
|
+
|
813
|
+
// ../core/lib/generate-id.ts
|
814
|
+
init_react_import();
|
815
|
+
|
816
|
+
// ../../node_modules/uuid/dist/esm-node/index.js
|
817
|
+
init_react_import();
|
818
|
+
|
819
|
+
// ../../node_modules/uuid/dist/esm-node/rng.js
|
820
|
+
init_react_import();
|
821
|
+
import crypto from "crypto";
|
822
|
+
var rnds8Pool = new Uint8Array(256);
|
823
|
+
var poolPtr = rnds8Pool.length;
|
824
|
+
function rng() {
|
825
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
826
|
+
crypto.randomFillSync(rnds8Pool);
|
827
|
+
poolPtr = 0;
|
828
|
+
}
|
829
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
830
|
+
}
|
831
|
+
|
832
|
+
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
833
|
+
init_react_import();
|
834
|
+
var byteToHex = [];
|
835
|
+
for (let i = 0; i < 256; ++i) {
|
836
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
837
|
+
}
|
838
|
+
function unsafeStringify(arr, offset = 0) {
|
839
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
840
|
+
}
|
841
|
+
|
842
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
843
|
+
init_react_import();
|
844
|
+
|
845
|
+
// ../../node_modules/uuid/dist/esm-node/native.js
|
846
|
+
init_react_import();
|
847
|
+
import crypto2 from "crypto";
|
848
|
+
var native_default = {
|
849
|
+
randomUUID: crypto2.randomUUID
|
850
|
+
};
|
851
|
+
|
852
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
853
|
+
function v4(options, buf, offset) {
|
854
|
+
if (native_default.randomUUID && !buf && !options) {
|
855
|
+
return native_default.randomUUID();
|
856
|
+
}
|
857
|
+
options = options || {};
|
858
|
+
const rnds = options.random || (options.rng || rng)();
|
859
|
+
rnds[6] = rnds[6] & 15 | 64;
|
860
|
+
rnds[8] = rnds[8] & 63 | 128;
|
861
|
+
if (buf) {
|
862
|
+
offset = offset || 0;
|
863
|
+
for (let i = 0; i < 16; ++i) {
|
864
|
+
buf[offset + i] = rnds[i];
|
865
|
+
}
|
866
|
+
return buf;
|
867
|
+
}
|
868
|
+
return unsafeStringify(rnds);
|
869
|
+
}
|
870
|
+
var v4_default = v4;
|
871
|
+
|
872
|
+
// ../core/lib/generate-id.ts
|
873
|
+
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
874
|
+
|
875
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
876
|
+
init_react_import();
|
679
877
|
var getIdsForParent = (zoneCompound, state) => {
|
680
878
|
const [parentId] = zoneCompound.split(":");
|
681
879
|
const node = state.indexes.nodes[parentId];
|
682
880
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
683
881
|
};
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
882
|
+
|
883
|
+
// ../core/lib/data/populate-ids.ts
|
884
|
+
init_react_import();
|
885
|
+
|
886
|
+
// ../core/lib/data/walk-tree.ts
|
887
|
+
init_react_import();
|
888
|
+
function walkTree(data, config, callbackFn) {
|
889
|
+
var _a, _b;
|
890
|
+
const walkItem = (item) => {
|
891
|
+
return mapSlots(
|
892
|
+
item,
|
893
|
+
(content, parentId, propName) => {
|
894
|
+
var _a2;
|
895
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
896
|
+
},
|
897
|
+
config,
|
898
|
+
true
|
899
|
+
);
|
691
900
|
};
|
901
|
+
if ("props" in data) {
|
902
|
+
return walkItem(data);
|
903
|
+
}
|
904
|
+
const _data = data;
|
905
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
906
|
+
const mappedContent = _data.content.map(walkItem);
|
907
|
+
return {
|
908
|
+
root: walkItem(_data.root),
|
909
|
+
content: (_b = callbackFn(mappedContent, {
|
910
|
+
parentId: "root",
|
911
|
+
propName: "default-zone"
|
912
|
+
})) != null ? _b : mappedContent,
|
913
|
+
zones: Object.keys(zones).reduce(
|
914
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
915
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
916
|
+
}),
|
917
|
+
{}
|
918
|
+
)
|
919
|
+
};
|
920
|
+
}
|
921
|
+
|
922
|
+
// ../core/lib/data/populate-ids.ts
|
923
|
+
var populateIds = (data, config, override = false) => {
|
924
|
+
const id = generateId(data.type);
|
925
|
+
return walkTree(
|
926
|
+
__spreadProps(__spreadValues({}, data), {
|
927
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
928
|
+
}),
|
929
|
+
config,
|
930
|
+
(contents) => contents.map((item) => {
|
931
|
+
const id2 = generateId(item.type);
|
932
|
+
return __spreadProps(__spreadValues({}, item), {
|
933
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
934
|
+
});
|
935
|
+
})
|
936
|
+
);
|
937
|
+
};
|
938
|
+
|
939
|
+
// ../core/reducer/actions/insert.ts
|
940
|
+
function insertAction(state, action, appStore) {
|
941
|
+
const id = action.id || generateId(action.componentType);
|
942
|
+
const emptyComponentData = populateIds(
|
943
|
+
{
|
944
|
+
type: action.componentType,
|
945
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
946
|
+
id
|
947
|
+
})
|
948
|
+
},
|
949
|
+
appStore.config
|
950
|
+
);
|
692
951
|
const [parentId] = action.destinationZone.split(":");
|
693
952
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
694
|
-
return
|
953
|
+
return walkAppState(
|
695
954
|
state,
|
696
|
-
config,
|
955
|
+
appStore.config,
|
697
956
|
(content, zoneCompound) => {
|
698
957
|
if (zoneCompound === action.destinationZone) {
|
699
958
|
return insert(
|
@@ -716,6 +975,142 @@ function insertAction(state, action, config) {
|
|
716
975
|
}
|
717
976
|
);
|
718
977
|
}
|
978
|
+
|
979
|
+
// ../core/reducer/actions/replace.ts
|
980
|
+
init_react_import();
|
981
|
+
var replaceAction = (state, action, appStore) => {
|
982
|
+
const [parentId] = action.destinationZone.split(":");
|
983
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
984
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
985
|
+
const idChanged = originalId !== action.data.props.id;
|
986
|
+
if (idChanged) {
|
987
|
+
throw new Error(
|
988
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
989
|
+
);
|
990
|
+
}
|
991
|
+
const data = populateIds(action.data, appStore.config);
|
992
|
+
return walkAppState(
|
993
|
+
state,
|
994
|
+
appStore.config,
|
995
|
+
(content, zoneCompound) => {
|
996
|
+
const newContent = [...content];
|
997
|
+
if (zoneCompound === action.destinationZone) {
|
998
|
+
newContent[action.destinationIndex] = data;
|
999
|
+
}
|
1000
|
+
return newContent;
|
1001
|
+
},
|
1002
|
+
(childItem, path) => {
|
1003
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1004
|
+
if (childItem.props.id === data.props.id) {
|
1005
|
+
return data;
|
1006
|
+
} else if (childItem.props.id === parentId) {
|
1007
|
+
return childItem;
|
1008
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1009
|
+
return childItem;
|
1010
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1011
|
+
return childItem;
|
1012
|
+
}
|
1013
|
+
return null;
|
1014
|
+
}
|
1015
|
+
);
|
1016
|
+
};
|
1017
|
+
|
1018
|
+
// ../core/reducer/actions/replace-root.ts
|
1019
|
+
init_react_import();
|
1020
|
+
var replaceRootAction = (state, action, appStore) => {
|
1021
|
+
return walkAppState(
|
1022
|
+
state,
|
1023
|
+
appStore.config,
|
1024
|
+
(content) => content,
|
1025
|
+
(childItem) => {
|
1026
|
+
if (childItem.props.id === "root") {
|
1027
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1028
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1029
|
+
readOnly: action.root.readOnly
|
1030
|
+
});
|
1031
|
+
}
|
1032
|
+
return childItem;
|
1033
|
+
}
|
1034
|
+
);
|
1035
|
+
};
|
1036
|
+
|
1037
|
+
// ../core/reducer/actions/duplicate.ts
|
1038
|
+
init_react_import();
|
1039
|
+
|
1040
|
+
// ../core/lib/data/get-item.ts
|
1041
|
+
init_react_import();
|
1042
|
+
function getItem(selector, state) {
|
1043
|
+
var _a, _b;
|
1044
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1045
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
// ../core/reducer/actions/duplicate.ts
|
1049
|
+
function duplicateAction(state, action, appStore) {
|
1050
|
+
const item = getItem(
|
1051
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1052
|
+
state
|
1053
|
+
);
|
1054
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1055
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1056
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1057
|
+
id: generateId(item.type)
|
1058
|
+
})
|
1059
|
+
});
|
1060
|
+
const modified = walkAppState(
|
1061
|
+
state,
|
1062
|
+
appStore.config,
|
1063
|
+
(content, zoneCompound) => {
|
1064
|
+
if (zoneCompound === action.sourceZone) {
|
1065
|
+
return insert(content, action.sourceIndex + 1, item);
|
1066
|
+
}
|
1067
|
+
return content;
|
1068
|
+
},
|
1069
|
+
(childItem, path, index) => {
|
1070
|
+
const zoneCompound = path[path.length - 1];
|
1071
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1072
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1073
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1074
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1075
|
+
id: generateId(childItem.type)
|
1076
|
+
})
|
1077
|
+
});
|
1078
|
+
}
|
1079
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1080
|
+
return newItem;
|
1081
|
+
}
|
1082
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1083
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1084
|
+
return childItem;
|
1085
|
+
}
|
1086
|
+
return null;
|
1087
|
+
}
|
1088
|
+
);
|
1089
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1090
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1091
|
+
itemSelector: {
|
1092
|
+
index: action.sourceIndex + 1,
|
1093
|
+
zone: action.sourceZone
|
1094
|
+
}
|
1095
|
+
})
|
1096
|
+
});
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
// ../core/reducer/actions/reorder.ts
|
1100
|
+
init_react_import();
|
1101
|
+
|
1102
|
+
// ../core/reducer/actions/move.ts
|
1103
|
+
init_react_import();
|
1104
|
+
|
1105
|
+
// ../core/lib/data/remove.ts
|
1106
|
+
init_react_import();
|
1107
|
+
var remove = (list, index) => {
|
1108
|
+
const result = Array.from(list);
|
1109
|
+
result.splice(index, 1);
|
1110
|
+
return result;
|
1111
|
+
};
|
1112
|
+
|
1113
|
+
// ../core/reducer/actions/move.ts
|
719
1114
|
var moveAction = (state, action, appStore) => {
|
720
1115
|
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
721
1116
|
return state;
|
@@ -727,7 +1122,7 @@ var moveAction = (state, action, appStore) => {
|
|
727
1122
|
if (!item) return state;
|
728
1123
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
729
1124
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
730
|
-
return
|
1125
|
+
return walkAppState(
|
731
1126
|
state,
|
732
1127
|
appStore.config,
|
733
1128
|
(content, zoneCompound) => {
|
@@ -755,57 +1150,26 @@ var moveAction = (state, action, appStore) => {
|
|
755
1150
|
}
|
756
1151
|
);
|
757
1152
|
};
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
const idChanged = originalId !== action.data.props.id;
|
763
|
-
if (idChanged) {
|
764
|
-
throw new Error(
|
765
|
-
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
766
|
-
);
|
767
|
-
}
|
768
|
-
return walkTree(
|
1153
|
+
|
1154
|
+
// ../core/reducer/actions/reorder.ts
|
1155
|
+
var reorderAction = (state, action, appStore) => {
|
1156
|
+
return moveAction(
|
769
1157
|
state,
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
return newContent;
|
1158
|
+
{
|
1159
|
+
type: "move",
|
1160
|
+
sourceIndex: action.sourceIndex,
|
1161
|
+
sourceZone: action.destinationZone,
|
1162
|
+
destinationIndex: action.destinationIndex,
|
1163
|
+
destinationZone: action.destinationZone
|
777
1164
|
},
|
778
|
-
|
779
|
-
const pathIds = path.map((p) => p.split(":")[0]);
|
780
|
-
if (childItem.props.id === action.data.props.id) {
|
781
|
-
return action.data;
|
782
|
-
} else if (childItem.props.id === parentId) {
|
783
|
-
return childItem;
|
784
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
785
|
-
return childItem;
|
786
|
-
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
787
|
-
return childItem;
|
788
|
-
}
|
789
|
-
return null;
|
790
|
-
}
|
1165
|
+
appStore
|
791
1166
|
);
|
792
1167
|
};
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
if (action.state.indexes) {
|
797
|
-
console.warn(
|
798
|
-
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
799
|
-
);
|
800
|
-
return newState;
|
801
|
-
}
|
802
|
-
return walkTree(newState, appStore.config);
|
803
|
-
}
|
804
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
805
|
-
};
|
1168
|
+
|
1169
|
+
// ../core/reducer/actions/remove.ts
|
1170
|
+
init_react_import();
|
806
1171
|
var removeAction = (state, action, appStore) => {
|
807
1172
|
const item = getItem({ index: action.index, zone: action.zone }, state);
|
808
|
-
const [parentId] = action.zone.split(":");
|
809
1173
|
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
810
1174
|
(acc, [nodeId, nodeData]) => {
|
811
1175
|
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
@@ -816,7 +1180,7 @@ var removeAction = (state, action, appStore) => {
|
|
816
1180
|
},
|
817
1181
|
[item.props.id]
|
818
1182
|
);
|
819
|
-
const newState =
|
1183
|
+
const newState = walkAppState(
|
820
1184
|
state,
|
821
1185
|
appStore.config,
|
822
1186
|
(content, zoneCompound) => {
|
@@ -824,24 +1188,17 @@ var removeAction = (state, action, appStore) => {
|
|
824
1188
|
return remove(content, action.index);
|
825
1189
|
}
|
826
1190
|
return content;
|
827
|
-
},
|
828
|
-
(childItem, path) => {
|
829
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
830
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
831
|
-
return childItem;
|
832
|
-
}
|
833
|
-
return null;
|
834
1191
|
}
|
835
1192
|
);
|
836
1193
|
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
837
|
-
const
|
838
|
-
if (nodesToDelete.includes(
|
1194
|
+
const parentId = zoneCompound.split(":")[0];
|
1195
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
839
1196
|
delete newState.data.zones[zoneCompound];
|
840
1197
|
}
|
841
1198
|
});
|
842
1199
|
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
843
|
-
const
|
844
|
-
if (nodesToDelete.includes(
|
1200
|
+
const parentId = zoneCompound.split(":")[0];
|
1201
|
+
if (nodesToDelete.includes(parentId)) {
|
845
1202
|
delete newState.indexes.zones[zoneCompound];
|
846
1203
|
}
|
847
1204
|
});
|
@@ -850,168 +1207,104 @@ var removeAction = (state, action, appStore) => {
|
|
850
1207
|
});
|
851
1208
|
return newState;
|
852
1209
|
};
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
if (
|
861
|
-
return
|
862
|
-
}
|
863
|
-
if (action.type === "replaceRoot") {
|
864
|
-
return walkTree(
|
865
|
-
state,
|
866
|
-
appStore.config,
|
867
|
-
(content) => content,
|
868
|
-
(childItem) => {
|
869
|
-
if (childItem.props.id === "root") {
|
870
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
871
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
872
|
-
readOnly: action.root.readOnly
|
873
|
-
});
|
874
|
-
}
|
875
|
-
return childItem;
|
876
|
-
}
|
877
|
-
);
|
878
|
-
}
|
879
|
-
if (action.type === "duplicate") {
|
880
|
-
const item = getItem(
|
881
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
882
|
-
state
|
883
|
-
);
|
884
|
-
const idsInPath = getIdsForParent(action.sourceZone, state);
|
885
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
886
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
887
|
-
id: generateId(item.type)
|
888
|
-
})
|
889
|
-
});
|
890
|
-
const modified = walkTree(
|
891
|
-
state,
|
892
|
-
appStore.config,
|
893
|
-
(content, zoneCompound) => {
|
894
|
-
if (zoneCompound === action.sourceZone) {
|
895
|
-
return insert(content, action.sourceIndex + 1, item);
|
896
|
-
}
|
897
|
-
return content;
|
898
|
-
},
|
899
|
-
(childItem, path, index) => {
|
900
|
-
const zoneCompound = path[path.length - 1];
|
901
|
-
const parents = path.map((p) => p.split(":")[0]);
|
902
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
903
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
904
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
905
|
-
id: generateId(childItem.type)
|
906
|
-
})
|
907
|
-
});
|
908
|
-
}
|
909
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
910
|
-
return newItem;
|
911
|
-
}
|
912
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
913
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
914
|
-
return childItem;
|
915
|
-
}
|
916
|
-
return null;
|
917
|
-
}
|
918
|
-
);
|
919
|
-
return __spreadProps(__spreadValues({}, modified), {
|
920
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
921
|
-
itemSelector: {
|
922
|
-
index: action.sourceIndex + 1,
|
923
|
-
zone: action.sourceZone
|
924
|
-
}
|
925
|
-
})
|
926
|
-
});
|
927
|
-
}
|
928
|
-
if (action.type === "reorder") {
|
929
|
-
return moveAction(
|
930
|
-
state,
|
931
|
-
{
|
932
|
-
type: "move",
|
933
|
-
sourceIndex: action.sourceIndex,
|
934
|
-
sourceZone: action.destinationZone,
|
935
|
-
destinationIndex: action.destinationIndex,
|
936
|
-
destinationZone: action.destinationZone
|
937
|
-
},
|
938
|
-
appStore
|
939
|
-
);
|
940
|
-
}
|
941
|
-
if (action.type === "move") {
|
942
|
-
return moveAction(state, action, appStore);
|
943
|
-
}
|
944
|
-
if (action.type === "remove") {
|
945
|
-
return removeAction(state, action, appStore);
|
946
|
-
}
|
947
|
-
if (action.type === "registerZone") {
|
948
|
-
if (zoneCache[action.zone]) {
|
949
|
-
return __spreadProps(__spreadValues({}, state), {
|
950
|
-
data: __spreadProps(__spreadValues({}, state.data), {
|
951
|
-
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
952
|
-
[action.zone]: zoneCache[action.zone]
|
953
|
-
})
|
954
|
-
}),
|
955
|
-
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
956
|
-
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
957
|
-
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
958
|
-
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
959
|
-
type: "dropzone"
|
960
|
-
})
|
961
|
-
})
|
962
|
-
})
|
963
|
-
});
|
964
|
-
}
|
965
|
-
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1210
|
+
|
1211
|
+
// ../core/reducer/actions/register-zone.ts
|
1212
|
+
init_react_import();
|
1213
|
+
|
1214
|
+
// ../core/lib/data/setup-zone.ts
|
1215
|
+
init_react_import();
|
1216
|
+
var setupZone = (data, zoneKey) => {
|
1217
|
+
if (zoneKey === rootDroppableId) {
|
1218
|
+
return data;
|
966
1219
|
}
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
1220
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1221
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1222
|
+
});
|
1223
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1224
|
+
return newData;
|
1225
|
+
};
|
1226
|
+
|
1227
|
+
// ../core/reducer/actions/register-zone.ts
|
1228
|
+
var zoneCache = {};
|
1229
|
+
function registerZoneAction(state, action) {
|
1230
|
+
if (zoneCache[action.zone]) {
|
975
1231
|
return __spreadProps(__spreadValues({}, state), {
|
976
1232
|
data: __spreadProps(__spreadValues({}, state.data), {
|
977
|
-
zones:
|
1233
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1234
|
+
[action.zone]: zoneCache[action.zone]
|
1235
|
+
})
|
978
1236
|
}),
|
979
1237
|
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
980
|
-
zones:
|
1238
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1239
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1240
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1241
|
+
type: "dropzone"
|
1242
|
+
})
|
1243
|
+
})
|
981
1244
|
})
|
982
1245
|
});
|
983
1246
|
}
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
}
|
996
|
-
|
1247
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1248
|
+
}
|
1249
|
+
function unregisterZoneAction(state, action) {
|
1250
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1251
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1252
|
+
if (_zones[action.zone]) {
|
1253
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1254
|
+
delete _zones[action.zone];
|
1255
|
+
}
|
1256
|
+
delete zoneIndex[action.zone];
|
1257
|
+
return __spreadProps(__spreadValues({}, state), {
|
1258
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1259
|
+
zones: _zones
|
1260
|
+
}),
|
1261
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1262
|
+
zones: zoneIndex
|
1263
|
+
})
|
1264
|
+
});
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
// ../core/reducer/actions/set-data.ts
|
1268
|
+
init_react_import();
|
1269
|
+
var setDataAction = (state, action, appStore) => {
|
1270
|
+
if (typeof action.data === "object") {
|
1271
|
+
console.warn(
|
1272
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1273
|
+
);
|
1274
|
+
return walkAppState(
|
997
1275
|
__spreadProps(__spreadValues({}, state), {
|
998
|
-
data: __spreadValues(__spreadValues({}, state.data), action.data
|
1276
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
999
1277
|
}),
|
1000
1278
|
appStore.config
|
1001
1279
|
);
|
1002
1280
|
}
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1281
|
+
return walkAppState(
|
1282
|
+
__spreadProps(__spreadValues({}, state), {
|
1283
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1284
|
+
}),
|
1285
|
+
appStore.config
|
1286
|
+
);
|
1287
|
+
};
|
1288
|
+
|
1289
|
+
// ../core/reducer/actions/set-ui.ts
|
1290
|
+
init_react_import();
|
1291
|
+
var setUiAction = (state, action) => {
|
1292
|
+
if (typeof action.ui === "object") {
|
1009
1293
|
return __spreadProps(__spreadValues({}, state), {
|
1010
|
-
ui: __spreadValues(__spreadValues({}, state.ui), action.ui
|
1294
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1011
1295
|
});
|
1012
1296
|
}
|
1013
|
-
return state
|
1014
|
-
}
|
1297
|
+
return __spreadProps(__spreadValues({}, state), {
|
1298
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1299
|
+
});
|
1300
|
+
};
|
1301
|
+
|
1302
|
+
// ../core/lib/data/make-state-public.ts
|
1303
|
+
init_react_import();
|
1304
|
+
var makeStatePublic = (state) => {
|
1305
|
+
const { data, ui } = state;
|
1306
|
+
return { data, ui };
|
1307
|
+
};
|
1015
1308
|
|
1016
1309
|
// ../core/reducer/actions.tsx
|
1017
1310
|
init_react_import();
|
@@ -1030,7 +1323,7 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1030
1323
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1031
1324
|
if (record) record(newAppState);
|
1032
1325
|
}
|
1033
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1326
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1034
1327
|
return newAppState;
|
1035
1328
|
};
|
1036
1329
|
}
|
@@ -1041,8 +1334,43 @@ function createReducer({
|
|
1041
1334
|
}) {
|
1042
1335
|
return storeInterceptor(
|
1043
1336
|
(state, action) => {
|
1044
|
-
|
1045
|
-
|
1337
|
+
if (action.type === "set") {
|
1338
|
+
return setAction(state, action, appStore);
|
1339
|
+
}
|
1340
|
+
if (action.type === "insert") {
|
1341
|
+
return insertAction(state, action, appStore);
|
1342
|
+
}
|
1343
|
+
if (action.type === "replace") {
|
1344
|
+
return replaceAction(state, action, appStore);
|
1345
|
+
}
|
1346
|
+
if (action.type === "replaceRoot") {
|
1347
|
+
return replaceRootAction(state, action, appStore);
|
1348
|
+
}
|
1349
|
+
if (action.type === "duplicate") {
|
1350
|
+
return duplicateAction(state, action, appStore);
|
1351
|
+
}
|
1352
|
+
if (action.type === "reorder") {
|
1353
|
+
return reorderAction(state, action, appStore);
|
1354
|
+
}
|
1355
|
+
if (action.type === "move") {
|
1356
|
+
return moveAction(state, action, appStore);
|
1357
|
+
}
|
1358
|
+
if (action.type === "remove") {
|
1359
|
+
return removeAction(state, action, appStore);
|
1360
|
+
}
|
1361
|
+
if (action.type === "registerZone") {
|
1362
|
+
return registerZoneAction(state, action);
|
1363
|
+
}
|
1364
|
+
if (action.type === "unregisterZone") {
|
1365
|
+
return unregisterZoneAction(state, action);
|
1366
|
+
}
|
1367
|
+
if (action.type === "setData") {
|
1368
|
+
return setDataAction(state, action, appStore);
|
1369
|
+
}
|
1370
|
+
if (action.type === "setUi") {
|
1371
|
+
return setUiAction(state, action);
|
1372
|
+
}
|
1373
|
+
return state;
|
1046
1374
|
},
|
1047
1375
|
record,
|
1048
1376
|
onAction
|
@@ -1237,7 +1565,7 @@ var createHistorySlice = (set, get) => {
|
|
1237
1565
|
const { dispatch, history } = get();
|
1238
1566
|
dispatch({
|
1239
1567
|
type: "set",
|
1240
|
-
state: ((_a = history.histories[
|
1568
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1241
1569
|
});
|
1242
1570
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1243
1571
|
},
|
@@ -1253,7 +1581,11 @@ var createNodesSlice = (set, get) => ({
|
|
1253
1581
|
const s = get().nodes;
|
1254
1582
|
const emptyNode = {
|
1255
1583
|
id,
|
1256
|
-
methods: {
|
1584
|
+
methods: {
|
1585
|
+
sync: () => null,
|
1586
|
+
hideOverlay: () => null,
|
1587
|
+
showOverlay: () => null
|
1588
|
+
},
|
1257
1589
|
element: null
|
1258
1590
|
};
|
1259
1591
|
const existingNode = s.nodes[id];
|
@@ -1286,11 +1618,11 @@ var createNodesSlice = (set, get) => ({
|
|
1286
1618
|
init_react_import();
|
1287
1619
|
import { useEffect as useEffect3 } from "react";
|
1288
1620
|
|
1289
|
-
// ../core/lib/flatten-data.ts
|
1621
|
+
// ../core/lib/data/flatten-data.ts
|
1290
1622
|
init_react_import();
|
1291
1623
|
var flattenData = (state, config) => {
|
1292
1624
|
const data = [];
|
1293
|
-
|
1625
|
+
walkAppState(
|
1294
1626
|
state,
|
1295
1627
|
config,
|
1296
1628
|
(content) => content,
|
@@ -1304,12 +1636,13 @@ var flattenData = (state, config) => {
|
|
1304
1636
|
|
1305
1637
|
// ../core/lib/get-changed.ts
|
1306
1638
|
init_react_import();
|
1639
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1307
1640
|
var getChanged = (newItem, oldItem) => {
|
1308
1641
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1309
1642
|
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1310
1643
|
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1311
1644
|
return __spreadProps(__spreadValues({}, acc), {
|
1312
|
-
[item]: oldItemProps[item]
|
1645
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1313
1646
|
});
|
1314
1647
|
}, {}) : {};
|
1315
1648
|
};
|
@@ -1321,12 +1654,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1321
1654
|
const { cache: cache2, globalPermissions } = permissions;
|
1322
1655
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1323
1656
|
var _a, _b, _c;
|
1324
|
-
const {
|
1325
|
-
config: config2,
|
1326
|
-
state: appState,
|
1327
|
-
setComponentLoading,
|
1328
|
-
unsetComponentLoading
|
1329
|
-
} = get();
|
1657
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1330
1658
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1331
1659
|
if (!componentConfig) {
|
1332
1660
|
return;
|
@@ -1335,14 +1663,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1335
1663
|
if (componentConfig.resolvePermissions) {
|
1336
1664
|
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1337
1665
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1338
|
-
setComponentLoading(item2.props.id);
|
1666
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1339
1667
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1340
1668
|
item2,
|
1341
1669
|
{
|
1342
1670
|
changed,
|
1343
1671
|
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1344
1672
|
permissions: initialPermissions,
|
1345
|
-
appState,
|
1673
|
+
appState: makeStatePublic(appState),
|
1346
1674
|
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1347
1675
|
}
|
1348
1676
|
);
|
@@ -1360,7 +1688,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1360
1688
|
})
|
1361
1689
|
})
|
1362
1690
|
});
|
1363
|
-
|
1691
|
+
clearTimeout2();
|
1364
1692
|
}
|
1365
1693
|
}
|
1366
1694
|
});
|
@@ -1370,7 +1698,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1370
1698
|
// Shim the root data in by conforming to component data shape
|
1371
1699
|
{
|
1372
1700
|
type: "root",
|
1373
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1701
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1374
1702
|
},
|
1375
1703
|
force2
|
1376
1704
|
);
|
@@ -1385,7 +1713,6 @@ var createPermissionsSlice = (set, get) => {
|
|
1385
1713
|
} else if (root) {
|
1386
1714
|
resolveDataForRoot(force);
|
1387
1715
|
} else {
|
1388
|
-
resolveDataForRoot(force);
|
1389
1716
|
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1390
1717
|
yield resolveDataForItem(item2, force);
|
1391
1718
|
}));
|
@@ -1416,7 +1743,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1416
1743
|
} else if (root) {
|
1417
1744
|
const rootConfig = config.root;
|
1418
1745
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1419
|
-
const resolvedForItem = resolvedPermissions["
|
1746
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1420
1747
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1421
1748
|
}
|
1422
1749
|
return globalPermissions;
|
@@ -1433,44 +1760,23 @@ var createFieldsSlice = (_set, _get) => {
|
|
1433
1760
|
return {
|
1434
1761
|
fields: {},
|
1435
1762
|
loading: false,
|
1436
|
-
lastResolvedData: {}
|
1763
|
+
lastResolvedData: {},
|
1764
|
+
id: void 0
|
1437
1765
|
};
|
1438
1766
|
};
|
1439
1767
|
|
1440
1768
|
// ../core/lib/resolve-component-data.ts
|
1441
1769
|
init_react_import();
|
1442
|
-
|
1443
|
-
// ../core/lib/map-slots.ts
|
1444
|
-
init_react_import();
|
1445
|
-
function mapSlots(item, map, recursive = true, isSlot2) {
|
1446
|
-
return __async(this, null, function* () {
|
1447
|
-
const props = __spreadValues({}, item.props);
|
1448
|
-
yield forEachSlot(
|
1449
|
-
item,
|
1450
|
-
(_parentId, propName, content) => __async(this, null, function* () {
|
1451
|
-
const mappedContent = recursive ? yield Promise.all(
|
1452
|
-
content.map((item2) => __async(this, null, function* () {
|
1453
|
-
return yield mapSlots(item2, map, recursive, isSlot2);
|
1454
|
-
}))
|
1455
|
-
) : content;
|
1456
|
-
props[propName] = yield map(mappedContent, propName);
|
1457
|
-
}),
|
1458
|
-
false,
|
1459
|
-
isSlot2
|
1460
|
-
);
|
1461
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1462
|
-
});
|
1463
|
-
}
|
1464
|
-
|
1465
|
-
// ../core/lib/resolve-component-data.ts
|
1466
|
-
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1770
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1467
1771
|
var cache = { lastChange: {} };
|
1468
|
-
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") {
|
1469
1773
|
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1470
|
-
|
1471
|
-
|
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) {
|
1472
1778
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1473
|
-
if (item && (0,
|
1779
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1474
1780
|
return { node: resolved, didChange: false };
|
1475
1781
|
}
|
1476
1782
|
const changed = getChanged(item, oldItem);
|
@@ -1480,52 +1786,48 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1480
1786
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1481
1787
|
changed,
|
1482
1788
|
lastData: oldItem,
|
1483
|
-
metadata,
|
1789
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1484
1790
|
trigger
|
1485
1791
|
});
|
1486
|
-
|
1487
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1488
|
-
});
|
1489
|
-
if (recursive) {
|
1490
|
-
resolvedItem = yield mapSlots(
|
1491
|
-
resolvedItem,
|
1492
|
-
(content) => __async(void 0, null, function* () {
|
1493
|
-
return Promise.all(
|
1494
|
-
content.map(
|
1495
|
-
(childItem) => __async(void 0, null, function* () {
|
1496
|
-
return (yield resolveComponentData(
|
1497
|
-
childItem,
|
1498
|
-
config,
|
1499
|
-
metadata,
|
1500
|
-
onResolveStart,
|
1501
|
-
onResolveEnd,
|
1502
|
-
trigger,
|
1503
|
-
false
|
1504
|
-
)).node;
|
1505
|
-
})
|
1506
|
-
)
|
1507
|
-
);
|
1508
|
-
}),
|
1509
|
-
false,
|
1510
|
-
createIsSlotConfig(config)
|
1511
|
-
);
|
1512
|
-
}
|
1792
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1513
1793
|
if (Object.keys(readOnly).length) {
|
1514
1794
|
resolvedItem.readOnly = readOnly;
|
1515
1795
|
}
|
1516
|
-
cache.lastChange[id] = {
|
1517
|
-
item,
|
1518
|
-
resolved: resolvedItem
|
1519
|
-
};
|
1520
|
-
if (onResolveEnd) {
|
1521
|
-
onResolveEnd(resolvedItem);
|
1522
|
-
}
|
1523
|
-
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
1524
1796
|
}
|
1525
|
-
|
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
|
+
};
|
1526
1828
|
});
|
1527
1829
|
|
1528
|
-
// ../core/lib/to-root.ts
|
1830
|
+
// ../core/lib/data/to-root.ts
|
1529
1831
|
init_react_import();
|
1530
1832
|
var toRoot = (item) => {
|
1531
1833
|
if ("type" in item && item.type !== "root") {
|
@@ -1542,7 +1844,8 @@ var toRoot = (item) => {
|
|
1542
1844
|
return { props: {}, readOnly };
|
1543
1845
|
};
|
1544
1846
|
|
1545
|
-
// ../core/store/
|
1847
|
+
// ../core/store/default-app-state.ts
|
1848
|
+
init_react_import();
|
1546
1849
|
var defaultAppState = {
|
1547
1850
|
data: { content: [], root: {}, zones: {} },
|
1548
1851
|
ui: {
|
@@ -1568,170 +1871,182 @@ var defaultAppState = {
|
|
1568
1871
|
zones: {}
|
1569
1872
|
}
|
1570
1873
|
};
|
1874
|
+
|
1875
|
+
// ../core/store/index.ts
|
1571
1876
|
var defaultPageFields = {
|
1572
1877
|
title: { type: "text" }
|
1573
1878
|
};
|
1574
1879
|
var createAppStore = (initialAppStore) => create()(
|
1575
|
-
subscribeWithSelector((set, get) =>
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1880
|
+
subscribeWithSelector((set, get) => {
|
1881
|
+
var _a, _b;
|
1882
|
+
return __spreadProps(__spreadValues({
|
1883
|
+
state: defaultAppState,
|
1884
|
+
config: { components: {} },
|
1885
|
+
componentState: {},
|
1886
|
+
plugins: [],
|
1887
|
+
overrides: {},
|
1888
|
+
viewports: defaultViewports,
|
1889
|
+
zoomConfig: {
|
1890
|
+
autoZoom: 1,
|
1891
|
+
rootHeight: 0,
|
1892
|
+
zoom: 1
|
1893
|
+
},
|
1894
|
+
status: "LOADING",
|
1895
|
+
iframe: {},
|
1896
|
+
metadata: {}
|
1897
|
+
}, initialAppStore), {
|
1898
|
+
fields: createFieldsSlice(set, get),
|
1899
|
+
history: createHistorySlice(set, get),
|
1900
|
+
nodes: createNodesSlice(set, get),
|
1901
|
+
permissions: createPermissionsSlice(set, get),
|
1902
|
+
getComponentConfig: (type) => {
|
1903
|
+
var _a2;
|
1904
|
+
const { config, selectedItem } = get();
|
1905
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1906
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1907
|
+
},
|
1908
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1909
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1910
|
+
initialAppStore.state
|
1911
|
+
) : null,
|
1912
|
+
dispatch: (action) => set((s) => {
|
1913
|
+
var _a2, _b2;
|
1914
|
+
const { record } = get().history;
|
1915
|
+
const dispatch = createReducer({
|
1916
|
+
record,
|
1917
|
+
appStore: s
|
1918
|
+
});
|
1919
|
+
const state = dispatch(s.state, action);
|
1920
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1921
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1922
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1923
|
+
}),
|
1924
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1925
|
+
setStatus: (status) => set({ status }),
|
1926
|
+
setComponentState: (componentState) => set({ componentState }),
|
1927
|
+
pendingLoadTimeouts: {},
|
1928
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1929
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1930
|
+
const loadId = generateId();
|
1931
|
+
const setLoading = () => {
|
1932
|
+
var _a2;
|
1933
|
+
const { componentState } = get();
|
1934
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1935
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1936
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1937
|
+
})
|
1938
|
+
}));
|
1939
|
+
};
|
1940
|
+
const unsetLoading = () => {
|
1941
|
+
var _a2;
|
1942
|
+
const { componentState } = get();
|
1943
|
+
clearTimeout(timeout);
|
1944
|
+
delete pendingLoadTimeouts[loadId];
|
1945
|
+
set({ pendingLoadTimeouts });
|
1946
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1947
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1948
|
+
loadingCount: Math.max(
|
1949
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1950
|
+
0
|
1951
|
+
)
|
1952
|
+
})
|
1953
|
+
}));
|
1954
|
+
};
|
1955
|
+
const timeout = setTimeout(() => {
|
1956
|
+
if (loading) {
|
1957
|
+
setLoading();
|
1958
|
+
} else {
|
1959
|
+
unsetLoading();
|
1960
|
+
}
|
1961
|
+
delete pendingLoadTimeouts[loadId];
|
1962
|
+
set({ pendingLoadTimeouts });
|
1963
|
+
}, defer);
|
1964
|
+
set({
|
1965
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1966
|
+
[id]: timeout
|
1638
1967
|
})
|
1639
|
-
})
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
}
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1679
|
-
}),
|
1680
|
-
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1681
|
-
const { config, metadata, setComponentLoading } = get();
|
1682
|
-
return yield resolveComponentData(
|
1683
|
-
componentData,
|
1684
|
-
config,
|
1685
|
-
metadata,
|
1686
|
-
(item) => setComponentLoading(
|
1687
|
-
"id" in item.props ? item.props.id : "root",
|
1688
|
-
true,
|
1689
|
-
50
|
1690
|
-
),
|
1691
|
-
(item) => setComponentLoading(
|
1692
|
-
"id" in item.props ? item.props.id : "root",
|
1693
|
-
false,
|
1694
|
-
0
|
1695
|
-
),
|
1696
|
-
trigger
|
1697
|
-
);
|
1698
|
-
}),
|
1699
|
-
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1700
|
-
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1701
|
-
walkTree(
|
1702
|
-
state,
|
1703
|
-
config,
|
1704
|
-
(content) => content,
|
1705
|
-
(childItem) => {
|
1706
|
-
resolveComponentData2(childItem, "load").then((resolved) => {
|
1707
|
-
const { state: state2 } = get();
|
1708
|
-
const node = state2.indexes.nodes[resolved.node.props.id];
|
1709
|
-
if (node && resolved.didChange) {
|
1710
|
-
if (resolved.node.props.id === "root") {
|
1711
|
-
dispatch({
|
1712
|
-
type: "replaceRoot",
|
1713
|
-
root: toRoot(resolved.node)
|
1714
|
-
});
|
1715
|
-
} else {
|
1716
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1717
|
-
const parentZone = state2.indexes.zones[zoneCompound];
|
1718
|
-
const index = parentZone.contentIds.indexOf(
|
1719
|
-
resolved.node.props.id
|
1720
|
-
);
|
1721
|
-
dispatch({
|
1722
|
-
type: "replace",
|
1723
|
-
data: resolved.node,
|
1724
|
-
destinationIndex: index,
|
1725
|
-
destinationZone: zoneCompound
|
1726
|
-
});
|
1727
|
-
}
|
1968
|
+
});
|
1969
|
+
return unsetLoading;
|
1970
|
+
},
|
1971
|
+
unsetComponentLoading: (id) => {
|
1972
|
+
const { setComponentLoading } = get();
|
1973
|
+
setComponentLoading(id, false);
|
1974
|
+
},
|
1975
|
+
// Helper
|
1976
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1977
|
+
const dispatch = createReducer({
|
1978
|
+
record: () => {
|
1979
|
+
},
|
1980
|
+
appStore: s
|
1981
|
+
});
|
1982
|
+
const state = dispatch(s.state, {
|
1983
|
+
type: "setUi",
|
1984
|
+
ui,
|
1985
|
+
recordHistory
|
1986
|
+
});
|
1987
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1988
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1989
|
+
}),
|
1990
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1991
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1992
|
+
const timeouts = {};
|
1993
|
+
return yield resolveComponentData(
|
1994
|
+
componentData,
|
1995
|
+
config,
|
1996
|
+
metadata,
|
1997
|
+
(item) => {
|
1998
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1999
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2000
|
+
},
|
2001
|
+
(item) => __async(void 0, null, function* () {
|
2002
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2003
|
+
if ("type" in item) {
|
2004
|
+
yield permissions.refreshPermissions({ item });
|
2005
|
+
} else {
|
2006
|
+
yield permissions.refreshPermissions({ root: true });
|
1728
2007
|
}
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
2008
|
+
timeouts[id]();
|
2009
|
+
}),
|
2010
|
+
trigger
|
2011
|
+
);
|
2012
|
+
}),
|
2013
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2014
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2015
|
+
walkAppState(
|
2016
|
+
state,
|
2017
|
+
config,
|
2018
|
+
(content) => content,
|
2019
|
+
(childItem) => {
|
2020
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2021
|
+
const { state: state2 } = get();
|
2022
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2023
|
+
if (node && resolved.didChange) {
|
2024
|
+
if (resolved.node.props.id === "root") {
|
2025
|
+
dispatch({
|
2026
|
+
type: "replaceRoot",
|
2027
|
+
root: toRoot(resolved.node)
|
2028
|
+
});
|
2029
|
+
} else {
|
2030
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2031
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2032
|
+
const index = parentZone.contentIds.indexOf(
|
2033
|
+
resolved.node.props.id
|
2034
|
+
);
|
2035
|
+
dispatch({
|
2036
|
+
type: "replace",
|
2037
|
+
data: resolved.node,
|
2038
|
+
destinationIndex: index,
|
2039
|
+
destinationZone: zoneCompound
|
2040
|
+
});
|
2041
|
+
}
|
2042
|
+
}
|
2043
|
+
});
|
2044
|
+
return childItem;
|
2045
|
+
}
|
2046
|
+
);
|
2047
|
+
})
|
2048
|
+
});
|
2049
|
+
})
|
1735
2050
|
);
|
1736
2051
|
var appStoreContext = createContext(createAppStore());
|
1737
2052
|
function useAppStore(selector) {
|
@@ -1793,10 +2108,10 @@ init_react_import();
|
|
1793
2108
|
// ../core/lib/filter.ts
|
1794
2109
|
init_react_import();
|
1795
2110
|
|
1796
|
-
// ../core/lib/reorder.ts
|
2111
|
+
// ../core/lib/data/reorder.ts
|
1797
2112
|
init_react_import();
|
1798
2113
|
|
1799
|
-
// ../core/lib/replace.ts
|
2114
|
+
// ../core/lib/data/replace.ts
|
1800
2115
|
init_react_import();
|
1801
2116
|
|
1802
2117
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
@@ -1982,15 +2297,37 @@ var HeadingAnalyzer = () => {
|
|
1982
2297
|
const [hierarchy, setHierarchy] = useState([]);
|
1983
2298
|
useEffect5(() => {
|
1984
2299
|
const frame = getFrame();
|
1985
|
-
|
1986
|
-
|
1987
|
-
setHierarchy(buildHierarchy(entry));
|
1988
|
-
const observer = new MutationObserver(() => {
|
2300
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2301
|
+
const createHierarchy = () => {
|
1989
2302
|
setHierarchy(buildHierarchy(entry));
|
2303
|
+
};
|
2304
|
+
const entryObserver = new MutationObserver(() => {
|
2305
|
+
createHierarchy();
|
2306
|
+
});
|
2307
|
+
const frameObserver = new MutationObserver(() => {
|
2308
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2309
|
+
if (entry) {
|
2310
|
+
registerEntryObserver();
|
2311
|
+
frameObserver.disconnect();
|
2312
|
+
}
|
1990
2313
|
});
|
1991
|
-
|
2314
|
+
const registerEntryObserver = () => {
|
2315
|
+
if (!entry) return;
|
2316
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2317
|
+
};
|
2318
|
+
const registerFrameObserver = () => {
|
2319
|
+
if (!frame) return;
|
2320
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2321
|
+
};
|
2322
|
+
if (entry) {
|
2323
|
+
createHierarchy();
|
2324
|
+
registerEntryObserver();
|
2325
|
+
} else {
|
2326
|
+
registerFrameObserver();
|
2327
|
+
}
|
1992
2328
|
return () => {
|
1993
|
-
|
2329
|
+
entryObserver.disconnect();
|
2330
|
+
frameObserver.disconnect();
|
1994
2331
|
};
|
1995
2332
|
}, [data]);
|
1996
2333
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|