@observablehq/notebook-kit 2.5.6 → 2.5.7

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.6",
8
+ "version": "2.5.7",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",
@@ -103,8 +103,8 @@ export function transpileTemplate(input, tag = "", raw = false) {
103
103
  (raw ? escapeRawTemplateElements : escapeTemplateElements)(source, template);
104
104
  node = template;
105
105
  }
106
- source.insertLeft(node.start, `${cell?.output ? `const ${cell.output} = ` : ""}${prefix}\``);
107
- source.insertRight(node.end, `\`${suffix}${cell?.output ? ";" : ""}`);
106
+ source.insertLeft(node.start, `${prefix}\``);
107
+ source.insertRight(node.end, `\`${suffix}`);
108
108
  return String(source);
109
109
  }
110
110
  function getRaw(cell) {
@@ -26,8 +26,15 @@ export function transpile(input, mode, options) {
26
26
  : mode !== "js"
27
27
  ? transpileJavaScript(transpileTemplate(cell), options)
28
28
  : transpileJavaScript(input, options);
29
- if (cell.hidden)
29
+ if (cell.hidden) {
30
30
  transpiled.autodisplay = false;
31
+ }
32
+ else if (mode !== "ts" && mode !== "js" && mode !== "ojs") {
33
+ if (cell.output)
34
+ transpiled.output = cell.output;
35
+ if (cell.value)
36
+ transpiled.autodisplay = true;
37
+ }
31
38
  return transpiled;
32
39
  }
33
40
  export function transpileTypeScript(input, options) {
@@ -122,7 +122,7 @@ export function observable({ window = new JSDOM().window, parser = new window.DO
122
122
  statics.add(cell);
123
123
  }
124
124
  cell.mode = "js";
125
- cell.value = `FileAttachment(${JSON.stringify(relative(sourceDir, cachePath))})${getInterpreterMethod(format)}`;
125
+ cell.value = `FileAttachment(${JSON.stringify(relative(sourceDir, cachePath))})${getInterpreterMethod(format)}${hidden || !cell.output ? "" : ".then(display)"}`;
126
126
  if (cell.output) {
127
127
  cell.value = `const ${cell.output} = ${cell.value};`;
128
128
  cell.output = undefined;
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.6",
8
+ "version": "2.5.7",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",