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

@observablehq/stdlib

Package Overview
Dependencies
Maintainers
3
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@observablehq/stdlib - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

src/sqlite.js

4

dist/stdlib.js

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

// @observablehq/stdlib v3.6.0 Copyright 2021 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";const t=new Map,n=[],r=n.map,o=n.some,i=n.hasOwnProperty,a="https://cdn.jsdelivr.net/npm/",u=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,s=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,l=/\.[^/]*$/,c=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function d(e){const t=u.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function f(e){const n=`${a}${e.name}${e.version?`@${e.version}`:""}/package.json`;let r=t.get(n);return r||t.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!t.has(e.url)&&t.set(e.url,r),e.json()}))),r}RequireError.prototype.name=RequireError.name;var h=m((async function(e,t){if(e.startsWith(a)&&(e=e.substring(a.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const n=d(e);if(!n)return`${a}${e}`;if(!n.version&&null!=t&&t.startsWith(a)){const e=await f(d(t.substring(a.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!l.test(n.path)&&(n.path+=".js"),n.path&&n.version&&s.test(n.version))return`${a}${n.name}@${n.version}/${n.path}`;const r=await f(n);return`${a}${r.name}@${r.version}/${n.path||function(e){for(const t of c){const n=e[t];if("string"==typeof n)return l.test(n)?n:`${n}.js`}}(r)||"index.js"}`}));function m(e){const t=new Map,o=a(null);function i(e){if("string"!=typeof e)return e;let r=t.get(e);return r||t.set(e,r=new Promise(((t,r)=>{const o=document.createElement("script");o.onload=()=>{try{t(n.pop()(a(e)))}catch(e){r(new RequireError("invalid module"))}o.remove()},o.onerror=()=>{r(new RequireError("unable to load module")),o.remove()},o.async=!0,o.src=e,window.define=g,document.head.appendChild(o)}))),r}function a(t){return n=>Promise.resolve(e(n,t)).then(i)}function u(e){return arguments.length>1?Promise.all(r.call(arguments,o)).then(p):o(e)}return u.alias=function(t){return m(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},u.resolve=e,u}function p(e){const t={};for(const n of e)for(const e in n)i.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:v(n,e)}):t[e]=n[e]);return t}function v(e,t){return()=>e[t]}function w(e){return"exports"===(e+="")||"module"===e}function g(e,t,i){const a=arguments.length;a<2?(i=e,t=[]):a<3&&(i=t,t="string"==typeof e?[]:e),n.push(o.call(t,w)?e=>{const n={},o={exports:n};return Promise.all(r.call(t,(t=>"exports"===(t+="")?n:"module"===t?o:e(t)))).then((e=>(i.apply(null,e),o.exports)))}:e=>Promise.all(r.call(t,e)).then((e=>"function"==typeof i?i.apply(null,e):i)))}async function y(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function b(e,t,{array:n=!1,typed:r=!1}={}){const[o,i]=await Promise.all([e.text(),h("d3-dsv@2.0.0/dist/d3-dsv.min.js")]);return("\t"===t?n?i.tsvParseRows:i.tsvParse:n?i.csvParseRows:i.csvParse)(o,r&&i.autoType)}g.amd={};class x{constructor(e,t){Object.defineProperties(this,{_url:{value:e},name:{value:t,enumerable:!0}})}async url(){return await this._url+""}async blob(){return(await y(this)).blob()}async arrayBuffer(){return(await y(this)).arrayBuffer()}async text(){return(await y(this)).text()}async json(){return(await y(this)).json()}async stream(){return(await y(this)).body}async csv(e){return b(this,",",e)}async tsv(e){return b(this,"\t",e)}async image(){const e=await this.url();return new Promise(((t,n)=>{const r=new Image;new URL(e,document.baseURI).origin!==new URL(location).origin&&(r.crossOrigin="anonymous"),r.onload=()=>t(r),r.onerror=()=>n(new Error(`Unable to load file: ${this.name}`)),r.src=e}))}}function j(e){throw new Error(`File not found: ${e}`)}var E={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var P=0;function k(e){this.id=e,this.href=new URL(`#${e}`,location)+""}k.prototype.toString=function(){return"url("+this.href+")"};var L={canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var o=r.getContext("2d");return o.scale(n,n),o},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),o=r.appendChild(document.createElement("button"));async function i(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),o.textContent=n,o.disabled=!1}return o.textContent=n,r.download=t,r.onclick=async t=>{if(o.disabled=!0,r.href)return i();o.textContent="Saving…";try{const t=await("function"==typeof e?e():e);o.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){o.textContent=n}if(t.eventPhase)return i();o.disabled=!1},r},element:function(e,t){var n,r=e+="",o=r.indexOf(":");o>=0&&"xmlns"!==(r=e.slice(0,o))&&(e=e.slice(o+1));var i=E.hasOwnProperty(r)?document.createElementNS(E[r],e):document.createElement(e);if(t)for(var a in t)o=(r=a).indexOf(":"),n=t[a],o>=0&&"xmlns"!==(r=a.slice(0,o))&&(a=a.slice(o+1)),E.hasOwnProperty(r)?i.setAttributeNS(E[r],a,n):i.setAttribute(a,n);return i},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)})),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:function(e){return new k("O-"+(null==e?"":e+"-")+ ++P)}};var $={buffer:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)}))},url:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)}))}};function O(){return this}function A(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:O,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function N(e){let t,n,r=!1;const o=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=o&&"function"!=typeof o)throw new Error("function"==typeof o.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:O,throw:()=>({done:!0}),return:()=>(null!=o&&o(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function R(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var C={disposable:A,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return N((function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=R(e);function o(){t(R(e))}return e.addEventListener(n,o),void 0!==r&&t(r),function(){e.removeEventListener(n,o)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:N,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:O,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=0|Math.max(0,Math.ceil((t-e)/n));++r<o;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return A(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function M(e,t){return function(n){var r,o,i,a,u,s,l,c,d=n[0],f=[],h=null,m=-1;for(u=1,s=arguments.length;u<s;++u){if((r=arguments[u])instanceof Node)f[++m]=r,d+="\x3c!--o:"+m+"--\x3e";else if(Array.isArray(r)){for(l=0,c=r.length;l<c;++l)(o=r[l])instanceof Node?(null===h&&(f[++m]=h=document.createDocumentFragment(),d+="\x3c!--o:"+m+"--\x3e"),h.appendChild(o)):(h=null,d+=o);h=null}else d+=r;d+=n[u]}if(h=e(d),++m>0){for(i=new Array(m),a=document.createTreeWalker(h,NodeFilter.SHOW_COMMENT,null,!1);a.nextNode();)o=a.currentNode,/^o:/.test(o.nodeValue)&&(i[+o.nodeValue.slice(2)]=o);for(u=0;u<m;++u)(o=i[u])&&o.parentNode.replaceChild(f[u],o)}return 1===h.childNodes.length?h.removeChild(h.firstChild):11===h.nodeType?((o=t()).appendChild(h),o):h}}var U=M((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));const S="https://cdn.jsdelivr.net/npm/@observablehq/highlight.js@2.0.0/";function q(e){return function(){return e("marked@0.3.12/marked.min.js").then((function(t){return M((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var o=r.querySelectorAll("pre code[class]");return o.length>0&&e(S+"highlight.min.js").then((function(t){o.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(S+"async-languages/index.js").then((r=>{if(r.has(n.className))return e(S+"async-languages/"+r.get(n.className)).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}}function T(e){let t;Object.defineProperties(this,{generator:{value:N((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*F(){for(;;)yield Date.now()}var D=new Map;function z(e,t){var n;return(n=D.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){D.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)}));return D.set(t,n),n}(n,e).then((()=>t))}var _={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return z(Math.ceil((Date.now()+1)/e)*e,t)},when:z};function W(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}function B(e){return null==e?h:m(e)}var H=M((function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t}),(function(){return document.createElementNS("http://www.w3.org/2000/svg","g")})),I=String.raw;function V(e){return new Promise((function(t,n){var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onerror=n,r.onload=t,document.head.appendChild(r)}))}function G(e){return function(){return Promise.all([e("@observablehq/katex@0.11.1/dist/katex.min.js"),e.resolve("@observablehq/katex@0.11.1/dist/katex.min.css").then(V)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(I.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}}function X(e){return async()=>{const[t,n,r]=await Promise.all(["vega@5.20.2/build/vega.min.js","vega-lite@5.1.0/build/vega-lite.min.js","vega-lite-api@5.0.0/build/vega-lite-api.min.js"].map((t=>e(t))));return r.register(t,n)}}function J(){return N((function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}}))}var K=Object.assign((function(e){const t=B(e);var n;Object.defineProperties(this,(n={DOM:()=>L,FileAttachment:()=>j,Files:()=>$,Generators:()=>C,Inputs:()=>t("@observablehq/inputs@0.8.0/dist/inputs.umd.min.js"),Mutable:()=>T,Plot:()=>t("@observablehq/plot@0.1.0/dist/plot.umd.min.js"),Promises:()=>_,_:()=>t("lodash@4.17.21/lodash.min.js"),d3:()=>t("d3@6.7.0/dist/d3.min.js"),dot:()=>t("@observablehq/graphviz@0.2.1/dist/graphviz.min.js"),htl:()=>t("htl@0.2.5/dist/htl.min.js"),html:()=>U,md:q(t),now:F,require:()=>t,resolve:()=>W,svg:()=>H,tex:G(t),vl:X(t),width:J},Object.fromEntries(Object.entries(n).map(Q))))}),{resolve:h.resolve});function Q([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);return new x(n,t)}),{prototype:x.prototype})},e.Library=K,Object.defineProperty(e,"__esModule",{value:!0})}));
// @observablehq/stdlib v3.7.0 Copyright 2021 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";const t=new Map,n=[],r=n.map,o=n.some,i=n.hasOwnProperty,a="https://cdn.jsdelivr.net/npm/",s=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,u=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,l=/\.[^/]*$/,c=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function d(e){const t=s.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function f(e){const n=`${a}${e.name}${e.version?`@${e.version}`:""}/package.json`;let r=t.get(n);return r||t.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!t.has(e.url)&&t.set(e.url,r),e.json()}))),r}RequireError.prototype.name=RequireError.name;var m=h((async function(e,t){if(e.startsWith(a)&&(e=e.substring(a.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const n=d(e);if(!n)return`${a}${e}`;if(!n.version&&null!=t&&t.startsWith(a)){const e=await f(d(t.substring(a.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!l.test(n.path)&&(n.path+=".js"),n.path&&n.version&&u.test(n.version))return`${a}${n.name}@${n.version}/${n.path}`;const r=await f(n);return`${a}${r.name}@${r.version}/${n.path||function(e){for(const t of c){const n=e[t];if("string"==typeof n)return l.test(n)?n:`${n}.js`}}(r)||"index.js"}`}));function h(e){const t=new Map,o=a(null);function i(e){if("string"!=typeof e)return e;let r=t.get(e);return r||t.set(e,r=new Promise(((t,r)=>{const o=document.createElement("script");o.onload=()=>{try{t(n.pop()(a(e)))}catch(e){r(new RequireError("invalid module"))}o.remove()},o.onerror=()=>{r(new RequireError("unable to load module")),o.remove()},o.async=!0,o.src=e,window.define=g,document.head.appendChild(o)}))),r}function a(t){return n=>Promise.resolve(e(n,t)).then(i)}function s(e){return arguments.length>1?Promise.all(r.call(arguments,o)).then(p):o(e)}return s.alias=function(t){return h(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},s.resolve=e,s}function p(e){const t={};for(const n of e)for(const e in n)i.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:v(n,e)}):t[e]=n[e]);return t}function v(e,t){return()=>e[t]}function w(e){return"exports"===(e+="")||"module"===e}function g(e,t,i){const a=arguments.length;a<2?(i=e,t=[]):a<3&&(i=t,t="string"==typeof e?[]:e),n.push(o.call(t,w)?e=>{const n={},o={exports:n};return Promise.all(r.call(t,(t=>"exports"===(t+="")?n:"module"===t?o:e(t)))).then((e=>(i.apply(null,e),o.exports)))}:e=>Promise.all(r.call(t,e)).then((e=>"function"==typeof i?i.apply(null,e):i)))}async function y(e){return(await e("sql.js@1.5.0/dist/sql-wasm.js"))({locateFile:e=>`https://cdn.jsdelivr.net/npm/sql.js@1.5.0/dist/${e}`})}g.amd={};class b{constructor(e){Object.defineProperties(this,{_db:{value:e}})}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:o,values:i}=r,a=i.map((e=>Object.fromEntries(e.map(((e,t)=>[o[t],e])))));return a.columns=o,a}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return x("pre",{className:"observablehq--inspect"},[E((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return x("table",{value:t},[x("thead",[x("tr",n.map((e=>x("th",[E(e)]))))]),x("tbody",t.map((e=>x("tr",n.map((t=>x("td",[E(e[t])])))))))])}}function x(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function E(e){return document.createTextNode(e)}async function j(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function P(e,t,{array:n=!1,typed:r=!1}={}){const[o,i]=await Promise.all([e.text(),m("d3-dsv@2.0.0/dist/d3-dsv.min.js")]);return("\t"===t?n?i.tsvParseRows:i.tsvParse:n?i.csvParseRows:i.csvParse)(o,r&&i.autoType)}class L{constructor(e,t){Object.defineProperties(this,{_url:{value:e},name:{value:t,enumerable:!0}})}async url(){return await this._url+""}async blob(){return(await j(this)).blob()}async arrayBuffer(){return(await j(this)).arrayBuffer()}async text(){return(await j(this)).text()}async json(){return(await j(this)).json()}async stream(){return(await j(this)).body}async csv(e){return P(this,",",e)}async tsv(e){return P(this,"\t",e)}async image(){const e=await this.url();return new Promise(((t,n)=>{const r=new Image;new URL(e,document.baseURI).origin!==new URL(location).origin&&(r.crossOrigin="anonymous"),r.onload=()=>t(r),r.onerror=()=>n(new Error(`Unable to load file: ${this.name}`)),r.src=e}))}async sqlite(){const[e,t]=await Promise.all([y(m),this.arrayBuffer()]),n=new e.Database(new Uint8Array(t));return new b(n)}}function k(e){throw new Error(`File not found: ${e}`)}var O={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var $=0;function N(e){this.id=e,this.href=new URL(`#${e}`,location)+""}N.prototype.toString=function(){return"url("+this.href+")"};var R={canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var o=r.getContext("2d");return o.scale(n,n),o},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),o=r.appendChild(document.createElement("button"));async function i(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),o.textContent=n,o.disabled=!1}return o.textContent=n,r.download=t,r.onclick=async t=>{if(o.disabled=!0,r.href)return i();o.textContent="Saving…";try{const t=await("function"==typeof e?e():e);o.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){o.textContent=n}if(t.eventPhase)return i();o.disabled=!1},r},element:function(e,t){var n,r=e+="",o=r.indexOf(":");o>=0&&"xmlns"!==(r=e.slice(0,o))&&(e=e.slice(o+1));var i=O.hasOwnProperty(r)?document.createElementNS(O[r],e):document.createElement(e);if(t)for(var a in t)o=(r=a).indexOf(":"),n=t[a],o>=0&&"xmlns"!==(r=a.slice(0,o))&&(a=a.slice(o+1)),O.hasOwnProperty(r)?i.setAttributeNS(O[r],a,n):i.setAttribute(a,n);return i},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)})),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:function(e){return new N("O-"+(null==e?"":e+"-")+ ++$)}};var q={buffer:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)}))},url:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)}))}};function A(){return this}function C(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:A,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function M(e){let t,n,r=!1;const o=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=o&&"function"!=typeof o)throw new Error("function"==typeof o.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:A,throw:()=>({done:!0}),return:()=>(null!=o&&o(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function U(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var S={disposable:C,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return M((function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=U(e);function o(){t(U(e))}return e.addEventListener(n,o),void 0!==r&&t(r),function(){e.removeEventListener(n,o)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:M,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:A,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=0|Math.max(0,Math.ceil((t-e)/n));++r<o;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return C(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function T(e,t){return function(n){var r,o,i,a,s,u,l,c,d=n[0],f=[],m=null,h=-1;for(s=1,u=arguments.length;s<u;++s){if((r=arguments[s])instanceof Node)f[++h]=r,d+="\x3c!--o:"+h+"--\x3e";else if(Array.isArray(r)){for(l=0,c=r.length;l<c;++l)(o=r[l])instanceof Node?(null===m&&(f[++h]=m=document.createDocumentFragment(),d+="\x3c!--o:"+h+"--\x3e"),m.appendChild(o)):(m=null,d+=o);m=null}else d+=r;d+=n[s]}if(m=e(d),++h>0){for(i=new Array(h),a=document.createTreeWalker(m,NodeFilter.SHOW_COMMENT,null,!1);a.nextNode();)o=a.currentNode,/^o:/.test(o.nodeValue)&&(i[+o.nodeValue.slice(2)]=o);for(s=0;s<h;++s)(o=i[s])&&o.parentNode.replaceChild(f[s],o)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((o=t()).appendChild(m),o):m}}var F=T((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));const _="https://cdn.jsdelivr.net/npm/@observablehq/highlight.js@2.0.0/";function D(e){let t;Object.defineProperties(this,{generator:{value:M((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*z(){for(;;)yield Date.now()}var W=new Map;function B(e,t){var n;return(n=W.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){W.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)}));return W.set(t,n),n}(n,e).then((()=>t))}var H={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return B(Math.ceil((Date.now()+1)/e)*e,t)},when:B};function I(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}function Q(e){return null==e?m:h(e)}var V=T((function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t}),(function(){return document.createElementNS("http://www.w3.org/2000/svg","g")})),X=String.raw;function G(e){return new Promise((function(t,n){var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onerror=n,r.onload=t,document.head.appendChild(r)}))}function Y(){return M((function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}}))}var J=Object.assign((function(e){const t=Q(e);var n;Object.defineProperties(this,(n={DOM:()=>R,FileAttachment:()=>k,Files:()=>q,Generators:()=>S,Inputs:()=>t("@observablehq/inputs@0.8.0/dist/inputs.umd.min.js"),Mutable:()=>D,Plot:()=>t("@observablehq/plot@0.1.0/dist/plot.umd.min.js"),Promises:()=>H,SQLite:()=>y(t),_:()=>t("lodash@4.17.21/lodash.min.js"),d3:()=>t("d3@6.7.0/dist/d3.min.js"),dot:()=>t("@observablehq/graphviz@0.2.1/dist/graphviz.min.js"),htl:()=>t("htl@0.2.5/dist/htl.min.js"),html:()=>F,md:()=>function(e){return e("marked@0.3.12/marked.min.js").then((function(t){return T((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var o=r.querySelectorAll("pre code[class]");return o.length>0&&e(_+"highlight.min.js").then((function(t){o.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(_+"async-languages/index.js").then((r=>{if(r.has(n.className))return e(_+"async-languages/"+r.get(n.className)).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),now:z,require:()=>t,resolve:()=>I,svg:()=>V,tex:()=>function(e){return Promise.all([e("@observablehq/katex@0.11.1/dist/katex.min.js"),e.resolve("@observablehq/katex@0.11.1/dist/katex.min.css").then(G)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(X.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),vl:()=>async function(e){const[t,n,r]=await Promise.all(["vega@5.20.2/build/vega.min.js","vega-lite@5.1.0/build/vega-lite.min.js","vega-lite-api@5.0.0/build/vega-lite-api.min.js"].map((t=>e(t))));return r.register(t,n)}(t),width:Y},Object.fromEntries(Object.entries(n).map(K))))}),{resolve:m.resolve});function K([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);return new L(n,t)}),{prototype:L.prototype})},e.Library=J,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@observablehq/stdlib",
"version": "3.6.0",
"version": "3.7.0",
"license": "ISC",

