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

vega-runtime

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-runtime - npm Package Compare versions

Comparing version 6.1.2 to 6.1.3

build/vega-runtime.min.js.map

256

build/vega-runtime.js

@@ -10,33 +10,28 @@ (function (global, factory) {

*/
function parse(spec) {
function parse (spec) {
const ctx = this,
operators = spec.operators || [];
operators = spec.operators || []; // parse background
// parse background
if (spec.background) {
ctx.background = spec.background;
}
} // parse event configuration
// parse event configuration
if (spec.eventConfig) {
ctx.eventConfig = spec.eventConfig;
}
} // parse locale configuration
// parse locale configuration
if (spec.locale) {
ctx.locale = spec.locale;
}
} // parse operators
// parse operators
operators.forEach(entry => ctx.parseOperator(entry));
// parse operator parameters
operators.forEach(entry => ctx.parseOperatorParameters(entry));
operators.forEach(entry => ctx.parseOperator(entry)); // parse operator parameters
// parse streams
(spec.streams || []).forEach(entry => ctx.parseStream(entry));
operators.forEach(entry => ctx.parseOperatorParameters(entry)); // parse streams
// parse updates
(spec.streams || []).forEach(entry => ctx.parseStream(entry)); // parse updates
(spec.updates || []).forEach(entry => ctx.parseUpdate(entry));
return ctx.resolve();

@@ -47,6 +42,4 @@ }

Swap = vegaUtil.toSet(['group', 'image', 'rect']);
function adjustSpatial(encode, marktype) {
let code = '';
if (Skip[marktype]) return code;

@@ -59,2 +52,3 @@

}
code += 'o.width=o.x2-o.x;';

@@ -75,2 +69,3 @@ } else {

}
code += 'o.height=o.y2-o.y;';

