blockly-fluid 1.3.21 → 1.3.23
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/index.js +22 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -82,15 +82,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
82
82
|
output: true,
|
|
83
83
|
|
|
84
84
|
generator: ({ DROPDOWN }) => [
|
|
85
|
-
`"${
|
|
86
|
-
(Object.entries(
|
|
87
|
-
(Object.prototype.toString.call(input.options) === "[object Object]")
|
|
88
|
-
? input.options
|
|
89
|
-
: {}
|
|
90
|
-
).find((option) => option[1] === DROPDOWN)?.[0] || DROPDOWN)
|
|
91
|
-
.replaceAll("\\", "\\\\")
|
|
92
|
-
.replaceAll(`"`, `\\"`)
|
|
93
|
-
}"`,
|
|
85
|
+
`"${DROPDOWN.replaceAll("\\", "\\\\").replaceAll(`"`, `\\"`)}"`,
|
|
94
86
|
"atomic"
|
|
95
87
|
]
|
|
96
88
|
};
|
|
@@ -243,7 +235,10 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
243
235
|
Blockly.Python,
|
|
244
236
|
Blockly.Lua,
|
|
245
237
|
Blockly.PHP
|
|
246
|
-
].filter(Boolean).map((codeGenerator) => [
|
|
238
|
+
].filter(Boolean).map((codeGenerator) => [
|
|
239
|
+
codeGenerator.name_,
|
|
240
|
+
codeGenerator
|
|
241
|
+
])),
|
|
247
242
|
...languageGenerators,
|
|
248
243
|
...{
|
|
249
244
|
Fallback: languageGeneratorFallback
|
|
@@ -312,7 +307,22 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
312
307
|
])),
|
|
313
308
|
...(input.name) ? {
|
|
314
309
|
[input.name]: (({
|
|
315
|
-
[Blockly.INPUT_VALUE]: () =>
|
|
310
|
+
[Blockly.INPUT_VALUE]: () => {
|
|
311
|
+
const value = languageGenerator.valueToCode(block, input.name, languageGenerator.ORDER_ATOMIC);
|
|
312
|
+
|
|
313
|
+
if (Object.prototype.toString.call(inputs[input.name].options) === "[object Object]") {
|
|
314
|
+
return `((${
|
|
315
|
+
JSON.stringify(
|
|
316
|
+
Object.fromEntries(
|
|
317
|
+
Object.entries(inputs[input.name].options)
|
|
318
|
+
.map((option) => option.reverse())
|
|
319
|
+
)
|
|
320
|
+
)
|
|
321
|
+
})[${value}] || ${value})`;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
return value;
|
|
325
|
+
},
|
|
316
326
|
[Blockly.NEXT_STATEMENT]: () => languageGenerator.statementToCode(block, input.name)
|
|
317
327
|
})[input.type] || (() => null))()
|
|
318
328
|
} : {}
|
|
@@ -336,11 +346,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
336
346
|
output: true,
|
|
337
347
|
|
|
338
348
|
generator: ({ TEXT }) => [
|
|
339
|
-
`"${
|
|
340
|
-
TEXT
|
|
341
|
-
.replaceAll("\\", "\\\\")
|
|
342
|
-
.replaceAll(`"`, `\\"`)
|
|
343
|
-
}"`,
|
|
349
|
+
`"${TEXT.replaceAll("\\", "\\\\").replaceAll(`"`, `\\"`)}"`,
|
|
344
350
|
"atomic"
|
|
345
351
|
]
|
|
346
352
|
};
|