@@ -5,0 +5,0 @@ "main": "dist/stdlib.js",

import {require as requireDefault} from "d3-require";
import sqlite, {SQLiteDatabaseClient} from "./sqlite.js";

@@ -59,2 +60,7 @@ async function remote_fetch(file) {

}
async sqlite() {
const [SQL, buffer] = await Promise.all([sqlite(requireDefault), this.arrayBuffer()]);
const db = new SQL.Database(new Uint8Array(buffer));
return new SQLiteDatabaseClient(db);
}
}

@@ -61,0 +67,0 @@

@@ -13,2 +13,3 @@ import {require as requireDefault} from "d3-require";

import requirer from "./require.js";
import SQLite from "./sqlite.js";
import svg from "./svg.js";

@@ -30,2 +31,3 @@ import tex from "./tex.js";

Promises: () => Promises,
SQLite: () => SQLite(require),
_: () => require("lodash@4.17.21/lodash.min.js"),

@@ -36,3 +38,3 @@ d3: () => require("d3@6.7.0/dist/d3.min.js"),

html: () => html,
md: md(require),
md: () => md(require),
now: now,

@@ -42,4 +44,4 @@ require: () => require,

svg: () => svg,
tex: tex(require),
vl: vegalite(require),
tex: () => tex(require),
vl: () => vegalite(require),
width: width

