Browse Source

Merge pull request #41 from AToMPM/eslint-fixes

Add ESLint capability. Turn server-side code into proper modules.
vasco-sousa 7 years ago
parent
commit
65659443ec

+ 3 - 0
.eslintignore

@@ -0,0 +1,3 @@
+client/3rd_party_libs/*
+doc/*
+coverage/*

+ 35 - 0
.eslintrc.json

@@ -0,0 +1,35 @@
+{
+    "env": {
+        "browser": true,
+        "es6": true,
+        "node": true,
+        "jquery": true
+    },
+    "extends": "eslint:recommended",
+    "parserOptions": {
+        "sourceType": "module"
+    },
+    "rules": {
+        
+        "linebreak-style": [
+            "warn",
+            "unix"
+        ],
+        "quotes": [
+            "off",
+            "single"
+        ],
+        "semi": [
+            "error",
+            "always"
+        ],
+        "no-console": ["off"],
+        
+        //ERRORS TO WARN AND FIX LATER
+        "no-mixed-spaces-and-tabs": ["off"],
+        "no-unused-vars": ["off"],
+        "no-redeclare": ["off"],
+         "no-undef": ["off"],
+         "no-useless-escape": ["off"]
+    }
+}

+ 35 - 31
___do.js

@@ -29,7 +29,7 @@ exports.parallel = function parallel(actions) {
         }
         }
       }, errback);
       }, errback);
     });
     });
-  }
+  };
 };
 };
 
 
 // Chains together several actions feeding the output of the first to the
 // Chains together several actions feeding the output of the first to the
@@ -50,12 +50,13 @@ exports.chain = function chain(actions) {
       }
       }
     }
     }
     actions[pos](loop, errback);
     actions[pos](loop, errback);
-  }
-}
+  };
+};
 
 
 // Takes an array and does an array map over it using the async callback `fn`
 // Takes an array and does an array map over it using the async callback `fn`
 // The signature of `fn` is `function fn(item, callback, errback)`
 // The signature of `fn` is `function fn(item, callback, errback)`
-exports.map = function map(array, fn) { return function (callback, errback) {
+exports.map = function map(array, fn) {
+  return function (callback, errback) {
   var counter = array.length;
   var counter = array.length;
   var new_array = [];
   var new_array = [];
   array.forEach(function (item, index) {
   array.forEach(function (item, index) {
@@ -63,7 +64,7 @@ exports.map = function map(array, fn) { return function (callback, errback) {
       new_array[index] = result;
       new_array[index] = result;
       counter--;
       counter--;
       if (counter <= 0) {
       if (counter <= 0) {
-        new_array.length = array.length
+        new_array.length = array.length;
         callback(new_array);
         callback(new_array);
       }
       }
     };
     };
@@ -72,7 +73,8 @@ exports.map = function map(array, fn) { return function (callback, errback) {
       cont(local_callback, errback);
       cont(local_callback, errback);
     }
     }
   });
   });
-}}
+};
+};
 
 
 // Takes an array and does an array filter over it using the async callback `fn`
 // Takes an array and does an array filter over it using the async callback `fn`
 // The signature of `fn` is `function fn(item, callback, errback)`
 // The signature of `fn` is `function fn(item, callback, errback)`
@@ -98,7 +100,8 @@ exports.filter = function filter(array, fn) { return function (callback, errback
       cont(local_callback, errback);
       cont(local_callback, errback);
     }
     }
   });
   });
-}}
+};
+};
 
 
 // Takes an array and does a combined filter and map over it.  If the result
 // Takes an array and does a combined filter and map over it.  If the result
 // of an item is undefined, then it's filtered out, otherwise it's mapped in.
 // of an item is undefined, then it's filtered out, otherwise it's mapped in.
@@ -122,28 +125,29 @@ exports.filterMap = function filterMap(array, fn) { return function (callback, e
       cont(local_callback, errback);
       cont(local_callback, errback);
     }
     }
   });
   });
-}};
+};
+};
 
 
 // Allows to group several callbacks.
 // Allows to group several callbacks.
-exports.combo = function combo(callback) {
-  var items = 0,
-      results = [];
-  function add() {
-    var id = items;
-    items++;
-    return function () {
-      check(id, arguments);
-    };
-  }
-  function check(id, arguments) {
-    results[id] = Array.prototype.slice.call(arguments);
-    items--;
-    if (items == 0) {
-      callback.apply(this, results);
-    }
-  }
-  return { add: add, check: check };
-}
+// exports.combo = function combo(callback) {
+//   var items = 0,
+//       results = [];
+//   function add() {
+//     var id = items;
+//     items++;
+//     return function () {
+//       check(id, arguments);
+//     };
+//   }
+//   function check(id, arguments) {
+//     results[id] = Array.prototype.slice.call(arguments);
+//     items--;
+//     if (items == 0) {
+//       callback.apply(this, results);
+//     }
+//   }
+//   return { add: add, check: check };
+// }
 
 
 
 
 // Takes any async lib that uses callback based signatures and converts
 // Takes any async lib that uses callback based signatures and converts
@@ -164,10 +168,10 @@ exports.convert = function (lib, names) {
             callback(val);
             callback(val);
           }
           }
         });
         });
-        lib[key].apply(lib, args)
-      }
-    }
+        lib[key].apply(lib, args);
+      };
+    };
   });
   });
   return newlib;
   return newlib;
-}
+};
 
 

+ 5 - 2
___fs++.js

@@ -73,7 +73,10 @@ exports.findfiles =
                                             if (_fs.lstatSync(path).isDirectory()) {
                                             if (_fs.lstatSync(path).isDirectory()) {
                                                 newpath = newpath + '/';
                                                 newpath = newpath + '/';
                                             }
                                             }
-                                        } catch (e) {}                                        
+                                        } catch (e) {
+                                            console.log("Error!");
+                                            console.log(e);
+										}
                                         return newpath;
                                         return newpath;
 									});
 									});
 							paths.pop();
 							paths.pop();
@@ -95,7 +98,7 @@ exports.findfiles =
                                     if (_fs.lstatSync(path).isDirectory()) {
                                     if (_fs.lstatSync(path).isDirectory()) {
                                         return path + "/";
                                         return path + "/";
                                     } else return path;
                                     } else return path;
-                                })
+                                });
 							callback(err,newpaths.join('\n'),stderr);
 							callback(err,newpaths.join('\n'),stderr);
                         }
                         }
 					});
 					});

+ 42 - 15
__worker.js

@@ -106,15 +106,10 @@
 
 
 /**************************** LIBRARIES and GLOBALS ****************************/
 /**************************** LIBRARIES and GLOBALS ****************************/
 var  _util 	= require('util'),
 var  _util 	= require('util'),
-	 _path 	= require('path'),
 	 _http 	= require('http'),
 	 _http 	= require('http'),
 	 _do  	= require('./___do'),
 	 _do  	= require('./___do'),
 	 _fs 	 	= _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']),
 	 _fs 	 	= _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']),
-	 _fspp	= _do.convert(require('./___fs++'), ['mkdirs']),	 
-	 _siocl	= require('socket.io-client'),
 	 _utils	= require('./utils'),
 	 _utils	= require('./utils'),
-	 _styleinfo = require('./styleinfo'),
-	 _svg		= require('./libsvg').SVG,
 	 _wlib,
 	 _wlib,
 	 _mmmk,
 	 _mmmk,
 	 _mt,
 	 _mt,
@@ -129,13 +124,13 @@ var keepaliveAgent = new _http.Agent({keepAlive: true, maxSockets: 10, maxFreeSo
 /* return a failure continuable */
 /* return a failure continuable */
 function __errorContinuable(err)	
 function __errorContinuable(err)	
 {
 {
-	return function(callback,errback) {errback(err);}
+	return function(callback,errback) {errback(err);};
 }
 }
 
 
 /* return a success continuable */
 /* return a success continuable */
 function __successContinuable(arg)	
 function __successContinuable(arg)	
 {
 {
-	return function(callback,errback) {callback(arg);}
+	return function(callback,errback) {callback(arg);};
 }
 }
 
 
 
 
@@ -497,9 +492,17 @@ process.on('message',
 
 
 			__wtype = msg['workerType'];
 			__wtype = msg['workerType'];
 			__wid   = msg['workerId'];
 			__wid   = msg['workerId'];
-			_wlib   = eval('('+_fs.readFileSync('.'+__wtype+'.js', 'utf8')+')');
-			_mmmk   = eval('('+_fs.readFileSync('./mmmk.js', 'utf8')+')');
-			_mt  	  = eval('('+_fs.readFileSync('./libmt.js', 'utf8')+')');
+
+            if (__wtype == "/asworker") {
+                _wlib = require("./asworker");
+            } else if (__wtype == "/csworker") {
+                _wlib = require("./csworker");
+            } else {
+                throw "Error! Unknown worker type: " + __wtype;
+            }
+			_mmmk   = require('./mmmk');
+
+            _mt  	  = require('./libmt');
 
 
 			_plugins = {};
 			_plugins = {};
 			_fs.readdirSync('./plugins').forEach(
 			_fs.readdirSync('./plugins').forEach(
@@ -511,8 +514,7 @@ process.on('message',
 							throw 'invalid plugin filename, see user\'s manual';
 							throw 'invalid plugin filename, see user\'s manual';
 
 
 						p = p.match(/(.*)\.js$/)[1];
 						p = p.match(/(.*)\.js$/)[1];
-						_plugins[p] = eval(
-							'('+_fs.readFileSync('./plugins/'+p+'.js','utf8')+')');
+						_plugins[p] = require('./plugins/' + p);
 						if( ! ('interfaces' in _plugins[p]) ||
 						if( ! ('interfaces' in _plugins[p]) ||
 							 ! ('csworker' in _plugins[p])  ||
 							 ! ('csworker' in _plugins[p])  ||
 							 ! ('asworker' in _plugins[p]) )
 							 ! ('asworker' in _plugins[p]) )
@@ -628,7 +630,7 @@ function __handleClientRequest(uri,method,reqData,respIndex)
 							 method,
 							 method,
  							 uri,
  							 uri,
 							 reqData,
 							 reqData,
- 							 _wlib)
+ 							 _wlib);
  						 return true;
  						 return true;
 	 				 }
 	 				 }
 	 			 }) )
 	 			 }) )
@@ -752,7 +754,7 @@ function POST_batchedit(resp,reqData)
 			 							  '/batchCheckpoint?wid='+__wid+
 			 							  '/batchCheckpoint?wid='+__wid+
 	  										  '&backstagePass='+__backstagePass,
 	  										  '&backstagePass='+__backstagePass,
 				 						  {'name':name});
 				 						  {'name':name});
-						  }
+						  };
 	 		 },
 	 		 },
 		 actions = [__successContinuable(), setbchkpt(startchkpt)];
 		 actions = [__successContinuable(), setbchkpt(startchkpt)];
 
 
@@ -813,7 +815,7 @@ function POST_batchedit(resp,reqData)
 					function()	
 					function()	
 					{
 					{
 						__backstagePass = undefined;
 						__backstagePass = undefined;
-						__postInternalErrorMsg(resp,err)
+						__postInternalErrorMsg(resp,err);
 					},
 					},
 					function(undoErr)	
 					function(undoErr)	
 					{	
 					{	
@@ -826,3 +828,28 @@ function POST_batchedit(resp,reqData)
 			}
 			}
 	);
 	);
 }
 }
+
+module.exports = {
+	__errorContinuable,
+	__successContinuable,
+	__httpReq,
+	__wHttpReq,
+
+	__postInternalErrorMsg,
+	__postForbiddenErrorMsg,
+	__postBadReqErrorMsg,
+	__sequenceNumber,
+
+	__postMessage,
+	__uri_to_id,
+	__id_to_uri,
+	__batchCheckpoint,
+
+	GET__current_state,
+
+	//GLOBAL VARS
+	__ids2uris,
+	__nextSequenceNumber,
+	__wtype,
+
+};

+ 18 - 3
asworker.js

@@ -2,8 +2,23 @@
 *  Copyright 2011 by the AToMPM team and licensed under the LGPL
 *  Copyright 2011 by the AToMPM team and licensed under the LGPL
 *  See COPYING.lesser and README.md in the root of this project for full details
 *  See COPYING.lesser and README.md in the root of this project for full details
 */
 */
-
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("./__worker");
+
+const _do = require("./___do");
+const _utils = require('./utils');
+const _mmmk = require("./mmmk");
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+
+
+module.exports = {
 	/************************** REST REQUEST HANDLING **************************/
 	/************************** REST REQUEST HANDLING **************************/
 	/* INTENT :
 	/* INTENT :
 			ask our mtworker to do something (e.g., change transformation execution
 			ask our mtworker to do something (e.g., change transformation execution
@@ -499,4 +514,4 @@
 					 'sequence#':__sequenceNumber(),
 					 'sequence#':__sequenceNumber(),
 					 'respIndex':resp});
 					 'respIndex':resp});
 		}	
 		}	
-}
+};

+ 3 - 3
client/behavioursc_canvas.js

@@ -202,7 +202,7 @@ __canvasBehaviourStatechart = {
 					if( ! GeometryUtils.areTransformationsAllowed() )
 					if( ! GeometryUtils.areTransformationsAllowed() )
 						console.warn('the selection dragging mode can only be activated if '+
 						console.warn('the selection dragging mode can only be activated if '+
 										 'all of the ends of selected edges are also selected, '+
 										 'all of the ends of selected edges are also selected, '+
-										 'and if the geometry controls are inactive')
+										 'and if the geometry controls are inactive');
 					else			
 					else			
 						this.__T(this.__STATE_DRAGGING_SELECTION,event);
 						this.__T(this.__STATE_DRAGGING_SELECTION,event);
 				}
 				}
@@ -212,7 +212,7 @@ __canvasBehaviourStatechart = {
 					if( ! GeometryUtils.areTransformationsAllowed() )
 					if( ! GeometryUtils.areTransformationsAllowed() )
 						console.warn('the geometry controls can only be activated if all '+
 						console.warn('the geometry controls can only be activated if all '+
 										 'of the ends of selected edges are also selected, and'+
 										 'of the ends of selected edges are also selected, and'+
-										 'if the geometry controls aren\'t already active')
+										 'if the geometry controls aren\'t already active');
 					else			
 					else			
 						GeometryUtils.showGeometryControlsOverlay();
 						GeometryUtils.showGeometryControlsOverlay();
 				}
 				}
@@ -423,5 +423,5 @@ __canvasBehaviourStatechart = {
 				}
 				}
 			}
 			}
 		}
 		}
-	}
+	};
 
 

+ 1 - 1
client/behavioursc_dialog.js

@@ -91,4 +91,4 @@ __dialogBehaviourStatechart = {
 				}
 				}
 			}
 			}
 		}	
 		}	
-}
+};

+ 9 - 9
client/client.js

@@ -336,7 +336,7 @@ function _saveModel(fname,backup,autosave)
 	  collaborator) inherit them */
 	  collaborator) inherit them */
 function _setInvisibleMetamodels(mms)
 function _setInvisibleMetamodels(mms)
 {
 {
-	mms = mms.map( function(mm) {return mm.match(/(.*)\.metamodel/)[1]} );
+	mms = mms.map( function(mm) {return mm.match(/(.*)\.metamodel/)[1];} );
 
 
 	function hideOrShow(uri,icon)
 	function hideOrShow(uri,icon)
 	{
 	{
@@ -396,8 +396,8 @@ function _newFormalism(formalism_name) {
 			if( ! utils.isHttpSuccessCode(statusCode) ) {
 			if( ! utils.isHttpSuccessCode(statusCode) ) {
 				WindowManagement.openDialog(_ERROR, 'failed to create new formalism :: '+resp);
 				WindowManagement.openDialog(_ERROR, 'failed to create new formalism :: '+resp);
             } else {
             } else {
-                WindowManagement.spawnClient("/Formalisms/" + formalism_name + "/" + formalism_name + ".model")
-                WindowManagement.spawnClient("/Formalisms/" + formalism_name + "/" + formalism_name + ".defaultIcons.model")
+                WindowManagement.spawnClient("/Formalisms/" + formalism_name + "/" + formalism_name + ".model");
+                WindowManagement.spawnClient("/Formalisms/" + formalism_name + "/" + formalism_name + ".defaultIcons.model");
             }
             }
 		});
 		});
 }
 }
