@observablehq/notebook-kit 1.7.0 → 1.7.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": "1.7.0",
8
+ "version": "1.7.2",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "vitest",
@@ -23,11 +23,18 @@ function resolve(_specifier) {
23
23
  const { name, range, path } = parseNpmSpecifier(specifier);
24
24
  return `https://cdn.jsdelivr.net/npm/${name}${range}${path + (isFile(path) || isDirectory(path) ? "" : "/+esm")}`;
25
25
  }
26
+ /** Promote exclusive default export to module. */
27
+ function defaultify(module) {
28
+ for (const key in module)
29
+ if (key !== "default")
30
+ return { ...module }; // any named export
31
+ return "default" in module ? module.default : { ...module }; // promote exclusive default export
32
+ }
26
33
  /** Allow mutation of required modules while maintaining a canonical instance; ugly! */
27
34
  function objectify(module) {
28
35
  let object = cache.get(module);
29
36
  if (!object)
30
- cache.set(module, (object = { ...module }));
37
+ cache.set(module, (object = defaultify(module)));
31
38
  return object;
32
39
  }
33
40
  /** Returns true for e.g. https://example.com/ */
@@ -25,6 +25,7 @@ export class Workbook {
25
25
  return extract(sheet, options);
26
26
  }
27
27
  }
28
+ Object.defineProperty(Workbook, "name", { value: "Workbook" }); // prevent mangling
28
29
  function extract(sheet, { range, headers } = {}) {
29
30
  let [[c0, r0], [c1, r1]] = parseRange(range, sheet); // eslint-disable-line prefer-const
30
31
  const headerRow = headers ? sheet.getRow(++r0) : null;
@@ -17,5 +17,6 @@ declare class ZipArchiveEntry extends AbstractFile {
17
17
  arrayBuffer(): Promise<ArrayBuffer>;
18
18
  text(): Promise<string>;
19
19
  json(): Promise<any>;
20
+ stream(): Promise<ReadableStream<Uint8Array>>;
20
21
  }
21
22
  export {};
@@ -19,7 +19,7 @@ export class ZipArchive {
19
19
  }
20
20
  class ZipArchiveEntry extends AbstractFile {
21
21
  constructor(object) {
22
- super(undefined, object.name);
22
+ super(object.name);
23
23
  Object.defineProperty(this, "href", {
24
24
  enumerable: true,
25
25
  configurable: true,
@@ -46,4 +46,9 @@ class ZipArchiveEntry extends AbstractFile {
46
46
  async json() {
47
47
  return JSON.parse(await this.text());
48
48
  }
49
+ async stream() {
50
+ return (await this.blob()).stream(); // since href is unavailable
51
+ }
49
52
  }
53
+ Object.defineProperty(ZipArchive, "name", { value: "ZipArchive" }); // prevent mangling
54
+ Object.defineProperty(ZipArchiveEntry, "name", { value: "ZipArchiveEntry" }); // prevent mangling
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": "1.7.0",
8
+ "version": "1.7.2",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "vitest",