@observablehq/notebook-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +7 -0
- package/dist/bin/build.d.ts +2 -0
- package/dist/bin/build.js +63 -0
- package/dist/bin/download.d.ts +2 -0
- package/dist/bin/download.js +49 -0
- package/dist/bin/notebooks.d.ts +2 -0
- package/dist/bin/notebooks.js +33 -0
- package/dist/bin/preview.d.ts +2 -0
- package/dist/bin/preview.js +48 -0
- package/dist/package.json +73 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/javascript/assignments.d.ts +2 -0
- package/dist/src/javascript/assignments.js +37 -0
- package/dist/src/javascript/assignments.test.d.ts +1 -0
- package/dist/src/javascript/assignments.test.js +33 -0
- package/dist/src/javascript/awaits.d.ts +2 -0
- package/dist/src/javascript/awaits.js +23 -0
- package/dist/src/javascript/awaits.test.d.ts +1 -0
- package/dist/src/javascript/awaits.test.js +22 -0
- package/dist/src/javascript/declarations.d.ts +2 -0
- package/dist/src/javascript/declarations.js +45 -0
- package/dist/src/javascript/files.d.ts +3 -0
- package/dist/src/javascript/files.js +18 -0
- package/dist/src/javascript/globals.d.ts +1 -0
- package/dist/src/javascript/globals.js +86 -0
- package/dist/src/javascript/imports/jsr.d.ts +2 -0
- package/dist/src/javascript/imports/jsr.js +6 -0
- package/dist/src/javascript/imports/npm.d.ts +2 -0
- package/dist/src/javascript/imports/npm.js +47 -0
- package/dist/src/javascript/imports/npm.test.d.ts +1 -0
- package/dist/src/javascript/imports/npm.test.js +32 -0
- package/dist/src/javascript/imports/observable.d.ts +8 -0
- package/dist/src/javascript/imports/observable.js +64 -0
- package/dist/src/javascript/imports/observable.test.d.ts +1 -0
- package/dist/src/javascript/imports/observable.test.js +13 -0
- package/dist/src/javascript/imports.d.ts +21 -0
- package/dist/src/javascript/imports.js +146 -0
- package/dist/src/javascript/observable.d.ts +2 -0
- package/dist/src/javascript/observable.js +72 -0
- package/dist/src/javascript/parse.d.ts +11 -0
- package/dist/src/javascript/parse.js +53 -0
- package/dist/src/javascript/references.d.ts +8 -0
- package/dist/src/javascript/references.js +129 -0
- package/dist/src/javascript/references.test.d.ts +1 -0
- package/dist/src/javascript/references.test.js +38 -0
- package/dist/src/javascript/sourcemap.d.ts +21 -0
- package/dist/src/javascript/sourcemap.js +143 -0
- package/dist/src/javascript/sourcemap.test.d.ts +1 -0
- package/dist/src/javascript/sourcemap.test.js +88 -0
- package/dist/src/javascript/strings.d.ts +8 -0
- package/dist/src/javascript/strings.js +42 -0
- package/dist/src/javascript/strings.test.d.ts +1 -0
- package/dist/src/javascript/strings.test.js +31 -0
- package/dist/src/javascript/syntaxError.d.ts +2 -0
- package/dist/src/javascript/syntaxError.js +5 -0
- package/dist/src/javascript/template.d.ts +3 -0
- package/dist/src/javascript/template.js +141 -0
- package/dist/src/javascript/template.test.d.ts +1 -0
- package/dist/src/javascript/template.test.js +32 -0
- package/dist/src/javascript/transpile.d.ts +25 -0
- package/dist/src/javascript/transpile.js +42 -0
- package/dist/src/javascript/transpile.test.d.ts +1 -0
- package/dist/src/javascript/transpile.test.js +29 -0
- package/dist/src/javascript/walk.d.ts +5 -0
- package/dist/src/javascript/walk.js +13 -0
- package/dist/src/lib/notebook.d.ts +35 -0
- package/dist/src/lib/notebook.js +19 -0
- package/dist/src/lib/notebook.test.d.ts +1 -0
- package/dist/src/lib/notebook.test.js +26 -0
- package/dist/src/lib/serialize.d.ts +5 -0
- package/dist/src/lib/serialize.js +97 -0
- package/dist/src/lib/serialize.test.d.ts +1 -0
- package/dist/src/lib/serialize.test.js +125 -0
- package/dist/src/lib/text.d.ts +1 -0
- package/dist/src/lib/text.js +3 -0
- package/dist/src/runtime/define.d.ts +28 -0
- package/dist/src/runtime/define.js +62 -0
- package/dist/src/runtime/display.d.ts +16 -0
- package/dist/src/runtime/display.js +60 -0
- package/dist/src/runtime/index.d.ts +11 -0
- package/dist/src/runtime/index.js +14 -0
- package/dist/src/runtime/inspect.d.ts +3 -0
- package/dist/src/runtime/inspect.js +43 -0
- package/dist/src/runtime/stdlib/assets.d.ts +4 -0
- package/dist/src/runtime/stdlib/assets.js +110 -0
- package/dist/src/runtime/stdlib/assets.test.d.ts +1 -0
- package/dist/src/runtime/stdlib/assets.test.js +78 -0
- package/dist/src/runtime/stdlib/dom/canvas.d.ts +1 -0
- package/dist/src/runtime/stdlib/dom/canvas.js +6 -0
- package/dist/src/runtime/stdlib/dom/context2d.d.ts +1 -0
- package/dist/src/runtime/stdlib/dom/context2d.js +9 -0
- package/dist/src/runtime/stdlib/dom/index.d.ts +5 -0
- package/dist/src/runtime/stdlib/dom/index.js +5 -0
- package/dist/src/runtime/stdlib/dom/svg.d.ts +1 -0
- package/dist/src/runtime/stdlib/dom/svg.js +7 -0
- package/dist/src/runtime/stdlib/dom/text.d.ts +1 -0
- package/dist/src/runtime/stdlib/dom/text.js +3 -0
- package/dist/src/runtime/stdlib/dom/uid.d.ts +8 -0
- package/dist/src/runtime/stdlib/dom/uid.js +25 -0
- package/dist/src/runtime/stdlib/dot.d.ts +2 -0
- package/dist/src/runtime/stdlib/dot.js +34 -0
- package/dist/src/runtime/stdlib/duckdb.d.ts +24 -0
- package/dist/src/runtime/stdlib/duckdb.js +379 -0
- package/dist/src/runtime/stdlib/fileAttachment.d.ts +71 -0
- package/dist/src/runtime/stdlib/fileAttachment.js +199 -0
- package/dist/src/runtime/stdlib/generators/index.d.ts +5 -0
- package/dist/src/runtime/stdlib/generators/index.js +5 -0
- package/dist/src/runtime/stdlib/generators/input.d.ts +1 -0
- package/dist/src/runtime/stdlib/generators/input.js +45 -0
- package/dist/src/runtime/stdlib/generators/now.d.ts +1 -0
- package/dist/src/runtime/stdlib/generators/now.js +5 -0
- package/dist/src/runtime/stdlib/generators/observe.d.ts +1 -0
- package/dist/src/runtime/stdlib/generators/observe.js +31 -0
- package/dist/src/runtime/stdlib/generators/queue.d.ts +1 -0
- package/dist/src/runtime/stdlib/generators/queue.js +27 -0
- package/dist/src/runtime/stdlib/generators/width.d.ts +1 -0
- package/dist/src/runtime/stdlib/generators/width.js +13 -0
- package/dist/src/runtime/stdlib/highlight.d.ts +2 -0
- package/dist/src/runtime/stdlib/highlight.js +76 -0
- package/dist/src/runtime/stdlib/index.d.ts +56 -0
- package/dist/src/runtime/stdlib/index.js +23 -0
- package/dist/src/runtime/stdlib/inputs.css +15 -0
- package/dist/src/runtime/stdlib/inputs.d.ts +2 -0
- package/dist/src/runtime/stdlib/inputs.js +2 -0
- package/dist/src/runtime/stdlib/leaflet.d.ts +1 -0
- package/dist/src/runtime/stdlib/leaflet.js +7 -0
- package/dist/src/runtime/stdlib/mapboxgl.d.ts +1 -0
- package/dist/src/runtime/stdlib/mapboxgl.js +5 -0
- package/dist/src/runtime/stdlib/md.d.ts +5 -0
- package/dist/src/runtime/stdlib/md.js +72 -0
- package/dist/src/runtime/stdlib/mermaid.d.ts +2 -0
- package/dist/src/runtime/stdlib/mermaid.js +11 -0
- package/dist/src/runtime/stdlib/mutable.d.ts +8 -0
- package/dist/src/runtime/stdlib/mutable.js +30 -0
- package/dist/src/runtime/stdlib/observer.d.ts +16 -0
- package/dist/src/runtime/stdlib/observer.js +42 -0
- package/dist/src/runtime/stdlib/recommendedLibraries.d.ts +25 -0
- package/dist/src/runtime/stdlib/recommendedLibraries.js +26 -0
- package/dist/src/runtime/stdlib/require.d.ts +4 -0
- package/dist/src/runtime/stdlib/require.js +40 -0
- package/dist/src/runtime/stdlib/sampleDatasets.d.ts +12 -0
- package/dist/src/runtime/stdlib/sampleDatasets.js +31 -0
- package/dist/src/runtime/stdlib/sql.d.ts +5 -0
- package/dist/src/runtime/stdlib/sql.js +5 -0
- package/dist/src/runtime/stdlib/template.d.ts +7 -0
- package/dist/src/runtime/stdlib/template.js +2 -0
- package/dist/src/runtime/stdlib/tex.d.ts +7 -0
- package/dist/src/runtime/stdlib/tex.js +18 -0
- package/dist/src/runtime/stdlib/vega-lite.d.ts +1 -0
- package/dist/src/runtime/stdlib/vega-lite.js +4 -0
- package/dist/src/styles/abstract-dark.css +14 -0
- package/dist/src/styles/abstract-light.css +14 -0
- package/dist/src/styles/global.css +266 -0
- package/dist/src/styles/highlight.css +47 -0
- package/dist/src/styles/index.css +14 -0
- package/dist/src/styles/inspector.css +89 -0
- package/dist/src/styles/plot.css +7 -0
- package/dist/src/styles/syntax-dark.css +12 -0
- package/dist/src/styles/syntax-light.css +12 -0
- package/dist/src/styles/theme-air.css +7 -0
- package/dist/src/styles/theme-coffee.css +7 -0
- package/dist/src/styles/theme-cotton.css +7 -0
- package/dist/src/styles/theme-deep-space.css +16 -0
- package/dist/src/styles/theme-glacier.css +7 -0
- package/dist/src/styles/theme-ink.css +7 -0
- package/dist/src/styles/theme-midnight.css +7 -0
- package/dist/src/styles/theme-near-midnight.css +7 -0
- package/dist/src/styles/theme-ocean-floor.css +7 -0
- package/dist/src/styles/theme-parchment.css +7 -0
- package/dist/src/styles/theme-slate.css +7 -0
- package/dist/src/styles/theme-stark.css +16 -0
- package/dist/src/styles/theme-sun-faded.css +7 -0
- package/dist/src/templates/default.html +31 -0
- package/dist/src/vite/config.d.ts +2 -0
- package/dist/src/vite/config.js +30 -0
- package/dist/src/vite/index.d.ts +2 -0
- package/dist/src/vite/index.js +2 -0
- package/dist/src/vite/observable.d.ts +12 -0
- package/dist/src/vite/observable.js +176 -0
- package/package.json +73 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const SRC_SELECTOR = [
|
|
2
|
+
"audio source[src]", // audio
|
|
3
|
+
"audio[src]", // audio
|
|
4
|
+
"img[src]", // images
|
|
5
|
+
"picture source[src]", // images
|
|
6
|
+
"video source[src]", // videos
|
|
7
|
+
"video[src]" // videos
|
|
8
|
+
].join();
|
|
9
|
+
const SRCSET_SELECTOR = [
|
|
10
|
+
"img[srcset]", // images
|
|
11
|
+
"picture source[srcset]" // images
|
|
12
|
+
].join();
|
|
13
|
+
const HREF_SELECTOR = [
|
|
14
|
+
"a[href][download]", // download links
|
|
15
|
+
"link[href]" // stylesheets
|
|
16
|
+
].join();
|
|
17
|
+
const ASSET_ATTRIBUTES = [
|
|
18
|
+
[SRC_SELECTOR, "src"],
|
|
19
|
+
[SRCSET_SELECTOR, "srcset"],
|
|
20
|
+
[HREF_SELECTOR, "href"]
|
|
21
|
+
];
|
|
22
|
+
/** Populates the asset keys from the specified root. */
|
|
23
|
+
export function collectAssets(assets, root) {
|
|
24
|
+
for (const [selector, name] of ASSET_ATTRIBUTES) {
|
|
25
|
+
for (const element of root.querySelectorAll(selector)) {
|
|
26
|
+
if (isRelExternal(element))
|
|
27
|
+
continue;
|
|
28
|
+
const source = decodeURI(element.getAttribute(name));
|
|
29
|
+
if (name === "srcset") {
|
|
30
|
+
for (const s of parseSrcset(source)) {
|
|
31
|
+
if (isSourcePath(s)) {
|
|
32
|
+
assets.add(asImportPath(s));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (isSourcePath(source)) {
|
|
37
|
+
assets.add(asImportPath(source));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Mutates the specified root to apply the specified asset mapping. */
|
|
43
|
+
export function mapAssets(root, assets) {
|
|
44
|
+
const resolve = (s) => assets.get(asImportPath(s)) ?? s;
|
|
45
|
+
for (const [selector, src] of ASSET_ATTRIBUTES) {
|
|
46
|
+
for (const element of root.querySelectorAll(selector)) {
|
|
47
|
+
if (isRelExternal(element))
|
|
48
|
+
continue;
|
|
49
|
+
const source = decodeURI(element.getAttribute(src));
|
|
50
|
+
if (src === "srcset")
|
|
51
|
+
element.setAttribute(src, resolveSrcset(source, resolve));
|
|
52
|
+
else
|
|
53
|
+
element.setAttribute(src, resolve(source));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Returns true if the specified element has rel=external. */
|
|
58
|
+
function isRelExternal(a) {
|
|
59
|
+
return /(?:^|\s)external(?:\s|$)/i.test(a.getAttribute("rel") ?? ""); // e.g., <a href rel="external">
|
|
60
|
+
}
|
|
61
|
+
/** Strips the query string and anchor fragment from the specified source. */
|
|
62
|
+
function asPath(source) {
|
|
63
|
+
const i = source.indexOf("?");
|
|
64
|
+
const j = source.indexOf("#");
|
|
65
|
+
const k = i >= 0 && j >= 0 ? Math.min(i, j) : i >= 0 ? i : j;
|
|
66
|
+
return k >= 0 ? source.slice(0, k) : source; // strip query string or anchor fragment
|
|
67
|
+
}
|
|
68
|
+
/** Converts the specified source into an import path, typically with ./. */
|
|
69
|
+
function asImportPath(source) {
|
|
70
|
+
const path = asPath(source);
|
|
71
|
+
return isImportPath(path) ? path : `./${path}`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns true if the specified import specifier is a path, as opposed to a
|
|
75
|
+
* bare module specifier or a URL; import paths start with ./, ../, or /.
|
|
76
|
+
*/
|
|
77
|
+
function isImportPath(specifier) {
|
|
78
|
+
return ["./", "../", "/"].some((prefix) => specifier.startsWith(prefix));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns true if the specified source (such as an img element src attribute)
|
|
82
|
+
* is a path; this is anything that is not empty and does not start with a
|
|
83
|
+
* protocol or a hash.
|
|
84
|
+
*/
|
|
85
|
+
function isSourcePath(specifier) {
|
|
86
|
+
return asPath(specifier) ? !/^(\w+:|#)/.test(specifier) : false;
|
|
87
|
+
}
|
|
88
|
+
/** Parses the specified srcset attribute, returning the array of sources. */
|
|
89
|
+
function parseSrcset(srcset) {
|
|
90
|
+
return srcset
|
|
91
|
+
.trim()
|
|
92
|
+
.split(/\s*,\s*/)
|
|
93
|
+
.filter((src) => src)
|
|
94
|
+
.map((src) => src.split(/\s+/)[0]);
|
|
95
|
+
}
|
|
96
|
+
/** Resolves the specified srcset attribute, resolving any sources. */
|
|
97
|
+
function resolveSrcset(srcset, resolve) {
|
|
98
|
+
return srcset
|
|
99
|
+
.trim()
|
|
100
|
+
.split(/\s*,\s*/)
|
|
101
|
+
.filter((src) => src)
|
|
102
|
+
.map((src) => {
|
|
103
|
+
const parts = src.split(/\s+/);
|
|
104
|
+
const path = resolve(parts[0]);
|
|
105
|
+
if (path)
|
|
106
|
+
parts[0] = encodeURI(path);
|
|
107
|
+
return parts.join(" ");
|
|
108
|
+
})
|
|
109
|
+
.join(", ");
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { html } from "htl";
|
|
3
|
+
import { assert, test } from "vitest";
|
|
4
|
+
import { collectAssets } from "./assets.js";
|
|
5
|
+
function getAssets(root) {
|
|
6
|
+
const assets = new Set();
|
|
7
|
+
collectAssets(assets, root);
|
|
8
|
+
return assets;
|
|
9
|
+
}
|
|
10
|
+
test("find asset paths in descendants", () => {
|
|
11
|
+
assert.deepStrictEqual(new Set([
|
|
12
|
+
"./a-href.txt",
|
|
13
|
+
"./audio-source-src.wav",
|
|
14
|
+
"./audio-src.wav",
|
|
15
|
+
"./img-src.png",
|
|
16
|
+
"./img-srcset-src.png",
|
|
17
|
+
"./img-srcset.png",
|
|
18
|
+
"./link.css",
|
|
19
|
+
"./picture-source-src.png",
|
|
20
|
+
"./picture-srcset-src.png",
|
|
21
|
+
"./picture-srcset.png",
|
|
22
|
+
"./video-source-src.mp4",
|
|
23
|
+
"./video-src.mp4"
|
|
24
|
+
]), getAssets(html `<div>
|
|
25
|
+
<a href="./a-href.txt" download>download</a>
|
|
26
|
+
<audio><source src="./audio-source-src.wav"></audio>
|
|
27
|
+
<audio src="./audio-src.wav"></audio>
|
|
28
|
+
<img src="./img-src.png">
|
|
29
|
+
<img src="./img-srcset-src.png" srcset="./img-srcset.png 2x">
|
|
30
|
+
<link href="./link.css" rel="stylesheet">
|
|
31
|
+
<picture><source src="./picture-source-src.png"></picture>
|
|
32
|
+
<picture><source src="./picture-srcset-src.png" srcset="./picture-srcset.png 2x"></picture>
|
|
33
|
+
<video><source src="./video-source-src.mp4"></video>
|
|
34
|
+
<video src="./video-src.mp4"></video>
|
|
35
|
+
</div>`));
|
|
36
|
+
});
|
|
37
|
+
test("decodes paths", () => {
|
|
38
|
+
assert.deepStrictEqual(new Set(["./hello world.png"]), getAssets(html `<div><img src="./hello%20world.png"></div>`));
|
|
39
|
+
});
|
|
40
|
+
test("strips query strings and anchor fragments from the path", () => {
|
|
41
|
+
assert.deepStrictEqual(new Set(["./img1.png", "./img2.png", "./img3.png", "./img4.png"]), getAssets(html `<div>
|
|
42
|
+
<img src="./img1.png?foo=bar">
|
|
43
|
+
<img src="./img2.png#baz">
|
|
44
|
+
<img src="./img3.png?foo#bar">
|
|
45
|
+
<img src="./img4.png#foo?bar">
|
|
46
|
+
</div>`));
|
|
47
|
+
});
|
|
48
|
+
test("adds a leading dot slash to relative paths", () => {
|
|
49
|
+
assert.deepStrictEqual(new Set([
|
|
50
|
+
"./file.png",
|
|
51
|
+
"./path/to/file.png",
|
|
52
|
+
"/root.png",
|
|
53
|
+
"./dot-slash.png",
|
|
54
|
+
"../dot-dot-slash.png"
|
|
55
|
+
]), getAssets(html `<div>
|
|
56
|
+
<img src="file.png">
|
|
57
|
+
<img src="path/to/file.png">
|
|
58
|
+
<img src="/root.png">
|
|
59
|
+
<img src="./dot-slash.png">
|
|
60
|
+
<img src="../dot-dot-slash.png">
|
|
61
|
+
</div>`));
|
|
62
|
+
});
|
|
63
|
+
test("ignores protocol links", () => {
|
|
64
|
+
assert.deepStrictEqual(new Set([]), getAssets(html `<div>
|
|
65
|
+
<img src="https://example.com/test.png">
|
|
66
|
+
</div>`));
|
|
67
|
+
});
|
|
68
|
+
test("ignores fragment links", () => {
|
|
69
|
+
assert.deepStrictEqual(new Set([]), getAssets(html `<div>
|
|
70
|
+
<a href="#test" download>download</a>
|
|
71
|
+
</div>`));
|
|
72
|
+
});
|
|
73
|
+
test("ignores rel=external elements", () => {
|
|
74
|
+
assert.deepStrictEqual(new Set(["./internal.txt"]), getAssets(html `<div>
|
|
75
|
+
<a href="external.txt" rel="external" download>download</a>
|
|
76
|
+
<a href="internal.txt" rel="notexternal" download>download</a>
|
|
77
|
+
</div>`));
|
|
78
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function canvas(width: number, height: number): HTMLCanvasElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function context2d(width: number, height: number, dpi?: number): CanvasRenderingContext2D;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function context2d(width, height, dpi = devicePixelRatio) {
|
|
2
|
+
const canvas = document.createElement("canvas");
|
|
3
|
+
canvas.width = width * dpi;
|
|
4
|
+
canvas.height = height * dpi;
|
|
5
|
+
canvas.style.width = `${width}px`;
|
|
6
|
+
const context = canvas.getContext("2d");
|
|
7
|
+
context.scale(dpi, dpi);
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function svg(width: number, height: number): SVGSVGElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function svg(width, height) {
|
|
2
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3
|
+
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
4
|
+
svg.setAttribute("width", `${width}`);
|
|
5
|
+
svg.setAttribute("height", `${height}`);
|
|
6
|
+
return svg;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function text(value: string): Text;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
let count = 0;
|
|
2
|
+
export function uid(name) {
|
|
3
|
+
return new Id(`O-${name == null ? "" : `${name}-`}${++count}`);
|
|
4
|
+
}
|
|
5
|
+
class Id {
|
|
6
|
+
constructor(id) {
|
|
7
|
+
Object.defineProperty(this, "id", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: void 0
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "href", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
this.id = id;
|
|
20
|
+
this.href = new URL(`#${id}`, location.href).href;
|
|
21
|
+
}
|
|
22
|
+
toString() {
|
|
23
|
+
return `url(${this.href})`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { instance } from "npm:@viz-js/viz";
|
|
2
|
+
const viz = await instance();
|
|
3
|
+
export const dot = (template, ...values) => {
|
|
4
|
+
const source = String.raw.call(String, template, ...values);
|
|
5
|
+
const svg = viz.renderSVGElement(source, {
|
|
6
|
+
graphAttributes: {
|
|
7
|
+
bgcolor: "none",
|
|
8
|
+
color: "#00000101",
|
|
9
|
+
fontcolor: "#00000101",
|
|
10
|
+
fontname: "var(--sans-serif)",
|
|
11
|
+
fontsize: "12"
|
|
12
|
+
},
|
|
13
|
+
nodeAttributes: {
|
|
14
|
+
color: "#00000101",
|
|
15
|
+
fontcolor: "#00000101",
|
|
16
|
+
fontname: "var(--sans-serif)",
|
|
17
|
+
fontsize: "12"
|
|
18
|
+
},
|
|
19
|
+
edgeAttributes: {
|
|
20
|
+
color: "#00000101"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
for (const e of svg.querySelectorAll("[stroke='#000001'][stroke-opacity='0.003922']")) {
|
|
24
|
+
e.setAttribute("stroke", "currentColor");
|
|
25
|
+
e.removeAttribute("stroke-opacity");
|
|
26
|
+
}
|
|
27
|
+
for (const e of svg.querySelectorAll("[fill='#000001'][fill-opacity='0.003922']")) {
|
|
28
|
+
e.setAttribute("fill", "currentColor");
|
|
29
|
+
e.removeAttribute("fill-opacity");
|
|
30
|
+
}
|
|
31
|
+
svg.remove();
|
|
32
|
+
svg.style = "max-width: 100%; height: auto;";
|
|
33
|
+
return svg;
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class DuckDBClient {
|
|
2
|
+
static of(sources?: {}, config?: {}): Promise<DuckDBClient>;
|
|
3
|
+
static sql(...args: any[]): Promise<(strings: any, ...args: any[]) => Promise<any>>;
|
|
4
|
+
constructor(db: any);
|
|
5
|
+
queryStream(query: any, params: any): Promise<{
|
|
6
|
+
schema: any;
|
|
7
|
+
readRows(): AsyncGenerator<any, void, unknown>;
|
|
8
|
+
}>;
|
|
9
|
+
query(query: any, params: any): Promise<any>;
|
|
10
|
+
queryRow(query: any, params: any): Promise<any>;
|
|
11
|
+
sql(strings: any, ...args: any[]): Promise<any>;
|
|
12
|
+
queryTag(strings: any, ...params: any[]): any[];
|
|
13
|
+
escape(name: any): string;
|
|
14
|
+
describeTables(): Promise<{
|
|
15
|
+
name: any;
|
|
16
|
+
}[]>;
|
|
17
|
+
describeColumns(options?: {}): Promise<{
|
|
18
|
+
name: any;
|
|
19
|
+
type: string;
|
|
20
|
+
nullable: boolean;
|
|
21
|
+
databaseType: any;
|
|
22
|
+
}[]>;
|
|
23
|
+
readonly dialect: string;
|
|
24
|
+
}
|