x-block-lib 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import './logic';
@@ -0,0 +1 @@
1
+ import './boolean/v1';
@@ -1,3 +1,4 @@
1
+ import './blocks';
1
2
  import './dialog';
2
3
  export * from './locale';
3
4
  import './plugins';
@@ -1,2 +1,7 @@
1
- declare const _default: {};
1
+ declare const _default: {
2
+ LOGIC_BOOLEAN_FALSE: string;
3
+ LOGIC_BOOLEAN_TRUE: string;
4
+ LOGIC_V1_BOOLEAN_TOOPTIP: string;
5
+ LOGIC_V1_BOOLEAN_HELPURL: string;
6
+ };
2
7
  export default _default;
@@ -1,2 +1,7 @@
1
- declare const _default: {};
1
+ declare const _default: {
2
+ LOGIC_BOOLEAN_FALSE: string;
3
+ LOGIC_BOOLEAN_TRUE: string;
4
+ LOGIC_V1_BOOLEAN_TOOPTIP: string;
5
+ LOGIC_V1_BOOLEAN_HELPURL: string;
6
+ };
2
7
  export default _default;
@@ -0,0 +1,3 @@
1
+ export declare class CustomCleanUp {
2
+ init(): void;
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare class DisableTopBlocks {
2
+ init(): void;
3
+ }
@@ -0,0 +1,9 @@
1
+ import * as Blockly from 'blockly/core';
2
+ export declare class ReadOnlyHorizontalFlyout extends Blockly.HorizontalFlyout {
3
+ protected addBlockListeners_(root: SVGElement, block: Blockly.BlockSvg, rect: SVGElement): void;
4
+ isBlockCreatable(block: Blockly.BlockSvg): boolean;
5
+ }
6
+ export declare class ReadOnlyVerticalFlyout extends Blockly.VerticalFlyout {
7
+ protected addBlockListeners_(root: SVGElement, block: Blockly.BlockSvg, rect: SVGElement): void;
8
+ isBlockCreatable(block: Blockly.BlockSvg): boolean;
9
+ }
@@ -1,3 +1,18 @@
1
- import * as Blockly from 'blockly/core';
2
- declare const toolbox: Blockly.utils.toolbox.ToolboxDefinition;
1
+ declare const toolbox: {
2
+ kind: string;
3
+ contents: {
4
+ kind: string;
5
+ name: string;
6
+ categorystyle: string;
7
+ contents: ({
8
+ kind: string;
9
+ text: string;
10
+ type?: undefined;
11
+ } | {
12
+ kind: string;
13
+ type: string;
14
+ text?: undefined;
15
+ })[];
16
+ }[];
17
+ };
3
18
  export default toolbox;
@@ -0,0 +1,15 @@
1
+ declare const logic: {
2
+ kind: string;
3
+ name: string;
4
+ categorystyle: string;
5
+ contents: ({
6
+ kind: string;
7
+ text: string;
8
+ type?: undefined;
9
+ } | {
10
+ kind: string;
11
+ type: string;
12
+ text?: undefined;
13
+ })[];
14
+ };
15
+ export default logic;
@@ -0,0 +1,11 @@
1
+ const O = {
2
+ LOGIC_BOOLEAN_FALSE: "false",
3
+ LOGIC_BOOLEAN_TRUE: "true",
4
+ LOGIC_V1_BOOLEAN_TOOPTIP: "LOGIC_V1_BOOLEAN_TOOPTIP",
5
+ LOGIC_V1_BOOLEAN_HELPURL: "LOGIC_V1_BOOLEAN_HELPURL"
6
+ }, L = {
7
+ ...O
8
+ };
9
+ export {
10
+ L as default
11
+ };
package/dist/index.js CHANGED
@@ -1,52 +1,77 @@
1
- import { getCurrentInstance as b, inject as m, defineComponent as h, ref as C, onMounted as k, nextTick as T, onBeforeUnmount as _, watch as d, openBlock as v, createElementBlock as R, withDirectives as K, createElementVNode as M } from "vue";
2
- import { openConfirmDlg as P, openPromptDlg as w, useViewStack as x } from "x-essential-lib";
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");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 { getCurrentInstance as C, inject as p, defineComponent as h, ref as k, onMounted as _, nextTick as T, onBeforeUnmount as O, watch as d, openBlock as v, createElementBlock as R, withDirectives as B, createElementVNode as L } from "vue";
3
+ import { openConfirmDlg as w, openPromptDlg as E, useViewStack as x } from "x-essential-lib";
3
4
  import * as e from "blockly/core";
4
- function B(r, t) {
5
- const o = b();
5
+ import { javascriptGenerator as M, Order as P } from "blockly/javascript";
6
+ function D(s, t) {
7
+ const o = C();
6
8
  if (!o)
7
- throw new Error(`[Vuetify] ${r} must be called from inside a setup function`);
9
+ throw new Error(`[Vuetify] ${s} must be called from inside a setup function`);
8
10
  return o;
9
11
  }
10
- const O = Symbol.for("vuetify:locale");
11
- function z() {
12
- const r = m(O);
13
- if (!r)
12
+ const K = Symbol.for("vuetify:locale");
13
+ function A() {
14
+ const s = p(K);
15
+ if (!s)
14
16
  throw new Error("[Vuetify] Could not find injected locale instance");
15
- return r;
17
+ return s;
16
18
  }
17
- const E = Symbol.for("vuetify:theme");
19
+ const F = Symbol.for("vuetify:theme");
18
20
  function I() {
19
- B("useTheme");
20
- const r = m(E, null);
21
- if (!r)
21
+ D("useTheme");
22
+ const s = p(F, null);
23
+ if (!s)
22
24
  throw new Error("Could not find Vuetify theme injection");
23
- return r;
25
+ return s;
24
26
  }
25
- e.dialog.setConfirm(async (r, t) => {
26
- const o = await P({
27
+ e.defineBlocksWithJsonArray([
28
+ {
29
+ type: "boolean_v1",
30
+ message0: "%1",
31
+ args0: [
32
+ {
33
+ type: "field_dropdown",
34
+ name: "BOOL",
35
+ options: [
36
+ ["%{BKY_LOGIC_BOOLEAN_FALSE}", "FALSE"],
37
+ ["%{BKY_LOGIC_BOOLEAN_TRUE}", "TRUE"]
38
+ ]
39
+ }
40
+ ],
41
+ output: "Boolean",
42
+ style: "logic_blocks",
43
+ tooltip: "%{BKY_LOGIC_V1_BOOLEAN_TOOLTIP}",
44
+ helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
45
+ }
46
+ ]);
47
+ M.forBlock.boolean_v1 = function(s) {
48
+ return [s.getFieldValue("BOOL") === "TRUE" ? "true" : "false", P.ATOMIC];
49
+ };
50
+ e.dialog.setConfirm(async (s, t) => {
51
+ const o = await w({
27
52
  title: "",
28
- text: r
53
+ text: s
29
54
  });
30
55
  t(!!o);
31
56
  });
32
- e.dialog.setPrompt(async (r, t, o) => {
33
- const a = await w({
57
+ e.dialog.setPrompt(async (s, t, o) => {
58
+ const r = await E({
34
59
  title: "",
35
60
  value: t
36
61
  });
37
- o(a);
62
+ o(r);
38
63
  });
39
- const D = (r, t) => {
40
- const o = r[t];
41
- return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((a, c) => {
42
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(c.bind(null, new Error("Unknown variable dynamic import: " + t)));
64
+ const z = (s, t) => {
65
+ const o = s[t];
66
+ return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((r, i) => {
67
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.bind(null, new Error("Unknown variable dynamic import: " + t)));
43
68
  });
44
69
  };
45
- async function f(r) {
46
- const t = await D(/* @__PURE__ */ Object.assign({ "./msg/en.ts": () => import("./en-DYxpcVy9.js"), "./msg/zhHans.ts": () => import("./zhHans-DjWw6Iqb.js") }), `./msg/${r}.ts`);
47
- e.setLocale(t);
70
+ async function g(s) {
71
+ const t = await z(/* @__PURE__ */ Object.assign({ "./msg/en.ts": () => import("./en-CCqtrcN-.js"), "./msg/zhHans.ts": () => import("./zhHans---jf3OTZ.js") }), `./msg/${s}.ts`);
72
+ e.setLocale(t.default);
48
73
  }
49
- class F {
74
+ class V {
50
75
  init({ contextMenu: t = !0, shortcut: o = !0 } = {
51
76
  contextMenu: !0,
52
77
  shortcut: !0
@@ -64,21 +89,15 @@ class F {
64
89
  displayText: function() {
65
90
  return e.Msg.CROSS_TAB_COPY ? e.Msg.CROSS_TAB_COPY : "Copy";
66
91
  },
67
- preconditionFn: function(o) {
68
- var s;
69
- const a = e.getSelected();
70
- if (!a)
71
- return "disabled";
72
- const c = (s = o.workspace) == null ? void 0 : s.getBlockById(
73
- a.id
74
- );
75
- return !c || !c.isDeletable() || !c.isMovable() ? "disabled" : "enabled";
92
+ preconditionFn: function() {
93
+ const o = e.getSelected();
94
+ return !o || !e.isDeletable(o) || !o.isDeletable() || !e.isDraggable(o) || !o.isMovable() || !e.isCopyable(o) ? "disabled" : "enabled";
76
95
  },
77
96
  callback: function(o) {
78
- var a;
97
+ var r;
79
98
  localStorage.setItem(
80
99
  "blocklyStash",
81
- JSON.stringify((a = o.block) == null ? void 0 : a.toCopyData())
100
+ JSON.stringify((r = o.block) == null ? void 0 : r.toCopyData())
82
101
  );
83
102
  },
84
103
  scopeType: e.ContextMenuRegistry.ScopeType.BLOCK,
@@ -93,19 +112,19 @@ class F {
93
112
  return e.Msg.CROSS_TAB_PASTE ? e.Msg.CROSS_TAB_PASTE : "Paste";
94
113
  },
95
114
  preconditionFn: function(o) {
96
- var s;
97
- const a = localStorage.getItem("blocklyStash");
98
- if (!a)
115
+ var l;
116
+ const r = localStorage.getItem("blocklyStash");
117
+ if (!r)
99
118
  return "disabled";
100
- const c = JSON.parse(a);
101
- return !c || !((s = o.workspace) != null && s.isCapacityAvailable(c.typeCounts)) ? "disabled" : "enabled";
119
+ const i = JSON.parse(r);
120
+ return !i || !((l = o.workspace) != null && l.isCapacityAvailable(i.typeCounts)) ? "disabled" : "enabled";
102
121
  },
103
122
  callback: function(o) {
104
- const a = localStorage.getItem("blocklyStash");
105
- if (!a)
123
+ const r = localStorage.getItem("blocklyStash");
124
+ if (!r)
106
125
  return;
107
- const c = JSON.parse(a);
108
- c && o.workspace && e.clipboard.paste(c, o.workspace);
126
+ const i = JSON.parse(r);
127
+ i && o.workspace && e.clipboard.paste(i, o.workspace);
109
128
  },
110
129
  scopeType: e.ContextMenuRegistry.ScopeType.WORKSPACE,
111
130
  id: "blockPasteFromStorage",
@@ -114,136 +133,166 @@ class F {
114
133
  e.ContextMenuRegistry.registry.register(t);
115
134
  }
116
135
  blockCopyToStorageShortcut() {
117
- const t = {
118
- name: "copy",
119
- preconditionFn: function(s) {
120
- if (s.options.readOnly || e.Gesture.inProgress())
121
- return !1;
122
- const n = e.getSelected();
123
- if (!n)
124
- return !1;
125
- const i = s.getBlockById(
126
- n.id
127
- );
128
- return !(!i || !i.isDeletable() || !i.isMovable() || i.isInMutator);
129
- },
130
- callback: function(s, n) {
131
- n.preventDefault();
132
- const i = e.getSelected();
133
- if (!i)
134
- return !1;
135
- const l = s.getBlockById(
136
- i.id
137
- );
138
- return l ? (s.hideChaff(), localStorage.setItem(
139
- "blocklyStash",
140
- JSON.stringify(l.toCopyData())
141
- ), !0) : !1;
142
- }
143
- };
144
- e.ShortcutRegistry.registry.register(t);
145
- const o = e.ShortcutRegistry.registry.createSerializedKey(
136
+ const t = e.ShortcutRegistry.registry.createSerializedKey(
146
137
  e.utils.KeyCodes.C,
147
138
  [e.utils.KeyCodes.CTRL]
148
- );
149
- e.ShortcutRegistry.registry.addKeyMapping(o, t.name);
150
- const a = e.ShortcutRegistry.registry.createSerializedKey(
139
+ ), o = e.ShortcutRegistry.registry.createSerializedKey(
151
140
  e.utils.KeyCodes.C,
152
141
  [e.utils.KeyCodes.ALT]
153
- );
154
- e.ShortcutRegistry.registry.addKeyMapping(a, t.name);
155
- const c = e.ShortcutRegistry.registry.createSerializedKey(
142
+ ), r = e.ShortcutRegistry.registry.createSerializedKey(
156
143
  e.utils.KeyCodes.C,
157
144
  [e.utils.KeyCodes.META]
158
- );
159
- e.ShortcutRegistry.registry.addKeyMapping(c, t.name);
160
- }
161
- blockCutToStorageShortcut() {
162
- const t = {
163
- name: "cut",
164
- preconditionFn: function(s) {
165
- if (s.options.readOnly || e.Gesture.inProgress())
145
+ ), i = {
146
+ name: "copy",
147
+ preconditionFn: function(l) {
148
+ if (l.options.readOnly || e.Gesture.inProgress())
166
149
  return !1;
167
150
  const n = e.getSelected();
168
- if (!n)
169
- return !1;
170
- const i = s.getBlockById(
171
- n.id
172
- );
173
- return !(!i || !i.isDeletable() || !i.isMovable() || s.isFlyout);
151
+ return !(!n || !e.isDeletable(n) || !n.isDeletable() || !e.isDraggable(n) || !n.isMovable() || !e.isCopyable(n));
174
152
  },
175
- callback: function(s, n) {
153
+ callback: function(l, n) {
176
154
  n.preventDefault();
177
- const i = e.getSelected();
178
- if (!i)
155
+ const a = e.getSelected();
156
+ if (!a || !e.isCopyable(a))
179
157
  return !1;
180
- const l = s.getBlockById(
181
- i.id
182
- );
183
- return l ? (localStorage.setItem(
184
- "blocklyStash",
185
- JSON.stringify(l.toCopyData())
186
- ), e.Events.setGroup(!0), l.dispose(!0), e.Events.setGroup(!1), !0) : !1;
187
- }
158
+ const c = a.toCopyData();
159
+ return c ? (l.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
160
+ },
161
+ keyCodes: [t, o, r]
188
162
  };
189
- e.ShortcutRegistry.registry.register(t);
190
- const o = e.ShortcutRegistry.registry.createSerializedKey(
163
+ e.ShortcutRegistry.registry.register(i);
164
+ }
165
+ blockCutToStorageShortcut() {
166
+ const t = e.ShortcutRegistry.registry.createSerializedKey(
191
167
  e.utils.KeyCodes.X,
192
168
  [e.utils.KeyCodes.CTRL]
193
- );
194
- e.ShortcutRegistry.registry.addKeyMapping(o, t.name);
195
- const a = e.ShortcutRegistry.registry.createSerializedKey(
169
+ ), o = e.ShortcutRegistry.registry.createSerializedKey(
196
170
  e.utils.KeyCodes.X,
197
171
  [e.utils.KeyCodes.ALT]
198
- );
199
- e.ShortcutRegistry.registry.addKeyMapping(a, t.name);
200
- const c = e.ShortcutRegistry.registry.createSerializedKey(
172
+ ), r = e.ShortcutRegistry.registry.createSerializedKey(
201
173
  e.utils.KeyCodes.X,
202
174
  [e.utils.KeyCodes.META]
203
- );
204
- e.ShortcutRegistry.registry.addKeyMapping(c, t.name);
205
- }
206
- blockPasteFromStorageShortcut() {
207
- const t = {
208
- name: "paste",
209
- preconditionFn: function(s) {
210
- if (s.options.readOnly || e.Gesture.inProgress())
211
- return !1;
212
- const n = localStorage.getItem("blocklyStash");
213
- if (!n)
175
+ ), i = {
176
+ name: "cut",
177
+ preconditionFn: function(l) {
178
+ if (l.options.readOnly || e.Gesture.inProgress())
214
179
  return !1;
215
- const i = JSON.parse(n);
216
- return !(!i || !s.isCapacityAvailable(i.typeCounts));
180
+ const n = e.getSelected();
181
+ return !(!n || !e.isDeletable(n) || !n.isDeletable() || !e.isDraggable(n) || !n.isMovable() || !e.isCopyable(n) || n.workspace.isFlyout);
217
182
  },
218
- callback: function(s, n) {
183
+ callback: function(l, n) {
219
184
  n.preventDefault();
220
- const i = localStorage.getItem("blocklyStash");
221
- if (!i)
185
+ const a = e.getSelected();
186
+ if (!a || !e.isDeletable(a) || !a.isDeletable() || !e.isCopyable(a))
222
187
  return !1;
223
- const l = JSON.parse(i);
224
- return l ? (e.clipboard.paste(l, s), !0) : !1;
225
- }
188
+ const c = a.toCopyData();
189
+ return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), a instanceof e.BlockSvg ? a.checkAndDelete() : a.dispose(), !0) : !1;
190
+ },
191
+ keyCodes: [t, o, r]
226
192
  };
227
- e.ShortcutRegistry.registry.register(t);
228
- const o = e.ShortcutRegistry.registry.createSerializedKey(
193
+ e.ShortcutRegistry.registry.register(i);
194
+ }
195
+ blockPasteFromStorageShortcut() {
196
+ const t = e.ShortcutRegistry.registry.createSerializedKey(
229
197
  e.utils.KeyCodes.V,
230
198
  [e.utils.KeyCodes.CTRL]
231
- );
232
- e.ShortcutRegistry.registry.addKeyMapping(o, t.name);
233
- const a = e.ShortcutRegistry.registry.createSerializedKey(
199
+ ), o = e.ShortcutRegistry.registry.createSerializedKey(
234
200
  e.utils.KeyCodes.V,
235
201
  [e.utils.KeyCodes.ALT]
236
- );
237
- e.ShortcutRegistry.registry.addKeyMapping(a, t.name);
238
- const c = e.ShortcutRegistry.registry.createSerializedKey(
202
+ ), r = e.ShortcutRegistry.registry.createSerializedKey(
239
203
  e.utils.KeyCodes.V,
240
204
  [e.utils.KeyCodes.META]
241
- );
242
- e.ShortcutRegistry.registry.addKeyMapping(c, t.name);
205
+ ), i = {
206
+ name: "paste",
207
+ preconditionFn: function(l) {
208
+ if (l.options.readOnly || e.Gesture.inProgress())
209
+ return !1;
210
+ const n = localStorage.getItem("blocklyStash");
211
+ if (!n)
212
+ return !1;
213
+ const a = JSON.parse(n);
214
+ return !(!a || !l.isCapacityAvailable(a.typeCounts));
215
+ },
216
+ callback: function(l, n) {
217
+ n.preventDefault();
218
+ const a = localStorage.getItem("blocklyStash");
219
+ if (!a)
220
+ return !1;
221
+ const c = JSON.parse(a);
222
+ return c ? (e.clipboard.paste(c, l), !0) : !1;
223
+ },
224
+ keyCodes: [t, o, r]
225
+ };
226
+ e.ShortcutRegistry.registry.register(i);
243
227
  }
244
228
  }
245
- const A = new F();
246
- A.init({ contextMenu: !0, shortcut: !0 });
229
+ class U {
230
+ init() {
231
+ const t = e.ContextMenuRegistry.registry.getItem("cleanWorkspace");
232
+ t && (t.callback = function(o) {
233
+ const r = o.workspace;
234
+ if (!r)
235
+ return;
236
+ r.setResizesEnabled(!1), e.Events.setGroup(!0);
237
+ const i = r.getTopBlocks(!0);
238
+ let l = 0;
239
+ for (let n = 0, a; a = i[n]; n++) {
240
+ if (!a.isMovable())
241
+ continue;
242
+ const c = a.getRelativeToSurfaceXY();
243
+ a.moveBy(-c.x, l - c.y, ["cleanup"]), a.snapToGrid(), l = a.getRelativeToSurfaceXY().y + a.getHeightWidth().height + 100;
244
+ }
245
+ e.Events.setGroup(!1), r.setResizesEnabled(!0);
246
+ });
247
+ }
248
+ }
249
+ function b(s) {
250
+ const t = s.getParent();
251
+ return t && b(t) ? !0 : !t && !!(s.outputConnection || s.previousConnection);
252
+ }
253
+ class Y {
254
+ init() {
255
+ const t = e.ContextMenuRegistry.registry.getItem("blockDisable");
256
+ t && (t.preconditionFn = function(o) {
257
+ const r = o.block;
258
+ return r && !r.isInFlyout && r.workspace.options.disable && r.isEditable() ? r.getInheritedDisabled() || b(r) ? "disabled" : "enabled" : "hidden";
259
+ });
260
+ }
261
+ }
262
+ class N extends e.HorizontalFlyout {
263
+ addBlockListeners_(t, o, r) {
264
+ e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, o, r);
265
+ }
266
+ isBlockCreatable(t) {
267
+ return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
268
+ }
269
+ }
270
+ class G extends e.VerticalFlyout {
271
+ addBlockListeners_(t, o, r) {
272
+ e.getMainWorkspace().options.readOnly || super.addBlockListeners_(t, o, r);
273
+ }
274
+ isBlockCreatable(t) {
275
+ return e.getMainWorkspace().options.readOnly ? !1 : super.isBlockCreatable(t);
276
+ }
277
+ }
278
+ const X = new V();
279
+ X.init({ contextMenu: !0, shortcut: !0 });
280
+ const j = new U();
281
+ j.init();
282
+ const W = new Y();
283
+ W.init();
284
+ e.registry.register(
285
+ e.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX,
286
+ e.registry.DEFAULT,
287
+ N,
288
+ !0
289
+ );
290
+ e.registry.register(
291
+ e.registry.Type.FLYOUTS_VERTICAL_TOOLBOX,
292
+ e.registry.DEFAULT,
293
+ G,
294
+ !0
295
+ );
247
296
  e.Themes.Classic.blockStyles = {
248
297
  color_blocks: {
249
298
  colourPrimary: "#a5745b",
@@ -368,7 +417,7 @@ e.Themes.Classic.categoryStyles = {
368
417
  colour: "#a55b80"
369
418
  }
370
419
  };
371
- const L = e.Theme.defineTheme("light", {
420
+ const $ = e.Theme.defineTheme("light", {
372
421
  name: "light",
373
422
  base: e.Themes.Classic,
374
423
  componentStyles: {
@@ -384,7 +433,7 @@ const L = e.Theme.defineTheme("light", {
384
433
  scrollbarOpacity: 0.4,
385
434
  cursorColour: ""
386
435
  }
387
- }), V = e.Theme.defineTheme("dark", {
436
+ }), J = e.Theme.defineTheme("dark", {
388
437
  name: "dark",
389
438
  base: e.Themes.Classic,
390
439
  componentStyles: {
@@ -401,55 +450,69 @@ const L = e.Theme.defineTheme("light", {
401
450
  cursorColour: ""
402
451
  }
403
452
  });
404
- function $(r) {
453
+ function H(s) {
405
454
  const t = e.getMainWorkspace();
406
- switch (console.log(t), r) {
455
+ switch (console.log(t), s) {
407
456
  case "light":
408
- t.setTheme(L);
457
+ t.setTheme($);
409
458
  break;
410
459
  case "dark":
411
- t.setTheme(V);
460
+ t.setTheme(J);
412
461
  break;
413
462
  }
414
463
  }
415
- const j = {
464
+ const q = {
465
+ kind: "category",
466
+ name: "%{BKY_CATEGORY_LOGIC}",
467
+ categorystyle: "logic_category",
468
+ contents: [
469
+ {
470
+ kind: "label",
471
+ text: "%{BKY_LABEL_BOOLEAN}"
472
+ },
473
+ {
474
+ kind: "block",
475
+ type: "boolean_v1"
476
+ }
477
+ ]
478
+ }, Z = {
416
479
  kind: "categoryToolbox",
417
- contents: []
480
+ contents: [q]
418
481
  };
419
- function N(r, t) {
420
- var c, s;
421
- const o = t.value, a = {
422
- passive: !((c = t.modifiers) != null && c.active)
482
+ function Q(s, t) {
483
+ var i, l;
484
+ const o = t.value, r = {
485
+ passive: !((i = t.modifiers) != null && i.active)
423
486
  };
424
- window.addEventListener("resize", o, a), r._onResize = Object(r._onResize), r._onResize[t.instance.$.uid] = {
487
+ window.addEventListener("resize", o, r), s._onResize = Object(s._onResize), s._onResize[t.instance.$.uid] = {
425
488
  handler: o,
426
- options: a
427
- }, (s = t.modifiers) != null && s.quiet || o();
489
+ options: r
490
+ }, (l = t.modifiers) != null && l.quiet || o();
428
491
  }
429
- function J(r, t) {
430
- var c;
431
- if (!((c = r._onResize) != null && c[t.instance.$.uid]))
492
+ function ee(s, t) {
493
+ var i;
494
+ if (!((i = s._onResize) != null && i[t.instance.$.uid]))
432
495
  return;
433
496
  const {
434
497
  handler: o,
435
- options: a
436
- } = r._onResize[t.instance.$.uid];
437
- window.removeEventListener("resize", o, a), delete r._onResize[t.instance.$.uid];
498
+ options: r
499
+ } = s._onResize[t.instance.$.uid];
500
+ window.removeEventListener("resize", o, r), delete s._onResize[t.instance.$.uid];
438
501
  }
439
- const X = {
440
- mounted: N,
441
- unmounted: J
442
- }, G = { class: "position-relative w-100 h-100" }, q = /* @__PURE__ */ h({
502
+ const te = {
503
+ mounted: Q,
504
+ unmounted: ee
505
+ }, oe = { class: "position-relative w-100 h-100" }, re = /* @__PURE__ */ h({
443
506
  __name: "index",
444
507
  props: {
445
508
  type: {},
446
509
  version: {}
447
510
  },
448
511
  emits: ["ready", "change"],
449
- setup(r, { emit: t }) {
450
- const o = z(), a = I(), { open: c } = x("blocklyEditorFlyout"), s = r, n = t, i = C(null);
451
- let l;
452
- const g = {
512
+ setup(s, { emit: t }) {
513
+ const o = A(), r = I(), { open: i } = x("blocklyEditorFlyout"), l = s, n = t, a = k(null);
514
+ let c;
515
+ const f = {
453
516
  grid: {
454
517
  length: 2,
455
518
  snap: !0,
@@ -461,7 +524,8 @@ const X = {
461
524
  scrollbars: !0,
462
525
  wheel: !0
463
526
  },
464
- theme: a.current.value.dark ? "dark" : "light",
527
+ readOnly: !1,
528
+ theme: r.current.value.dark ? "dark" : "light",
465
529
  trashcan: !1,
466
530
  zoom: {
467
531
  maxScale: 1,
@@ -471,48 +535,48 @@ const X = {
471
535
  wheel: !0
472
536
  }
473
537
  };
474
- k(async () => {
475
- if (!i.value)
538
+ _(async () => {
539
+ if (!a.value)
476
540
  return;
477
- await f(o.current.value);
541
+ await g(o.current.value);
478
542
  let u;
479
- s.type === "app" && s.version === "v1" && (u = j), g.toolbox = u, l = e.inject(i.value, g), l.addChangeListener(e.Events.disableOrphans), l.addChangeListener(S), await T(), n("ready", l);
543
+ l.type === "app" && l.version === "v1" && (u = Z), f.toolbox = u, c = e.inject(a.value, f), c.addChangeListener(e.Events.disableOrphans), c.addChangeListener(S), await T(), n("ready", c);
480
544
  });
481
- function p() {
482
- l && e.svgResize(l);
545
+ function m() {
546
+ c && e.svgResize(c);
483
547
  }
484
548
  function S(u) {
485
549
  n("change", u);
486
550
  }
487
- return _(() => {
488
- c.value = !1;
489
- }), d(c, (u) => {
551
+ return O(() => {
552
+ i.value = !1;
553
+ }), d(i, (u) => {
490
554
  var y;
491
- u || (y = l.getToolbox()) == null || y.clearSelection();
555
+ u || (y = c.getToolbox()) == null || y.clearSelection();
492
556
  }), d(
493
557
  () => o.current.value,
494
558
  (u) => {
495
- f(u);
559
+ g(u);
496
560
  }
497
561
  ), d(
498
- () => a.current.value.dark,
562
+ () => r.current.value.dark,
499
563
  (u) => {
500
- $(u ? "dark" : "light");
564
+ H(u ? "dark" : "light");
501
565
  }
502
- ), (u, y) => (v(), R("div", G, [
503
- K(M("div", {
566
+ ), (u, y) => (v(), R("div", oe, [
567
+ B(L("div", {
504
568
  class: "w-100 h-100",
505
569
  ref_key: "blocklyDiv",
506
- ref: i,
570
+ ref: a,
507
571
  id: "blocklyEditor"
508
572
  }, null, 512), [
509
- [X, p]
573
+ [te, m]
510
574
  ])
511
575
  ]));
512
576
  }
513
- }), U = (r) => {
514
- r.component("x-blockly", q);
515
- }, W = { install: U };
577
+ }), se = (s) => {
578
+ s.component("x-blockly", re);
579
+ }, le = { install: se };
516
580
  export {
517
- W as default
581
+ le as default
518
582
  };
@@ -0,0 +1,11 @@
1
+ const O = {
2
+ LOGIC_BOOLEAN_FALSE: "假",
3
+ LOGIC_BOOLEAN_TRUE: "真",
4
+ LOGIC_V1_BOOLEAN_TOOPTIP: "LOGIC_V1_BOOLEAN_TOOPTIP",
5
+ LOGIC_V1_BOOLEAN_HELPURL: "LOGIC_V1_BOOLEAN_HELPURL"
6
+ }, L = {
7
+ ...O
8
+ };
9
+ export {
10
+ L as default
11
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-block-lib",
3
3
  "private": false,
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -46,6 +46,7 @@
46
46
  "vite": "^5.2.0",
47
47
  "vite-plugin-css-injected-by-js": "^3.5.0",
48
48
  "vite-plugin-vuetify": "^2.0.3",
49
+ "vue-i18n": "^9.13.1",
49
50
  "vue-tsc": "^2.0.6"
50
51
  }
51
52
  }
@@ -1,4 +0,0 @@
1
- const e = {};
2
- export {
3
- e as default
4
- };
@@ -1,4 +0,0 @@
1
- const a = {};
2
- export {
3
- a as default
4
- };