blockly-fluid 1.3.9 → 1.3.11
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 +7 -6
- package/package.json +1 -1
- package/utils/dedent.js +15 -0
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
|
|
|
@@ -268,7 +273,7 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
268
273
|
code,
|
|
269
274
|
languageGenerator.ORDER_NONE
|
|
270
275
|
];
|
|
271
|
-
})((typeof blockGenerator === "function") ? blockGenerator(...[
|
|
276
|
+
})(dedent((typeof blockGenerator === "function") ? blockGenerator(...[
|
|
272
277
|
...((values) => {
|
|
273
278
|
if (!Object.keys(values).length) return [];
|
|
274
279
|
|
|
@@ -292,14 +297,10 @@ module.exports = (Blockly, { generator: languageGeneratorFallback, generators: l
|
|
|
292
297
|
} : {}
|
|
293
298
|
}), {}),
|
|
294
299
|
}), languageGenerator
|
|
295
|
-
]) : blockGenerator));
|
|
300
|
+
]) : blockGenerator)));
|
|
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
package/utils/dedent.js
ADDED
|
@@ -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
|
+
};
|