@myst-theme/jupyter 0.9.2 → 0.9.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.
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { GenericNode } from 'myst-common';
3
3
  export declare function usePlaceholder(): GenericNode | undefined;
4
- export declare function OutputDecoration({ outputId, placeholder, children, title, url, }: {
4
+ export declare function OutputDecoration({ outputId, placeholder, children, title, url, remoteBaseUrl, }: {
5
5
  outputId: string;
6
6
  placeholder?: GenericNode;
7
7
  children?: React.ReactNode;
8
8
  title?: string;
9
9
  url?: string;
10
+ remoteBaseUrl?: string;
10
11
  }): import("react/jsx-runtime").JSX.Element;
11
12
  //# sourceMappingURL=decoration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decoration.d.ts","sourceRoot":"","sources":["../src/decoration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAsB/C,wBAAgB,cAAc,4BAG7B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,KAA0B,EAC1B,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,2CA+DA"}
1
+ {"version":3,"file":"decoration.d.ts","sourceRoot":"","sources":["../src/decoration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAsB/C,wBAAgB,cAAc,4BAG7B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,KAA0B,EAC1B,GAAG,EACH,aAAa,GACd,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,2CAkEA"}
@@ -15,19 +15,22 @@ export function usePlaceholder() {
15
15
  const context = React.useContext(PlaceholderContext);
16
16
  return context.placeholder;
17
17
  }
18
- export function OutputDecoration({ outputId, placeholder, children, title = 'Jupyter Notebook', url, }) {
18
+ export function OutputDecoration({ outputId, placeholder, children, title = 'Jupyter Notebook', url, remoteBaseUrl, }) {
19
19
  const { kind } = useCellExecution(outputId);
20
20
  const compute = useComputeOptions();
21
21
  const Link = useLinkProvider();
22
22
  const top = useThemeTop();
23
23
  const baseurl = useBaseurl();
24
- const showComputeControls = (compute === null || compute === void 0 ? void 0 : compute.enabled) && (compute === null || compute === void 0 ? void 0 : compute.features.figureCompute) && kind === SourceFileKind.Article;
24
+ const showComputeControls = (compute === null || compute === void 0 ? void 0 : compute.enabled) &&
25
+ (compute === null || compute === void 0 ? void 0 : compute.features.figureCompute) &&
26
+ kind === SourceFileKind.Article &&
27
+ !remoteBaseUrl;
25
28
  if (showComputeControls) {
26
- return (_jsxs("div", { className: "mb-4 shadow", children: [_jsx("div", { className: "sticky z-[2] w-full bg-gray-100/80 backdrop-blur dark:bg-neutral-800/80 py-1 px-2", style: { top }, children: _jsxs("div", { className: "flex items-center", children: [_jsxs("div", { className: "flex items-center", children: [_jsx(JupyterIcon, { width: "1.25rem", height: "1.25rem", className: "inline-block" }), _jsx("span", { className: "ml-2", children: "Source:" }), url && (_jsx(Link, { to: withBaseurl(url, baseurl), className: "ml-2 no-underline text-normal hover:underline", children: title }))] }), _jsx("div", { className: "flex-grow" }), _jsx(ArticleStatusBadge, { id: outputId }), _jsx(ArticleRunNotebook, { id: outputId }), _jsx(ArticleResetNotebook, { id: outputId })] }) }), _jsx(PlaceholderProvider, { placeholder: placeholder, children: children })] }));
29
+ return (_jsxs("div", { className: "mb-4 shadow", children: [_jsx("div", { className: "sticky z-[2] w-full bg-gray-100/80 backdrop-blur dark:bg-neutral-800/80 py-1 px-2", style: { top }, children: _jsxs("div", { className: "flex items-center", children: [_jsxs("div", { className: "flex items-center", children: [_jsx(JupyterIcon, { width: "1.25rem", height: "1.25rem", className: "inline-block" }), _jsx("span", { className: "ml-2", children: "Source:" }), url && (_jsx(Link, { to: withBaseurl(url, remoteBaseUrl !== null && remoteBaseUrl !== void 0 ? remoteBaseUrl : baseurl), className: "ml-2 no-underline text-normal hover:underline", children: title }))] }), _jsx("div", { className: "flex-grow" }), _jsx(ArticleStatusBadge, { id: outputId }), _jsx(ArticleRunNotebook, { id: outputId }), _jsx(ArticleResetNotebook, { id: outputId })] }) }), _jsx(PlaceholderProvider, { placeholder: placeholder, children: children })] }));
27
30
  }
28
31
  // light
29
32
  if (kind === SourceFileKind.Article) {
30
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-end text-xs", children: [_jsx(JupyterIcon, { width: "0.75rem", height: "0.75rem", className: "inline-block" }), _jsx("div", { className: "ml-1", children: "Source:" }), url && (_jsx(Link, { to: withBaseurl(url, baseurl), className: "ml-1 no-underline text-normal hover:underline", children: title }))] }), _jsx(PlaceholderProvider, { placeholder: placeholder, children: children })] }));
33
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-end text-xs", children: [_jsx(JupyterIcon, { width: "0.75rem", height: "0.75rem", className: "inline-block" }), _jsx("div", { className: "ml-1", children: "Source:" }), url && (_jsx(Link, { to: withBaseurl(url, remoteBaseUrl !== null && remoteBaseUrl !== void 0 ? remoteBaseUrl : baseurl), className: "ml-1 no-underline text-normal hover:underline", children: title }))] }), _jsx(PlaceholderProvider, { placeholder: placeholder, children: children })] }));
31
34
  }
32
35
  // Notebook outputs do not need any decoration
33
36
  return _jsx(_Fragment, { children: children });
@@ -1 +1 @@
1
- {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,2CAapD"}
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,2CAcpD"}
package/dist/embed.js CHANGED
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { OutputDecoration } from './decoration.js';
3
3
  import { MyST } from 'myst-to-react';
4
4
  export function Embed({ node }) {
5
- var _a, _b, _c;
5
+ var _a, _b, _c, _d;
6
6
  const output = (_a = node.children) === null || _a === void 0 ? void 0 : _a.find((child) => child.type === 'output');
7
7
  if (!output)
8
8
  return _jsx(MyST, { ast: node.children });
9
- return (_jsx(OutputDecoration, { outputId: output.id, title: (_b = node.source) === null || _b === void 0 ? void 0 : _b.title, url: (_c = node.source) === null || _c === void 0 ? void 0 : _c.url, children: _jsx(MyST, { ast: node.children }) }, node.key));
9
+ return (_jsx(OutputDecoration, { outputId: output.id, title: (_b = node.source) === null || _b === void 0 ? void 0 : _b.title, url: (_c = node.source) === null || _c === void 0 ? void 0 : _c.url, remoteBaseUrl: (_d = node.source) === null || _d === void 0 ? void 0 : _d.remoteBaseUrl, children: _jsx(MyST, { ast: node.children }) }, node.key));
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"figure.d.ts","sourceRoot":"","sources":["../src/figure.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,wBAAgB,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,2CAyBrD"}
1
+ {"version":3,"file":"figure.d.ts","sourceRoot":"","sources":["../src/figure.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,wBAAgB,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,2CA0BrD"}
package/dist/figure.js CHANGED
@@ -4,14 +4,14 @@ import { DEFAULT_RENDERERS, MyST } from 'myst-to-react';
4
4
  import classNames from 'classnames';
5
5
  import { OutputDecoration } from './decoration.js';
6
6
  export function Figure({ node }) {
7
- var _a, _b, _c, _d, _e, _f;
7
+ var _a, _b, _c, _d, _e, _f, _g;
8
8
  const { container: Container } = DEFAULT_RENDERERS;
9
9
  const isFromJupyer = ((_a = node.source) === null || _a === void 0 ? void 0 : _a.kind) === SourceFileKind.Notebook;
10
10
  const output = (_b = node.children) === null || _b === void 0 ? void 0 : _b.find((child) => child.type === 'output');
11
11
  if (isFromJupyer && !!output) {
12
12
  const placeholder = (_c = node.children) === null || _c === void 0 ? void 0 : _c.find((child) => child.type === 'image' && child.placeholder);
13
13
  const others = (_d = node.children) === null || _d === void 0 ? void 0 : _d.filter((child) => !(child.type === 'image' && child.placeholder));
14
- return (_jsx("figure", { id: node.html_id || node.identifier || node.key, className: classNames({ subcontainer: node.subcontainer }, node.class), children: _jsx(OutputDecoration, { outputId: output.id, placeholder: placeholder, title: (_e = node.source) === null || _e === void 0 ? void 0 : _e.title, url: (_f = node.source) === null || _f === void 0 ? void 0 : _f.url, children: _jsx(MyST, { ast: others }) }, node.key) }));
14
+ return (_jsx("figure", { id: node.html_id || node.identifier || node.key, className: classNames({ subcontainer: node.subcontainer }, node.class), children: _jsx(OutputDecoration, { outputId: output.id, placeholder: placeholder, title: (_e = node.source) === null || _e === void 0 ? void 0 : _e.title, url: (_f = node.source) === null || _f === void 0 ? void 0 : _f.url, remoteBaseUrl: (_g = node.source) === null || _g === void 0 ? void 0 : _g.remoteBaseUrl, children: _jsx(MyST, { ast: others }) }, node.key) }));
15
15
  }
16
16
  return _jsx(Container, { node: node });
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myst-theme/jupyter",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -25,17 +25,17 @@
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.9.2",
28
+ "@myst-theme/providers": "^0.9.4",
29
29
  "@scienceicons/react": "^0.0.6",
30
30
  "buffer": "^6.0.3",
31
31
  "classnames": "^2.3.2",
32
32
  "jupyterlab-plotly": "^5.18.0",
33
- "myst-common": "^1.4.0",
34
- "myst-config": "^1.4.0",
35
- "myst-frontmatter": "^1.4.0",
33
+ "myst-common": "^1.4.1",
34
+ "myst-config": "^1.4.1",
35
+ "myst-frontmatter": "^1.4.1",
36
36
  "myst-spec": "^0.0.5",
37
- "myst-spec-ext": "^1.4.0",
38
- "myst-to-react": "^0.9.2",
37
+ "myst-spec-ext": "^1.4.1",
38
+ "myst-to-react": "^0.9.4",
39
39
  "nanoid": "^4.0.2",
40
40
  "nbtx": "^0.2.3",
41
41
  "react-syntax-highlighter": "^15.5.0",