@@ -418,7 +418,7 @@ function _newTransformation(transformation_loc) {
                 if( ! utils.isHttpSuccessCode(statusCode) ) {
                 if( ! utils.isHttpSuccessCode(statusCode) ) {
                     WindowManagement.openDialog(_ERROR, 'failed to create new transformation :: '+resp);
                     WindowManagement.openDialog(_ERROR, 'failed to create new transformation :: '+resp);
                 } else {
                 } else {
-                    WindowManagement.spawnClient(transformation_loc)
+                    WindowManagement.spawnClient(transformation_loc);
                 }
                 }
             });
             });
     } else {
     } else {
@@ -442,7 +442,7 @@ function _newRule(rule_loc) {
                 if( ! utils.isHttpSuccessCode(statusCode) ) {
                 if( ! utils.isHttpSuccessCode(statusCode) ) {
                     WindowManagement.openDialog(_ERROR, 'failed to create new rule :: '+resp);
                     WindowManagement.openDialog(_ERROR, 'failed to create new rule :: '+resp);
                 } else {
                 } else {
-                    WindowManagement.spawnClient(rule_loc)
+                    WindowManagement.spawnClient(rule_loc);
                 }
                 }
             });
             });
     } else {
     } else {
@@ -562,7 +562,7 @@ function _loadModelInWindow(args/*fname[]*/)
 	else if(tf > 0 )
 	else if(tf > 0 )
 		option = 'TF';
 		option = 'TF';
 	else if (vas == 'VAS')
 	else if (vas == 'VAS')
-		option = 'VAS';;
+		option = 'VAS';
 	WindowManagement.spawnClientOption(loc[aid],'',loc[path],option,loc[msg]);
 	WindowManagement.spawnClientOption(loc[aid],'',loc[path],option,loc[msg]);
 }
 }
 
 
@@ -633,7 +633,7 @@ function _openNewDialog(args)
 				}
 				}
 				data += ','+msg;				
 				data += ','+msg;				
 				data = '{'+data;
 				data = '{'+data;
-				data += '}'
+				data += '}';
 				_updateAttr({"asid":pid,"attr":"parameterList","val":data});
 				_updateAttr({"asid":pid,"attr":"parameterList","val":data});
 				play = function()
 				play = function()
                {
                {
@@ -684,7 +684,7 @@ function _loadToolbarInWindow(args/*fname[]*/)
 	else if(tr > 0 )
 	else if(tr > 0 )
 		option = 'TR';
 		option = 'TR';
 	else if(tf > 0 )
 	else if(tf > 0 )
-		option = 'TF';;	
+		option = 'TF';	
 	WindowManagement.spawnClientOption(loc[path],loc[aid],option,'',loc[msg]);
 	WindowManagement.spawnClientOption(loc[path],loc[aid],option,'',loc[msg]);
 }
 }
 
 
@@ -812,7 +812,7 @@ function __iconToFront(tgt)
 
 
 function _autolayout()
 function _autolayout()
 {
 {
-    Layout.autolayout()
+    Layout.autolayout();
 }
 }
 
 
 /*---------------------------- SELECTION OVERLAY -----------------------------*/
 /*---------------------------- SELECTION OVERLAY -----------------------------*/

+ 1 - 1
client/compile_utils.js

@@ -201,7 +201,7 @@ CompileUtils = function(){
 				continue;
 				continue;
 	
 	
 			var r  = __getVobjGeomAttrVal(vobj['orientation']['value']),
 			var r  = __getVobjGeomAttrVal(vobj['orientation']['value']),
-				 sx = __getVobjGeomAttrVal(vobj['scale']['value'][0])
+				 sx = __getVobjGeomAttrVal(vobj['scale']['value'][0]);
 				 sy = __getVobjGeomAttrVal(vobj['scale']['value'][1]);
 				 sy = __getVobjGeomAttrVal(vobj['scale']['value'][1]);
 			vobjects[vid].attr(vobj['style']['value']);
 			vobjects[vid].attr(vobj['style']['value']);
 			vobjects[vid].transform(
 			vobjects[vid].transform(

+ 1 - 1
client/constants.js

@@ -56,7 +56,7 @@ var __WEBPAGE__ = 'https://atompm.github.io/',
 	 __CONTAINMENT_LINK	 	= 'containment',
 	 __CONTAINMENT_LINK	 	= 'containment',
 
 
 	 __EVENT_RIGHT_RELEASE_CANVAS			= 0,
 	 __EVENT_RIGHT_RELEASE_CANVAS			= 0,
- 	 __EVENT_RIGHT_RELEASE_ICON			= 1
+ 	 __EVENT_RIGHT_RELEASE_ICON			= 1,
  	 __EVENT_RIGHT_PRESS_ICON				= 2,
  	 __EVENT_RIGHT_PRESS_ICON				= 2,
  	 __EVENT_LEFT_RELEASE_CANVAS			= 3,
  	 __EVENT_LEFT_RELEASE_CANVAS			= 3,
 	 __EVENT_LEFT_RELEASE_ICON				= 4,
 	 __EVENT_LEFT_RELEASE_ICON				= 4,

+ 5 - 5
client/file_browser.js

@@ -37,10 +37,10 @@ class FileBrowser{
                                 console.log("/" + window.localStorage.getItem('user') + fileb['getcurrfolder']() + folder_name + '.folder');
                                 console.log("/" + window.localStorage.getItem('user') + fileb['getcurrfolder']() + folder_name + '.folder');
                                 DataUtils.createFolder("/" + window.localStorage.getItem('user') + fileb['getcurrfolder']() + folder_name + '.folder', function (statusCode, resp) {
                                 DataUtils.createFolder("/" + window.localStorage.getItem('user') + fileb['getcurrfolder']() + folder_name + '.folder', function (statusCode, resp) {
                                     if (!utils.isHttpSuccessCode(statusCode)) {
                                     if (!utils.isHttpSuccessCode(statusCode)) {
-                                        feedback.html(resp)
+                                        feedback.html(resp);
                                     } else {
                                     } else {
                                         feedback.html('created ' + folder_name);
                                         feedback.html('created ' + folder_name);
-                                        fnames.push(fileb['getcurrfolder']() + folder_name + "/")
+                                        fnames.push(fileb['getcurrfolder']() + folder_name + "/");
                                         fileb['refresh'](fnames);
                                         fileb['refresh'](fnames);
                                     }
                                     }
                                 });
                                 });
@@ -219,7 +219,7 @@ class FileBrowser{
                     title,
                     title,
                     callback);
                     callback);
             });
             });
-    };
+    }
 
 
 
 
     /**
     /**
@@ -410,13 +410,13 @@ class FileBrowser{
                 return input.val();
                 return input.val();
             },
             },
             'clearselection': function () {
             'clearselection': function () {
-                clearSelection()
+                clearSelection();
             },
             },
             'refresh': function (fnames, the_folder) {
             'refresh': function (fnames, the_folder) {
                 setCurrentFileBrowserFolder(the_folder || currfolder, fnames);
                 setCurrentFileBrowserFolder(the_folder || currfolder, fnames);
             }
             }
         };
         };
-    };
+    }
 
 
 
 
 }
 }

+ 4 - 4
client/geometry_utils.js

@@ -107,7 +107,7 @@ GeometryUtils = function(){
 	 */
 	 */
 	this.previewSelectionTransformation = function(op,dir) {
 	this.previewSelectionTransformation = function(op,dir) {
         if (transformationPreviewOverlay == undefined)
         if (transformationPreviewOverlay == undefined)
-            return
+            return;
 		var bbox  = __selection['bbox'],
 		var bbox  = __selection['bbox'],
 			 scale = (dir > 0 ? 1.05 : 0.95),
 			 scale = (dir > 0 ? 1.05 : 0.95),
 			 angle = (dir > 0 ? 3 : -3);
 			 angle = (dir > 0 ? 3 : -3);
@@ -126,7 +126,7 @@ GeometryUtils = function(){
 	 */
 	 */
 	this.previewSelectionTranslation = function(x,y) {
 	this.previewSelectionTranslation = function(x,y) {
         if (transformationPreviewOverlay == undefined)
         if (transformationPreviewOverlay == undefined)
-            return
+            return;
 		var _x = parseInt(transformationPreviewOverlay.node.getAttribute('_x')),
 		var _x = parseInt(transformationPreviewOverlay.node.getAttribute('_x')),
 			 _y = parseInt(transformationPreviewOverlay.node.getAttribute('_y'));
 			 _y = parseInt(transformationPreviewOverlay.node.getAttribute('_y'));
 		transformationPreviewOverlay.translate(x-_x,y-_y);
 		transformationPreviewOverlay.translate(x-_x,y-_y);
@@ -276,7 +276,7 @@ GeometryUtils = function(){
                                                          true,
                                                          true,
                                                          false,
                                                          false,
                                                          requests)
                                                          requests)
-                                         )
+                                         );
             requests = requests.concat(to_concat);
             requests = requests.concat(to_concat);
         }
         }
 	
 	
@@ -440,7 +440,7 @@ GeometryUtils = function(){
 				 latter... the results of this form the emitted batchEdit */
 				 latter... the results of this form the emitted batchEdit */
 	this.transformSelection = function(callingContext,insertInfo) {
 	this.transformSelection = function(callingContext,insertInfo) {
         if (transformationPreviewOverlay == undefined)
         if (transformationPreviewOverlay == undefined)
-            return
+            return;
 		var T = transformationPreviewOverlay.node.getAttribute('transform');
 		var T = transformationPreviewOverlay.node.getAttribute('transform');
 		if( T == null || T == 'matrix(1,0,0,1,0,0)' )
 		if( T == null || T == 'matrix(1,0,0,1,0,0)' )
 		{
 		{

+ 4 - 4
client/gui_utils.js

@@ -174,7 +174,7 @@ GUIUtils = function(){
 			var vals 	 = type.match(/^ENUM\((.*)\)$/)[1],
 			var vals 	 = type.match(/^ENUM\((.*)\)$/)[1],
 				 input 	 = GUIUtils.getSelector(vals.split(','),false,[value]),
 				 input 	 = GUIUtils.getSelector(vals.split(','),false,[value]),
 				 getinput = 
 				 getinput = 
-					 function(_){return HttpUtils.getSelectorSelection(_)[0]};
+					 function(_){return HttpUtils.getSelectorSelection(_)[0];};
 		}
 		}
 	
 	
 		else if( type.match(/^boolean$/) )
 		else if( type.match(/^boolean$/) )
@@ -187,9 +187,9 @@ GUIUtils = function(){
 		else if( type.match(/^\$/) )
 		else if( type.match(/^\$/) )
 			return GUIUtils.getInputField(__specialTypes[type],value);
 			return GUIUtils.getInputField(__specialTypes[type],value);
 	
 	
-		else if (matches = type.match("^file<(.*)>")) {
+		else if ((matches = type.match("^file<(.*)>"))) {
 			var input 	 = GUIUtils.getFileInput(value,matches[1],"code_style string_input",1),
 			var input 	 = GUIUtils.getFileInput(value,matches[1],"code_style string_input",1),
-				 getinput = function(_){return _.val();}
+				 getinput = function(_){return _.val();};
         }
         }
 	
 	
 		else
 		else
@@ -273,7 +273,7 @@ GUIUtils = function(){
         });
         });
         string_input.extra_el = extra_el;
         string_input.extra_el = extra_el;
         return string_input;
         return string_input;
-    }
+    };
 	
 	
 	/**
 	/**
 	 * Constructs a <textarea> element. In this element, Alt + Right Arrow
 	 * Constructs a <textarea> element. In this element, Alt + Right Arrow

+ 1 - 1
client/input_bar_utils.js

@@ -32,7 +32,7 @@ InputBarUtils = function(){
 			}
 			}
 			
 			
 		}
 		}
-	}
+	};
 	
 	
 	return this;
 	return this;
 }();
 }();

+ 1 - 1
client/layout.js

@@ -97,7 +97,7 @@ Layout = function(){
             var s = edgeSource[assoc];
             var s = edgeSource[assoc];
             var t = edgeTarget[assoc];
             var t = edgeTarget[assoc];
 
 
-            links.push({source: s, target: t})
+            links.push({source: s, target: t});
         }
         }
 
 
 
 

+ 6 - 6
client/mmm_utils.js

@@ -180,7 +180,7 @@ function __createEdge(segments,style,edgeId,linkuri)
     }
     }
     function getOrderNr(id,visited) {
     function getOrderNr(id,visited) {
         var icon = __icons[id];
         var icon = __icons[id];
-        if (visited.indexOf(icon) > 0) return
+        if (visited.indexOf(icon) > 0) return;
         if (icon['ordernr']) return;
         if (icon['ordernr']) return;
         visited.push(icon);
         visited.push(icon);
         if (__isConnectionType(id)) {
         if (__isConnectionType(id)) {
@@ -188,10 +188,10 @@ function __createEdge(segments,style,edgeId,linkuri)
             icon['ordernr'] = 9999;
             icon['ordernr'] = 9999;
         } else if (icon['edgesIn'].length > 0) {
         } else if (icon['edgesIn'].length > 0) {
             for (var edgeId in icon['edgesIn']) {
             for (var edgeId in icon['edgesIn']) {
-                var associationid = __edges[icon['edgesIn'][edgeId]]['start']
+                var associationid = __edges[icon['edgesIn'][edgeId]]['start'];
                 if (__isContainmentConnectionType(associationid)) {
                 if (__isContainmentConnectionType(associationid)) {
                     getOrderNr(__edges[__icons[associationid]['edgesIn'][0]]['start'], visited);
                     getOrderNr(__edges[__icons[associationid]['edgesIn'][0]]['start'], visited);
-                    icon['ordernr'] = __icons[__edges[__icons[associationid]['edgesIn'][0]]['start']]['ordernr'] + 1
+                    icon['ordernr'] = __icons[__edges[__icons[associationid]['edgesIn'][0]]['start']]['ordernr'] + 1;
                 }
                 }
             }
             }
             if (!icon['ordernr']) icon['ordernr'] = 0;
             if (!icon['ordernr']) icon['ordernr'] = 0;
@@ -203,7 +203,7 @@ function __createEdge(segments,style,edgeId,linkuri)
         getOrderNr(id, []);
         getOrderNr(id, []);
     }
     }
     
     
-    Object.keys(__icons).concat().sort(function(a, b) {return __icons[a]['ordernr'] - __icons[b]['ordernr']}).forEach(function(el) {
+    Object.keys(__icons).concat().sort(function(a, b) {return __icons[a]['ordernr'] - __icons[b]['ordernr'];}).forEach(function(el) {
         __icons[el]['icon'].toFront();
         __icons[el]['icon'].toFront();
     });
     });
     Object.keys(__edges).forEach(function(el) {
     Object.keys(__edges).forEach(function(el) {
@@ -418,7 +418,7 @@ function __getIconsInContainer(container)
 			return [];
 			return [];
         
         
         if( explored.indexOf(container) > -1 ) {
         if( explored.indexOf(container) > -1 ) {
-            return []
+            return [];
         }
         }
 	
 	
 		var contents = 
 		var contents = 
@@ -436,7 +436,7 @@ function __getIconsInContainer(container)
 								}).concat([linkuri]);
 								}).concat([linkuri]);
 				}));
 				}));
                 
                 
-        explored.push(container)
+        explored.push(container);
 
 
         for (var ct_idx in contents) {
         for (var ct_idx in contents) {
             var to_concat = utils.flatten(getExplicitContents(contents[ct_idx], explored));
             var to_concat = utils.flatten(getExplicitContents(contents[ct_idx], explored));

+ 4 - 4
client/query_response.js

@@ -25,7 +25,7 @@ function __clearObsoleteChangelogs(pendingChangelogs,sn)
 function __forceNextASWSequenceNumber(sn)
 function __forceNextASWSequenceNumber(sn)
 {
 {
 	__nextASWSequenceNumber = sn;
 	__nextASWSequenceNumber = sn;
-	__clearObsoleteChangelogs(__pendingASWChangelogs,sn)
+	__clearObsoleteChangelogs(__pendingASWChangelogs,sn);
 }
 }
 
 
 
 
@@ -33,7 +33,7 @@ function __forceNextASWSequenceNumber(sn)
 function __forceNextCSWSequenceNumber(sn)
 function __forceNextCSWSequenceNumber(sn)
 {
 {
 	__nextCSWSequenceNumber = sn;
 	__nextCSWSequenceNumber = sn;
-	__clearObsoleteChangelogs(__pendingCSWChangelogs,sn)
+	__clearObsoleteChangelogs(__pendingCSWChangelogs,sn);
 }
 }
 
 
 //Todo: Shred this into smaller functions
 //Todo: Shred this into smaller functions
@@ -48,7 +48,7 @@ function __handleChangelog(changelog,seqNum,hitchhiker)
 {
 {
 	console.debug(' ++ ('+seqNum+') ',changelog);
 	console.debug(' ++ ('+seqNum+') ',changelog);
 
 
-	var isCSWChangelog 	 = seqNum.match(/csworker/)
+	var isCSWChangelog 	 = seqNum.match(/csworker/);
 		 nextSeqNum 	 	 = 
 		 nextSeqNum 	 	 = 
 			 (isCSWChangelog ? __nextCSWSequenceNumber : __nextASWSequenceNumber),
 			 (isCSWChangelog ? __nextCSWSequenceNumber : __nextASWSequenceNumber),
 		 pendingChangelogs = 
 		 pendingChangelogs = 
@@ -306,7 +306,7 @@ function __handleChangelog(changelog,seqNum,hitchhiker)
 						function(selection) {
 						function(selection) {
 							__select(selection);
 							__select(selection);
 						}, [__selection['items']], 5
 						}, [__selection['items']], 5
-					)
+					);
 			}
 			}
 
 
 			/* react to loading of an IconDefinition (CS metamodel)
 			/* react to loading of an IconDefinition (CS metamodel)

+ 12 - 6
client/selection_utils.js

@@ -153,7 +153,9 @@ function __flash(uri,color,timeout)
 	function turnOff()
 	function turnOff()
 	{
 	{
 		try			{__icons[uri]['icon'].unhighlight();} 
 		try			{__icons[uri]['icon'].unhighlight();} 
-		catch(err)	{}
+		catch(err)	{
+			console.log(err);
+		}
 	}
 	}
 	window.setTimeout(turnOff,timeout || 500);
 	window.setTimeout(turnOff,timeout || 500);
 }
 }
@@ -199,13 +201,17 @@ function __highlight(uri,followCrossFormalismLinks,timeout,color)
 				 function() 
 				 function() 
 				 {
 				 {
 					 try			{__icons[uri]['icon'].unhighlight();}
 					 try			{__icons[uri]['icon'].unhighlight();}
-					 catch(err)	{}
+					 catch(err)	{
+					 	console.log(err);
+					 }
 
 
 					 if( followCrossFormalismLinks != undefined )
 					 if( followCrossFormalismLinks != undefined )
 					 	neighbors.nodes.forEach( 
 					 	neighbors.nodes.forEach( 
 							function(n) {
 							function(n) {
 	  							try			{__icons[n]['icon'].unhighlight();}
 	  							try			{__icons[n]['icon'].unhighlight();}
-								catch(err)	{}
+								catch(err)	{
+	  								console.log(err);
+								}
 							} );
 							} );
 					 if( timeout != undefined )
 					 if( timeout != undefined )
 						 window.clearTimeout(tid);
 						 window.clearTimeout(tid);
@@ -216,7 +222,7 @@ function __highlight(uri,followCrossFormalismLinks,timeout,color)
 
 
 function isHighlighted(uri)
 function isHighlighted(uri)
 {
 {
-	return __highlighted.length > 0 && __highlighted.filter(function(hl) {return uri == hl['uri']}).length == 1;
+	return __highlighted.length > 0 && __highlighted.filter(function(hl) {return uri == hl['uri'];}).length == 1;
 }
 }
 
 
 
 
@@ -224,11 +230,11 @@ function __unhighlight(uri)
 {
 {
 	if( __highlighted.length > 0 )
 	if( __highlighted.length > 0 )
 	{
 	{
-		__highlighted.filter(function(hl) {return !uri || uri == hl['uri']}).forEach(function(hl) {hl.turnOff()})
+		__highlighted.filter(function(hl) {return !uri || uri == hl['uri'];}).forEach(function(hl) {hl.turnOff();});
 		if (!uri) {
 		if (!uri) {
 			__highlighted = [];
 			__highlighted = [];
 		} else {
 		} else {
-			__highlighted = __highlighted.filter(function(hl) {return uri != hl['uri']})
+			__highlighted = __highlighted.filter(function(hl) {return uri != hl['uri'];});
 		}
 		}
 		
 		
 	}
 	}

+ 4 - 2
client/window_event.js

@@ -25,8 +25,10 @@ WindowEventHelper = function(){
 				
 				
 				// Are we actually in the table?
 				// Are we actually in the table?
 				if( table != null && table.rows != undefined){
 				if( table != null && table.rows != undefined){
-					for(var i=0, row; row = table.rows[i]; i++){
-						
+					for(var i=0; i < table.length; i++){
+
+						let row = table.rows[i];
+
 						// Is the current row the parent row of the active element?
 						// Is the current row the parent row of the active element?
 						if( row == activeElement.parentNode.parentNode ){
 						if( row == activeElement.parentNode.parentNode ){
 							if( currentKeys[ KEY_SHIFT ] == 1){
 							if( currentKeys[ KEY_SHIFT ] == 1){

+ 2 - 2
client/window_management.js

@@ -596,7 +596,7 @@ WindowManagement = function(){
 				 c.__trafo = trafo;
 				 c.__trafo = trafo;
 				 c.__msg = msg;
 				 c.__msg = msg;
 				if (trafo == undefined){
 				if (trafo == undefined){
-					trafo = option
+					trafo = option;
 				}
 				}
 				if( tbname ){
 				if( tbname ){
 						toolbars = tbname.split(",");
 						toolbars = tbname.split(",");
@@ -735,7 +735,7 @@ WindowManagement = function(){
 		if(ev!=null && ev.keyCode==13) {
 		if(ev!=null && ev.keyCode==13) {
 			$('#div_dialog_' + (__dialog_stack.length-1).toString() + " .okbutton").click();
 			$('#div_dialog_' + (__dialog_stack.length-1).toString() + " .okbutton").click();
 		}
 		}
-        __dialog_stack.pop()
+        __dialog_stack.pop();
 		var dialog = $('#div_dialog_'+__dialog_stack.length);
 		var dialog = $('#div_dialog_'+__dialog_stack.length);
         dialog.remove();
         dialog.remove();
 		if (!__dialog_stack.length) {
 		if (!__dialog_stack.length) {

+ 49 - 18
csworker.js

@@ -177,7 +177,38 @@
 			SYSOUT message announcing the launching of the rule... a sensible and 
 			SYSOUT message announcing the launching of the rule... a sensible and 
 		  	nice solution would be not to remember such changelogs in
 		  	nice solution would be not to remember such changelogs in
 			__handledSeqNums */
 			__handledSeqNums */
