@observablehq/notebook-kit 2.0.0 → 2.1.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
|
@@ -7,9 +7,9 @@ export type DisplayState = {
|
|
|
7
7
|
/** for inspected values, any expanded paths; see getExpanded */
|
|
8
8
|
expanded: (number[][] | undefined)[];
|
|
9
9
|
};
|
|
10
|
-
export declare function display(state: DisplayState, value: unknown): void;
|
|
10
|
+
export declare function display(state: DisplayState, value: unknown, name?: string): void;
|
|
11
11
|
export declare function clear(state: DisplayState): void;
|
|
12
|
-
export declare function observe(state: DisplayState, { autodisplay, assets }: Definition): {
|
|
12
|
+
export declare function observe(state: DisplayState, { autodisplay, assets, output }: Definition): {
|
|
13
13
|
_error: boolean;
|
|
14
14
|
_node: HTMLDivElement;
|
|
15
15
|
pending(): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { inspect, inspectError, getExpanded } from "./inspect.js";
|
|
2
2
|
import { mapAssets } from "./stdlib/assets.js";
|
|
3
|
-
export function display(state, value) {
|
|
3
|
+
export function display(state, value, name) {
|
|
4
4
|
const { root, expanded } = state;
|
|
5
|
-
const node = isDisplayable(value, root) ? value : inspect(value, expanded[root.childNodes.length]); // prettier-ignore
|
|
5
|
+
const node = isDisplayable(value, root) ? value : inspect(value, expanded[root.childNodes.length], name); // prettier-ignore
|
|
6
6
|
displayNode(state, node);
|
|
7
7
|
}
|
|
8
8
|
function displayNode(state, node) {
|
|
@@ -16,8 +16,8 @@ function displayNode(state, node) {
|
|
|
16
16
|
state.root.appendChild(node);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function displayError(state, value) {
|
|
20
|
-
displayNode(state, inspectError(value));
|
|
19
|
+
function displayError(state, value, name) {
|
|
20
|
+
displayNode(state, inspectError(value, name));
|
|
21
21
|
}
|
|
22
22
|
// Note: Element.prototype is instanceof Node, but cannot be inserted! This
|
|
23
23
|
// excludes DocumentFragment since appending a fragment “dissolves” (mutates)
|
|
@@ -33,7 +33,7 @@ export function clear(state) {
|
|
|
33
33
|
while (state.root.lastChild)
|
|
34
34
|
state.root.lastChild.remove();
|
|
35
35
|
}
|
|
36
|
-
export function observe(state, { autodisplay, assets }) {
|
|
36
|
+
export function observe(state, { autodisplay, assets, output }) {
|
|
37
37
|
return {
|
|
38
38
|
_error: false,
|
|
39
39
|
_node: state.root, // _node for visibility promise
|
|
@@ -48,7 +48,7 @@ export function observe(state, { autodisplay, assets }) {
|
|
|
48
48
|
if (assets && value instanceof Element)
|
|
49
49
|
mapAssets(value, assets);
|
|
50
50
|
clear(state);
|
|
51
|
-
display(state, value);
|
|
51
|
+
display(state, value, output);
|
|
52
52
|
}
|
|
53
53
|
else if (state.autoclear) {
|
|
54
54
|
clear(state);
|
|
@@ -58,7 +58,7 @@ export function observe(state, { autodisplay, assets }) {
|
|
|
58
58
|
console.error(error);
|
|
59
59
|
this._error = true;
|
|
60
60
|
clear(state);
|
|
61
|
-
displayError(state, error);
|
|
61
|
+
displayError(state, error, output);
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function inspect(value: unknown, expanded?: number[][]): HTMLDivElement;
|
|
2
|
-
export declare function inspectError(value: unknown): HTMLDivElement;
|
|
1
|
+
export declare function inspect(value: unknown, expanded?: number[][], name?: string): HTMLDivElement;
|
|
2
|
+
export declare function inspectError(value: unknown, name?: string): HTMLDivElement;
|
|
3
3
|
export declare function getExpanded(node: Node): number[][] | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Inspector } from "@observablehq/inspector";
|
|
2
|
-
export function inspect(value, expanded) {
|
|
2
|
+
export function inspect(value, expanded, name) {
|
|
3
3
|
const node = document.createElement("div");
|
|
4
|
-
new Inspector(node).fulfilled(value);
|
|
4
|
+
new Inspector(node).fulfilled(value, name);
|
|
5
5
|
if (expanded) {
|
|
6
6
|
for (const path of expanded) {
|
|
7
7
|
let child = node;
|
|
@@ -12,9 +12,9 @@ export function inspect(value, expanded) {
|
|
|
12
12
|
}
|
|
13
13
|
return node;
|
|
14
14
|
}
|
|
15
|
-
export function inspectError(value) {
|
|
15
|
+
export function inspectError(value, name) {
|
|
16
16
|
const node = document.createElement("div");
|
|
17
|
-
new Inspector(node).rejected(value);
|
|
17
|
+
new Inspector(node).rejected(value, name);
|
|
18
18
|
return node;
|
|
19
19
|
}
|
|
20
20
|
export function getExpanded(node) {
|