Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arcsjs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arcsjs - npm Package Compare versions

Comparing version 0.9.6 to 0.9.7

2

build/arcs.min.js
/*! For license information please see arcs.min.js.LICENSE.txt */
var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n)},n={};t.d(n,{Z:()=>m});class e{constructor(t,n){this.slots=[],this.signals={},void 0!==t&&this.slot(t),void 0!==n&&this.signal(n)}slotList(){return this.slots}signalList(){return Object.keys(this.signals)}emit(t){let n,e,o,i=Array.prototype.slice.call(arguments,1);for(n in this.signals[t])e=this.signals[t][n].func,o=this.signals[t][n].obj,e.apply(o,i)}slot(t,n){let e=this;t instanceof Array?t.forEach((t=>{e.slots.includes(t)||e.slot(t)})):(this.slots.includes(t)||this.slots.push(t),void 0!==n&&(this[t]=n))}signal(t){let n=this;t instanceof Array?t.forEach((t=>{n.signals[t]=[]})):this.signals[t]=[]}static create(t,n,e){return void 0===t.prototype?(console.error("Cannot create such a component"),0):(t.prototype.slots=[],t.prototype.signals={},t.slotList=function(){return t.prototype.slots},t.prototype.slotList=function(){return this.slots},t.prototype.signalList=function(){return Object.keys(this.signals)},t.signalList=function(){return t.prototype.signalList()},t.prototype.emit=function(t){var n,e,o,i=Array.prototype.slice.call(arguments,1);for(n in this.signals[t])e=this.signals[t][n].func,o=this.signals[t][n].obj,e.apply(o,i)},t.prototype.slot=function(n,e){this.hasOwnProperty("slots")||(this.slots=t.prototype.slots.map((t=>t))),this.slots.includes(n)||this.slots.push(n),this[n]=e},t.prototype.signal=function(n){this.hasOwnProperty("signals")||(this.signals={},Object.assign(this.signals,t.prototype.signals)),this.signals[n]=[]},t.slot=function(n,e){var o;if(n instanceof Array)for(o=0;o<n.length;o++)t.prototype.slots.includes(n[o])||t.prototype.slots.push(n[o]);else t.prototype.slots.includes(n)||t.prototype.slots.push(n),void 0!==e&&(t.prototype[n]=e)},t.signal=function(n){var e;if(n instanceof Array)for(e=0;e<n.length;e++)t.prototype.signals[n[e]]=[];else t.prototype.signals[n]=[]},void 0!==n&&t.slot(n),void 0!==e&&t.signal(e),t)}static check(t){return void 0!==t.prototype&&void 0!==t.prototype.signals&&void 0!==t.prototype.slots}static connect(t,n,o,i){var r,s;if(void 0===t.signals)throw e.SourceIsNotComponent;if(void 0===t.signals[n]){let t=Object.assign({},e.UndefinedSignal);throw t.message=t.message+': "'+n+'"',t}if(void 0===o[i]){let t=Object.assign({},e.UndefinedSlot);throw t.message=t.message+': "'+i+'"',t}if(!t.hasOwnProperty("signals"))for(s in r=t.signals,t.signals={},r)t.signals[s]=[];t.signals[n].push({obj:o,func:o[i]})}static disconnect(t,n,e,o){var i;for(i=0;i<t.signals[n].length;i++)t.signals[n][i].obj===e&&t.signals[n][i].func===e[o]&&(t.signals[n].splice(i,1),i--)}static invoke(t,n,o){if(void 0===t[n])throw e.UndefinedSlot;t[n].apply(t,o)}static config(t,n){"function"==typeof t.config&&t.config(n)}}e.SourceIsNotComponent={message:"Source is not a component"},e.UndefinedSignal={message:"Signal is not defined"},e.UndefinedSlot={message:"Slot is not defined"};const o=e,i=function(t,n){this.eval=function(){return t[n]}},r=function(t,n,e){this.eval=function(){return n.eval(t)||e.eval(t)}},s=function(t,n,e){this.eval=function(t){return n.eval(t)&&n.eval(t)}};let c={build:function(t,n){var e,o,a,u;if("string"==typeof t)return n[t]=n[t]??!1,new i(n,t);for(e=c.build(t[0],n),u=1;u<t.length;u++)t[u].hasOwnProperty("and")?(a=c.build(t[u].and,n),o=new s(n,e,a)):t[u].hasOwnProperty("or")?(a=c.build(t[u].or,n),o=new r(n,e,a)):console.warn("[ARCS] Illegal tree"),e=o;return e}};const a=c,u=function(){function t(t,n,e,o,i,r){this.message=t,this.expected=n,this.found=e,this.offset=o,this.line=i,this.column=r,this.name="SyntaxError"}return function(t,n){function e(){this.constructor=t}e.prototype=n.prototype,t.prototype=new e}(t,Error),{SyntaxError:t,parse:function(n){var e,o=arguments.length>1?arguments[1]:{},i={},r={start:Z},s=Z,c=i,a=function(t,n){return[t].concat(n)},u=function(t){return{and:t}},l=function(t){return{or:t}},f=function(t){return t},h="(",p={type:"literal",value:"(",description:'"("'},d=")",g={type:"literal",value:")",description:'")"'},v=function(t){return[t]},y={type:"other",description:"id"},C=function(t){return t.trim()},m=/^[_a-zA-Z]/,w={type:"class",value:"[_a-zA-Z]",description:"[_a-zA-Z]"},S=/^[_a-zA-Z0-9]/,A={type:"class",value:"[_a-zA-Z0-9]",description:"[_a-zA-Z0-9]"},O="&",P={type:"literal",value:"&",description:'"&"'},x="|",b={type:"literal",value:"|",description:'"|"'},R=/^[ \r\n\t]/,j={type:"class",value:"[ \\r\\n\\t]",description:"[ \\r\\n\\t]"},F=0,k=0,N={line:1,column:1,seenCR:!1},T=0,L=[],E=0;if("startRule"in o){if(!(o.startRule in r))throw new Error("Can't start parsing from rule \""+o.startRule+'".');s=r[o.startRule]}function I(t){return k!==t&&(k>t&&(k=0,N={line:1,column:1,seenCR:!1}),function(t,e,o){var i,r;for(i=e;i<o;i++)"\n"===(r=n.charAt(i))?(t.seenCR||t.line++,t.column=1,t.seenCR=!1):"\r"===r||"\u2028"===r||"\u2029"===r?(t.line++,t.column=1,t.seenCR=!0):(t.column++,t.seenCR=!1)}(N,k,t),k=t),N}function _(t){F<T||(F>T&&(T=F,L=[]),L.push(t))}function U(e,o,i){var r=I(i),s=i<n.length?n.charAt(i):null;return null!==o&&function(t){var n=1;for(t.sort((function(t,n){return t.description<n.description?-1:t.description>n.description?1:0}));n<t.length;)t[n-1]===t[n]?t.splice(n,1):n++}(o),new t(null!==e?e:function(t,n){var e,o=new Array(t.length);for(e=0;e<t.length;e++)o[e]=t[e].description;return"Expected "+(t.length>1?o.slice(0,-1).join(", ")+" or "+o[t.length-1]:o[0])+" but "+(n?'"'+function(t){function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x80-\xFF]/g,(function(t){return"\\x"+n(t)})).replace(/[\u0180-\u0FFF]/g,(function(t){return"\\u0"+n(t)})).replace(/[\u1080-\uFFFF]/g,(function(t){return"\\u"+n(t)}))}(n)+'"':"end of input")+" found."}(o,s),o,s,i,r.line,r.column)}function Z(){return D()}function D(){var t,n,e,o;if(t=F,(n=z())!==i){if(e=[],(o=q())!==i)for(;o!==i;)e.push(o),o=q();else e=c;e!==i?t=n=a(n,e):(F=t,t=c)}else F=t,t=c;return t===i&&(t=z()),t}function q(){var t,n;return t=F,M()!==i&&(n=z())!==i?t=u(n):(F=t,t=c),t===i&&(t=F,B()!==i&&(n=z())!==i?t=l(n):(F=t,t=c)),t}function z(){var t,e,o,r;return t=F,(e=V())!==i&&(e=f(e)),(t=e)===i&&(t=F,40===n.charCodeAt(F)?(e=h,F++):(e=i,0===E&&_(p)),e!==i&&(o=D())!==i?(41===n.charCodeAt(F)?(r=d,F++):(r=i,0===E&&_(g)),r!==i?t=e=v(o):(F=t,t=c)):(F=t,t=c)),t}function V(){var t,e,o;return E++,t=F,e=F,(o=J())!==i&&(o=n.substring(e,F)),(e=o)!==i&&(e=C(e)),E--,(t=e)===i&&(e=i,0===E&&_(y)),t}function J(){var t,e,o,r,s;if(t=F,(e=$())!==i)if(m.test(n.charAt(F))?(o=n.charAt(F),F++):(o=i,0===E&&_(w)),o!==i){for(r=[],S.test(n.charAt(F))?(s=n.charAt(F),F++):(s=i,0===E&&_(A));s!==i;)r.push(s),S.test(n.charAt(F))?(s=n.charAt(F),F++):(s=i,0===E&&_(A));r!==i&&(s=$())!==i?t=e=[e,o,r,s]:(F=t,t=c)}else F=t,t=c;else F=t,t=c;return t}function M(){var t,e,o,r;return t=F,(e=$())!==i?(38===n.charCodeAt(F)?(o=O,F++):(o=i,0===E&&_(P)),o!==i&&(r=$())!==i?t=e=[e,o,r]:(F=t,t=c)):(F=t,t=c),t}function B(){var t,e,o,r;return t=F,(e=$())!==i?(124===n.charCodeAt(F)?(o=x,F++):(o=i,0===E&&_(b)),o!==i&&(r=$())!==i?t=e=[e,o,r]:(F=t,t=c)):(F=t,t=c),t}function $(){var t,e;for(t=[],R.test(n.charAt(F))?(e=n.charAt(F),F++):(e=i,0===E&&_(j));e!==i;)t.push(e),R.test(n.charAt(F))?(e=n.charAt(F),F++):(e=i,0===E&&_(j));return t}if((e=s())!==i&&F===n.length)return e;throw e!==i&&F<n.length&&_({type:"end",description:"end of input"}),U(null,L,T)}}}(),l=o.create((function(t){var n="",e="",o={},i="",r=this,s={},c={},l={},f=function(t){var n;r.slots.indexOf(t)<0&&r.slot(t,(n=t,function(){r.setToken(n)}))},h=function(t){var n;if(Object.keys(c).forEach((t=>c[t]=!1)),o.hasOwnProperty(t))for(n in c={},o[t])o[t].hasOwnProperty(n)&&(l[n]=a.build(s[t][n],c));i=t,r.emit("requestSheet",i),i===e&&r.emit("requestTermination")};this.setInitialState=function(t){i=n=t},this.setFinalState=function(t){e=t},this.addTransition=function(t,n,e){var i,r=/([A-Za-z_]\w*)/g;try{var c;if("string"==typeof(c=u.parse(n)))f(c);else for(;null!==(i=r.exec(n));)f(i[0]);s[t]=s[t]||{},s[t][n]=c,void 0===o[t]&&(o[t]={}),o[t][n]=e}catch(t){}},this.setToken=function(t){c.hasOwnProperty(t)&&(c[t]=!0);for(const[t,n]of Object.entries(l))n.eval()&&(l={},h(o[i][t]))},this.setTransitions=function(t){var n,e;for(n in t)if(t.hasOwnProperty(n))for(e in t[n])t[n].hasOwnProperty(e)&&this.addTransition(n,e,t[n][e])},this.start=function(){h(n)},void 0!==t&&(n=t.initial,e=t.final,this.setTransitions(t.transitions),i="")}),["setToken"],["requestSheet","requestTermination"]);let f=function(t){let n={},e={},o={},i=[],r=this,s=!1;if(o.StateMachine=l,void 0!==t){var c;for(c in i=t.libraries,t.components)t.components.hasOwnProperty(c)&&(n[c]=t.components[c]);if(void 0!==t.constants)for(c in t.constants)t.constants.hasOwnProperty(c)&&(e[c]=t.constants[c])}var a=async function(t){return m()?new Promise((function(n,e){var o=require(t);void 0!==o?n(o):e("[ARCS] File not found")})):(await fetch(t)).json()};this.loadLibrary=function(t,n){var e=t,o=t;return f.currentContext=r,"string"!=typeof t&&(o=t.name,e=t.url),i.indexOf(o)<0&&i.push(o),import(e).then((function(t){for(c in t.default)t.default.hasOwnProperty(c)&&f.currentContext.setFactory(c,t.default[c]);void 0!==n&&n()})).catch((function(t){console.error("[ARCS] Trouble loading '",e,"' with reason -",{msg:t})}))},this.getComponentList=function(){var t,e=Object.keys(n);for(t=0;t<e.length;t++)n.hasOwnProperty(e[t])||e.splice(t--,1);return e},this.getConstant=function(t){return e[t]},this.getComponentType=function(t){if(void 0!==n[t])return n[t].type},this.getComponentValue=function(t){if(void 0!==n[t])return n[t].value},this.getComponent=function(t){if(void 0!==n[t])return n[t].instance},this.getComponentName=function(t){var e,o;for(o=n.getComponentList(),e=0;e<o.length;e++)if(n[o[e]].instance===t)return o[e]},this.addFactories=function(t){for(c in s=!0,t)t.hasOwnProperty(c)&&(o[c]=t[c])},this.setFactory=function(t,n){o[t]=n},this.toJSON=function(){var t,e={};for(t in n)n.hasOwnProperty(t)&&(e[t]={type:n[t].type,value:n[t].value});return e},this.setComponentValue=function(t,e){n[t].value=e},this.addComponent=function(t,e,i){var r;n[t]={},n[t].type=e,n[t].value=i;var s=o[e];void 0!==s&&(r=new s(i)),n[t].instance=r},this.removeComponent=function(t){delete n[t]},this.getFactory=function(t){return o[t]},this.getFactoryList=function(){return Object.keys(o)},this.instanciate=async function(){try{s||await function(){var t;f.currentContext=r;var n=[];for(t=0;t<i.length;t++)n.push(r.loadLibrary(i[t]));return Promise.all(n)}(),await async function(){var t,r=[];for(t in n)if(n.hasOwnProperty(t)){if(void 0===o[n[t].type])return console.error("[ARCS] Factory "+n[t].type+" not found."),void console.error("[ARCS] Context dump follows: ",i,n,e);var s=o[n[t].type];try{void 0!==n[t].value||void 0!==n[t].url||void 0!==n[t].ref?(void 0!==n[t].value&&(n[t].instance=new s(n[t].value)),void 0!==n[t].url&&(console.log("loading data file",n[t].url),r.push(a(n[t].url).then(function(t,e){return function(o){return console.log("instanciating from data file"),n[t].instance=new e(o),Promise.resolve()}}(t,s)))),void 0!==n[t].ref&&void 0!==e[n[t].ref]&&(n[t].instance=new s(e[n[t].ref]))):n[t].instance=new s}catch(n){console.error("[ARCS] Component of type ",t," not instanciated.",n)}}return Promise.all(r)}()}catch(t){console.error("[ARCS] Trouble instanciating context",t)}};var u=function(t,n){var e,o=Object.create(n);for(e in t)t.hasOwnProperty(e)&&(o[e]=t[e]);return o};this.chain=function(t,i,r){return[u(t,n),u(i,e),u(r,o)]},this.setParent=function(t){if(void 0!==t){var i=t.chain(n,e,o);n=i[0],e=i[1],o=i[2]}}};f.currentContext=null;const h=f;let p=function(t,n,e){this.getDestination=function(){return t},this.getSlot=function(){return n},this.getValue=function(){return e},this.invoke=function(){let o=t[n];void 0!==o?o.apply(t,e):console.error("Undefined slot %s of component %s",n,t)}};p.cast=function(t,n){let e=n.getComponent(t.destination);if(void 0===e&&console.error("[ARCS] Destination ",t.destination," is undefined"),void 0!==t.value)return new p(e,t.slot,t.value);if(void 0!==t.ref)return new p(e,t.slot,n.getConstant(t.ref));if(void 0!==t.storage){let n=null;return"undefined"!=typeof localStorage&&null===localStorage.getItem(`ARCS.${storage.key}`)&&void 0!==t.storage.default&&(n=t.storage.default),new p(e,t.slot,n)}return new p(e,t.slot)},p.PRE_CONNECTION=0,p.POST_CONNECTION=1,p.CLEAN_UP=2;const d=p;let g=function(t,n,e,i){this.connect=function(){try{o.connect(t,n,e,i)}catch(o){console.log(o,t,n,e,i)}},this.disconnect=function(){o.disconnect(t,n,e,i)},this.getSource=function(){return t},this.getDestination=function(){return e},this.getSlot=function(){return i},this.getSignal=function(){return n}};g.cast=function(t,n){return new g(n.getComponent(t.source),t.signal,n.getComponent(t.destination),t.slot)};const v=g,y=function(t){var n,e,o,i,r,s=new h,c=[],a=[],u=[],l=[],f=0,p=0,g=0,y=0;n=function(){var t;for(t=0;t<c.length;t++)c[t].invoke()},e=function(){var t;for(t=0;t<a.length;t++)a[t].invoke()},o=function(){var t;for(t=0;t<u.length;t++)u[t].invoke()},i=function(){var t;for(t=0;t<l.length;t++)l[t].connect()},r=function(){var t;for(t=0;t<l.length;t++)l[t].disconnect()},this.setContext=function(t){s=t},this.activate=function(){s.instanciate().then((function(){n(),i(),e()}))},this.deactivate=function(){r(),o()},this.addPreConnection=function(t){var n=d.cast(t,s);return n.id=f++,c.push(n),n.id},this.addPostConnection=function(t){var n=d.cast(t,s);return n.id=p++,a.push(n),n.id},this.addCleanup=function(t){var n=d.cast(t,s);return n.id=g++,u.push(n),n.id},this.addConnection=function(t){var n=v.cast(t,s);return n.id=y++,l.push(n),n.id};let C=function(t,n){let e=n.length;for(;e--&&n[e].id!==t;);e>=0?n.splice(e,1):console.warn("Could not remove data with id",t)};this.removePreConnection=function(t){C(t,c)},this.removePostConnection=function(t){C(t,a)},this.removeCleanup=function(t){C(t,u)};var m=function(t,n,e){for(var o=e.length;o--&&e[o].id!==t;);o>=0&&(e[o].value=n)};this.changePreConnection=function(t,n){m(t,n,c)},this.changePostConnection=function(t,n){m(t,n,a)},this.changeCleanup=function(t,n){m(t,n,u)},this.removeConnection=function(t){C(t,l)};let w=function(t,n,e){let o,i=e.length,r=e.length;for(;i--&&e[i].id!==t;);for(;r--&&e[r].id!==n;);i>=0&&r>=0&&(o=e[i],e[i]=e[r],e[r]=o,e[i].id=t,e[r].id=n)};this.swapConnections=function(t,n){w(t,n,l)},this.swapCleanups=function(t,n){w(t,n,u)},this.swapPreConnections=function(t,n){w(t,n,c)},this.swapPostConnections=function(t,n){w(t,n,a)},this.import=function(n){n.hasOwnProperty("context")&&(s=new h(n.context)).setParent(t),s.instanciate().then((function(){!function(t){let n=0,e=d.cast,o=v.cast;if(void 0!==t.preconnections)for(n=0;n<t.preconnections.length;n++)c.push(e(t.preconnections[n],s));if(void 0!==t.postconnections)for(n=0;n<t.postconnections.length;n++)a.push(e(t.postconnections[n],s));if(void 0!==t.cleanups)for(n=0;n<t.cleanups.length;n++)u.push(e(t.cleanups[n],s));if(void 0!==t.connections)for(n=0;n<t.connections.length;n++)l.push(o(t.connections[n],s))}(n)}))};let S=function(t){return{destination:s.getComponentName(t.getDestination()),slot:t.getSlot(),value:t.getValue()}};this.toJSON=function(){let t,n=[],e=[],o=[],i=[];for(t=0;t<l.length;t++)o.push((r=l[t],{source:s.getComponentName(r.getSource()),signal:r.getSignal(),destination:s.getComponentName(r.getDestination()),slot:r.getSlot()}));var r;for(t=0;t<c.length;t++)n.push(S(c[t]));for(t=0;t<a.length;t++)e.push(S(a[t]));for(t=0;t<u.length;t++)i.push(S(u[t]));return{preconnections:n,postconnections:e,connections:o,cleanups:i}},s.setParent(t)};let C=function(){var t=new h,n={},e={},i=[],r=this,s="";this.export=function(){return{context:t,controller:t.getComponentName(e),sheets:n}},this.getContext=function(){return t},this.getSheetList=function(){return Object.keys(n)},this.getSheet=function(t){return n[t]},this.addSheet=function(e,o){n[e]=o,o.setContext(t)},this.removeSheet=function(t){delete n[t]},this.launch=function(){var i,s,c;if(console.log("[ARCS] Starting application..."),s=t.getComponent(e),void 0!==(e=s)){for(c=Object.keys(n),i=0;i<c.length;i++)(s=new y(t)).import(n[c[i]],t),n[c[i]]=s;o.connect(e,"requestSheet",r,"setSheet"),o.connect(e,"requestTermination",r,"finish"),e.start()}else console.error("[ARCS] undefined controller")},this.setController=function(n){e=t.getComponent(n)},this.setSheet=function(t){n.hasOwnProperty(t)?(s&&n[s].deactivate(),n[s=t].activate()):console.warn("[ARCS] Tried to activate hollow sheet named: "+t)},this.finish=function(){s&&n[s].deactivate()},this.import=function(o){t=new h(o.context),n=o.sheets,void 0===(e=o.controller)&&console.error("[ARCS] Undefined controller. Cannot start application.")},this.setFactory=function(t,n){factories[t]=n},this.setDependency=function(t){i[t]={}},this.start=async function(){console.log("[ARCS] Instanciating components..."),await t.instanciate(),this.launch()}};C.setDependency=function(t,n){t.setDependency(n)},o.create(C),C.slot("setSheet"),C.slot("finish");const m={Component:o,isInNode:function(){return"undefined"!=typeof process&&-1!==process.release.name.search(/node|io.js/)},StateMachine:l,Context:h,Invocation:d,Connection:v,Sheet:y,Application:C};var w=n.Z;export{w as default};
var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n)},n={};t.d(n,{Z:()=>w});class e{constructor(t,n){this.slots=[],this.signals={},void 0!==t&&this.slot(t),void 0!==n&&this.signal(n)}slotList(){return this.slots}signalList(){return Object.keys(this.signals)}emit(t){let n,e,o,i=Array.prototype.slice.call(arguments,1);for(n in this.signals[t])e=this.signals[t][n].func,o=this.signals[t][n].obj,e.apply(o,i)}slot(t,n){let e=this;t instanceof Array?t.forEach((t=>{e.slots.includes(t)||e.slot(t)})):(this.slots.includes(t)||this.slots.push(t),void 0!==n&&(this[t]=n))}signal(t){let n=this;t instanceof Array?t.forEach((t=>{n.signals[t]=[]})):this.signals[t]=[]}static create(t,n,e){return void 0===t.prototype?(console.error("Cannot create such a component"),0):(t.prototype.slots=[],t.prototype.signals={},t.slotList=function(){return t.prototype.slots},t.prototype.slotList=function(){return this.slots},t.prototype.signalList=function(){return Object.keys(this.signals)},t.signalList=function(){return t.prototype.signalList()},t.prototype.emit=function(t){var n,e,o,i=Array.prototype.slice.call(arguments,1);for(n in this.signals[t])e=this.signals[t][n].func,o=this.signals[t][n].obj,e.apply(o,i)},t.prototype.slot=function(n,e){this.hasOwnProperty("slots")||(this.slots=t.prototype.slots.map((t=>t))),this.slots.includes(n)||this.slots.push(n),this[n]=e},t.prototype.signal=function(n){this.hasOwnProperty("signals")||(this.signals={},Object.assign(this.signals,t.prototype.signals)),this.signals[n]=[]},t.slot=function(n,e){var o;if(n instanceof Array)for(o=0;o<n.length;o++)t.prototype.slots.includes(n[o])||t.prototype.slots.push(n[o]);else t.prototype.slots.includes(n)||t.prototype.slots.push(n),void 0!==e&&(t.prototype[n]=e)},t.signal=function(n){var e;if(n instanceof Array)for(e=0;e<n.length;e++)t.prototype.signals[n[e]]=[];else t.prototype.signals[n]=[]},void 0!==n&&t.slot(n),void 0!==e&&t.signal(e),t)}static check(t){return void 0!==t.prototype&&void 0!==t.prototype.signals&&void 0!==t.prototype.slots}static connect(t,n,o,i){var s,r;if(void 0===t.signals)throw e.SourceIsNotComponent;if(void 0===t.signals[n]){let t=Object.assign({},e.UndefinedSignal);throw t.message=t.message+': "'+n+'"',t}if(void 0===o[i]){let t=Object.assign({},e.UndefinedSlot);throw t.message=t.message+': "'+i+'"',t}if(!t.hasOwnProperty("signals"))for(r in s=t.signals,t.signals={},s)t.signals[r]=[];t.signals[n].push({obj:o,func:o[i]})}static disconnect(t,n,e,o){var i;for(i=0;i<t.signals[n].length;i++)t.signals[n][i].obj===e&&t.signals[n][i].func===e[o]&&(t.signals[n].splice(i,1),i--)}static invoke(t,n,o){if(void 0===t[n])throw e.UndefinedSlot;t[n].apply(t,o)}static config(t,n){"function"==typeof t.config&&t.config(n)}}e.SourceIsNotComponent={message:"Source is not a component"},e.UndefinedSignal={message:"Signal is not defined"},e.UndefinedSlot={message:"Slot is not defined"};const o=e,i=function(t,n){this.eval=function(){return t[n]}},s=function(t,n,e){this.eval=function(){return n.eval(t)||e.eval(t)}},r=function(t,n,e){this.eval=function(t){return n.eval(t)&&e.eval(t)}};let c={build:function(t,n){var e,o,a,u;if("string"==typeof t)return n[t]=n[t]??!1,new i(n,t);for(e=c.build(t[0],n),u=1;u<t.length;u++)t[u].hasOwnProperty("and")?(a=c.build(t[u].and,n),o=new r(n,e,a)):t[u].hasOwnProperty("or")?(a=c.build(t[u].or,n),o=new s(n,e,a)):console.warn("[ARCS] Illegal tree"),e=o;return e}};const a=c,u=function(){function t(t,n,e,o,i,s){this.message=t,this.expected=n,this.found=e,this.offset=o,this.line=i,this.column=s,this.name="SyntaxError"}return function(t,n){function e(){this.constructor=t}e.prototype=n.prototype,t.prototype=new e}(t,Error),{SyntaxError:t,parse:function(n){var e,o=arguments.length>1?arguments[1]:{},i={},s={start:Z},r=Z,c=i,a=function(t,n){return[t].concat(n)},u=function(t){return{and:t}},l=function(t){return{or:t}},f=function(t){return t},h="(",p={type:"literal",value:"(",description:'"("'},d=")",g={type:"literal",value:")",description:'")"'},v=function(t){return[t]},y={type:"other",description:"id"},C=function(t){return t.trim()},m=/^[_a-zA-Z]/,w={type:"class",value:"[_a-zA-Z]",description:"[_a-zA-Z]"},S=/^[_a-zA-Z0-9]/,A={type:"class",value:"[_a-zA-Z0-9]",description:"[_a-zA-Z0-9]"},O="&",P={type:"literal",value:"&",description:'"&"'},x="|",b={type:"literal",value:"|",description:'"|"'},R=/^[ \r\n\t]/,j={type:"class",value:"[ \\r\\n\\t]",description:"[ \\r\\n\\t]"},F=0,k=0,N={line:1,column:1,seenCR:!1},T=0,L=[],E=0;if("startRule"in o){if(!(o.startRule in s))throw new Error("Can't start parsing from rule \""+o.startRule+'".');r=s[o.startRule]}function I(t){return k!==t&&(k>t&&(k=0,N={line:1,column:1,seenCR:!1}),function(t,e,o){var i,s;for(i=e;i<o;i++)"\n"===(s=n.charAt(i))?(t.seenCR||t.line++,t.column=1,t.seenCR=!1):"\r"===s||"\u2028"===s||"\u2029"===s?(t.line++,t.column=1,t.seenCR=!0):(t.column++,t.seenCR=!1)}(N,k,t),k=t),N}function _(t){F<T||(F>T&&(T=F,L=[]),L.push(t))}function U(e,o,i){var s=I(i),r=i<n.length?n.charAt(i):null;return null!==o&&function(t){var n=1;for(t.sort((function(t,n){return t.description<n.description?-1:t.description>n.description?1:0}));n<t.length;)t[n-1]===t[n]?t.splice(n,1):n++}(o),new t(null!==e?e:function(t,n){var e,o=new Array(t.length);for(e=0;e<t.length;e++)o[e]=t[e].description;return"Expected "+(t.length>1?o.slice(0,-1).join(", ")+" or "+o[t.length-1]:o[0])+" but "+(n?'"'+function(t){function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x80-\xFF]/g,(function(t){return"\\x"+n(t)})).replace(/[\u0180-\u0FFF]/g,(function(t){return"\\u0"+n(t)})).replace(/[\u1080-\uFFFF]/g,(function(t){return"\\u"+n(t)}))}(n)+'"':"end of input")+" found."}(o,r),o,r,i,s.line,s.column)}function Z(){return D()}function D(){var t,n,e,o;if(t=F,(n=z())!==i){if(e=[],(o=q())!==i)for(;o!==i;)e.push(o),o=q();else e=c;e!==i?t=n=a(n,e):(F=t,t=c)}else F=t,t=c;return t===i&&(t=z()),t}function q(){var t,n;return t=F,M()!==i&&(n=z())!==i?t=u(n):(F=t,t=c),t===i&&(t=F,B()!==i&&(n=z())!==i?t=l(n):(F=t,t=c)),t}function z(){var t,e,o,s;return t=F,(e=V())!==i&&(e=f(e)),(t=e)===i&&(t=F,40===n.charCodeAt(F)?(e=h,F++):(e=i,0===E&&_(p)),e!==i&&(o=D())!==i?(41===n.charCodeAt(F)?(s=d,F++):(s=i,0===E&&_(g)),s!==i?t=e=v(o):(F=t,t=c)):(F=t,t=c)),t}function V(){var t,e,o;return E++,t=F,e=F,(o=J())!==i&&(o=n.substring(e,F)),(e=o)!==i&&(e=C(e)),E--,(t=e)===i&&(e=i,0===E&&_(y)),t}function J(){var t,e,o,s,r;if(t=F,(e=$())!==i)if(m.test(n.charAt(F))?(o=n.charAt(F),F++):(o=i,0===E&&_(w)),o!==i){for(s=[],S.test(n.charAt(F))?(r=n.charAt(F),F++):(r=i,0===E&&_(A));r!==i;)s.push(r),S.test(n.charAt(F))?(r=n.charAt(F),F++):(r=i,0===E&&_(A));s!==i&&(r=$())!==i?t=e=[e,o,s,r]:(F=t,t=c)}else F=t,t=c;else F=t,t=c;return t}function M(){var t,e,o,s;return t=F,(e=$())!==i?(38===n.charCodeAt(F)?(o=O,F++):(o=i,0===E&&_(P)),o!==i&&(s=$())!==i?t=e=[e,o,s]:(F=t,t=c)):(F=t,t=c),t}function B(){var t,e,o,s;return t=F,(e=$())!==i?(124===n.charCodeAt(F)?(o=x,F++):(o=i,0===E&&_(b)),o!==i&&(s=$())!==i?t=e=[e,o,s]:(F=t,t=c)):(F=t,t=c),t}function $(){var t,e;for(t=[],R.test(n.charAt(F))?(e=n.charAt(F),F++):(e=i,0===E&&_(j));e!==i;)t.push(e),R.test(n.charAt(F))?(e=n.charAt(F),F++):(e=i,0===E&&_(j));return t}if((e=r())!==i&&F===n.length)return e;throw e!==i&&F<n.length&&_({type:"end",description:"end of input"}),U(null,L,T)}}}(),l=o.create((function(t){var n="",e="",o={},i="",s=this,r={},c={},l={},f=function(t){var n;s.slots.indexOf(t)<0&&s.slot(t,(n=t,function(){s.setToken(n)}))},h=function(t){var n;if(Object.keys(c).forEach((t=>c[t]=!1)),o.hasOwnProperty(t))for(n in c={},o[t])o[t].hasOwnProperty(n)&&(l[n]=a.build(r[t][n],c));i=t,s.emit("requestSheet",i),i===e&&s.emit("requestTermination")};this.setInitialState=function(t){i=n=t},this.setFinalState=function(t){e=t},this.addTransition=function(t,n,e){var i,s=/([A-Za-z_]\w*)/g;try{var c;if("string"==typeof(c=u.parse(n)))f(c);else for(;null!==(i=s.exec(n));)f(i[0]);r[t]=r[t]||{},r[t][n]=c,void 0===o[t]&&(o[t]={}),o[t][n]=e}catch(t){}},this.setToken=function(t){c.hasOwnProperty(t)&&(c[t]=!0);for(const[t,n]of Object.entries(l))n.eval()&&(l={},h(o[i][t]))},this.setTransitions=function(t){var n,e;for(n in t)if(t.hasOwnProperty(n))for(e in t[n])t[n].hasOwnProperty(e)&&this.addTransition(n,e,t[n][e])},this.start=function(){h(n)},void 0!==t&&(n=t.initial,e=t.final,this.setTransitions(t.transitions),i="")}),["setToken"],["requestSheet","requestTermination"]);let f=function(t){let n={},e={},o={},i=[],s=this,r=!1;o.StateMachine=l,void 0!==t&&(i=t.libraries,Object.assign(n,t.components),Object.assign(e,t.constants));var c=async function(t){return w()?new Promise((function(n,e){var o=require(t);void 0!==o?n(o):e("[ARCS] File not found")})):(await fetch(t)).json()};this.loadLibrary=function(t,n){var e=t,o=t;return f.currentContext=s,"string"!=typeof t&&(o=t.name,e=t.url),i.indexOf(o)<0&&i.push(o),import(e).then((function(t){for(p in t.default)t.default.hasOwnProperty(p)&&f.currentContext.setFactory(p,t.default[p]);void 0!==n&&n()})).catch((function(t){console.error("[ARCS] Trouble loading '",e,"' with reason -",{msg:t})}))},this.getComponentList=function(){var t,e=Object.keys(n);for(t=0;t<e.length;t++)n.hasOwnProperty(e[t])||e.splice(t--,1);return e},this.getConstant=function(t){return e[t]},this.getComponentType=function(t){if(void 0!==n[t])return n[t].type},this.getComponentValue=function(t){if(void 0!==n[t])return n[t].value},this.getComponent=function(t){if(void 0!==n[t])return n[t].instance},this.getComponentName=function(t){var e,o;for(o=n.getComponentList(),e=0;e<o.length;e++)if(n[o[e]].instance===t)return o[e]},this.addFactories=function(t){for(p in r=!0,t)t.hasOwnProperty(p)&&(o[p]=t[p])},this.setFactory=function(t,n){o[t]=n},this.toJSON=function(){var t,e={};for(t in n)n.hasOwnProperty(t)&&(e[t]={type:n[t].type,value:n[t].value});return e},this.setComponentValue=function(t,e){n[t].value=e},this.addComponent=function(t,e,i){var s;n[t]={},n[t].type=e,n[t].value=i;var r=o[e];void 0!==r&&(s=new r(i)),n[t].instance=s},this.removeComponent=function(t){delete n[t]},this.getFactory=function(t){return o[t]},this.getFactoryList=function(){return Object.keys(o)},this.instanciate=async function(){try{r||await function(){var t;f.currentContext=s;var n=[];for(t=0;t<i.length;t++)n.push(s.loadLibrary(i[t]));return Promise.all(n)}(),await async function(){var t,s=[];for(t in n)if(n.hasOwnProperty(t)){if(void 0===o[n[t].type])return console.error("[ARCS] Factory "+n[t].type+" not found."),void console.error("[ARCS] Context dump follows: ",i,n,e);var r=o[n[t].type];try{void 0!==n[t].value||void 0!==n[t].url||void 0!==n[t].ref?(void 0!==n[t].value&&(n[t].instance=new r(n[t].value)),void 0!==n[t].url&&(console.log("loading data file",n[t].url),s.push(c(n[t].url).then(function(t,e){return function(o){return console.log("instanciating from data file"),n[t].instance=new e(o),Promise.resolve()}}(t,r)))),void 0!==n[t].ref&&void 0!==e[n[t].ref]&&(n[t].instance=new r(e[n[t].ref]))):n[t].instance=new r}catch(n){console.error("[ARCS] Component of type ",t," not instanciated.",n)}}return Promise.all(s)}()}catch(t){console.error("[ARCS] Trouble instanciating context",t)}};var a=function(t,n){return Object.create(n,t)};this.chain=function(t,i,s){return[a(t,n),a(i,e),a(s,o)]},this.setParent=function(t){if(void 0!==t){var i=t.chain(n,e,o);n=i[0],e=i[1],o=i[2]}}};f.currentContext=null;const h=f;let d=function(t,n,e){this.getDestination=function(){return t},this.getSlot=function(){return n},this.getValue=function(){return e},this.invoke=function(){let o=t[n];void 0!==o?o.apply(t,e):console.error("Undefined slot %s of component %s",n,t)}};d.cast=function(t,n){if(void 0!==t.call){let n=t.call.split(".");t.destination=n[0],t.slot=n[1]}let e=n.getComponent(t.destination);if(void 0===e&&console.error("[ARCS] Destination ",t.destination," is undefined"),void 0!==t.value)return new d(e,t.slot,t.value);if(void 0!==t.ref)return new d(e,t.slot,n.getConstant(t.ref));if(void 0!==t.storage){let n=null;return"undefined"!=typeof localStorage&&null===localStorage.getItem(`ARCS.${storage.key}`)&&void 0!==t.storage.default&&(n=t.storage.default),new d(e,t.slot,n)}return new d(e,t.slot)},d.PRE_CONNECTION=0,d.POST_CONNECTION=1,d.CLEAN_UP=2;const g=d;let v=function(t,n,e,i){this.connect=function(){try{o.connect(t,n,e,i)}catch(o){console.log(o,t,n,e,i)}},this.disconnect=function(){o.disconnect(t,n,e,i)},this.getSource=function(){return t},this.getDestination=function(){return e},this.getSlot=function(){return i},this.getSignal=function(){return n}};v.cast=function(t,n){if(void 0!==t.from){let n=t.from.split(".");t.source=n[0],t.signal=n[1]}if(void 0!==t.to){let n=t.to.split(".");t.destination=n[0],t.slot=n[1]}return new v(n.getComponent(t.source),t.signal,n.getComponent(t.destination),t.slot)};const y=v,C=function(t){var n,e,o,i,s,r=new h,c=[],a=[],u=[],l=[],f=0,p=0,d=0,v=0;n=function(){var t;for(t=0;t<c.length;t++)c[t].invoke()},e=function(){var t;for(t=0;t<a.length;t++)a[t].invoke()},o=function(){var t;for(t=0;t<u.length;t++)u[t].invoke()},i=function(){var t;for(t=0;t<l.length;t++)l[t].connect()},s=function(){var t;for(t=0;t<l.length;t++)l[t].disconnect()},this.setContext=function(t){r=t},this.activate=function(){r.instanciate().then((function(){n(),i(),e()}))},this.deactivate=function(){s(),o()},this.addPreConnection=function(t){var n=g.cast(t,r);return n.id=f++,c.push(n),n.id},this.addPostConnection=function(t){var n=g.cast(t,r);return n.id=p++,a.push(n),n.id},this.addCleanup=function(t){var n=g.cast(t,r);return n.id=d++,u.push(n),n.id},this.addConnection=function(t){var n=y.cast(t,r);return n.id=v++,l.push(n),n.id};let C=function(t,n){let e=n.length;for(;e--&&n[e].id!==t;);e>=0?n.splice(e,1):console.warn("Could not remove data with id",t)};this.removePreConnection=function(t){C(t,c)},this.removePostConnection=function(t){C(t,a)},this.removeCleanup=function(t){C(t,u)};var m=function(t,n,e){for(var o=e.length;o--&&e[o].id!==t;);o>=0&&(e[o].value=n)};this.changePreConnection=function(t,n){m(t,n,c)},this.changePostConnection=function(t,n){m(t,n,a)},this.changeCleanup=function(t,n){m(t,n,u)},this.removeConnection=function(t){C(t,l)};let w=function(t,n,e){let o,i=e.length,s=e.length;for(;i--&&e[i].id!==t;);for(;s--&&e[s].id!==n;);i>=0&&s>=0&&(o=e[i],e[i]=e[s],e[s]=o,e[i].id=t,e[s].id=n)};this.swapConnections=function(t,n){w(t,n,l)},this.swapCleanups=function(t,n){w(t,n,u)},this.swapPreConnections=function(t,n){w(t,n,c)},this.swapPostConnections=function(t,n){w(t,n,a)},this.import=function(n){n.hasOwnProperty("context")&&(r=new h(n.context)).setParent(t),r.instanciate().then((function(){!function(t){let n=0,e=g.cast,o=y.cast;if(void 0!==t.preconnections)for(n=0;n<t.preconnections.length;n++)c.push(e(t.preconnections[n],r));if(void 0!==t.postconnections)for(n=0;n<t.postconnections.length;n++)a.push(e(t.postconnections[n],r));if(void 0!==t.cleanups)for(n=0;n<t.cleanups.length;n++)u.push(e(t.cleanups[n],r));if(void 0!==t.connections)for(n=0;n<t.connections.length;n++)l.push(o(t.connections[n],r))}(n)}))};let S=function(t){return{destination:r.getComponentName(t.getDestination()),slot:t.getSlot(),value:t.getValue()}};this.toJSON=function(){let t,n=[],e=[],o=[],i=[];for(t=0;t<l.length;t++)o.push((s=l[t],{source:r.getComponentName(s.getSource()),signal:s.getSignal(),destination:r.getComponentName(s.getDestination()),slot:s.getSlot()}));var s;for(t=0;t<c.length;t++)n.push(S(c[t]));for(t=0;t<a.length;t++)e.push(S(a[t]));for(t=0;t<u.length;t++)i.push(S(u[t]));return{preconnections:n,postconnections:e,connections:o,cleanups:i}},r.setParent(t)};let m=function(){var t=new h,n={},e={},i=[],s=this,r="";this.export=function(){return{context:t,controller:t.getComponentName(e),sheets:n}},this.getContext=function(){return t},this.getSheetList=function(){return Object.keys(n)},this.getSheet=function(t){return n[t]},this.addSheet=function(e,o){n[e]=o,o.setContext(t)},this.removeSheet=function(t){delete n[t]},this.launch=function(){var i,r,c;if(console.log("[ARCS] Starting application..."),r=t.getComponent(e),void 0!==(e=r)){for(c=Object.keys(n),i=0;i<c.length;i++)(r=new C(t)).import(n[c[i]],t),n[c[i]]=r;o.connect(e,"requestSheet",s,"setSheet"),o.connect(e,"requestTermination",s,"finish"),e.start()}else console.error("[ARCS] undefined controller")},this.setController=function(n){e=t.getComponent(n)},this.setSheet=function(t){n.hasOwnProperty(t)?(r&&n[r].deactivate(),n[r=t].activate()):console.warn("[ARCS] Tried to activate hollow sheet named: "+t)},this.finish=function(){r&&n[r].deactivate()},this.import=function(o){t=new h(o.context),n=o.sheets,void 0===(e=o.controller)&&console.error("[ARCS] Undefined controller. Cannot start application.")},this.setFactory=function(t,n){factories[t]=n},this.setDependency=function(t){i[t]={}},this.start=async function(){console.log("[ARCS] Instanciating components..."),await t.instanciate(),this.launch()}};m.setDependency=function(t,n){t.setDependency(n)},o.create(m),m.slot("setSheet"),m.slot("finish");const w={Component:o,isInNode:function(){return"undefined"!=typeof process&&-1!==process.release.name.search(/node|io.js/)},StateMachine:l,Context:h,Invocation:g,Connection:y,Sheet:C,Application:m};var S=n.Z;export{S as default};
{
"name": "arcsjs",
"version": "0.9.6",
"version": "0.9.7",
"description": "Augmented Reality Component System in web browser and node environment",

@@ -5,0 +5,0 @@ "homepage": "http://arcs.ibisc.fr",

@@ -72,4 +72,14 @@ /******************************************************************************

Connection.cast = function (obj, context) {
return new Connection(context.getComponent(obj.source)/*[obj.source].instance*/, obj.signal,
context.getComponent(obj.destination)/*[obj.destination].instance*/, obj.slot);
if (obj.from !== undefined) {
let components = obj.from.split('.');
obj.source = components[0];
obj.signal = components[1];
}
if (obj.to !== undefined) {
let components = obj.to.split('.');
obj.destination = components[0];
obj.slot = components[1];
}
return new Connection(context.getComponent(obj.source), obj.signal,
context.getComponent(obj.destination), obj.slot);
};

