x-block-lib 0.6.24 → 0.6.26
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,7 @@
|
|
|
1
|
+
import * as Blockly from 'blockly/core';
|
|
2
|
+
export declare function spawnTextBlockV1(workspace: Blockly.Workspace, value: string): Blockly.Block;
|
|
3
|
+
export declare function spawnMathNumberBlockV1(workspace: Blockly.Workspace, value: number): Blockly.Block;
|
|
4
|
+
export declare function spawnLogicBooleanBlockV1(workspace: Blockly.Workspace, value: boolean): Blockly.Block;
|
|
5
|
+
export declare function spawnItemsBlockV1(workspace: Blockly.Workspace, items: string): Blockly.Block;
|
|
6
|
+
export declare function spawnTypesBlockV1(workspace: Blockly.Workspace, types: string): Blockly.Block;
|
|
7
|
+
export declare function spawnSelectCompBlockV1(workspace: Blockly.Workspace): Blockly.Block;
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export declare function ensureOpts(options: Blockly.MenuOption[]): Blockly.MenuOption[];
|
|
5
|
-
export declare function genParamShadowV1(param: {
|
|
6
|
-
type: 'string' | 'number' | 'boolean' | 'comp';
|
|
7
|
-
default: unknown;
|
|
8
|
-
}): Element;
|
|
9
|
-
export declare function spawnParameterBlockV1(workspace: Blockly.Workspace, key: string, name: string, locale: boolean): Blockly.Block;
|
|
10
|
-
export declare function ensureParameterBlockV1s(scope: Blockly.Block, params: [string, string, string, boolean][]): void;
|
|
11
|
-
export declare function spawnTextBlockV1(workspace: Blockly.Workspace, value: string): Blockly.Block;
|
|
12
|
-
export declare function spawnMathNumberBlockV1(workspace: Blockly.Workspace, value: number): Blockly.Block;
|
|
13
|
-
export declare function spawnLogicBooleanBlockV1(workspace: Blockly.Workspace, value: boolean): Blockly.Block;
|
|
14
|
-
export declare function spawnItemsBlockV1(workspace: Blockly.Workspace, items: string): Blockly.Block;
|
|
15
|
-
export declare function spawnTypesBlockV1(workspace: Blockly.Workspace, types: string): Blockly.Block;
|
|
16
|
-
export declare function spawnSelectCompBlockV1(workspace: Blockly.Workspace): Blockly.Block;
|
|
1
|
+
export * from './block';
|
|
2
|
+
export * from './misc';
|
|
3
|
+
export * from './parameter';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Blockly from 'blockly/core';
|
|
2
|
+
export declare function toBlockType(key: string): string;
|
|
3
|
+
export declare function toCheck(key: string): string;
|
|
4
|
+
export declare function ensureOpts(options: Blockly.MenuOption[]): Blockly.MenuOption[];
|
|
5
|
+
export declare function genParamShadowV1(param: {
|
|
6
|
+
type: 'string' | 'number' | 'boolean' | 'comp';
|
|
7
|
+
default: unknown;
|
|
8
|
+
}): Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as Blockly from 'blockly/core';
|
|
2
|
+
export declare function spawnParameterBlockV1(workspace: Blockly.Workspace, key: string, name: string, locale: boolean): Blockly.Block;
|
|
3
|
+
export declare function ensureParameterBlockV1s(scope: Blockly.Block, params: [string, string, string, boolean][]): void;
|
package/dist/index.js
CHANGED
|
@@ -1135,19 +1135,95 @@ function Te(e) {
|
|
|
1135
1135
|
let t = "";
|
|
1136
1136
|
if (e.type === "string") {
|
|
1137
1137
|
let n = "";
|
|
1138
|
-
typeof e.default == "string" && (n = e.default), t =
|
|
1138
|
+
typeof e.default == "string" && (n = e.default), t = `
|
|
1139
|
+
<shadow type="text_v1">
|
|
1140
|
+
<field name="TEXT">
|
|
1141
|
+
${n}
|
|
1142
|
+
</field>
|
|
1143
|
+
</shadow>
|
|
1144
|
+
`;
|
|
1139
1145
|
} else if (e.type === "number") {
|
|
1140
1146
|
let n = 0;
|
|
1141
|
-
typeof e.default == "number" && (n = e.default), t =
|
|
1147
|
+
typeof e.default == "number" && (n = e.default), t = `
|
|
1148
|
+
<shadow type="math_number_v1">
|
|
1149
|
+
<field name="NUM">
|
|
1150
|
+
${n}
|
|
1151
|
+
</field>
|
|
1152
|
+
</shadow>
|
|
1153
|
+
`;
|
|
1142
1154
|
} else if (e.type === "boolean") {
|
|
1143
1155
|
let n = "FALSE";
|
|
1144
|
-
typeof e.default == "boolean" && (n = e.default ? "TRUE" : "FALSE"), t =
|
|
1145
|
-
|
|
1156
|
+
typeof e.default == "boolean" && (n = e.default ? "TRUE" : "FALSE"), t = `
|
|
1157
|
+
<shadow type="logic_boolean_v1">
|
|
1158
|
+
<field name="BOOL">
|
|
1159
|
+
${n}
|
|
1160
|
+
</field>
|
|
1161
|
+
</shadow>
|
|
1162
|
+
`;
|
|
1163
|
+
} else e.type === "comp" ? t = `
|
|
1164
|
+
<shadow type="select_comp_v1">
|
|
1165
|
+
</shadow>
|
|
1166
|
+
` : console.assert(!1, "invalid param type", e.type);
|
|
1146
1167
|
return W.xml.textToDom(t);
|
|
1147
1168
|
}
|
|
1169
|
+
function kr(e, t) {
|
|
1170
|
+
const n = `
|
|
1171
|
+
<block type="text_v1">
|
|
1172
|
+
<field name="TEXT">
|
|
1173
|
+
${t}
|
|
1174
|
+
</field>
|
|
1175
|
+
</block>
|
|
1176
|
+
`, o = W.xml.textToDom(n);
|
|
1177
|
+
return zt.domToBlock(o, e);
|
|
1178
|
+
}
|
|
1179
|
+
function Nr(e, t) {
|
|
1180
|
+
const n = `
|
|
1181
|
+
<block type="math_number_v1">
|
|
1182
|
+
<field name="NUM">
|
|
1183
|
+
${t}
|
|
1184
|
+
</field>
|
|
1185
|
+
</block>
|
|
1186
|
+
`, o = W.xml.textToDom(n);
|
|
1187
|
+
return zt.domToBlock(o, e);
|
|
1188
|
+
}
|
|
1189
|
+
function Sr(e, t) {
|
|
1190
|
+
const o = `
|
|
1191
|
+
<block type="logic_boolean_v1">
|
|
1192
|
+
<field name="BOOL">
|
|
1193
|
+
${t ? "TRUE" : "FALSE"}
|
|
1194
|
+
</field>
|
|
1195
|
+
</block>
|
|
1196
|
+
`, i = W.xml.textToDom(o);
|
|
1197
|
+
return zt.domToBlock(i, e);
|
|
1198
|
+
}
|
|
1199
|
+
function Lr(e, t) {
|
|
1200
|
+
const o = `
|
|
1201
|
+
<block type="${jo(t)}">
|
|
1202
|
+
</block>
|
|
1203
|
+
`, i = W.xml.textToDom(o);
|
|
1204
|
+
return zt.domToBlock(i, e);
|
|
1205
|
+
}
|
|
1206
|
+
function Br(e, t) {
|
|
1207
|
+
const o = `
|
|
1208
|
+
<block type="${jo(t)}">
|
|
1209
|
+
</block>
|
|
1210
|
+
`, i = W.xml.textToDom(o);
|
|
1211
|
+
return zt.domToBlock(i, e);
|
|
1212
|
+
}
|
|
1213
|
+
function Rr(e) {
|
|
1214
|
+
const n = W.xml.textToDom(`
|
|
1215
|
+
<block type="select_comp_v1">
|
|
1216
|
+
</block>
|
|
1217
|
+
`);
|
|
1218
|
+
return zt.domToBlock(n, e);
|
|
1219
|
+
}
|
|
1148
1220
|
function rs(e, t, n, o) {
|
|
1149
|
-
const i =
|
|
1150
|
-
|
|
1221
|
+
const i = `
|
|
1222
|
+
<block type="parameter_v1">
|
|
1223
|
+
<mutation key="${t}" name="${n}" locale="${o ? "TRUE" : "FALSE"}"/>
|
|
1224
|
+
</block>
|
|
1225
|
+
`, s = W.xml.textToDom(i);
|
|
1226
|
+
return zt.domToBlock(s, e);
|
|
1151
1227
|
}
|
|
1152
1228
|
function je(e, t) {
|
|
1153
1229
|
try {
|
|
@@ -1174,30 +1250,6 @@ function je(e, t) {
|
|
|
1174
1250
|
x.enable();
|
|
1175
1251
|
}
|
|
1176
1252
|
}
|
|
1177
|
-
function kr(e, t) {
|
|
1178
|
-
const n = `<block type="text_v1"><field name="TEXT">${t}</field></block>`, o = W.xml.textToDom(n);
|
|
1179
|
-
return zt.domToBlock(o, e);
|
|
1180
|
-
}
|
|
1181
|
-
function Nr(e, t) {
|
|
1182
|
-
const n = `<block type="math_number_v1"><field name="NUM">${t}</field></block>`, o = W.xml.textToDom(n);
|
|
1183
|
-
return zt.domToBlock(o, e);
|
|
1184
|
-
}
|
|
1185
|
-
function Sr(e, t) {
|
|
1186
|
-
const o = `<block type="logic_boolean_v1"><field name="BOOL">${t ? "TRUE" : "FALSE"}</field></block>`, i = W.xml.textToDom(o);
|
|
1187
|
-
return zt.domToBlock(i, e);
|
|
1188
|
-
}
|
|
1189
|
-
function Lr(e, t) {
|
|
1190
|
-
const o = `<block type="${jo(t)}"></block>`, i = W.xml.textToDom(o);
|
|
1191
|
-
return zt.domToBlock(i, e);
|
|
1192
|
-
}
|
|
1193
|
-
function Br(e, t) {
|
|
1194
|
-
const o = `<block type="${jo(t)}"></block>`, i = W.xml.textToDom(o);
|
|
1195
|
-
return zt.domToBlock(i, e);
|
|
1196
|
-
}
|
|
1197
|
-
function Rr(e) {
|
|
1198
|
-
const n = W.xml.textToDom('<block type="select_comp_v1"></block>');
|
|
1199
|
-
return zt.domToBlock(n, e);
|
|
1200
|
-
}
|
|
1201
1253
|
function Xn(e) {
|
|
1202
1254
|
const { version: t } = L.app.activeObject;
|
|
1203
1255
|
if (!Fn[t])
|
|
@@ -2875,7 +2927,7 @@ const pf = {
|
|
|
2875
2927
|
this.comp = {
|
|
2876
2928
|
id: void 0,
|
|
2877
2929
|
name: ""
|
|
2878
|
-
}, this.appendDummyInput().appendField("%{BKY_UI_V1_SELECT_COMP_TITLE}").appendField(new U(() => this.genCompOpts_()), "COMP"), this.setOutput(!0, "
|
|
2930
|
+
}, this.appendDummyInput().appendField("%{BKY_UI_V1_SELECT_COMP_TITLE}").appendField(new U(() => this.genCompOpts_()), "COMP"), this.setOutput(!0, "Comp"), this.setStyle("prop_blocks"), this.setTooltip("%{BKY_UI_V1_SELECT_COMP_TOOLTIP}"), this.setHelpUrl("%{BKY_UI_V1_SELECT_COMP_HELPURL}"), this.initData_();
|
|
2879
2931
|
},
|
|
2880
2932
|
initData_: function() {
|
|
2881
2933
|
var n;
|
|
@@ -3171,7 +3223,7 @@ const df = {
|
|
|
3171
3223
|
if (!e)
|
|
3172
3224
|
return;
|
|
3173
3225
|
const t = this.getInput("VALUE"), n = e.raw;
|
|
3174
|
-
n.ui === "strInput" ? t.setCheck("String") : n.ui === "numInput" ? t.setCheck("Number") : n.ui === "switch" ? t.setCheck("Boolean") : n.ui === "colorPicker" ? t.setCheck("Colour") : n.ui === "select" ? t.setCheck(gn(n.items)) : n.ui === "multiTypes" ? t.setCheck(gn(n.types)) : n.ui === "compSelect" || n.ui === "slotSelect" ? t.setCheck("
|
|
3226
|
+
n.ui === "strInput" ? t.setCheck("String") : n.ui === "numInput" ? t.setCheck("Number") : n.ui === "switch" ? t.setCheck("Boolean") : n.ui === "colorPicker" ? t.setCheck("Colour") : n.ui === "select" ? t.setCheck(gn(n.items)) : n.ui === "multiTypes" ? t.setCheck(gn(n.types)) : n.ui === "compSelect" || n.ui === "slotSelect" ? t.setCheck("Comp") : t.setCheck(null);
|
|
3175
3227
|
},
|
|
3176
3228
|
checkWarning_: function() {
|
|
3177
3229
|
const e = He(this.node.id);
|
|
@@ -3291,7 +3343,7 @@ const hf = {
|
|
|
3291
3343
|
if (!e)
|
|
3292
3344
|
return;
|
|
3293
3345
|
const t = this.getInput("VALUE"), n = e.raw;
|
|
3294
|
-
n.ui === "strInput" ? t.setCheck("String") : n.ui === "numInput" ? t.setCheck("Number") : n.ui === "switch" ? t.setCheck("Boolean") : n.ui === "colorPicker" ? t.setCheck("Colour") : n.ui === "select" ? t.setCheck(gn(n.items)) : n.ui === "multiTypes" ? t.setCheck(gn(n.types)) : n.ui === "compSelect" || n.ui === "slotSelect" ? t.setCheck("
|
|
3346
|
+
n.ui === "strInput" ? t.setCheck("String") : n.ui === "numInput" ? t.setCheck("Number") : n.ui === "switch" ? t.setCheck("Boolean") : n.ui === "colorPicker" ? t.setCheck("Colour") : n.ui === "select" ? t.setCheck(gn(n.items)) : n.ui === "multiTypes" ? t.setCheck(gn(n.types)) : n.ui === "compSelect" || n.ui === "slotSelect" ? t.setCheck("Comp") : t.setCheck(null);
|
|
3295
3347
|
},
|
|
3296
3348
|
checkWarning_: function() {
|
|
3297
3349
|
const e = Yt(this.element.key);
|