Hi to all,
I'm working on a project and I'm using Blockly in conjunction with JS-interpreter to provide a simple programming environment to the end user.
I noticed a strange behavior. When I have a script like the one below, instead of printing the arrays the following is printed.

{
"N": {},
"O": {},
"h": {},
"ja": {
"N": {},
"O": {},
"h": {},
"ja": {
"N": {},
"O": {},
"h": {},
"ja": null
},
"D": "Array"
},
"D": "Array"
}
{
"N": {},
"O": {},
"h": {
"0": 123,
"1": "Hello"
},
"ja": {
"N": {},
"O": {},
"h": {},
"ja": {
"N": {},
"O": {},
"h": {},
"ja": null
},
"D": "Array"
},
"D": "Array"
}
Following is the code for the JS-interpreter API as well as the implementation of the text_print block.
const JSInterpreterAPI = (interpreter, globalObject) => {
const consoleLog = text => {
return console.log(text);
};
javascriptGenerator.addReservedWords('consoleLog');
interpreter.setProperty(
globalObject,
'consoleLog',
interpreter.createNativeFunction(consoleLog)
);
}
const code = javascriptGenerator.workspaceToCode(workspace);
const interpreter = new Interpreter( // eslint-disable-line
Babel.transform(code, { presets: ['es2015'] }).code,
JSInterpreterAPI(proxy)
);
const run = () => {
if (interpreter.run()) {
setTimeout(run, 1000);
}
};
run();
javascriptGenerator['text_print'] = function (block) {
const msg =
javascriptGenerator.valueToCode(block, 'TEXT', javascriptGenerator.ORDER_NONE) || "''";
return `consoleLog(${msg});\n`;
};