@observablehq/notebook-kit 2.4.1 → 2.5.0

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.4.1",
8
+ "version": "2.5.0",
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, `${prefix}\``);
107
- source.insertRight(node.end, `\`${suffix}`);
106
+ source.insertLeft(node.start, `${cell?.output ? `const ${cell.output} = ` : ""}${prefix}\``);
107
+ source.insertRight(node.end, `\`${suffix}${cell?.output ? ";" : ""}`);
108
108
  return String(source);
109
109
  }
110
110
  function getRaw(cell) {
@@ -128,10 +128,10 @@ function getDatabase(cell) {
128
128
  : `DatabaseClient(${JSON.stringify(database)}, {id: ${id}${since === undefined ? "" : `, since: ${JSON.stringify(since)}`}})`;
129
129
  }
130
130
  function getSqlPrefix(cell) {
131
- return `${getDatabase(cell)}.sql`;
131
+ return `${cell.hidden ? "" : cell.output ? "((_) => (display(Inputs.table(_)), _))(" : "Inputs.table("}await ${getDatabase(cell)}.sql`;
132
132
  }
133
133
  function getSqlSuffix(cell) {
134
- return cell.hidden ? "" : ".then(Inputs.table)";
134
+ return cell.hidden ? "" : ")";
135
135
  }
136
136
  function getSqlViewSuffix(cell) {
137
137
  return `.bind(${getDatabase(cell)})`;
@@ -30,12 +30,6 @@ export function transpile(input, mode, options) {
30
30
  transpiled.output = cell.output;
31
31
  if (cell.hidden)
32
32
  transpiled.autodisplay = false;
33
- else if (mode !== "js" && mode !== "ts" && mode !== "ojs") {
34
- transpiled.autodisplay = !!input;
35
- transpiled.autoview = mode === "sql" && transpiled.autodisplay && !!transpiled.output;
36
- if (transpiled.autoview)
37
- transpiled.output = `viewof$${transpiled.output}`;
38
- }
39
33
  return transpiled;
40
34
  }
41
35
  export function transpileTypeScript(input, options) {
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.4.1",
8
+ "version": "2.5.0",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",