-{
+let {
+    __id_to_uri,
+    __ids2uris, __nextSequenceNumber,
+    __postBadReqErrorMsg,
+    __postForbiddenErrorMsg,
+    __wtype,
+    GET__current_state
+} = require("./__worker");
+
+const {
+	__batchCheckpoint,
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("./__worker");
+
+const _do = require("./___do");
+const _utils = require('./utils');
+const _mmmk = require("./mmmk");
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _path = require('path');
+const _fspp	= _do.convert(require('./___fs++'), ['mkdirs']);
+const _svg = require('./libsvg').SVG;
+const _mt = require('./libmt');
+
+const _siocl = require('socket.io-client');
+
+module.exports = {
 	'__REGEN_ICON_RETRY_DELAY_MS':200,
 	'__REGEN_ICON_RETRY_DELAY_MS':200,
 	'__asmm2csmm':{},
 	'__asmm2csmm':{},
 	'__asid2csid':{},
 	'__asid2csid':{},
@@ -212,8 +243,8 @@
 	'__applyASWChanges' :
 	'__applyASWChanges' :
 		function(changelog,aswSequenceNumber,hitchhiker)
 		function(changelog,aswSequenceNumber,hitchhiker)
 		{
 		{
-			console.error('w#'+__wid+' ++ ('+aswSequenceNumber+') '+
-							_utils.jsons(changelog));
+			//console.error('w#'+__wid+' ++ ('+aswSequenceNumber+') '+
+			//				_utils.jsons(changelog));
 
 
 
 
 			if( _utils.sn2int(aswSequenceNumber) > 
 			if( _utils.sn2int(aswSequenceNumber) > 
@@ -538,8 +569,8 @@
 				{
 				{
 					var cschangelog = _utils.flatten(cschangelogs);
 					var cschangelog = _utils.flatten(cschangelogs);
 
 
-					console.error('w#'+__wid+' -- ('+aswSequenceNumber+') '+
-						_utils.jsons(cschangelog));
+					//console.error('w#'+__wid+' -- ('+aswSequenceNumber+') '+
+					//	_utils.jsons(cschangelog));
 
 
 					__postMessage(
 					__postMessage(
 							{'statusCode':200,
 							{'statusCode':200,
@@ -647,7 +678,7 @@
 												{
 												{
 													return self.__sn2int(pc['sequence#']) > 
 													return self.__sn2int(pc['sequence#']) > 
 																self.__sn2int(
 																self.__sn2int(
-																	self.__nextASWSequenceNumber)
+																	self.__nextASWSequenceNumber);
 												});
 												});
 										callback();
 										callback();
 										self.__applyPendingASWChanges();
 										self.__applyPendingASWChanges();
@@ -713,7 +744,7 @@
 					 pp  		= _svg.fns.getPointOnPathAtRatio(path,ldi.xratio);
 					 pp  		= _svg.fns.getPointOnPathAtRatio(path,ldi.xratio);
                      
                      
                 if (pp == undefined)
                 if (pp == undefined)
-                    continue
+                    continue;
                 
                 
 				var yoffset	= new _svg.types.Point(0,ldi.yoffset).rotate(pp.O),
 				var yoffset	= new _svg.types.Point(0,ldi.yoffset).rotate(pp.O),
 					endAt	= (ldi.xratio >= 1 ? 
 					endAt	= (ldi.xratio >= 1 ? 
@@ -876,12 +907,12 @@
 			//			new_node['$linktype'] = this.metamodels[metamodel]['connectorTypes'][type];	
 			//			new_node['$linktype'] = this.metamodels[metamodel]['connectorTypes'][type];	
 
 
 			return [];
 			return [];
-			return [{'op':'SYSOUT',
-			  		  'text':'WARNING :: '+
-						  		'a proper layout constraint solver has yet to be '+
-						  		'implemented... inter-VisualObject relationships are '+
-								'ignored and containers do not resize to fit their '+
-								'contents'}];
+			// return [{'op':'SYSOUT',
+			//   		  'text':'WARNING :: '+
+			// 			  		'a proper layout constraint solver has yet to be '+
+			// 			  		'implemented... inter-VisualObject relationships are '+
+			// 					'ignored and containers do not resize to fit their '+
+			// 					'contents'}];
 		},
 		},
 
 
 
 
@@ -1834,8 +1865,8 @@
                             function(result) {
                             function(result) {
                                 return __wHttpReq('PUT',
                                 return __wHttpReq('PUT',
                                            uri+'?wid='+aswid,
                                            uri+'?wid='+aswid,
-                                           ({'csm':_mmmk.read(), 'asmm': asmm}))
-                            }]
+                                           ({'csm':_mmmk.read(), 'asmm': asmm}));
+                            }];
                  } else {
                  } else {
                      actions = [__wHttpReq('PUT',
                      actions = [__wHttpReq('PUT',
                                            uri+'?wid='+aswid,
                                            uri+'?wid='+aswid,
@@ -1876,9 +1907,9 @@
 					{
 					{
 						var sn = asdata['sequence#'];
 						var sn = asdata['sequence#'];
 						if( self.__nextASWSequenceNumber - 1 > sn )
 						if( self.__nextASWSequenceNumber - 1 > sn )
-							self['PUT *.model'](resp,urin);
+							self['PUT *.model'](resp,uri);
 						else if( self.__nextASWSequenceNumber - 1 < sn )
 						else if( self.__nextASWSequenceNumber - 1 < sn )
-							setTimeout(self['PUT *.model'], 200, resp, urin);
+							setTimeout(self['PUT *.model'], 200, resp, uri);
 						else
 						else
 						{
 						{
 							if( (res = _mmmk.read())['$err'] )
 							if( (res = _mmmk.read())['$err'] )
@@ -2247,4 +2278,4 @@
 		{
 		{
 			return parseInt(sn.match(/.*#(\d*)/)[1]);
 			return parseInt(sn.match(/.*#(\d*)/)[1]);
 		}
 		}
-}
+};

+ 4 - 4
httpwsd.js

@@ -434,7 +434,7 @@ var httpserver = _http.createServer(
                                          _fs.unlink(newname);
                                          _fs.unlink(newname);
                                      }
                                      }
                                 }
                                 }
-                            _fspp.mv(userdir+"/"+folder+fname,userdir+data,onmove)
+                            _fspp.mv(userdir+"/"+folder+fname,userdir+data,onmove);
                         } else {
                         } else {
                             // rename
                             // rename
                             var matches  = url.pathname.match(/^\/(.*?)\/(.*\/)?(.*)\.(file|folder)$/),
                             var matches  = url.pathname.match(/^\/(.*?)\/(.*\/)?(.*)\.(file|folder)$/),
@@ -450,10 +450,10 @@ var httpserver = _http.createServer(
                                          else
                                          else
                                              __respond(resp,200);
                                              __respond(resp,200);
                                      };
                                      };
-                            _fs.rename(userdir+folder+fname,userdir+folder+data,onrename)
+                            _fs.rename(userdir+folder+fname,userdir+folder+data,onrename);
                         }
                         }
                     }
                     }
-                )
+                );
 				
 				
 			}
 			}
             
             
@@ -723,7 +723,7 @@ wsserver.sockets.on('connection',
 		  	has no more registered sockets, terminate it */
 		  	has no more registered sockets, terminate it */
 		function unregister(wid)
 		function unregister(wid)
 		{
 		{
-			var i = workerIds2socketIds[wid].indexOf(socket.id)
+			var i = workerIds2socketIds[wid].indexOf(socket.id);
 			if( i == -1 )
 			if( i == -1 )
 				__send(socket,403,'already unregistered from worker');
 				__send(socket,403,'already unregistered from worker');
 			else
 			else

+ 18 - 14
libmt.js

@@ -1,9 +1,13 @@
+
 /* This file is part of AToMPM - A Tool for Multi-Paradigm Modelling
 /* This file is part of AToMPM - A Tool for Multi-Paradigm Modelling
 *  Copyright 2011 by the AToMPM team and licensed under the LGPL
 *  Copyright 2011 by the AToMPM team and licensed under the LGPL
 *  See COPYING.lesser and README.md in the root of this project for full details
 *  See COPYING.lesser and README.md in the root of this project for full details
 */
 */
 
 
-{
+const _utils = require('./utils');
+
+/* eslint-disable no-inner-declarations */
+module.exports = {
 	/* apply transformation T to specified model 
 	/* apply transformation T to specified model 
 
 
 		TBI:: this method only supports transforming class diagrams to ER diagrams
 		TBI:: this method only supports transforming class diagrams to ER diagrams
@@ -51,8 +55,8 @@
                                         new_model.nodes[parent_id]['attributes']['value'].filter(
                                         new_model.nodes[parent_id]['attributes']['value'].filter(
                                             function(attr) {
                                             function(attr) {
                                                 return !new_model.nodes[child_id]['attributes']['value'].find(
                                                 return !new_model.nodes[child_id]['attributes']['value'].find(
-                                                    function(el) {return el['name'] == attr['name']}
-                                                )
+                                                    function(el) {return el['name'] == attr['name'];}
+                                                );
                                             }
                                             }
                                         )
                                         )
                                     );
                                     );
@@ -61,8 +65,8 @@
                                         new_model.nodes[parent_id]['constraints']['value'].filter(
                                         new_model.nodes[parent_id]['constraints']['value'].filter(
                                             function(constr) {
                                             function(constr) {
                                                 return !new_model.nodes[child_id]['constraints']['value'].find(
                                                 return !new_model.nodes[child_id]['constraints']['value'].find(
-                                                    function(el) {return el['name'] == constr['name']}
-                                                )
+                                                    function(el) {return el['name'] == constr['name'];}
+                                                );
                                             }
                                             }
                                         )
                                         )
                                     );
                                     );
@@ -71,8 +75,8 @@
                                         new_model.nodes[parent_id]['actions']['value'].filter(
                                         new_model.nodes[parent_id]['actions']['value'].filter(
                                             function(act) {
                                             function(act) {
                                                 return !new_model.nodes[child_id]['actions']['value'].find(
                                                 return !new_model.nodes[child_id]['actions']['value'].find(
-                                                    function(el) {return el['name'] == act['name']}
-                                                )
+                                                    function(el) {return el['name'] == act['name'];}
+                                                );
                                             }
                                             }
                                         )
                                         )
                                     );
                                     );
@@ -81,8 +85,8 @@
                                         new_model.nodes[parent_id]['cardinalities']['value'].filter(
                                         new_model.nodes[parent_id]['cardinalities']['value'].filter(
                                             function(card) {
                                             function(card) {
                                                 return !new_model.nodes[child_id]['cardinalities']['value'].find(
                                                 return !new_model.nodes[child_id]['cardinalities']['value'].find(
-                                                    function(el) {return el['dir'] == card['dir'] && el['type'] == card['type']}
-                                                )
+                                                    function(el) {return el['dir'] == card['dir'] && el['type'] == card['type'];}
+                                                );
                                             }
                                             }
                                         )
                                         )
                                     );
                                     );
@@ -182,7 +186,7 @@
 							new_model.nodes[id]['constraints']['value'].push(
 							new_model.nodes[id]['constraints']['value'].push(
 									{'name':'noAbstractInstances',
 									{'name':'noAbstractInstances',
 									 'event':'pre-create',
 									 'event':'pre-create',
-									 'code':'false'})
+									 'code':'false'});
 						}
 						}
 					}
 					}
 					else if( new_model.nodes[id]['$type'] == SCD+'/Association' )
 					else if( new_model.nodes[id]['$type'] == SCD+'/Association' )
@@ -197,7 +201,7 @@
 							a) remove all edges pertaining to it
 							a) remove all edges pertaining to it
 							b) remove it */
 							b) remove it */
 						new_model.edges = new_model.edges.filter(
 						new_model.edges = new_model.edges.filter(
-								function(edge)	{return edge['src'] != id && edge['dest'] != id});
+								function(edge)	{return edge['src'] != id && edge['dest'] != id;});
 						delete new_model.nodes[id];
 						delete new_model.nodes[id];
 					}
 					}
 				}
 				}
@@ -211,11 +215,11 @@
 					var type = new_model.nodes[id]['name']['value'];
 					var type = new_model.nodes[id]['name']['value'];
 					if( types2parentTypes[type] == undefined ) 
 					if( types2parentTypes[type] == undefined ) 
 					{
 					{
-						types2parentTypes[type] = []
+						types2parentTypes[type] = [];
 						ids2ancestors[id].forEach(
 						ids2ancestors[id].forEach(
 								function(a)
 								function(a)
 								{
 								{
-									types2parentTypes[type].push(new_model.nodes[a]['name']['value'])
+									types2parentTypes[type].push(new_model.nodes[a]['name']['value']);
 								});
 								});
 					}
 					}
 				}
 				}
@@ -471,5 +475,5 @@
 
 
 			return {'asmm':asmm,'csmms':csmms};
 			return {'asmm':asmm,'csmms':csmms};
 		}
 		}
-}
+};
 
 

+ 8 - 8
libsvg.js

@@ -169,7 +169,7 @@ SVG.types.ATransformable.prototype.transform =
 	function(tstr)
 	function(tstr)
 	{
 	{
 		return this.__transform(SVG.fns.__getTransformationMatrix(tstr));
 		return this.__transform(SVG.fns.__getTransformationMatrix(tstr));
-	}
+	};
 
 
 /* apply the given transformation matrix to this element */
 /* apply the given transformation matrix to this element */
 SVG.types.ATransformable.prototype.__transform = 
 SVG.types.ATransformable.prototype.__transform = 
@@ -425,13 +425,13 @@ _utils.extend(SVG.types.LinearPath, SVG.types.ATransformable);
 
 
 
 
 /*----------------------------------------------------------------------------*/
 /*----------------------------------------------------------------------------*/
-SVG.types.CubicPath = function() {}	//TBC
-SVG.types.Circle		= function() {}	//TBC
-SVG.types.Ellipse	= function() {}	//TBC
-SVG.types.Rectangle	= function() {}	//TBC
-SVG.types.Polygon	= function() {}	//TBC
-SVG.types.Star		= function() {}	//TBC
-SVG.types.Image		= function() {}	//TBC
+SVG.types.CubicPath = function() {};	//TBC
+SVG.types.Circle		= function() {};	//TBC
+SVG.types.Ellipse	= function() {};	//TBC
+SVG.types.Rectangle	= function() {};	//TBC
+SVG.types.Polygon	= function() {};	//TBC
+SVG.types.Star		= function() {};	//TBC
+SVG.types.Image		= function() {};	//TBC
 
 
 
 
 
 

+ 14 - 8
mmmk.js

@@ -10,7 +10,13 @@
 		atom3 supported 'save' events as a hack to enable forcing mm validation...
 		atom3 supported 'save' events as a hack to enable forcing mm validation...
 		in atompm, such validation is carried out by _mmmk.validateModel (which
 		in atompm, such validation is carried out by _mmmk.validateModel (which
 		clients can 'call') and thus, we do no support 'save' events... */
 		clients can 'call') and thus, we do no support 'save' events... */
-{
+
+const _utils = require('./utils');
+const _util = require("util");
+const _mt = require("./libmt");
+const _styleinfo = require('./styleinfo');
+
+module.exports = {
 	/********************************* GLOBALS *********************************/
 	/********************************* GLOBALS *********************************/
 	'metamodels':{},
 	'metamodels':{},
 	'model':{'nodes':{},'edges':[],'metamodels':[]},
 	'model':{'nodes':{},'edges':[],'metamodels':[]},
@@ -867,7 +873,7 @@
 				 model.edges == undefined ||
 				 model.edges == undefined ||
 				 model.metamodels == undefined ||
 				 model.metamodels == undefined ||
 				 model.metamodels.length == 0 )
 				 model.metamodels.length == 0 )
-				return {'$err':'provided model is either empty or not an atompm model'}
+				return {'$err':'provided model is either empty or not an atompm model'};
 
 
 			for( var i in model.edges )
 			for( var i in model.edges )
 			{
 			{
@@ -904,7 +910,7 @@
                 }
                 }
 			}
 			}
 
 
