@reacteditor/core 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +85 -0
  2. package/dist/Editor-GBV2O5RD.css +415 -0
  3. package/dist/Editor-IKMJILGR.mjs +204 -0
  4. package/dist/Render-EFT7YD2C.css +103 -0
  5. package/dist/Render-VDC7AEQK.mjs +55 -0
  6. package/dist/actions-BCDhqbeL.d.mts +849 -0
  7. package/dist/actions-BCDhqbeL.d.ts +849 -0
  8. package/dist/chunk-2YLS65V2.mjs +103 -0
  9. package/dist/chunk-6B2Q5R3C.mjs +53 -0
  10. package/dist/chunk-DXGQXXQG.mjs +63 -0
  11. package/dist/chunk-F7S5S6I2.mjs +114 -0
  12. package/dist/chunk-GAUBBDIR.mjs +463 -0
  13. package/dist/chunk-GUMYXUO3.mjs +33 -0
  14. package/dist/chunk-M6W7YEVX.mjs +95 -0
  15. package/dist/chunk-MFI3RDA4.mjs +11 -0
  16. package/dist/chunk-QNHSXCWU.mjs +8692 -0
  17. package/dist/chunk-SURZYH7D.mjs +1726 -0
  18. package/dist/chunk-V2OPYD42.mjs +708 -0
  19. package/dist/chunk-VD3EVRUF.mjs +476 -0
  20. package/dist/chunk-VOLQMQPK.mjs +146 -0
  21. package/dist/chunk-VUEM62JF.mjs +523 -0
  22. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  23. package/dist/full-ELX6RALJ.css +311 -0
  24. package/dist/full-OBTPW7TC.mjs +93 -0
  25. package/dist/index-ComBHfdn.d.ts +117 -0
  26. package/dist/index-DVwiIwYU.d.mts +117 -0
  27. package/dist/index.css +3033 -0
  28. package/dist/index.d.mts +396 -0
  29. package/dist/index.d.ts +396 -0
  30. package/dist/index.js +14688 -0
  31. package/dist/index.mjs +87 -0
  32. package/dist/internal.d.mts +27 -0
  33. package/dist/internal.d.ts +27 -0
  34. package/dist/internal.js +931 -0
  35. package/dist/internal.mjs +13 -0
  36. package/dist/loaded-35WC23HJ.mjs +60 -0
  37. package/dist/loaded-TBSVRJPY.css +90 -0
  38. package/dist/loaded-ULSROV73.mjs +57 -0
  39. package/dist/loaded-YYRJPIWZ.mjs +57 -0
  40. package/dist/no-external.css +3031 -0
  41. package/dist/no-external.d.mts +21 -0
  42. package/dist/no-external.d.ts +21 -0
  43. package/dist/no-external.js +14688 -0
  44. package/dist/no-external.mjs +87 -0
  45. package/dist/rsc.css +103 -0
  46. package/dist/rsc.d.mts +27 -0
  47. package/dist/rsc.d.ts +27 -0
  48. package/dist/rsc.js +1493 -0
  49. package/dist/rsc.mjs +148 -0
  50. package/dist/walk-tree-BPIigVTF.d.mts +29 -0
  51. package/dist/walk-tree-BZq1CPCH.d.ts +29 -0
  52. package/package.json +139 -0
