vega-loader
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -9,6 +9,11 @@ (function (global, factory) { | ||
// https://... file://... //... | ||
var protocol_re = /^([A-Za-z]+:)?\/\//; | ||
const protocol_re = /^([A-Za-z]+:)?\/\//; | ||
// Matches allowed URIs. From https://github.com/cure53/DOMPurify/blob/master/src/regexp.js with added file:// | ||
const allowed_re = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape | ||
const whitespace_re = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex | ||
// Special treatment in node.js for the file: protocol | ||
var fileProtocol = 'file://'; | ||
const fileProtocol = 'file://'; | ||
@@ -74,9 +79,11 @@ /** | ||
let isFile, hasProtocol, loadFile, base; | ||
let isFile, loadFile, base; | ||
if (uri == null || typeof uri !== 'string') { | ||
const isAllowed = allowed_re.test(uri.replace(whitespace_re, '')); | ||
if (uri == null || typeof uri !== 'string' || !isAllowed) { | ||
vegaUtil.error('Sanitize failure, invalid URI: ' + vegaUtil.stringValue(uri)); | ||
} | ||
hasProtocol = protocol_re.test(uri); | ||
const hasProtocol = protocol_re.test(uri); | ||
@@ -348,3 +355,3 @@ // if relative url (no protocol/host), prepend baseURL | ||
} else { | ||
return format.hasOwnProperty(name) ? format[name] : null; | ||
return vegaUtil.hasOwnProperty(format, name) ? format[name] : null; | ||
} | ||
@@ -367,3 +374,3 @@ } | ||
if (data.hasOwnProperty('columns')) delete data.columns; | ||
if (vegaUtil.hasOwnProperty(data, 'columns')) delete data.columns; | ||
return data; | ||
@@ -370,0 +377,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("d3-dsv"),require("topojson-client"),require("d3-time-format")):"function"==typeof define&&define.amd?define(["exports","vega-util","d3-dsv","topojson-client","d3-time-format"],t):t((e=e||self).vega={},e.vega,e.d3,e.topojson,e.d3)}(this,function(e,t,n,r,o){"use strict";var i=/^([A-Za-z]+:)?\/\//,s="file://";async function u(e,t){const n=await this.sanitize(e,t),r=n.href;return n.localFile?this.file(r):this.http(r,t)}async function f(e,n){n=t.extend({},this.options,n);const r=this.fileAccess,o={href:null};let u,f,a,c;return null!=e&&"string"==typeof e||t.error("Sanitize failure, invalid URI: "+t.stringValue(e)),f=i.test(e),(c=n.baseURL)&&!f&&(e.startsWith("/")||"/"===c[c.length-1]||(e="/"+e),e=c+e),a=(u=e.startsWith(s))||"file"===n.mode||"http"!==n.mode&&!f&&r,u?e=e.slice(s.length):e.startsWith("//")&&("file"===n.defaultProtocol?(e=e.slice(2),a=!0):e=(n.defaultProtocol||"http")+":"+e),Object.defineProperty(o,"localFile",{value:!!a}),o.href=e,n.target&&(o.target=n.target+""),n.rel&&(o.rel=n.rel+""),o}function a(e){return e?function(t){return new Promise(function(n,r){e.readFile(t,function(e,t){e?r(e):n(t)})})}:c}async function c(){t.error("No file system access.")}function l(e){return e?async function(n,r){const o=t.extend({},this.options.http,r),i=r&&r.response,s=await e(n,o);return s.ok?t.isFunction(s[i])?s[i]():s.text():t.error(s.status+""+s.statusText)}:p}async function p(){t.error("No HTTP fetch method available.")}var d={boolean:t.toBoolean,integer:t.toNumber,number:t.toNumber,date:t.toDate,string:t.toString,unknown:t.identity},h=[function(e){return"true"===e||"false"===e||!0===e||!1===e},function(e){return v(e)&&(e=+e)==~~e},v,function(e){return!isNaN(Date.parse(e))}],y=["boolean","integer","number","date"];function m(e,t){if(!e||!e.length)return"unknown";var n,r,o,i,s=0,u=e.length,f=h.length,a=h.map(function(e,t){return t+1});for(r=0,u=e.length;r<u;++r)for(n=t?e[r][t]:e[r],o=0;o<f;++o)if(a[o]&&(null!=(i=n)&&i==i)&&!h[o](n)&&(a[o]=0,++s===h.length))return"string";return s=a.reduce(function(e,t){return 0===e?t:e},0)-1,y[s]}function g(e,t){return t.reduce(function(t,n){return t[n]=m(e,n),t},{})}function v(e){return!(isNaN(+e)||e instanceof Date)}function j(e){const n=function(n,r){const o={delimiter:e};return b(n,r?t.extend(r,o):o)};return n.responseType="text",n}function b(e,r){return r.header&&(e=r.header.map(t.stringValue).join(r.delimiter)+"\n"+e),n.dsvFormat(r.delimiter).parse(e+"")}function x(e,n){const r=n&&n.property?t.field(n.property):t.identity;return!t.isObject(e)||(o=e,"function"==typeof Buffer&&t.isFunction(Buffer.isBuffer)&&Buffer.isBuffer(o))?r(JSON.parse(e)):function(e,t){return t&&t.copy?JSON.parse(JSON.stringify(e)):e}(r(e));var o}b.responseType="text",x.responseType="json";const O={interior:(e,t)=>e!==t,exterior:(e,t)=>e===t};function N(e,n){let o,i,s,u;return e=x(e,n),n&&n.feature?(o=r.feature,s=n.feature):n&&n.mesh?(o=r.mesh,s=n.mesh,u=O[n.filter]):t.error("Missing TopoJSON feature or mesh parameter."),(i=(i=e.objects[s])?o(e,i,u):t.error("Invalid TopoJSON object: "+s))&&i.features||[i]}N.responseType="json";const T={dsv:b,csv:j(","),tsv:j("\t"),json:x,topojson:N};function P(e,t){return arguments.length>1?(T[e]=t,this):T.hasOwnProperty(e)?T[e]:null}var w=function(e,t){return function(n){return{options:n||{},sanitize:f,load:u,fileAccess:!!t,file:a(t),http:l(e)}}}("undefined"!=typeof fetch&&fetch,null);e.format=T,e.formats=P,e.inferType=m,e.inferTypes=g,e.loader=w,e.read=function(e,n,r){const i=P((n=n||{}).type||"json");return i||t.error("Unknown data format type: "+n.type),e=i(e,n),n.parse&&function(e,t,n){if(e.length){n=n||o.timeParse;var r,i,s,u,f,a,c,l=e.columns||Object.keys(e[0]);for("auto"===t&&(t=g(e,l)),l=Object.keys(t),r=l.map(function(e){var r,i,s=t[e];if(s&&(0===s.indexOf("date:")||0===s.indexOf("utc:")))return("'"===(i=(r=s.split(/:(.+)?/,2))[1])[0]&&"'"===i[i.length-1]||'"'===i[0]&&'"'===i[i.length-1])&&(i=i.slice(1,-1)),"utc"===r[0]?o.utcParse(i):n(i);if(!d[s])throw Error("Illegal format pattern: "+e+":"+s);return d[s]}),u=0,a=e.length,c=l.length;u<a;++u)for(i=e[u],f=0;f<c;++f)s=l[f],i[s]=r[f](i[s])}}(e,n.parse,r),e.hasOwnProperty("columns")&&delete e.columns,e},e.responseType=function(e){const t=P(e);return t&&t.responseType||"text"},e.typeParsers=d,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("d3-dsv"),require("topojson-client"),require("d3-time-format")):"function"==typeof define&&define.amd?define(["exports","vega-util","d3-dsv","topojson-client","d3-time-format"],t):t((e=e||self).vega={},e.vega,e.d3,e.topojson,e.d3)}(this,function(e,t,n,r,o){"use strict";const i=/^([A-Za-z]+:)?\/\//,s=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,u=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,f="file://";async function a(e,t){const n=await this.sanitize(e,t),r=n.href;return n.localFile?this.file(r):this.http(r,t)}async function c(e,n){n=t.extend({},this.options,n);const r=this.fileAccess,o={href:null};let a,c,l;const p=s.test(e.replace(u,""));null!=e&&"string"==typeof e&&p||t.error("Sanitize failure, invalid URI: "+t.stringValue(e));const d=i.test(e);return(l=n.baseURL)&&!d&&(e.startsWith("/")||"/"===l[l.length-1]||(e="/"+e),e=l+e),c=(a=e.startsWith(f))||"file"===n.mode||"http"!==n.mode&&!d&&r,a?e=e.slice(f.length):e.startsWith("//")&&("file"===n.defaultProtocol?(e=e.slice(2),c=!0):e=(n.defaultProtocol||"http")+":"+e),Object.defineProperty(o,"localFile",{value:!!c}),o.href=e,n.target&&(o.target=n.target+""),n.rel&&(o.rel=n.rel+""),o}function l(e){return e?function(t){return new Promise(function(n,r){e.readFile(t,function(e,t){e?r(e):n(t)})})}:p}async function p(){t.error("No file system access.")}function d(e){return e?async function(n,r){const o=t.extend({},this.options.http,r),i=r&&r.response,s=await e(n,o);return s.ok?t.isFunction(s[i])?s[i]():s.text():t.error(s.status+""+s.statusText)}:h}async function h(){t.error("No HTTP fetch method available.")}var m={boolean:t.toBoolean,integer:t.toNumber,number:t.toNumber,date:t.toDate,string:t.toString,unknown:t.identity},y=[function(e){return"true"===e||"false"===e||!0===e||!1===e},function(e){return b(e)&&(e=+e)==~~e},b,function(e){return!isNaN(Date.parse(e))}],g=["boolean","integer","number","date"];function v(e,t){if(!e||!e.length)return"unknown";var n,r,o,i,s=0,u=e.length,f=y.length,a=y.map(function(e,t){return t+1});for(r=0,u=e.length;r<u;++r)for(n=t?e[r][t]:e[r],o=0;o<f;++o)if(a[o]&&(null!=(i=n)&&i==i)&&!y[o](n)&&(a[o]=0,++s===y.length))return"string";return s=a.reduce(function(e,t){return 0===e?t:e},0)-1,g[s]}function j(e,t){return t.reduce(function(t,n){return t[n]=v(e,n),t},{})}function b(e){return!(isNaN(+e)||e instanceof Date)}function x(e){const n=function(n,r){const o={delimiter:e};return O(n,r?t.extend(r,o):o)};return n.responseType="text",n}function O(e,r){return r.header&&(e=r.header.map(t.stringValue).join(r.delimiter)+"\n"+e),n.dsvFormat(r.delimiter).parse(e+"")}function N(e,n){const r=n&&n.property?t.field(n.property):t.identity;return!t.isObject(e)||(o=e,"function"==typeof Buffer&&t.isFunction(Buffer.isBuffer)&&Buffer.isBuffer(o))?r(JSON.parse(e)):function(e,t){return t&&t.copy?JSON.parse(JSON.stringify(e)):e}(r(e));var o}O.responseType="text",N.responseType="json";const T={interior:(e,t)=>e!==t,exterior:(e,t)=>e===t};function P(e,n){let o,i,s,u;return e=N(e,n),n&&n.feature?(o=r.feature,s=n.feature):n&&n.mesh?(o=r.mesh,s=n.mesh,u=T[n.filter]):t.error("Missing TopoJSON feature or mesh parameter."),(i=(i=e.objects[s])?o(e,i,u):t.error("Invalid TopoJSON object: "+s))&&i.features||[i]}P.responseType="json";const w={dsv:O,csv:x(","),tsv:x("\t"),json:N,topojson:P};function z(e,n){return arguments.length>1?(w[e]=n,this):t.hasOwnProperty(w,e)?w[e]:null}var S=function(e,t){return function(n){return{options:n||{},sanitize:c,load:a,fileAccess:!!t,file:l(t),http:d(e)}}}("undefined"!=typeof fetch&&fetch,null);e.format=w,e.formats=z,e.inferType=v,e.inferTypes=j,e.loader=S,e.read=function(e,n,r){const i=z((n=n||{}).type||"json");return i||t.error("Unknown data format type: "+n.type),e=i(e,n),n.parse&&function(e,t,n){if(!e.length)return;n=n||o.timeParse;var r,i,s,u,f,a,c,l=e.columns||Object.keys(e[0]);"auto"===t&&(t=j(e,l));for(l=Object.keys(t),r=l.map(function(e){var r,i,s=t[e];if(s&&(0===s.indexOf("date:")||0===s.indexOf("utc:")))return("'"===(i=(r=s.split(/:(.+)?/,2))[1])[0]&&"'"===i[i.length-1]||'"'===i[0]&&'"'===i[i.length-1])&&(i=i.slice(1,-1)),"utc"===r[0]?o.utcParse(i):n(i);if(!m[s])throw Error("Illegal format pattern: "+e+":"+s);return m[s]}),u=0,a=e.length,c=l.length;u<a;++u)for(i=e[u],f=0;f<c;++f)s=l[f],i[s]=r[f](i[s])}(e,n.parse,r),t.hasOwnProperty(e,"columns")&&delete e.columns,e},e.responseType=function(e){const t=z(e);return t&&t.responseType||"text"},e.typeParsers=m,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -12,6 +12,11 @@ 'use strict'; | ||
// https://... file://... //... | ||
var protocol_re = /^([A-Za-z]+:)?\/\//; | ||
const protocol_re = /^([A-Za-z]+:)?\/\//; | ||
// Matches allowed URIs. From https://github.com/cure53/DOMPurify/blob/master/src/regexp.js with added file:// | ||
const allowed_re = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape | ||
const whitespace_re = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex | ||
// Special treatment in node.js for the file: protocol | ||
var fileProtocol = 'file://'; | ||
const fileProtocol = 'file://'; | ||
@@ -77,9 +82,11 @@ /** | ||
let isFile, hasProtocol, loadFile, base; | ||
let isFile, loadFile, base; | ||
if (uri == null || typeof uri !== 'string') { | ||
const isAllowed = allowed_re.test(uri.replace(whitespace_re, '')); | ||
if (uri == null || typeof uri !== 'string' || !isAllowed) { | ||
vegaUtil.error('Sanitize failure, invalid URI: ' + vegaUtil.stringValue(uri)); | ||
} | ||
hasProtocol = protocol_re.test(uri); | ||
const hasProtocol = protocol_re.test(uri); | ||
@@ -351,3 +358,3 @@ // if relative url (no protocol/host), prepend baseURL | ||
} else { | ||
return format.hasOwnProperty(name) ? format[name] : null; | ||
return vegaUtil.hasOwnProperty(format, name) ? format[name] : null; | ||
} | ||
@@ -370,3 +377,3 @@ } | ||
if (data.hasOwnProperty('columns')) delete data.columns; | ||
if (vegaUtil.hasOwnProperty(data, 'columns')) delete data.columns; | ||
return data; | ||
@@ -373,0 +380,0 @@ } |
{ | ||
"name": "vega-loader", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "Network request and file loading utilities.", | ||
@@ -39,5 +39,5 @@ "keywords": [ | ||
"d3-time-format": "^2.1.3", | ||
"node-fetch": "^2.5.0", | ||
"node-fetch": "^2.6.0", | ||
"topojson-client": "^3.0.0", | ||
"vega-util": "^1.8.0" | ||
"vega-util": "^1.11.0" | ||
}, | ||
@@ -48,3 +48,3 @@ "browser": { | ||
}, | ||
"gitHead": "d2576ca617d8165211ffe6c23582b9dc1b88db7d" | ||
"gitHead": "b45fc90406ce2de167073b73d4ae5cf79c5e1705" | ||
} |
import {default as dsv, delimitedFormat} from './dsv'; | ||
import json from './json'; | ||
import topojson from './topojson'; | ||
import {hasOwnProperty} from 'vega-util'; | ||
@@ -18,3 +19,3 @@ export const format = { | ||
} else { | ||
return format.hasOwnProperty(name) ? format[name] : null; | ||
return hasOwnProperty(format, name) ? format[name] : null; | ||
} | ||
@@ -21,0 +22,0 @@ } |
@@ -5,6 +5,11 @@ import {extend, error, isFunction, stringValue} from 'vega-util'; | ||
// https://... file://... //... | ||
var protocol_re = /^([A-Za-z]+:)?\/\//; | ||
const protocol_re = /^([A-Za-z]+:)?\/\//; | ||
// Matches allowed URIs. From https://github.com/cure53/DOMPurify/blob/master/src/regexp.js with added file:// | ||
const allowed_re = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape | ||
const whitespace_re = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex | ||
// Special treatment in node.js for the file: protocol | ||
var fileProtocol = 'file://'; | ||
const fileProtocol = 'file://'; | ||
@@ -70,9 +75,11 @@ /** | ||
let isFile, hasProtocol, loadFile, base; | ||
let isFile, loadFile, base; | ||
if (uri == null || typeof uri !== 'string') { | ||
const isAllowed = allowed_re.test(uri.replace(whitespace_re, '')); | ||
if (uri == null || typeof uri !== 'string' || !isAllowed) { | ||
error('Sanitize failure, invalid URI: ' + stringValue(uri)); | ||
} | ||
hasProtocol = protocol_re.test(uri); | ||
const hasProtocol = protocol_re.test(uri); | ||
@@ -79,0 +86,0 @@ // if relative url (no protocol/host), prepend baseURL |
import {inferTypes, typeParsers} from './type'; | ||
import {formats} from './formats/index'; | ||
import {error} from 'vega-util'; | ||
import {error, hasOwnProperty} from 'vega-util'; | ||
import {timeParse, utcParse} from 'd3-time-format'; | ||
@@ -15,3 +15,3 @@ | ||
if (data.hasOwnProperty('columns')) delete data.columns; | ||
if (hasOwnProperty(data, 'columns')) delete data.columns; | ||
return data; | ||
@@ -18,0 +18,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57033
1103
Updatednode-fetch@^2.6.0
Updatedvega-util@^1.11.0