-            var checked_for_loops = []
+            var checked_for_loops = [];
 			for( var id in model.nodes )
 			for( var id in model.nodes )
 			{
 			{
 				var metamodel = this.__getMetamodel(model.nodes[id]['$type']),
 				var metamodel = this.__getMetamodel(model.nodes[id]['$type']),
@@ -925,6 +931,7 @@
                 if (checked_for_loops.indexOf(id) < 0 && !(type in this.metamodels[metamodel]['connectorTypes'])) {
                 if (checked_for_loops.indexOf(id) < 0 && !(type in this.metamodels[metamodel]['connectorTypes'])) {
                     var visited = [],
                     var visited = [],
                         tv = [id];
                         tv = [id];
+// eslint-disable-next-line no-inner-declarations
                     function dfs(to_visit) {
                     function dfs(to_visit) {
                         var curr = to_visit.pop();
                         var curr = to_visit.pop();
                         if( curr == undefined )
                         if( curr == undefined )
@@ -1004,7 +1011,6 @@
 					var model =	_utils.jsonp(this.read());
 					var model =	_utils.jsonp(this.read());
 					nodes = {};
 					nodes = {};
 					for (var id in model.nodes) {
 					for (var id in model.nodes) {
-						console
 						if (model.nodes[id]['$type'].slice(0, CS.length) == CS) {
 						if (model.nodes[id]['$type'].slice(0, CS.length) == CS) {
 							nodes[id] = model.nodes[id];
 							nodes[id] = model.nodes[id];
 						}
 						}
@@ -1409,7 +1415,7 @@
 										if( mm.legalConnections[type] == undefined )
 										if( mm.legalConnections[type] == undefined )
 											mm.legalConnections[type] = {};
 											mm.legalConnections[type] = {};
 										if( mm.legalConnections[type][nntype] == undefined )
 										if( mm.legalConnections[type][nntype] == undefined )
-											mm.legalConnections[type][nntype] = []
+											mm.legalConnections[type][nntype] = [];
 										mm.legalConnections[type][nntype].push(ntype);
 										mm.legalConnections[type][nntype].push(ntype);
 									});
 									});
 								});
 								});
@@ -1525,8 +1531,8 @@
 			else if( log == 'UNDOREDO' )
 			else if( log == 'UNDOREDO' )
 				this.undoredoJournal.push(step);
 				this.undoredoJournal.push(step);
 
 
-			else if( log == 'DONTLOG' )
-				;
+			//else if( log == 'DONTLOG' )
+			//	;
 		},
 		},
 
 
 
 
@@ -1915,4 +1921,4 @@
 			{
 			{
 				return fulltype.match(/.*\/(.*)/)[1];
 				return fulltype.match(/.*\/(.*)/)[1];
 			}
 			}
-}
+};

+ 12 - 2
plugins/chat.js

@@ -1,6 +1,16 @@
 /* Chat plugin for collaboration, need to list available users.
 /* Chat plugin for collaboration, need to list available users.
 , and notify when the message comes in by flashing chat "Open" link*/
 , and notify when the message comes in by flashing chat "Open" link*/
-{
+const {
+    __errorContinuable,
+    __httpReq,
+    __wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+module.exports = {
 	'interfaces'	: [{'method':'POST', 'url=':'/chat'}],
 	'interfaces'	: [{'method':'POST', 'url=':'/chat'}],
 
 
 
 
@@ -40,4 +50,4 @@
 				 'respIndex':resp});
 				 'respIndex':resp});
 			
 			
 		}
 		}
-}
+};

+ 20 - 4
plugins/codegenerator.js

@@ -1,4 +1,20 @@
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _mmmk = require("../mmmk");
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
 	'interfaces'	: [{'method':'POST', 'url=':'/generatecode'}],
 	'interfaces'	: [{'method':'POST', 'url=':'/generatecode'}],
 
 
 	'csworker'		: 
 	'csworker'		: 
@@ -56,7 +72,7 @@
 								if (possibleRoots.size > 1) {
 								if (possibleRoots.size > 1) {
 									 __postInternalErrorMsg(resp,"There can only be 1 root, found " + possibleRoots.size);
 									 __postInternalErrorMsg(resp,"There can only be 1 root, found " + possibleRoots.size);
 								} else {
 								} else {
-									function generateFolder(key, prefix) {
+									let generateFolder = function(key, prefix) {
 										var dir = prefix + as.nodes[key]['name']['value'] + '/';
 										var dir = prefix + as.nodes[key]['name']['value'] + '/';
 										writeActions = _fspp.mkdirs(dir);
 										writeActions = _fspp.mkdirs(dir);
 										_do.chain(writeActions)(
 										_do.chain(writeActions)(
@@ -70,7 +86,7 @@
 										for (var subFolder in subFolders[key]) {
 										for (var subFolder in subFolders[key]) {
 											generateFolder(subFolders[key][subFolder], dir);
 											generateFolder(subFolders[key][subFolder], dir);
 										}
 										}
-									}
+									};
 									generateFolder(possibleRoots[0], './generated_code/' + reqData['root'] + '/');
 									generateFolder(possibleRoots[0], './generated_code/' + reqData['root'] + '/');
 									__postMessage({'statusCode':200,
 									__postMessage({'statusCode':200,
 												   'respIndex':resp});
 												   'respIndex':resp});
@@ -93,4 +109,4 @@
 				{'statusCode':200,
 				{'statusCode':200,
 					 'respIndex':resp});	
 					 'respIndex':resp});	
 		}
 		}
-}
+};

+ 21 - 5
plugins/exportM2Ecore.js

@@ -1,4 +1,20 @@
-{
+const {
+    __errorContinuable,
+    __httpReq,
+    __wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _mmmk = require("../mmmk");
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
     'interfaces'
     'interfaces'
 :
 :
     [{'method': 'POST', 'url=': '/exportM2Ecore'}],
     [{'method': 'POST', 'url=': '/exportM2Ecore'}],
@@ -270,8 +286,8 @@
                             for (var i = 0; i < listContained.length; i++) {
                             for (var i = 0; i < listContained.length; i++) {
                                 contained += space(deep + 2) + '<' + listContained[i].linkType;
                                 contained += space(deep + 2) + '<' + listContained[i].linkType;
                                 var attributes = '';
                                 var attributes = '';
-                                if (listContained[i].attributes != null) {
-                                }
+                                // if (listContained[i].attributes != null) {
+                                // }
                                 contained += writeAttributes(listContained[i], deep + 2);
                                 contained += writeAttributes(listContained[i], deep + 2);
                                 if (listContained[i].contain.length > 0)
                                 if (listContained[i].contain.length > 0)
                                     contained += writeContained(listContained[i].contain, deep + 2);
                                     contained += writeContained(listContained[i].contain, deep + 2);
@@ -385,7 +401,7 @@
             function (err) {
             function (err) {
                 __postInternalErrorMsg(resp, err);
                 __postInternalErrorMsg(resp, err);
             }
             }
-        )
+        );
     }
     }
 
 
 ,
 ,
@@ -399,4 +415,4 @@
                 'respIndex': resp
                 'respIndex': resp
             });
             });
     }
     }
-}
+};

+ 20 - 4
plugins/exportMM2Ecore.js

