maze-blockly-wrapper 0.2.6 → 0.3.2
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.
- package/dist/blockly-CB1haBOu.cjs +329 -0
- package/dist/blockly-CB1haBOu.cjs.map +1 -0
- package/dist/blockly-D9trJ_x0.js +329 -0
- package/dist/blockly-D9trJ_x0.js.map +1 -0
- package/dist/blockly_compressed-Bdba50O4.js +21043 -0
- package/dist/{blockly_compressed-BMyLVN-Q.js.map → blockly_compressed-Bdba50O4.js.map} +1 -1
- package/dist/blockly_compressed-DKwMdvF1.cjs +21042 -0
- package/dist/{blockly_compressed-BSXJbxOI.cjs.map → blockly_compressed-DKwMdvF1.cjs.map} +1 -1
- package/dist/blocks-B05dnyOn.js +1707 -0
- package/dist/{blocks-B72zId9w.js.map → blocks-B05dnyOn.js.map} +1 -1
- package/dist/blocks-BabbRNKU.cjs +1707 -0
- package/dist/{blocks-GkRPBplU.cjs.map → blocks-BabbRNKU.cjs.map} +1 -1
- package/dist/components/BlocklyDebugTest.d.ts +30 -0
- package/dist/components/maze/MazeGame.d.ts +1 -0
- package/dist/index-C2TQzLih.js +5038 -0
- package/dist/index-C2TQzLih.js.map +1 -0
- package/dist/index-CeTmKa8Y.cjs +5053 -0
- package/dist/index-CeTmKa8Y.cjs.map +1 -0
- package/dist/index.cjs.js +34 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +32 -31
- package/dist/javascript-B767_urL.js +969 -0
- package/dist/{javascript-CBgY3c4m.js.map → javascript-B767_urL.js.map} +1 -1
- package/dist/javascript-Diow8phl.cjs +969 -0
- package/dist/{javascript-DCJc0bzp.cjs.map → javascript-Diow8phl.cjs.map} +1 -1
- package/dist/utils/blocklySetup.d.ts +4 -0
- package/package.json +1 -1
- package/dist/blockly-B8_W0qMx.js +0 -328
- package/dist/blockly-B8_W0qMx.js.map +0 -1
- package/dist/blockly-D-XLGkbZ.cjs +0 -2
- package/dist/blockly-D-XLGkbZ.cjs.map +0 -1
- package/dist/blockly_compressed-BMyLVN-Q.js +0 -15717
- package/dist/blockly_compressed-BSXJbxOI.cjs +0 -792
- package/dist/blocks-B72zId9w.js +0 -1316
- package/dist/blocks-GkRPBplU.cjs +0 -4
- package/dist/index-D10FGDwl.js +0 -3666
- package/dist/index-D10FGDwl.js.map +0 -1
- package/dist/index-I2TnBYCs.cjs +0 -74
- package/dist/index-I2TnBYCs.cjs.map +0 -1
- package/dist/javascript-CBgY3c4m.js +0 -819
- package/dist/javascript-DCJc0bzp.cjs +0 -219
|
@@ -0,0 +1,1707 @@
|
|
|
1
|
+
import { g as getDefaultExportFromCjs } from "./index-C2TQzLih.js";
|
|
2
|
+
import { r as requireBlockly_compressed } from "./blockly_compressed-Bdba50O4.js";
|
|
3
|
+
var blocks_compressed$1 = { exports: {} };
|
|
4
|
+
var blocks_compressed = blocks_compressed$1.exports;
|
|
5
|
+
var hasRequiredBlocks_compressed;
|
|
6
|
+
function requireBlocks_compressed() {
|
|
7
|
+
if (hasRequiredBlocks_compressed) return blocks_compressed$1.exports;
|
|
8
|
+
hasRequiredBlocks_compressed = 1;
|
|
9
|
+
(function(module, exports) {
|
|
10
|
+
(function(root, factory) {
|
|
11
|
+
{
|
|
12
|
+
module.exports = factory(requireBlockly_compressed());
|
|
13
|
+
}
|
|
14
|
+
})(blocks_compressed, function(__parent__) {
|
|
15
|
+
var $ = __parent__.__namespace__;
|
|
16
|
+
var blocks$$module$build$src$blocks$variables_dynamic = $.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{ type: "variables_get_dynamic", message0: "%1", args0: [{ type: "field_variable", name: "VAR", variable: "%{BKY_VARIABLES_DEFAULT_NAME}" }], output: null, style: "variable_dynamic_blocks", helpUrl: "%{BKY_VARIABLES_GET_HELPURL}", tooltip: "%{BKY_VARIABLES_GET_TOOLTIP}", extensions: ["contextMenu_variableDynamicSetterGetter"] }, { type: "variables_set_dynamic", message0: "%{BKY_VARIABLES_SET}", args0: [{
|
|
17
|
+
type: "field_variable",
|
|
18
|
+
name: "VAR",
|
|
19
|
+
variable: "%{BKY_VARIABLES_DEFAULT_NAME}"
|
|
20
|
+
}, { type: "input_value", name: "VALUE" }], previousStatement: null, nextStatement: null, style: "variable_dynamic_blocks", tooltip: "%{BKY_VARIABLES_SET_TOOLTIP}", helpUrl: "%{BKY_VARIABLES_SET_HELPURL}", extensions: ["contextMenu_variableDynamicSetterGetter"] }]), CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN$$module$build$src$blocks$variables_dynamic = { customContextMenu: function(a) {
|
|
21
|
+
if (!this.isInFlyout) {
|
|
22
|
+
if (this.type === "variables_get_dynamic") {
|
|
23
|
+
var b = "variables_set_dynamic";
|
|
24
|
+
var c = $.Msg$$module$build$src$core$msg.VARIABLES_GET_CREATE_SET;
|
|
25
|
+
} else b = "variables_get_dynamic", c = $.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET;
|
|
26
|
+
var d = this.getField("VAR");
|
|
27
|
+
b = { type: b, fields: { VAR: d.saveState(true) } };
|
|
28
|
+
a.push({ enabled: this.workspace.remainingCapacity() > 0, text: c.replace("%1", d.getText()), callback: $.callbackFactory$$module$build$src$core$contextmenu(this, b) });
|
|
29
|
+
} else if (this.type === "variables_get_dynamic" || this.type === "variables_get_reporter_dynamic") c = {
|
|
30
|
+
text: $.Msg$$module$build$src$core$msg.RENAME_VARIABLE,
|
|
31
|
+
enabled: true,
|
|
32
|
+
callback: renameOptionCallbackFactory$$module$build$src$blocks$variables_dynamic(this)
|
|
33
|
+
}, d = this.getField("VAR").getText(), d = { text: $.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1", d), enabled: true, callback: deleteOptionCallbackFactory$$module$build$src$blocks$variables_dynamic(this) }, a.unshift(c), a.unshift(d);
|
|
34
|
+
}, onchange: function(a) {
|
|
35
|
+
a = this.getFieldValue("VAR");
|
|
36
|
+
a = $.getVariable$$module$build$src$core$variables(this.workspace, a);
|
|
37
|
+
this.type === "variables_get_dynamic" ? this.outputConnection.setCheck(a.getType()) : this.getInput("VALUE").connection.setCheck(a.getType());
|
|
38
|
+
} }, renameOptionCallbackFactory$$module$build$src$blocks$variables_dynamic = function(a) {
|
|
39
|
+
return function() {
|
|
40
|
+
const b = a.workspace, c = a.getField("VAR").getVariable();
|
|
41
|
+
$.renameVariable$$module$build$src$core$variables(b, c);
|
|
42
|
+
};
|
|
43
|
+
}, deleteOptionCallbackFactory$$module$build$src$blocks$variables_dynamic = function(a) {
|
|
44
|
+
return function() {
|
|
45
|
+
const b = a.getField("VAR").getVariable();
|
|
46
|
+
b && $.deleteVariable$$module$build$src$core$variables(b.getWorkspace(), b, a);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
$.registerMixin$$module$build$src$core$extensions("contextMenu_variableDynamicSetterGetter", CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN$$module$build$src$blocks$variables_dynamic);
|
|
50
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$variables_dynamic);
|
|
51
|
+
var module$build$src$blocks$variables_dynamic = { blocks: blocks$$module$build$src$blocks$variables_dynamic };
|
|
52
|
+
var blocks$$module$build$src$blocks$variables = $.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{ type: "variables_get", message0: "%1", args0: [{ type: "field_variable", name: "VAR", variable: "%{BKY_VARIABLES_DEFAULT_NAME}" }], output: null, style: "variable_blocks", helpUrl: "%{BKY_VARIABLES_GET_HELPURL}", tooltip: "%{BKY_VARIABLES_GET_TOOLTIP}", extensions: ["contextMenu_variableSetterGetter"] }, { type: "variables_set", message0: "%{BKY_VARIABLES_SET}", args0: [
|
|
53
|
+
{ type: "field_variable", name: "VAR", variable: "%{BKY_VARIABLES_DEFAULT_NAME}" },
|
|
54
|
+
{ type: "input_value", name: "VALUE" }
|
|
55
|
+
], previousStatement: null, nextStatement: null, style: "variable_blocks", tooltip: "%{BKY_VARIABLES_SET_TOOLTIP}", helpUrl: "%{BKY_VARIABLES_SET_HELPURL}", extensions: ["contextMenu_variableSetterGetter"] }]), CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN$$module$build$src$blocks$variables = { customContextMenu: function(a) {
|
|
56
|
+
if (!this.isInFlyout) {
|
|
57
|
+
if (this.type === "variables_get") {
|
|
58
|
+
var b = "variables_set";
|
|
59
|
+
var c = $.Msg$$module$build$src$core$msg.VARIABLES_GET_CREATE_SET;
|
|
60
|
+
} else b = "variables_get", c = $.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET;
|
|
61
|
+
var d = this.getField("VAR");
|
|
62
|
+
b = { type: b, fields: { VAR: d.saveState(true) } };
|
|
63
|
+
a.push({ enabled: this.workspace.remainingCapacity() > 0, text: c.replace("%1", d.getText()), callback: $.callbackFactory$$module$build$src$core$contextmenu(this, b) });
|
|
64
|
+
} else if (this.type === "variables_get" || this.type === "variables_get_reporter") c = { text: $.Msg$$module$build$src$core$msg.RENAME_VARIABLE, enabled: true, callback: renameOptionCallbackFactory$$module$build$src$blocks$variables(this) }, d = this.getField("VAR").getText(), d = { text: $.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1", d), enabled: true, callback: deleteOptionCallbackFactory$$module$build$src$blocks$variables(this) }, a.unshift(c), a.unshift(d);
|
|
65
|
+
} }, renameOptionCallbackFactory$$module$build$src$blocks$variables = function(a) {
|
|
66
|
+
return function() {
|
|
67
|
+
const b = a.workspace, c = a.getField("VAR").getVariable();
|
|
68
|
+
$.renameVariable$$module$build$src$core$variables(b, c);
|
|
69
|
+
};
|
|
70
|
+
}, deleteOptionCallbackFactory$$module$build$src$blocks$variables = function(a) {
|
|
71
|
+
return function() {
|
|
72
|
+
const b = a.getField("VAR").getVariable();
|
|
73
|
+
b && $.deleteVariable$$module$build$src$core$variables(b.getWorkspace(), b, a);
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
$.registerMixin$$module$build$src$core$extensions("contextMenu_variableSetterGetter", CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN$$module$build$src$blocks$variables);
|
|
77
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$variables);
|
|
78
|
+
var module$build$src$blocks$variables = { blocks: blocks$$module$build$src$blocks$variables };
|
|
79
|
+
var blocks$$module$build$src$blocks$text = $.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([
|
|
80
|
+
{ type: "text", message0: "%1", args0: [{ type: "field_input", name: "TEXT", text: "" }], output: "String", style: "text_blocks", helpUrl: "%{BKY_TEXT_TEXT_HELPURL}", tooltip: "%{BKY_TEXT_TEXT_TOOLTIP}", extensions: ["text_quotes", "parent_tooltip_when_inline"] },
|
|
81
|
+
{ type: "text_join", message0: "", output: "String", style: "text_blocks", helpUrl: "%{BKY_TEXT_JOIN_HELPURL}", tooltip: "%{BKY_TEXT_JOIN_TOOLTIP}", mutator: "text_join_mutator" },
|
|
82
|
+
{ type: "text_create_join_container", message0: "%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2", args0: [{ type: "input_dummy" }, { type: "input_statement", name: "STACK" }], style: "text_blocks", tooltip: "%{BKY_TEXT_CREATE_JOIN_TOOLTIP}", enableContextMenu: false },
|
|
83
|
+
{ type: "text_create_join_item", message0: "%{BKY_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM}", previousStatement: null, nextStatement: null, style: "text_blocks", tooltip: "%{BKY_TEXT_CREATE_JOIN_ITEM_TOOLTIP}", enableContextMenu: false },
|
|
84
|
+
{
|
|
85
|
+
type: "text_append",
|
|
86
|
+
message0: "%{BKY_TEXT_APPEND_TITLE}",
|
|
87
|
+
args0: [{ type: "field_variable", name: "VAR", variable: "%{BKY_TEXT_APPEND_VARIABLE}" }, { type: "input_value", name: "TEXT" }],
|
|
88
|
+
previousStatement: null,
|
|
89
|
+
nextStatement: null,
|
|
90
|
+
style: "text_blocks",
|
|
91
|
+
extensions: ["text_append_tooltip"]
|
|
92
|
+
},
|
|
93
|
+
{ type: "text_length", message0: "%{BKY_TEXT_LENGTH_TITLE}", args0: [{ type: "input_value", name: "VALUE", check: ["String", "Array"] }], output: "Number", style: "text_blocks", tooltip: "%{BKY_TEXT_LENGTH_TOOLTIP}", helpUrl: "%{BKY_TEXT_LENGTH_HELPURL}" },
|
|
94
|
+
{
|
|
95
|
+
type: "text_isEmpty",
|
|
96
|
+
message0: "%{BKY_TEXT_ISEMPTY_TITLE}",
|
|
97
|
+
args0: [{ type: "input_value", name: "VALUE", check: ["String", "Array"] }],
|
|
98
|
+
output: "Boolean",
|
|
99
|
+
style: "text_blocks",
|
|
100
|
+
tooltip: "%{BKY_TEXT_ISEMPTY_TOOLTIP}",
|
|
101
|
+
helpUrl: "%{BKY_TEXT_ISEMPTY_HELPURL}"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: "text_indexOf",
|
|
105
|
+
message0: "%{BKY_TEXT_INDEXOF_TITLE}",
|
|
106
|
+
args0: [{ type: "input_value", name: "VALUE", check: "String" }, { type: "field_dropdown", name: "END", options: [["%{BKY_TEXT_INDEXOF_OPERATOR_FIRST}", "FIRST"], ["%{BKY_TEXT_INDEXOF_OPERATOR_LAST}", "LAST"]] }, { type: "input_value", name: "FIND", check: "String" }],
|
|
107
|
+
output: "Number",
|
|
108
|
+
style: "text_blocks",
|
|
109
|
+
helpUrl: "%{BKY_TEXT_INDEXOF_HELPURL}",
|
|
110
|
+
inputsInline: true,
|
|
111
|
+
extensions: ["text_indexOf_tooltip"]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "text_charAt",
|
|
115
|
+
message0: "%{BKY_TEXT_CHARAT_TITLE}",
|
|
116
|
+
args0: [{ type: "input_value", name: "VALUE", check: "String" }, { type: "field_dropdown", name: "WHERE", options: [["%{BKY_TEXT_CHARAT_FROM_START}", "FROM_START"], ["%{BKY_TEXT_CHARAT_FROM_END}", "FROM_END"], ["%{BKY_TEXT_CHARAT_FIRST}", "FIRST"], ["%{BKY_TEXT_CHARAT_LAST}", "LAST"], ["%{BKY_TEXT_CHARAT_RANDOM}", "RANDOM"]] }],
|
|
117
|
+
output: "String",
|
|
118
|
+
style: "text_blocks",
|
|
119
|
+
helpUrl: "%{BKY_TEXT_CHARAT_HELPURL}",
|
|
120
|
+
inputsInline: true,
|
|
121
|
+
mutator: "text_charAt_mutator"
|
|
122
|
+
}
|
|
123
|
+
]), GET_SUBSTRING_BLOCK$$module$build$src$blocks$text = { init: function() {
|
|
124
|
+
this.WHERE_OPTIONS_1 = [[$.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FROM_START, "FROM_START"], [$.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FROM_END, "FROM_END"], [$.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_START_FIRST, "FIRST"]];
|
|
125
|
+
this.WHERE_OPTIONS_2 = [[$.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_FROM_START, "FROM_START"], [
|
|
126
|
+
$.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_FROM_END,
|
|
127
|
+
"FROM_END"
|
|
128
|
+
], [$.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_END_LAST, "LAST"]];
|
|
129
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_HELPURL);
|
|
130
|
+
this.setStyle("text_blocks");
|
|
131
|
+
this.appendValueInput("STRING").setCheck("String").appendField($.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);
|
|
132
|
+
const a = (b) => {
|
|
133
|
+
const c = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: this["WHERE_OPTIONS_" + b] });
|
|
134
|
+
c.setValidator(function(d) {
|
|
135
|
+
const e = this.getValue();
|
|
136
|
+
d = d === "FROM_START" || d === "FROM_END";
|
|
137
|
+
d !== (e === "FROM_START" || e === "FROM_END") && this.getSourceBlock().updateAt_(b, d);
|
|
138
|
+
});
|
|
139
|
+
return c;
|
|
140
|
+
};
|
|
141
|
+
this.appendDummyInput("WHERE1_INPUT").appendField(a(1), "WHERE1");
|
|
142
|
+
this.appendDummyInput("AT1");
|
|
143
|
+
this.appendDummyInput("WHERE2_INPUT").appendField(a(2), "WHERE2");
|
|
144
|
+
this.appendDummyInput("AT2");
|
|
145
|
+
$.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL && this.appendDummyInput("TAIL").appendField($.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL);
|
|
146
|
+
this.setInputsInline(true);
|
|
147
|
+
this.setOutput(
|
|
148
|
+
true,
|
|
149
|
+
"String"
|
|
150
|
+
);
|
|
151
|
+
this.updateAt_(1, true);
|
|
152
|
+
this.updateAt_(2, true);
|
|
153
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TOOLTIP);
|
|
154
|
+
}, mutationToDom: function() {
|
|
155
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
156
|
+
var b = this.getInput("AT1") instanceof $.ValueInput$$module$build$src$core$inputs$value_input;
|
|
157
|
+
a.setAttribute("at1", `${b}`);
|
|
158
|
+
b = this.getInput("AT2") instanceof $.ValueInput$$module$build$src$core$inputs$value_input;
|
|
159
|
+
a.setAttribute("at2", `${b}`);
|
|
160
|
+
return a;
|
|
161
|
+
}, domToMutation: function(a) {
|
|
162
|
+
const b = a.getAttribute("at1") === "true";
|
|
163
|
+
a = a.getAttribute("at2") === "true";
|
|
164
|
+
this.updateAt_(1, b);
|
|
165
|
+
this.updateAt_(2, a);
|
|
166
|
+
}, updateAt_: function(a, b) {
|
|
167
|
+
this.removeInput("AT" + a);
|
|
168
|
+
this.removeInput("ORDINAL" + a, true);
|
|
169
|
+
b ? (this.appendValueInput("AT" + a).setCheck("Number"), $.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL" + a).appendField($.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT" + a);
|
|
170
|
+
a === 2 && $.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL && (this.removeInput(
|
|
171
|
+
"TAIL",
|
|
172
|
+
true
|
|
173
|
+
), this.appendDummyInput("TAIL").appendField($.Msg$$module$build$src$core$msg.TEXT_GET_SUBSTRING_TAIL));
|
|
174
|
+
a === 1 && (this.moveInputBefore("AT1", "WHERE2_INPUT"), this.getInput("ORDINAL1") && this.moveInputBefore("ORDINAL1", "WHERE2_INPUT"));
|
|
175
|
+
} };
|
|
176
|
+
blocks$$module$build$src$blocks$text.text_getSubstring = GET_SUBSTRING_BLOCK$$module$build$src$blocks$text;
|
|
177
|
+
blocks$$module$build$src$blocks$text.text_changeCase = { init: function() {
|
|
178
|
+
const a = [[$.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE, "UPPERCASE"], [$.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE, "LOWERCASE"], [$.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_OPERATOR_TITLECASE, "TITLECASE"]];
|
|
179
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_HELPURL);
|
|
180
|
+
this.setStyle("text_blocks");
|
|
181
|
+
this.appendValueInput("TEXT").setCheck("String").appendField($.fromJson$$module$build$src$core$field_registry({
|
|
182
|
+
type: "field_dropdown",
|
|
183
|
+
options: a
|
|
184
|
+
}), "CASE");
|
|
185
|
+
this.setOutput(true, "String");
|
|
186
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.TEXT_CHANGECASE_TOOLTIP);
|
|
187
|
+
} };
|
|
188
|
+
blocks$$module$build$src$blocks$text.text_trim = { init: function() {
|
|
189
|
+
const a = [[$.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_BOTH, "BOTH"], [$.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_LEFT, "LEFT"], [$.Msg$$module$build$src$core$msg.TEXT_TRIM_OPERATOR_RIGHT, "RIGHT"]];
|
|
190
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.TEXT_TRIM_HELPURL);
|
|
191
|
+
this.setStyle("text_blocks");
|
|
192
|
+
this.appendValueInput("TEXT").setCheck("String").appendField(
|
|
193
|
+
$.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: a }),
|
|
194
|
+
"MODE"
|
|
195
|
+
);
|
|
196
|
+
this.setOutput(true, "String");
|
|
197
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.TEXT_TRIM_TOOLTIP);
|
|
198
|
+
} };
|
|
199
|
+
blocks$$module$build$src$blocks$text.text_print = { init: function() {
|
|
200
|
+
this.jsonInit({ message0: $.Msg$$module$build$src$core$msg.TEXT_PRINT_TITLE, args0: [{ type: "input_value", name: "TEXT" }], previousStatement: null, nextStatement: null, style: "text_blocks", tooltip: $.Msg$$module$build$src$core$msg.TEXT_PRINT_TOOLTIP, helpUrl: $.Msg$$module$build$src$core$msg.TEXT_PRINT_HELPURL });
|
|
201
|
+
} };
|
|
202
|
+
var PROMPT_COMMON$$module$build$src$blocks$text = { updateType_: function(a) {
|
|
203
|
+
this.outputConnection.setCheck(a === "NUMBER" ? "Number" : "String");
|
|
204
|
+
}, mutationToDom: function() {
|
|
205
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
206
|
+
a.setAttribute("type", this.getFieldValue("TYPE"));
|
|
207
|
+
return a;
|
|
208
|
+
}, domToMutation: function(a) {
|
|
209
|
+
this.updateType_(a.getAttribute("type"));
|
|
210
|
+
} };
|
|
211
|
+
blocks$$module$build$src$blocks$text.text_prompt_ext = Object.assign({}, PROMPT_COMMON$$module$build$src$blocks$text, { init: function() {
|
|
212
|
+
var a = [[$.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT, "TEXT"], [$.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER, "NUMBER"]];
|
|
213
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL);
|
|
214
|
+
this.setStyle("text_blocks");
|
|
215
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: a });
|
|
216
|
+
a.setValidator((b) => {
|
|
217
|
+
this.updateType_(b);
|
|
218
|
+
});
|
|
219
|
+
this.appendValueInput("TEXT").appendField(
|
|
220
|
+
a,
|
|
221
|
+
"TYPE"
|
|
222
|
+
);
|
|
223
|
+
this.setOutput(true, "String");
|
|
224
|
+
this.setTooltip(() => this.getFieldValue("TYPE") === "TEXT" ? $.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT : $.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER);
|
|
225
|
+
} });
|
|
226
|
+
blocks$$module$build$src$blocks$text.text_prompt = Object.assign({}, PROMPT_COMMON$$module$build$src$blocks$text, { init: function() {
|
|
227
|
+
this.mixin(QUOTE_IMAGE_MIXIN$$module$build$src$blocks$text);
|
|
228
|
+
var a = [[$.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT, "TEXT"], [$.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER, "NUMBER"]];
|
|
229
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL);
|
|
230
|
+
this.setStyle("text_blocks");
|
|
231
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: a });
|
|
232
|
+
a.setValidator((b) => {
|
|
233
|
+
this.updateType_(b);
|
|
234
|
+
});
|
|
235
|
+
this.appendDummyInput().appendField(a, "TYPE").appendField(this.newQuote_(true)).appendField($.fromJson$$module$build$src$core$field_registry({ type: "field_input", text: "" }), "TEXT").appendField(this.newQuote_(false));
|
|
236
|
+
this.setOutput(true, "String");
|
|
237
|
+
this.setTooltip(() => this.getFieldValue("TYPE") === "TEXT" ? $.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT : $.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER);
|
|
238
|
+
} });
|
|
239
|
+
blocks$$module$build$src$blocks$text.text_count = { init: function() {
|
|
240
|
+
this.jsonInit({ message0: $.Msg$$module$build$src$core$msg.TEXT_COUNT_MESSAGE0, args0: [{ type: "input_value", name: "SUB", check: "String" }, { type: "input_value", name: "TEXT", check: "String" }], output: "Number", inputsInline: true, style: "text_blocks", tooltip: $.Msg$$module$build$src$core$msg.TEXT_COUNT_TOOLTIP, helpUrl: $.Msg$$module$build$src$core$msg.TEXT_COUNT_HELPURL });
|
|
241
|
+
} };
|
|
242
|
+
blocks$$module$build$src$blocks$text.text_replace = { init: function() {
|
|
243
|
+
this.jsonInit({ message0: $.Msg$$module$build$src$core$msg.TEXT_REPLACE_MESSAGE0, args0: [{ type: "input_value", name: "FROM", check: "String" }, { type: "input_value", name: "TO", check: "String" }, { type: "input_value", name: "TEXT", check: "String" }], output: "String", inputsInline: true, style: "text_blocks", tooltip: $.Msg$$module$build$src$core$msg.TEXT_REPLACE_TOOLTIP, helpUrl: $.Msg$$module$build$src$core$msg.TEXT_REPLACE_HELPURL });
|
|
244
|
+
} };
|
|
245
|
+
blocks$$module$build$src$blocks$text.text_reverse = { init: function() {
|
|
246
|
+
this.jsonInit({ message0: $.Msg$$module$build$src$core$msg.TEXT_REVERSE_MESSAGE0, args0: [{ type: "input_value", name: "TEXT", check: "String" }], output: "String", inputsInline: true, style: "text_blocks", tooltip: $.Msg$$module$build$src$core$msg.TEXT_REVERSE_TOOLTIP, helpUrl: $.Msg$$module$build$src$core$msg.TEXT_REVERSE_HELPURL });
|
|
247
|
+
} };
|
|
248
|
+
var QUOTE_IMAGE_MIXIN$$module$build$src$blocks$text = {
|
|
249
|
+
QUOTE_IMAGE_LEFT_DATAURI: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",
|
|
250
|
+
QUOTE_IMAGE_RIGHT_DATAURI: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",
|
|
251
|
+
QUOTE_IMAGE_WIDTH: 12,
|
|
252
|
+
QUOTE_IMAGE_HEIGHT: 12,
|
|
253
|
+
quoteField_: function(a) {
|
|
254
|
+
for (let b = 0, c; c = this.inputList[b]; b++) for (let d = 0, e; e = c.fieldRow[d]; d++) if (a === e.name) {
|
|
255
|
+
c.insertFieldAt(d, this.newQuote_(true));
|
|
256
|
+
c.insertFieldAt(d + 2, this.newQuote_(false));
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
console.warn('field named "' + a + '" not found in ' + this.toDevString());
|
|
260
|
+
},
|
|
261
|
+
newQuote_: function(a) {
|
|
262
|
+
a = this.RTL ? !a : a;
|
|
263
|
+
return $.fromJson$$module$build$src$core$field_registry({
|
|
264
|
+
type: "field_image",
|
|
265
|
+
src: a ? this.QUOTE_IMAGE_LEFT_DATAURI : this.QUOTE_IMAGE_RIGHT_DATAURI,
|
|
266
|
+
width: this.QUOTE_IMAGE_WIDTH,
|
|
267
|
+
height: this.QUOTE_IMAGE_HEIGHT,
|
|
268
|
+
alt: a ? "“" : "”"
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}, QUOTES_EXTENSION$$module$build$src$blocks$text = function() {
|
|
272
|
+
this.mixin(QUOTE_IMAGE_MIXIN$$module$build$src$blocks$text);
|
|
273
|
+
this.quoteField_("TEXT");
|
|
274
|
+
}, JOIN_MUTATOR_MIXIN$$module$build$src$blocks$text = {
|
|
275
|
+
itemCount_: 0,
|
|
276
|
+
mutationToDom: function() {
|
|
277
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
278
|
+
a.setAttribute("items", `${this.itemCount_}`);
|
|
279
|
+
return a;
|
|
280
|
+
},
|
|
281
|
+
domToMutation: function(a) {
|
|
282
|
+
this.itemCount_ = parseInt(a.getAttribute("items"), 10);
|
|
283
|
+
this.updateShape_();
|
|
284
|
+
},
|
|
285
|
+
saveExtraState: function() {
|
|
286
|
+
return { itemCount: this.itemCount_ };
|
|
287
|
+
},
|
|
288
|
+
loadExtraState: function(a) {
|
|
289
|
+
this.itemCount_ = a.itemCount;
|
|
290
|
+
this.updateShape_();
|
|
291
|
+
},
|
|
292
|
+
decompose: function(a) {
|
|
293
|
+
const b = a.newBlock("text_create_join_container");
|
|
294
|
+
b.initSvg();
|
|
295
|
+
let c = b.getInput("STACK").connection;
|
|
296
|
+
for (let d = 0; d < this.itemCount_; d++) {
|
|
297
|
+
const e = a.newBlock("text_create_join_item");
|
|
298
|
+
e.initSvg();
|
|
299
|
+
c.connect(e.previousConnection);
|
|
300
|
+
c = e.nextConnection;
|
|
301
|
+
}
|
|
302
|
+
return b;
|
|
303
|
+
},
|
|
304
|
+
compose: function(a) {
|
|
305
|
+
var b = a.getInputTargetBlock("STACK");
|
|
306
|
+
for (a = []; b; ) b.isInsertionMarker() || a.push(b.valueConnection_), b = b.getNextBlock();
|
|
307
|
+
for (b = 0; b < this.itemCount_; b++) {
|
|
308
|
+
const c = this.getInput("ADD" + b).connection.targetConnection;
|
|
309
|
+
c && !a.includes(c) && c.disconnect();
|
|
310
|
+
}
|
|
311
|
+
this.itemCount_ = a.length;
|
|
312
|
+
this.updateShape_();
|
|
313
|
+
for (b = 0; b < this.itemCount_; b++) {
|
|
314
|
+
let c;
|
|
315
|
+
(c = a[b]) == null || c.reconnect(this, "ADD" + b);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
saveConnections: function(a) {
|
|
319
|
+
a = a.getInputTargetBlock("STACK");
|
|
320
|
+
let b = 0;
|
|
321
|
+
for (; a; ) {
|
|
322
|
+
if (a.isInsertionMarker()) {
|
|
323
|
+
a = a.getNextBlock();
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const c = this.getInput("ADD" + b);
|
|
327
|
+
a.valueConnection_ = c && c.connection.targetConnection;
|
|
328
|
+
a = a.getNextBlock();
|
|
329
|
+
b++;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
updateShape_: function() {
|
|
333
|
+
this.itemCount_ && this.getInput("EMPTY") ? this.removeInput("EMPTY") : this.itemCount_ || this.getInput("EMPTY") || this.appendDummyInput("EMPTY").appendField(this.newQuote_(true)).appendField(this.newQuote_(false));
|
|
334
|
+
for (var a = 0; a < this.itemCount_; a++) if (!this.getInput("ADD" + a)) {
|
|
335
|
+
const b = this.appendValueInput("ADD" + a).setAlign($.Align$$module$build$src$core$inputs$align.RIGHT);
|
|
336
|
+
a === 0 && b.appendField($.Msg$$module$build$src$core$msg.TEXT_JOIN_TITLE_CREATEWITH);
|
|
337
|
+
}
|
|
338
|
+
for (a = this.itemCount_; this.getInput("ADD" + a); a++) this.removeInput("ADD" + a);
|
|
339
|
+
}
|
|
340
|
+
}, JOIN_EXTENSION$$module$build$src$blocks$text = function() {
|
|
341
|
+
this.mixin(QUOTE_IMAGE_MIXIN$$module$build$src$blocks$text);
|
|
342
|
+
this.itemCount_ = 2;
|
|
343
|
+
this.updateShape_();
|
|
344
|
+
this.setMutator(new $.MutatorIcon$$module$build$src$core$icons$mutator_icon(["text_create_join_item"], this));
|
|
345
|
+
};
|
|
346
|
+
$.register$$module$build$src$core$extensions("text_append_tooltip", $.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_TEXT_APPEND_TOOLTIP}", "VAR"));
|
|
347
|
+
var INDEXOF_TOOLTIP_EXTENSION$$module$build$src$blocks$text = function() {
|
|
348
|
+
this.setTooltip(() => $.Msg$$module$build$src$core$msg.TEXT_INDEXOF_TOOLTIP.replace("%1", this.workspace.options.oneBasedIndex ? "0" : "-1"));
|
|
349
|
+
}, CHARAT_MUTATOR_MIXIN$$module$build$src$blocks$text = { isAt_: false, mutationToDom: function() {
|
|
350
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
351
|
+
a.setAttribute("at", `${this.isAt_}`);
|
|
352
|
+
return a;
|
|
353
|
+
}, domToMutation: function(a) {
|
|
354
|
+
a = a.getAttribute("at") !== "false";
|
|
355
|
+
this.updateAt_(a);
|
|
356
|
+
}, updateAt_: function(a) {
|
|
357
|
+
this.removeInput(
|
|
358
|
+
"AT",
|
|
359
|
+
true
|
|
360
|
+
);
|
|
361
|
+
this.removeInput("ORDINAL", true);
|
|
362
|
+
a && (this.appendValueInput("AT").setCheck("Number"), $.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL").appendField($.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX));
|
|
363
|
+
$.Msg$$module$build$src$core$msg.TEXT_CHARAT_TAIL && (this.removeInput("TAIL", true), this.appendDummyInput("TAIL").appendField($.Msg$$module$build$src$core$msg.TEXT_CHARAT_TAIL));
|
|
364
|
+
this.isAt_ = a;
|
|
365
|
+
} }, CHARAT_EXTENSION$$module$build$src$blocks$text = function() {
|
|
366
|
+
this.getField("WHERE").setValidator(function(a) {
|
|
367
|
+
a = a === "FROM_START" || a === "FROM_END";
|
|
368
|
+
const b = this.getSourceBlock();
|
|
369
|
+
a !== b.isAt_ && b.updateAt_(a);
|
|
370
|
+
});
|
|
371
|
+
this.updateAt_(true);
|
|
372
|
+
this.setTooltip(() => {
|
|
373
|
+
var a = this.getFieldValue("WHERE");
|
|
374
|
+
let b = $.Msg$$module$build$src$core$msg.TEXT_CHARAT_TOOLTIP;
|
|
375
|
+
(a === "FROM_START" || a === "FROM_END") && (a = a === "FROM_START" ? $.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP : $.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP) && (b += " " + a.replace("%1", this.workspace.options.oneBasedIndex ? "#1" : "#0"));
|
|
376
|
+
return b;
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
$.register$$module$build$src$core$extensions("text_indexOf_tooltip", INDEXOF_TOOLTIP_EXTENSION$$module$build$src$blocks$text);
|
|
380
|
+
$.register$$module$build$src$core$extensions("text_quotes", QUOTES_EXTENSION$$module$build$src$blocks$text);
|
|
381
|
+
$.registerMixin$$module$build$src$core$extensions("quote_image_mixin", QUOTE_IMAGE_MIXIN$$module$build$src$blocks$text);
|
|
382
|
+
$.registerMutator$$module$build$src$core$extensions("text_join_mutator", JOIN_MUTATOR_MIXIN$$module$build$src$blocks$text, JOIN_EXTENSION$$module$build$src$blocks$text);
|
|
383
|
+
$.registerMutator$$module$build$src$core$extensions("text_charAt_mutator", CHARAT_MUTATOR_MIXIN$$module$build$src$blocks$text, CHARAT_EXTENSION$$module$build$src$blocks$text);
|
|
384
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$text);
|
|
385
|
+
var module$build$src$blocks$text = { blocks: blocks$$module$build$src$blocks$text };
|
|
386
|
+
var blocks$$module$build$src$blocks$procedures = {}, PROCEDURE_DEF_COMMON$$module$build$src$blocks$procedures = { setStatements_: function(a) {
|
|
387
|
+
this.hasStatements_ !== a && (a ? (this.appendStatementInput("STACK").appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_DO), this.getInput("RETURN") && this.moveInputBefore("STACK", "RETURN")) : this.removeInput("STACK", true), this.hasStatements_ = a);
|
|
388
|
+
}, updateParams_: function() {
|
|
389
|
+
let a = "";
|
|
390
|
+
this.arguments_.length && (a = $.Msg$$module$build$src$core$msg.PROCEDURES_BEFORE_PARAMS + " " + this.arguments_.join(", "));
|
|
391
|
+
$.disable$$module$build$src$core$events$utils();
|
|
392
|
+
try {
|
|
393
|
+
this.setFieldValue(a, "PARAMS");
|
|
394
|
+
} finally {
|
|
395
|
+
$.enable$$module$build$src$core$events$utils();
|
|
396
|
+
}
|
|
397
|
+
}, mutationToDom: function(a) {
|
|
398
|
+
const b = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
399
|
+
a && b.setAttribute("name", this.getFieldValue("NAME"));
|
|
400
|
+
for (let c = 0; c < this.argumentVarModels_.length; c++) {
|
|
401
|
+
const d = $.createElement$$module$build$src$core$utils$xml("arg"), e = this.argumentVarModels_[c];
|
|
402
|
+
d.setAttribute("name", e.getName());
|
|
403
|
+
d.setAttribute(
|
|
404
|
+
"varid",
|
|
405
|
+
e.getId()
|
|
406
|
+
);
|
|
407
|
+
a && this.paramIds_ && d.setAttribute("paramId", this.paramIds_[c]);
|
|
408
|
+
b.appendChild(d);
|
|
409
|
+
}
|
|
410
|
+
this.hasStatements_ || b.setAttribute("statements", "false");
|
|
411
|
+
return b;
|
|
412
|
+
}, domToMutation: function(a) {
|
|
413
|
+
this.arguments_ = [];
|
|
414
|
+
this.argumentVarModels_ = [];
|
|
415
|
+
for (let c = 0, d; d = a.childNodes[c]; c++) if (d.nodeName.toLowerCase() === "arg") {
|
|
416
|
+
var b = d;
|
|
417
|
+
const e = b.getAttribute("name");
|
|
418
|
+
b = b.getAttribute("varid") || b.getAttribute("varId");
|
|
419
|
+
this.arguments_.push(e);
|
|
420
|
+
b = $.getOrCreateVariablePackage$$module$build$src$core$variables(
|
|
421
|
+
this.workspace,
|
|
422
|
+
b,
|
|
423
|
+
e,
|
|
424
|
+
""
|
|
425
|
+
);
|
|
426
|
+
b !== null ? this.argumentVarModels_.push(b) : console.log(`Failed to create a variable named "${e}", ignoring.`);
|
|
427
|
+
}
|
|
428
|
+
this.updateParams_();
|
|
429
|
+
$.mutateCallers$$module$build$src$core$procedures(this);
|
|
430
|
+
this.setStatements_(a.getAttribute("statements") !== "false");
|
|
431
|
+
}, saveExtraState: function() {
|
|
432
|
+
if (!this.argumentVarModels_.length && this.hasStatements_) return null;
|
|
433
|
+
const a = /* @__PURE__ */ Object.create(null);
|
|
434
|
+
if (this.argumentVarModels_.length) {
|
|
435
|
+
a.params = [];
|
|
436
|
+
for (let b = 0; b < this.argumentVarModels_.length; b++) a.params.push({
|
|
437
|
+
name: this.argumentVarModels_[b].getName(),
|
|
438
|
+
id: this.argumentVarModels_[b].getId()
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
this.hasStatements_ || (a.hasStatements = false);
|
|
442
|
+
return a;
|
|
443
|
+
}, loadExtraState: function(a) {
|
|
444
|
+
this.arguments_ = [];
|
|
445
|
+
this.argumentVarModels_ = [];
|
|
446
|
+
if (a.params) for (let c = 0; c < a.params.length; c++) {
|
|
447
|
+
var b = a.params[c];
|
|
448
|
+
b = $.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace, b.id, b.name, "");
|
|
449
|
+
this.arguments_.push(b.getName());
|
|
450
|
+
this.argumentVarModels_.push(b);
|
|
451
|
+
}
|
|
452
|
+
this.updateParams_();
|
|
453
|
+
$.mutateCallers$$module$build$src$core$procedures(this);
|
|
454
|
+
this.setStatements_(a.hasStatements === false ? false : true);
|
|
455
|
+
}, decompose: function(a) {
|
|
456
|
+
const b = $.createElement$$module$build$src$core$utils$xml("block");
|
|
457
|
+
b.setAttribute("type", "procedures_mutatorcontainer");
|
|
458
|
+
var c = $.createElement$$module$build$src$core$utils$xml("statement");
|
|
459
|
+
c.setAttribute("name", "STACK");
|
|
460
|
+
b.appendChild(c);
|
|
461
|
+
for (let e = 0; e < this.arguments_.length; e++) {
|
|
462
|
+
const f = $.createElement$$module$build$src$core$utils$xml("block");
|
|
463
|
+
f.setAttribute("type", "procedures_mutatorarg");
|
|
464
|
+
var d = $.createElement$$module$build$src$core$utils$xml("field");
|
|
465
|
+
d.setAttribute(
|
|
466
|
+
"name",
|
|
467
|
+
"NAME"
|
|
468
|
+
);
|
|
469
|
+
const g = $.createTextNode$$module$build$src$core$utils$xml(this.arguments_[e]);
|
|
470
|
+
d.appendChild(g);
|
|
471
|
+
f.appendChild(d);
|
|
472
|
+
d = $.createElement$$module$build$src$core$utils$xml("next");
|
|
473
|
+
f.appendChild(d);
|
|
474
|
+
c.appendChild(f);
|
|
475
|
+
c = d;
|
|
476
|
+
}
|
|
477
|
+
a = $.domToBlock$$module$build$src$core$xml(b, a);
|
|
478
|
+
this.type === "procedures_defreturn" ? a.setFieldValue(this.hasStatements_, "STATEMENTS") : a.removeInput("STATEMENT_INPUT");
|
|
479
|
+
$.mutateCallers$$module$build$src$core$procedures(this);
|
|
480
|
+
return a;
|
|
481
|
+
}, compose: function(a) {
|
|
482
|
+
this.arguments_ = [];
|
|
483
|
+
this.paramIds_ = [];
|
|
484
|
+
this.argumentVarModels_ = [];
|
|
485
|
+
let b = a.getInputTargetBlock("STACK");
|
|
486
|
+
for (; b && !b.isInsertionMarker(); ) {
|
|
487
|
+
var c = b.getFieldValue("NAME");
|
|
488
|
+
this.arguments_.push(c);
|
|
489
|
+
c = this.workspace.getVariable(c, "");
|
|
490
|
+
this.argumentVarModels_.push(c);
|
|
491
|
+
this.paramIds_.push(b.id);
|
|
492
|
+
b = b.nextConnection && b.nextConnection.targetBlock();
|
|
493
|
+
}
|
|
494
|
+
this.updateParams_();
|
|
495
|
+
$.mutateCallers$$module$build$src$core$procedures(this);
|
|
496
|
+
a = a.getFieldValue("STATEMENTS");
|
|
497
|
+
if (a !== null && (a = a === "TRUE", this.hasStatements_ !== a)) if (a) {
|
|
498
|
+
this.setStatements_(true);
|
|
499
|
+
var d;
|
|
500
|
+
(d = this.statementConnection_) == null || d.reconnect(this, "STACK");
|
|
501
|
+
this.statementConnection_ = null;
|
|
502
|
+
} else {
|
|
503
|
+
d = this.getInput("STACK").connection;
|
|
504
|
+
if (this.statementConnection_ = d.targetConnection) d = d.targetBlock(), d.unplug(), d.bumpNeighbours();
|
|
505
|
+
this.setStatements_(false);
|
|
506
|
+
}
|
|
507
|
+
}, getVars: function() {
|
|
508
|
+
return this.arguments_;
|
|
509
|
+
}, getVarModels: function() {
|
|
510
|
+
return this.argumentVarModels_;
|
|
511
|
+
}, renameVarById: function(a, b) {
|
|
512
|
+
var c = this.workspace.getVariableById(a);
|
|
513
|
+
if (c.getType() === "") {
|
|
514
|
+
c = c.getName();
|
|
515
|
+
b = this.workspace.getVariableById(b);
|
|
516
|
+
var d = false;
|
|
517
|
+
for (let e = 0; e < this.argumentVarModels_.length; e++) this.argumentVarModels_[e].getId() === a && (this.arguments_[e] = b.getName(), this.argumentVarModels_[e] = b, d = true);
|
|
518
|
+
d && (this.displayRenamedVar_(c, b.getName()), $.mutateCallers$$module$build$src$core$procedures(this));
|
|
519
|
+
}
|
|
520
|
+
}, updateVarName: function(a) {
|
|
521
|
+
const b = a.getName();
|
|
522
|
+
let c = false, d;
|
|
523
|
+
for (let e = 0; e < this.argumentVarModels_.length; e++) this.argumentVarModels_[e].getId() === a.getId() && (d = this.arguments_[e], this.arguments_[e] = b, c = true);
|
|
524
|
+
c && (this.displayRenamedVar_(d, b), $.mutateCallers$$module$build$src$core$procedures(this));
|
|
525
|
+
}, displayRenamedVar_: function(a, b) {
|
|
526
|
+
this.updateParams_();
|
|
527
|
+
var c = this.getIcon($.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE);
|
|
528
|
+
if (c && c.bubbleIsVisible()) {
|
|
529
|
+
c = c.getWorkspace().getAllBlocks(false);
|
|
530
|
+
for (let d = 0, e; e = c[d]; d++) e.type === "procedures_mutatorarg" && $.Names$$module$build$src$core$names.equals(a, e.getFieldValue("NAME")) && e.setFieldValue(b, "NAME");
|
|
531
|
+
}
|
|
532
|
+
}, customContextMenu: function(a) {
|
|
533
|
+
if (!this.isInFlyout) {
|
|
534
|
+
var b = this.getFieldValue("NAME"), c = { type: this.callType_, extraState: { name: b, params: this.arguments_ } };
|
|
535
|
+
a.push({ enabled: true, text: $.Msg$$module$build$src$core$msg.PROCEDURES_CREATE_DO.replace(
|
|
536
|
+
"%1",
|
|
537
|
+
b
|
|
538
|
+
), callback: $.callbackFactory$$module$build$src$core$contextmenu(this, c) });
|
|
539
|
+
if (!this.isCollapsed()) for (b = 0; b < this.argumentVarModels_.length; b++) {
|
|
540
|
+
c = this.argumentVarModels_[b];
|
|
541
|
+
const d = { type: "variables_get", fields: { VAR: { name: c.getName(), id: c.getId(), type: c.getType() } } };
|
|
542
|
+
a.push({ enabled: true, text: $.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET.replace("%1", c.getName()), callback: $.callbackFactory$$module$build$src$core$contextmenu(this, d) });
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
} };
|
|
546
|
+
blocks$$module$build$src$blocks$procedures.procedures_defnoreturn = Object.assign({}, PROCEDURE_DEF_COMMON$$module$build$src$blocks$procedures, { init: function() {
|
|
547
|
+
var a = $.findLegalName$$module$build$src$core$procedures("", this);
|
|
548
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_input", text: a });
|
|
549
|
+
a.setValidator($.rename$$module$build$src$core$procedures);
|
|
550
|
+
a.setSpellcheck(false);
|
|
551
|
+
this.appendDummyInput().appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a, "NAME").appendField(
|
|
552
|
+
"",
|
|
553
|
+
"PARAMS"
|
|
554
|
+
);
|
|
555
|
+
this.setMutator(new $.MutatorIcon$$module$build$src$core$icons$mutator_icon(["procedures_mutatorarg"], this));
|
|
556
|
+
(this.workspace.options.comments || this.workspace.options.parentWorkspace && this.workspace.options.parentWorkspace.options.comments) && $.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_COMMENT && this.setCommentText($.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_COMMENT);
|
|
557
|
+
this.setStyle("procedure_blocks");
|
|
558
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_TOOLTIP);
|
|
559
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_HELPURL);
|
|
560
|
+
this.arguments_ = [];
|
|
561
|
+
this.argumentVarModels_ = [];
|
|
562
|
+
this.setStatements_(true);
|
|
563
|
+
this.statementConnection_ = null;
|
|
564
|
+
}, getProcedureDef: function() {
|
|
565
|
+
return [this.getFieldValue("NAME"), this.arguments_, false];
|
|
566
|
+
}, callType_: "procedures_callnoreturn" });
|
|
567
|
+
blocks$$module$build$src$blocks$procedures.procedures_defreturn = Object.assign({}, PROCEDURE_DEF_COMMON$$module$build$src$blocks$procedures, { init: function() {
|
|
568
|
+
var a = $.findLegalName$$module$build$src$core$procedures("", this);
|
|
569
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_input", text: a });
|
|
570
|
+
a.setValidator($.rename$$module$build$src$core$procedures);
|
|
571
|
+
a.setSpellcheck(false);
|
|
572
|
+
this.appendDummyInput().appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_TITLE).appendField(a, "NAME").appendField(
|
|
573
|
+
"",
|
|
574
|
+
"PARAMS"
|
|
575
|
+
);
|
|
576
|
+
this.appendValueInput("RETURN").setAlign($.Align$$module$build$src$core$inputs$align.RIGHT).appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN);
|
|
577
|
+
this.setMutator(new $.MutatorIcon$$module$build$src$core$icons$mutator_icon(["procedures_mutatorarg"], this));
|
|
578
|
+
(this.workspace.options.comments || this.workspace.options.parentWorkspace && this.workspace.options.parentWorkspace.options.comments) && $.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_COMMENT && this.setCommentText($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_COMMENT);
|
|
579
|
+
this.setStyle("procedure_blocks");
|
|
580
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_TOOLTIP);
|
|
581
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_HELPURL);
|
|
582
|
+
this.arguments_ = [];
|
|
583
|
+
this.argumentVarModels_ = [];
|
|
584
|
+
this.setStatements_(true);
|
|
585
|
+
this.statementConnection_ = null;
|
|
586
|
+
}, getProcedureDef: function() {
|
|
587
|
+
return [this.getFieldValue("NAME"), this.arguments_, true];
|
|
588
|
+
}, callType_: "procedures_callreturn" });
|
|
589
|
+
var PROCEDURES_MUTATORCONTAINER$$module$build$src$blocks$procedures = { init: function() {
|
|
590
|
+
this.appendDummyInput().appendField($.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORCONTAINER_TITLE);
|
|
591
|
+
this.appendStatementInput("STACK");
|
|
592
|
+
this.appendDummyInput("STATEMENT_INPUT").appendField($.Msg$$module$build$src$core$msg.PROCEDURES_ALLOW_STATEMENTS).appendField($.fromJson$$module$build$src$core$field_registry({ type: "field_checkbox", checked: true }), "STATEMENTS");
|
|
593
|
+
this.setStyle("procedure_blocks");
|
|
594
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
|
|
595
|
+
this.contextMenu = false;
|
|
596
|
+
} };
|
|
597
|
+
blocks$$module$build$src$blocks$procedures.procedures_mutatorcontainer = PROCEDURES_MUTATORCONTAINER$$module$build$src$blocks$procedures;
|
|
598
|
+
var ProcedureArgumentField$$module$build$src$blocks$procedures = class extends $.FieldTextInput$$module$build$src$core$field_textinput {
|
|
599
|
+
constructor() {
|
|
600
|
+
super(...arguments);
|
|
601
|
+
this.editingInteractively = false;
|
|
602
|
+
}
|
|
603
|
+
showEditor_(a) {
|
|
604
|
+
super.showEditor_(a);
|
|
605
|
+
this.editingInteractively = true;
|
|
606
|
+
this.editingVariable = void 0;
|
|
607
|
+
}
|
|
608
|
+
onFinishEditing_(a) {
|
|
609
|
+
super.onFinishEditing_(a);
|
|
610
|
+
this.editingInteractively = false;
|
|
611
|
+
}
|
|
612
|
+
}, PROCEDURES_MUTATORARGUMENT$$module$build$src$blocks$procedures = { init: function() {
|
|
613
|
+
const a = new ProcedureArgumentField$$module$build$src$blocks$procedures(
|
|
614
|
+
$.DEFAULT_ARG$$module$build$src$core$procedures,
|
|
615
|
+
this.validator_
|
|
616
|
+
);
|
|
617
|
+
this.appendDummyInput().appendField($.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORARG_TITLE).appendField(a, "NAME");
|
|
618
|
+
this.setPreviousStatement(true);
|
|
619
|
+
this.setNextStatement(true);
|
|
620
|
+
this.setStyle("procedure_blocks");
|
|
621
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.PROCEDURES_MUTATORARG_TOOLTIP);
|
|
622
|
+
this.contextMenu = false;
|
|
623
|
+
}, validator_: function(a) {
|
|
624
|
+
var b = this.getSourceBlock();
|
|
625
|
+
const c = b.workspace.getRootWorkspace();
|
|
626
|
+
a = a.replace(/[\s\xa0]+/g, " ").replace(/^ | $/g, "");
|
|
627
|
+
if (!a) return null;
|
|
628
|
+
const d = (b.workspace.targetWorkspace || b.workspace).getAllBlocks(false), e = a.toLowerCase();
|
|
629
|
+
for (let f = 0; f < d.length; f++) {
|
|
630
|
+
if (d[f].id === this.getSourceBlock().id) continue;
|
|
631
|
+
const g = d[f].getFieldValue("NAME");
|
|
632
|
+
if (g && g.toLowerCase() === e) return null;
|
|
633
|
+
}
|
|
634
|
+
if (b.isInFlyout) return a;
|
|
635
|
+
(b = c.getVariable(a, "")) && b.getName() !== a && c.renameVariableById(b.getId(), a);
|
|
636
|
+
b || (this.editingInteractively ? this.editingVariable ? c.renameVariableById(this.editingVariable.getId(), a) : this.editingVariable = c.createVariable(a, "") : c.createVariable(a, ""));
|
|
637
|
+
return a;
|
|
638
|
+
} };
|
|
639
|
+
blocks$$module$build$src$blocks$procedures.procedures_mutatorarg = PROCEDURES_MUTATORARGUMENT$$module$build$src$blocks$procedures;
|
|
640
|
+
var DISABLED_PROCEDURE_DEFINITION_DISABLED_REASON$$module$build$src$blocks$procedures = "DISABLED_PROCEDURE_DEFINITION", PROCEDURE_CALL_COMMON$$module$build$src$blocks$procedures = { getProcedureCall: function() {
|
|
641
|
+
return this.getFieldValue("NAME");
|
|
642
|
+
}, renameProcedure: function(a, b) {
|
|
643
|
+
$.Names$$module$build$src$core$names.equals(a, this.getProcedureCall()) && (this.setFieldValue(b, "NAME"), this.setTooltip((this.outputConnection ? $.Msg$$module$build$src$core$msg.PROCEDURES_CALLRETURN_TOOLTIP : $.Msg$$module$build$src$core$msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace(
|
|
644
|
+
"%1",
|
|
645
|
+
b
|
|
646
|
+
)));
|
|
647
|
+
}, setProcedureParameters_: function(a, b) {
|
|
648
|
+
var c = $.getDefinition$$module$build$src$core$procedures(this.getProcedureCall(), this.workspace);
|
|
649
|
+
(c = (c = c && c.getIcon($.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)) && c.bubbleIsVisible()) ? this.setCollapsed(false) : (this.quarkConnections_ = {}, this.quarkIds_ = null);
|
|
650
|
+
if (a.join("\n") === this.arguments_.join("\n")) this.quarkIds_ = b;
|
|
651
|
+
else {
|
|
652
|
+
if (b.length !== a.length) throw RangeError("paramNames and paramIds must be the same length.");
|
|
653
|
+
this.quarkIds_ || (this.quarkConnections_ = {}, this.quarkIds_ = []);
|
|
654
|
+
for (let e = 0; e < this.arguments_.length; e++) {
|
|
655
|
+
var d = this.getInput("ARG" + e);
|
|
656
|
+
d && (d = d.connection.targetConnection, this.quarkConnections_[this.quarkIds_[e]] = d, c && d && !b.includes(this.quarkIds_[e]) && (d.disconnect(), d.getSourceBlock().bumpNeighbours()));
|
|
657
|
+
}
|
|
658
|
+
this.arguments_ = [].concat(a);
|
|
659
|
+
this.argumentVarModels_ = [];
|
|
660
|
+
for (a = 0; a < this.arguments_.length; a++) c = $.getOrCreateVariablePackage$$module$build$src$core$variables(this.workspace, null, this.arguments_[a], ""), this.argumentVarModels_.push(c);
|
|
661
|
+
this.updateShape_();
|
|
662
|
+
if (this.quarkIds_ = b) {
|
|
663
|
+
for (b = 0; b < this.arguments_.length; b++) if (a = this.quarkIds_[b], a in this.quarkConnections_) {
|
|
664
|
+
let e;
|
|
665
|
+
((e = this.quarkConnections_[a]) == null ? 0 : e.reconnect(this, "ARG" + b)) || delete this.quarkConnections_[a];
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}, updateShape_: function() {
|
|
670
|
+
for (var a = 0; a < this.arguments_.length; a++) {
|
|
671
|
+
var b = this.getField("ARGNAME" + a);
|
|
672
|
+
if (b) {
|
|
673
|
+
$.disable$$module$build$src$core$events$utils();
|
|
674
|
+
try {
|
|
675
|
+
b.setValue(this.arguments_[a]);
|
|
676
|
+
} finally {
|
|
677
|
+
$.enable$$module$build$src$core$events$utils();
|
|
678
|
+
}
|
|
679
|
+
} else b = $.fromJson$$module$build$src$core$field_registry({
|
|
680
|
+
type: "field_label",
|
|
681
|
+
text: this.arguments_[a]
|
|
682
|
+
}), this.appendValueInput("ARG" + a).setAlign($.Align$$module$build$src$core$inputs$align.RIGHT).appendField(b, "ARGNAME" + a);
|
|
683
|
+
}
|
|
684
|
+
for (a = this.arguments_.length; this.getInput("ARG" + a); a++) this.removeInput("ARG" + a);
|
|
685
|
+
(a = this.getInput("TOPROW")) && (this.arguments_.length ? this.getField("WITH") || a.appendField($.Msg$$module$build$src$core$msg.PROCEDURES_CALL_BEFORE_PARAMS, "WITH") : this.getField("WITH") && a.removeField("WITH"));
|
|
686
|
+
}, mutationToDom: function() {
|
|
687
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
688
|
+
a.setAttribute("name", this.getProcedureCall());
|
|
689
|
+
for (let b = 0; b < this.arguments_.length; b++) {
|
|
690
|
+
const c = $.createElement$$module$build$src$core$utils$xml("arg");
|
|
691
|
+
c.setAttribute("name", this.arguments_[b]);
|
|
692
|
+
a.appendChild(c);
|
|
693
|
+
}
|
|
694
|
+
return a;
|
|
695
|
+
}, domToMutation: function(a) {
|
|
696
|
+
var b = a.getAttribute("name");
|
|
697
|
+
this.renameProcedure(this.getProcedureCall(), b);
|
|
698
|
+
b = [];
|
|
699
|
+
const c = [];
|
|
700
|
+
for (let d = 0, e; e = a.childNodes[d]; d++) e.nodeName.toLowerCase() === "arg" && (b.push(e.getAttribute("name")), c.push(e.getAttribute("paramId")));
|
|
701
|
+
this.setProcedureParameters_(
|
|
702
|
+
b,
|
|
703
|
+
c
|
|
704
|
+
);
|
|
705
|
+
}, saveExtraState: function() {
|
|
706
|
+
const a = /* @__PURE__ */ Object.create(null);
|
|
707
|
+
a.name = this.getProcedureCall();
|
|
708
|
+
this.arguments_.length && (a.params = this.arguments_);
|
|
709
|
+
return a;
|
|
710
|
+
}, loadExtraState: function(a) {
|
|
711
|
+
this.renameProcedure(this.getProcedureCall(), a.name);
|
|
712
|
+
if (a = a.params) {
|
|
713
|
+
const b = [];
|
|
714
|
+
b.length = a.length;
|
|
715
|
+
b.fill(null);
|
|
716
|
+
this.setProcedureParameters_(a, b);
|
|
717
|
+
}
|
|
718
|
+
}, getVars: function() {
|
|
719
|
+
return this.arguments_;
|
|
720
|
+
}, getVarModels: function() {
|
|
721
|
+
return this.argumentVarModels_;
|
|
722
|
+
}, onchange: function(a) {
|
|
723
|
+
if (this.workspace && !this.workspace.isFlyout && a.recordUndo) if (a.type === $.BLOCK_CREATE$$module$build$src$core$events$events && a.ids.includes(this.id)) {
|
|
724
|
+
var b = this.getProcedureCall(), c = $.getDefinition$$module$build$src$core$procedures(b, this.workspace);
|
|
725
|
+
!c || c.type === this.defType_ && JSON.stringify(c.getVars()) === JSON.stringify(this.arguments_) || (c = null);
|
|
726
|
+
if (c) c.isEnabled() || (this.setDisabledReason(true, DISABLED_PROCEDURE_DEFINITION_DISABLED_REASON$$module$build$src$blocks$procedures), this.setWarningText($.Msg$$module$build$src$core$msg.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace(
|
|
727
|
+
"%1",
|
|
728
|
+
b
|
|
729
|
+
)));
|
|
730
|
+
else {
|
|
731
|
+
$.setGroup$$module$build$src$core$events$utils(a.group);
|
|
732
|
+
a = $.createElement$$module$build$src$core$utils$xml("xml");
|
|
733
|
+
b = $.createElement$$module$build$src$core$utils$xml("block");
|
|
734
|
+
b.setAttribute("type", this.defType_);
|
|
735
|
+
c = this.getRelativeToSurfaceXY();
|
|
736
|
+
var d = c.y + $.config$$module$build$src$core$config.snapRadius * 2;
|
|
737
|
+
b.setAttribute("x", `${c.x + $.config$$module$build$src$core$config.snapRadius * (this.RTL ? -1 : 1)}`);
|
|
738
|
+
b.setAttribute("y", `${d}`);
|
|
739
|
+
c = this.mutationToDom();
|
|
740
|
+
b.appendChild(c);
|
|
741
|
+
c = $.createElement$$module$build$src$core$utils$xml("field");
|
|
742
|
+
c.setAttribute("name", "NAME");
|
|
743
|
+
d = this.getProcedureCall();
|
|
744
|
+
const e = $.findLegalName$$module$build$src$core$procedures(d, this);
|
|
745
|
+
d !== e && this.renameProcedure(d, e);
|
|
746
|
+
c.appendChild($.createTextNode$$module$build$src$core$utils$xml(d));
|
|
747
|
+
b.appendChild(c);
|
|
748
|
+
a.appendChild(b);
|
|
749
|
+
$.domToWorkspace$$module$build$src$core$xml(a, this.workspace);
|
|
750
|
+
$.setGroup$$module$build$src$core$events$utils(false);
|
|
751
|
+
}
|
|
752
|
+
} else a.type === $.BLOCK_DELETE$$module$build$src$core$events$events ? (b = this.getProcedureCall(), $.getDefinition$$module$build$src$core$procedures(
|
|
753
|
+
b,
|
|
754
|
+
this.workspace
|
|
755
|
+
) || ($.setGroup$$module$build$src$core$events$utils(a.group), this.dispose(true), $.setGroup$$module$build$src$core$events$utils(false))) : a.type === $.BLOCK_CHANGE$$module$build$src$core$events$events && a.element === "disabled" && (b = this.getProcedureCall(), (d = $.getDefinition$$module$build$src$core$procedures(b, this.workspace)) && d.id === a.blockId && ((c = $.getGroup$$module$build$src$core$events$utils()) && console.log("Saw an existing group while responding to a definition change"), $.setGroup$$module$build$src$core$events$utils(a.group), a = d.isEnabled(), this.setDisabledReason(!a, DISABLED_PROCEDURE_DEFINITION_DISABLED_REASON$$module$build$src$blocks$procedures), this.setWarningText(a ? null : $.Msg$$module$build$src$core$msg.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace("%1", b)), $.setGroup$$module$build$src$core$events$utils(c)));
|
|
756
|
+
}, customContextMenu: function(a) {
|
|
757
|
+
if (this.workspace.isMovable()) {
|
|
758
|
+
var b = this.getProcedureCall(), c = this.workspace;
|
|
759
|
+
a.push({ enabled: true, text: $.Msg$$module$build$src$core$msg.PROCEDURES_HIGHLIGHT_DEF, callback: function() {
|
|
760
|
+
const d = $.getDefinition$$module$build$src$core$procedures(b, c);
|
|
761
|
+
d && (c.centerOnBlock(d.id), $.getFocusManager$$module$build$src$core$focus_manager().focusNode(d));
|
|
762
|
+
} });
|
|
763
|
+
}
|
|
764
|
+
} };
|
|
765
|
+
blocks$$module$build$src$blocks$procedures.procedures_callnoreturn = Object.assign({}, PROCEDURE_CALL_COMMON$$module$build$src$blocks$procedures, { init: function() {
|
|
766
|
+
this.appendDummyInput("TOPROW").appendField("", "NAME");
|
|
767
|
+
this.setPreviousStatement(true);
|
|
768
|
+
this.setNextStatement(true);
|
|
769
|
+
this.setStyle("procedure_blocks");
|
|
770
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.PROCEDURES_CALLNORETURN_HELPURL);
|
|
771
|
+
this.arguments_ = [];
|
|
772
|
+
this.argumentVarModels_ = [];
|
|
773
|
+
this.quarkConnections_ = {};
|
|
774
|
+
this.quarkIds_ = null;
|
|
775
|
+
}, defType_: "procedures_defnoreturn" });
|
|
776
|
+
blocks$$module$build$src$blocks$procedures.procedures_callreturn = Object.assign({}, PROCEDURE_CALL_COMMON$$module$build$src$blocks$procedures, { init: function() {
|
|
777
|
+
this.appendDummyInput("TOPROW").appendField("", "NAME");
|
|
778
|
+
this.setOutput(true);
|
|
779
|
+
this.setStyle("procedure_blocks");
|
|
780
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.PROCEDURES_CALLRETURN_HELPURL);
|
|
781
|
+
this.arguments_ = [];
|
|
782
|
+
this.argumentVarModels_ = [];
|
|
783
|
+
this.quarkConnections_ = {};
|
|
784
|
+
this.quarkIds_ = null;
|
|
785
|
+
}, defType_: "procedures_defreturn" });
|
|
786
|
+
var UNPARENTED_IFRETURN_DISABLED_REASON$$module$build$src$blocks$procedures = "UNPARENTED_IFRETURN", PROCEDURES_IFRETURN$$module$build$src$blocks$procedures = {
|
|
787
|
+
init: function() {
|
|
788
|
+
this.appendValueInput("CONDITION").setCheck("Boolean").appendField($.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_IF);
|
|
789
|
+
this.appendValueInput("VALUE").appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN);
|
|
790
|
+
this.setInputsInline(true);
|
|
791
|
+
this.setPreviousStatement(true);
|
|
792
|
+
this.setNextStatement(true);
|
|
793
|
+
this.setStyle("procedure_blocks");
|
|
794
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_TOOLTIP);
|
|
795
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_HELPURL);
|
|
796
|
+
this.hasReturnValue_ = true;
|
|
797
|
+
},
|
|
798
|
+
mutationToDom: function() {
|
|
799
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
800
|
+
a.setAttribute("value", String(Number(this.hasReturnValue_)));
|
|
801
|
+
return a;
|
|
802
|
+
},
|
|
803
|
+
domToMutation: function(a) {
|
|
804
|
+
this.hasReturnValue_ = a.getAttribute("value") === "1";
|
|
805
|
+
this.hasReturnValue_ || (this.removeInput("VALUE"), this.appendDummyInput("VALUE").appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN));
|
|
806
|
+
},
|
|
807
|
+
onchange: function(a) {
|
|
808
|
+
if (!(this.workspace.isDragging && this.workspace.isDragging() || a.type !== $.BLOCK_MOVE$$module$build$src$core$events$events && a.type !== $.BLOCK_CREATE$$module$build$src$core$events$events)) {
|
|
809
|
+
a = false;
|
|
810
|
+
var b = this;
|
|
811
|
+
do {
|
|
812
|
+
if (this.FUNCTION_TYPES.includes(b.type)) {
|
|
813
|
+
a = true;
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
b = b.getSurroundParent();
|
|
817
|
+
} while (b);
|
|
818
|
+
a ? (b.type === "procedures_defnoreturn" && this.hasReturnValue_ ? (this.removeInput("VALUE"), this.appendDummyInput("VALUE").appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN), this.hasReturnValue_ = false) : b.type !== "procedures_defreturn" || this.hasReturnValue_ || (this.removeInput("VALUE"), this.appendValueInput("VALUE").appendField($.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_RETURN), this.hasReturnValue_ = true), this.setWarningText(null)) : this.setWarningText($.Msg$$module$build$src$core$msg.PROCEDURES_IFRETURN_WARNING);
|
|
819
|
+
if (!this.isInFlyout) try {
|
|
820
|
+
$.setRecordUndo$$module$build$src$core$events$utils(false), this.setDisabledReason(!a, UNPARENTED_IFRETURN_DISABLED_REASON$$module$build$src$blocks$procedures);
|
|
821
|
+
} finally {
|
|
822
|
+
$.setRecordUndo$$module$build$src$core$events$utils(true);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
FUNCTION_TYPES: ["procedures_defnoreturn", "procedures_defreturn"]
|
|
827
|
+
};
|
|
828
|
+
blocks$$module$build$src$blocks$procedures.procedures_ifreturn = PROCEDURES_IFRETURN$$module$build$src$blocks$procedures;
|
|
829
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$procedures);
|
|
830
|
+
var module$build$src$blocks$procedures = { blocks: blocks$$module$build$src$blocks$procedures };
|
|
831
|
+
var blocks$$module$build$src$blocks$math = $.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([
|
|
832
|
+
{ type: "math_number", message0: "%1", args0: [{ type: "field_number", name: "NUM", value: 0 }], output: "Number", helpUrl: "%{BKY_MATH_NUMBER_HELPURL}", style: "math_blocks", tooltip: "%{BKY_MATH_NUMBER_TOOLTIP}", extensions: ["parent_tooltip_when_inline"] },
|
|
833
|
+
{ type: "math_arithmetic", message0: "%1 %2 %3", args0: [{ type: "input_value", name: "A", check: "Number" }, { type: "field_dropdown", name: "OP", options: [[
|
|
834
|
+
"%{BKY_MATH_ADDITION_SYMBOL}",
|
|
835
|
+
"ADD"
|
|
836
|
+
], ["%{BKY_MATH_SUBTRACTION_SYMBOL}", "MINUS"], ["%{BKY_MATH_MULTIPLICATION_SYMBOL}", "MULTIPLY"], ["%{BKY_MATH_DIVISION_SYMBOL}", "DIVIDE"], ["%{BKY_MATH_POWER_SYMBOL}", "POWER"]] }, { type: "input_value", name: "B", check: "Number" }], inputsInline: true, output: "Number", style: "math_blocks", helpUrl: "%{BKY_MATH_ARITHMETIC_HELPURL}", extensions: ["math_op_tooltip"] },
|
|
837
|
+
{ type: "math_single", message0: "%1 %2", args0: [{ type: "field_dropdown", name: "OP", options: [["%{BKY_MATH_SINGLE_OP_ROOT}", "ROOT"], [
|
|
838
|
+
"%{BKY_MATH_SINGLE_OP_ABSOLUTE}",
|
|
839
|
+
"ABS"
|
|
840
|
+
], ["-", "NEG"], ["ln", "LN"], ["log10", "LOG10"], ["e^", "EXP"], ["10^", "POW10"]] }, { type: "input_value", name: "NUM", check: "Number" }], output: "Number", style: "math_blocks", helpUrl: "%{BKY_MATH_SINGLE_HELPURL}", extensions: ["math_op_tooltip"] },
|
|
841
|
+
{ type: "math_trig", message0: "%1 %2", args0: [{ type: "field_dropdown", name: "OP", options: [["%{BKY_MATH_TRIG_SIN}", "SIN"], ["%{BKY_MATH_TRIG_COS}", "COS"], ["%{BKY_MATH_TRIG_TAN}", "TAN"], ["%{BKY_MATH_TRIG_ASIN}", "ASIN"], ["%{BKY_MATH_TRIG_ACOS}", "ACOS"], [
|
|
842
|
+
"%{BKY_MATH_TRIG_ATAN}",
|
|
843
|
+
"ATAN"
|
|
844
|
+
]] }, { type: "input_value", name: "NUM", check: "Number" }], output: "Number", style: "math_blocks", helpUrl: "%{BKY_MATH_TRIG_HELPURL}", extensions: ["math_op_tooltip"] },
|
|
845
|
+
{ type: "math_constant", message0: "%1", args0: [{ type: "field_dropdown", name: "CONSTANT", options: [["π", "PI"], ["e", "E"], ["φ", "GOLDEN_RATIO"], ["sqrt(2)", "SQRT2"], ["sqrt(½)", "SQRT1_2"], ["∞", "INFINITY"]] }], output: "Number", style: "math_blocks", tooltip: "%{BKY_MATH_CONSTANT_TOOLTIP}", helpUrl: "%{BKY_MATH_CONSTANT_HELPURL}" },
|
|
846
|
+
{
|
|
847
|
+
type: "math_number_property",
|
|
848
|
+
message0: "%1 %2",
|
|
849
|
+
args0: [{ type: "input_value", name: "NUMBER_TO_CHECK", check: "Number" }, { type: "field_dropdown", name: "PROPERTY", options: [["%{BKY_MATH_IS_EVEN}", "EVEN"], ["%{BKY_MATH_IS_ODD}", "ODD"], ["%{BKY_MATH_IS_PRIME}", "PRIME"], ["%{BKY_MATH_IS_WHOLE}", "WHOLE"], ["%{BKY_MATH_IS_POSITIVE}", "POSITIVE"], ["%{BKY_MATH_IS_NEGATIVE}", "NEGATIVE"], ["%{BKY_MATH_IS_DIVISIBLE_BY}", "DIVISIBLE_BY"]] }],
|
|
850
|
+
inputsInline: true,
|
|
851
|
+
output: "Boolean",
|
|
852
|
+
style: "math_blocks",
|
|
853
|
+
tooltip: "%{BKY_MATH_IS_TOOLTIP}",
|
|
854
|
+
mutator: "math_is_divisibleby_mutator"
|
|
855
|
+
},
|
|
856
|
+
{ type: "math_change", message0: "%{BKY_MATH_CHANGE_TITLE}", args0: [{ type: "field_variable", name: "VAR", variable: "%{BKY_MATH_CHANGE_TITLE_ITEM}" }, { type: "input_value", name: "DELTA", check: "Number" }], previousStatement: null, nextStatement: null, style: "variable_blocks", helpUrl: "%{BKY_MATH_CHANGE_HELPURL}", extensions: ["math_change_tooltip"] },
|
|
857
|
+
{ type: "math_round", message0: "%1 %2", args0: [{ type: "field_dropdown", name: "OP", options: [
|
|
858
|
+
["%{BKY_MATH_ROUND_OPERATOR_ROUND}", "ROUND"],
|
|
859
|
+
["%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}", "ROUNDUP"],
|
|
860
|
+
["%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}", "ROUNDDOWN"]
|
|
861
|
+
] }, { type: "input_value", name: "NUM", check: "Number" }], output: "Number", style: "math_blocks", helpUrl: "%{BKY_MATH_ROUND_HELPURL}", tooltip: "%{BKY_MATH_ROUND_TOOLTIP}" },
|
|
862
|
+
{ type: "math_on_list", message0: "%1 %2", args0: [{ type: "field_dropdown", name: "OP", options: [["%{BKY_MATH_ONLIST_OPERATOR_SUM}", "SUM"], ["%{BKY_MATH_ONLIST_OPERATOR_MIN}", "MIN"], ["%{BKY_MATH_ONLIST_OPERATOR_MAX}", "MAX"], ["%{BKY_MATH_ONLIST_OPERATOR_AVERAGE}", "AVERAGE"], [
|
|
863
|
+
"%{BKY_MATH_ONLIST_OPERATOR_MEDIAN}",
|
|
864
|
+
"MEDIAN"
|
|
865
|
+
], ["%{BKY_MATH_ONLIST_OPERATOR_MODE}", "MODE"], ["%{BKY_MATH_ONLIST_OPERATOR_STD_DEV}", "STD_DEV"], ["%{BKY_MATH_ONLIST_OPERATOR_RANDOM}", "RANDOM"]] }, { type: "input_value", name: "LIST", check: "Array" }], output: "Number", style: "math_blocks", helpUrl: "%{BKY_MATH_ONLIST_HELPURL}", mutator: "math_modes_of_list_mutator", extensions: ["math_op_tooltip"] },
|
|
866
|
+
{
|
|
867
|
+
type: "math_modulo",
|
|
868
|
+
message0: "%{BKY_MATH_MODULO_TITLE}",
|
|
869
|
+
args0: [{ type: "input_value", name: "DIVIDEND", check: "Number" }, { type: "input_value", name: "DIVISOR", check: "Number" }],
|
|
870
|
+
inputsInline: true,
|
|
871
|
+
output: "Number",
|
|
872
|
+
style: "math_blocks",
|
|
873
|
+
tooltip: "%{BKY_MATH_MODULO_TOOLTIP}",
|
|
874
|
+
helpUrl: "%{BKY_MATH_MODULO_HELPURL}"
|
|
875
|
+
},
|
|
876
|
+
{ type: "math_constrain", message0: "%{BKY_MATH_CONSTRAIN_TITLE}", args0: [{ type: "input_value", name: "VALUE", check: "Number" }, { type: "input_value", name: "LOW", check: "Number" }, { type: "input_value", name: "HIGH", check: "Number" }], inputsInline: true, output: "Number", style: "math_blocks", tooltip: "%{BKY_MATH_CONSTRAIN_TOOLTIP}", helpUrl: "%{BKY_MATH_CONSTRAIN_HELPURL}" },
|
|
877
|
+
{
|
|
878
|
+
type: "math_random_int",
|
|
879
|
+
message0: "%{BKY_MATH_RANDOM_INT_TITLE}",
|
|
880
|
+
args0: [{ type: "input_value", name: "FROM", check: "Number" }, { type: "input_value", name: "TO", check: "Number" }],
|
|
881
|
+
inputsInline: true,
|
|
882
|
+
output: "Number",
|
|
883
|
+
style: "math_blocks",
|
|
884
|
+
tooltip: "%{BKY_MATH_RANDOM_INT_TOOLTIP}",
|
|
885
|
+
helpUrl: "%{BKY_MATH_RANDOM_INT_HELPURL}"
|
|
886
|
+
},
|
|
887
|
+
{ type: "math_random_float", message0: "%{BKY_MATH_RANDOM_FLOAT_TITLE_RANDOM}", output: "Number", style: "math_blocks", tooltip: "%{BKY_MATH_RANDOM_FLOAT_TOOLTIP}", helpUrl: "%{BKY_MATH_RANDOM_FLOAT_HELPURL}" },
|
|
888
|
+
{ type: "math_atan2", message0: "%{BKY_MATH_ATAN2_TITLE}", args0: [{
|
|
889
|
+
type: "input_value",
|
|
890
|
+
name: "X",
|
|
891
|
+
check: "Number"
|
|
892
|
+
}, { type: "input_value", name: "Y", check: "Number" }], inputsInline: true, output: "Number", style: "math_blocks", tooltip: "%{BKY_MATH_ATAN2_TOOLTIP}", helpUrl: "%{BKY_MATH_ATAN2_HELPURL}" }
|
|
893
|
+
]), TOOLTIPS_BY_OP$$module$build$src$blocks$math = {
|
|
894
|
+
ADD: "%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",
|
|
895
|
+
MINUS: "%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}",
|
|
896
|
+
MULTIPLY: "%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}",
|
|
897
|
+
DIVIDE: "%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}",
|
|
898
|
+
POWER: "%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}",
|
|
899
|
+
ROOT: "%{BKY_MATH_SINGLE_TOOLTIP_ROOT}",
|
|
900
|
+
ABS: "%{BKY_MATH_SINGLE_TOOLTIP_ABS}",
|
|
901
|
+
NEG: "%{BKY_MATH_SINGLE_TOOLTIP_NEG}",
|
|
902
|
+
LN: "%{BKY_MATH_SINGLE_TOOLTIP_LN}",
|
|
903
|
+
LOG10: "%{BKY_MATH_SINGLE_TOOLTIP_LOG10}",
|
|
904
|
+
EXP: "%{BKY_MATH_SINGLE_TOOLTIP_EXP}",
|
|
905
|
+
POW10: "%{BKY_MATH_SINGLE_TOOLTIP_POW10}",
|
|
906
|
+
SIN: "%{BKY_MATH_TRIG_TOOLTIP_SIN}",
|
|
907
|
+
COS: "%{BKY_MATH_TRIG_TOOLTIP_COS}",
|
|
908
|
+
TAN: "%{BKY_MATH_TRIG_TOOLTIP_TAN}",
|
|
909
|
+
ASIN: "%{BKY_MATH_TRIG_TOOLTIP_ASIN}",
|
|
910
|
+
ACOS: "%{BKY_MATH_TRIG_TOOLTIP_ACOS}",
|
|
911
|
+
ATAN: "%{BKY_MATH_TRIG_TOOLTIP_ATAN}",
|
|
912
|
+
SUM: "%{BKY_MATH_ONLIST_TOOLTIP_SUM}",
|
|
913
|
+
MIN: "%{BKY_MATH_ONLIST_TOOLTIP_MIN}",
|
|
914
|
+
MAX: "%{BKY_MATH_ONLIST_TOOLTIP_MAX}",
|
|
915
|
+
AVERAGE: "%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",
|
|
916
|
+
MEDIAN: "%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",
|
|
917
|
+
MODE: "%{BKY_MATH_ONLIST_TOOLTIP_MODE}",
|
|
918
|
+
STD_DEV: "%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",
|
|
919
|
+
RANDOM: "%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"
|
|
920
|
+
};
|
|
921
|
+
$.register$$module$build$src$core$extensions("math_op_tooltip", $.buildTooltipForDropdown$$module$build$src$core$extensions("OP", TOOLTIPS_BY_OP$$module$build$src$blocks$math));
|
|
922
|
+
var IS_DIVISIBLEBY_MUTATOR_MIXIN$$module$build$src$blocks$math = { mutationToDom: function() {
|
|
923
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation"), b = this.getFieldValue("PROPERTY") === "DIVISIBLE_BY";
|
|
924
|
+
a.setAttribute("divisor_input", String(b));
|
|
925
|
+
return a;
|
|
926
|
+
}, domToMutation: function(a) {
|
|
927
|
+
a = a.getAttribute("divisor_input") === "true";
|
|
928
|
+
this.updateShape_(a);
|
|
929
|
+
}, updateShape_: function(a) {
|
|
930
|
+
const b = this.getInput("DIVISOR");
|
|
931
|
+
a ? b || this.appendValueInput("DIVISOR").setCheck("Number") : b && this.removeInput("DIVISOR");
|
|
932
|
+
} }, IS_DIVISIBLE_MUTATOR_EXTENSION$$module$build$src$blocks$math = function() {
|
|
933
|
+
this.getField("PROPERTY").setValidator(function(a) {
|
|
934
|
+
a = a === "DIVISIBLE_BY";
|
|
935
|
+
this.getSourceBlock().updateShape_(a);
|
|
936
|
+
});
|
|
937
|
+
};
|
|
938
|
+
$.registerMutator$$module$build$src$core$extensions("math_is_divisibleby_mutator", IS_DIVISIBLEBY_MUTATOR_MIXIN$$module$build$src$blocks$math, IS_DIVISIBLE_MUTATOR_EXTENSION$$module$build$src$blocks$math);
|
|
939
|
+
$.register$$module$build$src$core$extensions("math_change_tooltip", $.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_MATH_CHANGE_TOOLTIP}", "VAR"));
|
|
940
|
+
var LIST_MODES_MUTATOR_MIXIN$$module$build$src$blocks$math = { updateType_: function(a) {
|
|
941
|
+
a === "MODE" ? this.outputConnection.setCheck("Array") : this.outputConnection.setCheck("Number");
|
|
942
|
+
}, mutationToDom: function() {
|
|
943
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
944
|
+
a.setAttribute("op", this.getFieldValue("OP"));
|
|
945
|
+
return a;
|
|
946
|
+
}, domToMutation: function(a) {
|
|
947
|
+
a = a.getAttribute("op");
|
|
948
|
+
if (a === null) throw new TypeError("xmlElement had no op attribute");
|
|
949
|
+
this.updateType_(a);
|
|
950
|
+
} }, LIST_MODES_MUTATOR_EXTENSION$$module$build$src$blocks$math = function() {
|
|
951
|
+
this.getField("OP").setValidator(function(a) {
|
|
952
|
+
this.updateType_(a);
|
|
953
|
+
}.bind(this));
|
|
954
|
+
};
|
|
955
|
+
$.registerMutator$$module$build$src$core$extensions("math_modes_of_list_mutator", LIST_MODES_MUTATOR_MIXIN$$module$build$src$blocks$math, LIST_MODES_MUTATOR_EXTENSION$$module$build$src$blocks$math);
|
|
956
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$math);
|
|
957
|
+
var module$build$src$blocks$math = { blocks: blocks$$module$build$src$blocks$math };
|
|
958
|
+
var blocks$$module$build$src$blocks$loops = $.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{ type: "controls_repeat_ext", message0: "%{BKY_CONTROLS_REPEAT_TITLE}", args0: [{ type: "input_value", name: "TIMES", check: "Number" }], message1: "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1", args1: [{ type: "input_statement", name: "DO" }], previousStatement: null, nextStatement: null, style: "loop_blocks", tooltip: "%{BKY_CONTROLS_REPEAT_TOOLTIP}", helpUrl: "%{BKY_CONTROLS_REPEAT_HELPURL}" }, {
|
|
959
|
+
type: "controls_repeat",
|
|
960
|
+
message0: "%{BKY_CONTROLS_REPEAT_TITLE}",
|
|
961
|
+
args0: [{ type: "field_number", name: "TIMES", value: 10, min: 0, precision: 1 }],
|
|
962
|
+
message1: "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",
|
|
963
|
+
args1: [{ type: "input_statement", name: "DO" }],
|
|
964
|
+
previousStatement: null,
|
|
965
|
+
nextStatement: null,
|
|
966
|
+
style: "loop_blocks",
|
|
967
|
+
tooltip: "%{BKY_CONTROLS_REPEAT_TOOLTIP}",
|
|
968
|
+
helpUrl: "%{BKY_CONTROLS_REPEAT_HELPURL}"
|
|
969
|
+
}, { type: "controls_whileUntil", message0: "%1 %2", args0: [
|
|
970
|
+
{ type: "field_dropdown", name: "MODE", options: [["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}", "WHILE"], ["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}", "UNTIL"]] },
|
|
971
|
+
{ type: "input_value", name: "BOOL", check: "Boolean" }
|
|
972
|
+
], message1: "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1", args1: [{ type: "input_statement", name: "DO" }], previousStatement: null, nextStatement: null, style: "loop_blocks", helpUrl: "%{BKY_CONTROLS_WHILEUNTIL_HELPURL}", extensions: ["controls_whileUntil_tooltip"] }, { type: "controls_for", message0: "%{BKY_CONTROLS_FOR_TITLE}", args0: [{ type: "field_variable", name: "VAR", variable: null }, { type: "input_value", name: "FROM", check: "Number", align: "RIGHT" }, {
|
|
973
|
+
type: "input_value",
|
|
974
|
+
name: "TO",
|
|
975
|
+
check: "Number",
|
|
976
|
+
align: "RIGHT"
|
|
977
|
+
}, { type: "input_value", name: "BY", check: "Number", align: "RIGHT" }], message1: "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1", args1: [{ type: "input_statement", name: "DO" }], inputsInline: true, previousStatement: null, nextStatement: null, style: "loop_blocks", helpUrl: "%{BKY_CONTROLS_FOR_HELPURL}", extensions: ["contextMenu_newGetVariableBlock", "controls_for_tooltip"] }, { type: "controls_forEach", message0: "%{BKY_CONTROLS_FOREACH_TITLE}", args0: [{ type: "field_variable", name: "VAR", variable: null }, {
|
|
978
|
+
type: "input_value",
|
|
979
|
+
name: "LIST",
|
|
980
|
+
check: "Array"
|
|
981
|
+
}], message1: "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1", args1: [{ type: "input_statement", name: "DO" }], previousStatement: null, nextStatement: null, style: "loop_blocks", helpUrl: "%{BKY_CONTROLS_FOREACH_HELPURL}", extensions: ["contextMenu_newGetVariableBlock", "controls_forEach_tooltip"] }, {
|
|
982
|
+
type: "controls_flow_statements",
|
|
983
|
+
message0: "%1",
|
|
984
|
+
args0: [{ type: "field_dropdown", name: "FLOW", options: [["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}", "BREAK"], ["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}", "CONTINUE"]] }],
|
|
985
|
+
previousStatement: null,
|
|
986
|
+
style: "loop_blocks",
|
|
987
|
+
helpUrl: "%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",
|
|
988
|
+
suppressPrefixSuffix: true,
|
|
989
|
+
extensions: ["controls_flow_tooltip", "controls_flow_in_loop_check"]
|
|
990
|
+
}]), WHILE_UNTIL_TOOLTIPS$$module$build$src$blocks$loops = { WHILE: "%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}", UNTIL: "%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}" };
|
|
991
|
+
$.register$$module$build$src$core$extensions("controls_whileUntil_tooltip", $.buildTooltipForDropdown$$module$build$src$core$extensions("MODE", WHILE_UNTIL_TOOLTIPS$$module$build$src$blocks$loops));
|
|
992
|
+
var BREAK_CONTINUE_TOOLTIPS$$module$build$src$blocks$loops = { BREAK: "%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}", CONTINUE: "%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}" };
|
|
993
|
+
$.register$$module$build$src$core$extensions("controls_flow_tooltip", $.buildTooltipForDropdown$$module$build$src$core$extensions("FLOW", BREAK_CONTINUE_TOOLTIPS$$module$build$src$blocks$loops));
|
|
994
|
+
var CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN$$module$build$src$blocks$loops = { customContextMenu: function(a) {
|
|
995
|
+
if (!this.isInFlyout) {
|
|
996
|
+
var b = this.getField("VAR"), c = b.getVariable().getName();
|
|
997
|
+
this.isCollapsed() || c === null || (b = { type: "variables_get", fields: { VAR: b.saveState(true) } }, a.push({ enabled: true, text: $.Msg$$module$build$src$core$msg.VARIABLES_SET_CREATE_GET.replace("%1", c), callback: $.callbackFactory$$module$build$src$core$contextmenu(this, b) }));
|
|
998
|
+
}
|
|
999
|
+
} };
|
|
1000
|
+
$.registerMixin$$module$build$src$core$extensions("contextMenu_newGetVariableBlock", CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN$$module$build$src$blocks$loops);
|
|
1001
|
+
$.register$$module$build$src$core$extensions("controls_for_tooltip", $.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_CONTROLS_FOR_TOOLTIP}", "VAR"));
|
|
1002
|
+
$.register$$module$build$src$core$extensions("controls_forEach_tooltip", $.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_CONTROLS_FOREACH_TOOLTIP}", "VAR"));
|
|
1003
|
+
var loopTypes$$module$build$src$blocks$loops = /* @__PURE__ */ new Set(["controls_repeat", "controls_repeat_ext", "controls_forEach", "controls_for", "controls_whileUntil"]), CONTROL_FLOW_NOT_IN_LOOP_DISABLED_REASON$$module$build$src$blocks$loops = "CONTROL_FLOW_NOT_IN_LOOP", CONTROL_FLOW_IN_LOOP_CHECK_MIXIN$$module$build$src$blocks$loops = { getSurroundLoop: function() {
|
|
1004
|
+
let a = this;
|
|
1005
|
+
do {
|
|
1006
|
+
if (loopTypes$$module$build$src$blocks$loops.has(a.type)) return a;
|
|
1007
|
+
a = a.getSurroundParent();
|
|
1008
|
+
} while (a);
|
|
1009
|
+
return null;
|
|
1010
|
+
}, onchange: function(a) {
|
|
1011
|
+
const b = this.workspace;
|
|
1012
|
+
if (b.isDragging && !b.isDragging() && (a.type === $.BLOCK_MOVE$$module$build$src$core$events$events || a.type === $.BLOCK_CREATE$$module$build$src$core$events$events) && (a = !!this.getSurroundLoop(), this.setWarningText(a ? null : $.Msg$$module$build$src$core$msg.CONTROLS_FLOW_STATEMENTS_WARNING), !this.isInFlyout)) try {
|
|
1013
|
+
$.setRecordUndo$$module$build$src$core$events$utils(false), this.setDisabledReason(!a, CONTROL_FLOW_NOT_IN_LOOP_DISABLED_REASON$$module$build$src$blocks$loops);
|
|
1014
|
+
} finally {
|
|
1015
|
+
$.setRecordUndo$$module$build$src$core$events$utils(true);
|
|
1016
|
+
}
|
|
1017
|
+
} };
|
|
1018
|
+
$.registerMixin$$module$build$src$core$extensions("controls_flow_in_loop_check", CONTROL_FLOW_IN_LOOP_CHECK_MIXIN$$module$build$src$blocks$loops);
|
|
1019
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$loops);
|
|
1020
|
+
var module$build$src$blocks$loops = { blocks: blocks$$module$build$src$blocks$loops, loopTypes: loopTypes$$module$build$src$blocks$loops };
|
|
1021
|
+
var blocks$$module$build$src$blocks$logic = $.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([
|
|
1022
|
+
{ type: "logic_boolean", message0: "%1", args0: [{ type: "field_dropdown", name: "BOOL", options: [["%{BKY_LOGIC_BOOLEAN_TRUE}", "TRUE"], ["%{BKY_LOGIC_BOOLEAN_FALSE}", "FALSE"]] }], output: "Boolean", style: "logic_blocks", tooltip: "%{BKY_LOGIC_BOOLEAN_TOOLTIP}", helpUrl: "%{BKY_LOGIC_BOOLEAN_HELPURL}" },
|
|
1023
|
+
{
|
|
1024
|
+
type: "controls_if",
|
|
1025
|
+
message0: "%{BKY_CONTROLS_IF_MSG_IF} %1",
|
|
1026
|
+
args0: [{ type: "input_value", name: "IF0", check: "Boolean" }],
|
|
1027
|
+
message1: "%{BKY_CONTROLS_IF_MSG_THEN} %1",
|
|
1028
|
+
args1: [{ type: "input_statement", name: "DO0" }],
|
|
1029
|
+
previousStatement: null,
|
|
1030
|
+
nextStatement: null,
|
|
1031
|
+
style: "logic_blocks",
|
|
1032
|
+
helpUrl: "%{BKY_CONTROLS_IF_HELPURL}",
|
|
1033
|
+
suppressPrefixSuffix: true,
|
|
1034
|
+
mutator: "controls_if_mutator",
|
|
1035
|
+
extensions: ["controls_if_tooltip"]
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
type: "controls_ifelse",
|
|
1039
|
+
message0: "%{BKY_CONTROLS_IF_MSG_IF} %1",
|
|
1040
|
+
args0: [{ type: "input_value", name: "IF0", check: "Boolean" }],
|
|
1041
|
+
message1: "%{BKY_CONTROLS_IF_MSG_THEN} %1",
|
|
1042
|
+
args1: [{ type: "input_statement", name: "DO0" }],
|
|
1043
|
+
message2: "%{BKY_CONTROLS_IF_MSG_ELSE} %1",
|
|
1044
|
+
args2: [{ type: "input_statement", name: "ELSE" }],
|
|
1045
|
+
previousStatement: null,
|
|
1046
|
+
nextStatement: null,
|
|
1047
|
+
style: "logic_blocks",
|
|
1048
|
+
tooltip: "%{BKYCONTROLS_IF_TOOLTIP_2}",
|
|
1049
|
+
helpUrl: "%{BKY_CONTROLS_IF_HELPURL}",
|
|
1050
|
+
suppressPrefixSuffix: true,
|
|
1051
|
+
extensions: ["controls_if_tooltip"]
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
type: "logic_compare",
|
|
1055
|
+
message0: "%1 %2 %3",
|
|
1056
|
+
args0: [{ type: "input_value", name: "A" }, { type: "field_dropdown", name: "OP", options: [["=", "EQ"], ["≠", "NEQ"], ["<", "LT"], ["≤", "LTE"], [">", "GT"], ["≥", "GTE"]] }, { type: "input_value", name: "B" }],
|
|
1057
|
+
inputsInline: true,
|
|
1058
|
+
output: "Boolean",
|
|
1059
|
+
style: "logic_blocks",
|
|
1060
|
+
helpUrl: "%{BKY_LOGIC_COMPARE_HELPURL}",
|
|
1061
|
+
extensions: ["logic_compare", "logic_op_tooltip"]
|
|
1062
|
+
},
|
|
1063
|
+
{ type: "logic_operation", message0: "%1 %2 %3", args0: [{ type: "input_value", name: "A", check: "Boolean" }, { type: "field_dropdown", name: "OP", options: [["%{BKY_LOGIC_OPERATION_AND}", "AND"], ["%{BKY_LOGIC_OPERATION_OR}", "OR"]] }, { type: "input_value", name: "B", check: "Boolean" }], inputsInline: true, output: "Boolean", style: "logic_blocks", helpUrl: "%{BKY_LOGIC_OPERATION_HELPURL}", extensions: ["logic_op_tooltip"] },
|
|
1064
|
+
{ type: "logic_negate", message0: "%{BKY_LOGIC_NEGATE_TITLE}", args0: [{ type: "input_value", name: "BOOL", check: "Boolean" }], output: "Boolean", style: "logic_blocks", tooltip: "%{BKY_LOGIC_NEGATE_TOOLTIP}", helpUrl: "%{BKY_LOGIC_NEGATE_HELPURL}" },
|
|
1065
|
+
{ type: "logic_null", message0: "%{BKY_LOGIC_NULL}", output: null, style: "logic_blocks", tooltip: "%{BKY_LOGIC_NULL_TOOLTIP}", helpUrl: "%{BKY_LOGIC_NULL_HELPURL}" },
|
|
1066
|
+
{
|
|
1067
|
+
type: "logic_ternary",
|
|
1068
|
+
message0: "%{BKY_LOGIC_TERNARY_CONDITION} %1",
|
|
1069
|
+
args0: [{ type: "input_value", name: "IF", check: "Boolean" }],
|
|
1070
|
+
message1: "%{BKY_LOGIC_TERNARY_IF_TRUE} %1",
|
|
1071
|
+
args1: [{ type: "input_value", name: "THEN" }],
|
|
1072
|
+
message2: "%{BKY_LOGIC_TERNARY_IF_FALSE} %1",
|
|
1073
|
+
args2: [{ type: "input_value", name: "ELSE" }],
|
|
1074
|
+
output: null,
|
|
1075
|
+
style: "logic_blocks",
|
|
1076
|
+
tooltip: "%{BKY_LOGIC_TERNARY_TOOLTIP}",
|
|
1077
|
+
helpUrl: "%{BKY_LOGIC_TERNARY_HELPURL}",
|
|
1078
|
+
extensions: ["logic_ternary"]
|
|
1079
|
+
},
|
|
1080
|
+
{ type: "controls_if_if", message0: "%{BKY_CONTROLS_IF_IF_TITLE_IF}", nextStatement: null, enableContextMenu: false, style: "logic_blocks", tooltip: "%{BKY_CONTROLS_IF_IF_TOOLTIP}" },
|
|
1081
|
+
{
|
|
1082
|
+
type: "controls_if_elseif",
|
|
1083
|
+
message0: "%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",
|
|
1084
|
+
previousStatement: null,
|
|
1085
|
+
nextStatement: null,
|
|
1086
|
+
enableContextMenu: false,
|
|
1087
|
+
style: "logic_blocks",
|
|
1088
|
+
tooltip: "%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"
|
|
1089
|
+
},
|
|
1090
|
+
{ type: "controls_if_else", message0: "%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}", previousStatement: null, enableContextMenu: false, style: "logic_blocks", tooltip: "%{BKY_CONTROLS_IF_ELSE_TOOLTIP}" }
|
|
1091
|
+
]), TOOLTIPS_BY_OP$$module$build$src$blocks$logic = {
|
|
1092
|
+
EQ: "%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",
|
|
1093
|
+
NEQ: "%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",
|
|
1094
|
+
LT: "%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",
|
|
1095
|
+
LTE: "%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",
|
|
1096
|
+
GT: "%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",
|
|
1097
|
+
GTE: "%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",
|
|
1098
|
+
AND: "%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",
|
|
1099
|
+
OR: "%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"
|
|
1100
|
+
};
|
|
1101
|
+
$.register$$module$build$src$core$extensions("logic_op_tooltip", $.buildTooltipForDropdown$$module$build$src$core$extensions("OP", TOOLTIPS_BY_OP$$module$build$src$blocks$logic));
|
|
1102
|
+
var CONTROLS_IF_MUTATOR_MIXIN$$module$build$src$blocks$logic = {
|
|
1103
|
+
elseifCount_: 0,
|
|
1104
|
+
elseCount_: 0,
|
|
1105
|
+
mutationToDom: function() {
|
|
1106
|
+
if (!this.elseifCount_ && !this.elseCount_) return null;
|
|
1107
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
1108
|
+
this.elseifCount_ && a.setAttribute("elseif", String(this.elseifCount_));
|
|
1109
|
+
this.elseCount_ && a.setAttribute("else", "1");
|
|
1110
|
+
return a;
|
|
1111
|
+
},
|
|
1112
|
+
domToMutation: function(a) {
|
|
1113
|
+
this.elseifCount_ = parseInt(a.getAttribute("elseif"), 10) || 0;
|
|
1114
|
+
this.elseCount_ = parseInt(a.getAttribute("else"), 10) || 0;
|
|
1115
|
+
this.rebuildShape_();
|
|
1116
|
+
},
|
|
1117
|
+
saveExtraState: function() {
|
|
1118
|
+
if (!this.elseifCount_ && !this.elseCount_) return null;
|
|
1119
|
+
const a = /* @__PURE__ */ Object.create(null);
|
|
1120
|
+
this.elseifCount_ && (a.elseIfCount = this.elseifCount_);
|
|
1121
|
+
this.elseCount_ && (a.hasElse = true);
|
|
1122
|
+
return a;
|
|
1123
|
+
},
|
|
1124
|
+
loadExtraState: function(a) {
|
|
1125
|
+
this.elseifCount_ = a.elseIfCount || 0;
|
|
1126
|
+
this.elseCount_ = a.hasElse ? 1 : 0;
|
|
1127
|
+
this.updateShape_();
|
|
1128
|
+
},
|
|
1129
|
+
decompose: function(a) {
|
|
1130
|
+
const b = a.newBlock("controls_if_if");
|
|
1131
|
+
b.initSvg();
|
|
1132
|
+
let c = b.nextConnection;
|
|
1133
|
+
for (let d = 1; d <= this.elseifCount_; d++) {
|
|
1134
|
+
const e = a.newBlock("controls_if_elseif");
|
|
1135
|
+
e.initSvg();
|
|
1136
|
+
c.connect(e.previousConnection);
|
|
1137
|
+
c = e.nextConnection;
|
|
1138
|
+
}
|
|
1139
|
+
this.elseCount_ && (a = a.newBlock("controls_if_else"), a.initSvg(), c.connect(a.previousConnection));
|
|
1140
|
+
return b;
|
|
1141
|
+
},
|
|
1142
|
+
compose: function(a) {
|
|
1143
|
+
a = a.nextConnection.targetBlock();
|
|
1144
|
+
this.elseCount_ = this.elseifCount_ = 0;
|
|
1145
|
+
const b = [null], c = [null];
|
|
1146
|
+
let d = null;
|
|
1147
|
+
for (; a; ) {
|
|
1148
|
+
if (!a.isInsertionMarker()) switch (a.type) {
|
|
1149
|
+
case "controls_if_elseif":
|
|
1150
|
+
this.elseifCount_++;
|
|
1151
|
+
b.push(a.valueConnection_);
|
|
1152
|
+
c.push(a.statementConnection_);
|
|
1153
|
+
break;
|
|
1154
|
+
case "controls_if_else":
|
|
1155
|
+
this.elseCount_++;
|
|
1156
|
+
d = a.statementConnection_;
|
|
1157
|
+
break;
|
|
1158
|
+
default:
|
|
1159
|
+
throw TypeError("Unknown block type: " + a.type);
|
|
1160
|
+
}
|
|
1161
|
+
a = a.getNextBlock();
|
|
1162
|
+
}
|
|
1163
|
+
this.updateShape_();
|
|
1164
|
+
this.reconnectChildBlocks_(b, c, d);
|
|
1165
|
+
},
|
|
1166
|
+
saveConnections: function(a) {
|
|
1167
|
+
a = a.nextConnection.targetBlock();
|
|
1168
|
+
let b = 1;
|
|
1169
|
+
for (; a; ) {
|
|
1170
|
+
if (!a.isInsertionMarker()) switch (a.type) {
|
|
1171
|
+
case "controls_if_elseif":
|
|
1172
|
+
var c = this.getInput("IF" + b);
|
|
1173
|
+
const d = this.getInput("DO" + b);
|
|
1174
|
+
a.valueConnection_ = c && c.connection.targetConnection;
|
|
1175
|
+
a.statementConnection_ = d && d.connection.targetConnection;
|
|
1176
|
+
b++;
|
|
1177
|
+
break;
|
|
1178
|
+
case "controls_if_else":
|
|
1179
|
+
c = this.getInput("ELSE");
|
|
1180
|
+
a.statementConnection_ = c && c.connection.targetConnection;
|
|
1181
|
+
break;
|
|
1182
|
+
default:
|
|
1183
|
+
throw TypeError("Unknown block type: " + a.type);
|
|
1184
|
+
}
|
|
1185
|
+
a = a.getNextBlock();
|
|
1186
|
+
}
|
|
1187
|
+
},
|
|
1188
|
+
rebuildShape_: function() {
|
|
1189
|
+
const a = [null], b = [null];
|
|
1190
|
+
let c = null;
|
|
1191
|
+
this.getInput("ELSE") && (c = this.getInput("ELSE").connection.targetConnection);
|
|
1192
|
+
for (let d = 1; this.getInput("IF" + d); d++) {
|
|
1193
|
+
const e = this.getInput("IF" + d), f = this.getInput("DO" + d);
|
|
1194
|
+
a.push(e.connection.targetConnection);
|
|
1195
|
+
b.push(f.connection.targetConnection);
|
|
1196
|
+
}
|
|
1197
|
+
this.updateShape_();
|
|
1198
|
+
this.reconnectChildBlocks_(a, b, c);
|
|
1199
|
+
},
|
|
1200
|
+
updateShape_: function() {
|
|
1201
|
+
this.getInput("ELSE") && this.removeInput("ELSE");
|
|
1202
|
+
for (var a = 1; this.getInput("IF" + a); a++) this.removeInput("IF" + a), this.removeInput("DO" + a);
|
|
1203
|
+
for (a = 1; a <= this.elseifCount_; a++) this.appendValueInput("IF" + a).setCheck("Boolean").appendField($.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSEIF), this.appendStatementInput("DO" + a).appendField($.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_THEN);
|
|
1204
|
+
this.elseCount_ && this.appendStatementInput("ELSE").appendField($.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSE);
|
|
1205
|
+
},
|
|
1206
|
+
reconnectChildBlocks_: function(a, b, c) {
|
|
1207
|
+
for (let d = 1; d <= this.elseifCount_; d++) {
|
|
1208
|
+
let e;
|
|
1209
|
+
(e = a[d]) == null || e.reconnect(this, "IF" + d);
|
|
1210
|
+
let f;
|
|
1211
|
+
(f = b[d]) == null || f.reconnect(this, "DO" + d);
|
|
1212
|
+
}
|
|
1213
|
+
c == null || c.reconnect(this, "ELSE");
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
$.registerMutator$$module$build$src$core$extensions("controls_if_mutator", CONTROLS_IF_MUTATOR_MIXIN$$module$build$src$blocks$logic, null, ["controls_if_elseif", "controls_if_else"]);
|
|
1217
|
+
var CONTROLS_IF_TOOLTIP_EXTENSION$$module$build$src$blocks$logic = function() {
|
|
1218
|
+
this.setTooltip(function() {
|
|
1219
|
+
if (this.elseifCount_ || this.elseCount_) {
|
|
1220
|
+
if (!this.elseifCount_ && this.elseCount_) return $.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_2;
|
|
1221
|
+
if (this.elseifCount_ && !this.elseCount_) return $.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_3;
|
|
1222
|
+
if (this.elseifCount_ && this.elseCount_) return $.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_4;
|
|
1223
|
+
} else return $.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_1;
|
|
1224
|
+
return "";
|
|
1225
|
+
}.bind(this));
|
|
1226
|
+
};
|
|
1227
|
+
$.register$$module$build$src$core$extensions("controls_if_tooltip", CONTROLS_IF_TOOLTIP_EXTENSION$$module$build$src$blocks$logic);
|
|
1228
|
+
var LOGIC_COMPARE_ONCHANGE_MIXIN$$module$build$src$blocks$logic = { onchange: function(a) {
|
|
1229
|
+
this.prevBlocks_ || (this.prevBlocks_ = [null, null]);
|
|
1230
|
+
var b = this.getInputTargetBlock("A");
|
|
1231
|
+
const c = this.getInputTargetBlock("B");
|
|
1232
|
+
b && c && !this.workspace.connectionChecker.doTypeChecks(b.outputConnection, c.outputConnection) && ($.setGroup$$module$build$src$core$events$utils(a.group), a = this.prevBlocks_[0], a !== b && (b.unplug(), !a || a.isDisposed() || a.isShadow() || this.getInput("A").connection.connect(a.outputConnection)), b = this.prevBlocks_[1], b !== c && (c.unplug(), !b || b.isDisposed() || b.isShadow() || this.getInput("B").connection.connect(b.outputConnection)), this.bumpNeighbours(), $.setGroup$$module$build$src$core$events$utils(false));
|
|
1233
|
+
this.prevBlocks_[0] = this.getInputTargetBlock("A");
|
|
1234
|
+
this.prevBlocks_[1] = this.getInputTargetBlock("B");
|
|
1235
|
+
} }, LOGIC_COMPARE_EXTENSION$$module$build$src$blocks$logic = function() {
|
|
1236
|
+
this.mixin(LOGIC_COMPARE_ONCHANGE_MIXIN$$module$build$src$blocks$logic);
|
|
1237
|
+
};
|
|
1238
|
+
$.register$$module$build$src$core$extensions("logic_compare", LOGIC_COMPARE_EXTENSION$$module$build$src$blocks$logic);
|
|
1239
|
+
var LOGIC_TERNARY_ONCHANGE_MIXIN$$module$build$src$blocks$logic = { prevParentConnection_: null, onchange: function(a) {
|
|
1240
|
+
const b = this.getInputTargetBlock("THEN"), c = this.getInputTargetBlock("ELSE"), d = this.outputConnection.targetConnection;
|
|
1241
|
+
if ((b || c) && d) for (let e = 0; e < 2; e++) {
|
|
1242
|
+
const f = e === 1 ? b : c;
|
|
1243
|
+
f && !f.workspace.connectionChecker.doTypeChecks(f.outputConnection, d) && ($.setGroup$$module$build$src$core$events$utils(a.group), d === this.prevParentConnection_ ? (this.unplug(), d.getSourceBlock().bumpNeighbours()) : (f.unplug(), f.bumpNeighbours()), $.setGroup$$module$build$src$core$events$utils(false));
|
|
1244
|
+
}
|
|
1245
|
+
this.prevParentConnection_ = d;
|
|
1246
|
+
} };
|
|
1247
|
+
$.registerMixin$$module$build$src$core$extensions("logic_ternary", LOGIC_TERNARY_ONCHANGE_MIXIN$$module$build$src$blocks$logic);
|
|
1248
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$logic);
|
|
1249
|
+
var module$build$src$blocks$logic = { blocks: blocks$$module$build$src$blocks$logic };
|
|
1250
|
+
var blocks$$module$build$src$blocks$lists = $.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([
|
|
1251
|
+
{ type: "lists_create_empty", message0: "%{BKY_LISTS_CREATE_EMPTY_TITLE}", output: "Array", style: "list_blocks", tooltip: "%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}", helpUrl: "%{BKY_LISTS_CREATE_EMPTY_HELPURL}" },
|
|
1252
|
+
{
|
|
1253
|
+
type: "lists_repeat",
|
|
1254
|
+
message0: "%{BKY_LISTS_REPEAT_TITLE}",
|
|
1255
|
+
args0: [{ type: "input_value", name: "ITEM" }, { type: "input_value", name: "NUM", check: "Number" }],
|
|
1256
|
+
output: "Array",
|
|
1257
|
+
style: "list_blocks",
|
|
1258
|
+
tooltip: "%{BKY_LISTS_REPEAT_TOOLTIP}",
|
|
1259
|
+
helpUrl: "%{BKY_LISTS_REPEAT_HELPURL}"
|
|
1260
|
+
},
|
|
1261
|
+
{ type: "lists_reverse", message0: "%{BKY_LISTS_REVERSE_MESSAGE0}", args0: [{ type: "input_value", name: "LIST", check: "Array" }], output: "Array", inputsInline: true, style: "list_blocks", tooltip: "%{BKY_LISTS_REVERSE_TOOLTIP}", helpUrl: "%{BKY_LISTS_REVERSE_HELPURL}" },
|
|
1262
|
+
{ type: "lists_isEmpty", message0: "%{BKY_LISTS_ISEMPTY_TITLE}", args0: [{ type: "input_value", name: "VALUE", check: ["String", "Array"] }], output: "Boolean", style: "list_blocks", tooltip: "%{BKY_LISTS_ISEMPTY_TOOLTIP}", helpUrl: "%{BKY_LISTS_ISEMPTY_HELPURL}" },
|
|
1263
|
+
{ type: "lists_length", message0: "%{BKY_LISTS_LENGTH_TITLE}", args0: [{ type: "input_value", name: "VALUE", check: ["String", "Array"] }], output: "Number", style: "list_blocks", tooltip: "%{BKY_LISTS_LENGTH_TOOLTIP}", helpUrl: "%{BKY_LISTS_LENGTH_HELPURL}" }
|
|
1264
|
+
]), LISTS_CREATE_WITH$$module$build$src$blocks$lists = { init: function() {
|
|
1265
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_HELPURL);
|
|
1266
|
+
this.setStyle("list_blocks");
|
|
1267
|
+
this.itemCount_ = 3;
|
|
1268
|
+
this.updateShape_();
|
|
1269
|
+
this.setOutput(true, "Array");
|
|
1270
|
+
this.setMutator(new $.MutatorIcon$$module$build$src$core$icons$mutator_icon(
|
|
1271
|
+
["lists_create_with_item"],
|
|
1272
|
+
this
|
|
1273
|
+
));
|
|
1274
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_TOOLTIP);
|
|
1275
|
+
}, mutationToDom: function() {
|
|
1276
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
1277
|
+
a.setAttribute("items", String(this.itemCount_));
|
|
1278
|
+
return a;
|
|
1279
|
+
}, domToMutation: function(a) {
|
|
1280
|
+
a = a.getAttribute("items");
|
|
1281
|
+
if (!a) throw new TypeError("element did not have items");
|
|
1282
|
+
this.itemCount_ = parseInt(a, 10);
|
|
1283
|
+
this.updateShape_();
|
|
1284
|
+
}, saveExtraState: function() {
|
|
1285
|
+
return { itemCount: this.itemCount_ };
|
|
1286
|
+
}, loadExtraState: function(a) {
|
|
1287
|
+
this.itemCount_ = a.itemCount;
|
|
1288
|
+
this.updateShape_();
|
|
1289
|
+
}, decompose: function(a) {
|
|
1290
|
+
const b = a.newBlock("lists_create_with_container");
|
|
1291
|
+
b.initSvg();
|
|
1292
|
+
let c = b.getInput("STACK").connection;
|
|
1293
|
+
for (let d = 0; d < this.itemCount_; d++) {
|
|
1294
|
+
const e = a.newBlock("lists_create_with_item");
|
|
1295
|
+
e.initSvg();
|
|
1296
|
+
if (!e.previousConnection) throw Error("itemBlock has no previousConnection");
|
|
1297
|
+
c.connect(e.previousConnection);
|
|
1298
|
+
c = e.nextConnection;
|
|
1299
|
+
}
|
|
1300
|
+
return b;
|
|
1301
|
+
}, compose: function(a) {
|
|
1302
|
+
var b = a.getInputTargetBlock("STACK");
|
|
1303
|
+
for (a = []; b; ) b.isInsertionMarker() || a.push(b.valueConnection_), b = b.getNextBlock();
|
|
1304
|
+
for (b = 0; b < this.itemCount_; b++) {
|
|
1305
|
+
const c = this.getInput("ADD" + b).connection.targetConnection;
|
|
1306
|
+
c && !a.includes(c) && c.disconnect();
|
|
1307
|
+
}
|
|
1308
|
+
this.itemCount_ = a.length;
|
|
1309
|
+
this.updateShape_();
|
|
1310
|
+
for (b = 0; b < this.itemCount_; b++) {
|
|
1311
|
+
let c;
|
|
1312
|
+
(c = a[b]) == null || c.reconnect(this, "ADD" + b);
|
|
1313
|
+
}
|
|
1314
|
+
}, saveConnections: function(a) {
|
|
1315
|
+
a = a.getInputTargetBlock("STACK");
|
|
1316
|
+
let b = 0;
|
|
1317
|
+
for (; a; ) {
|
|
1318
|
+
if (a.isInsertionMarker()) {
|
|
1319
|
+
a = a.getNextBlock();
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
const c = this.getInput("ADD" + b);
|
|
1323
|
+
let d;
|
|
1324
|
+
a.valueConnection_ = (d = c) == null ? void 0 : d.connection.targetConnection;
|
|
1325
|
+
a = a.getNextBlock();
|
|
1326
|
+
b++;
|
|
1327
|
+
}
|
|
1328
|
+
}, updateShape_: function() {
|
|
1329
|
+
this.itemCount_ && this.getInput("EMPTY") ? this.removeInput("EMPTY") : this.itemCount_ || this.getInput("EMPTY") || this.appendDummyInput("EMPTY").appendField($.Msg$$module$build$src$core$msg.LISTS_CREATE_EMPTY_TITLE);
|
|
1330
|
+
for (var a = 0; a < this.itemCount_; a++) if (!this.getInput("ADD" + a)) {
|
|
1331
|
+
const b = this.appendValueInput("ADD" + a).setAlign($.Align$$module$build$src$core$inputs$align.RIGHT);
|
|
1332
|
+
a === 0 && b.appendField($.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_INPUT_WITH);
|
|
1333
|
+
}
|
|
1334
|
+
for (a = this.itemCount_; this.getInput("ADD" + a); a++) this.removeInput("ADD" + a);
|
|
1335
|
+
} };
|
|
1336
|
+
blocks$$module$build$src$blocks$lists.lists_create_with = LISTS_CREATE_WITH$$module$build$src$blocks$lists;
|
|
1337
|
+
var LISTS_CREATE_WITH_CONTAINER$$module$build$src$blocks$lists = { init: function() {
|
|
1338
|
+
this.setStyle("list_blocks");
|
|
1339
|
+
this.appendDummyInput().appendField($.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);
|
|
1340
|
+
this.appendStatementInput("STACK");
|
|
1341
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);
|
|
1342
|
+
this.contextMenu = false;
|
|
1343
|
+
} };
|
|
1344
|
+
blocks$$module$build$src$blocks$lists.lists_create_with_container = LISTS_CREATE_WITH_CONTAINER$$module$build$src$blocks$lists;
|
|
1345
|
+
var LISTS_CREATE_WITH_ITEM$$module$build$src$blocks$lists = { init: function() {
|
|
1346
|
+
this.setStyle("list_blocks");
|
|
1347
|
+
this.appendDummyInput().appendField($.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_ITEM_TITLE);
|
|
1348
|
+
this.setPreviousStatement(true);
|
|
1349
|
+
this.setNextStatement(true);
|
|
1350
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_ITEM_TOOLTIP);
|
|
1351
|
+
this.contextMenu = false;
|
|
1352
|
+
} };
|
|
1353
|
+
blocks$$module$build$src$blocks$lists.lists_create_with_item = LISTS_CREATE_WITH_ITEM$$module$build$src$blocks$lists;
|
|
1354
|
+
var LISTS_INDEXOF$$module$build$src$blocks$lists = { init: function() {
|
|
1355
|
+
var a = [[$.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_FIRST, "FIRST"], [$.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_LAST, "LAST"]];
|
|
1356
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_HELPURL);
|
|
1357
|
+
this.setStyle("list_blocks");
|
|
1358
|
+
this.setOutput(true, "Number");
|
|
1359
|
+
this.appendValueInput("VALUE").setCheck("Array").appendField($.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_INPUT_IN_LIST);
|
|
1360
|
+
a = $.fromJson$$module$build$src$core$field_registry({
|
|
1361
|
+
type: "field_dropdown",
|
|
1362
|
+
options: a
|
|
1363
|
+
});
|
|
1364
|
+
if (!a) throw Error("field_dropdown not found");
|
|
1365
|
+
this.appendValueInput("FIND").appendField(a, "END");
|
|
1366
|
+
this.setInputsInline(true);
|
|
1367
|
+
this.setTooltip(() => $.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_TOOLTIP.replace("%1", this.workspace.options.oneBasedIndex ? "0" : "-1"));
|
|
1368
|
+
} };
|
|
1369
|
+
blocks$$module$build$src$blocks$lists.lists_indexOf = LISTS_INDEXOF$$module$build$src$blocks$lists;
|
|
1370
|
+
var LISTS_GETINDEX$$module$build$src$blocks$lists = { init: function() {
|
|
1371
|
+
var a = [[$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET, "GET"], [$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET_REMOVE, "GET_REMOVE"], [$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_REMOVE, "REMOVE"]];
|
|
1372
|
+
this.WHERE_OPTIONS = [
|
|
1373
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START, "FROM_START"],
|
|
1374
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END, "FROM_END"],
|
|
1375
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST, "FIRST"],
|
|
1376
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST, "LAST"],
|
|
1377
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM, "RANDOM"]
|
|
1378
|
+
];
|
|
1379
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_HELPURL);
|
|
1380
|
+
this.setStyle("list_blocks");
|
|
1381
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: a });
|
|
1382
|
+
a.setValidator(function(b) {
|
|
1383
|
+
b = b === "REMOVE";
|
|
1384
|
+
this.getSourceBlock().updateStatement_(b);
|
|
1385
|
+
});
|
|
1386
|
+
this.appendValueInput("VALUE").setCheck("Array").appendField($.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_INPUT_IN_LIST);
|
|
1387
|
+
this.appendDummyInput().appendField(a, "MODE").appendField("", "SPACE");
|
|
1388
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: this.WHERE_OPTIONS });
|
|
1389
|
+
a.setValidator(function(b) {
|
|
1390
|
+
const c = this.getValue();
|
|
1391
|
+
b = b === "FROM_START" || b === "FROM_END";
|
|
1392
|
+
b !== (c === "FROM_START" || c === "FROM_END") && this.getSourceBlock().updateAt_(b);
|
|
1393
|
+
});
|
|
1394
|
+
this.appendDummyInput().appendField(a, "WHERE");
|
|
1395
|
+
this.appendDummyInput("AT");
|
|
1396
|
+
$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL && this.appendDummyInput("TAIL").appendField($.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL);
|
|
1397
|
+
this.setInputsInline(true);
|
|
1398
|
+
this.setOutput(true);
|
|
1399
|
+
this.updateAt_(true);
|
|
1400
|
+
this.setTooltip(() => {
|
|
1401
|
+
const b = this.getFieldValue("MODE"), c = this.getFieldValue("WHERE");
|
|
1402
|
+
let d = "";
|
|
1403
|
+
switch (b + " " + c) {
|
|
1404
|
+
case "GET FROM_START":
|
|
1405
|
+
case "GET FROM_END":
|
|
1406
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;
|
|
1407
|
+
break;
|
|
1408
|
+
case "GET FIRST":
|
|
1409
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;
|
|
1410
|
+
break;
|
|
1411
|
+
case "GET LAST":
|
|
1412
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;
|
|
1413
|
+
break;
|
|
1414
|
+
case "GET RANDOM":
|
|
1415
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;
|
|
1416
|
+
break;
|
|
1417
|
+
case "GET_REMOVE FROM_START":
|
|
1418
|
+
case "GET_REMOVE FROM_END":
|
|
1419
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;
|
|
1420
|
+
break;
|
|
1421
|
+
case "GET_REMOVE FIRST":
|
|
1422
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;
|
|
1423
|
+
break;
|
|
1424
|
+
case "GET_REMOVE LAST":
|
|
1425
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;
|
|
1426
|
+
break;
|
|
1427
|
+
case "GET_REMOVE RANDOM":
|
|
1428
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;
|
|
1429
|
+
break;
|
|
1430
|
+
case "REMOVE FROM_START":
|
|
1431
|
+
case "REMOVE FROM_END":
|
|
1432
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;
|
|
1433
|
+
break;
|
|
1434
|
+
case "REMOVE FIRST":
|
|
1435
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;
|
|
1436
|
+
break;
|
|
1437
|
+
case "REMOVE LAST":
|
|
1438
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;
|
|
1439
|
+
break;
|
|
1440
|
+
case "REMOVE RANDOM":
|
|
1441
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM;
|
|
1442
|
+
}
|
|
1443
|
+
if (c === "FROM_START" || c === "FROM_END") d += " " + (c === "FROM_START" ? $.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP : $.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP).replace(
|
|
1444
|
+
"%1",
|
|
1445
|
+
this.workspace.options.oneBasedIndex ? "#1" : "#0"
|
|
1446
|
+
);
|
|
1447
|
+
return d;
|
|
1448
|
+
});
|
|
1449
|
+
}, mutationToDom: function() {
|
|
1450
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
1451
|
+
a.setAttribute("statement", String(!this.outputConnection));
|
|
1452
|
+
const b = this.getInput("AT") instanceof $.ValueInput$$module$build$src$core$inputs$value_input;
|
|
1453
|
+
a.setAttribute("at", String(b));
|
|
1454
|
+
return a;
|
|
1455
|
+
}, domToMutation: function(a) {
|
|
1456
|
+
const b = a.getAttribute("statement") === "true";
|
|
1457
|
+
this.updateStatement_(b);
|
|
1458
|
+
a = a.getAttribute("at") !== "false";
|
|
1459
|
+
this.updateAt_(a);
|
|
1460
|
+
}, saveExtraState: function() {
|
|
1461
|
+
return this.outputConnection ? null : { isStatement: true };
|
|
1462
|
+
}, loadExtraState: function(a) {
|
|
1463
|
+
a.isStatement ? this.updateStatement_(true) : typeof a === "string" && this.domToMutation($.textToDom$$module$build$src$core$utils$xml(a));
|
|
1464
|
+
}, updateStatement_: function(a) {
|
|
1465
|
+
a !== !this.outputConnection && (this.unplug(true, true), a ? (this.setOutput(false), this.setPreviousStatement(true), this.setNextStatement(true)) : (this.setPreviousStatement(false), this.setNextStatement(false), this.setOutput(true)));
|
|
1466
|
+
}, updateAt_: function(a) {
|
|
1467
|
+
this.removeInput("AT");
|
|
1468
|
+
this.removeInput("ORDINAL", true);
|
|
1469
|
+
a ? (this.appendValueInput("AT").setCheck("Number"), $.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL").appendField($.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT");
|
|
1470
|
+
$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL && this.moveInputBefore("TAIL", null);
|
|
1471
|
+
} };
|
|
1472
|
+
blocks$$module$build$src$blocks$lists.lists_getIndex = LISTS_GETINDEX$$module$build$src$blocks$lists;
|
|
1473
|
+
var LISTS_SETINDEX$$module$build$src$blocks$lists = { init: function() {
|
|
1474
|
+
var a = [[$.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_SET, "SET"], [$.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INSERT, "INSERT"]];
|
|
1475
|
+
this.WHERE_OPTIONS = [[$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START, "FROM_START"], [$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END, "FROM_END"], [$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST, "FIRST"], [$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST, "LAST"], [
|
|
1476
|
+
$.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,
|
|
1477
|
+
"RANDOM"
|
|
1478
|
+
]];
|
|
1479
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_HELPURL);
|
|
1480
|
+
this.setStyle("list_blocks");
|
|
1481
|
+
this.appendValueInput("LIST").setCheck("Array").appendField($.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_IN_LIST);
|
|
1482
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: a });
|
|
1483
|
+
this.appendDummyInput().appendField(a, "MODE").appendField("", "SPACE");
|
|
1484
|
+
a = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: this.WHERE_OPTIONS });
|
|
1485
|
+
a.setValidator(function(b) {
|
|
1486
|
+
const c = this.getValue();
|
|
1487
|
+
b = b === "FROM_START" || b === "FROM_END";
|
|
1488
|
+
b !== (c === "FROM_START" || c === "FROM_END") && this.getSourceBlock().updateAt_(b);
|
|
1489
|
+
});
|
|
1490
|
+
this.appendDummyInput().appendField(a, "WHERE");
|
|
1491
|
+
this.appendDummyInput("AT");
|
|
1492
|
+
this.appendValueInput("TO").appendField($.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_TO);
|
|
1493
|
+
this.setInputsInline(true);
|
|
1494
|
+
this.setPreviousStatement(true);
|
|
1495
|
+
this.setNextStatement(true);
|
|
1496
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP);
|
|
1497
|
+
this.updateAt_(true);
|
|
1498
|
+
this.setTooltip(() => {
|
|
1499
|
+
const b = this.getFieldValue("MODE"), c = this.getFieldValue("WHERE");
|
|
1500
|
+
let d = "";
|
|
1501
|
+
switch (b + " " + c) {
|
|
1502
|
+
case "SET FROM_START":
|
|
1503
|
+
case "SET FROM_END":
|
|
1504
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;
|
|
1505
|
+
break;
|
|
1506
|
+
case "SET FIRST":
|
|
1507
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;
|
|
1508
|
+
break;
|
|
1509
|
+
case "SET LAST":
|
|
1510
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;
|
|
1511
|
+
break;
|
|
1512
|
+
case "SET RANDOM":
|
|
1513
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;
|
|
1514
|
+
break;
|
|
1515
|
+
case "INSERT FROM_START":
|
|
1516
|
+
case "INSERT FROM_END":
|
|
1517
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;
|
|
1518
|
+
break;
|
|
1519
|
+
case "INSERT FIRST":
|
|
1520
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;
|
|
1521
|
+
break;
|
|
1522
|
+
case "INSERT LAST":
|
|
1523
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;
|
|
1524
|
+
break;
|
|
1525
|
+
case "INSERT RANDOM":
|
|
1526
|
+
d = $.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM;
|
|
1527
|
+
}
|
|
1528
|
+
if (c === "FROM_START" || c === "FROM_END") d += " " + $.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1", this.workspace.options.oneBasedIndex ? "#1" : "#0");
|
|
1529
|
+
return d;
|
|
1530
|
+
});
|
|
1531
|
+
}, mutationToDom: function() {
|
|
1532
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation"), b = this.getInput("AT") instanceof $.ValueInput$$module$build$src$core$inputs$value_input;
|
|
1533
|
+
a.setAttribute("at", String(b));
|
|
1534
|
+
return a;
|
|
1535
|
+
}, domToMutation: function(a) {
|
|
1536
|
+
a = a.getAttribute("at") !== "false";
|
|
1537
|
+
this.updateAt_(a);
|
|
1538
|
+
}, saveExtraState: function() {
|
|
1539
|
+
return null;
|
|
1540
|
+
}, loadExtraState: function() {
|
|
1541
|
+
}, updateAt_: function(a) {
|
|
1542
|
+
this.removeInput("AT");
|
|
1543
|
+
this.removeInput("ORDINAL", true);
|
|
1544
|
+
a ? (this.appendValueInput("AT").setCheck("Number"), $.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL").appendField($.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT");
|
|
1545
|
+
this.moveInputBefore("AT", "TO");
|
|
1546
|
+
this.getInput("ORDINAL") && this.moveInputBefore("ORDINAL", "TO");
|
|
1547
|
+
} };
|
|
1548
|
+
blocks$$module$build$src$blocks$lists.lists_setIndex = LISTS_SETINDEX$$module$build$src$blocks$lists;
|
|
1549
|
+
var LISTS_GETSUBLIST$$module$build$src$blocks$lists = { init: function() {
|
|
1550
|
+
this.WHERE_OPTIONS_1 = [[$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_START, "FROM_START"], [$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_END, "FROM_END"], [$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FIRST, "FIRST"]];
|
|
1551
|
+
this.WHERE_OPTIONS_2 = [
|
|
1552
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_START, "FROM_START"],
|
|
1553
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_END, "FROM_END"],
|
|
1554
|
+
[$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_LAST, "LAST"]
|
|
1555
|
+
];
|
|
1556
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_HELPURL);
|
|
1557
|
+
this.setStyle("list_blocks");
|
|
1558
|
+
this.appendValueInput("LIST").setCheck("Array").appendField($.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);
|
|
1559
|
+
const a = (b) => {
|
|
1560
|
+
const c = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: this["WHERE_OPTIONS_" + b] });
|
|
1561
|
+
c.setValidator(function(d) {
|
|
1562
|
+
const e = this.getValue();
|
|
1563
|
+
d = d === "FROM_START" || d === "FROM_END";
|
|
1564
|
+
d !== (e === "FROM_START" || e === "FROM_END") && this.getSourceBlock().updateAt_(b, d);
|
|
1565
|
+
});
|
|
1566
|
+
return c;
|
|
1567
|
+
};
|
|
1568
|
+
this.appendDummyInput("WHERE1_INPUT").appendField(a(1), "WHERE1");
|
|
1569
|
+
this.appendDummyInput("AT1");
|
|
1570
|
+
this.appendDummyInput("WHERE2_INPUT").appendField(a(2), "WHERE2");
|
|
1571
|
+
this.appendDummyInput("AT2");
|
|
1572
|
+
$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL && this.appendDummyInput("TAIL").appendField($.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL);
|
|
1573
|
+
this.setInputsInline(true);
|
|
1574
|
+
this.setOutput(true, "Array");
|
|
1575
|
+
this.updateAt_(
|
|
1576
|
+
1,
|
|
1577
|
+
true
|
|
1578
|
+
);
|
|
1579
|
+
this.updateAt_(2, true);
|
|
1580
|
+
this.setTooltip($.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TOOLTIP);
|
|
1581
|
+
}, mutationToDom: function() {
|
|
1582
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
1583
|
+
var b = this.getInput("AT1") instanceof $.ValueInput$$module$build$src$core$inputs$value_input;
|
|
1584
|
+
a.setAttribute("at1", String(b));
|
|
1585
|
+
b = this.getInput("AT2") instanceof $.ValueInput$$module$build$src$core$inputs$value_input;
|
|
1586
|
+
a.setAttribute("at2", String(b));
|
|
1587
|
+
return a;
|
|
1588
|
+
}, domToMutation: function(a) {
|
|
1589
|
+
const b = a.getAttribute("at1") === "true";
|
|
1590
|
+
a = a.getAttribute("at2") === "true";
|
|
1591
|
+
this.updateAt_(1, b);
|
|
1592
|
+
this.updateAt_(2, a);
|
|
1593
|
+
}, saveExtraState: function() {
|
|
1594
|
+
return null;
|
|
1595
|
+
}, loadExtraState: function() {
|
|
1596
|
+
}, updateAt_: function(a, b) {
|
|
1597
|
+
this.removeInput("AT" + a);
|
|
1598
|
+
this.removeInput("ORDINAL" + a, true);
|
|
1599
|
+
b ? (this.appendValueInput("AT" + a).setCheck("Number"), $.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL" + a).appendField($.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT" + a);
|
|
1600
|
+
a === 1 && (this.moveInputBefore(
|
|
1601
|
+
"AT1",
|
|
1602
|
+
"WHERE2_INPUT"
|
|
1603
|
+
), this.getInput("ORDINAL1") && this.moveInputBefore("ORDINAL1", "WHERE2_INPUT"));
|
|
1604
|
+
$.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL && this.moveInputBefore("TAIL", null);
|
|
1605
|
+
} };
|
|
1606
|
+
blocks$$module$build$src$blocks$lists.lists_getSublist = LISTS_GETSUBLIST$$module$build$src$blocks$lists;
|
|
1607
|
+
blocks$$module$build$src$blocks$lists.lists_sort = { init: function() {
|
|
1608
|
+
this.jsonInit({
|
|
1609
|
+
message0: "%{BKY_LISTS_SORT_TITLE}",
|
|
1610
|
+
args0: [{ type: "field_dropdown", name: "TYPE", options: [["%{BKY_LISTS_SORT_TYPE_NUMERIC}", "NUMERIC"], ["%{BKY_LISTS_SORT_TYPE_TEXT}", "TEXT"], ["%{BKY_LISTS_SORT_TYPE_IGNORECASE}", "IGNORE_CASE"]] }, { type: "field_dropdown", name: "DIRECTION", options: [["%{BKY_LISTS_SORT_ORDER_ASCENDING}", "1"], ["%{BKY_LISTS_SORT_ORDER_DESCENDING}", "-1"]] }, { type: "input_value", name: "LIST", check: "Array" }],
|
|
1611
|
+
output: "Array",
|
|
1612
|
+
style: "list_blocks",
|
|
1613
|
+
tooltip: "%{BKY_LISTS_SORT_TOOLTIP}",
|
|
1614
|
+
helpUrl: "%{BKY_LISTS_SORT_HELPURL}"
|
|
1615
|
+
});
|
|
1616
|
+
} };
|
|
1617
|
+
blocks$$module$build$src$blocks$lists.lists_split = {
|
|
1618
|
+
init: function() {
|
|
1619
|
+
const a = $.fromJson$$module$build$src$core$field_registry({ type: "field_dropdown", options: [[$.Msg$$module$build$src$core$msg.LISTS_SPLIT_LIST_FROM_TEXT, "SPLIT"], [$.Msg$$module$build$src$core$msg.LISTS_SPLIT_TEXT_FROM_LIST, "JOIN"]] });
|
|
1620
|
+
if (!a) throw Error("field_dropdown not found");
|
|
1621
|
+
a.setValidator((b) => {
|
|
1622
|
+
this.updateType_(b);
|
|
1623
|
+
});
|
|
1624
|
+
this.setHelpUrl($.Msg$$module$build$src$core$msg.LISTS_SPLIT_HELPURL);
|
|
1625
|
+
this.setStyle("list_blocks");
|
|
1626
|
+
this.appendValueInput("INPUT").setCheck("String").appendField(
|
|
1627
|
+
a,
|
|
1628
|
+
"MODE"
|
|
1629
|
+
);
|
|
1630
|
+
this.appendValueInput("DELIM").setCheck("String").appendField($.Msg$$module$build$src$core$msg.LISTS_SPLIT_WITH_DELIMITER);
|
|
1631
|
+
this.setInputsInline(true);
|
|
1632
|
+
this.setOutput(true, "Array");
|
|
1633
|
+
this.setTooltip(() => {
|
|
1634
|
+
const b = this.getFieldValue("MODE");
|
|
1635
|
+
if (b === "SPLIT") return $.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_SPLIT;
|
|
1636
|
+
if (b === "JOIN") return $.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_JOIN;
|
|
1637
|
+
throw Error("Unknown mode: " + b);
|
|
1638
|
+
});
|
|
1639
|
+
},
|
|
1640
|
+
updateType_: function(a) {
|
|
1641
|
+
if (this.getFieldValue("MODE") !== a) {
|
|
1642
|
+
const b = this.getInput("INPUT").connection;
|
|
1643
|
+
b.setShadowDom(null);
|
|
1644
|
+
const c = b.targetBlock();
|
|
1645
|
+
c && (b.disconnect(), c.isShadow() ? c.dispose(false) : this.bumpNeighbours());
|
|
1646
|
+
}
|
|
1647
|
+
a === "SPLIT" ? (this.outputConnection.setCheck("Array"), this.getInput("INPUT").setCheck("String")) : (this.outputConnection.setCheck("String"), this.getInput("INPUT").setCheck("Array"));
|
|
1648
|
+
},
|
|
1649
|
+
mutationToDom: function() {
|
|
1650
|
+
const a = $.createElement$$module$build$src$core$utils$xml("mutation");
|
|
1651
|
+
a.setAttribute("mode", this.getFieldValue("MODE"));
|
|
1652
|
+
return a;
|
|
1653
|
+
},
|
|
1654
|
+
domToMutation: function(a) {
|
|
1655
|
+
this.updateType_(a.getAttribute("mode"));
|
|
1656
|
+
},
|
|
1657
|
+
saveExtraState: function() {
|
|
1658
|
+
return { mode: this.getFieldValue("MODE") };
|
|
1659
|
+
},
|
|
1660
|
+
loadExtraState: function(a) {
|
|
1661
|
+
this.updateType_(a.mode);
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
$.defineBlocks$$module$build$src$core$common(blocks$$module$build$src$blocks$lists);
|
|
1665
|
+
var module$build$src$blocks$lists = { blocks: blocks$$module$build$src$blocks$lists };
|
|
1666
|
+
var blocks$$module$build$src$blocks$blocks = Object.assign({}, blocks$$module$build$src$blocks$lists, blocks$$module$build$src$blocks$logic, blocks$$module$build$src$blocks$loops, blocks$$module$build$src$blocks$math, blocks$$module$build$src$blocks$procedures, blocks$$module$build$src$blocks$text, blocks$$module$build$src$blocks$variables, blocks$$module$build$src$blocks$variables_dynamic), module$build$src$blocks$blocks = {
|
|
1667
|
+
blocks: blocks$$module$build$src$blocks$blocks,
|
|
1668
|
+
lists: module$build$src$blocks$lists,
|
|
1669
|
+
logic: module$build$src$blocks$logic,
|
|
1670
|
+
loops: module$build$src$blocks$loops,
|
|
1671
|
+
math: module$build$src$blocks$math,
|
|
1672
|
+
procedures: module$build$src$blocks$procedures,
|
|
1673
|
+
texts: module$build$src$blocks$text,
|
|
1674
|
+
variables: module$build$src$blocks$variables,
|
|
1675
|
+
variablesDynamic: module$build$src$blocks$variables_dynamic
|
|
1676
|
+
};
|
|
1677
|
+
module$build$src$blocks$blocks.__namespace__ = $;
|
|
1678
|
+
return module$build$src$blocks$blocks;
|
|
1679
|
+
});
|
|
1680
|
+
})(blocks_compressed$1);
|
|
1681
|
+
return blocks_compressed$1.exports;
|
|
1682
|
+
}
|
|
1683
|
+
var blocks_compressedExports = requireBlocks_compressed();
|
|
1684
|
+
const libraryBlocks = /* @__PURE__ */ getDefaultExportFromCjs(blocks_compressedExports);
|
|
1685
|
+
const {
|
|
1686
|
+
blocks,
|
|
1687
|
+
lists,
|
|
1688
|
+
logic,
|
|
1689
|
+
loops,
|
|
1690
|
+
math,
|
|
1691
|
+
procedures,
|
|
1692
|
+
texts,
|
|
1693
|
+
variables,
|
|
1694
|
+
variablesDynamic
|
|
1695
|
+
} = libraryBlocks;
|
|
1696
|
+
export {
|
|
1697
|
+
blocks,
|
|
1698
|
+
lists,
|
|
1699
|
+
logic,
|
|
1700
|
+
loops,
|
|
1701
|
+
math,
|
|
1702
|
+
procedures,
|
|
1703
|
+
texts,
|
|
1704
|
+
variables,
|
|
1705
|
+
variablesDynamic
|
|
1706
|
+
};
|
|
1707
|
+
//# sourceMappingURL=blocks-B05dnyOn.js.map
|