@myst-theme/jupyter 0.1.38 → 0.2.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAoD3C,eAAO,MAAM,cAAc;QAA2B,MAAM;aAAW,cAAc,EAAE;iBAiDtF,CAAC"}
|
package/dist/cjs/jupyter.js
CHANGED
|
@@ -32,6 +32,7 @@ const convertImages_1 = require("./convertImages");
|
|
|
32
32
|
const thebe_react_1 = require("thebe-react");
|
|
33
33
|
const providers_1 = require("./providers");
|
|
34
34
|
const myst_common_1 = require("myst-common");
|
|
35
|
+
const providers_2 = require("@myst-theme/providers");
|
|
35
36
|
function ActiveOutputRenderer({ id, data }) {
|
|
36
37
|
const ref = (0, providers_1.useCellRef)(id);
|
|
37
38
|
const exec = (0, providers_1.useNotebookCellExecution)(id);
|
|
@@ -65,6 +66,7 @@ const MemoPassiveOutputRenderer = react_1.default.memo(PassiveOutputRenderer);
|
|
|
65
66
|
const JupyterOutputs = ({ id, outputs }) => {
|
|
66
67
|
var _a;
|
|
67
68
|
const { core, load } = (0, thebe_react_1.useThebeCore)();
|
|
69
|
+
const { inCrossRef } = (0, providers_2.useXRefState)();
|
|
68
70
|
const { data, error } = (0, hooks_1.useFetchAnyTruncatedContent)(outputs);
|
|
69
71
|
const [loaded, setLoaded] = (0, react_1.useState)(false);
|
|
70
72
|
const [fullOutputs, setFullOutputs] = (0, react_1.useState)(null);
|
|
@@ -76,18 +78,18 @@ const JupyterOutputs = ({ id, outputs }) => {
|
|
|
76
78
|
load();
|
|
77
79
|
}, [core, load]);
|
|
78
80
|
(0, react_1.useEffect)(() => {
|
|
79
|
-
if (!data || loaded)
|
|
81
|
+
if (!data || loaded || fullOutputs != null)
|
|
80
82
|
return;
|
|
81
83
|
setLoaded(true);
|
|
82
84
|
(0, convertImages_1.fetchAndEncodeOutputImages)(data).then((out) => {
|
|
83
85
|
const compactOutputs = (0, nbtx_1.convertToIOutputs)(out, {});
|
|
84
86
|
setFullOutputs(compactOutputs);
|
|
85
87
|
});
|
|
86
|
-
}, [id, data]);
|
|
88
|
+
}, [id, data, fullOutputs]);
|
|
87
89
|
if (error) {
|
|
88
90
|
return (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "text-red-500" }, { children: ["Error rendering output: ", error.message] }));
|
|
89
91
|
}
|
|
90
|
-
if (registry && (exec === null || exec === void 0 ? void 0 : exec.cell)) {
|
|
92
|
+
if (!inCrossRef && registry && (exec === null || exec === void 0 ? void 0 : exec.cell)) {
|
|
91
93
|
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: registry === null || registry === void 0 ? void 0 : registry.register(id), "data-thebe-active-ref": "true" }, { children: [!fullOutputs && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && (0, jsx_runtime_1.jsx)(ActiveOutputRenderer, { id: id, data: fullOutputs })] })));
|
|
92
94
|
}
|
|
93
95
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!fullOutputs && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && core && ((0, jsx_runtime_1.jsx)(MemoPassiveOutputRenderer, { 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 }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAoD3C,eAAO,MAAM,cAAc;QAA2B,MAAM;aAAW,cAAc,EAAE;iBAiDtF,CAAC"}
|
package/dist/esm/jupyter.js
CHANGED
|
@@ -6,6 +6,7 @@ import { fetchAndEncodeOutputImages } from './convertImages';
|
|
|
6
6
|
import { useThebeCore } from 'thebe-react';
|
|
7
7
|
import { useCellRef, useCellRefRegistry, useNotebookCellExecution } from './providers';
|
|
8
8
|
import { SourceFileKind } from 'myst-common';
|
|
9
|
+
import { useXRefState } from '@myst-theme/providers';
|
|
9
10
|
function ActiveOutputRenderer({ id, data }) {
|
|
10
11
|
const ref = useCellRef(id);
|
|
11
12
|
const exec = useNotebookCellExecution(id);
|
|
@@ -39,6 +40,7 @@ const MemoPassiveOutputRenderer = React.memo(PassiveOutputRenderer);
|
|
|
39
40
|
export const JupyterOutputs = ({ id, outputs }) => {
|
|
40
41
|
var _a;
|
|
41
42
|
const { core, load } = useThebeCore();
|
|
43
|
+
const { inCrossRef } = useXRefState();
|
|
42
44
|
const { data, error } = useFetchAnyTruncatedContent(outputs);
|
|
43
45
|
const [loaded, setLoaded] = useState(false);
|
|
44
46
|
const [fullOutputs, setFullOutputs] = useState(null);
|
|
@@ -50,18 +52,18 @@ export const JupyterOutputs = ({ id, outputs }) => {
|
|
|
50
52
|
load();
|
|
51
53
|
}, [core, load]);
|
|
52
54
|
useEffect(() => {
|
|
53
|
-
if (!data || loaded)
|
|
55
|
+
if (!data || loaded || fullOutputs != null)
|
|
54
56
|
return;
|
|
55
57
|
setLoaded(true);
|
|
56
58
|
fetchAndEncodeOutputImages(data).then((out) => {
|
|
57
59
|
const compactOutputs = convertToIOutputs(out, {});
|
|
58
60
|
setFullOutputs(compactOutputs);
|
|
59
61
|
});
|
|
60
|
-
}, [id, data]);
|
|
62
|
+
}, [id, data, fullOutputs]);
|
|
61
63
|
if (error) {
|
|
62
64
|
return _jsxs("div", Object.assign({ className: "text-red-500" }, { children: ["Error rendering output: ", error.message] }));
|
|
63
65
|
}
|
|
64
|
-
if (registry && (exec === null || exec === void 0 ? void 0 : exec.cell)) {
|
|
66
|
+
if (!inCrossRef && registry && (exec === null || exec === void 0 ? void 0 : exec.cell)) {
|
|
65
67
|
return (_jsxs("div", Object.assign({ ref: registry === null || registry === void 0 ? void 0 : registry.register(id), "data-thebe-active-ref": "true" }, { children: [!fullOutputs && _jsx("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && _jsx(ActiveOutputRenderer, { id: id, data: fullOutputs })] })));
|
|
66
68
|
}
|
|
67
69
|
return (_jsxs(_Fragment, { children: [!fullOutputs && _jsx("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && core && (_jsx(MemoPassiveOutputRenderer, { id: id, data: fullOutputs, core: core, kind: (_a = exec === null || exec === void 0 ? void 0 : exec.kind) !== null && _a !== void 0 ? _a : SourceFileKind.Notebook }))] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAoD3C,eAAO,MAAM,cAAc;QAA2B,MAAM;aAAW,cAAc,EAAE;iBAiDtF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/jupyter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@headlessui/react": "^1.7.13",
|
|
23
23
|
"@heroicons/react": "^2.0.13",
|
|
24
|
-
"@myst-theme/providers": "^0.
|
|
24
|
+
"@myst-theme/providers": "^0.2.0",
|
|
25
25
|
"@popperjs/core": "^2.11.6",
|
|
26
26
|
"ansi-to-react": "^6.1.6",
|
|
27
27
|
"buffer": "^6.0.3",
|