Jean-Yves Didier

fixes in order to pass the loop test

This diff is collapsed. Click to expand it.
1 /* ugly hack in order to display data in web page instead of console */ 1 /* ugly hack in order to display data in web page instead of console */
2 import ARCS from '../build/arcs.js'; 2 import ARCS from '../build/arcs.js';
3 3
4 -var Console; 4 +let Console;
5 /** 5 /**
6 * @class Console 6 * @class Console
7 * @classdesc Redirects console messages to a given HTML element in the page. 7 * @classdesc Redirects console messages to a given HTML element in the page.
...@@ -44,3 +44,4 @@ Console = ARCS.Component.create( ...@@ -44,3 +44,4 @@ Console = ARCS.Component.create(
44 44
45 45
46 export default { Console: Console}; 46 export default { Console: Console};
47 +//export default {};
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
6 */ 6 */
7 7
8 import ARCS from '../build/arcs.js'; 8 import ARCS from '../build/arcs.js';
9 -
10 /** 9 /**
11 * @class Loop 10 * @class Loop
12 * @classdesc loop component creation using a compact style. 11 * @classdesc loop component creation using a compact style.
......
...@@ -217,4 +217,4 @@ Component.create(Application); ...@@ -217,4 +217,4 @@ Component.create(Application);
217 Application.slot("setSheet"); 217 Application.slot("setSheet");
218 Application.slot("finish"); 218 Application.slot("finish");
219 219
220 -export default {Application: Application}; 220 +export default Application;
......
1 -import ARCS from './arcs.js';
2 -
3 1
4 /** 2 /**
5 * Bootstrap for the ARCS engine in a browser environment. 3 * Bootstrap for the ARCS engine in a browser environment.
...@@ -9,7 +7,7 @@ import ARCS from './arcs.js'; ...@@ -9,7 +7,7 @@ import ARCS from './arcs.js';
9 "use strict"; 7 "use strict";
10 8
11 // basically, here we start by importing the module ARCS 9 // basically, here we start by importing the module ARCS
12 -import ARCS from './arcs.js'; 10 +import ARCS from './exports.js';
13 11
14 12
15 console.log("[ARCS] Bootstrapping..."); 13 console.log("[ARCS] Bootstrapping...");
......
...@@ -189,4 +189,4 @@ var Component = { ...@@ -189,4 +189,4 @@ var Component = {
189 } 189 }
190 }; 190 };
191 191
192 -export default { Component: Component}; 192 +export default Component;
......
...@@ -57,4 +57,4 @@ Connection.cast = function (obj, context) { ...@@ -57,4 +57,4 @@ Connection.cast = function (obj, context) {
57 }; 57 };
58 58
59 59
60 -export default { Connection: Connection}; 60 +export default Connection;
......
...@@ -20,7 +20,7 @@ let Context = function( ctx ) { ...@@ -20,7 +20,7 @@ let Context = function( ctx ) {
20 var instanciateComponents; 20 var instanciateComponents;
21 21
22 22
23 - factories.StateMachine = Statemachine; 23 + factories.StateMachine = StateMachine;
24 24
25 25
26 if (ctx !== undefined) { 26 if (ctx !== undefined) {
...@@ -140,6 +140,7 @@ let Context = function( ctx ) { ...@@ -140,6 +140,7 @@ let Context = function( ctx ) {
140 // TODO promisify call to cbFunction 140 // TODO promisify call to cbFunction
141 return import(/* webpackIgnore: true */libUrl).then( function(module) { 141 return import(/* webpackIgnore: true */libUrl).then( function(module) {
142 // TODO insert here component factories 142 // TODO insert here component factories
143 +
143 for (p in module.default) { 144 for (p in module.default) {
144 if (module.default.hasOwnProperty(p)) { 145 if (module.default.hasOwnProperty(p)) {
145 Context.currentContext.setFactory(p,module.default[p]); 146 Context.currentContext.setFactory(p,module.default[p]);
...@@ -149,7 +150,7 @@ let Context = function( ctx ) { ...@@ -149,7 +150,7 @@ let Context = function( ctx ) {
149 if (cbFunction !== undefined) { 150 if (cbFunction !== undefined) {
150 cbFunction(); 151 cbFunction();
151 } 152 }
152 - }).catch( function(msg) { console.error("[ARCS] Trouble loading '",libUrl,"' with reason -", msg) }); 153 + }).catch( function(msg) { console.error("[ARCS] Trouble loading '",libUrl,"' with reason -", {msg}) });
153 }; 154 };
154 155
155 /** 156 /**
...@@ -314,5 +315,5 @@ let Context = function( ctx ) { ...@@ -314,5 +315,5 @@ let Context = function( ctx ) {
314 /** pseudo-singleton to current context being used */ 315 /** pseudo-singleton to current context being used */
315 Context.currentContext = null; 316 Context.currentContext = null;
316 317
317 -export default {Context: Context}; 318 +export default Context;
318 319
......
...@@ -662,4 +662,4 @@ let EventLogicParser = (function() { ...@@ -662,4 +662,4 @@ let EventLogicParser = (function() {
662 }; 662 };
663 })(); 663 })();
664 664
665 -export default { EventLogicParser: EventLogicParser}; 665 +export default EventLogicParser;
......
...@@ -9,7 +9,7 @@ import Connection from './connection.js'; ...@@ -9,7 +9,7 @@ import Connection from './connection.js';
9 import Sheet from './sheet.js'; 9 import Sheet from './sheet.js';
10 import Application from './application.js'; 10 import Application from './application.js';
11 11
12 -export default { 12 +let ARCS = {
13 Component: Component, 13 Component: Component,
14 isInNode : isInNode, 14 isInNode : isInNode,
15 StateMachine: StateMachine, 15 StateMachine: StateMachine,
...@@ -19,3 +19,5 @@ export default { ...@@ -19,3 +19,5 @@ export default {
19 Sheet: Sheet, 19 Sheet: Sheet,
20 Application: Application 20 Application: Application
21 }; 21 };
22 +
23 +export default ARCS;
......
...@@ -66,4 +66,4 @@ Invocation.PRE_CONNECTION = 0; ...@@ -66,4 +66,4 @@ Invocation.PRE_CONNECTION = 0;
66 Invocation.POST_CONNECTION = 1; 66 Invocation.POST_CONNECTION = 1;
67 Invocation.CLEAN_UP = 2; 67 Invocation.CLEAN_UP = 2;
68 68
69 -export default { Invocation: Invocation}; 69 +export default Invocation;
......
...@@ -272,4 +272,4 @@ let Sheet = function (ctx /*context*/) { ...@@ -272,4 +272,4 @@ let Sheet = function (ctx /*context*/) {
272 context.setParent(ctx); 272 context.setParent(ctx);
273 }; 273 };
274 274
275 -export default {Sheet: Sheet}; 275 +export default Sheet;
......
...@@ -11,7 +11,8 @@ import EventLogicParser from './eventlogicparser.js'; ...@@ -11,7 +11,8 @@ import EventLogicParser from './eventlogicparser.js';
11 * @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
12 * @class 12 * @class
13 */ 13 */
14 -let Statemachine = new Component.create(function (obj) { 14 +
15 +let StateMachine = Component.create(function (obj) {
15 // dynamic construction: properties are initial state that have properties 16 // dynamic construction: properties are initial state that have properties
16 // that are tokens and value that are the final state 17 // that are tokens and value that are the final state
17 var initial = "", final = "", transitions = {}, currentState = "", self= this; 18 var initial = "", final = "", transitions = {}, currentState = "", self= this;
...@@ -20,7 +21,7 @@ let Statemachine = new Component.create(function (obj) { ...@@ -20,7 +21,7 @@ let Statemachine = new Component.create(function (obj) {
20 var network = {}; 21 var network = {};
21 22
22 23
23 - var addToken = function(t) { 24 + var addToken = function(t) {
24 if ( self.slots.indexOf(t) < 0 ) { 25 if ( self.slots.indexOf(t) < 0 ) {
25 self.slots.push(t); 26 self.slots.push(t);
26 self[t] = function( s ) { 27 self[t] = function( s ) {
...@@ -88,7 +89,7 @@ let Statemachine = new Component.create(function (obj) { ...@@ -88,7 +89,7 @@ let Statemachine = new Component.create(function (obj) {
88 var t, tsd, ts, tsc; 89 var t, tsd, ts, tsc;
89 try { 90 try {
90 91
91 - var tsd = ARCS.EventLogicParser.parse(token); 92 + var tsd = EventLogicParser.parse(token);
92 if (typeof tsd === "string") { 93 if (typeof tsd === "string") {
93 addToken(tsd); 94 addToken(tsd);
94 } else { 95 } else {
...@@ -151,7 +152,7 @@ let Statemachine = new Component.create(function (obj) { ...@@ -151,7 +152,7 @@ let Statemachine = new Component.create(function (obj) {
151 * the initial state (by default, it is the departure of the first transition 152 * the initial state (by default, it is the departure of the first transition
152 */ 153 */
153 this.start = function () { 154 this.start = function () {
154 - console.log("statemachine", this, initial,obj); 155 + //console.log("statemachine", this, initial,obj);
155 setSheet(initial); 156 setSheet(initial);
156 }; 157 };
157 158
...@@ -169,4 +170,4 @@ let Statemachine = new Component.create(function (obj) { ...@@ -169,4 +170,4 @@ let Statemachine = new Component.create(function (obj) {
169 ['requestSheet', 'requestTermination'] 170 ['requestSheet', 'requestTermination']
170 ); 171 );
171 172
172 -export default { StateMachine: StateMachine}; 173 +export default StateMachine;
......
...@@ -19,4 +19,4 @@ let TokenEvent = function() { ...@@ -19,4 +19,4 @@ let TokenEvent = function() {
19 }; 19 };
20 }; 20 };
21 21
22 -export default {TokenEvent: TokenEvent}; 22 +export default TokenEvent;
......
...@@ -56,4 +56,4 @@ TransitionNetwork.build = function(tree, tokenEvents) { ...@@ -56,4 +56,4 @@ TransitionNetwork.build = function(tree, tokenEvents) {
56 return res; 56 return res;
57 }; 57 };
58 58
59 -export default {TransitionNetwork: TransitionNetwork}; 59 +export default TransitionNetwork;
......
...@@ -42,4 +42,4 @@ ...@@ -42,4 +42,4 @@
42 } 42 }
43 } 43 }
44 } 44 }
45 -
...\ No newline at end of file ...\ No newline at end of file
45 +
......
1 const path = require('path'); 1 const path = require('path');
2 2
3 module.exports = { 3 module.exports = {
4 - entry: './src/exports.js', 4 + experiments : {
5 + outputModule: true
6 + },
7 + entry: {
8 + 'arcs' : {
9 + import : './src/exports.js',
10 + },
11 + 'arcs_browser' : {
12 + import : './src/arcs_browser.js'
13 + //dependOn : ['arcs']
14 + }
15 + },
5 mode: 'none', 16 mode: 'none',
6 output: { 17 output: {
7 - filename: 'arcs.js', 18 + filename: '[name].js',
8 path: path.resolve(__dirname, 'build'), 19 path: path.resolve(__dirname, 'build'),
20 + library: {
21 + type: 'module',
22 + }
9 }, 23 },
10 module: { 24 module: {
11 parser: { 25 parser: {
......