x-block-lib 0.10.1 → 0.10.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.
@@ -4,4 +4,7 @@ export declare enum CustomEventType {
4
4
  }
5
5
  export declare class StateChange extends Blockly.Events.Abstract {
6
6
  isBlank: boolean;
7
+ recordUndo: boolean;
8
+ type: string;
9
+ constructor(workspace: Blockly.Workspace);
7
10
  }
package/dist/index.js CHANGED
@@ -15,13 +15,6 @@ import { eventBus, globalObjects, messageWarning, openConfirmDlg, openPromptDlg,
15
15
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, isRef, mergeModels, mergeProps, nextTick, normalizeStyle, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, ref, renderList, renderSlot, resolveComponent, resolveDirective, toDisplayString, unref, useId, useModel, useTemplateRef, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
16
16
  import { useDisplay } from "vuetify";
17
17
  import { useI18n } from "vue-i18n";
18
- let CustomEventType = /* @__PURE__ */ function(e) {
19
- return e.STATE_CHANGE = "state_change", e;
20
- }({});
21
- var StateChange = class extends Events.Abstract {
22
- isBlank = !0;
23
- };
24
- registry.register(registry.Type.EVENT, CustomEventType.STATE_CHANGE, StateChange);
25
18
  var __rolldown_dynamic_import_helper_default = (e, y, b) => {
26
19
  let x = y.lastIndexOf("?"), S = e[x === -1 || x < y.lastIndexOf("/") ? y : y.slice(0, x)];
27
20
  return S ? typeof S == "function" ? S() : Promise.resolve(S) : new Promise((e, x) => {
@@ -228,8 +221,7 @@ Blocks.get_page_argument_v1 = {
228
221
  return genArgumentOpts();
229
222
  },
230
223
  onchange: function(e) {
231
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
232
- else if (e.type === Events.BLOCK_CHANGE) {
224
+ if (e.type === Events.BLOCK_CHANGE) {
233
225
  let y = e;
234
226
  y.blockId === this.id && (y.element === "field" && y.name === "ARGUMENT" && this.onArgumentChange_(y.newValue), setTimeout(() => {
235
227
  this.checkWarning_();
@@ -303,8 +295,7 @@ var createBlock$2 = (e, y) => {
303
295
  return ensureOpts(b);
304
296
  },
305
297
  onchange: function(e) {
306
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
307
- else if (e.type === Events.BLOCK_CHANGE) {
298
+ if (e.type === Events.BLOCK_CHANGE) {
308
299
  let y = e;
309
300
  y.blockId === this.id && (y.element === "field" && y.name === "TYPE" && this.onTypeChange_(y.newValue), setTimeout(() => {
310
301
  this.checkWarning_();
@@ -2107,8 +2098,7 @@ Blocks.app_bind_container_v1 = { init: function() {
2107
2098
  return this.kind === "state" ? genStateOpts() : ensureOpts([]);
2108
2099
  },
2109
2100
  onchange: function(e) {
2110
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
2111
- else if (e.type === Events.BLOCK_CHANGE) {
2101
+ if (e.type === Events.BLOCK_CHANGE) {
2112
2102
  let y = e;
2113
2103
  y.blockId === this.id && (y.element === "field" && (y.name === "KIND" ? this.onKindChange_(y.newValue) : y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "PROPERTY" ? this.onPropertyChange_(y.newValue) : y.name === "STATE" && this.onStateChange_(y.newValue)), setTimeout(() => {
2114
2104
  this.checkWarning_();
@@ -2250,8 +2240,7 @@ Blocks.app_bind_container_v1 = { init: function() {
2250
2240
  return genOnEventOpts(this.node.id);
2251
2241
  },
2252
2242
  onchange: function(e) {
2253
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
2254
- else if (e.type === Events.BLOCK_CHANGE) {
2243
+ if (e.type === Events.BLOCK_CHANGE) {
2255
2244
  let y = e;
2256
2245
  y.blockId === this.id && (y.element === "field" && (y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "EVENT" && this.onEventChange_(y.newValue)), setTimeout(() => {
2257
2246
  this.checkWarning_();
@@ -2406,8 +2395,7 @@ ${addIndent(x, 4)}${addIndent(S, 2)} } catch (e) {
2406
2395
  return genTriggerEventOpts(this.node.id);
2407
2396
  },
2408
2397
  onchange: function(e) {
2409
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
2410
- else if (e.type === Events.BLOCK_CHANGE) {
2398
+ if (e.type === Events.BLOCK_CHANGE) {
2411
2399
  let y = e;
2412
2400
  y.blockId === this.id && (y.element === "field" && (y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "EVENT" && this.onEventChange_(y.newValue)), setTimeout(() => {
2413
2401
  this.checkWarning_();
@@ -2677,8 +2665,7 @@ ${javascriptGenerator.statementToCode(e, "HANDLE")}}
2677
2665
  return genCallMethodOpts(this.node.id);
2678
2666
  },
2679
2667
  onchange: function(e) {
2680
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
2681
- else if (e.type === Events.BLOCK_CHANGE) {
2668
+ if (e.type === Events.BLOCK_CHANGE) {
2682
2669
  let y = e;
2683
2670
  y.blockId === this.id && (y.element === "field" && (y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "METHOD" && this.onMethodChange_(y.newValue)), setTimeout(() => {
2684
2671
  this.checkWarning_();
@@ -2890,8 +2877,7 @@ ${w}${e}}
2890
2877
  return genImplementMethodOpts(this.node.id);
2891
2878
  },
2892
2879
  onchange: function(e) {
2893
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
2894
- else if (e.type === Events.BLOCK_CHANGE) {
2880
+ if (e.type === Events.BLOCK_CHANGE) {
2895
2881
  let y = e;
2896
2882
  y.blockId === this.id && (y.element === "field" && (y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "METHOD" && this.onMethodChange_(y.newValue)), setTimeout(() => {
2897
2883
  this.checkWarning_();
@@ -3051,8 +3037,7 @@ ${E}${y}return __outputs__;
3051
3037
  return genImplementMethodOutputOpts(this.method.id);
3052
3038
  },
3053
3039
  onchange: function(e) {
3054
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
3055
- else if (e.type === Events.BLOCK_CHANGE) {
3040
+ if (e.type === Events.BLOCK_CHANGE) {
3056
3041
  let y = e;
3057
3042
  y.blockId === this.id && (y.element === "field" && (y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "METHOD" ? this.onMethodChange_(y.newValue) : y.name === "OUTPUT" && this.onOutputChange_(y.newValue)), setTimeout(() => {
3058
3043
  this.checkWarning_();
@@ -3218,8 +3203,7 @@ ${E}${y}return __outputs__;
3218
3203
  return genPageOpts(this.app.id);
3219
3204
  },
3220
3205
  onchange: function(e) {
3221
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
3222
- else if (e.type === Events.BLOCK_CHANGE) {
3206
+ if (e.type === Events.BLOCK_CHANGE) {
3223
3207
  let y = e;
3224
3208
  y.blockId === this.id && (y.element === "field" && (y.name === "APP" ? this.onAppChange_(y.newValue) : y.name === "PAGE" && this.onPageChange_(y.newValue)), setTimeout(() => {
3225
3209
  this.checkWarning_();
@@ -3293,8 +3277,7 @@ ${E}${y}return __outputs__;
3293
3277
  return genCompOpts();
3294
3278
  },
3295
3279
  onchange: function(e) {
3296
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
3297
- else if (e.type === Events.BLOCK_CHANGE) {
3280
+ if (e.type === Events.BLOCK_CHANGE) {
3298
3281
  let y = e;
3299
3282
  y.blockId === this.id && (y.element === "field" && y.name === "COMP" && this.onCompChange_(y.newValue), setTimeout(() => {
3300
3283
  this.checkWarning_();
@@ -3347,8 +3330,7 @@ ${E}${y}return __outputs__;
3347
3330
  return genSlotOpts_();
3348
3331
  },
3349
3332
  onchange: function(e) {
3350
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
3351
- else if (e.type === Events.BLOCK_CHANGE) {
3333
+ if (e.type === Events.BLOCK_CHANGE) {
3352
3334
  let y = e;
3353
3335
  y.blockId === this.id && (y.element === "field" && y.name === "SLOT" && this.onSlotChange_(y.newValue), setTimeout(() => {
3354
3336
  this.checkWarning_();
@@ -3417,8 +3399,7 @@ ${E}${y}return __outputs__;
3417
3399
  return genPropertyOpts(this.node.id, "read");
3418
3400
  },
3419
3401
  onchange: function(e) {
3420
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
3421
- else if (e.type === Events.BLOCK_CHANGE) {
3402
+ if (e.type === Events.BLOCK_CHANGE) {
3422
3403
  let y = e;
3423
3404
  y.blockId === this.id && (y.element === "field" && (y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "PROPERTY" && this.onPropertyChange_(y.newValue)), setTimeout(() => {
3424
3405
  this.checkWarning_();
@@ -3537,8 +3518,7 @@ ${E}${y}return __outputs__;
3537
3518
  return genPropertyOpts(this.node.id, "write");
3538
3519
  },
3539
3520
  onchange: function(e) {
3540
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
3541
- else if (e.type === Events.BLOCK_CHANGE) {
3521
+ if (e.type === Events.BLOCK_CHANGE) {
3542
3522
  let y = e;
3543
3523
  y.blockId === this.id && (y.element === "field" && (y.name === "NODE" ? this.onNodeChange_(y.newValue) : y.name === "PROPERTY" && this.onPropertyChange_(y.newValue)), setTimeout(() => {
3544
3524
  this.checkWarning_();
@@ -3655,8 +3635,7 @@ ${E}${y}return __outputs__;
3655
3635
  return genStateOpts();
3656
3636
  },
3657
3637
  onchange: function(e) {
3658
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
3659
- else if (e.type === Events.BLOCK_CHANGE) {
3638
+ if (e.type === Events.BLOCK_CHANGE) {
3660
3639
  let y = e;
3661
3640
  y.blockId === this.id && y.element === "field" && y.name === "STATE" && this.onStateChange_(y.newValue);
3662
3641
  }
@@ -4085,8 +4064,7 @@ Blocks.call_func_v1 = {
4085
4064
  return genFuncOpts(this.space.id);
4086
4065
  },
4087
4066
  onchange: function(e) {
4088
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
4089
- else if (e.type === Events.BLOCK_CHANGE) {
4067
+ if (e.type === Events.BLOCK_CHANGE) {
4090
4068
  let y = e;
4091
4069
  y.blockId === this.id && (y.element === "field" && (y.name === "SPACE" ? this.onSpaceChange_(y.newValue) : y.name === "FUNC" && this.onFuncChange_(y.newValue)), setTimeout(() => {
4092
4070
  this.checkWarning_();
@@ -4245,8 +4223,7 @@ ${E}${D}}
4245
4223
  return genFuncOpts(this.space.id);
4246
4224
  },
4247
4225
  onchange: function(e) {
4248
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
4249
- else if (e.type === Events.BLOCK_CHANGE) {
4226
+ if (e.type === Events.BLOCK_CHANGE) {
4250
4227
  let y = e;
4251
4228
  y.blockId === this.id && (y.element === "field" && (y.name === "SPACE" ? this.onSpaceChange_(y.newValue) : y.name === "FUNC" && this.onFuncChange_(y.newValue)), setTimeout(() => {
4252
4229
  this.checkWarning_();
@@ -4449,8 +4426,7 @@ ${b}}`;
4449
4426
  return genActiveFuncOutputOpts();
4450
4427
  },
4451
4428
  onchange: function(e) {
4452
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
4453
- else if (e.type === Events.BLOCK_CHANGE) {
4429
+ if (e.type === Events.BLOCK_CHANGE) {
4454
4430
  let y = e;
4455
4431
  y.blockId === this.id && (y.element === "field" && y.name === "OUTPUT" && this.onOutputChange_(y.newValue), setTimeout(() => {
4456
4432
  this.checkWarning_();
@@ -4748,8 +4724,7 @@ ${javascriptGenerator.statementToCode(e, "HANDLE")}}
4748
4724
  return genColumnOpts(this.space.id, this.table.id);
4749
4725
  },
4750
4726
  onchange: function(e) {
4751
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
4752
- else if (e.type === Events.BLOCK_CHANGE) {
4727
+ if (e.type === Events.BLOCK_CHANGE) {
4753
4728
  let y = e;
4754
4729
  y.blockId === this.id && y.element === "field" && (y.name === "SPACE" ? this.onSpaceChange_(y.newValue) : y.name === "TABLE" ? this.onTableChange_(y.newValue) : y.name === "COLUMN" && this.onColumnChange_(y.newValue)), setTimeout(() => {
4755
4730
  this.checkWarning_();
@@ -5269,8 +5244,7 @@ ${javascriptGenerator.statementToCode(e, "HANDLE")}}
5269
5244
  }), ensureOpts(e);
5270
5245
  },
5271
5246
  onchange: function(e) {
5272
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
5273
- else if (e.type === Events.BLOCK_CHANGE) {
5247
+ if (e.type === Events.BLOCK_CHANGE) {
5274
5248
  let y = e;
5275
5249
  if (y.blockId === this.id) {
5276
5250
  if (y.element === "field") {
@@ -5446,8 +5420,7 @@ ${javascriptGenerator.statementToCode(e, "HANDLE")}}
5446
5420
  return genTableOpts(this.space.id);
5447
5421
  },
5448
5422
  onchange: function(e) {
5449
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
5450
- else if (e.type === Events.BLOCK_CHANGE) {
5423
+ if (e.type === Events.BLOCK_CHANGE) {
5451
5424
  let y = e;
5452
5425
  y.blockId === this.id && (y.element === "field" && (y.name === "SPACE" ? this.onSpaceChange_(y.newValue) : y.name === "TABLE" && this.onTableChange_(y.newValue)), setTimeout(() => {
5453
5426
  this.checkWarning_();
@@ -5617,8 +5590,7 @@ ${y}}
5617
5590
  }), ensureOpts(e);
5618
5591
  },
5619
5592
  onchange: function(e) {
5620
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
5621
- else if (e.type === Events.BLOCK_CHANGE) {
5593
+ if (e.type === Events.BLOCK_CHANGE) {
5622
5594
  let y = e;
5623
5595
  if (y.blockId === this.id) {
5624
5596
  if (y.element === "field") {
@@ -7709,8 +7681,7 @@ Blocks.procedure_return_v1 = {
7709
7681
  }, 0);
7710
7682
  },
7711
7683
  onchange: function(e) {
7712
- if (e.type === CustomEventType.STATE_CHANGE) this.checkWarning_();
7713
- else if (e.type === Events.BLOCK_DRAG) {
7684
+ if (e.type === Events.BLOCK_DRAG) {
7714
7685
  let y = e;
7715
7686
  if (y.isStart || !y.blocks?.find((e) => e.id === this.id)) return;
7716
7687
  this.updateShape_(), setTimeout(() => {
@@ -8534,6 +8505,18 @@ var DisableTopBlocks = class {
8534
8505
  contextMenu: !0,
8535
8506
  shortcut: !0
8536
8507
  }), new DisableTopBlocks().init();
8508
+ let CustomEventType = /* @__PURE__ */ function(e) {
8509
+ return e.STATE_CHANGE = "state_change", e;
8510
+ }({});
8511
+ var StateChange = class extends Events.Abstract {
8512
+ isBlank = !0;
8513
+ recordUndo = !1;
8514
+ type = CustomEventType.STATE_CHANGE;
8515
+ constructor(e) {
8516
+ super(), this.workspaceId = e.id;
8517
+ }
8518
+ };
8519
+ registry.register(registry.Type.EVENT, CustomEventType.STATE_CHANGE, StateChange);
8537
8520
  function jumpTopBlock(e) {
8538
8521
  let y = getMainWorkspace();
8539
8522
  if (!y) return;
@@ -10098,6 +10081,13 @@ function createWorkspace(e, y, b, x) {
10098
10081
  options.theme = x ? "dark" : "light", options.toolbox = getToolbox(y, b);
10099
10082
  let S = inject$1(e, options);
10100
10083
  return S.addChangeListener((e) => {
10084
+ if (e.type === CustomEventType.STATE_CHANGE) {
10085
+ let e = S.getAllBlocks();
10086
+ for (let y of e) {
10087
+ let e = y;
10088
+ e.checkWarning_ && e.checkWarning_();
10089
+ }
10090
+ }
10101
10091
  setTimeout(() => {
10102
10092
  (0, import_dist.shadowBlockConversionChangeListener)(e);
10103
10093
  }, 0);
@@ -10288,7 +10278,7 @@ var _hoisted_1$1 = { class: "position-relative w-100 h-100" }, blockly_default =
10288
10278
  }, Y = () => {
10289
10279
  j.workspace.setScale(C.value);
10290
10280
  }, X = () => {
10291
- j.workspace.fireChangeListener(new StateChange());
10281
+ Events.fire(new (Events.get(CustomEventType.STATE_CHANGE))(j.workspace));
10292
10282
  }, Z = () => {
10293
10283
  k.value?.cleanWorkspace();
10294
10284
  }, Q = () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-block-lib",
3
3
  "private": false,
4
- "version": "0.10.1",
4
+ "version": "0.10.3",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -28,43 +28,43 @@
28
28
  "@blockly/shadow-block-converter": "^7.0.9",
29
29
  "@highlightjs/vue-plugin": "^2.1.0",
30
30
  "@sindresorhus/base62": "^1.0.0",
31
- "@vueuse/core": "^14.1.0",
32
- "axios": "^1.13.2",
31
+ "@vueuse/core": "^14.2.0",
32
+ "axios": "^1.13.4",
33
33
  "blockly": "^12.3.1",
34
34
  "highlight.js": "^11.11.1",
35
- "lodash-es": "^4.17.22",
35
+ "lodash-es": "^4.17.23",
36
36
  "vue": "^3.5.27",
37
37
  "vue-draggable-plus": "^0.6.1",
38
38
  "vue-i18n": "^11.2.8",
39
- "vue-router": "^4.6.4",
40
- "vuetify": "^3.11.7"
39
+ "vue-router": "^5.0.2",
40
+ "vuetify": "^3.11.8"
41
41
  },
42
42
  "peerDependencies": {
43
- "x-essential-lib": "^0.9.24",
44
- "x-runtime-lib": "^0.8.209",
45
- "x-state-lib": "^0.3.38"
43
+ "x-essential-lib": "^0.9.25",
44
+ "x-runtime-lib": "^0.8.213",
45
+ "x-state-lib": "^0.3.39"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@eslint/js": "^9.39.2",
49
49
  "@types/lodash-es": "^4.17.12",
50
- "@types/node": "^25.0.9",
51
- "@vitejs/plugin-vue": "^6.0.3",
50
+ "@types/node": "^25.2.0",
51
+ "@vitejs/plugin-vue": "^6.0.4",
52
52
  "eslint": "^9.39.2",
53
53
  "eslint-config-prettier": "^10.1.8",
54
54
  "eslint-plugin-prettier": "^5.5.5",
55
55
  "eslint-plugin-vue": "^10.7.0",
56
- "globals": "^17.0.0",
56
+ "globals": "^17.3.0",
57
57
  "husky": "^9.1.7",
58
58
  "lint-staged": "^16.2.7",
59
- "prettier": "3.8.0",
60
- "sass": "^1.97.2",
59
+ "prettier": "3.8.1",
60
+ "sass": "^1.97.3",
61
61
  "typescript": "^5.9.3",
62
- "typescript-eslint": "^8.53.1",
62
+ "typescript-eslint": "^8.54.0",
63
63
  "vite": "npm:rolldown-vite@7.3.1",
64
64
  "vite-plugin-css-injected-by-js": "^3.5.2",
65
65
  "vite-plugin-vuetify": "^2.1.3",
66
66
  "vue-eslint-parser": "^10.2.0",
67
- "vue-tsc": "^3.2.2"
67
+ "vue-tsc": "^3.2.4"
68
68
  },
69
69
  "overrides": {
70
70
  "vite": "npm:rolldown-vite@7.3.1"