@myst-theme/jupyter 0.14.0 → 0.14.2
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/README.md +4 -4
- package/dist/block.d.ts +2 -4
- package/dist/block.d.ts.map +1 -1
- package/dist/block.js +6 -14
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +4 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# @myst-theme/
|
|
1
|
+
# @myst-theme/jupyter
|
|
2
2
|
|
|
3
|
-
[](https://github.com/
|
|
3
|
+
[](https://www.npmjs.com/package/@myst-theme/jupyter)
|
|
4
|
+
[](https://github.com/jupyter-book/myst-theme/blob/main/LICENSE)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
React components for integrating Jupyter with MyST.
|
package/dist/block.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { GenericParent } from 'myst-common';
|
|
2
|
-
import type { NodeRenderers
|
|
3
|
-
export declare function NotebookBlock({
|
|
4
|
-
id: string;
|
|
2
|
+
import type { NodeRenderers } from '@myst-theme/providers';
|
|
3
|
+
export declare function NotebookBlock({ node, className }: {
|
|
5
4
|
node: GenericParent;
|
|
6
5
|
className?: string;
|
|
7
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export declare const NotebookBlockRenderer: NodeRenderer;
|
|
9
7
|
/**
|
|
10
8
|
* The logic for the selector is complex:
|
|
11
9
|
*
|
package/dist/block.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAgC7F;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAItC,CAAC"}
|
package/dist/block.js
CHANGED
|
@@ -3,27 +3,19 @@ import { Details, MyST } from 'myst-to-react';
|
|
|
3
3
|
import { SourceFileKind } from 'myst-spec-ext';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { NotebookClearCell, NotebookRunCell, NotebookRunCellSpinnerOnly, } from './controls/index.js';
|
|
6
|
-
import {
|
|
7
|
-
export function NotebookBlock({
|
|
6
|
+
import { usePageKind } from '@myst-theme/providers';
|
|
7
|
+
export function NotebookBlock({ node, className }) {
|
|
8
8
|
var _a, _b;
|
|
9
9
|
const pageKind = usePageKind();
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const dataClassName = typeof ((_a = node.data) === null || _a === void 0 ? void 0 : _a.class) === 'string' ? (_b = node.data) === null || _b === void 0 ? void 0 : _b.class : undefined;
|
|
13
|
-
// Hide the subgrid if either the dataClass or the className exists and includes `col-`
|
|
14
|
-
const noSubGrid = (dataClassName && dataClassName.includes('col-')) || (className && className.includes('col-'));
|
|
15
|
-
const block = (_jsxs("div", { id: id, className: classNames('relative group/block', className, dataClassName, {
|
|
16
|
-
[subGrid]: !noSubGrid,
|
|
10
|
+
const block = (_jsxs("div", { id: node.key, className: classNames('relative group/block', className, node.class, {
|
|
11
|
+
[(_a = node.data) === null || _a === void 0 ? void 0 : _a.class]: typeof ((_b = node.data) === null || _b === void 0 ? void 0 : _b.class) === 'string',
|
|
17
12
|
hidden: node.visibility === 'remove',
|
|
18
|
-
}), children: [pageKind === SourceFileKind.Notebook && node.kind === 'notebook-code' && (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex sticky top-[80px] z-10 opacity-70 group-hover/block:opacity-100 group-hover/block:hidden", children: _jsx("div", { className: "absolute top-0 -right-[28px] flex md:flex-col", children: _jsx(NotebookRunCellSpinnerOnly, { id:
|
|
13
|
+
}), children: [pageKind === SourceFileKind.Notebook && node.kind === 'notebook-code' && (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex sticky top-[80px] z-10 opacity-70 group-hover/block:opacity-100 group-hover/block:hidden", children: _jsx("div", { className: "absolute top-0 -right-[28px] flex md:flex-col", children: _jsx(NotebookRunCellSpinnerOnly, { id: node.key }) }) }), _jsx("div", { className: "hidden sticky top-[80px] z-10 opacity-70 group-hover/block:opacity-100 group-hover/block:flex", children: _jsxs("div", { className: "absolute top-0 -right-[28px] flex md:flex-col", children: [_jsx(NotebookRunCell, { id: node.key }), _jsx(NotebookClearCell, { id: node.key })] }) })] })), _jsx(MyST, { ast: node.children })] }));
|
|
19
14
|
if (node.visibility === 'hide') {
|
|
20
15
|
return _jsx(Details, { title: "Notebook Cell", children: block });
|
|
21
16
|
}
|
|
22
17
|
return block;
|
|
23
18
|
}
|
|
24
|
-
export const NotebookBlockRenderer = ({ node, className }) => {
|
|
25
|
-
return (_jsx(NotebookBlock, { id: node.key, node: node, className: classNames(node.class, className) }, node.key));
|
|
26
|
-
};
|
|
27
19
|
/**
|
|
28
20
|
* The logic for the selector is complex:
|
|
29
21
|
*
|
|
@@ -37,6 +29,6 @@ export const NotebookBlockRenderer = ({ node, className }) => {
|
|
|
37
29
|
*/
|
|
38
30
|
export const NOTEBOOK_BLOCK_RENDERERS = {
|
|
39
31
|
block: {
|
|
40
|
-
'block[kind=notebook-code],block[kind=notebook-content]':
|
|
32
|
+
'block[kind=notebook-code],block[kind=notebook-content]': NotebookBlock,
|
|
41
33
|
},
|
|
42
34
|
};
|
package/dist/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAKd,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAKd,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,CAoCA;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa;;;EAapC;AAED,wBAAgB,eAAe;;;;yBAOpB,iBAAiB;;kCAkBZ,MAAM;EAqBrB"}
|
package/dist/hooks.js
CHANGED
|
@@ -47,8 +47,8 @@ export function useLongContent(content, url) {
|
|
|
47
47
|
return { data: { content: content !== null && content !== void 0 ? content : '' } };
|
|
48
48
|
return { data, error };
|
|
49
49
|
}
|
|
50
|
-
const arrayFetcher = (
|
|
51
|
-
return Promise.all(urls.map((url) => fetcher(url
|
|
50
|
+
const arrayFetcher = (urls) => {
|
|
51
|
+
return Promise.all(urls.map((url) => fetcher(url)));
|
|
52
52
|
};
|
|
53
53
|
function shallowCloneOutputs(outputs) {
|
|
54
54
|
return outputs.map((output) => {
|
|
@@ -72,7 +72,8 @@ export function useFetchAnyTruncatedContent(outputs) {
|
|
|
72
72
|
itemsWithPaths.push(obj);
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
-
const
|
|
75
|
+
const paths = itemsWithPaths.map(({ path }) => path);
|
|
76
|
+
const { data, error } = useSWRImmutable(paths, arrayFetcher);
|
|
76
77
|
data === null || data === void 0 ? void 0 : data.forEach(({ content }, idx) => {
|
|
77
78
|
const obj = itemsWithPaths[idx];
|
|
78
79
|
if ('text' in obj) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/jupyter",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@curvenote/ansi-to-react": "^7.0.0",
|
|
26
26
|
"@headlessui/react": "^1.7.15",
|
|
27
27
|
"@heroicons/react": "^2.0.18",
|
|
28
|
-
"@myst-theme/providers": "^0.14.
|
|
28
|
+
"@myst-theme/providers": "^0.14.2",
|
|
29
29
|
"@scienceicons/react": "^0.0.11",
|
|
30
30
|
"buffer": "^6.0.3",
|
|
31
31
|
"classnames": "^2.5.1",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"myst-frontmatter": "^1.7.9",
|
|
36
36
|
"myst-spec": "^0.0.5",
|
|
37
37
|
"myst-spec-ext": "^1.7.9",
|
|
38
|
-
"myst-to-react": "^0.14.
|
|
38
|
+
"myst-to-react": "^0.14.2",
|
|
39
39
|
"nanoid": "^4.0.2",
|
|
40
40
|
"nbtx": "^0.2.3",
|
|
41
41
|
"react-syntax-highlighter": "^15.5.0",
|