x-block-lib 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="x-block-lib",e.appendChild(document.createTextNode(".blocklyToolboxDiv{overflow-x:hidden;width:56px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
- import { defineComponent as b, ref as C, onMounted as m, nextTick as k, onBeforeUnmount as S, watch as p, resolveDirective as T, openBlock as L, createElementBlock as E, withDirectives as I, createElementVNode as v } from "vue";
3
- import { useLocale as B, useTheme as R } from "vuetify";
4
- import { openConfirmDlg as x, openPromptDlg as P, useViewStack as F } from "x-essential-lib";
5
- import * as e from "blockly/core";
6
- import { javascriptGenerator as M, Order as K } from "blockly/javascript";
7
- e.defineBlocksWithJsonArray([
2
+ import { defineComponent as F, ref as A, onMounted as N, nextTick as D, onBeforeUnmount as M, watch as k, resolveDirective as V, openBlock as U, createElementBlock as Y, withDirectives as G, createElementVNode as W } from "vue";
3
+ import { useLocale as H, useTheme as z } from "vuetify";
4
+ import { openConfirmDlg as X, openPromptDlg as J, useViewStack as j } from "x-essential-lib";
5
+ import { d as g, j as $, O as q, E as p, u as c, M as f, C as Q, a as y, b as B, s as Z, S as u, c as S, g as h, i as b, e as T, f as O, h as d, k as v, G as L, B as ee, T as C, l as P, m as te, n as oe, o as ne } from "./blockly-kru4jhu1.js";
6
+ g([
8
7
  {
9
8
  type: "boolean_v1",
10
9
  message0: "%1",
@@ -24,138 +23,138 @@ e.defineBlocksWithJsonArray([
24
23
  helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
25
24
  }
26
25
  ]);
27
- M.forBlock.boolean_v1 = function(o) {
28
- return [o.getFieldValue("BOOL") === "TRUE" ? "true" : "false", K.ATOMIC];
26
+ $.forBlock.boolean_v1 = function(t) {
27
+ return [t.getFieldValue("BOOL") === "TRUE" ? "true" : "false", q.ATOMIC];
29
28
  };
30
- const A = {
29
+ const re = {
31
30
  elseIfCount_: 0,
32
31
  hasElse_: !1,
33
32
  mutationToDom: function() {
34
33
  if (this.elseIfCount_ <= 0 && !this.hasElse_)
35
34
  return null;
36
- const o = e.utils.xml.createElement("mutation");
37
- return this.elseIfCount_ > 0 && o.setAttribute("elseIf", String(this.elseIfCount_)), this.hasElse_ && o.setAttribute("else", "TRUE"), o;
35
+ const t = c.xml.createElement("mutation");
36
+ return this.elseIfCount_ > 0 && t.setAttribute("elseIf", String(this.elseIfCount_)), this.hasElse_ && t.setAttribute("else", "TRUE"), t;
38
37
  },
39
- domToMutation: function(o) {
40
- this.elseIfCount_ = parseInt(o.getAttribute("elseif"), 10) || 0, this.hasElse_ = o.getAttribute("else") === "TRUE", this.rebuildShape_();
38
+ domToMutation: function(t) {
39
+ this.elseIfCount_ = parseInt(t.getAttribute("elseif"), 10) || 0, this.hasElse_ = t.getAttribute("else") === "TRUE", this.rebuildShape_();
41
40
  },
42
41
  saveExtraState: function() {
43
42
  if (this.elseIfCount_ <= 0 && !this.hasElse_)
44
43
  return null;
45
- const o = /* @__PURE__ */ Object.create(null);
46
- return this.elseIfCount_ > 0 && (o.elseIfCount = this.elseIfCount_), this.hasElse_ && (o.hasElse = !0), o;
47
- },
48
- loadExtraState: function(o) {
49
- this.elseIfCount_ = o.elseIfCount || 0, this.hasElse_ = !!o.hasElse, this.updateShape_();
50
- },
51
- decompose: function(o) {
52
- const t = o.newBlock("if_if_v1");
53
- t.initSvg();
54
- let r = t.nextConnection;
55
- for (let n = 0; n < this.elseIfCount_; n++) {
56
- const s = o.newBlock(
44
+ const t = /* @__PURE__ */ Object.create(null);
45
+ return this.elseIfCount_ > 0 && (t.elseIfCount = this.elseIfCount_), this.hasElse_ && (t.hasElse = !0), t;
46
+ },
47
+ loadExtraState: function(t) {
48
+ this.elseIfCount_ = t.elseIfCount || 0, this.hasElse_ = !!t.hasElse, this.updateShape_();
49
+ },
50
+ decompose: function(t) {
51
+ const e = t.newBlock("if_if_v1");
52
+ e.initSvg();
53
+ let n = e.nextConnection;
54
+ for (let o = 0; o < this.elseIfCount_; o++) {
55
+ const r = t.newBlock(
57
56
  "if_else_if_v1"
58
57
  );
59
- s.initSvg(), r.connect(s.previousConnection), r = s.nextConnection;
58
+ r.initSvg(), n.connect(r.previousConnection), n = r.nextConnection;
60
59
  }
61
60
  if (this.hasElse_) {
62
- const n = o.newBlock("if_else_v1");
63
- n.initSvg(), r.connect(n.previousConnection);
61
+ const o = t.newBlock("if_else_v1");
62
+ o.initSvg(), n.connect(o.previousConnection);
64
63
  }
65
- return t;
64
+ return e;
66
65
  },
67
- compose: function(o) {
68
- let t = o.nextConnection.targetBlock();
66
+ compose: function(t) {
67
+ let e = t.nextConnection.targetBlock();
69
68
  this.elseIfCount_ = 0, this.hasElse_ = !1;
70
- const r = [null], n = [null];
71
- let s = null;
72
- for (; t; ) {
73
- if (t.isInsertionMarker()) {
74
- t = t.getNextBlock();
69
+ const n = [null], o = [null];
70
+ let r = null;
71
+ for (; e; ) {
72
+ if (e.isInsertionMarker()) {
73
+ e = e.getNextBlock();
75
74
  continue;
76
75
  }
77
- switch (t.type) {
76
+ switch (e.type) {
78
77
  case "if_else_if_v1":
79
- this.elseIfCount_++, r.push(
80
- t.valueConnection_
81
- ), n.push(
82
- t.statementConnection_
78
+ this.elseIfCount_++, n.push(
79
+ e.valueConnection_
80
+ ), o.push(
81
+ e.statementConnection_
83
82
  );
84
83
  break;
85
84
  case "if_else_v1":
86
- this.hasElse_ = !0, s = t.statementConnection_;
85
+ this.hasElse_ = !0, r = e.statementConnection_;
87
86
  break;
88
87
  default:
89
- throw TypeError("Unknown block type: " + t.type);
88
+ throw TypeError("Unknown block type: " + e.type);
90
89
  }
91
- t = t.getNextBlock();
90
+ e = e.getNextBlock();
92
91
  }
93
92
  this.updateShape_(), this.reconnectChildBlocks_(
94
- r,
95
93
  n,
96
- s
94
+ o,
95
+ r
97
96
  );
98
97
  },
99
- saveConnections: function(o) {
100
- let t = o.nextConnection.targetBlock(), r = 1;
101
- for (; t; ) {
102
- if (t.isInsertionMarker()) {
103
- t = t.getNextBlock();
98
+ saveConnections: function(t) {
99
+ let e = t.nextConnection.targetBlock(), n = 1;
100
+ for (; e; ) {
101
+ if (e.isInsertionMarker()) {
102
+ e = e.getNextBlock();
104
103
  continue;
105
104
  }
106
- switch (t.type) {
105
+ switch (e.type) {
107
106
  case "if_else_if_v1": {
108
- const n = this.getInput("IF" + r), s = this.getInput("DO" + r);
109
- t.valueConnection_ = n && n.connection.targetConnection, t.statementConnection_ = s && s.connection.targetConnection, r++;
107
+ const o = this.getInput("IF" + n), r = this.getInput("DO" + n);
108
+ e.valueConnection_ = o && o.connection.targetConnection, e.statementConnection_ = r && r.connection.targetConnection, n++;
110
109
  break;
111
110
  }
112
111
  case "if_else_v1": {
113
- const n = this.getInput("ELSE");
114
- t.statementConnection_ = n && n.connection.targetConnection;
112
+ const o = this.getInput("ELSE");
113
+ e.statementConnection_ = o && o.connection.targetConnection;
115
114
  break;
116
115
  }
117
116
  default:
118
- throw TypeError("Unknown block type: " + t.type);
117
+ throw TypeError("Unknown block type: " + e.type);
119
118
  }
120
- t = t.getNextBlock();
119
+ e = e.getNextBlock();
121
120
  }
122
121
  },
123
122
  rebuildShape_: function() {
124
- const o = [null], t = [null];
125
- let r = null;
126
- this.getInput("ELSE") && (r = this.getInput("ELSE").connection.targetConnection);
127
- for (let n = 1; this.getInput("IF" + n); n++) {
128
- const s = this.getInput("IF" + n), l = this.getInput("DO" + n);
129
- o.push(s.connection.targetConnection), t.push(l.connection.targetConnection);
123
+ const t = [null], e = [null];
124
+ let n = null;
125
+ this.getInput("ELSE") && (n = this.getInput("ELSE").connection.targetConnection);
126
+ for (let o = 1; this.getInput("IF" + o); o++) {
127
+ const r = this.getInput("IF" + o), s = this.getInput("DO" + o);
128
+ t.push(r.connection.targetConnection), e.push(s.connection.targetConnection);
130
129
  }
131
130
  this.updateShape_(), this.reconnectChildBlocks_(
132
- o,
133
131
  t,
134
- r
132
+ e,
133
+ n
135
134
  );
136
135
  },
137
136
  updateShape_: function() {
138
137
  this.getInput("ELSE") && this.removeInput("ELSE");
139
- for (let o = 1; this.getInput("IF" + o); o++)
140
- this.removeInput("IF" + o), this.removeInput("DO" + o);
141
- for (let o = 1; o <= this.elseIfCount_; o++)
142
- this.appendValueInput("IF" + o).setCheck("Boolean").appendField(e.Msg.LOGIC_ELSE_IF), this.appendStatementInput("DO" + o).appendField(e.Msg.LOGIC_DO);
143
- this.hasElse_ && this.appendStatementInput("ELSE").appendField(e.Msg.LOGIC_ELSE);
144
- },
145
- reconnectChildBlocks_: function(o, t, r) {
146
- var n, s;
147
- for (let l = 1; l <= this.elseIfCount_; l++)
148
- (n = o[l]) == null || n.reconnect(this, "IF" + l), (s = t[l]) == null || s.reconnect(this, "DO" + l);
149
- r == null || r.reconnect(this, "ELSE");
138
+ for (let t = 1; this.getInput("IF" + t); t++)
139
+ this.removeInput("IF" + t), this.removeInput("DO" + t);
140
+ for (let t = 1; t <= this.elseIfCount_; t++)
141
+ this.appendValueInput("IF" + t).setCheck("Boolean").appendField(f.LOGIC_ELSE_IF), this.appendStatementInput("DO" + t).appendField(f.LOGIC_DO);
142
+ this.hasElse_ && this.appendStatementInput("ELSE").appendField(f.LOGIC_ELSE);
143
+ },
144
+ reconnectChildBlocks_: function(t, e, n) {
145
+ var o, r;
146
+ for (let s = 1; s <= this.elseIfCount_; s++)
147
+ (o = t[s]) == null || o.reconnect(this, "IF" + s), (r = e[s]) == null || r.reconnect(this, "DO" + s);
148
+ n == null || n.reconnect(this, "ELSE");
150
149
  }
151
150
  };
152
- e.Extensions.registerMutator(
151
+ p.registerMutator(
153
152
  "if_v1_mutator",
154
- A,
153
+ re,
155
154
  void 0,
156
155
  ["if_else_if_v1", "if_else_v1"]
157
156
  );
158
- e.defineBlocksWithJsonArray([
157
+ g([
159
158
  {
160
159
  type: "if_v1",
161
160
  message0: "%{BKY_LOGIC_IF} %1",
@@ -203,72 +202,72 @@ e.defineBlocksWithJsonArray([
203
202
  style: "logic_blocks"
204
203
  }
205
204
  ]);
206
- const w = {
207
- customContextMenu: function(o) {
205
+ const se = {
206
+ customContextMenu: function(t) {
208
207
  if (this.isInFlyout)
209
208
  return;
210
- const t = this.getField("VAR"), r = t.getVariable(), n = r == null ? void 0 : r.name;
211
- if (!this.isCollapsed() && n) {
212
- const s = {
209
+ const e = this.getField("VAR"), n = e.getVariable(), o = n == null ? void 0 : n.name;
210
+ if (!this.isCollapsed() && o) {
211
+ const r = {
213
212
  type: "variables_get",
214
213
  fields: {
215
- VAR: t.saveState(!0)
214
+ VAR: e.saveState(!0)
216
215
  }
217
216
  };
218
- o.push({
217
+ t.push({
219
218
  enabled: !0,
220
- text: e.Msg.VARIABLES_SET_CREATE_GET.replace("%1", n),
221
- callback: e.ContextMenu.callbackFactory(this, s)
219
+ text: f.VARIABLES_SET_CREATE_GET.replace("%1", o),
220
+ callback: Q.callbackFactory(this, r)
222
221
  });
223
222
  }
224
223
  }
225
224
  };
226
- e.Extensions.registerMixin(
225
+ p.registerMixin(
227
226
  "contextMenu_newGetVariableBlock_v1",
228
- w
227
+ se
229
228
  );
230
- e.Extensions.register(
229
+ p.register(
231
230
  "flow_control_tooltip_v1",
232
- e.Extensions.buildTooltipForDropdown("MODE", {
231
+ p.buildTooltipForDropdown("MODE", {
233
232
  BREAK: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_BREAK}",
234
233
  CONTINUE: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}"
235
234
  })
236
235
  );
237
- const D = /* @__PURE__ */ new Set([
236
+ const ae = /* @__PURE__ */ new Set([
238
237
  "repeat_v1",
239
238
  "for_each_v1",
240
239
  "for_v1",
241
240
  "while_until_v1"
242
- ]), N = {
241
+ ]), le = {
243
242
  getSurroundLoop: function() {
244
- let o = this;
243
+ let t = this;
245
244
  do {
246
- if (D.has(o.type))
245
+ if (ae.has(t.type))
247
246
  return !0;
248
- o = o == null ? void 0 : o.getSurroundParent();
249
- } while (o);
247
+ t = t == null ? void 0 : t.getSurroundParent();
248
+ } while (t);
250
249
  return !1;
251
250
  },
252
- onchange: function(o) {
253
- const t = this.workspace;
254
- if (!t.isDragging || t.isDragging() || o.type !== e.Events.BLOCK_MOVE && o.type !== e.Events.BLOCK_CREATE)
251
+ onchange: function(t) {
252
+ const e = this.workspace;
253
+ if (!e.isDragging || e.isDragging() || t.type !== y.BLOCK_MOVE && t.type !== y.BLOCK_CREATE)
255
254
  return;
256
- const r = this.getSurroundLoop();
257
- if (console.log(o.type, r), this.setWarningText(
258
- r ? null : e.Msg.LOOP_FLOW_CONTROL_WARNING
255
+ const n = this.getSurroundLoop();
256
+ if (console.log(t.type, n), this.setWarningText(
257
+ n ? null : f.LOOP_FLOW_CONTROL_WARNING
259
258
  ), !this.isInFlyout)
260
259
  try {
261
- e.Events.setRecordUndo(!1), this.setDisabledReason(!r, "FLOW_CONTROL_NOT_IN_LOOP");
260
+ y.setRecordUndo(!1), this.setDisabledReason(!n, "FLOW_CONTROL_NOT_IN_LOOP");
262
261
  } finally {
263
- e.Events.setRecordUndo(!0);
262
+ y.setRecordUndo(!0);
264
263
  }
265
264
  }
266
265
  };
267
- e.Extensions.registerMixin(
266
+ p.registerMixin(
268
267
  "flow_control_in_loop_check_v1",
269
- N
268
+ le
270
269
  );
271
- e.defineBlocksWithJsonArray([
270
+ g([
272
271
  {
273
272
  type: "flow_control_v1",
274
273
  message0: "%1",
@@ -289,14 +288,14 @@ e.defineBlocksWithJsonArray([
289
288
  extensions: ["flow_control_tooltip_v1", "flow_control_in_loop_check_v1"]
290
289
  }
291
290
  ]);
292
- e.Extensions.register(
291
+ p.register(
293
292
  "for_tooltip_v1",
294
- e.Extensions.buildTooltipWithFieldText(
293
+ p.buildTooltipWithFieldText(
295
294
  "%{BKY_LOOP_V1_FOR_TOOLTIP}",
296
295
  "VAR"
297
296
  )
298
297
  );
299
- e.defineBlocksWithJsonArray([
298
+ g([
300
299
  {
301
300
  type: "for_v1",
302
301
  message0: "%{BKY_LOOP_V1_FOR_TITLE}",
@@ -340,14 +339,14 @@ e.defineBlocksWithJsonArray([
340
339
  extensions: ["contextMenu_newGetVariableBlock_v1", "for_tooltip_v1"]
341
340
  }
342
341
  ]);
343
- e.Extensions.register(
342
+ p.register(
344
343
  "for_each_tooltip_v1",
345
- e.Extensions.buildTooltipWithFieldText(
344
+ p.buildTooltipWithFieldText(
346
345
  "%{BKY_LOOP_V1_FOR_EACH_TOOLTIP}",
347
346
  "VAR"
348
347
  )
349
348
  );
350
- e.defineBlocksWithJsonArray([
349
+ g([
351
350
  {
352
351
  type: "for_each_v1",
353
352
  message0: "%{BKY_LOOP_V1_FOR_EACH_TITLE}",
@@ -377,14 +376,14 @@ e.defineBlocksWithJsonArray([
377
376
  extensions: ["contextMenu_newGetVariableBlock_v1", "for_each_tooltip_v1"]
378
377
  }
379
378
  ]);
380
- e.Extensions.register(
379
+ p.register(
381
380
  "while_until_tooltip_v1",
382
- e.Extensions.buildTooltipForDropdown("MODE", {
381
+ p.buildTooltipForDropdown("MODE", {
383
382
  WHILE: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE}",
384
383
  UNTIL: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}"
385
384
  })
386
385
  );
387
- e.defineBlocksWithJsonArray([
386
+ g([
388
387
  {
389
388
  type: "while_until_v1",
390
389
  message0: "%1 %2",
@@ -417,253 +416,232 @@ e.defineBlocksWithJsonArray([
417
416
  extensions: ["while_until_tooltip_v1"]
418
417
  }
419
418
  ]);
420
- e.dialog.setConfirm(async (o, t) => {
421
- const r = await x({
419
+ B.setConfirm(async (t, e) => {
420
+ const n = await X({
422
421
  title: "",
423
- text: o
422
+ text: t
424
423
  });
425
- t(!!r);
424
+ e(!!n);
426
425
  });
427
- e.dialog.setPrompt(async (o, t, r) => {
428
- const n = await P({
426
+ B.setPrompt(async (t, e, n) => {
427
+ const o = await J({
429
428
  title: "",
430
- value: t
429
+ value: e
431
430
  });
432
- r(n);
431
+ n(o);
433
432
  });
434
- const U = (o, t) => {
435
- const r = o[t];
436
- return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((n, s) => {
437
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(s.bind(null, new Error("Unknown variable dynamic import: " + t)));
433
+ const ie = (t, e, n) => {
434
+ const o = t[e];
435
+ return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((r, s) => {
436
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
437
+ s.bind(
438
+ null,
439
+ new Error(
440
+ "Unknown variable dynamic import: " + e + (e.split("/").length !== n ? ". Note that variables only represent file names one level deep." : "")
441
+ )
442
+ )
443
+ );
438
444
  });
439
445
  };
440
- async function f(o) {
441
- const t = await U(/* @__PURE__ */ Object.assign({ "./msg/en.ts": () => import("./en-c75t6n0y.js"), "./msg/zhHans.ts": () => import("./zhHans-dmzotd2n.js") }), `./msg/${o}.ts`);
442
- e.setLocale(t.default);
446
+ async function E(t) {
447
+ const e = await ie(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-c75t6n0y.js"), "./msg/zhHans/index.ts": () => import("./zhHans-dmzotd2n.js") }), `./msg/${t}/index.ts`, 4);
448
+ Z(e.default);
443
449
  }
444
- class V {
445
- init({ contextMenu: t = !0, shortcut: r = !0 } = {
450
+ class ce {
451
+ init({ contextMenu: e = !0, shortcut: n = !0 } = {
446
452
  contextMenu: !0,
447
453
  shortcut: !0
448
454
  }) {
449
- t && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), r && (e.ShortcutRegistry.registry.unregister(
450
- e.ShortcutItems.names.COPY
451
- ), e.ShortcutRegistry.registry.unregister(
452
- e.ShortcutItems.names.CUT
453
- ), e.ShortcutRegistry.registry.unregister(
454
- e.ShortcutItems.names.PASTE
455
+ e && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), n && (u.registry.unregister(
456
+ S.names.COPY
457
+ ), u.registry.unregister(
458
+ S.names.CUT
459
+ ), u.registry.unregister(
460
+ S.names.PASTE
455
461
  ), this.blockCopyToStorageShortcut(), this.blockCutToStorageShortcut(), this.blockPasteFromStorageShortcut());
456
462
  }
457
463
  blockCopyToStorageContextMenu() {
458
- const t = {
464
+ const e = {
459
465
  displayText: function() {
460
- return e.Msg.CROSS_TAB_COPY ? e.Msg.CROSS_TAB_COPY : "Copy";
466
+ return f.CROSS_TAB_COPY ? f.CROSS_TAB_COPY : "Copy";
461
467
  },
462
468
  preconditionFn: function() {
463
- const r = e.getSelected();
464
- return !r || !e.isDeletable(r) || !r.isDeletable() || !e.isDraggable(r) || !r.isMovable() || !e.isCopyable(r) ? "disabled" : "enabled";
469
+ const n = h();
470
+ return !n || !b(n) || !n.isDeletable() || !T(n) || !n.isMovable() || !O(n) ? "disabled" : "enabled";
465
471
  },
466
- callback: function(r) {
467
- var n;
472
+ callback: function(n) {
473
+ var o;
468
474
  localStorage.setItem(
469
475
  "blocklyStash",
470
- JSON.stringify((n = r.block) == null ? void 0 : n.toCopyData())
476
+ JSON.stringify((o = n.block) == null ? void 0 : o.toCopyData())
471
477
  );
472
478
  },
473
- scopeType: e.ContextMenuRegistry.ScopeType.BLOCK,
479
+ scopeType: d.ScopeType.BLOCK,
474
480
  id: "blockCopyToStorage",
475
481
  weight: 0
476
482
  };
477
- e.ContextMenuRegistry.registry.register(t);
483
+ d.registry.register(e);
478
484
  }
479
485
  blockPasteFromStorageContextMenu() {
480
- const t = {
486
+ const e = {
481
487
  displayText: function() {
482
- return e.Msg.CROSS_TAB_PASTE ? e.Msg.CROSS_TAB_PASTE : "Paste";
488
+ return f.CROSS_TAB_PASTE ? f.CROSS_TAB_PASTE : "Paste";
483
489
  },
484
- preconditionFn: function(r) {
485
- var l;
486
- const n = localStorage.getItem("blocklyStash");
487
- if (!n)
490
+ preconditionFn: function(n) {
491
+ var s;
492
+ const o = localStorage.getItem("blocklyStash");
493
+ if (!o)
488
494
  return "disabled";
489
- const s = JSON.parse(n);
490
- return !s || !((l = r.workspace) != null && l.isCapacityAvailable(s.typeCounts)) ? "disabled" : "enabled";
495
+ const r = JSON.parse(o);
496
+ return !r || !((s = n.workspace) != null && s.isCapacityAvailable(r.typeCounts)) ? "disabled" : "enabled";
491
497
  },
492
- callback: function(r) {
493
- const n = localStorage.getItem("blocklyStash");
494
- if (!n)
498
+ callback: function(n) {
499
+ const o = localStorage.getItem("blocklyStash");
500
+ if (!o)
495
501
  return;
496
- const s = JSON.parse(n);
497
- s && r.workspace && e.clipboard.paste(s, r.workspace);
502
+ const r = JSON.parse(o);
503
+ r && n.workspace && v.paste(r, n.workspace);
498
504
  },
499
- scopeType: e.ContextMenuRegistry.ScopeType.WORKSPACE,
505
+ scopeType: d.ScopeType.WORKSPACE,
500
506
  id: "blockPasteFromStorage",
501
507
  weight: 0
502
508
  };
503
- e.ContextMenuRegistry.registry.register(t);
509
+ d.registry.register(e);
504
510
  }
505
511
  blockCopyToStorageShortcut() {
506
- const t = e.ShortcutRegistry.registry.createSerializedKey(
507
- e.utils.KeyCodes.C,
508
- [e.utils.KeyCodes.CTRL]
509
- ), r = e.ShortcutRegistry.registry.createSerializedKey(
510
- e.utils.KeyCodes.C,
511
- [e.utils.KeyCodes.ALT]
512
- ), n = e.ShortcutRegistry.registry.createSerializedKey(
513
- e.utils.KeyCodes.C,
514
- [e.utils.KeyCodes.META]
515
- ), s = {
512
+ const e = u.registry.createSerializedKey(
513
+ c.KeyCodes.C,
514
+ [c.KeyCodes.CTRL]
515
+ ), n = u.registry.createSerializedKey(
516
+ c.KeyCodes.C,
517
+ [c.KeyCodes.ALT]
518
+ ), o = u.registry.createSerializedKey(
519
+ c.KeyCodes.C,
520
+ [c.KeyCodes.META]
521
+ ), r = {
516
522
  name: "copy",
517
- preconditionFn: function(l) {
518
- if (l.options.readOnly || e.Gesture.inProgress())
523
+ preconditionFn: function(s) {
524
+ if (s.options.readOnly || L.inProgress())
519
525
  return !1;
520
- const a = e.getSelected();
521
- return !(!a || !e.isDeletable(a) || !a.isDeletable() || !e.isDraggable(a) || !a.isMovable() || !e.isCopyable(a));
526
+ const l = h();
527
+ return !(!l || !b(l) || !l.isDeletable() || !T(l) || !l.isMovable() || !O(l));
522
528
  },
523
- callback: function(l, a) {
524
- a.preventDefault();
525
- const i = e.getSelected();
526
- if (!i || !e.isCopyable(i))
529
+ callback: function(s, l) {
530
+ l.preventDefault();
531
+ const a = h();
532
+ if (!a || !O(a))
527
533
  return !1;
528
- const c = i.toCopyData();
529
- return c ? (l.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
534
+ const i = a.toCopyData();
535
+ return i ? (s.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(i)), !0) : !1;
530
536
  },
531
- keyCodes: [t, r, n]
537
+ keyCodes: [e, n, o]
532
538
  };
533
- e.ShortcutRegistry.registry.register(s);
539
+ u.registry.register(r);
534
540
  }
535
541
  blockCutToStorageShortcut() {
536
- const t = e.ShortcutRegistry.registry.createSerializedKey(
537
- e.utils.KeyCodes.X,
538
- [e.utils.KeyCodes.CTRL]
539
- ), r = e.ShortcutRegistry.registry.createSerializedKey(
540
- e.utils.KeyCodes.X,
541
- [e.utils.KeyCodes.ALT]
542
- ), n = e.ShortcutRegistry.registry.createSerializedKey(
543
- e.utils.KeyCodes.X,
544
- [e.utils.KeyCodes.META]
545
- ), s = {
542
+ const e = u.registry.createSerializedKey(
543
+ c.KeyCodes.X,
544
+ [c.KeyCodes.CTRL]
545
+ ), n = u.registry.createSerializedKey(
546
+ c.KeyCodes.X,
547
+ [c.KeyCodes.ALT]
548
+ ), o = u.registry.createSerializedKey(
549
+ c.KeyCodes.X,
550
+ [c.KeyCodes.META]
551
+ ), r = {
546
552
  name: "cut",
547
- preconditionFn: function(l) {
548
- if (l.options.readOnly || e.Gesture.inProgress())
553
+ preconditionFn: function(s) {
554
+ if (s.options.readOnly || L.inProgress())
549
555
  return !1;
550
- const a = e.getSelected();
551
- return !(!a || !e.isDeletable(a) || !a.isDeletable() || !e.isDraggable(a) || !a.isMovable() || !e.isCopyable(a) || a.workspace.isFlyout);
556
+ const l = h();
557
+ return !(!l || !b(l) || !l.isDeletable() || !T(l) || !l.isMovable() || !O(l) || l.workspace.isFlyout);
552
558
  },
553
- callback: function(l, a) {
554
- a.preventDefault();
555
- const i = e.getSelected();
556
- if (!i || !e.isDeletable(i) || !i.isDeletable() || !e.isCopyable(i))
559
+ callback: function(s, l) {
560
+ l.preventDefault();
561
+ const a = h();
562
+ if (!a || !b(a) || !a.isDeletable() || !O(a))
557
563
  return !1;
558
- const c = i.toCopyData();
559
- return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), i instanceof e.BlockSvg ? i.checkAndDelete() : i.dispose(), !0) : !1;
564
+ const i = a.toCopyData();
565
+ return i ? (localStorage.setItem("blocklyStash", JSON.stringify(i)), a instanceof ee ? a.checkAndDelete() : a.dispose(), !0) : !1;
560
566
  },
561
- keyCodes: [t, r, n]
567
+ keyCodes: [e, n, o]
562
568
  };
563
- e.ShortcutRegistry.registry.register(s);
569
+ u.registry.register(r);
564
570
  }
565
571
  blockPasteFromStorageShortcut() {
566
- const t = e.ShortcutRegistry.registry.createSerializedKey(
567
- e.utils.KeyCodes.V,
568
- [e.utils.KeyCodes.CTRL]
569
- ), r = e.ShortcutRegistry.registry.createSerializedKey(
570
- e.utils.KeyCodes.V,
571
- [e.utils.KeyCodes.ALT]
572
- ), n = e.ShortcutRegistry.registry.createSerializedKey(
573
- e.utils.KeyCodes.V,
574
- [e.utils.KeyCodes.META]
575
- ), s = {
572
+ const e = u.registry.createSerializedKey(
573
+ c.KeyCodes.V,
574
+ [c.KeyCodes.CTRL]
575
+ ), n = u.registry.createSerializedKey(
576
+ c.KeyCodes.V,
577
+ [c.KeyCodes.ALT]
578
+ ), o = u.registry.createSerializedKey(
579
+ c.KeyCodes.V,
580
+ [c.KeyCodes.META]
581
+ ), r = {
576
582
  name: "paste",
577
- preconditionFn: function(l) {
578
- if (l.options.readOnly || e.Gesture.inProgress())
583
+ preconditionFn: function(s) {
584
+ if (s.options.readOnly || L.inProgress())
585
+ return !1;
586
+ const l = localStorage.getItem("blocklyStash");
587
+ if (!l)
579
588
  return !1;
589
+ const a = JSON.parse(l);
590
+ return !(!a || !s.isCapacityAvailable(a.typeCounts));
591
+ },
592
+ callback: function(s, l) {
593
+ l.preventDefault();
580
594
  const a = localStorage.getItem("blocklyStash");
581
595
  if (!a)
582
596
  return !1;
583
597
  const i = JSON.parse(a);
584
- return !(!i || !l.isCapacityAvailable(i.typeCounts));
598
+ return i ? (v.paste(i, s), !0) : !1;
585
599
  },
586
- callback: function(l, a) {
587
- a.preventDefault();
588
- const i = localStorage.getItem("blocklyStash");
589
- if (!i)
590
- return !1;
591
- const c = JSON.parse(i);
592
- return c ? (e.clipboard.paste(c, l), !0) : !1;
593
- },
594
- keyCodes: [t, r, n]
600
+ keyCodes: [e, n, o]
595
601
  };
596
- e.ShortcutRegistry.registry.register(s);
602
+ u.registry.register(r);
597
603
  }
598
604
  }
599
- class Y {
605
+ class ue {
600
606
  init() {
601
- const t = e.ContextMenuRegistry.registry.getItem("cleanWorkspace");
602
- t && (t.callback = function(r) {
603
- const n = r.workspace;
604
- if (!n)
607
+ const e = d.registry.getItem("cleanWorkspace");
608
+ e && (e.callback = function(n) {
609
+ const o = n.workspace;
610
+ if (!o)
605
611
  return;
606
- n.setResizesEnabled(!1), e.Events.setGroup(!0);
607
- const s = n.getTopBlocks(!0);
608
- let l = 0;
609
- for (let a = 0, i; i = s[a]; a++) {
610
- if (!i.isMovable())
612
+ o.setResizesEnabled(!1), y.setGroup(!0);
613
+ const r = o.getTopBlocks(!0);
614
+ let s = 0;
615
+ for (let l = 0, a; a = r[l]; l++) {
616
+ if (!a.isMovable())
611
617
  continue;
612
- const c = i.getRelativeToSurfaceXY();
613
- i.moveBy(-c.x, l - c.y, ["cleanup"]), i.snapToGrid(), l = i.getRelativeToSurfaceXY().y + i.getHeightWidth().height + 100;
618
+ const i = a.getRelativeToSurfaceXY();
619
+ a.moveBy(-i.x, s - i.y, ["cleanup"]), a.snapToGrid(), s = a.getRelativeToSurfaceXY().y + a.getHeightWidth().height + 100;
614
620
  }
615
- e.Events.setGroup(!1), n.setResizesEnabled(!0);
621
+ y.setGroup(!1), o.setResizesEnabled(!0);
616
622
  });
617
623
  }
618
624
  }
619
- function d(o) {
620
- const t = o.getParent();
621
- return t && d(t) ? !0 : !t && !!(o.outputConnection || o.previousConnection);
625
+ function R(t) {
626
+ const e = t.getParent();
627
+ return e && R(e) ? !0 : !e && !!(t.outputConnection || t.previousConnection);
622
628
  }
623
- class W {
629
+ class _e {
624
630
  init() {
625
- const t = e.ContextMenuRegistry.registry.getItem("blockDisable");
626
- t && (t.preconditionFn = function(r) {
627
- const n = r.block;
628
- return n && !n.isInFlyout && n.workspace.options.disable && n.isEditable() ? n.getInheritedDisabled() || d(n) ? "disabled" : "enabled" : "hidden";
631
+ const e = d.registry.getItem("blockDisable");
632
+ e && (e.preconditionFn = function(n) {
633
+ const o = n.block;
634
+ return o && !o.isInFlyout && o.workspace.options.disable && o.isEditable() ? o.getInheritedDisabled() || R(o) ? "disabled" : "enabled" : "hidden";
629
635
  });
630
636
  }
631
637
  }
632
- class G extends e.HorizontalFlyout {
633
- addBlockListeners_(t, r, n) {
634
- e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, r, n);
635
- }
636
- isBlockCreatable(t) {
637
- return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
638
- }
639
- }
640
- class H extends e.VerticalFlyout {
641
- addBlockListeners_(t, r, n) {
642
- e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, r, n);
643
- }
644
- isBlockCreatable(t) {
645
- return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
646
- }
647
- }
648
- const z = new V();
649
- z.init({ contextMenu: !0, shortcut: !0 });
650
- const X = new Y();
651
- X.init();
652
- const J = new W();
653
- J.init();
654
- e.registry.register(
655
- e.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
656
- e.registry.DEFAULT,
657
- G,
658
- !0
659
- );
660
- e.registry.register(
661
- e.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
662
- e.registry.DEFAULT,
663
- H,
664
- !0
665
- );
666
- e.Themes.Classic.blockStyles = {
638
+ const pe = new ce();
639
+ pe.init({ contextMenu: !0, shortcut: !0 });
640
+ const fe = new ue();
641
+ fe.init();
642
+ const ye = new _e();
643
+ ye.init();
644
+ C.Classic.blockStyles = {
667
645
  color_blocks: {
668
646
  colourPrimary: "#a5745b",
669
647
  colourSecondary: "#ede3de",
@@ -737,7 +715,7 @@ e.Themes.Classic.blockStyles = {
737
715
  hat: ""
738
716
  }
739
717
  };
740
- e.Themes.Classic.categoryStyles = {
718
+ C.Classic.categoryStyles = {
741
719
  calc_category: {
742
720
  colour: "#757575"
743
721
  },
@@ -787,9 +765,9 @@ e.Themes.Classic.categoryStyles = {
787
765
  colour: "#a55b80"
788
766
  }
789
767
  };
790
- const j = e.Theme.defineTheme("light", {
768
+ const de = P.defineTheme("light", {
791
769
  name: "light",
792
- base: e.Themes.Classic,
770
+ base: C.Classic,
793
771
  componentStyles: {
794
772
  workspaceBackgroundColour: "#ffffff",
795
773
  toolboxBackgroundColour: "#eeeeee",
@@ -803,9 +781,9 @@ const j = e.Theme.defineTheme("light", {
803
781
  scrollbarOpacity: 0.4,
804
782
  cursorColour: ""
805
783
  }
806
- }), q = e.Theme.defineTheme("dark", {
784
+ }), ge = P.defineTheme("dark", {
807
785
  name: "dark",
808
- base: e.Themes.Classic,
786
+ base: C.Classic,
809
787
  componentStyles: {
810
788
  workspaceBackgroundColour: "#1e1e1e",
811
789
  toolboxBackgroundColour: "#272727",
@@ -820,18 +798,18 @@ const j = e.Theme.defineTheme("light", {
820
798
  cursorColour: ""
821
799
  }
822
800
  });
823
- function $(o) {
824
- const t = e.getMainWorkspace();
825
- switch (console.log(t), o) {
801
+ function he(t) {
802
+ const e = te();
803
+ switch (console.log(e), t) {
826
804
  case "light":
827
- t.setTheme(j);
805
+ e.setTheme(de);
828
806
  break;
829
807
  case "dark":
830
- t.setTheme(q);
808
+ e.setTheme(ge);
831
809
  break;
832
810
  }
833
811
  }
834
- const Z = {
812
+ const Oe = {
835
813
  kind: "category",
836
814
  name: "%{BKY_CATEGORY_LOGIC}",
837
815
  categorystyle: "logic_category",
@@ -849,7 +827,7 @@ const Z = {
849
827
  type: "if_v1"
850
828
  }
851
829
  ]
852
- }, Q = {
830
+ }, be = {
853
831
  kind: "category",
854
832
  name: "%{BKY_CATEGORY_LOOP}",
855
833
  categorystyle: "loop_category",
@@ -871,20 +849,20 @@ const Z = {
871
849
  type: "for_each_v1"
872
850
  }
873
851
  ]
874
- }, ee = {
852
+ }, Ce = {
875
853
  kind: "categoryToolbox",
876
- contents: [Z, Q]
877
- }, te = { class: "position-relative w-100 h-100" }, oe = /* @__PURE__ */ b({
854
+ contents: [Oe, be]
855
+ }, me = { class: "position-relative w-100 h-100" }, ke = /* @__PURE__ */ F({
878
856
  __name: "index",
879
857
  props: {
880
858
  type: {},
881
859
  version: {}
882
860
  },
883
861
  emits: ["ready", "change"],
884
- setup(o, { emit: t }) {
885
- const r = B(), n = R(), { open: s } = F("blocklyEditorFlyout"), l = o, a = t, i = C(null);
886
- let c;
887
- const y = {
862
+ setup(t, { emit: e }) {
863
+ const n = H(), o = z(), { open: r } = j("blocklyEditorFlyout"), s = t, l = e, a = A(null);
864
+ let i;
865
+ const I = {
888
866
  grid: {
889
867
  length: 2,
890
868
  snap: !0,
@@ -897,7 +875,7 @@ const Z = {
897
875
  wheel: !0
898
876
  },
899
877
  readOnly: !1,
900
- theme: n.current.value.dark ? "dark" : "light",
878
+ theme: o.current.value.dark ? "dark" : "light",
901
879
  trashcan: !1,
902
880
  zoom: {
903
881
  maxScale: 1,
@@ -907,51 +885,51 @@ const Z = {
907
885
  wheel: !0
908
886
  }
909
887
  };
910
- m(async () => {
911
- if (!i.value)
888
+ N(async () => {
889
+ if (!a.value)
912
890
  return;
913
- await f(r.current.value);
914
- let u;
915
- l.type === "app" && l.version === "v1" && (u = ee), y.toolbox = u, c = e.inject(i.value, y), c.addChangeListener(e.Events.disableOrphans), c.addChangeListener(h), await k(), a("ready", c);
891
+ await E(n.current.value);
892
+ let _;
893
+ s.type === "app" && s.version === "v1" && (_ = Ce), I.toolbox = _, i = oe(a.value, I), i.addChangeListener(y.disableOrphans), i.addChangeListener(K), await D(), l("ready", i);
916
894
  });
917
- function g() {
918
- c && e.svgResize(c);
895
+ function x() {
896
+ i && ne(i);
919
897
  }
920
- function h(u) {
921
- a("change", u);
898
+ function K(_) {
899
+ l("change", _);
922
900
  }
923
- return S(() => {
924
- s.value = !1;
925
- }), p(s, (u) => {
926
- var _;
927
- u || (_ = c.getToolbox()) == null || _.clearSelection();
928
- }), p(
929
- () => r.current.value,
930
- (u) => {
931
- f(u);
901
+ return M(() => {
902
+ r.value = !1;
903
+ }), k(r, (_) => {
904
+ var m;
905
+ _ || (m = i.getToolbox()) == null || m.clearSelection();
906
+ }), k(
907
+ () => n.current.value,
908
+ (_) => {
909
+ E(_);
932
910
  }
933
- ), p(
934
- () => n.current.value.dark,
935
- (u) => {
936
- $(u ? "dark" : "light");
911
+ ), k(
912
+ () => o.current.value.dark,
913
+ (_) => {
914
+ he(_ ? "dark" : "light");
937
915
  }
938
- ), (u, _) => {
939
- const O = T("resize");
940
- return L(), E("div", te, [
941
- I(v("div", {
916
+ ), (_, m) => {
917
+ const w = V("resize");
918
+ return U(), Y("div", me, [
919
+ G(W("div", {
942
920
  class: "w-100 h-100",
943
921
  ref_key: "blocklyDiv",
944
- ref: i,
922
+ ref: a,
945
923
  id: "blocklyEditor"
946
924
  }, null, 512), [
947
- [O, g]
925
+ [w, x]
948
926
  ])
949
927
  ]);
950
928
  };
951
929
  }
952
- }), re = (o) => {
953
- o.component("x-blockly", oe);
954
- }, ae = { install: re };
930
+ }), Se = (t) => {
931
+ t.component("x-blockly", ke);
932
+ }, Ee = { install: Se };
955
933
  export {
956
- ae as default
934
+ Ee as default
957
935
  };