Showing
6 changed files
with
47 additions
and
34 deletions
... | @@ -59,11 +59,8 @@ module.exports = function (grunt) { | ... | @@ -59,11 +59,8 @@ module.exports = function (grunt) { |
59 | } | 59 | } |
60 | } | 60 | } |
61 | }, | 61 | }, |
62 | - obfuscator: { | 62 | + terser: { |
63 | build: { | 63 | build: { |
64 | - options: { | ||
65 | - banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' | ||
66 | - }, | ||
67 | files: { | 64 | files: { |
68 | 'build/arcs.min.js': [ | 65 | 'build/arcs.min.js': [ |
69 | 'build/arcs.js' | 66 | 'build/arcs.js' |
... | @@ -90,7 +87,7 @@ module.exports = function (grunt) { | ... | @@ -90,7 +87,7 @@ module.exports = function (grunt) { |
90 | } | 87 | } |
91 | 88 | ||
92 | }, | 89 | }, |
93 | - concat: { | 90 | + concat: { |
94 | dist: { | 91 | dist: { |
95 | src: [ | 92 | src: [ |
96 | 'src/arcs.js', | 93 | 'src/arcs.js', |
... | @@ -122,22 +119,21 @@ module.exports = function (grunt) { | ... | @@ -122,22 +119,21 @@ module.exports = function (grunt) { |
122 | dest: 'build/arcseditor.js' | 119 | dest: 'build/arcseditor.js' |
123 | } | 120 | } |
124 | 121 | ||
125 | - } | 122 | + } |
126 | 123 | ||
127 | - | ||
128 | }); | 124 | }); |
129 | 125 | ||
130 | -// Load the plugin that provides the "uglify" task. | 126 | + // Load the plugin that provides the "uglify" task. |
131 | grunt.loadNpmTasks('grunt-contrib-obfuscator'); | 127 | grunt.loadNpmTasks('grunt-contrib-obfuscator'); |
132 | grunt.loadNpmTasks('grunt-file-minify'); | 128 | grunt.loadNpmTasks('grunt-file-minify'); |
133 | grunt.loadNpmTasks('grunt-contrib-concat'); | 129 | grunt.loadNpmTasks('grunt-contrib-concat'); |
134 | grunt.loadNpmTasks('grunt-jsdoc'); | 130 | grunt.loadNpmTasks('grunt-jsdoc'); |
135 | grunt.loadNpmTasks('grunt-jslint'); | 131 | grunt.loadNpmTasks('grunt-jslint'); |
132 | + grunt.loadNpmTasks('grunt-terser'); | ||
136 | grunt.loadNpmTasks('grunt-bower-task'); | 133 | grunt.loadNpmTasks('grunt-bower-task'); |
137 | 134 | ||
138 | - | 135 | + // Default task(s). |
139 | -// Default task(s). | 136 | + grunt.registerTask('default', ['concat','terser'/*'file_minify','obfuscator'*/]); |
140 | - grunt.registerTask('default', ['concat',/*'file_minify','obfuscator'*/]); | ||
141 | grunt.registerTask('lint', ['jslint']); | 137 | grunt.registerTask('lint', ['jslint']); |
142 | grunt.registerTask('doc', ['jsdoc']); | 138 | grunt.registerTask('doc', ['jsdoc']); |
143 | }; | 139 | }; | ... | ... |
... | @@ -233,7 +233,7 @@ ARCS.Context = function( ctx ) { | ... | @@ -233,7 +233,7 @@ ARCS.Context = function( ctx ) { |
233 | var constants = {}; | 233 | var constants = {}; |
234 | var factories = {}; | 234 | var factories = {}; |
235 | var libraries = []; | 235 | var libraries = []; |
236 | - var depLibPromises=[]; | 236 | + //var depLibPromises=[]; |
237 | var self = this; | 237 | var self = this; |
238 | var loadLibraries; | 238 | var loadLibraries; |
239 | var loadDataFile; | 239 | var loadDataFile; |
... | @@ -283,13 +283,13 @@ ARCS.Context = function( ctx ) { | ... | @@ -283,13 +283,13 @@ ARCS.Context = function( ctx ) { |
283 | }; | 283 | }; |
284 | 284 | ||
285 | //! TODO not needed anymore? | 285 | //! TODO not needed anymore? |
286 | - this.addLibraryPromise = function(p) { | 286 | + /*this.addLibraryPromise = function(p) { |
287 | depLibPromises.push(p); | 287 | depLibPromises.push(p); |
288 | - }; | 288 | + };*/ |
289 | 289 | ||
290 | - promiseLibrary = function(libName) { | 290 | + /*promiseLibrary = function(libName) { |
291 | return import(libName); | 291 | return import(libName); |
292 | - }; | 292 | + };*/ |
293 | 293 | ||
294 | //! TODO modify loadLibraries and loadLibrary to directly register | 294 | //! TODO modify loadLibraries and loadLibrary to directly register |
295 | // factories so that arcs_module is not needed anymore ? | 295 | // factories so that arcs_module is not needed anymore ? |
... | @@ -302,7 +302,8 @@ ARCS.Context = function( ctx ) { | ... | @@ -302,7 +302,8 @@ ARCS.Context = function( ctx ) { |
302 | var res=[]; | 302 | var res=[]; |
303 | for(i=0; i < libraries.length; i++) { | 303 | for(i=0; i < libraries.length; i++) { |
304 | //! TODO | 304 | //! TODO |
305 | - res.push(import(libraries[i])); | 305 | + res.push(loadLibrary(libraries[i])); |
306 | + //import(libraries[i])); | ||
306 | } | 307 | } |
307 | return Promise.all(res); | 308 | return Promise.all(res); |
308 | }; | 309 | }; |
... | @@ -369,7 +370,15 @@ ARCS.Context = function( ctx ) { | ... | @@ -369,7 +370,15 @@ ARCS.Context = function( ctx ) { |
369 | } | 370 | } |
370 | 371 | ||
371 | libraries.push(libActualName); | 372 | libraries.push(libActualName); |
372 | - promiseLibrary(libUrl).then( function() { | 373 | + // TODO promisify call to cbFunction |
374 | + return import(libUrl).then( function(module) { | ||
375 | + // TODO insert here component factories | ||
376 | + for (p in module) { | ||
377 | + if (module.hasOwnProperty(p)) { | ||
378 | + ARCS.Context.currentContext.setFactory(p,module[p]); | ||
379 | + } | ||
380 | + } | ||
381 | + | ||
373 | if (cbFunction !== undefined) { | 382 | if (cbFunction !== undefined) { |
374 | cbFunction(); | 383 | cbFunction(); |
375 | } | 384 | } |
... | @@ -491,9 +500,8 @@ ARCS.Context = function( ctx ) { | ... | @@ -491,9 +500,8 @@ ARCS.Context = function( ctx ) { |
491 | // this should return a promise ! | 500 | // this should return a promise ! |
492 | this.instanciate = function () { | 501 | this.instanciate = function () { |
493 | //! TODO | 502 | //! TODO |
494 | - return loadLibraries().then(function() { return Promise.all(depLibPromises); }) | 503 | + return loadLibraries().then(instanciateComponents) |
495 | - .then(instanciateComponents) | 504 | + .catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); }); |
496 | - .catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); }); | ||
497 | 505 | ||
498 | }; | 506 | }; |
499 | 507 | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
17 | "grunt": ">=0.4.5", | 17 | "grunt": ">=0.4.5", |
18 | "grunt-jslint": ">=1.1.12", | 18 | "grunt-jslint": ">=1.1.12", |
19 | "grunt-contrib-obfuscator": "*", | 19 | "grunt-contrib-obfuscator": "*", |
20 | + "grunt-terser": "*", | ||
20 | "grunt-file-minify": ">=1.0.0", | 21 | "grunt-file-minify": ">=1.0.0", |
21 | "grunt-jsdoc": ">=0.5.6", | 22 | "grunt-jsdoc": ">=0.5.6", |
22 | "grunt-bower-task": ">=0.4.0", | 23 | "grunt-bower-task": ">=0.4.0", | ... | ... |
1 | -#!/usr/bin/env node | 1 | +#!/usr/bin/env node --experimental-modules --experimental-json modules |
2 | 2 | ||
3 | -var ARCS = require('./arcs.js'); | 3 | +import ARCS from './arcs.js'; |
4 | -var application = require('./appli.json'); | 4 | +import application from './appli.json'; |
5 | var aap = new ARCS.Application(); | 5 | var aap = new ARCS.Application(); |
6 | aap.import(application); | 6 | aap.import(application); |
7 | aap.start(); | 7 | aap.start(); | ... | ... |
... | @@ -9,7 +9,7 @@ ARCS.Context = function( ctx ) { | ... | @@ -9,7 +9,7 @@ ARCS.Context = function( ctx ) { |
9 | var constants = {}; | 9 | var constants = {}; |
10 | var factories = {}; | 10 | var factories = {}; |
11 | var libraries = []; | 11 | var libraries = []; |
12 | - var depLibPromises=[]; | 12 | + //var depLibPromises=[]; |
13 | var self = this; | 13 | var self = this; |
14 | var loadLibraries; | 14 | var loadLibraries; |
15 | var loadDataFile; | 15 | var loadDataFile; |
... | @@ -59,13 +59,13 @@ ARCS.Context = function( ctx ) { | ... | @@ -59,13 +59,13 @@ ARCS.Context = function( ctx ) { |
59 | }; | 59 | }; |
60 | 60 | ||
61 | //! TODO not needed anymore? | 61 | //! TODO not needed anymore? |
62 | - this.addLibraryPromise = function(p) { | 62 | + /*this.addLibraryPromise = function(p) { |
63 | depLibPromises.push(p); | 63 | depLibPromises.push(p); |
64 | - }; | 64 | + };*/ |
65 | 65 | ||
66 | - promiseLibrary = function(libName) { | 66 | + /*promiseLibrary = function(libName) { |
67 | return import(libName); | 67 | return import(libName); |
68 | - }; | 68 | + };*/ |
69 | 69 | ||
70 | //! TODO modify loadLibraries and loadLibrary to directly register | 70 | //! TODO modify loadLibraries and loadLibrary to directly register |
71 | // factories so that arcs_module is not needed anymore ? | 71 | // factories so that arcs_module is not needed anymore ? |
... | @@ -78,7 +78,8 @@ ARCS.Context = function( ctx ) { | ... | @@ -78,7 +78,8 @@ ARCS.Context = function( ctx ) { |
78 | var res=[]; | 78 | var res=[]; |
79 | for(i=0; i < libraries.length; i++) { | 79 | for(i=0; i < libraries.length; i++) { |
80 | //! TODO | 80 | //! TODO |
81 | - res.push(import(libraries[i])); | 81 | + res.push(loadLibrary(libraries[i])); |
82 | + //import(libraries[i])); | ||
82 | } | 83 | } |
83 | return Promise.all(res); | 84 | return Promise.all(res); |
84 | }; | 85 | }; |
... | @@ -145,7 +146,15 @@ ARCS.Context = function( ctx ) { | ... | @@ -145,7 +146,15 @@ ARCS.Context = function( ctx ) { |
145 | } | 146 | } |
146 | 147 | ||
147 | libraries.push(libActualName); | 148 | libraries.push(libActualName); |
148 | - promiseLibrary(libUrl).then( function() { | 149 | + // TODO promisify call to cbFunction |
150 | + return import(libUrl).then( function(module) { | ||
151 | + // TODO insert here component factories | ||
152 | + for (p in module) { | ||
153 | + if (module.hasOwnProperty(p)) { | ||
154 | + ARCS.Context.currentContext.setFactory(p,module[p]); | ||
155 | + } | ||
156 | + } | ||
157 | + | ||
149 | if (cbFunction !== undefined) { | 158 | if (cbFunction !== undefined) { |
150 | cbFunction(); | 159 | cbFunction(); |
151 | } | 160 | } |
... | @@ -267,9 +276,8 @@ ARCS.Context = function( ctx ) { | ... | @@ -267,9 +276,8 @@ ARCS.Context = function( ctx ) { |
267 | // this should return a promise ! | 276 | // this should return a promise ! |
268 | this.instanciate = function () { | 277 | this.instanciate = function () { |
269 | //! TODO | 278 | //! TODO |
270 | - return loadLibraries().then(function() { return Promise.all(depLibPromises); }) | 279 | + return loadLibraries().then(instanciateComponents) |
271 | - .then(instanciateComponents) | 280 | + .catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); }); |
272 | - .catch(function(msg) { console.log("[ARCS] Trouble instanciating context", msg); }); | ||
273 | 281 | ||
274 | }; | 282 | }; |
275 | 283 | ... | ... |
-
Please register or login to post a comment