@observablehq/notebook-kit 2.5.1 → 2.5.3
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/dist/package.json +1 -1
- package/dist/src/runtime/index.d.ts +1 -0
- package/dist/src/runtime/index.js +1 -0
- package/dist/src/runtime/stdlib/fileAttachment.d.ts +5 -2
- package/dist/src/runtime/stdlib/fileAttachment.js +2 -2
- package/dist/src/runtime/stdlib/index.d.ts +2 -1
- package/dist/src/runtime/stdlib/index.js +2 -0
- package/dist/src/runtime/stdlib/recommendedLibraries.d.ts +0 -1
- package/dist/src/runtime/stdlib/recommendedLibraries.js +0 -1
- package/dist/src/vite/observable.js +8 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -13,6 +13,7 @@ export type * from "./stdlib/fileAttachment.js";
|
|
|
13
13
|
export { FileAttachment, requireFileRegistration, registerFile } from "./stdlib/fileAttachment.js";
|
|
14
14
|
export type * from "./stdlib/interpreter.js";
|
|
15
15
|
export { Interpreter } from "./stdlib/interpreter.js";
|
|
16
|
+
export { sql } from "./stdlib/sql.js";
|
|
16
17
|
export declare class NotebookRuntime {
|
|
17
18
|
readonly runtime: Runtime & {
|
|
18
19
|
fileAttachments: typeof fileAttachments;
|
|
@@ -8,6 +8,7 @@ export * from "./stdlib/index.js";
|
|
|
8
8
|
export { DatabaseClient } from "./stdlib/databaseClient.js";
|
|
9
9
|
export { FileAttachment, requireFileRegistration, registerFile } from "./stdlib/fileAttachment.js";
|
|
10
10
|
export { Interpreter } from "./stdlib/interpreter.js";
|
|
11
|
+
export { sql } from "./stdlib/sql.js";
|
|
11
12
|
export class NotebookRuntime {
|
|
12
13
|
constructor(builtins = library) {
|
|
13
14
|
Object.defineProperty(this, "runtime", {
|
|
@@ -89,9 +89,12 @@ declare class FileAttachmentImpl extends AbstractFile {
|
|
|
89
89
|
href: string;
|
|
90
90
|
constructor(href: string, name: string, mimeType?: string, lastModified?: number, size?: number);
|
|
91
91
|
}
|
|
92
|
-
type
|
|
92
|
+
type FileResolution = {
|
|
93
93
|
url: string;
|
|
94
94
|
mimeType?: string;
|
|
95
|
-
|
|
95
|
+
lastModified?: number;
|
|
96
|
+
size?: number;
|
|
97
|
+
};
|
|
98
|
+
type FileResolver = (name: string) => FileResolution | string | null;
|
|
96
99
|
export declare function fileAttachments(resolve: FileResolver): (name: string) => FileAttachment;
|
|
97
100
|
export {};
|
|
@@ -220,8 +220,8 @@ export function fileAttachments(resolve) {
|
|
|
220
220
|
if (result == null)
|
|
221
221
|
throw new Error(`File not found: ${name}`);
|
|
222
222
|
if (typeof result === "object" && "url" in result) {
|
|
223
|
-
const { url, mimeType } = result;
|
|
224
|
-
return new FileAttachmentImpl(url, name, mimeType);
|
|
223
|
+
const { url, mimeType, lastModified, size } = result;
|
|
224
|
+
return new FileAttachmentImpl(url, name, mimeType, lastModified, size);
|
|
225
225
|
}
|
|
226
226
|
return new FileAttachmentImpl(result, name);
|
|
227
227
|
}
|
|
@@ -6,6 +6,7 @@ import * as Generators from "./generators/index.js";
|
|
|
6
6
|
import { Interpreter } from "./interpreter.js";
|
|
7
7
|
import { Mutable } from "./mutable.js";
|
|
8
8
|
import * as Promises from "./promises/index.js";
|
|
9
|
+
import { sql } from "./sql.js";
|
|
9
10
|
export declare const root: HTMLElement;
|
|
10
11
|
export declare const library: {
|
|
11
12
|
aapl: () => Promise<any>;
|
|
@@ -40,7 +41,6 @@ export declare const library: {
|
|
|
40
41
|
Plot: () => Promise<any>;
|
|
41
42
|
React: () => Promise<any>;
|
|
42
43
|
ReactDOM: () => Promise<any>;
|
|
43
|
-
sql: () => Promise<typeof import("./sql.js").sql>;
|
|
44
44
|
tex: () => Promise<import("./template.js").RawTemplateRenderer & {
|
|
45
45
|
options: (options?: any) => import("./template.js").RawTemplateRenderer;
|
|
46
46
|
block: import("./template.js").RawTemplateRenderer;
|
|
@@ -101,4 +101,5 @@ export declare const library: {
|
|
|
101
101
|
Promises: () => typeof Promises;
|
|
102
102
|
Files: () => typeof Files;
|
|
103
103
|
DOM: () => typeof DOM;
|
|
104
|
+
sql: () => typeof sql;
|
|
104
105
|
};
|
|
@@ -8,6 +8,7 @@ import { Mutable } from "./mutable.js";
|
|
|
8
8
|
import * as Promises from "./promises/index.js";
|
|
9
9
|
import * as recommendedLibraries from "./recommendedLibraries.js";
|
|
10
10
|
import * as sampleDatasets from "./sampleDatasets.js";
|
|
11
|
+
import { sql } from "./sql.js";
|
|
11
12
|
export const root = document.querySelector("main") ?? document.body;
|
|
12
13
|
export const library = {
|
|
13
14
|
dark: () => Generators.dark(),
|
|
@@ -21,6 +22,7 @@ export const library = {
|
|
|
21
22
|
Promises: () => Promises, // deprecated!
|
|
22
23
|
Files: () => Files, // deprecated!
|
|
23
24
|
DOM: () => DOM, // deprecated!
|
|
25
|
+
sql: () => sql,
|
|
24
26
|
...recommendedLibraries,
|
|
25
27
|
...sampleDatasets
|
|
26
28
|
};
|
|
@@ -18,7 +18,6 @@ export declare const mermaid: () => Promise<import("./template.js").AsyncRawTemp
|
|
|
18
18
|
export declare const Plot: () => Promise<any>;
|
|
19
19
|
export declare const React: () => Promise<any>;
|
|
20
20
|
export declare const ReactDOM: () => Promise<any>;
|
|
21
|
-
export declare const sql: () => Promise<typeof import("./sql.js").sql>;
|
|
22
21
|
export declare const tex: () => Promise<import("./template.js").RawTemplateRenderer & {
|
|
23
22
|
options: (options?: any) => import("./template.js").RawTemplateRenderer;
|
|
24
23
|
block: import("./template.js").RawTemplateRenderer;
|
|
@@ -18,7 +18,6 @@ export const mermaid = () => import("./mermaid.js").then((_) => _.mermaid);
|
|
|
18
18
|
export const Plot = () => import("https://cdn.jsdelivr.net/npm/@observablehq/plot/+esm");
|
|
19
19
|
export const React = () => import("https://cdn.jsdelivr.net/npm/react/+esm");
|
|
20
20
|
export const ReactDOM = () => import("https://cdn.jsdelivr.net/npm/react-dom/+esm");
|
|
21
|
-
export const sql = () => import("./sql.js").then((_) => _.sql);
|
|
22
21
|
// export const SQLite = () => import("observablehq:stdlib/sqlite").then((_) => _.default);
|
|
23
22
|
// export const SQLiteDatabaseClient = () => import("observablehq:stdlib/sqlite").then((_) => _.SQLiteDatabaseClient);
|
|
24
23
|
export const tex = () => import("./tex.js").then((_) => _.tex);
|
|
@@ -89,6 +89,10 @@ export function observable({ window = new JSDOM().window, parser = new window.DO
|
|
|
89
89
|
}
|
|
90
90
|
cell.mode = "js";
|
|
91
91
|
cell.value = `FileAttachment(${JSON.stringify(relative(dir, cachePath))}).json().then(DatabaseClient.revive)${hidden ? "" : `.then(Inputs.table)${cell.output ? ".then(view)" : ""}`}`;
|
|
92
|
+
if (cell.output) {
|
|
93
|
+
cell.value = `const ${cell.output} = ${cell.value};`;
|
|
94
|
+
cell.output = undefined;
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
else if (isInterpreter(mode)) {
|
|
@@ -119,6 +123,10 @@ export function observable({ window = new JSDOM().window, parser = new window.DO
|
|
|
119
123
|
}
|
|
120
124
|
cell.mode = "js";
|
|
121
125
|
cell.value = `FileAttachment(${JSON.stringify(relative(sourceDir, cachePath))})${getInterpreterMethod(format)}`;
|
|
126
|
+
if (cell.output) {
|
|
127
|
+
cell.value = `const ${cell.output} = ${cell.value};`;
|
|
128
|
+
cell.output = undefined;
|
|
129
|
+
}
|
|
122
130
|
}
|
|
123
131
|
collectAssets(assets, div);
|
|
124
132
|
if (pinned) {
|