Skip to content

Commit a50a867

Browse files
authored
rm DatabaseClient (#594)
1 parent 0789bc5 commit a50a867

13 files changed

+10
-399
lines changed

src/client/main.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Runtime} from "observablehq:runtime";
2-
import {registerDatabase, registerFile} from "observablehq:stdlib";
3-
import {DatabaseClient, FileAttachment, Generators, Mutable, resize} from "observablehq:stdlib";
2+
import {registerFile} from "observablehq:stdlib";
3+
import {FileAttachment, Generators, Mutable, resize} from "observablehq:stdlib";
44
import {inspect, inspectError} from "./inspect.js";
55
import * as recommendedLibraries from "./stdlib/recommendedLibraries.js";
66
import * as sampleDatasets from "./stdlib/sampleDatasets.js";
@@ -9,7 +9,6 @@ const library = {
99
now: () => Generators.now(),
1010
width: () => Generators.width(document.querySelector("main")),
1111
resize: () => resize,
12-
DatabaseClient: () => DatabaseClient,
1312
FileAttachment: () => FileAttachment,
1413
Generators: () => Generators,
1514
Mutable: () => Mutable,
@@ -23,7 +22,7 @@ export const main = runtime.module();
2322
export const cellsById = new Map(); // TODO hide
2423

2524
export function define(cell) {
26-
const {id, inline, inputs = [], outputs = [], files = [], databases = [], body} = cell;
25+
const {id, inline, inputs = [], outputs = [], files = [], body} = cell;
2726
const variables = [];
2827
cellsById.get(id)?.variables.forEach((v) => v.delete());
2928
cellsById.set(id, {cell, variables});
@@ -60,7 +59,6 @@ export function define(cell) {
6059
variables.push(v);
6160
for (const o of outputs) variables.push(main.variable(true).define(o, [`cell ${id}`], (exports) => exports[o]));
6261
for (const f of files) registerFile(f.name, f);
63-
for (const d of databases) registerDatabase(d.name, d);
6462
}
6563

6664
// Note: Element.prototype is instanceof Node, but cannot be inserted!

src/client/preview.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export function open({hash, eval: compile} = {}) {
6262
inline: item.inline,
6363
inputs: item.inputs,
6464
outputs: item.outputs,
65-
databases: item.databases,
6665
files: item.files,
6766
body: compile(item.body)
6867
});

src/client/stdlib.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export {DatabaseClient, registerDatabase} from "./stdlib/databaseClient.js";
21
export {AbstractFile, FileAttachment, registerFile} from "./stdlib/fileAttachment.js";
32
export * as Generators from "./stdlib/generators/index.js";
43
export {Mutable} from "./stdlib/mutable.js";

src/client/stdlib/databaseClient.js

Lines changed: 0 additions & 207 deletions
This file was deleted.

src/javascript.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type {Expression, Identifier, Node, Options, Program} from "acorn";
33
import {fileReference} from "./files.js";
44
import {findAssignments} from "./javascript/assignments.js";
55
import {findAwaits} from "./javascript/awaits.js";
6-
import {resolveDatabases} from "./javascript/databases.js";
76
import {findDeclarations} from "./javascript/declarations.js";
87
import {findFeatures} from "./javascript/features.js";
98
import {findExports, findImportDeclarations, findImports} from "./javascript/imports.js";
@@ -13,10 +12,6 @@ import {syntaxError} from "./javascript/syntaxError.js";
1312
import {Sourcemap} from "./sourcemap.js";
1413
import {red} from "./tty.js";
1514

16-
export interface DatabaseReference {
17-
name: string;
18-
}
19-
2015
export interface FileReference {
2116
/** The relative path from the page to the original file (e.g., "./test.txt"). */
2217
name: string;
@@ -32,7 +27,7 @@ export interface ImportReference {
3227
}
3328

3429
export interface Feature {
35-
type: "FileAttachment" | "DatabaseClient" | "Secret";
30+
type: "FileAttachment";
3631
name: string;
3732
}
3833

@@ -42,7 +37,6 @@ export interface BaseTranspile {
4237
inputs?: string[];
4338
outputs?: string[];
4439
inline?: boolean;
45-
databases?: DatabaseReference[];
4640
files?: FileReference[];
4741
imports?: ImportReference[];
4842
}
@@ -69,9 +63,6 @@ export function transpileJavaScript(input: string, options: ParseOptions): Pendi
6963
const {id, root, sourcePath, verbose = true} = options;
7064
try {
7165
const node = parseJavaScript(input, options);
72-
const databases = node.features
73-
.filter((f) => f.type === "DatabaseClient")
74-
.map((f): DatabaseReference => ({name: f.name}));
7566
const files = node.features
7667
.filter((f) => f.type === "FileAttachment")
7768
.map(({name}) => fileReference(name, sourcePath));
@@ -85,7 +76,6 @@ export function transpileJavaScript(input: string, options: ParseOptions): Pendi
8576
...(inputs.length ? {inputs} : null),
8677
...(options.inline ? {inline: true} : null),
8778
...(node.declarations?.length ? {outputs: node.declarations.map(({name}) => name)} : null),
88-
...(databases.length ? {databases: resolveDatabases(databases)} : null),
8979
...(files.length ? {files} : null),
9080
body: async () => {
9181
const output = new Sourcemap(input);

src/javascript/databases.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/javascript/features.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export function findFeatures(node: Node, path: string, references: Identifier[],
1717
let type = featureMap.get(callee);
1818
// If this feature wasn’t explicitly imported into this cell, then ignore
1919
// function calls that are not references to the feature. For example, if
20-
// there’s a local variable called Secret, that will mask the built-in
21-
// Secret and won’t be considered a feature.
20+
// there’s a local variable called FileAttachment, that will mask the
21+
// built-in FileAttachment and won’t be considered a feature.
2222
if (!type) {
2323
if (!references.includes(callee)) return;
2424
const name = callee.name;
25-
if (name !== "Secret" && name !== "FileAttachment" && name !== "DatabaseClient") return;
25+
if (name !== "FileAttachment") return;
2626
type = name;
2727
}
2828
features.push(getFeature(type, node, path, input));
@@ -50,9 +50,7 @@ export function getFeatureReferenceMap(node: Node): Map<Identifier, Feature["typ
5050
if (
5151
specifier.type === "ImportSpecifier" &&
5252
specifier.imported.type === "Identifier" &&
53-
(specifier.imported.name === "FileAttachment" ||
54-
specifier.imported.name === "Secret" ||
55-
specifier.imported.name === "DatabaseClient")
53+
specifier.imported.name === "FileAttachment"
5654
) {
5755
declarations.add(specifier.local);
5856
alias.set(specifier.local.name, specifier.imported.name);

0 commit comments

Comments
 (0)