x-block-lib 0.5.18 → 0.5.20

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.
@@ -3,6 +3,7 @@ type ParameterV1Type = typeof PARAMETER_V1;
3
3
  interface ParameterV1 extends ParameterV1Type {
4
4
  key: string;
5
5
  name: string;
6
+ locale: boolean;
6
7
  }
7
8
  export type ParameterBlockV1 = Blockly.Block & ParameterV1;
8
9
  declare const PARAMETER_V1: {
@@ -12,9 +13,10 @@ declare const PARAMETER_V1: {
12
13
  saveExtraState: (this: ParameterBlockV1) => {
13
14
  key: string;
14
15
  name: string;
16
+ locale: boolean;
15
17
  };
16
18
  loadExtraState: (this: ParameterBlockV1, state: any) => void;
17
- setKeyName: (this: ParameterBlockV1, key: string, name: string) => void;
19
+ setKeyName: (this: ParameterBlockV1, key: string, name: string, locale: boolean) => void;
18
20
  onchange: (this: ParameterBlockV1, event: Blockly.Events.Abstract) => void;
19
21
  tryDuplicate_: (this: ParameterBlockV1, event: Blockly.Events.BlockMove) => void;
20
22
  updateShape_: (this: ParameterBlockV1) => void;
@@ -4,5 +4,5 @@ export declare function genParamShadowV1(param: {
4
4
  type: 'string' | 'number' | 'boolean';
5
5
  default: unknown;
6
6
  }): Element;
7
- export declare function spawnParameterBlockV1(workspace: Blockly.Workspace, key: string, name: string): Blockly.Block;
8
- export declare function ensureParameterBlockV1s(scope: Blockly.Block, params: [string, string, string][]): void;
7
+ export declare function spawnParameterBlockV1(workspace: Blockly.Workspace, key: string, name: string, locale: boolean): Blockly.Block;
8
+ export declare function ensureParameterBlockV1s(scope: Blockly.Block, params: [string, string, string, boolean][]): void;
package/dist/index.js CHANGED
@@ -228,25 +228,30 @@ function pe(e) {
228
228
  console.assert(!1, "invalid param type", e.type);
229
229
  return I.xml.textToDom(t);
230
230
  }
231
- function Ui(e, t, n) {
232
- const o = `<xml><block type="parameter_v1"><mutation key="${t}" name="${n}"/></block></xml>`, i = I.xml.textToDom(o), s = cl.domToWorkspace(i, e);
233
- return e.getBlockById(s[0]);
231
+ function Ui(e, t, n, o) {
232
+ const i = `<xml><block type="parameter_v1"><mutation key="${t}" name="${n}" locale="${o ? "TRUE" : "FALSE"}"/></block></xml>`, s = I.xml.textToDom(i), a = cl.domToWorkspace(s, e);
233
+ return e.getBlockById(a[0]);
234
234
  }
235
235
  function Pe(e, t) {
236
236
  try {
237
237
  P.disable(), t.forEach((n) => {
238
- var c;
239
- const [o, i, s] = n, a = (c = e.getInput(o)) == null ? void 0 : c.connection;
240
- if (!a)
238
+ var p;
239
+ const [o, i, s, a] = n, l = (p = e.getInput(o)) == null ? void 0 : p.connection;
240
+ if (!l)
241
241
  return;
242
- let l = a.targetBlock();
243
- if (l) {
244
- const p = l;
245
- if (p && p.key === i && p.name === s)
242
+ let c = l.targetBlock();
243
+ if (c) {
244
+ const _ = c;
245
+ if (_ && _.key === i && _.name === s)
246
246
  return;
247
- l.dispose();
247
+ c.dispose();
248
248
  }
249
- l = Ui(e.workspace, i, s), l.outputConnection.connect(a);
249
+ c = Ui(
250
+ e.workspace,
251
+ i,
252
+ s,
253
+ a
254
+ ), c.outputConnection.connect(l);
250
255
  });
251
256
  } finally {
252
257
  P.enable();
@@ -299,7 +304,7 @@ const wl = I.xml, Vl = [
299
304
  },
300
305
  {
301
306
  type: "query_data_v1",
302
- inputs: ["SUCCESS", "MESSAGE", "MAINDATA", "EXTRADATA"]
307
+ inputs: ["SUCCESS", "MESSAGE", "MAIN_DATA", "EXTRA_DATA"]
303
308
  },
304
309
  {
305
310
  type: "update_data_v1",
@@ -313,26 +318,27 @@ function Fl(e, t) {
313
318
  }
314
319
  const Yl = {
315
320
  init: function() {
316
- this.key = "", this.name = "", this.appendDummyInput().appendField("", "LABEL"), this.setOutput(!0), this.setColour(220);
321
+ this.key = "", this.name = "", this.locale = !1, this.appendDummyInput().appendField("", "LABEL"), this.setOutput(!0), this.setColour(220);
317
322
  },
318
323
  mutationToDom: function() {
319
324
  const e = wl.createElement("mutation");
320
- return e.setAttribute("key", this.key), e.setAttribute("name", this.name), e;
325
+ return e.setAttribute("key", this.key), e.setAttribute("name", this.name), e.setAttribute("locale", this.locale ? "TRUE" : "FALSE"), e;
321
326
  },
322
327
  domToMutation: function(e) {
323
- this.key = e.getAttribute("key") ?? "", this.name = e.getAttribute("name") ?? "", this.updateShape_();
328
+ this.key = e.getAttribute("key") ?? "", this.name = e.getAttribute("name") ?? "", this.locale = e.getAttribute("locale") === "TRUE", this.updateShape_();
324
329
  },
325
330
  saveExtraState: function() {
326
331
  return {
327
332
  key: this.key,
328
- name: this.name
333
+ name: this.name,
334
+ locale: this.locale
329
335
  };
330
336
  },
331
337
  loadExtraState: function(e) {
332
- this.key = e.key ?? "", this.name = e.name ?? "", this.updateShape_();
338
+ this.key = e.key ?? "", this.name = e.name ?? "", this.locale = e.locale ?? !1, this.updateShape_();
333
339
  },
334
- setKeyName: function(e, t) {
335
- this.key = e, this.name = t, this.updateShape_();
340
+ setKeyName: function(e, t, n) {
341
+ this.key = e, this.name = t, this.locale = n, this.updateShape_();
336
342
  },
337
343
  onchange: function(e) {
338
344
  if (e.type === P.BLOCK_MOVE) {
@@ -350,7 +356,12 @@ const Yl = {
350
356
  P.disable();
351
357
  const o = (n = t.getInput(e.oldInputName)) == null ? void 0 : n.connection;
352
358
  if (o) {
353
- const i = Ui(this.workspace, this.key, this.name);
359
+ const i = Ui(
360
+ this.workspace,
361
+ this.key,
362
+ this.name,
363
+ this.locale
364
+ );
354
365
  o.connect(i.outputConnection);
355
366
  }
356
367
  } finally {
@@ -358,7 +369,7 @@ const Yl = {
358
369
  }
359
370
  },
360
371
  updateShape_: function() {
361
- this.name ? this.setFieldValue(g[this.name], "LABEL") : this.setFieldValue(this.key, "LABEL");
372
+ this.locale ? this.setFieldValue(g[this.name], "LABEL") : this.setFieldValue(this.name, "LABEL");
362
373
  }
363
374
  };
364
375
  D.parameter_v1 = Yl;
@@ -1238,8 +1249,8 @@ const W_ = {
1238
1249
  return;
1239
1250
  const e = [];
1240
1251
  for (let t = 0; t < this.func.outputs.length; t++) {
1241
- const { name: n } = this.func.outputs[t];
1242
- e.push(["OUTPUT" + t, n, ""]);
1252
+ const { id: n, name: o } = this.func.outputs[t];
1253
+ e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
1243
1254
  }
1244
1255
  Pe(this, e);
1245
1256
  },
@@ -1382,8 +1393,8 @@ const j_ = {
1382
1393
  return;
1383
1394
  const e = [];
1384
1395
  for (let t = 0; t < this.func.outputs.length; t++) {
1385
- const { name: n } = this.func.outputs[t];
1386
- e.push(["OUTPUT" + t, n, ""]);
1396
+ const { id: n, name: o } = this.func.outputs[t];
1397
+ e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
1387
1398
  }
1388
1399
  Pe(this, e);
1389
1400
  },
@@ -1503,7 +1514,7 @@ const X_ = {
1503
1514
  const e = [];
1504
1515
  for (let t = 0; t < this.func.inputs.length; t++) {
1505
1516
  const { id: n, name: o } = this.func.inputs[t];
1506
- e.push(["INPUT" + t, n, o]);
1517
+ e.push(["INPUT" + t, `__param@${n}__`, o, !1]);
1507
1518
  }
1508
1519
  Pe(this, e);
1509
1520
  },
@@ -1658,9 +1669,9 @@ const J_ = {
1658
1669
  },
1659
1670
  rebuildBlocks_: function() {
1660
1671
  this.isInsertionMarker() || Pe(this, [
1661
- ["SUCCESS", "__success__", "PARAM_SUCCESS"],
1662
- ["MESSAGE", "__message__", "PARAM_MESSAGE"],
1663
- ["DATA", "__data__", "PARAM_DATA"]
1672
+ ["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
1673
+ ["MESSAGE", "__message__", "PARAM_MESSAGE", !0],
1674
+ ["DATA", "__data__", "PARAM_DATA", !0]
1664
1675
  ]);
1665
1676
  }
1666
1677
  };
@@ -1979,8 +1990,8 @@ const nd = {
1979
1990
  },
1980
1991
  rebuildBlocks_: function() {
1981
1992
  this.isInsertionMarker() || Pe(this, [
1982
- ["SUCCESS", "__success__", "PARAM_SUCCESS"],
1983
- ["MESSAGE", "__message__", "PARAM_MESSAGE"]
1993
+ ["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
1994
+ ["MESSAGE", "__message__", "PARAM_MESSAGE", !0]
1984
1995
  ]);
1985
1996
  }
1986
1997
  };
@@ -2038,10 +2049,10 @@ const od = {
2038
2049
  },
2039
2050
  rebuildBlocks_: function() {
2040
2051
  this.isInsertionMarker() || Pe(this, [
2041
- ["SUCCESS", "__success__", "PARAM_SUCCESS"],
2042
- ["MESSAGE", "__message__", "PARAM_MESSAGE"],
2043
- ["MAIN_DATA", "__mainData__", "PARAM_MAIN_DATA"],
2044
- ["EXTRA_DATA", "__extraData__", "PARAM_EXTRA_DATA"]
2052
+ ["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
2053
+ ["MESSAGE", "__message__", "PARAM_MESSAGE", !0],
2054
+ ["MAIN_DATA", "__mainData__", "PARAM_MAIN_DATA", !0],
2055
+ ["EXTRA_DATA", "__extraData__", "PARAM_EXTRA_DATA", !0]
2045
2056
  ]);
2046
2057
  }
2047
2058
  };
@@ -2674,9 +2685,9 @@ const pd = {
2674
2685
  },
2675
2686
  rebuildBlocks_: function() {
2676
2687
  this.isInsertionMarker() || Pe(this, [
2677
- ["SUCCESS", "__success__", "PARAM_SUCCESS"],
2678
- ["MESSAGE", "__message__", "PARAM_MESSAGE"],
2679
- ["DATA", "__data__", "PARAM_DATA"]
2688
+ ["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
2689
+ ["MESSAGE", "__message__", "PARAM_MESSAGE", !0],
2690
+ ["DATA", "__data__", "PARAM_DATA", !0]
2680
2691
  ]);
2681
2692
  }
2682
2693
  };
@@ -4771,10 +4782,15 @@ const Sd = {
4771
4782
  const t = this.args[e], n = this.getInput("ARG" + e).connection;
4772
4783
  let o = n.targetBlock();
4773
4784
  if (o)
4774
- o.setKeyName(t.name, "");
4785
+ o.setKeyName(`__param@${t.id}__`, t.name, !1);
4775
4786
  else
4776
4787
  try {
4777
- P.disable(), o = Ui(this.workspace, t.name, ""), o.outputConnection.connect(n);
4788
+ P.disable(), o = Ui(
4789
+ this.workspace,
4790
+ `__param@${t.id}__`,
4791
+ t.name,
4792
+ !1
4793
+ ), o.outputConnection.connect(n);
4778
4794
  } finally {
4779
4795
  P.enable();
4780
4796
  }
@@ -5811,8 +5827,8 @@ const Kd = {
5811
5827
  return;
5812
5828
  const e = [];
5813
5829
  for (let t = 0; t < this.method.outputs.length; t++) {
5814
- const n = this.method.outputs[t];
5815
- e.push(["OUTPUT" + t, n.key, n.name]);
5830
+ const { key: n, name: o } = this.method.outputs[t];
5831
+ e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
5816
5832
  }
5817
5833
  e.length > 0 && Pe(this, e);
5818
5834
  },
@@ -5995,8 +6011,8 @@ const Hd = {
5995
6011
  return;
5996
6012
  const e = [];
5997
6013
  for (let t = 0; t < this.method.outputs.length; t++) {
5998
- const n = this.method.outputs[t];
5999
- e.push(["OUTPUT" + t, n.key, n.name]);
6014
+ const { key: n, name: o } = this.method.outputs[t];
6015
+ e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
6000
6016
  }
6001
6017
  e.length > 0 && Pe(this, e);
6002
6018
  },
@@ -6156,7 +6172,7 @@ const jd = {
6156
6172
  const e = [];
6157
6173
  for (let t = 0; t < this.method.inputs.length; t++) {
6158
6174
  const { id: n, name: o } = this.method.inputs[t];
6159
- e.push(["INPUT" + t, n, o]);
6175
+ e.push(["INPUT" + t, `__param@${n}__`, o, !1]);
6160
6176
  }
6161
6177
  Pe(this, e);
6162
6178
  },
@@ -6744,7 +6760,7 @@ const oh = {
6744
6760
  return;
6745
6761
  const e = [];
6746
6762
  this.event.params.forEach(({ key: t, name: n }, o) => {
6747
- e.push(["PARAM" + o, t, n]);
6763
+ e.push(["PARAM" + o, `__param@${t}__`, n, !1]);
6748
6764
  }), e.length > 0 && Pe(this, e);
6749
6765
  },
6750
6766
  checkWarning_: function() {
@@ -6878,7 +6894,7 @@ const ih = {
6878
6894
  return;
6879
6895
  const e = [];
6880
6896
  this.event.params.forEach(({ key: t, name: n }, o) => {
6881
- e.push(["PARAM" + o, n, t]);
6897
+ e.push(["PARAM" + o, `__param@${t}__`, n, !1]);
6882
6898
  }), e.length > 0 && Pe(this, e);
6883
6899
  },
6884
6900
  checkWarning_: function() {
@@ -6936,10 +6952,8 @@ const sh = {
6936
6952
  this.getInput("TEXT").connection.setShadowDom(t);
6937
6953
  },
6938
6954
  rebuildBlocks_: function() {
6939
- if (this.isInsertionMarker())
6940
- return;
6941
- Pe(this, [
6942
- ["RESULT", "__result__", "PARAM_RESULT"]
6955
+ this.isInsertionMarker() || Pe(this, [
6956
+ ["RESULT", "__result__", "PARAM_RESULT", !1]
6943
6957
  ]);
6944
6958
  }
6945
6959
  };
@@ -6977,10 +6991,8 @@ const ah = {
6977
6991
  this.getInput("VALUE").connection.setShadowDom(n);
6978
6992
  },
6979
6993
  rebuildBlocks_: function() {
6980
- if (this.isInsertionMarker())
6981
- return;
6982
- Pe(this, [
6983
- ["RESULT", "__result__", "PARAM_RESULT"]
6994
+ this.isInsertionMarker() || Pe(this, [
6995
+ ["RESULT", "__result__", "PARAM_RESULT", !1]
6984
6996
  ]);
6985
6997
  }
6986
6998
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-block-lib",
3
3
  "private": false,
4
- "version": "0.5.18",
4
+ "version": "0.5.20",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "vue-draggable-plus": "^0.5.4",
33
33
  "vuetify": "^3.7.3",
34
34
  "x-essential-lib": "^0.7.11",
35
- "x-runtime-lib": "^0.5.34",
35
+ "x-runtime-lib": "^0.5.35",
36
36
  "x-state-lib": "^0.1.6"
37
37
  },
38
38
  "devDependencies": {