mo4islona / node-blockly Goto Github PK
View Code? Open in Web Editor NEWBlockly for Node.js and Browser via CommonJS module
Blockly for Node.js and Browser via CommonJS module
It looks like this library only supports english. Is there any way you know of to add additional translation files?
I am getting an error with the following code:
<xml xmlns="http://www.w3.org/1999/xhtml">
<variables></variables>
<block type="controls_repeat_ext" id="(BFo|WQ,-6A?iUwjWMq*" x="238" y="63">
<value name="TIMES">
<shadow type="math_number" id="QU(s4?wLG]]%mQZ:pPQP">
<field name="NUM">10</field>
</shadow>
</value>
</block>
</xml>
Most of the XML generated by this doesn't seem to work with node-blockly
(tested the XML against the in-browser generator, XML is valid).
You can reproduce this in your live demo, http://mo4islona.github.io/blockly/
First, load the page and change the language to french. Open the the Loops flyout to see that the while block has been translated to french. Then close the flyout and translate back to english. Check the Loops flyout again and still see french in the While block.
It seems like these blocks are getting stuck on whatever language they are set to when you first look at them.
Node version: 8.9.4
OS: win32 x64
I just use yarn add node-blockly
to install the package.When start to install dependency libxmljs
, it will throw error log as below :
Arguments:
C:\Program Files\nodejs\node.exe D:\Yarn\bin\yarn.js add node-blockly
PATH:
D:\Python27\;D:\Python27\Scripts;D:\mupdf-1.12.0-windows;D:\iverilog\gtkwave\bin;D:\iverilog\bin;C:\Users\Shen-Teng Tu\AppData\Local\atom\bin;D:\MinGW\bin;D:\phantomjs-2.1.1-windows\bin;D:\Gradle\gradle-3.5\bin;D:\cygwin64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Pandoc\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\dotnet\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;D:\Go\bin;D:\Yarn\bin\;E:\MongoDB\Server\3.4\bin;D:\Microsoft VS Code\bin;C:\Users\Shen-Teng Tu\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin;C:\Users\Shen-Teng Tu\AppData\Roaming\npm;C:\Users\Shen-Teng Tu\AppData\Local\Yarn\bin
Yarn version:
1.5.1
Node version:
8.9.4
Platform:
win32 x64
npm manifest:
{
"name": "node-blockly-test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
yarn manifest:
No manifest
Lockfile:
No lockfile
Trace:
Error: D:\GitHubAtomProjects\node-blockly-test\node_modules\libxmljs: Command failed.
Exit code: 1
Command: C:\windows\system32\cmd.exe
Arguments: /d /s /c node-gyp rebuild
Directory: D:\GitHubAtomProjects\node-blockly-test\node_modules\libxmljs
Output:
D:\GitHubAtomProjects\node-blockly-test\node_modules\libxmljs>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn D:\Python27\python.EXE
gyp info spawn args [ 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=2015',
gyp info spawn args '-I',
gyp info spawn args 'D:\\GitHubAtomProjects\\node-blockly-test\\node_modules\\libxmljs\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Shen-Teng Tu\\.node-gyp\\8.9.4\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\Shen-Teng Tu\\.node-gyp\\8.9.4',
gyp info spawn args '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\Users\\Shen-Teng Tu\\.node-gyp\\8.9.4\\<(target_arch)\\node.lib',
gyp info spawn args '-Dmodule_root_dir=D:\\GitHubAtomProjects\\node-blockly-test\\node_modules\\libxmljs',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'D:\\GitHubAtomProjects\\node-blockly-test\\node_modules\\libxmljs\\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
�b�o�Ӥ�פ��@���ظm�@�ӱM�סC�Y�n�ҥΥ���իءA�Х[�J "/m" �ѼơC
buf.c
catalog.c
chvalid.c
dict.c
..\..\..\vendor\libxml\catalog.c(979): warning C4013: 'open' undefined; assuming extern returning int [D:\GitHubAtomProjects\node-blockly-test\node_modules\libxmljs\build\vendor\libxml\libxml.vcxproj]
.......
.......
.......
.......
C:\Users\Shen-Teng Tu\.node-gyp\8.9.4\include\node\v8.h(3177): note: see declaration of 'v8::Object::SetAccessor' (compiling source file ..\src\xml_xpath_context.cc)
C:\Users\Shen-Teng Tu\.node-gyp\8.9.4\x64\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x273E6F [D:\GitHubAtomProjects\node-blockly-test\node_modules\libxmljs\build\xmljs.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\GitHubAtomProjects\node-blockly-test\node_modules\libxmljs
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
at ProcessTermError.MessageError (D:\Yarn\lib\cli.js:186:110)
at new ProcessTermError (D:\Yarn\lib\cli.js:226:113)
at ChildProcess.<anonymous> (D:\Yarn\lib\cli.js:30281:17)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Socket.stream.socket.on (internal/child_process.js:346:11)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at Pipe._handle.close [as _onclose] (net.js:554:12)
I try to find out the problem. Remove all modules then install libxmljs
only, it get success with no error.Remove all modules again then only install just xmlshim
, it get error as above.
I found libxmljs
which xmlshim
depend on is not original package. I don't know if this is the main reason.
I'm trying to use this library to load blockly synchronously. But when I try to require the module I get 'document.getElementById' errors during runtime and the app completely breaks. Anyone who has experience with this? Am I doing something horribly wrong?
node-blockly does not compile on node v12.10.0, it errors compiling libxmljs
.
@mo4islona I see you've created an issue upstream upstream already.
What is the status? For our current (new) experiments with blockly I've downgraded to node 10, but that's just for a short while.
When trying to use this package with the latest version of blockly, I get the following error (via test and server use):
ReferenceError: goog is not defined
Hi,
I'm trying to use your repo with webpack. But no success (see below).
Any suggestions? Thank you very much,
Larry
import Blockly from "node-blockly";
Gives webpack errors
WARNING in ./node_modules/jsdom/lib/jsdom/utils.js 186:21-40
Critical dependency: the request of a dependency is an expression
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
WARNING in ./node_modules/parse5/lib/index.js 55:23-49
Critical dependency: the request of a dependency is an expression
@ ./node_modules/jsdom/lib/jsdom/browser/domtohtml.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js
Module not found: Error: Can't resolve 'child_process' in '/Users/larry.kluger/www/envelope-builder/node_modules/jsdom/lib/jsdom/living'
@ ./node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js 4:22-46
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/bindings/bindings.js
Module not found: Error: Can't resolve 'fs' in '/Users/larry.kluger/www/envelope-builder/node_modules/bindings'
@ ./node_modules/bindings/bindings.js 6:9-22
@ ./node_modules/libxmljs/lib/bindings.js
@ ./node_modules/libxmljs/index.js
@ ./node_modules/xmlshim/index.js
@ ./node_modules/node-blockly/lib/blockly_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/jsdom/lib/jsdom/browser/resource-loader.js
Module not found: Error: Can't resolve 'fs' in '/Users/larry.kluger/www/envelope-builder/node_modules/jsdom/lib/jsdom/browser'
@ ./node_modules/jsdom/lib/jsdom/browser/resource-loader.js 7:11-24
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/jsdom/lib/jsdom/living/xhr-utils.js
Module not found: Error: Can't resolve 'fs' in '/Users/larry.kluger/www/envelope-builder/node_modules/jsdom/lib/jsdom/living'
@ ./node_modules/jsdom/lib/jsdom/living/xhr-utils.js 6:11-24
@ ./node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/pn/fs.js
Module not found: Error: Can't resolve 'fs' in '/Users/larry.kluger/www/envelope-builder/node_modules/pn'
@ ./node_modules/pn/fs.js 1:9-22
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in '/Users/larry.kluger/www/envelope-builder/node_modules/request/lib'
@ ./node_modules/request/lib/har.js 3:9-22
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise-native/lib/rp.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in '/Users/larry.kluger/www/envelope-builder/node_modules/forever-agent'
@ ./node_modules/forever-agent/index.js 6:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise-native/lib/rp.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in '/Users/larry.kluger/www/envelope-builder/node_modules/tough-cookie/lib'
@ ./node_modules/tough-cookie/lib/cookie.js 32:10-24
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in '/Users/larry.kluger/www/envelope-builder/node_modules/tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 3:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise-native/lib/rp.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/larry.kluger/www/envelope-builder/node_modules/forever-agent'
@ ./node_modules/forever-agent/index.js 7:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise-native/lib/rp.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/larry.kluger/www/envelope-builder/node_modules/tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 4:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/request-promise-native/lib/rp.js
@ ./node_modules/jsdom/lib/api.js
@ ./node_modules/node-blockly/lib/blocks_compressed.js
@ ./node_modules/node-blockly/_blockly.js
@ ./node_modules/node-blockly/index.js
@ ./src/index.js
Hi,
I'm trying to translate xml string to a javascript string in the browser but I don't have a visual workspace. I'm trying to use the code from the README except that I require the browser version on node-blockly. This is the essential part of my code:
var Blockly = require('node-blockly/browser');
var xml = Blockly.Xml.textToDom(xml_text);
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(xml, workspace);
var code = Blockly.JavaScript.workspaceToCode(workspace);
If I do this I get the following error:
Error: Trying to set block style to procedure_blocks before theme was defined via Blockly.setTheme().
at module.exports.Blockly.Block.setStyle (blockly_compressed_browser.js:1460)
at module.exports.Blockly.Block.init (blocks_compressed_browser.js:106)
at new module.exports.Blockly.Block (blockly_compressed_browser.js:1440)
at module.exports.Blockly.Workspace.newBlock (blockly_compressed_browser.js:1029)
at Object.module.exports.Blockly.Xml.domToBlockHeadless_ (blockly_compressed_browser.js:993)
at Object.module.exports.Blockly.Xml.domToBlock (blockly_compressed_browser.js:990)
at Object.module.exports.Blockly.Xml.domToWorkspace (blockly_compressed_browser.js:986)
Which method would you recommend to go from an xml string to a javascript string in the browser?
Many thanks!
Hi @mo4islona,
I think we can move all the dependencies to devDependencies
so this becomes a dependency free package (or just one dependency). We only seem to be using lodash for _.extend
which can be easily emulated; the others only seem to be needed at build time. Before setting about doing this I wanted to ensure I wasn't missing something - is there a reason I've overlooked that we need the other dependencies for people who install via npm
?
Cheers,
Benjie.
From the commit history I can see that you have moved to xmlshim
that will cause a problem in build for people who are behind an http proxy
xmlshim
depends on pulling libxmljs
from git://github.com/znerol/libxmljs.git#xmlwriter-0.17.1
and this url doesn't work behind an http proxy
I had the following error
Command failed: /usr/bin/git clone --depth=1 -q -b xmlwriter-0.18.0 git://github.com/znerol/libxmljs.git /home/jenkins/.npm/_cacache/tmp/git-clone-bd5b74dd
This broke my build unfortunately and probably will break other people's build who uses http proxy
I'm trying to use Blockly.Extensions with this library to do validations in the browser. But I get the error that Blockly.Extensions is undefined. Is there support for Blocky.Extensions in this library?
hi,
node-blockly is great, I like it
how to use Blockly.inject
with node-blockly
For some reason, when I call Blockly.setLocale() I get an uncaught type error, Uncaught TypeError: _.extend(...) is not a function
This is in browser.js line 14. I'm not sure what causes this to happen..
with the following definition:
{
"icons": [
"event"
],
"max": 1,
"block": {
"type": "on_message",
"message0": "on message received %1 %2",
"args0": [
{
"type": "input_dummy"
},
{
"type": "input_statement",
"name": "code"
}
],
"colour": 0,
"tooltip": "Triggers when a message is received",
"helpUrl": ""
},
"generator": "_return = '\\\\nmodule.exports.message = async message => { try { var channel = message.channel; var member = message.member; var guild = message.guild; ' + Blockly.JavaScript.statementToCode(block, 'code') + '} catch (e) { require(\"../../src/errors\").onerror(\"' + data.req.body.guild + '\", e); } }'"
}
if (json.generator || json.returnGen) {
generators.push({
type: json.block.type,
generator: json.generator,
returnGen: json.returnGen,
});
}
Client-side (not used for anything except debugging):
<% generators.forEach(g => { %>
Blockly.JavaScript['<%= g.type %>'] = function(block) {
var _return;
if (block.returns) eval(decode("<%= g.returnGen %>"));
else eval(decode("<%= g.generator %>"));
return _return;
}
<% }); %>
Server-side (used for compiling):
for (var generator of dlocklyInstance.generators) {
Blockly.JavaScript[generator.type] = function (block) {
var _return;
if (block.returns) eval(generator.returnGen.replace(/\\\\/g, "\\"));
else eval(generator.generator.replace(/\\\\/g, "\\"));
return _return;
}
}
Basically, in the end, the block's generator is set correctly.
The returns
property of the block is used for a generic mutation, and this error only occurs with event/root blocks. (unmutated)
I use two environments. I use the browser version of Blockly (obviously), and I also use the Node version of Blockly in order to compile XML server-side and avoid code injection.
When running the workspaceToCode
function in the browser, the returned code is correct:
module.exports.message = async message => {
try {
var channel = message.channel;
var member = message.member;
var guild = message.guild;
} catch (e) {
require("../../src/errors").onerror("591692042304880815", e);
}
}
However, when running the workspaceToCode
function server-side, an error is thrown
TypeError: Expecting string from statement block: on_message
at module.exports.Blockly.Generator.blockToCode (C:\Users\user\Desktop\Dlockly\node_modules\.pnpm\registry.npmjs.org\node-blockly\1.2.5\node_modules\node-blockly\lib\blockly_compressed.js:864:348)
at module.exports.Blockly.Generator.workspaceToCode (C:\Users\user\Desktop\Dlockly\node_modules\.pnpm\registry.npmjs.org\node-blockly\1.2.5\node_modules\node-blockly\lib\blockly_compressed.js:862:246)
I replaced the server-side generator with this, in order to add some console logs:
for (var generator of dlocklyInstance.generators) {
Blockly.JavaScript[generator.type] = function (block) {
var _return;
console.log(generator.type);
console.log(block.type);
if (block.returns) eval(generator.returnGen.replace(/\\\\/g, "\\"));
else eval(generator.generator.replace(/\\\\/g, "\\"));
console.log(_return);
return _return;
}
}
And I got the following result:
generator.type
= send_message
block.type
= on_message
_return
= await .send();
// Code generated via the send_message
generator
What?? The block uses a different generator?
I have been trying to wrap my head around this for a while. I do not think this is an issue with my code, since no matter how badly I mess up the code, generator.type
should never be different from block.type
. Right?
I decided to post this issue here first before posting it on the main blockly repository, in case there was any relation specifically to the node version.
The api I'm using passes me a javascript defined set of blocks. (React application)
So I have to load the javascript via script tag.
The issue is that node-blockly doesn't seem to expose the Blockly.Blocks so when I load the script, I get a undefined "Blockly.Blocks". How can I load it without having to convert the javascript to xml?
Example:
Blockly.Blocks['or'] = { init: function() { this.jsonInit({ "args0": [ { "check": "Boolean", "name": "op1", "type": "input_value" }, { "check": "Boolean", "name": "op2", "type": "input_value" } ], "colour": 165, "helpUrl": "", "message0": "%1 or %2", "output": "Boolean", "tooltip": "", "type": "or" }); } };
In the version that I pull down from NPM, in the blockly_compressed.js file there is a mispelled "function" (spelled as "funcion") that breaks stuff. Any chance of a release to fix that?
Here's my code. However, it returns an error:
browser.default.Theme.defineTheme is not a function
import Blockly from "node-blockly/browser";
const theme = Blockly.Theme.defineTheme("stone", {
base: Blockly.Themes.Classic,
fontStyle: {
family: "Raleway, sans serif",
weight: "bold",
size: 12
},
componentStyles: {
workspaceBackgroundColour: "red",
toolboxBackgroundColour: "#333"
}
});
export default theme;
Hi, i've tried to import custom blocks using the "Import" directive in Node (I'm not a Node.js guru...), then load my XML and finally i've tried to generate my Python Code, but i'm receiving this error:
> Blockly.Python.workspaceToCode(workspace);
TypeError: Cannot read property 'call' of undefined
at module.exports.Blockly.Generator.blockToCode
Do you know why? it's possible to import custom blocks definition and imports on your Node Module?
Thanks.
I'm pretty sure a blockly update broke localization, and by extension the entire toolbox, in 1.0.28.
https://github.com/google/blockly/blame/81dcdcb287e7027450336c74a104e8438e23e364/core/utils.js#L474
Looks like this:
if (Blockly.Msg[msgKey] == null) {
Changed to this:
if (Blockly.utils.getMessageArray_()[msgKey] == null) {
node-blockly does not install on NodeJS 10.x
I have a workaround PR at znerol/node-xmlshim#8 to use libxmljs 0.19.3 (PR libxmljs/libxmljs#523), which supports NodeJS 10.x. Unfortunately there are multiple dependencies involved for the workaround, until znerol/node-xmlshim
considers the aforementioned PR to use libxmljs 0.19.3+
My fork at eyz/node-blockly@3dd2524 implements these changes for my own personal use, but I believe the proper solution is for znerol/node-xmlshim#8 to be evaluated and potentially merged
I need to make a change here in order to support fieldDate.
I'm not sure if I need to do my own blockly and node-blockly build or what. Do you have instructions for how to do a build of node-blockly ourselves?
Certain blocks use functions that are exposed by blockly, such as mathRandomInt
.
There is also the toLowerCase
function defined by blockly on String.prototype
.
These functions cannot be accessed in node-blockly since they are not exposed.
Hi! Anyone working on updating to the latest Blockly release (Q2 2020)? https://github.com/google/blockly/releases
Turn off the eslint for binary js, so we can download the js, then require and run with eslint enabled project.
Due to the node part need gyp which not works for node 10, so I just download the *_browser.js and put to my react project.
I'm having an issue saving variables with node-blockly
. Here is my code:
const Blockly = require('node-blockly');
var xml = decodeURIComponent(data.req.body.xml);
var dom = Blockly.Xml.textToDom(xml);
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(dom, workspace);
var js = Blockly.JavaScript.workspaceToCode(workspace);
If there are no overridden shadows, the code is generated successfully. But if there are, I get the following error:
ReferenceError: Element is not defined
at Object.module.exports.Blockly.Xml.domToVariables (node_modules\node-blockly\lib\blockly_compressed.js:997:93)
at Object.module.exports.Blockly.Xml.domToWorkspace (node_modules\node-blockly\lib\blockly_compressed.js:991:441)
at module.exports (src\requests\save.js:45:17)
Upon doing some research, I figured out that Element
is a DOM interface which is not available in Node.JS, so I installed jsdom
and jsdom-global
and changed my code to this:
const Blockly = require('node-blockly');
require('jsdom-global')();
var xml = decodeURIComponent(data.req.body.xml);
var dom = Blockly.Xml.textToDom(xml);
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(dom, workspace);
var js = Blockly.JavaScript.workspaceToCode(workspace);
This resulted in the following error:
Error: Trying to set block style to list_blocks before theme was defined via Blockly.setTheme().
at module.exports.Blockly.Block.setStyle (node_modules\node-blockly\lib\blockly_compressed.js:1465:83)
at module.exports.Blockly.Block.init (node_modules\node-blockly\lib\blocks_compressed.js:26:511)
at new module.exports.Blockly.Block (node_modules\node-blockly\lib\blockly_compressed.js:1445:428)
So then I decided to set the style first, changing my code to this:
const Blockly = require('node-blockly');
require('jsdom-global')();
Blockly.setTheme(Blockly.Themes.Classic);
var xml = decodeURIComponent(data.req.body.xml);
var dom = Blockly.Xml.textToDom(xml);
var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(dom, workspace);
var js = Blockly.JavaScript.workspaceToCode(workspace);
Which then resulted in this error:
TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
at Object.convert (node_modules\node-blockly\node_modules\jsdom\lib\jsdom\living\generated\Node.js:749:11)
at HTMLUnknownElement.appendChild (node_modules\node-blockly\node_modules\jsdom\lib\jsdom\living\generated\Node.js:280:29)
at Object.module.exports.Blockly.Xml.blockToDom (node_modules\node-blockly\lib\blockly_compressed.js:12517:54)
The error originates from this statement:
After dome debugging, I saw that the type of the parameter was HTMLUnknownElement
.
I've been trying to fix this for a while but have made no progress, so I decided to open this issue.
Running an Express app on Node.JS version 8.15.1
File can be found here: https://github.com/AlexejheroYTB/Dlockly/blob/master/src/requests/save.js
The new minor release (v1.2.1) caused the helper functions under goog
to be missing.
Expected:
import * as Blockly from 'node-blockly/browser';
Blockly.goog.require('Blockly.utils');
Actual:
import * as Blockly from 'node-blockly/browser';
Blockly.goog.require('Blockly.utils'); // TypeError: Cannot read property 'provide' of **undefined**
Ref: issue #36
I noticed some references from https://blockly-demo.appspot.com/static/media/
including files such as click.mp3, disconnect.wav, delete.mp3, sprites.png
I am wondering if these can be transformed to base64, so that every project could parse them...
Yes, some corner of this world cannot connect to blockly-demo.appspot.com by default...
Thanks
Looking forward to your reply!
I want to build a local application with blockly and three.js on the web page, and pass the return value of blockly's user block program to define/require state management module, so as to realize real-time data interaction。How do you pass data in eval?
In my Blockly Program, I have callbacks that reference certain variable names, such as msg, channel, and member. However, when I try to add those words as reserved words, they appear in the list of RESERVED_WORDS_, but when I name a variable msg, it still says var msg in the generated code, not var msg2. Any way around this?
My code (using react-blockly-drawer):
{
name: "initMessageListener",
category: "Listeners",
block: {
init: function() {
this.jsonInit({
message0: "On Message %1",
args0: [
{
type: "input_statement",
name: "CALLBACK"
}
],
previousStatement: null,
nextStatement: null,
colour: "#ff6d6b",
tooltip:
"Every time message is sent on the server, the code inside this block runs",
helpUrl:
"https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-message"
});
}
},
generator: block => {
if (!Blockly.JavaScript.RESERVED_WORDS_.includes("msg")) {
Blockly.JavaScript.addReservedWords("msg");
}
}
}
I wrapped the compressed version of Blockly
in my own project, but I can't figure how to use the uncompressed version instead.
I've hit a wall with the google-closure-library
dependency, and while I was searching the web for answers, I've found your project.
Looking at your code, I've noticed you are also using the compressed files... have you tried using the uncompressed version?
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.