vega-interpreter 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -163,6 +163,11 @@
|
|
|
163
163
|
return apply('replace', arguments, String);
|
|
164
164
|
},
|
|
165
165
|
trim: x => String(x).trim(),
|
|
166
|
+
// Base64 encode/decode
|
|
167
|
+
// Convert binary string to base64-encoded ascii
|
|
168
|
+
btoa: x => btoa(x),
|
|
169
|
+
// Convert base64-encoded ascii to binary string
|
|
170
|
+
atob: x => atob(x),
|
|
166
171
|
// regexp functions
|
|
167
172
|
regexp: RegExp,
|
|
168
173
|
test: (r, t) => RegExp(r).test(t)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-util"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega=e.vega||{},e.vega)}(this,(function(e,t){"use strict";var n={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-util"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega=e.vega||{},e.vega)}(this,(function(e,t){"use strict";var n={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},a={"*":(e,t)=>e*t,"+":(e,t)=>e+t,"-":(e,t)=>e-t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">=":(e,t)=>e>=t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,"&":(e,t)=>e&t,"|":(e,t)=>e|t,"^":(e,t)=>e^t,"<<":(e,t)=>e<<t,">>":(e,t)=>e>>t,">>>":(e,t)=>e>>>t},r={"+":e=>+e,"-":e=>-e,"~":e=>~e,"!":e=>!e};const o=Array.prototype.slice,i=(e,t,n)=>{const a=n?n(t[0]):t[0];return a[e].apply(a,o.call(t,1))};var s={isNaN:Number.isNaN,isFinite:Number.isFinite,abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,clamp:(e,t,n)=>Math.max(t,Math.min(n,e)),now:Date.now,utc:Date.UTC,datetime:(e,t,n,a,r,o,i)=>new Date(e,t||0,null!=n?n:1,a||0,r||0,o||0,i||0),date:e=>new Date(e).getDate(),day:e=>new Date(e).getDay(),year:e=>new Date(e).getFullYear(),month:e=>new Date(e).getMonth(),hours:e=>new Date(e).getHours(),minutes:e=>new Date(e).getMinutes(),seconds:e=>new Date(e).getSeconds(),milliseconds:e=>new Date(e).getMilliseconds(),time:e=>new Date(e).getTime(),timezoneoffset:e=>new Date(e).getTimezoneOffset(),utcdate:e=>new Date(e).getUTCDate(),utcday:e=>new Date(e).getUTCDay(),utcyear:e=>new Date(e).getUTCFullYear(),utcmonth:e=>new Date(e).getUTCMonth(),utchours:e=>new Date(e).getUTCHours(),utcminutes:e=>new Date(e).getUTCMinutes(),utcseconds:e=>new Date(e).getUTCSeconds(),utcmilliseconds:e=>new Date(e).getUTCMilliseconds(),length:e=>e.length,join:function(){return i("join",arguments)},indexof:function(){return i("indexOf",arguments)},lastindexof:function(){return i("lastIndexOf",arguments)},slice:function(){return i("slice",arguments)},reverse:e=>e.slice().reverse(),sort:e=>e.slice().sort(t.ascending),parseFloat:parseFloat,parseInt:parseInt,upper:e=>String(e).toUpperCase(),lower:e=>String(e).toLowerCase(),substring:function(){return i("substring",arguments,String)},split:function(){return i("split",arguments,String)},replace:function(){return i("replace",arguments,String)},trim:e=>String(e).trim(),btoa:e=>btoa(e),atob:e=>atob(e),regexp:RegExp,test:(e,t)=>RegExp(e).test(t)};const c=["view","item","group","xy","x","y"],u=new Set([Function,eval,setTimeout,setInterval]);"function"==typeof setImmediate&&u.add(setImmediate);const l={Literal:(e,t)=>t.value,Identifier:(e,t)=>{const a=t.name;return e.memberDepth>0?a:"datum"===a?e.datum:"event"===a?e.event:"item"===a?e.item:n[a]||e.params["$"+a]},MemberExpression:(e,t)=>{const n=!t.computed,a=e(t.object);n&&(e.memberDepth+=1);const r=e(t.property);if(n&&(e.memberDepth-=1),!u.has(a[r]))return a[r];console.error(`Prevented interpretation of member "${r}" which could lead to insecure code execution`)},CallExpression:(e,t)=>{const n=t.arguments;let a=t.callee.name;return a.startsWith("_")&&(a=a.slice(1)),"if"===a?e(n[0])?e(n[1]):e(n[2]):(e.fn[a]||s[a]).apply(e.fn,n.map(e))},ArrayExpression:(e,t)=>t.elements.map(e),BinaryExpression:(e,t)=>a[t.operator](e(t.left),e(t.right)),UnaryExpression:(e,t)=>r[t.operator](e(t.argument)),ConditionalExpression:(e,t)=>e(t.test)?e(t.consequent):e(t.alternate),LogicalExpression:(e,t)=>"&&"===t.operator?e(t.left)&&e(t.right):e(t.left)||e(t.right),ObjectExpression:(e,t)=>t.properties.reduce(((t,n)=>{e.memberDepth+=1;const a=e(n.key);return e.memberDepth-=1,u.has(e(n.value))?console.error(`Prevented interpretation of property "${a}" which could lead to insecure code execution`):t[a]=e(n.value),t}),{})};function m(e,t,n,a,r,o){const i=e=>l[e.type](i,e);return i.memberDepth=0,i.fn=Object.create(t),i.params=n,i.datum=a,i.event=r,i.item=o,c.forEach((e=>i.fn[e]=function(){return r.vega[e](...arguments)})),i(e)}var p={operator(e,t){const n=t.ast,a=e.functions;return e=>m(n,a,e)},parameter(e,t){const n=t.ast,a=e.functions;return(e,t)=>m(n,a,t,e)},event(e,t){const n=t.ast,a=e.functions;return e=>m(n,a,void 0,void 0,e)},handler(e,t){const n=t.ast,a=e.functions;return(e,t)=>{const r=t.item&&t.item.datum;return m(n,a,e,r,t)}},encode(e,t){const{marktype:n,channels:a}=t,r=e.functions,o="group"===n||"image"===n||"rect"===n;return(e,t)=>{const i=e.datum;let s,c=0;for(const n in a)s=m(a[n].ast,r,t,i,void 0,e),e[n]!==s&&(e[n]=s,c=1);return"rule"!==n&&function(e,t,n){let a;t.x2&&(t.x?(n&&e.x>e.x2&&(a=e.x,e.x=e.x2,e.x2=a),e.width=e.x2-e.x):e.x=e.x2-(e.width||0)),t.xc&&(e.x=e.xc-(e.width||0)/2),t.y2&&(t.y?(n&&e.y>e.y2&&(a=e.y,e.y=e.y2,e.y2=a),e.height=e.y2-e.y):e.y=e.y2-(e.height||0)),t.yc&&(e.y=e.yc-(e.height||0)/2)}(e,a,o),c}}};e.expressionInterpreter=p}));
|
|
2
2
|
//# sourceMappingURL=vega-interpreter.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vega-interpreter.min.js","sources":["../src/constants.js","../src/ops-binary.js","../src/ops-unary.js","../src/functions.js","../src/interpret.js","../src/expression.js","../src/adjust-spatial.js"],"sourcesContent":["export default {\n NaN: NaN,\n E: Math.E,\n LN2: Math.LN2,\n LN10: Math.LN10,\n LOG2E: Math.LOG2E,\n LOG10E: Math.LOG10E,\n PI: Math.PI,\n SQRT1_2: Math.SQRT1_2,\n SQRT2: Math.SQRT2,\n MIN_VALUE: Number.MIN_VALUE,\n MAX_VALUE: Number.MAX_VALUE\n};\n","export default {\n '*': (a, b) => a * b,\n '+': (a, b) => a + b,\n '-': (a, b) => a - b,\n '/': (a, b) => a / b,\n '%': (a, b) => a % b,\n '>': (a, b) => a > b,\n '<': (a, b) => a < b,\n '<=': (a, b) => a <= b,\n '>=': (a, b) => a >= b,\n '==': (a, b) => a == b,\n '!=': (a, b) => a != b,\n '===': (a, b) => a === b,\n '!==': (a, b) => a !== b,\n '&': (a, b) => a & b,\n '|': (a, b) => a | b,\n '^': (a, b) => a ^ b,\n '<<': (a, b) => a << b,\n '>>': (a, b) => a >> b,\n '>>>': (a, b) => a >>> b\n};\n","export default {\n '+': a => +a,\n '-': a => -a,\n '~': a => ~a,\n '!': a => !a\n};\n","import { ascending } from 'vega-util';\n\nconst slice = Array.prototype.slice;\n\nconst apply = (m, args, cast) => {\n const obj = cast ? cast(args[0]) : args[0];\n return obj[m].apply(obj, slice.call(args, 1));\n};\n\nconst datetime = (y, m, d, H, M, S, ms) =>\n new Date(y, m || 0, d != null ? d : 1, H || 0, M || 0, S || 0, ms || 0);\n\nexport default {\n // math functions\n isNaN: Number.isNaN,\n isFinite: Number.isFinite,\n abs: Math.abs,\n acos: Math.acos,\n asin: Math.asin,\n atan: Math.atan,\n atan2: Math.atan2,\n ceil: Math.ceil,\n cos: Math.cos,\n exp: Math.exp,\n floor: Math.floor,\n log: Math.log,\n max: Math.max,\n min: Math.min,\n pow: Math.pow,\n random: Math.random,\n round: Math.round,\n sin: Math.sin,\n sqrt: Math.sqrt,\n tan: Math.tan,\n clamp: (a, b, c) => Math.max(b, Math.min(c, a)),\n\n // date functions\n now: Date.now,\n utc: Date.UTC,\n datetime: datetime,\n date: d => new Date(d).getDate(),\n day: d => new Date(d).getDay(),\n year: d => new Date(d).getFullYear(),\n month: d => new Date(d).getMonth(),\n hours: d => new Date(d).getHours(),\n minutes: d => new Date(d).getMinutes(),\n seconds: d => new Date(d).getSeconds(),\n milliseconds: d => new Date(d).getMilliseconds(),\n time: d => new Date(d).getTime(),\n timezoneoffset: d => new Date(d).getTimezoneOffset(),\n utcdate: d => new Date(d).getUTCDate(),\n utcday: d => new Date(d).getUTCDay(),\n utcyear: d => new Date(d).getUTCFullYear(),\n utcmonth: d => new Date(d).getUTCMonth(),\n utchours: d => new Date(d).getUTCHours(),\n utcminutes: d => new Date(d).getUTCMinutes(),\n utcseconds: d => new Date(d).getUTCSeconds(),\n utcmilliseconds: d => new Date(d).getUTCMilliseconds(),\n\n // sequence functions\n length: x => x.length,\n join: function() { return apply('join', arguments); },\n indexof: function() { return apply('indexOf', arguments); },\n lastindexof: function() { return apply('lastIndexOf', arguments); },\n slice: function() { return apply('slice', arguments); },\n reverse: x => x.slice().reverse(),\n sort: x => x.slice().sort(ascending),\n\n // string functions\n parseFloat: parseFloat,\n parseInt: parseInt,\n upper: x => String(x).toUpperCase(),\n lower: x => String(x).toLowerCase(),\n substring: function() { return apply('substring', arguments, String); },\n split: function() { return apply('split', arguments, String); },\n replace: function() { return apply('replace', arguments, String); },\n trim: x => String(x).trim(),\n\n // regexp functions\n regexp: RegExp,\n test: (r, t) => RegExp(r).test(t)\n};\n","import Constants from './constants';\nimport Ops from './ops-binary';\nimport Unary from './ops-unary';\nimport Functions from './functions';\n\nconst EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];\nconst DisallowedMethods = new Set([\n Function,\n eval,\n setTimeout,\n setInterval\n]);\n\nif (typeof setImmediate === 'function') DisallowedMethods.add(setImmediate);\n\nconst Visitors = {\n Literal: ($, n) => n.value,\n\n Identifier: ($, n) => {\n const id = n.name;\n return $.memberDepth > 0 ? id\n : id === 'datum' ? $.datum\n : id === 'event' ? $.event\n : id === 'item' ? $.item\n : Constants[id] || $.params['$' + id];\n },\n\n MemberExpression: ($, n) => {\n const d = !n.computed,\n o = $(n.object);\n if (d) $.memberDepth += 1;\n const p = $(n.property);\n if (d) $.memberDepth -= 1;\n if (DisallowedMethods.has(o[p])) {\n // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of member \"${p}\" which could lead to insecure code execution`);\n return;\n }\n return o[p];\n },\n\n CallExpression: ($, n) => {\n const args = n.arguments;\n let name = n.callee.name;\n\n // handle special internal functions used by encoders\n // re-route to corresponding standard function\n if (name.startsWith('_')) {\n name = name.slice(1);\n }\n\n // special case \"if\" due to conditional evaluation of branches\n return name === 'if'\n ? ($(args[0]) ? $(args[1]) : $(args[2]))\n : ($.fn[name] || Functions[name]).apply($.fn, args.map($));\n },\n\n ArrayExpression: ($, n) => n.elements.map($),\n\n BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),\n\n UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),\n\n ConditionalExpression: ($, n) => $(n.test)\n ? $(n.consequent)\n : $(n.alternate),\n\n LogicalExpression: ($, n) => n.operator === '&&'\n ? $(n.left) && $(n.right)\n : $(n.left) || $(n.right),\n\n ObjectExpression: ($, n) => n.properties.reduce((o, p) => {\n $.memberDepth += 1;\n const k = $(p.key);\n $.memberDepth -= 1;\n if (DisallowedMethods.has($(p.value))) {\n // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of property \"${k}\" which could lead to insecure code execution`);\n } else {\n o[k] = $(p.value);\n }\n return o;\n }, {})\n};\n\nexport default function(ast, fn, params, datum, event, item) {\n const $ = n => Visitors[n.type]($, n);\n $.memberDepth = 0;\n $.fn = Object.create(fn);\n $.params = params;\n $.datum = datum;\n $.event = event;\n $.item = item;\n\n // route event functions to annotated vega event context\n EventFunctions.forEach(f => $.fn[f] = (...args) => event.vega[f](...args));\n\n return $(ast);\n}\n","import adjustSpatial from './adjust-spatial';\nimport interpret from './interpret';\n\nexport default {\n /**\n * Parse an expression used to update an operator value.\n */\n operator(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return _ => interpret(ast, fn, _);\n },\n\n /**\n * Parse an expression provided as an operator parameter value.\n */\n parameter(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (datum, _) => interpret(ast, fn, _, datum);\n },\n\n /**\n * Parse an expression applied to an event stream.\n */\n event(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return event => interpret(ast, fn, undefined, undefined, event);\n },\n\n /**\n * Parse an expression used to handle an event-driven operator update.\n */\n handler(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (_, event) => {\n const datum = event.item && event.item.datum;\n return interpret(ast, fn, _, datum, event);\n };\n },\n\n /**\n * Parse an expression that performs visual encoding.\n */\n encode(ctx, encode) {\n const {marktype, channels} = encode,\n fn = ctx.functions,\n swap = marktype === 'group'\n || marktype === 'image'\n || marktype === 'rect';\n\n return (item, _) => {\n const datum = item.datum;\n let m = 0, v;\n\n for (const name in channels) {\n v = interpret(channels[name].ast, fn, _, datum, undefined, item);\n if (item[name] !== v) {\n item[name] = v;\n m = 1;\n }\n }\n\n if (marktype !== 'rule') {\n adjustSpatial(item, channels, swap);\n }\n return m;\n };\n }\n};\n","export default function(item, encode, swap) {\n let t;\n\n if (encode.x2) {\n if (encode.x) {\n if (swap && item.x > item.x2) {\n t = item.x;\n item.x = item.x2;\n item.x2 = t;\n }\n item.width = item.x2 - item.x;\n } else {\n item.x = item.x2 - (item.width || 0);\n }\n }\n\n if (encode.xc) {\n item.x = item.xc - (item.width || 0) / 2;\n }\n\n if (encode.y2) {\n if (encode.y) {\n if (swap && item.y > item.y2) {\n t = item.y;\n item.y = item.y2;\n item.y2 = t;\n }\n item.height = item.y2 - item.y;\n } else {\n item.y = item.y2 - (item.height || 0);\n }\n }\n\n if (encode.yc) {\n item.y = item.yc - (item.height || 0) / 2;\n }\n}\n"],"names":["Constants","NaN","E","Math","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2","MIN_VALUE","Number","MAX_VALUE","Ops","*","a","b","+","-","/","%",">","<","<=",">=","==","!=","===","!==","&","|","^","<<",">>",">>>","Unary","slice","Array","prototype","apply","m","args","cast","obj","call","Functions","isNaN","isFinite","abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","random","round","sin","sqrt","tan","clamp","c","now","Date","utc","UTC","datetime","y","d","H","M","S","ms","date","getDate","day","getDay","year","getFullYear","month","getMonth","hours","getHours","minutes","getMinutes","seconds","getSeconds","milliseconds","getMilliseconds","time","getTime","timezoneoffset","getTimezoneOffset","utcdate","getUTCDate","utcday","getUTCDay","utcyear","getUTCFullYear","utcmonth","getUTCMonth","utchours","getUTCHours","utcminutes","getUTCMinutes","utcseconds","getUTCSeconds","utcmilliseconds","getUTCMilliseconds","length","x","join","arguments","indexof","lastindexof","reverse","sort","ascending","parseFloat","parseInt","upper","String","toUpperCase","lower","toLowerCase","substring","split","replace","trim","regexp","RegExp","test","r","t","EventFunctions","DisallowedMethods","Set","Function","eval","setTimeout","setInterval","setImmediate","add","Visitors","Literal","$","n","value","Identifier","id","name","memberDepth","datum","event","item","params","MemberExpression","computed","o","object","p","property","has","console","error","CallExpression","callee","startsWith","fn","map","ArrayExpression","elements","BinaryExpression","operator","left","right","UnaryExpression","argument","ConditionalExpression","consequent","alternate","LogicalExpression","ObjectExpression","properties","reduce","k","key","interpret","ast","type","Object","create","forEach","f","vega","expression","ctx","expr","functions","_","parameter","undefined","handler","encode","marktype","channels","swap","v","x2","width","xc","y2","height","yc","adjustSpatial"],"mappings":"8RAAe,IAAAA,EAAA,CACbC,IAAYA,IACZC,EAAYC,KAAKD,EACjBE,IAAYD,KAAKC,IACjBC,KAAYF,KAAKE,KACjBC,MAAYH,KAAKG,MACjBC,OAAYJ,KAAKI,OACjBC,GAAYL,KAAKK,GACjBC,QAAYN,KAAKM,QACjBC,MAAYP,KAAKO,MACjBC,UAAYC,OAAOD,UACnBE,UAAYD,OAAOC,WCXNC,EAAA,CACb,IAAKC,CAACC,EAAGC,IAAMD,EAAIC,EACnB,IAAKC,CAACF,EAAGC,IAAMD,EAAIC,EACnB,IAAKE,CAACH,EAAGC,IAAMD,EAAIC,EACnB,IAAKG,CAACJ,EAAGC,IAAMD,EAAIC,EACnB,IAAKI,CAACL,EAAGC,IAAMD,EAAIC,EACnB,IAAKK,CAACN,EAAGC,IAAMD,EAAIC,EACnB,I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src/functions.js","../src/interpret.js","../src/expression.js","../src/adjust-spatial.js"],"sourcesContent":["export default {\n NaN: NaN,\n E: Math.E,\n LN2: Math.LN2,\n LN10: Math.LN10,\n LOG2E: Math.LOG2E,\n LOG10E: Math.LOG10E,\n PI: Math.PI,\n SQRT1_2: Math.SQRT1_2,\n SQRT2: Math.SQRT2,\n MIN_VALUE: Number.MIN_VALUE,\n MAX_VALUE: Number.MAX_VALUE\n};\n","export default {\n '*': (a, b) => a * b,\n '+': (a, b) => a + b,\n '-': (a, b) => a - b,\n '/': (a, b) => a / b,\n '%': (a, b) => a % b,\n '>': (a, b) => a > b,\n '<': (a, b) => a < b,\n '<=': (a, b) => a <= b,\n '>=': (a, b) => a >= b,\n '==': (a, b) => a == b,\n '!=': (a, b) => a != b,\n '===': (a, b) => a === b,\n '!==': (a, b) => a !== b,\n '&': (a, b) => a & b,\n '|': (a, b) => a | b,\n '^': (a, b) => a ^ b,\n '<<': (a, b) => a << b,\n '>>': (a, b) => a >> b,\n '>>>': (a, b) => a >>> b\n};\n","export default {\n '+': a => +a,\n '-': a => -a,\n '~': a => ~a,\n '!': a => !a\n};\n","import { ascending } from 'vega-util';\n\nconst slice = Array.prototype.slice;\n\nconst apply = (m, args, cast) => {\n const obj = cast ? cast(args[0]) : args[0];\n return obj[m].apply(obj, slice.call(args, 1));\n};\n\nconst datetime = (y, m, d, H, M, S, ms) =>\n new Date(y, m || 0, d != null ? d : 1, H || 0, M || 0, S || 0, ms || 0);\n\nexport default {\n // math functions\n isNaN: Number.isNaN,\n isFinite: Number.isFinite,\n abs: Math.abs,\n acos: Math.acos,\n asin: Math.asin,\n atan: Math.atan,\n atan2: Math.atan2,\n ceil: Math.ceil,\n cos: Math.cos,\n exp: Math.exp,\n floor: Math.floor,\n log: Math.log,\n max: Math.max,\n min: Math.min,\n pow: Math.pow,\n random: Math.random,\n round: Math.round,\n sin: Math.sin,\n sqrt: Math.sqrt,\n tan: Math.tan,\n clamp: (a, b, c) => Math.max(b, Math.min(c, a)),\n\n // date functions\n now: Date.now,\n utc: Date.UTC,\n datetime: datetime,\n date: d => new Date(d).getDate(),\n day: d => new Date(d).getDay(),\n year: d => new Date(d).getFullYear(),\n month: d => new Date(d).getMonth(),\n hours: d => new Date(d).getHours(),\n minutes: d => new Date(d).getMinutes(),\n seconds: d => new Date(d).getSeconds(),\n milliseconds: d => new Date(d).getMilliseconds(),\n time: d => new Date(d).getTime(),\n timezoneoffset: d => new Date(d).getTimezoneOffset(),\n utcdate: d => new Date(d).getUTCDate(),\n utcday: d => new Date(d).getUTCDay(),\n utcyear: d => new Date(d).getUTCFullYear(),\n utcmonth: d => new Date(d).getUTCMonth(),\n utchours: d => new Date(d).getUTCHours(),\n utcminutes: d => new Date(d).getUTCMinutes(),\n utcseconds: d => new Date(d).getUTCSeconds(),\n utcmilliseconds: d => new Date(d).getUTCMilliseconds(),\n\n // sequence functions\n length: x => x.length,\n join: function() { return apply('join', arguments); },\n indexof: function() { return apply('indexOf', arguments); },\n lastindexof: function() { return apply('lastIndexOf', arguments); },\n slice: function() { return apply('slice', arguments); },\n reverse: x => x.slice().reverse(),\n sort: x => x.slice().sort(ascending),\n\n // string functions\n parseFloat: parseFloat,\n parseInt: parseInt,\n upper: x => String(x).toUpperCase(),\n lower: x => String(x).toLowerCase(),\n substring: function() { return apply('substring', arguments, String); },\n split: function() { return apply('split', arguments, String); },\n replace: function() { return apply('replace', arguments, String); },\n trim: x => String(x).trim(),\n // Base64 encode/decode\n // Convert binary string to base64-encoded ascii\n btoa: x => btoa(x),\n // Convert base64-encoded ascii to binary string\n atob: x => atob(x),\n\n // regexp functions\n regexp: RegExp,\n test: (r, t) => RegExp(r).test(t)\n};\n","import Constants from './constants';\nimport Ops from './ops-binary';\nimport Unary from './ops-unary';\nimport Functions from './functions';\n\nconst EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];\nconst DisallowedMethods = new Set([\n Function,\n eval,\n setTimeout,\n setInterval\n]);\n\nif (typeof setImmediate === 'function') DisallowedMethods.add(setImmediate);\n\nconst Visitors = {\n Literal: ($, n) => n.value,\n\n Identifier: ($, n) => {\n const id = n.name;\n return $.memberDepth > 0 ? id\n : id === 'datum' ? $.datum\n : id === 'event' ? $.event\n : id === 'item' ? $.item\n : Constants[id] || $.params['$' + id];\n },\n\n MemberExpression: ($, n) => {\n const d = !n.computed,\n o = $(n.object);\n if (d) $.memberDepth += 1;\n const p = $(n.property);\n if (d) $.memberDepth -= 1;\n if (DisallowedMethods.has(o[p])) {\n // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of member \"${p}\" which could lead to insecure code execution`);\n return;\n }\n return o[p];\n },\n\n CallExpression: ($, n) => {\n const args = n.arguments;\n let name = n.callee.name;\n\n // handle special internal functions used by encoders\n // re-route to corresponding standard function\n if (name.startsWith('_')) {\n name = name.slice(1);\n }\n\n // special case \"if\" due to conditional evaluation of branches\n return name === 'if'\n ? ($(args[0]) ? $(args[1]) : $(args[2]))\n : ($.fn[name] || Functions[name]).apply($.fn, args.map($));\n },\n\n ArrayExpression: ($, n) => n.elements.map($),\n\n BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),\n\n UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),\n\n ConditionalExpression: ($, n) => $(n.test)\n ? $(n.consequent)\n : $(n.alternate),\n\n LogicalExpression: ($, n) => n.operator === '&&'\n ? $(n.left) && $(n.right)\n : $(n.left) || $(n.right),\n\n ObjectExpression: ($, n) => n.properties.reduce((o, p) => {\n $.memberDepth += 1;\n const k = $(p.key);\n $.memberDepth -= 1;\n if (DisallowedMethods.has($(p.value))) {\n // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of property \"${k}\" which could lead to insecure code execution`);\n } else {\n o[k] = $(p.value);\n }\n return o;\n }, {})\n};\n\nexport default function(ast, fn, params, datum, event, item) {\n const $ = n => Visitors[n.type]($, n);\n $.memberDepth = 0;\n $.fn = Object.create(fn);\n $.params = params;\n $.datum = datum;\n $.event = event;\n $.item = item;\n\n // route event functions to annotated vega event context\n EventFunctions.forEach(f => $.fn[f] = (...args) => event.vega[f](...args));\n\n return $(ast);\n}\n","import adjustSpatial from './adjust-spatial';\nimport interpret from './interpret';\n\nexport default {\n /**\n * Parse an expression used to update an operator value.\n */\n operator(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return _ => interpret(ast, fn, _);\n },\n\n /**\n * Parse an expression provided as an operator parameter value.\n */\n parameter(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (datum, _) => interpret(ast, fn, _, datum);\n },\n\n /**\n * Parse an expression applied to an event stream.\n */\n event(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return event => interpret(ast, fn, undefined, undefined, event);\n },\n\n /**\n * Parse an expression used to handle an event-driven operator update.\n */\n handler(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (_, event) => {\n const datum = event.item && event.item.datum;\n return interpret(ast, fn, _, datum, event);\n };\n },\n\n /**\n * Parse an expression that performs visual encoding.\n */\n encode(ctx, encode) {\n const {marktype, channels} = encode,\n fn = ctx.functions,\n swap = marktype === 'group'\n || marktype === 'image'\n || marktype === 'rect';\n\n return (item, _) => {\n const datum = item.datum;\n let m = 0, v;\n\n for (const name in channels) {\n v = interpret(channels[name].ast, fn, _, datum, undefined, item);\n if (item[name] !== v) {\n item[name] = v;\n m = 1;\n }\n }\n\n if (marktype !== 'rule') {\n adjustSpatial(item, channels, swap);\n }\n return m;\n };\n }\n};\n","export default function(item, encode, swap) {\n let t;\n\n if (encode.x2) {\n if (encode.x) {\n if (swap && item.x > item.x2) {\n t = item.x;\n item.x = item.x2;\n item.x2 = t;\n }\n item.width = item.x2 - item.x;\n } else {\n item.x = item.x2 - (item.width || 0);\n }\n }\n\n if (encode.xc) {\n item.x = item.xc - (item.width || 0) / 2;\n }\n\n if (encode.y2) {\n if (encode.y) {\n if (swap && item.y > item.y2) {\n t = item.y;\n item.y = item.y2;\n item.y2 = t;\n }\n item.height = item.y2 - item.y;\n } else {\n item.y = item.y2 - (item.height || 0);\n }\n }\n\n if (encode.yc) {\n item.y = item.yc - (item.height || 0) / 2;\n }\n}\n"],"names":["Constants","NaN","E","Math","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2","MIN_VALUE","Number","MAX_VALUE","Ops","*","a","b","+","-","/","%",">","<","<=",">=","==","!=","===","!==","&","|","^","<<",">>",">>>","Unary","slice","Array","prototype","apply","m","args","cast","obj","call","Functions","isNaN","isFinite","abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","random","round","sin","sqrt","tan","clamp","c","now","Date","utc","UTC","datetime","y","d","H","M","S","ms","date","getDate","day","getDay","year","getFullYear","month","getMonth","hours","getHours","minutes","getMinutes","seconds","getSeconds","milliseconds","getMilliseconds","time","getTime","timezoneoffset","getTimezoneOffset","utcdate","getUTCDate","utcday","getUTCDay","utcyear","getUTCFullYear","utcmonth","getUTCMonth","utchours","getUTCHours","utcminutes","getUTCMinutes","utcseconds","getUTCSeconds","utcmilliseconds","getUTCMilliseconds","length","x","join","arguments","indexof","lastindexof","reverse","sort","ascending","parseFloat","parseInt","upper","String","toUpperCase","lower","toLowerCase","substring","split","replace","trim","btoa","atob","regexp","RegExp","test","r","t","EventFunctions","DisallowedMethods","Set","Function","eval","setTimeout","setInterval","setImmediate","add","Visitors","Literal","$","n","value","Identifier","id","name","memberDepth","datum","event","item","params","MemberExpression","computed","o","object","p","property","has","console","error","CallExpression","callee","startsWith","fn","map","ArrayExpression","elements","BinaryExpression","operator","left","right","UnaryExpression","argument","ConditionalExpression","consequent","alternate","LogicalExpression","ObjectExpression","properties","reduce","k","key","interpret","ast","type","Object","create","forEach","f","vega","expression","ctx","expr","functions","_","parameter","undefined","handler","encode","marktype","channels","swap","v","x2","width","xc","y2","height","yc","adjustSpatial"],"mappings":"8RAAe,IAAAA,EAAA,CACbC,IAAYA,IACZC,EAAYC,KAAKD,EACjBE,IAAYD,KAAKC,IACjBC,KAAYF,KAAKE,KACjBC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GrCN,EAAOQ,KACLR,EAAO1I,GACL6I,GAAQpD,EAAKzF,EAAIyF,EAAKyD,KACxB9E,EAAIqB,EAAKzF,EACTyF,EAAKzF,EAAIyF,EAAKyD,GACdzD,EAAKyD,GAAK9E,GAEZqB,EAAK0D,OAAS1D,EAAKyD,GAAKzD,EAAKzF,GAE7ByF,EAAKzF,EAAIyF,EAAKyD,IAAMzD,EAAK0D,QAAU,IAInCT,EAAOU,KACT3D,EAAKzF,EAAIyF,EAAK2D,IAAM3D,EAAK0D,QAAU,GAAK,EAE5C,CD0BQE,CAAc5D,EAAMmD,EAAUC,GAEzB9K,CAAC,CAEZ"}
|
|
@@ -159,6 +159,11 @@ var Functions = {
|
|
|
159
159
|
return apply('replace', arguments, String);
|
|
160
160
|
},
|
|
161
161
|
trim: x => String(x).trim(),
|
|
162
|
+
// Base64 encode/decode
|
|
163
|
+
// Convert binary string to base64-encoded ascii
|
|
164
|
+
btoa: x => btoa(x),
|
|
165
|
+
// Convert base64-encoded ascii to binary string
|
|
166
|
+
atob: x => atob(x),
|
|
162
167
|
// regexp functions
|
|
163
168
|
regexp: RegExp,
|
|
164
169
|
test: (r, t) => RegExp(r).test(t)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vega-interpreter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "CSP-compliant interpreter for Vega expressions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vega",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"vega": "*"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "2fe2e63de54821d858bdcbe2aa38e72a9f2e6234"
|
|
32
32
|
}
|
package/src/functions.js
CHANGED
|
@@ -75,6 +75,11 @@ export default {
|
|
|
75
75
|
split: function() { return apply('split', arguments, String); },
|
|
76
76
|
replace: function() { return apply('replace', arguments, String); },
|
|
77
77
|
trim: x => String(x).trim(),
|
|
78
|
+
// Base64 encode/decode
|
|
79
|
+
// Convert binary string to base64-encoded ascii
|
|
80
|
+
btoa: x => btoa(x),
|
|
81
|
+
// Convert base64-encoded ascii to binary string
|
|
82
|
+
atob: x => atob(x),
|
|
78
83
|
|
|
79
84
|
// regexp functions
|
|
80
85
|
regexp: RegExp,
|