@observablehq/notebook-kit 2.6.2 → 2.6.4

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.6.2",
8
+ "version": "2.6.4",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",
@@ -127,6 +127,6 @@ function asDeclaration(ref) {
127
127
  return ref.type === "ViewExpression"
128
128
  ? `viewof$${ref.id.name}`
129
129
  : ref.type === "MutableExpression"
130
- ? `mutable ${ref.id.name}` // "initial x", really
130
+ ? `initial ${ref.id.name}`
131
131
  : ref.name;
132
132
  }
@@ -0,0 +1 @@
1
+ export declare function unprefix(name: string, prefix: string): string;
@@ -0,0 +1,5 @@
1
+ export function unprefix(name, prefix) {
2
+ if (!name.startsWith(prefix))
3
+ throw new Error(`expected ${prefix}: ${name}`);
4
+ return name.slice(prefix.length);
5
+ }
@@ -1,3 +1,4 @@
1
+ import { unprefix } from "../lib/unprefix.js";
1
2
  import { clear, display, observe } from "./display.js";
2
3
  import { input } from "./stdlib/generators/index.js";
3
4
  import { Mutator } from "./stdlib/mutable.js";
@@ -43,7 +44,7 @@ export function define(main, state, definition, observer = observe) {
43
44
  variables.push(main.define(o, [output], input));
44
45
  }
45
46
  else if (automutable) {
46
- const o = unprefix(output, "mutable ");
47
+ const o = unprefix(output, "initial ");
47
48
  const x = `cell ${id}`;
48
49
  v.define(o, [x], ([mutable]) => mutable); // observe live value
49
50
  variables.push(main.define(output, inputs, body), // initial value
@@ -56,8 +57,3 @@ export function define(main, state, definition, observer = observe) {
56
57
  }
57
58
  }
58
59
  }
59
- function unprefix(name, prefix) {
60
- if (!name.startsWith(prefix))
61
- throw new Error(`expected ${prefix}: ${name}`);
62
- return name.slice(prefix.length);
63
- }
@@ -10,7 +10,7 @@ export type DisplayState = {
10
10
  };
11
11
  export declare function display(state: DisplayState, value: unknown, name?: string, mode?: DisplayMode): void;
12
12
  export declare function clear(state: DisplayState): void;
13
- export declare function observe(state: DisplayState, { autodisplay, assets, output: name, displayMode: mode }: Definition): {
13
+ export declare function observe(state: DisplayState, { autodisplay, assets, output: name, automutable, displayMode: mode }: Definition): {
14
14
  _error: boolean;
15
15
  _node: HTMLDivElement;
16
16
  pending(): void;
@@ -1,3 +1,4 @@
1
+ import { unprefix } from "../lib/unprefix.js";
1
2
  import { inspect, inspectError, getExpanded } from "./inspect.js";
2
3
  import { mapAssets } from "./stdlib/assets.js";
3
4
  export function display(state, value, name, mode) {
@@ -45,7 +46,9 @@ export function clear(state) {
45
46
  while (state.root.lastChild)
46
47
  state.root.lastChild.remove();
47
48
  }
48
- export function observe(state, { autodisplay, assets, output: name, displayMode: mode }) {
49
+ export function observe(state, { autodisplay, assets, output: name, automutable, displayMode: mode }) {
50
+ if (automutable && name)
51
+ name = unprefix(name, "initial ");
49
52
  return {
50
53
  _error: false,
51
54
  _node: state.root, // _node for visibility promise
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.6.2",
8
+ "version": "2.6.4",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",