@@ -76,0 +86,0 @@

@@ -29,5 +29,7 @@ import StateMachine from './statemachine.js';

libraries = ctx.libraries;
var p;
for (p in ctx.components) {
Object.assign(components,ctx.components);
Object.assign(constants, ctx.constants);
//var p;
/*for (p in ctx.components) {
if (ctx.components.hasOwnProperty(p)) {

@@ -37,4 +39,5 @@ components[p] = ctx.components[p];

}
*/
if (ctx.constants !== undefined) {
/*if (ctx.constants !== undefined) {
for (p in ctx.constants) {

@@ -45,3 +48,3 @@ if (ctx.constants.hasOwnProperty(p)) {

}
}
}*/

@@ -81,2 +84,6 @@ }

// TODO if, one day, we want to instanciate a component with several components,
// it would be done in two phases:
// 1/ new cmp = new XXX()
// 2/ XXX.apply(cmp, [...])
var instanciateComponents = async function() {

@@ -295,4 +302,7 @@ var p, promises=[];

// due to javascript engine optimizations
var newObj = Object.create(proto);
var p ;
// TODO would it be better to use the 2nd version of create
//var newObj = Object.create(proto);
let newObj = Object.create(proto, obj);
/*var p ;

@@ -303,3 +313,3 @@ for (p in obj) {

}
}
}*/
return newObj;

@@ -306,0 +316,0 @@ };

@@ -55,2 +55,9 @@ /******************************************************************************

Invocation.cast = function (obj, context) {
if (obj.call !== undefined) {
let components = obj.call.split('.');
obj.destination = components[0];
obj.slot = components[1];
}
let component = context.getComponent(obj.destination);

@@ -60,4 +67,3 @@ if (component === undefined) {

}
if (obj.value !== undefined) {

@@ -64,0 +70,0 @@ return new Invocation(component, obj.slot, obj.value);

@@ -18,3 +18,3 @@ /* the aim of the transition network is to build a network of promises */

this.eval = function(tokenEvents) {
return left.eval(tokenEvents) && left.eval(tokenEvents);
return left.eval(tokenEvents) && right.eval(tokenEvents);
};

@@ -21,0 +21,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc