@observablehq/stdlib
Advanced tools
Comparing version 3.4.1 to 3.5.0
@@ -1,2 +0,2 @@ | ||
// @observablehq/stdlib v3.4.1 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=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,l=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,s=/\.[^/]*$/,c=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function f(e){const t=u.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function d(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=f(e);if(!n)return`${a}${e}`;if(!n.version&&null!=t&&t.startsWith(a)){const e=await d(f(t.substring(a.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!s.test(n.path)&&(n.path+=".js"),n.path&&n.version&&l.test(n.version))return`${a}${n.name}@${n.version}/${n.path}`;const r=await d(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 s.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=b,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(w):o(e)}return u.alias=function(t){return h(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},u.resolve=e,u}function w(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 p(e){return"exports"===(e+="")||"module"===e}function b(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,p)?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 g(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function y(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)}b.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 g(this)).blob()}async arrayBuffer(){return(await g(this)).arrayBuffer()}async text(){return(await g(this)).text()}async json(){return(await g(this)).json()}async stream(){return(await g(this)).body}async csv(e){return y(this,",",e)}async tsv(e){return y(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 E(e){throw new Error(`File not found: ${e}`)}function P(e){return function(){return e}}var j={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 k=0;function L(e){this.id=e,this.href=new URL(`#${e}`,location)+""}L.prototype.toString=function(){return"url("+this.href+")"};var $={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=j.hasOwnProperty(r)?document.createElementNS(j[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)),j.hasOwnProperty(r)?i.setAttributeNS(j[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 L("O-"+(null==e?"":e+"-")+ ++k)}};var A={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 N(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 R(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 C(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 M={disposable:N,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return R((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=C(e);function o(){t(C(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:R,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 N(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function U(e,t){return function(n){var r,o,i,a,u,l,s,c,f=n[0],d=[],m=null,h=-1;for(u=1,l=arguments.length;u<l;++u){if((r=arguments[u])instanceof Node)d[++h]=r,f+="\x3c!--o:"+h+"--\x3e";else if(Array.isArray(r)){for(s=0,c=r.length;s<c;++s)(o=r[s])instanceof Node?(null===m&&(d[++h]=m=document.createDocumentFragment(),f+="\x3c!--o:"+h+"--\x3e"),m.appendChild(o)):(m=null,f+=o);m=null}else f+=r;f+=n[u]}if(m=e(f),++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(u=0;u<h;++u)(o=i[u])&&o.parentNode.replaceChild(d[u],o)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((o=t()).appendChild(m),o):m}}var S=U((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));const T="https://cdn.jsdelivr.net/npm/@observablehq/highlight.js@2.0.0/";function F(e){return function(){return e("marked@0.3.12/marked.min.js").then((function(t){return U((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(T+"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(T+"async-languages/index.js").then((r=>{if(r.has(n.className))return e(T+"async-languages/"+r.get(n.className)).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}}function q(e){let t;Object.defineProperties(this,{generator:{value:R((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*D(){for(;;)yield Date.now()}var W=new Map;function _(e,t){var n;return(n=W.get(e=+e))?n.then(P(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(P(t))}var z={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return _(Math.ceil((Date.now()+1)/e)*e,t)},when:_};function B(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 H(e){return null==e?m:h(e)}var I=U((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")})),V=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 X(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(G)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(V.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}}function J(){return R((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=H(e);Object.defineProperties(this,{DOM:{value:$,writable:!0,enumerable:!0},FileAttachment:{value:P(E),writable:!0,enumerable:!0},Files:{value:A,writable:!0,enumerable:!0},Generators:{value:M,writable:!0,enumerable:!0},html:{value:P(S),writable:!0,enumerable:!0},md:{value:F(t),writable:!0,enumerable:!0},Mutable:{value:P(q),writable:!0,enumerable:!0},now:{value:D,writable:!0,enumerable:!0},Promises:{value:z,writable:!0,enumerable:!0},require:{value:P(t),writable:!0,enumerable:!0},resolve:{value:P(B),writable:!0,enumerable:!0},svg:{value:P(I),writable:!0,enumerable:!0},tex:{value:X(t),writable:!0,enumerable:!0},width:{value:J,writable:!0,enumerable:!0}})}),{resolve:m.resolve});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.5.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 T(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 q(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 _(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 W={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return _(Math.ceil((Date.now()+1)/e)*e,t)},when:_};function z(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:()=>q,Plot:()=>t("@observablehq/plot@0.1.0/dist/plot.umd.min.js"),Promises:()=>W,_:()=>t("lodash@4.17.21/lodash.min.js"),d3:()=>t("d3@6.7.0/dist/d3.min.js"),htl:()=>t("htl@0.2.5/dist/htl.min.js"),html:()=>U,md:T(t),now:F,require:()=>t,resolve:()=>z,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})})); |
{ | ||
"name": "@observablehq/stdlib", | ||
"version": "3.4.1", | ||
"version": "3.5.0", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "main": "dist/stdlib.js", |
import {require as requireDefault} from "d3-require"; | ||
import constant from "./constant.js"; | ||
import DOM from "./dom/index.js"; | ||
@@ -16,2 +15,3 @@ import Files from "./files/index.js"; | ||
import tex from "./tex.js"; | ||
import vegalite from "./vegalite.js"; | ||
import width from "./width.js"; | ||
@@ -21,18 +21,32 @@ | ||
const require = requirer(resolver); | ||
Object.defineProperties(this, { | ||
DOM: {value: DOM, writable: true, enumerable: true}, | ||
FileAttachment: {value: constant(NoFileAttachments), writable: true, enumerable: true}, | ||
Files: {value: Files, writable: true, enumerable: true}, | ||
Generators: {value: Generators, writable: true, enumerable: true}, | ||
html: {value: constant(html), writable: true, enumerable: true}, | ||
md: {value: md(require), writable: true, enumerable: true}, | ||
Mutable: {value: constant(Mutable), writable: true, enumerable: true}, | ||
now: {value: now, writable: true, enumerable: true}, | ||
Promises: {value: Promises, writable: true, enumerable: true}, | ||
require: {value: constant(require), writable: true, enumerable: true}, | ||
resolve: {value: constant(resolve), writable: true, enumerable: true}, | ||
svg: {value: constant(svg), writable: true, enumerable: true}, | ||
tex: {value: tex(require), writable: true, enumerable: true}, | ||
width: {value: width, writable: true, enumerable: true} | ||
}); | ||
Object.defineProperties(this, properties({ | ||
DOM: () => DOM, | ||
FileAttachment: () => NoFileAttachments, | ||
Files: () => Files, | ||
Generators: () => Generators, | ||
Inputs: () => require("@observablehq/inputs@0.8.0/dist/inputs.umd.min.js"), | ||
Mutable: () => Mutable, | ||
Plot: () => require("@observablehq/plot@0.1.0/dist/plot.umd.min.js"), | ||
Promises: () => Promises, | ||
_: () => require("lodash@4.17.21/lodash.min.js"), | ||
d3: () => require("d3@6.7.0/dist/d3.min.js"), | ||
htl: () => require("htl@0.2.5/dist/htl.min.js"), | ||
html: () => html, | ||
md: md(require), | ||
now: now, | ||
require: () => require, | ||
resolve: () => resolve, | ||
svg: () => svg, | ||
tex: tex(require), | ||
vl: vegalite(require), | ||
width: width | ||
})); | ||
}, {resolve: requireDefault.resolve}); | ||
function properties(values) { | ||
return Object.fromEntries(Object.entries(values).map(property)); | ||
} | ||
function property([key, value]) { | ||
return [key, ({value, writable: true, enumerable: true})]; | ||
} |
@@ -1,3 +0,1 @@ | ||
import constant from "../constant.js"; | ||
var timeouts = new Map; | ||
@@ -19,5 +17,5 @@ | ||
var now; | ||
return (now = timeouts.get(time = +time)) ? now.then(constant(value)) | ||
return (now = timeouts.get(time = +time)) ? now.then(() => value) | ||
: (now = Date.now()) >= time ? Promise.resolve(value) | ||
: timeout(now, time).then(constant(value)); | ||
: timeout(now, time).then(() => value); | ||
} |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
82534
736
5