Jean-Yves Didier

added an entry in invocations to look up to localstorage

/******/ "use strict";
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
......@@ -1635,20 +1634,35 @@ let Invocation = function (destination, slot, value) {
* @param context {object} the context in which this invocation takes place.
* @return an invocation
*/
Invocation.cast = function (obj, context) {
if (obj.value !== undefined) {
var component = context.getComponent(obj.destination);
if (component === undefined) {
Invocation.cast = function (obj, context) {
let component = context.getComponent(obj.destination);
if (component === undefined) {
console.error("[ARCS] Destination ",obj.destination, " is undefined");
}
}
if (obj.value !== undefined) {
return new Invocation(component, obj.slot, obj.value);
}
// this one looks odd, seems there is a failure in the logic.
if (obj.ref !== undefined) {
return new Invocation(context.getComponent(obj.destination), obj.slot, context.getConstant(obj.ref));
return new Invocation(component, obj.slot, context.getConstant(obj.ref));
}
if (obj.storage !== undefined) {
let data = null;
if (typeof(localStorage) !== "undefined") {
let item = localStorage.getItem(storage.key);
if (item === null) {
if (typeof (obj.storage.default) !== "undefined") {
data = obj.storage.default;
}
}
}
return new Invocation(component, obj.slot, data);
}
};
/*ARCS.Invocation.revert = function(obj, context) {
......
This diff is collapsed. Click to expand it.
......@@ -12,6 +12,8 @@ Console = ARCS.Component.create(
if (id === undefined) {
return ;
}
if (typeof document === "undefined") return;
var output = document.getElementById(id);
......
......@@ -6,10 +6,8 @@ const path=require('path');
module.exports = function arcsappToJs(options, loaderContext, content) {
// content is here our file arcsapp.json
let descr = JSON.parse(content);
console.log(descr.context.libraries);
let code = `import ARCS from '../../build/arcs.js';\n`;
let libs = [];
......
......@@ -37,20 +37,35 @@ let Invocation = function (destination, slot, value) {
* @param context {object} the context in which this invocation takes place.
* @return an invocation
*/
Invocation.cast = function (obj, context) {
if (obj.value !== undefined) {
var component = context.getComponent(obj.destination);
if (component === undefined) {
Invocation.cast = function (obj, context) {
let component = context.getComponent(obj.destination);
if (component === undefined) {
console.error("[ARCS] Destination ",obj.destination, " is undefined");
}
}
if (obj.value !== undefined) {
return new Invocation(component, obj.slot, obj.value);
}
// this one looks odd, seems there is a failure in the logic.
if (obj.ref !== undefined) {
return new Invocation(context.getComponent(obj.destination), obj.slot, context.getConstant(obj.ref));
return new Invocation(component, obj.slot, context.getConstant(obj.ref));
}
if (obj.storage !== undefined) {
let data = null;
if (typeof(localStorage) !== "undefined") {
let item = localStorage.getItem(storage.key);
if (item === null) {
if (typeof (obj.storage.default) !== "undefined") {
data = obj.storage.default;
}
}
}
return new Invocation(component, obj.slot, data);
}
};
/*ARCS.Invocation.revert = function(obj, context) {
......