@@ -1,4 +1,20 @@
-{
+const {
+    __errorContinuable,
+    __httpReq,
+    __wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _mmmk = require("../mmmk");
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
     'interfaces'
     'interfaces'
 :
 :
     [{'method': 'POST', 'url=': '/exportMM2Ecore'}],
     [{'method': 'POST', 'url=': '/exportMM2Ecore'}],
@@ -58,7 +74,7 @@
                             'float': 'EFloat',
                             'float': 'EFloat',
                             'boolean': 'EBoolean',
                             'boolean': 'EBoolean',
                             'code': 'EString'
                             'code': 'EString'
-                        }
+                        };
 
 
 
 
                         /**
                         /**
@@ -602,7 +618,7 @@
             function (err) {
             function (err) {
                 __postInternalErrorMsg(resp, err);
                 __postInternalErrorMsg(resp, err);
             }
             }
-        )
+        );
     }
     }
 
 
 ,
 ,
@@ -616,4 +632,4 @@
                 'respIndex': resp
                 'respIndex': resp
             });
             });
     }
     }
-}
+};

+ 25 - 10
plugins/exportmmtomd.js

@@ -1,4 +1,19 @@
-{	
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
 	'interfaces': [{'method':'POST', 'url=':'/exportmmtomd'}],
 	'interfaces': [{'method':'POST', 'url=':'/exportmmtomd'}],
 	'csworker':
 	'csworker':
 		function(resp, method, uri, reqData, wcontext) {
 		function(resp, method, uri, reqData, wcontext) {
@@ -84,7 +99,7 @@
 								} else {
 								} else {
 									edges[as.edges[i].dest] = ([as.edges[i].src, as.edges[i + 1].dest]);
 									edges[as.edges[i].dest] = ([as.edges[i].src, as.edges[i + 1].dest]);
 								}
 								}
-							};
+							}
 							// Add superclass Link to all Edges (this is class is not present in AToMPM thus not contained in as.nodes)
 							// Add superclass Link to all Edges (this is class is not present in AToMPM thus not contained in as.nodes)
 							for (var key in as.nodes) {
 							for (var key in as.nodes) {
 								// console.log(key);
 								// console.log(key);
@@ -94,12 +109,12 @@
 								}
 								}
 							}
 							}
 							
 							
-							file_contents += 'Model ' + reqData['name'] + ' {\n'
+							file_contents += 'Model ' + reqData['name'] + ' {\n';
 							
 							
 							var sorted_nodes = [];
 							var sorted_nodes = [];
 							var sorted_edges = [];
 							var sorted_edges = [];
 							var nodes_no_superclasses = [];
 							var nodes_no_superclasses = [];
-							var c_to_superclass = {}
+							var c_to_superclass = {};
 							// copy superclasses dictionary
 							// copy superclasses dictionary
 							for (var key in superclasses_ids) {
 							for (var key in superclasses_ids) {
 								c_to_superclass[key] = superclasses_ids[key].slice(0);
 								c_to_superclass[key] = superclasses_ids[key].slice(0);
@@ -119,7 +134,7 @@
 							// get all nodes without any superclasses
 							// get all nodes without any superclasses
 							for (var key in as.nodes) {
 							for (var key in as.nodes) {
 								if (!(key in superclasses_ids)) {
 								if (!(key in superclasses_ids)) {
-									nodes_no_superclasses.push(key)
+									nodes_no_superclasses.push(key);
 								}
 								}
 							}
 							}
 							// topological sort
 							// topological sort
@@ -211,7 +226,7 @@
 									'list<double>': 'double[*]',
 									'list<double>': 'double[*]',
 									'list<real>': 'double[*]',
 									'list<real>': 'double[*]',
 									'code': 'String'
 									'code': 'String'
-									}
+									};
 									
 									
 									// DEPRECATED: No longer needed after adding the Link Node
 									// DEPRECATED: No longer needed after adding the Link Node
 									// if (key in edges) {
 									// if (key in edges) {
@@ -224,8 +239,8 @@
 										file_contents += node.attributes['value'][prop].name + ':' + (t in typemapping ? typemapping[t] : t) + (node.attributes['value'][prop]['default'] != '' ?  ' = ' + (t.search('list') >= 0 ? '[' : '') + node.attributes['value'][prop]['default'] + (t.search('list') >= 0 ? ']' : '') : '') + ';\n';
 										file_contents += node.attributes['value'][prop].name + ':' + (t in typemapping ? typemapping[t] : t) + (node.attributes['value'][prop]['default'] != '' ?  ' = ' + (t.search('list') >= 0 ? '[' : '') + node.attributes['value'][prop]['default'] + (t.search('list') >= 0 ? ']' : '') : '') + ';\n';
 									}
 									}
 									file_contents += '}\n';	
 									file_contents += '}\n';	
-								};
-							};
+								}
+							}
 							file_contents += '}\n';
 							file_contents += '}\n';
 							_fs.writeFileSync('./exported_to_md/' + reqData['name'] + '.mdepth', file_contents);
 							_fs.writeFileSync('./exported_to_md/' + reqData['name'] + '.mdepth', file_contents);
 							__postMessage({	'statusCode': 200,
 							__postMessage({	'statusCode': 200,
@@ -235,7 +250,7 @@
 					);					
 					);					
 				},
 				},
 				function(err) {__postInternalErrorMsg(resp, err);}
 				function(err) {__postInternalErrorMsg(resp, err);}
-			)
+			);
 		},
 		},
 	'asworker':
 	'asworker':
 		function(resp, method, uri, reqData, wcontext)
 		function(resp, method, uri, reqData, wcontext)
@@ -244,4 +259,4 @@
 				{'statusCode': 200,
 				{'statusCode': 200,
 					 'respIndex': resp});	
 					 'respIndex': resp});	
 		}
 		}
-}
+};

+ 25 - 10
plugins/exportmtomd.js

@@ -1,4 +1,19 @@
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
 	
 	
 	'interfaces': [{'method':'POST', 'url=':'/exportmtomd'}],
 	'interfaces': [{'method':'POST', 'url=':'/exportmtomd'}],
 	'csworker':
 	'csworker':
@@ -81,7 +96,7 @@
 							// Import extra metamodels
 							// Import extra metamodels
 							for (var i = mms.length - 1; i >= 0; i--) {
 							for (var i = mms.length - 1; i >= 0; i--) {
 								file_contents += 'load "' + extract_md_type(mms[i]) + '"\n';
 								file_contents += 'load "' + extract_md_type(mms[i]) + '"\n';
-							};
+							}
 							// FIX: Define an auxiliary metamodel which imports all other metamodels and is then instantiated by the main model
 							// FIX: Define an auxiliary metamodel which imports all other metamodels and is then instantiated by the main model
 							var mm = extract_md_type(mms[0]);
 							var mm = extract_md_type(mms[0]);
 							var modelName = reqData['name'];
 							var modelName = reqData['name'];
@@ -89,16 +104,16 @@
 							file_contents += '\nModel ' + mm + ' imports ';
 							file_contents += '\nModel ' + mm + ' imports ';
 							for (var i = 0; i < mms.length - 1; i++) {
 							for (var i = 0; i < mms.length - 1; i++) {
 								file_contents += extract_md_type(mms[i]) + ', ';
 								file_contents += extract_md_type(mms[i]) + ', ';
-							};
-							file_contents += extract_md_type(mms[mms.length - 1])
+							}
+							file_contents += extract_md_type(mms[mms.length - 1]);
 							file_contents += ' {} \n\n';
 							file_contents += ' {} \n\n';
 							var edges = {};
 							var edges = {};
 							for (var i = 0; i < as.edges.length; i += 2) {
 							for (var i = 0; i < as.edges.length; i += 2) {
 								if (as.edges[i].dest != as.edges[i + 1].src) console.error('The source and destination of the edge are different!');
 								if (as.edges[i].dest != as.edges[i + 1].src) console.error('The source and destination of the edge are different!');
 								edges[as.edges[i].dest] = ([as.edges[i].src, as.edges[i + 1].dest]);
 								edges[as.edges[i].dest] = ([as.edges[i].src, as.edges[i + 1].dest]);
-							};
+							}
 							// Model definition
 							// Model definition
-							file_contents += mm + ' ' + modelName + ' {\n'
+							file_contents += mm + ' ' + modelName + ' {\n';
 							// console.log('------------');
 							// console.log('------------');
 							// console.log(as.nodes);
 							// console.log(as.nodes);
 							// console.log('------------');
 							// console.log('------------');
@@ -168,8 +183,8 @@
 									}
 									}
 									file_contents += '}\n';
 									file_contents += '}\n';
 								// }
 								// }
-							};
-							file_contents += '}\n'
+							}
+							file_contents += '}\n';
 							_fs.writeFileSync('./exported_to_md/' + reqData['name'] + '.mdepth', file_contents);
 							_fs.writeFileSync('./exported_to_md/' + reqData['name'] + '.mdepth', file_contents);
 							__postMessage({	'statusCode': 200,
 							__postMessage({	'statusCode': 200,
 											'respIndex': resp});
 											'respIndex': resp});
@@ -178,7 +193,7 @@
 					);					
 					);					
 				},
 				},
 				function(err) {__postInternalErrorMsg(resp, err);}
 				function(err) {__postInternalErrorMsg(resp, err);}
-			)
+			);
 		},
 		},
 	'asworker':
 	'asworker':
 		function(resp, method, uri, reqData, wcontext)
 		function(resp, method, uri, reqData, wcontext)
@@ -187,4 +202,4 @@
 				{'statusCode': 200,
 				{'statusCode': 200,
 					 'respIndex': resp});	
 					 'respIndex': resp});	
 		}
 		}
-}
+};

+ 27 - 11
plugins/exportpnml.js

@@ -1,5 +1,21 @@
 /* a simple hello world plugin... it listens for "POST /hello" requests... requests are received by "csworker" and forwarded to "asworker"... both respond with their __worker\'s id and with a counter of the number of handled requests */
 /* a simple hello world plugin... it listens for "POST /hello" requests... requests are received by "csworker" and forwarded to "asworker"... both respond with their __worker\'s id and with a counter of the number of handled requests */
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _mmmk = require("../mmmk");
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
 	'interfaces'	: [{'method':'POST', 'url=':'/pnml'}],
 	'interfaces'	: [{'method':'POST', 'url=':'/pnml'}],
 
 
 
 
@@ -34,7 +50,7 @@
 								var cs = _utils.jsonp(res);
 								var cs = _utils.jsonp(res);
 								var as = _utils.jsonp(asdata['data']);
 								var as = _utils.jsonp(asdata['data']);
 								
 								
-								function addPlace(name,id,x,y,initial) {
+								let addPlace = function(name,id,x,y,initial) {
 									var file='<place id="'+id+'">\n';
 									var file='<place id="'+id+'">\n';
 									file+='<name>\n';
 									file+='<name>\n';
 								    file +='<text>"'+name+'"</text>\n';
 								    file +='<text>"'+name+'"</text>\n';
@@ -48,22 +64,22 @@
     							    }
     							    }
                                     file+='</place>\n';
                                     file+='</place>\n';
                                     return file;
                                     return file;
-								}
-								function addTrans(name,id,x,y) {
+								};
+								let addTrans = function(name,id,x,y) {
 									var file='<transition id="'+id+'">\n <name> <text>'+name+'</text>\n';
 									var file='<transition id="'+id+'">\n <name> <text>'+name+'</text>\n';
 									file+='<graphics>   <offset x="22" y="-14"/>  </graphics>\n';
 									file+='<graphics>   <offset x="22" y="-14"/>  </graphics>\n';
                                    file+='</name>\n<graphics> <position x="'+x+'" y="'+y+'"/></graphics>\n</transition>\n';
                                    file+='</name>\n<graphics> <position x="'+x+'" y="'+y+'"/></graphics>\n</transition>\n';
                                    return file;
                                    return file;
-								}
-								function addArc(from,to) {
+								};
+								let addArc = function(from,to) {
 									var file='<arc id="'+from+to+'" source="'+from+'" target="'+to+'">\n';
 									var file='<arc id="'+from+to+'" source="'+from+'" target="'+to+'">\n';
                                     file+='<inscription> <text>1</text> </inscription> </arc>\n';
                                     file+='<inscription> <text>1</text> </inscription> </arc>\n';
                                     return file;
                                     return file;
-								}
+								};
 								var mData = {
 								var mData = {
 										'csm':_utils.jsonp(res),
 										'csm':_utils.jsonp(res),
 										'asm':_utils.jsonp(asdata['data'])},
 										'asm':_utils.jsonp(asdata['data'])},
-									 path  = reqData['fname']
+									 path  = reqData['fname'];
 									 dir	 = _path.dirname(path).replace(/"/g,'\\"'),
 									 dir	 = _path.dirname(path).replace(/"/g,'\\"'),
 									 
 									 
 									 writeActions = 
 									 writeActions = 
@@ -78,7 +94,7 @@
 											    var x=0;
 											    var x=0;
 											    var y=0;
 											    var y=0;
 											    var initial = 0;
 											    var initial = 0;
-											    var name = ''
+											    var name = '';
 											    var tokens =  0;
 											    var tokens =  0;
 												if (as.nodes[key]['$type'].indexOf('Transition') != -1) {
 												if (as.nodes[key]['$type'].indexOf('Transition') != -1) {
 													x = cs.nodes[key]['position']['value'][0];
 													x = cs.nodes[key]['position']['value'][0];
@@ -117,7 +133,7 @@
 										  _fs.write(fd,head);
 										  _fs.write(fd,head);
 										  _fs.close(fd);
 										  _fs.close(fd);
 											});
 											});
-											 return true
+											 return true;
 										 }];
 										 }];
 								_do.chain(writeActions)(
 								_do.chain(writeActions)(
 									function()
 									function()
@@ -151,4 +167,4 @@
 					 'sequence#':__sequenceNumber(),
 					 'sequence#':__sequenceNumber(),
 					 'respIndex':resp});
 					 'respIndex':resp});
 		}
 		}
-}
+};

+ 85 - 70
plugins/exporttoppdevs.js

@@ -1,4 +1,19 @@
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
 	
 	
 	'interfaces': [{'method':'POST', 'url=':'/exportmtoppdevs'}],
 	'interfaces': [{'method':'POST', 'url=':'/exportmtoppdevs'}],
 	'csworker':
 	'csworker':
@@ -16,11 +31,11 @@
 								incoming = {},
 								incoming = {},
 								outgoing = {};
 								outgoing = {};
 							
 							
-							file_contents += 'import sys\n'
-							file_contents += 'sys.path.append("../../pypdevs/src/")\n\n'
-							file_contents += 'from DEVS import *\n'
-							file_contents += 'from infinity import INFINITY\n'
-							file_contents += 'from util import *\n\n'
+							file_contents += 'import sys\n';
+							file_contents += 'sys.path.append("../../pypdevs/src/")\n\n';
+							file_contents += 'from DEVS import *\n';
+							file_contents += 'from infinity import INFINITY\n';
+							file_contents += 'from util import *\n\n';
 							
 							
 							for (var key in as.nodes) {
 							for (var key in as.nodes) {
 								var node = as.nodes[key];
 								var node = as.nodes[key];
@@ -47,14 +62,14 @@
 									for (var e_key in as.edges) {
 									for (var e_key in as.edges) {
 										var e = as.edges[e_key];
 										var e = as.edges[e_key];
 										if (e['dest'] == key) {
 										if (e['dest'] == key) {
-											safe_add(incoming[key], e['src'])
+											safe_add(incoming[key], e['src']);
 											if (!(e['src'] in outgoing)) {
 											if (!(e['src'] in outgoing)) {
 												outgoing[e['src']] = [];
 												outgoing[e['src']] = [];
 											}
 											}
 											safe_add(outgoing[e['src']], key);
 											safe_add(outgoing[e['src']], key);
 										}
 										}
 										if (e['src'] == key) {
 										if (e['src'] == key) {
-											safe_add(outgoing[key], e['dest'])
+											safe_add(outgoing[key], e['dest']);
 											if (!(e['dest'] in incoming)) {
 											if (!(e['dest'] in incoming)) {
 												incoming[e['dest']] = [];
 												incoming[e['dest']] = [];
 											}
 											}
@@ -75,64 +90,64 @@
 							
 							
 							for (var key in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/StateDefinition']) {
 							for (var key in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/StateDefinition']) {
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/StateDefinition'][key],
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/StateDefinition'][key],
-									list_of_params = ['name=""'].concat(node['parameters']['value'].map(function(el) {return el['name'] + '=None'})),
-									list_of_param_names = ['name'].concat(node['parameters']['value'].map(function(el) {return el['name']})),
-									list_of_attrs = [['name', '']].concat(node['attributes']['value'].map(function(el) {return [el['name'], el['default']]}));
+									list_of_params = ['name=""'].concat(node['parameters']['value'].map(function(el) {return el['name'] + '=None';})),
+									list_of_param_names = ['name'].concat(node['parameters']['value'].map(function(el) {return el['name'];})),
+									list_of_attrs = [['name', '']].concat(node['attributes']['value'].map(function(el) {return [el['name'], el['default']];}));
 								file_contents += 'class ' + node['name']['value'] + ':\n';
 								file_contents += 'class ' + node['name']['value'] + ':\n';
 								file_contents += '\tdef __init__(self, ' + list_of_params.join(', ') + '):\n';
 								file_contents += '\tdef __init__(self, ' + list_of_params.join(', ') + '):\n';
-                                file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] : el[1])}).join('\n') + "\n";
-                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line}).join('\n');
+                                file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] : el[1]);}).join('\n') + "\n";
+                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line;}).join('\n');
 								file_contents += '\n\n';
 								file_contents += '\n\n';
 							}
 							}
 							
 							
 							for (var key in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/Event']) {
 							for (var key in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/Event']) {
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/Event'][key],
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/Event'][key],
-									list_of_params = (node['parameters']['value'].map(function(el) {return el['name'] + '=None'})),
-									list_of_param_names = (node['parameters']['value'].map(function(el) {return el['name']})),
-									list_of_attrs = (node['attributes']['value'].map(function(el) {return [el['name'], el['default']]}));
+									list_of_params = (node['parameters']['value'].map(function(el) {return el['name'] + '=None';})),
+									list_of_param_names = (node['parameters']['value'].map(function(el) {return el['name'];})),
+									list_of_attrs = (node['attributes']['value'].map(function(el) {return [el['name'], el['default']];}));
 								file_contents += 'class ' + node['name']['value'] + ':\n';
 								file_contents += 'class ' + node['name']['value'] + ':\n';
 								file_contents += '\tdef __init__(self, ' + list_of_params.join(', ') + '):\n';
 								file_contents += '\tdef __init__(self, ' + list_of_params.join(', ') + '):\n';
-								file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] : el[1])}).join('\n') + "\n";
-                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line}).join('\n');
+								file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] : el[1]);}).join('\n') + "\n";
+                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line;}).join('\n');
 								file_contents += '\n\n';
 								file_contents += '\n\n';
 								file_contents += '\tdef __str__(self):\n';
 								file_contents += '\tdef __str__(self):\n';
