Jean-Yves Didier

use of terser as an API

......@@ -59,11 +59,8 @@ module.exports = function (grunt) {
}
}
},
obfuscator: {
terser: {
build: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'build/arcs.min.js': [
'build/arcs.js'
......@@ -90,7 +87,7 @@ module.exports = function (grunt) {
}
},
concat: {
concat: {
dist: {
src: [
'src/arcs.js',
......@@ -122,22 +119,21 @@ module.exports = function (grunt) {
dest: 'build/arcseditor.js'
}
}
}
});
// Load the plugin that provides the "uglify" task.
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-obfuscator');
grunt.loadNpmTasks('grunt-file-minify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-terser');
grunt.loadNpmTasks('grunt-bower-task');
// Default task(s).
grunt.registerTask('default', ['concat',/*'file_minify','obfuscator'*/]);
// Default task(s).
grunt.registerTask('default', ['concat','terser'/*'file_minify','obfuscator'*/]);
grunt.registerTask('lint', ['jslint']);
grunt.registerTask('doc', ['jsdoc']);
};
......
......@@ -233,7 +233,7 @@ ARCS.Context = function( ctx ) {
var constants = {};
var factories = {};
var libraries = [];
var depLibPromises=[];
//var depLibPromises=[];
var self = this;
var loadLibraries;
var loadDataFile;
......@@ -283,13 +283,13 @@ ARCS.Context = function( ctx ) {
};
//! TODO not needed anymore?
this.addLibraryPromise = function(p) {
/*this.addLibraryPromise = function(p) {
depLibPromises.push(p);
};
};*/
promiseLibrary = function(libName) {
/*promiseLibrary = function(libName) {
return import(libName);
};
};*/
//! TODO modify loadLibraries and loadLibrary to directly register
// factories so that arcs_module is not needed anymore ?
......@@ -302,7 +302,8 @@ ARCS.Context = function( ctx ) {
var res=[];
for(i=0; i < libraries.length; i++) {
//! TODO
res.push(import(libraries[i]));
res.push(loadLibrary(libraries[i]));
//import(libraries[i]));
}
return Promise.all(res);
};
......@@ -369,7 +370,15 @@ ARCS.Context = function( ctx ) {
}
libraries.push(libActualName);
promiseLibrary(libUrl).then( function() {
// TODO promisify call to cbFunction
return import(libUrl).then( function(module) {
// TODO insert here component factories
for (p in module) {
if (module.hasOwnProperty(p)) {
ARCS.Context.currentContext.setFactory(p,module[p]);
}
}
if (cbFunction !== undefined) {
cbFunction();
}
......@@ -491,9 +500,8 @@ ARCS.Context = function( ctx ) {
// this should return a promise !
this.instanciate = function () {
//! TODO
return loadLibraries().then(function() { return Promise.all(depLibPromises); })
.then(instanciateComponents)
.catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); });
return loadLibraries().then(instanciateComponents)
.catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); });
};
......
This diff is collapsed. Click to expand it.
......@@ -17,6 +17,7 @@
"grunt": ">=0.4.5",
"grunt-jslint": ">=1.1.12",
"grunt-contrib-obfuscator": "*",
"grunt-terser": "*",
"grunt-file-minify": ">=1.0.0",
"grunt-jsdoc": ">=0.5.6",
"grunt-bower-task": ">=0.4.0",
......
#!/usr/bin/env node
#!/usr/bin/env node --experimental-modules --experimental-json modules
var ARCS = require('./arcs.js');
var application = require('./appli.json');
import ARCS from './arcs.js';
import application from './appli.json';
var aap = new ARCS.Application();
aap.import(application);
aap.start();
......
......@@ -9,7 +9,7 @@ ARCS.Context = function( ctx ) {
var constants = {};
var factories = {};
var libraries = [];
var depLibPromises=[];
//var depLibPromises=[];
var self = this;
var loadLibraries;
var loadDataFile;
......@@ -59,13 +59,13 @@ ARCS.Context = function( ctx ) {
};
//! TODO not needed anymore?
this.addLibraryPromise = function(p) {
/*this.addLibraryPromise = function(p) {
depLibPromises.push(p);
};
};*/
promiseLibrary = function(libName) {
/*promiseLibrary = function(libName) {
return import(libName);
};
};*/
//! TODO modify loadLibraries and loadLibrary to directly register
// factories so that arcs_module is not needed anymore ?
......@@ -78,7 +78,8 @@ ARCS.Context = function( ctx ) {
var res=[];
for(i=0; i < libraries.length; i++) {
//! TODO
res.push(import(libraries[i]));
res.push(loadLibrary(libraries[i]));
//import(libraries[i]));
}
return Promise.all(res);
};
......@@ -145,7 +146,15 @@ ARCS.Context = function( ctx ) {
}
libraries.push(libActualName);
promiseLibrary(libUrl).then( function() {
// TODO promisify call to cbFunction
return import(libUrl).then( function(module) {
// TODO insert here component factories
for (p in module) {
if (module.hasOwnProperty(p)) {
ARCS.Context.currentContext.setFactory(p,module[p]);
}
}
if (cbFunction !== undefined) {
cbFunction();
}
......@@ -267,9 +276,8 @@ ARCS.Context = function( ctx ) {
// this should return a promise !
this.instanciate = function () {
//! TODO
return loadLibraries().then(function() { return Promise.all(depLibPromises); })
.then(instanciateComponents)
.catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); });
return loadLibraries().then(instanciateComponents)
.catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); });
};
......