@@ -88,11 +83,8 @@ } else {

}
function canonicalType(type) {
return (type + '').toLowerCase();
}
function isOperator(type) {
return canonicalType(type) === 'operator';
return canonicalType(type) === 'operator';
}
function isCollect(type) {

@@ -104,10 +96,11 @@ return canonicalType(type) === 'collect';

// wrap code in return statement if expression does not terminate
if (code[code.length-1] !== ';') {
if (code[code.length - 1] !== ';') {
code = 'return(' + code + ');';
}
var fn = Function.apply(null, args.concat(code));
const fn = Function(...args.concat(code));
return ctx && ctx.functions ? fn.bind(ctx.functions) : fn;
}
} // generate code for comparing a single field
// generate code for comparing a single field
function _compare(u, v, lt, gt) {

@@ -148,12 +141,15 @@ return `((u = ${u}) < (v = ${v}) || u == null) && v != null ? ${lt}

encode: (ctx, encode) => {
const {marktype, channels} = encode;
const {
marktype,
channels
} = encode;
let code = 'var o=item,datum=o.datum,m=0,$;';
let code = 'var o=item,datum=o.datum,m=0,$;';
for (const name in channels) {
const o ='o[' + vegaUtil.stringValue(name) + ']';
const o = 'o[' + vegaUtil.stringValue(name) + ']';
code += `$=${channels[name].code};if(${o}!==$)${o}=$,m=1;`;
}
code += adjustSpatial(channels, marktype);
code += 'return m;';
return expression(ctx, ['item', '_'], code);

@@ -172,7 +168,10 @@ },

},
comparator(fields, orders) {
let t;
const map = (f, i) => {
const o = orders[i];
let u, v;
if (f.path) {

@@ -182,13 +181,14 @@ u = `a${f.path}`;

} else {
(t = t || {})['f'+i] = f;
(t = t || {})['f' + i] = f;
u = `this.f${i}(a)`;
v = `this.f${i}(b)`;
}
return _compare(u, v, -o, o);
};
const fn = Function('a', 'b', 'var u, v; return '
+ fields.map(map).join('') + '0;');
const fn = Function('a', 'b', 'var u, v; return ' + fields.map(map).join('') + '0;');
return t ? fn.bind(t) : fn;
}
}

@@ -200,9 +200,8 @@ };

*/
function parseOperator(spec) {
const ctx = this;
if (isOperator(spec.type) || !spec.type) {
ctx.operator(
spec,
spec.update ? ctx.operatorExpression(spec.update) : null
);
ctx.operator(spec, spec.update ? ctx.operatorExpression(spec.update) : null);
} else {

@@ -212,16 +211,13 @@ ctx.transform(spec, spec.type);

}
/**
* Parse and assign operator parameters.
*/
function parseOperatorParameters(spec) {
const ctx = this;
if (spec.params) {
const op = ctx.get(spec.id);
if (!op) vegaUtil.error('Invalid operator id: ' + spec.id);
ctx.dataflow.connect(op, op.parameters(
ctx.parseParameters(spec.params),
spec.react,
spec.initonly
));
ctx.dataflow.connect(op, op.parameters(ctx.parseParameters(spec.params), spec.react, spec.initonly));
}

@@ -233,2 +229,3 @@ }

*/
function parseParameters(spec, params) {

@@ -240,5 +237,3 @@ params = params || {};

const value = spec[key];
params[key] = vegaUtil.isArray(value)
? value.map(v => parseParameter(v, ctx, params))
: parseParameter(value, ctx, params);
params[key] = vegaUtil.isArray(value) ? value.map(v => parseParameter(v, ctx, params)) : parseParameter(value, ctx, params);
}

@@ -248,11 +243,12 @@

}
/**
* Parse a single parameter.
*/
function parseParameter(spec, ctx, params) {
if (!spec || !vegaUtil.isObject(spec)) return spec;
for (let i=0, n=PARSERS.length, p; i<n; ++i) {
for (let i = 0, n = PARSERS.length, p; i < n; ++i) {
p = PARSERS[i];
if (vegaUtil.hasOwnProperty(spec, p.key)) {

@@ -265,49 +261,68 @@ return p.parse(spec, ctx, params);

}
/** Reference parsers. */
var PARSERS = [
{key: '$ref', parse: getOperator},
{key: '$key', parse: getKey},
{key: '$expr', parse: getExpression},
{key: '$field', parse: getField},
{key: '$encode', parse: getEncode},
{key: '$compare', parse: getCompare},
{key: '$context', parse: getContext},
{key: '$subflow', parse: getSubflow},
{key: '$tupleid', parse: getTupleId}
];
var PARSERS = [{
key: '$ref',
parse: getOperator
}, {
key: '$key',
parse: getKey
}, {
key: '$expr',
parse: getExpression
}, {
key: '$field',
parse: getField
}, {
key: '$encode',
parse: getEncode
}, {
key: '$compare',
parse: getCompare
}, {
key: '$context',
parse: getContext
}, {
key: '$subflow',
parse: getSubflow
}, {
key: '$tupleid',
parse: getTupleId
}];
/**
* Resolve an operator reference.
*/
function getOperator(_, ctx) {
return ctx.get(_.$ref) || vegaUtil.error('Operator not defined: ' + _.$ref);
}
/**
* Resolve an expression reference.
*/
function getExpression(_, ctx, params) {
if (_.$params) { // parse expression parameters
if (_.$params) {
// parse expression parameters
ctx.parseParameters(_.$params, params);
}
const k = 'e:' + _.$expr.code + '_' + _.$name;
return ctx.fn[k] || (ctx.fn[k] = vegaUtil.accessor(
ctx.parameterExpression(_.$expr),
_.$fields,
_.$name
));
return ctx.fn[k] || (ctx.fn[k] = vegaUtil.accessor(ctx.parameterExpression(_.$expr), _.$fields, _.$name));
}
/**
* Resolve a key accessor reference.
*/
function getKey(_, ctx) {
const k = 'k:' + _.$key + '_' + (!!_.$flat);
const k = 'k:' + _.$key + '_' + !!_.$flat;
return ctx.fn[k] || (ctx.fn[k] = vegaUtil.key(_.$key, _.$flat, ctx.expr.codegen));
}
/**
* Resolve a field accessor reference.
*/
function getField(_, ctx) {

@@ -318,6 +333,7 @@ if (!_.$field) return null;

}
/**
* Resolve a comparator function reference.
*/
function getCompare(_, ctx) {

@@ -327,9 +343,10 @@ // As of Vega 5.5.3, $tupleid sort is no longer used.

const k = 'c:' + _.$compare + '_' + _.$order,
c = vegaUtil.array(_.$compare).map(_ => (_ && _.$tupleid) ? vegaDataflow.tupleid : _);
c = vegaUtil.array(_.$compare).map(_ => _ && _.$tupleid ? vegaDataflow.tupleid : _);
return ctx.fn[k] || (ctx.fn[k] = vegaUtil.compare(c, _.$order, ctx.expr.codegen));
}
/**
* Resolve an encode operator reference.
*/
function getEncode(_, ctx) {

@@ -344,18 +361,21 @@ const spec = _.$encode,

}
return encode;
}
/**
* Resolve a context reference.
*/
function getContext(_, ctx) {
return ctx;
}
/**
* Resolve a recursive subflow specification.
*/
function getSubflow(_, ctx) {
const spec = _.$subflow;
return function(dataflow, key, parent) {
return function (dataflow, key, parent) {
const subctx = ctx.fork().parse(spec),

@@ -365,10 +385,13 @@ op = subctx.get(spec.operators[0].id),

if (p) p.set(parent);
op.detachSubflow = () => ctx.detach(subctx);
return op;
};
}
/**
* Resolve a tuple id reference.
*/
function getTupleId() {

@@ -381,3 +404,4 @@ return vegaDataflow.tupleid;

*/
function parseStream(spec) {
function parseStream (spec) {
var ctx = this,

@@ -390,4 +414,3 @@ filter = spec.filter != null ? ctx.eventExpression(spec.filter) : undefined,

stream = ctx.events(spec.source, spec.type, filter);
}
else if (spec.merge) {
} else if (spec.merge) {
args = spec.merge.map(_ => ctx.get(_));

@@ -419,3 +442,2 @@ stream = args[0].merge.apply(args[0], args.slice(1));

if (spec.consume) stream.consume(true);
ctx.stream(spec, stream);

@@ -427,3 +449,4 @@ }

*/
function parseUpdate(spec) {
function parseUpdate (spec) {
var ctx = this,

@@ -435,9 +458,5 @@ srcid = vegaUtil.isObject(srcid = spec.source) ? srcid.$ref : srcid,

params = undefined;
if (!source) vegaUtil.error('Source not defined: ' + spec.source);
target = spec.target && spec.target.$expr ? ctx.eventExpression(spec.target.$expr) : ctx.get(spec.target);
target = spec.target && spec.target.$expr
? ctx.eventExpression(spec.target.$expr)
: ctx.get(spec.target);
if (update && update.$expr) {

@@ -447,2 +466,3 @@ if (update.$params) {

}
update = ctx.handlerExpression(update.$expr);

@@ -454,4 +474,5 @@ }

var SKIP = {skip: true};
const SKIP = {
skip: true
};
function getState(options) {

@@ -462,5 +483,6 @@ var ctx = this,

if (options.signals) {
var signals = (state.signals = {});
var signals = state.signals = {};
Object.keys(ctx.signals).forEach(key => {
var op = ctx.signals[key];
const op = ctx.signals[key];
if (options.signals(key, op)) {

@@ -473,5 +495,6 @@ signals[key] = op.value;

if (options.data) {
var data = (state.data = {});
var data = state.data = {};
Object.keys(ctx.data).forEach(key => {
var dataset = ctx.data[key];
const dataset = ctx.data[key];
if (options.data(key, dataset)) {

@@ -489,3 +512,2 @@ data[key] = dataset.input.value;

}
function setState(state) {

@@ -496,16 +518,10 @@ var ctx = this,

signals = state.signals;
Object.keys(signals || {}).forEach(key => {
df.update(ctx.signals[key], signals[key], SKIP);
});
Object.keys(data || {}).forEach(key => {
df.pulse(
ctx.data[key].input,
df.changeset().remove(vegaUtil.truthy).insert(data[key])
);
df.pulse(ctx.data[key].input, df.changeset().remove(vegaUtil.truthy).insert(data[key]));
});
(state.subcontext || []).forEach((substate, i) => {
var subctx = ctx.subcontext[i];
(state.subcontext || []).forEach((substate, i) => {
const subctx = ctx.subcontext[i];
if (subctx) subctx.setState(substate);

@@ -520,3 +536,4 @@ });

*/
function context(df, transforms, functions, expr) {
function context (df, transforms, functions, expr) {
return new Context(df, transforms, functions, expr);

@@ -529,4 +546,3 @@ }

this.events = df.events.bind(df);
this.expr = expr || expressionCodegen,
this.signals = {};
this.expr = expr || expressionCodegen, this.signals = {};
this.scales = {};

@@ -536,2 +552,3 @@ this.nodes = {};

this.fn = {};
if (functions) {

@@ -553,2 +570,3 @@ this.functions = Object.create(functions);

this.fn = Object.create(ctx.fn);
if (ctx.functions) {

@@ -566,18 +584,24 @@ this.functions = Object.create(ctx.functions);

},
detach(ctx) {
this.subcontext = this.subcontext.filter(c => c !== ctx);
this.subcontext = this.subcontext.filter(c => c !== ctx); // disconnect all nodes in the subcontext
// wipe out targets first for better efficiency
// disconnect all nodes in the subcontext
// wipe out targets first for better efficiency
const keys = Object.keys(ctx.nodes);
for (const key of keys) ctx.nodes[key]._targets = null;
for (const key of keys) ctx.nodes[key].detach();
ctx.nodes = null;
},
get(id) {
return this.nodes[id];
},
set(id, node) {
return this.nodes[id] = node;
},
add(spec, op) {

@@ -587,3 +611,2 @@ const ctx = this,

data = spec.value;
ctx.set(spec.id, op);

@@ -606,3 +629,4 @@

if (spec.parent) {
var p = ctx.get(spec.parent.$ref);
let p = ctx.get(spec.parent.$ref);
if (p) {

@@ -635,2 +659,3 @@ df.connect(p, [op]);

},
resolve() {

@@ -641,11 +666,15 @@ (this.unresolved || []).forEach(fn => fn());

},
operator(spec, update) {
this.add(spec, this.dataflow.add(spec.value, update));
},
transform(spec, type) {
this.add(spec, this.dataflow.add(this.transforms[canonicalType(type)]));
},
stream(spec, stream) {
this.set(spec.id, stream);
},
update(spec, stream, target, update, params) {

@@ -659,11 +688,15 @@ this.dataflow.on(stream, target, update, params, spec.options);

},
parameterExpression(expr) {
return this.expr.parameter(this, expr);
},
eventExpression(expr) {
return this.expr.event(this, expr);
},
handlerExpression(expr) {
return this.expr.handler(this, expr);
},
encodeExpression(encode) {

@@ -680,3 +713,2 @@ return this.expr.encode(this, encode);

parseUpdate,
// state methods

@@ -683,0 +715,0 @@ getState,

@@ -1,1 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-dataflow")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega={},e.vega,e.vega)}(this,(function(e,t,r){"use strict";const n=t.toSet(["rule"]),o=t.toSet(["group","image","rect"]);function a(e){return(e+"").toLowerCase()}function s(e,t,r){";"!==r[r.length-1]&&(r="return("+r+");");var n=Function.apply(null,t.concat(r));return e&&e.functions?n.bind(e.functions):n}var i={operator:(e,t)=>s(e,["_"],t.code),parameter:(e,t)=>s(e,["datum","_"],t.code),event:(e,t)=>s(e,["event"],t.code),handler:(e,t)=>s(e,["_","event"],`var datum=event.item&&event.item.datum;return ${t.code};`),encode:(e,r)=>{const{marktype:a,channels:i}=r;let c="var o=item,datum=o.datum,m=0,$;";for(const e in i){const r="o["+t.stringValue(e)+"]";c+=`$=${i[e].code};if(${r}!==$)${r}=$,m=1;`}return c+=function(e,t){let r="";return n[t]||(e.x2&&(e.x?(o[t]&&(r+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"),r+="o.width=o.x2-o.x;"):r+="o.x=o.x2-(o.width||0);"),e.xc&&(r+="o.x=o.xc-(o.width||0)/2;"),e.y2&&(e.y?(o[t]&&(r+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"),r+="o.height=o.y2-o.y;"):r+="o.y=o.y2-(o.height||0);"),e.yc&&(r+="o.y=o.yc-(o.height||0)/2;")),r}(i,a),c+="return m;",s(e,["item","_"],c)},codegen:{get(e){const r=`[${e.map(t.stringValue).join("][")}]`,n=Function("_",`return _${r};`);return n.path=r,n},comparator(e,t){let r;const n=Function("a","b","var u, v; return "+e.map((e,n)=>{const o=t[n];let a,s;return e.path?(a="a"+e.path,s="b"+e.path):((r=r||{})["f"+n]=e,a=`this.f${n}(a)`,s=`this.f${n}(b)`),function(e,t,r,n){return`((u = ${e}) < (v = ${t}) || u == null) && v != null ? ${r}\n : (u > v || v == null) && u != null ? ${n}\n : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${r}\n : v !== v && u === u ? ${n} : `}(a,s,-o,o)}).join("")+"0;");return r?n.bind(r):n}}};function c(e,r,n){if(!e||!t.isObject(e))return e;for(let o,a=0,s=u.length;a<s;++a)if(o=u[a],t.hasOwnProperty(e,o.key))return o.parse(e,r,n);return e}var u=[{key:"$ref",parse:function(e,r){return r.get(e.$ref)||t.error("Operator not defined: "+e.$ref)}},{key:"$key",parse:function(e,r){const n="k:"+e.$key+"_"+!!e.$flat;return r.fn[n]||(r.fn[n]=t.key(e.$key,e.$flat,r.expr.codegen))}},{key:"$expr",parse:function(e,r,n){e.$params&&r.parseParameters(e.$params,n);const o="e:"+e.$expr.code+"_"+e.$name;return r.fn[o]||(r.fn[o]=t.accessor(r.parameterExpression(e.$expr),e.$fields,e.$name))}},{key:"$field",parse:function(e,r){if(!e.$field)return null;const n="f:"+e.$field+"_"+e.$name;return r.fn[n]||(r.fn[n]=t.field(e.$field,e.$name,r.expr.codegen))}},{key:"$encode",parse:function(e,r){const n=e.$encode,o={};for(const e in n){const a=n[e];o[e]=t.accessor(r.encodeExpression(a.$expr),a.$fields),o[e].output=a.$output}return o}},{key:"$compare",parse:function(e,n){const o="c:"+e.$compare+"_"+e.$order,a=t.array(e.$compare).map(e=>e&&e.$tupleid?r.tupleid:e);return n.fn[o]||(n.fn[o]=t.compare(a,e.$order,n.expr.codegen))}},{key:"$context",parse:function(e,t){return t}},{key:"$subflow",parse:function(e,t){const r=e.$subflow;return function(e,n,o){const a=t.fork().parse(r),s=a.get(r.operators[0].id),i=a.signals.parent;return i&&i.set(o),s.detachSubflow=()=>t.detach(a),s}}},{key:"$tupleid",parse:function(){return r.tupleid}}];var p={skip:!0};function f(e,t,r,n){this.dataflow=e,this.transforms=t,this.events=e.events.bind(e),this.expr=n||i,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},r&&(this.functions=Object.create(r),this.functions.context=this)}function d(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.events=e.events,this.expr=e.expr,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)}f.prototype=d.prototype={fork(){const e=new d(this);return(this.subcontext||(this.subcontext=[])).push(e),e},detach(e){this.subcontext=this.subcontext.filter(t=>t!==e);const t=Object.keys(e.nodes);for(const r of t)e.nodes[r]._targets=null;for(const r of t)e.nodes[r].detach();e.nodes=null},get(e){return this.nodes[e]},set(e,t){return this.nodes[e]=t},add(e,t){const r=this,n=r.dataflow,o=e.value;if(r.set(e.id,t),"collect"===a(e.type)&&o&&(o.$ingest?n.ingest(t,o.$ingest,o.$format):o.$request?n.preload(t,o.$request,o.$format):n.pulse(t,n.changeset().insert(o))),e.root&&(r.root=t),e.parent){var s=r.get(e.parent.$ref);s?(n.connect(s,[t]),t.targets().add(s)):(r.unresolved=r.unresolved||[]).push(()=>{s=r.get(e.parent.$ref),n.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(const n in e.data){const o=r.data[n]||(r.data[n]={});e.data[n].forEach(e=>o[e]=t)}},resolve(){return(this.unresolved||[]).forEach(e=>e()),delete this.unresolved,this},operator(e,t){this.add(e,this.dataflow.add(e.value,t))},transform(e,t){this.add(e,this.dataflow.add(this.transforms[a(t)]))},stream(e,t){this.set(e.id,t)},update(e,t,r,n,o){this.dataflow.on(t,r,n,o,e.options)},operatorExpression(e){return this.expr.operator(this,e)},parameterExpression(e){return this.expr.parameter(this,e)},eventExpression(e){return this.expr.event(this,e)},handlerExpression(e){return this.expr.handler(this,e)},encodeExpression(e){return this.expr.encode(this,e)},parse:function(e){const t=this,r=e.operators||[];return e.background&&(t.background=e.background),e.eventConfig&&(t.eventConfig=e.eventConfig),e.locale&&(t.locale=e.locale),r.forEach(e=>t.parseOperator(e)),r.forEach(e=>t.parseOperatorParameters(e)),(e.streams||[]).forEach(e=>t.parseStream(e)),(e.updates||[]).forEach(e=>t.parseUpdate(e)),t.resolve()},parseOperator:function(e){const t=this;"operator"!==a(e.type)&&e.type?t.transform(e,e.type):t.operator(e,e.update?t.operatorExpression(e.update):null)},parseOperatorParameters:function(e){const r=this;if(e.params){const n=r.get(e.id);n||t.error("Invalid operator id: "+e.id),r.dataflow.connect(n,n.parameters(r.parseParameters(e.params),e.react,e.initonly))}},parseParameters:function(e,r){r=r||{};const n=this;for(const o in e){const a=e[o];r[o]=t.isArray(a)?a.map(e=>c(e,n,r)):c(a,n,r)}return r},parseStream:function(e){var r,n=this,o=null!=e.filter?n.eventExpression(e.filter):void 0,a=null!=e.stream?n.get(e.stream):void 0;e.source?a=n.events(e.source,e.type,o):e.merge&&(a=(r=e.merge.map(e=>n.get(e)))[0].merge.apply(r[0],r.slice(1))),e.between&&(r=e.between.map(e=>n.get(e)),a=a.between(r[0],r[1])),e.filter&&(a=a.filter(o)),null!=e.throttle&&(a=a.throttle(+e.throttle)),null!=e.debounce&&(a=a.debounce(+e.debounce)),null==a&&t.error("Invalid stream definition: "+JSON.stringify(e)),e.consume&&a.consume(!0),n.stream(e,a)},parseUpdate:function(e){var r,n=this,o=t.isObject(o=e.source)?o.$ref:o,a=n.get(o),s=e.update,i=void 0;a||t.error("Source not defined: "+e.source),r=e.target&&e.target.$expr?n.eventExpression(e.target.$expr):n.get(e.target),s&&s.$expr&&(s.$params&&(i=n.parseParameters(s.$params)),s=n.handlerExpression(s.$expr)),n.update(e,a,r,s,i)},getState:function(e){var t=this,r={};if(e.signals){var n=r.signals={};Object.keys(t.signals).forEach(r=>{var o=t.signals[r];e.signals(r,o)&&(n[r]=o.value)})}if(e.data){var o=r.data={};Object.keys(t.data).forEach(r=>{var n=t.data[r];e.data(r,n)&&(o[r]=n.input.value)})}return t.subcontext&&!1!==e.recurse&&(r.subcontext=t.subcontext.map(t=>t.getState(e))),r},setState:function(e){var r=this,n=r.dataflow,o=e.data,a=e.signals;Object.keys(a||{}).forEach(e=>{n.update(r.signals[e],a[e],p)}),Object.keys(o||{}).forEach(e=>{n.pulse(r.data[e].input,n.changeset().remove(t.truthy).insert(o[e]))}),(e.subcontext||[]).forEach((e,t)=>{var n=r.subcontext[t];n&&n.setState(e)})}},e.context=function(e,t,r,n){return new f(e,t,r,n)},Object.defineProperty(e,"__esModule",{value:!0})}));
var vega=function(e,t,n){"use strict";const r=t.toSet(["rule"]),o=t.toSet(["group","image","rect"]);function a(e){return(e+"").toLowerCase()}function s(e,t,n){";"!==n[n.length-1]&&(n="return("+n+");");const r=Function(...t.concat(n));return e&&e.functions?r.bind(e.functions):r}var c={operator:(e,t)=>s(e,["_"],t.code),parameter:(e,t)=>s(e,["datum","_"],t.code),event:(e,t)=>s(e,["event"],t.code),handler:(e,t)=>s(e,["_","event"],"var datum=event.item&&event.item.datum;return ".concat(t.code,";")),encode:(e,n)=>{const{marktype:a,channels:c}=n;let i="var o=item,datum=o.datum,m=0,$;";for(const e in c){const n="o["+t.stringValue(e)+"]";i+="$=".concat(c[e].code,";if(").concat(n,"!==$)").concat(n,"=$,m=1;")}return i+=function(e,t){let n="";return r[t]||(e.x2&&(e.x?(o[t]&&(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"),n+="o.width=o.x2-o.x;"):n+="o.x=o.x2-(o.width||0);"),e.xc&&(n+="o.x=o.xc-(o.width||0)/2;"),e.y2&&(e.y?(o[t]&&(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"),n+="o.height=o.y2-o.y;"):n+="o.y=o.y2-(o.height||0);"),e.yc&&(n+="o.y=o.yc-(o.height||0)/2;")),n}(c,a),i+="return m;",s(e,["item","_"],i)},codegen:{get(e){const n="[".concat(e.map(t.stringValue).join("]["),"]"),r=Function("_","return _".concat(n,";"));return r.path=n,r},comparator(e,t){let n;const r=Function("a","b","var u, v; return "+e.map((e,r)=>{const o=t[r];let a,s;return e.path?(a="a".concat(e.path),s="b".concat(e.path)):((n=n||{})["f"+r]=e,a="this.f".concat(r,"(a)"),s="this.f".concat(r,"(b)")),function(e,t,n,r){return"((u = ".concat(e,") < (v = ").concat(t,") || u == null) && v != null ? ").concat(n,"\n : (u > v || v == null) && u != null ? ").concat(r,"\n : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ").concat(n,"\n : v !== v && u === u ? ").concat(r," : ")}(a,s,-o,o)}).join("")+"0;");return n?r.bind(n):r}}};function i(e,n,r){if(!e||!t.isObject(e))return e;for(let o,a=0,s=u.length;a<s;++a)if(o=u[a],t.hasOwnProperty(e,o.key))return o.parse(e,n,r);return e}var u=[{key:"$ref",parse:function(e,n){return n.get(e.$ref)||t.error("Operator not defined: "+e.$ref)}},{key:"$key",parse:function(e,n){const r="k:"+e.$key+"_"+!!e.$flat;return n.fn[r]||(n.fn[r]=t.key(e.$key,e.$flat,n.expr.codegen))}},{key:"$expr",parse:function(e,n,r){e.$params&&n.parseParameters(e.$params,r);const o="e:"+e.$expr.code+"_"+e.$name;return n.fn[o]||(n.fn[o]=t.accessor(n.parameterExpression(e.$expr),e.$fields,e.$name))}},{key:"$field",parse:function(e,n){if(!e.$field)return null;const r="f:"+e.$field+"_"+e.$name;return n.fn[r]||(n.fn[r]=t.field(e.$field,e.$name,n.expr.codegen))}},{key:"$encode",parse:function(e,n){const r=e.$encode,o={};for(const e in r){const a=r[e];o[e]=t.accessor(n.encodeExpression(a.$expr),a.$fields),o[e].output=a.$output}return o}},{key:"$compare",parse:function(e,r){const o="c:"+e.$compare+"_"+e.$order,a=t.array(e.$compare).map(e=>e&&e.$tupleid?n.tupleid:e);return r.fn[o]||(r.fn[o]=t.compare(a,e.$order,r.expr.codegen))}},{key:"$context",parse:function(e,t){return t}},{key:"$subflow",parse:function(e,t){const n=e.$subflow;return function(e,r,o){const a=t.fork().parse(n),s=a.get(n.operators[0].id),c=a.signals.parent;return c&&c.set(o),s.detachSubflow=()=>t.detach(a),s}}},{key:"$tupleid",parse:function(){return n.tupleid}}];const p={skip:!0};function d(e,t,n,r){this.dataflow=e,this.transforms=t,this.events=e.events.bind(e),this.expr=r||c,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this)}function f(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.events=e.events,this.expr=e.expr,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)}return d.prototype=f.prototype={fork(){const e=new f(this);return(this.subcontext||(this.subcontext=[])).push(e),e},detach(e){this.subcontext=this.subcontext.filter(t=>t!==e);const t=Object.keys(e.nodes);for(const n of t)e.nodes[n]._targets=null;for(const n of t)e.nodes[n].detach();e.nodes=null},get(e){return this.nodes[e]},set(e,t){return this.nodes[e]=t},add(e,t){const n=this,r=n.dataflow,o=e.value;if(n.set(e.id,t),"collect"===a(e.type)&&o&&(o.$ingest?r.ingest(t,o.$ingest,o.$format):o.$request?r.preload(t,o.$request,o.$format):r.pulse(t,r.changeset().insert(o))),e.root&&(n.root=t),e.parent){let o=n.get(e.parent.$ref);o?(r.connect(o,[t]),t.targets().add(o)):(n.unresolved=n.unresolved||[]).push(()=>{o=n.get(e.parent.$ref),r.connect(o,[t]),t.targets().add(o)})}if(e.signal&&(n.signals[e.signal]=t),e.scale&&(n.scales[e.scale]=t),e.data)for(const r in e.data){const o=n.data[r]||(n.data[r]={});e.data[r].forEach(e=>o[e]=t)}},resolve(){return(this.unresolved||[]).forEach(e=>e()),delete this.unresolved,this},operator(e,t){this.add(e,this.dataflow.add(e.value,t))},transform(e,t){this.add(e,this.dataflow.add(this.transforms[a(t)]))},stream(e,t){this.set(e.id,t)},update(e,t,n,r,o){this.dataflow.on(t,n,r,o,e.options)},operatorExpression(e){return this.expr.operator(this,e)},parameterExpression(e){return this.expr.parameter(this,e)},eventExpression(e){return this.expr.event(this,e)},handlerExpression(e){return this.expr.handler(this,e)},encodeExpression(e){return this.expr.encode(this,e)},parse:function(e){const t=this,n=e.operators||[];return e.background&&(t.background=e.background),e.eventConfig&&(t.eventConfig=e.eventConfig),e.locale&&(t.locale=e.locale),n.forEach(e=>t.parseOperator(e)),n.forEach(e=>t.parseOperatorParameters(e)),(e.streams||[]).forEach(e=>t.parseStream(e)),(e.updates||[]).forEach(e=>t.parseUpdate(e)),t.resolve()},parseOperator:function(e){const t=this;"operator"!==a(e.type)&&e.type?t.transform(e,e.type):t.operator(e,e.update?t.operatorExpression(e.update):null)},parseOperatorParameters:function(e){const n=this;if(e.params){const r=n.get(e.id);r||t.error("Invalid operator id: "+e.id),n.dataflow.connect(r,r.parameters(n.parseParameters(e.params),e.react,e.initonly))}},parseParameters:function(e,n){n=n||{};const r=this;for(const o in e){const a=e[o];n[o]=t.isArray(a)?a.map(e=>i(e,r,n)):i(a,r,n)}return n},parseStream:function(e){var n,r=this,o=null!=e.filter?r.eventExpression(e.filter):void 0,a=null!=e.stream?r.get(e.stream):void 0;e.source?a=r.events(e.source,e.type,o):e.merge&&(a=(n=e.merge.map(e=>r.get(e)))[0].merge.apply(n[0],n.slice(1))),e.between&&(n=e.between.map(e=>r.get(e)),a=a.between(n[0],n[1])),e.filter&&(a=a.filter(o)),null!=e.throttle&&(a=a.throttle(+e.throttle)),null!=e.debounce&&(a=a.debounce(+e.debounce)),null==a&&t.error("Invalid stream definition: "+JSON.stringify(e)),e.consume&&a.consume(!0),r.stream(e,a)},parseUpdate:function(e){var n,r=this,o=t.isObject(o=e.source)?o.$ref:o,a=r.get(o),s=e.update,c=void 0;a||t.error("Source not defined: "+e.source),n=e.target&&e.target.$expr?r.eventExpression(e.target.$expr):r.get(e.target),s&&s.$expr&&(s.$params&&(c=r.parseParameters(s.$params)),s=r.handlerExpression(s.$expr)),r.update(e,a,n,s,c)},getState:function(e){var t=this,n={};if(e.signals){var r=n.signals={};Object.keys(t.signals).forEach(n=>{const o=t.signals[n];e.signals(n,o)&&(r[n]=o.value)})}if(e.data){var o=n.data={};Object.keys(t.data).forEach(n=>{const r=t.data[n];e.data(n,r)&&(o[n]=r.input.value)})}return t.subcontext&&!1!==e.recurse&&(n.subcontext=t.subcontext.map(t=>t.getState(e))),n},setState:function(e){var n=this,r=n.dataflow,o=e.data,a=e.signals;Object.keys(a||{}).forEach(e=>{r.update(n.signals[e],a[e],p)}),Object.keys(o||{}).forEach(e=>{r.pulse(n.data[e].input,r.changeset().remove(t.truthy).insert(o[e]))}),(e.subcontext||[]).forEach((e,t)=>{const r=n.subcontext[t];r&&r.setState(e)})}},e.context=function(e,t,n,r){return new d(e,t,n,r)},e}({},vega,vega);
//# sourceMappingURL=vega-runtime.min.js.map
{
"name": "vega-runtime",
"version": "6.1.2",
"version": "6.1.3",
"description": "Runtime support for Vega dataflows.",

@@ -14,17 +14,15 @@ "keywords": [

"main": "build/vega-runtime.js",
"module": "index",
"module": "build/vega-runtime.module.js",
"unpkg": "build/vega-runtime.min.js",
"repository": "vega/vega",
"scripts": {
"rollup": "rollup -f umd -g vega-dataflow:vega,vega-util:vega -n vega -o build/vega-runtime.js -- index.js",
"prebuild": "rimraf build && mkdir build",
"build": "yarn rollup",
"postbuild": "terser build/vega-runtime.js -c -m -o build/vega-runtime.min.js",
"pretest": "yarn prebuild && yarn rollup",
"prebuild": "rimraf build",
"build": "rollup -c",
"pretest": "yarn build --config-test",
"test": "tape 'test/**/*-test.js'",
"prepublishOnly": "yarn test && yarn build",
"postpublish": "git push && git push --tags"
"prepublishOnly": "yarn test && yarn build"
},
"dependencies": {
"vega-dataflow": "^5.7.2",
"vega-util": "^1.15.1"
"vega-dataflow": "^5.7.3",
"vega-util": "^1.15.2"
},

@@ -35,3 +33,3 @@ "devDependencies": {

},
"gitHead": "8d6793f4ca7eaaf2d22186764e9ce2dae687cf52"
"gitHead": "4affcbedb9d14815dbb6d3b250ed231b54fc95c0"
}

@@ -99,3 +99,3 @@ import parse from './dataflow';

if (spec.parent) {
var p = ctx.get(spec.parent.$ref);
let p = ctx.get(spec.parent.$ref);
if (p) {

@@ -102,0 +102,0 @@ df.connect(p, [op]);

@@ -9,3 +9,3 @@ import {adjustSpatial} from './util';

}
var fn = Function.apply(null, args.concat(code));
const fn = Function(...args.concat(code));
return ctx && ctx.functions ? fn.bind(ctx.functions) : fn;

@@ -12,0 +12,0 @@ }

import {truthy} from 'vega-util';
var SKIP = {skip: true};
const SKIP = {skip: true};

@@ -12,3 +12,3 @@ export function getState(options) {

Object.keys(ctx.signals).forEach(key => {
var op = ctx.signals[key];
const op = ctx.signals[key];
if (options.signals(key, op)) {

@@ -23,3 +23,3 @@ signals[key] = op.value;

Object.keys(ctx.data).forEach(key => {
var dataset = ctx.data[key];
const dataset = ctx.data[key];
if (options.data(key, dataset)) {

@@ -56,5 +56,5 @@ data[key] = dataset.input.value;

(state.subcontext || []).forEach((substate, i) => {
var subctx = ctx.subcontext[i];
const subctx = ctx.subcontext[i];
if (subctx) subctx.setState(substate);
});
}
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