-								file_contents += '\t\treturn "' + node['name']['value'] + '(" + ' + list_of_attrs.map(function(el) {return 'str(self.' + el[0] + ')'}).join(' + ", " + ') + ' + ")"';
+								file_contents += '\t\treturn "' + node['name']['value'] + '(" + ' + list_of_attrs.map(function(el) {return 'str(self.' + el[0] + ')';}).join(' + ", " + ') + ' + ")"';
 								file_contents += '\n\n';
 								file_contents += '\n\n';
 							}
 							}
 							
 							
 							for (var idx in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/AtomicDEVS']) {
 							for (var idx in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/AtomicDEVS']) {
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/AtomicDEVS'][idx],
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/AtomicDEVS'][idx],
-									list_of_params = (node['parameters']['value'].map(function(el) {return el['name'] + '=None'})),
-									list_of_param_names = (node['parameters']['value'].map(function(el) {return el['name']})),
-									list_of_attrs = (node['attributes']['value'].map(function(el) {return [el['name'], el['default']]}));
+									list_of_params = (node['parameters']['value'].map(function(el) {return el['name'] + '=None';})),
+									list_of_param_names = (node['parameters']['value'].map(function(el) {return el['name'];})),
+									list_of_attrs = (node['attributes']['value'].map(function(el) {return [el['name'], el['default']];}));
 								file_contents += 'class ' + node['name']['value'] + '(AtomicDEVS):\n';
 								file_contents += 'class ' + node['name']['value'] + '(AtomicDEVS):\n';
 								file_contents += '\tdef __init__(' + (['self', 'name="' + node['name']['value'] + '"'].concat(list_of_params).join(', ')) + '):\n';
 								file_contents += '\tdef __init__(' + (['self', 'name="' + node['name']['value'] + '"'].concat(list_of_params).join(', ')) + '):\n';
 								file_contents += '\t\tAtomicDEVS.__init__(self, name)\n';
 								file_contents += '\t\tAtomicDEVS.__init__(self, name)\n';
-								file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] + ' if ' + el[0] + ' is not None else ' + el[1] : el[1])}).join('\n');
+								file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] + ' if ' + el[0] + ' is not None else ' + el[1] : el[1]);}).join('\n');
 								file_contents += '\n';
 								file_contents += '\n';
 								key = type_map_keys['/Formalisms/ParallelDEVS/ParallelDEVS/AtomicDEVS'][idx];
 								key = type_map_keys['/Formalisms/ParallelDEVS/ParallelDEVS/AtomicDEVS'][idx];
-								statedef = as.nodes[outgoing[outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/statedef'})[0]][0]];
-								states = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/states'}).map(function(statesid) {return outgoing[statesid][0]}).map(function(sid) {return as.nodes[sid]});
-								defstate = states.filter(function(el) {return el['initial']['value']})[0]
-								list_of_assigns = ['name="' + defstate['name']['value'] + '"'].concat(statedef['initial_binding']['value'].map(function(el) {return el['name'] + '=' + el['val']}))
+								statedef = as.nodes[outgoing[outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/statedef';})[0]][0]];
+								states = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/states';}).map(function(statesid) {return outgoing[statesid][0];}).map(function(sid) {return as.nodes[sid];});
+								defstate = states.filter(function(el) {return el['initial']['value'];})[0];
+								list_of_assigns = ['name="' + defstate['name']['value'] + '"'].concat(statedef['initial_binding']['value'].map(function(el) {return el['name'] + '=' + el['val'];}));
 								file_contents += '\t\tself.state = ' + statedef['name']['value'] + '(' + list_of_assigns.join(', ') + ')\n';
 								file_contents += '\t\tself.state = ' + statedef['name']['value'] + '(' + list_of_assigns.join(', ') + ')\n';
-                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line}).join('\n') + "\n";
-								ports = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ports'}).map(function(portsid) {return outgoing[portsid][0]}).map(function(pid) {return as.nodes[pid]});
-								file_contents += '\t\tself.my_ports = {' + ports.map(function(el) {return '"' + el['name']['value'] + '": ' + (el['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/OutputPort' ? 'self.addOutPort("' : 'self.addInPort("') + el['name']['value'] + '")'}).join(', ') + '}\n\n'
-								file_contents += '\tdef timeAdvance(self):\n'
-								file_contents += states.map(function(s) {return '\t\tif self.state.name == "' + s['name']['value'] + '":\n' + s['time_advance']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n')}).join('\n')
+                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line;}).join('\n') + "\n";
+								ports = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ports';}).map(function(portsid) {return outgoing[portsid][0];}).map(function(pid) {return as.nodes[pid];});
+								file_contents += '\t\tself.my_ports = {' + ports.map(function(el) {return '"' + el['name']['value'] + '": ' + (el['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/OutputPort' ? 'self.addOutPort("' : 'self.addInPort("') + el['name']['value'] + '")';}).join(', ') + '}\n\n';
+								file_contents += '\tdef timeAdvance(self):\n';
+								file_contents += states.map(function(s) {return '\t\tif self.state.name == "' + s['name']['value'] + '":\n' + s['time_advance']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');}).join('\n');
 								file_contents += '\n\n';
 								file_contents += '\n\n';
-								file_contents += '\tdef outputFnc(self):\n'
-                                file_contents += '\t\tdef subfunc(self):\n'
-                                file_contents += states.map(function(s) {return '\t\t\tif self.state.name == "' + s['name']['value'] + '":\n' + (s['output']['value'] == '' ? ['\t\t\t\treturn {}'] : s['output']['value'].split('\n').map(function(line) {return '\t\t\t\t' + line}).join('\n'))}).join('\n') + "\n";
+								file_contents += '\tdef outputFnc(self):\n';
+                                file_contents += '\t\tdef subfunc(self):\n';
+                                file_contents += states.map(function(s) {return '\t\t\tif self.state.name == "' + s['name']['value'] + '":\n' + (s['output']['value'] == '' ? ['\t\t\t\treturn {}'] : s['output']['value'].split('\n').map(function(line) {return '\t\t\t\t' + line;}).join('\n'));}).join('\n') + "\n";
                                 file_contents += '\t\treturn {self.my_ports[k]: v for k, v in subfunc(self).iteritems()}\n';
                                 file_contents += '\t\treturn {self.my_ports[k]: v for k, v in subfunc(self).iteritems()}\n';
 								file_contents += '\n\n';
 								file_contents += '\n\n';
-								file_contents += '\tdef intTransition(self):\n'
+								file_contents += '\tdef intTransition(self):\n';
 								var content = false;
 								var content = false;
 								for (var sidx in states) {
 								for (var sidx in states) {
 									s = states[sidx];
 									s = states[sidx];
 									if (outgoing[s['$key']]) {
 									if (outgoing[s['$key']]) {
-										internals = outgoing[s['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/InternalTransition'}).map(function(tid) {return as.nodes[tid]});
+										internals = outgoing[s['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/InternalTransition';}).map(function(tid) {return as.nodes[tid];});
 										for (var iidx in internals) {
 										for (var iidx in internals) {
 											content = true;
 											content = true;
 											internal = internals[iidx];
 											internal = internals[iidx];
@@ -140,9 +155,9 @@
 												cond_name = 'cond_int_' + s['name']['value'] + '_to_' + target['name']['value'],
 												cond_name = 'cond_int_' + s['name']['value'] + '_to_' + target['name']['value'],
 												action_name = 'action_int_' + s['name']['value'] + '_to_' + target['name']['value'];
 												action_name = 'action_int_' + s['name']['value'] + '_to_' + target['name']['value'];
 											file_contents += '\t\t\def ' + cond_name + '():\n';
 											file_contents += '\t\t\def ' + cond_name + '():\n';
-											file_contents += internal['condition']['value'] == '' ? '\t\t\treturn True' : internal['condition']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n');
+											file_contents += internal['condition']['value'] == '' ? '\t\t\treturn True' : internal['condition']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');
 											file_contents += '\n\t\t\def ' + action_name + '():\n';
 											file_contents += '\n\t\t\def ' + action_name + '():\n';
-											file_contents += internal['action']['value'] == '' ? '\t\t\treturn {}' : internal['action']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n');
+											file_contents += internal['action']['value'] == '' ? '\t\t\treturn {}' : internal['action']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');
 											file_contents += '\n\t\tif self.state.name == "' + s['name']['value'] + '" and ' + cond_name + '():\n';
 											file_contents += '\n\t\tif self.state.name == "' + s['name']['value'] + '" and ' + cond_name + '():\n';
 											file_contents += '\t\t\treturn ' + statedef['name']['value'] + '(name="' + target['name']['value'] + '", **' + action_name + '())\n\n';
 											file_contents += '\t\t\treturn ' + statedef['name']['value'] + '(name="' + target['name']['value'] + '", **' + action_name + '())\n\n';
 										}
 										}
@@ -155,23 +170,23 @@
 									file_contents += '\t\t\treturn AtomicDEVS.intTransition(self)\n';
 									file_contents += '\t\t\treturn AtomicDEVS.intTransition(self)\n';
 								}
 								}
 								file_contents += '\n';
 								file_contents += '\n';
-								file_contents += '\tdef extTransition(self, my_inputs):\n'
-								file_contents += '\t\tinputs = {k.getPortName(): v for k, v in my_inputs.iteritems()}\n'
+								file_contents += '\tdef extTransition(self, my_inputs):\n';
+								file_contents += '\t\tinputs = {k.getPortName(): v for k, v in my_inputs.iteritems()}\n';
 								content = false;
 								content = false;
 								for (var sidx in states) {
 								for (var sidx in states) {
 									s = states[sidx];
 									s = states[sidx];
 									if (outgoing[s['$key']]) {
 									if (outgoing[s['$key']]) {
-										externals = outgoing[s['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ExternalTransition'}).map(function(tid) {return as.nodes[tid]});
+										let externals = outgoing[s['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ExternalTransition';}).map(function(tid) {return as.nodes[tid];});
 										for (var iidx in externals) {
 										for (var iidx in externals) {
 											content  = true;
 											content  = true;
-											external = externals[iidx];
-											var target = as.nodes[outgoing[external['$key']][0]],
+											let extern = externals[iidx];
+											var target = as.nodes[outgoing[extern['$key']][0]],
 												cond_name = 'cond_ext_' + s['name']['value'] + '_to_' + target['name']['value'],
 												cond_name = 'cond_ext_' + s['name']['value'] + '_to_' + target['name']['value'],
 												action_name = 'action_ext_' + s['name']['value'] + '_to_' + target['name']['value'];
 												action_name = 'action_ext_' + s['name']['value'] + '_to_' + target['name']['value'];
 											file_contents += '\t\t\def ' + cond_name + '():\n';
 											file_contents += '\t\t\def ' + cond_name + '():\n';
-											file_contents += external['condition']['value'] == '' ? '\t\t\treturn True' : external['condition']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n');
+											file_contents += extern['condition']['value'] == '' ? '\t\t\treturn True' : extern['condition']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');
 											file_contents += '\n\t\t\def ' + action_name + '():\n';
 											file_contents += '\n\t\t\def ' + action_name + '():\n';
-											file_contents += external['action']['value'] == '' ? '\t\t\treturn {}' : external['action']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n');
+											file_contents += extern['action']['value'] == '' ? '\t\t\treturn {}' : extern['action']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');
 											file_contents += '\n\t\tif self.state.name == "' + s['name']['value'] + '" and ' + cond_name + '():\n';
 											file_contents += '\n\t\tif self.state.name == "' + s['name']['value'] + '" and ' + cond_name + '():\n';
 											file_contents += '\t\t\treturn ' + statedef['name']['value'] + '(name="' + target['name']['value'] + '", **' + action_name + '())\n\n';
 											file_contents += '\t\t\treturn ' + statedef['name']['value'] + '(name="' + target['name']['value'] + '", **' + action_name + '())\n\n';
 										}
 										}
@@ -183,13 +198,13 @@
 									file_contents += '\t\telse:\n';
 									file_contents += '\t\telse:\n';
 									file_contents += '\t\t\treturn AtomicDEVS.extTransition(self, my_inputs)\n';
 									file_contents += '\t\t\treturn AtomicDEVS.extTransition(self, my_inputs)\n';
 								}
 								}
-								file_contents += '\n'
-								file_contents += '\tdef confTransition(self, my_inputs):\n'
-								file_contents += '\t\tinputs = {k.getPortName(): v for k, v in my_inputs.iteritems()}\n'
+								file_contents += '\n';
+								file_contents += '\tdef confTransition(self, my_inputs):\n';
+								file_contents += '\t\tinputs = {k.getPortName(): v for k, v in my_inputs.iteritems()}\n';
 								content = false;
 								content = false;
 								for (var sidx in states) {
 								for (var sidx in states) {
 									s = states[sidx];
 									s = states[sidx];
-									confluents = outgoing[s['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ConfluentTransition'}).map(function(tid) {return as.nodes[tid]});
+									confluents = outgoing[s['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ConfluentTransition';}).map(function(tid) {return as.nodes[tid];});
 									for (var iidx in confluents) {
 									for (var iidx in confluents) {
 										content  = true;
 										content  = true;
 										confluent = confluents[iidx];
 										confluent = confluents[iidx];
@@ -197,9 +212,9 @@
 											cond_name = 'cond_conf_' + s['name']['value'] + '_to_' + target['name']['value'],
 											cond_name = 'cond_conf_' + s['name']['value'] + '_to_' + target['name']['value'],
 											action_name = 'action_conf_' + s['name']['value'] + '_to_' + target['name']['value'];
 											action_name = 'action_conf_' + s['name']['value'] + '_to_' + target['name']['value'];
 										file_contents += '\t\t\def ' + cond_name + '():\n';
 										file_contents += '\t\t\def ' + cond_name + '():\n';
-										file_contents += confluent['condition']['value'] == '' ? '\t\t\treturn True' : confluent['condition']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n');
+										file_contents += confluent['condition']['value'] == '' ? '\t\t\treturn True' : confluent['condition']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');
 										file_contents += '\n\t\t\def ' + action_name + '():\n';
 										file_contents += '\n\t\t\def ' + action_name + '():\n';
-										file_contents += confluent['action']['value'] == '' ? '\t\t\treturn {}' : confluent['action']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n');
+										file_contents += confluent['action']['value'] == '' ? '\t\t\treturn {}' : confluent['action']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');
 										file_contents += '\n\t\tif self.state.name == "' + s['name']['value'] + '" and ' + cond_name + '():\n';
 										file_contents += '\n\t\tif self.state.name == "' + s['name']['value'] + '" and ' + cond_name + '():\n';
 										file_contents += '\t\t\treturn ' + statedef['name']['value'] + '(name="' + target['name']['value'] + '", **' + action_name + '())\n\n';
 										file_contents += '\t\t\treturn ' + statedef['name']['value'] + '(name="' + target['name']['value'] + '", **' + action_name + '())\n\n';
 									}
 									}
@@ -210,35 +225,35 @@
 									file_contents += '\t\telse:\n';
 									file_contents += '\t\telse:\n';
 									file_contents += '\t\t\treturn AtomicDEVS.confTransition(self, my_inputs)\n';
 									file_contents += '\t\t\treturn AtomicDEVS.confTransition(self, my_inputs)\n';
 								}
 								}
-								file_contents += '\n'
+								file_contents += '\n';
 							}
 							}
 							
 							
 							for (var idx in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/CoupledDEVS']) {
 							for (var idx in type_map['/Formalisms/ParallelDEVS/ParallelDEVS/CoupledDEVS']) {
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/CoupledDEVS'][idx],
 								var node = type_map['/Formalisms/ParallelDEVS/ParallelDEVS/CoupledDEVS'][idx],
-									list_of_params = (node['parameters']['value'].map(function(el) {return el['name'] + '=None'})),
-									list_of_param_names = (node['parameters']['value'].map(function(el) {return el['name']})),
-									list_of_attrs = (node['attributes']['value'].map(function(el) {return [el['name'], el['default']]}));
+									list_of_params = (node['parameters']['value'].map(function(el) {return el['name'] + '=None';})),
+									list_of_param_names = (node['parameters']['value'].map(function(el) {return el['name'];})),
+									list_of_attrs = (node['attributes']['value'].map(function(el) {return [el['name'], el['default']];}));
 								file_contents += 'class ' + node['name']['value'] + '(CoupledDEVS):\n';
 								file_contents += 'class ' + node['name']['value'] + '(CoupledDEVS):\n';
 								file_contents += '\tdef __init__(' + (['self', 'name="' + node['name']['value'] + '"'].concat(list_of_params).join(', ')) + '):\n';
 								file_contents += '\tdef __init__(' + (['self', 'name="' + node['name']['value'] + '"'].concat(list_of_params).join(', ')) + '):\n';
 								file_contents += '\t\tCoupledDEVS.__init__(self, name)\n';
 								file_contents += '\t\tCoupledDEVS.__init__(self, name)\n';
-								file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] : el[1])}).join('\n') + "\n";
-                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line}).join('\n') + "\n";
+								file_contents += list_of_attrs.map(function(el) {return '\t\tself.' + el[0] + ' = ' + (list_of_param_names.indexOf(el[0]) != -1 ? el[0] : el[1]);}).join('\n') + "\n";
+                                file_contents += node['__init__']['value'].split('\n').map(function(line) {return '\t\t' + line;}).join('\n') + "\n";
 								key = type_map_keys['/Formalisms/ParallelDEVS/ParallelDEVS/CoupledDEVS'][idx];
 								key = type_map_keys['/Formalisms/ParallelDEVS/ParallelDEVS/CoupledDEVS'][idx];
-								ports = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ports'}).map(function(portsid) {return outgoing[portsid][0]}).map(function(pid) {return as.nodes[pid]});
-								file_contents += '\t\tself.my_ports = {' + ports.map(function(el) {return '"' + el['name']['value'] + '": ' + (el['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/OutputPort' ? 'self.addOutPort("' : 'self.addInPort("') + el['name']['value'] + '")'}).join(', ') + '}\n'
+								ports = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ports';}).map(function(portsid) {return outgoing[portsid][0];}).map(function(pid) {return as.nodes[pid];});
+								file_contents += '\t\tself.my_ports = {' + ports.map(function(el) {return '"' + el['name']['value'] + '": ' + (el['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/OutputPort' ? 'self.addOutPort("' : 'self.addInPort("') + el['name']['value'] + '")';}).join(', ') + '}\n';
 								file_contents += '\t\tself.submodels = {}\n';
 								file_contents += '\t\tself.submodels = {}\n';
-								submodels = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/submodels'}).map(function(submodelsid) {return outgoing[submodelsid][0]}).map(function(mid) {return as.nodes[mid]});
-								file_contents += submodels.map(function(m) {return '\t\tself.submodels["' + m['name']['value'] + '"] = self.addSubModel(' + m['devs_type']['value'] + '(' + ['name="' + m['name']['value'] + '"'].concat(m['parameter_binding']['value'].map(function(pb) {return pb['name'] + '=' + pb['val']})).join(', ') + '))'}).join('\n');
+								submodels = outgoing[key].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/submodels';}).map(function(submodelsid) {return outgoing[submodelsid][0];}).map(function(mid) {return as.nodes[mid];});
+								file_contents += submodels.map(function(m) {return '\t\tself.submodels["' + m['name']['value'] + '"] = self.addSubModel(' + m['devs_type']['value'] + '(' + ['name="' + m['name']['value'] + '"'].concat(m['parameter_binding']['value'].map(function(pb) {return pb['name'] + '=' + pb['val'];})).join(', ') + '))';}).join('\n');
 								file_contents += '\n\n';
 								file_contents += '\n\n';
-								myportkeys = ports.map(function(port) {return port['$key']});
+								myportkeys = ports.map(function(port) {return port['$key'];});
 								port_to_m = {};
 								port_to_m = {};
 								m_to_ports = {};
 								m_to_ports = {};
 								m_to_ports[key] = ports;
 								m_to_ports[key] = ports;
-								ports.forEach(function(p) {port_to_m[p['$key']] = node});
+								ports.forEach(function(p) {port_to_m[p['$key']] = node;});
 								for (var skey in submodels) {
 								for (var skey in submodels) {
 									var m = submodels[skey];
 									var m = submodels[skey];
 									m_to_ports[m['$key']] = [];
 									m_to_ports[m['$key']] = [];
-									ports = outgoing[m['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ports'}).map(function(portsid) {return outgoing[portsid][0]}).map(function(pid) {return as.nodes[pid]});
+									ports = outgoing[m['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/ports';}).map(function(portsid) {return outgoing[portsid][0];}).map(function(pid) {return as.nodes[pid];});
 									ports.forEach(function(p) {port_to_m[p['$key']] = m; m_to_ports[m['$key']].push(p);});
 									ports.forEach(function(p) {port_to_m[p['$key']] = m; m_to_ports[m['$key']].push(p);});
 								}
 								}
 								for (var mkey in m_to_ports) {
 								for (var mkey in m_to_ports) {
@@ -246,7 +261,7 @@
 										var p = m_to_ports[mkey][pidx],
 										var p = m_to_ports[mkey][pidx],
 											pkey = p['$key'];
 											pkey = p['$key'];
 										if (pkey in outgoing) {
 										if (pkey in outgoing) {
-											var conns = outgoing[pkey].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/channel'}).map(function(channelid) {return as.nodes[channelid]})
+											var conns = outgoing[pkey].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/ParallelDEVS/ParallelDEVS/channel';}).map(function(channelid) {return as.nodes[channelid];});
 											for (var cidx in conns) {
 											for (var cidx in conns) {
 												var conn = conns[cidx],
 												var conn = conns[cidx],
 													target = as.nodes[outgoing[conn['$key']][0]],
 													target = as.nodes[outgoing[conn['$key']][0]],
@@ -255,7 +270,7 @@
 													toportstr = (port_to_m[target['$key']]['$key'] == key ? 'self' : 'self.submodels["' + port_to_m[target['$key']]['name']['value'] + '"]') + '.my_ports["' + target['name']['value'] + '"]';
 													toportstr = (port_to_m[target['$key']]['$key'] == key ? 'self' : 'self.submodels["' + port_to_m[target['$key']]['name']['value'] + '"]') + '.my_ports["' + target['name']['value'] + '"]';
 												if (conn['transfer_function']['value'] != '') {
 												if (conn['transfer_function']['value'] != '') {
 													file_contents += '\t\tdef ' + transfname + '(event):\n';
 													file_contents += '\t\tdef ' + transfname + '(event):\n';
-													file_contents += conn['transfer_function']['value'].split('\n').map(function(line) {return '\t\t\t' + line}).join('\n');
+													file_contents += conn['transfer_function']['value'].split('\n').map(function(line) {return '\t\t\t' + line;}).join('\n');
 													file_contents += '\n\n';
 													file_contents += '\n\n';
 													file_contents += '\t\tself.connectPorts(' + fromportstr + ', ' + toportstr + ', ' + transfname + ')\n\n';
 													file_contents += '\t\tself.connectPorts(' + fromportstr + ', ' + toportstr + ', ' + transfname + ')\n\n';
 												} else {
 												} else {
@@ -279,7 +294,7 @@
 
 
 							file_contents += 'def termination_condition(time, model, transitioned):\n';
 							file_contents += 'def termination_condition(time, model, transitioned):\n';
 							file_contents += '\ttime = time[0]\n';
 							file_contents += '\ttime = time[0]\n';
-							file_contents += type_map['/Formalisms/ParallelDEVS/ParallelDEVS/Simulation'][0]['end_condition']['value'].split('\n').map(function(line) {return '\t' + line}).join('\n') + '\n';
+							file_contents += type_map['/Formalisms/ParallelDEVS/ParallelDEVS/Simulation'][0]['end_condition']['value'].split('\n').map(function(line) {return '\t' + line;}).join('\n') + '\n';
 							
 							
 							_fs.writeFileSync('./exported_to_pypdevs/experiment.py', file_contents);
 							_fs.writeFileSync('./exported_to_pypdevs/experiment.py', file_contents);
 							
 							
@@ -290,7 +305,7 @@
 					);
 					);
 				},
 				},
 				function(err) {__postInternalErrorMsg(resp, err);}
 				function(err) {__postInternalErrorMsg(resp, err);}
-			)
+			);
 		},
 		},
 	'asworker':
 	'asworker':
 		function(resp, method, uri, reqData, wcontext)
 		function(resp, method, uri, reqData, wcontext)
@@ -299,4 +314,4 @@
 				{'statusCode': 200,
 				{'statusCode': 200,
 					 'respIndex': resp});	
 					 'respIndex': resp});	
 		}
 		}
-}
+};

