{"_id":"vega-interpreter","_rev":"2999755","name":"vega-interpreter","description":"CSP-compliant interpreter for Vega expressions.","dist-tags":{"latest":"1.0.5"},"maintainers":[{"name":"jheer","email":""}],"time":{"modified":"2023-08-29T08:49:31.000Z","created":"2020-06-02T09:52:17.426Z","1.0.5":"2023-03-01T20:35:09.848Z","1.0.4":"2020-10-12T08:24:48.643Z","1.0.3":"2020-09-23T17:35:39.520Z","1.0.2":"2020-08-31T13:56:05.271Z","1.0.1":"2020-06-12T07:28:55.124Z","1.0.0":"2020-06-02T09:52:17.426Z"},"users":{},"author":{"name":"Jeffrey Heer","url":"http://idl.cs.washington.edu"},"repository":{"type":"git","url":"git+https://github.com/vega/vega.git"},"versions":{"1.0.5":{"name":"vega-interpreter","version":"1.0.5","description":"CSP-compliant interpreter for Vega expressions.","keywords":["vega","expression","interpreter","runtime"],"license":"BSD-3-Clause","author":{"name":"Jeffrey Heer","url":"http://idl.cs.washington.edu"},"main":"build/vega-interpreter.js","module":"build/vega-interpreter.module.js","unpkg":"build/vega-interpreter.min.js","types":"index.d.ts","repository":{"type":"git","url":"git+https://github.com/vega/vega.git"},"scripts":{"prebuild":"rimraf build","build":"rollup -c rollup.config.mjs --extend","pretest":"yarn build --config-test","test":"TZ=America/Los_Angeles tape 'test/**/*-test.js'","prepublishOnly":"yarn test && yarn build"},"devDependencies":{"vega":"*"},"gitHead":"fb1092f6b931d450f9c210b67ae4752bd3dd461b","bugs":{"url":"https://github.com/vega/vega/issues"},"homepage":"https://github.com/vega/vega#readme","_id":"vega-interpreter@1.0.5","_nodeVersion":"18.3.0","_npmVersion":"lerna/6.5.1/node@v18.3.0+arm64 (darwin)","dist":{"shasum":"19e1d1b5f84a4ea9cb25c4e90a05ce16cd058484","size":13992,"noattachment":false,"key":"/vega-interpreter/-/vega-interpreter-1.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/vega-interpreter/download/vega-interpreter-1.0.5.tgz"},"_npmUser":{"name":"jheer","email":"jeffrey.heer@gmail.com"},"directories":{},"maintainers":[{"name":"jheer","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vega-interpreter_1.0.5_1677702909610_0.006745331167486546"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-03-01T20:35:09.848Z","publish_time":1677702909848,"_cnpm_publish_time":1677702909848},"1.0.4":{"name":"vega-interpreter","version":"1.0.4","description":"CSP-compliant interpreter for Vega expressions.","keywords":["vega","expression","interpreter","runtime"],"license":"BSD-3-Clause","author":{"name":"Jeffrey Heer","url":"http://idl.cs.washington.edu"},"main":"build/vega-interpreter.js","module":"build/vega-interpreter.module.js","unpkg":"build/vega-interpreter.min.js","types":"index.d.ts","repository":{"type":"git","url":"https://github.com/vega/vega.git"},"scripts":{"prebuild":"rimraf build","build":"rollup -c --extend","pretest":"yarn build --config-test","test":"TZ=America/Los_Angeles tape 'test/**/*-test.js'","prepublishOnly":"yarn test && yarn build"},"devDependencies":{"vega":"*"},"licenseText":"Copyright (c) 2015-2018, University of Washington Interactive Data Lab\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors\n  may be used to endorse or promote products derived from this software\n  without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","_id":"vega-interpreter@1.0.4","dist":{"shasum":"291ebf85bc2d1c3550a3da22ff75b3ba0d326a39","size":12934,"noattachment":false,"key":"/vega-interpreter/-/vega-interpreter-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/vega-interpreter/download/vega-interpreter-1.0.4.tgz"},"maintainers":[{"name":"jheer","email":""}],"_npmUser":{"name":"jheer","email":"jeffrey.heer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vega-interpreter_1.0.4_1602491088526_0.929004527913655"},"_hasShrinkwrap":false,"publish_time":1602491088643,"_cnpm_publish_time":1602491088643,"_cnpmcore_publish_time":"2021-12-16T20:16:52.436Z"},"1.0.3":{"name":"vega-interpreter","version":"1.0.3","description":"CSP-compliant interpreter for Vega expressions.","keywords":["vega","expression","interpreter","runtime"],"license":"BSD-3-Clause","author":{"name":"Jeffrey Heer","url":"http://idl.cs.washington.edu"},"main":"build/vega-interpreter.js","module":"build/vega-interpreter.module.js","unpkg":"build/vega-interpreter.min.js","types":"index.d.ts","repository":{"type":"git","url":"git+https://github.com/vega/vega.git"},"scripts":{"prebuild":"rimraf build","build":"rollup -c --extend","pretest":"yarn build --config-test","test":"TZ=America/Los_Angeles tape 'test/**/*-test.js'","prepublishOnly":"yarn test && yarn build"},"devDependencies":{"vega":"*"},"gitHead":"1d7db81379c538f8a8ee081a87702d8e4fdce30c","bugs":{"url":"https://github.com/vega/vega/issues"},"homepage":"https://github.com/vega/vega#readme","_id":"vega-interpreter@1.0.3","_nodeVersion":"12.18.3","_npmVersion":"lerna/3.22.1/node@v12.18.3+x64 (darwin)","dist":{"shasum":"810de6e121f75d14d9f1f51554637903e206ed86","size":12951,"noattachment":false,"key":"/vega-interpreter/-/vega-interpreter-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/vega-interpreter/download/vega-interpreter-1.0.3.tgz"},"maintainers":[{"name":"jheer","email":""}],"_npmUser":{"name":"jheer","email":"jeffrey.heer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vega-interpreter_1.0.3_1600882539335_0.11003587577463692"},"_hasShrinkwrap":false,"publish_time":1600882539520,"_cnpm_publish_time":1600882539520,"_cnpmcore_publish_time":"2021-12-16T20:16:52.634Z"},"1.0.2":{"name":"vega-interpreter","version":"1.0.2","description":"CSP-compliant interpreter for Vega expressions.","keywords":["vega","expression","interpreter","runtime"],"license":"BSD-3-Clause","author":{"name":"Jeffrey Heer","url":"http://idl.cs.washington.edu"},"types":"index.d.ts","main":"build/vega-interpreter.js","module":"index","repository":{"type":"git","url":"git+https://github.com/vega/vega.git"},"scripts":{"rollup":"rollup -f umd -n vega --extend -o build/vega-interpreter.js -- index.js","prebuild":"rimraf build && mkdir build","build":"yarn rollup","postbuild":"terser build/vega-interpreter.js -c -m -o build/vega-interpreter.min.js","pretest":"yarn prebuild && yarn rollup","test":"TZ=America/Los_Angeles tape 'test/**/*-test.js'","prepublishOnly":"yarn test && yarn build","postpublish":"git push && git push --tags"},"devDependencies":{"vega":"*"},"gitHead":"8d6793f4ca7eaaf2d22186764e9ce2dae687cf52","bugs":{"url":"https://github.com/vega/vega/issues"},"homepage":"https://github.com/vega/vega#readme","_id":"vega-interpreter@1.0.2","_nodeVersion":"12.18.3","_npmVersion":"lerna/3.22.1/node@v12.18.3+x64 (darwin)","dist":{"shasum":"a4f7b037d331d838b6ec51831195aee4d84fbd8a","size":7870,"noattachment":false,"key":"/vega-interpreter/-/vega-interpreter-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/vega-interpreter/download/vega-interpreter-1.0.2.tgz"},"maintainers":[{"name":"jheer","email":""}],"_npmUser":{"name":"jheer","email":"jeffrey.heer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vega-interpreter_1.0.2_1598882165158_0.14384513792845222"},"_hasShrinkwrap":false,"publish_time":1598882165271,"_cnpm_publish_time":1598882165271,"_cnpmcore_publish_time":"2021-12-16T20:16:52.873Z"},"1.0.1":{"name":"vega-interpreter","version":"1.0.1","description":"CSP-compliant interpreter for Vega expressions.","keywords":["vega","expression","interpreter","runtime"],"license":"BSD-3-Clause","author":{"name":"Jeffrey Heer","url":"http://idl.cs.washington.edu"},"main":"build/vega-interpreter.js","module":"index","repository":{"type":"git","url":"https://github.com/vega/vega.git"},"scripts":{"rollup":"rollup -f umd -n vega --extend -o build/vega-interpreter.js -- index.js","prebuild":"rimraf build && mkdir build","build":"yarn rollup","postbuild":"terser build/vega-interpreter.js -c -m -o build/vega-interpreter.min.js","pretest":"yarn prebuild && yarn rollup","test":"TZ=America/Los_Angeles tape 'test/**/*-test.js'","prepublishOnly":"yarn test && yarn build","postpublish":"git push && git push --tags"},"devDependencies":{"vega":"*"},"licenseText":"Copyright (c) 2015-2018, University of Washington Interactive Data Lab\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors\n  may be used to endorse or promote products derived from this software\n  without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","_id":"vega-interpreter@1.0.1","dist":{"shasum":"7eabbfcf2669445b0e3ad0f597132c99c430c4f0","size":7798,"noattachment":false,"key":"/vega-interpreter/-/vega-interpreter-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/vega-interpreter/download/vega-interpreter-1.0.1.tgz"},"maintainers":[{"name":"jheer","email":""}],"_npmUser":{"name":"jheer","email":"jeffrey.heer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vega-interpreter_1.0.1_1591946935043_0.15146300459965256"},"_hasShrinkwrap":false,"publish_time":1591946935124,"_cnpm_publish_time":1591946935124,"_cnpmcore_publish_time":"2021-12-16T20:16:53.208Z"},"1.0.0":{"name":"vega-interpreter","version":"1.0.0","description":"CSP-compliant interpreter for Vega expressions.","keywords":["vega","expression","interpreter","runtime"],"license":"BSD-3-Clause","author":{"name":"Jeffrey Heer","url":"http://idl.cs.washington.edu"},"main":"build/vega-interpreter.js","module":"index","repository":{"type":"git","url":"git+https://github.com/vega/vega.git"},"scripts":{"rollup":"rollup -f umd -n vega -o build/vega-interpreter.js -- index.js","prebuild":"rimraf build && mkdir build","build":"yarn rollup","postbuild":"terser build/vega-interpreter.js -c -m -o build/vega-interpreter.min.js","pretest":"yarn prebuild && yarn rollup","test":"TZ=America/Los_Angeles tape 'test/**/*-test.js'","prepublishOnly":"yarn test && yarn build","postpublish":"git push && git push --tags"},"devDependencies":{"vega":"*"},"gitHead":"62565bbe084a422c4a0cbc6e19c6f7c45a3e5137","bugs":{"url":"https://github.com/vega/vega/issues"},"homepage":"https://github.com/vega/vega#readme","_id":"vega-interpreter@1.0.0","_nodeVersion":"12.16.1","_npmVersion":"lerna/3.22.0/node@v12.16.1+x64 (darwin)","dist":{"shasum":"06ad03a358b8040fedb983054c9b99ca0facba57","size":7741,"noattachment":false,"key":"/vega-interpreter/-/vega-interpreter-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/vega-interpreter/download/vega-interpreter-1.0.0.tgz"},"maintainers":[{"name":"jheer","email":""}],"_npmUser":{"name":"jheer","email":"jeffrey.heer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vega-interpreter_1.0.0_1591091537309_0.299090663002997"},"_hasShrinkwrap":false,"publish_time":1591091537426,"_cnpm_publish_time":1591091537426,"_cnpmcore_publish_time":"2021-12-16T20:16:53.476Z"}},"readme":"# vega-interpreter\n\nAn interpreter for Vega expressions, that is [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) compliant. By default, the Vega parser performs code generation for parsed Vega expressions, and the Vega runtime then uses the [Function constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/Function) to create JavaScript functions from the generated code. Although the Vega parser includes its own security checks, the runtime generation of functions from source code nevertheless violates security policies designed to prevent cross-site scripting.\n\nIn addition to generated code, the Vega parser output can include the parsed [Abstract Syntax Tree (AST)](https://en.wikipedia.org/wiki/Abstract_syntax_tree) of an expression. This package provides an interpreter that evaluates expressions by traversing an AST and performing each operation in turn. Use of the interpreter enables compliance with CSP, but can incur a performance penalty. In tests of initial parse and dataflow evaluation times, the interpreter is on average ~10% slower. Interactive update performance may incur higher penalties, as it is often more expression-heavy and also amortizes the one-time cost of Function constructor parsing.\n\n## Usage\n\nTo use the interpreter, three steps must be taken:\n\n1. Load the Vega interpreter module, either using a separate HTML script tag or as part of a custom Vega build.\n2. Invoke the Vega parser with the `{ ast: true }` option to enable inclusion of parsed ASTs in the output.\n3. Pass the interpreter as an option to the Vega View constructor. The underlying runtime will be configured to use the alternate expression evaluator.\n\n```js\nconst spec; // Vega specification to show.\n\n// Parse the Vega specification with AST output enabled\n// Pass a null configuration value as the second argument\nconst runtimeSpec = vega.parse(spec, null, { ast: true });\n\n// Call the Vega View constructor with an 'expr' interpreter option\nconst view = new vega.View(runtimeSpec, {\n  expr:      vega.expressionInterpreter, // use interpreter\n  renderer:  'canvas',  // renderer (canvas or svg)\n  container: '#view',   // parent DOM container\n  hover:     true       // enable hover processing\n});\n\nview.runAsync();\n```\n","_attachments":{},"homepage":"https://github.com/vega/vega#readme","bugs":{"url":"https://github.com/vega/vega/issues"},"license":"BSD-3-Clause"}