Skip to content

Commit

Permalink
Merge 3f5b117 into d8a16db
Browse files Browse the repository at this point in the history
  • Loading branch information
ghys authored Sep 29, 2021
2 parents d8a16db + 3f5b117 commit e6ae713
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,17 @@ import defineOHBlocks from '@/assets/definitions/blockly/ohblocks'
Vue.config.ignoredElements = ['field', 'block', 'category', 'xml', 'mutation', 'value', 'sep']
// Code to prepend to have a common API to openHAB objects when running GraalVM JS or Nashorn.
const prependCode = `
if (typeof(require) === "function") {
ctx = this;
var runtime = require("@runtime");
itemRegistry = runtime.itemRegistry;
events = runtime.events;
}
`
export default {
props: ['blocks'],
data () {
Expand Down Expand Up @@ -470,7 +481,7 @@ export default {
return Blockly.Xml.domToText(xml)
},
getCode () {
return Blockly.JavaScript.workspaceToCode(this.workspace)
return prependCode + Blockly.JavaScript.workspaceToCode(this.workspace)
},
onChange (event) {
if (event.type === Blockly.Events.FINISHED_LOADING) {
Expand Down

0 comments on commit e6ae713

Please sign in to comment.