blockly-fluid 1.3.9 → 1.3.10

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
@@ -1,7 +1,12 @@
1
+ const dedent = require("./utils/dedent.js");
1
2
  const escapeXml = require("./utils/escapeXml.js");
2
3
 
3
4
  module.exports = (Blockly, { generator: languageGeneratorFallback, generators: languageGenerators = {}, translate = (text) => text } = {}) => {
4
5
  const Blocks = new Proxy({}, {
6
+ get(_, name) {
7
+ return Blockly.Blocks[name];
8
+ },
9
+
5
10
  set(_, name, configuration = {}) {
6
11
  if (typeof configuration === "function") (configuration = configuration());
7
12
 
@@ -258,7 +263,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
258
263
  };
259
264
  };
260
265
 
261
- languageGenerator.forBlock[name] = (block) => (((code) => {
266
+ languageGenerator.forBlock[name] = (block) => dedent(((code) => {
262
267
  if (!output) return code;
263
268
 
264
269
  return (Array.isArray(code)) ? [
@@ -296,10 +301,6 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
296
301
  });
297
302
 
298
303
  return true;
299
- },
300
-
301
- get(_, name) {
302
- return Blockly.Blocks[name];
303
304
  }
304
305
  });
305
306
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockly-fluid",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "description": "A flexible proxy wrapper for Blockly blocks.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,15 @@
1
+ module.exports = (strings, ...values) => {
2
+ let text = String.raw({ raw: strings }, ...values);
3
+
4
+ text = text.replace(/^\n/, "").replace(/\n$/, "");
5
+
6
+ const indent = text.match(/^[ \t]*(?=\S)/gm);
7
+
8
+ if (indent) {
9
+ const minimumIndent = Math.min(...indent.map(i => i.length));
10
+
11
+ text = text.replace(new RegExp(`^[ \\t]{${minimumIndent}}`, "gm"), "");
12
+ };
13
+
14
+ return text;
15
+ };