Toggle navigation
Toggle navigation
This project
Loading...
Sign in
arcs
/
arcs.js
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Yves Didier
2019-12-10 14:42:04 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f8383e1225a718c1457a5042ebd177df187cfa2e
f8383e12
1 parent
64aa25fb
use of terser as an API
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
30 deletions
Gruntfile.js
build/arcs.js
build/arcs.min.js
package.json
src/arcs_node.js
src/context.js
Gruntfile.js
View file @
f8383e1
...
...
@@ -59,11 +59,8 @@ module.exports = function (grunt) {
}
}
},
obfuscato
r
:
{
terse
r
:
{
build
:
{
options
:
{
banner
:
'/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files
:
{
'build/arcs.min.js'
:
[
'build/arcs.js'
...
...
@@ -124,20 +121,19 @@ module.exports = function (grunt) {
}
});
// 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'
]);
};
...
...
build/arcs.js
View file @
f8383e1
...
...
@@ -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,8 +500,7 @@ ARCS.Context = function( ctx ) {
// this should return a promise !
this
.
instanciate
=
function
()
{
//! TODO
return
loadLibraries
().
then
(
function
()
{
return
Promise
.
all
(
depLibPromises
);
})
.
then
(
instanciateComponents
)
return
loadLibraries
().
then
(
instanciateComponents
)
.
catch
(
function
(
msg
)
{
console
.
log
(
"[ARCS] Trouble instanciating context"
,
msg
);
});
};
...
...
build/arcs.min.js
View file @
f8383e1
This diff is collapsed. Click to expand it.
package.json
View file @
f8383e1
...
...
@@ -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"
,
...
...
src/arcs_node.js
View file @
f8383e1
#!/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
();
...
...
src/context.js
View file @
f8383e1
...
...
@@ -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,8 +276,7 @@ ARCS.Context = function( ctx ) {
// this should return a promise !
this
.
instanciate
=
function
()
{
//! TODO
return
loadLibraries
().
then
(
function
()
{
return
Promise
.
all
(
depLibPromises
);
})
.
then
(
instanciateComponents
)
return
loadLibraries
().
then
(
instanciateComponents
)
.
catch
(
function
(
msg
)
{
console
.
log
(
"[ARCS] Trouble instanciating context"
,
msg
);
});
};
...
...
Please
register
or
login
to post a comment