blockly-fluid 1.3.12 → 1.3.14

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 CHANGED
@@ -254,12 +254,18 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
254
254
  let current = hatBlock.getNextBlock();
255
255
 
256
256
  while (current) {
257
- code += (languageGenerator.forBlock[current.type]) ? languageGenerator.forBlock[current.type](current, languageGenerator) : "";
257
+ code += (
258
+ (
259
+ (languageGenerator.forBlock[current.type])
260
+ ? languageGenerator.forBlock[current.type](current, languageGenerator)
261
+ : ""
262
+ ) + "\n\n"
263
+ );
258
264
 
259
265
  current = current.getNextBlock();
260
266
  };
261
267
 
262
- return code;
268
+ return code.replace(/\n+$/, "");
263
269
  };
264
270
  };
265
271
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly-fluid",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "A flexible proxy wrapper for Blockly blocks.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/utils/dedent.js CHANGED
@@ -1,15 +1,24 @@
1
- module.exports = (strings, ...values) => {
2
- let text = String.raw({ raw: strings }, ...values);
1
+ module.exports = (text) => {
2
+ const lines = text.split("\n");
3
3
 
4
- text = text.replace(/^\n/, "").replace(/\n$/, "");
4
+ const firstLine = lines.find((line) => line.trim().length > 0);
5
5
 
6
- const indent = text.match(/^[ \t]*(?=\S)/gm);
6
+ if (!firstLine) return text;
7
7
 
8
- if (indent) {
9
- const minimumIndent = Math.min(...indent.map(i => i.length));
8
+ const indentMatch = firstLine.match(/^[ \t]*/);
9
+ const indentSize = (indentMatch) ? indentMatch[0].length : 0;
10
10
 
11
- text = text.replace(new RegExp(`^[ \\t]{${minimumIndent}}`, "gm"), "");
12
- };
11
+ if (indentSize === 0) return text;
13
12
 
14
- return text;
13
+ return (
14
+ lines
15
+ .map((line) => (
16
+ (line.startsWith(" ".repeat(indentSize)))
17
+ ? line.slice(indentSize)
18
+ : line
19
+ ))
20
+ .join("\n")
21
+ .replace(/^\n/, "")
22
+ .replace(/\n\s*$/, "")
23
+ );
15
24
  };