@@ -46,0 +48,0 @@ }));

import template from "./template.js";
const HL_ROOT =
"https://cdn.jsdelivr.net/npm/@observablehq/highlight.js@2.0.0/";
const HL_ROOT = "https://cdn.jsdelivr.net/npm/@observablehq/highlight.js@2.0.0/";
export default function(require) {
return function() {
return require("marked@0.3.12/marked.min.js").then(function(marked) {
return template(
function(string) {
var root = document.createElement("div");
root.innerHTML = marked(string, {langPrefix: ""}).trim();
var code = root.querySelectorAll("pre code[class]");
if (code.length > 0) {
require(HL_ROOT + "highlight.min.js").then(function(hl) {
code.forEach(function(block) {
function done() {
hl.highlightBlock(block);
block.parentNode.classList.add("observablehq--md-pre");
}
if (hl.getLanguage(block.className)) {
done();
} else {
require(HL_ROOT + "async-languages/index.js")
.then(index => {
if (index.has(block.className)) {
return require(HL_ROOT +
"async-languages/" +
index.get(block.className)).then(language => {
hl.registerLanguage(block.className, language);
});
}
})
.then(done, done);
}
});
return require("marked@0.3.12/marked.min.js").then(function(marked) {
return template(
function(string) {
var root = document.createElement("div");
root.innerHTML = marked(string, {langPrefix: ""}).trim();
var code = root.querySelectorAll("pre code[class]");
if (code.length > 0) {
require(HL_ROOT + "highlight.min.js").then(function(hl) {
code.forEach(function(block) {
function done() {
hl.highlightBlock(block);
block.parentNode.classList.add("observablehq--md-pre");
}
if (hl.getLanguage(block.className)) {
done();
} else {
require(HL_ROOT + "async-languages/index.js")
.then(index => {
if (index.has(block.className)) {
return require(HL_ROOT +
"async-languages/" +
index.get(block.className)).then(language => {
hl.registerLanguage(block.className, language);
});
}
})
.then(done, done);
}
});
}
return root;
},
function() {
return document.createElement("div");
});
}
);
});
};
return root;
},
function() {
return document.createElement("div");
}
);
});
}

@@ -14,23 +14,21 @@ var raw = String.raw;

export default function(require) {
return function() {
return Promise.all([
require("@observablehq/katex@0.11.1/dist/katex.min.js"),
require.resolve("@observablehq/katex@0.11.1/dist/katex.min.css").then(style)
]).then(function(values) {
var katex = values[0], tex = renderer();
export default function tex(require) {
return Promise.all([
require("@observablehq/katex@0.11.1/dist/katex.min.js"),
require.resolve("@observablehq/katex@0.11.1/dist/katex.min.css").then(style)
]).then(function(values) {
var katex = values[0], tex = renderer();
function renderer(options) {
return function() {
var root = document.createElement("div");
katex.render(raw.apply(String, arguments), root, options);
return root.removeChild(root.firstChild);
};
}
function renderer(options) {
return function() {
var root = document.createElement("div");
katex.render(raw.apply(String, arguments), root, options);
return root.removeChild(root.firstChild);
};
}
tex.options = renderer;
tex.block = renderer({displayMode: true});
return tex;
});
};
tex.options = renderer;
tex.block = renderer({displayMode: true});
return tex;
});
}

@@ -1,10 +0,8 @@

export default function vl(require) {
return async () => {
const [vega, vegalite, api] = await Promise.all([
"vega@5.20.2/build/vega.min.js",
"vega-lite@5.1.0/build/vega-lite.min.js",
"vega-lite-api@5.0.0/build/vega-lite-api.min.js"
].map(module => require(module)));
return api.register(vega, vegalite);
};
export default async function vl(require) {
const [vega, vegalite, api] = await Promise.all([
"vega@5.20.2/build/vega.min.js",
"vega-lite@5.1.0/build/vega-lite.min.js",
"vega-lite-api@5.0.0/build/vega-lite-api.min.js"
].map(module => require(module)));
return api.register(vega, vegalite);
}
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