@tvolden/block-code-editor 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/block-editor.cjs +4 -4
- package/dist/block-editor.js +1428 -1299
- package/dist/commands/build.d.ts +5 -0
- package/dist/components/BlockRenderer.d.ts +4 -0
- package/dist/components/Canvas.d.ts +4 -0
- package/dist/components/MouthDecorations.d.ts +9 -1
- package/dist/utils/blockLayout.d.ts +58 -3
- package/package.json +1 -1
package/dist/block-editor.js
CHANGED
|
@@ -1,252 +1,252 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
function
|
|
1
|
+
import { jsxs as m, jsx as l, Fragment as bt } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as _o, useContext as Ao, useState as B, useMemo as Ne, forwardRef as Oo, useRef as se, useEffect as ee, useCallback as C } from "react";
|
|
3
|
+
function Lo(e, t, n) {
|
|
4
4
|
"dependencies" in e ? n(e.dependencies(t)) : e.onClick();
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function te(e) {
|
|
7
7
|
return `${e.publisher}/${e.name}`;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return `${
|
|
9
|
+
function Ye(e) {
|
|
10
|
+
return `${It}${te(e)}@${e.version}`;
|
|
11
11
|
}
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
const n = e.split(/[.-]/),
|
|
15
|
-
for (let
|
|
16
|
-
const i = n[
|
|
17
|
-
if (
|
|
12
|
+
const It = "dep:";
|
|
13
|
+
function No(e, t) {
|
|
14
|
+
const n = e.split(/[.-]/), o = t.split(/[.-]/);
|
|
15
|
+
for (let r = 0; r < Math.max(n.length, o.length); r++) {
|
|
16
|
+
const i = n[r] ?? "0", s = o[r] ?? "0", c = Number(i), p = Number(s), y = !isNaN(c) && !isNaN(p) ? c - p : i.localeCompare(s);
|
|
17
|
+
if (y !== 0) return y;
|
|
18
18
|
}
|
|
19
19
|
return 0;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
class
|
|
21
|
+
const fi = 1;
|
|
22
|
+
class R extends Error {
|
|
23
23
|
code;
|
|
24
24
|
constructor(t, n) {
|
|
25
25
|
super(n), this.name = "CommandRejected", this.code = t;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function Qe(e, t) {
|
|
29
29
|
switch (t.type) {
|
|
30
30
|
case "InsertBlocks":
|
|
31
|
-
return
|
|
31
|
+
return zo(e, t);
|
|
32
32
|
case "RemoveBlocks":
|
|
33
|
-
return
|
|
33
|
+
return Wo(e, t);
|
|
34
34
|
case "MoveBlock":
|
|
35
|
-
return
|
|
35
|
+
return qo(e, t);
|
|
36
36
|
case "Attach":
|
|
37
|
-
return
|
|
37
|
+
return Uo(e, t);
|
|
38
38
|
case "Detach":
|
|
39
|
-
return
|
|
39
|
+
return Yo(e, t);
|
|
40
40
|
case "SetText":
|
|
41
|
-
return
|
|
41
|
+
return Fo(e, t);
|
|
42
42
|
case "SetDependencies":
|
|
43
|
-
return
|
|
43
|
+
return Xo(e, t);
|
|
44
44
|
case "Batch":
|
|
45
|
-
return
|
|
45
|
+
return jo(e, t);
|
|
46
46
|
default:
|
|
47
|
-
throw new
|
|
47
|
+
throw new R("INVALID_COMMAND", `Unknown command type '${t.type}'.`);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function vt(e) {
|
|
51
51
|
return {
|
|
52
52
|
textValue: e?.textValue ?? null,
|
|
53
53
|
queryBlockId: e?.queryBlockId ?? null,
|
|
54
54
|
commandBlockId: e?.commandBlockId ?? null
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const t =
|
|
59
|
-
return { ...e, ...t, paramSlots: e.paramSlots.map(
|
|
57
|
+
function Me(e) {
|
|
58
|
+
const t = Xt(e) ? { x: e.x, y: e.y } : { x: 0, y: 0 };
|
|
59
|
+
return { ...e, ...t, paramSlots: e.paramSlots.map(vt) };
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function Re(e) {
|
|
62
62
|
return e == null || e === "" ? null : e;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function ze(e, t) {
|
|
65
65
|
const n = e.blocks.get(t);
|
|
66
|
-
if (!n) throw new
|
|
66
|
+
if (!n) throw new R("BLOCK_NOT_FOUND", `Block '${t}' doesn't exist.`);
|
|
67
67
|
return n;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function Xt(e) {
|
|
70
70
|
return !e.parentBlockId && !e.embeddedInBlockId;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function Pn(e) {
|
|
73
73
|
const t = [];
|
|
74
74
|
e.nextBlockId && t.push(e.nextBlockId);
|
|
75
75
|
for (const n of e.paramSlots)
|
|
76
76
|
n.queryBlockId && t.push(n.queryBlockId), n.commandBlockId && t.push(n.commandBlockId);
|
|
77
77
|
return t;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
const n = [],
|
|
81
|
-
for (;
|
|
82
|
-
const i =
|
|
83
|
-
if (
|
|
79
|
+
function $t(e, t) {
|
|
80
|
+
const n = [], o = /* @__PURE__ */ new Set(), r = [t];
|
|
81
|
+
for (; r.length > 0; ) {
|
|
82
|
+
const i = r.shift();
|
|
83
|
+
if (o.has(i)) continue;
|
|
84
84
|
const s = e.get(i);
|
|
85
|
-
s && (
|
|
85
|
+
s && (o.add(i), n.push(i), r.push(...Pn(s)));
|
|
86
86
|
}
|
|
87
87
|
return n;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
const t = (
|
|
91
|
-
if (e.length === 0) throw new
|
|
89
|
+
function En(e) {
|
|
90
|
+
const t = (r) => new R("NOT_A_FRAGMENT", `The blocks aren't one fragment: ${r}.`);
|
|
91
|
+
if (e.length === 0) throw new R("INVALID_COMMAND", "The command has no blocks.");
|
|
92
92
|
const n = /* @__PURE__ */ new Map();
|
|
93
|
-
for (const
|
|
94
|
-
if (n.has(
|
|
95
|
-
n.set(
|
|
93
|
+
for (const r of e) {
|
|
94
|
+
if (n.has(r.instanceId)) throw t(`'${r.instanceId}' is given twice`);
|
|
95
|
+
n.set(r.instanceId, r);
|
|
96
96
|
}
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
for (const
|
|
100
|
-
if (
|
|
101
|
-
const i = n.get(
|
|
102
|
-
if (!i || i.parentBlockId !==
|
|
103
|
-
throw t(`the block under '${
|
|
97
|
+
const o = e.filter(Xt);
|
|
98
|
+
if (o.length !== 1) throw t(`it has ${o.length} roots`);
|
|
99
|
+
for (const r of e) {
|
|
100
|
+
if (r.nextBlockId) {
|
|
101
|
+
const i = n.get(r.nextBlockId);
|
|
102
|
+
if (!i || i.parentBlockId !== r.instanceId || i.embeddedInBlockId)
|
|
103
|
+
throw t(`the block under '${r.instanceId}' doesn't match`);
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
105
|
+
if (r.paramSlots.forEach((i, s) => {
|
|
106
106
|
for (const c of [i.queryBlockId, i.commandBlockId]) {
|
|
107
107
|
if (!c) continue;
|
|
108
108
|
const p = n.get(c);
|
|
109
|
-
if (!p || p.embeddedInBlockId !==
|
|
110
|
-
throw t(`slot ${s} of '${
|
|
109
|
+
if (!p || p.embeddedInBlockId !== r.instanceId || p.embeddedSlotIndex !== s || p.parentBlockId)
|
|
110
|
+
throw t(`slot ${s} of '${r.instanceId}' doesn't match`);
|
|
111
111
|
}
|
|
112
|
-
}),
|
|
113
|
-
const i = n.get(
|
|
114
|
-
if (!i || i.nextBlockId !==
|
|
115
|
-
throw t(`the block above '${
|
|
112
|
+
}), r.parentBlockId) {
|
|
113
|
+
const i = n.get(r.parentBlockId);
|
|
114
|
+
if (!i || i.nextBlockId !== r.instanceId)
|
|
115
|
+
throw t(`the block above '${r.instanceId}' doesn't match`);
|
|
116
116
|
}
|
|
117
|
-
if (
|
|
118
|
-
const i = n.get(
|
|
119
|
-
if (!i || i.queryBlockId !==
|
|
120
|
-
throw t(`the block holding '${
|
|
117
|
+
if (r.embeddedInBlockId) {
|
|
118
|
+
const i = n.get(r.embeddedInBlockId)?.paramSlots[r.embeddedSlotIndex];
|
|
119
|
+
if (!i || i.queryBlockId !== r.instanceId && i.commandBlockId !== r.instanceId)
|
|
120
|
+
throw t(`the block holding '${r.instanceId}' doesn't match`);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
if (
|
|
124
|
-
return
|
|
123
|
+
if ($t(n, o[0].instanceId).length !== e.length) throw t("not every block hangs off the root");
|
|
124
|
+
return o[0];
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
return JSON.stringify(
|
|
126
|
+
function Ro(e, t) {
|
|
127
|
+
return JSON.stringify(Me(e)) === JSON.stringify(Me(t));
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
return
|
|
129
|
+
function ht(e, t, n) {
|
|
130
|
+
const o = e.paramSlots.map(vt);
|
|
131
|
+
return o[t] = { ...o[t], ...n }, { ...e, paramSlots: o };
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function Mn(e, t) {
|
|
134
134
|
if (!Number.isInteger(t) || t < 0 || t >= e.paramSlots.length)
|
|
135
|
-
throw new
|
|
136
|
-
return
|
|
135
|
+
throw new R("NO_SUCH_SLOT", `Block '${e.instanceId}' has no slot ${t}.`);
|
|
136
|
+
return vt(e.paramSlots[t]);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Dn(e, t) {
|
|
139
139
|
if (e.x !== t.x || e.y !== t.y)
|
|
140
|
-
throw new
|
|
141
|
-
}
|
|
142
|
-
function vn(e) {
|
|
143
|
-
if (!Ht(e)) throw new N("NOT_A_ROOT", `Block '${e.instanceId}' is linked, not a root.`);
|
|
140
|
+
throw new R("POSITION_CHANGED", `Block '${e.instanceId}' isn't at (${t.x}, ${t.y}).`);
|
|
144
141
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const n = new Set(e.map(Tt));
|
|
148
|
-
return e.length === t.length && n.size === new Set(t.map(Tt)).size && t.every((r) => n.has(Tt(r)));
|
|
142
|
+
function _n(e) {
|
|
143
|
+
if (!Xt(e)) throw new R("NOT_A_ROOT", `Block '${e.instanceId}' is linked, not a root.`);
|
|
149
144
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
145
|
+
const Nt = (e) => `${e.publisher}/${e.name}@${e.version}`;
|
|
146
|
+
function Ho(e, t) {
|
|
147
|
+
const n = new Set(e.map(Nt));
|
|
148
|
+
return e.length === t.length && n.size === new Set(t.map(Nt)).size && t.every((o) => n.has(Nt(o)));
|
|
149
|
+
}
|
|
150
|
+
function zo(e, t) {
|
|
151
|
+
En(t.blocks);
|
|
152
|
+
for (const o of t.blocks)
|
|
153
|
+
if (e.blocks.has(o.instanceId))
|
|
154
|
+
throw new R("ID_EXISTS", `Block '${o.instanceId}' already exists.`);
|
|
155
155
|
const n = new Map(e.blocks);
|
|
156
|
-
for (const
|
|
156
|
+
for (const o of t.blocks) n.set(o.instanceId, Me(o));
|
|
157
157
|
return { ...e, blocks: n };
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
|
|
159
|
+
function Wo(e, t) {
|
|
160
|
+
En(t.blocks);
|
|
161
161
|
const n = /* @__PURE__ */ new Set();
|
|
162
|
-
for (const
|
|
163
|
-
const i =
|
|
164
|
-
if (!
|
|
165
|
-
n.add(
|
|
162
|
+
for (const r of t.blocks) {
|
|
163
|
+
const i = ze(e, r.instanceId);
|
|
164
|
+
if (!Ro(i, r)) throw new R("BLOCK_CHANGED", `Block '${r.instanceId}' has changed.`);
|
|
165
|
+
n.add(r.instanceId);
|
|
166
166
|
}
|
|
167
|
-
for (const
|
|
168
|
-
if (!n.has(
|
|
169
|
-
throw new
|
|
170
|
-
const
|
|
171
|
-
return n.forEach((
|
|
167
|
+
for (const r of e.blocks.values())
|
|
168
|
+
if (!n.has(r.instanceId) && Pn(r).some((i) => n.has(i)))
|
|
169
|
+
throw new R("LINKED_FROM_OUTSIDE", `Block '${r.instanceId}' links into the blocks to remove.`);
|
|
170
|
+
const o = new Map(e.blocks);
|
|
171
|
+
return n.forEach((r) => o.delete(r)), { ...e, blocks: o };
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
const n =
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
return
|
|
178
|
-
}
|
|
179
|
-
function
|
|
180
|
-
const n =
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
throw new
|
|
173
|
+
function qo(e, t) {
|
|
174
|
+
const n = ze(e, t.id);
|
|
175
|
+
_n(n), Dn(n, t.from);
|
|
176
|
+
const o = new Map(e.blocks);
|
|
177
|
+
return o.set(n.instanceId, { ...n, x: t.to.x, y: t.to.y }), { ...e, blocks: o };
|
|
178
|
+
}
|
|
179
|
+
function Uo(e, t) {
|
|
180
|
+
const n = ze(e, t.id);
|
|
181
|
+
_n(n), Dn(n, t.from);
|
|
182
|
+
const o = t.to, r = "next" in o ? o.next : "mouth" in o ? o.mouth : o.socket, i = ze(e, r);
|
|
183
|
+
if ($t(e.blocks, n.instanceId).includes(r))
|
|
184
|
+
throw new R("CYCLE", `Block '${r}' is inside the fragment of '${n.instanceId}'.`);
|
|
185
185
|
const s = new Map(e.blocks);
|
|
186
|
-
if ("next" in
|
|
187
|
-
if (i.nextBlockId) throw new
|
|
188
|
-
return s.set(
|
|
186
|
+
if ("next" in o) {
|
|
187
|
+
if (i.nextBlockId) throw new R("PLACE_OCCUPIED", `Block '${r}' already has a block under it.`);
|
|
188
|
+
return s.set(r, { ...i, nextBlockId: n.instanceId }), s.set(n.instanceId, { ...n, x: 0, y: 0, parentBlockId: r }), { ...e, blocks: s };
|
|
189
189
|
}
|
|
190
|
-
const c =
|
|
191
|
-
if ("mouth" in
|
|
190
|
+
const c = Mn(i, o.slot);
|
|
191
|
+
if ("mouth" in o) {
|
|
192
192
|
if (c.commandBlockId || c.queryBlockId)
|
|
193
|
-
throw new
|
|
194
|
-
s.set(
|
|
193
|
+
throw new R("PLACE_OCCUPIED", `Mouth ${o.slot} of '${r}' isn't empty.`);
|
|
194
|
+
s.set(r, ht(i, o.slot, { commandBlockId: n.instanceId }));
|
|
195
195
|
} else {
|
|
196
196
|
if (c.queryBlockId || c.commandBlockId || c.textValue !== null)
|
|
197
|
-
throw new
|
|
198
|
-
s.set(
|
|
197
|
+
throw new R("PLACE_OCCUPIED", `Socket ${o.slot} of '${r}' isn't empty.`);
|
|
198
|
+
s.set(r, ht(i, o.slot, { queryBlockId: n.instanceId }));
|
|
199
199
|
}
|
|
200
|
-
return s.set(n.instanceId, { ...n, x: 0, y: 0, embeddedInBlockId:
|
|
200
|
+
return s.set(n.instanceId, { ...n, x: 0, y: 0, embeddedInBlockId: r, embeddedSlotIndex: o.slot }), { ...e, blocks: s };
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function Vo(e, t, n) {
|
|
203
203
|
if ("next" in n)
|
|
204
204
|
return t.parentBlockId === n.next && e.blocks.get(n.next)?.nextBlockId === t.instanceId;
|
|
205
|
-
const
|
|
206
|
-
if (t.embeddedInBlockId !==
|
|
207
|
-
const
|
|
208
|
-
return ("mouth" in n ?
|
|
209
|
-
}
|
|
210
|
-
function
|
|
211
|
-
const n =
|
|
212
|
-
if (!
|
|
213
|
-
throw new
|
|
214
|
-
const
|
|
215
|
-
if ("next" in
|
|
216
|
-
const i =
|
|
217
|
-
|
|
205
|
+
const o = "mouth" in n ? n.mouth : n.socket;
|
|
206
|
+
if (t.embeddedInBlockId !== o || t.embeddedSlotIndex !== n.slot) return !1;
|
|
207
|
+
const r = vt(e.blocks.get(o)?.paramSlots[n.slot]);
|
|
208
|
+
return ("mouth" in n ? r.commandBlockId : r.queryBlockId) === t.instanceId;
|
|
209
|
+
}
|
|
210
|
+
function Yo(e, t) {
|
|
211
|
+
const n = ze(e, t.id);
|
|
212
|
+
if (!Vo(e, n, t.from))
|
|
213
|
+
throw new R("NOT_AT_PLACE", `Block '${n.instanceId}' isn't linked at the given place.`);
|
|
214
|
+
const o = new Map(e.blocks), r = t.from;
|
|
215
|
+
if ("next" in r) {
|
|
216
|
+
const i = o.get(r.next);
|
|
217
|
+
o.set(r.next, { ...i, nextBlockId: null });
|
|
218
218
|
} else {
|
|
219
|
-
const i = "mouth" in
|
|
220
|
-
|
|
219
|
+
const i = "mouth" in r ? r.mouth : r.socket, s = "mouth" in r ? { commandBlockId: null } : { queryBlockId: null };
|
|
220
|
+
o.set(i, ht(o.get(i), r.slot, s));
|
|
221
221
|
}
|
|
222
|
-
return
|
|
222
|
+
return o.set(n.instanceId, {
|
|
223
223
|
...n,
|
|
224
224
|
x: t.to.x,
|
|
225
225
|
y: t.to.y,
|
|
226
226
|
parentBlockId: null,
|
|
227
227
|
embeddedInBlockId: null,
|
|
228
228
|
embeddedSlotIndex: -1
|
|
229
|
-
}), { ...e, blocks:
|
|
230
|
-
}
|
|
231
|
-
function
|
|
232
|
-
const n =
|
|
233
|
-
if (
|
|
234
|
-
throw new
|
|
235
|
-
if (
|
|
236
|
-
throw new
|
|
237
|
-
const
|
|
238
|
-
return
|
|
229
|
+
}), { ...e, blocks: o };
|
|
230
|
+
}
|
|
231
|
+
function Fo(e, t) {
|
|
232
|
+
const n = ze(e, t.blockId), o = Mn(n, t.slot);
|
|
233
|
+
if (o.queryBlockId)
|
|
234
|
+
throw new R("SLOT_HAS_QUERY", `Slot ${t.slot} of '${n.instanceId}' holds a query.`);
|
|
235
|
+
if (Re(o.textValue) !== Re(t.from))
|
|
236
|
+
throw new R("TEXT_CHANGED", `Slot ${t.slot} of '${n.instanceId}' has changed.`);
|
|
237
|
+
const r = new Map(e.blocks);
|
|
238
|
+
return r.set(n.instanceId, ht(n, t.slot, { textValue: Re(t.to) })), { ...e, blocks: r };
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
if (!
|
|
242
|
-
throw new
|
|
240
|
+
function Xo(e, t) {
|
|
241
|
+
if (!Ho(e.dependencies, t.from))
|
|
242
|
+
throw new R("DEPENDENCIES_CHANGED", "The dependencies have changed.");
|
|
243
243
|
return { ...e, dependencies: t.to.map((n) => ({ publisher: n.publisher, name: n.name, version: n.version })) };
|
|
244
244
|
}
|
|
245
|
-
function
|
|
246
|
-
return t.commands.reduce(
|
|
245
|
+
function jo(e, t) {
|
|
246
|
+
return t.commands.reduce(Qe, e);
|
|
247
247
|
}
|
|
248
|
-
const
|
|
249
|
-
class
|
|
248
|
+
const He = { x: 0, y: 0 };
|
|
249
|
+
class St {
|
|
250
250
|
state;
|
|
251
251
|
commands = [];
|
|
252
252
|
constructor(t) {
|
|
@@ -256,84 +256,88 @@ class gt {
|
|
|
256
256
|
return this.state;
|
|
257
257
|
}
|
|
258
258
|
add(t) {
|
|
259
|
-
this.state =
|
|
259
|
+
this.state = Qe(this.state, t), this.commands.push(t);
|
|
260
260
|
}
|
|
261
261
|
/** The user action: nothing, one command, or a batch. */
|
|
262
262
|
build() {
|
|
263
263
|
return this.commands.length === 0 ? null : this.commands.length === 1 ? this.commands[0] : { type: "Batch", commands: this.commands };
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function An(e) {
|
|
267
267
|
return { x: Math.round(e.x), y: Math.round(e.y) };
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function jt(e, t) {
|
|
270
270
|
return t.parentBlockId ? { next: t.parentBlockId } : t.embeddedInBlockId ? e.blocks.get(t.embeddedInBlockId)?.paramSlots[t.embeddedSlotIndex]?.commandBlockId === t.instanceId ? { mouth: t.embeddedInBlockId, slot: t.embeddedSlotIndex } : { socket: t.embeddedInBlockId, slot: t.embeddedSlotIndex } : null;
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function Ko(e, t) {
|
|
273
273
|
return JSON.stringify(e) === JSON.stringify(t);
|
|
274
274
|
}
|
|
275
|
-
function
|
|
276
|
-
return
|
|
275
|
+
function On(e, t) {
|
|
276
|
+
return $t(e.blocks, t).map((n) => Me(e.blocks.get(n)));
|
|
277
277
|
}
|
|
278
|
-
function
|
|
278
|
+
function Qo(e, t) {
|
|
279
279
|
let n = t;
|
|
280
280
|
for (; ; ) {
|
|
281
|
-
const
|
|
282
|
-
if (!
|
|
283
|
-
n =
|
|
281
|
+
const o = e.blocks.get(n)?.nextBlockId;
|
|
282
|
+
if (!o) return n;
|
|
283
|
+
n = o;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
const
|
|
286
|
+
function Ln(e, t, n) {
|
|
287
|
+
const o = e.current.blocks.get(t), r = { x: o.x, y: o.y };
|
|
288
288
|
if ("socket" in n) {
|
|
289
|
-
const i =
|
|
290
|
-
i !== null && e.add({ type: "SetText", blockId: n.socket, slot: n.slot, from: i, to: null }), e.add({ type: "Attach", id: t, to: n, from:
|
|
289
|
+
const i = Re(e.current.blocks.get(n.socket)?.paramSlots[n.slot]?.textValue);
|
|
290
|
+
i !== null && e.add({ type: "SetText", blockId: n.socket, slot: n.slot, from: i, to: null }), e.add({ type: "Attach", id: t, to: n, from: r });
|
|
291
291
|
return;
|
|
292
292
|
}
|
|
293
293
|
if ("mouth" in n) {
|
|
294
294
|
const i = e.current.blocks.get(n.mouth)?.paramSlots[n.slot]?.commandBlockId ?? null;
|
|
295
295
|
if (i) {
|
|
296
|
-
e.add({ type: "Detach", id: i, from: n, to:
|
|
296
|
+
e.add({ type: "Detach", id: i, from: n, to: He }), e.add({ type: "Attach", id: t, to: n, from: r }), e.add({ type: "Attach", id: i, to: { next: Qo(e.current, t) }, from: He });
|
|
297
297
|
return;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
e.add({ type: "Attach", id: t, to: n, from:
|
|
300
|
+
e.add({ type: "Attach", id: t, to: n, from: r });
|
|
301
|
+
}
|
|
302
|
+
function Go(e, t, n, o) {
|
|
303
|
+
const r = new St(e), i = An(n);
|
|
304
|
+
return r.add({ type: "InsertBlocks", blocks: [Me({ ...t, ...i })] }), o && Ln(r, t.instanceId, o), r.build();
|
|
301
305
|
}
|
|
302
|
-
function
|
|
303
|
-
const
|
|
304
|
-
|
|
306
|
+
function Rt(e, t, n, o) {
|
|
307
|
+
const r = e.blocks.get(t);
|
|
308
|
+
if (!r) return null;
|
|
309
|
+
const i = new St(e), s = An(n), c = jt(e, r);
|
|
310
|
+
return o && c && Ko(o, c) ? null : (c ? i.add({ type: "Detach", id: t, from: c, to: s }) : !o && (r.x !== s.x || r.y !== s.y) && i.add({ type: "MoveBlock", id: t, from: { x: r.x, y: r.y }, to: s }), o && Ln(i, t, o), i.build());
|
|
305
311
|
}
|
|
306
|
-
function
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
const i = new gt(e), s = $n(n), c = zt(e, o);
|
|
310
|
-
return r && c && Mo(r, c) ? null : (c ? i.add({ type: "Detach", id: t, from: c, to: s }) : !r && (o.x !== s.x || o.y !== s.y) && i.add({ type: "MoveBlock", id: t, from: { x: o.x, y: o.y }, to: s }), r && Bn(i, t, r), i.build());
|
|
312
|
+
function Zo(e, t, n, o) {
|
|
313
|
+
const r = e.blocks.get(t)?.paramSlots[n]?.commandBlockId;
|
|
314
|
+
return r ? Rt(e, r, o, null) : null;
|
|
311
315
|
}
|
|
312
|
-
function
|
|
316
|
+
function Jo(e, t) {
|
|
313
317
|
const n = e.blocks.get(t);
|
|
314
318
|
if (!n) return null;
|
|
315
|
-
const
|
|
316
|
-
return
|
|
319
|
+
const o = new St(e), r = jt(e, n);
|
|
320
|
+
return r && o.add({ type: "Detach", id: t, from: r, to: He }), o.add({ type: "RemoveBlocks", blocks: On(o.current, t) }), o.build();
|
|
317
321
|
}
|
|
318
|
-
function
|
|
319
|
-
const
|
|
320
|
-
return
|
|
322
|
+
function vn(e, t, n, o) {
|
|
323
|
+
const r = Re(n), i = Re(o);
|
|
324
|
+
return r === i ? null : { type: "SetText", blockId: e, slot: t, from: r, to: i };
|
|
321
325
|
}
|
|
322
|
-
function
|
|
323
|
-
const
|
|
324
|
-
for (const
|
|
325
|
-
const i =
|
|
326
|
+
function er(e, t, n) {
|
|
327
|
+
const o = new St(e);
|
|
328
|
+
for (const r of n) {
|
|
329
|
+
const i = o.current.blocks.get(r);
|
|
326
330
|
if (!i) continue;
|
|
327
|
-
const s =
|
|
331
|
+
const s = jt(o.current, i), c = i.nextBlockId;
|
|
328
332
|
if (c) {
|
|
329
|
-
const p = s ?
|
|
330
|
-
|
|
333
|
+
const p = s ? He : { x: i.x, y: i.y };
|
|
334
|
+
o.add({ type: "Detach", id: c, from: { next: r }, to: p });
|
|
331
335
|
}
|
|
332
|
-
s &&
|
|
336
|
+
s && o.add({ type: "Detach", id: r, from: s, to: He }), o.add({ type: "RemoveBlocks", blocks: On(o.current, r) }), c && s && o.add({ type: "Attach", id: c, to: s, from: He });
|
|
333
337
|
}
|
|
334
|
-
return
|
|
338
|
+
return o.add({ type: "SetDependencies", from: o.current.dependencies, to: t }), o.build();
|
|
335
339
|
}
|
|
336
|
-
function
|
|
340
|
+
function Nn(e) {
|
|
337
341
|
switch (e.type) {
|
|
338
342
|
case "InsertBlocks":
|
|
339
343
|
return { type: "RemoveBlocks", blocks: e.blocks };
|
|
@@ -350,80 +354,80 @@ function wn(e) {
|
|
|
350
354
|
case "SetDependencies":
|
|
351
355
|
return { type: "SetDependencies", from: e.to, to: e.from };
|
|
352
356
|
case "Batch":
|
|
353
|
-
return { type: "Batch", commands: e.commands.map(
|
|
357
|
+
return { type: "Batch", commands: e.commands.map(Nn).reverse() };
|
|
354
358
|
default:
|
|
355
|
-
throw new
|
|
359
|
+
throw new R("INVALID_COMMAND", `Unknown command type '${e.type}'.`);
|
|
356
360
|
}
|
|
357
361
|
}
|
|
358
|
-
function
|
|
362
|
+
function Rn(e, t = 0) {
|
|
359
363
|
return { confirmed: e, version: t, pending: [], undo: [], redo: [] };
|
|
360
364
|
}
|
|
361
|
-
function
|
|
365
|
+
function tr(e, t, n) {
|
|
362
366
|
return { ...e, pending: [...e.pending, { id: t, command: n, kind: "do", original: n }] };
|
|
363
367
|
}
|
|
364
|
-
function
|
|
368
|
+
function nr(e, t) {
|
|
365
369
|
const n = e.undo[e.undo.length - 1];
|
|
366
|
-
if (!n || !
|
|
367
|
-
const
|
|
368
|
-
return { sync: { ...e, pending: [...e.pending, { id: t, command:
|
|
370
|
+
if (!n || !pt(e)) return null;
|
|
371
|
+
const o = Nn(n);
|
|
372
|
+
return { sync: { ...e, pending: [...e.pending, { id: t, command: o, kind: "undo", original: n }] }, command: o };
|
|
369
373
|
}
|
|
370
|
-
function
|
|
374
|
+
function or(e, t) {
|
|
371
375
|
const n = e.redo[e.redo.length - 1];
|
|
372
|
-
return !n || !
|
|
376
|
+
return !n || !pt(e) ? null : { sync: { ...e, pending: [...e.pending, { id: t, command: n, kind: "redo", original: n }] }, command: n };
|
|
373
377
|
}
|
|
374
|
-
function
|
|
378
|
+
function pt(e) {
|
|
375
379
|
return e.pending.length === 0;
|
|
376
380
|
}
|
|
377
|
-
function
|
|
378
|
-
return { sync:
|
|
381
|
+
function rr(e, t, n) {
|
|
382
|
+
return { sync: Rn(e, t), dropped: n.pending.length };
|
|
379
383
|
}
|
|
380
|
-
function
|
|
381
|
-
let
|
|
384
|
+
function $n(e, t, n) {
|
|
385
|
+
let o;
|
|
382
386
|
try {
|
|
383
|
-
|
|
387
|
+
o = Qe(e.confirmed, t.command);
|
|
384
388
|
} catch {
|
|
385
389
|
return { sync: e, outOfSync: !0 };
|
|
386
390
|
}
|
|
387
|
-
const
|
|
388
|
-
if (!
|
|
389
|
-
switch (
|
|
391
|
+
const r = e.pending.find((s) => s.id === t.id), i = { ...e, confirmed: o, version: n, pending: e.pending.filter((s) => s.id !== t.id) };
|
|
392
|
+
if (!r) return { sync: i, outOfSync: !1 };
|
|
393
|
+
switch (r.kind) {
|
|
390
394
|
case "do":
|
|
391
|
-
return { sync: { ...i, undo: [...i.undo,
|
|
395
|
+
return { sync: { ...i, undo: [...i.undo, r.original], redo: [] }, outOfSync: !1 };
|
|
392
396
|
case "undo":
|
|
393
|
-
return { sync: { ...i, undo: i.undo.slice(0, -1), redo: [...i.redo,
|
|
397
|
+
return { sync: { ...i, undo: i.undo.slice(0, -1), redo: [...i.redo, r.original] }, outOfSync: !1 };
|
|
394
398
|
case "redo":
|
|
395
|
-
return { sync: { ...i, undo: [...i.undo,
|
|
399
|
+
return { sync: { ...i, undo: [...i.undo, r.original], redo: i.redo.slice(0, -1) }, outOfSync: !1 };
|
|
396
400
|
}
|
|
397
401
|
}
|
|
398
|
-
function
|
|
399
|
-
const n = e.pending.find((
|
|
402
|
+
function Sn(e, t) {
|
|
403
|
+
const n = e.pending.find((r) => r.id === t) ?? null;
|
|
400
404
|
if (!n) return { sync: e, action: null };
|
|
401
|
-
const
|
|
402
|
-
return n.kind === "undo" ? { sync: { ...
|
|
405
|
+
const o = { ...e, pending: e.pending.filter((r) => r.id !== t) };
|
|
406
|
+
return n.kind === "undo" ? { sync: { ...o, undo: o.undo.slice(0, -1) }, action: n } : n.kind === "redo" ? { sync: { ...o, redo: o.redo.slice(0, -1) }, action: n } : { sync: o, action: n };
|
|
403
407
|
}
|
|
404
|
-
function
|
|
408
|
+
function wn(e) {
|
|
405
409
|
let t = e.confirmed;
|
|
406
|
-
for (const
|
|
410
|
+
for (const o of e.pending)
|
|
407
411
|
try {
|
|
408
|
-
t =
|
|
412
|
+
t = Qe(t, o.command);
|
|
409
413
|
} catch {
|
|
410
414
|
break;
|
|
411
415
|
}
|
|
412
416
|
const n = /* @__PURE__ */ new Set();
|
|
413
|
-
return t !== e.confirmed && t.blocks.forEach((
|
|
414
|
-
e.confirmed.blocks.get(
|
|
417
|
+
return t !== e.confirmed && t.blocks.forEach((o, r) => {
|
|
418
|
+
e.confirmed.blocks.get(r) !== o && n.add(r);
|
|
415
419
|
}), { state: t, provisionalIds: n };
|
|
416
420
|
}
|
|
417
|
-
const
|
|
418
|
-
class
|
|
419
|
-
presence =
|
|
421
|
+
const Hn = 66, ir = { cursor: null, drag: null, typing: null };
|
|
422
|
+
class sr {
|
|
423
|
+
presence = ir;
|
|
420
424
|
lastSent = Number.NEGATIVE_INFINITY;
|
|
421
425
|
timer = null;
|
|
422
426
|
send;
|
|
423
427
|
intervalMs;
|
|
424
428
|
now;
|
|
425
|
-
constructor(t, n =
|
|
426
|
-
this.send = t, this.intervalMs = n, this.now =
|
|
429
|
+
constructor(t, n = Hn, o = Date.now) {
|
|
430
|
+
this.send = t, this.intervalMs = n, this.now = o;
|
|
427
431
|
}
|
|
428
432
|
get current() {
|
|
429
433
|
return this.presence;
|
|
@@ -446,223 +450,283 @@ class qo {
|
|
|
446
450
|
this.dispose(), this.lastSent = this.now(), this.send(this.presence);
|
|
447
451
|
}
|
|
448
452
|
}
|
|
449
|
-
const
|
|
450
|
-
async function
|
|
451
|
-
const t =
|
|
453
|
+
const gt = "command", Ie = /* @__PURE__ */ new Map(), Ge = /* @__PURE__ */ new Map(), Be = /* @__PURE__ */ new Map();
|
|
454
|
+
async function Kt(e) {
|
|
455
|
+
const t = Be.get(e.id);
|
|
452
456
|
if (t && t.info.url === e.url) return t;
|
|
453
|
-
t &&
|
|
457
|
+
t && Qt(e.id);
|
|
454
458
|
const n = await fetch(e.url);
|
|
455
459
|
if (!n.ok) throw new Error(`HTTP ${n.status} fetching ${e.url}`);
|
|
456
|
-
const
|
|
457
|
-
for (const c of
|
|
458
|
-
|
|
459
|
-
const s = { info: e, blockIds:
|
|
460
|
-
return
|
|
460
|
+
const o = await n.json(), r = [], i = [];
|
|
461
|
+
for (const c of o)
|
|
462
|
+
Ie.has(c.id) ? i.push(c.id) : (Ie.set(c.id, c), Ge.set(c.id, e.id), r.push(c.id));
|
|
463
|
+
const s = { info: e, blockIds: r, conflictIds: i };
|
|
464
|
+
return Be.set(e.id, s), s;
|
|
461
465
|
}
|
|
462
|
-
function
|
|
463
|
-
const t =
|
|
466
|
+
function Qt(e) {
|
|
467
|
+
const t = Be.get(e);
|
|
464
468
|
if (t) {
|
|
465
469
|
for (const n of t.blockIds)
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
Ie.delete(n), Ge.delete(n);
|
|
471
|
+
Be.delete(e);
|
|
468
472
|
}
|
|
469
473
|
}
|
|
470
|
-
function
|
|
471
|
-
return Array.from(
|
|
474
|
+
function Fe() {
|
|
475
|
+
return Array.from(Be.values());
|
|
472
476
|
}
|
|
473
|
-
function
|
|
474
|
-
return
|
|
477
|
+
function zn(e) {
|
|
478
|
+
return Ge.get(e);
|
|
475
479
|
}
|
|
476
|
-
function
|
|
477
|
-
const t =
|
|
480
|
+
function yt(e) {
|
|
481
|
+
const t = Ie.get(e);
|
|
478
482
|
if (!t) throw new Error(`Block definition not found: "${e}"`);
|
|
479
483
|
return t;
|
|
480
484
|
}
|
|
481
|
-
function
|
|
482
|
-
return
|
|
485
|
+
function N(e) {
|
|
486
|
+
return Ie.get(e);
|
|
483
487
|
}
|
|
484
|
-
function
|
|
485
|
-
return [...
|
|
488
|
+
function Wn() {
|
|
489
|
+
return [...Ie.values()];
|
|
486
490
|
}
|
|
487
|
-
function
|
|
488
|
-
return [...new Set(
|
|
491
|
+
function cr() {
|
|
492
|
+
return [...new Set(Wn().map((e) => e.category))];
|
|
489
493
|
}
|
|
490
|
-
function
|
|
491
|
-
const n = [],
|
|
494
|
+
function lr(e, t) {
|
|
495
|
+
const n = [], o = [];
|
|
492
496
|
for (const i of t)
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
return
|
|
497
|
+
Ie.has(i.id) ? o.push(i.id) : (Ie.set(i.id, i), Ge.set(i.id, e.id), n.push(i.id));
|
|
498
|
+
const r = { info: e, blockIds: n, conflictIds: o };
|
|
499
|
+
return Be.set(e.id, r), r;
|
|
496
500
|
}
|
|
497
|
-
async function
|
|
498
|
-
|
|
501
|
+
async function ar(e) {
|
|
502
|
+
Be.get(Bn)?.info.url !== e && (Ie.clear(), Ge.clear(), Be.clear(), await Kt({ id: Bn, name: "Core", description: "Built-in blocks", url: e, builtIn: !0 }));
|
|
499
503
|
}
|
|
500
|
-
const
|
|
501
|
-
function
|
|
504
|
+
const Bn = "__core__", qn = 36, De = 50, we = 24, je = 24, Gt = 16, dr = 24, Ke = 24, ur = 16, Un = 26, fr = 11, hr = 6, Vn = 16, Yn = 20, pr = 26, gr = 8, yr = 6, Ht = 12, lt = 12, Fn = 8, zt = 6;
|
|
505
|
+
function Xn(e) {
|
|
502
506
|
return e.blockType === "query" && e.returnType ? `${e.name} [${e.returnType}]` : e.name;
|
|
503
507
|
}
|
|
504
|
-
const
|
|
505
|
-
number: { w: 44, h:
|
|
506
|
-
string: { w: 60, h:
|
|
507
|
-
boolean: { w: 52, h:
|
|
508
|
-
},
|
|
509
|
-
function
|
|
510
|
-
return
|
|
508
|
+
const mr = {
|
|
509
|
+
number: { w: 44, h: we },
|
|
510
|
+
string: { w: 60, h: we },
|
|
511
|
+
boolean: { w: 52, h: we }
|
|
512
|
+
}, xr = { w: 75, h: we };
|
|
513
|
+
function mt(e) {
|
|
514
|
+
return mr[e] ?? xr;
|
|
511
515
|
}
|
|
512
|
-
function
|
|
513
|
-
return e.blockType === "command" && t.type ===
|
|
516
|
+
function xe(e, t) {
|
|
517
|
+
return e.blockType === "command" && t.type === gt;
|
|
514
518
|
}
|
|
515
|
-
|
|
516
|
-
|
|
519
|
+
function kr(e) {
|
|
520
|
+
return e.params.some((t) => xe(e, t));
|
|
521
|
+
}
|
|
522
|
+
const Wt = 18;
|
|
523
|
+
function jn(e, t) {
|
|
517
524
|
return !!e.optional && !t?.queryBlockId && !t?.textValue;
|
|
518
525
|
}
|
|
519
|
-
function
|
|
526
|
+
function Kn(e) {
|
|
520
527
|
return `+ ${e}`;
|
|
521
528
|
}
|
|
522
|
-
function
|
|
523
|
-
return
|
|
529
|
+
function Qn(e) {
|
|
530
|
+
return Kn(e).length * Zn + 12;
|
|
531
|
+
}
|
|
532
|
+
function Zt(e, t, n) {
|
|
533
|
+
return xe(e, t) && !!t.optional && !n?.commandBlockId && !n?.opened;
|
|
534
|
+
}
|
|
535
|
+
function br(e, t) {
|
|
536
|
+
if (t.size === 0) return e;
|
|
537
|
+
let n = null;
|
|
538
|
+
for (const o of t) {
|
|
539
|
+
const [r, i] = Ir(o), s = (n ?? e).get(r), c = s?.paramSlots[i];
|
|
540
|
+
if (!s || !c || c.commandBlockId) continue;
|
|
541
|
+
n ??= new Map(e);
|
|
542
|
+
const p = s.paramSlots.map((y, x) => x === i ? { ...y, opened: !0 } : y);
|
|
543
|
+
n.set(r, { ...s, paramSlots: p });
|
|
544
|
+
}
|
|
545
|
+
return n ?? e;
|
|
546
|
+
}
|
|
547
|
+
function qt(e, t) {
|
|
548
|
+
return `${e}#${t}`;
|
|
549
|
+
}
|
|
550
|
+
function Ir(e) {
|
|
551
|
+
const t = e.lastIndexOf("#");
|
|
552
|
+
return [e.slice(0, t), Number(e.slice(t + 1))];
|
|
553
|
+
}
|
|
554
|
+
function vr(e) {
|
|
555
|
+
const t = [];
|
|
556
|
+
return e.forEach((n) => {
|
|
557
|
+
const o = N(n.definitionId);
|
|
558
|
+
o && o.params.forEach((r, i) => {
|
|
559
|
+
xe(o, r) && r.optional && n.paramSlots[i]?.commandBlockId && t.push(qt(n.instanceId, i));
|
|
560
|
+
});
|
|
561
|
+
}), t;
|
|
524
562
|
}
|
|
525
|
-
function
|
|
526
|
-
if (
|
|
563
|
+
function Gn(e, t, n) {
|
|
564
|
+
if (jn(e, t)) return Qn(e.name);
|
|
527
565
|
if (t?.queryBlockId && n) {
|
|
528
|
-
const
|
|
529
|
-
if (
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
566
|
+
const o = n.get(t.queryBlockId);
|
|
567
|
+
if (o) {
|
|
568
|
+
const r = N(o.definitionId);
|
|
569
|
+
if (r) return fe(r, o.paramSlots, n);
|
|
532
570
|
}
|
|
533
571
|
}
|
|
534
|
-
return
|
|
572
|
+
return mt(e.type).w;
|
|
535
573
|
}
|
|
536
|
-
const
|
|
537
|
-
function
|
|
538
|
-
const
|
|
574
|
+
const Zn = 5;
|
|
575
|
+
function $r(e, t, n) {
|
|
576
|
+
const r = t === "number" || t === "boolean" ? n - we : n - 10, i = Math.floor(r / Zn);
|
|
539
577
|
return e.length <= i ? e : i <= 1 ? "…" : `${e.slice(0, i - 1)}…`;
|
|
540
578
|
}
|
|
541
|
-
function
|
|
579
|
+
function xt(e, t) {
|
|
542
580
|
return `${e}: ${t}`;
|
|
543
581
|
}
|
|
544
|
-
function
|
|
545
|
-
const t =
|
|
582
|
+
function Jn(e) {
|
|
583
|
+
const t = xt(e.name, e.type);
|
|
546
584
|
return e.optional ? `${t} (optional)` : t;
|
|
547
585
|
}
|
|
548
|
-
function
|
|
586
|
+
function Sr(e) {
|
|
549
587
|
return Math.max(72, e.length * 6 + 22);
|
|
550
588
|
}
|
|
551
|
-
function
|
|
552
|
-
let t =
|
|
589
|
+
function Jt(e) {
|
|
590
|
+
let t = gr;
|
|
553
591
|
return (e.blockType === "start" ? e.provides ?? [] : []).map((n) => {
|
|
554
|
-
const
|
|
555
|
-
return t +=
|
|
592
|
+
const o = { id: n.id, name: n.name, x: t, y: De + 6, w: Sr(n.name) };
|
|
593
|
+
return t += o.w + yr, o;
|
|
556
594
|
});
|
|
557
595
|
}
|
|
558
|
-
function
|
|
559
|
-
let
|
|
560
|
-
for (let
|
|
561
|
-
|
|
562
|
-
const
|
|
563
|
-
if (
|
|
564
|
-
const
|
|
565
|
-
|
|
596
|
+
function fe(e, t, n) {
|
|
597
|
+
let o = Ht + lt + Xn(e).length * zt;
|
|
598
|
+
for (let c = 0; c < e.params.length; c++)
|
|
599
|
+
xe(e, e.params[c]) || (o += Fn + Gn(e.params[c], t?.[c], n));
|
|
600
|
+
const r = Jt(e);
|
|
601
|
+
if (r.length > 0) {
|
|
602
|
+
const c = r[r.length - 1];
|
|
603
|
+
o = Math.max(o, c.x + c.w + lt);
|
|
566
604
|
}
|
|
567
|
-
e.params.forEach((
|
|
568
|
-
|
|
605
|
+
e.params.forEach((c) => {
|
|
606
|
+
xe(e, c) && (o = Math.max(o, Gt + Ht + c.name.length * zt + lt + (c.optional ? Vn : 0)));
|
|
569
607
|
});
|
|
570
|
-
const i = e
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return e.blockType === "start" ? Ce : e.blockType === "command" ? Dn : be;
|
|
575
|
-
}
|
|
576
|
-
function ve(e, t, n) {
|
|
577
|
-
if (e.blockType === "start")
|
|
578
|
-
return Ce + (e.provides && e.provides.length > 0 ? 8 + jo : 0);
|
|
579
|
-
if (e.blockType === "command") {
|
|
580
|
-
const r = Ee(e, t, n);
|
|
581
|
-
if (r.length === 0) return Dn;
|
|
582
|
-
const o = r[r.length - 1];
|
|
583
|
-
return o.y + o.h + Fo;
|
|
608
|
+
const i = Ze(e, t, n);
|
|
609
|
+
if (i.length > 0) {
|
|
610
|
+
const c = i[i.length - 1];
|
|
611
|
+
o = Math.max(o, c.x + c.w + lt);
|
|
584
612
|
}
|
|
585
|
-
|
|
613
|
+
const s = e.blockType === "start" ? 140 : 110;
|
|
614
|
+
return Math.max(s, o);
|
|
615
|
+
}
|
|
616
|
+
function We(e) {
|
|
617
|
+
return e.blockType === "start" ? De : e.blockType === "command" ? qn : we;
|
|
618
|
+
}
|
|
619
|
+
function Ce(e, t, n) {
|
|
620
|
+
return e.blockType === "start" ? De + (e.provides && e.provides.length > 0 ? 8 + pr : 0) : e.blockType === "command" ? kr(e) ? eo(e, t, n) + wr(e, t) : qn : we;
|
|
621
|
+
}
|
|
622
|
+
function eo(e, t, n) {
|
|
623
|
+
const o = Ae(e, t, n);
|
|
624
|
+
if (o.length === 0) return We(e);
|
|
625
|
+
const r = o[o.length - 1];
|
|
626
|
+
return r.y + r.h;
|
|
627
|
+
}
|
|
628
|
+
function wr(e, t) {
|
|
629
|
+
return e.params.some((n, o) => Zt(e, n, t?.[o])) ? Un : ur;
|
|
630
|
+
}
|
|
631
|
+
function Ze(e, t, n) {
|
|
632
|
+
const o = e.params.map((s, c) => ({ param: s, index: c })).filter(({ param: s, index: c }) => Zt(e, s, t?.[c]));
|
|
633
|
+
if (o.length === 0) return [];
|
|
634
|
+
const r = eo(e, t, n) + (Un - Wt) / 2;
|
|
635
|
+
let i = fr;
|
|
636
|
+
return o.map(({ param: s, index: c }) => {
|
|
637
|
+
const p = { index: c, name: s.name, x: i, y: r, w: Qn(s.name), h: Wt };
|
|
638
|
+
return i += p.w + hr, p;
|
|
639
|
+
});
|
|
586
640
|
}
|
|
587
|
-
function
|
|
588
|
-
const n =
|
|
589
|
-
return n ?
|
|
641
|
+
function en(e, t) {
|
|
642
|
+
const n = N(e.definitionId);
|
|
643
|
+
return n ? Ce(n, e.paramSlots, t) : je;
|
|
590
644
|
}
|
|
591
|
-
function
|
|
645
|
+
function to(e, t) {
|
|
592
646
|
let n = 0;
|
|
593
|
-
const
|
|
594
|
-
let
|
|
595
|
-
for (;
|
|
596
|
-
|
|
597
|
-
const i = t.get(
|
|
647
|
+
const o = /* @__PURE__ */ new Set();
|
|
648
|
+
let r = e;
|
|
649
|
+
for (; r && !o.has(r); ) {
|
|
650
|
+
o.add(r);
|
|
651
|
+
const i = t.get(r);
|
|
598
652
|
if (!i) break;
|
|
599
|
-
n +=
|
|
653
|
+
n += en(i, t), r = i.nextBlockId;
|
|
600
654
|
}
|
|
601
655
|
return n;
|
|
602
656
|
}
|
|
603
|
-
function
|
|
604
|
-
const
|
|
605
|
-
let
|
|
606
|
-
return e.params.forEach((
|
|
607
|
-
if (!
|
|
608
|
-
let
|
|
609
|
-
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
}),
|
|
613
|
-
}
|
|
614
|
-
function
|
|
615
|
-
|
|
616
|
-
|
|
657
|
+
function Ae(e, t, n) {
|
|
658
|
+
const o = [], r = e.params.findIndex((s) => xe(e, s));
|
|
659
|
+
let i = We(e);
|
|
660
|
+
return e.params.forEach((s, c) => {
|
|
661
|
+
if (!xe(e, s) || Zt(e, s, t?.[c])) return;
|
|
662
|
+
let p = null;
|
|
663
|
+
c !== r && (p = i, i += Ke);
|
|
664
|
+
const y = t?.[c]?.commandBlockId, x = y && n ? to(y, n) : 0, k = Math.max(dr, x);
|
|
665
|
+
o.push({ index: c, name: s.name, x: Gt, y: i, h: k, dividerY: p, optional: !!s.optional }), i += k;
|
|
666
|
+
}), o;
|
|
667
|
+
}
|
|
668
|
+
function Br(e, t, n) {
|
|
669
|
+
return [
|
|
670
|
+
...Ae(e, t, n).map((o) => ({ slot: o.index, x: o.x, y: o.y })),
|
|
671
|
+
...Ze(e, t, n).map((o) => ({ slot: o.index, x: o.x, y: o.y }))
|
|
672
|
+
];
|
|
673
|
+
}
|
|
674
|
+
function Cr(e, t) {
|
|
675
|
+
const n = e.dividerY ?? e.y - Ke;
|
|
676
|
+
return { x: t - Vn / 2 - 4, y: n + Ke / 2 };
|
|
677
|
+
}
|
|
678
|
+
function Je(e, t, n) {
|
|
679
|
+
const o = We(e), r = [];
|
|
680
|
+
let i = Ht + Xn(e).length * zt;
|
|
617
681
|
for (let s = 0; s < e.params.length; s++) {
|
|
618
682
|
const c = e.params[s];
|
|
619
|
-
if (
|
|
620
|
-
const p =
|
|
621
|
-
i +=
|
|
683
|
+
if (xe(e, c)) continue;
|
|
684
|
+
const p = jn(c, t?.[s]), y = Gn(c, t?.[s], n), x = p ? Wt : mt(c.type).h;
|
|
685
|
+
i += Fn, r.push({ x: i, y: (o - x) / 2, w: y, h: x, type: c.type, index: s, collapsed: p }), i += y;
|
|
622
686
|
}
|
|
623
|
-
return
|
|
687
|
+
return r;
|
|
624
688
|
}
|
|
625
|
-
function
|
|
689
|
+
function Tr(e) {
|
|
626
690
|
const t = /* @__PURE__ */ new Map();
|
|
627
|
-
function n(
|
|
628
|
-
const s = e.get(
|
|
629
|
-
if (!s || t.has(
|
|
630
|
-
t.set(
|
|
631
|
-
const c =
|
|
691
|
+
function n(o, r, i) {
|
|
692
|
+
const s = e.get(o);
|
|
693
|
+
if (!s || t.has(o)) return;
|
|
694
|
+
t.set(o, { x: r, y: i });
|
|
695
|
+
const c = N(s.definitionId);
|
|
632
696
|
if (c) {
|
|
633
|
-
for (const p of
|
|
634
|
-
const
|
|
635
|
-
|
|
697
|
+
for (const p of Je(c, s.paramSlots, e)) {
|
|
698
|
+
const y = s.paramSlots[p.index]?.queryBlockId;
|
|
699
|
+
y && n(y, r + p.x, i + p.y);
|
|
636
700
|
}
|
|
637
|
-
for (const p of
|
|
638
|
-
const
|
|
639
|
-
|
|
701
|
+
for (const p of Ae(c, s.paramSlots, e)) {
|
|
702
|
+
const y = s.paramSlots[p.index]?.commandBlockId;
|
|
703
|
+
y && n(y, r + p.x, i + p.y);
|
|
640
704
|
}
|
|
641
705
|
}
|
|
642
|
-
s.nextBlockId && n(s.nextBlockId,
|
|
706
|
+
s.nextBlockId && n(s.nextBlockId, r, i + en(s, e));
|
|
643
707
|
}
|
|
644
|
-
return e.forEach((
|
|
645
|
-
!
|
|
708
|
+
return e.forEach((o) => {
|
|
709
|
+
!o.parentBlockId && !o.embeddedInBlockId && n(o.instanceId, o.x, o.y);
|
|
646
710
|
}), t;
|
|
647
711
|
}
|
|
648
|
-
function
|
|
712
|
+
function Pr(e, t) {
|
|
649
713
|
const n = /* @__PURE__ */ new Set();
|
|
650
|
-
function
|
|
714
|
+
function o(s) {
|
|
651
715
|
const c = [];
|
|
652
716
|
let p = s ?? null;
|
|
653
717
|
for (; p && !n.has(p); ) {
|
|
654
|
-
const
|
|
655
|
-
if (!
|
|
656
|
-
c.push(
|
|
718
|
+
const y = e.blocks.get(p);
|
|
719
|
+
if (!y) break;
|
|
720
|
+
c.push(r(y)), p = y.nextBlockId;
|
|
657
721
|
}
|
|
658
722
|
return c;
|
|
659
723
|
}
|
|
660
|
-
function
|
|
724
|
+
function r(s) {
|
|
661
725
|
n.add(s.instanceId);
|
|
662
|
-
const c = t(s.definitionId), p = s.paramSlots.map((
|
|
663
|
-
const
|
|
664
|
-
let
|
|
665
|
-
return c &&
|
|
726
|
+
const c = t(s.definitionId), p = s.paramSlots.map((y, x) => {
|
|
727
|
+
const k = c?.params[x] ?? { name: `param${x}`, type: "string" }, L = y.queryBlockId ? e.blocks.get(y.queryBlockId) : void 0;
|
|
728
|
+
let T;
|
|
729
|
+
return c && xe(c, k) ? T = { kind: "body", body: o(y.commandBlockId) } : L ? T = { kind: "query", node: r(L) } : y.textValue !== null && y.textValue !== void 0 && y.textValue !== "" ? T = { kind: "text", text: y.textValue } : T = { kind: "empty" }, { name: k.name, type: k.type, value: T };
|
|
666
730
|
});
|
|
667
731
|
return {
|
|
668
732
|
definitionId: s.definitionId,
|
|
@@ -672,7 +736,7 @@ function rr(e, t) {
|
|
|
672
736
|
};
|
|
673
737
|
}
|
|
674
738
|
return {
|
|
675
|
-
roots: [...e.blocks.values()].filter((s) => !s.parentBlockId && !s.embeddedInBlockId).sort((s, c) => s.y - c.y || s.x - c.x || (s.instanceId < c.instanceId ? -1 : s.instanceId > c.instanceId ? 1 : 0)).map((s) => ({ position: { x: s.x, y: s.y }, body:
|
|
739
|
+
roots: [...e.blocks.values()].filter((s) => !s.parentBlockId && !s.embeddedInBlockId).sort((s, c) => s.y - c.y || s.x - c.x || (s.instanceId < c.instanceId ? -1 : s.instanceId > c.instanceId ? 1 : 0)).map((s) => ({ position: { x: s.x, y: s.y }, body: o(s.instanceId) }))
|
|
676
740
|
};
|
|
677
741
|
}
|
|
678
742
|
const Xe = {
|
|
@@ -730,7 +794,7 @@ const Xe = {
|
|
|
730
794
|
switcherText: "#5a6888",
|
|
731
795
|
switcherActiveText: "#c9a43a",
|
|
732
796
|
switcherBorder: "#252d42"
|
|
733
|
-
},
|
|
797
|
+
}, Er = {
|
|
734
798
|
id: "light",
|
|
735
799
|
label: "Light",
|
|
736
800
|
appBg: "#f0f2f6",
|
|
@@ -773,64 +837,64 @@ const Xe = {
|
|
|
773
837
|
switcherText: "#9090a0",
|
|
774
838
|
switcherActiveText: "#1a2030",
|
|
775
839
|
switcherBorder: "#dde2ec"
|
|
776
|
-
},
|
|
777
|
-
function
|
|
778
|
-
return
|
|
840
|
+
}, at = [Xe, Er], dt = _o(Xe);
|
|
841
|
+
function Q() {
|
|
842
|
+
return Ao(dt);
|
|
779
843
|
}
|
|
780
|
-
const
|
|
781
|
-
function
|
|
844
|
+
const K = 16, Se = 14, Pe = K + Se / 2, Ee = 5, O = 4;
|
|
845
|
+
function Mr(e, t) {
|
|
782
846
|
return [
|
|
783
|
-
`M ${
|
|
847
|
+
`M ${O} 0`,
|
|
784
848
|
// Top edge with inlet (triangle dips into the block)
|
|
785
|
-
`H ${
|
|
786
|
-
`H ${e -
|
|
787
|
-
`V ${t -
|
|
849
|
+
`H ${K} L ${Pe} ${Ee} L ${K + Se} 0`,
|
|
850
|
+
`H ${e - O} Q ${e} 0 ${e} ${O}`,
|
|
851
|
+
`V ${t - O} Q ${e} ${t} ${e - O} ${t}`,
|
|
788
852
|
// Bottom edge with outlet (triangle protrudes below)
|
|
789
|
-
`H ${
|
|
790
|
-
`H ${
|
|
791
|
-
`V ${
|
|
853
|
+
`H ${K + Se} L ${Pe} ${t + Ee} L ${K} ${t}`,
|
|
854
|
+
`H ${O} Q 0 ${t} 0 ${t - O}`,
|
|
855
|
+
`V ${O} Q 0 0 ${O} 0 Z`
|
|
792
856
|
].join(" ");
|
|
793
857
|
}
|
|
794
|
-
function
|
|
795
|
-
const
|
|
796
|
-
`M ${
|
|
858
|
+
function Dr(e, t, n, o) {
|
|
859
|
+
const r = [
|
|
860
|
+
`M ${O} 0`,
|
|
797
861
|
// Top edge with inlet
|
|
798
|
-
`H ${
|
|
799
|
-
`H ${e -
|
|
862
|
+
`H ${K} L ${Pe} ${Ee} L ${K + Se} 0`,
|
|
863
|
+
`H ${e - O} Q ${e} 0 ${e} ${O}`
|
|
800
864
|
];
|
|
801
|
-
for (const i of
|
|
865
|
+
for (const i of o) {
|
|
802
866
|
const s = i.y, c = i.y + i.h;
|
|
803
|
-
|
|
867
|
+
r.push(
|
|
804
868
|
// Right edge down to the mouth, then its roof leftwards with an outlet tab into the mouth
|
|
805
869
|
`V ${s}`,
|
|
806
|
-
`H ${n +
|
|
870
|
+
`H ${n + K + Se} L ${n + Pe} ${s + Ee} L ${n + K} ${s}`,
|
|
807
871
|
`H ${n}`,
|
|
808
872
|
// Inner wall, then the floor rightwards with an inlet for the chain's last tab
|
|
809
873
|
`V ${c}`,
|
|
810
|
-
`H ${n +
|
|
874
|
+
`H ${n + K} L ${n + Pe} ${c + Ee} L ${n + K + Se} ${c}`,
|
|
811
875
|
`H ${e}`
|
|
812
876
|
);
|
|
813
877
|
}
|
|
814
|
-
return
|
|
815
|
-
`V ${t -
|
|
878
|
+
return r.push(
|
|
879
|
+
`V ${t - O} Q ${e} ${t} ${e - O} ${t}`,
|
|
816
880
|
// Bottom edge with outlet
|
|
817
|
-
`H ${
|
|
818
|
-
`H ${
|
|
819
|
-
`V ${
|
|
820
|
-
),
|
|
881
|
+
`H ${K + Se} L ${Pe} ${t + Ee} L ${K} ${t}`,
|
|
882
|
+
`H ${O} Q 0 ${t} 0 ${t - O}`,
|
|
883
|
+
`V ${O} Q 0 0 ${O} 0 Z`
|
|
884
|
+
), r.join(" ");
|
|
821
885
|
}
|
|
822
|
-
function
|
|
886
|
+
function _r(e, t) {
|
|
823
887
|
return [
|
|
824
888
|
"M 0 10 Q 0 0 10 0",
|
|
825
889
|
`H ${e - 10} Q ${e} 0 ${e} 10`,
|
|
826
|
-
`V ${t -
|
|
890
|
+
`V ${t - O} Q ${e} ${t} ${e - O} ${t}`,
|
|
827
891
|
// Bottom outlet only — start blocks have no inlet
|
|
828
|
-
`H ${
|
|
829
|
-
`H ${
|
|
892
|
+
`H ${K + Se} L ${Pe} ${t + Ee} L ${K} ${t}`,
|
|
893
|
+
`H ${O} Q 0 ${t} 0 ${t - O}`,
|
|
830
894
|
"V 10 Z"
|
|
831
895
|
].join(" ");
|
|
832
896
|
}
|
|
833
|
-
function
|
|
897
|
+
function Ar(e, t) {
|
|
834
898
|
const n = t / 2;
|
|
835
899
|
return [
|
|
836
900
|
`M ${n} 0 H ${e - n}`,
|
|
@@ -838,7 +902,7 @@ function ar(e, t) {
|
|
|
838
902
|
`H ${n} A ${n} ${n} 0 0 1 ${n} 0 Z`
|
|
839
903
|
].join(" ");
|
|
840
904
|
}
|
|
841
|
-
function
|
|
905
|
+
function Or(e, t) {
|
|
842
906
|
const n = t / 2;
|
|
843
907
|
return [
|
|
844
908
|
`M ${n} 0 H ${e - n}`,
|
|
@@ -846,7 +910,7 @@ function dr(e, t) {
|
|
|
846
910
|
`H ${n} L 0 ${t / 2} Z`
|
|
847
911
|
].join(" ");
|
|
848
912
|
}
|
|
849
|
-
function
|
|
913
|
+
function no(e, t, n) {
|
|
850
914
|
return [
|
|
851
915
|
`M ${n} 0 H ${e - n} Q ${e} 0 ${e} ${n}`,
|
|
852
916
|
`V ${t - n} Q ${e} ${t} ${e - n} ${t}`,
|
|
@@ -854,49 +918,49 @@ function Wn(e, t, n) {
|
|
|
854
918
|
`V ${n} Q 0 0 ${n} 0 Z`
|
|
855
919
|
].join(" ");
|
|
856
920
|
}
|
|
857
|
-
function
|
|
858
|
-
return
|
|
921
|
+
function Lr(e, t) {
|
|
922
|
+
return no(e, t, 5);
|
|
859
923
|
}
|
|
860
|
-
function
|
|
861
|
-
return
|
|
924
|
+
function Nr(e, t) {
|
|
925
|
+
return no(e, t, 9);
|
|
862
926
|
}
|
|
863
|
-
function
|
|
927
|
+
function tn(e, t, n) {
|
|
864
928
|
switch (e) {
|
|
865
929
|
case "number":
|
|
866
|
-
return
|
|
930
|
+
return Ar(t, n);
|
|
867
931
|
case "boolean":
|
|
868
|
-
return
|
|
932
|
+
return Or(t, n);
|
|
869
933
|
case "string":
|
|
870
|
-
return
|
|
934
|
+
return Lr(t, n);
|
|
871
935
|
default:
|
|
872
|
-
return
|
|
936
|
+
return Nr(t, n);
|
|
873
937
|
}
|
|
874
938
|
}
|
|
875
|
-
function
|
|
876
|
-
return
|
|
877
|
-
}
|
|
878
|
-
function
|
|
879
|
-
const
|
|
880
|
-
if (e.blockType === "start") return
|
|
881
|
-
if (e.blockType === "query") return
|
|
882
|
-
const i =
|
|
883
|
-
return i.length > 0 ?
|
|
884
|
-
}
|
|
885
|
-
function
|
|
886
|
-
const s =
|
|
887
|
-
function
|
|
888
|
-
const
|
|
889
|
-
if (!
|
|
890
|
-
const
|
|
891
|
-
n([...t, { publisher:
|
|
939
|
+
function nn(e, t, n) {
|
|
940
|
+
return tn(e, t, n);
|
|
941
|
+
}
|
|
942
|
+
function on(e, t, n) {
|
|
943
|
+
const o = fe(e, t, n), r = Ce(e, t, n);
|
|
944
|
+
if (e.blockType === "start") return _r(o, r);
|
|
945
|
+
if (e.blockType === "query") return tn(e.returnType, o, r);
|
|
946
|
+
const i = Ae(e, t, n);
|
|
947
|
+
return i.length > 0 ? Dr(o, r, Gt, i) : Mr(o, r);
|
|
948
|
+
}
|
|
949
|
+
function Rr({ available: e, dependencies: t, onChange: n, actions: o, blockCounts: r, conflictCounts: i }) {
|
|
950
|
+
const s = Q(), [c, p] = B(""), [y, x] = B(""), [k, L] = B(!1), [T, W] = B(null), z = new Map(e.map((b) => [te(b), b])), Y = new Set(t.map(te)), q = e.filter((b) => !Y.has(te(b)));
|
|
951
|
+
function S() {
|
|
952
|
+
const b = z.get(c);
|
|
953
|
+
if (!b) return;
|
|
954
|
+
const U = k && y.trim() ? y.trim() : b.version;
|
|
955
|
+
n([...t, { publisher: b.publisher, name: b.name, version: U }]), p(""), x("");
|
|
892
956
|
}
|
|
893
|
-
function
|
|
894
|
-
n(t.filter((
|
|
957
|
+
function g(b) {
|
|
958
|
+
n(t.filter((U) => te(U) !== b)), W(null);
|
|
895
959
|
}
|
|
896
|
-
function
|
|
897
|
-
n(t.map((
|
|
960
|
+
function ne(b, U) {
|
|
961
|
+
n(t.map((F) => te(F) === b ? { ...F, version: U } : F));
|
|
898
962
|
}
|
|
899
|
-
const
|
|
963
|
+
const G = {
|
|
900
964
|
background: s.inputBg,
|
|
901
965
|
color: s.textPrimary,
|
|
902
966
|
border: `1px solid ${s.inputBorder}`,
|
|
@@ -905,7 +969,7 @@ function hr({ available: e, dependencies: t, onChange: n, actions: r, blockCount
|
|
|
905
969
|
padding: "4px 6px",
|
|
906
970
|
outline: "none",
|
|
907
971
|
minWidth: 0
|
|
908
|
-
},
|
|
972
|
+
}, oe = {
|
|
909
973
|
background: "none",
|
|
910
974
|
color: s.textSecondary,
|
|
911
975
|
border: `1px solid ${s.border}`,
|
|
@@ -913,10 +977,10 @@ function hr({ available: e, dependencies: t, onChange: n, actions: r, blockCount
|
|
|
913
977
|
fontSize: 11,
|
|
914
978
|
padding: "4px 8px",
|
|
915
979
|
cursor: "pointer"
|
|
916
|
-
},
|
|
917
|
-
return /* @__PURE__ */
|
|
980
|
+
}, Z = T ? r.get(T) ?? 0 : 0;
|
|
981
|
+
return /* @__PURE__ */ m("div", { style: { flex: 1, overflowY: "auto", padding: 10, display: "flex", flexDirection: "column", gap: 6 }, children: [
|
|
918
982
|
t.length === 0 && /* @__PURE__ */ l("div", { style: { color: s.textMuted, fontSize: 11, fontStyle: "italic" }, children: "No packages yet — add one to get blocks." }),
|
|
919
|
-
|
|
983
|
+
T && /* @__PURE__ */ m("div", { style: {
|
|
920
984
|
border: `1px solid ${s.deleteActiveBorder}`,
|
|
921
985
|
background: s.deleteActiveBg,
|
|
922
986
|
borderRadius: 4,
|
|
@@ -925,54 +989,54 @@ function hr({ available: e, dependencies: t, onChange: n, actions: r, blockCount
|
|
|
925
989
|
color: s.textPrimary
|
|
926
990
|
}, children: [
|
|
927
991
|
"Remove ",
|
|
928
|
-
/* @__PURE__ */ l("b", { children:
|
|
992
|
+
/* @__PURE__ */ l("b", { children: T }),
|
|
929
993
|
"?",
|
|
930
994
|
" ",
|
|
931
|
-
|
|
932
|
-
/* @__PURE__ */
|
|
995
|
+
Z > 0 ? `Its ${Z} block${Z === 1 ? "" : "s"} on the canvas ${Z === 1 ? "is" : "are"} deleted.` : "None of its blocks are on the canvas.",
|
|
996
|
+
/* @__PURE__ */ m("div", { style: { display: "flex", gap: 6, marginTop: 6 }, children: [
|
|
933
997
|
/* @__PURE__ */ l(
|
|
934
998
|
"button",
|
|
935
999
|
{
|
|
936
1000
|
type: "button",
|
|
937
|
-
onClick: () =>
|
|
938
|
-
style: { ...
|
|
1001
|
+
onClick: () => g(T),
|
|
1002
|
+
style: { ...oe, background: s.deleteActiveBorder, color: "white", borderColor: s.deleteActiveBorder },
|
|
939
1003
|
children: "Remove"
|
|
940
1004
|
}
|
|
941
1005
|
),
|
|
942
|
-
/* @__PURE__ */ l("button", { type: "button", onClick: () => W(null), style:
|
|
1006
|
+
/* @__PURE__ */ l("button", { type: "button", onClick: () => W(null), style: oe, children: "Cancel" })
|
|
943
1007
|
] })
|
|
944
1008
|
] }),
|
|
945
|
-
t.map((
|
|
946
|
-
const
|
|
947
|
-
return /* @__PURE__ */
|
|
948
|
-
/* @__PURE__ */ l("span", { "aria-hidden": !0, style: { width: 9, height: 9, flexShrink: 0, background:
|
|
949
|
-
/* @__PURE__ */ l("span", { title:
|
|
1009
|
+
t.map((b) => {
|
|
1010
|
+
const U = te(b), F = z.get(U), H = F && No(F.version, b.version) > 0 ? F.version : null, he = i.get(U) ?? 0;
|
|
1011
|
+
return /* @__PURE__ */ m("div", { style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11 }, children: [
|
|
1012
|
+
/* @__PURE__ */ l("span", { "aria-hidden": !0, style: { width: 9, height: 9, flexShrink: 0, background: F?.color ?? s.border } }),
|
|
1013
|
+
/* @__PURE__ */ l("span", { title: F?.description, style: {
|
|
950
1014
|
color: s.textPrimary,
|
|
951
1015
|
overflow: "hidden",
|
|
952
1016
|
textOverflow: "ellipsis",
|
|
953
1017
|
whiteSpace: "nowrap"
|
|
954
|
-
}, children:
|
|
955
|
-
/* @__PURE__ */ l("span", { style: { color: s.textMuted, fontVariantNumeric: "tabular-nums" }, children:
|
|
956
|
-
|
|
1018
|
+
}, children: U }),
|
|
1019
|
+
/* @__PURE__ */ l("span", { style: { color: s.textMuted, fontVariantNumeric: "tabular-nums" }, children: b.version }),
|
|
1020
|
+
he > 0 && /* @__PURE__ */ m(
|
|
957
1021
|
"span",
|
|
958
1022
|
{
|
|
959
|
-
title: `${
|
|
1023
|
+
title: `${he} block ID(s) skipped: another package already defines them`,
|
|
960
1024
|
style: { fontSize: 9, color: s.accent, border: `1px solid ${s.accent}`, borderRadius: 3, padding: "0 3px" },
|
|
961
1025
|
children: [
|
|
962
1026
|
"⚠ ",
|
|
963
|
-
|
|
1027
|
+
he
|
|
964
1028
|
]
|
|
965
1029
|
}
|
|
966
1030
|
),
|
|
967
|
-
|
|
1031
|
+
H && /* @__PURE__ */ m(
|
|
968
1032
|
"button",
|
|
969
1033
|
{
|
|
970
1034
|
type: "button",
|
|
971
|
-
onClick: () =>
|
|
972
|
-
title: `Version ${
|
|
973
|
-
style: { ...
|
|
1035
|
+
onClick: () => ne(U, H),
|
|
1036
|
+
title: `Version ${H} is available. Click to update.`,
|
|
1037
|
+
style: { ...oe, padding: "0 5px", fontSize: 10, color: s.accent, borderColor: s.accent },
|
|
974
1038
|
children: [
|
|
975
|
-
|
|
1039
|
+
H,
|
|
976
1040
|
" available"
|
|
977
1041
|
]
|
|
978
1042
|
}
|
|
@@ -981,88 +1045,158 @@ function hr({ available: e, dependencies: t, onChange: n, actions: r, blockCount
|
|
|
981
1045
|
"button",
|
|
982
1046
|
{
|
|
983
1047
|
type: "button",
|
|
984
|
-
onClick: () => W(
|
|
1048
|
+
onClick: () => W(U),
|
|
985
1049
|
title: "Remove package",
|
|
986
1050
|
style: { marginLeft: "auto", background: "none", border: "none", color: s.textMuted, fontSize: 15, lineHeight: 1, cursor: "pointer" },
|
|
987
1051
|
children: "×"
|
|
988
1052
|
}
|
|
989
1053
|
)
|
|
990
|
-
] },
|
|
1054
|
+
] }, U);
|
|
991
1055
|
}),
|
|
992
|
-
/* @__PURE__ */
|
|
993
|
-
/* @__PURE__ */
|
|
994
|
-
/* @__PURE__ */ l("option", { value: "", children:
|
|
995
|
-
|
|
996
|
-
|
|
1056
|
+
/* @__PURE__ */ m("div", { style: { display: "flex", gap: 6, marginTop: 4 }, children: [
|
|
1057
|
+
/* @__PURE__ */ m("select", { value: c, onChange: (b) => p(b.target.value), style: { ...G, flex: 1 }, children: [
|
|
1058
|
+
/* @__PURE__ */ l("option", { value: "", children: q.length ? "Add package…" : "No more packages" }),
|
|
1059
|
+
q.map((b) => /* @__PURE__ */ m("option", { value: te(b), children: [
|
|
1060
|
+
te(b),
|
|
997
1061
|
" ",
|
|
998
|
-
|
|
999
|
-
] },
|
|
1062
|
+
b.version
|
|
1063
|
+
] }, te(b)))
|
|
1000
1064
|
] }),
|
|
1001
|
-
|
|
1065
|
+
k && /* @__PURE__ */ l(
|
|
1002
1066
|
"input",
|
|
1003
1067
|
{
|
|
1004
|
-
value:
|
|
1005
|
-
onChange: (
|
|
1006
|
-
placeholder:
|
|
1007
|
-
style: { ...
|
|
1068
|
+
value: y,
|
|
1069
|
+
onChange: (b) => x(b.target.value),
|
|
1070
|
+
placeholder: z.get(c)?.version ?? "version",
|
|
1071
|
+
style: { ...G, width: 64 }
|
|
1008
1072
|
}
|
|
1009
1073
|
),
|
|
1010
1074
|
/* @__PURE__ */ l(
|
|
1011
1075
|
"button",
|
|
1012
1076
|
{
|
|
1013
1077
|
type: "button",
|
|
1014
|
-
onClick:
|
|
1078
|
+
onClick: S,
|
|
1015
1079
|
disabled: !c,
|
|
1016
|
-
style: { ...
|
|
1080
|
+
style: { ...oe, opacity: c ? 1 : 0.4, cursor: c ? "pointer" : "default" },
|
|
1017
1081
|
children: "Add"
|
|
1018
1082
|
}
|
|
1019
1083
|
)
|
|
1020
1084
|
] }),
|
|
1021
|
-
|
|
1085
|
+
o && o.length > 0 && /* @__PURE__ */ l("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, children: o.map((b) => /* @__PURE__ */ l("button", { type: "button", onClick: () => Lo(b, t, n), title: b.title, style: oe, children: b.label }, b.label)) }),
|
|
1022
1086
|
/* @__PURE__ */ l(
|
|
1023
1087
|
"button",
|
|
1024
1088
|
{
|
|
1025
1089
|
type: "button",
|
|
1026
|
-
onClick: () =>
|
|
1090
|
+
onClick: () => L((b) => !b),
|
|
1027
1091
|
style: { alignSelf: "flex-start", background: "none", border: "none", padding: 0, color: s.textMuted, fontSize: 10, cursor: "pointer" },
|
|
1028
|
-
children:
|
|
1092
|
+
children: k ? "Hide version choice" : "Choose a specific version…"
|
|
1093
|
+
}
|
|
1094
|
+
)
|
|
1095
|
+
] });
|
|
1096
|
+
}
|
|
1097
|
+
function rn({ name: e, w: t, h: n }) {
|
|
1098
|
+
const o = Q();
|
|
1099
|
+
return /* @__PURE__ */ m(bt, { children: [
|
|
1100
|
+
/* @__PURE__ */ l(
|
|
1101
|
+
"rect",
|
|
1102
|
+
{
|
|
1103
|
+
x: 0.5,
|
|
1104
|
+
y: 0.5,
|
|
1105
|
+
width: t - 1,
|
|
1106
|
+
height: n - 1,
|
|
1107
|
+
rx: (n - 1) / 2,
|
|
1108
|
+
fill: "transparent",
|
|
1109
|
+
stroke: o.textMuted,
|
|
1110
|
+
strokeWidth: 1,
|
|
1111
|
+
strokeDasharray: "3,2"
|
|
1112
|
+
}
|
|
1113
|
+
),
|
|
1114
|
+
/* @__PURE__ */ l(
|
|
1115
|
+
"text",
|
|
1116
|
+
{
|
|
1117
|
+
x: t / 2,
|
|
1118
|
+
y: n / 2 + 3,
|
|
1119
|
+
textAnchor: "middle",
|
|
1120
|
+
fill: o.textMuted,
|
|
1121
|
+
fontSize: 9,
|
|
1122
|
+
fontFamily: "sans-serif",
|
|
1123
|
+
style: { userSelect: "none", pointerEvents: "none" },
|
|
1124
|
+
children: Kn(e)
|
|
1029
1125
|
}
|
|
1030
1126
|
)
|
|
1031
1127
|
] });
|
|
1032
1128
|
}
|
|
1033
|
-
const
|
|
1034
|
-
function
|
|
1035
|
-
const
|
|
1036
|
-
return /* @__PURE__ */
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1129
|
+
const Hr = 5;
|
|
1130
|
+
function Cn({ w: e, title: t, onRemove: n }) {
|
|
1131
|
+
const o = Q();
|
|
1132
|
+
return /* @__PURE__ */ m(
|
|
1133
|
+
"g",
|
|
1134
|
+
{
|
|
1135
|
+
transform: `translate(${e - 2},-1)`,
|
|
1136
|
+
onPointerDown: (r) => r.stopPropagation(),
|
|
1137
|
+
onClick: (r) => {
|
|
1138
|
+
r.stopPropagation(), n();
|
|
1139
|
+
},
|
|
1140
|
+
style: { cursor: "pointer" },
|
|
1141
|
+
children: [
|
|
1142
|
+
/* @__PURE__ */ l("title", { children: t }),
|
|
1143
|
+
/* @__PURE__ */ l("circle", { r: Hr, fill: o.blockBody, stroke: o.textMuted, strokeWidth: 1 }),
|
|
1144
|
+
/* @__PURE__ */ l("path", { d: "M -2 -2 L 2 2 M 2 -2 L -2 2", stroke: o.blockText, strokeWidth: 1.2, strokeLinecap: "round" })
|
|
1145
|
+
]
|
|
1146
|
+
}
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
function sn({ chips: e, onOpen: t }) {
|
|
1150
|
+
return /* @__PURE__ */ l(bt, { children: e.map((n) => /* @__PURE__ */ m(
|
|
1151
|
+
"g",
|
|
1152
|
+
{
|
|
1153
|
+
transform: `translate(${n.x},${n.y})`,
|
|
1154
|
+
onPointerDown: t ? (o) => o.stopPropagation() : void 0,
|
|
1155
|
+
onClick: t ? (o) => {
|
|
1156
|
+
o.stopPropagation(), t(n.index);
|
|
1157
|
+
} : void 0,
|
|
1158
|
+
style: { cursor: t ? "pointer" : void 0 },
|
|
1159
|
+
children: [
|
|
1160
|
+
/* @__PURE__ */ l("title", { children: `${xt(n.name, gt)} (optional)${t ? ": click to add it, or drop commands here" : ""}` }),
|
|
1161
|
+
/* @__PURE__ */ l(rn, { name: n.name, w: n.w, h: n.h })
|
|
1162
|
+
]
|
|
1163
|
+
},
|
|
1164
|
+
n.index
|
|
1165
|
+
)) });
|
|
1166
|
+
}
|
|
1167
|
+
const zr = "#c08820";
|
|
1168
|
+
function cn({ mouths: e, w: t, isEmpty: n }) {
|
|
1169
|
+
const o = Q();
|
|
1170
|
+
return /* @__PURE__ */ l("g", { style: { pointerEvents: "none" }, children: e.map((r) => /* @__PURE__ */ m("g", { children: [
|
|
1171
|
+
r.dividerY !== null && /* @__PURE__ */ m("g", { style: { pointerEvents: "all" }, children: [
|
|
1172
|
+
/* @__PURE__ */ l("title", { children: xt(r.name, gt) }),
|
|
1173
|
+
/* @__PURE__ */ l("rect", { x: 0, y: r.dividerY, width: t, height: Ke, fill: "transparent" }),
|
|
1040
1174
|
/* @__PURE__ */ l(
|
|
1041
1175
|
"text",
|
|
1042
1176
|
{
|
|
1043
1177
|
x: 11,
|
|
1044
|
-
y:
|
|
1045
|
-
fill:
|
|
1178
|
+
y: r.dividerY + Ke / 2 + 4,
|
|
1179
|
+
fill: o.blockText,
|
|
1046
1180
|
fontSize: 10,
|
|
1047
1181
|
fontWeight: "bold",
|
|
1048
1182
|
fontFamily: "sans-serif",
|
|
1049
1183
|
style: { userSelect: "none" },
|
|
1050
|
-
children:
|
|
1184
|
+
children: r.name
|
|
1051
1185
|
}
|
|
1052
1186
|
)
|
|
1053
1187
|
] }),
|
|
1054
|
-
n(
|
|
1055
|
-
/* @__PURE__ */ l("title", { children:
|
|
1188
|
+
n(r.index) && /* @__PURE__ */ m("g", { style: { pointerEvents: "all" }, children: [
|
|
1189
|
+
/* @__PURE__ */ l("title", { children: xt(r.name, gt) }),
|
|
1056
1190
|
/* @__PURE__ */ l(
|
|
1057
1191
|
"rect",
|
|
1058
1192
|
{
|
|
1059
|
-
x:
|
|
1060
|
-
y:
|
|
1061
|
-
width: Math.max(60,
|
|
1062
|
-
height:
|
|
1193
|
+
x: r.x + 3,
|
|
1194
|
+
y: r.y + 3,
|
|
1195
|
+
width: Math.max(60, r.name.length * 6 + 20),
|
|
1196
|
+
height: r.h - 6,
|
|
1063
1197
|
rx: 3,
|
|
1064
1198
|
fill: "transparent",
|
|
1065
|
-
stroke:
|
|
1199
|
+
stroke: zr,
|
|
1066
1200
|
strokeWidth: 1,
|
|
1067
1201
|
strokeDasharray: "4,3"
|
|
1068
1202
|
}
|
|
@@ -1070,100 +1204,48 @@ function Kt({ mouths: e, w: t, isEmpty: n }) {
|
|
|
1070
1204
|
/* @__PURE__ */ l(
|
|
1071
1205
|
"text",
|
|
1072
1206
|
{
|
|
1073
|
-
x:
|
|
1074
|
-
y:
|
|
1075
|
-
fill:
|
|
1207
|
+
x: r.x + 10,
|
|
1208
|
+
y: r.y + r.h / 2 + 3,
|
|
1209
|
+
fill: o.textMuted,
|
|
1076
1210
|
fontSize: 9,
|
|
1077
1211
|
fontFamily: "sans-serif",
|
|
1078
1212
|
fontStyle: "italic",
|
|
1079
1213
|
style: { userSelect: "none" },
|
|
1080
|
-
children:
|
|
1214
|
+
children: r.name
|
|
1081
1215
|
}
|
|
1082
1216
|
)
|
|
1083
1217
|
] })
|
|
1084
|
-
] },
|
|
1218
|
+
] }, r.index)) });
|
|
1085
1219
|
}
|
|
1086
|
-
function
|
|
1087
|
-
const
|
|
1220
|
+
function oo({ name: e, type: t, w: n, h: o }) {
|
|
1221
|
+
const r = Q();
|
|
1088
1222
|
return /* @__PURE__ */ l(
|
|
1089
1223
|
"text",
|
|
1090
1224
|
{
|
|
1091
1225
|
x: n / 2,
|
|
1092
|
-
y:
|
|
1226
|
+
y: o / 2 + 3,
|
|
1093
1227
|
textAnchor: "middle",
|
|
1094
|
-
fill:
|
|
1228
|
+
fill: r.textMuted,
|
|
1095
1229
|
fontSize: 9,
|
|
1096
1230
|
fontFamily: "sans-serif",
|
|
1097
1231
|
fontStyle: "italic",
|
|
1098
1232
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1099
|
-
children:
|
|
1100
|
-
}
|
|
1101
|
-
);
|
|
1102
|
-
}
|
|
1103
|
-
function Un({ name: e, w: t, h: n }) {
|
|
1104
|
-
const r = K();
|
|
1105
|
-
return /* @__PURE__ */ y(Rt, { children: [
|
|
1106
|
-
/* @__PURE__ */ l(
|
|
1107
|
-
"rect",
|
|
1108
|
-
{
|
|
1109
|
-
x: 0.5,
|
|
1110
|
-
y: 0.5,
|
|
1111
|
-
width: t - 1,
|
|
1112
|
-
height: n - 1,
|
|
1113
|
-
rx: (n - 1) / 2,
|
|
1114
|
-
fill: "transparent",
|
|
1115
|
-
stroke: r.textMuted,
|
|
1116
|
-
strokeWidth: 1,
|
|
1117
|
-
strokeDasharray: "3,2"
|
|
1118
|
-
}
|
|
1119
|
-
),
|
|
1120
|
-
/* @__PURE__ */ l(
|
|
1121
|
-
"text",
|
|
1122
|
-
{
|
|
1123
|
-
x: t / 2,
|
|
1124
|
-
y: n / 2 + 3,
|
|
1125
|
-
textAnchor: "middle",
|
|
1126
|
-
fill: r.textMuted,
|
|
1127
|
-
fontSize: 9,
|
|
1128
|
-
fontFamily: "sans-serif",
|
|
1129
|
-
style: { userSelect: "none", pointerEvents: "none" },
|
|
1130
|
-
children: Nn(e)
|
|
1131
|
-
}
|
|
1132
|
-
)
|
|
1133
|
-
] });
|
|
1134
|
-
}
|
|
1135
|
-
const gr = 5;
|
|
1136
|
-
function yr({ w: e, title: t, onRemove: n }) {
|
|
1137
|
-
const r = K();
|
|
1138
|
-
return /* @__PURE__ */ y(
|
|
1139
|
-
"g",
|
|
1140
|
-
{
|
|
1141
|
-
transform: `translate(${e - 2},-1)`,
|
|
1142
|
-
onPointerDown: (o) => o.stopPropagation(),
|
|
1143
|
-
onClick: (o) => {
|
|
1144
|
-
o.stopPropagation(), n();
|
|
1145
|
-
},
|
|
1146
|
-
style: { cursor: "pointer" },
|
|
1147
|
-
children: [
|
|
1148
|
-
/* @__PURE__ */ l("title", { children: t }),
|
|
1149
|
-
/* @__PURE__ */ l("circle", { r: gr, fill: r.blockBody, stroke: r.textMuted, strokeWidth: 1 }),
|
|
1150
|
-
/* @__PURE__ */ l("path", { d: "M -2 -2 L 2 2 M 2 -2 L -2 2", stroke: r.blockText, strokeWidth: 1.2, strokeLinecap: "round" })
|
|
1151
|
-
]
|
|
1233
|
+
children: $r(e, t, n)
|
|
1152
1234
|
}
|
|
1153
1235
|
);
|
|
1154
1236
|
}
|
|
1155
|
-
function
|
|
1156
|
-
const
|
|
1237
|
+
function ro({ def: e, onPointerDown: t, isPlaced: n }) {
|
|
1238
|
+
const o = Q(), r = fe(e), i = Ce(e), s = Je(e), c = Ae(e), p = Ze(e), y = `pal-${e.id}`, x = on(e);
|
|
1157
1239
|
return /* @__PURE__ */ l(
|
|
1158
1240
|
"div",
|
|
1159
1241
|
{
|
|
1160
1242
|
style: { marginBottom: 6, userSelect: "none", position: "relative", opacity: n ? 0.4 : 1 },
|
|
1161
|
-
onPointerDown: n ? void 0 : (
|
|
1243
|
+
onPointerDown: n ? void 0 : (k) => t(k, e.id),
|
|
1162
1244
|
title: n ? "Already on canvas — only one instance allowed" : void 0,
|
|
1163
|
-
children: /* @__PURE__ */
|
|
1164
|
-
/* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("clipPath", { id:
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */ l("path", { d:
|
|
1245
|
+
children: /* @__PURE__ */ m("svg", { width: r + 2, height: i + 8, style: { display: "block", cursor: n ? "not-allowed" : "grab", overflow: "visible" }, children: [
|
|
1246
|
+
/* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("clipPath", { id: y, children: /* @__PURE__ */ l("path", { d: x }) }) }),
|
|
1247
|
+
/* @__PURE__ */ m("g", { transform: "translate(1, 1)", children: [
|
|
1248
|
+
/* @__PURE__ */ l("path", { d: x, fill: o.blockBody, stroke: o.blockBorder, strokeWidth: 1.5 }),
|
|
1167
1249
|
/* @__PURE__ */ l(
|
|
1168
1250
|
"rect",
|
|
1169
1251
|
{
|
|
@@ -1172,81 +1254,82 @@ function Vn({ def: e, onPointerDown: t, isPlaced: n }) {
|
|
|
1172
1254
|
width: 4,
|
|
1173
1255
|
height: i + 20,
|
|
1174
1256
|
fill: e.color,
|
|
1175
|
-
clipPath: `url(#${
|
|
1257
|
+
clipPath: `url(#${y})`
|
|
1176
1258
|
}
|
|
1177
1259
|
),
|
|
1178
|
-
c.length > 0 && /* @__PURE__ */ l(
|
|
1179
|
-
/* @__PURE__ */
|
|
1260
|
+
c.length > 0 && /* @__PURE__ */ l(cn, { mouths: c, w: r, isEmpty: () => !0 }),
|
|
1261
|
+
/* @__PURE__ */ l(sn, { chips: p }),
|
|
1262
|
+
/* @__PURE__ */ m(
|
|
1180
1263
|
"text",
|
|
1181
1264
|
{
|
|
1182
1265
|
x: 11,
|
|
1183
|
-
y:
|
|
1184
|
-
fill:
|
|
1266
|
+
y: We(e) / 2 + 4,
|
|
1267
|
+
fill: o.blockText,
|
|
1185
1268
|
fontSize: 11,
|
|
1186
1269
|
fontWeight: "bold",
|
|
1187
1270
|
fontFamily: "sans-serif",
|
|
1188
1271
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1189
1272
|
children: [
|
|
1190
1273
|
e.name,
|
|
1191
|
-
e.blockType === "query" && e.returnType && /* @__PURE__ */ l("tspan", { fill:
|
|
1274
|
+
e.blockType === "query" && e.returnType && /* @__PURE__ */ l("tspan", { fill: o.textMuted, fontSize: 9, fontWeight: "normal", children: ` [${e.returnType}]` })
|
|
1192
1275
|
]
|
|
1193
1276
|
}
|
|
1194
1277
|
),
|
|
1195
1278
|
n && /* @__PURE__ */ l(
|
|
1196
1279
|
"text",
|
|
1197
1280
|
{
|
|
1198
|
-
x:
|
|
1281
|
+
x: r / 2,
|
|
1199
1282
|
y: i / 2 + 4,
|
|
1200
1283
|
textAnchor: "middle",
|
|
1201
|
-
fill:
|
|
1284
|
+
fill: o.textMuted,
|
|
1202
1285
|
fontSize: 9,
|
|
1203
1286
|
fontFamily: "sans-serif",
|
|
1204
1287
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1205
1288
|
children: "✓ on canvas"
|
|
1206
1289
|
}
|
|
1207
1290
|
),
|
|
1208
|
-
s.map((
|
|
1209
|
-
const
|
|
1210
|
-
return /* @__PURE__ */
|
|
1211
|
-
/* @__PURE__ */ l("title", { children:
|
|
1212
|
-
|
|
1291
|
+
s.map((k) => {
|
|
1292
|
+
const L = e.params[k.index];
|
|
1293
|
+
return /* @__PURE__ */ m("g", { transform: `translate(${k.x},${k.y})`, children: [
|
|
1294
|
+
/* @__PURE__ */ l("title", { children: Jn(L) }),
|
|
1295
|
+
k.collapsed ? /* @__PURE__ */ l(rn, { name: L.name, w: k.w, h: k.h }) : /* @__PURE__ */ m(bt, { children: [
|
|
1213
1296
|
/* @__PURE__ */ l(
|
|
1214
1297
|
"path",
|
|
1215
1298
|
{
|
|
1216
|
-
d:
|
|
1217
|
-
fill:
|
|
1218
|
-
stroke:
|
|
1299
|
+
d: nn(k.type, k.w, k.h),
|
|
1300
|
+
fill: o.socketBody,
|
|
1301
|
+
stroke: o.blockBorder,
|
|
1219
1302
|
strokeWidth: 1
|
|
1220
1303
|
}
|
|
1221
1304
|
),
|
|
1222
|
-
/* @__PURE__ */ l(
|
|
1305
|
+
/* @__PURE__ */ l(oo, { name: L.name, type: k.type, w: k.w, h: k.h })
|
|
1223
1306
|
] })
|
|
1224
|
-
] },
|
|
1307
|
+
] }, k.index);
|
|
1225
1308
|
}),
|
|
1226
|
-
e.blockType === "start" && e.provides && e.provides.length > 0 && /* @__PURE__ */
|
|
1309
|
+
e.blockType === "start" && e.provides && e.provides.length > 0 && /* @__PURE__ */ m("g", { children: [
|
|
1227
1310
|
/* @__PURE__ */ l(
|
|
1228
1311
|
"line",
|
|
1229
1312
|
{
|
|
1230
1313
|
x1: 8,
|
|
1231
|
-
y1:
|
|
1232
|
-
x2:
|
|
1233
|
-
y2:
|
|
1314
|
+
y1: De,
|
|
1315
|
+
x2: r - 8,
|
|
1316
|
+
y2: De,
|
|
1234
1317
|
stroke: "rgba(255,255,255,0.15)",
|
|
1235
1318
|
strokeWidth: 1
|
|
1236
1319
|
}
|
|
1237
1320
|
),
|
|
1238
|
-
|
|
1239
|
-
const
|
|
1240
|
-
return /* @__PURE__ */
|
|
1321
|
+
Jt(e).map((k) => {
|
|
1322
|
+
const T = N(k.id)?.color ?? e.color, W = k.w, z = Yn;
|
|
1323
|
+
return /* @__PURE__ */ m("g", { transform: `translate(${k.x}, ${k.y})`, children: [
|
|
1241
1324
|
/* @__PURE__ */ l(
|
|
1242
1325
|
"rect",
|
|
1243
1326
|
{
|
|
1244
1327
|
x: 0,
|
|
1245
1328
|
y: 0,
|
|
1246
|
-
width:
|
|
1247
|
-
height:
|
|
1329
|
+
width: W,
|
|
1330
|
+
height: z,
|
|
1248
1331
|
rx: 10,
|
|
1249
|
-
fill:
|
|
1332
|
+
fill: T,
|
|
1250
1333
|
opacity: 0.82,
|
|
1251
1334
|
stroke: "rgba(255,255,255,0.25)",
|
|
1252
1335
|
strokeWidth: 1
|
|
@@ -1255,18 +1338,18 @@ function Vn({ def: e, onPointerDown: t, isPlaced: n }) {
|
|
|
1255
1338
|
/* @__PURE__ */ l(
|
|
1256
1339
|
"text",
|
|
1257
1340
|
{
|
|
1258
|
-
x:
|
|
1259
|
-
y:
|
|
1341
|
+
x: W / 2,
|
|
1342
|
+
y: z / 2 + 3.5,
|
|
1260
1343
|
textAnchor: "middle",
|
|
1261
1344
|
fill: "white",
|
|
1262
1345
|
fontSize: 9.5,
|
|
1263
1346
|
fontFamily: "sans-serif",
|
|
1264
1347
|
fontWeight: "bold",
|
|
1265
1348
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1266
|
-
children:
|
|
1349
|
+
children: k.name
|
|
1267
1350
|
}
|
|
1268
1351
|
)
|
|
1269
|
-
] },
|
|
1352
|
+
] }, k.id);
|
|
1270
1353
|
})
|
|
1271
1354
|
] })
|
|
1272
1355
|
] })
|
|
@@ -1274,13 +1357,13 @@ function Vn({ def: e, onPointerDown: t, isPlaced: n }) {
|
|
|
1274
1357
|
}
|
|
1275
1358
|
);
|
|
1276
1359
|
}
|
|
1277
|
-
function
|
|
1278
|
-
const s =
|
|
1279
|
-
return /* @__PURE__ */
|
|
1280
|
-
/* @__PURE__ */
|
|
1360
|
+
function Wr({ cat: e, defs: t, collapsed: n, onToggle: o, onPointerDown: r, placedStartIds: i }) {
|
|
1361
|
+
const s = Q();
|
|
1362
|
+
return /* @__PURE__ */ m("div", { style: { marginBottom: 2 }, children: [
|
|
1363
|
+
/* @__PURE__ */ m(
|
|
1281
1364
|
"button",
|
|
1282
1365
|
{
|
|
1283
|
-
onClick: () =>
|
|
1366
|
+
onClick: () => o(e),
|
|
1284
1367
|
style: {
|
|
1285
1368
|
display: "flex",
|
|
1286
1369
|
alignItems: "center",
|
|
@@ -1302,36 +1385,36 @@ function mr({ cat: e, defs: t, collapsed: n, onToggle: r, onPointerDown: o, plac
|
|
|
1302
1385
|
}
|
|
1303
1386
|
),
|
|
1304
1387
|
!n && /* @__PURE__ */ l("div", { style: { paddingBottom: 4 }, children: t.map((c) => /* @__PURE__ */ l(
|
|
1305
|
-
|
|
1388
|
+
ro,
|
|
1306
1389
|
{
|
|
1307
1390
|
def: c,
|
|
1308
|
-
onPointerDown:
|
|
1391
|
+
onPointerDown: r,
|
|
1309
1392
|
isPlaced: c.blockType === "start" && i.has(c.id)
|
|
1310
1393
|
},
|
|
1311
1394
|
c.id
|
|
1312
1395
|
)) })
|
|
1313
1396
|
] });
|
|
1314
1397
|
}
|
|
1315
|
-
function
|
|
1398
|
+
function qr({
|
|
1316
1399
|
onPointerDown: e,
|
|
1317
1400
|
isDropTarget: t,
|
|
1318
1401
|
registryVersion: n,
|
|
1319
|
-
packages:
|
|
1320
|
-
placedStartIds:
|
|
1402
|
+
packages: o,
|
|
1403
|
+
placedStartIds: r
|
|
1321
1404
|
}) {
|
|
1322
|
-
const i =
|
|
1323
|
-
function
|
|
1324
|
-
|
|
1325
|
-
const
|
|
1326
|
-
return
|
|
1405
|
+
const i = Q(), [s, c] = B("blocks"), [p, y] = B(""), [x, k] = B(/* @__PURE__ */ new Set()), L = Ne(() => Wn().filter((g) => !g.category.startsWith("$")), [n]), T = Ne(() => cr().filter((g) => !g.startsWith("$")), [n]), W = p.trim().toLowerCase(), z = W ? L.filter((g) => g.name.toLowerCase().includes(W)) : null;
|
|
1406
|
+
function Y(g) {
|
|
1407
|
+
k((ne) => {
|
|
1408
|
+
const G = new Set(ne);
|
|
1409
|
+
return G.has(g) ? G.delete(g) : G.add(g), G;
|
|
1327
1410
|
});
|
|
1328
1411
|
}
|
|
1329
|
-
const
|
|
1412
|
+
const q = o?.dependencies.length ?? 0, S = (g) => ({
|
|
1330
1413
|
flex: 1,
|
|
1331
1414
|
background: "none",
|
|
1332
1415
|
border: "none",
|
|
1333
|
-
borderBottom: `2px solid ${s ===
|
|
1334
|
-
color: s ===
|
|
1416
|
+
borderBottom: `2px solid ${s === g ? i.accent : "transparent"}`,
|
|
1417
|
+
color: s === g ? i.accent : i.textMuted,
|
|
1335
1418
|
fontSize: 10,
|
|
1336
1419
|
fontWeight: "bold",
|
|
1337
1420
|
textTransform: "uppercase",
|
|
@@ -1340,7 +1423,7 @@ function xr({
|
|
|
1340
1423
|
cursor: "pointer",
|
|
1341
1424
|
transition: "color 0.15s, border-color 0.15s"
|
|
1342
1425
|
});
|
|
1343
|
-
return /* @__PURE__ */
|
|
1426
|
+
return /* @__PURE__ */ m("div", { style: {
|
|
1344
1427
|
width: 260,
|
|
1345
1428
|
minWidth: 260,
|
|
1346
1429
|
backgroundColor: i.paletteBg,
|
|
@@ -1350,21 +1433,21 @@ function xr({
|
|
|
1350
1433
|
height: "100%",
|
|
1351
1434
|
overflow: "hidden"
|
|
1352
1435
|
}, children: [
|
|
1353
|
-
|
|
1354
|
-
/* @__PURE__ */ l("button", { style:
|
|
1355
|
-
/* @__PURE__ */
|
|
1436
|
+
o && /* @__PURE__ */ m("div", { style: { display: "flex", borderBottom: `1px solid ${i.border}`, flexShrink: 0, background: i.paletteHeaderBg }, children: [
|
|
1437
|
+
/* @__PURE__ */ l("button", { style: S("blocks"), onClick: () => c("blocks"), children: "Blocks" }),
|
|
1438
|
+
/* @__PURE__ */ m("button", { style: S("packages"), onClick: () => c("packages"), children: [
|
|
1356
1439
|
"Packages",
|
|
1357
|
-
|
|
1440
|
+
q > 0 ? ` · ${q}` : ""
|
|
1358
1441
|
] })
|
|
1359
1442
|
] }),
|
|
1360
|
-
s === "blocks" && /* @__PURE__ */
|
|
1443
|
+
s === "blocks" && /* @__PURE__ */ m(bt, { children: [
|
|
1361
1444
|
/* @__PURE__ */ l("div", { style: { padding: "8px 10px 6px", flexShrink: 0 }, children: /* @__PURE__ */ l(
|
|
1362
1445
|
"input",
|
|
1363
1446
|
{
|
|
1364
1447
|
type: "search",
|
|
1365
1448
|
placeholder: "Search blocks…",
|
|
1366
1449
|
value: p,
|
|
1367
|
-
onChange: (
|
|
1450
|
+
onChange: (g) => y(g.target.value),
|
|
1368
1451
|
style: {
|
|
1369
1452
|
width: "100%",
|
|
1370
1453
|
boxSizing: "border-box",
|
|
@@ -1378,25 +1461,25 @@ function xr({
|
|
|
1378
1461
|
}
|
|
1379
1462
|
}
|
|
1380
1463
|
) }),
|
|
1381
|
-
/* @__PURE__ */ l("div", { style: { flex: 1, overflowY: "auto", padding: "4px 10px 0" }, children:
|
|
1382
|
-
|
|
1464
|
+
/* @__PURE__ */ l("div", { style: { flex: 1, overflowY: "auto", padding: "4px 10px 0" }, children: z ? z.length > 0 ? z.map((g) => /* @__PURE__ */ l(
|
|
1465
|
+
ro,
|
|
1383
1466
|
{
|
|
1384
|
-
def:
|
|
1467
|
+
def: g,
|
|
1385
1468
|
onPointerDown: e,
|
|
1386
|
-
isPlaced:
|
|
1469
|
+
isPlaced: g.blockType === "start" && r.has(g.id)
|
|
1387
1470
|
},
|
|
1388
|
-
|
|
1389
|
-
)) : /* @__PURE__ */ l("div", { style: { color: i.textMuted, fontSize: 11, padding: "12px 0", textAlign: "center" }, children: "No blocks match" }) :
|
|
1390
|
-
|
|
1471
|
+
g.id
|
|
1472
|
+
)) : /* @__PURE__ */ l("div", { style: { color: i.textMuted, fontSize: 11, padding: "12px 0", textAlign: "center" }, children: "No blocks match" }) : T.map((g) => /* @__PURE__ */ l(
|
|
1473
|
+
Wr,
|
|
1391
1474
|
{
|
|
1392
|
-
cat:
|
|
1393
|
-
defs:
|
|
1394
|
-
collapsed:
|
|
1395
|
-
onToggle:
|
|
1475
|
+
cat: g,
|
|
1476
|
+
defs: L.filter((ne) => ne.category === g),
|
|
1477
|
+
collapsed: x.has(g),
|
|
1478
|
+
onToggle: Y,
|
|
1396
1479
|
onPointerDown: e,
|
|
1397
|
-
placedStartIds:
|
|
1480
|
+
placedStartIds: r
|
|
1398
1481
|
},
|
|
1399
|
-
|
|
1482
|
+
g
|
|
1400
1483
|
)) }),
|
|
1401
1484
|
/* @__PURE__ */ l("div", { style: {
|
|
1402
1485
|
flexShrink: 0,
|
|
@@ -1416,83 +1499,87 @@ function xr({
|
|
|
1416
1499
|
userSelect: "none"
|
|
1417
1500
|
}, children: t ? "Release to delete" : "Drag here to delete" })
|
|
1418
1501
|
] }),
|
|
1419
|
-
s === "packages" &&
|
|
1502
|
+
s === "packages" && o && /* @__PURE__ */ l(Rr, { ...o })
|
|
1420
1503
|
] });
|
|
1421
1504
|
}
|
|
1422
|
-
function
|
|
1423
|
-
let
|
|
1505
|
+
function Ur(e, t, n) {
|
|
1506
|
+
let o = e;
|
|
1424
1507
|
for (; ; )
|
|
1425
|
-
if (
|
|
1426
|
-
const
|
|
1427
|
-
if (!
|
|
1428
|
-
|
|
1429
|
-
} else if (
|
|
1430
|
-
const
|
|
1431
|
-
if (!
|
|
1432
|
-
|
|
1508
|
+
if (o.embeddedInBlockId) {
|
|
1509
|
+
const r = n.get(o.embeddedInBlockId);
|
|
1510
|
+
if (!r) return !1;
|
|
1511
|
+
o = r;
|
|
1512
|
+
} else if (o.parentBlockId) {
|
|
1513
|
+
const r = n.get(o.parentBlockId);
|
|
1514
|
+
if (!r) return !1;
|
|
1515
|
+
o = r;
|
|
1433
1516
|
} else
|
|
1434
|
-
return
|
|
1517
|
+
return N(o.definitionId)?.provides?.some((i) => i.id === t) ?? !1;
|
|
1435
1518
|
}
|
|
1436
|
-
function
|
|
1519
|
+
function wt(e) {
|
|
1437
1520
|
const {
|
|
1438
1521
|
block: t,
|
|
1439
1522
|
allBlocks: n,
|
|
1440
|
-
onPointerDown:
|
|
1441
|
-
onBlockClick:
|
|
1523
|
+
onPointerDown: o,
|
|
1524
|
+
onBlockClick: r,
|
|
1442
1525
|
onSocketClick: i,
|
|
1443
1526
|
editingSocket: s,
|
|
1444
1527
|
onSocketCommit: c,
|
|
1445
1528
|
onSocketCancelEdit: p,
|
|
1446
|
-
onOutputDrag:
|
|
1447
|
-
isGhost:
|
|
1448
|
-
draggingIds:
|
|
1449
|
-
provisionalIds:
|
|
1450
|
-
onSocketInput:
|
|
1529
|
+
onOutputDrag: y,
|
|
1530
|
+
isGhost: x,
|
|
1531
|
+
draggingIds: k,
|
|
1532
|
+
provisionalIds: L,
|
|
1533
|
+
onSocketInput: T,
|
|
1451
1534
|
onParamRemove: W,
|
|
1535
|
+
onMouthOpen: z,
|
|
1536
|
+
onMouthClose: Y,
|
|
1452
1537
|
embedded: q
|
|
1453
|
-
} = e,
|
|
1454
|
-
const
|
|
1455
|
-
return
|
|
1456
|
-
|
|
1538
|
+
} = e, S = Q(), g = N(t.definitionId), ne = k?.has(t.instanceId) ?? !1, G = L?.has(t.instanceId) ?? !1, oe = (u, _, X, J) => {
|
|
1539
|
+
const le = u ? n.get(u) : void 0;
|
|
1540
|
+
return le ? /* @__PURE__ */ l("g", { transform: `translate(${_},${X})`, children: /* @__PURE__ */ l(
|
|
1541
|
+
wt,
|
|
1457
1542
|
{
|
|
1458
|
-
block:
|
|
1543
|
+
block: le,
|
|
1459
1544
|
allBlocks: n,
|
|
1460
|
-
onPointerDown:
|
|
1461
|
-
onBlockClick:
|
|
1545
|
+
onPointerDown: o,
|
|
1546
|
+
onBlockClick: r,
|
|
1462
1547
|
onSocketClick: i,
|
|
1463
1548
|
editingSocket: s,
|
|
1464
1549
|
onSocketCommit: c,
|
|
1465
1550
|
onSocketCancelEdit: p,
|
|
1466
|
-
onOutputDrag:
|
|
1467
|
-
isGhost:
|
|
1468
|
-
draggingIds:
|
|
1469
|
-
provisionalIds:
|
|
1470
|
-
onSocketInput:
|
|
1551
|
+
onOutputDrag: y,
|
|
1552
|
+
isGhost: x,
|
|
1553
|
+
draggingIds: k,
|
|
1554
|
+
provisionalIds: L,
|
|
1555
|
+
onSocketInput: T,
|
|
1471
1556
|
onParamRemove: W,
|
|
1557
|
+
onMouthOpen: z,
|
|
1558
|
+
onMouthClose: Y,
|
|
1472
1559
|
embedded: !0
|
|
1473
1560
|
}
|
|
1474
|
-
) },
|
|
1561
|
+
) }, J) : null;
|
|
1475
1562
|
};
|
|
1476
|
-
if (!
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1479
|
-
} : void 0,
|
|
1480
|
-
|
|
1481
|
-
} : void 0,
|
|
1482
|
-
return /* @__PURE__ */
|
|
1563
|
+
if (!g) {
|
|
1564
|
+
const u = o ? (J) => {
|
|
1565
|
+
J.stopPropagation(), o(J, t.instanceId);
|
|
1566
|
+
} : void 0, _ = r ? (J) => {
|
|
1567
|
+
J.stopPropagation(), r(t.instanceId);
|
|
1568
|
+
} : void 0, X = t.definitionId.replace(/^__coll__/, "").slice(0, 16);
|
|
1569
|
+
return /* @__PURE__ */ m(
|
|
1483
1570
|
"g",
|
|
1484
1571
|
{
|
|
1485
|
-
transform:
|
|
1486
|
-
opacity:
|
|
1572
|
+
transform: x || q ? void 0 : `translate(${t.x},${t.y})`,
|
|
1573
|
+
opacity: ne ? 0.35 : 0.85,
|
|
1487
1574
|
children: [
|
|
1488
|
-
/* @__PURE__ */
|
|
1575
|
+
/* @__PURE__ */ m("g", { onPointerDown: u, onClick: _, style: { cursor: "grab" }, children: [
|
|
1489
1576
|
/* @__PURE__ */ l(
|
|
1490
1577
|
"rect",
|
|
1491
1578
|
{
|
|
1492
1579
|
x: 0,
|
|
1493
1580
|
y: 0,
|
|
1494
1581
|
width: 160,
|
|
1495
|
-
height:
|
|
1582
|
+
height: je,
|
|
1496
1583
|
rx: 3,
|
|
1497
1584
|
fill: "rgba(160,40,40,0.18)",
|
|
1498
1585
|
stroke: "#c05050",
|
|
@@ -1500,7 +1587,7 @@ function yt(e) {
|
|
|
1500
1587
|
strokeDasharray: "5,3"
|
|
1501
1588
|
}
|
|
1502
1589
|
),
|
|
1503
|
-
/* @__PURE__ */
|
|
1590
|
+
/* @__PURE__ */ m(
|
|
1504
1591
|
"text",
|
|
1505
1592
|
{
|
|
1506
1593
|
x: 8,
|
|
@@ -1512,48 +1599,48 @@ function yt(e) {
|
|
|
1512
1599
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1513
1600
|
children: [
|
|
1514
1601
|
"⚠ ",
|
|
1515
|
-
|
|
1602
|
+
X,
|
|
1516
1603
|
" (missing)"
|
|
1517
1604
|
]
|
|
1518
1605
|
}
|
|
1519
1606
|
)
|
|
1520
1607
|
] }),
|
|
1521
|
-
|
|
1608
|
+
oe(t.nextBlockId, 0, je, "next")
|
|
1522
1609
|
]
|
|
1523
1610
|
}
|
|
1524
1611
|
);
|
|
1525
1612
|
}
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1528
|
-
} : void 0,
|
|
1529
|
-
|
|
1613
|
+
const Z = fe(g, t.paramSlots, n), b = Ce(g, t.paramSlots, n), U = We(g), F = Je(g, t.paramSlots, n), H = Ae(g, t.paramSlots, n), he = Ze(g, t.paramSlots, n), ce = ne ? 0.35 : G ? 0.6 : x && !q ? 0.75 : 1, qe = `clip-${x ? "g" : "c"}-${t.instanceId}`, pe = on(g, t.paramSlots, n), et = o ? (u) => {
|
|
1614
|
+
u.stopPropagation(), o(u, t.instanceId);
|
|
1615
|
+
} : void 0, D = r ? (u) => {
|
|
1616
|
+
u.stopPropagation(), r(t.instanceId);
|
|
1530
1617
|
} : void 0;
|
|
1531
|
-
if (
|
|
1532
|
-
const
|
|
1533
|
-
return /* @__PURE__ */
|
|
1618
|
+
if (g.category.startsWith("$") && !x && !Ur(t, g.id, n)) {
|
|
1619
|
+
const u = fe(g), _ = we, X = tn(g.returnType ?? "string", u, _);
|
|
1620
|
+
return /* @__PURE__ */ m(
|
|
1534
1621
|
"g",
|
|
1535
1622
|
{
|
|
1536
|
-
transform:
|
|
1537
|
-
opacity:
|
|
1538
|
-
onPointerDown:
|
|
1539
|
-
onClick:
|
|
1623
|
+
transform: x || q ? void 0 : `translate(${t.x},${t.y})`,
|
|
1624
|
+
opacity: ne ? 0.35 : 0.85,
|
|
1625
|
+
onPointerDown: et,
|
|
1626
|
+
onClick: D,
|
|
1540
1627
|
style: { cursor: "grab" },
|
|
1541
1628
|
children: [
|
|
1542
1629
|
/* @__PURE__ */ l(
|
|
1543
1630
|
"path",
|
|
1544
1631
|
{
|
|
1545
|
-
d:
|
|
1632
|
+
d: X,
|
|
1546
1633
|
fill: "rgba(180,100,0,0.15)",
|
|
1547
1634
|
stroke: "#c08820",
|
|
1548
1635
|
strokeWidth: 1.5,
|
|
1549
1636
|
strokeDasharray: "5,3"
|
|
1550
1637
|
}
|
|
1551
1638
|
),
|
|
1552
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ m(
|
|
1553
1640
|
"text",
|
|
1554
1641
|
{
|
|
1555
|
-
x:
|
|
1556
|
-
y:
|
|
1642
|
+
x: u / 2,
|
|
1643
|
+
y: _ / 2 + 3.5,
|
|
1557
1644
|
textAnchor: "middle",
|
|
1558
1645
|
fill: "#c08820",
|
|
1559
1646
|
fontSize: 9,
|
|
@@ -1562,7 +1649,7 @@ function yt(e) {
|
|
|
1562
1649
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1563
1650
|
children: [
|
|
1564
1651
|
"⚠ ",
|
|
1565
|
-
|
|
1652
|
+
g.name
|
|
1566
1653
|
]
|
|
1567
1654
|
}
|
|
1568
1655
|
)
|
|
@@ -1570,24 +1657,24 @@ function yt(e) {
|
|
|
1570
1657
|
}
|
|
1571
1658
|
);
|
|
1572
1659
|
}
|
|
1573
|
-
return /* @__PURE__ */
|
|
1660
|
+
return /* @__PURE__ */ m(
|
|
1574
1661
|
"g",
|
|
1575
1662
|
{
|
|
1576
|
-
transform:
|
|
1577
|
-
opacity:
|
|
1578
|
-
onPointerDown:
|
|
1579
|
-
onClick:
|
|
1580
|
-
style: { cursor:
|
|
1663
|
+
transform: x || q ? void 0 : `translate(${t.x},${t.y})`,
|
|
1664
|
+
opacity: ce,
|
|
1665
|
+
onPointerDown: et,
|
|
1666
|
+
onClick: D,
|
|
1667
|
+
style: { cursor: x ? "grabbing" : "grab" },
|
|
1581
1668
|
children: [
|
|
1582
|
-
/* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("clipPath", { id:
|
|
1669
|
+
/* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("clipPath", { id: qe, children: /* @__PURE__ */ l("path", { d: pe }) }) }),
|
|
1583
1670
|
/* @__PURE__ */ l(
|
|
1584
1671
|
"path",
|
|
1585
1672
|
{
|
|
1586
|
-
d:
|
|
1587
|
-
fill:
|
|
1588
|
-
stroke:
|
|
1673
|
+
d: pe,
|
|
1674
|
+
fill: S.blockBody,
|
|
1675
|
+
stroke: G ? S.accent : S.blockBorder,
|
|
1589
1676
|
strokeWidth: 1.5,
|
|
1590
|
-
strokeDasharray:
|
|
1677
|
+
strokeDasharray: G ? "4,3" : void 0
|
|
1591
1678
|
}
|
|
1592
1679
|
),
|
|
1593
1680
|
/* @__PURE__ */ l(
|
|
@@ -1596,59 +1683,59 @@ function yt(e) {
|
|
|
1596
1683
|
x: 0,
|
|
1597
1684
|
y: 0,
|
|
1598
1685
|
width: 4,
|
|
1599
|
-
height:
|
|
1600
|
-
fill:
|
|
1601
|
-
clipPath: `url(#${
|
|
1686
|
+
height: b + 20,
|
|
1687
|
+
fill: g.color,
|
|
1688
|
+
clipPath: `url(#${qe})`
|
|
1602
1689
|
}
|
|
1603
1690
|
),
|
|
1604
|
-
/* @__PURE__ */
|
|
1691
|
+
/* @__PURE__ */ m(
|
|
1605
1692
|
"text",
|
|
1606
1693
|
{
|
|
1607
1694
|
x: 11,
|
|
1608
|
-
y:
|
|
1609
|
-
fill:
|
|
1695
|
+
y: U / 2 + 4,
|
|
1696
|
+
fill: S.blockText,
|
|
1610
1697
|
fontSize: 11,
|
|
1611
1698
|
fontWeight: "bold",
|
|
1612
1699
|
fontFamily: "sans-serif",
|
|
1613
1700
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1614
1701
|
children: [
|
|
1615
|
-
|
|
1616
|
-
|
|
1702
|
+
g.name,
|
|
1703
|
+
g.blockType === "query" && g.returnType && /* @__PURE__ */ l("tspan", { fill: S.textMuted, fontSize: 9, fontWeight: "normal", children: ` [${g.returnType}]` })
|
|
1617
1704
|
]
|
|
1618
1705
|
}
|
|
1619
1706
|
),
|
|
1620
|
-
|
|
1707
|
+
g.blockType === "start" && g.provides && g.provides.length > 0 && /* @__PURE__ */ m("g", { children: [
|
|
1621
1708
|
/* @__PURE__ */ l(
|
|
1622
1709
|
"line",
|
|
1623
1710
|
{
|
|
1624
1711
|
x1: 8,
|
|
1625
|
-
y1:
|
|
1626
|
-
x2:
|
|
1627
|
-
y2:
|
|
1712
|
+
y1: De,
|
|
1713
|
+
x2: Z - 8,
|
|
1714
|
+
y2: De,
|
|
1628
1715
|
stroke: "rgba(255,255,255,0.15)",
|
|
1629
1716
|
strokeWidth: 1
|
|
1630
1717
|
}
|
|
1631
1718
|
),
|
|
1632
|
-
|
|
1633
|
-
const
|
|
1634
|
-
return /* @__PURE__ */
|
|
1719
|
+
Jt(g).map((u) => {
|
|
1720
|
+
const X = N(u.id)?.color ?? g.color, J = u.w, le = Yn, ke = !x && !q;
|
|
1721
|
+
return /* @__PURE__ */ m(
|
|
1635
1722
|
"g",
|
|
1636
1723
|
{
|
|
1637
|
-
transform: `translate(${
|
|
1638
|
-
onPointerDown:
|
|
1639
|
-
|
|
1724
|
+
transform: `translate(${u.x}, ${u.y})`,
|
|
1725
|
+
onPointerDown: ke ? (ve) => {
|
|
1726
|
+
ve.stopPropagation(), y?.(ve, u.id);
|
|
1640
1727
|
} : void 0,
|
|
1641
|
-
style: { cursor:
|
|
1728
|
+
style: { cursor: ke ? "grab" : "default" },
|
|
1642
1729
|
children: [
|
|
1643
1730
|
/* @__PURE__ */ l(
|
|
1644
1731
|
"rect",
|
|
1645
1732
|
{
|
|
1646
1733
|
x: 0,
|
|
1647
1734
|
y: 0,
|
|
1648
|
-
width:
|
|
1649
|
-
height:
|
|
1735
|
+
width: J,
|
|
1736
|
+
height: le,
|
|
1650
1737
|
rx: 10,
|
|
1651
|
-
fill:
|
|
1738
|
+
fill: X,
|
|
1652
1739
|
opacity: 0.82,
|
|
1653
1740
|
stroke: "rgba(255,255,255,0.25)",
|
|
1654
1741
|
strokeWidth: 1
|
|
@@ -1657,187 +1744,209 @@ function yt(e) {
|
|
|
1657
1744
|
/* @__PURE__ */ l(
|
|
1658
1745
|
"text",
|
|
1659
1746
|
{
|
|
1660
|
-
x:
|
|
1661
|
-
y:
|
|
1747
|
+
x: J / 2,
|
|
1748
|
+
y: le / 2 + 3.5,
|
|
1662
1749
|
textAnchor: "middle",
|
|
1663
1750
|
fill: "white",
|
|
1664
1751
|
fontSize: 9.5,
|
|
1665
1752
|
fontFamily: "sans-serif",
|
|
1666
1753
|
fontWeight: "bold",
|
|
1667
1754
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1668
|
-
children:
|
|
1755
|
+
children: u.name
|
|
1669
1756
|
}
|
|
1670
1757
|
)
|
|
1671
1758
|
]
|
|
1672
1759
|
},
|
|
1673
|
-
|
|
1760
|
+
u.id
|
|
1674
1761
|
);
|
|
1675
1762
|
})
|
|
1676
1763
|
] }),
|
|
1677
|
-
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1764
|
+
F.map((u) => {
|
|
1765
|
+
const _ = t.paramSlots[u.index], X = _?.queryBlockId, J = X ? n.get(X) : null, le = g.params[u.index], ke = le.name, ve = Jn(le), Oe = le.optional && W && !x ? /* @__PURE__ */ l(
|
|
1766
|
+
Cn,
|
|
1680
1767
|
{
|
|
1681
|
-
w:
|
|
1682
|
-
title: `Leave out ${
|
|
1683
|
-
onRemove: () => W(t.instanceId,
|
|
1768
|
+
w: u.w,
|
|
1769
|
+
title: `Leave out ${ke}`,
|
|
1770
|
+
onRemove: () => W(t.instanceId, u.index)
|
|
1684
1771
|
}
|
|
1685
1772
|
) : null;
|
|
1686
|
-
if (
|
|
1687
|
-
return /* @__PURE__ */
|
|
1688
|
-
/* @__PURE__ */ l("title", { children:
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
] },
|
|
1692
|
-
const
|
|
1693
|
-
if (
|
|
1694
|
-
return /* @__PURE__ */
|
|
1773
|
+
if (J)
|
|
1774
|
+
return /* @__PURE__ */ m("g", { children: [
|
|
1775
|
+
/* @__PURE__ */ l("title", { children: ve }),
|
|
1776
|
+
oe(X, u.x, u.y, "query"),
|
|
1777
|
+
Oe && /* @__PURE__ */ l("g", { transform: `translate(${u.x},${u.y})`, children: Oe })
|
|
1778
|
+
] }, u.index);
|
|
1779
|
+
const be = _?.textValue, re = s?.blockId === t.instanceId && s?.slotIndex === u.index;
|
|
1780
|
+
if (u.collapsed && !re)
|
|
1781
|
+
return /* @__PURE__ */ m(
|
|
1695
1782
|
"g",
|
|
1696
1783
|
{
|
|
1697
|
-
transform: `translate(${
|
|
1698
|
-
onPointerDown: (
|
|
1699
|
-
onClick: (
|
|
1700
|
-
|
|
1784
|
+
transform: `translate(${u.x},${u.y})`,
|
|
1785
|
+
onPointerDown: (v) => v.stopPropagation(),
|
|
1786
|
+
onClick: (v) => {
|
|
1787
|
+
v.stopPropagation(), i?.(t.instanceId, u.index);
|
|
1701
1788
|
},
|
|
1702
1789
|
style: { cursor: "pointer" },
|
|
1703
1790
|
children: [
|
|
1704
|
-
/* @__PURE__ */ l("title", { children: `${
|
|
1705
|
-
/* @__PURE__ */ l(
|
|
1791
|
+
/* @__PURE__ */ l("title", { children: `${ve}: click to type a value, or drop a ${u.type} query here` }),
|
|
1792
|
+
/* @__PURE__ */ l(rn, { name: ke, w: u.w, h: u.h })
|
|
1706
1793
|
]
|
|
1707
1794
|
},
|
|
1708
|
-
|
|
1795
|
+
u.index
|
|
1709
1796
|
);
|
|
1710
|
-
const
|
|
1711
|
-
return /* @__PURE__ */
|
|
1797
|
+
const ae = u.collapsed ? Math.max(u.w, mt(u.type).w) : u.w, ge = u.collapsed ? mt(u.type).h : u.h;
|
|
1798
|
+
return /* @__PURE__ */ m(
|
|
1712
1799
|
"g",
|
|
1713
1800
|
{
|
|
1714
|
-
transform: `translate(${
|
|
1715
|
-
onPointerDown: (
|
|
1716
|
-
onClick: (
|
|
1717
|
-
|
|
1801
|
+
transform: `translate(${u.x},${u.y + (u.h - ge) / 2})`,
|
|
1802
|
+
onPointerDown: (v) => v.stopPropagation(),
|
|
1803
|
+
onClick: (v) => {
|
|
1804
|
+
v.stopPropagation(), i?.(t.instanceId, u.index);
|
|
1718
1805
|
},
|
|
1719
1806
|
style: { cursor: "text" },
|
|
1720
1807
|
children: [
|
|
1721
|
-
/* @__PURE__ */ l("title", { children:
|
|
1808
|
+
/* @__PURE__ */ l("title", { children: ve }),
|
|
1722
1809
|
/* @__PURE__ */ l(
|
|
1723
1810
|
"path",
|
|
1724
1811
|
{
|
|
1725
|
-
d:
|
|
1726
|
-
fill:
|
|
1727
|
-
stroke:
|
|
1728
|
-
strokeWidth:
|
|
1812
|
+
d: nn(u.type, ae, ge),
|
|
1813
|
+
fill: re ? S.blockBorder : S.socketBody,
|
|
1814
|
+
stroke: S.blockBorder,
|
|
1815
|
+
strokeWidth: re ? 1.5 : 1
|
|
1729
1816
|
}
|
|
1730
1817
|
),
|
|
1731
|
-
|
|
1818
|
+
re ? /* @__PURE__ */ l("foreignObject", { x: 0, y: 0, width: ae, height: ge, children: /* @__PURE__ */ l(
|
|
1732
1819
|
"input",
|
|
1733
1820
|
{
|
|
1734
1821
|
autoFocus: !0,
|
|
1735
|
-
defaultValue:
|
|
1736
|
-
onChange: (
|
|
1737
|
-
onKeyDown: (
|
|
1738
|
-
|
|
1822
|
+
defaultValue: be ?? "",
|
|
1823
|
+
onChange: (v) => T?.(t.instanceId, u.index, v.target.value),
|
|
1824
|
+
onKeyDown: (v) => {
|
|
1825
|
+
v.stopPropagation(), v.key === "Enter" && c?.(t.instanceId, u.index, v.target.value), v.key === "Escape" && p?.();
|
|
1739
1826
|
},
|
|
1740
|
-
onBlur: (
|
|
1741
|
-
onPointerDown: (
|
|
1827
|
+
onBlur: (v) => c?.(t.instanceId, u.index, v.target.value),
|
|
1828
|
+
onPointerDown: (v) => v.stopPropagation(),
|
|
1742
1829
|
style: {
|
|
1743
1830
|
width: "100%",
|
|
1744
1831
|
height: "100%",
|
|
1745
1832
|
background: "transparent",
|
|
1746
1833
|
border: "none",
|
|
1747
1834
|
outline: "none",
|
|
1748
|
-
color:
|
|
1835
|
+
color: S.blockText,
|
|
1749
1836
|
fontSize: 10,
|
|
1750
1837
|
fontFamily: "sans-serif",
|
|
1751
1838
|
textAlign: "center",
|
|
1752
1839
|
padding: "0 4px",
|
|
1753
1840
|
boxSizing: "border-box",
|
|
1754
|
-
caretColor:
|
|
1841
|
+
caretColor: S.blockText
|
|
1755
1842
|
}
|
|
1756
1843
|
}
|
|
1757
|
-
) }) :
|
|
1844
|
+
) }) : be ? /* @__PURE__ */ l(
|
|
1758
1845
|
"text",
|
|
1759
1846
|
{
|
|
1760
|
-
x:
|
|
1761
|
-
y:
|
|
1847
|
+
x: u.w / 2,
|
|
1848
|
+
y: u.h / 2 + 4,
|
|
1762
1849
|
textAnchor: "middle",
|
|
1763
|
-
fill:
|
|
1850
|
+
fill: S.blockText,
|
|
1764
1851
|
fontSize: 10,
|
|
1765
1852
|
fontFamily: "sans-serif",
|
|
1766
|
-
fontStyle:
|
|
1853
|
+
fontStyle: G ? "italic" : void 0,
|
|
1767
1854
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1768
|
-
children:
|
|
1855
|
+
children: be
|
|
1769
1856
|
}
|
|
1770
|
-
) : /* @__PURE__ */ l(
|
|
1771
|
-
|
|
1857
|
+
) : /* @__PURE__ */ l(oo, { name: ke, type: u.type, w: u.w, h: u.h }),
|
|
1858
|
+
!re && Oe
|
|
1772
1859
|
]
|
|
1773
1860
|
},
|
|
1774
|
-
|
|
1861
|
+
u.index
|
|
1775
1862
|
);
|
|
1776
1863
|
}),
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1864
|
+
H.length > 0 && /* @__PURE__ */ l(cn, { mouths: H, w: Z, isEmpty: (u) => !t.paramSlots[u]?.commandBlockId }),
|
|
1865
|
+
H.map((u) => oe(t.paramSlots[u.index]?.commandBlockId, u.x, u.y, `mouth-${u.index}`)),
|
|
1866
|
+
!x && Y && H.filter((u) => u.optional).map((u) => {
|
|
1867
|
+
const _ = Cr(u, Z);
|
|
1868
|
+
return /* @__PURE__ */ l("g", { transform: `translate(${_.x},${_.y})`, children: /* @__PURE__ */ l(
|
|
1869
|
+
Cn,
|
|
1870
|
+
{
|
|
1871
|
+
w: 2,
|
|
1872
|
+
title: `Leave out ${u.name}`,
|
|
1873
|
+
onRemove: () => Y(t.instanceId, u.index)
|
|
1874
|
+
}
|
|
1875
|
+
) }, `close-${u.index}`);
|
|
1876
|
+
}),
|
|
1877
|
+
/* @__PURE__ */ l(
|
|
1878
|
+
sn,
|
|
1879
|
+
{
|
|
1880
|
+
chips: he,
|
|
1881
|
+
onOpen: !x && z ? (u) => z(t.instanceId, u) : void 0
|
|
1882
|
+
}
|
|
1883
|
+
),
|
|
1884
|
+
oe(t.nextBlockId, 0, b, "next")
|
|
1780
1885
|
]
|
|
1781
1886
|
}
|
|
1782
1887
|
);
|
|
1783
1888
|
}
|
|
1784
|
-
const
|
|
1889
|
+
const io = Oo(
|
|
1785
1890
|
({
|
|
1786
1891
|
blocks: e,
|
|
1787
1892
|
draggingIds: t,
|
|
1788
1893
|
provisionalIds: n,
|
|
1789
|
-
onBlockPointerDown:
|
|
1790
|
-
onBlockClick:
|
|
1894
|
+
onBlockPointerDown: o,
|
|
1895
|
+
onBlockClick: r,
|
|
1791
1896
|
onSocketClick: i,
|
|
1792
1897
|
editingSocket: s,
|
|
1793
1898
|
onSocketInput: c,
|
|
1794
1899
|
onSocketCommit: p,
|
|
1795
|
-
onSocketCancelEdit:
|
|
1796
|
-
onParamRemove:
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1900
|
+
onSocketCancelEdit: y,
|
|
1901
|
+
onParamRemove: x,
|
|
1902
|
+
onMouthOpen: k,
|
|
1903
|
+
onMouthClose: L,
|
|
1904
|
+
onOutputDrag: T,
|
|
1905
|
+
overlay: W
|
|
1906
|
+
}, z) => {
|
|
1907
|
+
const Y = Q(), q = [...e.values()].filter((S) => !S.embeddedInBlockId && !S.parentBlockId);
|
|
1908
|
+
return /* @__PURE__ */ m(
|
|
1802
1909
|
"svg",
|
|
1803
1910
|
{
|
|
1804
|
-
ref:
|
|
1805
|
-
style: { flex: 1, background:
|
|
1806
|
-
onPointerDown: (
|
|
1807
|
-
|
|
1911
|
+
ref: z,
|
|
1912
|
+
style: { flex: 1, background: Y.canvasBg, display: "block" },
|
|
1913
|
+
onPointerDown: (S) => {
|
|
1914
|
+
S.target === S.currentTarget && S.preventDefault();
|
|
1808
1915
|
},
|
|
1809
1916
|
children: [
|
|
1810
|
-
/* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("pattern", { id: "grid", width: "28", height: "28", patternUnits: "userSpaceOnUse", children: /* @__PURE__ */ l("circle", { cx: "14", cy: "14", r: "0.7", fill:
|
|
1917
|
+
/* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("pattern", { id: "grid", width: "28", height: "28", patternUnits: "userSpaceOnUse", children: /* @__PURE__ */ l("circle", { cx: "14", cy: "14", r: "0.7", fill: Y.gridDot }) }) }),
|
|
1811
1918
|
/* @__PURE__ */ l("rect", { width: "100%", height: "100%", fill: "url(#grid)" }),
|
|
1812
|
-
q.map((
|
|
1813
|
-
|
|
1919
|
+
q.map((S) => /* @__PURE__ */ l(
|
|
1920
|
+
wt,
|
|
1814
1921
|
{
|
|
1815
|
-
block:
|
|
1922
|
+
block: S,
|
|
1816
1923
|
allBlocks: e,
|
|
1817
|
-
onPointerDown:
|
|
1818
|
-
onBlockClick:
|
|
1924
|
+
onPointerDown: o,
|
|
1925
|
+
onBlockClick: r,
|
|
1819
1926
|
onSocketClick: i,
|
|
1820
1927
|
draggingIds: t,
|
|
1821
1928
|
provisionalIds: n,
|
|
1822
1929
|
editingSocket: s,
|
|
1823
1930
|
onSocketInput: c,
|
|
1824
1931
|
onSocketCommit: p,
|
|
1825
|
-
onSocketCancelEdit:
|
|
1826
|
-
onParamRemove:
|
|
1827
|
-
|
|
1932
|
+
onSocketCancelEdit: y,
|
|
1933
|
+
onParamRemove: x,
|
|
1934
|
+
onMouthOpen: k,
|
|
1935
|
+
onMouthClose: L,
|
|
1936
|
+
onOutputDrag: T
|
|
1828
1937
|
},
|
|
1829
|
-
|
|
1938
|
+
S.instanceId
|
|
1830
1939
|
)),
|
|
1831
|
-
|
|
1940
|
+
W
|
|
1832
1941
|
]
|
|
1833
1942
|
}
|
|
1834
1943
|
);
|
|
1835
1944
|
}
|
|
1836
1945
|
);
|
|
1837
|
-
|
|
1838
|
-
function
|
|
1839
|
-
const t =
|
|
1840
|
-
return /* @__PURE__ */ l("div", { style: { display: "flex", gap: 4 }, children:
|
|
1946
|
+
io.displayName = "Canvas";
|
|
1947
|
+
function Vr({ onSelect: e }) {
|
|
1948
|
+
const t = Q();
|
|
1949
|
+
return /* @__PURE__ */ l("div", { style: { display: "flex", gap: 4 }, children: at.map((n) => /* @__PURE__ */ l("button", { onClick: () => e(n), style: {
|
|
1841
1950
|
background: t.id === n.id ? t.switcherActiveBg : t.switcherBg,
|
|
1842
1951
|
border: `1px solid ${t.switcherBorder}`,
|
|
1843
1952
|
borderRadius: 4,
|
|
@@ -1850,8 +1959,8 @@ function br({ onSelect: e }) {
|
|
|
1850
1959
|
transition: "color 0.1s, background 0.1s"
|
|
1851
1960
|
}, children: n.label }, n.id)) });
|
|
1852
1961
|
}
|
|
1853
|
-
function
|
|
1854
|
-
const s =
|
|
1962
|
+
function Yr({ canUndo: e, canRedo: t, onUndo: n, onRedo: o, notice: r, extra: i }) {
|
|
1963
|
+
const s = Q(), c = (p) => ({
|
|
1855
1964
|
width: 28,
|
|
1856
1965
|
height: 24,
|
|
1857
1966
|
padding: 0,
|
|
@@ -1864,15 +1973,15 @@ function Ir({ canUndo: e, canRedo: t, onUndo: n, onRedo: r, notice: o, extra: i
|
|
|
1864
1973
|
cursor: p ? "pointer" : "default",
|
|
1865
1974
|
opacity: p ? 1 : 0.5
|
|
1866
1975
|
});
|
|
1867
|
-
return /* @__PURE__ */
|
|
1868
|
-
|
|
1976
|
+
return /* @__PURE__ */ m("div", { style: { position: "absolute", top: 8, right: 8, display: "flex", alignItems: "center", gap: 6, pointerEvents: "none" }, children: [
|
|
1977
|
+
r && /* @__PURE__ */ l("span", { style: {
|
|
1869
1978
|
fontSize: 11,
|
|
1870
1979
|
color: s.textPrimary,
|
|
1871
1980
|
background: s.paletteBg,
|
|
1872
1981
|
border: `1px solid ${s.accent}`,
|
|
1873
1982
|
borderRadius: 4,
|
|
1874
1983
|
padding: "3px 8px"
|
|
1875
|
-
}, children:
|
|
1984
|
+
}, children: r }),
|
|
1876
1985
|
i && /* @__PURE__ */ l("div", { style: { pointerEvents: "auto" }, children: i }),
|
|
1877
1986
|
/* @__PURE__ */ l(
|
|
1878
1987
|
"button",
|
|
@@ -1893,48 +2002,48 @@ function Ir({ canUndo: e, canRedo: t, onUndo: n, onRedo: r, notice: o, extra: i
|
|
|
1893
2002
|
title: "Redo (Ctrl+Shift+Z)",
|
|
1894
2003
|
"aria-label": "Redo",
|
|
1895
2004
|
disabled: !t,
|
|
1896
|
-
onClick:
|
|
2005
|
+
onClick: o,
|
|
1897
2006
|
style: { ...c(t), pointerEvents: "auto" },
|
|
1898
2007
|
children: "↷"
|
|
1899
2008
|
}
|
|
1900
2009
|
)
|
|
1901
2010
|
] });
|
|
1902
2011
|
}
|
|
1903
|
-
function
|
|
2012
|
+
function Fr(e) {
|
|
1904
2013
|
try {
|
|
1905
2014
|
return localStorage.getItem(e);
|
|
1906
2015
|
} catch {
|
|
1907
2016
|
return null;
|
|
1908
2017
|
}
|
|
1909
2018
|
}
|
|
1910
|
-
function
|
|
2019
|
+
function Xr(e, t) {
|
|
1911
2020
|
try {
|
|
1912
2021
|
localStorage.setItem(e, t);
|
|
1913
2022
|
} catch {
|
|
1914
2023
|
}
|
|
1915
2024
|
}
|
|
1916
|
-
let
|
|
1917
|
-
function
|
|
1918
|
-
|
|
2025
|
+
let _e = null;
|
|
2026
|
+
function jr(e) {
|
|
2027
|
+
_e === null && (_e = e);
|
|
1919
2028
|
}
|
|
1920
|
-
function
|
|
1921
|
-
|
|
2029
|
+
function Kr(e) {
|
|
2030
|
+
_e === e && (_e = null);
|
|
1922
2031
|
}
|
|
1923
|
-
function
|
|
1924
|
-
|
|
2032
|
+
function Qr(e) {
|
|
2033
|
+
_e = e;
|
|
1925
2034
|
}
|
|
1926
|
-
function
|
|
1927
|
-
return
|
|
2035
|
+
function Gr(e) {
|
|
2036
|
+
return _e === null || _e === e;
|
|
1928
2037
|
}
|
|
1929
|
-
function
|
|
1930
|
-
const n =
|
|
1931
|
-
return /* @__PURE__ */
|
|
2038
|
+
function Zr({ writers: e, onExport: t }) {
|
|
2039
|
+
const n = Q(), [o, r] = B(!1);
|
|
2040
|
+
return /* @__PURE__ */ m("div", { style: { position: "relative" }, children: [
|
|
1932
2041
|
/* @__PURE__ */ l(
|
|
1933
2042
|
"button",
|
|
1934
2043
|
{
|
|
1935
2044
|
type: "button",
|
|
1936
|
-
onClick: () =>
|
|
1937
|
-
"aria-expanded":
|
|
2045
|
+
onClick: () => r((i) => !i),
|
|
2046
|
+
"aria-expanded": o,
|
|
1938
2047
|
style: {
|
|
1939
2048
|
height: 24,
|
|
1940
2049
|
padding: "0 8px",
|
|
@@ -1948,7 +2057,7 @@ function Cr({ writers: e, onExport: t }) {
|
|
|
1948
2057
|
children: "Export ▾"
|
|
1949
2058
|
}
|
|
1950
2059
|
),
|
|
1951
|
-
|
|
2060
|
+
o && /* @__PURE__ */ l("div", { role: "menu", style: {
|
|
1952
2061
|
position: "absolute",
|
|
1953
2062
|
top: 28,
|
|
1954
2063
|
right: 0,
|
|
@@ -1958,13 +2067,13 @@ function Cr({ writers: e, onExport: t }) {
|
|
|
1958
2067
|
border: `1px solid ${n.border}`,
|
|
1959
2068
|
borderRadius: 4,
|
|
1960
2069
|
padding: 3
|
|
1961
|
-
}, children: e.map((i) => /* @__PURE__ */
|
|
2070
|
+
}, children: e.map((i) => /* @__PURE__ */ m(
|
|
1962
2071
|
"button",
|
|
1963
2072
|
{
|
|
1964
2073
|
type: "button",
|
|
1965
2074
|
role: "menuitem",
|
|
1966
2075
|
onClick: () => {
|
|
1967
|
-
|
|
2076
|
+
r(!1), t(i);
|
|
1968
2077
|
},
|
|
1969
2078
|
style: {
|
|
1970
2079
|
display: "block",
|
|
@@ -1980,7 +2089,7 @@ function Cr({ writers: e, onExport: t }) {
|
|
|
1980
2089
|
children: [
|
|
1981
2090
|
i.label,
|
|
1982
2091
|
" ",
|
|
1983
|
-
/* @__PURE__ */
|
|
2092
|
+
/* @__PURE__ */ m("span", { style: { color: n.textMuted }, children: [
|
|
1984
2093
|
".",
|
|
1985
2094
|
i.fileExtension
|
|
1986
2095
|
] })
|
|
@@ -1990,40 +2099,40 @@ function Cr({ writers: e, onExport: t }) {
|
|
|
1990
2099
|
)) })
|
|
1991
2100
|
] });
|
|
1992
2101
|
}
|
|
1993
|
-
function
|
|
1994
|
-
const n =
|
|
1995
|
-
if (!n) return { w: 160, h:
|
|
1996
|
-
const
|
|
1997
|
-
return { w:
|
|
1998
|
-
}
|
|
1999
|
-
function
|
|
2000
|
-
const
|
|
2001
|
-
return /* @__PURE__ */ l("g", { style: { pointerEvents: "none" }, children: e.map((
|
|
2002
|
-
const { color: i } =
|
|
2003
|
-
if (
|
|
2004
|
-
const c = t.get(
|
|
2005
|
-
p &&
|
|
2006
|
-
/* @__PURE__ */
|
|
2007
|
-
/* @__PURE__ */ l("path", { d:
|
|
2008
|
-
/* @__PURE__ */
|
|
2009
|
-
|
|
2102
|
+
function Jr(e, t) {
|
|
2103
|
+
const n = N(e.definitionId);
|
|
2104
|
+
if (!n) return { w: 160, h: je };
|
|
2105
|
+
const o = n.blockType === "query" ? en(e, t) : to(e.instanceId, t);
|
|
2106
|
+
return { w: fe(n, e.paramSlots, t), h: o };
|
|
2107
|
+
}
|
|
2108
|
+
function ei({ peers: e, blocks: t, layout: n }) {
|
|
2109
|
+
const o = Q();
|
|
2110
|
+
return /* @__PURE__ */ l("g", { style: { pointerEvents: "none" }, children: e.map((r) => {
|
|
2111
|
+
const { color: i } = r, s = [];
|
|
2112
|
+
if (r.typing) {
|
|
2113
|
+
const c = t.get(r.typing.blockId), p = n.get(r.typing.blockId), y = c && N(c.definitionId), x = y && c && Je(y, c.paramSlots, t).find((k) => k.index === r.typing.slot);
|
|
2114
|
+
p && x && s.push(
|
|
2115
|
+
/* @__PURE__ */ m("g", { transform: `translate(${p.x + x.x},${p.y + x.y})`, children: [
|
|
2116
|
+
/* @__PURE__ */ l("path", { d: nn(x.type, x.w, x.h), fill: o.socketBody, stroke: i, strokeWidth: 2 }),
|
|
2117
|
+
/* @__PURE__ */ m("text", { x: x.w / 2, y: x.h / 2 + 4, textAnchor: "middle", fill: i, fontSize: 10, fontFamily: "sans-serif", children: [
|
|
2118
|
+
r.typing.text,
|
|
2010
2119
|
"|"
|
|
2011
2120
|
] })
|
|
2012
2121
|
] }, "typing")
|
|
2013
2122
|
);
|
|
2014
2123
|
}
|
|
2015
|
-
if (
|
|
2016
|
-
const c = t.get(
|
|
2124
|
+
if (r.drag && "leadId" in r.drag) {
|
|
2125
|
+
const c = t.get(r.drag.leadId), p = n.get(r.drag.leadId);
|
|
2017
2126
|
if (c && p) {
|
|
2018
|
-
const { w:
|
|
2127
|
+
const { w: y, h: x } = Jr(c, t);
|
|
2019
2128
|
s.push(
|
|
2020
2129
|
/* @__PURE__ */ l(
|
|
2021
2130
|
"rect",
|
|
2022
2131
|
{
|
|
2023
2132
|
x: p.x - 3,
|
|
2024
2133
|
y: p.y - 3,
|
|
2025
|
-
width:
|
|
2026
|
-
height:
|
|
2134
|
+
width: y + 6,
|
|
2135
|
+
height: x + 6,
|
|
2027
2136
|
rx: 5,
|
|
2028
2137
|
fill: "none",
|
|
2029
2138
|
stroke: i,
|
|
@@ -2032,39 +2141,39 @@ function Er({ peers: e, blocks: t, layout: n }) {
|
|
|
2032
2141
|
},
|
|
2033
2142
|
"origin"
|
|
2034
2143
|
),
|
|
2035
|
-
/* @__PURE__ */
|
|
2036
|
-
/* @__PURE__ */ l(
|
|
2037
|
-
/* @__PURE__ */ l("rect", { x: -3, y: -3, width:
|
|
2144
|
+
/* @__PURE__ */ m("g", { transform: `translate(${r.drag.at.x},${r.drag.at.y})`, opacity: 0.5, children: [
|
|
2145
|
+
/* @__PURE__ */ l(wt, { block: c, allBlocks: t, isGhost: !0 }),
|
|
2146
|
+
/* @__PURE__ */ l("rect", { x: -3, y: -3, width: y + 6, height: x + 6, rx: 5, fill: "none", stroke: i, strokeWidth: 1.5 })
|
|
2038
2147
|
] }, "ghost")
|
|
2039
2148
|
);
|
|
2040
2149
|
}
|
|
2041
2150
|
}
|
|
2042
|
-
if (
|
|
2043
|
-
const c =
|
|
2151
|
+
if (r.drag && "definitionId" in r.drag) {
|
|
2152
|
+
const c = N(r.drag.definitionId), p = c ? fe(c) : 120, y = c ? Ce(c) : je;
|
|
2044
2153
|
s.push(
|
|
2045
|
-
/* @__PURE__ */
|
|
2046
|
-
/* @__PURE__ */ l("rect", { width: p, height:
|
|
2047
|
-
/* @__PURE__ */ l("text", { x: 8, y:
|
|
2154
|
+
/* @__PURE__ */ m("g", { transform: `translate(${r.drag.at.x},${r.drag.at.y})`, children: [
|
|
2155
|
+
/* @__PURE__ */ l("rect", { width: p, height: y, rx: 4, fill: i, fillOpacity: 0.12, stroke: i, strokeWidth: 1.5, strokeDasharray: "5,3" }),
|
|
2156
|
+
/* @__PURE__ */ l("text", { x: 8, y: y / 2 + 4, fill: i, fontSize: 11, fontWeight: "bold", fontFamily: "sans-serif", children: c?.name ?? r.drag.definitionId })
|
|
2048
2157
|
] }, "new")
|
|
2049
2158
|
);
|
|
2050
2159
|
}
|
|
2051
|
-
if (
|
|
2052
|
-
const c =
|
|
2160
|
+
if (r.cursor) {
|
|
2161
|
+
const c = r.name.length * 6.5 + 10;
|
|
2053
2162
|
s.push(
|
|
2054
|
-
/* @__PURE__ */
|
|
2163
|
+
/* @__PURE__ */ m("g", { transform: `translate(${r.cursor.x},${r.cursor.y})`, children: [
|
|
2055
2164
|
/* @__PURE__ */ l("path", { d: "M 0 0 L 0 14 L 4 10.5 L 7 17 L 9.5 16 L 6.5 9.5 L 11 9.5 Z", fill: i, stroke: "white", strokeWidth: 1 }),
|
|
2056
2165
|
/* @__PURE__ */ l("rect", { x: 12, y: 14, width: c, height: 16, rx: 3, fill: i }),
|
|
2057
|
-
/* @__PURE__ */ l("text", { x: 17, y: 26, fill: "white", fontSize: 10, fontFamily: "sans-serif", children:
|
|
2166
|
+
/* @__PURE__ */ l("text", { x: 17, y: 26, fill: "white", fontSize: 10, fontFamily: "sans-serif", children: r.name })
|
|
2058
2167
|
] }, "cursor")
|
|
2059
2168
|
);
|
|
2060
2169
|
}
|
|
2061
|
-
return /* @__PURE__ */ l("g", { children: s },
|
|
2170
|
+
return /* @__PURE__ */ l("g", { children: s }, r.clientId);
|
|
2062
2171
|
}) });
|
|
2063
2172
|
}
|
|
2064
|
-
const
|
|
2065
|
-
function
|
|
2066
|
-
const
|
|
2067
|
-
return t === "HOST_REJECTED" ? `${
|
|
2173
|
+
const ti = "local";
|
|
2174
|
+
function ni(e, t, n) {
|
|
2175
|
+
const o = e === "undo" ? "Couldn't undo" : e === "redo" ? "Couldn't redo" : "Your change was undone";
|
|
2176
|
+
return t === "HOST_REJECTED" ? `${o}: ${n}` : `${o}: ${{
|
|
2068
2177
|
TEXT_CHANGED: "someone else changed that parameter",
|
|
2069
2178
|
PLACE_OCCUPIED: "someone else put a block there first",
|
|
2070
2179
|
BLOCK_NOT_FOUND: "a block it needs was deleted",
|
|
@@ -2075,40 +2184,40 @@ function Mr(e, t, n) {
|
|
|
2075
2184
|
DEPENDENCIES_CHANGED: "someone else changed the packages"
|
|
2076
2185
|
}[t] ?? "the canvas has changed"}.`;
|
|
2077
2186
|
}
|
|
2078
|
-
function
|
|
2187
|
+
function ut() {
|
|
2079
2188
|
if (typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
2080
2189
|
const e = crypto.getRandomValues(new Uint8Array(16));
|
|
2081
2190
|
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
2082
2191
|
const t = [...e].map((n) => n.toString(16).padStart(2, "0")).join("");
|
|
2083
2192
|
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
2084
2193
|
}
|
|
2085
|
-
function
|
|
2194
|
+
function oi(e, t) {
|
|
2086
2195
|
return e.embeddedInBlockId ? t.get(e.embeddedInBlockId)?.paramSlots[e.embeddedSlotIndex]?.commandBlockId === e.instanceId : !1;
|
|
2087
2196
|
}
|
|
2088
|
-
function
|
|
2197
|
+
function ri(e) {
|
|
2089
2198
|
return e.kind === "next" ? { next: e.blockId } : { mouth: e.blockId, slot: e.slotIndex };
|
|
2090
2199
|
}
|
|
2091
|
-
async function
|
|
2200
|
+
async function Tn(e, t) {
|
|
2092
2201
|
if (!e || !t) return !1;
|
|
2093
|
-
const n = new Map(e.map((s) => [
|
|
2094
|
-
|
|
2202
|
+
const n = new Map(e.map((s) => [Ye(s), s])), o = new Set(Fe().map((s) => s.info.id).filter((s) => s.startsWith(It))), r = [...o].filter((s) => !n.has(s)), i = [...n].filter(([s]) => !o.has(s));
|
|
2203
|
+
r.forEach(Qt);
|
|
2095
2204
|
for (const [s, c] of i)
|
|
2096
|
-
await
|
|
2097
|
-
return
|
|
2098
|
-
}
|
|
2099
|
-
function
|
|
2100
|
-
const t = new Map(
|
|
2101
|
-
return e.forEach((
|
|
2102
|
-
const
|
|
2103
|
-
if (!
|
|
2104
|
-
const i = t.get(
|
|
2205
|
+
await Kt({ id: s, name: te(c), description: "", url: t(c), builtIn: !1 });
|
|
2206
|
+
return r.length > 0 || i.length > 0;
|
|
2207
|
+
}
|
|
2208
|
+
function ii(e) {
|
|
2209
|
+
const t = new Map(Fe().map((o) => [o.info.id, o.info.name])), n = /* @__PURE__ */ new Map();
|
|
2210
|
+
return e.forEach((o) => {
|
|
2211
|
+
const r = zn(o.definitionId);
|
|
2212
|
+
if (!r?.startsWith(It)) return;
|
|
2213
|
+
const i = t.get(r);
|
|
2105
2214
|
n.set(i, (n.get(i) ?? 0) + 1);
|
|
2106
2215
|
}), n;
|
|
2107
2216
|
}
|
|
2108
|
-
function
|
|
2109
|
-
const
|
|
2217
|
+
function si(e, t, n) {
|
|
2218
|
+
const o = yt(e);
|
|
2110
2219
|
return {
|
|
2111
|
-
instanceId:
|
|
2220
|
+
instanceId: ut(),
|
|
2112
2221
|
definitionId: e,
|
|
2113
2222
|
x: t,
|
|
2114
2223
|
y: n,
|
|
@@ -2116,325 +2225,343 @@ function Nr(e, t, n) {
|
|
|
2116
2225
|
parentBlockId: null,
|
|
2117
2226
|
embeddedInBlockId: null,
|
|
2118
2227
|
embeddedSlotIndex: -1,
|
|
2119
|
-
paramSlots:
|
|
2228
|
+
paramSlots: o.params.map(() => ({ textValue: null, queryBlockId: null, commandBlockId: null }))
|
|
2120
2229
|
};
|
|
2121
2230
|
}
|
|
2122
|
-
function
|
|
2231
|
+
function Ut(e, t) {
|
|
2123
2232
|
const n = [];
|
|
2124
|
-
let
|
|
2125
|
-
for (;
|
|
2126
|
-
n.push(
|
|
2233
|
+
let o = e;
|
|
2234
|
+
for (; o; )
|
|
2235
|
+
n.push(o), o = t.get(o)?.nextBlockId ?? null;
|
|
2127
2236
|
return n;
|
|
2128
2237
|
}
|
|
2129
|
-
function
|
|
2238
|
+
function Vt(e, t) {
|
|
2130
2239
|
const n = t.get(e);
|
|
2131
|
-
return n?.parentBlockId ?
|
|
2240
|
+
return n?.parentBlockId ? Vt(n.parentBlockId, t) : n && oi(n, t) ? Vt(n.embeddedInBlockId, t) : e;
|
|
2132
2241
|
}
|
|
2133
|
-
function
|
|
2134
|
-
const n =
|
|
2242
|
+
function Yt(e, t) {
|
|
2243
|
+
const n = N(e.definitionId);
|
|
2135
2244
|
if (!n) return `[missing:${e.definitionId}]`;
|
|
2136
|
-
const
|
|
2245
|
+
const o = e.paramSlots.map((r, i) => {
|
|
2137
2246
|
const s = n.params[i];
|
|
2138
|
-
if (s &&
|
|
2139
|
-
const p = (
|
|
2247
|
+
if (s && xe(n, s)) {
|
|
2248
|
+
const p = (r.commandBlockId ? Ut(r.commandBlockId, t) : []).map((y) => t.get(y)).filter(Boolean).map((y) => Yt(y, t));
|
|
2140
2249
|
return p.length > 0 ? `{ ${p.join("; ")} }` : "{ }";
|
|
2141
2250
|
}
|
|
2142
|
-
if (
|
|
2143
|
-
const c = t.get(
|
|
2144
|
-
if (c) return
|
|
2251
|
+
if (r.queryBlockId) {
|
|
2252
|
+
const c = t.get(r.queryBlockId);
|
|
2253
|
+
if (c) return Yt(c, t);
|
|
2145
2254
|
}
|
|
2146
|
-
return
|
|
2255
|
+
return r.textValue !== null && r.textValue !== void 0 ? n.params[i]?.type === "string" ? `"${r.textValue}"` : r.textValue : "_";
|
|
2147
2256
|
});
|
|
2148
|
-
return `${n.id}(${
|
|
2257
|
+
return `${n.id}(${o.join(", ")})`;
|
|
2149
2258
|
}
|
|
2150
|
-
function
|
|
2151
|
-
const n =
|
|
2259
|
+
function ci({ ghostPos: e, blocks: t }) {
|
|
2260
|
+
const n = Q();
|
|
2152
2261
|
if (!e) return null;
|
|
2153
2262
|
if (e.instanceId) {
|
|
2154
2263
|
const p = t.get(e.instanceId);
|
|
2155
2264
|
if (p)
|
|
2156
|
-
return /* @__PURE__ */ l("svg", { style: { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", pointerEvents: "none", zIndex: 9999 }, children: /* @__PURE__ */ l("g", { transform: `translate(${e.x},${e.y})`, opacity: 0.8, children: /* @__PURE__ */ l(
|
|
2265
|
+
return /* @__PURE__ */ l("svg", { style: { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", pointerEvents: "none", zIndex: 9999 }, children: /* @__PURE__ */ l("g", { transform: `translate(${e.x},${e.y})`, opacity: 0.8, children: /* @__PURE__ */ l(wt, { block: p, allBlocks: t, isGhost: !0 }) }) });
|
|
2157
2266
|
}
|
|
2158
|
-
const
|
|
2159
|
-
return /* @__PURE__ */
|
|
2267
|
+
const o = yt(e.defId), r = Ce(o), i = o.blockType === "command", s = on(o), c = Ae(o);
|
|
2268
|
+
return /* @__PURE__ */ m("svg", { style: { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", pointerEvents: "none", zIndex: 9999 }, children: [
|
|
2160
2269
|
i && /* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("clipPath", { id: "ghost-pal-clip", children: /* @__PURE__ */ l("path", { d: s }) }) }),
|
|
2161
|
-
/* @__PURE__ */
|
|
2162
|
-
/* @__PURE__ */ l("path", { d: s, fill: i ? n.blockBody :
|
|
2163
|
-
i && /* @__PURE__ */ l("rect", { x: 0, y: 0, width: 4, height:
|
|
2164
|
-
c.length > 0 && /* @__PURE__ */ l(
|
|
2270
|
+
/* @__PURE__ */ m("g", { transform: `translate(${e.x},${e.y})`, opacity: 0.8, children: [
|
|
2271
|
+
/* @__PURE__ */ l("path", { d: s, fill: i ? n.blockBody : o.color, stroke: i ? n.blockBorder : "rgba(0,0,0,0.4)", strokeWidth: 1.5 }),
|
|
2272
|
+
i && /* @__PURE__ */ l("rect", { x: 0, y: 0, width: 4, height: r + 20, fill: o.color, clipPath: "url(#ghost-pal-clip)" }),
|
|
2273
|
+
c.length > 0 && /* @__PURE__ */ l(cn, { mouths: c, w: fe(o), isEmpty: () => !0 }),
|
|
2274
|
+
/* @__PURE__ */ l(sn, { chips: Ze(o) }),
|
|
2165
2275
|
/* @__PURE__ */ l(
|
|
2166
2276
|
"text",
|
|
2167
2277
|
{
|
|
2168
2278
|
x: 11,
|
|
2169
|
-
y:
|
|
2279
|
+
y: We(o) / 2 + 4,
|
|
2170
2280
|
fill: i ? n.blockText : "white",
|
|
2171
2281
|
fontSize: 11,
|
|
2172
2282
|
fontWeight: "bold",
|
|
2173
2283
|
fontFamily: "sans-serif",
|
|
2174
2284
|
style: { userSelect: "none" },
|
|
2175
|
-
children:
|
|
2285
|
+
children: o.name
|
|
2176
2286
|
}
|
|
2177
2287
|
)
|
|
2178
2288
|
] })
|
|
2179
2289
|
] });
|
|
2180
2290
|
}
|
|
2181
|
-
function
|
|
2291
|
+
function li(e, t) {
|
|
2182
2292
|
return e.returnType === t || (e.usableAs?.includes(t) ?? !1);
|
|
2183
2293
|
}
|
|
2184
|
-
function
|
|
2294
|
+
function hi({
|
|
2185
2295
|
blocksUrl: e = "/blocks.json",
|
|
2186
2296
|
blocksUrls: t,
|
|
2187
2297
|
onRun: n,
|
|
2188
|
-
onThemeChange:
|
|
2189
|
-
navTabs:
|
|
2298
|
+
onThemeChange: o,
|
|
2299
|
+
navTabs: r,
|
|
2190
2300
|
initialState: i,
|
|
2191
2301
|
onSave: s,
|
|
2192
2302
|
themeId: c,
|
|
2193
2303
|
hideTitleBar: p,
|
|
2194
|
-
getStateRef:
|
|
2195
|
-
additionalBlocks:
|
|
2196
|
-
dependencies:
|
|
2197
|
-
onDependenciesChange:
|
|
2198
|
-
packageBlocksUrl:
|
|
2304
|
+
getStateRef: y,
|
|
2305
|
+
additionalBlocks: x,
|
|
2306
|
+
dependencies: k,
|
|
2307
|
+
onDependenciesChange: L,
|
|
2308
|
+
packageBlocksUrl: T,
|
|
2199
2309
|
availablePackages: W,
|
|
2200
|
-
packageActions:
|
|
2201
|
-
collaboration:
|
|
2202
|
-
scriptWriters:
|
|
2203
|
-
onExport:
|
|
2310
|
+
packageActions: z,
|
|
2311
|
+
collaboration: Y,
|
|
2312
|
+
scriptWriters: q,
|
|
2313
|
+
onExport: S
|
|
2204
2314
|
}) {
|
|
2205
|
-
const [
|
|
2206
|
-
if (c) return
|
|
2207
|
-
const a =
|
|
2208
|
-
return
|
|
2209
|
-
}), [
|
|
2210
|
-
c !==
|
|
2211
|
-
const [
|
|
2212
|
-
blocks: new Map((i?.blocks ?? []).map(([a, d]) => [a,
|
|
2213
|
-
dependencies:
|
|
2214
|
-
})), { state:
|
|
2215
|
-
|
|
2216
|
-
|
|
2315
|
+
const [g, ne] = B(() => {
|
|
2316
|
+
if (c) return at.find((d) => d.id === c) ?? Xe;
|
|
2317
|
+
const a = Fr("cardcq-theme");
|
|
2318
|
+
return at.find((d) => d.id === a) ?? Xe;
|
|
2319
|
+
}), [G, oe] = B(c);
|
|
2320
|
+
c !== G && (oe(c), c && ne(at.find((a) => a.id === c) ?? Xe));
|
|
2321
|
+
const [Z, b] = B(!1), [U, F] = B(null), H = Y?.commands, he = Y?.clientId ?? ti, [ce, qe] = B(() => Rn({
|
|
2322
|
+
blocks: new Map((i?.blocks ?? []).map(([a, d]) => [a, Me(d)])),
|
|
2323
|
+
dependencies: k ?? []
|
|
2324
|
+
})), { state: pe, provisionalIds: et } = Ne(() => wn(ce), [ce]), D = pe.blocks, u = se(ce), _ = se(pe);
|
|
2325
|
+
ee(() => {
|
|
2326
|
+
u.current = ce, _.current = pe;
|
|
2217
2327
|
});
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
|
|
2328
|
+
const X = (k ?? []).map(Ye).join("|"), [J, le] = B(X);
|
|
2329
|
+
X !== J && (le(X), !H && X !== ce.confirmed.dependencies.map(Ye).join("|") && qe((a) => ({ ...a, confirmed: { ...a.confirmed, dependencies: k ?? [] } })));
|
|
2330
|
+
const ke = se(L);
|
|
2331
|
+
ee(() => {
|
|
2332
|
+
ke.current = L;
|
|
2223
2333
|
});
|
|
2224
|
-
const [
|
|
2225
|
-
|
|
2334
|
+
const [ve, Oe] = B(null), be = se(null), re = C((a) => {
|
|
2335
|
+
Oe(a), be.current && clearTimeout(be.current), be.current = setTimeout(() => Oe(null), 5e3);
|
|
2226
2336
|
}, []);
|
|
2227
|
-
|
|
2228
|
-
|
|
2337
|
+
ee(() => () => {
|
|
2338
|
+
be.current && clearTimeout(be.current);
|
|
2229
2339
|
}, []);
|
|
2230
|
-
const
|
|
2231
|
-
const d =
|
|
2232
|
-
|
|
2233
|
-
}, []),
|
|
2234
|
-
const h = { id: d, clientId:
|
|
2235
|
-
if (
|
|
2236
|
-
|
|
2340
|
+
const ae = C((a) => {
|
|
2341
|
+
const d = u.current;
|
|
2342
|
+
u.current = a, _.current = wn(a).state, qe(a), a.confirmed.dependencies !== d.confirmed.dependencies && ke.current?.(a.confirmed.dependencies);
|
|
2343
|
+
}, []), ge = C((a, d, f) => {
|
|
2344
|
+
const h = { id: d, clientId: he, baseVersion: u.current.version, command: f };
|
|
2345
|
+
if (H) {
|
|
2346
|
+
ae(a), H.submit(h);
|
|
2237
2347
|
return;
|
|
2238
2348
|
}
|
|
2239
|
-
const I =
|
|
2240
|
-
I.outOfSync ? (
|
|
2241
|
-
}, [
|
|
2349
|
+
const I = $n(a, h, a.version + 1);
|
|
2350
|
+
I.outOfSync ? (ae(Sn(a, d).sync), re("That change couldn't be made: the canvas has changed.")) : ae(I.sync);
|
|
2351
|
+
}, [he, H, ae, re]), v = C((a) => {
|
|
2242
2352
|
if (!a) return;
|
|
2243
|
-
const d =
|
|
2244
|
-
|
|
2245
|
-
}, [
|
|
2246
|
-
const a =
|
|
2247
|
-
d &&
|
|
2248
|
-
}, [
|
|
2249
|
-
const a =
|
|
2250
|
-
d &&
|
|
2251
|
-
}, [
|
|
2252
|
-
|
|
2253
|
-
if (!
|
|
2254
|
-
const a = new
|
|
2255
|
-
|
|
2256
|
-
const d =
|
|
2353
|
+
const d = ut();
|
|
2354
|
+
ge(tr(u.current, d, a), d, a);
|
|
2355
|
+
}, [ge]), Bt = C(() => {
|
|
2356
|
+
const a = ut(), d = nr(u.current, a);
|
|
2357
|
+
d && ge(d.sync, a, d.command);
|
|
2358
|
+
}, [ge]), Ct = C(() => {
|
|
2359
|
+
const a = ut(), d = or(u.current, a);
|
|
2360
|
+
d && ge(d.sync, a, d.command);
|
|
2361
|
+
}, [ge]), tt = Y?.presence, an = Y?.presenceIntervalMs ?? Hn, de = se(null), [dn, un] = B([]);
|
|
2362
|
+
ee(() => {
|
|
2363
|
+
if (!tt) return;
|
|
2364
|
+
const a = new sr((f) => tt.publish(f), an);
|
|
2365
|
+
de.current = a;
|
|
2366
|
+
const d = tt.subscribe((f) => un(f.filter((h) => h.clientId !== he)));
|
|
2257
2367
|
return () => {
|
|
2258
|
-
a.updateNow({ cursor: null, drag: null, typing: null }), a.dispose(),
|
|
2368
|
+
a.updateNow({ cursor: null, drag: null, typing: null }), a.dispose(), de.current = null, d(), un([]);
|
|
2259
2369
|
};
|
|
2260
|
-
}, [
|
|
2261
|
-
if (
|
|
2262
|
-
return
|
|
2370
|
+
}, [tt, an, he]), ee(() => {
|
|
2371
|
+
if (H)
|
|
2372
|
+
return H.subscribe((a) => {
|
|
2263
2373
|
if (a.type === "snapshot") {
|
|
2264
2374
|
const d = {
|
|
2265
|
-
blocks: new Map(a.state.blocks.map(([h, I]) => [h,
|
|
2375
|
+
blocks: new Map(a.state.blocks.map(([h, I]) => [h, Me(I)])),
|
|
2266
2376
|
dependencies: a.state.dependencies
|
|
2267
|
-
},
|
|
2268
|
-
|
|
2377
|
+
}, f = rr(d, a.version, u.current);
|
|
2378
|
+
ae(f.sync), f.dropped > 0 && re("Reloaded from the server: your unconfirmed changes were discarded.");
|
|
2269
2379
|
} else if (a.type === "applied") {
|
|
2270
|
-
const d =
|
|
2271
|
-
d.outOfSync ? (
|
|
2380
|
+
const d = $n(u.current, a.envelope, a.version);
|
|
2381
|
+
d.outOfSync ? (re("Out of sync with the server: reloading…"), H.resync?.()) : ae(d.sync);
|
|
2272
2382
|
} else {
|
|
2273
|
-
const d =
|
|
2274
|
-
|
|
2383
|
+
const d = Sn(u.current, a.id);
|
|
2384
|
+
ae(d.sync), d.action && re(ni(d.action.kind, a.code, a.message));
|
|
2275
2385
|
}
|
|
2276
2386
|
});
|
|
2277
|
-
}, [
|
|
2278
|
-
const [
|
|
2279
|
-
|
|
2280
|
-
const
|
|
2281
|
-
|
|
2387
|
+
}, [H, ae, re]);
|
|
2388
|
+
const [Te] = B(() => /* @__PURE__ */ Symbol("BlockEditor"));
|
|
2389
|
+
ee(() => (jr(Te), () => Kr(Te)), [Te]);
|
|
2390
|
+
const fn = C(() => Qr(Te), [Te]);
|
|
2391
|
+
ee(() => {
|
|
2282
2392
|
function a(d) {
|
|
2283
|
-
if (!
|
|
2284
|
-
const
|
|
2285
|
-
if (
|
|
2393
|
+
if (!Gr(Te)) return;
|
|
2394
|
+
const f = d.target;
|
|
2395
|
+
if (f && (f.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(f.tagName)) || !(d.ctrlKey || d.metaKey)) return;
|
|
2286
2396
|
const h = d.key.toLowerCase();
|
|
2287
|
-
h === "z" && !d.shiftKey ? (d.preventDefault(),
|
|
2397
|
+
h === "z" && !d.shiftKey ? (d.preventDefault(), Bt()) : (h === "z" && d.shiftKey || h === "y" && !d.metaKey) && (d.preventDefault(), Ct());
|
|
2288
2398
|
}
|
|
2289
2399
|
return window.addEventListener("keydown", a), () => window.removeEventListener("keydown", a);
|
|
2290
|
-
}, [
|
|
2291
|
-
const
|
|
2400
|
+
}, [Bt, Ct, Te]);
|
|
2401
|
+
const co = Ne(() => {
|
|
2292
2402
|
const a = /* @__PURE__ */ new Set();
|
|
2293
|
-
for (const d of
|
|
2294
|
-
|
|
2403
|
+
for (const d of D.values())
|
|
2404
|
+
N(d.definitionId)?.blockType === "start" && a.add(d.definitionId);
|
|
2295
2405
|
return a;
|
|
2296
|
-
}, [
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2406
|
+
}, [D]), [lo, nt] = B(null), [ao, hn] = B(/* @__PURE__ */ new Set()), [uo, pn] = B(!1), [ot, Tt] = B(0), [fo, Pt] = B([]), [rt, Et] = B(() => /* @__PURE__ */ new Set()), [gn, ho] = B(null);
|
|
2407
|
+
if (gn?.blocks !== D || gn.registryVersion !== ot) {
|
|
2408
|
+
ho({ blocks: D, registryVersion: ot });
|
|
2409
|
+
const a = vr(D);
|
|
2410
|
+
a.some((d) => !rt.has(d)) && Et(/* @__PURE__ */ new Set([...rt, ...a]));
|
|
2411
|
+
}
|
|
2412
|
+
const ie = Ne(() => br(D, rt), [D, rt]), ue = Ne(() => Tr(ie), [ie, ot]);
|
|
2413
|
+
ee(() => {
|
|
2414
|
+
y && (y.current = () => ({ blocks: [...D.entries()] }));
|
|
2415
|
+
}, [D, y]);
|
|
2416
|
+
const ye = se(null), Mt = se(!1), it = se(null), Ue = (t ?? [e]).join("|"), Dt = k !== void 0 || Y?.commands !== void 0 && T !== void 0, _t = se(Dt ? pe.dependencies : void 0), At = se(T);
|
|
2417
|
+
ee(() => {
|
|
2418
|
+
_t.current = Dt ? pe.dependencies : void 0, At.current = T;
|
|
2303
2419
|
});
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2420
|
+
const po = pe.dependencies.map(Ye).join("|"), Le = se(Promise.resolve()), [go, yo] = B(Ue);
|
|
2421
|
+
Ue !== go && (yo(Ue), b(!1), F(null)), ee(() => {
|
|
2306
2422
|
let a = !1;
|
|
2307
|
-
const d =
|
|
2308
|
-
return
|
|
2423
|
+
const d = Ue.split("|");
|
|
2424
|
+
return Le.current = Le.current.then(async () => {
|
|
2309
2425
|
if (!a)
|
|
2310
2426
|
try {
|
|
2311
|
-
await
|
|
2312
|
-
for (let
|
|
2313
|
-
await
|
|
2314
|
-
id: `__extra_${
|
|
2315
|
-
name: `Extra ${
|
|
2427
|
+
await ar(d[0]);
|
|
2428
|
+
for (let f = 1; f < d.length && !a; f++)
|
|
2429
|
+
await Kt({
|
|
2430
|
+
id: `__extra_${f}__`,
|
|
2431
|
+
name: `Extra ${f}`,
|
|
2316
2432
|
description: "",
|
|
2317
|
-
url: d[
|
|
2433
|
+
url: d[f],
|
|
2318
2434
|
builtIn: !0
|
|
2319
2435
|
});
|
|
2320
|
-
if (a || (await
|
|
2321
|
-
|
|
2322
|
-
} catch (
|
|
2323
|
-
a ||
|
|
2436
|
+
if (a || (await Tn(_t.current, At.current), a)) return;
|
|
2437
|
+
Pt(Fe()), Tt((f) => f + 1), b(!0);
|
|
2438
|
+
} catch (f) {
|
|
2439
|
+
a || F(String(f));
|
|
2324
2440
|
}
|
|
2325
2441
|
}), () => {
|
|
2326
2442
|
a = !0;
|
|
2327
2443
|
};
|
|
2328
|
-
}, [
|
|
2329
|
-
if (!
|
|
2444
|
+
}, [Ue]), ee(() => {
|
|
2445
|
+
if (!Z) return;
|
|
2330
2446
|
let a = !1;
|
|
2331
|
-
return
|
|
2447
|
+
return Le.current = Le.current.then(async () => {
|
|
2332
2448
|
if (!a)
|
|
2333
2449
|
try {
|
|
2334
|
-
if (!await
|
|
2335
|
-
|
|
2450
|
+
if (!await Tn(_t.current, At.current)) return;
|
|
2451
|
+
Pt(Fe()), Tt((f) => f + 1);
|
|
2336
2452
|
} catch (d) {
|
|
2337
|
-
|
|
2453
|
+
F(String(d));
|
|
2338
2454
|
}
|
|
2339
2455
|
}), () => {
|
|
2340
2456
|
a = !0;
|
|
2341
2457
|
};
|
|
2342
|
-
}, [
|
|
2343
|
-
if (!
|
|
2458
|
+
}, [Z, po]), ee(() => {
|
|
2459
|
+
if (!Z) return;
|
|
2344
2460
|
let a = !1;
|
|
2345
|
-
return
|
|
2461
|
+
return Le.current = Le.current.then(() => {
|
|
2346
2462
|
if (!a)
|
|
2347
2463
|
try {
|
|
2348
|
-
|
|
2464
|
+
Qt("__inline__"), x && x.length > 0 && lr(
|
|
2349
2465
|
{ id: "__inline__", name: "Inline", description: "", url: "", builtIn: !0 },
|
|
2350
|
-
|
|
2351
|
-
),
|
|
2466
|
+
x
|
|
2467
|
+
), Pt(Fe()), Tt((d) => d + 1);
|
|
2352
2468
|
} catch (d) {
|
|
2353
|
-
|
|
2469
|
+
F(String(d));
|
|
2354
2470
|
}
|
|
2355
2471
|
}), () => {
|
|
2356
2472
|
a = !0;
|
|
2357
2473
|
};
|
|
2358
|
-
}, [
|
|
2359
|
-
const
|
|
2360
|
-
const
|
|
2361
|
-
return { x: a -
|
|
2362
|
-
}, []),
|
|
2363
|
-
if (
|
|
2364
|
-
let
|
|
2365
|
-
const
|
|
2366
|
-
(!
|
|
2367
|
-
},
|
|
2368
|
-
const
|
|
2369
|
-
return
|
|
2474
|
+
}, [x, Z]);
|
|
2475
|
+
const $e = C((a, d) => {
|
|
2476
|
+
const f = it.current?.getBoundingClientRect() ?? { left: 0, top: 0 };
|
|
2477
|
+
return { x: a - f.left, y: d - f.top };
|
|
2478
|
+
}, []), yn = C((a, d, f, h, I) => {
|
|
2479
|
+
if (N(f)?.blockType !== "command") return null;
|
|
2480
|
+
let E = null;
|
|
2481
|
+
const M = (P) => {
|
|
2482
|
+
(!E || P.dist < E.dist) && (E = P);
|
|
2483
|
+
}, A = (P, V) => {
|
|
2484
|
+
const j = Math.abs(a - P), $ = Math.abs(d - V);
|
|
2485
|
+
return j < 40 && $ < 24 ? Math.hypot(j, $) : null;
|
|
2370
2486
|
};
|
|
2371
|
-
return
|
|
2487
|
+
return ie.forEach((P) => {
|
|
2372
2488
|
if (I.has(P.instanceId)) return;
|
|
2373
|
-
const
|
|
2374
|
-
if (!(!
|
|
2489
|
+
const V = N(P.definitionId), j = ue.get(P.instanceId);
|
|
2490
|
+
if (!(!V || V.blockType === "query" || !j)) {
|
|
2375
2491
|
if (!P.nextBlockId || P.nextBlockId === h) {
|
|
2376
|
-
const
|
|
2377
|
-
|
|
2492
|
+
const $ = j.y + Ce(V, P.paramSlots, ie), me = A(j.x, $);
|
|
2493
|
+
me !== null && M({ kind: "next", blockId: P.instanceId, snapX: j.x, snapY: $, dist: me });
|
|
2378
2494
|
}
|
|
2379
|
-
for (const
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2495
|
+
for (const $ of Br(V, P.paramSlots, ie)) {
|
|
2496
|
+
const me = j.x + $.x, st = j.y + $.y, ct = A(me, st);
|
|
2497
|
+
ct !== null && M({ kind: "mouth", blockId: P.instanceId, slotIndex: $.slot, snapX: me, snapY: st, dist: ct });
|
|
2382
2498
|
}
|
|
2383
2499
|
}
|
|
2384
|
-
}),
|
|
2385
|
-
}, [
|
|
2386
|
-
const
|
|
2387
|
-
if (!
|
|
2388
|
-
const
|
|
2389
|
-
let
|
|
2390
|
-
return
|
|
2391
|
-
if (I.has(
|
|
2392
|
-
const P =
|
|
2393
|
-
if (!P || !
|
|
2394
|
-
|
|
2395
|
-
if (!
|
|
2396
|
-
const
|
|
2397
|
-
if (
|
|
2398
|
-
const
|
|
2399
|
-
if (
|
|
2400
|
-
const
|
|
2401
|
-
(!
|
|
2500
|
+
}), E;
|
|
2501
|
+
}, [ie, ue]), mn = C((a, d, f, h, I) => {
|
|
2502
|
+
const w = N(f);
|
|
2503
|
+
if (!w || w.blockType !== "query") return null;
|
|
2504
|
+
const E = 20;
|
|
2505
|
+
let M = null;
|
|
2506
|
+
return ie.forEach((A) => {
|
|
2507
|
+
if (I.has(A.instanceId)) return;
|
|
2508
|
+
const P = N(A.definitionId), V = ue.get(A.instanceId);
|
|
2509
|
+
if (!P || !V) return;
|
|
2510
|
+
Je(P, A.paramSlots, ie).forEach(($) => {
|
|
2511
|
+
if (!li(w, $.type)) return;
|
|
2512
|
+
const me = A.paramSlots[$.index]?.queryBlockId;
|
|
2513
|
+
if (me && me !== h) return;
|
|
2514
|
+
const st = V.x + $.x + $.w / 2, ct = V.y + $.y + $.h / 2, kn = Math.abs(a + $.w / 2 - st), bn = Math.abs(d + $.h / 2 - ct);
|
|
2515
|
+
if (kn < $.w / 2 + E && bn < $.h / 2 + E) {
|
|
2516
|
+
const In = Math.hypot(kn, bn);
|
|
2517
|
+
(!M || In < M.dist) && (M = { blockId: A.instanceId, slotIndex: $.index, snapX: V.x + $.x, snapY: V.y + $.y, dist: In });
|
|
2402
2518
|
}
|
|
2403
2519
|
});
|
|
2404
|
-
}),
|
|
2405
|
-
}, [
|
|
2406
|
-
if (
|
|
2407
|
-
const d =
|
|
2520
|
+
}), M;
|
|
2521
|
+
}, [ie, ue]), mo = C((a) => {
|
|
2522
|
+
if (ye.current?.moved) return;
|
|
2523
|
+
const d = Vt(a, D), h = Ut(d, D).map((I) => D.get(I)).filter(Boolean).map((I) => Yt(I, D));
|
|
2408
2524
|
n?.(h);
|
|
2409
|
-
}, [
|
|
2410
|
-
if (
|
|
2411
|
-
const
|
|
2412
|
-
|
|
2413
|
-
}, []),
|
|
2414
|
-
|
|
2415
|
-
}, []),
|
|
2416
|
-
const h =
|
|
2417
|
-
|
|
2418
|
-
}, [
|
|
2419
|
-
|
|
2420
|
-
}, []),
|
|
2421
|
-
const
|
|
2525
|
+
}, [D, n]), [xo, Ot] = B(null), Ve = se(null), ko = C((a, d) => {
|
|
2526
|
+
if (ye.current?.moved) return;
|
|
2527
|
+
const f = _.current.blocks.get(a)?.paramSlots[d]?.textValue ?? null;
|
|
2528
|
+
Ve.current = { blockId: a, slotIndex: d, startText: f }, Ot(Ve.current), de.current?.updateNow({ typing: { blockId: a, slot: d, text: f ?? "" } });
|
|
2529
|
+
}, []), bo = C((a, d, f) => {
|
|
2530
|
+
de.current?.update({ typing: { blockId: a, slot: d, text: f } });
|
|
2531
|
+
}, []), Io = C((a, d, f) => {
|
|
2532
|
+
const h = Ve.current;
|
|
2533
|
+
Ve.current = null, Ot(null), !(!h || h.blockId !== a || h.slotIndex !== d) && (de.current?.updateNow({ typing: null }), v(vn(a, d, h.startText, f)));
|
|
2534
|
+
}, [v]), vo = C(() => {
|
|
2535
|
+
Ve.current = null, Ot(null), de.current?.updateNow({ typing: null });
|
|
2536
|
+
}, []), $o = C((a, d) => {
|
|
2537
|
+
const f = _.current, h = f.blocks.get(a), I = h?.paramSlots[d];
|
|
2422
2538
|
if (!h || !I) return;
|
|
2423
2539
|
if (!I.queryBlockId) {
|
|
2424
|
-
|
|
2540
|
+
v(vn(a, d, I.textValue, null));
|
|
2425
2541
|
return;
|
|
2426
2542
|
}
|
|
2427
|
-
const
|
|
2428
|
-
|
|
2429
|
-
}, [
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2543
|
+
const w = N(h.definitionId), E = ue.get(a) ?? h, M = E.x + (w ? fe(w, h.paramSlots, f.blocks) : 0) + 24;
|
|
2544
|
+
v(Rt(f, I.queryBlockId, { x: M, y: E.y }, null));
|
|
2545
|
+
}, [ue, v]), So = C((a, d) => {
|
|
2546
|
+
ye.current?.moved || Et((f) => new Set(f).add(qt(a, d)));
|
|
2547
|
+
}, []), wo = C((a, d) => {
|
|
2548
|
+
Et((M) => {
|
|
2549
|
+
const A = new Set(M);
|
|
2550
|
+
return A.delete(qt(a, d)), A;
|
|
2551
|
+
});
|
|
2552
|
+
const f = _.current, h = f.blocks.get(a);
|
|
2553
|
+
if (!h) return;
|
|
2554
|
+
const I = N(h.definitionId), w = ue.get(a) ?? h, E = w.x + (I ? fe(I, h.paramSlots, f.blocks) : 0) + 24;
|
|
2555
|
+
v(Zo(f, a, d, { x: E, y: w.y }));
|
|
2556
|
+
}, [ue, v]), Bo = C((a) => {
|
|
2557
|
+
const d = _.current, f = new Set(a.map(te)), h = new Set(d.dependencies.filter((w) => !f.has(te(w))).map(Ye)), I = [...d.blocks.values()].filter((w) => h.has(zn(w.definitionId) ?? "")).map((w) => w.instanceId);
|
|
2558
|
+
v(er(d, a, I));
|
|
2559
|
+
}, [v]), Co = C((a) => {
|
|
2560
|
+
ne(a), c || Xr("cardcq-theme", a.id), o?.(a);
|
|
2561
|
+
}, [o, c]), xn = C((a, d) => {
|
|
2435
2562
|
a.preventDefault();
|
|
2436
|
-
const
|
|
2437
|
-
|
|
2563
|
+
const f = yt(d), h = fe(f), I = Ce(f);
|
|
2564
|
+
ye.current = {
|
|
2438
2565
|
type: "palette",
|
|
2439
2566
|
defId: d,
|
|
2440
2567
|
offsetX: h / 2,
|
|
@@ -2442,86 +2569,86 @@ function Ur({
|
|
|
2442
2569
|
startClientX: a.clientX,
|
|
2443
2570
|
startClientY: a.clientY,
|
|
2444
2571
|
moved: !1
|
|
2445
|
-
},
|
|
2446
|
-
}, []),
|
|
2572
|
+
}, nt({ x: a.clientX - h / 2, y: a.clientY - I / 2, defId: d }), a.target.setPointerCapture(a.pointerId);
|
|
2573
|
+
}, []), To = C((a, d) => {
|
|
2447
2574
|
a.preventDefault();
|
|
2448
|
-
const
|
|
2449
|
-
if (!
|
|
2450
|
-
const { x: h, y: I } =
|
|
2451
|
-
|
|
2575
|
+
const f = D.get(d);
|
|
2576
|
+
if (!f) return;
|
|
2577
|
+
const { x: h, y: I } = $e(a.clientX, a.clientY), { x: w, y: E } = ue.get(d) ?? f, M = h - w, A = I - E, V = N(f.definitionId)?.blockType === "query" ? [d] : Ut(d, D);
|
|
2578
|
+
ye.current = {
|
|
2452
2579
|
type: "canvas",
|
|
2453
|
-
defId:
|
|
2580
|
+
defId: f.definitionId,
|
|
2454
2581
|
instanceId: d,
|
|
2455
|
-
carriedIds:
|
|
2456
|
-
offsetX:
|
|
2457
|
-
offsetY:
|
|
2582
|
+
carriedIds: V,
|
|
2583
|
+
offsetX: M,
|
|
2584
|
+
offsetY: A,
|
|
2458
2585
|
startClientX: a.clientX,
|
|
2459
2586
|
startClientY: a.clientY,
|
|
2460
2587
|
moved: !1
|
|
2461
|
-
},
|
|
2462
|
-
}, [
|
|
2463
|
-
|
|
2464
|
-
function a(
|
|
2465
|
-
const h =
|
|
2588
|
+
}, hn(/* @__PURE__ */ new Set([d])), nt({ x: a.clientX - M, y: a.clientY - A, defId: f.definitionId, instanceId: d }), a.target.setPointerCapture(a.pointerId);
|
|
2589
|
+
}, [D, ue, $e]);
|
|
2590
|
+
ee(() => {
|
|
2591
|
+
function a(f) {
|
|
2592
|
+
const h = ye.current;
|
|
2466
2593
|
if (!h) return;
|
|
2467
2594
|
let I = !1;
|
|
2468
|
-
if (!h.moved && (Math.abs(
|
|
2469
|
-
|
|
2470
|
-
x:
|
|
2471
|
-
y:
|
|
2595
|
+
if (!h.moved && (Math.abs(f.clientX - h.startClientX) > 4 || Math.abs(f.clientY - h.startClientY) > 4) && (h.moved = !0, I = !0), !h.moved) return;
|
|
2596
|
+
nt({
|
|
2597
|
+
x: f.clientX - h.offsetX,
|
|
2598
|
+
y: f.clientY - h.offsetY,
|
|
2472
2599
|
defId: h.defId,
|
|
2473
2600
|
instanceId: h.instanceId
|
|
2474
2601
|
});
|
|
2475
|
-
const
|
|
2476
|
-
if (I ?
|
|
2477
|
-
const
|
|
2478
|
-
|
|
2602
|
+
const w = $e(f.clientX - h.offsetX, f.clientY - h.offsetY), E = h.type === "canvas" ? { drag: { leadId: h.instanceId, at: w }, cursor: $e(f.clientX, f.clientY) } : { drag: { definitionId: h.defId, at: w }, cursor: $e(f.clientX, f.clientY) };
|
|
2603
|
+
if (I ? de.current?.updateNow(E) : de.current?.update(E), h.type === "canvas") {
|
|
2604
|
+
const M = it.current?.getBoundingClientRect(), A = !!M && f.clientX < M.left;
|
|
2605
|
+
A !== Mt.current && (Mt.current = A, pn(A));
|
|
2479
2606
|
}
|
|
2480
2607
|
}
|
|
2481
|
-
function d(
|
|
2482
|
-
const h =
|
|
2483
|
-
if (!h || (
|
|
2484
|
-
|
|
2485
|
-
const I =
|
|
2608
|
+
function d(f) {
|
|
2609
|
+
const h = ye.current;
|
|
2610
|
+
if (!h || (ye.current = null, nt(null), hn(/* @__PURE__ */ new Set()), Mt.current = !1, pn(!1), !h.moved)) return;
|
|
2611
|
+
de.current?.updateNow({ drag: null });
|
|
2612
|
+
const I = it.current?.getBoundingClientRect();
|
|
2486
2613
|
if (!I) return;
|
|
2487
|
-
const
|
|
2488
|
-
if (h.type === "canvas" &&
|
|
2489
|
-
|
|
2614
|
+
const w = _.current;
|
|
2615
|
+
if (h.type === "canvas" && f.clientX < I.left) {
|
|
2616
|
+
v(Jo(w, h.instanceId));
|
|
2490
2617
|
return;
|
|
2491
2618
|
}
|
|
2492
|
-
const
|
|
2493
|
-
let
|
|
2494
|
-
if (
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2619
|
+
const E = f.clientX - h.offsetX - I.left, M = f.clientY - h.offsetY - I.top, A = yt(h.defId), P = h.type === "canvas" ? h.instanceId : null, V = new Set(P ? $t(w.blocks, P) : []);
|
|
2620
|
+
let j = null;
|
|
2621
|
+
if (A.blockType === "query") {
|
|
2622
|
+
const $ = mn(E, M, h.defId, P, V);
|
|
2623
|
+
$ && (j = { socket: $.blockId, slot: $.slotIndex });
|
|
2497
2624
|
} else {
|
|
2498
|
-
const
|
|
2499
|
-
|
|
2625
|
+
const $ = yn(E, M, h.defId, P, V);
|
|
2626
|
+
$ && (j = ri($));
|
|
2500
2627
|
}
|
|
2501
2628
|
if (h.type === "palette") {
|
|
2502
|
-
if (
|
|
2629
|
+
if (f.clientX < I.left || f.clientX > I.right || f.clientY < I.top || f.clientY > I.bottom || A.blockType === "start" && [...w.blocks.values()].some((me) => me.definitionId === h.defId))
|
|
2503
2630
|
return;
|
|
2504
|
-
|
|
2631
|
+
v(Go(w, si(h.defId, E, M), { x: E, y: M }, j));
|
|
2505
2632
|
} else
|
|
2506
|
-
|
|
2633
|
+
v(Rt(w, P, { x: E, y: M }, j));
|
|
2507
2634
|
}
|
|
2508
2635
|
return document.addEventListener("pointermove", a), document.addEventListener("pointerup", d), () => {
|
|
2509
2636
|
document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", d);
|
|
2510
2637
|
};
|
|
2511
|
-
}, [
|
|
2512
|
-
const
|
|
2513
|
-
|
|
2514
|
-
}, [
|
|
2515
|
-
|
|
2516
|
-
}, []),
|
|
2517
|
-
const d = a.write(
|
|
2518
|
-
if (
|
|
2519
|
-
|
|
2638
|
+
}, [yn, mn, v, $e]);
|
|
2639
|
+
const Po = C((a) => {
|
|
2640
|
+
ye.current?.moved || de.current?.update({ cursor: $e(a.clientX, a.clientY) });
|
|
2641
|
+
}, [$e]), Eo = C(() => {
|
|
2642
|
+
ye.current?.moved || de.current?.updateNow({ cursor: null });
|
|
2643
|
+
}, []), Mo = C((a) => {
|
|
2644
|
+
const d = a.write(Pr(_.current, N));
|
|
2645
|
+
if (S) {
|
|
2646
|
+
S(d, a);
|
|
2520
2647
|
return;
|
|
2521
2648
|
}
|
|
2522
|
-
const
|
|
2523
|
-
h.href =
|
|
2524
|
-
}, [
|
|
2649
|
+
const f = URL.createObjectURL(new Blob([d], { type: "text/plain" })), h = document.createElement("a");
|
|
2650
|
+
h.href = f, h.download = `behavior.${a.fileExtension}`, h.click(), URL.revokeObjectURL(f);
|
|
2651
|
+
}, [S]), Lt = {
|
|
2525
2652
|
display: "flex",
|
|
2526
2653
|
flexDirection: "column",
|
|
2527
2654
|
flex: 1,
|
|
@@ -2529,45 +2656,45 @@ function Ur({
|
|
|
2529
2656
|
width: "100%",
|
|
2530
2657
|
height: "100%",
|
|
2531
2658
|
overflow: "hidden",
|
|
2532
|
-
background:
|
|
2533
|
-
color:
|
|
2659
|
+
background: g.appBg,
|
|
2660
|
+
color: g.textPrimary,
|
|
2534
2661
|
fontFamily: "system-ui, sans-serif",
|
|
2535
2662
|
boxSizing: "border-box"
|
|
2536
|
-
},
|
|
2663
|
+
}, Do = {
|
|
2537
2664
|
display: "flex",
|
|
2538
2665
|
flex: 1,
|
|
2539
2666
|
minHeight: 0,
|
|
2540
2667
|
overflow: "hidden"
|
|
2541
2668
|
};
|
|
2542
|
-
return
|
|
2669
|
+
return U ? /* @__PURE__ */ l(dt.Provider, { value: g, children: /* @__PURE__ */ m("div", { style: { ...Lt, alignItems: "center", justifyContent: "center", color: "#c06060", fontFamily: "monospace" }, children: [
|
|
2543
2670
|
"Failed to load blocks: ",
|
|
2544
|
-
|
|
2545
|
-
] }) }) :
|
|
2546
|
-
!p && /* @__PURE__ */
|
|
2671
|
+
U
|
|
2672
|
+
] }) }) : Z ? /* @__PURE__ */ l(dt.Provider, { value: g, children: /* @__PURE__ */ m("div", { style: Lt, onPointerDownCapture: fn, onFocusCapture: fn, children: [
|
|
2673
|
+
!p && /* @__PURE__ */ m("div", { style: {
|
|
2547
2674
|
flexShrink: 0,
|
|
2548
2675
|
display: "flex",
|
|
2549
2676
|
alignItems: "center",
|
|
2550
2677
|
gap: 10,
|
|
2551
2678
|
padding: "0 14px",
|
|
2552
2679
|
height: 38,
|
|
2553
|
-
background:
|
|
2554
|
-
borderBottom: `1px solid ${
|
|
2680
|
+
background: g.titleBg,
|
|
2681
|
+
borderBottom: `1px solid ${g.border}`
|
|
2555
2682
|
}, children: [
|
|
2556
|
-
/* @__PURE__ */ l("span", { style: { color:
|
|
2557
|
-
/* @__PURE__ */ l("span", { style: { color:
|
|
2558
|
-
|
|
2559
|
-
/* @__PURE__ */
|
|
2683
|
+
/* @__PURE__ */ l("span", { style: { color: g.titlePrimaryText, fontWeight: "bold", fontSize: 13, letterSpacing: 1, textTransform: "uppercase" }, children: "CardCQ" }),
|
|
2684
|
+
/* @__PURE__ */ l("span", { style: { color: g.titleSecondaryText, fontSize: 11, letterSpacing: 0.5 }, children: "Behavior Editor" }),
|
|
2685
|
+
r,
|
|
2686
|
+
/* @__PURE__ */ m("div", { style: { marginLeft: "auto", display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
2560
2687
|
s && /* @__PURE__ */ l(
|
|
2561
2688
|
"button",
|
|
2562
2689
|
{
|
|
2563
|
-
onClick: () => s({ blocks: [...
|
|
2690
|
+
onClick: () => s({ blocks: [...D.entries()] }),
|
|
2564
2691
|
style: {
|
|
2565
2692
|
padding: "3px 10px",
|
|
2566
2693
|
fontSize: 11,
|
|
2567
2694
|
fontWeight: "bold",
|
|
2568
|
-
background:
|
|
2569
|
-
color:
|
|
2570
|
-
border: `1px solid ${
|
|
2695
|
+
background: g.titleBg,
|
|
2696
|
+
color: g.titlePrimaryText,
|
|
2697
|
+
border: `1px solid ${g.border}`,
|
|
2571
2698
|
borderRadius: 4,
|
|
2572
2699
|
cursor: "pointer",
|
|
2573
2700
|
letterSpacing: 0.5
|
|
@@ -2575,84 +2702,86 @@ function Ur({
|
|
|
2575
2702
|
children: "Save"
|
|
2576
2703
|
}
|
|
2577
2704
|
),
|
|
2578
|
-
!c && /* @__PURE__ */ l(
|
|
2705
|
+
!c && /* @__PURE__ */ l(Vr, { onSelect: Co })
|
|
2579
2706
|
] })
|
|
2580
2707
|
] }),
|
|
2581
|
-
/* @__PURE__ */
|
|
2708
|
+
/* @__PURE__ */ m("div", { style: Do, children: [
|
|
2582
2709
|
/* @__PURE__ */ l(
|
|
2583
|
-
|
|
2710
|
+
qr,
|
|
2584
2711
|
{
|
|
2585
|
-
onPointerDown:
|
|
2586
|
-
isDropTarget:
|
|
2587
|
-
registryVersion:
|
|
2588
|
-
packages:
|
|
2712
|
+
onPointerDown: xn,
|
|
2713
|
+
isDropTarget: uo,
|
|
2714
|
+
registryVersion: ot,
|
|
2715
|
+
packages: Dt && (L || H) ? {
|
|
2589
2716
|
available: W ?? [],
|
|
2590
|
-
dependencies:
|
|
2591
|
-
onChange:
|
|
2592
|
-
actions:
|
|
2593
|
-
blockCounts:
|
|
2594
|
-
conflictCounts: new Map(
|
|
2717
|
+
dependencies: pe.dependencies,
|
|
2718
|
+
onChange: Bo,
|
|
2719
|
+
actions: z,
|
|
2720
|
+
blockCounts: ii(D),
|
|
2721
|
+
conflictCounts: new Map(fo.filter((a) => a.info.id.startsWith(It)).map((a) => [a.info.name, a.conflictIds.length]))
|
|
2595
2722
|
} : void 0,
|
|
2596
|
-
placedStartIds:
|
|
2723
|
+
placedStartIds: co
|
|
2597
2724
|
}
|
|
2598
2725
|
),
|
|
2599
|
-
/* @__PURE__ */
|
|
2726
|
+
/* @__PURE__ */ m(
|
|
2600
2727
|
"div",
|
|
2601
2728
|
{
|
|
2602
2729
|
style: { flex: 1, minWidth: 0, display: "flex", position: "relative" },
|
|
2603
|
-
onPointerMove:
|
|
2604
|
-
onPointerLeave:
|
|
2730
|
+
onPointerMove: Po,
|
|
2731
|
+
onPointerLeave: Eo,
|
|
2605
2732
|
children: [
|
|
2606
2733
|
/* @__PURE__ */ l(
|
|
2607
|
-
|
|
2734
|
+
io,
|
|
2608
2735
|
{
|
|
2609
|
-
ref:
|
|
2610
|
-
blocks:
|
|
2611
|
-
draggingIds:
|
|
2612
|
-
provisionalIds:
|
|
2613
|
-
onBlockPointerDown:
|
|
2614
|
-
onBlockClick:
|
|
2615
|
-
onSocketClick:
|
|
2616
|
-
editingSocket:
|
|
2617
|
-
onSocketInput:
|
|
2618
|
-
onSocketCommit:
|
|
2619
|
-
onSocketCancelEdit:
|
|
2620
|
-
onParamRemove:
|
|
2621
|
-
|
|
2622
|
-
|
|
2736
|
+
ref: it,
|
|
2737
|
+
blocks: ie,
|
|
2738
|
+
draggingIds: ao,
|
|
2739
|
+
provisionalIds: et,
|
|
2740
|
+
onBlockPointerDown: To,
|
|
2741
|
+
onBlockClick: mo,
|
|
2742
|
+
onSocketClick: ko,
|
|
2743
|
+
editingSocket: xo,
|
|
2744
|
+
onSocketInput: bo,
|
|
2745
|
+
onSocketCommit: Io,
|
|
2746
|
+
onSocketCancelEdit: vo,
|
|
2747
|
+
onParamRemove: $o,
|
|
2748
|
+
onMouthOpen: So,
|
|
2749
|
+
onMouthClose: wo,
|
|
2750
|
+
onOutputDrag: xn,
|
|
2751
|
+
overlay: dn.length > 0 ? /* @__PURE__ */ l(ei, { peers: dn, blocks: ie, layout: ue }) : null
|
|
2623
2752
|
}
|
|
2624
2753
|
),
|
|
2625
2754
|
/* @__PURE__ */ l(
|
|
2626
|
-
|
|
2755
|
+
Yr,
|
|
2627
2756
|
{
|
|
2628
|
-
canUndo:
|
|
2629
|
-
canRedo:
|
|
2630
|
-
onUndo:
|
|
2631
|
-
onRedo:
|
|
2632
|
-
notice:
|
|
2633
|
-
extra:
|
|
2757
|
+
canUndo: pt(ce) && ce.undo.length > 0,
|
|
2758
|
+
canRedo: pt(ce) && ce.redo.length > 0,
|
|
2759
|
+
onUndo: Bt,
|
|
2760
|
+
onRedo: Ct,
|
|
2761
|
+
notice: ve,
|
|
2762
|
+
extra: q && q.length > 0 ? /* @__PURE__ */ l(Zr, { writers: q, onExport: Mo }) : null
|
|
2634
2763
|
}
|
|
2635
2764
|
)
|
|
2636
2765
|
]
|
|
2637
2766
|
}
|
|
2638
2767
|
)
|
|
2639
2768
|
] }),
|
|
2640
|
-
/* @__PURE__ */ l(
|
|
2641
|
-
] }) }) : /* @__PURE__ */ l(
|
|
2769
|
+
/* @__PURE__ */ l(ci, { ghostPos: lo, blocks: ie })
|
|
2770
|
+
] }) }) : /* @__PURE__ */ l(dt.Provider, { value: g, children: /* @__PURE__ */ l("div", { style: { ...Lt, alignItems: "center", justifyContent: "center", color: g.textMuted }, children: "Loading…" }) });
|
|
2642
2771
|
}
|
|
2643
|
-
function
|
|
2772
|
+
function ln(e) {
|
|
2644
2773
|
const t = e.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toLowerCase();
|
|
2645
2774
|
return /^[0-9]/.test(t) ? `_${t}` : t || "_";
|
|
2646
2775
|
}
|
|
2647
|
-
function
|
|
2776
|
+
function Ft(e) {
|
|
2648
2777
|
return JSON.stringify(e);
|
|
2649
2778
|
}
|
|
2650
|
-
function
|
|
2779
|
+
function so(e, t) {
|
|
2651
2780
|
switch (e.kind) {
|
|
2652
2781
|
case "text":
|
|
2653
|
-
return t === "string" ?
|
|
2782
|
+
return t === "string" ? Ft(e.text) : t === "boolean" ? e.text.toLowerCase() === "true" ? "True" : "False" : /^-?\d+(\.\d+)?$/.test(e.text) ? e.text : Ft(e.text);
|
|
2654
2783
|
case "query":
|
|
2655
|
-
return
|
|
2784
|
+
return ft(e.node);
|
|
2656
2785
|
case "body":
|
|
2657
2786
|
return "None";
|
|
2658
2787
|
// mouths are written as blocks, not arguments
|
|
@@ -2660,47 +2789,47 @@ function Xn(e, t) {
|
|
|
2660
2789
|
return "None";
|
|
2661
2790
|
}
|
|
2662
2791
|
}
|
|
2663
|
-
function
|
|
2664
|
-
const t = e.args.filter((n) => n.value.kind !== "body").map((n) =>
|
|
2665
|
-
return `${
|
|
2792
|
+
function ft(e) {
|
|
2793
|
+
const t = e.args.filter((n) => n.value.kind !== "body").map((n) => so(n.value, n.type));
|
|
2794
|
+
return `${ln(e.name)}(${t.join(", ")})`;
|
|
2666
2795
|
}
|
|
2667
|
-
function
|
|
2796
|
+
function kt(e, t) {
|
|
2668
2797
|
return e.length === 0 ? [`${t}pass`] : e.flatMap((n) => {
|
|
2669
|
-
const
|
|
2670
|
-
if (
|
|
2671
|
-
const
|
|
2672
|
-
if (
|
|
2673
|
-
const i =
|
|
2674
|
-
return [`${t}with ${
|
|
2798
|
+
const o = n.args.filter((i) => i.value.kind === "body");
|
|
2799
|
+
if (o.length === 0) return [`${t}${ft(n)}`];
|
|
2800
|
+
const r = `${t} `;
|
|
2801
|
+
if (o.length === 1) {
|
|
2802
|
+
const i = o[0].value;
|
|
2803
|
+
return [`${t}with ${ft(n)}:`, ...kt(i.body, r)];
|
|
2675
2804
|
}
|
|
2676
2805
|
return [
|
|
2677
|
-
`${t}with ${
|
|
2678
|
-
...
|
|
2679
|
-
`${
|
|
2680
|
-
...
|
|
2806
|
+
`${t}with ${ft(n)}:`,
|
|
2807
|
+
...o.flatMap((i) => [
|
|
2808
|
+
`${r}with ${ln(i.name)}:`,
|
|
2809
|
+
...kt(i.value.body, `${r} `)
|
|
2681
2810
|
])
|
|
2682
2811
|
];
|
|
2683
2812
|
});
|
|
2684
2813
|
}
|
|
2685
|
-
const
|
|
2814
|
+
const pi = {
|
|
2686
2815
|
id: "python",
|
|
2687
2816
|
label: "Python",
|
|
2688
2817
|
fileExtension: "py",
|
|
2689
2818
|
write(e) {
|
|
2690
2819
|
return `# Generated by the block editor
|
|
2691
2820
|
|
|
2692
|
-
${e.roots.map((n,
|
|
2693
|
-
const [
|
|
2694
|
-
if (
|
|
2695
|
-
const s =
|
|
2821
|
+
${e.roots.map((n, o) => {
|
|
2822
|
+
const [r, ...i] = n.body;
|
|
2823
|
+
if (r?.blockType === "start") {
|
|
2824
|
+
const s = r.args.filter((c) => c.value.kind !== "body").map((c) => so(c.value, c.type));
|
|
2696
2825
|
return [
|
|
2697
|
-
`@on(${[
|
|
2698
|
-
`def ${
|
|
2699
|
-
...
|
|
2826
|
+
`@on(${[Ft(r.name), ...s].join(", ")})`,
|
|
2827
|
+
`def ${ln(r.name)}():`,
|
|
2828
|
+
...kt(i, " ")
|
|
2700
2829
|
].join(`
|
|
2701
2830
|
`);
|
|
2702
2831
|
}
|
|
2703
|
-
return [`def chain_${
|
|
2832
|
+
return [`def chain_${o + 1}():`, ...kt(n.body, " ")].join(`
|
|
2704
2833
|
`);
|
|
2705
2834
|
}).join(`
|
|
2706
2835
|
|
|
@@ -2709,7 +2838,7 @@ ${e.roots.map((n, r) => {
|
|
|
2709
2838
|
`;
|
|
2710
2839
|
}
|
|
2711
2840
|
};
|
|
2712
|
-
class
|
|
2841
|
+
class gi {
|
|
2713
2842
|
state;
|
|
2714
2843
|
version = 0;
|
|
2715
2844
|
clients = /* @__PURE__ */ new Map();
|
|
@@ -2729,24 +2858,24 @@ class Yr {
|
|
|
2729
2858
|
return { state: this.state, version: this.version };
|
|
2730
2859
|
}
|
|
2731
2860
|
/** A client's channels. Connecting again with the same id gives channels to the same client (its listeners stay). */
|
|
2732
|
-
connect(t, n,
|
|
2733
|
-
const
|
|
2861
|
+
connect(t, n, o) {
|
|
2862
|
+
const r = this.clients.get(t) ?? {
|
|
2734
2863
|
id: t,
|
|
2735
2864
|
name: n,
|
|
2736
|
-
color:
|
|
2865
|
+
color: o,
|
|
2737
2866
|
commandListeners: /* @__PURE__ */ new Set(),
|
|
2738
2867
|
presenceListeners: /* @__PURE__ */ new Set(),
|
|
2739
2868
|
presence: { cursor: null, drag: null, typing: null }
|
|
2740
2869
|
};
|
|
2741
|
-
return
|
|
2870
|
+
return r.name = n, r.color = o, this.clients.set(t, r), { commands: {
|
|
2742
2871
|
submit: (c) => this.later(() => this.receive(c)),
|
|
2743
|
-
subscribe: (c) => (
|
|
2744
|
-
resync: () => this.later(() =>
|
|
2872
|
+
subscribe: (c) => (r.commandListeners.add(c), this.later(() => c(this.snapshot())), () => r.commandListeners.delete(c)),
|
|
2873
|
+
resync: () => this.later(() => r.commandListeners.forEach((c) => c(this.snapshot())))
|
|
2745
2874
|
}, presence: {
|
|
2746
2875
|
publish: (c) => {
|
|
2747
|
-
|
|
2876
|
+
r.presence = c, this.broadcastPresence();
|
|
2748
2877
|
},
|
|
2749
|
-
subscribe: (c) => (
|
|
2878
|
+
subscribe: (c) => (r.presenceListeners.add(c), c(this.peersOf(t)), () => r.presenceListeners.delete(c))
|
|
2750
2879
|
} };
|
|
2751
2880
|
}
|
|
2752
2881
|
/**
|
|
@@ -2764,16 +2893,16 @@ class Yr {
|
|
|
2764
2893
|
}
|
|
2765
2894
|
receive(t) {
|
|
2766
2895
|
try {
|
|
2767
|
-
this.state =
|
|
2768
|
-
} catch (
|
|
2769
|
-
if (!(
|
|
2770
|
-
const
|
|
2771
|
-
this.clients.get(t.clientId)?.commandListeners.forEach((i) => i(
|
|
2896
|
+
this.state = Qe(this.state, t.command);
|
|
2897
|
+
} catch (o) {
|
|
2898
|
+
if (!(o instanceof R)) throw o;
|
|
2899
|
+
const r = { type: "rejected", id: t.id, code: o.code, message: o.message };
|
|
2900
|
+
this.clients.get(t.clientId)?.commandListeners.forEach((i) => i(r));
|
|
2772
2901
|
return;
|
|
2773
2902
|
}
|
|
2774
2903
|
this.version += 1;
|
|
2775
2904
|
const n = { type: "applied", envelope: t, version: this.version };
|
|
2776
|
-
this.clients.forEach((
|
|
2905
|
+
this.clients.forEach((o) => o.commandListeners.forEach((r) => r(n)));
|
|
2777
2906
|
}
|
|
2778
2907
|
peersOf(t) {
|
|
2779
2908
|
return [...this.clients.values()].filter((n) => n.id !== t).map((n) => ({ ...n.presence, clientId: n.id, name: n.name, color: n.color }));
|
|
@@ -2783,33 +2912,33 @@ class Yr {
|
|
|
2783
2912
|
}
|
|
2784
2913
|
}
|
|
2785
2914
|
export {
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2915
|
+
hi as BlockEditor,
|
|
2916
|
+
fi as COMMANDS_VERSION,
|
|
2917
|
+
gt as COMMAND_PARAM_TYPE,
|
|
2918
|
+
R as CommandRejected,
|
|
2919
|
+
gi as LocalServer,
|
|
2920
|
+
at as THEMES,
|
|
2921
|
+
dt as ThemeContext,
|
|
2922
|
+
Vr as ThemeSwitcher,
|
|
2923
|
+
Qe as applyCommand,
|
|
2924
|
+
er as changeDependencies,
|
|
2925
|
+
No as compareVersions,
|
|
2797
2926
|
Xe as darkTheme,
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2927
|
+
hi as default,
|
|
2928
|
+
Jo as deleteChain,
|
|
2929
|
+
$t as fragmentOf,
|
|
2930
|
+
Nn as invertCommand,
|
|
2931
|
+
Rt as moveChain,
|
|
2932
|
+
Me as normalizeBlock,
|
|
2933
|
+
vt as normalizeSlot,
|
|
2934
|
+
Re as normalizeText,
|
|
2935
|
+
te as packageKey,
|
|
2936
|
+
Go as placeNewBlock,
|
|
2937
|
+
jt as placeOf,
|
|
2938
|
+
pi as pythonWriter,
|
|
2939
|
+
An as roundPosition,
|
|
2940
|
+
Ko as samePlace,
|
|
2941
|
+
vn as setSocketText,
|
|
2942
|
+
Pr as toProgram,
|
|
2943
|
+
Q as useTheme
|
|
2815
2944
|
};
|