Jean-Yves Didier

can now bundle things with webpack

...@@ -116,18 +116,18 @@ module.exports = function (grunt) { ...@@ -116,18 +116,18 @@ module.exports = function (grunt) {
116 concat: { 116 concat: {
117 dist: { 117 dist: {
118 src: [ 118 src: [
119 - 'src/arcs.js', 119 + 'src/arcs.js', *
120 - 'src/component.js', 120 + 'src/component.js', *
121 - 'src/context.js', 121 + 'src/context.js', *
122 - 'src/invocation.js', 122 + 'src/invocation.js', *
123 - 'src/connection.js', 123 + 'src/connection.js', *
124 'src/sheet.js', 124 'src/sheet.js',
125 - 'src/eventlogicparser.js', 125 + 'src/eventlogicparser.js', *
126 - 'src/tokenevent.js', 126 + 'src/tokenevent.js', *
127 - 'src/transitionnetwork.js', 127 + 'src/transitionnetwork.js', *
128 - 'src/statemachine.js', 128 + 'src/statemachine.js', *
129 'src/application.js', 129 'src/application.js',
130 - 'src/exports.js' 130 + 'src/exports.js' *
131 ], 131 ],
132 dest: 'build/arcs.js' 132 dest: 'build/arcs.js'
133 }, 133 },
......
This diff is collapsed. Click to expand it.
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
12 ], 12 ],
13 "author": "Jean-Yves Didier", 13 "author": "Jean-Yves Didier",
14 "license": "GPL-3.0-or-later", 14 "license": "GPL-3.0-or-later",
15 + "dependencies": {
16 + "tracking": ">=1.1.3",
17 + "three": ">=0.131",
18 + "js-aruco": ">=0.1",
19 + "codemirror": ">=5.62"
20 + },
15 "devDependencies": { 21 "devDependencies": {
16 "bower": ">=1.3.9", 22 "bower": ">=1.3.9",
17 "grunt": ">=0.4.5", 23 "grunt": ">=0.4.5",
......
1 /****************************************************************************** 1 /******************************************************************************
2 * Application implementation 2 * Application implementation
3 * ***************************************************************************/ 3 * ***************************************************************************/
4 +import Context from './context.js';
5 +import Sheet from './sheet.js';
6 +import Component from './component.js';
4 7
5 /** 8 /**
6 * Creates an application runnable by the ARCS engine. 9 * Creates an application runnable by the ARCS engine.
...@@ -11,8 +14,8 @@ ...@@ -11,8 +14,8 @@
11 * to load all external scripts describing components, instanciate 14 * to load all external scripts describing components, instanciate
12 * all components and then start the application 15 * all components and then start the application
13 */ 16 */
14 -ARCS.Application = function () { 17 +let Application = function () {
15 - var context = new ARCS.Context(), 18 + var context = new Context(),
16 sheets = {}, 19 sheets = {},
17 controller = {}, 20 controller = {},
18 dependencies = [], 21 dependencies = [],
...@@ -68,13 +71,13 @@ ARCS.Application = function () { ...@@ -68,13 +71,13 @@ ARCS.Application = function () {
68 // then we should work on sheets 71 // then we should work on sheets
69 sheetList = Object.keys(sheets); 72 sheetList = Object.keys(sheets);
70 for (i = 0; i < sheetList.length; i++) { 73 for (i = 0; i < sheetList.length; i++) {
71 - temp = new ARCS.Sheet(context); 74 + temp = new Sheet(context);
72 temp.import(sheets[sheetList[i]], context); 75 temp.import(sheets[sheetList[i]], context);
73 sheets[sheetList[i]] = temp; 76 sheets[sheetList[i]] = temp;
74 } 77 }
75 78
76 - ARCS.Component.connect(controller, "requestSheet", self, "setSheet"); 79 + Component.connect(controller, "requestSheet", self, "setSheet");
77 - ARCS.Component.connect(controller, "requestTermination", self, "finish"); 80 + Component.connect(controller, "requestTermination", self, "finish");
78 controller.start(); 81 controller.start();
79 }; 82 };
80 83
...@@ -173,7 +176,7 @@ ARCS.Application = function () { ...@@ -173,7 +176,7 @@ ARCS.Application = function () {
173 * 176 *
174 */ 177 */
175 this.import = function (object) { 178 this.import = function (object) {
176 - context = new ARCS.Context(object.context/*.components*/); 179 + context = new Context(object.context/*.components*/);
177 sheets = object.sheets; 180 sheets = object.sheets;
178 controller = object.controller; 181 controller = object.controller;
179 if (controller === undefined) { 182 if (controller === undefined) {
...@@ -204,13 +207,14 @@ ARCS.Application = function () { ...@@ -204,13 +207,14 @@ ARCS.Application = function () {
204 }; 207 };
205 }; 208 };
206 209
207 -ARCS.Application.setDependency = function (app, key) { 210 +Application.setDependency = function (app, key) {
208 app.setDependency(key); 211 app.setDependency(key);
209 }; 212 };
210 213
211 214
212 215
213 -ARCS.Component.create(ARCS.Application); 216 +Component.create(Application);
214 -ARCS.Application.slot("setSheet"); 217 +Application.slot("setSheet");
215 -ARCS.Application.slot("finish"); 218 +Application.slot("finish");
216 219
220 +export default {Application: Application};
......
...@@ -5,18 +5,13 @@ ...@@ -5,18 +5,13 @@
5 //"use strict"; 5 //"use strict";
6 6
7 7
8 +
9 +
8 /** 10 /**
9 * Main source: describes all the methods needed by the ARCS engine 11 * Main source: describes all the methods needed by the ARCS engine
10 * @file 12 * @file
11 */ 13 */
12 14
13 -/**
14 - * Defines all elements needed for Augmented Reality Component System
15 - * @namespace
16 - */
17 -var ARCS = ARCS || {};
18 -
19 -
20 15
21 /****************************************************************************** 16 /******************************************************************************
22 * Helper functions to determine environment 17 * Helper functions to determine environment
...@@ -24,9 +19,12 @@ var ARCS = ARCS || {}; ...@@ -24,9 +19,12 @@ var ARCS = ARCS || {};
24 19
25 /** 20 /**
26 * @return {boolean} true if ARCS is run in a node.js environment 21 * @return {boolean} true if ARCS is run in a node.js environment
27 - */ 22 + */
28 -ARCS.isInNode = function () {
29 - return (typeof require === 'function' && require.resolve);
30 -};
31 23
24 +export default function isInNode() {
25 + return (typeof process !== 'undefined') &&
26 + (process.release.name.search(/node|io.js/) !== -1);
27 +
28 + // return (typeof require === 'function' && require.resolve);
29 +};
32 30
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
8 * 8 *
9 * @namespace 9 * @namespace
10 */ 10 */
11 -ARCS.Component = { 11 +var Component = {
12 /** Error message */ 12 /** Error message */
13 SourceIsNotComponent : {message : "Source is not a component"}, 13 SourceIsNotComponent : {message : "Source is not a component"},
14 /** Error message */ 14 /** Error message */
...@@ -124,13 +124,13 @@ ARCS.Component = { ...@@ -124,13 +124,13 @@ ARCS.Component = {
124 var orig, p; 124 var orig, p;
125 // here we can perform various checks. 125 // here we can perform various checks.
126 if (source.signals === undefined) { 126 if (source.signals === undefined) {
127 - throw ARCS.Component.SourceIsNotComponent; 127 + throw Component.SourceIsNotComponent;
128 } 128 }
129 if (source.signals[signal] === undefined) { 129 if (source.signals[signal] === undefined) {
130 - throw ARCS.Component.UndefinedSignal; 130 + throw Component.UndefinedSignal;
131 } 131 }
132 if (destination[slt] === undefined) { 132 if (destination[slt] === undefined) {
133 - throw ARCS.Component.UndefinedSlot; 133 + throw Component.UndefinedSlot;
134 } 134 }
135 // we must also check if the signals dispose of their own implementation 135 // we must also check if the signals dispose of their own implementation
136 if (!source.hasOwnProperty('signals')) { 136 if (!source.hasOwnProperty('signals')) {
...@@ -170,7 +170,7 @@ ARCS.Component = { ...@@ -170,7 +170,7 @@ ARCS.Component = {
170 */ 170 */
171 invoke : function (destination, slt, value) { 171 invoke : function (destination, slt, value) {
172 if (destination[slt] === undefined) { 172 if (destination[slt] === undefined) {
173 - throw ARCS.Component.UndefinedSlot; 173 + throw Component.UndefinedSlot;
174 } 174 }
175 175
176 176
...@@ -188,3 +188,5 @@ ARCS.Component = { ...@@ -188,3 +188,5 @@ ARCS.Component = {
188 } 188 }
189 } 189 }
190 }; 190 };
191 +
192 +export default { Component: Component};
......
1 /****************************************************************************** 1 /******************************************************************************
2 * Connection implementation 2 * Connection implementation
3 * ***************************************************************************/ 3 * ***************************************************************************/
4 +import Component from './component.js';
5 +
4 /** 6 /**
5 * Defines a connection between two components 7 * Defines a connection between two components
6 * @param source {object} component at the source 8 * @param source {object} component at the source
...@@ -9,14 +11,14 @@ ...@@ -9,14 +11,14 @@
9 * @param slot {string} name of the signal receiving data 11 * @param slot {string} name of the signal receiving data
10 * @class 12 * @class
11 */ 13 */
12 -ARCS.Connection = function (source, signal, destination, slot) { 14 +let Connection = function (source, signal, destination, slot) {
13 /** 15 /**
14 * Connects two components as described in this object 16 * Connects two components as described in this object
15 * @function ARCS.Connection#connect 17 * @function ARCS.Connection#connect
16 */ 18 */
17 this.connect = function () { 19 this.connect = function () {
18 try { 20 try {
19 - ARCS.Component.connect(source, signal, destination, slot); 21 + Component.connect(source, signal, destination, slot);
20 } catch(e) { console.log(e, source, signal, destination, slot); } 22 } catch(e) { console.log(e, source, signal, destination, slot); }
21 }; 23 };
22 /** 24 /**
...@@ -24,7 +26,7 @@ ARCS.Connection = function (source, signal, destination, slot) { ...@@ -24,7 +26,7 @@ ARCS.Connection = function (source, signal, destination, slot) {
24 * described in this object. 26 * described in this object.
25 */ 27 */
26 this.disconnect = function () { 28 this.disconnect = function () {
27 - ARCS.Component.disconnect(source, signal, destination, slot); 29 + Component.disconnect(source, signal, destination, slot);
28 }; 30 };
29 31
30 this.getSource = function() { 32 this.getSource = function() {
...@@ -49,7 +51,10 @@ ARCS.Connection = function (source, signal, destination, slot) { ...@@ -49,7 +51,10 @@ ARCS.Connection = function (source, signal, destination, slot) {
49 * @param context {object} the context in which this connection takes place. 51 * @param context {object} the context in which this connection takes place.
50 * @return a connection 52 * @return a connection
51 */ 53 */
52 -ARCS.Connection.cast = function (obj, context) { 54 +Connection.cast = function (obj, context) {
53 - return new ARCS.Connection(context.getComponent(obj.source)/*[obj.source].instance*/, obj.signal, 55 + return new Connection(context.getComponent(obj.source)/*[obj.source].instance*/, obj.signal,
54 context.getComponent(obj.destination)/*[obj.destination].instance*/, obj.slot); 56 context.getComponent(obj.destination)/*[obj.destination].instance*/, obj.slot);
55 }; 57 };
58 +
59 +
60 +export default { Connection: Connection};
......
1 +import StateMachine from './statemachine.js';
2 +import isInNode from './arcs.js';
3 +
1 /** 4 /**
2 * @class ARCS.Context 5 * @class ARCS.Context
3 * @classdesc Class representing a context containing libraries and components 6 * @classdesc Class representing a context containing libraries and components
4 * used by different parts of the framework. 7 * used by different parts of the framework.
5 * @param ctx {object} an object representing data for the context. 8 * @param ctx {object} an object representing data for the context.
6 */ 9 */
7 -ARCS.Context = function( ctx ) { 10 +let Context = function( ctx ) {
8 var components = {}; 11 var components = {};
9 var constants = {}; 12 var constants = {};
10 var factories = {}; 13 var factories = {};
...@@ -17,7 +20,7 @@ ARCS.Context = function( ctx ) { ...@@ -17,7 +20,7 @@ ARCS.Context = function( ctx ) {
17 var instanciateComponents; 20 var instanciateComponents;
18 21
19 22
20 - factories.StateMachine = ARCS.Statemachine; 23 + factories.StateMachine = Statemachine;
21 24
22 25
23 if (ctx !== undefined) { 26 if (ctx !== undefined) {
...@@ -43,9 +46,9 @@ ARCS.Context = function( ctx ) { ...@@ -43,9 +46,9 @@ ARCS.Context = function( ctx ) {
43 var loadDataFile =async function(fileName) { 46 var loadDataFile =async function(fileName) {
44 var dataPromise ; 47 var dataPromise ;
45 48
46 - if (ARCS.isInNode()) { 49 + if (isInNode()) {
47 return new Promise(function (resolve, reject) { 50 return new Promise(function (resolve, reject) {
48 - var dep = require(fileName); 51 + var dep = require(/* webpackIgnore: true */fileName);
49 if (dep !== undefined) { 52 if (dep !== undefined) {
50 resolve(dep); 53 resolve(dep);
51 } else { 54 } else {
...@@ -62,7 +65,7 @@ ARCS.Context = function( ctx ) { ...@@ -62,7 +65,7 @@ ARCS.Context = function( ctx ) {
62 var i; 65 var i;
63 // we will use different instances of require either the one of node 66 // we will use different instances of require either the one of node
64 // or the one from require.js 67 // or the one from require.js
65 - ARCS.Context.currentContext = self; 68 + Context.currentContext = self;
66 69
67 var res=[]; 70 var res=[];
68 for(i=0; i < libraries.length; i++) { 71 for(i=0; i < libraries.length; i++) {
...@@ -125,7 +128,7 @@ ARCS.Context = function( ctx ) { ...@@ -125,7 +128,7 @@ ARCS.Context = function( ctx ) {
125 this.loadLibrary = function (libName, cbFunction) { 128 this.loadLibrary = function (libName, cbFunction) {
126 var libUrl = libName, libActualName = libName; 129 var libUrl = libName, libActualName = libName;
127 130
128 - ARCS.Context.currentContext = self; 131 + Context.currentContext = self;
129 if (typeof libName !== "string") { 132 if (typeof libName !== "string") {
130 libActualName = libName.name; 133 libActualName = libName.name;
131 libUrl = libName.url; 134 libUrl = libName.url;
...@@ -135,11 +138,11 @@ ARCS.Context = function( ctx ) { ...@@ -135,11 +138,11 @@ ARCS.Context = function( ctx ) {
135 libraries.push(libActualName); 138 libraries.push(libActualName);
136 } 139 }
137 // TODO promisify call to cbFunction 140 // TODO promisify call to cbFunction
138 - return import(libUrl).then( function(module) { 141 + return import(/* webpackIgnore: true */libUrl).then( function(module) {
139 // TODO insert here component factories 142 // TODO insert here component factories
140 for (p in module.default) { 143 for (p in module.default) {
141 if (module.default.hasOwnProperty(p)) { 144 if (module.default.hasOwnProperty(p)) {
142 - ARCS.Context.currentContext.setFactory(p,module.default[p]); 145 + Context.currentContext.setFactory(p,module.default[p]);
143 } 146 }
144 } 147 }
145 148
...@@ -309,7 +312,7 @@ ARCS.Context = function( ctx ) { ...@@ -309,7 +312,7 @@ ARCS.Context = function( ctx ) {
309 312
310 313
311 /** pseudo-singleton to current context being used */ 314 /** pseudo-singleton to current context being used */
312 -ARCS.Context.currentContext = null; 315 +Context.currentContext = null;
313 -
314 316
317 +export default {Context: Context};
315 318
......
...@@ -36,7 +36,7 @@ WS = [ \r\n\t]* ...@@ -36,7 +36,7 @@ WS = [ \r\n\t]*
36 ******************************************************************************/ 36 ******************************************************************************/
37 37
38 38
39 -ARCS.EventLogicParser = (function() { 39 +let EventLogicParser = (function() {
40 /* 40 /*
41 * Generated by PEG.js 0.8.0. 41 * Generated by PEG.js 0.8.0.
42 * 42 *
...@@ -661,3 +661,5 @@ ARCS.EventLogicParser = (function() { ...@@ -661,3 +661,5 @@ ARCS.EventLogicParser = (function() {
661 parse: parse 661 parse: parse
662 }; 662 };
663 })(); 663 })();
664 +
665 +export default { EventLogicParser: EventLogicParser};
......
1 // no longer needed with the use of imports 1 // no longer needed with the use of imports
2 2
3 -export { ARCS as default};
...\ No newline at end of file ...\ No newline at end of file
3 +import Component from './component.js';
4 +import StateMachine from './statemachine.js';
5 +import isInNode from './arcs.js';
6 +import Context from './context.js';
7 +import Invocation from './invocation.js';
8 +import Connection from './connection.js';
9 +import Sheet from './sheet.js';
10 +import Application from './application.js';
11 +
12 +export default {
13 + Component: Component,
14 + isInNode : isInNode,
15 + StateMachine: StateMachine,
16 + Context: Context,
17 + Invocation: Invocation,
18 + Connection: Connection,
19 + Sheet: Sheet,
20 + Application: Application
21 +};
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
8 * @param value {mixed} value passed to the invoked slot 8 * @param value {mixed} value passed to the invoked slot
9 * @constructor 9 * @constructor
10 */ 10 */
11 -ARCS.Invocation = function (destination, slot, value) { 11 +
12 +let Invocation = function (destination, slot, value) {
12 this.getDestination = function () { 13 this.getDestination = function () {
13 return destination; 14 return destination;
14 }; 15 };
...@@ -36,19 +37,19 @@ ARCS.Invocation = function (destination, slot, value) { ...@@ -36,19 +37,19 @@ ARCS.Invocation = function (destination, slot, value) {
36 * @param context {object} the context in which this invocation takes place. 37 * @param context {object} the context in which this invocation takes place.
37 * @return an invocation 38 * @return an invocation
38 */ 39 */
39 -ARCS.Invocation.cast = function (obj, context) { 40 +Invocation.cast = function (obj, context) {
40 if (obj.value !== undefined) { 41 if (obj.value !== undefined) {
41 var component = context.getComponent(obj.destination); 42 var component = context.getComponent(obj.destination);
42 if (component === undefined) { 43 if (component === undefined) {
43 console.error("[ARCS] Destination ",obj.destination, " is undefined"); 44 console.error("[ARCS] Destination ",obj.destination, " is undefined");
44 } 45 }
45 46
46 - return new ARCS.Invocation(component, obj.slot, obj.value); 47 + return new Invocation(component, obj.slot, obj.value);
47 } 48 }
48 49
49 // this one looks odd, seems there is a failure in the logic. 50 // this one looks odd, seems there is a failure in the logic.
50 if (obj.ref !== undefined) { 51 if (obj.ref !== undefined) {
51 - return new ARCS.Invocation(context.getComponent(obj.destination), obj.slot, context.getConstant(obj.ref)); 52 + return new Invocation(context.getComponent(obj.destination), obj.slot, context.getConstant(obj.ref));
52 } 53 }
53 }; 54 };
54 55
...@@ -61,6 +62,8 @@ ARCS.Invocation.cast = function (obj, context) { ...@@ -61,6 +62,8 @@ ARCS.Invocation.cast = function (obj, context) {
61 };*/ 62 };*/
62 63
63 64
64 -ARCS.Invocation.PRE_CONNECTION = 0;
65 -ARCS.Invocation.POST_CONNECTION = 1;
66 -ARCS.Invocation.CLEAN_UP = 2;
...\ No newline at end of file ...\ No newline at end of file
65 +Invocation.PRE_CONNECTION = 0;
66 +Invocation.POST_CONNECTION = 1;
67 +Invocation.CLEAN_UP = 2;
68 +
69 +export default { Invocation: Invocation};
......
1 /****************************************************************************** 1 /******************************************************************************
2 * Sheet implementation 2 * Sheet implementation
3 * ***************************************************************************/ 3 * ***************************************************************************/
4 +import Context from './context.js';
5 +import Invocation from './invocation.js';
6 +import Connection from './connection.js';
7 +
4 /** 8 /**
5 * Constructs a sheet 9 * Constructs a sheet
6 * @param context {object} a context object 10 * @param context {object} a context object
...@@ -11,8 +15,8 @@ ...@@ -11,8 +15,8 @@
11 * and a set of {@link ARCS.Connection}. Sheets have two high level operations: 15 * and a set of {@link ARCS.Connection}. Sheets have two high level operations:
12 * activation and deactivation. 16 * activation and deactivation.
13 */ 17 */
14 -ARCS.Sheet = function (ctx /*context*/) { 18 +let Sheet = function (ctx /*context*/) {
15 - var context = new ARCS.Context(); 19 + var context = new Context();
16 var preconnections = [], postconnections = [], cleanups = [], connections = [], 20 var preconnections = [], postconnections = [], cleanups = [], connections = [],
17 invokePreconnections, invokePostconnections, invokeCleanups, 21 invokePreconnections, invokePostconnections, invokeCleanups,
18 connect, disconnect, getComponentName, 22 connect, disconnect, getComponentName,
...@@ -74,14 +78,14 @@ ARCS.Sheet = function (ctx /*context*/) { ...@@ -74,14 +78,14 @@ ARCS.Sheet = function (ctx /*context*/) {
74 }; 78 };
75 79
76 this.addPreConnection = function (obj) { 80 this.addPreConnection = function (obj) {
77 - var pre = ARCS.Invocation.cast(obj, context); 81 + var pre = Invocation.cast(obj, context);
78 pre.id = preCount++; 82 pre.id = preCount++;
79 preconnections.push(pre); 83 preconnections.push(pre);
80 return pre.id; 84 return pre.id;
81 }; 85 };
82 86
83 this.addPostConnection = function (obj) { 87 this.addPostConnection = function (obj) {
84 - var post = ARCS.Invocation.cast(obj, context); 88 + var post = Invocation.cast(obj, context);
85 post.id = postCount++; 89 post.id = postCount++;
86 postconnections.push(post); 90 postconnections.push(post);
87 return post.id; 91 return post.id;
...@@ -89,14 +93,14 @@ ARCS.Sheet = function (ctx /*context*/) { ...@@ -89,14 +93,14 @@ ARCS.Sheet = function (ctx /*context*/) {
89 93
90 94
91 this.addCleanup = function (obj) { 95 this.addCleanup = function (obj) {
92 - var cleanup = ARCS.Invocation.cast(obj, context); 96 + var cleanup = Invocation.cast(obj, context);
93 cleanup.id = cleanCount++; 97 cleanup.id = cleanCount++;
94 cleanups.push(cleanup); 98 cleanups.push(cleanup);
95 return cleanup.id; 99 return cleanup.id;
96 }; 100 };
97 101
98 this.addConnection = function (obj) { 102 this.addConnection = function (obj) {
99 - var connection = ARCS.Connection.cast(obj, context); 103 + var connection = Connection.cast(obj, context);
100 connection.id = connCount++; 104 connection.id = connCount++;
101 connections.push(connection); 105 connections.push(connection);
102 return connection.id; 106 return connection.id;
...@@ -187,7 +191,7 @@ ARCS.Sheet = function (ctx /*context*/) { ...@@ -187,7 +191,7 @@ ARCS.Sheet = function (ctx /*context*/) {
187 191
188 192
189 var cacheConnectionsInvocations = function(object) { 193 var cacheConnectionsInvocations = function(object) {
190 - var i = 0, castInvocation = ARCS.Invocation.cast, castConnection = ARCS.Connection.cast; 194 + var i = 0, castInvocation = Invocation.cast, castConnection = Connection.cast;
191 for (i = 0; i < object.preconnections.length; i++) { 195 for (i = 0; i < object.preconnections.length; i++) {
192 preconnections.push(castInvocation(object.preconnections[i], context)); 196 preconnections.push(castInvocation(object.preconnections[i], context));
193 } 197 }
...@@ -208,7 +212,7 @@ ARCS.Sheet = function (ctx /*context*/) { ...@@ -208,7 +212,7 @@ ARCS.Sheet = function (ctx /*context*/) {
208 */ 212 */
209 this.import = function (object) { 213 this.import = function (object) {
210 if (object.hasOwnProperty("context")) { 214 if (object.hasOwnProperty("context")) {
211 - context = new ARCS.Context(object.context); 215 + context = new Context(object.context);
212 context.setParent(ctx); 216 context.setParent(ctx);
213 } 217 }
214 218
...@@ -267,3 +271,5 @@ ARCS.Sheet = function (ctx /*context*/) { ...@@ -267,3 +271,5 @@ ARCS.Sheet = function (ctx /*context*/) {
267 //console.log("setting parent"); 271 //console.log("setting parent");
268 context.setParent(ctx); 272 context.setParent(ctx);
269 }; 273 };
274 +
275 +export default {Sheet: Sheet};
......
1 /****************************************************************************** 1 /******************************************************************************
2 * Statemachine implementation 2 * Statemachine implementation
3 * ***************************************************************************/ 3 * ***************************************************************************/
4 +
5 +import Component from './component.js';
6 +import TransitionNetwork from './transitionnetwork.js';
7 +import EventLogicParser from './eventlogicparser.js';
8 +
4 /** 9 /**
5 * Describes a statemachine 10 * Describes a statemachine
6 * @param obj {object} an object describing a state machine. If obj is empty then the statemachine is empty 11 * @param obj {object} an object describing a state machine. If obj is empty then the statemachine is empty
7 * @class 12 * @class
8 */ 13 */
9 -ARCS.Statemachine = new ARCS.Component.create(function (obj) { 14 +let Statemachine = new Component.create(function (obj) {
10 // dynamic construction: properties are initial state that have properties 15 // dynamic construction: properties are initial state that have properties
11 // that are tokens and value that are the final state 16 // that are tokens and value that are the final state
12 var initial = "", final = "", transitions = {}, currentState = "", self= this; 17 var initial = "", final = "", transitions = {}, currentState = "", self= this;
...@@ -35,7 +40,7 @@ ARCS.Statemachine = new ARCS.Component.create(function (obj) { ...@@ -35,7 +40,7 @@ ARCS.Statemachine = new ARCS.Component.create(function (obj) {
35 tokenEvents = {}; 40 tokenEvents = {};
36 for (t in transitions[s]) { 41 for (t in transitions[s]) {
37 if (transitions[s].hasOwnProperty(t)) { 42 if (transitions[s].hasOwnProperty(t)) {
38 - network = ARCS.TransitionNetwork.build(astTokens[t],tokenEvents).promise; 43 + network = TransitionNetwork.build(astTokens[t],tokenEvents).promise;
39 network.then( 44 network.then(
40 function() { 45 function() {
41 var token; 46 var token;
...@@ -164,3 +169,4 @@ ARCS.Statemachine = new ARCS.Component.create(function (obj) { ...@@ -164,3 +169,4 @@ ARCS.Statemachine = new ARCS.Component.create(function (obj) {
164 ['requestSheet', 'requestTermination'] 169 ['requestSheet', 'requestTermination']
165 ); 170 );
166 171
172 +export default { StateMachine: StateMachine};
......
1 // this class creates a promise that can be deferred as long as necessary. 1 // this class creates a promise that can be deferred as long as necessary.
2 // calls to accept or reject will solve the promise. 2 // calls to accept or reject will solve the promise.
3 3
4 -ARCS.TokenEvent = function() { 4 +let TokenEvent = function() {
5 var refResolve; 5 var refResolve;
6 var refReject; 6 var refReject;
7 7
...@@ -17,4 +17,6 @@ ARCS.TokenEvent = function() { ...@@ -17,4 +17,6 @@ ARCS.TokenEvent = function() {
17 this.abort = function() { 17 this.abort = function() {
18 refReject(); 18 refReject();
19 }; 19 };
20 -};
...\ No newline at end of file ...\ No newline at end of file
20 +};
21 +
22 +export default {TokenEvent: TokenEvent};
......
1 /* the aim of the transition network is to build a network of promises */ 1 /* the aim of the transition network is to build a network of promises */
2 +import TokenEvent from './tokenevent.js';
2 3
3 -ARCS.TransitionNetwork = function() { 4 +
5 +let TransitionNetwork = function() {
4 // object storing token events (that is to say references to promises) 6 // object storing token events (that is to say references to promises)
5 this.promise = {}; 7 this.promise = {};
6 8
...@@ -16,7 +18,7 @@ ARCS.TransitionNetwork = function() { ...@@ -16,7 +18,7 @@ ARCS.TransitionNetwork = function() {
16 18
17 }; 19 };
18 20
19 -ARCS.TransitionNetwork.build = function(tree, tokenEvents) { 21 +TransitionNetwork.build = function(tree, tokenEvents) {
20 var res; 22 var res;
21 var tmpTN; 23 var tmpTN;
22 var rightTN; 24 var rightTN;
...@@ -27,22 +29,22 @@ ARCS.TransitionNetwork.build = function(tree, tokenEvents) { ...@@ -27,22 +29,22 @@ ARCS.TransitionNetwork.build = function(tree, tokenEvents) {
27 if (tokenEvents.hasOwnProperty(tree)) { 29 if (tokenEvents.hasOwnProperty(tree)) {
28 tokenEvent = tokenEvents[tree]; 30 tokenEvent = tokenEvents[tree];
29 } else { 31 } else {
30 - tokenEvents[tree] = tokenEvent = new ARCS.TokenEvent(); 32 + tokenEvents[tree] = tokenEvent = new TokenEvent();
31 } 33 }
32 - var tn = new ARCS.TransitionNetwork(); 34 + var tn = new TransitionNetwork();
33 tn.promise = tokenEvent.promise; 35 tn.promise = tokenEvent.promise;
34 return tn; 36 return tn;
35 } 37 }
36 38
37 - res = ARCS.TransitionNetwork.build(tree[0],tokenEvents); 39 + res = TransitionNetwork.build(tree[0],tokenEvents);
38 var i; 40 var i;
39 for (i=1; i < tree.length; i++) { 41 for (i=1; i < tree.length; i++) {
40 if (tree[i].hasOwnProperty('and')) { 42 if (tree[i].hasOwnProperty('and')) {
41 - rightTN = ARCS.TransitionNetwork.build(tree[i]['and'], tokenEvents); 43 + rightTN = TransitionNetwork.build(tree[i]['and'], tokenEvents);
42 tmpTN = res.and(rightTN); 44 tmpTN = res.and(rightTN);
43 } else { 45 } else {
44 if (tree[i].hasOwnProperty('or')) { 46 if (tree[i].hasOwnProperty('or')) {
45 - rightTN = ARCS.TransitionNetwork.build(tree[i]['or'], tokenEvents); 47 + rightTN = TransitionNetwork.build(tree[i]['or'], tokenEvents);
46 tmpTN = res.or(rightTN); 48 tmpTN = res.or(rightTN);
47 } else { 49 } else {
48 console.warn('[ARCS] Illegal tree'); 50 console.warn('[ARCS] Illegal tree');
...@@ -52,4 +54,6 @@ ARCS.TransitionNetwork.build = function(tree, tokenEvents) { ...@@ -52,4 +54,6 @@ ARCS.TransitionNetwork.build = function(tree, tokenEvents) {
52 } 54 }
53 55
54 return res; 56 return res;
55 -};
...\ No newline at end of file ...\ No newline at end of file
57 +};
58 +
59 +export default {TransitionNetwork: TransitionNetwork};
......
1 +const path = require('path');
2 +
3 +module.exports = {
4 + entry: './src/exports.js',
5 + mode: 'none',
6 + output: {
7 + filename: 'arcs.js',
8 + path: path.resolve(__dirname, 'build'),
9 + },
10 + module: {
11 + parser: {
12 + javascript: {
13 + commonjsMagicComments: true
14 + }
15 + }
16 + }
17 +};