+ 34 - 19
plugins/exporttosccdxml.js

@@ -1,5 +1,20 @@
 /* SCCDXML exporter plugin*/
 /* SCCDXML exporter plugin*/
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
 	'interfaces'	: [{'method':'POST', 'url=':'/exporttosccdxml'}],
 	'interfaces'	: [{'method':'POST', 'url=':'/exporttosccdxml'}],
 	'csworker'		: 
 	'csworker'		: 
         function(resp,method,uri,reqData,wcontext)
         function(resp,method,uri,reqData,wcontext)
@@ -41,7 +56,7 @@
 								}
 								}
 								
 								
 								function find_initial(state){
 								function find_initial(state){
-									var substates = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain'}).map(function(tid) {return as.nodes[tid]});
+									var substates = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain';}).map(function(tid) {return as.nodes[tid];});
 									for (var sidx in substates){
 									for (var sidx in substates){
 										var substate = as.nodes[outgoing[substates[sidx]['$key']]];
 										var substate = as.nodes[outgoing[substates[sidx]['$key']]];
 										if(substate['isStart']['value']){
 										if(substate['isStart']['value']){
@@ -51,7 +66,7 @@
 								}
 								}
 								
 								
 								function get_full_path(state){
 								function get_full_path(state){
-									var parent_link = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes'}).map(function(tid) {return as.nodes[tid]})[0];
+									var parent_link = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes';}).map(function(tid) {return as.nodes[tid];})[0];
 									if (parent_link != undefined){
 									if (parent_link != undefined){
 										var parent = as.nodes[incoming[parent_link['$key']][0]];
 										var parent = as.nodes[incoming[parent_link['$key']][0]];
 										return get_full_path(parent).concat([state['name']['value']]);
 										return get_full_path(parent).concat([state['name']['value']]);
@@ -106,9 +121,9 @@
 										else{
 										else{
 											contents += ' scope="' + r['scope'] + '">\n';
 											contents += ' scope="' + r['scope'] + '">\n';
 										}
 										}
-										arguments = r['arguments'];
-										for (var aidx in arguments){
-											var arg = arguments[aidx];
+										let args = r['arguments'];
+										for (var aidx in args){
+											var arg = args[aidx];
 											if(arg != ""){
 											if(arg != ""){
 												contents += '<parameter expr="' + xml_safe(arg) + '"/>\n';
 												contents += '<parameter expr="' + xml_safe(arg) + '"/>\n';
 											}
 											}
@@ -123,7 +138,7 @@
 									if(outgoing[state['$key']] == undefined){
 									if(outgoing[state['$key']] == undefined){
 										return "";
 										return "";
 									}
 									}
-									var transitions = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/transition'}).map(function(tid) {return as.nodes[tid]});
+									var transitions = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/transition';}).map(function(tid) {return as.nodes[tid];});
 									for (var tidx in transitions){
 									for (var tidx in transitions){
 										var transition = transitions[tidx];
 										var transition = transitions[tidx];
 										contents += "<transition ";
 										contents += "<transition ";
@@ -208,10 +223,10 @@
 											ocContain = [];
 											ocContain = [];
 									}
 									}
 									else{
 									else{
-										var containOC = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC'}).map(function(tid) {return as.nodes[tid]});
-										var contain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain'}).map(function(tid) {return as.nodes[tid]});
-										var ocContain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain'}).map(function(tid) {return as.nodes[tid]});
-										var history = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes'}).map(function(tid) {return as.nodes[tid]});
+										var containOC = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC';}).map(function(tid) {return as.nodes[tid];});
+										var contain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain';}).map(function(tid) {return as.nodes[tid];});
+										var ocContain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain';}).map(function(tid) {return as.nodes[tid];});
+										var history = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes';}).map(function(tid) {return as.nodes[tid];});
 									}
 									}
 									var s = as.nodes[state['$key']];
 									var s = as.nodes[state['$key']];
 									if (is_root){
 									if (is_root){
@@ -248,7 +263,7 @@
 										contents += '</state>\n';
 										contents += '</state>\n';
 									}
 									}
 									else {
 									else {
-										var history = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes'}).map(function(tid) {return as.nodes[tid]});
+										var history = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes';}).map(function(tid) {return as.nodes[tid];});
 										if (history.length > 0){
 										if (history.length > 0){
 											contents += '<history id="' + s['name']['value'] + '" type="' + s['type']['value'].trim() + '"/>\n';
 											contents += '<history id="' + s['name']['value'] + '" type="' + s['type']['value'].trim() + '"/>\n';
 										}
 										}
@@ -270,14 +285,14 @@
 										for (var e_key in as.edges) {
 										for (var e_key in as.edges) {
 											var e = as.edges[e_key];
 											var e = as.edges[e_key];
 											if (e['dest'] == key) {
 											if (e['dest'] == key) {
-												safe_add(incoming[key], e['src'])
+												safe_add(incoming[key], e['src']);
 												if (!(e['src'] in outgoing)) {
 												if (!(e['src'] in outgoing)) {
 													outgoing[e['src']] = [];
 													outgoing[e['src']] = [];
 												}
 												}
 												safe_add(outgoing[e['src']], key);
 												safe_add(outgoing[e['src']], key);
 											}
 											}
 											if (e['src'] == key) {
 											if (e['src'] == key) {
-												safe_add(outgoing[key], e['dest'])
+												safe_add(outgoing[key], e['dest']);
 												if (!(e['dest'] in incoming)) {
 												if (!(e['dest'] in incoming)) {
 													incoming[e['dest']] = [];
 													incoming[e['dest']] = [];
 												}
 												}
@@ -303,12 +318,12 @@
 									if(!external){
 									if(!external){
 										file_contents += '<class name="' + node['name']['value'] + '" default="true">\n';
 										file_contents += '<class name="' + node['name']['value'] + '" default="true">\n';
 										file_contents += '\t<relationships>\n';
 										file_contents += '\t<relationships>\n';
-										inheritances = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Inheritance'}).map(function(tid) {return as.nodes[tid]});
+										inheritances = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Inheritance';}).map(function(tid) {return as.nodes[tid];});
 										for (var iidx in inheritances){
 										for (var iidx in inheritances){
 											target = as.nodes[outgoing[inheritances[iidx]['$key']][0]];
 											target = as.nodes[outgoing[inheritances[iidx]['$key']][0]];
 											file_contents += '\t\t<inheritance class="' + target['name']['value'] + '"/>\n';
 											file_contents += '\t\t<inheritance class="' + target['name']['value'] + '"/>\n';
 										}
 										}
-										associations = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Association'}).map(function(tid) {return as.nodes[tid]});
+										associations = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Association';}).map(function(tid) {return as.nodes[tid];});
 										for (var iidx in associations){
 										for (var iidx in associations){
 											target = as.nodes[outgoing[associations[iidx]['$key']][0]];
 											target = as.nodes[outgoing[associations[iidx]['$key']][0]];
 											file_contents += '\t\t<association name="' + associations[iidx]['name']['value'] + '" class="' + target['name']['value'] + '"/>\n';
 											file_contents += '\t\t<association name="' + associations[iidx]['name']['value'] + '" class="' + target['name']['value'] + '"/>\n';
@@ -333,7 +348,7 @@
 											file_contents += '\t</method>\n';
 											file_contents += '\t</method>\n';
 										}
 										}
 										
 										
-										var behaviour = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/behaviour'}).map(function(tid) {return as.nodes[tid]});
+										var behaviour = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/behaviour';}).map(function(tid) {return as.nodes[tid];});
 										var statechart = as.nodes[outgoing[behaviour[0]['$key']][0]];
 										var statechart = as.nodes[outgoing[behaviour[0]['$key']][0]];
 										file_contents += recursive(statechart, true);
 										file_contents += recursive(statechart, true);
 										file_contents += '</class>\n';
 										file_contents += '</class>\n';
@@ -348,7 +363,7 @@
 					);
 					);
 				},
 				},
 				function(err) {__postInternalErrorMsg(resp, err);}
 				function(err) {__postInternalErrorMsg(resp, err);}
-			)
+			);
 		},
 		},
 
 
 	'asworker'		: 
 	'asworker'		: 
@@ -359,4 +374,4 @@
 					{'statusCode':200, 
 					{'statusCode':200, 
 					 'respIndex':resp});
 					 'respIndex':resp});
 		}
 		}
-}
+};

+ 36 - 20
plugins/exporttosccdxml_debug.js

@@ -1,5 +1,21 @@
 /* SCCDXML exporter plugin*/
 /* SCCDXML exporter plugin*/
-{
+const {
+    __errorContinuable,
+    __httpReq,
+    __wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _mmmk = require("../mmmk");
+const _fs = _do.convert(require('fs'), ['readFile', 'writeFile', 'readdir']);
+const _fspp	= _do.convert(require('../___fs++'), ['mkdirs']);
+
+module.exports = {
 	'interfaces'	: [{'method':'POST', 'url=':'/exporttosccdxml_debug'}],
 	'interfaces'	: [{'method':'POST', 'url=':'/exporttosccdxml_debug'}],
 	'csworker'		: 
 	'csworker'		: 
         function(resp,method,uri,reqData,wcontext)
         function(resp,method,uri,reqData,wcontext)
@@ -41,7 +57,7 @@
 								}
 								}
 								
 								
 								function find_initial(state){
 								function find_initial(state){
-									var substates = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain'}).map(function(tid) {return as.nodes[tid]});
+									var substates = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain';}).map(function(tid) {return as.nodes[tid];});
 									for (var sidx in substates){
 									for (var sidx in substates){
 										var substate = as.nodes[outgoing[substates[sidx]['$key']]];
 										var substate = as.nodes[outgoing[substates[sidx]['$key']]];
 										if(substate['isStart']['value']){
 										if(substate['isStart']['value']){
@@ -51,7 +67,7 @@
 								}
 								}
 								
 								
 								function get_full_path(state){
 								function get_full_path(state){
-									var parent_link = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes'}).map(function(tid) {return as.nodes[tid]})[0];
+									var parent_link = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC' || as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes';}).map(function(tid) {return as.nodes[tid];})[0];
 									if (parent_link != undefined){
 									if (parent_link != undefined){
 										var parent = as.nodes[incoming[parent_link['$key']][0]];
 										var parent = as.nodes[incoming[parent_link['$key']][0]];
 										return get_full_path(parent).concat([state['name']['value']]);
 										return get_full_path(parent).concat([state['name']['value']]);
@@ -93,7 +109,7 @@
 								}
 								}
 								
 								
 								function write_raise(lst){
 								function write_raise(lst){
-									contents = "";
+									let contents = "";
 									for(var ridx in lst){
 									for(var ridx in lst){
 										var r = lst[ridx];
 										var r = lst[ridx];
 										contents += '<raise event="' + r['event'] + '"';
 										contents += '<raise event="' + r['event'] + '"';
@@ -106,9 +122,9 @@
 										else{
 										else{
 											contents += ' scope="' + r['scope'] + '">\n';
 											contents += ' scope="' + r['scope'] + '">\n';
 										}
 										}
-										arguments = r['arguments'];
-										for (var aidx in arguments){
-											var arg = arguments[aidx];
+										let args = r['arguments'];
+										for (var aidx in args){
+											var arg = args[aidx];
 											if(arg != ""){
 											if(arg != ""){
 												contents += '<parameter expr="' + xml_safe(arg) + '"/>\n';
 												contents += '<parameter expr="' + xml_safe(arg) + '"/>\n';
 											}
 											}
@@ -123,7 +139,7 @@
 									if(outgoing[state['$key']] == undefined){
 									if(outgoing[state['$key']] == undefined){
 										return "";
 										return "";
 									}
 									}
-									var transitions = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/transition'}).map(function(tid) {return as.nodes[tid]});
+									var transitions = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/transition';}).map(function(tid) {return as.nodes[tid];});
 									for (var tidx in transitions){
 									for (var tidx in transitions){
 										var transition = transitions[tidx];
 										var transition = transitions[tidx];
 										contents += "<transition ";
 										contents += "<transition ";
@@ -238,10 +254,10 @@
 											ocContain = [];
 											ocContain = [];
 									}
 									}
 									else{
 									else{
-										var containOC = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC'}).map(function(tid) {return as.nodes[tid]});
-										var contain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain'}).map(function(tid) {return as.nodes[tid]});
-										var ocContain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain'}).map(function(tid) {return as.nodes[tid]});
-										var history = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes'}).map(function(tid) {return as.nodes[tid]});
+										var containOC = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/containOC';}).map(function(tid) {return as.nodes[tid];});
+										var contain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/contain';}).map(function(tid) {return as.nodes[tid];});
+										var ocContain = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/ocContain';}).map(function(tid) {return as.nodes[tid];});
+										var history = outgoing[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes';}).map(function(tid) {return as.nodes[tid];});
 									}
 									}
 									var s = as.nodes[state['$key']];
 									var s = as.nodes[state['$key']];
 									if (is_root){
 									if (is_root){
@@ -278,7 +294,7 @@
 										contents += '</state>\n';
 										contents += '</state>\n';
 									}
 									}
 									else {
 									else {
-										var history = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes'}).map(function(tid) {return as.nodes[tid]});
+										var history = incoming[state['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/includes';}).map(function(tid) {return as.nodes[tid];});
 										if (history.length > 0){
 										if (history.length > 0){
 											contents += '<history id="' + s['name']['value'] + '" type="' + s['type']['value'].trim() + '"/>\n';
 											contents += '<history id="' + s['name']['value'] + '" type="' + s['type']['value'].trim() + '"/>\n';
 										}
 										}
@@ -300,14 +316,14 @@
 										for (var e_key in as.edges) {
 										for (var e_key in as.edges) {
 											var e = as.edges[e_key];
 											var e = as.edges[e_key];
 											if (e['dest'] == key) {
 											if (e['dest'] == key) {
-												safe_add(incoming[key], e['src'])
+												safe_add(incoming[key], e['src']);
 												if (!(e['src'] in outgoing)) {
 												if (!(e['src'] in outgoing)) {
 													outgoing[e['src']] = [];
 													outgoing[e['src']] = [];
 												}
 												}
 												safe_add(outgoing[e['src']], key);
 												safe_add(outgoing[e['src']], key);
 											}
 											}
 											if (e['src'] == key) {
 											if (e['src'] == key) {
-												safe_add(outgoing[key], e['dest'])
+												safe_add(outgoing[key], e['dest']);
 												if (!(e['dest'] in incoming)) {
 												if (!(e['dest'] in incoming)) {
 													incoming[e['dest']] = [];
 													incoming[e['dest']] = [];
 												}
 												}
@@ -333,12 +349,12 @@
 									if(!external){
 									if(!external){
 										file_contents += '<class name="' + node['name']['value'] + '" default="true">\n';
 										file_contents += '<class name="' + node['name']['value'] + '" default="true">\n';
 										file_contents += '\t<relationships>\n';
 										file_contents += '\t<relationships>\n';
-										inheritances = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Inheritance'}).map(function(tid) {return as.nodes[tid]});
+										inheritances = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Inheritance';}).map(function(tid) {return as.nodes[tid];});
 										for (var iidx in inheritances){
 										for (var iidx in inheritances){
 											target = as.nodes[outgoing[inheritances[iidx]['$key']][0]];
 											target = as.nodes[outgoing[inheritances[iidx]['$key']][0]];
 											file_contents += '\t\t<inheritance class="' + target['name']['value'] + '"/>\n';
 											file_contents += '\t\t<inheritance class="' + target['name']['value'] + '"/>\n';
 										}
 										}
-										associations = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Association'}).map(function(tid) {return as.nodes[tid]});
+										associations = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/Association';}).map(function(tid) {return as.nodes[tid];});
 										for (var iidx in associations){
 										for (var iidx in associations){
 											target = as.nodes[outgoing[associations[iidx]['$key']][0]];
 											target = as.nodes[outgoing[associations[iidx]['$key']][0]];
 											file_contents += '\t\t<association name="' + associations[iidx]['name']['value'] + '" class="' + target['name']['value'] + '"/>\n';
 											file_contents += '\t\t<association name="' + associations[iidx]['name']['value'] + '" class="' + target['name']['value'] + '"/>\n';
@@ -374,7 +390,7 @@
 											file_contents += '\t</method>\n';
 											file_contents += '\t</method>\n';
 										}
 										}
 										
 										
-										var behaviour = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/behaviour'}).map(function(tid) {return as.nodes[tid]});
+										var behaviour = outgoing[node['$key']].filter(function(el) {return as.nodes[el]['$type'] == '/Formalisms/SCCD/SCCD/behaviour';}).map(function(tid) {return as.nodes[tid];});
 										var statechart = as.nodes[outgoing[behaviour[0]['$key']][0]];
 										var statechart = as.nodes[outgoing[behaviour[0]['$key']][0]];
 										file_contents += recursive(statechart, true);
 										file_contents += recursive(statechart, true);
 										file_contents += '</class>\n';
 										file_contents += '</class>\n';
@@ -389,7 +405,7 @@
 					);
 					);
 				},
 				},
 				function(err) {__postInternalErrorMsg(resp, err);}
 				function(err) {__postInternalErrorMsg(resp, err);}
-			)
+			);
 		},
 		},
 
 
 	'asworker'		: 
 	'asworker'		: 
@@ -400,4 +416,4 @@
 					{'statusCode':200, 
 					{'statusCode':200, 
 					 'respIndex':resp});
 					 'respIndex':resp});
 		}
 		}
-}
+};

+ 14 - 2
plugins/helloworld.js

@@ -1,5 +1,17 @@
 /* a simple hello world plugin... it listens for "POST /hello" requests... requests are received by "csworker" and forwarded to "asworker"... both respond with their __worker\'s id and with a counter of the number of handled requests */
 /* a simple hello world plugin... it listens for "POST /hello" requests... requests are received by "csworker" and forwarded to "asworker"... both respond with their __worker\'s id and with a counter of the number of handled requests */
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+
+module.exports = {
 	'interfaces'	: [{'method':'POST', 'url=':'/hello'}],
 	'interfaces'	: [{'method':'POST', 'url=':'/hello'}],
 
 
 
 
@@ -40,4 +52,4 @@
 					 'sequence#':__sequenceNumber(),
 					 'sequence#':__sequenceNumber(),
 					 'respIndex':resp});
 					 'respIndex':resp});
 		}
 		}
-}
+};

+ 14 - 2
plugins/helloworld2.js

@@ -1,5 +1,17 @@
 /* a more advanced hello world plugin... it listens for "POST /hello.cs", "POST /hello.as" and "POST /hello" requests... "POST /hello.cs" requests are received and handled by "csworker"... "POST /hello.as" requests are received by "csworker" and forwarded to "asworker" for handling... "POST /hello" requests trigger a misuse error */
 /* a more advanced hello world plugin... it listens for "POST /hello.cs", "POST /hello.as" and "POST /hello" requests... "POST /hello.cs" requests are received and handled by "csworker"... "POST /hello.as" requests are received by "csworker" and forwarded to "asworker" for handling... "POST /hello" requests trigger a misuse error */
-{
+const {
+    __errorContinuable,
+    __httpReq,
+    __wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+
+module.exports = {
 	'interfaces'	: 
 	'interfaces'	: 
 		[{'method':'POST', 'urlm':'^/hello\.[ac]s$'},
 		[{'method':'POST', 'urlm':'^/hello\.[ac]s$'},
 		 {'method':'POST', 'url=':'/hello'}],
 		 {'method':'POST', 'url=':'/hello'}],
@@ -52,5 +64,5 @@
 					 'sequence#':__sequenceNumber(),
 					 'sequence#':__sequenceNumber(),
 					 'respIndex':resp});
 					 'respIndex':resp});
 		}
 		}
