@versa-stack/v-craft 1.0.4 → 1.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/components/CraftEditor.vue.d.ts +4 -7
- package/dist/types/components/CraftEditorBlueprint.vue.d.ts +2 -1
- package/dist/types/components/CraftEditorBlueprintsList.vue.d.ts +2 -1
- package/dist/types/components/CraftEditorPanelForm.vue.d.ts +17 -16
- package/dist/types/components/CraftEditorPanelLayers.vue.d.ts +2 -1
- package/dist/types/components/CraftEditorPanelLayout.vue.d.ts +2 -1
- package/dist/types/components/CraftEditorPanelNodeEventsSettings.vue.d.ts +6 -7
- package/dist/types/components/CraftEditorPanelNodeLayer.vue.d.ts +2 -1
- package/dist/types/components/CraftEditorPanelNodeSettings.vue.d.ts +6 -7
- package/dist/types/components/CraftEditorPanelSettings.vue.d.ts +4 -3
- package/dist/types/components/CraftFrame.vue.d.ts +4 -10
- package/dist/types/components/CraftIframe.vue.d.ts +1 -5
- package/dist/types/components/CraftNodeStatic.vue.d.ts +9 -0
- package/dist/types/components/CraftStaticRenderer.vue.d.ts +5 -3
- package/dist/types/components/composable/index.d.ts +1 -0
- package/dist/types/components/composable/useCraftFrame.d.ts +134 -104
- package/dist/types/components/composable/useCraftNode.d.ts +3 -3
- package/dist/types/components/composable/useCraftNodeEvents.d.ts +1 -2
- package/dist/types/components/composable/useCraftNodeWrapper.d.ts +133 -104
- package/dist/types/components/composable/useDragCraftNode.d.ts +2 -1
- package/dist/types/components/composable/useNodeElement.d.ts +9 -0
- package/dist/types/components/composable/useResolveCraftNode.d.ts +4 -2
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/components/utils.d.ts +3 -1
- package/dist/types/lib/CraftNodeResolver.d.ts +13 -6
- package/dist/types/lib/craftNode.d.ts +15 -12
- package/dist/types/lib/dragCraftNode/dragOver.d.ts +2 -1
- package/dist/types/lib/dragCraftNode/drop.d.ts +3 -2
- package/dist/types/lib/dragCraftNode/index.d.ts +2 -2
- package/dist/types/lib/model.d.ts +18 -3
- package/dist/types/lib/renderCraftNodes.d.ts +4 -3
- package/dist/types/lib/vNodeToCraftNode.d.ts +2 -1
- package/dist/types/store/editor.d.ts +134 -105
- package/dist/v-craft.css +1 -1
- package/dist/v-craft.es.js +1356 -1208
- package/dist/v-craft.es.js.map +1 -1
- package/package.json +1 -1
package/dist/v-craft.es.js
CHANGED
|
@@ -1,54 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defineStore as
|
|
3
|
-
import { v4 as
|
|
4
|
-
import { debounce as
|
|
5
|
-
import { FormKit as
|
|
6
|
-
const
|
|
1
|
+
import { inject as ue, computed as b, defineAsyncComponent as ft, defineComponent as I, useSlots as je, useAttrs as ht, unref as d, openBlock as m, createBlock as x, resolveDynamicComponent as ce, normalizeProps as Pe, mergeProps as ge, createSlots as de, renderList as $, withCtx as H, renderSlot as Y, guardReactiveProps as pt, createCommentVNode as k, markRaw as Fe, ref as F, watch as te, normalizeClass as se, createTextVNode as vt, toDisplayString as ee, createElementBlock as y, withKeys as Me, withModifiers as j, nextTick as ne, provide as q, resolveComponent as U, createVNode as W, Fragment as R, createElementVNode as S, toRef as ve, onUnmounted as mt, toRefs as ie, normalizeStyle as Se, withDirectives as gt, Teleport as yt, vShow as bt, onMounted as ye, onBeforeMount as Et, onBeforeUnmount as Ct, readonly as He, onUpdated as _t, toHandlers as ke, h as Nt } from "vue";
|
|
2
|
+
import { defineStore as Ve, storeToRefs as G } from "pinia";
|
|
3
|
+
import { v4 as le } from "uuid";
|
|
4
|
+
import { debounce as Ke } from "lodash-es";
|
|
5
|
+
import { FormKit as Xe, FormKitSchema as ze } from "@formkit/vue";
|
|
6
|
+
const wt = (t, e) => {
|
|
7
|
+
if (!t)
|
|
8
|
+
return e.componentName;
|
|
9
|
+
const r = t.resolveComponent(e);
|
|
10
|
+
return r ? typeof r == "function" && !("setup" in r) && !("render" in r) ? ft(r) : r : t.resolve(e.componentName)?.componentName || e.componentName;
|
|
11
|
+
}, fe = (t) => {
|
|
12
|
+
const e = ue("resolver"), r = b(() => !e || !t?.value ? {} : e.value.resolve(
|
|
13
|
+
t.value.componentName
|
|
14
|
+
)), n = b(() => r.value?.defaultProps || {}), o = b(
|
|
15
|
+
() => wt(e?.value, t.value)
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
resolvedNode: r,
|
|
19
|
+
resolver: e,
|
|
20
|
+
defaultProps: n,
|
|
21
|
+
componentToRender: o
|
|
22
|
+
};
|
|
23
|
+
}, Ot = /* @__PURE__ */ I({
|
|
7
24
|
name: "CraftCanvas",
|
|
8
25
|
__name: "CraftCanvas",
|
|
9
26
|
props: {
|
|
10
27
|
componentName: {}
|
|
11
28
|
},
|
|
12
29
|
setup(t) {
|
|
13
|
-
const e =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
const e = je(), r = ht(), n = t, o = b(() => ({
|
|
31
|
+
componentName: n.componentName,
|
|
32
|
+
props: {},
|
|
33
|
+
slots: {},
|
|
34
|
+
uuid: ""
|
|
35
|
+
})), { componentToRender: s } = fe(o);
|
|
36
|
+
return (i, a) => d(s) ? (m(), x(ce(d(s)), Pe(ge({ key: 0 }, d(r))), de({ _: 2 }, [
|
|
37
|
+
$(d(e), (u, c) => ({
|
|
38
|
+
name: c,
|
|
39
|
+
fn: H((f) => [
|
|
40
|
+
Y(i.$slots, c, Pe(pt(f || {})))
|
|
19
41
|
])
|
|
20
42
|
}))
|
|
21
|
-
]), 1040)) :
|
|
43
|
+
]), 1040)) : k("", !0);
|
|
22
44
|
}
|
|
23
|
-
}),
|
|
24
|
-
const
|
|
25
|
-
t.value.componentName
|
|
26
|
-
)), n = w(() => r.value?.defaultProps || {});
|
|
27
|
-
return {
|
|
28
|
-
resolvedNode: r,
|
|
29
|
-
resolver: e,
|
|
30
|
-
defaultProps: n
|
|
31
|
-
};
|
|
32
|
-
}, mt = () => {
|
|
33
|
-
const t = ae("craftNode");
|
|
45
|
+
}), xt = () => {
|
|
46
|
+
const t = ue("craftNode");
|
|
34
47
|
if (!t)
|
|
35
48
|
throw new Error("craftNode or resolver not provided");
|
|
36
|
-
const { resolver: e, resolvedNode: r, defaultProps: n } =
|
|
49
|
+
const { resolver: e, resolvedNode: r, defaultProps: n } = fe(t);
|
|
37
50
|
return {
|
|
38
51
|
craftNode: t,
|
|
39
52
|
resolver: e,
|
|
40
53
|
resolvedNode: r,
|
|
41
54
|
defaultProps: n
|
|
42
55
|
};
|
|
43
|
-
},
|
|
56
|
+
}, qe = (t) => t.visible === void 0 || t.visible, St = (t) => {
|
|
44
57
|
let e = t;
|
|
45
|
-
const r =
|
|
58
|
+
const r = L();
|
|
46
59
|
for (; e.parentUuid; )
|
|
47
|
-
if (e = r.nodeMap.get(e.parentUuid),
|
|
60
|
+
if (e = r.nodeMap.get(e.parentUuid), K(e))
|
|
48
61
|
return !0;
|
|
49
62
|
return !1;
|
|
50
|
-
},
|
|
51
|
-
const r =
|
|
63
|
+
}, kt = (t) => St(t) ? t.rules?.canDrag ? t.rules.canDrag(t) : !0 : !1, Ye = (t, e) => {
|
|
64
|
+
const r = L();
|
|
52
65
|
let n = e;
|
|
53
66
|
for (; n?.parentUuid; ) {
|
|
54
67
|
if (n.parentUuid === t.uuid)
|
|
@@ -56,26 +69,34 @@ const vt = /* @__PURE__ */ $({
|
|
|
56
69
|
n = r.nodeMap.get(n.parentUuid);
|
|
57
70
|
}
|
|
58
71
|
return !1;
|
|
59
|
-
},
|
|
60
|
-
if (!
|
|
72
|
+
}, J = (t) => t.componentName === "CraftCanvas" ? t.props.componentName : t.componentName, oe = (t, e, r) => {
|
|
73
|
+
if (!K(e) || t.uuid === e.uuid)
|
|
61
74
|
return !1;
|
|
62
|
-
const n = r.resolve(
|
|
75
|
+
const n = r.resolve(J(e)), o = r.resolve(J(t)), s = n?.rules || {}, i = o?.rules || {};
|
|
63
76
|
if (t.parentUuid) {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
77
|
+
const u = L().nodeMap.get(t.parentUuid), c = r.resolve(J(u))?.rules || {};
|
|
78
|
+
if (c.canMoveOut && !c.canMoveOut(t, e, r))
|
|
66
79
|
return;
|
|
67
80
|
}
|
|
68
|
-
return !(i.canMoveInto && !i.canMoveInto(t, e, r) ||
|
|
69
|
-
},
|
|
70
|
-
const n =
|
|
71
|
-
return e.uuid === t.uuid || !e.parentUuid ? !1 :
|
|
81
|
+
return !(i.canMoveInto && !i.canMoveInto(t, e, r) || Ye(t, e) || s.canMoveIn && !s.canMoveIn(t, e, r));
|
|
82
|
+
}, K = (t) => t.componentName === "CraftCanvas", me = (t, e, r) => {
|
|
83
|
+
const n = L();
|
|
84
|
+
return e.uuid === t.uuid || !e.parentUuid ? !1 : oe(
|
|
72
85
|
t,
|
|
73
86
|
n.nodeMap.get(e.parentUuid),
|
|
74
87
|
r
|
|
75
88
|
);
|
|
76
|
-
},
|
|
77
|
-
e.forEach((r) => (r.uuid || (r.uuid =
|
|
78
|
-
}), t),
|
|
89
|
+
}, Qe = (t) => (t.uuid || (t.uuid = le()), t.slots && Object.values(t.slots).forEach((e) => {
|
|
90
|
+
e.forEach((r) => (r.uuid || (r.uuid = le()), r.parentUuid !== t.uuid && (r.parentUuid = t.uuid), Qe(r), r));
|
|
91
|
+
}), t), We = (t, e) => {
|
|
92
|
+
if (!t.slots || Object.keys(t.slots).length === 0) {
|
|
93
|
+
const n = e.resolveNode?.(t)?.slots;
|
|
94
|
+
n && n.length > 0 ? (t.slots = {}, n.forEach((o) => {
|
|
95
|
+
t.slots[o] = [];
|
|
96
|
+
})) : t.slots = { default: [] };
|
|
97
|
+
}
|
|
98
|
+
return t;
|
|
99
|
+
}, L = Ve("editor", {
|
|
79
100
|
state: () => ({
|
|
80
101
|
nodeMap: /* @__PURE__ */ new Map(),
|
|
81
102
|
rootNodes: [],
|
|
@@ -113,12 +134,12 @@ const vt = /* @__PURE__ */ $({
|
|
|
113
134
|
toggleNodeVisibility(t) {
|
|
114
135
|
const e = this.nodeMap.get(t.uuid);
|
|
115
136
|
if (e) {
|
|
116
|
-
if (e.visible = !
|
|
117
|
-
const r = (n) => (n.visible = e.visible, n.slots && Object.values(n.slots).forEach((
|
|
118
|
-
|
|
137
|
+
if (e.visible = !qe(e), e.slots) {
|
|
138
|
+
const r = (n) => (n.visible = e.visible, n.slots && Object.values(n.slots).forEach((o) => {
|
|
139
|
+
o.forEach((s) => r(s));
|
|
119
140
|
}), this.nodeMap.set(n.uuid, n), n);
|
|
120
141
|
Object.values(e.slots).forEach((n) => {
|
|
121
|
-
n.forEach((
|
|
142
|
+
n.forEach((o) => r(o));
|
|
122
143
|
});
|
|
123
144
|
}
|
|
124
145
|
this.nodeMap.set(e.uuid, e);
|
|
@@ -138,18 +159,22 @@ const vt = /* @__PURE__ */ $({
|
|
|
138
159
|
setNodes(t) {
|
|
139
160
|
this.clear(), this.rootNodes = [];
|
|
140
161
|
const e = (r) => {
|
|
141
|
-
this.
|
|
142
|
-
|
|
143
|
-
|
|
162
|
+
this.resolver && r.componentName === "CraftCanvas" && We(r, this.resolver);
|
|
163
|
+
const n = r.slots ? {} : { default: [] };
|
|
164
|
+
r.slots && Object.keys(r.slots).forEach((o) => {
|
|
165
|
+
n[o] = [];
|
|
166
|
+
}), this.nodeMap.set(r.uuid, { ...r, slots: n }), r.parentUuid || this.rootNodes.push(r.uuid), r.slots && Object.entries(r.slots).forEach(([o, s]) => {
|
|
167
|
+
s.forEach((i) => {
|
|
168
|
+
i.parentUuid = r.uuid, e(i), this.nodeMap.get(r.uuid).slots[o] || (this.nodeMap.get(r.uuid).slots[o] = []), this.nodeMap.get(r.uuid).slots[o].push(i);
|
|
144
169
|
});
|
|
145
170
|
});
|
|
146
171
|
};
|
|
147
172
|
t.forEach(e);
|
|
148
173
|
},
|
|
149
174
|
addNodeRecursively(t, e = null) {
|
|
150
|
-
const r = t.uuid ||
|
|
151
|
-
this.nodeMap.set(r,
|
|
152
|
-
|
|
175
|
+
const r = t.uuid || le(), n = { ...t, uuid: r, parentUuid: e };
|
|
176
|
+
this.nodeMap.set(r, Fe(n)), e || this.rootNodes.push(r), t.slots && Object.values(t.slots).forEach((o) => {
|
|
177
|
+
o.forEach((s) => this.addNodeRecursively(s, r));
|
|
153
178
|
});
|
|
154
179
|
},
|
|
155
180
|
selectNode(t) {
|
|
@@ -162,8 +187,8 @@ const vt = /* @__PURE__ */ $({
|
|
|
162
187
|
this.emancipateNode(t), t.uuid === this.selectedUuid && (this.selectedUuid = null);
|
|
163
188
|
const e = (r) => {
|
|
164
189
|
r.slots && Object.values(r.slots).forEach((n) => {
|
|
165
|
-
n.forEach((
|
|
166
|
-
this.nodeMap.delete(
|
|
190
|
+
n.forEach((o) => {
|
|
191
|
+
this.nodeMap.delete(o.uuid), delete this.nodeRefsRecord[o.uuid], e(o);
|
|
167
192
|
});
|
|
168
193
|
});
|
|
169
194
|
};
|
|
@@ -175,9 +200,9 @@ const vt = /* @__PURE__ */ $({
|
|
|
175
200
|
const e = t.parentUuid;
|
|
176
201
|
if (!e) return t;
|
|
177
202
|
const r = this.nodeMap.get(e);
|
|
178
|
-
return r && r.slots && Object.entries(r.slots).forEach(([n,
|
|
179
|
-
r.slots[n] =
|
|
180
|
-
(
|
|
203
|
+
return r && r.slots && Object.entries(r.slots).forEach(([n, o]) => {
|
|
204
|
+
r.slots[n] = o.filter(
|
|
205
|
+
(s) => s.uuid !== t.uuid
|
|
181
206
|
);
|
|
182
207
|
}), t.parentUuid = null, this.nodeMap.get(t.uuid) === t && this.nodeMap.delete(t.uuid), t;
|
|
183
208
|
},
|
|
@@ -188,11 +213,11 @@ const vt = /* @__PURE__ */ $({
|
|
|
188
213
|
},
|
|
189
214
|
appendNodeTo(t, e, r = "default") {
|
|
190
215
|
if (!this.resolver) throw new Error("Resolver is not set.");
|
|
191
|
-
if (!
|
|
216
|
+
if (!oe(t, e, this.resolver))
|
|
192
217
|
throw new Error(
|
|
193
|
-
`${
|
|
218
|
+
`${J(
|
|
194
219
|
t
|
|
195
|
-
)} is not allowed to be a child of ${
|
|
220
|
+
)} is not allowed to be a child of ${J(e)}.`
|
|
196
221
|
);
|
|
197
222
|
t = this.emancipateNode(t), t.parentUuid = e.uuid;
|
|
198
223
|
const n = this.nodeMap.get(e.uuid);
|
|
@@ -200,11 +225,11 @@ const vt = /* @__PURE__ */ $({
|
|
|
200
225
|
},
|
|
201
226
|
prependNodeTo(t, e, r = "default") {
|
|
202
227
|
if (!this.resolver) throw new Error("Resolver is not set");
|
|
203
|
-
if (!
|
|
228
|
+
if (!oe(t, e, this.resolver))
|
|
204
229
|
throw new Error(
|
|
205
|
-
`${
|
|
230
|
+
`${J(
|
|
206
231
|
t
|
|
207
|
-
)} is not allowed to be a child of ${
|
|
232
|
+
)} is not allowed to be a child of ${J(e)}.`
|
|
208
233
|
);
|
|
209
234
|
t = this.emancipateNode(t), t.parentUuid = e.uuid;
|
|
210
235
|
const n = this.nodeMap.get(e.uuid);
|
|
@@ -212,41 +237,41 @@ const vt = /* @__PURE__ */ $({
|
|
|
212
237
|
},
|
|
213
238
|
insertNodeBefore(t, e, r) {
|
|
214
239
|
if (!this.resolver) throw new Error("Resolver is not set");
|
|
215
|
-
if (!
|
|
240
|
+
if (!me(t, e, this.resolver))
|
|
216
241
|
throw new Error("Can not be the sibling of the target node.");
|
|
217
242
|
t = this.emancipateNode(t);
|
|
218
243
|
const n = e.parentUuid;
|
|
219
244
|
if (!n) throw new Error("Target node has no parent.");
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
(i) =>
|
|
245
|
+
const o = this.nodeMap.get(n);
|
|
246
|
+
if (o && o.slots) {
|
|
247
|
+
const s = r || Object.keys(o.slots).find(
|
|
248
|
+
(i) => o.slots[i].some((a) => a.uuid === e.uuid)
|
|
224
249
|
);
|
|
225
|
-
if (
|
|
226
|
-
const i =
|
|
250
|
+
if (s && o.slots[s]) {
|
|
251
|
+
const i = o.slots[s].findIndex(
|
|
227
252
|
(a) => a.uuid === e.uuid
|
|
228
253
|
);
|
|
229
|
-
i !== -1 && (
|
|
254
|
+
i !== -1 && (o.slots[s].splice(i, 0, t), t.parentUuid = n, this.nodeMap.set(o.uuid, o), this.addNodeAndChildrenToMap(t));
|
|
230
255
|
}
|
|
231
256
|
}
|
|
232
257
|
},
|
|
233
258
|
insertNodeAfter(t, e, r) {
|
|
234
259
|
if (!this.resolver) throw new Error("Resolver is not set");
|
|
235
|
-
if (!
|
|
260
|
+
if (!me(t, e, this.resolver))
|
|
236
261
|
throw new Error("Can not be the sibling of the target node.");
|
|
237
262
|
t = this.emancipateNode(t);
|
|
238
263
|
const n = e.parentUuid;
|
|
239
264
|
if (!n) throw new Error("Target node has no parent.");
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
const
|
|
243
|
-
(i) =>
|
|
265
|
+
const o = this.nodeMap.get(n);
|
|
266
|
+
if (o && o.slots) {
|
|
267
|
+
const s = r || Object.keys(o.slots).find(
|
|
268
|
+
(i) => o.slots[i].some((a) => a.uuid === e.uuid)
|
|
244
269
|
);
|
|
245
|
-
if (
|
|
246
|
-
const i =
|
|
270
|
+
if (s && o.slots[s]) {
|
|
271
|
+
const i = o.slots[s].findIndex(
|
|
247
272
|
(a) => a.uuid === e.uuid
|
|
248
273
|
);
|
|
249
|
-
i !== -1 && (
|
|
274
|
+
i !== -1 && (o.slots[s].splice(i + 1, 0, t), t.parentUuid = n, this.nodeMap.set(o.uuid, o), this.addNodeAndChildrenToMap(t));
|
|
250
275
|
}
|
|
251
276
|
}
|
|
252
277
|
},
|
|
@@ -266,18 +291,20 @@ const vt = /* @__PURE__ */ $({
|
|
|
266
291
|
const n = t.nodeMap.get(r);
|
|
267
292
|
if (!n)
|
|
268
293
|
throw new Error(`Node with UUID ${r} not found`);
|
|
269
|
-
const
|
|
270
|
-
return n.slots && Object.entries(n.slots).forEach(([
|
|
271
|
-
s
|
|
294
|
+
const o = {};
|
|
295
|
+
return n.slots && Object.entries(n.slots).forEach(([s, i]) => {
|
|
296
|
+
o[s] = i.map(
|
|
297
|
+
(a) => e(a.uuid)
|
|
298
|
+
);
|
|
272
299
|
}), {
|
|
273
300
|
...n,
|
|
274
|
-
slots:
|
|
301
|
+
slots: o
|
|
275
302
|
};
|
|
276
303
|
};
|
|
277
304
|
return t.rootNodes.map((r) => e(r));
|
|
278
305
|
}
|
|
279
306
|
}
|
|
280
|
-
}),
|
|
307
|
+
}), Dt = ["value", "onKeyup"], At = /* @__PURE__ */ I({
|
|
281
308
|
__name: "CraftComponentSimpleText",
|
|
282
309
|
props: {
|
|
283
310
|
content: { default: "Lorem ipsum dolor sit amet..." },
|
|
@@ -286,77 +313,100 @@ const vt = /* @__PURE__ */ $({
|
|
|
286
313
|
},
|
|
287
314
|
emits: ["update:content"],
|
|
288
315
|
setup(t, { emit: e }) {
|
|
289
|
-
const r = t, n = e, s =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
});
|
|
295
|
-
}, p = () => {
|
|
296
|
-
o.value && (o.value.style.height = "auto", o.value.style.height = `${o.value.scrollHeight}px`);
|
|
297
|
-
}, b = async () => {
|
|
298
|
-
if (a.enableDragging(), s.value) {
|
|
299
|
-
s.value = !1;
|
|
300
|
-
const D = o.value?.value.trim() || "";
|
|
301
|
-
if (D !== r.content) {
|
|
302
|
-
if (!u.value?.uuid)
|
|
303
|
-
return;
|
|
304
|
-
a.nodeMap.set(u.value.uuid, {
|
|
305
|
-
...u.value,
|
|
306
|
-
props: {
|
|
307
|
-
...u.value.props,
|
|
308
|
-
content: D
|
|
309
|
-
}
|
|
310
|
-
}), await ue(), n("update:content", D);
|
|
311
|
-
}
|
|
316
|
+
const r = t, n = e, s = (() => {
|
|
317
|
+
try {
|
|
318
|
+
return L();
|
|
319
|
+
} catch {
|
|
320
|
+
return null;
|
|
312
321
|
}
|
|
322
|
+
})(), i = s ? G(s).enabled : F(!1), a = F(!1), u = F(null), c = F(""), { craftNode: f } = xt(), p = b(() => !!s && i.value), v = b(() => p.value && !a.value), h = () => {
|
|
323
|
+
v.value && g();
|
|
313
324
|
}, g = () => {
|
|
314
|
-
|
|
325
|
+
c.value = r.content, a.value = !0, s?.disableDragging(), ne(() => {
|
|
326
|
+
u.value && (u.value.focus(), C());
|
|
327
|
+
});
|
|
328
|
+
}, C = () => {
|
|
329
|
+
u.value && (u.value.style.height = "auto", u.value.style.height = `${u.value.scrollHeight}px`);
|
|
330
|
+
}, T = async () => {
|
|
331
|
+
if (s?.enableDragging(), !a.value) return;
|
|
332
|
+
a.value = !1;
|
|
333
|
+
const A = u.value?.value.trim() ?? "";
|
|
334
|
+
A !== r.content && f.value?.uuid && (s?.nodeMap.set(f.value.uuid, {
|
|
335
|
+
...f.value,
|
|
336
|
+
props: {
|
|
337
|
+
...f.value.props,
|
|
338
|
+
content: A
|
|
339
|
+
}
|
|
340
|
+
}), await ne(), n("update:content", A));
|
|
341
|
+
}, N = () => {
|
|
342
|
+
a.value = !1, n("update:content", c.value);
|
|
315
343
|
};
|
|
316
|
-
return
|
|
317
|
-
!
|
|
318
|
-
}), (
|
|
319
|
-
class:
|
|
344
|
+
return s && te(i, (A) => {
|
|
345
|
+
!A && a.value && N();
|
|
346
|
+
}), (A, E) => (m(), x(ce(t.componentName), {
|
|
347
|
+
class: se({
|
|
348
|
+
"pre-wrap": !a.value,
|
|
349
|
+
"editable-text": p.value,
|
|
350
|
+
"is-editable": p.value,
|
|
351
|
+
"is-editing": a.value
|
|
352
|
+
}),
|
|
320
353
|
onDblclick: h
|
|
321
354
|
}, {
|
|
322
|
-
default:
|
|
323
|
-
|
|
324
|
-
|
|
355
|
+
default: H(() => [
|
|
356
|
+
vt(ee(a.value ? "" : t.content) + " ", 1),
|
|
357
|
+
a.value ? (m(), y("textarea", {
|
|
325
358
|
key: 0,
|
|
326
359
|
ref_key: "textareaRef",
|
|
327
|
-
ref:
|
|
360
|
+
ref: u,
|
|
328
361
|
class: "editable-text__textarea",
|
|
329
362
|
value: t.content,
|
|
330
|
-
onInput:
|
|
331
|
-
onBlur:
|
|
363
|
+
onInput: C,
|
|
364
|
+
onBlur: T,
|
|
332
365
|
onKeyup: [
|
|
333
|
-
|
|
334
|
-
|
|
366
|
+
Me(j(T, ["exact"]), ["enter"]),
|
|
367
|
+
Me(N, ["esc"])
|
|
335
368
|
]
|
|
336
|
-
}, null, 40,
|
|
369
|
+
}, null, 40, Dt)) : k("", !0)
|
|
337
370
|
]),
|
|
338
371
|
_: 1
|
|
339
372
|
}, 40, ["class"]));
|
|
340
373
|
}
|
|
341
374
|
});
|
|
342
|
-
class
|
|
375
|
+
class be {
|
|
343
376
|
resolverMap = {};
|
|
377
|
+
resolveComponentHook;
|
|
344
378
|
constructor(e = {}) {
|
|
345
|
-
return this.setResolverMap(e),
|
|
379
|
+
return this.setResolverMap(e), Fe(this);
|
|
346
380
|
}
|
|
347
381
|
setResolverMap(e) {
|
|
348
382
|
this.resolverMap = {}, Object.entries(e).forEach(([r, n]) => {
|
|
349
383
|
this.resolverMap[n.componentName] = n;
|
|
350
384
|
});
|
|
351
385
|
}
|
|
386
|
+
onResolveComponent(e) {
|
|
387
|
+
this.resolveComponentHook = e;
|
|
388
|
+
}
|
|
352
389
|
resolve(e) {
|
|
353
390
|
return this.resolverMap[e];
|
|
354
391
|
}
|
|
392
|
+
resolveComponent(e) {
|
|
393
|
+
const r = K(e) ? e.props.componentName : e.componentName, n = (o) => {
|
|
394
|
+
const s = this.resolve(o);
|
|
395
|
+
if (s?.component)
|
|
396
|
+
return typeof s.component == "function" && !("setup" in s.component) && !("render" in s.component), s.component;
|
|
397
|
+
};
|
|
398
|
+
if (this.resolveComponentHook) {
|
|
399
|
+
const o = this.resolveComponentHook(e, n);
|
|
400
|
+
if (o)
|
|
401
|
+
return o;
|
|
402
|
+
}
|
|
403
|
+
return n(r);
|
|
404
|
+
}
|
|
355
405
|
getDefaultProps(e) {
|
|
356
406
|
return this.resolveNode(e)?.defaultProps || {};
|
|
357
407
|
}
|
|
358
408
|
resolveNode(e) {
|
|
359
|
-
return
|
|
409
|
+
return K(e) ? this.resolve(e.props.componentName) : this.resolve(e.componentName);
|
|
360
410
|
}
|
|
361
411
|
getSchema(e) {
|
|
362
412
|
return this.resolveNode(e)?.propsSchema || {};
|
|
@@ -368,63 +418,7 @@ class ye {
|
|
|
368
418
|
return this.resolveNode(e)?.rules || {};
|
|
369
419
|
}
|
|
370
420
|
}
|
|
371
|
-
const
|
|
372
|
-
__name: "CraftEditor",
|
|
373
|
-
props: {
|
|
374
|
-
config: {},
|
|
375
|
-
useIframe: { type: Boolean, default: !1 },
|
|
376
|
-
iFrameStyleSheets: { default: () => [] },
|
|
377
|
-
iFrameClass: { type: [Boolean, null, String, Object, Array], default: "" },
|
|
378
|
-
inheritStyles: { type: Boolean, default: !1 }
|
|
379
|
-
},
|
|
380
|
-
emits: ["nodeDragStart", "nodeDragEnd", "iframeLoad"],
|
|
381
|
-
setup(t, { emit: e }) {
|
|
382
|
-
const r = t, n = e, s = j(), { getDraggedNode: o } = Z(s);
|
|
383
|
-
le(o, (a) => {
|
|
384
|
-
if (a) {
|
|
385
|
-
n("nodeDragStart", a);
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
n("nodeDragEnd");
|
|
389
|
-
});
|
|
390
|
-
const i = K(new ye(r.config.resolverMap));
|
|
391
|
-
return re("resolver", i), (a, c) => {
|
|
392
|
-
const u = B("CraftFrame"), d = B("CraftEditorPanelLayout");
|
|
393
|
-
return v(), N(d, {
|
|
394
|
-
blueprints: t.config.blueprintsLibrary
|
|
395
|
-
}, ge({ _: 2 }, [
|
|
396
|
-
a.$slots["panel-layout"] ? {
|
|
397
|
-
name: "panel-layout",
|
|
398
|
-
fn: X(({ blueprints: h, deselectNodes: m }) => [
|
|
399
|
-
W(a.$slots, "panel-layout", {
|
|
400
|
-
blueprints: h,
|
|
401
|
-
deselectNodes: m
|
|
402
|
-
})
|
|
403
|
-
]),
|
|
404
|
-
key: "0"
|
|
405
|
-
} : {
|
|
406
|
-
name: "default",
|
|
407
|
-
fn: X(() => [
|
|
408
|
-
G(u, {
|
|
409
|
-
useIframe: t.useIframe,
|
|
410
|
-
inheritStyles: t.inheritStyles,
|
|
411
|
-
iFrameStyleSheets: t.iFrameStyleSheets,
|
|
412
|
-
iFrameClass: t.iFrameClass,
|
|
413
|
-
resolverMap: t.config.resolverMap,
|
|
414
|
-
onIframeLoad: c[0] || (c[0] = (h) => n("iframeLoad", h))
|
|
415
|
-
}, {
|
|
416
|
-
default: X(() => [
|
|
417
|
-
W(a.$slots, "default")
|
|
418
|
-
]),
|
|
419
|
-
_: 3
|
|
420
|
-
}, 8, ["useIframe", "inheritStyles", "iFrameStyleSheets", "iFrameClass", "resolverMap"])
|
|
421
|
-
]),
|
|
422
|
-
key: "1"
|
|
423
|
-
}
|
|
424
|
-
]), 1032, ["blueprints"]);
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
}), Se = He("indicator", {
|
|
421
|
+
const De = Ve("indicator", {
|
|
428
422
|
state: () => ({
|
|
429
423
|
barSize: 2,
|
|
430
424
|
visible: !1,
|
|
@@ -455,18 +449,18 @@ const Ct = /* @__PURE__ */ $({
|
|
|
455
449
|
},
|
|
456
450
|
pointAfter(t) {
|
|
457
451
|
this.show();
|
|
458
|
-
const { top: e, left: r, width: n, height:
|
|
459
|
-
this.coordinates.top = e, this.coordinates.left = r + n, this.dimensions.width = this.barSize, this.dimensions.height =
|
|
452
|
+
const { top: e, left: r, width: n, height: o } = t.getBoundingClientRect();
|
|
453
|
+
this.coordinates.top = e, this.coordinates.left = r + n, this.dimensions.width = this.barSize, this.dimensions.height = o;
|
|
460
454
|
},
|
|
461
455
|
pointInside(t) {
|
|
462
456
|
this.show();
|
|
463
|
-
const e =
|
|
464
|
-
this.coordinates.top = r +
|
|
457
|
+
const e = $e(t), { top: r, left: n, width: o, height: s } = t.getBoundingClientRect(), i = Number.parseInt(e.paddingLeft), a = Number.parseInt(e.paddingTop), u = Number.parseInt(e.paddingRight);
|
|
458
|
+
this.coordinates.top = r + s - a, this.coordinates.left = n + i, this.dimensions.width = o - i - u, this.dimensions.height = this.barSize;
|
|
465
459
|
},
|
|
466
460
|
pointInsideTop(t) {
|
|
467
461
|
this.show();
|
|
468
|
-
const e =
|
|
469
|
-
this.coordinates.top = r + i, this.coordinates.left = n +
|
|
462
|
+
const e = $e(t), { top: r, left: n, width: o } = t.getBoundingClientRect(), s = Number.parseInt(e.paddingLeft), i = Number.parseInt(e.paddingTop), a = Number.parseInt(e.paddingRight);
|
|
463
|
+
this.coordinates.top = r + i, this.coordinates.left = n + s, this.dimensions.width = o - s - a, this.dimensions.height = this.barSize;
|
|
470
464
|
}
|
|
471
465
|
},
|
|
472
466
|
getters: {
|
|
@@ -476,73 +470,139 @@ const Ct = /* @__PURE__ */ $({
|
|
|
476
470
|
size: (t) => t.dimensions
|
|
477
471
|
}
|
|
478
472
|
});
|
|
479
|
-
function
|
|
480
|
-
|
|
473
|
+
function $e(t) {
|
|
474
|
+
if (!(t instanceof HTMLElement))
|
|
475
|
+
return {
|
|
476
|
+
paddingTop: "0",
|
|
477
|
+
paddingLeft: "0",
|
|
478
|
+
paddingRight: "0",
|
|
479
|
+
paddingBottom: "0"
|
|
480
|
+
};
|
|
481
|
+
const { paddingTop: e, paddingLeft: r, paddingRight: n, paddingBottom: o } = getComputedStyle(t), s = {
|
|
481
482
|
paddingTop: e,
|
|
482
483
|
paddingLeft: r,
|
|
483
484
|
paddingRight: n,
|
|
484
|
-
paddingBottom:
|
|
485
|
+
paddingBottom: o
|
|
485
486
|
};
|
|
486
|
-
return Object.keys(
|
|
487
|
-
|
|
488
|
-
}),
|
|
487
|
+
return Object.keys(s).forEach((i) => {
|
|
488
|
+
s[i] = parseInt(s[i].slice(0, -2), 10);
|
|
489
|
+
}), s;
|
|
489
490
|
}
|
|
490
|
-
const
|
|
491
|
+
const Pt = /* @__PURE__ */ I({
|
|
492
|
+
__name: "CraftEditor",
|
|
493
|
+
props: {
|
|
494
|
+
config: {},
|
|
495
|
+
iframe: {}
|
|
496
|
+
},
|
|
497
|
+
emits: ["nodeDragStart", "nodeDragEnd", "iframeLoad"],
|
|
498
|
+
setup(t, { emit: e }) {
|
|
499
|
+
const r = t, n = e, o = L(), s = De(), { getDraggedNode: i } = G(o);
|
|
500
|
+
te(i, (u) => {
|
|
501
|
+
if (u) {
|
|
502
|
+
n("nodeDragStart", u);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
n("nodeDragEnd"), s.hide();
|
|
506
|
+
});
|
|
507
|
+
const a = F(
|
|
508
|
+
r.config.resolver || new be(r.config.resolverMap)
|
|
509
|
+
);
|
|
510
|
+
return q("resolver", a), (u, c) => {
|
|
511
|
+
const f = U("CraftFrame"), p = U("CraftEditorPanelLayout");
|
|
512
|
+
return m(), x(p, {
|
|
513
|
+
blueprints: t.config.blueprintsLibrary
|
|
514
|
+
}, de({ _: 2 }, [
|
|
515
|
+
u.$slots["panel-layout"] ? {
|
|
516
|
+
name: "panel-layout",
|
|
517
|
+
fn: H(({ blueprints: v, deselectNodes: h }) => [
|
|
518
|
+
Y(u.$slots, "panel-layout", {
|
|
519
|
+
blueprints: v,
|
|
520
|
+
deselectNodes: h
|
|
521
|
+
})
|
|
522
|
+
]),
|
|
523
|
+
key: "0"
|
|
524
|
+
} : {
|
|
525
|
+
name: "default",
|
|
526
|
+
fn: H(() => [
|
|
527
|
+
W(f, {
|
|
528
|
+
iframe: t.iframe,
|
|
529
|
+
resolverMap: t.config.resolverMap,
|
|
530
|
+
onIframeLoad: c[0] || (c[0] = (v) => n("iframeLoad", v))
|
|
531
|
+
}, {
|
|
532
|
+
default: H(() => [
|
|
533
|
+
Y(u.$slots, "default")
|
|
534
|
+
]),
|
|
535
|
+
_: 3
|
|
536
|
+
}, 8, ["iframe", "resolverMap"])
|
|
537
|
+
]),
|
|
538
|
+
key: "1"
|
|
539
|
+
}
|
|
540
|
+
]), 1032, ["blueprints"]);
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
}), Mt = /* @__PURE__ */ I({
|
|
491
544
|
name: "CraftEditorBlueprint",
|
|
492
545
|
__name: "CraftEditorBlueprint",
|
|
493
546
|
props: {
|
|
494
547
|
craftNode: {}
|
|
495
548
|
},
|
|
496
549
|
setup(t) {
|
|
497
|
-
const e =
|
|
498
|
-
console.log("CraftEditorBlueprint - dragging node:",
|
|
499
|
-
}, o = (
|
|
500
|
-
|
|
550
|
+
const e = L(), r = t, n = (s) => {
|
|
551
|
+
console.log("CraftEditorBlueprint - dragging node:", r.craftNode), console.log("CraftEditorBlueprint - node.componentName:", r.craftNode.componentName), console.log("CraftEditorBlueprint - node.props:", r.craftNode.props), e.dragNode(r.craftNode);
|
|
552
|
+
}, o = (s) => {
|
|
553
|
+
s.stopPropagation(), e.dragNode(null);
|
|
501
554
|
};
|
|
502
|
-
return (
|
|
555
|
+
return (s, i) => (m(), y("div", {
|
|
503
556
|
draggable: !0,
|
|
504
|
-
onDragstart:
|
|
557
|
+
onDragstart: j(n, ["stop"]),
|
|
505
558
|
onDragend: o
|
|
506
559
|
}, [
|
|
507
|
-
|
|
560
|
+
Y(s.$slots, "default")
|
|
508
561
|
], 32));
|
|
509
562
|
}
|
|
510
|
-
}),
|
|
511
|
-
const n = t.blueprints[r],
|
|
563
|
+
}), Ge = (t, e) => Object.keys(t.blueprints).map((r) => {
|
|
564
|
+
const n = t.blueprints[r], o = e.getDefaultProps({
|
|
512
565
|
...n,
|
|
513
|
-
uuid:
|
|
566
|
+
uuid: le()
|
|
514
567
|
});
|
|
515
568
|
return {
|
|
516
569
|
...n,
|
|
517
|
-
props: { ...
|
|
570
|
+
props: { ...o, ...n.props }
|
|
518
571
|
};
|
|
519
|
-
}),
|
|
572
|
+
}), Ze = (t) => {
|
|
573
|
+
let e = 0;
|
|
574
|
+
for (let s = 0; s < t.length; s++)
|
|
575
|
+
e = t.charCodeAt(s) + ((e << 5) - e);
|
|
576
|
+
const r = e % 360, n = 70 + e % 30, o = 45 + e % 30;
|
|
577
|
+
return `hsla(${r}, ${n}%, ${o}%, 0.9)`;
|
|
578
|
+
}, $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
520
579
|
__proto__: null,
|
|
521
|
-
blueprintsWithDefaults:
|
|
522
|
-
|
|
580
|
+
blueprintsWithDefaults: Ge,
|
|
581
|
+
generateColorFromUUID: Ze
|
|
582
|
+
}, Symbol.toStringTag, { value: "Module" })), Rt = { key: 0 }, It = { class: "flex flex-wrap gap-2 p-1" }, Tt = { class: "v-craft-blueprint" }, Ut = { class: "v-craft-blueprint-label" }, Bt = /* @__PURE__ */ I({
|
|
523
583
|
__name: "CraftEditorBlueprintsList",
|
|
524
584
|
props: {
|
|
525
585
|
blueprints: {}
|
|
526
586
|
},
|
|
527
587
|
setup(t) {
|
|
528
|
-
const e =
|
|
588
|
+
const e = ue("resolver");
|
|
529
589
|
return (r, n) => {
|
|
530
|
-
const
|
|
531
|
-
return
|
|
532
|
-
(
|
|
533
|
-
|
|
534
|
-
group:
|
|
535
|
-
resolver:
|
|
590
|
+
const o = U("CraftEditorBlueprint");
|
|
591
|
+
return d(e) ? (m(), y("div", Rt, [
|
|
592
|
+
(m(!0), y(R, null, $(t.blueprints.groups, (s) => (m(), y("div", null, [
|
|
593
|
+
Y(r.$slots, "blueprint-group", {
|
|
594
|
+
group: s,
|
|
595
|
+
resolver: d(e)
|
|
536
596
|
}, () => [
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
(
|
|
597
|
+
S("h4", null, ee(s.label), 1),
|
|
598
|
+
S("div", It, [
|
|
599
|
+
(m(!0), y(R, null, $(d(Ge)(s, d(e)), (i, a) => (m(), x(o, {
|
|
540
600
|
craftNode: i,
|
|
541
601
|
key: a
|
|
542
602
|
}, {
|
|
543
|
-
default:
|
|
544
|
-
|
|
545
|
-
|
|
603
|
+
default: H(() => [
|
|
604
|
+
S("div", Tt, [
|
|
605
|
+
S("div", Ut, ee(i.label), 1)
|
|
546
606
|
])
|
|
547
607
|
]),
|
|
548
608
|
_: 2
|
|
@@ -550,10 +610,10 @@ const wt = /* @__PURE__ */ $({
|
|
|
550
610
|
])
|
|
551
611
|
])
|
|
552
612
|
]))), 256))
|
|
553
|
-
])) :
|
|
613
|
+
])) : k("", !0);
|
|
554
614
|
};
|
|
555
615
|
}
|
|
556
|
-
}),
|
|
616
|
+
}), Lt = { class: "v-craft-panel v-craft-blueprints-panel" }, jt = { class: "v-craft-panel-content" }, Ft = /* @__PURE__ */ I({
|
|
557
617
|
name: "CraftEditorPanelBlueprints",
|
|
558
618
|
__name: "CraftEditorPanelBlueprints",
|
|
559
619
|
props: {
|
|
@@ -562,21 +622,21 @@ const wt = /* @__PURE__ */ $({
|
|
|
562
622
|
emits: ["close"],
|
|
563
623
|
setup(t) {
|
|
564
624
|
return (e, r) => {
|
|
565
|
-
const n =
|
|
566
|
-
return
|
|
567
|
-
r[0] || (r[0] =
|
|
568
|
-
|
|
569
|
-
|
|
625
|
+
const n = U("CraftEditorBlueprintsList");
|
|
626
|
+
return m(), y("div", Lt, [
|
|
627
|
+
r[0] || (r[0] = S("h3", { class: "v-craft-title" }, "blueprints", -1)),
|
|
628
|
+
S("div", jt, [
|
|
629
|
+
W(n, { blueprints: t.blueprints }, null, 8, ["blueprints"])
|
|
570
630
|
])
|
|
571
631
|
]);
|
|
572
632
|
};
|
|
573
633
|
}
|
|
574
|
-
}),
|
|
634
|
+
}), Ee = (t, e) => {
|
|
575
635
|
const r = t.__vccOpts || t;
|
|
576
|
-
for (const [n,
|
|
577
|
-
r[n] =
|
|
636
|
+
for (const [n, o] of e)
|
|
637
|
+
r[n] = o;
|
|
578
638
|
return r;
|
|
579
|
-
},
|
|
639
|
+
}, Ht = /* @__PURE__ */ Ee(Ft, [["__scopeId", "data-v-a6de4dca"]]), Vt = /* @__PURE__ */ I({
|
|
580
640
|
__name: "CraftEditorPanelForm",
|
|
581
641
|
props: {
|
|
582
642
|
craftNode: {},
|
|
@@ -585,35 +645,35 @@ const wt = /* @__PURE__ */ $({
|
|
|
585
645
|
},
|
|
586
646
|
emits: ["update"],
|
|
587
647
|
setup(t, { emit: e }) {
|
|
588
|
-
const r = t, n = e,
|
|
589
|
-
() =>
|
|
590
|
-
),
|
|
591
|
-
n("update",
|
|
592
|
-
}, 50),
|
|
593
|
-
|
|
648
|
+
const r = t, n = e, o = ve(r, "model"), s = ve(r, "schema"), i = ve(r, "craftNode"), a = b(
|
|
649
|
+
() => o.value ? { ...o.value } : {}
|
|
650
|
+
), u = Ke((f) => {
|
|
651
|
+
n("update", f);
|
|
652
|
+
}, 50), c = (f) => {
|
|
653
|
+
f != null && u(f);
|
|
594
654
|
};
|
|
595
|
-
return
|
|
655
|
+
return mt(() => u.cancel()), (f, p) => Y(f.$slots, "panel-content", {
|
|
596
656
|
craftNode: i.value,
|
|
597
657
|
model: a.value,
|
|
598
|
-
handleFormInput:
|
|
599
|
-
schema:
|
|
658
|
+
handleFormInput: c,
|
|
659
|
+
schema: s.value
|
|
600
660
|
});
|
|
601
661
|
}
|
|
602
|
-
}),
|
|
662
|
+
}), Kt = { class: "v-craft-panel v-craft-layers-panel" }, Xt = { class: "v-craft-layers" }, zt = { class: "v-craft-node-layers" }, qt = /* @__PURE__ */ I({
|
|
603
663
|
name: "CraftEditorPanelLayers",
|
|
604
664
|
__name: "CraftEditorPanelLayers",
|
|
605
665
|
setup(t) {
|
|
606
|
-
const e =
|
|
607
|
-
e.selectNode(
|
|
666
|
+
const e = L(), { nodeTree: r } = G(e), n = (o) => {
|
|
667
|
+
e.selectNode(o);
|
|
608
668
|
};
|
|
609
|
-
return (
|
|
610
|
-
const i =
|
|
611
|
-
return
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
(
|
|
616
|
-
key:
|
|
669
|
+
return (o, s) => {
|
|
670
|
+
const i = U("CraftEditorPanelNodeLayer");
|
|
671
|
+
return m(), y("div", Kt, [
|
|
672
|
+
s[0] || (s[0] = S("h3", { class: "v-craft-title" }, "tree", -1)),
|
|
673
|
+
S("div", Xt, [
|
|
674
|
+
S("ul", zt, [
|
|
675
|
+
(m(!0), y(R, null, $(d(r), (a, u) => (m(), x(i, {
|
|
676
|
+
key: u,
|
|
617
677
|
craftNode: a,
|
|
618
678
|
onLayerClick: n
|
|
619
679
|
}, null, 8, ["craftNode"]))), 128))
|
|
@@ -622,91 +682,89 @@ const wt = /* @__PURE__ */ $({
|
|
|
622
682
|
]);
|
|
623
683
|
};
|
|
624
684
|
}
|
|
625
|
-
}),
|
|
685
|
+
}), Yt = /* @__PURE__ */ Ee(qt, [["__scopeId", "data-v-ab795ec3"]]), Qt = { key: 0 }, Wt = {
|
|
626
686
|
key: 1,
|
|
627
687
|
class: "v-craft-panel-manager"
|
|
628
|
-
},
|
|
688
|
+
}, Gt = { class: "flex w-full justify-between gap-10" }, Zt = { class: "v-craft-grid-panel v-craft-panel-left shrink" }, Jt = { class: "v-craft-grid-panel v-craft-panel-right shrink" }, er = /* @__PURE__ */ I({
|
|
629
689
|
__name: "CraftEditorPanelLayout",
|
|
630
690
|
props: {
|
|
631
691
|
blueprints: {}
|
|
632
692
|
},
|
|
633
693
|
setup(t) {
|
|
634
|
-
const e =
|
|
694
|
+
const e = L(), r = () => {
|
|
635
695
|
e.selectNode(null);
|
|
636
696
|
};
|
|
637
|
-
return (n,
|
|
638
|
-
const
|
|
639
|
-
return n.$slots["panel-layout"] ? (
|
|
640
|
-
|
|
697
|
+
return (n, o) => {
|
|
698
|
+
const s = U("CraftEditorPanelBlueprints"), i = U("CraftEditorPanelLayers"), a = U("CraftEditorPanelSettings");
|
|
699
|
+
return n.$slots["panel-layout"] ? (m(), y("div", Qt, [
|
|
700
|
+
Y(n.$slots, "panel-layout", {
|
|
641
701
|
blueprints: t.blueprints,
|
|
642
702
|
deselectNodes: r
|
|
643
703
|
}, void 0, !0)
|
|
644
|
-
])) : (
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
704
|
+
])) : (m(), y("div", Wt, [
|
|
705
|
+
S("div", Gt, [
|
|
706
|
+
S("div", Zt, [
|
|
707
|
+
W(s, { blueprints: t.blueprints }, null, 8, ["blueprints"])
|
|
648
708
|
]),
|
|
649
|
-
|
|
709
|
+
S("div", {
|
|
650
710
|
class: "v-craft-panel-center flex grow",
|
|
651
|
-
onClick:
|
|
711
|
+
onClick: j(r, ["stop"])
|
|
652
712
|
}, [
|
|
653
|
-
|
|
713
|
+
Y(n.$slots, "default", {}, void 0, !0)
|
|
654
714
|
]),
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
715
|
+
S("div", Jt, [
|
|
716
|
+
W(i),
|
|
717
|
+
W(a)
|
|
658
718
|
])
|
|
659
719
|
])
|
|
660
720
|
]));
|
|
661
721
|
};
|
|
662
722
|
}
|
|
663
|
-
}),
|
|
723
|
+
}), tr = /* @__PURE__ */ Ee(er, [["__scopeId", "data-v-81a2200d"]]), rr = {
|
|
664
724
|
key: 0,
|
|
665
725
|
class: "v-craft-panel-settings formkit-fieldset v-craft-scrollable-content"
|
|
666
|
-
},
|
|
726
|
+
}, nr = /* @__PURE__ */ I({
|
|
667
727
|
__name: "CraftEditorPanelNodeEventsSettings",
|
|
668
728
|
props: {
|
|
669
729
|
craftNode: {},
|
|
670
|
-
schema: { default: () =>
|
|
730
|
+
schema: { default: () => [] }
|
|
671
731
|
},
|
|
672
732
|
emits: ["update:events"],
|
|
673
733
|
setup(t, { emit: e }) {
|
|
674
|
-
const r = t, { craftNode: n, schema:
|
|
734
|
+
const r = t, { craftNode: n, schema: o } = ie(r), s = e;
|
|
675
735
|
return (i, a) => {
|
|
676
|
-
const
|
|
677
|
-
return
|
|
678
|
-
craftNode:
|
|
679
|
-
schema:
|
|
680
|
-
model:
|
|
681
|
-
onUpdate: a[0] || (a[0] = (
|
|
736
|
+
const u = U("CraftEditorPanelForm");
|
|
737
|
+
return m(), x(u, {
|
|
738
|
+
craftNode: d(n),
|
|
739
|
+
schema: d(o),
|
|
740
|
+
model: d(n)?.events,
|
|
741
|
+
onUpdate: a[0] || (a[0] = (c) => s("update:events", c))
|
|
682
742
|
}, {
|
|
683
|
-
"panel-content":
|
|
684
|
-
|
|
685
|
-
a[1] || (a[1] =
|
|
686
|
-
(
|
|
687
|
-
key:
|
|
743
|
+
"panel-content": H(({ craftNode: c, model: f, handleFormInput: p, schema: v }) => [
|
|
744
|
+
v ? (m(), y("fieldset", rr, [
|
|
745
|
+
a[1] || (a[1] = S("legend", { class: "formkit-legend" }, "Events", -1)),
|
|
746
|
+
(m(), x(d(Xe), {
|
|
747
|
+
key: c?.uuid,
|
|
688
748
|
type: "form",
|
|
689
|
-
value:
|
|
690
|
-
onInput:
|
|
749
|
+
value: f,
|
|
750
|
+
onInput: p,
|
|
691
751
|
actions: !1
|
|
692
752
|
}, {
|
|
693
|
-
default:
|
|
694
|
-
|
|
695
|
-
schema: m
|
|
696
|
-
}, null, 8, ["schema"])
|
|
753
|
+
default: H(() => [
|
|
754
|
+
W(d(ze), { schema: v }, null, 8, ["schema"])
|
|
697
755
|
]),
|
|
698
756
|
_: 2
|
|
699
757
|
}, 1032, ["value", "onInput"]))
|
|
700
|
-
])) :
|
|
758
|
+
])) : k("", !0)
|
|
701
759
|
]),
|
|
702
760
|
_: 1
|
|
703
761
|
}, 8, ["craftNode", "schema", "model"]);
|
|
704
762
|
};
|
|
705
763
|
}
|
|
706
|
-
}),
|
|
764
|
+
}), or = { class: "v-craft-component-layer-face" }, sr = { class: "v-craft-component-name" }, ir = {
|
|
707
765
|
key: 0,
|
|
708
766
|
class: "v-craft-node-layers nested-layers"
|
|
709
|
-
},
|
|
767
|
+
}, ar = /* @__PURE__ */ I({
|
|
710
768
|
__name: "CraftEditorPanelNodeLayer",
|
|
711
769
|
props: {
|
|
712
770
|
craftNode: {},
|
|
@@ -714,46 +772,46 @@ const wt = /* @__PURE__ */ $({
|
|
|
714
772
|
},
|
|
715
773
|
emits: ["layer-click"],
|
|
716
774
|
setup(t, { emit: e }) {
|
|
717
|
-
const r = t, { craftNode: n, visible:
|
|
718
|
-
() =>
|
|
719
|
-
), i = e, a =
|
|
720
|
-
() =>
|
|
721
|
-
),
|
|
775
|
+
const r = t, { craftNode: n, visible: o } = ie(r), s = b(
|
|
776
|
+
() => o.value && n.value.visible === void 0 || n.value.visible
|
|
777
|
+
), i = e, a = L(), { selectedNode: u } = G(a), c = b(() => J(n.value)), f = b(
|
|
778
|
+
() => u?.value?.uuid === n.value.uuid
|
|
779
|
+
), p = () => {
|
|
722
780
|
a.toggleNodeVisibility(n.value);
|
|
723
781
|
};
|
|
724
|
-
return (
|
|
725
|
-
const
|
|
726
|
-
return
|
|
727
|
-
class:
|
|
728
|
-
"v-craft-node-layer-selected":
|
|
782
|
+
return (v, h) => {
|
|
783
|
+
const g = U("CraftEditorPanelNodeLayer", !0);
|
|
784
|
+
return m(), y("li", {
|
|
785
|
+
class: se(["v-craft-node-layer", {
|
|
786
|
+
"v-craft-node-layer-selected": f.value
|
|
729
787
|
}]),
|
|
730
|
-
onClick:
|
|
788
|
+
onClick: h[1] || (h[1] = j((C) => i("layer-click", d(n)), ["prevent", "stop"]))
|
|
731
789
|
}, [
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
790
|
+
S("div", or, [
|
|
791
|
+
S("div", sr, ee(c.value), 1),
|
|
792
|
+
S("button", {
|
|
735
793
|
type: "button",
|
|
736
794
|
class: "v-craft-component-icon",
|
|
737
|
-
onClick:
|
|
738
|
-
},
|
|
795
|
+
onClick: j(p, ["prevent", "stop"])
|
|
796
|
+
}, ee(s.value ? "hide" : "show"), 1)
|
|
739
797
|
]),
|
|
740
|
-
|
|
741
|
-
(
|
|
742
|
-
(
|
|
743
|
-
key: `${
|
|
744
|
-
craftNode:
|
|
745
|
-
onLayerClick:
|
|
746
|
-
visible:
|
|
798
|
+
d(n).slots && Object.keys(d(n).slots).length > 0 ? (m(), y("ul", ir, [
|
|
799
|
+
(m(!0), y(R, null, $(d(n).slots, (C, T) => (m(), y(R, { key: T }, [
|
|
800
|
+
(m(!0), y(R, null, $(C, (N, A) => (m(), x(g, {
|
|
801
|
+
key: `${T}-${A}`,
|
|
802
|
+
craftNode: N,
|
|
803
|
+
onLayerClick: h[0] || (h[0] = (E) => i("layer-click", E)),
|
|
804
|
+
visible: s.value
|
|
747
805
|
}, null, 8, ["craftNode", "visible"]))), 128))
|
|
748
806
|
], 64))), 128))
|
|
749
|
-
])) :
|
|
807
|
+
])) : k("", !0)
|
|
750
808
|
], 2);
|
|
751
809
|
};
|
|
752
810
|
}
|
|
753
|
-
}),
|
|
811
|
+
}), lr = /* @__PURE__ */ Ee(ar, [["__scopeId", "data-v-208a4e02"]]), ur = {
|
|
754
812
|
key: 0,
|
|
755
813
|
class: "v-craft-panel-settings formkit-fieldset v-craft-scrollable-content"
|
|
756
|
-
},
|
|
814
|
+
}, cr = /* @__PURE__ */ I({
|
|
757
815
|
__name: "CraftEditorPanelNodeSettings",
|
|
758
816
|
props: {
|
|
759
817
|
craftNode: {},
|
|
@@ -761,132 +819,130 @@ const wt = /* @__PURE__ */ $({
|
|
|
761
819
|
},
|
|
762
820
|
emits: ["update:props"],
|
|
763
821
|
setup(t, { emit: e }) {
|
|
764
|
-
const r = t, { craftNode: n, schema:
|
|
822
|
+
const r = t, { craftNode: n, schema: o } = ie(r), s = e;
|
|
765
823
|
return (i, a) => {
|
|
766
|
-
const
|
|
767
|
-
return
|
|
768
|
-
craftNode:
|
|
769
|
-
schema:
|
|
770
|
-
model:
|
|
771
|
-
onUpdate: a[0] || (a[0] = (
|
|
824
|
+
const u = U("CraftEditorPanelForm");
|
|
825
|
+
return m(), x(u, {
|
|
826
|
+
craftNode: d(n),
|
|
827
|
+
schema: d(o),
|
|
828
|
+
model: d(n)?.props,
|
|
829
|
+
onUpdate: a[0] || (a[0] = (c) => s("update:props", c))
|
|
772
830
|
}, {
|
|
773
|
-
"panel-content":
|
|
774
|
-
|
|
775
|
-
a[1] || (a[1] =
|
|
776
|
-
(
|
|
777
|
-
key:
|
|
831
|
+
"panel-content": H(({ craftNode: c, model: f, handleFormInput: p, schema: v }) => [
|
|
832
|
+
v ? (m(), y("fieldset", ur, [
|
|
833
|
+
a[1] || (a[1] = S("legend", { class: "formkit-legend" }, "Properties", -1)),
|
|
834
|
+
(m(), x(d(Xe), {
|
|
835
|
+
key: c?.uuid,
|
|
778
836
|
type: "form",
|
|
779
|
-
value:
|
|
780
|
-
onInput:
|
|
837
|
+
value: f,
|
|
838
|
+
onInput: p,
|
|
781
839
|
actions: !1
|
|
782
840
|
}, {
|
|
783
|
-
default:
|
|
784
|
-
|
|
785
|
-
schema: m
|
|
786
|
-
}, null, 8, ["schema"])
|
|
841
|
+
default: H(() => [
|
|
842
|
+
W(d(ze), { schema: v }, null, 8, ["schema"])
|
|
787
843
|
]),
|
|
788
844
|
_: 2
|
|
789
845
|
}, 1032, ["value", "onInput"]))
|
|
790
|
-
])) :
|
|
846
|
+
])) : k("", !0)
|
|
791
847
|
]),
|
|
792
848
|
_: 1
|
|
793
849
|
}, 8, ["craftNode", "schema", "model"]);
|
|
794
850
|
};
|
|
795
851
|
}
|
|
796
|
-
}),
|
|
852
|
+
}), dr = { class: "text-sm" }, fr = { key: 0 }, hr = {
|
|
797
853
|
key: 0,
|
|
798
854
|
class: "v-craft-settings"
|
|
799
|
-
},
|
|
855
|
+
}, pr = {
|
|
800
856
|
key: 1,
|
|
801
857
|
class: "v-craft-settings"
|
|
802
|
-
},
|
|
858
|
+
}, vr = {
|
|
803
859
|
class: "v-craft-actions",
|
|
804
860
|
"data-type": "button"
|
|
805
|
-
},
|
|
861
|
+
}, mr = /* @__PURE__ */ I({
|
|
806
862
|
__name: "CraftEditorPanelSettings",
|
|
807
863
|
setup(t) {
|
|
808
|
-
const e =
|
|
864
|
+
const e = L(), { selectedNode: r } = G(e), n = ue("resolver"), o = b(() => !r.value || !n?.value ? [] : n.value.getSchema(r.value)), s = b(() => !r.value || !n?.value ? [] : n.value.getEventsSchema(r.value)), i = b(
|
|
809
865
|
() => r.value && r.value.parentUuid
|
|
810
866
|
), a = () => {
|
|
811
867
|
r.value && e.removeNode(r.value);
|
|
812
|
-
},
|
|
868
|
+
}, u = b(
|
|
813
869
|
() => r.value ? `${n?.value?.resolveNode(r.value)?.componentName || "Unknown"}` : ""
|
|
814
|
-
),
|
|
815
|
-
r.value &&
|
|
816
|
-
},
|
|
817
|
-
r.value &&
|
|
870
|
+
), c = (p) => {
|
|
871
|
+
r.value && p && e.updateNodeProps(r.value.uuid, p);
|
|
872
|
+
}, f = (p) => {
|
|
873
|
+
r.value && p && e.updateNodeEvents(r.value.uuid, p);
|
|
818
874
|
};
|
|
819
|
-
return (
|
|
820
|
-
const
|
|
821
|
-
return
|
|
822
|
-
selectedNode:
|
|
823
|
-
nodeName:
|
|
824
|
-
handlePropsUpdate:
|
|
825
|
-
schema:
|
|
826
|
-
eventsSchema:
|
|
827
|
-
handleEventsUpdate:
|
|
875
|
+
return (p, v) => {
|
|
876
|
+
const h = U("CraftEditorPanelNodeSettings"), g = U("CraftEditorPanelNodeEventsSettings");
|
|
877
|
+
return Y(p.$slots, "panel-content", {
|
|
878
|
+
selectedNode: d(r),
|
|
879
|
+
nodeName: u.value,
|
|
880
|
+
handlePropsUpdate: c,
|
|
881
|
+
schema: o.value,
|
|
882
|
+
eventsSchema: s.value,
|
|
883
|
+
handleEventsUpdate: f,
|
|
828
884
|
deleteable: i.value,
|
|
829
885
|
removeNode: a
|
|
830
886
|
}, () => [
|
|
831
|
-
|
|
887
|
+
S("div", {
|
|
832
888
|
ref: "panel",
|
|
833
889
|
class: "v-craft-panel v-craft-settings-panel",
|
|
834
|
-
onClick:
|
|
890
|
+
onClick: j(() => !1, ["prevent", "stop"])
|
|
835
891
|
}, [
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
892
|
+
v[1] || (v[1] = S("h3", { class: "v-craft-title" }, "component inspector", -1)),
|
|
893
|
+
S("span", dr, ee(d(r)?.uuid), 1),
|
|
894
|
+
d(r) ? k("", !0) : (m(), y("div", fr, [...v[0] || (v[0] = [
|
|
895
|
+
S("p", null, "select a component to inspect", -1)
|
|
840
896
|
])])),
|
|
841
|
-
|
|
842
|
-
class:
|
|
897
|
+
S("div", {
|
|
898
|
+
class: se(["v-craft-properties", { "v-craft-visible": d(r) }])
|
|
843
899
|
}, [
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
craftNode:
|
|
848
|
-
schema: s.value,
|
|
849
|
-
"onUpdate:props": u
|
|
850
|
-
}, null, 8, ["craftNode", "schema"])
|
|
851
|
-
])) : x("", !0),
|
|
852
|
-
o.value && f(r) ? (v(), E("div", sr, [
|
|
853
|
-
G(b, {
|
|
854
|
-
craftNode: f(r),
|
|
900
|
+
S("h4", null, ee(u.value), 1),
|
|
901
|
+
o.value ? (m(), y("div", hr, [
|
|
902
|
+
W(h, {
|
|
903
|
+
craftNode: d(r),
|
|
855
904
|
schema: o.value,
|
|
856
|
-
"onUpdate:
|
|
905
|
+
"onUpdate:props": c
|
|
906
|
+
}, null, 8, ["craftNode", "schema"])
|
|
907
|
+
])) : k("", !0),
|
|
908
|
+
s.value && d(r) ? (m(), y("div", pr, [
|
|
909
|
+
W(g, {
|
|
910
|
+
craftNode: d(r),
|
|
911
|
+
schema: s.value,
|
|
912
|
+
"onUpdate:events": f
|
|
857
913
|
}, null, 8, ["craftNode", "schema"])
|
|
858
|
-
])) :
|
|
859
|
-
|
|
860
|
-
i.value ? (
|
|
914
|
+
])) : k("", !0),
|
|
915
|
+
S("div", vr, [
|
|
916
|
+
i.value ? (m(), y("button", {
|
|
861
917
|
key: 0,
|
|
862
918
|
class: "formkit-input v-craft-delete",
|
|
863
|
-
onClick:
|
|
864
|
-
}, " Delete ")) :
|
|
919
|
+
onClick: j(a, ["prevent"])
|
|
920
|
+
}, " Delete ")) : k("", !0)
|
|
865
921
|
])
|
|
866
922
|
], 2)
|
|
867
923
|
], 512)
|
|
868
924
|
]);
|
|
869
925
|
};
|
|
870
926
|
}
|
|
871
|
-
}),
|
|
927
|
+
}), Re = /* @__PURE__ */ I({
|
|
872
928
|
__name: "CraftDropIndicator",
|
|
873
929
|
setup(t) {
|
|
874
|
-
const e =
|
|
875
|
-
const { top: n, left:
|
|
930
|
+
const e = De(), r = () => {
|
|
931
|
+
const { top: n, left: o } = e.position, { width: s, height: i } = e.size;
|
|
876
932
|
return {
|
|
877
933
|
top: `${n}px`,
|
|
878
|
-
left: `${
|
|
934
|
+
left: `${o}px`,
|
|
879
935
|
height: `${i}px`,
|
|
880
|
-
width: `${
|
|
936
|
+
width: `${s}px`
|
|
881
937
|
};
|
|
882
938
|
};
|
|
883
|
-
return (n,
|
|
939
|
+
return (n, o) => d(e).isShown ? (m(), y("div", {
|
|
884
940
|
key: 0,
|
|
885
|
-
class:
|
|
886
|
-
style:
|
|
887
|
-
}, null, 6)) :
|
|
941
|
+
class: se(["v-craft-indicator", { "v-craft-forbidden": d(e).isForbidden }]),
|
|
942
|
+
style: Se(r())
|
|
943
|
+
}, null, 6)) : k("", !0);
|
|
888
944
|
}
|
|
889
|
-
}),
|
|
945
|
+
}), Je = /* @__PURE__ */ I({
|
|
890
946
|
__name: "CraftIframe",
|
|
891
947
|
props: {
|
|
892
948
|
iframeClass: { type: [Boolean, null, String, Object, Array], default: "" },
|
|
@@ -894,535 +950,496 @@ const wt = /* @__PURE__ */ $({
|
|
|
894
950
|
inheritStyles: { type: Boolean, default: !1 },
|
|
895
951
|
styleSheets: { default: () => [] },
|
|
896
952
|
styles: { default: () => [] },
|
|
897
|
-
iframeId: { default: "v-craft-iframe" }
|
|
898
|
-
width: { default: "auto" },
|
|
899
|
-
height: { default: "auto" }
|
|
953
|
+
iframeId: { default: "v-craft-iframe" }
|
|
900
954
|
},
|
|
901
955
|
emits: ["iframeLoad"],
|
|
902
956
|
setup(t, { emit: e }) {
|
|
903
|
-
const r = t, n =
|
|
904
|
-
|
|
905
|
-
const p = () => {
|
|
906
|
-
ue(() => {
|
|
957
|
+
const r = t, n = F(), o = F(!1), s = F(), i = () => {
|
|
958
|
+
ne(() => {
|
|
907
959
|
if (!n.value) {
|
|
908
960
|
console.error("iframe could not be loaded.");
|
|
909
961
|
return;
|
|
910
962
|
}
|
|
911
|
-
|
|
912
|
-
n.value &&
|
|
913
|
-
}), r.styleSheets.forEach((
|
|
914
|
-
n.value &&
|
|
915
|
-
}),
|
|
916
|
-
n.value && (
|
|
963
|
+
p("iframeLoad", n.value), n.value?.setAttribute("data-iframe-ready", "true"), f(), r.inheritStyles && a(), r.styles.forEach((v) => {
|
|
964
|
+
n.value && u(n.value, v);
|
|
965
|
+
}), r.styleSheets.forEach((v) => {
|
|
966
|
+
n.value && c(n.value, v);
|
|
967
|
+
}), o.value = !0, ne(() => {
|
|
968
|
+
n.value && (s.value = n.value?.contentWindow?.document.body);
|
|
917
969
|
});
|
|
918
970
|
});
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
const y = n.value.contentWindow;
|
|
927
|
-
if (!y) return;
|
|
928
|
-
if (i.value?.disconnect(), a.value?.disconnect(), c.value !== "auto" || u.value !== "auto") {
|
|
929
|
-
n.value.style.height = `${c.value}px`, n.value.style.width = `${u.value}px`;
|
|
930
|
-
return;
|
|
931
|
-
}
|
|
932
|
-
n.value.style.width = "100%", n.value.style.height = "100%", i.value = new MutationObserver(() => {
|
|
933
|
-
setTimeout(g, 100);
|
|
934
|
-
}), i.value.observe(y.document.body, {
|
|
935
|
-
childList: !0,
|
|
936
|
-
subtree: !0,
|
|
937
|
-
attributes: !0,
|
|
938
|
-
characterData: !0
|
|
971
|
+
}, a = () => {
|
|
972
|
+
const v = n.value?.contentWindow?.parent.document;
|
|
973
|
+
if (!v) return;
|
|
974
|
+
Array.from(v.querySelectorAll("style") ?? []).forEach((C) => {
|
|
975
|
+
n.value?.contentDocument?.head.appendChild(C.cloneNode(!0));
|
|
976
|
+
}), Array.from(v.querySelectorAll("link[rel='stylesheet']") ?? []).forEach((C) => {
|
|
977
|
+
n.value?.contentDocument?.head.appendChild(C.cloneNode(!0));
|
|
939
978
|
});
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
}
|
|
957
|
-
const J = y.body, he = y.documentElement, P = Math.max(
|
|
958
|
-
150,
|
|
959
|
-
J.scrollHeight,
|
|
960
|
-
J.offsetHeight,
|
|
961
|
-
he.scrollHeight,
|
|
962
|
-
he.offsetHeight
|
|
963
|
-
), S = Math.max(P, I);
|
|
964
|
-
n.value && Math.abs(S - h) > 1 && (h = S, n.value.style.height = `${S}px`), m = !1;
|
|
965
|
-
}));
|
|
966
|
-
}, D = () => {
|
|
967
|
-
const y = n.value?.contentWindow?.parent.document;
|
|
968
|
-
if (!y) return;
|
|
969
|
-
Array.from(y.querySelectorAll("style") ?? []).forEach((J) => {
|
|
970
|
-
n.value?.contentDocument?.head.appendChild(J.cloneNode(!0));
|
|
971
|
-
}), Array.from(y.querySelectorAll("link[rel='stylesheet']") ?? []).forEach((J) => {
|
|
972
|
-
n.value?.contentDocument?.head.appendChild(J.cloneNode(!0));
|
|
973
|
-
});
|
|
974
|
-
}, F = (y, k) => {
|
|
975
|
-
const I = document.createElement("style");
|
|
976
|
-
I.innerHTML = k, y?.contentWindow?.document.getElementsByTagName("head").item(0)?.appendChild(I);
|
|
977
|
-
}, A = (y, k) => {
|
|
978
|
-
const I = document.createElement("link");
|
|
979
|
-
I.rel = "stylesheet", I.href = k, y.contentWindow?.document.head.appendChild(I);
|
|
980
|
-
}, z = () => {
|
|
981
|
-
const y = n.value?.contentWindow?.document;
|
|
982
|
-
if (!y) return;
|
|
983
|
-
const k = y.querySelector("body");
|
|
984
|
-
if (!k) return;
|
|
985
|
-
const I = y.createAttribute("id");
|
|
986
|
-
I.nodeValue = "v-craft-body", k.attributes.setNamedItem(I);
|
|
987
|
-
}, R = e;
|
|
988
|
-
return Le(() => {
|
|
989
|
-
i.value?.disconnect(), a.value?.disconnect();
|
|
990
|
-
}), (y, k) => lt((v(), E("div", {
|
|
991
|
-
class: oe({ "h-full": d.value })
|
|
992
|
-
}, [
|
|
993
|
-
O("iframe", {
|
|
979
|
+
}, u = (v, h) => {
|
|
980
|
+
const g = document.createElement("style");
|
|
981
|
+
g.innerHTML = h, v?.contentWindow?.document.getElementsByTagName("head").item(0)?.appendChild(g);
|
|
982
|
+
}, c = (v, h) => {
|
|
983
|
+
const g = document.createElement("link");
|
|
984
|
+
g.rel = "stylesheet", g.href = h, v.contentWindow?.document.head.appendChild(g);
|
|
985
|
+
}, f = () => {
|
|
986
|
+
const v = n.value?.contentWindow?.document;
|
|
987
|
+
if (!v) return;
|
|
988
|
+
const h = v.querySelector("body");
|
|
989
|
+
if (!h) return;
|
|
990
|
+
const g = v.createAttribute("id");
|
|
991
|
+
g.nodeValue = "v-craft-body", h.attributes.setNamedItem(g);
|
|
992
|
+
}, p = e;
|
|
993
|
+
return (v, h) => gt((m(), y("div", null, [
|
|
994
|
+
S("iframe", {
|
|
994
995
|
id: "v-craft-iframe",
|
|
995
996
|
ref_key: "iframeRef",
|
|
996
997
|
ref: n,
|
|
997
|
-
class:
|
|
998
|
-
style:
|
|
999
|
-
onload:
|
|
998
|
+
class: se(t.iframeClass),
|
|
999
|
+
style: Se(t.iframeStyle),
|
|
1000
|
+
onload: i
|
|
1000
1001
|
}, null, 6),
|
|
1001
|
-
|
|
1002
|
+
o.value ? (m(), x(yt, {
|
|
1002
1003
|
key: 0,
|
|
1003
1004
|
to: n.value?.contentWindow?.document.body
|
|
1004
1005
|
}, [
|
|
1005
|
-
|
|
1006
|
-
], 8, ["to"])) :
|
|
1007
|
-
],
|
|
1008
|
-
[
|
|
1006
|
+
Y(v.$slots, "default")
|
|
1007
|
+
], 8, ["to"])) : k("", !0)
|
|
1008
|
+
], 512)), [
|
|
1009
|
+
[bt, v.$slots.default]
|
|
1009
1010
|
]);
|
|
1010
1011
|
}
|
|
1011
|
-
}),
|
|
1012
|
-
const n =
|
|
1012
|
+
}), gr = (t) => typeof t.type == "symbol" ? "Fragment" : typeof t.type == "string" ? t.type : t.type.name ? t.type.name : "anonmymous", _e = (t, e, r = null) => {
|
|
1013
|
+
const n = gr(e), { props: o } = e, s = {
|
|
1013
1014
|
componentName: n,
|
|
1014
|
-
props:
|
|
1015
|
+
props: o,
|
|
1015
1016
|
slots: {},
|
|
1016
1017
|
parentUuid: r?.uuid ?? null,
|
|
1017
|
-
uuid:
|
|
1018
|
+
uuid: le()
|
|
1018
1019
|
};
|
|
1019
1020
|
return e.children && (typeof e.children == "object" && !Array.isArray(e.children) ? Object.entries(e.children).forEach(([i, a]) => {
|
|
1020
1021
|
if (typeof a == "function") {
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1022
|
+
const u = a();
|
|
1023
|
+
u && (s.slots[i] = Ie(
|
|
1024
|
+
t,
|
|
1025
|
+
u,
|
|
1026
|
+
s
|
|
1027
|
+
));
|
|
1023
1028
|
}
|
|
1024
|
-
}) : Array.isArray(e.children) && (
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
+
}) : Array.isArray(e.children) && (s.slots.default = Ie(
|
|
1030
|
+
t,
|
|
1031
|
+
e.children,
|
|
1032
|
+
s
|
|
1033
|
+
))), s;
|
|
1034
|
+
}, Ie = (t, e, r) => !e || !(e instanceof Array) ? [] : e.map((n) => _e(t, n, r)).filter((n) => !!n), yr = (t) => {
|
|
1035
|
+
const e = L(), { hasNodes: r } = G(e), n = t ? F(new be(t)) : ue("resolver");
|
|
1036
|
+
n?.value && e.setResolver(n.value), t && q("resolver", n);
|
|
1037
|
+
const o = () => {
|
|
1029
1038
|
if (n?.value && !r.value) {
|
|
1030
|
-
const
|
|
1031
|
-
if (
|
|
1032
|
-
return
|
|
1033
|
-
const
|
|
1034
|
-
return
|
|
1039
|
+
const s = je(), a = (s.default ? s.default() : []).flatMap((u) => {
|
|
1040
|
+
if (u.key === "_default" && u.children && Array.isArray(u.children))
|
|
1041
|
+
return u.children.map((c) => {
|
|
1042
|
+
const f = _e(n.value, c);
|
|
1043
|
+
return f || console.error("Invalid node created from child:", c), f;
|
|
1035
1044
|
}).filter(Boolean);
|
|
1036
1045
|
{
|
|
1037
|
-
const
|
|
1038
|
-
return
|
|
1046
|
+
const c = _e(n.value, u);
|
|
1047
|
+
return c || console.error("Invalid node created from slot:", u), [c];
|
|
1039
1048
|
}
|
|
1040
1049
|
}).filter(Boolean);
|
|
1041
1050
|
a.length && e.setNodes(a);
|
|
1042
1051
|
}
|
|
1043
1052
|
};
|
|
1044
|
-
return
|
|
1053
|
+
return ye(o), te(
|
|
1045
1054
|
() => n?.value,
|
|
1046
|
-
(
|
|
1047
|
-
|
|
1055
|
+
(s) => {
|
|
1056
|
+
s && e.setResolver(s);
|
|
1048
1057
|
}
|
|
1049
1058
|
), {
|
|
1050
1059
|
editor: e,
|
|
1051
|
-
mountNodes:
|
|
1060
|
+
mountNodes: o
|
|
1052
1061
|
};
|
|
1053
|
-
},
|
|
1062
|
+
}, br = { class: "v-craft-frame" }, Er = /* @__PURE__ */ I({
|
|
1054
1063
|
name: "CraftFrame",
|
|
1055
1064
|
__name: "CraftFrame",
|
|
1056
1065
|
props: {
|
|
1057
|
-
|
|
1058
|
-
iFrameStyle: { type: [Boolean, null, String, Object, Array], default: () => ({}) },
|
|
1059
|
-
iFrameStyleSheets: { default: () => [] },
|
|
1060
|
-
iFrameStyles: { default: () => [] },
|
|
1061
|
-
iFrameWidth: { default: "auto" },
|
|
1062
|
-
iFrameClass: { type: [Boolean, null, String, Object, Array] },
|
|
1063
|
-
inheritStyles: { type: Boolean, default: !1 },
|
|
1066
|
+
iframe: {},
|
|
1064
1067
|
resolverMap: {},
|
|
1065
|
-
useIframe: { type: Boolean, default: !1 },
|
|
1066
1068
|
viewOnly: { type: Boolean, default: !1 }
|
|
1067
1069
|
},
|
|
1068
1070
|
emits: ["iframeLoad"],
|
|
1069
1071
|
setup(t, { emit: e }) {
|
|
1070
|
-
const r = t, {
|
|
1071
|
-
|
|
1072
|
-
},
|
|
1073
|
-
return (
|
|
1074
|
-
const
|
|
1075
|
-
return
|
|
1076
|
-
|
|
1072
|
+
const r = t, { iframe: n } = ie(r), o = (f) => {
|
|
1073
|
+
s("iframeLoad", f);
|
|
1074
|
+
}, s = e, { editor: i } = yr(r.resolverMap), { nodeTree: a, hasNodes: u, enabled: c } = G(i);
|
|
1075
|
+
return (f, p) => {
|
|
1076
|
+
const v = U("CraftNodeViewer"), h = U("CraftNodeEditor");
|
|
1077
|
+
return m(), y("div", br, [
|
|
1078
|
+
d(n) ? (m(), x(Je, {
|
|
1077
1079
|
key: 0,
|
|
1078
1080
|
onIframeLoad: o,
|
|
1079
|
-
inheritStyles:
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
width: f(n),
|
|
1087
|
-
height: f(s)
|
|
1081
|
+
inheritStyles: d(n)?.inheritStyles,
|
|
1082
|
+
iframeStyle: d(n)?.iframeStyle,
|
|
1083
|
+
iframeClass: d(n)?.iframeClass,
|
|
1084
|
+
class: se(d(n)?.wrapperClass),
|
|
1085
|
+
style: Se(d(n)?.wrapperStyle),
|
|
1086
|
+
styles: d(n)?.styles,
|
|
1087
|
+
styleSheets: d(n)?.styleSheets
|
|
1088
1088
|
}, {
|
|
1089
|
-
default:
|
|
1090
|
-
(t.viewOnly || !
|
|
1089
|
+
default: H(() => [
|
|
1090
|
+
(t.viewOnly || !d(c)) && d(u) ? (m(!0), y(R, { key: 0 }, $(d(a), (g) => (m(), x(v, {
|
|
1091
1091
|
key: `${g.uuid}-view`,
|
|
1092
1092
|
craftNode: g
|
|
1093
|
-
}, null, 8, ["craftNode"]))), 128)) :
|
|
1094
|
-
!t.viewOnly &&
|
|
1093
|
+
}, null, 8, ["craftNode"]))), 128)) : k("", !0),
|
|
1094
|
+
!t.viewOnly && d(c) && d(u) ? (m(!0), y(R, { key: 1 }, $(d(a), (g) => (m(), x(h, {
|
|
1095
1095
|
key: `${g.uuid}-edit`,
|
|
1096
1096
|
craftNode: g
|
|
1097
|
-
}, null, 8, ["craftNode"]))), 128)) :
|
|
1098
|
-
!t.viewOnly &&
|
|
1097
|
+
}, null, 8, ["craftNode"]))), 128)) : k("", !0),
|
|
1098
|
+
!t.viewOnly && d(c) ? (m(), x(Re, { key: 2 })) : k("", !0)
|
|
1099
1099
|
]),
|
|
1100
1100
|
_: 1
|
|
1101
|
-
}, 8, ["inheritStyles", "
|
|
1102
|
-
!
|
|
1101
|
+
}, 8, ["inheritStyles", "iframeStyle", "iframeClass", "class", "style", "styles", "styleSheets"])) : k("", !0),
|
|
1102
|
+
!d(n) && (t.viewOnly || !d(c)) && d(u) ? (m(!0), y(R, { key: 1 }, $(d(a), (g) => (m(), x(v, {
|
|
1103
1103
|
key: `${g.uuid}-view`,
|
|
1104
1104
|
craftNode: g
|
|
1105
|
-
}, null, 8, ["craftNode"]))), 128)) :
|
|
1106
|
-
!
|
|
1105
|
+
}, null, 8, ["craftNode"]))), 128)) : k("", !0),
|
|
1106
|
+
!d(n) && !t.viewOnly && d(c) && d(u) ? (m(!0), y(R, { key: 2 }, $(d(a), (g) => (m(), x(h, {
|
|
1107
1107
|
key: `${g.uuid}-edit`,
|
|
1108
1108
|
craftNode: g
|
|
1109
|
-
}, null, 8, ["craftNode"]))), 128)) :
|
|
1110
|
-
!
|
|
1109
|
+
}, null, 8, ["craftNode"]))), 128)) : k("", !0),
|
|
1110
|
+
!d(n) && !t.viewOnly && d(c) ? (m(), x(Re, { key: 3 })) : k("", !0)
|
|
1111
1111
|
]);
|
|
1112
1112
|
};
|
|
1113
1113
|
}
|
|
1114
|
-
}),
|
|
1115
|
-
const r =
|
|
1114
|
+
}), Cr = (t, e) => {
|
|
1115
|
+
const r = L(), { enabled: n, selectedUuid: o, draggingDisabled: s } = G(r);
|
|
1116
1116
|
let i = null;
|
|
1117
1117
|
const a = () => {
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1118
|
+
const p = e?.value?.$el;
|
|
1119
|
+
p && p !== i && (i = p, r.setNodeRef(t, p));
|
|
1120
1120
|
};
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
() =>
|
|
1121
|
+
ye(a), te(e, a, { flush: "post" });
|
|
1122
|
+
const u = b(
|
|
1123
|
+
() => o.value === t.uuid
|
|
1124
1124
|
);
|
|
1125
1125
|
return {
|
|
1126
|
-
isDraggable:
|
|
1127
|
-
isSelected:
|
|
1126
|
+
isDraggable: b(() => n.value && !s.value && kt(t)),
|
|
1127
|
+
isSelected: u,
|
|
1128
1128
|
selectNode: () => {
|
|
1129
1129
|
n.value && r.selectNode(t);
|
|
1130
1130
|
}
|
|
1131
1131
|
};
|
|
1132
|
-
},
|
|
1133
|
-
const
|
|
1134
|
-
!t.value?.events || !Object.values(t.value.events).length || Object.entries(t.value.events).forEach(([
|
|
1135
|
-
if (!
|
|
1132
|
+
}, Ae = (t, e, r, n) => {
|
|
1133
|
+
const o = /* @__PURE__ */ new Map(), s = () => {
|
|
1134
|
+
!t.value?.events || !Object.values(t.value.events).length || Object.entries(t.value.events).forEach(([i, a]) => {
|
|
1135
|
+
if (!a.trim())
|
|
1136
1136
|
return;
|
|
1137
|
-
const
|
|
1137
|
+
const u = (...c) => {
|
|
1138
1138
|
try {
|
|
1139
1139
|
new Function(
|
|
1140
1140
|
"ctx",
|
|
1141
1141
|
"craftNode",
|
|
1142
1142
|
"args",
|
|
1143
|
-
|
|
1143
|
+
a
|
|
1144
1144
|
)(
|
|
1145
|
-
{ ...r,
|
|
1146
|
-
|
|
1145
|
+
{ ...e, getNodes: r, getNode: n },
|
|
1146
|
+
t.value.uuid,
|
|
1147
1147
|
...c
|
|
1148
1148
|
);
|
|
1149
|
-
} catch (
|
|
1149
|
+
} catch (f) {
|
|
1150
1150
|
console.error(
|
|
1151
1151
|
`Event code execution failed with code:
|
|
1152
|
-
${
|
|
1152
|
+
${a}
|
|
1153
1153
|
|
|
1154
1154
|
Error:`,
|
|
1155
|
-
|
|
1155
|
+
f
|
|
1156
1156
|
);
|
|
1157
1157
|
}
|
|
1158
1158
|
};
|
|
1159
|
-
|
|
1159
|
+
o.set(i, u);
|
|
1160
1160
|
});
|
|
1161
1161
|
};
|
|
1162
|
-
return
|
|
1162
|
+
return te(
|
|
1163
1163
|
() => t,
|
|
1164
1164
|
() => {
|
|
1165
1165
|
s();
|
|
1166
1166
|
}
|
|
1167
|
-
),
|
|
1167
|
+
), Et(() => {
|
|
1168
1168
|
s();
|
|
1169
|
-
}),
|
|
1170
|
-
|
|
1169
|
+
}), Ct(() => {
|
|
1170
|
+
o.clear();
|
|
1171
1171
|
}), {
|
|
1172
|
-
eventHandlers:
|
|
1172
|
+
eventHandlers: b(() => Object.fromEntries(o))
|
|
1173
1173
|
};
|
|
1174
|
-
},
|
|
1174
|
+
}, et = (t) => {
|
|
1175
1175
|
const e = (() => {
|
|
1176
1176
|
try {
|
|
1177
|
-
return
|
|
1177
|
+
return L();
|
|
1178
1178
|
} catch {
|
|
1179
1179
|
return null;
|
|
1180
1180
|
}
|
|
1181
|
-
})(), r =
|
|
1182
|
-
return
|
|
1181
|
+
})(), r = b(() => e ? G(e).enabled?.value ?? !1 : !1), n = b(() => t.value?.visible !== !1);
|
|
1182
|
+
return q("craftNode", He(t)), {
|
|
1183
1183
|
editor: e,
|
|
1184
1184
|
craftNode: t,
|
|
1185
1185
|
enabled: r,
|
|
1186
1186
|
visible: n
|
|
1187
1187
|
};
|
|
1188
|
-
},
|
|
1188
|
+
}, tt = (t, e) => {
|
|
1189
|
+
if (!e.getBoundingClientRect) return !1;
|
|
1189
1190
|
const r = e.getBoundingClientRect();
|
|
1190
1191
|
return t.clientX - r.left < r.width / 2;
|
|
1191
|
-
},
|
|
1192
|
+
}, rt = (t, e) => {
|
|
1193
|
+
if (!e.getBoundingClientRect) return !1;
|
|
1192
1194
|
const r = e.getBoundingClientRect();
|
|
1193
1195
|
return t.clientY - r.top < r.height / 2;
|
|
1194
|
-
},
|
|
1196
|
+
}, nt = (t, e) => {
|
|
1197
|
+
if (!e.getBoundingClientRect) return !1;
|
|
1195
1198
|
const r = e.getBoundingClientRect();
|
|
1196
1199
|
return t.clientX - r.left < 15 || t.clientY - r.top < 15 || r.right - t.clientX < 15 || r.bottom - t.clientY < 15;
|
|
1197
|
-
},
|
|
1200
|
+
}, ot = (t, e, { editor: r, indicator: n, craftNode: o, resolver: s }) => {
|
|
1198
1201
|
if (r.draggedNode) {
|
|
1199
|
-
if (n.setIsForbidden(!
|
|
1202
|
+
if (n.setIsForbidden(!me(r.draggedNode, o.value, s)), tt(t, e)) {
|
|
1200
1203
|
n.pointBefore(e);
|
|
1201
1204
|
return;
|
|
1202
1205
|
}
|
|
1203
1206
|
n.pointAfter(e);
|
|
1204
1207
|
}
|
|
1205
|
-
},
|
|
1208
|
+
}, _r = (t, e, { editor: r, indicator: n, craftNode: o, resolver: s }) => {
|
|
1206
1209
|
if (!r.draggedNode) return;
|
|
1207
1210
|
const a = t.target.closest(".v-craft-drop-text");
|
|
1208
1211
|
if (a) {
|
|
1209
|
-
const
|
|
1210
|
-
n.setIsForbidden(
|
|
1212
|
+
const c = !oe(r.draggedNode, o.value, s);
|
|
1213
|
+
n.setIsForbidden(c), n.pointInside(a);
|
|
1211
1214
|
return;
|
|
1212
1215
|
}
|
|
1213
|
-
if (
|
|
1214
|
-
|
|
1216
|
+
if (nt(t, e)) {
|
|
1217
|
+
ot(t, e, { editor: r, indicator: n, craftNode: o, resolver: s });
|
|
1215
1218
|
return;
|
|
1216
1219
|
}
|
|
1217
|
-
const
|
|
1218
|
-
if (n.setIsForbidden(
|
|
1220
|
+
const u = !oe(r.draggedNode, o.value, s);
|
|
1221
|
+
if (n.setIsForbidden(u), rt(t, e)) {
|
|
1219
1222
|
n.pointInsideTop(e);
|
|
1220
1223
|
return;
|
|
1221
1224
|
}
|
|
1222
1225
|
n.pointInside(e);
|
|
1223
|
-
},
|
|
1224
|
-
if (
|
|
1225
|
-
|
|
1226
|
+
}, Nr = (t, e, r) => {
|
|
1227
|
+
if (K(r.craftNode.value)) {
|
|
1228
|
+
_r(t, e, r);
|
|
1226
1229
|
return;
|
|
1227
1230
|
}
|
|
1228
|
-
|
|
1229
|
-
},
|
|
1230
|
-
if (!
|
|
1231
|
+
ot(t, e, r);
|
|
1232
|
+
}, st = (t, e, r, n) => {
|
|
1233
|
+
if (!me(
|
|
1231
1234
|
r,
|
|
1232
1235
|
n.craftNode.value,
|
|
1233
1236
|
n.resolver
|
|
1234
1237
|
))
|
|
1235
1238
|
return n.craftNode.value;
|
|
1236
|
-
const
|
|
1237
|
-
if (!
|
|
1239
|
+
const o = n.craftNode.value.parentUuid ? n.editor.nodeMap.get(n.craftNode.value.parentUuid) : null;
|
|
1240
|
+
if (!o)
|
|
1238
1241
|
return n.craftNode.value;
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
if (c && q(c))
|
|
1254
|
-
return st(t, e, r, { ...n, craftNode: K(c) }), n.craftNode.value;
|
|
1255
|
-
const u = a.closest(".v-craft-drop-text");
|
|
1256
|
-
let d = "default";
|
|
1257
|
-
if (u) {
|
|
1258
|
-
const h = u.getAttribute("data-slot-name");
|
|
1259
|
-
h && (d = h);
|
|
1242
|
+
const s = Object.values(o.slots || {}).flat().find((i) => i.uuid === n.craftNode.value.uuid);
|
|
1243
|
+
return !s || s.uuid === r.uuid || (tt(t, e) ? n.editor.insertNodeBefore(r, s) : n.editor.insertNodeAfter(r, s)), n.craftNode.value;
|
|
1244
|
+
}, it = (t, e, r, n) => {
|
|
1245
|
+
const { editor: o, resolver: s, craftNode: i } = n, a = t.target, u = o.nodeMap.get(a.id);
|
|
1246
|
+
if (u && K(u))
|
|
1247
|
+
return it(t, e, r, {
|
|
1248
|
+
...n,
|
|
1249
|
+
craftNode: F(u)
|
|
1250
|
+
}), n.craftNode.value;
|
|
1251
|
+
const c = a.closest(".v-craft-drop-text");
|
|
1252
|
+
let f = "default";
|
|
1253
|
+
if (c) {
|
|
1254
|
+
const p = c.getAttribute("data-slot-name");
|
|
1255
|
+
p && (f = p);
|
|
1260
1256
|
} else {
|
|
1261
|
-
if (
|
|
1262
|
-
return
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1257
|
+
if (nt(t, e))
|
|
1258
|
+
return st(t, e, r, n);
|
|
1259
|
+
const p = n.craftNode.value.slots || {}, v = Object.keys(p);
|
|
1260
|
+
f = v.length > 0 ? v[0] : "default";
|
|
1265
1261
|
}
|
|
1266
|
-
return
|
|
1262
|
+
return oe(
|
|
1267
1263
|
r,
|
|
1268
1264
|
n.craftNode.value,
|
|
1269
1265
|
n.resolver
|
|
1270
|
-
) && (
|
|
1271
|
-
|
|
1266
|
+
) && (rt(t, e) ? n.editor.prependNodeTo(
|
|
1267
|
+
r,
|
|
1268
|
+
n.craftNode.value,
|
|
1269
|
+
f
|
|
1270
|
+
) : n.editor.appendNodeTo(r, n.craftNode.value, f)), n.craftNode.value;
|
|
1271
|
+
}, wr = (t, e, r) => {
|
|
1272
1272
|
if (!r.editor.draggedNode)
|
|
1273
1273
|
return r.craftNode.value;
|
|
1274
1274
|
const n = (() => {
|
|
1275
|
-
let
|
|
1276
|
-
return r.editor.draggedNode?.uuid ?
|
|
1275
|
+
let o;
|
|
1276
|
+
return r.editor.draggedNode?.uuid ? o = JSON.parse(JSON.stringify(r.editor.draggedNode)) : o = Qe(
|
|
1277
1277
|
JSON.parse(JSON.stringify(r.editor.draggedNode))
|
|
1278
|
-
),
|
|
1278
|
+
), We(o, r.resolver);
|
|
1279
1279
|
})();
|
|
1280
|
-
return
|
|
1281
|
-
},
|
|
1282
|
-
handleDragOver:
|
|
1283
|
-
handleDrop:
|
|
1284
|
-
},
|
|
1285
|
-
const n =
|
|
1280
|
+
return K(r.craftNode.value) ? it(t, e, n, r) : st(t, e, n, r);
|
|
1281
|
+
}, Te = {
|
|
1282
|
+
handleDragOver: Nr,
|
|
1283
|
+
handleDrop: wr
|
|
1284
|
+
}, Or = (t, e, r) => {
|
|
1285
|
+
const n = L(), o = De(), s = (c) => {
|
|
1286
1286
|
n.enabled && n.dragNode(t.value);
|
|
1287
|
-
}, i =
|
|
1288
|
-
n.enabled && e.value?.$el &&
|
|
1287
|
+
}, i = Ke((c) => {
|
|
1288
|
+
n.enabled && e.value?.$el && Te.handleDragOver(c, e.value.$el, {
|
|
1289
1289
|
editor: n,
|
|
1290
|
-
indicator:
|
|
1290
|
+
indicator: o,
|
|
1291
1291
|
craftNode: t,
|
|
1292
1292
|
resolver: r
|
|
1293
1293
|
});
|
|
1294
1294
|
}, 8);
|
|
1295
1295
|
return {
|
|
1296
|
-
handleDragStart:
|
|
1296
|
+
handleDragStart: s,
|
|
1297
1297
|
handleDragOver: i,
|
|
1298
|
-
handleDrop: (
|
|
1299
|
-
n.enabled && e.value?.$el &&
|
|
1298
|
+
handleDrop: (c) => {
|
|
1299
|
+
n.enabled && e.value?.$el && Te.handleDrop(c, e.value.$el, {
|
|
1300
1300
|
editor: n,
|
|
1301
|
-
indicator:
|
|
1301
|
+
indicator: o,
|
|
1302
1302
|
craftNode: t,
|
|
1303
1303
|
resolver: r
|
|
1304
1304
|
});
|
|
1305
1305
|
},
|
|
1306
1306
|
handleDragEnd: () => {
|
|
1307
|
-
n.enabled &&
|
|
1307
|
+
n.enabled && n.dragNode(null);
|
|
1308
1308
|
}
|
|
1309
1309
|
};
|
|
1310
|
-
},
|
|
1310
|
+
}, xr = ["data-slot-name"], Sr = { class: "v-craft-slot-name" }, kr = /* @__PURE__ */ I({
|
|
1311
1311
|
name: "CraftNodeEditor",
|
|
1312
1312
|
__name: "CraftNodeEditor",
|
|
1313
1313
|
props: {
|
|
1314
1314
|
craftNode: {}
|
|
1315
1315
|
},
|
|
1316
1316
|
setup(t) {
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
|
|
1317
|
+
const e = t, { craftNode: r } = ie(e), { editor: n, visible: o } = et(r), { resolvedNode: s, defaultProps: i, resolver: a, componentToRender: u } = fe(r);
|
|
1318
|
+
te(
|
|
1319
|
+
a,
|
|
1320
|
+
(w) => {
|
|
1321
|
+
w && q("resolver", a);
|
|
1322
|
+
},
|
|
1323
|
+
{ immediate: !0 }
|
|
1324
|
+
);
|
|
1325
|
+
const c = F(null), f = F(null), p = b(() => n?.nodeDataMap[r.value.uuid]), { isSelected: v, isDraggable: h, selectNode: g } = Cr(
|
|
1320
1326
|
r.value,
|
|
1321
1327
|
c
|
|
1322
|
-
), { handleDragStart:
|
|
1328
|
+
), { handleDragStart: C, handleDragOver: T, handleDrop: N, handleDragEnd: A } = Or(r, c, a.value), { eventHandlers: E } = Ae(
|
|
1323
1329
|
r,
|
|
1324
|
-
n,
|
|
1325
|
-
n?.
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1330
|
+
n?.eventsContext || {},
|
|
1331
|
+
() => n?.nodeMap ? Object.fromEntries(n.nodeMap.entries()) : null,
|
|
1332
|
+
(w) => n?.nodeMap[w] ?? null
|
|
1333
|
+
), P = b(() => {
|
|
1334
|
+
const w = a?.value?.resolve(r.value.componentName);
|
|
1335
|
+
return w?.label ? w.label : K(r.value) ? r.value.props.componentName : w?.componentName || r.value.componentName;
|
|
1336
|
+
}), M = b(() => Ze(r.value.uuid)), V = () => {
|
|
1337
|
+
const D = (f.value?.ownerDocument ?? c.value?.$el?.ownerDocument ?? document).querySelector(
|
|
1338
|
+
`[data-craft-uuid="${r.value.uuid}"]`
|
|
1339
|
+
);
|
|
1340
|
+
if (D) return D;
|
|
1341
|
+
let B = c.value?.$el;
|
|
1342
|
+
for (; B && !(B instanceof HTMLElement); )
|
|
1343
|
+
B = B.nextElementSibling ?? null;
|
|
1344
|
+
return B ?? null;
|
|
1345
|
+
}, he = (w, D, B) => {
|
|
1346
|
+
if (!(w instanceof Element)) {
|
|
1347
|
+
console.error("resolveNodeEl returned a non-Element:", w);
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
w.style.setProperty("--node-name", D), w.style.setProperty("--node-color", B), w.setAttribute("data-node-name", D);
|
|
1351
|
+
}, pe = () => {
|
|
1352
|
+
const w = V();
|
|
1353
|
+
w && (f.value = w, he(w, P.value ?? "(n/a)", M.value));
|
|
1354
|
+
};
|
|
1355
|
+
ye(() => ne(pe)), _t(() => ne(pe)), te([P, M], () => {
|
|
1356
|
+
f.value && he(f.value, P.value ?? "", M.value);
|
|
1357
|
+
});
|
|
1358
|
+
const at = b(() => {
|
|
1359
|
+
const D = a?.value?.resolveNode?.(r.value)?.slots;
|
|
1360
|
+
return D && D.length > 0 ? D : ["default"];
|
|
1361
|
+
}), lt = b(() => K(r.value) ? !0 : Object.values(r.value.slots || {}).some(
|
|
1362
|
+
(w) => w.length > 0
|
|
1363
|
+
)), ut = () => g(), ct = (w, D) => p.value ? p.value.slotName && p.value.slotName !== D ? [] : dt(p.value, w) : [], dt = (w, D) => w.type === "single" ? D.map((B) => ({
|
|
1364
|
+
key: `${B.uuid}-single`,
|
|
1344
1365
|
craftNode: {
|
|
1345
|
-
...
|
|
1346
|
-
props: {
|
|
1347
|
-
...U.props,
|
|
1348
|
-
...P.item || {}
|
|
1349
|
-
}
|
|
1366
|
+
...B,
|
|
1367
|
+
props: { ...B.props, ...w.item || {} }
|
|
1350
1368
|
}
|
|
1351
|
-
})) :
|
|
1352
|
-
|
|
1353
|
-
key: `${
|
|
1369
|
+
})) : w.type === "list" ? w.list ? D.reduce((B, ae) => B.concat(
|
|
1370
|
+
w.list.map((X, z) => ({
|
|
1371
|
+
key: `${ae.uuid}-data-${z}`,
|
|
1354
1372
|
craftNode: {
|
|
1355
|
-
...
|
|
1356
|
-
props: {
|
|
1357
|
-
...Q.props,
|
|
1358
|
-
...H || {}
|
|
1359
|
-
}
|
|
1373
|
+
...ae,
|
|
1374
|
+
props: { ...ae.props, ...X || {} }
|
|
1360
1375
|
}
|
|
1361
1376
|
}))
|
|
1362
1377
|
), []) : [] : [];
|
|
1363
|
-
return (
|
|
1364
|
-
const
|
|
1365
|
-
return
|
|
1378
|
+
return (w, D) => {
|
|
1379
|
+
const B = U("CraftNodeViewer"), ae = U("CraftNodeEditor", !0);
|
|
1380
|
+
return d(o) && d(r) && d(s) ? (m(), x(ce(d(u)), ge({
|
|
1366
1381
|
key: 0,
|
|
1367
1382
|
ref_key: "nodeRef",
|
|
1368
1383
|
ref: c
|
|
1369
|
-
}, {
|
|
1370
|
-
|
|
1371
|
-
|
|
1384
|
+
}, {
|
|
1385
|
+
...d(i),
|
|
1386
|
+
...d(r).props,
|
|
1387
|
+
"data-craft-uuid": d(r).uuid
|
|
1388
|
+
}, ke(d(E)), {
|
|
1372
1389
|
class: {
|
|
1373
|
-
"v-craft-node-selected":
|
|
1374
|
-
"v-craft-node":
|
|
1375
|
-
"v-craft-canvas":
|
|
1376
|
-
"v-craft-empty": !r.
|
|
1377
|
-
"v-craft-other-node-dragged":
|
|
1390
|
+
"v-craft-node-selected": d(v),
|
|
1391
|
+
"v-craft-node": d(n)?.enabled,
|
|
1392
|
+
"v-craft-canvas": d(K)(d(r)),
|
|
1393
|
+
"v-craft-empty": !d(r).slots || Object.keys(d(r).slots).length === 0 || Object.values(d(r).slots).every((X) => X.length === 0),
|
|
1394
|
+
"v-craft-other-node-dragged": d(n)?.draggedNode && !d(Ye)(d(n).draggedNode, d(r))
|
|
1378
1395
|
},
|
|
1379
|
-
draggable:
|
|
1380
|
-
onClick:
|
|
1381
|
-
onDragend:
|
|
1382
|
-
onDragover:
|
|
1383
|
-
onDragstart:
|
|
1384
|
-
onDrop:
|
|
1385
|
-
}),
|
|
1386
|
-
|
|
1387
|
-
name:
|
|
1388
|
-
fn:
|
|
1389
|
-
|
|
1396
|
+
draggable: d(n)?.enabled && d(h),
|
|
1397
|
+
onClick: j(ut, ["prevent", "stop"]),
|
|
1398
|
+
onDragend: j(d(A), ["prevent", "stop"]),
|
|
1399
|
+
onDragover: j(d(T), ["prevent", "stop"]),
|
|
1400
|
+
onDragstart: j(d(C), ["stop"]),
|
|
1401
|
+
onDrop: j(d(N), ["prevent", "stop"])
|
|
1402
|
+
}), de({ _: 2 }, [
|
|
1403
|
+
$(at.value, (X) => ({
|
|
1404
|
+
name: X,
|
|
1405
|
+
fn: H(() => [
|
|
1406
|
+
d(K)(d(r)) && (!d(r).slots || d(r).slots[X]?.length == 0) ? (m(), y("div", {
|
|
1390
1407
|
key: 0,
|
|
1391
1408
|
class: "v-craft-drop-text",
|
|
1392
|
-
"data-slot-name":
|
|
1393
|
-
onDragover:
|
|
1409
|
+
"data-slot-name": X,
|
|
1410
|
+
onDragover: D[0] || (D[0] = j(
|
|
1394
1411
|
//@ts-ignore
|
|
1395
|
-
(...
|
|
1412
|
+
(...z) => d(T) && d(T)(...z),
|
|
1396
1413
|
["prevent", "stop"]
|
|
1397
1414
|
)),
|
|
1398
|
-
onDrop:
|
|
1415
|
+
onDrop: D[1] || (D[1] = j(
|
|
1399
1416
|
//@ts-ignore
|
|
1400
|
-
(...
|
|
1417
|
+
(...z) => d(N) && d(N)(...z),
|
|
1401
1418
|
["prevent", "stop"]
|
|
1402
1419
|
))
|
|
1403
1420
|
}, [
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
], 40,
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
r.
|
|
1410
|
-
|
|
1411
|
-
), (
|
|
1412
|
-
key:
|
|
1413
|
-
craftNode:
|
|
1414
|
-
}, null, 8, ["craftNode"]))), 128)) :
|
|
1415
|
-
(
|
|
1416
|
-
key:
|
|
1417
|
-
craftNode:
|
|
1421
|
+
D[2] || (D[2] = S("span", { class: "v-craft-drop-text-label" }, "Drop a component here", -1)),
|
|
1422
|
+
S("span", Sr, ee(X), 1)
|
|
1423
|
+
], 40, xr)) : k("", !0),
|
|
1424
|
+
lt.value ? (m(), y(R, { key: 1 }, [
|
|
1425
|
+
p.value?.type && p.value.slotName === X ? (m(!0), y(R, { key: 0 }, $(ct(
|
|
1426
|
+
d(r).slots?.[X] || [],
|
|
1427
|
+
X
|
|
1428
|
+
), (z) => (m(), x(B, {
|
|
1429
|
+
key: z.key,
|
|
1430
|
+
craftNode: z.craftNode
|
|
1431
|
+
}, null, 8, ["craftNode"]))), 128)) : k("", !0),
|
|
1432
|
+
(m(!0), y(R, null, $(d(r).slots?.[X] || [], (z) => (m(), x(ae, {
|
|
1433
|
+
key: z.uuid,
|
|
1434
|
+
craftNode: z
|
|
1418
1435
|
}, null, 8, ["craftNode"]))), 128))
|
|
1419
|
-
], 64)) :
|
|
1436
|
+
], 64)) : k("", !0)
|
|
1420
1437
|
])
|
|
1421
1438
|
}))
|
|
1422
|
-
]), 1040, ["
|
|
1439
|
+
]), 1040, ["class", "draggable", "onDragend", "onDragover", "onDragstart", "onDrop"])) : k("", !0);
|
|
1423
1440
|
};
|
|
1424
1441
|
}
|
|
1425
|
-
}),
|
|
1442
|
+
}), Ne = /* @__PURE__ */ I({
|
|
1426
1443
|
name: "CraftNodeViewer",
|
|
1427
1444
|
__name: "CraftNodeViewer",
|
|
1428
1445
|
props: {
|
|
@@ -1431,105 +1448,192 @@ Error:`,
|
|
|
1431
1448
|
eventsContext: {}
|
|
1432
1449
|
},
|
|
1433
1450
|
setup(t) {
|
|
1434
|
-
const e = t, r =
|
|
1435
|
-
|
|
1436
|
-
const c =
|
|
1451
|
+
const e = t, r = ve(e, "craftNode"), { editor: n, visible: o } = et(r), { resolvedNode: s, defaultProps: i, resolver: a, componentToRender: u } = fe(r);
|
|
1452
|
+
q("resolver", a);
|
|
1453
|
+
const c = b(() => ({
|
|
1437
1454
|
...i.value,
|
|
1438
1455
|
...r.value?.props
|
|
1439
|
-
})),
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1456
|
+
})), f = b(() => e.nodeDataMap?.[r.value.uuid] || n?.nodeDataMap?.[r.value.uuid]), p = b(() => r.value.slots || {}), v = b(() => K(r.value)), h = b(() => {
|
|
1457
|
+
if (!g.value)
|
|
1458
|
+
return [];
|
|
1459
|
+
const E = [], M = a?.value?.resolveNode?.(r.value)?.slots;
|
|
1460
|
+
return M && M.length > 0 ? E.push(...M) : E.push("default"), E;
|
|
1461
|
+
}), g = b(() => v.value ? !0 : Object.values(p.value).some((E) => E.length > 0)), C = (E, P) => f.value ? f.value.slotName && f.value.slotName !== P ? [] : A(f.value, E) : [], T = F(null), { eventHandlers: N } = Ae(
|
|
1443
1462
|
r,
|
|
1444
|
-
n,
|
|
1445
|
-
|
|
1463
|
+
e.eventsContext || n?.eventsContext || {},
|
|
1464
|
+
() => n?.nodeMap ? Object.fromEntries(n.nodeMap.entries()) : null,
|
|
1465
|
+
(E) => n?.nodeMap[E] ?? null
|
|
1446
1466
|
);
|
|
1447
|
-
|
|
1448
|
-
|
|
1467
|
+
ye(() => {
|
|
1468
|
+
T.value && r.value && n && n.setNodeRef(r.value, T.value);
|
|
1449
1469
|
});
|
|
1450
|
-
const
|
|
1451
|
-
key: `${
|
|
1470
|
+
const A = (E, P) => E.type === "single" ? P.map((M) => ({
|
|
1471
|
+
key: `${M.uuid}-single`,
|
|
1452
1472
|
craftNode: {
|
|
1453
|
-
...
|
|
1473
|
+
...M,
|
|
1454
1474
|
props: {
|
|
1455
|
-
...
|
|
1456
|
-
...
|
|
1475
|
+
...M.props,
|
|
1476
|
+
...E.item || {}
|
|
1457
1477
|
}
|
|
1458
1478
|
}
|
|
1459
|
-
})) :
|
|
1479
|
+
})) : E.type === "list" ? E.list ? P.reduce((M, V) => M.concat(
|
|
1460
1480
|
//@ts-ignore
|
|
1461
|
-
|
|
1462
|
-
key: `${
|
|
1481
|
+
E.list.map((he, pe) => ({
|
|
1482
|
+
key: `${V.uuid}-data-${pe}`,
|
|
1463
1483
|
craftNode: {
|
|
1464
|
-
...
|
|
1484
|
+
...V,
|
|
1465
1485
|
props: {
|
|
1466
|
-
...
|
|
1467
|
-
...
|
|
1486
|
+
...V.props,
|
|
1487
|
+
...he || {}
|
|
1468
1488
|
}
|
|
1469
1489
|
}
|
|
1470
1490
|
}))
|
|
1471
1491
|
), []) : [] : [];
|
|
1472
|
-
return (
|
|
1492
|
+
return (E, P) => d(o) && d(a) && d(s) ? (m(), x(ce(d(u)), ge({
|
|
1473
1493
|
key: 0,
|
|
1474
1494
|
ref_key: "nodeRef",
|
|
1475
|
-
ref:
|
|
1476
|
-
}, c.value,
|
|
1477
|
-
|
|
1478
|
-
name:
|
|
1479
|
-
fn:
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
key:
|
|
1483
|
-
craftNode:
|
|
1484
|
-
}, null, 8, ["craftNode"]))), 128)) : (
|
|
1485
|
-
key:
|
|
1486
|
-
craftNode:
|
|
1495
|
+
ref: T
|
|
1496
|
+
}, c.value, ke(d(N))), de({ _: 2 }, [
|
|
1497
|
+
$(h.value, (M) => ({
|
|
1498
|
+
name: M,
|
|
1499
|
+
fn: H(() => [
|
|
1500
|
+
g.value ? (m(), y(R, { key: 0 }, [
|
|
1501
|
+
f.value?.type ? (m(!0), y(R, { key: 1 }, $(C(p.value[M], M), (V) => (m(), x(Ne, {
|
|
1502
|
+
key: V.key,
|
|
1503
|
+
craftNode: V.craftNode
|
|
1504
|
+
}, null, 8, ["craftNode"]))), 128)) : (m(!0), y(R, { key: 0 }, $(p.value[M], (V) => (m(), x(Ne, {
|
|
1505
|
+
key: V.uuid,
|
|
1506
|
+
craftNode: V
|
|
1487
1507
|
}, null, 8, ["craftNode"]))), 128))
|
|
1488
|
-
], 64)) :
|
|
1508
|
+
], 64)) : k("", !0)
|
|
1509
|
+
])
|
|
1510
|
+
}))
|
|
1511
|
+
]), 1040)) : k("", !0);
|
|
1512
|
+
}
|
|
1513
|
+
}), we = /* @__PURE__ */ I({
|
|
1514
|
+
name: "CraftNodeStatic",
|
|
1515
|
+
__name: "CraftNodeStatic",
|
|
1516
|
+
props: {
|
|
1517
|
+
craftNode: {},
|
|
1518
|
+
nodeMap: {},
|
|
1519
|
+
nodeDataMap: {},
|
|
1520
|
+
eventsContext: {}
|
|
1521
|
+
},
|
|
1522
|
+
setup(t) {
|
|
1523
|
+
const e = t, { craftNode: r, nodeMap: n } = ie(e), { resolvedNode: o, defaultProps: s, resolver: i, componentToRender: a } = fe(r);
|
|
1524
|
+
q("resolver", i), q("craftNode", He(r.value));
|
|
1525
|
+
const u = b(() => ({
|
|
1526
|
+
...s.value,
|
|
1527
|
+
...r.value?.props
|
|
1528
|
+
})), c = b(() => e.nodeDataMap?.[r.value.uuid] || null), f = b(() => r.value.slots || {}), p = b(() => K(r.value)), v = b(() => {
|
|
1529
|
+
if (!h.value)
|
|
1530
|
+
return [];
|
|
1531
|
+
const N = [], E = i?.value?.resolveNode?.(r.value)?.slots;
|
|
1532
|
+
return E && E.length > 0 ? N.push(...E) : N.push("default"), N;
|
|
1533
|
+
}), h = b(() => p.value ? !0 : Object.values(f.value).some((N) => N.length > 0)), g = (N, A) => c.value ? c.value.slotName && c.value.slotName !== A ? [] : T(c.value, N) : [], { eventHandlers: C } = Ae(
|
|
1534
|
+
r,
|
|
1535
|
+
e.eventsContext || {},
|
|
1536
|
+
() => Object.fromEntries(n.value.entries()),
|
|
1537
|
+
(N) => n.value[N] ?? null
|
|
1538
|
+
), T = (N, A) => N.type === "single" ? A.map((E) => ({
|
|
1539
|
+
key: `${E.uuid}-single`,
|
|
1540
|
+
craftNode: {
|
|
1541
|
+
...E,
|
|
1542
|
+
props: {
|
|
1543
|
+
...E.props,
|
|
1544
|
+
...N.item || {}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
})) : N.type === "list" ? N.list ? A.reduce((E, P) => E.concat(
|
|
1548
|
+
//@ts-ignore
|
|
1549
|
+
N.list.map((M, V) => ({
|
|
1550
|
+
key: `${P.uuid}-data-${V}`,
|
|
1551
|
+
craftNode: {
|
|
1552
|
+
...P,
|
|
1553
|
+
props: {
|
|
1554
|
+
...P.props,
|
|
1555
|
+
...M || {}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
}))
|
|
1559
|
+
), []) : [] : [];
|
|
1560
|
+
return (N, A) => (d(r).visible || d(r).visible === void 0) && d(i) && d(o) ? (m(), x(ce(d(a)), ge({
|
|
1561
|
+
key: 0,
|
|
1562
|
+
ref: "nodeRef"
|
|
1563
|
+
}, u.value, ke(d(C))), de({ _: 2 }, [
|
|
1564
|
+
$(v.value, (E) => ({
|
|
1565
|
+
name: E,
|
|
1566
|
+
fn: H(() => [
|
|
1567
|
+
h.value ? (m(), y(R, { key: 0 }, [
|
|
1568
|
+
c.value?.type ? (m(!0), y(R, { key: 1 }, $(g(f.value[E], E), (P) => (m(), x(we, {
|
|
1569
|
+
key: P.key,
|
|
1570
|
+
craftNode: P.craftNode,
|
|
1571
|
+
nodeMap: d(n),
|
|
1572
|
+
nodeDataMap: t.nodeDataMap,
|
|
1573
|
+
eventsContext: t.eventsContext
|
|
1574
|
+
}, null, 8, ["craftNode", "nodeMap", "nodeDataMap", "eventsContext"]))), 128)) : (m(!0), y(R, { key: 0 }, $(f.value[E], (P) => (m(), x(we, {
|
|
1575
|
+
key: P.uuid,
|
|
1576
|
+
craftNode: P,
|
|
1577
|
+
nodeMap: d(n),
|
|
1578
|
+
nodeDataMap: t.nodeDataMap,
|
|
1579
|
+
eventsContext: t.eventsContext
|
|
1580
|
+
}, null, 8, ["craftNode", "nodeMap", "nodeDataMap", "eventsContext"]))), 128))
|
|
1581
|
+
], 64)) : k("", !0)
|
|
1489
1582
|
])
|
|
1490
1583
|
}))
|
|
1491
|
-
]), 1040)) :
|
|
1584
|
+
]), 1040)) : k("", !0);
|
|
1492
1585
|
}
|
|
1493
|
-
}),
|
|
1586
|
+
}), Dr = /* @__PURE__ */ I({
|
|
1494
1587
|
name: "CraftStaticRenderer",
|
|
1495
1588
|
__name: "CraftStaticRenderer",
|
|
1496
1589
|
props: {
|
|
1497
1590
|
nodes: {},
|
|
1498
1591
|
resolverMap: {},
|
|
1592
|
+
resolver: {},
|
|
1499
1593
|
nodeDataMap: {},
|
|
1500
1594
|
eventsContext: {}
|
|
1501
1595
|
},
|
|
1502
1596
|
setup(t) {
|
|
1503
|
-
const e = t, r =
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1597
|
+
const e = t, r = (s, i) => {
|
|
1598
|
+
i.set(s.uuid, s), Object.entries(s.slots).forEach(([a, u]) => {
|
|
1599
|
+
u?.forEach && u.forEach((c) => r(c, i));
|
|
1600
|
+
});
|
|
1601
|
+
}, n = b(() => {
|
|
1602
|
+
const s = /* @__PURE__ */ new Map();
|
|
1603
|
+
return e.nodes.forEach((i) => r(i, s)), s;
|
|
1604
|
+
}), o = b(
|
|
1605
|
+
() => e.resolver || new be(e.resolverMap)
|
|
1606
|
+
);
|
|
1607
|
+
return q("resolver", o), q("nodeDataMap", e.nodeDataMap || {}), q("eventsContext", e.eventsContext || {}), (s, i) => (m(!0), y(R, null, $(t.nodes, (a) => (m(), x(we, {
|
|
1608
|
+
key: a.uuid,
|
|
1609
|
+
craftNode: a,
|
|
1610
|
+
nodeMap: n.value,
|
|
1507
1611
|
nodeDataMap: t.nodeDataMap,
|
|
1508
1612
|
eventsContext: t.eventsContext
|
|
1509
|
-
}, null, 8, ["craftNode", "nodeDataMap", "eventsContext"]))), 128));
|
|
1613
|
+
}, null, 8, ["craftNode", "nodeMap", "nodeDataMap", "eventsContext"]))), 128));
|
|
1510
1614
|
}
|
|
1511
|
-
}),
|
|
1615
|
+
}), Ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1512
1616
|
__proto__: null,
|
|
1513
|
-
CraftCanvas:
|
|
1514
|
-
CraftComponentSimpleText:
|
|
1515
|
-
CraftEditor:
|
|
1516
|
-
CraftEditorBlueprint:
|
|
1517
|
-
CraftEditorBlueprintsList:
|
|
1518
|
-
CraftEditorPanelBlueprints:
|
|
1519
|
-
CraftEditorPanelForm:
|
|
1520
|
-
CraftEditorPanelLayers:
|
|
1521
|
-
CraftEditorPanelLayout:
|
|
1522
|
-
CraftEditorPanelNodeEventsSettings:
|
|
1523
|
-
CraftEditorPanelNodeLayer:
|
|
1524
|
-
CraftEditorPanelNodeSettings:
|
|
1525
|
-
CraftEditorPanelSettings:
|
|
1526
|
-
CraftFrame:
|
|
1527
|
-
CraftIframe:
|
|
1528
|
-
CraftNodeEditor:
|
|
1529
|
-
CraftNodeViewer:
|
|
1530
|
-
CraftStaticRenderer:
|
|
1531
|
-
Utils:
|
|
1532
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1617
|
+
CraftCanvas: Ot,
|
|
1618
|
+
CraftComponentSimpleText: At,
|
|
1619
|
+
CraftEditor: Pt,
|
|
1620
|
+
CraftEditorBlueprint: Mt,
|
|
1621
|
+
CraftEditorBlueprintsList: Bt,
|
|
1622
|
+
CraftEditorPanelBlueprints: Ht,
|
|
1623
|
+
CraftEditorPanelForm: Vt,
|
|
1624
|
+
CraftEditorPanelLayers: Yt,
|
|
1625
|
+
CraftEditorPanelLayout: tr,
|
|
1626
|
+
CraftEditorPanelNodeEventsSettings: nr,
|
|
1627
|
+
CraftEditorPanelNodeLayer: lr,
|
|
1628
|
+
CraftEditorPanelNodeSettings: cr,
|
|
1629
|
+
CraftEditorPanelSettings: mr,
|
|
1630
|
+
CraftFrame: Er,
|
|
1631
|
+
CraftIframe: Je,
|
|
1632
|
+
CraftNodeEditor: kr,
|
|
1633
|
+
CraftNodeViewer: Ne,
|
|
1634
|
+
CraftStaticRenderer: Dr,
|
|
1635
|
+
Utils: $t
|
|
1636
|
+
}, Symbol.toStringTag, { value: "Module" })), Zr = {
|
|
1533
1637
|
metadata: {
|
|
1534
1638
|
name: "default"
|
|
1535
1639
|
},
|
|
@@ -1545,7 +1649,21 @@ Error:`,
|
|
|
1545
1649
|
}
|
|
1546
1650
|
}
|
|
1547
1651
|
};
|
|
1548
|
-
|
|
1652
|
+
function Jr() {
|
|
1653
|
+
const t = F(null);
|
|
1654
|
+
return { nodeEl: t, vNodeEl: {
|
|
1655
|
+
mounted(r) {
|
|
1656
|
+
t.value = r;
|
|
1657
|
+
},
|
|
1658
|
+
updated(r) {
|
|
1659
|
+
t.value = r;
|
|
1660
|
+
},
|
|
1661
|
+
unmounted() {
|
|
1662
|
+
t.value = null;
|
|
1663
|
+
}
|
|
1664
|
+
} };
|
|
1665
|
+
}
|
|
1666
|
+
class Ar {
|
|
1549
1667
|
/**
|
|
1550
1668
|
* @callback HookCallback
|
|
1551
1669
|
* @this {*|Jsep} this
|
|
@@ -1566,11 +1684,11 @@ class Cr {
|
|
|
1566
1684
|
*/
|
|
1567
1685
|
add(e, r, n) {
|
|
1568
1686
|
if (typeof arguments[0] != "string")
|
|
1569
|
-
for (let
|
|
1570
|
-
this.add(
|
|
1687
|
+
for (let o in arguments[0])
|
|
1688
|
+
this.add(o, arguments[0][o], arguments[1]);
|
|
1571
1689
|
else
|
|
1572
|
-
(Array.isArray(e) ? e : [e]).forEach(function(
|
|
1573
|
-
this[
|
|
1690
|
+
(Array.isArray(e) ? e : [e]).forEach(function(o) {
|
|
1691
|
+
this[o] = this[o] || [], r && this[o][n ? "unshift" : "push"](r);
|
|
1574
1692
|
}, this);
|
|
1575
1693
|
}
|
|
1576
1694
|
/**
|
|
@@ -1588,7 +1706,7 @@ class Cr {
|
|
|
1588
1706
|
});
|
|
1589
1707
|
}
|
|
1590
1708
|
}
|
|
1591
|
-
class
|
|
1709
|
+
class Pr {
|
|
1592
1710
|
constructor(e) {
|
|
1593
1711
|
this.jsep = e, this.registered = {};
|
|
1594
1712
|
}
|
|
@@ -1608,10 +1726,10 @@ class wr {
|
|
|
1608
1726
|
register() {
|
|
1609
1727
|
for (var e = arguments.length, r = new Array(e), n = 0; n < e; n++)
|
|
1610
1728
|
r[n] = arguments[n];
|
|
1611
|
-
r.forEach((
|
|
1612
|
-
if (typeof
|
|
1729
|
+
r.forEach((o) => {
|
|
1730
|
+
if (typeof o != "object" || !o.name || !o.init)
|
|
1613
1731
|
throw new Error("Invalid JSEP plugin format");
|
|
1614
|
-
this.registered[
|
|
1732
|
+
this.registered[o.name] || (o.init(this.jsep), this.registered[o.name] = o);
|
|
1615
1733
|
});
|
|
1616
1734
|
}
|
|
1617
1735
|
}
|
|
@@ -1853,12 +1971,12 @@ class l {
|
|
|
1853
1971
|
* @returns {jsep.Expression[]}
|
|
1854
1972
|
*/
|
|
1855
1973
|
gobbleExpressions(e) {
|
|
1856
|
-
let r = [], n,
|
|
1974
|
+
let r = [], n, o;
|
|
1857
1975
|
for (; this.index < this.expr.length; )
|
|
1858
1976
|
if (n = this.code, n === l.SEMCOL_CODE || n === l.COMMA_CODE)
|
|
1859
1977
|
this.index++;
|
|
1860
|
-
else if (
|
|
1861
|
-
r.push(
|
|
1978
|
+
else if (o = this.gobbleExpression())
|
|
1979
|
+
r.push(o);
|
|
1862
1980
|
else if (this.index < this.expr.length) {
|
|
1863
1981
|
if (n === e)
|
|
1864
1982
|
break;
|
|
@@ -1897,40 +2015,40 @@ class l {
|
|
|
1897
2015
|
* @returns {?jsep.BinaryExpression}
|
|
1898
2016
|
*/
|
|
1899
2017
|
gobbleBinaryExpression() {
|
|
1900
|
-
let e, r, n,
|
|
2018
|
+
let e, r, n, o, s, i, a, u, c;
|
|
1901
2019
|
if (i = this.gobbleToken(), !i || (r = this.gobbleBinaryOp(), !r))
|
|
1902
2020
|
return i;
|
|
1903
|
-
for (
|
|
2021
|
+
for (s = {
|
|
1904
2022
|
value: r,
|
|
1905
2023
|
prec: l.binaryPrecedence(r),
|
|
1906
2024
|
right_a: l.right_associative.has(r)
|
|
1907
|
-
}, a = this.gobbleToken(), a || this.throwError("Expected expression after " + r),
|
|
2025
|
+
}, a = this.gobbleToken(), a || this.throwError("Expected expression after " + r), o = [i, s, a]; r = this.gobbleBinaryOp(); ) {
|
|
1908
2026
|
if (n = l.binaryPrecedence(r), n === 0) {
|
|
1909
2027
|
this.index -= r.length;
|
|
1910
2028
|
break;
|
|
1911
2029
|
}
|
|
1912
|
-
|
|
2030
|
+
s = {
|
|
1913
2031
|
value: r,
|
|
1914
2032
|
prec: n,
|
|
1915
2033
|
right_a: l.right_associative.has(r)
|
|
1916
|
-
},
|
|
1917
|
-
const
|
|
1918
|
-
for (;
|
|
1919
|
-
a =
|
|
2034
|
+
}, c = r;
|
|
2035
|
+
const f = (p) => s.right_a && p.right_a ? n > p.prec : n <= p.prec;
|
|
2036
|
+
for (; o.length > 2 && f(o[o.length - 2]); )
|
|
2037
|
+
a = o.pop(), r = o.pop().value, i = o.pop(), e = {
|
|
1920
2038
|
type: l.BINARY_EXP,
|
|
1921
2039
|
operator: r,
|
|
1922
2040
|
left: i,
|
|
1923
2041
|
right: a
|
|
1924
|
-
},
|
|
1925
|
-
e = this.gobbleToken(), e || this.throwError("Expected expression after " +
|
|
2042
|
+
}, o.push(e);
|
|
2043
|
+
e = this.gobbleToken(), e || this.throwError("Expected expression after " + c), o.push(s, e);
|
|
1926
2044
|
}
|
|
1927
|
-
for (
|
|
2045
|
+
for (u = o.length - 1, e = o[u]; u > 1; )
|
|
1928
2046
|
e = {
|
|
1929
2047
|
type: l.BINARY_EXP,
|
|
1930
|
-
operator:
|
|
1931
|
-
left:
|
|
2048
|
+
operator: o[u - 1].value,
|
|
2049
|
+
left: o[u - 2],
|
|
1932
2050
|
right: e
|
|
1933
|
-
},
|
|
2051
|
+
}, u -= 2;
|
|
1934
2052
|
return e;
|
|
1935
2053
|
}
|
|
1936
2054
|
/**
|
|
@@ -1939,38 +2057,38 @@ class l {
|
|
|
1939
2057
|
* @returns {boolean|jsep.Expression}
|
|
1940
2058
|
*/
|
|
1941
2059
|
gobbleToken() {
|
|
1942
|
-
let e, r, n,
|
|
1943
|
-
if (this.gobbleSpaces(),
|
|
1944
|
-
return this.runHook("after-token",
|
|
2060
|
+
let e, r, n, o;
|
|
2061
|
+
if (this.gobbleSpaces(), o = this.searchHook("gobble-token"), o)
|
|
2062
|
+
return this.runHook("after-token", o);
|
|
1945
2063
|
if (e = this.code, l.isDecimalDigit(e) || e === l.PERIOD_CODE)
|
|
1946
2064
|
return this.gobbleNumericLiteral();
|
|
1947
2065
|
if (e === l.SQUOTE_CODE || e === l.DQUOTE_CODE)
|
|
1948
|
-
|
|
2066
|
+
o = this.gobbleStringLiteral();
|
|
1949
2067
|
else if (e === l.OBRACK_CODE)
|
|
1950
|
-
|
|
2068
|
+
o = this.gobbleArray();
|
|
1951
2069
|
else {
|
|
1952
2070
|
for (r = this.expr.substr(this.index, l.max_unop_len), n = r.length; n > 0; ) {
|
|
1953
2071
|
if (l.unary_ops.hasOwnProperty(r) && (!l.isIdentifierStart(this.code) || this.index + r.length < this.expr.length && !l.isIdentifierPart(this.expr.charCodeAt(this.index + r.length)))) {
|
|
1954
2072
|
this.index += n;
|
|
1955
|
-
const
|
|
1956
|
-
return
|
|
2073
|
+
const s = this.gobbleToken();
|
|
2074
|
+
return s || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
|
|
1957
2075
|
type: l.UNARY_EXP,
|
|
1958
2076
|
operator: r,
|
|
1959
|
-
argument:
|
|
2077
|
+
argument: s,
|
|
1960
2078
|
prefix: !0
|
|
1961
2079
|
});
|
|
1962
2080
|
}
|
|
1963
2081
|
r = r.substr(0, --n);
|
|
1964
2082
|
}
|
|
1965
|
-
l.isIdentifierStart(e) ? (
|
|
2083
|
+
l.isIdentifierStart(e) ? (o = this.gobbleIdentifier(), l.literals.hasOwnProperty(o.name) ? o = {
|
|
1966
2084
|
type: l.LITERAL,
|
|
1967
|
-
value: l.literals[
|
|
1968
|
-
raw:
|
|
1969
|
-
} :
|
|
2085
|
+
value: l.literals[o.name],
|
|
2086
|
+
raw: o.name
|
|
2087
|
+
} : o.name === l.this_str && (o = {
|
|
1970
2088
|
type: l.THIS_EXP
|
|
1971
|
-
})) : e === l.OPAREN_CODE && (
|
|
2089
|
+
})) : e === l.OPAREN_CODE && (o = this.gobbleGroup());
|
|
1972
2090
|
}
|
|
1973
|
-
return
|
|
2091
|
+
return o ? (o = this.gobbleTokenProperty(o), this.runHook("after-token", o)) : this.runHook("after-token", !1);
|
|
1974
2092
|
}
|
|
1975
2093
|
/**
|
|
1976
2094
|
* Gobble properties of of identifiers/strings/arrays/groups.
|
|
@@ -2039,14 +2157,14 @@ class l {
|
|
|
2039
2157
|
gobbleStringLiteral() {
|
|
2040
2158
|
let e = "";
|
|
2041
2159
|
const r = this.index, n = this.expr.charAt(this.index++);
|
|
2042
|
-
let
|
|
2160
|
+
let o = !1;
|
|
2043
2161
|
for (; this.index < this.expr.length; ) {
|
|
2044
|
-
let
|
|
2045
|
-
if (
|
|
2046
|
-
|
|
2162
|
+
let s = this.expr.charAt(this.index++);
|
|
2163
|
+
if (s === n) {
|
|
2164
|
+
o = !0;
|
|
2047
2165
|
break;
|
|
2048
|
-
} else if (
|
|
2049
|
-
switch (
|
|
2166
|
+
} else if (s === "\\")
|
|
2167
|
+
switch (s = this.expr.charAt(this.index++), s) {
|
|
2050
2168
|
case "n":
|
|
2051
2169
|
e += `
|
|
2052
2170
|
`;
|
|
@@ -2067,12 +2185,12 @@ class l {
|
|
|
2067
2185
|
e += "\v";
|
|
2068
2186
|
break;
|
|
2069
2187
|
default:
|
|
2070
|
-
e +=
|
|
2188
|
+
e += s;
|
|
2071
2189
|
}
|
|
2072
2190
|
else
|
|
2073
|
-
e +=
|
|
2191
|
+
e += s;
|
|
2074
2192
|
}
|
|
2075
|
-
return
|
|
2193
|
+
return o || this.throwError('Unclosed quote after "' + e + '"'), {
|
|
2076
2194
|
type: l.LITERAL,
|
|
2077
2195
|
value: e,
|
|
2078
2196
|
raw: this.expr.substring(r, this.index)
|
|
@@ -2105,22 +2223,22 @@ class l {
|
|
|
2105
2223
|
*/
|
|
2106
2224
|
gobbleArguments(e) {
|
|
2107
2225
|
const r = [];
|
|
2108
|
-
let n = !1,
|
|
2226
|
+
let n = !1, o = 0;
|
|
2109
2227
|
for (; this.index < this.expr.length; ) {
|
|
2110
2228
|
this.gobbleSpaces();
|
|
2111
|
-
let
|
|
2112
|
-
if (
|
|
2113
|
-
n = !0, this.index++, e === l.CPAREN_CODE &&
|
|
2229
|
+
let s = this.code;
|
|
2230
|
+
if (s === e) {
|
|
2231
|
+
n = !0, this.index++, e === l.CPAREN_CODE && o && o >= r.length && this.throwError("Unexpected token " + String.fromCharCode(e));
|
|
2114
2232
|
break;
|
|
2115
|
-
} else if (
|
|
2116
|
-
if (this.index++,
|
|
2233
|
+
} else if (s === l.COMMA_CODE) {
|
|
2234
|
+
if (this.index++, o++, o !== r.length) {
|
|
2117
2235
|
if (e === l.CPAREN_CODE)
|
|
2118
2236
|
this.throwError("Unexpected token ,");
|
|
2119
2237
|
else if (e === l.CBRACK_CODE)
|
|
2120
|
-
for (let i = r.length; i <
|
|
2238
|
+
for (let i = r.length; i < o; i++)
|
|
2121
2239
|
r.push(null);
|
|
2122
2240
|
}
|
|
2123
|
-
} else if (r.length !==
|
|
2241
|
+
} else if (r.length !== o && o !== 0)
|
|
2124
2242
|
this.throwError("Expected comma");
|
|
2125
2243
|
else {
|
|
2126
2244
|
const i = this.gobbleExpression();
|
|
@@ -2161,10 +2279,10 @@ class l {
|
|
|
2161
2279
|
};
|
|
2162
2280
|
}
|
|
2163
2281
|
}
|
|
2164
|
-
const
|
|
2282
|
+
const Mr = new Ar();
|
|
2165
2283
|
Object.assign(l, {
|
|
2166
|
-
hooks:
|
|
2167
|
-
plugins: new
|
|
2284
|
+
hooks: Mr,
|
|
2285
|
+
plugins: new Pr(l),
|
|
2168
2286
|
// Node Types
|
|
2169
2287
|
// ----------
|
|
2170
2288
|
// This is the full set of types that any JSEP node can be.
|
|
@@ -2260,28 +2378,28 @@ Object.assign(l, {
|
|
|
2260
2378
|
});
|
|
2261
2379
|
l.max_unop_len = l.getMaxKeyLen(l.unary_ops);
|
|
2262
2380
|
l.max_binop_len = l.getMaxKeyLen(l.binary_ops);
|
|
2263
|
-
const
|
|
2381
|
+
const Q = (t) => new l(t).parse(), $r = Object.getOwnPropertyNames(class {
|
|
2264
2382
|
});
|
|
2265
|
-
Object.getOwnPropertyNames(l).filter((t) =>
|
|
2266
|
-
|
|
2383
|
+
Object.getOwnPropertyNames(l).filter((t) => !$r.includes(t) && Q[t] === void 0).forEach((t) => {
|
|
2384
|
+
Q[t] = l[t];
|
|
2267
2385
|
});
|
|
2268
|
-
|
|
2269
|
-
const
|
|
2270
|
-
var
|
|
2386
|
+
Q.Jsep = l;
|
|
2387
|
+
const Rr = "ConditionalExpression";
|
|
2388
|
+
var Ir = {
|
|
2271
2389
|
name: "ternary",
|
|
2272
2390
|
init(t) {
|
|
2273
2391
|
t.hooks.add("after-expression", function(r) {
|
|
2274
2392
|
if (r.node && this.code === t.QUMARK_CODE) {
|
|
2275
2393
|
this.index++;
|
|
2276
|
-
const n = r.node,
|
|
2277
|
-
if (
|
|
2394
|
+
const n = r.node, o = this.gobbleExpression();
|
|
2395
|
+
if (o || this.throwError("Expected expression"), this.gobbleSpaces(), this.code === t.COLON_CODE) {
|
|
2278
2396
|
this.index++;
|
|
2279
|
-
const
|
|
2280
|
-
if (
|
|
2281
|
-
type:
|
|
2397
|
+
const s = this.gobbleExpression();
|
|
2398
|
+
if (s || this.throwError("Expected expression"), r.node = {
|
|
2399
|
+
type: Rr,
|
|
2282
2400
|
test: n,
|
|
2283
|
-
consequent:
|
|
2284
|
-
alternate:
|
|
2401
|
+
consequent: o,
|
|
2402
|
+
alternate: s
|
|
2285
2403
|
}, n.operator && t.binary_ops[n.operator] <= 0.9) {
|
|
2286
2404
|
let i = n;
|
|
2287
2405
|
for (; i.right.operator && t.binary_ops[i.right.operator] <= 0.9; )
|
|
@@ -2294,31 +2412,31 @@ var xr = {
|
|
|
2294
2412
|
});
|
|
2295
2413
|
}
|
|
2296
2414
|
};
|
|
2297
|
-
|
|
2298
|
-
const
|
|
2299
|
-
var
|
|
2415
|
+
Q.plugins.register(Ir);
|
|
2416
|
+
const Be = 47, Tr = 92;
|
|
2417
|
+
var Ur = {
|
|
2300
2418
|
name: "regex",
|
|
2301
2419
|
init(t) {
|
|
2302
2420
|
t.hooks.add("gobble-token", function(r) {
|
|
2303
|
-
if (this.code ===
|
|
2421
|
+
if (this.code === Be) {
|
|
2304
2422
|
const n = ++this.index;
|
|
2305
|
-
let
|
|
2423
|
+
let o = !1;
|
|
2306
2424
|
for (; this.index < this.expr.length; ) {
|
|
2307
|
-
if (this.code ===
|
|
2308
|
-
const
|
|
2425
|
+
if (this.code === Be && !o) {
|
|
2426
|
+
const s = this.expr.slice(n, this.index);
|
|
2309
2427
|
let i = "";
|
|
2310
2428
|
for (; ++this.index < this.expr.length; ) {
|
|
2311
|
-
const
|
|
2312
|
-
if (
|
|
2429
|
+
const u = this.code;
|
|
2430
|
+
if (u >= 97 && u <= 122 || u >= 65 && u <= 90 || u >= 48 && u <= 57)
|
|
2313
2431
|
i += this.char;
|
|
2314
2432
|
else
|
|
2315
2433
|
break;
|
|
2316
2434
|
}
|
|
2317
2435
|
let a;
|
|
2318
2436
|
try {
|
|
2319
|
-
a = new RegExp(
|
|
2320
|
-
} catch (
|
|
2321
|
-
this.throwError(
|
|
2437
|
+
a = new RegExp(s, i);
|
|
2438
|
+
} catch (u) {
|
|
2439
|
+
this.throwError(u.message);
|
|
2322
2440
|
}
|
|
2323
2441
|
return r.node = {
|
|
2324
2442
|
type: t.LITERAL,
|
|
@@ -2326,54 +2444,54 @@ var Ar = {
|
|
|
2326
2444
|
raw: this.expr.slice(n - 1, this.index)
|
|
2327
2445
|
}, r.node = this.gobbleTokenProperty(r.node), r.node;
|
|
2328
2446
|
}
|
|
2329
|
-
this.code === t.OBRACK_CODE ?
|
|
2447
|
+
this.code === t.OBRACK_CODE ? o = !0 : o && this.code === t.CBRACK_CODE && (o = !1), this.index += this.code === Tr ? 2 : 1;
|
|
2330
2448
|
}
|
|
2331
2449
|
this.throwError("Unclosed Regex");
|
|
2332
2450
|
}
|
|
2333
2451
|
});
|
|
2334
2452
|
}
|
|
2335
2453
|
};
|
|
2336
|
-
const
|
|
2454
|
+
const Ce = 43, Br = 45, re = {
|
|
2337
2455
|
name: "assignment",
|
|
2338
2456
|
assignmentOperators: /* @__PURE__ */ new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
2339
|
-
updateOperators: [
|
|
2457
|
+
updateOperators: [Ce, Br],
|
|
2340
2458
|
assignmentPrecedence: 0.9,
|
|
2341
2459
|
init(t) {
|
|
2342
2460
|
const e = [t.IDENTIFIER, t.MEMBER_EXP];
|
|
2343
|
-
|
|
2344
|
-
const
|
|
2345
|
-
|
|
2461
|
+
re.assignmentOperators.forEach((n) => t.addBinaryOp(n, re.assignmentPrecedence, !0)), t.hooks.add("gobble-token", function(o) {
|
|
2462
|
+
const s = this.code;
|
|
2463
|
+
re.updateOperators.some((i) => i === s && i === this.expr.charCodeAt(this.index + 1)) && (this.index += 2, o.node = {
|
|
2346
2464
|
type: "UpdateExpression",
|
|
2347
|
-
operator:
|
|
2465
|
+
operator: s === Ce ? "++" : "--",
|
|
2348
2466
|
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
2349
2467
|
prefix: !0
|
|
2350
|
-
}, (!
|
|
2351
|
-
}), t.hooks.add("after-token", function(
|
|
2352
|
-
if (
|
|
2353
|
-
const
|
|
2354
|
-
|
|
2468
|
+
}, (!o.node.argument || !e.includes(o.node.argument.type)) && this.throwError(`Unexpected ${o.node.operator}`));
|
|
2469
|
+
}), t.hooks.add("after-token", function(o) {
|
|
2470
|
+
if (o.node) {
|
|
2471
|
+
const s = this.code;
|
|
2472
|
+
re.updateOperators.some((i) => i === s && i === this.expr.charCodeAt(this.index + 1)) && (e.includes(o.node.type) || this.throwError(`Unexpected ${o.node.operator}`), this.index += 2, o.node = {
|
|
2355
2473
|
type: "UpdateExpression",
|
|
2356
|
-
operator:
|
|
2357
|
-
argument:
|
|
2474
|
+
operator: s === Ce ? "++" : "--",
|
|
2475
|
+
argument: o.node,
|
|
2358
2476
|
prefix: !1
|
|
2359
2477
|
});
|
|
2360
2478
|
}
|
|
2361
|
-
}), t.hooks.add("after-expression", function(
|
|
2362
|
-
|
|
2479
|
+
}), t.hooks.add("after-expression", function(o) {
|
|
2480
|
+
o.node && r(o.node);
|
|
2363
2481
|
});
|
|
2364
2482
|
function r(n) {
|
|
2365
|
-
|
|
2366
|
-
|
|
2483
|
+
re.assignmentOperators.has(n.operator) ? (n.type = "AssignmentExpression", r(n.left), r(n.right)) : n.operator || Object.values(n).forEach((o) => {
|
|
2484
|
+
o && typeof o == "object" && r(o);
|
|
2367
2485
|
});
|
|
2368
2486
|
}
|
|
2369
2487
|
}
|
|
2370
2488
|
};
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
const
|
|
2489
|
+
Q.plugins.register(Ur, re);
|
|
2490
|
+
Q.addUnaryOp("typeof");
|
|
2491
|
+
Q.addUnaryOp("void");
|
|
2492
|
+
Q.addLiteral("null", null);
|
|
2493
|
+
Q.addLiteral("undefined", void 0);
|
|
2494
|
+
const Lr = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]), O = {
|
|
2377
2495
|
/**
|
|
2378
2496
|
* @param {jsep.Expression} ast
|
|
2379
2497
|
* @param {Record<string, any>} subs
|
|
@@ -2382,67 +2500,67 @@ const Dr = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
2382
2500
|
switch (t.type) {
|
|
2383
2501
|
case "BinaryExpression":
|
|
2384
2502
|
case "LogicalExpression":
|
|
2385
|
-
return
|
|
2503
|
+
return O.evalBinaryExpression(t, e);
|
|
2386
2504
|
case "Compound":
|
|
2387
|
-
return
|
|
2505
|
+
return O.evalCompound(t, e);
|
|
2388
2506
|
case "ConditionalExpression":
|
|
2389
|
-
return
|
|
2507
|
+
return O.evalConditionalExpression(t, e);
|
|
2390
2508
|
case "Identifier":
|
|
2391
|
-
return
|
|
2509
|
+
return O.evalIdentifier(t, e);
|
|
2392
2510
|
case "Literal":
|
|
2393
|
-
return
|
|
2511
|
+
return O.evalLiteral(t, e);
|
|
2394
2512
|
case "MemberExpression":
|
|
2395
|
-
return
|
|
2513
|
+
return O.evalMemberExpression(t, e);
|
|
2396
2514
|
case "UnaryExpression":
|
|
2397
|
-
return
|
|
2515
|
+
return O.evalUnaryExpression(t, e);
|
|
2398
2516
|
case "ArrayExpression":
|
|
2399
|
-
return
|
|
2517
|
+
return O.evalArrayExpression(t, e);
|
|
2400
2518
|
case "CallExpression":
|
|
2401
|
-
return
|
|
2519
|
+
return O.evalCallExpression(t, e);
|
|
2402
2520
|
case "AssignmentExpression":
|
|
2403
|
-
return
|
|
2521
|
+
return O.evalAssignmentExpression(t, e);
|
|
2404
2522
|
default:
|
|
2405
2523
|
throw SyntaxError("Unexpected expression", t);
|
|
2406
2524
|
}
|
|
2407
2525
|
},
|
|
2408
2526
|
evalBinaryExpression(t, e) {
|
|
2409
2527
|
return {
|
|
2410
|
-
"||": (n,
|
|
2411
|
-
"&&": (n,
|
|
2412
|
-
"|": (n,
|
|
2413
|
-
"^": (n,
|
|
2414
|
-
"&": (n,
|
|
2528
|
+
"||": (n, o) => n || o(),
|
|
2529
|
+
"&&": (n, o) => n && o(),
|
|
2530
|
+
"|": (n, o) => n | o(),
|
|
2531
|
+
"^": (n, o) => n ^ o(),
|
|
2532
|
+
"&": (n, o) => n & o(),
|
|
2415
2533
|
// eslint-disable-next-line eqeqeq -- API
|
|
2416
|
-
"==": (n,
|
|
2534
|
+
"==": (n, o) => n == o(),
|
|
2417
2535
|
// eslint-disable-next-line eqeqeq -- API
|
|
2418
|
-
"!=": (n,
|
|
2419
|
-
"===": (n,
|
|
2420
|
-
"!==": (n,
|
|
2421
|
-
"<": (n,
|
|
2422
|
-
">": (n,
|
|
2423
|
-
"<=": (n,
|
|
2424
|
-
">=": (n,
|
|
2425
|
-
"<<": (n,
|
|
2426
|
-
">>": (n,
|
|
2427
|
-
">>>": (n,
|
|
2428
|
-
"+": (n,
|
|
2429
|
-
"-": (n,
|
|
2430
|
-
"*": (n,
|
|
2431
|
-
"/": (n,
|
|
2432
|
-
"%": (n,
|
|
2433
|
-
}[t.operator](
|
|
2536
|
+
"!=": (n, o) => n != o(),
|
|
2537
|
+
"===": (n, o) => n === o(),
|
|
2538
|
+
"!==": (n, o) => n !== o(),
|
|
2539
|
+
"<": (n, o) => n < o(),
|
|
2540
|
+
">": (n, o) => n > o(),
|
|
2541
|
+
"<=": (n, o) => n <= o(),
|
|
2542
|
+
">=": (n, o) => n >= o(),
|
|
2543
|
+
"<<": (n, o) => n << o(),
|
|
2544
|
+
">>": (n, o) => n >> o(),
|
|
2545
|
+
">>>": (n, o) => n >>> o(),
|
|
2546
|
+
"+": (n, o) => n + o(),
|
|
2547
|
+
"-": (n, o) => n - o(),
|
|
2548
|
+
"*": (n, o) => n * o(),
|
|
2549
|
+
"/": (n, o) => n / o(),
|
|
2550
|
+
"%": (n, o) => n % o()
|
|
2551
|
+
}[t.operator](O.evalAst(t.left, e), () => O.evalAst(t.right, e));
|
|
2434
2552
|
},
|
|
2435
2553
|
evalCompound(t, e) {
|
|
2436
2554
|
let r;
|
|
2437
2555
|
for (let n = 0; n < t.body.length; n++) {
|
|
2438
2556
|
t.body[n].type === "Identifier" && ["var", "let", "const"].includes(t.body[n].name) && t.body[n + 1] && t.body[n + 1].type === "AssignmentExpression" && (n += 1);
|
|
2439
|
-
const
|
|
2440
|
-
r =
|
|
2557
|
+
const o = t.body[n];
|
|
2558
|
+
r = O.evalAst(o, e);
|
|
2441
2559
|
}
|
|
2442
2560
|
return r;
|
|
2443
2561
|
},
|
|
2444
2562
|
evalConditionalExpression(t, e) {
|
|
2445
|
-
return
|
|
2563
|
+
return O.evalAst(t.test, e) ? O.evalAst(t.consequent, e) : O.evalAst(t.alternate, e);
|
|
2446
2564
|
},
|
|
2447
2565
|
evalIdentifier(t, e) {
|
|
2448
2566
|
if (Object.hasOwn(e, t.name))
|
|
@@ -2457,33 +2575,33 @@ const Dr = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
2457
2575
|
// NOTE: `String(value)` throws error when
|
|
2458
2576
|
// value has overwritten the toString method to return non-string
|
|
2459
2577
|
// i.e. `value = {toString: () => []}`
|
|
2460
|
-
t.computed ?
|
|
2578
|
+
t.computed ? O.evalAst(t.property) : t.property.name
|
|
2461
2579
|
// `object.property` property is Identifier
|
|
2462
|
-
), n =
|
|
2580
|
+
), n = O.evalAst(t.object, e);
|
|
2463
2581
|
if (n == null)
|
|
2464
2582
|
throw TypeError(`Cannot read properties of ${n} (reading '${r}')`);
|
|
2465
|
-
if (!Object.hasOwn(n, r) &&
|
|
2583
|
+
if (!Object.hasOwn(n, r) && Lr.has(r))
|
|
2466
2584
|
throw TypeError(`Cannot read properties of ${n} (reading '${r}')`);
|
|
2467
|
-
const
|
|
2468
|
-
return typeof
|
|
2585
|
+
const o = n[r];
|
|
2586
|
+
return typeof o == "function" ? o.bind(n) : o;
|
|
2469
2587
|
},
|
|
2470
2588
|
evalUnaryExpression(t, e) {
|
|
2471
2589
|
return {
|
|
2472
|
-
"-": (n) => -
|
|
2473
|
-
"!": (n) => !
|
|
2474
|
-
"~": (n) => ~
|
|
2590
|
+
"-": (n) => -O.evalAst(n, e),
|
|
2591
|
+
"!": (n) => !O.evalAst(n, e),
|
|
2592
|
+
"~": (n) => ~O.evalAst(n, e),
|
|
2475
2593
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
2476
|
-
"+": (n) => +
|
|
2477
|
-
typeof: (n) => typeof
|
|
2594
|
+
"+": (n) => +O.evalAst(n, e),
|
|
2595
|
+
typeof: (n) => typeof O.evalAst(n, e),
|
|
2478
2596
|
// eslint-disable-next-line no-void, sonarjs/void-use -- feature
|
|
2479
|
-
void: (n) => void
|
|
2597
|
+
void: (n) => void O.evalAst(n, e)
|
|
2480
2598
|
}[t.operator](t.argument);
|
|
2481
2599
|
},
|
|
2482
2600
|
evalArrayExpression(t, e) {
|
|
2483
|
-
return t.elements.map((r) =>
|
|
2601
|
+
return t.elements.map((r) => O.evalAst(r, e));
|
|
2484
2602
|
},
|
|
2485
2603
|
evalCallExpression(t, e) {
|
|
2486
|
-
const r = t.arguments.map((
|
|
2604
|
+
const r = t.arguments.map((o) => O.evalAst(o, e)), n = O.evalAst(t.callee, e);
|
|
2487
2605
|
if (n === Function)
|
|
2488
2606
|
throw new Error("Function constructor is disabled");
|
|
2489
2607
|
return n(...r);
|
|
@@ -2491,16 +2609,16 @@ const Dr = /* @__PURE__ */ new Set(["constructor", "__proto__", "__defineGetter_
|
|
|
2491
2609
|
evalAssignmentExpression(t, e) {
|
|
2492
2610
|
if (t.left.type !== "Identifier")
|
|
2493
2611
|
throw SyntaxError("Invalid left-hand side in assignment");
|
|
2494
|
-
const r = t.left.name, n =
|
|
2612
|
+
const r = t.left.name, n = O.evalAst(t.right, e);
|
|
2495
2613
|
return e[r] = n, e[r];
|
|
2496
2614
|
}
|
|
2497
2615
|
};
|
|
2498
|
-
class
|
|
2616
|
+
class jr {
|
|
2499
2617
|
/**
|
|
2500
2618
|
* @param {string} expr Expression to evaluate
|
|
2501
2619
|
*/
|
|
2502
2620
|
constructor(e) {
|
|
2503
|
-
this.code = e, this.ast =
|
|
2621
|
+
this.code = e, this.ast = Q(this.code);
|
|
2504
2622
|
}
|
|
2505
2623
|
/**
|
|
2506
2624
|
* @param {object} context Object whose items will be added
|
|
@@ -2509,16 +2627,16 @@ class kr {
|
|
|
2509
2627
|
*/
|
|
2510
2628
|
runInNewContext(e) {
|
|
2511
2629
|
const r = Object.assign(/* @__PURE__ */ Object.create(null), e);
|
|
2512
|
-
return
|
|
2630
|
+
return O.evalAst(this.ast, r);
|
|
2513
2631
|
}
|
|
2514
2632
|
}
|
|
2515
|
-
function
|
|
2633
|
+
function Z(t, e) {
|
|
2516
2634
|
return t = t.slice(), t.push(e), t;
|
|
2517
2635
|
}
|
|
2518
|
-
function
|
|
2636
|
+
function Oe(t, e) {
|
|
2519
2637
|
return e = e.slice(), e.unshift(t), e;
|
|
2520
2638
|
}
|
|
2521
|
-
class
|
|
2639
|
+
class Fr extends Error {
|
|
2522
2640
|
/**
|
|
2523
2641
|
* @param {AnyResult} value The evaluated scalar value
|
|
2524
2642
|
*/
|
|
@@ -2526,32 +2644,32 @@ class $r extends Error {
|
|
|
2526
2644
|
super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'), this.avoidNew = !0, this.value = e, this.name = "NewError";
|
|
2527
2645
|
}
|
|
2528
2646
|
}
|
|
2529
|
-
function
|
|
2530
|
-
if (!(this instanceof
|
|
2647
|
+
function _(t, e, r, n, o) {
|
|
2648
|
+
if (!(this instanceof _))
|
|
2531
2649
|
try {
|
|
2532
|
-
return new
|
|
2650
|
+
return new _(t, e, r, n, o);
|
|
2533
2651
|
} catch (i) {
|
|
2534
2652
|
if (!i.avoidNew)
|
|
2535
2653
|
throw i;
|
|
2536
2654
|
return i.value;
|
|
2537
2655
|
}
|
|
2538
|
-
typeof t == "string" && (
|
|
2539
|
-
const
|
|
2540
|
-
if (t = t || {}, this.json = t.json || r, this.path = t.path || e, this.resultType = t.resultType || "value", this.flatten = t.flatten || !1, this.wrap = Object.hasOwn(t, "wrap") ? t.wrap : !0, this.sandbox = t.sandbox || {}, this.eval = t.eval === void 0 ? "safe" : t.eval, this.ignoreEvalErrors = typeof t.ignoreEvalErrors > "u" ? !1 : t.ignoreEvalErrors, this.parent = t.parent || null, this.parentProperty = t.parentProperty || null, this.callback = t.callback || n || null, this.otherTypeCallback = t.otherTypeCallback ||
|
|
2656
|
+
typeof t == "string" && (o = n, n = r, r = e, e = t, t = null);
|
|
2657
|
+
const s = t && typeof t == "object";
|
|
2658
|
+
if (t = t || {}, this.json = t.json || r, this.path = t.path || e, this.resultType = t.resultType || "value", this.flatten = t.flatten || !1, this.wrap = Object.hasOwn(t, "wrap") ? t.wrap : !0, this.sandbox = t.sandbox || {}, this.eval = t.eval === void 0 ? "safe" : t.eval, this.ignoreEvalErrors = typeof t.ignoreEvalErrors > "u" ? !1 : t.ignoreEvalErrors, this.parent = t.parent || null, this.parentProperty = t.parentProperty || null, this.callback = t.callback || n || null, this.otherTypeCallback = t.otherTypeCallback || o || function() {
|
|
2541
2659
|
throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
|
|
2542
2660
|
}, t.autostart !== !1) {
|
|
2543
2661
|
const i = {
|
|
2544
|
-
path:
|
|
2662
|
+
path: s ? t.path : e
|
|
2545
2663
|
};
|
|
2546
|
-
|
|
2664
|
+
s ? "json" in t && (i.json = t.json) : i.json = r;
|
|
2547
2665
|
const a = this.evaluate(i);
|
|
2548
2666
|
if (!a || typeof a != "object")
|
|
2549
|
-
throw new
|
|
2667
|
+
throw new Fr(a);
|
|
2550
2668
|
return a;
|
|
2551
2669
|
}
|
|
2552
2670
|
}
|
|
2553
|
-
|
|
2554
|
-
let
|
|
2671
|
+
_.prototype.evaluate = function(t, e, r, n) {
|
|
2672
|
+
let o = this.parent, s = this.parentProperty, {
|
|
2555
2673
|
flatten: i,
|
|
2556
2674
|
wrap: a
|
|
2557
2675
|
} = this;
|
|
@@ -2562,174 +2680,174 @@ C.prototype.evaluate = function(t, e, r, n) {
|
|
|
2562
2680
|
throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
|
|
2563
2681
|
({
|
|
2564
2682
|
json: e
|
|
2565
|
-
} = t), i = Object.hasOwn(t, "flatten") ? t.flatten : i, this.currResultType = Object.hasOwn(t, "resultType") ? t.resultType : this.currResultType, this.currSandbox = Object.hasOwn(t, "sandbox") ? t.sandbox : this.currSandbox, a = Object.hasOwn(t, "wrap") ? t.wrap : a, this.currEval = Object.hasOwn(t, "eval") ? t.eval : this.currEval, r = Object.hasOwn(t, "callback") ? t.callback : r, this.currOtherTypeCallback = Object.hasOwn(t, "otherTypeCallback") ? t.otherTypeCallback : this.currOtherTypeCallback,
|
|
2683
|
+
} = t), i = Object.hasOwn(t, "flatten") ? t.flatten : i, this.currResultType = Object.hasOwn(t, "resultType") ? t.resultType : this.currResultType, this.currSandbox = Object.hasOwn(t, "sandbox") ? t.sandbox : this.currSandbox, a = Object.hasOwn(t, "wrap") ? t.wrap : a, this.currEval = Object.hasOwn(t, "eval") ? t.eval : this.currEval, r = Object.hasOwn(t, "callback") ? t.callback : r, this.currOtherTypeCallback = Object.hasOwn(t, "otherTypeCallback") ? t.otherTypeCallback : this.currOtherTypeCallback, o = Object.hasOwn(t, "parent") ? t.parent : o, s = Object.hasOwn(t, "parentProperty") ? t.parentProperty : s, t = t.path;
|
|
2566
2684
|
}
|
|
2567
|
-
if (
|
|
2685
|
+
if (o = o || null, s = s || null, Array.isArray(t) && (t = _.toPathString(t)), !t && t !== "" || !e)
|
|
2568
2686
|
return;
|
|
2569
|
-
const
|
|
2570
|
-
|
|
2571
|
-
const
|
|
2572
|
-
return
|
|
2687
|
+
const u = _.toPathArray(t);
|
|
2688
|
+
u[0] === "$" && u.length > 1 && u.shift(), this._hasParentSelector = null;
|
|
2689
|
+
const c = this._trace(u, e, ["$"], o, s, r).filter(function(f) {
|
|
2690
|
+
return f && !f.isParentSelector;
|
|
2573
2691
|
});
|
|
2574
|
-
return
|
|
2575
|
-
const
|
|
2576
|
-
return i && Array.isArray(
|
|
2692
|
+
return c.length ? !a && c.length === 1 && !c[0].hasArrExpr ? this._getPreferredOutput(c[0]) : c.reduce((f, p) => {
|
|
2693
|
+
const v = this._getPreferredOutput(p);
|
|
2694
|
+
return i && Array.isArray(v) ? f = f.concat(v) : f.push(v), f;
|
|
2577
2695
|
}, []) : a ? [] : void 0;
|
|
2578
2696
|
};
|
|
2579
|
-
|
|
2697
|
+
_.prototype._getPreferredOutput = function(t) {
|
|
2580
2698
|
const e = this.currResultType;
|
|
2581
2699
|
switch (e) {
|
|
2582
2700
|
case "all": {
|
|
2583
|
-
const r = Array.isArray(t.path) ? t.path :
|
|
2584
|
-
return t.pointer =
|
|
2701
|
+
const r = Array.isArray(t.path) ? t.path : _.toPathArray(t.path);
|
|
2702
|
+
return t.pointer = _.toPointer(r), t.path = typeof t.path == "string" ? t.path : _.toPathString(t.path), t;
|
|
2585
2703
|
}
|
|
2586
2704
|
case "value":
|
|
2587
2705
|
case "parent":
|
|
2588
2706
|
case "parentProperty":
|
|
2589
2707
|
return t[e];
|
|
2590
2708
|
case "path":
|
|
2591
|
-
return
|
|
2709
|
+
return _.toPathString(t[e]);
|
|
2592
2710
|
case "pointer":
|
|
2593
|
-
return
|
|
2711
|
+
return _.toPointer(t.path);
|
|
2594
2712
|
default:
|
|
2595
2713
|
throw new TypeError("Unknown result type");
|
|
2596
2714
|
}
|
|
2597
2715
|
};
|
|
2598
|
-
|
|
2716
|
+
_.prototype._handleCallback = function(t, e, r) {
|
|
2599
2717
|
if (e) {
|
|
2600
2718
|
const n = this._getPreferredOutput(t);
|
|
2601
|
-
t.path = typeof t.path == "string" ? t.path :
|
|
2719
|
+
t.path = typeof t.path == "string" ? t.path : _.toPathString(t.path), e(n, r, t);
|
|
2602
2720
|
}
|
|
2603
2721
|
};
|
|
2604
|
-
|
|
2605
|
-
let
|
|
2722
|
+
_.prototype._trace = function(t, e, r, n, o, s, i, a) {
|
|
2723
|
+
let u;
|
|
2606
2724
|
if (!t.length)
|
|
2607
|
-
return
|
|
2725
|
+
return u = {
|
|
2608
2726
|
path: r,
|
|
2609
2727
|
value: e,
|
|
2610
2728
|
parent: n,
|
|
2611
|
-
parentProperty:
|
|
2729
|
+
parentProperty: o,
|
|
2612
2730
|
hasArrExpr: i
|
|
2613
|
-
}, this._handleCallback(
|
|
2614
|
-
const
|
|
2615
|
-
function
|
|
2616
|
-
Array.isArray(
|
|
2617
|
-
|
|
2618
|
-
}) :
|
|
2619
|
-
}
|
|
2620
|
-
if ((typeof
|
|
2621
|
-
|
|
2622
|
-
else if (
|
|
2623
|
-
this._walk(e, (
|
|
2624
|
-
|
|
2731
|
+
}, this._handleCallback(u, s, "value"), u;
|
|
2732
|
+
const c = t[0], f = t.slice(1), p = [];
|
|
2733
|
+
function v(h) {
|
|
2734
|
+
Array.isArray(h) ? h.forEach((g) => {
|
|
2735
|
+
p.push(g);
|
|
2736
|
+
}) : p.push(h);
|
|
2737
|
+
}
|
|
2738
|
+
if ((typeof c != "string" || a) && e && Object.hasOwn(e, c))
|
|
2739
|
+
v(this._trace(f, e[c], Z(r, c), e, c, s, i));
|
|
2740
|
+
else if (c === "*")
|
|
2741
|
+
this._walk(e, (h) => {
|
|
2742
|
+
v(this._trace(f, e[h], Z(r, h), e, h, s, !0, !0));
|
|
2625
2743
|
});
|
|
2626
|
-
else if (
|
|
2627
|
-
|
|
2628
|
-
typeof e[
|
|
2744
|
+
else if (c === "..")
|
|
2745
|
+
v(this._trace(f, e, r, n, o, s, i)), this._walk(e, (h) => {
|
|
2746
|
+
typeof e[h] == "object" && v(this._trace(t.slice(), e[h], Z(r, h), e, h, s, !0));
|
|
2629
2747
|
});
|
|
2630
2748
|
else {
|
|
2631
|
-
if (
|
|
2749
|
+
if (c === "^")
|
|
2632
2750
|
return this._hasParentSelector = !0, {
|
|
2633
2751
|
path: r.slice(0, -1),
|
|
2634
|
-
expr:
|
|
2752
|
+
expr: f,
|
|
2635
2753
|
isParentSelector: !0
|
|
2636
2754
|
};
|
|
2637
|
-
if (
|
|
2638
|
-
return
|
|
2639
|
-
path:
|
|
2640
|
-
value:
|
|
2755
|
+
if (c === "~")
|
|
2756
|
+
return u = {
|
|
2757
|
+
path: Z(r, c),
|
|
2758
|
+
value: o,
|
|
2641
2759
|
parent: n,
|
|
2642
2760
|
parentProperty: null
|
|
2643
|
-
}, this._handleCallback(
|
|
2644
|
-
if (
|
|
2645
|
-
|
|
2646
|
-
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(
|
|
2647
|
-
|
|
2648
|
-
else if (
|
|
2761
|
+
}, this._handleCallback(u, s, "property"), u;
|
|
2762
|
+
if (c === "$")
|
|
2763
|
+
v(this._trace(f, e, r, null, null, s, i));
|
|
2764
|
+
else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(c))
|
|
2765
|
+
v(this._slice(c, f, e, r, n, o, s));
|
|
2766
|
+
else if (c.indexOf("?(") === 0) {
|
|
2649
2767
|
if (this.currEval === !1)
|
|
2650
2768
|
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
2651
|
-
const
|
|
2652
|
-
|
|
2653
|
-
const
|
|
2654
|
-
this._trace(
|
|
2655
|
-
}) : this._walk(e, (
|
|
2656
|
-
this._eval(
|
|
2769
|
+
const h = c.replace(/^\?\((.*?)\)$/u, "$1"), g = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(h);
|
|
2770
|
+
g ? this._walk(e, (C) => {
|
|
2771
|
+
const T = [g[2]], N = g[1] ? e[C][g[1]] : e[C];
|
|
2772
|
+
this._trace(T, N, r, n, o, s, !0).length > 0 && v(this._trace(f, e[C], Z(r, C), e, C, s, !0));
|
|
2773
|
+
}) : this._walk(e, (C) => {
|
|
2774
|
+
this._eval(h, e[C], C, r, n, o) && v(this._trace(f, e[C], Z(r, C), e, C, s, !0));
|
|
2657
2775
|
});
|
|
2658
|
-
} else if (
|
|
2776
|
+
} else if (c[0] === "(") {
|
|
2659
2777
|
if (this.currEval === !1)
|
|
2660
2778
|
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
2661
|
-
|
|
2662
|
-
} else if (
|
|
2663
|
-
let
|
|
2664
|
-
const
|
|
2665
|
-
switch (
|
|
2779
|
+
v(this._trace(Oe(this._eval(c, e, r.at(-1), r.slice(0, -1), n, o), f), e, r, n, o, s, i));
|
|
2780
|
+
} else if (c[0] === "@") {
|
|
2781
|
+
let h = !1;
|
|
2782
|
+
const g = c.slice(1, -2);
|
|
2783
|
+
switch (g) {
|
|
2666
2784
|
case "scalar":
|
|
2667
|
-
(!e || !["object", "function"].includes(typeof e)) && (
|
|
2785
|
+
(!e || !["object", "function"].includes(typeof e)) && (h = !0);
|
|
2668
2786
|
break;
|
|
2669
2787
|
case "boolean":
|
|
2670
2788
|
case "string":
|
|
2671
2789
|
case "undefined":
|
|
2672
2790
|
case "function":
|
|
2673
|
-
typeof e ===
|
|
2791
|
+
typeof e === g && (h = !0);
|
|
2674
2792
|
break;
|
|
2675
2793
|
case "integer":
|
|
2676
|
-
Number.isFinite(e) && !(e % 1) && (
|
|
2794
|
+
Number.isFinite(e) && !(e % 1) && (h = !0);
|
|
2677
2795
|
break;
|
|
2678
2796
|
case "number":
|
|
2679
|
-
Number.isFinite(e) && (
|
|
2797
|
+
Number.isFinite(e) && (h = !0);
|
|
2680
2798
|
break;
|
|
2681
2799
|
case "nonFinite":
|
|
2682
|
-
typeof e == "number" && !Number.isFinite(e) && (
|
|
2800
|
+
typeof e == "number" && !Number.isFinite(e) && (h = !0);
|
|
2683
2801
|
break;
|
|
2684
2802
|
case "object":
|
|
2685
|
-
e && typeof e ===
|
|
2803
|
+
e && typeof e === g && (h = !0);
|
|
2686
2804
|
break;
|
|
2687
2805
|
case "array":
|
|
2688
|
-
Array.isArray(e) && (
|
|
2806
|
+
Array.isArray(e) && (h = !0);
|
|
2689
2807
|
break;
|
|
2690
2808
|
case "other":
|
|
2691
|
-
|
|
2809
|
+
h = this.currOtherTypeCallback(e, r, n, o);
|
|
2692
2810
|
break;
|
|
2693
2811
|
case "null":
|
|
2694
|
-
e === null && (
|
|
2812
|
+
e === null && (h = !0);
|
|
2695
2813
|
break;
|
|
2696
2814
|
/* c8 ignore next 2 */
|
|
2697
2815
|
default:
|
|
2698
|
-
throw new TypeError("Unknown value type " +
|
|
2816
|
+
throw new TypeError("Unknown value type " + g);
|
|
2699
2817
|
}
|
|
2700
|
-
if (
|
|
2701
|
-
return
|
|
2818
|
+
if (h)
|
|
2819
|
+
return u = {
|
|
2702
2820
|
path: r,
|
|
2703
2821
|
value: e,
|
|
2704
2822
|
parent: n,
|
|
2705
|
-
parentProperty:
|
|
2706
|
-
}, this._handleCallback(
|
|
2707
|
-
} else if (
|
|
2708
|
-
const
|
|
2709
|
-
|
|
2710
|
-
} else if (
|
|
2711
|
-
const
|
|
2712
|
-
for (const
|
|
2713
|
-
|
|
2714
|
-
} else !a && e && Object.hasOwn(e,
|
|
2823
|
+
parentProperty: o
|
|
2824
|
+
}, this._handleCallback(u, s, "value"), u;
|
|
2825
|
+
} else if (c[0] === "`" && e && Object.hasOwn(e, c.slice(1))) {
|
|
2826
|
+
const h = c.slice(1);
|
|
2827
|
+
v(this._trace(f, e[h], Z(r, h), e, h, s, i, !0));
|
|
2828
|
+
} else if (c.includes(",")) {
|
|
2829
|
+
const h = c.split(",");
|
|
2830
|
+
for (const g of h)
|
|
2831
|
+
v(this._trace(Oe(g, f), e, r, n, o, s, !0));
|
|
2832
|
+
} else !a && e && Object.hasOwn(e, c) && v(this._trace(f, e[c], Z(r, c), e, c, s, i, !0));
|
|
2715
2833
|
}
|
|
2716
2834
|
if (this._hasParentSelector)
|
|
2717
|
-
for (let
|
|
2718
|
-
const
|
|
2719
|
-
if (
|
|
2720
|
-
const
|
|
2721
|
-
if (Array.isArray(
|
|
2722
|
-
h
|
|
2723
|
-
const
|
|
2724
|
-
for (let
|
|
2725
|
-
|
|
2835
|
+
for (let h = 0; h < p.length; h++) {
|
|
2836
|
+
const g = p[h];
|
|
2837
|
+
if (g && g.isParentSelector) {
|
|
2838
|
+
const C = this._trace(g.expr, e, g.path, n, o, s, i);
|
|
2839
|
+
if (Array.isArray(C)) {
|
|
2840
|
+
p[h] = C[0];
|
|
2841
|
+
const T = C.length;
|
|
2842
|
+
for (let N = 1; N < T; N++)
|
|
2843
|
+
h++, p.splice(h, 0, C[N]);
|
|
2726
2844
|
} else
|
|
2727
|
-
h
|
|
2845
|
+
p[h] = C;
|
|
2728
2846
|
}
|
|
2729
2847
|
}
|
|
2730
|
-
return
|
|
2848
|
+
return p;
|
|
2731
2849
|
};
|
|
2732
|
-
|
|
2850
|
+
_.prototype._walk = function(t, e) {
|
|
2733
2851
|
if (Array.isArray(t)) {
|
|
2734
2852
|
const r = t.length;
|
|
2735
2853
|
for (let n = 0; n < r; n++)
|
|
@@ -2738,92 +2856,92 @@ C.prototype._walk = function(t, e) {
|
|
|
2738
2856
|
e(r);
|
|
2739
2857
|
});
|
|
2740
2858
|
};
|
|
2741
|
-
|
|
2859
|
+
_.prototype._slice = function(t, e, r, n, o, s, i) {
|
|
2742
2860
|
if (!Array.isArray(r))
|
|
2743
2861
|
return;
|
|
2744
|
-
const a = r.length,
|
|
2745
|
-
let
|
|
2746
|
-
|
|
2747
|
-
const
|
|
2748
|
-
for (let
|
|
2749
|
-
this._trace(
|
|
2750
|
-
|
|
2862
|
+
const a = r.length, u = t.split(":"), c = u[2] && Number.parseInt(u[2]) || 1;
|
|
2863
|
+
let f = u[0] && Number.parseInt(u[0]) || 0, p = u[1] && Number.parseInt(u[1]) || a;
|
|
2864
|
+
f = f < 0 ? Math.max(0, f + a) : Math.min(a, f), p = p < 0 ? Math.max(0, p + a) : Math.min(a, p);
|
|
2865
|
+
const v = [];
|
|
2866
|
+
for (let h = f; h < p; h += c)
|
|
2867
|
+
this._trace(Oe(h, e), r, n, o, s, i, !0).forEach((C) => {
|
|
2868
|
+
v.push(C);
|
|
2751
2869
|
});
|
|
2752
|
-
return
|
|
2870
|
+
return v;
|
|
2753
2871
|
};
|
|
2754
|
-
|
|
2755
|
-
this.currSandbox._$_parentProperty =
|
|
2872
|
+
_.prototype._eval = function(t, e, r, n, o, s) {
|
|
2873
|
+
this.currSandbox._$_parentProperty = s, this.currSandbox._$_parent = o, this.currSandbox._$_property = r, this.currSandbox._$_root = this.json, this.currSandbox._$_v = e;
|
|
2756
2874
|
const i = t.includes("@path");
|
|
2757
|
-
i && (this.currSandbox._$_path =
|
|
2875
|
+
i && (this.currSandbox._$_path = _.toPathString(n.concat([r])));
|
|
2758
2876
|
const a = this.currEval + "Script:" + t;
|
|
2759
|
-
if (!
|
|
2760
|
-
let
|
|
2761
|
-
if (i && (
|
|
2762
|
-
|
|
2877
|
+
if (!_.cache[a]) {
|
|
2878
|
+
let u = t.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
2879
|
+
if (i && (u = u.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0)
|
|
2880
|
+
_.cache[a] = new this.safeVm.Script(u);
|
|
2763
2881
|
else if (this.currEval === "native")
|
|
2764
|
-
|
|
2882
|
+
_.cache[a] = new this.vm.Script(u);
|
|
2765
2883
|
else if (typeof this.currEval == "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
2766
|
-
const
|
|
2767
|
-
|
|
2884
|
+
const c = this.currEval;
|
|
2885
|
+
_.cache[a] = new c(u);
|
|
2768
2886
|
} else if (typeof this.currEval == "function")
|
|
2769
|
-
|
|
2770
|
-
runInNewContext: (
|
|
2887
|
+
_.cache[a] = {
|
|
2888
|
+
runInNewContext: (c) => this.currEval(u, c)
|
|
2771
2889
|
};
|
|
2772
2890
|
else
|
|
2773
2891
|
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
2774
2892
|
}
|
|
2775
2893
|
try {
|
|
2776
|
-
return
|
|
2777
|
-
} catch (
|
|
2894
|
+
return _.cache[a].runInNewContext(this.currSandbox);
|
|
2895
|
+
} catch (u) {
|
|
2778
2896
|
if (this.ignoreEvalErrors)
|
|
2779
2897
|
return !1;
|
|
2780
|
-
throw new Error("jsonPath: " +
|
|
2898
|
+
throw new Error("jsonPath: " + u.message + ": " + t);
|
|
2781
2899
|
}
|
|
2782
2900
|
};
|
|
2783
|
-
|
|
2784
|
-
|
|
2901
|
+
_.cache = {};
|
|
2902
|
+
_.toPathString = function(t) {
|
|
2785
2903
|
const e = t, r = e.length;
|
|
2786
2904
|
let n = "$";
|
|
2787
|
-
for (let
|
|
2788
|
-
/^(~|\^|@.*?\(\))$/u.test(e[
|
|
2905
|
+
for (let o = 1; o < r; o++)
|
|
2906
|
+
/^(~|\^|@.*?\(\))$/u.test(e[o]) || (n += /^[0-9*]+$/u.test(e[o]) ? "[" + e[o] + "]" : "['" + e[o] + "']");
|
|
2789
2907
|
return n;
|
|
2790
2908
|
};
|
|
2791
|
-
|
|
2909
|
+
_.toPointer = function(t) {
|
|
2792
2910
|
const e = t, r = e.length;
|
|
2793
2911
|
let n = "";
|
|
2794
|
-
for (let
|
|
2795
|
-
/^(~|\^|@.*?\(\))$/u.test(e[
|
|
2912
|
+
for (let o = 1; o < r; o++)
|
|
2913
|
+
/^(~|\^|@.*?\(\))$/u.test(e[o]) || (n += "/" + e[o].toString().replaceAll("~", "~0").replaceAll("/", "~1"));
|
|
2796
2914
|
return n;
|
|
2797
2915
|
};
|
|
2798
|
-
|
|
2916
|
+
_.toPathArray = function(t) {
|
|
2799
2917
|
const {
|
|
2800
2918
|
cache: e
|
|
2801
|
-
} =
|
|
2919
|
+
} = _;
|
|
2802
2920
|
if (e[t])
|
|
2803
2921
|
return e[t].concat();
|
|
2804
|
-
const r = [],
|
|
2922
|
+
const r = [], o = t.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function(s, i) {
|
|
2805
2923
|
return "[#" + (r.push(i) - 1) + "]";
|
|
2806
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(
|
|
2924
|
+
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function(s, i) {
|
|
2807
2925
|
return "['" + i.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
2808
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(
|
|
2926
|
+
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function(s, i) {
|
|
2809
2927
|
return ";" + i.split("").join(";") + ";";
|
|
2810
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "").split(";").map(function(
|
|
2811
|
-
const i =
|
|
2812
|
-
return !i || !i[1] ?
|
|
2928
|
+
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "").split(";").map(function(s) {
|
|
2929
|
+
const i = s.match(/#(\d+)/u);
|
|
2930
|
+
return !i || !i[1] ? s : r[i[1]];
|
|
2813
2931
|
});
|
|
2814
|
-
return e[t] =
|
|
2932
|
+
return e[t] = o, e[t].concat();
|
|
2815
2933
|
};
|
|
2816
|
-
|
|
2817
|
-
Script:
|
|
2934
|
+
_.prototype.safeVm = {
|
|
2935
|
+
Script: jr
|
|
2818
2936
|
};
|
|
2819
|
-
const
|
|
2937
|
+
const Hr = function(t, e, r) {
|
|
2820
2938
|
const n = t.length;
|
|
2821
|
-
for (let
|
|
2822
|
-
const
|
|
2823
|
-
r(
|
|
2939
|
+
for (let o = 0; o < n; o++) {
|
|
2940
|
+
const s = t[o];
|
|
2941
|
+
r(s) && e.push(t.splice(o--, 1)[0]);
|
|
2824
2942
|
}
|
|
2825
2943
|
};
|
|
2826
|
-
class
|
|
2944
|
+
class Vr {
|
|
2827
2945
|
/**
|
|
2828
2946
|
* @param {string} expr Expression to evaluate
|
|
2829
2947
|
*/
|
|
@@ -2837,106 +2955,134 @@ class Ir {
|
|
|
2837
2955
|
*/
|
|
2838
2956
|
runInNewContext(e) {
|
|
2839
2957
|
let r = this.code;
|
|
2840
|
-
const n = Object.keys(e),
|
|
2841
|
-
|
|
2842
|
-
const
|
|
2843
|
-
r =
|
|
2844
|
-
let
|
|
2845
|
-
return /function/u.test(
|
|
2958
|
+
const n = Object.keys(e), o = [];
|
|
2959
|
+
Hr(n, o, (c) => typeof e[c] == "function");
|
|
2960
|
+
const s = n.map((c) => e[c]);
|
|
2961
|
+
r = o.reduce((c, f) => {
|
|
2962
|
+
let p = e[f].toString();
|
|
2963
|
+
return /function/u.test(p) || (p = "function " + p), "var " + f + "=" + p + ";" + c;
|
|
2846
2964
|
}, "") + r, !/(['"])use strict\1/u.test(r) && !n.includes("arguments") && (r = "var arguments = undefined;" + r), r = r.replace(/;\s*$/u, "");
|
|
2847
|
-
const a = r.lastIndexOf(";"),
|
|
2848
|
-
return new Function(...n,
|
|
2965
|
+
const a = r.lastIndexOf(";"), u = a !== -1 ? r.slice(0, a + 1) + " return " + r.slice(a + 1) : " return " + r;
|
|
2966
|
+
return new Function(...n, u)(...s);
|
|
2849
2967
|
}
|
|
2850
2968
|
}
|
|
2851
|
-
|
|
2852
|
-
Script:
|
|
2969
|
+
_.prototype.vm = {
|
|
2970
|
+
Script: Vr
|
|
2853
2971
|
};
|
|
2854
|
-
function
|
|
2972
|
+
function Le(t, e, r) {
|
|
2855
2973
|
const n = e.replace(/^\$\.?/, "").split(/\.|\[|\]/).filter(Boolean);
|
|
2856
|
-
let
|
|
2974
|
+
let o = t;
|
|
2857
2975
|
for (let i = 0; i < n.length - 1; i++) {
|
|
2858
|
-
const a = n[i],
|
|
2976
|
+
const a = n[i], u = n[i + 1], c = /^\d+$/.test(u);
|
|
2859
2977
|
if (a === "__proto__" || a === "constructor" || a === "prototype")
|
|
2860
2978
|
throw new Error("Invalid path part: " + a);
|
|
2861
|
-
if (a in
|
|
2862
|
-
const
|
|
2863
|
-
Array.isArray(
|
|
2979
|
+
if (a in o || (o[a] = c ? [] : {}), c) {
|
|
2980
|
+
const f = parseInt(u, 10);
|
|
2981
|
+
Array.isArray(o[a]) || (o[a] = []), o[a].length <= f && (o[a][f] = i === n.length - 2 ? r : {}), o = o[a][f], i++;
|
|
2864
2982
|
} else
|
|
2865
|
-
|
|
2866
|
-
}
|
|
2867
|
-
const
|
|
2868
|
-
if (
|
|
2869
|
-
throw new Error("Invalid path part: " +
|
|
2870
|
-
if (/^\d+$/.test(
|
|
2871
|
-
const i = parseInt(
|
|
2872
|
-
Array.isArray(
|
|
2983
|
+
o = o[a];
|
|
2984
|
+
}
|
|
2985
|
+
const s = n[n.length - 1];
|
|
2986
|
+
if (s === "__proto__" || s === "constructor" || s === "prototype")
|
|
2987
|
+
throw new Error("Invalid path part: " + s);
|
|
2988
|
+
if (/^\d+$/.test(s)) {
|
|
2989
|
+
const i = parseInt(s, 10);
|
|
2990
|
+
Array.isArray(o) || (o = []), o[i] = r;
|
|
2873
2991
|
} else
|
|
2874
|
-
s
|
|
2992
|
+
o[s] = r;
|
|
2875
2993
|
}
|
|
2876
|
-
const
|
|
2994
|
+
const tn = (t, e, r) => {
|
|
2877
2995
|
const n = {
|
|
2878
2996
|
type: e.type,
|
|
2879
2997
|
item: e.type === "single" ? {} : void 0,
|
|
2880
2998
|
list: e.type === "list" ? [] : void 0
|
|
2881
|
-
},
|
|
2882
|
-
let
|
|
2883
|
-
return a.patchSource === "value" ? a.value ?? a.defaultValue ?? null : (a.patchSource === "child" && (
|
|
2884
|
-
},
|
|
2999
|
+
}, o = (i, a) => {
|
|
3000
|
+
let u = i;
|
|
3001
|
+
return a.patchSource === "value" ? a.value ?? a.defaultValue ?? null : (a.patchSource === "child" && (u = r), (a.type === "single" ? _({ path: a.fromPath, json: u, resultType: "value" }) : _({ path: a.fromPath, json: u })) ?? a.defaultValue ?? null);
|
|
3002
|
+
}, s = e.type === "single" ? _({ path: e.fromPath, json: t, resultType: "value" }) : _({ path: e.fromPath, json: t });
|
|
2885
3003
|
return e.type === "single" ? e.patches.forEach((i) => {
|
|
2886
|
-
const a = s
|
|
2887
|
-
|
|
2888
|
-
}) : e.type === "list" && (n.list =
|
|
3004
|
+
const a = o(s, i);
|
|
3005
|
+
Le(n.item, i.toPath, a);
|
|
3006
|
+
}) : e.type === "list" && (n.list = s.map((i) => {
|
|
2889
3007
|
const a = {};
|
|
2890
|
-
return e.patches.forEach((
|
|
2891
|
-
const
|
|
2892
|
-
|
|
3008
|
+
return e.patches.forEach((u) => {
|
|
3009
|
+
const c = o(i, u);
|
|
3010
|
+
Le(a, u.toPath, c);
|
|
2893
3011
|
}), a;
|
|
2894
3012
|
})), n;
|
|
2895
3013
|
};
|
|
2896
|
-
function
|
|
3014
|
+
function Kr(t, e) {
|
|
2897
3015
|
const r = {};
|
|
2898
|
-
return !t.events || !Object.keys(t.events).length || Object.entries(t.events).forEach(([n,
|
|
2899
|
-
|
|
3016
|
+
return !t.events || !Object.keys(t.events).length || Object.entries(t.events).forEach(([n, o]) => {
|
|
3017
|
+
o?.trim() && (r[n] = (...s) => {
|
|
2900
3018
|
try {
|
|
2901
|
-
new Function(
|
|
3019
|
+
new Function(
|
|
3020
|
+
"ctx",
|
|
3021
|
+
"craftNode",
|
|
3022
|
+
"args",
|
|
3023
|
+
o
|
|
3024
|
+
)(e, t, ...s);
|
|
2902
3025
|
} catch (i) {
|
|
2903
|
-
console.error(
|
|
2904
|
-
|
|
3026
|
+
console.error(
|
|
3027
|
+
`Event code execution failed with code:
|
|
3028
|
+
${o}
|
|
2905
3029
|
|
|
2906
|
-
Error:`,
|
|
3030
|
+
Error:`,
|
|
3031
|
+
i
|
|
3032
|
+
);
|
|
2907
3033
|
}
|
|
2908
3034
|
});
|
|
2909
3035
|
}), r;
|
|
2910
3036
|
}
|
|
2911
|
-
function
|
|
3037
|
+
function Xr(t, e, r = "default") {
|
|
2912
3038
|
if (!t.slots || !t.slots[r]) return [];
|
|
2913
3039
|
const n = t.slots[r];
|
|
2914
|
-
return e.type === "single" ? n.map((
|
|
2915
|
-
...
|
|
2916
|
-
uuid: `${
|
|
2917
|
-
props: { ...
|
|
3040
|
+
return e.type === "single" ? n.map((o) => ({
|
|
3041
|
+
...o,
|
|
3042
|
+
uuid: `${o.uuid}-single`,
|
|
3043
|
+
props: { ...o.props, ...e.item || {} }
|
|
2918
3044
|
})) : e.type === "list" && e.list ? n.flatMap(
|
|
2919
|
-
(
|
|
2920
|
-
...
|
|
2921
|
-
uuid: `${
|
|
2922
|
-
props: { ...
|
|
3045
|
+
(o) => e.list.map((s, i) => ({
|
|
3046
|
+
...o,
|
|
3047
|
+
uuid: `${o.uuid}-data-${i}`,
|
|
3048
|
+
props: { ...o.props, ...s || {} }
|
|
2923
3049
|
}))
|
|
2924
3050
|
) : [];
|
|
2925
3051
|
}
|
|
2926
|
-
function
|
|
2927
|
-
if (!
|
|
3052
|
+
function xe(t, e, r, n, o) {
|
|
3053
|
+
if (!qe(t))
|
|
2928
3054
|
return null;
|
|
2929
|
-
const
|
|
2930
|
-
...
|
|
3055
|
+
const s = e.resolveNode(t), i = s?.componentName || t.componentName, a = r?.[i] || i, u = {
|
|
3056
|
+
...s?.defaultProps || {},
|
|
2931
3057
|
...t.props
|
|
2932
|
-
},
|
|
2933
|
-
let
|
|
2934
|
-
return
|
|
3058
|
+
}, c = o ? Kr(t, o) : {}, f = n?.[t.uuid];
|
|
3059
|
+
let p;
|
|
3060
|
+
return f?.type ? p = Xr(
|
|
3061
|
+
t,
|
|
3062
|
+
f,
|
|
3063
|
+
f.slotName || "default"
|
|
3064
|
+
).map(
|
|
3065
|
+
(h) => xe(
|
|
3066
|
+
h,
|
|
3067
|
+
e,
|
|
3068
|
+
r,
|
|
3069
|
+
n,
|
|
3070
|
+
o
|
|
3071
|
+
)
|
|
3072
|
+
).filter((h) => h !== null) : t.slots && (p = Object.values(t.slots).flat().map(
|
|
3073
|
+
(v) => xe(
|
|
3074
|
+
v,
|
|
3075
|
+
e,
|
|
3076
|
+
r,
|
|
3077
|
+
n,
|
|
3078
|
+
o
|
|
3079
|
+
)
|
|
3080
|
+
).filter((v) => v !== null)), Nt(a, { key: t.uuid, ...u, ...c }, p);
|
|
2935
3081
|
}
|
|
2936
|
-
function
|
|
2937
|
-
const r = new
|
|
3082
|
+
function rn(t, e) {
|
|
3083
|
+
const r = new be(e.resolverMap);
|
|
2938
3084
|
return t.map(
|
|
2939
|
-
(n) =>
|
|
3085
|
+
(n) => xe(
|
|
2940
3086
|
n,
|
|
2941
3087
|
r,
|
|
2942
3088
|
e.componentRegistry,
|
|
@@ -2945,7 +3091,7 @@ function zr(t, e) {
|
|
|
2945
3091
|
)
|
|
2946
3092
|
).filter((n) => n !== null);
|
|
2947
3093
|
}
|
|
2948
|
-
const
|
|
3094
|
+
const nn = {
|
|
2949
3095
|
CraftComponentSimpleText: {
|
|
2950
3096
|
componentName: "CraftComponentSimpleText",
|
|
2951
3097
|
eventsSchema: {
|
|
@@ -2991,49 +3137,51 @@ const qr = {
|
|
|
2991
3137
|
CraftCanvas: {
|
|
2992
3138
|
componentName: "CraftCanvas"
|
|
2993
3139
|
}
|
|
2994
|
-
},
|
|
2995
|
-
for (const e in
|
|
2996
|
-
t.component(e,
|
|
2997
|
-
},
|
|
3140
|
+
}, zr = (t) => {
|
|
3141
|
+
for (const e in Ue)
|
|
3142
|
+
t.component(e, Ue[e]);
|
|
3143
|
+
}, on = { install: zr };
|
|
2998
3144
|
export {
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3145
|
+
Ot as CraftCanvas,
|
|
3146
|
+
At as CraftComponentSimpleText,
|
|
3147
|
+
Pt as CraftEditor,
|
|
3148
|
+
Mt as CraftEditorBlueprint,
|
|
3149
|
+
Bt as CraftEditorBlueprintsList,
|
|
3150
|
+
Ht as CraftEditorPanelBlueprints,
|
|
3151
|
+
Vt as CraftEditorPanelForm,
|
|
3152
|
+
Yt as CraftEditorPanelLayers,
|
|
3153
|
+
tr as CraftEditorPanelLayout,
|
|
3154
|
+
nr as CraftEditorPanelNodeEventsSettings,
|
|
3155
|
+
lr as CraftEditorPanelNodeLayer,
|
|
3156
|
+
cr as CraftEditorPanelNodeSettings,
|
|
3157
|
+
mr as CraftEditorPanelSettings,
|
|
3158
|
+
Er as CraftFrame,
|
|
3159
|
+
Je as CraftIframe,
|
|
3160
|
+
kr as CraftNodeEditor,
|
|
3161
|
+
be as CraftNodeResolver,
|
|
3162
|
+
Ne as CraftNodeViewer,
|
|
3163
|
+
Dr as CraftStaticRenderer,
|
|
3164
|
+
$t as Utils,
|
|
3165
|
+
on as VCraft,
|
|
3166
|
+
Qe as buildCraftNodeTree,
|
|
3167
|
+
oe as craftNodeCanBeChildOf,
|
|
3168
|
+
me as craftNodeCanBeSiblingOf,
|
|
3169
|
+
St as craftNodeInCanvas,
|
|
3170
|
+
Ye as craftNodeIsAncestorOf,
|
|
3171
|
+
K as craftNodeIsCanvas,
|
|
3172
|
+
kt as craftNodeIsDraggable,
|
|
3173
|
+
Zr as defaultBlueprints,
|
|
3174
|
+
nn as defaultResolvers,
|
|
3175
|
+
We as initializeSlotsFromResolver,
|
|
3176
|
+
qe as isVisible,
|
|
3177
|
+
tn as mapData,
|
|
3178
|
+
xe as renderCraftNodeToVNode,
|
|
3179
|
+
rn as renderCraftNodesToVNodes,
|
|
3180
|
+
J as resolveNodeName,
|
|
3181
|
+
xt as useCraftNode,
|
|
3182
|
+
L as useEditor,
|
|
3183
|
+
De as useIndicator,
|
|
3184
|
+
Jr as useNodeElement,
|
|
3185
|
+
fe as useResolveCraftNode
|
|
3038
3186
|
};
|
|
3039
3187
|
//# sourceMappingURL=v-craft.es.js.map
|