@tvolden/block-code-editor 0.2.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 +12 -0
- package/dist/block-editor.cjs +4 -4
- package/dist/block-editor.js +1569 -1312
- package/dist/blocks.json +47 -2
- package/dist/commands/build.d.ts +5 -0
- package/dist/components/BlockRenderer.d.ts +6 -0
- package/dist/components/Canvas.d.ts +6 -0
- package/dist/components/MouthDecorations.d.ts +9 -1
- package/dist/components/OptionalChip.d.ts +12 -0
- package/dist/types.d.ts +6 -0
- package/dist/utils/blockLayout.d.ts +87 -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 Te(e) {
|
|
58
|
-
const t = _t(e) ? { x: e.x, y: e.y } : { x: 0, y: 0 };
|
|
59
|
-
return { ...e, ...t, paramSlots: e.paramSlots.map(ut) };
|
|
60
|
-
}
|
|
61
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
|
+
}
|
|
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
|
-
const
|
|
109
|
-
if (!
|
|
110
|
-
throw t(`slot ${s} of '${
|
|
108
|
+
const p = n.get(c);
|
|
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
|
|
140
|
+
throw new R("POSITION_CHANGED", `Block '${e.instanceId}' isn't at (${t.x}, ${t.y}).`);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
if (!
|
|
142
|
+
function _n(e) {
|
|
143
|
+
if (!Xt(e)) throw new R("NOT_A_ROOT", `Block '${e.instanceId}' is linked, not a root.`);
|
|
144
144
|
}
|
|
145
|
-
const
|
|
146
|
-
function
|
|
147
|
-
const n = new Set(e.map(
|
|
148
|
-
return e.length === t.length && n.size === new Set(t.map(
|
|
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
149
|
}
|
|
150
|
-
function
|
|
151
|
-
|
|
152
|
-
for (const
|
|
153
|
-
if (e.blocks.has(
|
|
154
|
-
throw new
|
|
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 mo(e, t) {
|
|
232
|
-
const n = _e(e, t.blockId), r = gn(n, t.slot);
|
|
233
|
-
if (r.queryBlockId)
|
|
234
|
-
throw new _("SLOT_HAS_QUERY", `Slot ${t.slot} of '${n.instanceId}' holds a query.`);
|
|
235
|
-
if (Me(r.textValue) !== Me(t.from))
|
|
236
|
-
throw new _("TEXT_CHANGED", `Slot ${t.slot} of '${n.instanceId}' has changed.`);
|
|
237
|
-
const o = new Map(e.blocks);
|
|
238
|
-
return o.set(n.instanceId, it(n, t.slot, { textValue: Me(t.to) })), { ...e, blocks: o };
|
|
229
|
+
}), { ...e, blocks: o };
|
|
239
230
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
242
|
-
|
|
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
|
+
}
|
|
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 pt {
|
|
|
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 pt(e), s = kn(n), c = Nt(e, o);
|
|
310
|
-
return r && c && bo(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
|
|
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 In(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,214 +450,296 @@ class Mo {
|
|
|
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
|
|
461
|
-
}
|
|
462
|
-
function
|
|
463
|
-
const t =
|
|
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;
|
|
465
|
+
}
|
|
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;
|
|
515
|
+
}
|
|
516
|
+
function xe(e, t) {
|
|
517
|
+
return e.blockType === "command" && t.type === gt;
|
|
511
518
|
}
|
|
512
|
-
function
|
|
513
|
-
return e.
|
|
519
|
+
function kr(e) {
|
|
520
|
+
return e.params.some((t) => xe(e, t));
|
|
521
|
+
}
|
|
522
|
+
const Wt = 18;
|
|
523
|
+
function jn(e, t) {
|
|
524
|
+
return !!e.optional && !t?.queryBlockId && !t?.textValue;
|
|
525
|
+
}
|
|
526
|
+
function Kn(e) {
|
|
527
|
+
return `+ ${e}`;
|
|
528
|
+
}
|
|
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;
|
|
514
546
|
}
|
|
515
|
-
function
|
|
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;
|
|
562
|
+
}
|
|
563
|
+
function Gn(e, t, n) {
|
|
564
|
+
if (jn(e, t)) return Qn(e.name);
|
|
516
565
|
if (t?.queryBlockId && n) {
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
519
|
-
const
|
|
520
|
-
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);
|
|
521
570
|
}
|
|
522
571
|
}
|
|
523
|
-
return
|
|
572
|
+
return mt(e.type).w;
|
|
524
573
|
}
|
|
525
|
-
const
|
|
526
|
-
function
|
|
527
|
-
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);
|
|
528
577
|
return e.length <= i ? e : i <= 1 ? "…" : `${e.slice(0, i - 1)}…`;
|
|
529
578
|
}
|
|
530
|
-
function
|
|
579
|
+
function xt(e, t) {
|
|
531
580
|
return `${e}: ${t}`;
|
|
532
581
|
}
|
|
533
|
-
function
|
|
582
|
+
function Jn(e) {
|
|
583
|
+
const t = xt(e.name, e.type);
|
|
584
|
+
return e.optional ? `${t} (optional)` : t;
|
|
585
|
+
}
|
|
586
|
+
function Sr(e) {
|
|
534
587
|
return Math.max(72, e.length * 6 + 22);
|
|
535
588
|
}
|
|
536
|
-
function
|
|
537
|
-
let
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
for (const i of e.provides)
|
|
542
|
-
r = Math.max(r, et + zt(i.name) + wt);
|
|
543
|
-
e.params.forEach((i) => {
|
|
544
|
-
Ne(e, i) && (r = Math.max(r, Rt + et + i.name.length * Et + wt));
|
|
589
|
+
function Jt(e) {
|
|
590
|
+
let t = gr;
|
|
591
|
+
return (e.blockType === "start" ? e.provides ?? [] : []).map((n) => {
|
|
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;
|
|
545
594
|
});
|
|
546
|
-
const o = e.blockType === "start" ? 140 : 110;
|
|
547
|
-
return Math.max(o, r);
|
|
548
|
-
}
|
|
549
|
-
function Xe(e) {
|
|
550
|
-
return e.blockType === "start" ? me : e.blockType === "command" ? wn : ke;
|
|
551
595
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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);
|
|
556
604
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
605
|
+
e.params.forEach((c) => {
|
|
606
|
+
xe(e, c) && (o = Math.max(o, Gt + Ht + c.name.length * zt + lt + (c.optional ? Vn : 0)));
|
|
607
|
+
});
|
|
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);
|
|
562
612
|
}
|
|
563
|
-
|
|
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
|
+
});
|
|
564
640
|
}
|
|
565
|
-
function
|
|
566
|
-
const n =
|
|
567
|
-
return n ?
|
|
641
|
+
function en(e, t) {
|
|
642
|
+
const n = N(e.definitionId);
|
|
643
|
+
return n ? Ce(n, e.paramSlots, t) : je;
|
|
568
644
|
}
|
|
569
|
-
function
|
|
645
|
+
function to(e, t) {
|
|
570
646
|
let n = 0;
|
|
571
|
-
const
|
|
572
|
-
let
|
|
573
|
-
for (;
|
|
574
|
-
|
|
575
|
-
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);
|
|
576
652
|
if (!i) break;
|
|
577
|
-
n +=
|
|
653
|
+
n += en(i, t), r = i.nextBlockId;
|
|
578
654
|
}
|
|
579
655
|
return n;
|
|
580
656
|
}
|
|
581
|
-
function
|
|
582
|
-
const
|
|
583
|
-
let
|
|
584
|
-
return e.params.forEach((
|
|
585
|
-
if (!
|
|
586
|
-
let
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
}),
|
|
591
|
-
}
|
|
592
|
-
function
|
|
593
|
-
|
|
594
|
-
|
|
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;
|
|
595
681
|
for (let s = 0; s < e.params.length; s++) {
|
|
596
682
|
const c = e.params[s];
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
599
|
-
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;
|
|
600
686
|
}
|
|
601
|
-
return
|
|
687
|
+
return r;
|
|
602
688
|
}
|
|
603
|
-
function
|
|
689
|
+
function Tr(e) {
|
|
604
690
|
const t = /* @__PURE__ */ new Map();
|
|
605
|
-
function n(
|
|
606
|
-
const s = e.get(
|
|
607
|
-
if (!s || t.has(
|
|
608
|
-
t.set(
|
|
609
|
-
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);
|
|
610
696
|
if (c) {
|
|
611
|
-
for (const
|
|
612
|
-
const
|
|
613
|
-
|
|
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);
|
|
614
700
|
}
|
|
615
|
-
for (const
|
|
616
|
-
const
|
|
617
|
-
|
|
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);
|
|
618
704
|
}
|
|
619
705
|
}
|
|
620
|
-
s.nextBlockId && n(s.nextBlockId,
|
|
706
|
+
s.nextBlockId && n(s.nextBlockId, r, i + en(s, e));
|
|
621
707
|
}
|
|
622
|
-
return e.forEach((
|
|
623
|
-
!
|
|
708
|
+
return e.forEach((o) => {
|
|
709
|
+
!o.parentBlockId && !o.embeddedInBlockId && n(o.instanceId, o.x, o.y);
|
|
624
710
|
}), t;
|
|
625
711
|
}
|
|
626
|
-
function
|
|
712
|
+
function Pr(e, t) {
|
|
627
713
|
const n = /* @__PURE__ */ new Set();
|
|
628
|
-
function
|
|
714
|
+
function o(s) {
|
|
629
715
|
const c = [];
|
|
630
|
-
let
|
|
631
|
-
for (;
|
|
632
|
-
const
|
|
633
|
-
if (!
|
|
634
|
-
c.push(
|
|
716
|
+
let p = s ?? null;
|
|
717
|
+
for (; p && !n.has(p); ) {
|
|
718
|
+
const y = e.blocks.get(p);
|
|
719
|
+
if (!y) break;
|
|
720
|
+
c.push(r(y)), p = y.nextBlockId;
|
|
635
721
|
}
|
|
636
722
|
return c;
|
|
637
723
|
}
|
|
638
|
-
function
|
|
724
|
+
function r(s) {
|
|
639
725
|
n.add(s.instanceId);
|
|
640
|
-
const c = t(s.definitionId),
|
|
641
|
-
const
|
|
642
|
-
let
|
|
643
|
-
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 };
|
|
644
730
|
});
|
|
645
731
|
return {
|
|
646
732
|
definitionId: s.definitionId,
|
|
647
733
|
name: c?.name ?? s.definitionId,
|
|
648
734
|
blockType: c?.blockType ?? "missing",
|
|
649
|
-
args:
|
|
735
|
+
args: p
|
|
650
736
|
};
|
|
651
737
|
}
|
|
652
738
|
return {
|
|
653
|
-
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) }))
|
|
654
740
|
};
|
|
655
741
|
}
|
|
656
|
-
const
|
|
742
|
+
const Xe = {
|
|
657
743
|
id: "dark",
|
|
658
744
|
label: "Dark",
|
|
659
745
|
// Surfaces — stepped hierarchy so each layer reads as distinct
|
|
@@ -708,7 +794,7 @@ const qe = {
|
|
|
708
794
|
switcherText: "#5a6888",
|
|
709
795
|
switcherActiveText: "#c9a43a",
|
|
710
796
|
switcherBorder: "#252d42"
|
|
711
|
-
},
|
|
797
|
+
}, Er = {
|
|
712
798
|
id: "light",
|
|
713
799
|
label: "Light",
|
|
714
800
|
appBg: "#f0f2f6",
|
|
@@ -751,64 +837,64 @@ const qe = {
|
|
|
751
837
|
switcherText: "#9090a0",
|
|
752
838
|
switcherActiveText: "#1a2030",
|
|
753
839
|
switcherBorder: "#dde2ec"
|
|
754
|
-
},
|
|
755
|
-
function
|
|
756
|
-
return
|
|
840
|
+
}, at = [Xe, Er], dt = _o(Xe);
|
|
841
|
+
function Q() {
|
|
842
|
+
return Ao(dt);
|
|
757
843
|
}
|
|
758
|
-
const
|
|
759
|
-
function
|
|
844
|
+
const K = 16, Se = 14, Pe = K + Se / 2, Ee = 5, O = 4;
|
|
845
|
+
function Mr(e, t) {
|
|
760
846
|
return [
|
|
761
|
-
`M ${
|
|
847
|
+
`M ${O} 0`,
|
|
762
848
|
// Top edge with inlet (triangle dips into the block)
|
|
763
|
-
`H ${
|
|
764
|
-
`H ${e -
|
|
765
|
-
`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}`,
|
|
766
852
|
// Bottom edge with outlet (triangle protrudes below)
|
|
767
|
-
`H ${
|
|
768
|
-
`H ${
|
|
769
|
-
`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`
|
|
770
856
|
].join(" ");
|
|
771
857
|
}
|
|
772
|
-
function
|
|
773
|
-
const
|
|
774
|
-
`M ${
|
|
858
|
+
function Dr(e, t, n, o) {
|
|
859
|
+
const r = [
|
|
860
|
+
`M ${O} 0`,
|
|
775
861
|
// Top edge with inlet
|
|
776
|
-
`H ${
|
|
777
|
-
`H ${e -
|
|
862
|
+
`H ${K} L ${Pe} ${Ee} L ${K + Se} 0`,
|
|
863
|
+
`H ${e - O} Q ${e} 0 ${e} ${O}`
|
|
778
864
|
];
|
|
779
|
-
for (const i of
|
|
865
|
+
for (const i of o) {
|
|
780
866
|
const s = i.y, c = i.y + i.h;
|
|
781
|
-
|
|
867
|
+
r.push(
|
|
782
868
|
// Right edge down to the mouth, then its roof leftwards with an outlet tab into the mouth
|
|
783
869
|
`V ${s}`,
|
|
784
|
-
`H ${n +
|
|
870
|
+
`H ${n + K + Se} L ${n + Pe} ${s + Ee} L ${n + K} ${s}`,
|
|
785
871
|
`H ${n}`,
|
|
786
872
|
// Inner wall, then the floor rightwards with an inlet for the chain's last tab
|
|
787
873
|
`V ${c}`,
|
|
788
|
-
`H ${n +
|
|
874
|
+
`H ${n + K} L ${n + Pe} ${c + Ee} L ${n + K + Se} ${c}`,
|
|
789
875
|
`H ${e}`
|
|
790
876
|
);
|
|
791
877
|
}
|
|
792
|
-
return
|
|
793
|
-
`V ${t -
|
|
878
|
+
return r.push(
|
|
879
|
+
`V ${t - O} Q ${e} ${t} ${e - O} ${t}`,
|
|
794
880
|
// Bottom edge with outlet
|
|
795
|
-
`H ${
|
|
796
|
-
`H ${
|
|
797
|
-
`V ${
|
|
798
|
-
),
|
|
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(" ");
|
|
799
885
|
}
|
|
800
|
-
function
|
|
886
|
+
function _r(e, t) {
|
|
801
887
|
return [
|
|
802
888
|
"M 0 10 Q 0 0 10 0",
|
|
803
889
|
`H ${e - 10} Q ${e} 0 ${e} 10`,
|
|
804
|
-
`V ${t -
|
|
890
|
+
`V ${t - O} Q ${e} ${t} ${e - O} ${t}`,
|
|
805
891
|
// Bottom outlet only — start blocks have no inlet
|
|
806
|
-
`H ${
|
|
807
|
-
`H ${
|
|
892
|
+
`H ${K + Se} L ${Pe} ${t + Ee} L ${K} ${t}`,
|
|
893
|
+
`H ${O} Q 0 ${t} 0 ${t - O}`,
|
|
808
894
|
"V 10 Z"
|
|
809
895
|
].join(" ");
|
|
810
896
|
}
|
|
811
|
-
function
|
|
897
|
+
function Ar(e, t) {
|
|
812
898
|
const n = t / 2;
|
|
813
899
|
return [
|
|
814
900
|
`M ${n} 0 H ${e - n}`,
|
|
@@ -816,7 +902,7 @@ function Fo(e, t) {
|
|
|
816
902
|
`H ${n} A ${n} ${n} 0 0 1 ${n} 0 Z`
|
|
817
903
|
].join(" ");
|
|
818
904
|
}
|
|
819
|
-
function
|
|
905
|
+
function Or(e, t) {
|
|
820
906
|
const n = t / 2;
|
|
821
907
|
return [
|
|
822
908
|
`M ${n} 0 H ${e - n}`,
|
|
@@ -824,7 +910,7 @@ function Qo(e, t) {
|
|
|
824
910
|
`H ${n} L 0 ${t / 2} Z`
|
|
825
911
|
].join(" ");
|
|
826
912
|
}
|
|
827
|
-
function
|
|
913
|
+
function no(e, t, n) {
|
|
828
914
|
return [
|
|
829
915
|
`M ${n} 0 H ${e - n} Q ${e} 0 ${e} ${n}`,
|
|
830
916
|
`V ${t - n} Q ${e} ${t} ${e - n} ${t}`,
|
|
@@ -832,49 +918,49 @@ function Mn(e, t, n) {
|
|
|
832
918
|
`V ${n} Q 0 0 ${n} 0 Z`
|
|
833
919
|
].join(" ");
|
|
834
920
|
}
|
|
835
|
-
function
|
|
836
|
-
return
|
|
921
|
+
function Lr(e, t) {
|
|
922
|
+
return no(e, t, 5);
|
|
837
923
|
}
|
|
838
|
-
function
|
|
839
|
-
return
|
|
924
|
+
function Nr(e, t) {
|
|
925
|
+
return no(e, t, 9);
|
|
840
926
|
}
|
|
841
|
-
function
|
|
927
|
+
function tn(e, t, n) {
|
|
842
928
|
switch (e) {
|
|
843
929
|
case "number":
|
|
844
|
-
return
|
|
930
|
+
return Ar(t, n);
|
|
845
931
|
case "boolean":
|
|
846
|
-
return
|
|
932
|
+
return Or(t, n);
|
|
847
933
|
case "string":
|
|
848
|
-
return
|
|
934
|
+
return Lr(t, n);
|
|
849
935
|
default:
|
|
850
|
-
return
|
|
936
|
+
return Nr(t, n);
|
|
851
937
|
}
|
|
852
938
|
}
|
|
853
|
-
function
|
|
854
|
-
return
|
|
855
|
-
}
|
|
856
|
-
function
|
|
857
|
-
const
|
|
858
|
-
if (e.blockType === "start") return
|
|
859
|
-
if (e.blockType === "query") return
|
|
860
|
-
const i =
|
|
861
|
-
return i.length > 0 ?
|
|
862
|
-
}
|
|
863
|
-
function
|
|
864
|
-
const s =
|
|
865
|
-
function
|
|
866
|
-
const
|
|
867
|
-
if (!
|
|
868
|
-
const
|
|
869
|
-
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("");
|
|
870
956
|
}
|
|
871
|
-
function
|
|
872
|
-
n(t.filter((
|
|
957
|
+
function g(b) {
|
|
958
|
+
n(t.filter((U) => te(U) !== b)), W(null);
|
|
873
959
|
}
|
|
874
|
-
function ne(
|
|
875
|
-
n(t.map((
|
|
960
|
+
function ne(b, U) {
|
|
961
|
+
n(t.map((F) => te(F) === b ? { ...F, version: U } : F));
|
|
876
962
|
}
|
|
877
|
-
const
|
|
963
|
+
const G = {
|
|
878
964
|
background: s.inputBg,
|
|
879
965
|
color: s.textPrimary,
|
|
880
966
|
border: `1px solid ${s.inputBorder}`,
|
|
@@ -883,7 +969,7 @@ function Zo({ available: e, dependencies: t, onChange: n, actions: r, blockCount
|
|
|
883
969
|
padding: "4px 6px",
|
|
884
970
|
outline: "none",
|
|
885
971
|
minWidth: 0
|
|
886
|
-
},
|
|
972
|
+
}, oe = {
|
|
887
973
|
background: "none",
|
|
888
974
|
color: s.textSecondary,
|
|
889
975
|
border: `1px solid ${s.border}`,
|
|
@@ -891,10 +977,10 @@ function Zo({ available: e, dependencies: t, onChange: n, actions: r, blockCount
|
|
|
891
977
|
fontSize: 11,
|
|
892
978
|
padding: "4px 8px",
|
|
893
979
|
cursor: "pointer"
|
|
894
|
-
},
|
|
895
|
-
return /* @__PURE__ */
|
|
896
|
-
t.length === 0 && /* @__PURE__ */
|
|
897
|
-
|
|
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: [
|
|
982
|
+
t.length === 0 && /* @__PURE__ */ l("div", { style: { color: s.textMuted, fontSize: 11, fontStyle: "italic" }, children: "No packages yet — add one to get blocks." }),
|
|
983
|
+
T && /* @__PURE__ */ m("div", { style: {
|
|
898
984
|
border: `1px solid ${s.deleteActiveBorder}`,
|
|
899
985
|
background: s.deleteActiveBg,
|
|
900
986
|
borderRadius: 4,
|
|
@@ -903,194 +989,264 @@ function Zo({ available: e, dependencies: t, onChange: n, actions: r, blockCount
|
|
|
903
989
|
color: s.textPrimary
|
|
904
990
|
}, children: [
|
|
905
991
|
"Remove ",
|
|
906
|
-
/* @__PURE__ */
|
|
992
|
+
/* @__PURE__ */ l("b", { children: T }),
|
|
907
993
|
"?",
|
|
908
994
|
" ",
|
|
909
|
-
|
|
910
|
-
/* @__PURE__ */
|
|
911
|
-
/* @__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: [
|
|
997
|
+
/* @__PURE__ */ l(
|
|
912
998
|
"button",
|
|
913
999
|
{
|
|
914
1000
|
type: "button",
|
|
915
|
-
onClick: () =>
|
|
916
|
-
style: { ...
|
|
1001
|
+
onClick: () => g(T),
|
|
1002
|
+
style: { ...oe, background: s.deleteActiveBorder, color: "white", borderColor: s.deleteActiveBorder },
|
|
917
1003
|
children: "Remove"
|
|
918
1004
|
}
|
|
919
1005
|
),
|
|
920
|
-
/* @__PURE__ */
|
|
1006
|
+
/* @__PURE__ */ l("button", { type: "button", onClick: () => W(null), style: oe, children: "Cancel" })
|
|
921
1007
|
] })
|
|
922
1008
|
] }),
|
|
923
|
-
t.map((
|
|
924
|
-
const
|
|
925
|
-
return /* @__PURE__ */
|
|
926
|
-
/* @__PURE__ */
|
|
927
|
-
/* @__PURE__ */
|
|
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: {
|
|
928
1014
|
color: s.textPrimary,
|
|
929
1015
|
overflow: "hidden",
|
|
930
1016
|
textOverflow: "ellipsis",
|
|
931
1017
|
whiteSpace: "nowrap"
|
|
932
|
-
}, children:
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
|
|
1018
|
+
}, children: U }),
|
|
1019
|
+
/* @__PURE__ */ l("span", { style: { color: s.textMuted, fontVariantNumeric: "tabular-nums" }, children: b.version }),
|
|
1020
|
+
he > 0 && /* @__PURE__ */ m(
|
|
935
1021
|
"span",
|
|
936
1022
|
{
|
|
937
|
-
title: `${
|
|
1023
|
+
title: `${he} block ID(s) skipped: another package already defines them`,
|
|
938
1024
|
style: { fontSize: 9, color: s.accent, border: `1px solid ${s.accent}`, borderRadius: 3, padding: "0 3px" },
|
|
939
1025
|
children: [
|
|
940
1026
|
"⚠ ",
|
|
941
|
-
|
|
1027
|
+
he
|
|
942
1028
|
]
|
|
943
1029
|
}
|
|
944
1030
|
),
|
|
945
|
-
|
|
1031
|
+
H && /* @__PURE__ */ m(
|
|
946
1032
|
"button",
|
|
947
1033
|
{
|
|
948
1034
|
type: "button",
|
|
949
|
-
onClick: () => ne(
|
|
950
|
-
title: `Version ${
|
|
951
|
-
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 },
|
|
952
1038
|
children: [
|
|
953
|
-
|
|
1039
|
+
H,
|
|
954
1040
|
" available"
|
|
955
1041
|
]
|
|
956
1042
|
}
|
|
957
1043
|
),
|
|
958
|
-
/* @__PURE__ */
|
|
1044
|
+
/* @__PURE__ */ l(
|
|
959
1045
|
"button",
|
|
960
1046
|
{
|
|
961
1047
|
type: "button",
|
|
962
|
-
onClick: () =>
|
|
1048
|
+
onClick: () => W(U),
|
|
963
1049
|
title: "Remove package",
|
|
964
1050
|
style: { marginLeft: "auto", background: "none", border: "none", color: s.textMuted, fontSize: 15, lineHeight: 1, cursor: "pointer" },
|
|
965
1051
|
children: "×"
|
|
966
1052
|
}
|
|
967
1053
|
)
|
|
968
|
-
] },
|
|
1054
|
+
] }, U);
|
|
969
1055
|
}),
|
|
970
|
-
/* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
/* @__PURE__ */
|
|
973
|
-
|
|
974
|
-
|
|
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),
|
|
975
1061
|
" ",
|
|
976
|
-
|
|
977
|
-
] },
|
|
1062
|
+
b.version
|
|
1063
|
+
] }, te(b)))
|
|
978
1064
|
] }),
|
|
979
|
-
|
|
1065
|
+
k && /* @__PURE__ */ l(
|
|
980
1066
|
"input",
|
|
981
1067
|
{
|
|
982
|
-
value:
|
|
983
|
-
onChange: (
|
|
984
|
-
placeholder:
|
|
985
|
-
style: { ...
|
|
1068
|
+
value: y,
|
|
1069
|
+
onChange: (b) => x(b.target.value),
|
|
1070
|
+
placeholder: z.get(c)?.version ?? "version",
|
|
1071
|
+
style: { ...G, width: 64 }
|
|
986
1072
|
}
|
|
987
1073
|
),
|
|
988
|
-
/* @__PURE__ */
|
|
1074
|
+
/* @__PURE__ */ l(
|
|
989
1075
|
"button",
|
|
990
1076
|
{
|
|
991
1077
|
type: "button",
|
|
992
|
-
onClick:
|
|
1078
|
+
onClick: S,
|
|
993
1079
|
disabled: !c,
|
|
994
|
-
style: { ...
|
|
1080
|
+
style: { ...oe, opacity: c ? 1 : 0.4, cursor: c ? "pointer" : "default" },
|
|
995
1081
|
children: "Add"
|
|
996
1082
|
}
|
|
997
1083
|
)
|
|
998
1084
|
] }),
|
|
999
|
-
|
|
1000
|
-
/* @__PURE__ */
|
|
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)) }),
|
|
1086
|
+
/* @__PURE__ */ l(
|
|
1001
1087
|
"button",
|
|
1002
1088
|
{
|
|
1003
1089
|
type: "button",
|
|
1004
|
-
onClick: () =>
|
|
1090
|
+
onClick: () => L((b) => !b),
|
|
1005
1091
|
style: { alignSelf: "flex-start", background: "none", border: "none", padding: 0, color: s.textMuted, fontSize: 10, cursor: "pointer" },
|
|
1006
|
-
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)
|
|
1007
1125
|
}
|
|
1008
1126
|
)
|
|
1009
1127
|
] });
|
|
1010
1128
|
}
|
|
1011
|
-
const
|
|
1012
|
-
function
|
|
1013
|
-
const
|
|
1014
|
-
return /* @__PURE__ */
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
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" }),
|
|
1174
|
+
/* @__PURE__ */ l(
|
|
1019
1175
|
"text",
|
|
1020
1176
|
{
|
|
1021
1177
|
x: 11,
|
|
1022
|
-
y:
|
|
1023
|
-
fill:
|
|
1178
|
+
y: r.dividerY + Ke / 2 + 4,
|
|
1179
|
+
fill: o.blockText,
|
|
1024
1180
|
fontSize: 10,
|
|
1025
1181
|
fontWeight: "bold",
|
|
1026
1182
|
fontFamily: "sans-serif",
|
|
1027
1183
|
style: { userSelect: "none" },
|
|
1028
|
-
children:
|
|
1184
|
+
children: r.name
|
|
1029
1185
|
}
|
|
1030
1186
|
)
|
|
1031
1187
|
] }),
|
|
1032
|
-
n(
|
|
1033
|
-
/* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1188
|
+
n(r.index) && /* @__PURE__ */ m("g", { style: { pointerEvents: "all" }, children: [
|
|
1189
|
+
/* @__PURE__ */ l("title", { children: xt(r.name, gt) }),
|
|
1190
|
+
/* @__PURE__ */ l(
|
|
1035
1191
|
"rect",
|
|
1036
1192
|
{
|
|
1037
|
-
x:
|
|
1038
|
-
y:
|
|
1039
|
-
width: Math.max(60,
|
|
1040
|
-
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,
|
|
1041
1197
|
rx: 3,
|
|
1042
1198
|
fill: "transparent",
|
|
1043
|
-
stroke:
|
|
1199
|
+
stroke: zr,
|
|
1044
1200
|
strokeWidth: 1,
|
|
1045
1201
|
strokeDasharray: "4,3"
|
|
1046
1202
|
}
|
|
1047
1203
|
),
|
|
1048
|
-
/* @__PURE__ */
|
|
1204
|
+
/* @__PURE__ */ l(
|
|
1049
1205
|
"text",
|
|
1050
1206
|
{
|
|
1051
|
-
x:
|
|
1052
|
-
y:
|
|
1053
|
-
fill:
|
|
1207
|
+
x: r.x + 10,
|
|
1208
|
+
y: r.y + r.h / 2 + 3,
|
|
1209
|
+
fill: o.textMuted,
|
|
1054
1210
|
fontSize: 9,
|
|
1055
1211
|
fontFamily: "sans-serif",
|
|
1056
1212
|
fontStyle: "italic",
|
|
1057
1213
|
style: { userSelect: "none" },
|
|
1058
|
-
children:
|
|
1214
|
+
children: r.name
|
|
1059
1215
|
}
|
|
1060
1216
|
)
|
|
1061
1217
|
] })
|
|
1062
|
-
] },
|
|
1218
|
+
] }, r.index)) });
|
|
1063
1219
|
}
|
|
1064
|
-
function
|
|
1065
|
-
const
|
|
1066
|
-
return /* @__PURE__ */
|
|
1220
|
+
function oo({ name: e, type: t, w: n, h: o }) {
|
|
1221
|
+
const r = Q();
|
|
1222
|
+
return /* @__PURE__ */ l(
|
|
1067
1223
|
"text",
|
|
1068
1224
|
{
|
|
1069
1225
|
x: n / 2,
|
|
1070
|
-
y:
|
|
1226
|
+
y: o / 2 + 3,
|
|
1071
1227
|
textAnchor: "middle",
|
|
1072
|
-
fill:
|
|
1228
|
+
fill: r.textMuted,
|
|
1073
1229
|
fontSize: 9,
|
|
1074
1230
|
fontFamily: "sans-serif",
|
|
1075
1231
|
fontStyle: "italic",
|
|
1076
1232
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1077
|
-
children:
|
|
1233
|
+
children: $r(e, t, n)
|
|
1078
1234
|
}
|
|
1079
1235
|
);
|
|
1080
1236
|
}
|
|
1081
|
-
function
|
|
1082
|
-
const
|
|
1083
|
-
return /* @__PURE__ */
|
|
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);
|
|
1239
|
+
return /* @__PURE__ */ l(
|
|
1084
1240
|
"div",
|
|
1085
1241
|
{
|
|
1086
1242
|
style: { marginBottom: 6, userSelect: "none", position: "relative", opacity: n ? 0.4 : 1 },
|
|
1087
|
-
onPointerDown: n ? void 0 : (
|
|
1243
|
+
onPointerDown: n ? void 0 : (k) => t(k, e.id),
|
|
1088
1244
|
title: n ? "Already on canvas — only one instance allowed" : void 0,
|
|
1089
|
-
children: /* @__PURE__ */
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
/* @__PURE__ */
|
|
1092
|
-
/* @__PURE__ */
|
|
1093
|
-
/* @__PURE__ */
|
|
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 }),
|
|
1249
|
+
/* @__PURE__ */ l(
|
|
1094
1250
|
"rect",
|
|
1095
1251
|
{
|
|
1096
1252
|
x: 0,
|
|
@@ -1098,99 +1254,102 @@ function _n({ def: e, onPointerDown: t, isPlaced: n }) {
|
|
|
1098
1254
|
width: 4,
|
|
1099
1255
|
height: i + 20,
|
|
1100
1256
|
fill: e.color,
|
|
1101
|
-
clipPath: `url(#${
|
|
1257
|
+
clipPath: `url(#${y})`
|
|
1102
1258
|
}
|
|
1103
1259
|
),
|
|
1104
|
-
c.length > 0 && /* @__PURE__ */
|
|
1105
|
-
/* @__PURE__ */
|
|
1260
|
+
c.length > 0 && /* @__PURE__ */ l(cn, { mouths: c, w: r, isEmpty: () => !0 }),
|
|
1261
|
+
/* @__PURE__ */ l(sn, { chips: p }),
|
|
1262
|
+
/* @__PURE__ */ m(
|
|
1106
1263
|
"text",
|
|
1107
1264
|
{
|
|
1108
1265
|
x: 11,
|
|
1109
|
-
y:
|
|
1110
|
-
fill:
|
|
1266
|
+
y: We(e) / 2 + 4,
|
|
1267
|
+
fill: o.blockText,
|
|
1111
1268
|
fontSize: 11,
|
|
1112
1269
|
fontWeight: "bold",
|
|
1113
1270
|
fontFamily: "sans-serif",
|
|
1114
1271
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1115
1272
|
children: [
|
|
1116
1273
|
e.name,
|
|
1117
|
-
e.blockType === "query" && e.returnType && /* @__PURE__ */
|
|
1274
|
+
e.blockType === "query" && e.returnType && /* @__PURE__ */ l("tspan", { fill: o.textMuted, fontSize: 9, fontWeight: "normal", children: ` [${e.returnType}]` })
|
|
1118
1275
|
]
|
|
1119
1276
|
}
|
|
1120
1277
|
),
|
|
1121
|
-
n && /* @__PURE__ */
|
|
1278
|
+
n && /* @__PURE__ */ l(
|
|
1122
1279
|
"text",
|
|
1123
1280
|
{
|
|
1124
|
-
x:
|
|
1281
|
+
x: r / 2,
|
|
1125
1282
|
y: i / 2 + 4,
|
|
1126
1283
|
textAnchor: "middle",
|
|
1127
|
-
fill:
|
|
1284
|
+
fill: o.textMuted,
|
|
1128
1285
|
fontSize: 9,
|
|
1129
1286
|
fontFamily: "sans-serif",
|
|
1130
1287
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1131
1288
|
children: "✓ on canvas"
|
|
1132
1289
|
}
|
|
1133
1290
|
),
|
|
1134
|
-
s.map((
|
|
1135
|
-
const
|
|
1136
|
-
return /* @__PURE__ */
|
|
1137
|
-
/* @__PURE__ */
|
|
1138
|
-
/* @__PURE__ */
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
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: [
|
|
1296
|
+
/* @__PURE__ */ l(
|
|
1297
|
+
"path",
|
|
1298
|
+
{
|
|
1299
|
+
d: nn(k.type, k.w, k.h),
|
|
1300
|
+
fill: o.socketBody,
|
|
1301
|
+
stroke: o.blockBorder,
|
|
1302
|
+
strokeWidth: 1
|
|
1303
|
+
}
|
|
1304
|
+
),
|
|
1305
|
+
/* @__PURE__ */ l(oo, { name: L.name, type: k.type, w: k.w, h: k.h })
|
|
1306
|
+
] })
|
|
1307
|
+
] }, k.index);
|
|
1149
1308
|
}),
|
|
1150
|
-
e.blockType === "start" && e.provides && e.provides.length > 0 && /* @__PURE__ */
|
|
1151
|
-
/* @__PURE__ */
|
|
1309
|
+
e.blockType === "start" && e.provides && e.provides.length > 0 && /* @__PURE__ */ m("g", { children: [
|
|
1310
|
+
/* @__PURE__ */ l(
|
|
1152
1311
|
"line",
|
|
1153
1312
|
{
|
|
1154
1313
|
x1: 8,
|
|
1155
|
-
y1:
|
|
1156
|
-
x2:
|
|
1157
|
-
y2:
|
|
1314
|
+
y1: De,
|
|
1315
|
+
x2: r - 8,
|
|
1316
|
+
y2: De,
|
|
1158
1317
|
stroke: "rgba(255,255,255,0.15)",
|
|
1159
1318
|
strokeWidth: 1
|
|
1160
1319
|
}
|
|
1161
1320
|
),
|
|
1162
|
-
e.
|
|
1163
|
-
const
|
|
1164
|
-
return /* @__PURE__ */
|
|
1165
|
-
/* @__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: [
|
|
1324
|
+
/* @__PURE__ */ l(
|
|
1166
1325
|
"rect",
|
|
1167
1326
|
{
|
|
1168
1327
|
x: 0,
|
|
1169
1328
|
y: 0,
|
|
1170
|
-
width:
|
|
1171
|
-
height:
|
|
1329
|
+
width: W,
|
|
1330
|
+
height: z,
|
|
1172
1331
|
rx: 10,
|
|
1173
|
-
fill:
|
|
1332
|
+
fill: T,
|
|
1174
1333
|
opacity: 0.82,
|
|
1175
1334
|
stroke: "rgba(255,255,255,0.25)",
|
|
1176
1335
|
strokeWidth: 1
|
|
1177
1336
|
}
|
|
1178
1337
|
),
|
|
1179
|
-
/* @__PURE__ */
|
|
1338
|
+
/* @__PURE__ */ l(
|
|
1180
1339
|
"text",
|
|
1181
1340
|
{
|
|
1182
|
-
x:
|
|
1183
|
-
y:
|
|
1341
|
+
x: W / 2,
|
|
1342
|
+
y: z / 2 + 3.5,
|
|
1184
1343
|
textAnchor: "middle",
|
|
1185
1344
|
fill: "white",
|
|
1186
1345
|
fontSize: 9.5,
|
|
1187
1346
|
fontFamily: "sans-serif",
|
|
1188
1347
|
fontWeight: "bold",
|
|
1189
1348
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1190
|
-
children:
|
|
1349
|
+
children: k.name
|
|
1191
1350
|
}
|
|
1192
1351
|
)
|
|
1193
|
-
] },
|
|
1352
|
+
] }, k.id);
|
|
1194
1353
|
})
|
|
1195
1354
|
] })
|
|
1196
1355
|
] })
|
|
@@ -1198,13 +1357,13 @@ function _n({ def: e, onPointerDown: t, isPlaced: n }) {
|
|
|
1198
1357
|
}
|
|
1199
1358
|
);
|
|
1200
1359
|
}
|
|
1201
|
-
function
|
|
1202
|
-
const s =
|
|
1203
|
-
return /* @__PURE__ */
|
|
1204
|
-
/* @__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(
|
|
1205
1364
|
"button",
|
|
1206
1365
|
{
|
|
1207
|
-
onClick: () =>
|
|
1366
|
+
onClick: () => o(e),
|
|
1208
1367
|
style: {
|
|
1209
1368
|
display: "flex",
|
|
1210
1369
|
alignItems: "center",
|
|
@@ -1219,43 +1378,43 @@ function er({ cat: e, defs: t, collapsed: n, onToggle: r, onPointerDown: o, plac
|
|
|
1219
1378
|
marginBottom: n ? 0 : 6
|
|
1220
1379
|
},
|
|
1221
1380
|
children: [
|
|
1222
|
-
/* @__PURE__ */
|
|
1223
|
-
/* @__PURE__ */
|
|
1224
|
-
n && /* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ l("span", { style: { color: s.accent, fontSize: 8, lineHeight: 1, opacity: 0.6 }, children: n ? "▶" : "▼" }),
|
|
1382
|
+
/* @__PURE__ */ l("span", { style: { color: s.accent, fontSize: 10, fontWeight: "bold", textTransform: "uppercase", letterSpacing: 1, opacity: 0.85 }, children: e }),
|
|
1383
|
+
n && /* @__PURE__ */ l("span", { style: { color: s.textMuted, fontSize: 9, marginLeft: "auto" }, children: t.length })
|
|
1225
1384
|
]
|
|
1226
1385
|
}
|
|
1227
1386
|
),
|
|
1228
|
-
!n && /* @__PURE__ */
|
|
1229
|
-
|
|
1387
|
+
!n && /* @__PURE__ */ l("div", { style: { paddingBottom: 4 }, children: t.map((c) => /* @__PURE__ */ l(
|
|
1388
|
+
ro,
|
|
1230
1389
|
{
|
|
1231
1390
|
def: c,
|
|
1232
|
-
onPointerDown:
|
|
1391
|
+
onPointerDown: r,
|
|
1233
1392
|
isPlaced: c.blockType === "start" && i.has(c.id)
|
|
1234
1393
|
},
|
|
1235
1394
|
c.id
|
|
1236
1395
|
)) })
|
|
1237
1396
|
] });
|
|
1238
1397
|
}
|
|
1239
|
-
function
|
|
1398
|
+
function qr({
|
|
1240
1399
|
onPointerDown: e,
|
|
1241
1400
|
isDropTarget: t,
|
|
1242
1401
|
registryVersion: n,
|
|
1243
|
-
packages:
|
|
1244
|
-
placedStartIds:
|
|
1402
|
+
packages: o,
|
|
1403
|
+
placedStartIds: r
|
|
1245
1404
|
}) {
|
|
1246
|
-
const i =
|
|
1247
|
-
function
|
|
1248
|
-
|
|
1249
|
-
const
|
|
1250
|
-
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;
|
|
1251
1410
|
});
|
|
1252
1411
|
}
|
|
1253
|
-
const
|
|
1412
|
+
const q = o?.dependencies.length ?? 0, S = (g) => ({
|
|
1254
1413
|
flex: 1,
|
|
1255
1414
|
background: "none",
|
|
1256
1415
|
border: "none",
|
|
1257
|
-
borderBottom: `2px solid ${s ===
|
|
1258
|
-
color: s ===
|
|
1416
|
+
borderBottom: `2px solid ${s === g ? i.accent : "transparent"}`,
|
|
1417
|
+
color: s === g ? i.accent : i.textMuted,
|
|
1259
1418
|
fontSize: 10,
|
|
1260
1419
|
fontWeight: "bold",
|
|
1261
1420
|
textTransform: "uppercase",
|
|
@@ -1264,7 +1423,7 @@ function tr({
|
|
|
1264
1423
|
cursor: "pointer",
|
|
1265
1424
|
transition: "color 0.15s, border-color 0.15s"
|
|
1266
1425
|
});
|
|
1267
|
-
return /* @__PURE__ */
|
|
1426
|
+
return /* @__PURE__ */ m("div", { style: {
|
|
1268
1427
|
width: 260,
|
|
1269
1428
|
minWidth: 260,
|
|
1270
1429
|
backgroundColor: i.paletteBg,
|
|
@@ -1274,21 +1433,21 @@ function tr({
|
|
|
1274
1433
|
height: "100%",
|
|
1275
1434
|
overflow: "hidden"
|
|
1276
1435
|
}, children: [
|
|
1277
|
-
|
|
1278
|
-
/* @__PURE__ */
|
|
1279
|
-
/* @__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: [
|
|
1280
1439
|
"Packages",
|
|
1281
|
-
|
|
1440
|
+
q > 0 ? ` · ${q}` : ""
|
|
1282
1441
|
] })
|
|
1283
1442
|
] }),
|
|
1284
|
-
s === "blocks" && /* @__PURE__ */
|
|
1285
|
-
/* @__PURE__ */
|
|
1443
|
+
s === "blocks" && /* @__PURE__ */ m(bt, { children: [
|
|
1444
|
+
/* @__PURE__ */ l("div", { style: { padding: "8px 10px 6px", flexShrink: 0 }, children: /* @__PURE__ */ l(
|
|
1286
1445
|
"input",
|
|
1287
1446
|
{
|
|
1288
1447
|
type: "search",
|
|
1289
1448
|
placeholder: "Search blocks…",
|
|
1290
|
-
value:
|
|
1291
|
-
onChange: (
|
|
1449
|
+
value: p,
|
|
1450
|
+
onChange: (g) => y(g.target.value),
|
|
1292
1451
|
style: {
|
|
1293
1452
|
width: "100%",
|
|
1294
1453
|
boxSizing: "border-box",
|
|
@@ -1302,27 +1461,27 @@ function tr({
|
|
|
1302
1461
|
}
|
|
1303
1462
|
}
|
|
1304
1463
|
) }),
|
|
1305
|
-
/* @__PURE__ */
|
|
1306
|
-
|
|
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,
|
|
1307
1466
|
{
|
|
1308
|
-
def:
|
|
1467
|
+
def: g,
|
|
1309
1468
|
onPointerDown: e,
|
|
1310
|
-
isPlaced:
|
|
1469
|
+
isPlaced: g.blockType === "start" && r.has(g.id)
|
|
1311
1470
|
},
|
|
1312
|
-
|
|
1313
|
-
)) : /* @__PURE__ */
|
|
1314
|
-
|
|
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,
|
|
1315
1474
|
{
|
|
1316
|
-
cat:
|
|
1317
|
-
defs:
|
|
1318
|
-
collapsed:
|
|
1319
|
-
onToggle:
|
|
1475
|
+
cat: g,
|
|
1476
|
+
defs: L.filter((ne) => ne.category === g),
|
|
1477
|
+
collapsed: x.has(g),
|
|
1478
|
+
onToggle: Y,
|
|
1320
1479
|
onPointerDown: e,
|
|
1321
|
-
placedStartIds:
|
|
1480
|
+
placedStartIds: r
|
|
1322
1481
|
},
|
|
1323
|
-
|
|
1482
|
+
g
|
|
1324
1483
|
)) }),
|
|
1325
|
-
/* @__PURE__ */
|
|
1484
|
+
/* @__PURE__ */ l("div", { style: {
|
|
1326
1485
|
flexShrink: 0,
|
|
1327
1486
|
margin: "8px 10px 10px",
|
|
1328
1487
|
padding: "7px 10px",
|
|
@@ -1340,81 +1499,87 @@ function tr({
|
|
|
1340
1499
|
userSelect: "none"
|
|
1341
1500
|
}, children: t ? "Release to delete" : "Drag here to delete" })
|
|
1342
1501
|
] }),
|
|
1343
|
-
s === "packages" &&
|
|
1502
|
+
s === "packages" && o && /* @__PURE__ */ l(Rr, { ...o })
|
|
1344
1503
|
] });
|
|
1345
1504
|
}
|
|
1346
|
-
function
|
|
1347
|
-
let
|
|
1505
|
+
function Ur(e, t, n) {
|
|
1506
|
+
let o = e;
|
|
1348
1507
|
for (; ; )
|
|
1349
|
-
if (
|
|
1350
|
-
const
|
|
1351
|
-
if (!
|
|
1352
|
-
|
|
1353
|
-
} else if (
|
|
1354
|
-
const
|
|
1355
|
-
if (!
|
|
1356
|
-
|
|
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;
|
|
1357
1516
|
} else
|
|
1358
|
-
return
|
|
1517
|
+
return N(o.definitionId)?.provides?.some((i) => i.id === t) ?? !1;
|
|
1359
1518
|
}
|
|
1360
|
-
function
|
|
1519
|
+
function wt(e) {
|
|
1361
1520
|
const {
|
|
1362
1521
|
block: t,
|
|
1363
1522
|
allBlocks: n,
|
|
1364
|
-
onPointerDown:
|
|
1365
|
-
onBlockClick:
|
|
1523
|
+
onPointerDown: o,
|
|
1524
|
+
onBlockClick: r,
|
|
1366
1525
|
onSocketClick: i,
|
|
1367
1526
|
editingSocket: s,
|
|
1368
1527
|
onSocketCommit: c,
|
|
1369
|
-
onSocketCancelEdit:
|
|
1370
|
-
onOutputDrag:
|
|
1371
|
-
isGhost:
|
|
1372
|
-
draggingIds:
|
|
1373
|
-
provisionalIds:
|
|
1374
|
-
onSocketInput:
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1528
|
+
onSocketCancelEdit: p,
|
|
1529
|
+
onOutputDrag: y,
|
|
1530
|
+
isGhost: x,
|
|
1531
|
+
draggingIds: k,
|
|
1532
|
+
provisionalIds: L,
|
|
1533
|
+
onSocketInput: T,
|
|
1534
|
+
onParamRemove: W,
|
|
1535
|
+
onMouthOpen: z,
|
|
1536
|
+
onMouthClose: Y,
|
|
1537
|
+
embedded: q
|
|
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,
|
|
1380
1542
|
{
|
|
1381
|
-
block:
|
|
1543
|
+
block: le,
|
|
1382
1544
|
allBlocks: n,
|
|
1383
|
-
onPointerDown:
|
|
1384
|
-
onBlockClick:
|
|
1545
|
+
onPointerDown: o,
|
|
1546
|
+
onBlockClick: r,
|
|
1385
1547
|
onSocketClick: i,
|
|
1386
1548
|
editingSocket: s,
|
|
1387
1549
|
onSocketCommit: c,
|
|
1388
|
-
onSocketCancelEdit:
|
|
1389
|
-
onOutputDrag:
|
|
1390
|
-
isGhost:
|
|
1391
|
-
draggingIds:
|
|
1392
|
-
provisionalIds:
|
|
1393
|
-
onSocketInput:
|
|
1550
|
+
onSocketCancelEdit: p,
|
|
1551
|
+
onOutputDrag: y,
|
|
1552
|
+
isGhost: x,
|
|
1553
|
+
draggingIds: k,
|
|
1554
|
+
provisionalIds: L,
|
|
1555
|
+
onSocketInput: T,
|
|
1556
|
+
onParamRemove: W,
|
|
1557
|
+
onMouthOpen: z,
|
|
1558
|
+
onMouthClose: Y,
|
|
1394
1559
|
embedded: !0
|
|
1395
1560
|
}
|
|
1396
|
-
) },
|
|
1561
|
+
) }, J) : null;
|
|
1397
1562
|
};
|
|
1398
|
-
if (!
|
|
1399
|
-
const
|
|
1400
|
-
|
|
1401
|
-
} : void 0,
|
|
1402
|
-
|
|
1403
|
-
} : void 0,
|
|
1404
|
-
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(
|
|
1405
1570
|
"g",
|
|
1406
1571
|
{
|
|
1407
|
-
transform:
|
|
1408
|
-
opacity:
|
|
1572
|
+
transform: x || q ? void 0 : `translate(${t.x},${t.y})`,
|
|
1573
|
+
opacity: ne ? 0.35 : 0.85,
|
|
1409
1574
|
children: [
|
|
1410
|
-
/* @__PURE__ */
|
|
1411
|
-
/* @__PURE__ */
|
|
1575
|
+
/* @__PURE__ */ m("g", { onPointerDown: u, onClick: _, style: { cursor: "grab" }, children: [
|
|
1576
|
+
/* @__PURE__ */ l(
|
|
1412
1577
|
"rect",
|
|
1413
1578
|
{
|
|
1414
1579
|
x: 0,
|
|
1415
1580
|
y: 0,
|
|
1416
1581
|
width: 160,
|
|
1417
|
-
height:
|
|
1582
|
+
height: je,
|
|
1418
1583
|
rx: 3,
|
|
1419
1584
|
fill: "rgba(160,40,40,0.18)",
|
|
1420
1585
|
stroke: "#c05050",
|
|
@@ -1422,7 +1587,7 @@ function ht(e) {
|
|
|
1422
1587
|
strokeDasharray: "5,3"
|
|
1423
1588
|
}
|
|
1424
1589
|
),
|
|
1425
|
-
/* @__PURE__ */
|
|
1590
|
+
/* @__PURE__ */ m(
|
|
1426
1591
|
"text",
|
|
1427
1592
|
{
|
|
1428
1593
|
x: 8,
|
|
@@ -1434,48 +1599,48 @@ function ht(e) {
|
|
|
1434
1599
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1435
1600
|
children: [
|
|
1436
1601
|
"⚠ ",
|
|
1437
|
-
|
|
1602
|
+
X,
|
|
1438
1603
|
" (missing)"
|
|
1439
1604
|
]
|
|
1440
1605
|
}
|
|
1441
1606
|
)
|
|
1442
1607
|
] }),
|
|
1443
|
-
|
|
1608
|
+
oe(t.nextBlockId, 0, je, "next")
|
|
1444
1609
|
]
|
|
1445
1610
|
}
|
|
1446
1611
|
);
|
|
1447
1612
|
}
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1450
|
-
} : void 0,
|
|
1451
|
-
|
|
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);
|
|
1452
1617
|
} : void 0;
|
|
1453
|
-
if (
|
|
1454
|
-
const
|
|
1455
|
-
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(
|
|
1456
1621
|
"g",
|
|
1457
1622
|
{
|
|
1458
|
-
transform:
|
|
1459
|
-
opacity:
|
|
1460
|
-
onPointerDown:
|
|
1461
|
-
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,
|
|
1462
1627
|
style: { cursor: "grab" },
|
|
1463
1628
|
children: [
|
|
1464
|
-
/* @__PURE__ */
|
|
1629
|
+
/* @__PURE__ */ l(
|
|
1465
1630
|
"path",
|
|
1466
1631
|
{
|
|
1467
|
-
d:
|
|
1632
|
+
d: X,
|
|
1468
1633
|
fill: "rgba(180,100,0,0.15)",
|
|
1469
1634
|
stroke: "#c08820",
|
|
1470
1635
|
strokeWidth: 1.5,
|
|
1471
1636
|
strokeDasharray: "5,3"
|
|
1472
1637
|
}
|
|
1473
1638
|
),
|
|
1474
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ m(
|
|
1475
1640
|
"text",
|
|
1476
1641
|
{
|
|
1477
|
-
x:
|
|
1478
|
-
y:
|
|
1642
|
+
x: u / 2,
|
|
1643
|
+
y: _ / 2 + 3.5,
|
|
1479
1644
|
textAnchor: "middle",
|
|
1480
1645
|
fill: "#c08820",
|
|
1481
1646
|
fontSize: 9,
|
|
@@ -1484,7 +1649,7 @@ function ht(e) {
|
|
|
1484
1649
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1485
1650
|
children: [
|
|
1486
1651
|
"⚠ ",
|
|
1487
|
-
|
|
1652
|
+
g.name
|
|
1488
1653
|
]
|
|
1489
1654
|
}
|
|
1490
1655
|
)
|
|
@@ -1492,245 +1657,296 @@ function ht(e) {
|
|
|
1492
1657
|
}
|
|
1493
1658
|
);
|
|
1494
1659
|
}
|
|
1495
|
-
return /* @__PURE__ */
|
|
1660
|
+
return /* @__PURE__ */ m(
|
|
1496
1661
|
"g",
|
|
1497
1662
|
{
|
|
1498
|
-
transform:
|
|
1499
|
-
opacity:
|
|
1500
|
-
onPointerDown:
|
|
1501
|
-
onClick:
|
|
1502
|
-
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" },
|
|
1503
1668
|
children: [
|
|
1504
|
-
/* @__PURE__ */
|
|
1505
|
-
/* @__PURE__ */
|
|
1669
|
+
/* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("clipPath", { id: qe, children: /* @__PURE__ */ l("path", { d: pe }) }) }),
|
|
1670
|
+
/* @__PURE__ */ l(
|
|
1506
1671
|
"path",
|
|
1507
1672
|
{
|
|
1508
|
-
d:
|
|
1509
|
-
fill:
|
|
1510
|
-
stroke: G ?
|
|
1673
|
+
d: pe,
|
|
1674
|
+
fill: S.blockBody,
|
|
1675
|
+
stroke: G ? S.accent : S.blockBorder,
|
|
1511
1676
|
strokeWidth: 1.5,
|
|
1512
1677
|
strokeDasharray: G ? "4,3" : void 0
|
|
1513
1678
|
}
|
|
1514
1679
|
),
|
|
1515
|
-
/* @__PURE__ */
|
|
1680
|
+
/* @__PURE__ */ l(
|
|
1516
1681
|
"rect",
|
|
1517
1682
|
{
|
|
1518
1683
|
x: 0,
|
|
1519
1684
|
y: 0,
|
|
1520
1685
|
width: 4,
|
|
1521
|
-
height:
|
|
1522
|
-
fill:
|
|
1523
|
-
clipPath: `url(#${
|
|
1686
|
+
height: b + 20,
|
|
1687
|
+
fill: g.color,
|
|
1688
|
+
clipPath: `url(#${qe})`
|
|
1524
1689
|
}
|
|
1525
1690
|
),
|
|
1526
|
-
/* @__PURE__ */
|
|
1691
|
+
/* @__PURE__ */ m(
|
|
1527
1692
|
"text",
|
|
1528
1693
|
{
|
|
1529
1694
|
x: 11,
|
|
1530
|
-
y:
|
|
1531
|
-
fill:
|
|
1695
|
+
y: U / 2 + 4,
|
|
1696
|
+
fill: S.blockText,
|
|
1532
1697
|
fontSize: 11,
|
|
1533
1698
|
fontWeight: "bold",
|
|
1534
1699
|
fontFamily: "sans-serif",
|
|
1535
1700
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1536
1701
|
children: [
|
|
1537
|
-
|
|
1538
|
-
|
|
1702
|
+
g.name,
|
|
1703
|
+
g.blockType === "query" && g.returnType && /* @__PURE__ */ l("tspan", { fill: S.textMuted, fontSize: 9, fontWeight: "normal", children: ` [${g.returnType}]` })
|
|
1539
1704
|
]
|
|
1540
1705
|
}
|
|
1541
1706
|
),
|
|
1542
|
-
|
|
1543
|
-
/* @__PURE__ */
|
|
1707
|
+
g.blockType === "start" && g.provides && g.provides.length > 0 && /* @__PURE__ */ m("g", { children: [
|
|
1708
|
+
/* @__PURE__ */ l(
|
|
1544
1709
|
"line",
|
|
1545
1710
|
{
|
|
1546
1711
|
x1: 8,
|
|
1547
|
-
y1:
|
|
1548
|
-
x2:
|
|
1549
|
-
y2:
|
|
1712
|
+
y1: De,
|
|
1713
|
+
x2: Z - 8,
|
|
1714
|
+
y2: De,
|
|
1550
1715
|
stroke: "rgba(255,255,255,0.15)",
|
|
1551
1716
|
strokeWidth: 1
|
|
1552
1717
|
}
|
|
1553
1718
|
),
|
|
1554
|
-
|
|
1555
|
-
const
|
|
1556
|
-
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(
|
|
1557
1722
|
"g",
|
|
1558
1723
|
{
|
|
1559
|
-
transform: `translate(${
|
|
1560
|
-
onPointerDown:
|
|
1561
|
-
|
|
1724
|
+
transform: `translate(${u.x}, ${u.y})`,
|
|
1725
|
+
onPointerDown: ke ? (ve) => {
|
|
1726
|
+
ve.stopPropagation(), y?.(ve, u.id);
|
|
1562
1727
|
} : void 0,
|
|
1563
|
-
style: { cursor:
|
|
1728
|
+
style: { cursor: ke ? "grab" : "default" },
|
|
1564
1729
|
children: [
|
|
1565
|
-
/* @__PURE__ */
|
|
1730
|
+
/* @__PURE__ */ l(
|
|
1566
1731
|
"rect",
|
|
1567
1732
|
{
|
|
1568
1733
|
x: 0,
|
|
1569
1734
|
y: 0,
|
|
1570
|
-
width:
|
|
1571
|
-
height:
|
|
1735
|
+
width: J,
|
|
1736
|
+
height: le,
|
|
1572
1737
|
rx: 10,
|
|
1573
|
-
fill:
|
|
1738
|
+
fill: X,
|
|
1574
1739
|
opacity: 0.82,
|
|
1575
1740
|
stroke: "rgba(255,255,255,0.25)",
|
|
1576
1741
|
strokeWidth: 1
|
|
1577
1742
|
}
|
|
1578
1743
|
),
|
|
1579
|
-
/* @__PURE__ */
|
|
1744
|
+
/* @__PURE__ */ l(
|
|
1580
1745
|
"text",
|
|
1581
1746
|
{
|
|
1582
|
-
x:
|
|
1583
|
-
y:
|
|
1747
|
+
x: J / 2,
|
|
1748
|
+
y: le / 2 + 3.5,
|
|
1584
1749
|
textAnchor: "middle",
|
|
1585
1750
|
fill: "white",
|
|
1586
1751
|
fontSize: 9.5,
|
|
1587
1752
|
fontFamily: "sans-serif",
|
|
1588
1753
|
fontWeight: "bold",
|
|
1589
1754
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1590
|
-
children:
|
|
1755
|
+
children: u.name
|
|
1591
1756
|
}
|
|
1592
1757
|
)
|
|
1593
1758
|
]
|
|
1594
1759
|
},
|
|
1595
|
-
|
|
1760
|
+
u.id
|
|
1596
1761
|
);
|
|
1597
1762
|
})
|
|
1598
1763
|
] }),
|
|
1599
|
-
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
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,
|
|
1767
|
+
{
|
|
1768
|
+
w: u.w,
|
|
1769
|
+
title: `Leave out ${ke}`,
|
|
1770
|
+
onRemove: () => W(t.instanceId, u.index)
|
|
1771
|
+
}
|
|
1772
|
+
) : null;
|
|
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(
|
|
1782
|
+
"g",
|
|
1783
|
+
{
|
|
1784
|
+
transform: `translate(${u.x},${u.y})`,
|
|
1785
|
+
onPointerDown: (v) => v.stopPropagation(),
|
|
1786
|
+
onClick: (v) => {
|
|
1787
|
+
v.stopPropagation(), i?.(t.instanceId, u.index);
|
|
1788
|
+
},
|
|
1789
|
+
style: { cursor: "pointer" },
|
|
1790
|
+
children: [
|
|
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 })
|
|
1793
|
+
]
|
|
1794
|
+
},
|
|
1795
|
+
u.index
|
|
1796
|
+
);
|
|
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(
|
|
1608
1799
|
"g",
|
|
1609
1800
|
{
|
|
1610
|
-
transform: `translate(${
|
|
1611
|
-
onPointerDown: (
|
|
1612
|
-
onClick: (
|
|
1613
|
-
|
|
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);
|
|
1614
1805
|
},
|
|
1615
1806
|
style: { cursor: "text" },
|
|
1616
1807
|
children: [
|
|
1617
|
-
/* @__PURE__ */
|
|
1618
|
-
/* @__PURE__ */
|
|
1808
|
+
/* @__PURE__ */ l("title", { children: ve }),
|
|
1809
|
+
/* @__PURE__ */ l(
|
|
1619
1810
|
"path",
|
|
1620
1811
|
{
|
|
1621
|
-
d:
|
|
1622
|
-
fill:
|
|
1623
|
-
stroke:
|
|
1624
|
-
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
|
|
1625
1816
|
}
|
|
1626
1817
|
),
|
|
1627
|
-
|
|
1818
|
+
re ? /* @__PURE__ */ l("foreignObject", { x: 0, y: 0, width: ae, height: ge, children: /* @__PURE__ */ l(
|
|
1628
1819
|
"input",
|
|
1629
1820
|
{
|
|
1630
1821
|
autoFocus: !0,
|
|
1631
|
-
defaultValue:
|
|
1632
|
-
onChange: (
|
|
1633
|
-
onKeyDown: (
|
|
1634
|
-
|
|
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?.();
|
|
1635
1826
|
},
|
|
1636
|
-
onBlur: (
|
|
1637
|
-
onPointerDown: (
|
|
1827
|
+
onBlur: (v) => c?.(t.instanceId, u.index, v.target.value),
|
|
1828
|
+
onPointerDown: (v) => v.stopPropagation(),
|
|
1638
1829
|
style: {
|
|
1639
1830
|
width: "100%",
|
|
1640
1831
|
height: "100%",
|
|
1641
1832
|
background: "transparent",
|
|
1642
1833
|
border: "none",
|
|
1643
1834
|
outline: "none",
|
|
1644
|
-
color:
|
|
1835
|
+
color: S.blockText,
|
|
1645
1836
|
fontSize: 10,
|
|
1646
1837
|
fontFamily: "sans-serif",
|
|
1647
1838
|
textAlign: "center",
|
|
1648
1839
|
padding: "0 4px",
|
|
1649
1840
|
boxSizing: "border-box",
|
|
1650
|
-
caretColor:
|
|
1841
|
+
caretColor: S.blockText
|
|
1651
1842
|
}
|
|
1652
1843
|
}
|
|
1653
|
-
) }) :
|
|
1844
|
+
) }) : be ? /* @__PURE__ */ l(
|
|
1654
1845
|
"text",
|
|
1655
1846
|
{
|
|
1656
|
-
x:
|
|
1657
|
-
y:
|
|
1847
|
+
x: u.w / 2,
|
|
1848
|
+
y: u.h / 2 + 4,
|
|
1658
1849
|
textAnchor: "middle",
|
|
1659
|
-
fill:
|
|
1850
|
+
fill: S.blockText,
|
|
1660
1851
|
fontSize: 10,
|
|
1661
1852
|
fontFamily: "sans-serif",
|
|
1662
1853
|
fontStyle: G ? "italic" : void 0,
|
|
1663
1854
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1664
|
-
children:
|
|
1855
|
+
children: be
|
|
1665
1856
|
}
|
|
1666
|
-
) : /* @__PURE__ */
|
|
1857
|
+
) : /* @__PURE__ */ l(oo, { name: ke, type: u.type, w: u.w, h: u.h }),
|
|
1858
|
+
!re && Oe
|
|
1667
1859
|
]
|
|
1668
1860
|
},
|
|
1669
|
-
|
|
1861
|
+
u.index
|
|
1670
1862
|
);
|
|
1671
1863
|
}),
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
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")
|
|
1675
1885
|
]
|
|
1676
1886
|
}
|
|
1677
1887
|
);
|
|
1678
1888
|
}
|
|
1679
|
-
const
|
|
1889
|
+
const io = Oo(
|
|
1680
1890
|
({
|
|
1681
1891
|
blocks: e,
|
|
1682
1892
|
draggingIds: t,
|
|
1683
1893
|
provisionalIds: n,
|
|
1684
|
-
onBlockPointerDown:
|
|
1685
|
-
onBlockClick:
|
|
1894
|
+
onBlockPointerDown: o,
|
|
1895
|
+
onBlockClick: r,
|
|
1686
1896
|
onSocketClick: i,
|
|
1687
1897
|
editingSocket: s,
|
|
1688
1898
|
onSocketInput: c,
|
|
1689
|
-
onSocketCommit:
|
|
1690
|
-
onSocketCancelEdit:
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1899
|
+
onSocketCommit: p,
|
|
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(
|
|
1696
1909
|
"svg",
|
|
1697
1910
|
{
|
|
1698
|
-
ref:
|
|
1699
|
-
style: { flex: 1, background:
|
|
1700
|
-
onPointerDown: (
|
|
1701
|
-
|
|
1911
|
+
ref: z,
|
|
1912
|
+
style: { flex: 1, background: Y.canvasBg, display: "block" },
|
|
1913
|
+
onPointerDown: (S) => {
|
|
1914
|
+
S.target === S.currentTarget && S.preventDefault();
|
|
1702
1915
|
},
|
|
1703
1916
|
children: [
|
|
1704
|
-
/* @__PURE__ */
|
|
1705
|
-
/* @__PURE__ */
|
|
1706
|
-
|
|
1707
|
-
|
|
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 }) }) }),
|
|
1918
|
+
/* @__PURE__ */ l("rect", { width: "100%", height: "100%", fill: "url(#grid)" }),
|
|
1919
|
+
q.map((S) => /* @__PURE__ */ l(
|
|
1920
|
+
wt,
|
|
1708
1921
|
{
|
|
1709
|
-
block:
|
|
1922
|
+
block: S,
|
|
1710
1923
|
allBlocks: e,
|
|
1711
|
-
onPointerDown:
|
|
1712
|
-
onBlockClick:
|
|
1924
|
+
onPointerDown: o,
|
|
1925
|
+
onBlockClick: r,
|
|
1713
1926
|
onSocketClick: i,
|
|
1714
1927
|
draggingIds: t,
|
|
1715
1928
|
provisionalIds: n,
|
|
1716
1929
|
editingSocket: s,
|
|
1717
1930
|
onSocketInput: c,
|
|
1718
|
-
onSocketCommit:
|
|
1719
|
-
onSocketCancelEdit:
|
|
1720
|
-
|
|
1931
|
+
onSocketCommit: p,
|
|
1932
|
+
onSocketCancelEdit: y,
|
|
1933
|
+
onParamRemove: x,
|
|
1934
|
+
onMouthOpen: k,
|
|
1935
|
+
onMouthClose: L,
|
|
1936
|
+
onOutputDrag: T
|
|
1721
1937
|
},
|
|
1722
|
-
|
|
1938
|
+
S.instanceId
|
|
1723
1939
|
)),
|
|
1724
|
-
|
|
1940
|
+
W
|
|
1725
1941
|
]
|
|
1726
1942
|
}
|
|
1727
1943
|
);
|
|
1728
1944
|
}
|
|
1729
1945
|
);
|
|
1730
|
-
|
|
1731
|
-
function
|
|
1732
|
-
const t =
|
|
1733
|
-
return /* @__PURE__ */
|
|
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: {
|
|
1734
1950
|
background: t.id === n.id ? t.switcherActiveBg : t.switcherBg,
|
|
1735
1951
|
border: `1px solid ${t.switcherBorder}`,
|
|
1736
1952
|
borderRadius: 4,
|
|
@@ -1743,31 +1959,31 @@ function or({ onSelect: e }) {
|
|
|
1743
1959
|
transition: "color 0.1s, background 0.1s"
|
|
1744
1960
|
}, children: n.label }, n.id)) });
|
|
1745
1961
|
}
|
|
1746
|
-
function
|
|
1747
|
-
const s =
|
|
1962
|
+
function Yr({ canUndo: e, canRedo: t, onUndo: n, onRedo: o, notice: r, extra: i }) {
|
|
1963
|
+
const s = Q(), c = (p) => ({
|
|
1748
1964
|
width: 28,
|
|
1749
1965
|
height: 24,
|
|
1750
1966
|
padding: 0,
|
|
1751
1967
|
background: s.paletteBg,
|
|
1752
|
-
color:
|
|
1968
|
+
color: p ? s.textPrimary : s.textMuted,
|
|
1753
1969
|
border: `1px solid ${s.border}`,
|
|
1754
1970
|
borderRadius: 4,
|
|
1755
1971
|
fontSize: 14,
|
|
1756
1972
|
lineHeight: 1,
|
|
1757
|
-
cursor:
|
|
1758
|
-
opacity:
|
|
1973
|
+
cursor: p ? "pointer" : "default",
|
|
1974
|
+
opacity: p ? 1 : 0.5
|
|
1759
1975
|
});
|
|
1760
|
-
return /* @__PURE__ */
|
|
1761
|
-
|
|
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: {
|
|
1762
1978
|
fontSize: 11,
|
|
1763
1979
|
color: s.textPrimary,
|
|
1764
1980
|
background: s.paletteBg,
|
|
1765
1981
|
border: `1px solid ${s.accent}`,
|
|
1766
1982
|
borderRadius: 4,
|
|
1767
1983
|
padding: "3px 8px"
|
|
1768
|
-
}, children:
|
|
1769
|
-
i && /* @__PURE__ */
|
|
1770
|
-
/* @__PURE__ */
|
|
1984
|
+
}, children: r }),
|
|
1985
|
+
i && /* @__PURE__ */ l("div", { style: { pointerEvents: "auto" }, children: i }),
|
|
1986
|
+
/* @__PURE__ */ l(
|
|
1771
1987
|
"button",
|
|
1772
1988
|
{
|
|
1773
1989
|
type: "button",
|
|
@@ -1779,55 +1995,55 @@ function rr({ canUndo: e, canRedo: t, onUndo: n, onRedo: r, notice: o, extra: i
|
|
|
1779
1995
|
children: "↶"
|
|
1780
1996
|
}
|
|
1781
1997
|
),
|
|
1782
|
-
/* @__PURE__ */
|
|
1998
|
+
/* @__PURE__ */ l(
|
|
1783
1999
|
"button",
|
|
1784
2000
|
{
|
|
1785
2001
|
type: "button",
|
|
1786
2002
|
title: "Redo (Ctrl+Shift+Z)",
|
|
1787
2003
|
"aria-label": "Redo",
|
|
1788
2004
|
disabled: !t,
|
|
1789
|
-
onClick:
|
|
2005
|
+
onClick: o,
|
|
1790
2006
|
style: { ...c(t), pointerEvents: "auto" },
|
|
1791
2007
|
children: "↷"
|
|
1792
2008
|
}
|
|
1793
2009
|
)
|
|
1794
2010
|
] });
|
|
1795
2011
|
}
|
|
1796
|
-
function
|
|
2012
|
+
function Fr(e) {
|
|
1797
2013
|
try {
|
|
1798
2014
|
return localStorage.getItem(e);
|
|
1799
2015
|
} catch {
|
|
1800
2016
|
return null;
|
|
1801
2017
|
}
|
|
1802
2018
|
}
|
|
1803
|
-
function
|
|
2019
|
+
function Xr(e, t) {
|
|
1804
2020
|
try {
|
|
1805
2021
|
localStorage.setItem(e, t);
|
|
1806
2022
|
} catch {
|
|
1807
2023
|
}
|
|
1808
2024
|
}
|
|
1809
|
-
let
|
|
1810
|
-
function
|
|
1811
|
-
|
|
2025
|
+
let _e = null;
|
|
2026
|
+
function jr(e) {
|
|
2027
|
+
_e === null && (_e = e);
|
|
1812
2028
|
}
|
|
1813
|
-
function
|
|
1814
|
-
|
|
2029
|
+
function Kr(e) {
|
|
2030
|
+
_e === e && (_e = null);
|
|
1815
2031
|
}
|
|
1816
|
-
function
|
|
1817
|
-
|
|
2032
|
+
function Qr(e) {
|
|
2033
|
+
_e = e;
|
|
1818
2034
|
}
|
|
1819
|
-
function
|
|
1820
|
-
return
|
|
2035
|
+
function Gr(e) {
|
|
2036
|
+
return _e === null || _e === e;
|
|
1821
2037
|
}
|
|
1822
|
-
function
|
|
1823
|
-
const n =
|
|
1824
|
-
return /* @__PURE__ */
|
|
1825
|
-
/* @__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: [
|
|
2041
|
+
/* @__PURE__ */ l(
|
|
1826
2042
|
"button",
|
|
1827
2043
|
{
|
|
1828
2044
|
type: "button",
|
|
1829
|
-
onClick: () =>
|
|
1830
|
-
"aria-expanded":
|
|
2045
|
+
onClick: () => r((i) => !i),
|
|
2046
|
+
"aria-expanded": o,
|
|
1831
2047
|
style: {
|
|
1832
2048
|
height: 24,
|
|
1833
2049
|
padding: "0 8px",
|
|
@@ -1841,7 +2057,7 @@ function ur({ writers: e, onExport: t }) {
|
|
|
1841
2057
|
children: "Export ▾"
|
|
1842
2058
|
}
|
|
1843
2059
|
),
|
|
1844
|
-
|
|
2060
|
+
o && /* @__PURE__ */ l("div", { role: "menu", style: {
|
|
1845
2061
|
position: "absolute",
|
|
1846
2062
|
top: 28,
|
|
1847
2063
|
right: 0,
|
|
@@ -1851,13 +2067,13 @@ function ur({ writers: e, onExport: t }) {
|
|
|
1851
2067
|
border: `1px solid ${n.border}`,
|
|
1852
2068
|
borderRadius: 4,
|
|
1853
2069
|
padding: 3
|
|
1854
|
-
}, children: e.map((i) => /* @__PURE__ */
|
|
2070
|
+
}, children: e.map((i) => /* @__PURE__ */ m(
|
|
1855
2071
|
"button",
|
|
1856
2072
|
{
|
|
1857
2073
|
type: "button",
|
|
1858
2074
|
role: "menuitem",
|
|
1859
2075
|
onClick: () => {
|
|
1860
|
-
|
|
2076
|
+
r(!1), t(i);
|
|
1861
2077
|
},
|
|
1862
2078
|
style: {
|
|
1863
2079
|
display: "block",
|
|
@@ -1873,7 +2089,7 @@ function ur({ writers: e, onExport: t }) {
|
|
|
1873
2089
|
children: [
|
|
1874
2090
|
i.label,
|
|
1875
2091
|
" ",
|
|
1876
|
-
/* @__PURE__ */
|
|
2092
|
+
/* @__PURE__ */ m("span", { style: { color: n.textMuted }, children: [
|
|
1877
2093
|
".",
|
|
1878
2094
|
i.fileExtension
|
|
1879
2095
|
] })
|
|
@@ -1883,40 +2099,40 @@ function ur({ writers: e, onExport: t }) {
|
|
|
1883
2099
|
)) })
|
|
1884
2100
|
] });
|
|
1885
2101
|
}
|
|
1886
|
-
function
|
|
1887
|
-
const n =
|
|
1888
|
-
if (!n) return { w: 160, h:
|
|
1889
|
-
const
|
|
1890
|
-
return { w:
|
|
1891
|
-
}
|
|
1892
|
-
function
|
|
1893
|
-
const
|
|
1894
|
-
return /* @__PURE__ */
|
|
1895
|
-
const { color: i } =
|
|
1896
|
-
if (
|
|
1897
|
-
const c = t.get(
|
|
1898
|
-
|
|
1899
|
-
/* @__PURE__ */
|
|
1900
|
-
/* @__PURE__ */
|
|
1901
|
-
/* @__PURE__ */
|
|
1902
|
-
|
|
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,
|
|
1903
2119
|
"|"
|
|
1904
2120
|
] })
|
|
1905
2121
|
] }, "typing")
|
|
1906
2122
|
);
|
|
1907
2123
|
}
|
|
1908
|
-
if (
|
|
1909
|
-
const c = t.get(
|
|
1910
|
-
if (c &&
|
|
1911
|
-
const { w:
|
|
2124
|
+
if (r.drag && "leadId" in r.drag) {
|
|
2125
|
+
const c = t.get(r.drag.leadId), p = n.get(r.drag.leadId);
|
|
2126
|
+
if (c && p) {
|
|
2127
|
+
const { w: y, h: x } = Jr(c, t);
|
|
1912
2128
|
s.push(
|
|
1913
|
-
/* @__PURE__ */
|
|
2129
|
+
/* @__PURE__ */ l(
|
|
1914
2130
|
"rect",
|
|
1915
2131
|
{
|
|
1916
|
-
x:
|
|
1917
|
-
y:
|
|
1918
|
-
width:
|
|
1919
|
-
height:
|
|
2132
|
+
x: p.x - 3,
|
|
2133
|
+
y: p.y - 3,
|
|
2134
|
+
width: y + 6,
|
|
2135
|
+
height: x + 6,
|
|
1920
2136
|
rx: 5,
|
|
1921
2137
|
fill: "none",
|
|
1922
2138
|
stroke: i,
|
|
@@ -1925,39 +2141,39 @@ function pr({ peers: e, blocks: t, layout: n }) {
|
|
|
1925
2141
|
},
|
|
1926
2142
|
"origin"
|
|
1927
2143
|
),
|
|
1928
|
-
/* @__PURE__ */
|
|
1929
|
-
/* @__PURE__ */
|
|
1930
|
-
/* @__PURE__ */
|
|
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 })
|
|
1931
2147
|
] }, "ghost")
|
|
1932
2148
|
);
|
|
1933
2149
|
}
|
|
1934
2150
|
}
|
|
1935
|
-
if (
|
|
1936
|
-
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;
|
|
1937
2153
|
s.push(
|
|
1938
|
-
/* @__PURE__ */
|
|
1939
|
-
/* @__PURE__ */
|
|
1940
|
-
/* @__PURE__ */
|
|
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 })
|
|
1941
2157
|
] }, "new")
|
|
1942
2158
|
);
|
|
1943
2159
|
}
|
|
1944
|
-
if (
|
|
1945
|
-
const c =
|
|
2160
|
+
if (r.cursor) {
|
|
2161
|
+
const c = r.name.length * 6.5 + 10;
|
|
1946
2162
|
s.push(
|
|
1947
|
-
/* @__PURE__ */
|
|
1948
|
-
/* @__PURE__ */
|
|
1949
|
-
/* @__PURE__ */
|
|
1950
|
-
/* @__PURE__ */
|
|
2163
|
+
/* @__PURE__ */ m("g", { transform: `translate(${r.cursor.x},${r.cursor.y})`, children: [
|
|
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 }),
|
|
2165
|
+
/* @__PURE__ */ l("rect", { x: 12, y: 14, width: c, height: 16, rx: 3, fill: i }),
|
|
2166
|
+
/* @__PURE__ */ l("text", { x: 17, y: 26, fill: "white", fontSize: 10, fontFamily: "sans-serif", children: r.name })
|
|
1951
2167
|
] }, "cursor")
|
|
1952
2168
|
);
|
|
1953
2169
|
}
|
|
1954
|
-
return /* @__PURE__ */
|
|
2170
|
+
return /* @__PURE__ */ l("g", { children: s }, r.clientId);
|
|
1955
2171
|
}) });
|
|
1956
2172
|
}
|
|
1957
|
-
const
|
|
1958
|
-
function
|
|
1959
|
-
const
|
|
1960
|
-
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}: ${{
|
|
1961
2177
|
TEXT_CHANGED: "someone else changed that parameter",
|
|
1962
2178
|
PLACE_OCCUPIED: "someone else put a block there first",
|
|
1963
2179
|
BLOCK_NOT_FOUND: "a block it needs was deleted",
|
|
@@ -1968,40 +2184,40 @@ function gr(e, t, n) {
|
|
|
1968
2184
|
DEPENDENCIES_CHANGED: "someone else changed the packages"
|
|
1969
2185
|
}[t] ?? "the canvas has changed"}.`;
|
|
1970
2186
|
}
|
|
1971
|
-
function
|
|
2187
|
+
function ut() {
|
|
1972
2188
|
if (typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
1973
2189
|
const e = crypto.getRandomValues(new Uint8Array(16));
|
|
1974
2190
|
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
1975
2191
|
const t = [...e].map((n) => n.toString(16).padStart(2, "0")).join("");
|
|
1976
2192
|
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
1977
2193
|
}
|
|
1978
|
-
function
|
|
2194
|
+
function oi(e, t) {
|
|
1979
2195
|
return e.embeddedInBlockId ? t.get(e.embeddedInBlockId)?.paramSlots[e.embeddedSlotIndex]?.commandBlockId === e.instanceId : !1;
|
|
1980
2196
|
}
|
|
1981
|
-
function
|
|
2197
|
+
function ri(e) {
|
|
1982
2198
|
return e.kind === "next" ? { next: e.blockId } : { mouth: e.blockId, slot: e.slotIndex };
|
|
1983
2199
|
}
|
|
1984
|
-
async function
|
|
2200
|
+
async function Tn(e, t) {
|
|
1985
2201
|
if (!e || !t) return !1;
|
|
1986
|
-
const n = new Map(e.map((s) => [
|
|
1987
|
-
|
|
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);
|
|
1988
2204
|
for (const [s, c] of i)
|
|
1989
|
-
await
|
|
1990
|
-
return
|
|
1991
|
-
}
|
|
1992
|
-
function
|
|
1993
|
-
const t = new Map(
|
|
1994
|
-
return e.forEach((
|
|
1995
|
-
const
|
|
1996
|
-
if (!
|
|
1997
|
-
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);
|
|
1998
2214
|
n.set(i, (n.get(i) ?? 0) + 1);
|
|
1999
2215
|
}), n;
|
|
2000
2216
|
}
|
|
2001
|
-
function
|
|
2002
|
-
const
|
|
2217
|
+
function si(e, t, n) {
|
|
2218
|
+
const o = yt(e);
|
|
2003
2219
|
return {
|
|
2004
|
-
instanceId:
|
|
2220
|
+
instanceId: ut(),
|
|
2005
2221
|
definitionId: e,
|
|
2006
2222
|
x: t,
|
|
2007
2223
|
y: n,
|
|
@@ -2009,392 +2225,430 @@ function xr(e, t, n) {
|
|
|
2009
2225
|
parentBlockId: null,
|
|
2010
2226
|
embeddedInBlockId: null,
|
|
2011
2227
|
embeddedSlotIndex: -1,
|
|
2012
|
-
paramSlots:
|
|
2228
|
+
paramSlots: o.params.map(() => ({ textValue: null, queryBlockId: null, commandBlockId: null }))
|
|
2013
2229
|
};
|
|
2014
2230
|
}
|
|
2015
|
-
function
|
|
2231
|
+
function Ut(e, t) {
|
|
2016
2232
|
const n = [];
|
|
2017
|
-
let
|
|
2018
|
-
for (;
|
|
2019
|
-
n.push(
|
|
2233
|
+
let o = e;
|
|
2234
|
+
for (; o; )
|
|
2235
|
+
n.push(o), o = t.get(o)?.nextBlockId ?? null;
|
|
2020
2236
|
return n;
|
|
2021
2237
|
}
|
|
2022
|
-
function
|
|
2238
|
+
function Vt(e, t) {
|
|
2023
2239
|
const n = t.get(e);
|
|
2024
|
-
return n?.parentBlockId ?
|
|
2240
|
+
return n?.parentBlockId ? Vt(n.parentBlockId, t) : n && oi(n, t) ? Vt(n.embeddedInBlockId, t) : e;
|
|
2025
2241
|
}
|
|
2026
|
-
function
|
|
2027
|
-
const n =
|
|
2242
|
+
function Yt(e, t) {
|
|
2243
|
+
const n = N(e.definitionId);
|
|
2028
2244
|
if (!n) return `[missing:${e.definitionId}]`;
|
|
2029
|
-
const
|
|
2245
|
+
const o = e.paramSlots.map((r, i) => {
|
|
2030
2246
|
const s = n.params[i];
|
|
2031
|
-
if (s &&
|
|
2032
|
-
const
|
|
2033
|
-
return
|
|
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));
|
|
2249
|
+
return p.length > 0 ? `{ ${p.join("; ")} }` : "{ }";
|
|
2034
2250
|
}
|
|
2035
|
-
if (
|
|
2036
|
-
const c = t.get(
|
|
2037
|
-
if (c) return
|
|
2251
|
+
if (r.queryBlockId) {
|
|
2252
|
+
const c = t.get(r.queryBlockId);
|
|
2253
|
+
if (c) return Yt(c, t);
|
|
2038
2254
|
}
|
|
2039
|
-
return
|
|
2255
|
+
return r.textValue !== null && r.textValue !== void 0 ? n.params[i]?.type === "string" ? `"${r.textValue}"` : r.textValue : "_";
|
|
2040
2256
|
});
|
|
2041
|
-
return `${n.id}(${
|
|
2257
|
+
return `${n.id}(${o.join(", ")})`;
|
|
2042
2258
|
}
|
|
2043
|
-
function
|
|
2044
|
-
const
|
|
2259
|
+
function ci({ ghostPos: e, blocks: t }) {
|
|
2260
|
+
const n = Q();
|
|
2045
2261
|
if (!e) return null;
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
return /* @__PURE__ */ a("svg", { style: { position: "fixed", top: 0, left: 0, width: "100%", height: "100%", pointerEvents: "none", zIndex: 9999 }, children: /* @__PURE__ */ a("g", { transform: `translate(${e.x},${e.y})`, opacity: 0.8, children: /* @__PURE__ */ a(ht, { block: h, allBlocks: n, isGhost: !0 }) }) });
|
|
2262
|
+
if (e.instanceId) {
|
|
2263
|
+
const p = t.get(e.instanceId);
|
|
2264
|
+
if (p)
|
|
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 }) }) });
|
|
2051
2266
|
}
|
|
2052
|
-
const
|
|
2053
|
-
return /* @__PURE__ */
|
|
2054
|
-
|
|
2055
|
-
/* @__PURE__ */
|
|
2056
|
-
/* @__PURE__ */
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
/* @__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: [
|
|
2269
|
+
i && /* @__PURE__ */ l("defs", { children: /* @__PURE__ */ l("clipPath", { id: "ghost-pal-clip", children: /* @__PURE__ */ l("path", { d: s }) }) }),
|
|
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) }),
|
|
2275
|
+
/* @__PURE__ */ l(
|
|
2060
2276
|
"text",
|
|
2061
2277
|
{
|
|
2062
2278
|
x: 11,
|
|
2063
|
-
y:
|
|
2064
|
-
fill:
|
|
2279
|
+
y: We(o) / 2 + 4,
|
|
2280
|
+
fill: i ? n.blockText : "white",
|
|
2065
2281
|
fontSize: 11,
|
|
2066
2282
|
fontWeight: "bold",
|
|
2067
2283
|
fontFamily: "sans-serif",
|
|
2068
2284
|
style: { userSelect: "none" },
|
|
2069
|
-
children:
|
|
2285
|
+
children: o.name
|
|
2070
2286
|
}
|
|
2071
2287
|
)
|
|
2072
2288
|
] })
|
|
2073
2289
|
] });
|
|
2074
2290
|
}
|
|
2075
|
-
function
|
|
2291
|
+
function li(e, t) {
|
|
2076
2292
|
return e.returnType === t || (e.usableAs?.includes(t) ?? !1);
|
|
2077
2293
|
}
|
|
2078
|
-
function
|
|
2294
|
+
function hi({
|
|
2079
2295
|
blocksUrl: e = "/blocks.json",
|
|
2080
2296
|
blocksUrls: t,
|
|
2081
2297
|
onRun: n,
|
|
2082
|
-
onThemeChange:
|
|
2083
|
-
navTabs:
|
|
2298
|
+
onThemeChange: o,
|
|
2299
|
+
navTabs: r,
|
|
2084
2300
|
initialState: i,
|
|
2085
2301
|
onSave: s,
|
|
2086
2302
|
themeId: c,
|
|
2087
|
-
hideTitleBar:
|
|
2088
|
-
getStateRef:
|
|
2089
|
-
additionalBlocks:
|
|
2090
|
-
dependencies:
|
|
2091
|
-
onDependenciesChange:
|
|
2092
|
-
packageBlocksUrl:
|
|
2093
|
-
availablePackages:
|
|
2094
|
-
packageActions:
|
|
2095
|
-
collaboration:
|
|
2096
|
-
scriptWriters:
|
|
2097
|
-
onExport:
|
|
2303
|
+
hideTitleBar: p,
|
|
2304
|
+
getStateRef: y,
|
|
2305
|
+
additionalBlocks: x,
|
|
2306
|
+
dependencies: k,
|
|
2307
|
+
onDependenciesChange: L,
|
|
2308
|
+
packageBlocksUrl: T,
|
|
2309
|
+
availablePackages: W,
|
|
2310
|
+
packageActions: z,
|
|
2311
|
+
collaboration: Y,
|
|
2312
|
+
scriptWriters: q,
|
|
2313
|
+
onExport: S
|
|
2098
2314
|
}) {
|
|
2099
|
-
const [
|
|
2100
|
-
if (c) return
|
|
2101
|
-
const
|
|
2102
|
-
return
|
|
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;
|
|
2103
2327
|
});
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
const [X, re] = P(!1), [le, x] = P(null), T = v?.commands, q = v?.clientId ?? hr, [Y, ae] = P(() => vn({
|
|
2110
|
-
blocks: new Map((i?.blocks ?? []).map(([l, d]) => [l, Te(d)])),
|
|
2111
|
-
dependencies: B ?? []
|
|
2112
|
-
})), { state: ie, provisionalIds: m } = ze(() => dn(Y), [Y]), b = ie.blocks, M = te(Y), V = te(ie);
|
|
2113
|
-
Q(() => {
|
|
2114
|
-
M.current = Y, V.current = ie;
|
|
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;
|
|
2115
2333
|
});
|
|
2116
|
-
const
|
|
2117
|
-
|
|
2118
|
-
const fe = te(W);
|
|
2119
|
-
Q(() => {
|
|
2120
|
-
fe.current = W;
|
|
2121
|
-
});
|
|
2122
|
-
const [O, Oe] = P(null), Le = te(null), Pe = E((l) => {
|
|
2123
|
-
Oe(l), Le.current && clearTimeout(Le.current), Le.current = setTimeout(() => Oe(null), 5e3);
|
|
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);
|
|
2124
2336
|
}, []);
|
|
2125
|
-
|
|
2126
|
-
|
|
2337
|
+
ee(() => () => {
|
|
2338
|
+
be.current && clearTimeout(be.current);
|
|
2127
2339
|
}, []);
|
|
2128
|
-
const
|
|
2129
|
-
const d =
|
|
2130
|
-
|
|
2131
|
-
}, []),
|
|
2132
|
-
const
|
|
2133
|
-
if (
|
|
2134
|
-
|
|
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);
|
|
2135
2347
|
return;
|
|
2136
2348
|
}
|
|
2137
|
-
const
|
|
2138
|
-
|
|
2139
|
-
}, [
|
|
2140
|
-
if (!
|
|
2141
|
-
const d =
|
|
2142
|
-
|
|
2143
|
-
}, [
|
|
2144
|
-
const
|
|
2145
|
-
d &&
|
|
2146
|
-
}, [
|
|
2147
|
-
const
|
|
2148
|
-
d &&
|
|
2149
|
-
}, [
|
|
2150
|
-
|
|
2151
|
-
if (!
|
|
2152
|
-
const
|
|
2153
|
-
|
|
2154
|
-
const d =
|
|
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) => {
|
|
2352
|
+
if (!a) return;
|
|
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)));
|
|
2155
2367
|
return () => {
|
|
2156
|
-
|
|
2368
|
+
a.updateNow({ cursor: null, drag: null, typing: null }), a.dispose(), de.current = null, d(), un([]);
|
|
2157
2369
|
};
|
|
2158
|
-
}, [
|
|
2159
|
-
if (
|
|
2160
|
-
return
|
|
2161
|
-
if (
|
|
2370
|
+
}, [tt, an, he]), ee(() => {
|
|
2371
|
+
if (H)
|
|
2372
|
+
return H.subscribe((a) => {
|
|
2373
|
+
if (a.type === "snapshot") {
|
|
2162
2374
|
const d = {
|
|
2163
|
-
blocks: new Map(
|
|
2164
|
-
dependencies:
|
|
2165
|
-
},
|
|
2166
|
-
|
|
2167
|
-
} else if (
|
|
2168
|
-
const d =
|
|
2169
|
-
d.outOfSync ? (
|
|
2375
|
+
blocks: new Map(a.state.blocks.map(([h, I]) => [h, Me(I)])),
|
|
2376
|
+
dependencies: a.state.dependencies
|
|
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.");
|
|
2379
|
+
} else if (a.type === "applied") {
|
|
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);
|
|
2170
2382
|
} else {
|
|
2171
|
-
const d =
|
|
2172
|
-
|
|
2383
|
+
const d = Sn(u.current, a.id);
|
|
2384
|
+
ae(d.sync), d.action && re(ni(d.action.kind, a.code, a.message));
|
|
2173
2385
|
}
|
|
2174
2386
|
});
|
|
2175
|
-
}, [
|
|
2176
|
-
const [
|
|
2177
|
-
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2180
|
-
function
|
|
2181
|
-
if (!
|
|
2182
|
-
const
|
|
2183
|
-
if (
|
|
2184
|
-
const
|
|
2185
|
-
|
|
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(() => {
|
|
2392
|
+
function a(d) {
|
|
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;
|
|
2396
|
+
const h = d.key.toLowerCase();
|
|
2397
|
+
h === "z" && !d.shiftKey ? (d.preventDefault(), Bt()) : (h === "z" && d.shiftKey || h === "y" && !d.metaKey) && (d.preventDefault(), Ct());
|
|
2186
2398
|
}
|
|
2187
|
-
return window.addEventListener("keydown",
|
|
2188
|
-
}, [
|
|
2189
|
-
const
|
|
2190
|
-
const
|
|
2191
|
-
for (const d of
|
|
2192
|
-
|
|
2193
|
-
return
|
|
2194
|
-
}, [
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2399
|
+
return window.addEventListener("keydown", a), () => window.removeEventListener("keydown", a);
|
|
2400
|
+
}, [Bt, Ct, Te]);
|
|
2401
|
+
const co = Ne(() => {
|
|
2402
|
+
const a = /* @__PURE__ */ new Set();
|
|
2403
|
+
for (const d of D.values())
|
|
2404
|
+
N(d.definitionId)?.blockType === "start" && a.add(d.definitionId);
|
|
2405
|
+
return a;
|
|
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;
|
|
2201
2419
|
});
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2204
|
-
let
|
|
2205
|
-
const d =
|
|
2206
|
-
return
|
|
2207
|
-
if (!
|
|
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(() => {
|
|
2422
|
+
let a = !1;
|
|
2423
|
+
const d = Ue.split("|");
|
|
2424
|
+
return Le.current = Le.current.then(async () => {
|
|
2425
|
+
if (!a)
|
|
2208
2426
|
try {
|
|
2209
|
-
await
|
|
2210
|
-
for (let
|
|
2211
|
-
await
|
|
2212
|
-
id: `__extra_${
|
|
2213
|
-
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}`,
|
|
2214
2432
|
description: "",
|
|
2215
|
-
url: d[
|
|
2433
|
+
url: d[f],
|
|
2216
2434
|
builtIn: !0
|
|
2217
2435
|
});
|
|
2218
|
-
if (
|
|
2219
|
-
|
|
2220
|
-
} catch (
|
|
2221
|
-
|
|
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));
|
|
2222
2440
|
}
|
|
2223
2441
|
}), () => {
|
|
2224
|
-
|
|
2442
|
+
a = !0;
|
|
2225
2443
|
};
|
|
2226
|
-
}, [
|
|
2227
|
-
if (!
|
|
2228
|
-
let
|
|
2229
|
-
return
|
|
2230
|
-
if (!
|
|
2444
|
+
}, [Ue]), ee(() => {
|
|
2445
|
+
if (!Z) return;
|
|
2446
|
+
let a = !1;
|
|
2447
|
+
return Le.current = Le.current.then(async () => {
|
|
2448
|
+
if (!a)
|
|
2231
2449
|
try {
|
|
2232
|
-
if (!await
|
|
2233
|
-
|
|
2450
|
+
if (!await Tn(_t.current, At.current)) return;
|
|
2451
|
+
Pt(Fe()), Tt((f) => f + 1);
|
|
2234
2452
|
} catch (d) {
|
|
2235
|
-
|
|
2453
|
+
F(String(d));
|
|
2236
2454
|
}
|
|
2237
2455
|
}), () => {
|
|
2238
|
-
|
|
2456
|
+
a = !0;
|
|
2239
2457
|
};
|
|
2240
|
-
}, [
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2458
|
+
}, [Z, po]), ee(() => {
|
|
2459
|
+
if (!Z) return;
|
|
2460
|
+
let a = !1;
|
|
2461
|
+
return Le.current = Le.current.then(() => {
|
|
2462
|
+
if (!a)
|
|
2463
|
+
try {
|
|
2464
|
+
Qt("__inline__"), x && x.length > 0 && lr(
|
|
2465
|
+
{ id: "__inline__", name: "Inline", description: "", url: "", builtIn: !0 },
|
|
2466
|
+
x
|
|
2467
|
+
), Pt(Fe()), Tt((d) => d + 1);
|
|
2468
|
+
} catch (d) {
|
|
2469
|
+
F(String(d));
|
|
2470
|
+
}
|
|
2471
|
+
}), () => {
|
|
2472
|
+
a = !0;
|
|
2473
|
+
};
|
|
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);
|
|
2256
2485
|
return j < 40 && $ < 24 ? Math.hypot(j, $) : null;
|
|
2257
2486
|
};
|
|
2258
|
-
return
|
|
2259
|
-
if (
|
|
2260
|
-
const
|
|
2261
|
-
if (!(!
|
|
2262
|
-
if (!
|
|
2263
|
-
const $ = j.y +
|
|
2264
|
-
|
|
2487
|
+
return ie.forEach((P) => {
|
|
2488
|
+
if (I.has(P.instanceId)) return;
|
|
2489
|
+
const V = N(P.definitionId), j = ue.get(P.instanceId);
|
|
2490
|
+
if (!(!V || V.blockType === "query" || !j)) {
|
|
2491
|
+
if (!P.nextBlockId || P.nextBlockId === h) {
|
|
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 });
|
|
2265
2494
|
}
|
|
2266
|
-
for (const $ of
|
|
2267
|
-
const
|
|
2268
|
-
|
|
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 });
|
|
2269
2498
|
}
|
|
2270
2499
|
}
|
|
2271
|
-
}),
|
|
2272
|
-
}, [
|
|
2273
|
-
const
|
|
2274
|
-
if (!
|
|
2275
|
-
const
|
|
2276
|
-
let
|
|
2277
|
-
return
|
|
2278
|
-
if (
|
|
2279
|
-
const
|
|
2280
|
-
if (!
|
|
2281
|
-
|
|
2282
|
-
if (!
|
|
2283
|
-
const
|
|
2284
|
-
if (
|
|
2285
|
-
const
|
|
2286
|
-
if (
|
|
2287
|
-
const
|
|
2288
|
-
(!
|
|
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 });
|
|
2289
2518
|
}
|
|
2290
2519
|
});
|
|
2291
|
-
}),
|
|
2292
|
-
}, [
|
|
2293
|
-
if (
|
|
2294
|
-
const d =
|
|
2295
|
-
n?.(
|
|
2296
|
-
}, [
|
|
2297
|
-
if (
|
|
2298
|
-
const
|
|
2299
|
-
|
|
2300
|
-
}, []),
|
|
2301
|
-
|
|
2302
|
-
}, []),
|
|
2303
|
-
const
|
|
2304
|
-
|
|
2305
|
-
}, [
|
|
2306
|
-
|
|
2307
|
-
}, []),
|
|
2308
|
-
const
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
const
|
|
2315
|
-
|
|
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));
|
|
2524
|
+
n?.(h);
|
|
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];
|
|
2538
|
+
if (!h || !I) return;
|
|
2539
|
+
if (!I.queryBlockId) {
|
|
2540
|
+
v(vn(a, d, I.textValue, null));
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
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) => {
|
|
2562
|
+
a.preventDefault();
|
|
2563
|
+
const f = yt(d), h = fe(f), I = Ce(f);
|
|
2564
|
+
ye.current = {
|
|
2316
2565
|
type: "palette",
|
|
2317
2566
|
defId: d,
|
|
2318
|
-
offsetX:
|
|
2319
|
-
offsetY:
|
|
2320
|
-
startClientX:
|
|
2321
|
-
startClientY:
|
|
2567
|
+
offsetX: h / 2,
|
|
2568
|
+
offsetY: I / 2,
|
|
2569
|
+
startClientX: a.clientX,
|
|
2570
|
+
startClientY: a.clientY,
|
|
2322
2571
|
moved: !1
|
|
2323
|
-
},
|
|
2324
|
-
}, []),
|
|
2325
|
-
|
|
2326
|
-
const
|
|
2327
|
-
if (!
|
|
2328
|
-
const { x:
|
|
2329
|
-
|
|
2572
|
+
}, nt({ x: a.clientX - h / 2, y: a.clientY - I / 2, defId: d }), a.target.setPointerCapture(a.pointerId);
|
|
2573
|
+
}, []), To = C((a, d) => {
|
|
2574
|
+
a.preventDefault();
|
|
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 = {
|
|
2330
2579
|
type: "canvas",
|
|
2331
|
-
defId:
|
|
2580
|
+
defId: f.definitionId,
|
|
2332
2581
|
instanceId: d,
|
|
2333
|
-
carriedIds:
|
|
2334
|
-
offsetX:
|
|
2335
|
-
offsetY:
|
|
2336
|
-
startClientX:
|
|
2337
|
-
startClientY:
|
|
2582
|
+
carriedIds: V,
|
|
2583
|
+
offsetX: M,
|
|
2584
|
+
offsetY: A,
|
|
2585
|
+
startClientX: a.clientX,
|
|
2586
|
+
startClientY: a.clientY,
|
|
2338
2587
|
moved: !1
|
|
2339
|
-
},
|
|
2340
|
-
}, [
|
|
2341
|
-
|
|
2342
|
-
function
|
|
2343
|
-
const
|
|
2344
|
-
if (!
|
|
2345
|
-
let
|
|
2346
|
-
if (!
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
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;
|
|
2593
|
+
if (!h) return;
|
|
2594
|
+
let I = !1;
|
|
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,
|
|
2599
|
+
defId: h.defId,
|
|
2600
|
+
instanceId: h.instanceId
|
|
2601
|
+
});
|
|
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));
|
|
2352
2606
|
}
|
|
2353
2607
|
}
|
|
2354
|
-
function d(
|
|
2355
|
-
const
|
|
2356
|
-
if (!
|
|
2357
|
-
|
|
2358
|
-
const
|
|
2359
|
-
if (!
|
|
2360
|
-
const
|
|
2361
|
-
if (
|
|
2362
|
-
|
|
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();
|
|
2613
|
+
if (!I) return;
|
|
2614
|
+
const w = _.current;
|
|
2615
|
+
if (h.type === "canvas" && f.clientX < I.left) {
|
|
2616
|
+
v(Jo(w, h.instanceId));
|
|
2363
2617
|
return;
|
|
2364
2618
|
}
|
|
2365
|
-
const
|
|
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) : []);
|
|
2366
2620
|
let j = null;
|
|
2367
|
-
if (
|
|
2368
|
-
const $ =
|
|
2621
|
+
if (A.blockType === "query") {
|
|
2622
|
+
const $ = mn(E, M, h.defId, P, V);
|
|
2369
2623
|
$ && (j = { socket: $.blockId, slot: $.slotIndex });
|
|
2370
2624
|
} else {
|
|
2371
|
-
const $ =
|
|
2372
|
-
$ && (j =
|
|
2625
|
+
const $ = yn(E, M, h.defId, P, V);
|
|
2626
|
+
$ && (j = ri($));
|
|
2373
2627
|
}
|
|
2374
|
-
if (
|
|
2375
|
-
if (
|
|
2628
|
+
if (h.type === "palette") {
|
|
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))
|
|
2376
2630
|
return;
|
|
2377
|
-
|
|
2631
|
+
v(Go(w, si(h.defId, E, M), { x: E, y: M }, j));
|
|
2378
2632
|
} else
|
|
2379
|
-
|
|
2633
|
+
v(Rt(w, P, { x: E, y: M }, j));
|
|
2380
2634
|
}
|
|
2381
|
-
return document.addEventListener("pointermove",
|
|
2382
|
-
document.removeEventListener("pointermove",
|
|
2635
|
+
return document.addEventListener("pointermove", a), document.addEventListener("pointerup", d), () => {
|
|
2636
|
+
document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", d);
|
|
2383
2637
|
};
|
|
2384
|
-
}, [
|
|
2385
|
-
const
|
|
2386
|
-
|
|
2387
|
-
}, [
|
|
2388
|
-
|
|
2389
|
-
}, []),
|
|
2390
|
-
const d =
|
|
2391
|
-
if (
|
|
2392
|
-
|
|
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);
|
|
2393
2647
|
return;
|
|
2394
2648
|
}
|
|
2395
|
-
const
|
|
2396
|
-
|
|
2397
|
-
}, [
|
|
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 = {
|
|
2398
2652
|
display: "flex",
|
|
2399
2653
|
flexDirection: "column",
|
|
2400
2654
|
flex: 1,
|
|
@@ -2402,45 +2656,45 @@ function wr({
|
|
|
2402
2656
|
width: "100%",
|
|
2403
2657
|
height: "100%",
|
|
2404
2658
|
overflow: "hidden",
|
|
2405
|
-
background:
|
|
2406
|
-
color:
|
|
2659
|
+
background: g.appBg,
|
|
2660
|
+
color: g.textPrimary,
|
|
2407
2661
|
fontFamily: "system-ui, sans-serif",
|
|
2408
2662
|
boxSizing: "border-box"
|
|
2409
|
-
},
|
|
2663
|
+
}, Do = {
|
|
2410
2664
|
display: "flex",
|
|
2411
2665
|
flex: 1,
|
|
2412
2666
|
minHeight: 0,
|
|
2413
2667
|
overflow: "hidden"
|
|
2414
2668
|
};
|
|
2415
|
-
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: [
|
|
2416
2670
|
"Failed to load blocks: ",
|
|
2417
|
-
|
|
2418
|
-
] }) }) :
|
|
2419
|
-
!
|
|
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: {
|
|
2420
2674
|
flexShrink: 0,
|
|
2421
2675
|
display: "flex",
|
|
2422
2676
|
alignItems: "center",
|
|
2423
2677
|
gap: 10,
|
|
2424
2678
|
padding: "0 14px",
|
|
2425
2679
|
height: 38,
|
|
2426
|
-
background:
|
|
2427
|
-
borderBottom: `1px solid ${
|
|
2680
|
+
background: g.titleBg,
|
|
2681
|
+
borderBottom: `1px solid ${g.border}`
|
|
2428
2682
|
}, children: [
|
|
2429
|
-
/* @__PURE__ */
|
|
2430
|
-
/* @__PURE__ */
|
|
2431
|
-
|
|
2432
|
-
/* @__PURE__ */
|
|
2433
|
-
s && /* @__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: [
|
|
2687
|
+
s && /* @__PURE__ */ l(
|
|
2434
2688
|
"button",
|
|
2435
2689
|
{
|
|
2436
|
-
onClick: () => s({ blocks: [...
|
|
2690
|
+
onClick: () => s({ blocks: [...D.entries()] }),
|
|
2437
2691
|
style: {
|
|
2438
2692
|
padding: "3px 10px",
|
|
2439
2693
|
fontSize: 11,
|
|
2440
2694
|
fontWeight: "bold",
|
|
2441
|
-
background:
|
|
2442
|
-
color:
|
|
2443
|
-
border: `1px solid ${
|
|
2695
|
+
background: g.titleBg,
|
|
2696
|
+
color: g.titlePrimaryText,
|
|
2697
|
+
border: `1px solid ${g.border}`,
|
|
2444
2698
|
borderRadius: 4,
|
|
2445
2699
|
cursor: "pointer",
|
|
2446
2700
|
letterSpacing: 0.5
|
|
@@ -2448,83 +2702,86 @@ function wr({
|
|
|
2448
2702
|
children: "Save"
|
|
2449
2703
|
}
|
|
2450
2704
|
),
|
|
2451
|
-
!c && /* @__PURE__ */
|
|
2705
|
+
!c && /* @__PURE__ */ l(Vr, { onSelect: Co })
|
|
2452
2706
|
] })
|
|
2453
2707
|
] }),
|
|
2454
|
-
/* @__PURE__ */
|
|
2455
|
-
/* @__PURE__ */
|
|
2456
|
-
|
|
2708
|
+
/* @__PURE__ */ m("div", { style: Do, children: [
|
|
2709
|
+
/* @__PURE__ */ l(
|
|
2710
|
+
qr,
|
|
2457
2711
|
{
|
|
2458
|
-
onPointerDown:
|
|
2459
|
-
isDropTarget:
|
|
2460
|
-
registryVersion:
|
|
2461
|
-
packages:
|
|
2462
|
-
available:
|
|
2463
|
-
dependencies:
|
|
2464
|
-
onChange:
|
|
2465
|
-
actions:
|
|
2466
|
-
blockCounts:
|
|
2467
|
-
conflictCounts: new Map(
|
|
2712
|
+
onPointerDown: xn,
|
|
2713
|
+
isDropTarget: uo,
|
|
2714
|
+
registryVersion: ot,
|
|
2715
|
+
packages: Dt && (L || H) ? {
|
|
2716
|
+
available: W ?? [],
|
|
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]))
|
|
2468
2722
|
} : void 0,
|
|
2469
|
-
placedStartIds:
|
|
2723
|
+
placedStartIds: co
|
|
2470
2724
|
}
|
|
2471
2725
|
),
|
|
2472
|
-
/* @__PURE__ */
|
|
2726
|
+
/* @__PURE__ */ m(
|
|
2473
2727
|
"div",
|
|
2474
2728
|
{
|
|
2475
2729
|
style: { flex: 1, minWidth: 0, display: "flex", position: "relative" },
|
|
2476
|
-
onPointerMove:
|
|
2477
|
-
onPointerLeave:
|
|
2730
|
+
onPointerMove: Po,
|
|
2731
|
+
onPointerLeave: Eo,
|
|
2478
2732
|
children: [
|
|
2479
|
-
/* @__PURE__ */
|
|
2480
|
-
|
|
2733
|
+
/* @__PURE__ */ l(
|
|
2734
|
+
io,
|
|
2481
2735
|
{
|
|
2482
|
-
ref:
|
|
2483
|
-
blocks:
|
|
2484
|
-
draggingIds:
|
|
2485
|
-
provisionalIds:
|
|
2486
|
-
onBlockPointerDown:
|
|
2487
|
-
onBlockClick:
|
|
2488
|
-
onSocketClick:
|
|
2489
|
-
editingSocket:
|
|
2490
|
-
onSocketInput:
|
|
2491
|
-
onSocketCommit:
|
|
2492
|
-
onSocketCancelEdit:
|
|
2493
|
-
|
|
2494
|
-
|
|
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
|
|
2495
2752
|
}
|
|
2496
2753
|
),
|
|
2497
|
-
/* @__PURE__ */
|
|
2498
|
-
|
|
2754
|
+
/* @__PURE__ */ l(
|
|
2755
|
+
Yr,
|
|
2499
2756
|
{
|
|
2500
|
-
canUndo:
|
|
2501
|
-
canRedo:
|
|
2502
|
-
onUndo:
|
|
2503
|
-
onRedo:
|
|
2504
|
-
notice:
|
|
2505
|
-
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
|
|
2506
2763
|
}
|
|
2507
2764
|
)
|
|
2508
2765
|
]
|
|
2509
2766
|
}
|
|
2510
2767
|
)
|
|
2511
2768
|
] }),
|
|
2512
|
-
/* @__PURE__ */
|
|
2513
|
-
] }) }) : /* @__PURE__ */
|
|
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…" }) });
|
|
2514
2771
|
}
|
|
2515
|
-
function
|
|
2772
|
+
function ln(e) {
|
|
2516
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();
|
|
2517
2774
|
return /^[0-9]/.test(t) ? `_${t}` : t || "_";
|
|
2518
2775
|
}
|
|
2519
|
-
function
|
|
2776
|
+
function Ft(e) {
|
|
2520
2777
|
return JSON.stringify(e);
|
|
2521
2778
|
}
|
|
2522
|
-
function
|
|
2779
|
+
function so(e, t) {
|
|
2523
2780
|
switch (e.kind) {
|
|
2524
2781
|
case "text":
|
|
2525
|
-
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);
|
|
2526
2783
|
case "query":
|
|
2527
|
-
return
|
|
2784
|
+
return ft(e.node);
|
|
2528
2785
|
case "body":
|
|
2529
2786
|
return "None";
|
|
2530
2787
|
// mouths are written as blocks, not arguments
|
|
@@ -2532,47 +2789,47 @@ function On(e, t) {
|
|
|
2532
2789
|
return "None";
|
|
2533
2790
|
}
|
|
2534
2791
|
}
|
|
2535
|
-
function
|
|
2536
|
-
const t = e.args.filter((n) => n.value.kind !== "body").map((n) =>
|
|
2537
|
-
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(", ")})`;
|
|
2538
2795
|
}
|
|
2539
|
-
function
|
|
2796
|
+
function kt(e, t) {
|
|
2540
2797
|
return e.length === 0 ? [`${t}pass`] : e.flatMap((n) => {
|
|
2541
|
-
const
|
|
2542
|
-
if (
|
|
2543
|
-
const
|
|
2544
|
-
if (
|
|
2545
|
-
const i =
|
|
2546
|
-
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)];
|
|
2547
2804
|
}
|
|
2548
2805
|
return [
|
|
2549
|
-
`${t}with ${
|
|
2550
|
-
...
|
|
2551
|
-
`${
|
|
2552
|
-
...
|
|
2806
|
+
`${t}with ${ft(n)}:`,
|
|
2807
|
+
...o.flatMap((i) => [
|
|
2808
|
+
`${r}with ${ln(i.name)}:`,
|
|
2809
|
+
...kt(i.value.body, `${r} `)
|
|
2553
2810
|
])
|
|
2554
2811
|
];
|
|
2555
2812
|
});
|
|
2556
2813
|
}
|
|
2557
|
-
const
|
|
2814
|
+
const pi = {
|
|
2558
2815
|
id: "python",
|
|
2559
2816
|
label: "Python",
|
|
2560
2817
|
fileExtension: "py",
|
|
2561
2818
|
write(e) {
|
|
2562
2819
|
return `# Generated by the block editor
|
|
2563
2820
|
|
|
2564
|
-
${e.roots.map((n,
|
|
2565
|
-
const [
|
|
2566
|
-
if (
|
|
2567
|
-
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));
|
|
2568
2825
|
return [
|
|
2569
|
-
`@on(${[
|
|
2570
|
-
`def ${
|
|
2571
|
-
...
|
|
2826
|
+
`@on(${[Ft(r.name), ...s].join(", ")})`,
|
|
2827
|
+
`def ${ln(r.name)}():`,
|
|
2828
|
+
...kt(i, " ")
|
|
2572
2829
|
].join(`
|
|
2573
2830
|
`);
|
|
2574
2831
|
}
|
|
2575
|
-
return [`def chain_${
|
|
2832
|
+
return [`def chain_${o + 1}():`, ...kt(n.body, " ")].join(`
|
|
2576
2833
|
`);
|
|
2577
2834
|
}).join(`
|
|
2578
2835
|
|
|
@@ -2581,7 +2838,7 @@ ${e.roots.map((n, r) => {
|
|
|
2581
2838
|
`;
|
|
2582
2839
|
}
|
|
2583
2840
|
};
|
|
2584
|
-
class
|
|
2841
|
+
class gi {
|
|
2585
2842
|
state;
|
|
2586
2843
|
version = 0;
|
|
2587
2844
|
clients = /* @__PURE__ */ new Map();
|
|
@@ -2601,24 +2858,24 @@ class Cr {
|
|
|
2601
2858
|
return { state: this.state, version: this.version };
|
|
2602
2859
|
}
|
|
2603
2860
|
/** A client's channels. Connecting again with the same id gives channels to the same client (its listeners stay). */
|
|
2604
|
-
connect(t, n,
|
|
2605
|
-
const
|
|
2861
|
+
connect(t, n, o) {
|
|
2862
|
+
const r = this.clients.get(t) ?? {
|
|
2606
2863
|
id: t,
|
|
2607
2864
|
name: n,
|
|
2608
|
-
color:
|
|
2865
|
+
color: o,
|
|
2609
2866
|
commandListeners: /* @__PURE__ */ new Set(),
|
|
2610
2867
|
presenceListeners: /* @__PURE__ */ new Set(),
|
|
2611
2868
|
presence: { cursor: null, drag: null, typing: null }
|
|
2612
2869
|
};
|
|
2613
|
-
return
|
|
2870
|
+
return r.name = n, r.color = o, this.clients.set(t, r), { commands: {
|
|
2614
2871
|
submit: (c) => this.later(() => this.receive(c)),
|
|
2615
|
-
subscribe: (c) => (
|
|
2616
|
-
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())))
|
|
2617
2874
|
}, presence: {
|
|
2618
2875
|
publish: (c) => {
|
|
2619
|
-
|
|
2876
|
+
r.presence = c, this.broadcastPresence();
|
|
2620
2877
|
},
|
|
2621
|
-
subscribe: (c) => (
|
|
2878
|
+
subscribe: (c) => (r.presenceListeners.add(c), c(this.peersOf(t)), () => r.presenceListeners.delete(c))
|
|
2622
2879
|
} };
|
|
2623
2880
|
}
|
|
2624
2881
|
/**
|
|
@@ -2636,16 +2893,16 @@ class Cr {
|
|
|
2636
2893
|
}
|
|
2637
2894
|
receive(t) {
|
|
2638
2895
|
try {
|
|
2639
|
-
this.state =
|
|
2640
|
-
} catch (
|
|
2641
|
-
if (!(
|
|
2642
|
-
const
|
|
2643
|
-
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));
|
|
2644
2901
|
return;
|
|
2645
2902
|
}
|
|
2646
2903
|
this.version += 1;
|
|
2647
2904
|
const n = { type: "applied", envelope: t, version: this.version };
|
|
2648
|
-
this.clients.forEach((
|
|
2905
|
+
this.clients.forEach((o) => o.commandListeners.forEach((r) => r(n)));
|
|
2649
2906
|
}
|
|
2650
2907
|
peersOf(t) {
|
|
2651
2908
|
return [...this.clients.values()].filter((n) => n.id !== t).map((n) => ({ ...n.presence, clientId: n.id, name: n.name, color: n.color }));
|
|
@@ -2655,33 +2912,33 @@ class Cr {
|
|
|
2655
2912
|
}
|
|
2656
2913
|
}
|
|
2657
2914
|
export {
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
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,
|
|
2926
|
+
Xe as darkTheme,
|
|
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
|
|
2687
2944
|
};
|