--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
So then I tried a simpler case of just generating code for a color block. In this case there is a call to "Blockly.createSvgElement" which involves actions using the "document" object. That traces back to Blockly.Field in field.js:40
--
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="text_print" id="18" inline="false" x="206" y="241">
<value name="TEXT">
<block type="text" id="36">
<field name="TEXT">Don't panic!</field>
</block>
</value>
</block>
</xml>
/private/tmp/closure-library/closure/goog/asserts/asserts.js:85
goog.asserts.DEFAULT_ERROR_HANDLER = function(e) { throw e; };
^
AssertionError: Assertion failed: Expected string but got undefined: undefined.
at new goog.asserts.AssertionError (/private/tmp/closure-library/closure/goog/asserts/asserts.js:62:20)
at Object.goog.asserts.doAssertFailure_ (/private/tmp/closure-library/closure/goog/asserts/asserts.js:119:11)
at Object.goog.asserts.assertString (/private/tmp/closure-library/closure/goog/asserts/asserts.js:211:18)
at Blockly.Block.interpolateMsg (/private/tmp/blockly/core/block.js:878:16)
at Blockly.Blocks.text_print.init (/private/tmp/blockly/blocks_compressed.js:138:117)
at Blockly.Block.fill (/private/tmp/blockly/core/block.js:128:10)
at Blockly.Block.initialize (/private/tmp/blockly/core/block.js:85:8)
at Function.Blockly.Block.obtain (/private/tmp/blockly/core/block.js:71:14)
at Object.Blockly.Xml.domToBlock (/private/tmp/blockly/core/xml.js:264:27)
at Object.Blockly.Xml.domToWorkspace (/private/tmp/blockly/core/xml.js:223:31)
/private/tmp/blockly/core/utils.js:263
document.createElementNS(Blockly.SVG_NS, name));
^
ReferenceError: document is not defined
at Object.Blockly.createSvgElement (/private/tmp/blockly/core/utils.js:263:7)
at new Blockly.FieldImage (/private/tmp/blockly/core/field_image.js:51:30)
at Blockly.Blocks.text.newQuote_ (/private/tmp/blockly/blocks_compressed.js:117:372)
at Blockly.Blocks.text.init (/private/tmp/blockly/blocks_compressed.js:117:169)
at Blockly.Block.fill (/private/tmp/blockly/core/block.js:128:10)
at Blockly.Block.initialize (/private/tmp/blockly/core/block.js:85:8)
at Function.Blockly.Block.obtain (/private/tmp/blockly/core/block.js:71:14)
at Object.Blockly.Xml.domToBlock (/private/tmp/blockly/core/xml.js:264:27)
at Object.Blockly.Xml.domToBlock (/private/tmp/blockly/core/xml.js:354:36)
at Object.Blockly.Xml.domToWorkspace (/private/tmp/blockly/core/xml.js:223:31)// This program is to be used with NodeJS run Blockly headless. It loads
// Blockly XML from `input.xml` and outputs python code on `stdout`.
global.DOMParser = require('xmldom').DOMParser;
global.Blockly = require('./blockly_uncompressed.js');
require('./blocks_compressed.js');
require('./python_compressed.js');
require('./msg/messages.js');
var fs = require('fs');
//the contents of './input.xml' are passed as the `data` parameter
fs.readFile('./input.xml', function (err, data) {
if (err) throw err;
var xmlText = data.toString(); //convert the data buffer to a string
try {
var xml = Blockly.Xml.textToDom(xmlText);
} catch (e) {
console.log(e);
return;
}
// Create a headless workspace.
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(workspace, xml);
var code = Blockly.Python.workspaceToCode(workspace);
console.log(code);
});
window.BLOCKLY_DIR = (function() {
^
ReferenceError: window is not defined
at Object.<anonymous> (/Users/matt/Projects/Newton/poc_blockly_nodejs/blockly/blockly_uncompressed.js:4:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/matt/Projects/Newton/poc_blockly_nodejs/blockly/app.headless.js:8:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
var scripts = document.getElementsByTagName('script');
^
ReferenceError: document is not defined
at /Users/matt/Projects/Newton/poc_blockly_nodejs/blockly/blockly_uncompressed.js:6:17
at Object.<anonymous> (/Users/matt/Projects/Newton/poc_blockly_nodejs/blockly/blockly_uncompressed.js:16:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/matt/Projects/Newton/poc_blockly_nodejs/blockly/app.headless.js:6:18)
at Module._compile (module.js:456:26)
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.