x-block-lib 0.5.18 → 0.5.19
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
|
|
233
|
-
return e.getBlockById(
|
|
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
|
|
239
|
-
const [o, i, s] = n,
|
|
240
|
-
if (!
|
|
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
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
242
|
+
let c = l.targetBlock();
|
|
243
|
+
if (c) {
|
|
244
|
+
const _ = c;
|
|
245
|
+
if (_ && _.key === i && _.name === s)
|
|
246
246
|
return;
|
|
247
|
-
|
|
247
|
+
c.dispose();
|
|
248
248
|
}
|
|
249
|
-
|
|
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();
|
|
@@ -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,7 @@ 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(this.workspace, this.key, this.name, this.locale);
|
|
354
360
|
o.connect(i.outputConnection);
|
|
355
361
|
}
|
|
356
362
|
} finally {
|
|
@@ -358,7 +364,7 @@ const Yl = {
|
|
|
358
364
|
}
|
|
359
365
|
},
|
|
360
366
|
updateShape_: function() {
|
|
361
|
-
this.
|
|
367
|
+
this.locale ? this.setFieldValue(g[this.name], "LABEL") : this.setFieldValue(this.name, "LABEL");
|
|
362
368
|
}
|
|
363
369
|
};
|
|
364
370
|
D.parameter_v1 = Yl;
|
|
@@ -1238,8 +1244,8 @@ const W_ = {
|
|
|
1238
1244
|
return;
|
|
1239
1245
|
const e = [];
|
|
1240
1246
|
for (let t = 0; t < this.func.outputs.length; t++) {
|
|
1241
|
-
const {
|
|
1242
|
-
e.push(["OUTPUT" + t, n,
|
|
1247
|
+
const { id: n, name: o } = this.func.outputs[t];
|
|
1248
|
+
e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
|
|
1243
1249
|
}
|
|
1244
1250
|
Pe(this, e);
|
|
1245
1251
|
},
|
|
@@ -1382,8 +1388,8 @@ const j_ = {
|
|
|
1382
1388
|
return;
|
|
1383
1389
|
const e = [];
|
|
1384
1390
|
for (let t = 0; t < this.func.outputs.length; t++) {
|
|
1385
|
-
const {
|
|
1386
|
-
e.push(["OUTPUT" + t, n,
|
|
1391
|
+
const { id: n, name: o } = this.func.outputs[t];
|
|
1392
|
+
e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
|
|
1387
1393
|
}
|
|
1388
1394
|
Pe(this, e);
|
|
1389
1395
|
},
|
|
@@ -1503,7 +1509,7 @@ const X_ = {
|
|
|
1503
1509
|
const e = [];
|
|
1504
1510
|
for (let t = 0; t < this.func.inputs.length; t++) {
|
|
1505
1511
|
const { id: n, name: o } = this.func.inputs[t];
|
|
1506
|
-
e.push(["INPUT" + t, n,
|
|
1512
|
+
e.push(["INPUT" + t, `__param@${n}__`, o, !1]);
|
|
1507
1513
|
}
|
|
1508
1514
|
Pe(this, e);
|
|
1509
1515
|
},
|
|
@@ -1658,9 +1664,9 @@ const J_ = {
|
|
|
1658
1664
|
},
|
|
1659
1665
|
rebuildBlocks_: function() {
|
|
1660
1666
|
this.isInsertionMarker() || Pe(this, [
|
|
1661
|
-
["SUCCESS", "__success__", "PARAM_SUCCESS"],
|
|
1662
|
-
["MESSAGE", "__message__", "PARAM_MESSAGE"],
|
|
1663
|
-
["DATA", "__data__", "PARAM_DATA"]
|
|
1667
|
+
["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
|
|
1668
|
+
["MESSAGE", "__message__", "PARAM_MESSAGE", !0],
|
|
1669
|
+
["DATA", "__data__", "PARAM_DATA", !0]
|
|
1664
1670
|
]);
|
|
1665
1671
|
}
|
|
1666
1672
|
};
|
|
@@ -1979,8 +1985,8 @@ const nd = {
|
|
|
1979
1985
|
},
|
|
1980
1986
|
rebuildBlocks_: function() {
|
|
1981
1987
|
this.isInsertionMarker() || Pe(this, [
|
|
1982
|
-
["SUCCESS", "__success__", "PARAM_SUCCESS"],
|
|
1983
|
-
["MESSAGE", "__message__", "PARAM_MESSAGE"]
|
|
1988
|
+
["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
|
|
1989
|
+
["MESSAGE", "__message__", "PARAM_MESSAGE", !0]
|
|
1984
1990
|
]);
|
|
1985
1991
|
}
|
|
1986
1992
|
};
|
|
@@ -2038,10 +2044,10 @@ const od = {
|
|
|
2038
2044
|
},
|
|
2039
2045
|
rebuildBlocks_: function() {
|
|
2040
2046
|
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"]
|
|
2047
|
+
["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
|
|
2048
|
+
["MESSAGE", "__message__", "PARAM_MESSAGE", !0],
|
|
2049
|
+
["MAIN_DATA", "__mainData__", "PARAM_MAIN_DATA", !0],
|
|
2050
|
+
["EXTRA_DATA", "__extraData__", "PARAM_EXTRA_DATA", !0]
|
|
2045
2051
|
]);
|
|
2046
2052
|
}
|
|
2047
2053
|
};
|
|
@@ -2674,9 +2680,9 @@ const pd = {
|
|
|
2674
2680
|
},
|
|
2675
2681
|
rebuildBlocks_: function() {
|
|
2676
2682
|
this.isInsertionMarker() || Pe(this, [
|
|
2677
|
-
["SUCCESS", "__success__", "PARAM_SUCCESS"],
|
|
2678
|
-
["MESSAGE", "__message__", "PARAM_MESSAGE"],
|
|
2679
|
-
["DATA", "__data__", "PARAM_DATA"]
|
|
2683
|
+
["SUCCESS", "__success__", "PARAM_SUCCESS", !0],
|
|
2684
|
+
["MESSAGE", "__message__", "PARAM_MESSAGE", !0],
|
|
2685
|
+
["DATA", "__data__", "PARAM_DATA", !0]
|
|
2680
2686
|
]);
|
|
2681
2687
|
}
|
|
2682
2688
|
};
|
|
@@ -4771,10 +4777,10 @@ const Sd = {
|
|
|
4771
4777
|
const t = this.args[e], n = this.getInput("ARG" + e).connection;
|
|
4772
4778
|
let o = n.targetBlock();
|
|
4773
4779
|
if (o)
|
|
4774
|
-
o.setKeyName(t.name,
|
|
4780
|
+
o.setKeyName(`__param@${t.id}__`, t.name, !1);
|
|
4775
4781
|
else
|
|
4776
4782
|
try {
|
|
4777
|
-
P.disable(), o = Ui(this.workspace, t.name,
|
|
4783
|
+
P.disable(), o = Ui(this.workspace, `__param@${t.id}__`, t.name, !1), o.outputConnection.connect(n);
|
|
4778
4784
|
} finally {
|
|
4779
4785
|
P.enable();
|
|
4780
4786
|
}
|
|
@@ -5811,8 +5817,8 @@ const Kd = {
|
|
|
5811
5817
|
return;
|
|
5812
5818
|
const e = [];
|
|
5813
5819
|
for (let t = 0; t < this.method.outputs.length; t++) {
|
|
5814
|
-
const n = this.method.outputs[t];
|
|
5815
|
-
e.push(["OUTPUT" + t, n
|
|
5820
|
+
const { key: n, name: o } = this.method.outputs[t];
|
|
5821
|
+
e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
|
|
5816
5822
|
}
|
|
5817
5823
|
e.length > 0 && Pe(this, e);
|
|
5818
5824
|
},
|
|
@@ -5995,8 +6001,8 @@ const Hd = {
|
|
|
5995
6001
|
return;
|
|
5996
6002
|
const e = [];
|
|
5997
6003
|
for (let t = 0; t < this.method.outputs.length; t++) {
|
|
5998
|
-
const n = this.method.outputs[t];
|
|
5999
|
-
e.push(["OUTPUT" + t, n
|
|
6004
|
+
const { key: n, name: o } = this.method.outputs[t];
|
|
6005
|
+
e.push(["OUTPUT" + t, `__param@${n}__`, o, !1]);
|
|
6000
6006
|
}
|
|
6001
6007
|
e.length > 0 && Pe(this, e);
|
|
6002
6008
|
},
|
|
@@ -6156,7 +6162,7 @@ const jd = {
|
|
|
6156
6162
|
const e = [];
|
|
6157
6163
|
for (let t = 0; t < this.method.inputs.length; t++) {
|
|
6158
6164
|
const { id: n, name: o } = this.method.inputs[t];
|
|
6159
|
-
e.push(["INPUT" + t, n,
|
|
6165
|
+
e.push(["INPUT" + t, `__param@${n}__`, o, !1]);
|
|
6160
6166
|
}
|
|
6161
6167
|
Pe(this, e);
|
|
6162
6168
|
},
|
|
@@ -6744,7 +6750,7 @@ const oh = {
|
|
|
6744
6750
|
return;
|
|
6745
6751
|
const e = [];
|
|
6746
6752
|
this.event.params.forEach(({ key: t, name: n }, o) => {
|
|
6747
|
-
e.push(["PARAM" + o, t,
|
|
6753
|
+
e.push(["PARAM" + o, `__param@${t}__`, n, !1]);
|
|
6748
6754
|
}), e.length > 0 && Pe(this, e);
|
|
6749
6755
|
},
|
|
6750
6756
|
checkWarning_: function() {
|
|
@@ -6878,7 +6884,7 @@ const ih = {
|
|
|
6878
6884
|
return;
|
|
6879
6885
|
const e = [];
|
|
6880
6886
|
this.event.params.forEach(({ key: t, name: n }, o) => {
|
|
6881
|
-
e.push(["PARAM" + o, n,
|
|
6887
|
+
e.push(["PARAM" + o, `__param@${t}__`, n, !1]);
|
|
6882
6888
|
}), e.length > 0 && Pe(this, e);
|
|
6883
6889
|
},
|
|
6884
6890
|
checkWarning_: function() {
|
|
@@ -6936,10 +6942,8 @@ const sh = {
|
|
|
6936
6942
|
this.getInput("TEXT").connection.setShadowDom(t);
|
|
6937
6943
|
},
|
|
6938
6944
|
rebuildBlocks_: function() {
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
Pe(this, [
|
|
6942
|
-
["RESULT", "__result__", "PARAM_RESULT"]
|
|
6945
|
+
this.isInsertionMarker() || Pe(this, [
|
|
6946
|
+
["RESULT", "__result__", "PARAM_RESULT", !1]
|
|
6943
6947
|
]);
|
|
6944
6948
|
}
|
|
6945
6949
|
};
|
|
@@ -6977,10 +6981,8 @@ const ah = {
|
|
|
6977
6981
|
this.getInput("VALUE").connection.setShadowDom(n);
|
|
6978
6982
|
},
|
|
6979
6983
|
rebuildBlocks_: function() {
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
Pe(this, [
|
|
6983
|
-
["RESULT", "__result__", "PARAM_RESULT"]
|
|
6984
|
+
this.isInsertionMarker() || Pe(this, [
|
|
6985
|
+
["RESULT", "__result__", "PARAM_RESULT", !1]
|
|
6984
6986
|
]);
|
|
6985
6987
|
}
|
|
6986
6988
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-block-lib",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.19",
|
|
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.
|
|
35
|
+
"x-runtime-lib": "^0.5.35",
|
|
36
36
|
"x-state-lib": "^0.1.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|