blockly-fluid 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/index.js +9 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = (Blockly, { generator: languageGeneratorFallback, generators: languageGenerators, translate = (text) => text } = {}) => {
1
+ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: languageGenerators = {}, translate = (text) => text } = {}) => {
2
2
  const Blocks = new Proxy({}, {
3
3
  set(_, name, {
4
4
  inputs = {},
@@ -14,7 +14,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
14
14
  tooltip = "",
15
15
  help = "",
16
16
  generator: blockGeneratorFallback,
17
- generators: blockGenerators
17
+ generators: blockGenerators = {}
18
18
  }) {
19
19
  Blockly.Blocks[name] = {
20
20
  init: function () {
@@ -145,12 +145,12 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
145
145
  languageGenerator.forBlock[name] = (block) => blockGenerator({
146
146
  ...block.inputList.reduce((accumulator, input) => ({
147
147
  ...accumulator,
148
- ...Object.fromEntries(input.fieldRow.map((field) => [field.name, block.getFieldValue(field.name)])),
148
+ ...Object.fromEntries(input.fieldRow.filter((field) => field.name).map((field) => [field.name, block.getFieldValue(field.name)])),
149
149
  ...(input.name) ? {
150
- [input.name]: ({
151
- [Blockly.INPUT_VALUE]: languageGenerator.valueToCode(block, input.name, languageGenerator.ORDER_ATOMIC),
152
- [Blockly.NEXT_STATEMENT]: languageGenerator.statementToCode(block, input.name)
153
- })[input.type] ?? null
150
+ [input.name]: (({
151
+ [Blockly.INPUT_VALUE]: () => languageGenerator.valueToCode(block, input.name, languageGenerator.ORDER_ATOMIC),
152
+ [Blockly.NEXT_STATEMENT]: () => languageGenerator.statementToCode(block, input.name)
153
+ })[input.type] || (() => null))()
154
154
  } : {}
155
155
  }), {}),
156
156
  });
@@ -174,7 +174,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
174
174
  output: true,
175
175
 
176
176
  generator({ TEXT = `""` }) {
177
- return `"${TEXT}"`;
177
+ return [`"${TEXT}"`, Blockly.JavaScript.ORDER_ATOMIC];
178
178
  }
179
179
  };
180
180
 
@@ -193,7 +193,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
193
193
  output: Number,
194
194
 
195
195
  generator({ NUMBER = 0 }) {
196
- return `${parseFloat(NUMBER)}`;
196
+ return [`${parseFloat(NUMBER)}`, Blockly.JavaScript.ORDER_ATOMIC];
197
197
  }
198
198
  };
199
199
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly-fluid",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A flexible proxy wrapper for Blockly blocks.",
5
5
  "main": "index.js",
6
6
  "scripts": {