Permalink
Browse files

Added index module to act as main entry point into scion modules, and…

… modified nodejs demo to use it.
  • Loading branch information...
1 parent f6bb9ff commit 38723078b56303078bf168cf55556ea9aecee5e2 @jbeard4 committed Mar 28, 2012
Showing with 10 additions and 7 deletions.
  1. +4 −7 demo/nodejs/test.js
  2. +6 −0 lib/index.js
View
@@ -1,21 +1,18 @@
var xml2jsonml = require('xml2jsonml'),
- annotator = require('../../lib/util/annotate-scxml-json'),
- json2model = require('../../lib/scxml/json2model'),
- scxml = require('../../lib/scxml/SCXML');
-
+ scion = require('../../lib/index');
//1 - 2. get the xml file and convert it to jsonml
xml2jsonml.parseFile(process.argv[2],function(scxmlJson){
//3. annotate jsonml
- var annotatedScxmlJson = annotator.transform(scxmlJson,true,true,true,true);
+ var annotatedScxmlJson = scion.annotator.transform(scxmlJson,true,true,true,true);
//4. Convert the SCXML-JSON document to a statechart object model. This step essentially converts id labels to object references, parses JavaScript scripts and expressions embedded in the SCXML as js functions, and does some validation for correctness.
- var model = json2model(annotatedScxmlJson);
+ var model = scion.json2model(annotatedScxmlJson);
console.log("model",model);
//5. Use the statechart object model to instantiate an instance of the statechart interpreter. Optionally, we can pass to the construct an object to be used as the context object (the 'this' object) in script evaluation. Lots of other parameters are available.
- var interpreter = new scxml.NodeInterpreter(model);
+ var interpreter = new scion.scxml.NodeInterpreter(model);
console.log("interpreter",interpreter);
//6. We would connect relevant event listeners to the statechart instance here.
View
@@ -0,0 +1,6 @@
+//this module provides a single point of access to all important user-facing modules in scion
+module.exports = {
+ annotator : require('./util/annotate-scxml-json'),
+ json2model : require('./scxml/json2model'),
+ scxml : require('./scxml/SCXML')
+};

0 comments on commit 3872307

Please sign in to comment.