-}
+};
 
 

+ 17 - 3
plugins/model_stats.js

@@ -1,5 +1,19 @@
 /* a simple plugin that outputs some general information about a model... the point here is to demo how to use _mmmk from a plugin */
 /* a simple plugin that outputs some general information about a model... the point here is to demo how to use _mmmk from a plugin */
-{
+const {
+    __errorContinuable,
+    __httpReq,
+	__wHttpReq,
+    __postInternalErrorMsg, __postMessage,
+    __sequenceNumber,
+    __successContinuable,
+	__uri_to_id
+} = require("../__worker");
+
+const _do = require("../___do");
+const _utils = require('../utils');
+const _mmmk = require("../mmmk");
+
+module.exports = {
 	'interfaces'	: [{'method':'GET', 'url=':'/stats'}],
 	'interfaces'	: [{'method':'GET', 'url=':'/stats'}],
 
 
 
 
@@ -11,7 +25,7 @@
 		{
 		{
 			var model = _utils.jsonp(_mmmk.read()),
 			var model = _utils.jsonp(_mmmk.read()),
 				 t2i	 = {};
 				 t2i	 = {};
-console.warn(model, typeof(model))			
+			console.warn(model, typeof(model));
 			for( var id in model.nodes )
 			for( var id in model.nodes )
 			{
 			{
 				var node = model.nodes[id];
 				var node = model.nodes[id];
@@ -54,6 +68,6 @@ console.warn(model, typeof(model))
   					 'sequence#':__sequenceNumber(),
   					 'sequence#':__sequenceNumber(),
 					 'respIndex':resp});
 					 'respIndex':resp});
 		}
 		}
-}
+};
 
 
 
 

+ 1 - 1
tests/test_utils.js

@@ -102,7 +102,7 @@ function callback(client, load_function, files_to_skip) {
             //console.log(filenames);
             //console.log(filenames);
             load_function(client, filenames);
             load_function(client, filenames);
         }
         }
-    }
+    };
 }
 }
 
 
 module.exports = {
 module.exports = {

+ 1 - 1
types.js

@@ -15,4 +15,4 @@ __specialTypes = {
 	'$ARG':'map<[name,type],[string,string]>',
 	'$ARG':'map<[name,type],[string,string]>',
 	
 	
 	'$METHOD':'map<[name,args,returntype,body],[string,list<$ARG>,string,code]>'
 	'$METHOD':'map<[name,args,returntype,body],[string,list<$ARG>,string,code]>'
-}
+};

+ 5 - 5
utils.js

@@ -298,7 +298,7 @@ utils.createCookie =
 		}
 		}
 		else var expires = "";
 		else var expires = "";
 		document.cookie = name+"="+value+expires+"; path=/";
 		document.cookie = name+"="+value+expires+"; path=/";
-	}
+	};
 
 
 /* returns the value of the cookie with given name */
 /* returns the value of the cookie with given name */
 utils.readCookie =
 utils.readCookie =
@@ -311,13 +311,13 @@ utils.readCookie =
 			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 		}
 		}
 		return null;
 		return null;
-	}
+	};
 
 
 /* erases the cookie with given name */
 /* erases the cookie with given name */
 utils.eraseCookie =
 utils.eraseCookie =
 	function(name) {
 	function(name) {
 		createCookie(name,"",-1);
 		createCookie(name,"",-1);
-	}
+	};
 	
 	
 __pendingCalls = {};
 __pendingCalls = {};
 
 
@@ -334,7 +334,7 @@ utils.doAfterUnlessRepeated =
 			clearTimeout(__pendingCalls[func]);
 			clearTimeout(__pendingCalls[func]);
 		}
 		}
 		__pendingCalls[func] = setTimeout(doIt, ms);
 		__pendingCalls[func] = setTimeout(doIt, ms);
-	}
+	};
 
 
 /* NOTE: 'exports' exists in back-end 'require', but not in browser import...
 /* NOTE: 'exports' exists in back-end 'require', but not in browser import...
 			this ensures no errors are reported during browser imports */
 			this ensures no errors are reported during browser imports */
@@ -367,4 +367,4 @@ exports.values 						= utils.values;
 exports.createCookie				= utils.createCookie;
 exports.createCookie				= utils.createCookie;
 exports.readCookie					= utils.readCookie;
 exports.readCookie					= utils.readCookie;
 exports.eraseCookie					= utils.eraseCookie;
 exports.eraseCookie					= utils.eraseCookie;
-exports.doAfterUnlessRepeated		= utils.doAfterUnlessRepeated
+exports.doAfterUnlessRepeated		= utils.doAfterUnlessRepeated;