From f28561abb3842c479d8fce04776d260c4270fc38 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Tue, 8 Nov 2022 09:41:08 -0800 Subject: [PATCH 1/6] esm --- README.md | 114 +++--- bin/resolve-dependencies | 2 +- package.json | 40 ++- rollup.config.js | 4 +- src/{array.mjs => array.js} | 0 src/{dependencies.mjs => dependencies.js} | 2 +- src/{dependency.mjs => dependency.js} | 0 src/dom/{canvas.mjs => canvas.js} | 0 src/dom/{context2d.mjs => context2d.js} | 0 src/dom/{download.mjs => download.js} | 0 src/dom/{element.mjs => element.js} | 0 src/dom/index.js | 23 ++ src/dom/index.mjs | 23 -- src/dom/{input.mjs => input.js} | 0 src/dom/{range.mjs => range.js} | 0 src/dom/{select.mjs => select.js} | 0 src/dom/{svg.mjs => svg.js} | 0 src/dom/{text.mjs => text.js} | 0 src/dom/{uid.mjs => uid.js} | 0 src/{fileAttachment.mjs => fileAttachment.js} | 8 +- src/files/{buffer.mjs => buffer.js} | 0 src/files/index.js | 9 + src/files/index.mjs | 9 - src/files/{text.mjs => text.js} | 0 src/files/{url.mjs => url.js} | 0 .../{disposable.mjs => disposable.js} | 2 +- src/generators/{filter.mjs => filter.js} | 0 src/generators/index.js | 21 ++ src/generators/index.mjs | 21 -- src/generators/{input.mjs => input.js} | 2 +- src/generators/{map.mjs => map.js} | 0 src/generators/{observe.mjs => observe.js} | 2 +- src/generators/{queue.mjs => queue.js} | 2 +- src/generators/{range.mjs => range.js} | 0 src/generators/{valueAt.mjs => valueAt.js} | 0 src/generators/{worker.mjs => worker.js} | 2 +- src/{html.mjs => html.js} | 2 +- src/{index.mjs => index.js} | 6 +- src/{leaflet.mjs => leaflet.js} | 2 +- src/{library.mjs => library.js} | 40 +-- src/{md.mjs => md.js} | 4 +- src/{mermaid.mjs => mermaid.js} | 4 +- src/{mutable.mjs => mutable.js} | 2 +- src/{now.mjs => now.js} | 0 src/promises/{delay.mjs => delay.js} | 0 src/promises/index.js | 9 + src/promises/index.mjs | 9 - src/promises/{tick.mjs => tick.js} | 2 +- src/promises/{when.mjs => when.js} | 0 src/{require.mjs => require.js} | 0 src/{resolve.mjs => resolve.js} | 0 src/{sqlite.mjs => sqlite.js} | 4 +- src/{svg.mjs => svg.js} | 2 +- src/{table.mjs => table.js} | 4 +- src/{template.mjs => template.js} | 0 src/{tex.mjs => tex.js} | 2 +- src/{that.mjs => that.js} | 0 src/{vegalite.mjs => vegalite.js} | 2 +- src/{width.mjs => width.js} | 2 +- src/{xlsx.mjs => xlsx.js} | 0 test/DOM/{uid-test.mjs => uid-test.js} | 2 +- ...ments-test.mjs => fileAttachments-test.js} | 2 +- ...disposable-test.mjs => disposable-test.js} | 2 +- ...generators-test.mjs => generators-test.js} | 14 +- test/{index-test.mjs => index-test.js} | 2 +- .../{delay-test.mjs => delay-test.js} | 4 +- test/{table-test.mjs => table-test.js} | 2 +- test/{xlsx-test.mjs => xlsx-test.js} | 2 +- yarn.lock | 325 +++++++++++------- 69 files changed, 411 insertions(+), 326 deletions(-) rename src/{array.mjs => array.js} (100%) rename src/{dependencies.mjs => dependencies.js} (97%) rename src/{dependency.mjs => dependency.js} (100%) rename src/dom/{canvas.mjs => canvas.js} (100%) rename src/dom/{context2d.mjs => context2d.js} (100%) rename src/dom/{download.mjs => download.js} (100%) rename src/dom/{element.mjs => element.js} (100%) create mode 100644 src/dom/index.js delete mode 100644 src/dom/index.mjs rename src/dom/{input.mjs => input.js} (100%) rename src/dom/{range.mjs => range.js} (100%) rename src/dom/{select.mjs => select.js} (100%) rename src/dom/{svg.mjs => svg.js} (100%) rename src/dom/{text.mjs => text.js} (100%) rename src/dom/{uid.mjs => uid.js} (100%) rename src/{fileAttachment.mjs => fileAttachment.js} (95%) rename src/files/{buffer.mjs => buffer.js} (100%) create mode 100644 src/files/index.js delete mode 100644 src/files/index.mjs rename src/files/{text.mjs => text.js} (100%) rename src/files/{url.mjs => url.js} (100%) rename src/generators/{disposable.mjs => disposable.js} (92%) rename src/generators/{filter.mjs => filter.js} (100%) create mode 100644 src/generators/index.js delete mode 100644 src/generators/index.mjs rename src/generators/{input.mjs => input.js} (96%) rename src/generators/{map.mjs => map.js} (100%) rename src/generators/{observe.mjs => observe.js} (96%) rename src/generators/{queue.mjs => queue.js} (96%) rename src/generators/{range.mjs => range.js} (100%) rename src/generators/{valueAt.mjs => valueAt.js} (100%) rename src/generators/{worker.mjs => worker.js} (85%) rename src/{html.mjs => html.js} (86%) rename src/{index.mjs => index.js} (53%) rename src/{leaflet.mjs => leaflet.js} (86%) rename src/{library.mjs => library.js} (87%) rename src/{md.mjs => md.js} (93%) rename src/{mermaid.mjs => mermaid.js} (81%) rename src/{mutable.mjs => mutable.js} (86%) rename src/{now.mjs => now.js} (100%) rename src/promises/{delay.mjs => delay.js} (100%) create mode 100644 src/promises/index.js delete mode 100644 src/promises/index.mjs rename src/promises/{tick.mjs => tick.js} (79%) rename src/promises/{when.mjs => when.js} (100%) rename src/{require.mjs => require.js} (100%) rename src/{resolve.mjs => resolve.js} (100%) rename src/{sqlite.mjs => sqlite.js} (98%) rename src/{svg.mjs => svg.js} (86%) rename src/{table.mjs => table.js} (99%) rename src/{template.mjs => template.js} (100%) rename src/{tex.mjs => tex.js} (95%) rename src/{that.mjs => that.js} (100%) rename src/{vegalite.mjs => vegalite.js} (73%) rename src/{width.mjs => width.js} (88%) rename src/{xlsx.mjs => xlsx.js} (100%) rename test/DOM/{uid-test.mjs => uid-test.js} (89%) rename test/{fileAttachments-test.mjs => fileAttachments-test.js} (96%) rename test/generators/{disposable-test.mjs => disposable-test.js} (93%) rename test/generators/{generators-test.mjs => generators-test.js} (78%) rename test/{index-test.mjs => index-test.js} (94%) rename test/promises/{delay-test.mjs => delay-test.js} (90%) rename test/{table-test.mjs => table-test.js} (99%) rename test/{xlsx-test.mjs => xlsx-test.js} (99%) diff --git a/README.md b/README.md index 28003118..dafee0ae 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ For examples, see https://observablehq.com/@observablehq/stdlib. ### DOM -# DOM.canvas(width, height) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/canvas.mjs "Source") +# DOM.canvas(width, height) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/canvas.js "Source") Returns a new canvas element with the specified *width* and *height*. For example, to create a 960×500 canvas: @@ -41,7 +41,7 @@ html`` If you are using [2D Canvas](https://www.w3.org/TR/2dcontext/) (rather than [WebGL](https://webglfundamentals.org/)), you should use [DOM.context2d](#DOM_context2d) instead of DOM.canvas for automatic pixel density scaling. -# DOM.context2d(width, height[, dpi]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/context2d.mjs "Source") +# DOM.context2d(width, height[, dpi]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/context2d.js "Source") Returns a new canvas context with the specified *width* and *height* and the specified device pixel ratio *dpi*. If *dpi* is not specified, it defaults to [*window*.devicePixelRatio](https://developer.mozilla.org/docs/Web/API/Window/devicePixelRatio). To access the context’s canvas, use [*context*.canvas](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/canvas). For example, to create a 960×500 canvas: @@ -54,7 +54,7 @@ Returns a new canvas context with the specified *width* and *height* and the spe If you are using [WebGL](https://webglfundamentals.org/) (rather than [2D Canvas](https://www.w3.org/TR/2dcontext/)), you should use [DOM.canvas](#DOM_canvas) or the [html](#html) tagged template literal instead of DOM.context2d. -# DOM.download(object\[, name\]\[, value\]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/download.mjs "Source") +# DOM.download(object\[, name\]\[, value\]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/download.js "Source") Returns an anchor element containing a button that when clicked will download a file representing the specified *object*. The *object* should be anything supported by [URL.createObjectURL](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL) such as a [file](https://developer.mozilla.org/docs/Web/API/File) or a [blob](https://developer.mozilla.org/docs/Web/API/Blob). For example, to create a button to download a Canvas element as a PNG: @@ -70,7 +70,7 @@ DOM.download(() => new Promise(resolve => canvas.toBlob(resolve))) If the *object* is a promise, or if it is a function that returns a promise, the promise will be awaited before downloading. If necessary, an additional click may be required to download the asynchronous value. -# DOM.element(name[, attributes]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/element.mjs "Source") +# DOM.element(name[, attributes]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/element.js "Source") Returns a new element with the specified *name*. For example, to create an empty H1 element: @@ -110,7 +110,7 @@ svg`` In general, you probably want to use the [html](#html) or [svg](#svg) tagged template literal instead of DOM.element. -# DOM.input([type]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/input.mjs "Source") +# DOM.input([type]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/input.js "Source") Returns a new input element with the specified *type*. If *type* is not specified or null, a text input is created. For example, to create a new file input: @@ -126,7 +126,7 @@ html`` In general, you probably want to use the [html](#html) tagged template literal instead of DOM.input. -# DOM.range(\[min, \]\[max\]\[, step\]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/range.mjs "Source") +# DOM.range(\[min, \]\[max\]\[, step\]) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/range.js "Source") Returns a new range input element. (See also [DOM.input](#input).) If *max* is specified, sets the maximum value of the range to the specified number; if *max* is not specified or null, sets the maximum value of the range to 1. If *min* is specified, sets the minimum value of the range to the specified number; if *min* is not specified or null, sets the minimum value of the range to 0. If *step* is specified, sets the step value of the range to the specified number; if *step* is not specified or null, sets the step value of the range to `any`. For example, to create a slider that ranges the integers from -180 to +180, inclusive: @@ -142,7 +142,7 @@ html`` In general, you probably want to use the [html](#html) tagged template literal instead of DOM.input. -# DOM.select(values) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/select.mjs "Source") +# DOM.select(values) [<>](https://github.com/observablehq/stdlib/blob/main/src/dom/select.js "Source") Returns a new select element with an option for each string in the specified *values* array. For example, to create a drop-down menu of three colors: @@ -170,7 +170,7 @@ html`