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
2021-08-29 21:47:22 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
64ca04ff1299a995330f17aae0248805bc3689c6
64ca04ff
1 parent
2adc929b
finalized bundle creation from application description
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
44 deletions
build/arcs.js
build/arcs.min.js
build/arcs_browser.js
src/application.js
src/arcs_browser.js
src/arcsapp_bundler.js
src/context.js
tests/loop/loop_bundle.html
tests/loop/webpack.config.js
build/arcs.js
View file @
64ca04f
/******/
"use strict"
;
/******/
var
__webpack_modules__
=
([
/* 0 */
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
...
...
@@ -1264,16 +1265,17 @@ __webpack_require__.r(__webpack_exports__);
* @param ctx {object} an object representing data for the context.
*/
let
Context
=
function
(
ctx
)
{
var
components
=
{};
var
constants
=
{};
var
factories
=
{};
var
libraries
=
[];
let
components
=
{};
let
constants
=
{};
let
factories
=
{};
let
libraries
=
[];
//var depLibPromises=[];
var
self
=
this
;
let
self
=
this
;
var
loadLibraries
;
var
loadDataFile
;
var
promiseLibrary
;
var
instanciateComponents
;
let
preInit
=
false
;
factories
.
StateMachine
=
_statemachine_js__WEBPACK_IMPORTED_MODULE_0__
.
default
;
...
...
@@ -1330,9 +1332,8 @@ let Context = function( ctx ) {
return
Promise
.
all
(
res
);
};
var
instanciateComponents
=
function
()
{
var
instanciateComponents
=
async
function
()
{
var
p
,
promises
=
[];
for
(
p
in
components
)
{
if
(
components
.
hasOwnProperty
(
p
))
{
if
(
factories
[
components
[
p
].
type
]
===
undefined
)
{
...
...
@@ -1472,6 +1473,14 @@ let Context = function( ctx ) {
};
this
.
addFactories
=
function
(
obj
)
{
preInit
=
true
;
for
(
p
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
p
))
factories
[
p
]
=
obj
[
p
];
}
};
this
.
setFactory
=
function
(
key
,
factory
)
{
factories
[
key
]
=
factory
;
};
...
...
@@ -1522,11 +1531,15 @@ let Context = function( ctx ) {
};
// this should return a promise !
this
.
instanciate
=
function
()
{
this
.
instanciate
=
async
function
()
{
//! TODO
return
loadLibraries
().
then
(
instanciateComponents
)
.
catch
(
function
(
msg
)
{
console
.
error
(
"[ARCS] Trouble instanciating context"
,
msg
);
});
try
{
if
(
!
preInit
)
await
loadLibraries
();
await
instanciateComponents
();
}
catch
(
e
)
{
console
.
error
(
"[ARCS] Trouble instanciating context"
,
e
);
};
};
...
...
@@ -2088,12 +2101,18 @@ let Application = function () {
delete
sheets
[
sName
];
};
preProcess
=
function
()
{
this
.
launch
=
function
()
{
console
.
log
(
"[ARCS] Starting application..."
);
// first, we should instanciate components
var
i
,
temp
,
sheetList
;
temp
=
context
.
getComponent
(
controller
);
//[controller].instance;
controller
=
temp
;
if
(
controller
===
undefined
)
{
console
.
error
(
"[ARCS] undefined controller"
);
return
;
}
// then we should work on sheets
sheetList
=
Object
.
keys
(
sheets
);
for
(
i
=
0
;
i
<
sheetList
.
length
;
i
++
)
{
...
...
@@ -2223,13 +2242,14 @@ let Application = function () {
this
.
setDependency
=
function
(
key
)
{
dependencies
[
key
]
=
{};
};
/**
* Starts the application
*/
this
.
start
=
function
()
{
console
.
log
(
"[ARCS] Starting application..."
);
context
.
instanciate
().
then
(
preProcess
);
this
.
start
=
async
function
()
{
console
.
log
(
"[ARCS] Instanciating components..."
);
await
context
.
instanciate
();
this
.
launch
();
};
};
...
...
build/arcs.min.js
View file @
64ca04f
This diff is collapsed. Click to expand it.
build/arcs_browser.js
View file @
64ca04f
...
...
@@ -12,7 +12,7 @@ import ARCS from "./arcs.js";
console
.
log
(
"[ARCS] Bootstrapping..."
);
var
baseUrl
,
appDescription
,
requireMarkup
,
xhr
;
let
baseUrl
,
appDescription
,
requireMarkup
,
xhr
;
requireMarkup
=
document
.
querySelector
(
'[data-arcsapp]'
);
if
(
requireMarkup
!==
undefined
)
{
...
...
@@ -22,13 +22,13 @@ if (requireMarkup !== undefined) {
(
async
function
toto
()
{
var
description
=
await
(
fetch
(
appDescription
));
var
applicationObject
=
await
(
description
.
json
());
let
description
=
await
(
fetch
(
appDescription
));
let
applicationObject
=
await
(
description
.
json
());
console
.
log
(
"[ARCS] Application description loaded"
);
var
aap
=
new
ARCS
.
Application
();
aap
.
import
(
applicationObject
);
let
aap
=
new
ARCS
.
Application
();
a
wait
a
ap
.
import
(
applicationObject
);
aap
.
start
();
})();
...
...
src/application.js
View file @
64ca04f
...
...
@@ -62,12 +62,18 @@ let Application = function () {
delete
sheets
[
sName
];
};
preProcess
=
function
()
{
this
.
launch
=
function
()
{
console
.
log
(
"[ARCS] Starting application..."
);
// first, we should instanciate components
var
i
,
temp
,
sheetList
;
temp
=
context
.
getComponent
(
controller
);
//[controller].instance;
controller
=
temp
;
if
(
controller
===
undefined
)
{
console
.
error
(
"[ARCS] undefined controller"
);
return
;
}
// then we should work on sheets
sheetList
=
Object
.
keys
(
sheets
);
for
(
i
=
0
;
i
<
sheetList
.
length
;
i
++
)
{
...
...
@@ -197,13 +203,14 @@ let Application = function () {
this
.
setDependency
=
function
(
key
)
{
dependencies
[
key
]
=
{};
};
/**
* Starts the application
*/
this
.
start
=
function
()
{
console
.
log
(
"[ARCS] Starting application..."
);
context
.
instanciate
().
then
(
preProcess
);
this
.
start
=
async
function
()
{
console
.
log
(
"[ARCS] Instanciating components..."
);
await
context
.
instanciate
();
this
.
launch
();
};
};
...
...
src/arcs_browser.js
View file @
64ca04f
...
...
@@ -12,7 +12,7 @@ import ARCS from "./arcs.js";
console
.
log
(
"[ARCS] Bootstrapping..."
);
var
baseUrl
,
appDescription
,
requireMarkup
,
xhr
;
let
baseUrl
,
appDescription
,
requireMarkup
,
xhr
;
requireMarkup
=
document
.
querySelector
(
'[data-arcsapp]'
);
if
(
requireMarkup
!==
undefined
)
{
...
...
@@ -22,13 +22,13 @@ if (requireMarkup !== undefined) {
(
async
function
toto
()
{
var
description
=
await
(
fetch
(
appDescription
));
var
applicationObject
=
await
(
description
.
json
());
let
description
=
await
(
fetch
(
appDescription
));
let
applicationObject
=
await
(
description
.
json
());
console
.
log
(
"[ARCS] Application description loaded"
);
var
aap
=
new
ARCS
.
Application
();
aap
.
import
(
applicationObject
);
let
aap
=
new
ARCS
.
Application
();
a
wait
a
ap
.
import
(
applicationObject
);
aap
.
start
();
})();
...
...
src/arcsapp_bundler.js
View file @
64ca04f
...
...
@@ -2,11 +2,35 @@
*
*/
const
path
=
require
(
'path'
);
module
.
exports
=
function
arcsappToJs
(
options
,
loaderContext
,
content
)
{
// content is here our file arcsapp.json
let
code
=
`let descr=
${
content
}
;`
let
descr
=
JSON
.
parse
(
content
);
console
.
log
(
descr
.
context
.
libraries
);
let
code
=
`import ARCS from '../../build/arcs.js';\n`
;
let
libs
=
[];
let
libCnt
=
0
;
descr
.
context
.
libraries
.
forEach
(
e
=>
{
let
libPath
=
path
.
resolve
(
__dirname
,
'../build'
,
e
);
code
+=
`import __obj
${
libCnt
}
from '
${
libPath
}
';\n`
;
libs
.
push
(
`__obj
${
libCnt
}
`
);
libCnt
++
;
});
code
+=
`let descr=
${
content
}
;\n`
;
code
+=
`let aap = new ARCS.Application();\n`
;
code
+=
`aap.import(descr);\n`
;
libs
.
forEach
(
l
=>
{
code
+=
`aap.getContext().addFactories(
${
l
}
);\n`
;
});
code
+=
`aap.start();\n`
;
return
{
cacheable
:
true
,
...
...
src/context.js
View file @
64ca04f
...
...
@@ -8,16 +8,17 @@ import isInNode from './arcs.js';
* @param ctx {object} an object representing data for the context.
*/
let
Context
=
function
(
ctx
)
{
var
components
=
{};
var
constants
=
{};
var
factories
=
{};
var
libraries
=
[];
let
components
=
{};
let
constants
=
{};
let
factories
=
{};
let
libraries
=
[];
//var depLibPromises=[];
var
self
=
this
;
let
self
=
this
;
var
loadLibraries
;
var
loadDataFile
;
var
promiseLibrary
;
var
instanciateComponents
;
let
preInit
=
false
;
factories
.
StateMachine
=
StateMachine
;
...
...
@@ -74,9 +75,8 @@ let Context = function( ctx ) {
return
Promise
.
all
(
res
);
};
var
instanciateComponents
=
function
()
{
var
instanciateComponents
=
async
function
()
{
var
p
,
promises
=
[];
for
(
p
in
components
)
{
if
(
components
.
hasOwnProperty
(
p
))
{
if
(
factories
[
components
[
p
].
type
]
===
undefined
)
{
...
...
@@ -216,6 +216,14 @@ let Context = function( ctx ) {
};
this
.
addFactories
=
function
(
obj
)
{
preInit
=
true
;
for
(
p
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
p
))
factories
[
p
]
=
obj
[
p
];
}
};
this
.
setFactory
=
function
(
key
,
factory
)
{
factories
[
key
]
=
factory
;
};
...
...
@@ -266,11 +274,15 @@ let Context = function( ctx ) {
};
// this should return a promise !
this
.
instanciate
=
function
()
{
this
.
instanciate
=
async
function
()
{
//! TODO
return
loadLibraries
().
then
(
instanciateComponents
)
.
catch
(
function
(
msg
)
{
console
.
error
(
"[ARCS] Trouble instanciating context"
,
msg
);
});
try
{
if
(
!
preInit
)
await
loadLibraries
();
await
instanciateComponents
();
}
catch
(
e
)
{
console
.
error
(
"[ARCS] Trouble instanciating context"
,
e
);
};
};
...
...
tests/loop/loop_bundle.html
0 → 100644
View file @
64ca04f
<html>
<head>
<title>
ARCS engine
</title>
<script
type=
"module"
src=
"loop_bundle.js"
>
</script>
<style>
body
{
font-family
:
sans-serif
;
}
</style>
</head>
<body>
<h1>
ARCS in Web Browser
</h1>
<div
style=
"height:80vh; overflow: auto; border: solid 1px navy;"
>
<p
id=
"output"
style=
"margin: 5px; padding: 5px; font-family: monospace;"
></p>
<div>
</body>
</html>
tests/loop/webpack.config.js
View file @
64ca04f
...
...
@@ -7,7 +7,7 @@ module.exports = {
output
:
{
path
:
path
.
resolve
(
__dirname
,
''
),
filename
:
"
toto
.js"
filename
:
"
loop_bundle
.js"
},
module
:
{
rules
:
[
...
...
Please
register
or
login
to post a comment