vega-runtime
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -274,3 +274,4 @@ (function (global, factory) { | ||
function parseUpdate(spec, ctx) { | ||
var source = ctx.get(spec.source), | ||
var srcid = vegaUtil.isObject(srcid = spec.source) ? srcid.$ref : srcid, | ||
source = ctx.get(srcid), | ||
target = null, | ||
@@ -277,0 +278,0 @@ update = spec.update, |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util"],t):t(e.vega={},e.vega,e.vega)}(this,function(e,a,i){"use strict";function s(e,t,n){";"!==t[t.length-1]&&(t="return("+t+");");var r=Function.apply(null,e.concat(t));return n&&n.functions?r.bind(n.functions):r}function u(e,t){return s(["event"],e,t)}function c(e,t,n){var r,a;for(r in n=n||{},e)(a=e[r])&&a.$expr&&a.$params&&c(a.$params,t,n),n[r]=i.isArray(a)?a.map(function(e){return o(e,t)}):o(a,t);return n}function o(e,t){if(!e||!i.isObject(e))return e;for(var n,r=0,a=f.length;r<a;++r)if(n=f[r],e.hasOwnProperty(n.key))return n.parse(e,t);return e}var f=[{key:"$ref",parse:function(e,t){return t.get(e.$ref)||i.error("Operator not defined: "+e.$ref)}},{key:"$key",parse:function(e,t){var n="k:"+e.$key+"_"+!!e.$flat;return t.fn[n]||(t.fn[n]=i.key(e.$key,e.$flat))}},{key:"$expr",parse:function(e,t){var n="e:"+e.$expr;return t.fn[n]||(t.fn[n]=i.accessor((r=e.$expr,a=t,s(["datum","_"],r,a)),e.$fields,e.$name));var r,a}},{key:"$field",parse:function(e,t){if(!e.$field)return null;var n="f:"+e.$field+"_"+e.$name;return t.fn[n]||(t.fn[n]=i.field(e.$field,e.$name))}},{key:"$encode",parse:function(e,t){var n,r,a=e.$encode,o={};for(n in a)r=a[n],o[n]=i.accessor(s(["item","_"],r.$expr,t),r.$fields),o[n].output=r.$output;return o}},{key:"$compare",parse:function(e,t){var n="c:"+e.$compare+"_"+e.$order,r=i.array(e.$compare).map(function(e){return e&&e.$tupleid?a.tupleid:e});return t.fn[n]||(t.fn[n]=i.compare(r,e.$order))}},{key:"$context",parse:function(e,t){return t}},{key:"$subflow",parse:function(e,s){var i=e.$subflow;return function(e,t,n){var r=l(i,s.fork()),a=r.get(i.operators[0].id),o=r.signals.parent;return o&&o.set(n),a}}},{key:"$tupleid",parse:function(){return a.tupleid}}];function d(e){return(e+"").toLowerCase()}function n(e,t){"operator"!==d(e.type)&&e.type?t.transform(e,e.type):t.operator(e,e.update?s(["_"],e.update,t):null)}function r(e,t){var n=t.get(e.source),r=null,a=e.update,o=void 0;n||i.error("Source not defined: "+e.source),r=e.target&&e.target.$expr?u(e.target.$expr,t):t.get(e.target),a&&a.$expr&&(a.$params&&(o=c(a.$params,t)),a=s(["_","event"],a.$expr,t)),t.update(e,n,r,a,o)}function l(e,s){var t=e.operators||[];return e.background&&(s.background=e.background),e.eventConfig&&(s.eventConfig=e.eventConfig),t.forEach(function(e){n(e,s)}),t.forEach(function(e){var t,n,r,a;n=s,(t=e).params&&((r=n.get(t.id))||i.error("Invalid operator id: "+t.id),a=c(t.params,n),n.dataflow.connect(r,r.parameters(a)))}),(e.streams||[]).forEach(function(e){var t,n,r,a,o;n=s,a=null!=(t=e).filter?u(t.filter,n):void 0,o=null!=t.stream?n.get(t.stream):void 0,t.source?o=n.events(t.source,t.type,a):t.merge&&(o=(r=t.merge.map(n.get.bind(n)))[0].merge.apply(r[0],r.slice(1))),t.between&&(r=t.between.map(n.get.bind(n)),o=o.between(r[0],r[1])),t.filter&&(o=o.filter(a)),null!=t.throttle&&(o=o.throttle(+t.throttle)),null!=t.debounce&&(o=o.debounce(+t.debounce)),null==o&&i.error("Invalid stream definition: "+JSON.stringify(t)),t.consume&&o.consume(!0),n.stream(t,o)}),(e.updates||[]).forEach(function(e){r(e,s)}),s.resolve()}var p={skip:!0};function h(e,t,n){this.dataflow=e,this.transforms=t,this.events=e.events.bind(e),this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this)}function t(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.functions=e.functions,this.events=e.events,this.signals=Object.create(e.signals),this.scales=Object.create(e.scales),this.nodes=Object.create(e.nodes),this.data=Object.create(e.data),this.fn=Object.create(e.fn),e.functions&&(this.functions=Object.create(e.functions),this.functions.context=this)}h.prototype=t.prototype={fork:function(){var e=new t(this);return(this.subcontext||(this.subcontext=[])).push(e),e},get:function(e){return this.nodes[e]},set:function(e,t){return this.nodes[e]=t},add:function(e,t){var n,r=this,a=r.dataflow;if(r.set(e.id,t),"collect"===d(e.type)&&(n=e.value)&&(n.$ingest?a.ingest(t,n.$ingest,n.$format):n.$request?a.request(t,n.$request,n.$format):a.pulse(t,a.changeset().insert(n))),e.root&&(r.root=t),e.parent){var o=r.get(e.parent.$ref);o?(a.connect(o,[t]),t.targets().add(o)):(r.unresolved=r.unresolved||[]).push(function(){o=r.get(e.parent.$ref),a.connect(o,[t]),t.targets().add(o)})}if(e.signal&&(r.signals[e.signal]=t),e.scale&&(r.scales[e.scale]=t),e.data)for(var s in e.data)n=r.data[s]||(r.data[s]={}),e.data[s].forEach(function(e){n[e]=t})},resolve:function(){return(this.unresolved||[]).forEach(function(e){e()}),delete this.unresolved,this},operator:function(e,t,n){this.add(e,this.dataflow.add(e.value,t,n,e.react))},transform:function(e,t,n){this.add(e,this.dataflow.add(this.transforms[d(t)],n))},stream:function(e,t){this.set(e.id,t)},update:function(e,t,n,r,a){this.dataflow.on(t,n,r,a,e.options)},getState:function(n){var r=this,e={};if(n.signals){var a=e.signals={};Object.keys(r.signals).forEach(function(e){var t=r.signals[e];n.signals(e,t)&&(a[e]=t.value)})}if(n.data){var o=e.data={};Object.keys(r.data).forEach(function(e){var t=r.data[e];n.data(e,t)&&(o[e]=t.input.value)})}return r.subcontext&&!1!==n.recurse&&(e.subcontext=r.subcontext.map(function(e){return e.getState(n)})),e},setState:function(e){var r=this,t=r.dataflow,n=e.data,a=e.signals;Object.keys(a||{}).forEach(function(e){t.update(r.signals[e],a[e],p)}),Object.keys(n||{}).forEach(function(e){t.pulse(r.data[e].input,t.changeset().remove(i.truthy).insert(n[e]))}),(e.subcontext||[]).forEach(function(e,t){var n=r.subcontext[t];n&&n.setState(e)})}},e.parse=l,e.context=function(e,t,n){return new h(e,t,n)},e.expression=s,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util"],t):t(e.vega={},e.vega,e.vega)}(this,function(e,a,i){"use strict";function u(e,t,n){";"!==t[t.length-1]&&(t="return("+t+");");var r=Function.apply(null,e.concat(t));return n&&n.functions?r.bind(n.functions):r}function c(e,t){return u(["event"],e,t)}function f(e,t,n){var r,a;for(r in n=n||{},e)(a=e[r])&&a.$expr&&a.$params&&f(a.$params,t,n),n[r]=i.isArray(a)?a.map(function(e){return s(e,t)}):s(a,t);return n}function s(e,t){if(!e||!i.isObject(e))return e;for(var n,r=0,a=o.length;r<a;++r)if(n=o[r],e.hasOwnProperty(n.key))return n.parse(e,t);return e}var o=[{key:"$ref",parse:function(e,t){return t.get(e.$ref)||i.error("Operator not defined: "+e.$ref)}},{key:"$key",parse:function(e,t){var n="k:"+e.$key+"_"+!!e.$flat;return t.fn[n]||(t.fn[n]=i.key(e.$key,e.$flat))}},{key:"$expr",parse:function(e,t){var n="e:"+e.$expr;return t.fn[n]||(t.fn[n]=i.accessor((r=e.$expr,a=t,u(["datum","_"],r,a)),e.$fields,e.$name));var r,a}},{key:"$field",parse:function(e,t){if(!e.$field)return null;var n="f:"+e.$field+"_"+e.$name;return t.fn[n]||(t.fn[n]=i.field(e.$field,e.$name))}},{key:"$encode",parse:function(e,t){var n,r,a=e.$encode,s={};for(n in a)r=a[n],s[n]=i.accessor(u(["item","_"],r.$expr,t),r.$fields),s[n].output=r.$output;return s}},{key:"$compare",parse:function(e,t){var n="c:"+e.$compare+"_"+e.$order,r=i.array(e.$compare).map(function(e){return e&&e.$tupleid?a.tupleid:e});return t.fn[n]||(t.fn[n]=i.compare(r,e.$order))}},{key:"$context",parse:function(e,t){return t}},{key:"$subflow",parse:function(e,o){var i=e.$subflow;return function(e,t,n){var r=l(i,o.fork()),a=r.get(i.operators[0].id),s=r.signals.parent;return s&&s.set(n),a}}},{key:"$tupleid",parse:function(){return a.tupleid}}];function d(e){return(e+"").toLowerCase()}function n(e,t){"operator"!==d(e.type)&&e.type?t.transform(e,e.type):t.operator(e,e.update?u(["_"],e.update,t):null)}function r(e,t){var n=i.isObject(n=e.source)?n.$ref:n,r=t.get(n),a=null,s=e.update,o=void 0;r||i.error("Source not defined: "+e.source),a=e.target&&e.target.$expr?c(e.target.$expr,t):t.get(e.target),s&&s.$expr&&(s.$params&&(o=f(s.$params,t)),s=u(["_","event"],s.$expr,t)),t.update(e,r,a,s,o)}function l(e,o){var t=e.operators||[];return e.background&&(o.background=e.background),e.eventConfig&&(o.eventConfig=e.eventConfig),t.forEach(function(e){n(e,o)}),t.forEach(function(e){var t,n,r,a;n=o,(t=e).params&&((r=n.get(t.id))||i.error("Invalid operator id: "+t.id),a=f(t.params,n),n.dataflow.connect(r,r.parameters(a)))}),(e.streams||[]).forEach(function(e){var t,n,r,a,s;n=o,a=null!=(t=e).filter?c(t.filter,n):void 0,s=null!=t.stream?n.get(t.stream):void 0,t.source?s=n.events(t.source,t.type,a):t.merge&&(s=(r=t.merge.map(n.get.bind(n)))[0].merge.apply(r[0],r.slice(1))),t.between&&(r=t.between.map(n.get.bind(n)),s=s.between(r[0],r[1])),t.filter&&(s=s.filter(a)),null!=t.throttle&&(s=s.throttle(+t.throttle)),null!=t.debounce&&(s=s.debounce(+t.debounce)),null==s&&i.error("Invalid stream definition: "+JSON.stringify(t)),t.consume&&s.consume(!0),n.stream(t,s)}),(e.updates||[]).forEach(function(e){r(e,o)}),o.resolve()}var p={skip:!0};function h(e,t,n){this.dataflow=e,this.transforms=t,this.events=e.events.bind(e),this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this)}function t(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.functions=e.functions,this.events=e.events,this.signals=Object.create(e.signals),this.scales=Object.create(e.scales),this.nodes=Object.create(e.nodes),this.data=Object.create(e.data),this.fn=Object.create(e.fn),e.functions&&(this.functions=Object.create(e.functions),this.functions.context=this)}h.prototype=t.prototype={fork:function(){var e=new t(this);return(this.subcontext||(this.subcontext=[])).push(e),e},get:function(e){return this.nodes[e]},set:function(e,t){return this.nodes[e]=t},add:function(e,t){var n,r=this,a=r.dataflow;if(r.set(e.id,t),"collect"===d(e.type)&&(n=e.value)&&(n.$ingest?a.ingest(t,n.$ingest,n.$format):n.$request?a.request(t,n.$request,n.$format):a.pulse(t,a.changeset().insert(n))),e.root&&(r.root=t),e.parent){var s=r.get(e.parent.$ref);s?(a.connect(s,[t]),t.targets().add(s)):(r.unresolved=r.unresolved||[]).push(function(){s=r.get(e.parent.$ref),a.connect(s,[t]),t.targets().add(s)})}if(e.signal&&(r.signals[e.signal]=t),e.scale&&(r.scales[e.scale]=t),e.data)for(var o in e.data)n=r.data[o]||(r.data[o]={}),e.data[o].forEach(function(e){n[e]=t})},resolve:function(){return(this.unresolved||[]).forEach(function(e){e()}),delete this.unresolved,this},operator:function(e,t,n){this.add(e,this.dataflow.add(e.value,t,n,e.react))},transform:function(e,t,n){this.add(e,this.dataflow.add(this.transforms[d(t)],n))},stream:function(e,t){this.set(e.id,t)},update:function(e,t,n,r,a){this.dataflow.on(t,n,r,a,e.options)},getState:function(n){var r=this,e={};if(n.signals){var a=e.signals={};Object.keys(r.signals).forEach(function(e){var t=r.signals[e];n.signals(e,t)&&(a[e]=t.value)})}if(n.data){var s=e.data={};Object.keys(r.data).forEach(function(e){var t=r.data[e];n.data(e,t)&&(s[e]=t.input.value)})}return r.subcontext&&!1!==n.recurse&&(e.subcontext=r.subcontext.map(function(e){return e.getState(n)})),e},setState:function(e){var r=this,t=r.dataflow,n=e.data,a=e.signals;Object.keys(a||{}).forEach(function(e){t.update(r.signals[e],a[e],p)}),Object.keys(n||{}).forEach(function(e){t.pulse(r.data[e].input,t.changeset().remove(i.truthy).insert(n[e]))}),(e.subcontext||[]).forEach(function(e,t){var n=r.subcontext[t];n&&n.setState(e)})}},e.parse=l,e.context=function(e,t,n){return new h(e,t,n)},e.expression=u,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-runtime", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Runtime support for Vega dataflows.", | ||
@@ -27,7 +27,7 @@ "keywords": [ | ||
"test": "tape 'test/**/*-test.js' && eslint index.js src test", | ||
"prepublish": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"postpublish": "git push && git push --tags && zip -j build/vega-runtime.zip -- LICENSE README.md build/vega-runtime.js build/vega-runtime.min.js" | ||
}, | ||
"dependencies": { | ||
"vega-dataflow": "^4.0.0", | ||
"vega-dataflow": "^4.0.1", | ||
"vega-util": "^1.7.0" | ||
@@ -34,0 +34,0 @@ }, |
import {eventExpression, handlerExpression} from './expression'; | ||
import parseParameters from './parameters'; | ||
import {error} from 'vega-util'; | ||
import {error, isObject} from 'vega-util'; | ||
@@ -9,3 +9,4 @@ /** | ||
export default function(spec, ctx) { | ||
var source = ctx.get(spec.source), | ||
var srcid = isObject(srcid = spec.source) ? srcid.$ref : srcid, | ||
source = ctx.get(srcid), | ||
target = null, | ||
@@ -12,0 +13,0 @@ update = spec.update, |
35883
17
914
Updatedvega-dataflow@^4.0.1