@observablehq/notebook-kit 2.5.1 → 2.5.2

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.5.1",
8
+ "version": "2.5.2",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",
@@ -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 FileResolver = (name: string) => {
92
+ type FileResolution = {
93
93
  url: string;
94
94
  mimeType?: string;
95
- } | string | null;
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
  }
@@ -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) {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.5.1",
8
+ "version": "2.5.2",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",