@myst-theme/jupyter 0.3.0 → 0.3.1
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/cjs/BinderBadge.js +2 -2
- package/dist/cjs/components.js +1 -1
- package/dist/cjs/error.js +1 -1
- package/dist/cjs/hooks.js +1 -1
- package/dist/cjs/jupyter.d.ts +3 -2
- package/dist/cjs/jupyter.d.ts.map +1 -1
- package/dist/cjs/jupyter.js +27 -26
- package/dist/cjs/output.d.ts.map +1 -1
- package/dist/cjs/output.js +6 -5
- package/dist/cjs/providers.d.ts +15 -12
- package/dist/cjs/providers.d.ts.map +1 -1
- package/dist/cjs/providers.js +48 -90
- package/dist/cjs/safe.js +1 -1
- package/dist/cjs/stream.js +1 -1
- package/dist/cjs/utils.d.ts +8 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +179 -0
- package/dist/esm/BinderBadge.js +2 -2
- package/dist/esm/components.js +1 -1
- package/dist/esm/error.js +1 -1
- package/dist/esm/hooks.js +1 -1
- package/dist/esm/jupyter.d.ts +3 -2
- package/dist/esm/jupyter.d.ts.map +1 -1
- package/dist/esm/jupyter.js +29 -27
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +7 -6
- package/dist/esm/providers.d.ts +15 -12
- package/dist/esm/providers.d.ts.map +1 -1
- package/dist/esm/providers.js +47 -89
- package/dist/esm/safe.js +1 -1
- package/dist/esm/stream.js +1 -1
- package/dist/esm/utils.d.ts +8 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +175 -0
- package/dist/types/jupyter.d.ts +3 -2
- package/dist/types/jupyter.d.ts.map +1 -1
- package/dist/types/output.d.ts.map +1 -1
- package/dist/types/providers.d.ts +15 -12
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/utils.d.ts +8 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +13 -17
package/dist/cjs/BinderBadge.js
CHANGED
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BinderBadge = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
function BinderBadgeLogo() {
|
|
6
|
-
return ((0, jsx_runtime_1.jsxs)("svg",
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "109", height: "20", children: [(0, jsx_runtime_1.jsxs)("linearGradient", { id: "b", x2: "0", y2: "100%", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0", stopColor: "#bbb", stopOpacity: ".1" }), (0, jsx_runtime_1.jsx)("stop", { offset: "1", stopOpacity: ".1" })] }), (0, jsx_runtime_1.jsx)("clipPath", { id: "a", children: (0, jsx_runtime_1.jsx)("rect", { width: "109", height: "20", fill: "#fff", rx: "3" }) }), (0, jsx_runtime_1.jsxs)("g", { clipPath: "url(#a)", children: [(0, jsx_runtime_1.jsx)("path", { fill: "#555", d: "M0 0h64v20H0z" }), (0, jsx_runtime_1.jsx)("path", { fill: "#579aca", d: "M64 0h45v20H64z" }), (0, jsx_runtime_1.jsx)("path", { fill: "url(#b)", d: "M0 0h109v20H0z" })] }), (0, jsx_runtime_1.jsxs)("g", { fill: "#fff", fontFamily: "DejaVu Sans,Verdana,Geneva,sans-serif", fontSize: "110", textAnchor: "middle", children: [(0, jsx_runtime_1.jsx)("image", { width: "14", height: "14", x: "5", y: "3", href: "data:image/png;base64,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" }), (0, jsx_runtime_1.jsx)("text", { x: "415", y: "150", fill: "#010101", fillOpacity: ".3", textLength: "370", transform: "scale(.1)", children: "launch" }), (0, jsx_runtime_1.jsx)("text", { x: "415", y: "140", textLength: "370", transform: "scale(.1)", children: "launch" }), (0, jsx_runtime_1.jsx)("text", { x: "855", y: "150", fill: "#010101", fillOpacity: ".3", textLength: "350", transform: "scale(.1)", children: "binder" }), (0, jsx_runtime_1.jsx)("text", { x: "855", y: "140", textLength: "350", transform: "scale(.1)", children: "binder" })] })] }));
|
|
7
7
|
}
|
|
8
8
|
function BinderBadge({ binder }) {
|
|
9
9
|
if (!binder)
|
|
10
10
|
return null;
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)("div",
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "inline-block mr-1 opacity-80 hover:opacity-100", children: (0, jsx_runtime_1.jsx)("a", { href: binder, title: `Launch Binder Session: ${binder}`, target: "_blank", rel: "noopener noreferrer", className: "text-inherit hover:text-inherit", children: (0, jsx_runtime_1.jsx)(BinderBadgeLogo, {}) }) }));
|
|
12
12
|
}
|
|
13
13
|
exports.BinderBadge = BinderBadge;
|
package/dist/cjs/components.js
CHANGED
|
@@ -18,7 +18,7 @@ const hooks_1 = require("./hooks");
|
|
|
18
18
|
const MaybeLongContent = ({ content, path, render, }) => {
|
|
19
19
|
const { error, data } = (0, hooks_1.useLongContent)(content, path);
|
|
20
20
|
if (error) {
|
|
21
|
-
return (0, jsx_runtime_1.jsxs)("div",
|
|
21
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: "text-red-500", children: ["Error loading content: ", error.message] });
|
|
22
22
|
}
|
|
23
23
|
if (!data) {
|
|
24
24
|
return (0, jsx_runtime_1.jsx)("div", { children: "Fetching long content...." });
|
package/dist/cjs/error.js
CHANGED
|
@@ -9,7 +9,7 @@ const nbtx_1 = require("nbtx");
|
|
|
9
9
|
const components_1 = require("./components");
|
|
10
10
|
function Error({ output }) {
|
|
11
11
|
return ((0, jsx_runtime_1.jsx)(components_1.MaybeLongContent, { content: (0, nbtx_1.ensureString)(output.traceback), path: output.path, render: (content) => {
|
|
12
|
-
return ((0, jsx_runtime_1.jsx)("pre",
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("pre", { className: "text-sm font-thin font-system jupyter-error", children: (0, jsx_runtime_1.jsx)(ansi_to_react_1.default, { children: content !== null && content !== void 0 ? content : '' }) }));
|
|
13
13
|
} }));
|
|
14
14
|
}
|
|
15
15
|
exports.default = Error;
|
package/dist/cjs/hooks.js
CHANGED
|
@@ -54,7 +54,7 @@ function useLongContent(content, url) {
|
|
|
54
54
|
}
|
|
55
55
|
exports.useLongContent = useLongContent;
|
|
56
56
|
const arrayFetcher = (...urls) => {
|
|
57
|
-
return Promise.all(urls.map((url) => fetcher(url)));
|
|
57
|
+
return Promise.all(urls.map((url) => fetcher(url[0])));
|
|
58
58
|
};
|
|
59
59
|
function shallowCloneOutputs(outputs) {
|
|
60
60
|
return outputs.map((output) => {
|
package/dist/cjs/jupyter.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { MinifiedOutput } from 'nbtx';
|
|
2
|
-
export declare const JupyterOutputs: ({ id, outputs }: {
|
|
3
|
+
export declare const JupyterOutputs: React.MemoExoticComponent<({ id, outputs }: {
|
|
3
4
|
id: string;
|
|
4
5
|
outputs: MinifiedOutput[];
|
|
5
|
-
}) => import("react/jsx-runtime").JSX.Element
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
6
7
|
//# sourceMappingURL=jupyter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAyD3C,eAAO,MAAM,cAAc;QACD,MAAM;aAAW,cAAc,EAAE;8CAiD1D,CAAC"}
|
package/dist/cjs/jupyter.js
CHANGED
|
@@ -29,48 +29,50 @@ const react_1 = __importStar(require("react"));
|
|
|
29
29
|
const hooks_1 = require("./hooks");
|
|
30
30
|
const nbtx_1 = require("nbtx");
|
|
31
31
|
const convertImages_1 = require("./convertImages");
|
|
32
|
-
const thebe_react_1 = require("thebe-react");
|
|
33
32
|
const providers_1 = require("./providers");
|
|
34
33
|
const myst_common_1 = require("myst-common");
|
|
35
34
|
const providers_2 = require("@myst-theme/providers");
|
|
35
|
+
const thebe_react_1 = require("thebe-react");
|
|
36
36
|
function ActiveOutputRenderer({ id, data }) {
|
|
37
|
-
const ref = (0, providers_1.useCellRef)(id);
|
|
38
37
|
const exec = (0, providers_1.useNotebookCellExecution)(id);
|
|
38
|
+
const ref = (0, react_1.useRef)(null);
|
|
39
39
|
(0, react_1.useEffect)(() => {
|
|
40
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
if (!ref.current || !(exec === null || exec === void 0 ? void 0 : exec.cell)) {
|
|
42
|
+
console.debug(`No cell ref available for cell ${(_a = exec === null || exec === void 0 ? void 0 : exec.cell) === null || _a === void 0 ? void 0 : _a.id}`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (exec.cell.isAttachedToDOM) {
|
|
46
|
+
console.debug(`Cell ${exec.cell.id} already attached to DOM`);
|
|
41
47
|
return;
|
|
48
|
+
}
|
|
42
49
|
console.debug(`Attaching cell ${exec.cell.id} to DOM at:`, {
|
|
43
|
-
el: ref.
|
|
44
|
-
connected: ref.
|
|
50
|
+
el: ref.current,
|
|
51
|
+
connected: ref.current.isConnected,
|
|
45
52
|
data,
|
|
46
53
|
});
|
|
47
|
-
exec.cell.attachToDOM(ref.
|
|
54
|
+
exec.cell.attachToDOM(ref.current);
|
|
48
55
|
exec.cell.render(data);
|
|
49
|
-
}, [ref === null || ref === void 0 ? void 0 : ref.
|
|
50
|
-
return
|
|
56
|
+
}, [ref === null || ref === void 0 ? void 0 : ref.current, exec === null || exec === void 0 ? void 0 : exec.cell]);
|
|
57
|
+
return (0, jsx_runtime_1.jsx)("div", { ref: ref, "data-thebe-active-ref": "true", className: "relative" });
|
|
51
58
|
}
|
|
52
59
|
function PassiveOutputRenderer({ id, data, core, kind, }) {
|
|
53
|
-
const
|
|
60
|
+
const cell = (0, react_1.useRef)(new core.PassiveCellRenderer(id, undefined, undefined));
|
|
54
61
|
const ref = (0, react_1.useRef)(null);
|
|
55
|
-
(0, react_1.useEffect)(() => {
|
|
56
|
-
cell.render(data, kind === myst_common_1.SourceFileKind.Article);
|
|
57
|
-
}, [data, cell]);
|
|
58
62
|
(0, react_1.useEffect)(() => {
|
|
59
63
|
if (!ref.current)
|
|
60
64
|
return;
|
|
61
|
-
cell.attachToDOM(ref.current, true);
|
|
65
|
+
cell.current.attachToDOM(ref.current, true);
|
|
66
|
+
cell.current.render(data, kind === myst_common_1.SourceFileKind.Article);
|
|
62
67
|
}, [ref]);
|
|
63
68
|
return (0, jsx_runtime_1.jsx)("div", { ref: ref, "data-thebe-passive-ref": "true" });
|
|
64
69
|
}
|
|
65
|
-
|
|
66
|
-
const JupyterOutputs = ({ id, outputs }) => {
|
|
70
|
+
exports.JupyterOutputs = react_1.default.memo(({ id, outputs }) => {
|
|
67
71
|
var _a;
|
|
68
|
-
const { core, load } = (0, thebe_react_1.
|
|
72
|
+
const { core, load } = (0, thebe_react_1.useThebeLoader)();
|
|
69
73
|
const { inCrossRef } = (0, providers_2.useXRefState)();
|
|
70
74
|
const { data, error } = (0, hooks_1.useFetchAnyTruncatedContent)(outputs);
|
|
71
|
-
const [loaded, setLoaded] = (0, react_1.useState)(false);
|
|
72
75
|
const [fullOutputs, setFullOutputs] = (0, react_1.useState)(null);
|
|
73
|
-
const registry = (0, providers_1.useCellRefRegistry)();
|
|
74
76
|
const exec = (0, providers_1.useNotebookCellExecution)(id);
|
|
75
77
|
(0, react_1.useEffect)(() => {
|
|
76
78
|
if (core)
|
|
@@ -78,20 +80,19 @@ const JupyterOutputs = ({ id, outputs }) => {
|
|
|
78
80
|
load();
|
|
79
81
|
}, [core, load]);
|
|
80
82
|
(0, react_1.useEffect)(() => {
|
|
81
|
-
if (!data ||
|
|
83
|
+
if (!data || fullOutputs != null)
|
|
82
84
|
return;
|
|
83
|
-
setLoaded(true);
|
|
84
85
|
(0, convertImages_1.fetchAndEncodeOutputImages)(data).then((out) => {
|
|
85
86
|
const compactOutputs = (0, nbtx_1.convertToIOutputs)(out, {});
|
|
86
87
|
setFullOutputs(compactOutputs);
|
|
87
88
|
});
|
|
88
89
|
}, [id, data, fullOutputs]);
|
|
89
90
|
if (error) {
|
|
90
|
-
|
|
91
|
+
console.error(error);
|
|
92
|
+
return (0, jsx_runtime_1.jsxs)("div", { className: "text-red-500", children: ["Error rendering output: ", error.message] });
|
|
91
93
|
}
|
|
92
|
-
if (!inCrossRef &&
|
|
93
|
-
return ((0, jsx_runtime_1.jsxs)("div",
|
|
94
|
+
if (!inCrossRef && (exec === null || exec === void 0 ? void 0 : exec.ready)) {
|
|
95
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [!fullOutputs && (0, jsx_runtime_1.jsx)("div", { className: "p-2.5", children: "Loading..." }), fullOutputs && (0, jsx_runtime_1.jsx)(ActiveOutputRenderer, { id: id, data: fullOutputs })] }));
|
|
94
96
|
}
|
|
95
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
96
|
-
};
|
|
97
|
-
exports.JupyterOutputs = JupyterOutputs;
|
|
97
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [!fullOutputs && (0, jsx_runtime_1.jsx)("div", { className: "p-2.5", children: "Loading..." }), fullOutputs && core && ((0, jsx_runtime_1.jsx)(PassiveOutputRenderer, { id: id, data: fullOutputs, core: core, kind: (_a = exec === null || exec === void 0 ? void 0 : exec.kind) !== null && _a !== void 0 ? _a : myst_common_1.SourceFileKind.Notebook }))] }));
|
|
98
|
+
});
|
package/dist/cjs/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAO/D,eAAO,MAAM,mBAAmB,aAA+B,CAAC;AAEhE,eAAO,MAAM,iBAAiB,aAMb,CAAC;AAElB,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AA6CD,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,2CAYvC"}
|
package/dist/cjs/output.js
CHANGED
|
@@ -10,6 +10,7 @@ const classnames_1 = __importDefault(require("classnames"));
|
|
|
10
10
|
const safe_1 = require("./safe");
|
|
11
11
|
const jupyter_1 = require("./jupyter");
|
|
12
12
|
const providers_1 = require("./providers");
|
|
13
|
+
const react_1 = require("react");
|
|
13
14
|
exports.DIRECT_OUTPUT_TYPES = new Set(['stream', 'error']);
|
|
14
15
|
exports.DIRECT_MIME_TYPES = new Set([
|
|
15
16
|
nbtx_1.KnownCellOutputMimeTypes.TextPlain,
|
|
@@ -32,21 +33,21 @@ function allOutputsAreSafe(outputs, directOutputTypes, directMimeTypes) {
|
|
|
32
33
|
}
|
|
33
34
|
exports.allOutputsAreSafe = allOutputsAreSafe;
|
|
34
35
|
function JupyterOutput({ nodeKey, nodeType, identifier, data, align, }) {
|
|
35
|
-
const
|
|
36
|
+
const ready = (0, providers_1.useReadyToExecute)();
|
|
36
37
|
const outputs = data;
|
|
37
|
-
const allSafe = allOutputsAreSafe(outputs, exports.DIRECT_OUTPUT_TYPES, exports.DIRECT_MIME_TYPES);
|
|
38
|
+
const allSafe = (0, react_1.useMemo)(() => allOutputsAreSafe(outputs, exports.DIRECT_OUTPUT_TYPES, exports.DIRECT_MIME_TYPES), [outputs]);
|
|
38
39
|
let component;
|
|
39
|
-
if (allSafe && !
|
|
40
|
+
if (allSafe && !ready) {
|
|
40
41
|
component = (0, jsx_runtime_1.jsx)(safe_1.SafeOutputs, { keyStub: nodeKey, outputs: outputs });
|
|
41
42
|
}
|
|
42
43
|
else {
|
|
43
44
|
component = (0, jsx_runtime_1.jsx)(jupyter_1.JupyterOutputs, { id: nodeKey, outputs: outputs });
|
|
44
45
|
}
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)("figure",
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)("figure", { id: identifier || undefined, "data-mdast-node-type": nodeType, "data-mdast-node-id": nodeKey, className: (0, classnames_1.default)('max-w-full overflow-visible m-0 group not-prose relative', {
|
|
46
47
|
'text-left': !align || align === 'left',
|
|
47
48
|
'text-center': align === 'center',
|
|
48
49
|
'text-right': align === 'right',
|
|
49
|
-
})
|
|
50
|
+
}), children: component }));
|
|
50
51
|
}
|
|
51
52
|
function Output(node) {
|
|
52
53
|
// Note, NodeRenderer's can't have hooks in it directly!
|
package/dist/cjs/providers.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { GenericParent } from 'myst-common';
|
|
2
2
|
import { SourceFileKind } from 'myst-common';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import type { Config, IThebeCell, IThebeCellExecuteReturn, ThebeCore, ThebeNotebook } from 'thebe-core';
|
|
4
|
+
import type { Config, IRenderMimeRegistry, IThebeCell, IThebeCellExecuteReturn, ThebeCore, ThebeNotebook } from 'thebe-core';
|
|
5
5
|
import type { IThebeNotebookError, NotebookExecuteOptions } from 'thebe-react';
|
|
6
6
|
import type { Root } from 'mdast';
|
|
7
|
+
export declare function useComputeOptions(): {
|
|
8
|
+
canCompute: boolean;
|
|
9
|
+
thebe?: undefined;
|
|
10
|
+
githubBadgeUrl?: undefined;
|
|
11
|
+
binderBadgeUrl?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
canCompute: boolean;
|
|
14
|
+
thebe: import("./utils").ExtendedCoreOptions | undefined;
|
|
15
|
+
githubBadgeUrl: string | undefined;
|
|
16
|
+
binderBadgeUrl: string | undefined;
|
|
17
|
+
};
|
|
7
18
|
export declare function ConfiguredThebeServerProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
8
19
|
export type PartialPage = {
|
|
9
20
|
kind: SourceFileKind;
|
|
@@ -12,8 +23,7 @@ export type PartialPage = {
|
|
|
12
23
|
slug: string;
|
|
13
24
|
mdast: Root;
|
|
14
25
|
};
|
|
15
|
-
export declare function notebookFromMdast(core: ThebeCore, config: Config, mdast: GenericParent, idkMap: Record<string, string
|
|
16
|
-
type CellRefRegistry = Record<string, HTMLDivElement>;
|
|
26
|
+
export declare function notebookFromMdast(core: ThebeCore, config: Config, mdast: GenericParent, idkMap: Record<string, string>, rendermime: IRenderMimeRegistry): ThebeNotebook;
|
|
17
27
|
type IdKeyMap = Record<string, string>;
|
|
18
28
|
interface NotebookContextType {
|
|
19
29
|
kind: SourceFileKind;
|
|
@@ -25,9 +35,7 @@ interface NotebookContextType {
|
|
|
25
35
|
executeAll: (options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
|
|
26
36
|
executeSome: (predicate: (cell: IThebeCell) => boolean, options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
|
|
27
37
|
notebook: ThebeNotebook | undefined;
|
|
28
|
-
registry: CellRefRegistry;
|
|
29
38
|
idkMap: IdKeyMap;
|
|
30
|
-
register: (id: string) => (el: HTMLDivElement) => void;
|
|
31
39
|
restart: () => Promise<void>;
|
|
32
40
|
clear: () => void;
|
|
33
41
|
}
|
|
@@ -36,12 +44,6 @@ export declare function NotebookProvider({ siteConfig, page, children, }: React.
|
|
|
36
44
|
page: PartialPage;
|
|
37
45
|
}>): import("react/jsx-runtime").JSX.Element;
|
|
38
46
|
export declare function useHasNotebookProvider(): boolean;
|
|
39
|
-
export declare function useCellRefRegistry(): {
|
|
40
|
-
register: (id: string) => (el: HTMLDivElement) => void;
|
|
41
|
-
} | undefined;
|
|
42
|
-
export declare function useCellRef(id: string): {
|
|
43
|
-
el: HTMLDivElement | null;
|
|
44
|
-
} | undefined;
|
|
45
47
|
export declare function useMDASTNotebook(): NotebookContextType | undefined;
|
|
46
48
|
export declare function useNotebookExecution(): {
|
|
47
49
|
ready: boolean;
|
|
@@ -53,6 +55,7 @@ export declare function useNotebookExecution(): {
|
|
|
53
55
|
notebook: ThebeNotebook | undefined;
|
|
54
56
|
clear: () => void;
|
|
55
57
|
} | undefined;
|
|
58
|
+
export declare function useReadyToExecute(): boolean;
|
|
56
59
|
export declare function useNotebookCellExecution(id: string): {
|
|
57
60
|
kind: SourceFileKind;
|
|
58
61
|
ready: boolean;
|
|
@@ -61,7 +64,7 @@ export declare function useNotebookCellExecution(id: string): {
|
|
|
61
64
|
notebookIsExecuting: boolean;
|
|
62
65
|
execute: (options?: NotebookExecuteOptions) => Promise<(IThebeCellExecuteReturn | null)[]>;
|
|
63
66
|
clear: () => void | undefined;
|
|
64
|
-
notebook: ThebeNotebook
|
|
67
|
+
notebook: ThebeNotebook;
|
|
65
68
|
} | undefined;
|
|
66
69
|
export {};
|
|
67
70
|
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EACV,MAAM,
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,uBAAuB,EACvB,SAAS,EACT,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAQ/E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,iBAAiB;;;;;;;;;;EAwBhC;AAED,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,2CAalF;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,UAAU,EAAE,mBAAmB,iBAuChC;AAED,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvC,UAAU,mBAAmB;IAC3B,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,mBAAmB,EAAE,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,KACzC,OAAO,CAAC,CAAC,uBAAuB,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IACjD,WAAW,EAAE,CACX,SAAS,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,EACxC,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,KACzC,OAAO,CAAC,CAAC,uBAAuB,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IACjD,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,IAAI,EACJ,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,2CA8DrE;AAED,wBAAgB,sBAAsB,YAGrC;AAED,wBAAgB,gBAAgB,oCAG/B;AAED,wBAAgB,oBAAoB;;;;;;;;;cAQnC;AAED,wBAAgB,iBAAiB,YAGhC;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM;;;;;;wBAiBhB,sBAAsB;;;cAmBxD"}
|
package/dist/cjs/providers.js
CHANGED
|
@@ -32,58 +32,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.useNotebookCellExecution = exports.
|
|
35
|
+
exports.useNotebookCellExecution = exports.useReadyToExecute = exports.useNotebookExecution = exports.useMDASTNotebook = exports.useHasNotebookProvider = exports.NotebookProvider = exports.notebookFromMdast = exports.ConfiguredThebeServerProvider = exports.useComputeOptions = void 0;
|
|
36
36
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
37
37
|
const myst_common_1 = require("myst-common");
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
const thebe_react_1 = require("thebe-react");
|
|
40
40
|
const providers_1 = require("@myst-theme/providers");
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
const utils_1 = require("./utils");
|
|
42
|
+
function useComputeOptions() {
|
|
43
|
+
const config = (0, providers_1.useSiteManifest)();
|
|
44
|
+
const makeOptions = () => {
|
|
45
|
+
var _a;
|
|
46
|
+
if (!config)
|
|
47
|
+
return { canCompute: false };
|
|
48
|
+
// TODO there may be multiple projects?
|
|
49
|
+
// useProjectManifest?
|
|
50
|
+
const mainProject = (_a = config === null || config === void 0 ? void 0 : config.projects) === null || _a === void 0 ? void 0 : _a[0];
|
|
51
|
+
const thebeFrontmatter = mainProject === null || mainProject === void 0 ? void 0 : mainProject.thebe;
|
|
52
|
+
const githubBadgeUrl = mainProject === null || mainProject === void 0 ? void 0 : mainProject.github;
|
|
53
|
+
const binderBadgeUrl = mainProject === null || mainProject === void 0 ? void 0 : mainProject.binder;
|
|
54
|
+
const thebeOptions = (0, utils_1.thebeFrontmatterToOptions)(thebeFrontmatter, githubBadgeUrl, binderBadgeUrl);
|
|
55
|
+
return {
|
|
56
|
+
canCompute: thebeFrontmatter !== undefined && thebeFrontmatter !== false,
|
|
57
|
+
thebe: thebeOptions,
|
|
58
|
+
githubBadgeUrl,
|
|
59
|
+
binderBadgeUrl,
|
|
53
60
|
};
|
|
54
|
-
}
|
|
55
|
-
const useServer = (local !== null && local !== void 0 ? local : server);
|
|
56
|
-
if (server) {
|
|
57
|
-
const splitUrl = (_c = useServer.url) === null || _c === void 0 ? void 0 : _c.split('://');
|
|
58
|
-
const wsUrl = (splitUrl === null || splitUrl === void 0 ? void 0 : splitUrl.length) === 2 ? `ws://${splitUrl[1]}` : undefined;
|
|
59
|
-
output.serverSettings = {
|
|
60
|
-
baseUrl: useServer.url,
|
|
61
|
-
token: useServer.token,
|
|
62
|
-
wsUrl,
|
|
63
|
-
appendToken: true,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
output.kernelOptions = {
|
|
67
|
-
kernelName: kernelName,
|
|
68
|
-
name: kernelName,
|
|
69
|
-
path: sessionName,
|
|
70
61
|
};
|
|
71
|
-
|
|
72
|
-
output.savedSessionOptions = {
|
|
73
|
-
enabled: true,
|
|
74
|
-
maxAge: 38300,
|
|
75
|
-
storagePrefix: 'thebe',
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return output;
|
|
62
|
+
return react_1.default.useMemo(makeOptions, [config]);
|
|
79
63
|
}
|
|
64
|
+
exports.useComputeOptions = useComputeOptions;
|
|
80
65
|
function ConfiguredThebeServerProvider({ children }) {
|
|
81
|
-
const thebe =
|
|
82
|
-
return ((0, jsx_runtime_1.jsx)(thebe_react_1.ThebeServerProvider,
|
|
66
|
+
const { thebe } = useComputeOptions();
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)(thebe_react_1.ThebeServerProvider, { connect: false, options: thebe, useBinder: thebe === null || thebe === void 0 ? void 0 : thebe.useBinder, useJupyterLite: thebe === null || thebe === void 0 ? void 0 : thebe.useJupyterLite, children: children }));
|
|
83
68
|
}
|
|
84
69
|
exports.ConfiguredThebeServerProvider = ConfiguredThebeServerProvider;
|
|
85
|
-
function notebookFromMdast(core, config, mdast, idkMap) {
|
|
86
|
-
const rendermime = undefined; // share rendermime beyond notebook scope?
|
|
70
|
+
function notebookFromMdast(core, config, mdast, idkMap, rendermime) {
|
|
87
71
|
const notebook = new core.ThebeNotebook(mdast.key, config, rendermime);
|
|
88
72
|
// no metadata included in mdast yet
|
|
89
73
|
//Object.assign(notebook.metadata, ipynb.metadata);
|
|
@@ -115,18 +99,17 @@ function NotebookProvider({ siteConfig, page, children, }) {
|
|
|
115
99
|
// so at some point this gets the whole site config and can
|
|
116
100
|
// be use to lookup notebooks and recover ThebeNotebooks that
|
|
117
101
|
// can be used to execute notebook pages or blocks in articles
|
|
118
|
-
const { core } = (0, thebe_react_1.
|
|
102
|
+
const { core } = (0, thebe_react_1.useThebeLoader)();
|
|
119
103
|
const { config } = (0, thebe_react_1.useThebeConfig)();
|
|
104
|
+
const rendermime = (0, thebe_react_1.useRenderMimeRegistry)();
|
|
120
105
|
const { ready, attached, executing, executed, errors, executeAll, executeSome, clear, session, notebook, setNotebook, } = (0, thebe_react_1.useNotebookBase)();
|
|
121
|
-
const registry = (0, react_1.useRef)({});
|
|
122
106
|
const idkMap = (0, react_1.useRef)({});
|
|
123
107
|
(0, react_1.useEffect)(() => {
|
|
124
108
|
if (!core || !config)
|
|
125
109
|
return;
|
|
126
|
-
registry.current = {};
|
|
127
110
|
idkMap.current = {};
|
|
128
111
|
if (page.kind === myst_common_1.SourceFileKind.Notebook) {
|
|
129
|
-
const nb = notebookFromMdast(core, config, page.mdast, idkMap.current);
|
|
112
|
+
const nb = notebookFromMdast(core, config, page.mdast, idkMap.current, rendermime);
|
|
130
113
|
setNotebook(nb);
|
|
131
114
|
}
|
|
132
115
|
else {
|
|
@@ -134,20 +117,7 @@ function NotebookProvider({ siteConfig, page, children, }) {
|
|
|
134
117
|
setNotebook(undefined);
|
|
135
118
|
}
|
|
136
119
|
}, [core, config, page]);
|
|
137
|
-
|
|
138
|
-
return (el) => {
|
|
139
|
-
if (el != null && registry.current[idkMap.current[id]] !== el) {
|
|
140
|
-
if (!el.isConnected) {
|
|
141
|
-
console.debug(`skipping ref for cell ${id} as host is not connected`);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
console.debug(`new ref for cell ${id} registered`);
|
|
145
|
-
registry.current[idkMap.current[id]] = el;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
return ((0, jsx_runtime_1.jsx)(NotebookContext.Provider, Object.assign({ value: {
|
|
120
|
+
return ((0, jsx_runtime_1.jsx)(NotebookContext.Provider, { value: {
|
|
151
121
|
kind: page.kind,
|
|
152
122
|
ready,
|
|
153
123
|
attached,
|
|
@@ -157,12 +127,10 @@ function NotebookProvider({ siteConfig, page, children, }) {
|
|
|
157
127
|
executeAll,
|
|
158
128
|
executeSome,
|
|
159
129
|
notebook,
|
|
160
|
-
registry: registry.current,
|
|
161
130
|
idkMap: idkMap.current,
|
|
162
|
-
register,
|
|
163
131
|
restart: () => { var _a; return (_a = session === null || session === void 0 ? void 0 : session.restart()) !== null && _a !== void 0 ? _a : Promise.resolve(); },
|
|
164
132
|
clear,
|
|
165
|
-
}
|
|
133
|
+
}, children: children }));
|
|
166
134
|
}
|
|
167
135
|
exports.NotebookProvider = NotebookProvider;
|
|
168
136
|
function useHasNotebookProvider() {
|
|
@@ -170,24 +138,6 @@ function useHasNotebookProvider() {
|
|
|
170
138
|
return notebookState !== undefined;
|
|
171
139
|
}
|
|
172
140
|
exports.useHasNotebookProvider = useHasNotebookProvider;
|
|
173
|
-
function useCellRefRegistry() {
|
|
174
|
-
const notebookState = (0, react_1.useContext)(NotebookContext);
|
|
175
|
-
if (notebookState === undefined)
|
|
176
|
-
return undefined;
|
|
177
|
-
return { register: notebookState.register };
|
|
178
|
-
}
|
|
179
|
-
exports.useCellRefRegistry = useCellRefRegistry;
|
|
180
|
-
function useCellRef(id) {
|
|
181
|
-
var _a;
|
|
182
|
-
const notebookState = (0, react_1.useContext)(NotebookContext);
|
|
183
|
-
if (notebookState === undefined)
|
|
184
|
-
return undefined;
|
|
185
|
-
const { registry, idkMap } = notebookState;
|
|
186
|
-
const entry = Object.entries(notebookState.registry).find(([cellId]) => cellId === idkMap[id]);
|
|
187
|
-
console.debug('useCellRef', { id, registry, idkMap, entry });
|
|
188
|
-
return { el: (_a = entry === null || entry === void 0 ? void 0 : entry[1]) !== null && _a !== void 0 ? _a : null };
|
|
189
|
-
}
|
|
190
|
-
exports.useCellRef = useCellRef;
|
|
191
141
|
function useMDASTNotebook() {
|
|
192
142
|
const notebookState = (0, react_1.useContext)(NotebookContext);
|
|
193
143
|
return notebookState;
|
|
@@ -201,6 +151,12 @@ function useNotebookExecution() {
|
|
|
201
151
|
return { ready, attached, executing, executed, errors, execute: executeAll, notebook, clear };
|
|
202
152
|
}
|
|
203
153
|
exports.useNotebookExecution = useNotebookExecution;
|
|
154
|
+
function useReadyToExecute() {
|
|
155
|
+
var _a;
|
|
156
|
+
const notebookState = (0, react_1.useContext)(NotebookContext);
|
|
157
|
+
return (_a = notebookState === null || notebookState === void 0 ? void 0 : notebookState.ready) !== null && _a !== void 0 ? _a : false;
|
|
158
|
+
}
|
|
159
|
+
exports.useReadyToExecute = useReadyToExecute;
|
|
204
160
|
function useNotebookCellExecution(id) {
|
|
205
161
|
// setup a cell only executing state
|
|
206
162
|
const [executing, setExecuting] = (0, react_1.useState)(false);
|
|
@@ -218,15 +174,17 @@ function useNotebookCellExecution(id) {
|
|
|
218
174
|
});
|
|
219
175
|
}
|
|
220
176
|
const cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
221
|
-
return
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
177
|
+
return notebook
|
|
178
|
+
? {
|
|
179
|
+
kind,
|
|
180
|
+
ready,
|
|
181
|
+
cell,
|
|
182
|
+
executing,
|
|
183
|
+
notebookIsExecuting,
|
|
184
|
+
execute,
|
|
185
|
+
clear: () => cell === null || cell === void 0 ? void 0 : cell.clear(),
|
|
186
|
+
notebook,
|
|
187
|
+
}
|
|
188
|
+
: undefined;
|
|
231
189
|
}
|
|
232
190
|
exports.useNotebookCellExecution = useNotebookCellExecution;
|
package/dist/cjs/safe.js
CHANGED
|
@@ -61,7 +61,7 @@ function SafeOutput({ output }) {
|
|
|
61
61
|
if (image)
|
|
62
62
|
return (0, jsx_runtime_1.jsx)(OutputImage, { image: image, text: text });
|
|
63
63
|
if (text)
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)("div",
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "whitespace-pre-wrap font-mono text-sm", children: (0, jsx_runtime_1.jsx)(ansi_to_react_1.default, { children: text.content }) }));
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
67
|
default:
|
package/dist/cjs/stream.js
CHANGED
|
@@ -8,6 +8,6 @@ const ansi_to_react_1 = __importDefault(require("ansi-to-react"));
|
|
|
8
8
|
const nbtx_1 = require("nbtx");
|
|
9
9
|
const components_1 = require("./components");
|
|
10
10
|
function Stream({ output }) {
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)(components_1.MaybeLongContent, { content: (0, nbtx_1.ensureString)(output.text), path: output.path, render: (content) => ((0, jsx_runtime_1.jsx)("pre",
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(components_1.MaybeLongContent, { content: (0, nbtx_1.ensureString)(output.text), path: output.path, render: (content) => ((0, jsx_runtime_1.jsx)("pre", { className: "text-sm font-thin font-system", children: (0, jsx_runtime_1.jsx)(ansi_to_react_1.default, { children: content !== null && content !== void 0 ? content : '' }) })) }));
|
|
12
12
|
}
|
|
13
13
|
exports.default = Stream;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Thebe } from 'myst-frontmatter';
|
|
2
|
+
import type { CoreOptions } from 'thebe-core';
|
|
3
|
+
export type ExtendedCoreOptions = CoreOptions & {
|
|
4
|
+
useBinder?: boolean;
|
|
5
|
+
useJupyterLite?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function thebeFrontmatterToOptions(fm: boolean | Thebe | undefined, githubBadgeUrl: string | undefined, binderBadgeUrl: string | undefined): ExtendedCoreOptions | undefined;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EAIN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,YAAY,CAAC;AAE5D,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAqDF,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,EAC/B,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,mBAAmB,GAAG,SAAS,CA+IjC"}
|