@@ -0,0 +1,476 @@
1
+ import {
2
+ styles_module_default
3
+ } from "./chunk-MFI3RDA4.mjs";
4
+ import {
5
+ defaultAppState,
6
+ resolveComponentData
7
+ } from "./chunk-VOLQMQPK.mjs";
8
+ import {
9
+ get_class_name_factory_default
10
+ } from "./chunk-Y2EFNT5P.mjs";
11
+ import {
12
+ generateId,
13
+ getZoneId,
14
+ mapFields,
15
+ toComponent,
16
+ walkAppState,
17
+ walkTree
18
+ } from "./chunk-GAUBBDIR.mjs";
19
+ import {
20
+ __async,
21
+ __objRest,
22
+ __spreadProps,
23
+ __spreadValues,
24
+ init_react_import
25
+ } from "./chunk-M6W7YEVX.mjs";
26
+
27
+ // lib/migrate.ts
28
+ init_react_import();
29
+ var migrations = [
30
+ // Migrate root to root.props
31
+ (data) => {
32
+ const rootProps = data.root.props || data.root;
33
+ if (Object.keys(data.root).length > 0 && !data.root.props) {
34
+ console.warn(
35
+ "Migration applied: Root props moved from `root` to `root.props`."
36
+ );
37
+ return __spreadProps(__spreadValues({}, data), {
38
+ root: {
39
+ props: __spreadValues({}, rootProps)
40
+ }
41
+ });
42
+ }
43
+ return data;
44
+ },
45
+ // Migrate zones to slots
46
+ (data, config, migrationOptions) => {
47
+ var _a, _b;
48
+ if (!config) return data;
49
+ console.log("Migrating DropZones to slots...");
50
+ const updatedItems = {};
51
+ const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
52
+ const { indexes } = walkAppState(appState, config);
53
+ const deletedCompounds = [];
54
+ walkAppState(appState, config, (content, zoneCompound, zoneType) => {
55
+ var _a2, _b2, _c;
56
+ if (zoneType === "dropzone") {
57
+ const [id, slotName] = zoneCompound.split(":");
58
+ const nodeData = indexes.nodes[id].data;
59
+ const componentType = nodeData.type;
60
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
61
+ if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
62
+ updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
63
+ props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
64
+ [slotName]: content
65
+ })
66
+ });
67
+ deletedCompounds.push(zoneCompound);
68
+ }
69
+ return content;
70
+ }
71
+ return content;
72
+ });
73
+ const updated = walkAppState(
74
+ appState,
75
+ config,
76
+ (content) => content,
77
+ (item) => {
78
+ var _a2;
79
+ return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
80
+ }
81
+ );
82
+ deletedCompounds.forEach((zoneCompound) => {
83
+ var _a2;
84
+ const [_, propName] = zoneCompound.split(":");
85
+ console.log(
86
+ `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
87
+ );
88
+ (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
89
+ });
90
+ if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
91
+ const unmigratedZonesGrouped = {};
92
+ Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
93
+ var _a2;
94
+ const [componentId, propName] = zoneCompound.split(":");
95
+ const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
96
+ if (!content) {
97
+ return;
98
+ }
99
+ if (!unmigratedZonesGrouped[componentId]) {
100
+ unmigratedZonesGrouped[componentId] = {};
101
+ }
102
+ if (!unmigratedZonesGrouped[componentId][propName]) {
103
+ unmigratedZonesGrouped[componentId][propName] = content;
104
+ }
105
+ });
106
+ Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
107
+ updated.data = walkTree(updated.data, config, (content) => {
108
+ return content.map((child) => {
109
+ var _a2;
110
+ if (child.props.id !== componentId) {
111
+ return child;
112
+ }
113
+ const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
114
+ if (!migrateFn) {
115
+ return child;
116
+ }
117
+ const zones = unmigratedZonesGrouped[componentId];
118
+ const migratedProps = migrateFn(child.props, zones);
119
+ Object.keys(zones).forEach((propName) => {
120
+ var _a3;
121
+ const zoneCompound = `${componentId}:${propName}`;
122
+ console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
123
+ (_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
124
+ });
125
+ return __spreadProps(__spreadValues({}, child), {
126
+ props: migratedProps
127
+ });
128
+ });
129
+ });
130
+ });
131
+ }
132
+ Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
133
+ const [_, propName] = zoneCompound.split(":");
134
+ throw new Error(
135
+ `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
136
+ );
137
+ });
138
+ delete updated.data.zones;
139
+ return updated.data;
140
+ }
141
+ ];
142
+ function migrate(data, config, migrationOptions) {
143
+ return migrations == null ? void 0 : migrations.reduce(
144
+ (acc, migration) => migration(acc, config, migrationOptions),
145
+ data
146
+ );
147
+ }
148
+
149
+ // lib/transform-props.ts
150
+ init_react_import();
151
+
152
+ // lib/data/default-data.ts
153
+ init_react_import();
154
+ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
155
+ root: data.root || {},
156
+ content: data.content || []
157
+ });
158
+
159
+ // lib/transform-props.ts
160
+ function transformProps(data, propTransforms, config = { components: {} }) {
161
+ const mapItem = (item) => {
162
+ if (propTransforms[item.type]) {
163
+ return __spreadProps(__spreadValues({}, item), {
164
+ props: __spreadValues({
165
+ id: item.props.id
166
+ }, propTransforms[item.type](item.props))
167
+ });
168
+ }
169
+ return item;
170
+ };
171
+ const defaultedData = defaultData(data);
172
+ const rootProps = defaultedData.root.props || defaultedData.root;
173
+ let newRoot = __spreadValues({}, defaultedData.root);
174
+ if (propTransforms["root"]) {
175
+ newRoot.props = propTransforms["root"](rootProps);
176
+ }
177
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
178
+ const updatedData = walkTree(
179
+ dataWithUpdatedRoot,
180
+ config,
181
+ (content) => content.map(mapItem)
182
+ );
183
+ if (!defaultedData.root.props) {
184
+ updatedData.root = updatedData.root.props;
185
+ }
186
+ return updatedData;
187
+ }
188
+
189
+ // lib/resolve-all-data.ts
190
+ init_react_import();
191
+
192
+ // lib/group-zones-by-component.ts
193
+ init_react_import();
194
+ var groupZonesByComponent = (data) => {
195
+ var _a;
196
+ const zoneEntries = Object.entries((_a = data.zones) != null ? _a : {});
197
+ return zoneEntries.reduce((acc, [zoneCompound, zoneContent]) => {
198
+ const [componentId, zoneName] = getZoneId(zoneCompound);
199
+ if (!componentId.length || !zoneName.length) return acc;
200
+ if (!acc[componentId]) {
201
+ acc[componentId] = [];
202
+ }
203
+ acc[componentId].push({ zoneCompound, content: zoneContent });
204
+ return acc;
205
+ }, {});
206
+ };
207
+
208
+ // lib/resolve-all-data.ts
209
+ function resolveAllData(_0, _1) {
210
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
211
+ const defaultedData = defaultData(data);
212
+ const zonesByComponent = groupZonesByComponent(defaultedData);
213
+ let resolvedZones = {};
214
+ const resolveNode = (_node, parent) => __async(null, null, function* () {
215
+ const node = toComponent(_node);
216
+ onResolveStart == null ? void 0 : onResolveStart(node);
217
+ const resolved = (yield resolveComponentData(
218
+ node,
219
+ config,
220
+ metadata,
221
+ () => {
222
+ },
223
+ () => {
224
+ },
225
+ "force",
226
+ parent
227
+ )).node;
228
+ const resolvedAsComponent = toComponent(resolved);
229
+ const resolvedDeepPromise = mapFields(
230
+ resolved,
231
+ {
232
+ slot: ({ value }) => processContent(value, resolvedAsComponent)
233
+ },
234
+ config
235
+ );
236
+ let resolveZonePromises = [];
237
+ if (zonesByComponent[resolvedAsComponent.props.id]) {
238
+ resolveZonePromises = zonesByComponent[resolvedAsComponent.props.id].map(
239
+ (_02) => __async(null, [_02], function* ({ zoneCompound, content }) {
240
+ resolvedZones[zoneCompound] = yield processContent(
241
+ content,
242
+ resolvedAsComponent
243
+ );
244
+ })
245
+ );
246
+ }
247
+ const resolvedDeep = yield resolvedDeepPromise;
248
+ yield Promise.all(resolveZonePromises);
249
+ onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
250
+ return resolvedDeep;
251
+ });
252
+ const processContent = (content, parent) => __async(null, null, function* () {
253
+ return Promise.all(content.map((item) => resolveNode(item, parent)));
254
+ });
255
+ const result = defaultData({});
256
+ result.root = yield resolveNode(defaultedData.root, null);
257
+ result.content = yield processContent(
258
+ defaultedData.content,
259
+ toComponent(result.root)
260
+ );
261
+ result.zones = resolvedZones;
262
+ return result;
263
+ });
264
+ }
265
+
266
+ // lib/field-transforms/default-transforms/slot-transform.tsx
267
+ init_react_import();
268
+ var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
269
+ slot: ({ value: content, propName, field, isReadOnly }) => {
270
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
271
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
272
+ allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
273
+ disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
274
+ }, dzProps), {
275
+ zone: propName,
276
+ content
277
+ }));
278
+ return Slot;
279
+ }
280
+ });
281
+
282
+ // lib/use-slots.tsx
283
+ init_react_import();
284
+
285
+ // lib/field-transforms/use-field-transforms.tsx
286
+ init_react_import();
287
+ import { useMemo } from "react";
288
+
289
+ // lib/field-transforms/build-mappers.ts
290
+ init_react_import();
291
+ function buildMappers(transforms, readOnly, forceReadOnly) {
292
+ return Object.keys(transforms).reduce((acc, _fieldType) => {
293
+ const fieldType = _fieldType;
294
+ return __spreadProps(__spreadValues({}, acc), {
295
+ [fieldType]: (_a) => {
296
+ var _b = _a, {
297
+ parentId
298
+ } = _b, params = __objRest(_b, [
299
+ "parentId"
300
+ ]);
301
+ const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
302
+ const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
303
+ const fn = transforms[fieldType];
304
+ return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
305
+ isReadOnly,
306
+ componentId: parentId
307
+ }));
308
+ }
309
+ });
310
+ }, {});
311
+ }
312
+
313
+ // lib/field-transforms/use-field-transforms.tsx
314
+ function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
315
+ const mappers = useMemo(
316
+ () => buildMappers(transforms, readOnly, forceReadOnly),
317
+ [transforms, readOnly, forceReadOnly]
318
+ );
319
+ const transformedProps = useMemo(() => {
320
+ return mapFields(item, mappers, config).props;
321
+ }, [config, item, mappers]);
322
+ const mergedProps = useMemo(
323
+ () => __spreadValues(__spreadValues({}, item.props), transformedProps),
324
+ [item.props, transformedProps]
325
+ );
326
+ return mergedProps;
327
+ }
328
+
329
+ // lib/use-slots.tsx
330
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
331
+ return useFieldTransforms(
332
+ config,
333
+ item,
334
+ getSlotTransform(renderSlotEdit, renderSlotRender),
335
+ readOnly,
336
+ forceReadOnly
337
+ );
338
+ }
339
+
340
+ // components/RichTextEditor/lib/use-richtext-props.tsx
341
+ init_react_import();
342
+ import { lazy, Suspense, useMemo as useMemo2 } from "react";
343
+
344
+ // components/RichTextEditor/components/RenderFallback.tsx
345
+ init_react_import();
346
+ import { jsx } from "react/jsx-runtime";
347
+ var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
348
+ function RichTextRenderFallback({ content }) {
349
+ return /* @__PURE__ */ jsx("div", { className: getClassName(), children: /* @__PURE__ */ jsx(
350
+ "div",
351
+ {
352
+ className: "rich-text",
353
+ dangerouslySetInnerHTML: { __html: content }
354
+ }
355
+ ) });
356
+ }
357
+
358
+ // components/RichTextEditor/lib/mapDeep.ts
359
+ init_react_import();
360
+ var mapDeep = (source, path, render) => {
361
+ if (!source) {
362
+ return null;
363
+ }
364
+ if (path.length === 0) {
365
+ return render(source);
366
+ }
367
+ const [key, ...rest] = path;
368
+ if (Array.isArray(source)) {
369
+ return source.map((item) => mapDeep(item, path, render));
370
+ }
371
+ return __spreadProps(__spreadValues({}, source), {
372
+ [key]: mapDeep(source[key], rest, render)
373
+ });
374
+ };
375
+
376
+ // components/RichTextEditor/lib/use-richtext-props.tsx
377
+ import { jsx as jsx2 } from "react/jsx-runtime";
378
+ function useRichtextProps(fields, props) {
379
+ const findAllRichtextKeys = (fields2, path = []) => {
380
+ if (!fields2) return [];
381
+ const result = [];
382
+ for (const [key, field] of Object.entries(fields2)) {
383
+ const currentPath = [...path, key];
384
+ if (field.type === "richtext") {
385
+ result.push({
386
+ path: currentPath,
387
+ field
388
+ });
389
+ }
390
+ if (field.type === "array" && "arrayFields" in field) {
391
+ result.push(...findAllRichtextKeys(field.arrayFields, currentPath));
392
+ }
393
+ if (field.type === "object" && "objectFields" in field) {
394
+ result.push(...findAllRichtextKeys(field.objectFields, currentPath));
395
+ }
396
+ }
397
+ return result;
398
+ };
399
+ const richtextKeys = useMemo2(() => findAllRichtextKeys(fields), [fields]);
400
+ const richtextProps = useMemo2(() => {
401
+ if (!(richtextKeys == null ? void 0 : richtextKeys.length)) return {};
402
+ const RichTextRender = lazy(
403
+ () => import("./Render-VDC7AEQK.mjs").then((m) => ({
404
+ default: m.RichTextRender
405
+ }))
406
+ );
407
+ let result = __spreadValues({}, props);
408
+ for (const { path, field } of richtextKeys) {
409
+ result = mapDeep(result, path, (content) => /* @__PURE__ */ jsx2(
410
+ Suspense,
411
+ {
412
+ fallback: /* @__PURE__ */ jsx2(RichTextRenderFallback, { content }),
413
+ children: /* @__PURE__ */ jsx2(RichTextRender, { content, field })
414
+ },
415
+ generateId()
416
+ ));
417
+ }
418
+ return result;
419
+ }, [richtextKeys, props, fields]);
420
+ return richtextProps;
421
+ }
422
+
423
+ // components/SlotRender/server.tsx
424
+ init_react_import();
425
+ import { forwardRef } from "react";
426
+ import { jsx as jsx3 } from "react/jsx-runtime";
427
+ var SlotRenderPure = (props) => /* @__PURE__ */ jsx3(SlotRender, __spreadValues({}, props));
428
+ var Item = ({
429
+ config,
430
+ item,
431
+ metadata
432
+ }) => {
433
+ const Component = config.components[item.type];
434
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx3(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
435
+ const richtextProps = useRichtextProps(Component.fields, props);
436
+ return /* @__PURE__ */ jsx3(
437
+ Component.render,
438
+ __spreadProps(__spreadValues(__spreadValues({}, props), richtextProps), {
439
+ editor: __spreadProps(__spreadValues({}, props.editor), {
440
+ metadata: metadata || {}
441
+ })
442
+ })
443
+ );
444
+ };
445
+ var SlotRender = forwardRef(
446
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
447
+ const El = as != null ? as : "div";
448
+ return /* @__PURE__ */ jsx3(El, { className, style, ref, children: content.map((item) => {
449
+ if (!config.components[item.type]) {
450
+ return null;
451
+ }
452
+ return /* @__PURE__ */ jsx3(
453
+ Item,
454
+ {
455
+ config,
456
+ item,
457
+ metadata
458
+ },
459
+ item.props.id
460
+ );
461
+ }) });
462
+ }
463
+ );
464
+
465
+ export {
466
+ buildMappers,
467
+ getSlotTransform,
468
+ useSlots,
469
+ RichTextRenderFallback,
470
+ useRichtextProps,
471
+ SlotRenderPure,
472
+ SlotRender,
473
+ migrate,
474
+ transformProps,
475
+ resolveAllData
476
+ };
@@ -0,0 +1,146 @@
1
+ import {
2
+ mapFields,
3
+ toComponent
4
+ } from "./chunk-GAUBBDIR.mjs";
5
+ import {
6
+ __async,
7
+ __spreadProps,
8
+ __spreadValues,
9
+ init_react_import
10
+ } from "./chunk-M6W7YEVX.mjs";
11
+
12
+ // components/ViewportControls/default-viewports.ts
13
+ init_react_import();
14
+ var defaultViewports = [
15
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
16
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
17
+ { width: "100%", height: "auto", icon: "Monitor", label: "Desktop" }
18
+ ];
19
+
20
+ // lib/resolve-component-data.ts
21
+ init_react_import();
22
+
23
+ // lib/get-changed.ts
24
+ init_react_import();
25
+ import { deepEqual } from "fast-equals";
26
+ var getChanged = (newItem, oldItem) => {
27
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
28
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
29
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
30
+ return __spreadProps(__spreadValues({}, acc), {
31
+ [item]: !deepEqual(oldItemProps[item], newItemProps[item])
32
+ });
33
+ }, {}) : {};
34
+ };
35
+
36
+ // lib/resolve-component-data.ts
37
+ import { deepEqual as deepEqual2 } from "fast-equals";
38
+ var cache = { lastChange: {} };
39
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", parent = null) {
40
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
41
+ const resolvedItem = __spreadValues({}, item);
42
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
43
+ const id = "id" in item.props ? item.props.id : "root";
44
+ if (shouldRunResolver) {
45
+ const {
46
+ item: oldItem = null,
47
+ resolved = {},
48
+ parentId: oldParentId = null
49
+ } = cache.lastChange[id] || {};
50
+ const isRootOrInserted = oldParentId === null;
51
+ const parentChanged = !isRootOrInserted && (parent == null ? void 0 : parent.props.id) !== oldParentId;
52
+ const dataChanged = item && !deepEqual2(item, oldItem);
53
+ const shouldSkip = trigger === "move" && !parentChanged || trigger !== "move" && trigger !== "force" && !dataChanged;
54
+ if (shouldSkip) {
55
+ return { node: resolved, didChange: false };
56
+ }
57
+ const changed = getChanged(item, oldItem);
58
+ if (onResolveStart) {
59
+ onResolveStart(item);
60
+ }
61
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
62
+ changed,
63
+ lastData: oldItem,
64
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
65
+ trigger,
66
+ parent
67
+ });
68
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
69
+ if (Object.keys(readOnly).length) {
70
+ resolvedItem.readOnly = readOnly;
71
+ }
72
+ }
73
+ const itemAsComponentData = toComponent(resolvedItem);
74
+ let itemWithResolvedChildren = yield mapFields(
75
+ resolvedItem,
76
+ {
77
+ slot: (_02) => __async(null, [_02], function* ({ value }) {
78
+ const content = value;
79
+ return yield Promise.all(
80
+ content.map(
81
+ (childItem) => __async(null, null, function* () {
82
+ return (yield resolveComponentData(
83
+ childItem,
84
+ config,
85
+ metadata,
86
+ onResolveStart,
87
+ onResolveEnd,
88
+ trigger,
89
+ itemAsComponentData
90
+ )).node;
91
+ })
92
+ )
93
+ );
94
+ })
95
+ },
96
+ config
97
+ );
98
+ if (shouldRunResolver && onResolveEnd) {
99
+ onResolveEnd(resolvedItem);
100
+ }
101
+ cache.lastChange[id] = {
102
+ item,
103
+ resolved: itemWithResolvedChildren,
104
+ parentId: parent == null ? void 0 : parent.props.id
105
+ };
106
+ return {
107
+ node: itemWithResolvedChildren,
108
+ didChange: !deepEqual2(item, itemWithResolvedChildren)
109
+ };
110
+ });
111
+
112
+ // store/default-app-state.ts
113
+ init_react_import();
114
+ var defaultAppState = {
115
+ data: { content: [], root: {}, zones: {} },
116
+ ui: {
117
+ leftSideBarVisible: true,
118
+ rightSideBarVisible: true,
119
+ arrayState: {},
120
+ itemSelector: null,
121
+ componentList: {},
122
+ isDragging: false,
123
+ previewMode: "edit",
124
+ viewports: {
125
+ current: {
126
+ width: defaultViewports[0].width,
127
+ height: defaultViewports[0].height || "auto"
128
+ },
129
+ options: [],
130
+ controlsVisible: true
131
+ },
132
+ field: { focus: null },
133
+ plugin: { current: null }
134
+ },
135
+ indexes: {
136
+ nodes: {},
137
+ zones: {}
138
+ }
139
+ };
140
+
141
+ export {
142
+ defaultViewports,
143
+ getChanged,
144
+ resolveComponentData,
145
+ defaultAppState
146
+ };