@myst-theme/jupyter 0.3.7 → 0.4.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.
Files changed (117) hide show
  1. package/dist/cjs/BinderBadge.js +1 -1
  2. package/dist/cjs/ErrorTray.d.ts +4 -4
  3. package/dist/cjs/ErrorTray.d.ts.map +1 -1
  4. package/dist/cjs/ErrorTray.js +11 -3
  5. package/dist/cjs/decoration.d.ts +11 -0
  6. package/dist/cjs/decoration.d.ts.map +1 -0
  7. package/dist/cjs/decoration.js +39 -0
  8. package/dist/cjs/embed.d.ts +3 -2
  9. package/dist/cjs/embed.d.ts.map +1 -1
  10. package/dist/cjs/embed.js +8 -18
  11. package/dist/cjs/execute/actions.d.ts +1 -1
  12. package/dist/cjs/execute/actions.d.ts.map +1 -1
  13. package/dist/cjs/execute/busy.d.ts +24 -2
  14. package/dist/cjs/execute/busy.d.ts.map +1 -1
  15. package/dist/cjs/execute/busy.js +86 -9
  16. package/dist/cjs/execute/hooks.d.ts +5 -2
  17. package/dist/cjs/execute/hooks.d.ts.map +1 -1
  18. package/dist/cjs/execute/hooks.js +19 -10
  19. package/dist/cjs/execute/provider.d.ts +7 -2
  20. package/dist/cjs/execute/provider.d.ts.map +1 -1
  21. package/dist/cjs/execute/provider.js +5 -3
  22. package/dist/cjs/execute/reducer.js +2 -2
  23. package/dist/cjs/execute/selectors.d.ts +0 -1
  24. package/dist/cjs/execute/selectors.d.ts.map +1 -1
  25. package/dist/cjs/execute/selectors.js +9 -14
  26. package/dist/cjs/execute/types.d.ts +1 -1
  27. package/dist/cjs/execute/types.d.ts.map +1 -1
  28. package/dist/cjs/execute/utils.d.ts.map +1 -1
  29. package/dist/cjs/execute/utils.js +9 -8
  30. package/dist/cjs/figure.d.ts +5 -0
  31. package/dist/cjs/figure.d.ts.map +1 -0
  32. package/dist/cjs/figure.js +20 -0
  33. package/dist/cjs/index.d.ts +2 -0
  34. package/dist/cjs/index.d.ts.map +1 -1
  35. package/dist/cjs/index.js +2 -0
  36. package/dist/cjs/jupyter.d.ts.map +1 -1
  37. package/dist/cjs/jupyter.js +20 -6
  38. package/dist/cjs/output.d.ts +9 -1
  39. package/dist/cjs/output.d.ts.map +1 -1
  40. package/dist/cjs/output.js +17 -9
  41. package/dist/cjs/providers.d.ts +7 -2
  42. package/dist/cjs/providers.d.ts.map +1 -1
  43. package/dist/cjs/providers.js +8 -3
  44. package/dist/cjs/utils.js +2 -2
  45. package/dist/esm/BinderBadge.js +1 -1
  46. package/dist/esm/ErrorTray.d.ts +4 -4
  47. package/dist/esm/ErrorTray.d.ts.map +1 -1
  48. package/dist/esm/ErrorTray.js +11 -3
  49. package/dist/esm/decoration.d.ts +11 -0
  50. package/dist/esm/decoration.d.ts.map +1 -0
  51. package/dist/esm/decoration.js +31 -0
  52. package/dist/esm/embed.d.ts +3 -2
  53. package/dist/esm/embed.d.ts.map +1 -1
  54. package/dist/esm/embed.js +9 -19
  55. package/dist/esm/execute/actions.d.ts +1 -1
  56. package/dist/esm/execute/actions.d.ts.map +1 -1
  57. package/dist/esm/execute/busy.d.ts +24 -2
  58. package/dist/esm/execute/busy.d.ts.map +1 -1
  59. package/dist/esm/execute/busy.js +84 -8
  60. package/dist/esm/execute/hooks.d.ts +5 -2
  61. package/dist/esm/execute/hooks.d.ts.map +1 -1
  62. package/dist/esm/execute/hooks.js +18 -9
  63. package/dist/esm/execute/provider.d.ts +7 -2
  64. package/dist/esm/execute/provider.d.ts.map +1 -1
  65. package/dist/esm/execute/provider.js +4 -2
  66. package/dist/esm/execute/reducer.js +1 -1
  67. package/dist/esm/execute/selectors.d.ts +0 -1
  68. package/dist/esm/execute/selectors.d.ts.map +1 -1
  69. package/dist/esm/execute/selectors.js +7 -11
  70. package/dist/esm/execute/types.d.ts +1 -1
  71. package/dist/esm/execute/types.d.ts.map +1 -1
  72. package/dist/esm/execute/utils.d.ts.map +1 -1
  73. package/dist/esm/execute/utils.js +9 -8
  74. package/dist/esm/figure.d.ts +5 -0
  75. package/dist/esm/figure.d.ts.map +1 -0
  76. package/dist/esm/figure.js +16 -0
  77. package/dist/esm/index.d.ts +2 -0
  78. package/dist/esm/index.d.ts.map +1 -1
  79. package/dist/esm/index.js +2 -0
  80. package/dist/esm/jupyter.d.ts.map +1 -1
  81. package/dist/esm/jupyter.js +16 -5
  82. package/dist/esm/output.d.ts +9 -1
  83. package/dist/esm/output.d.ts.map +1 -1
  84. package/dist/esm/output.js +15 -8
  85. package/dist/esm/providers.d.ts +7 -2
  86. package/dist/esm/providers.d.ts.map +1 -1
  87. package/dist/esm/providers.js +6 -2
  88. package/dist/esm/utils.js +2 -2
  89. package/dist/types/ErrorTray.d.ts +4 -4
  90. package/dist/types/ErrorTray.d.ts.map +1 -1
  91. package/dist/types/decoration.d.ts +11 -0
  92. package/dist/types/decoration.d.ts.map +1 -0
  93. package/dist/types/embed.d.ts +3 -2
  94. package/dist/types/embed.d.ts.map +1 -1
  95. package/dist/types/execute/actions.d.ts +1 -1
  96. package/dist/types/execute/actions.d.ts.map +1 -1
  97. package/dist/types/execute/busy.d.ts +24 -2
  98. package/dist/types/execute/busy.d.ts.map +1 -1
  99. package/dist/types/execute/hooks.d.ts +5 -2
  100. package/dist/types/execute/hooks.d.ts.map +1 -1
  101. package/dist/types/execute/provider.d.ts +7 -2
  102. package/dist/types/execute/provider.d.ts.map +1 -1
  103. package/dist/types/execute/selectors.d.ts +0 -1
  104. package/dist/types/execute/selectors.d.ts.map +1 -1
  105. package/dist/types/execute/types.d.ts +1 -1
  106. package/dist/types/execute/types.d.ts.map +1 -1
  107. package/dist/types/execute/utils.d.ts.map +1 -1
  108. package/dist/types/figure.d.ts +5 -0
  109. package/dist/types/figure.d.ts.map +1 -0
  110. package/dist/types/index.d.ts +2 -0
  111. package/dist/types/index.d.ts.map +1 -1
  112. package/dist/types/jupyter.d.ts.map +1 -1
  113. package/dist/types/output.d.ts +9 -1
  114. package/dist/types/output.d.ts.map +1 -1
  115. package/dist/types/providers.d.ts +7 -2
  116. package/dist/types/providers.d.ts.map +1 -1
  117. package/package.json +11 -9
@@ -8,6 +8,6 @@ function BinderBadgeLogo() {
8
8
  function BinderBadge({ binder }) {
9
9
  if (!binder)
10
10
  return null;
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, {}) }) }));
11
+ return ((0, jsx_runtime_1.jsx)("div", { className: "inline-block m-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;
@@ -1,5 +1,5 @@
1
- import type { IThebeNotebookError } from 'thebe-react';
2
- export declare function ErrorTray({ errors }: {
3
- errors: IThebeNotebookError[];
4
- }): import("react/jsx-runtime").JSX.Element;
1
+ export declare function ErrorTray({ pageSlug, index }: {
2
+ pageSlug: string;
3
+ index?: string;
4
+ }): import("react/jsx-runtime").JSX.Element | null;
5
5
  //# sourceMappingURL=ErrorTray.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorTray.d.ts","sourceRoot":"","sources":["../../src/ErrorTray.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAgDvD,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA;CAAE,2CAStE"}
1
+ {"version":3,"file":"ErrorTray.d.ts","sourceRoot":"","sources":["../../src/ErrorTray.tsx"],"names":[],"mappings":"AAmDA,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,kDAkBlF"}
@@ -4,6 +4,7 @@ exports.ErrorTray = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const thebe_react_1 = require("thebe-react");
7
+ const busy_1 = require("./execute/busy");
7
8
  function ErrorDecoration({ children, idx }) {
8
9
  return ((0, jsx_runtime_1.jsxs)("div", { className: "relative py-3 mx-2 my-8 border rounded", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute z-10 flex items-center bg-white -top-3 -left-2", children: idx && (0, jsx_runtime_1.jsxs)("div", { className: "ml-1 text-sm text-gray-500", children: ["cell #: ", idx] }) }), (0, jsx_runtime_1.jsx)("div", { className: "mx-3", children: children })] }));
9
10
  }
@@ -26,9 +27,16 @@ function ErrorTrayMessage({ errors }) {
26
27
  }, [core, errors]);
27
28
  if (!core)
28
29
  return null;
29
- return ((0, jsx_runtime_1.jsx)("div", { children: errors.map((error, idx) => ((0, jsx_runtime_1.jsx)("div", { className: "min-w-[400px]", children: (0, jsx_runtime_1.jsx)(ErrorDecoration, { idx: error.index, children: (0, jsx_runtime_1.jsx)("div", { className: "z-100", ref: refs[idx] }, error.id) }) }))) }));
30
+ return ((0, jsx_runtime_1.jsx)("div", { children: errors.map((error, idx) => ((0, jsx_runtime_1.jsx)("div", { className: "not-prose min-w-[400px]", children: (0, jsx_runtime_1.jsx)(ErrorDecoration, { idx: error.index, children: (0, jsx_runtime_1.jsx)("div", { className: "z-100", ref: refs[idx] }, error.id) }) }))) }));
30
31
  }
31
- function ErrorTray({ errors }) {
32
- return ((0, jsx_runtime_1.jsxs)("div", { className: "relative px-4 pt-3 mt-8 text-sm text-red-600 border border-red-400 rounded border-1", children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "font-bold", children: "Error" }), " - a page refresh may resolve this."] }), (0, jsx_runtime_1.jsx)(ErrorTrayMessage, { errors: errors })] }));
32
+ function ErrorTray({ pageSlug, index }) {
33
+ const { items } = (0, busy_1.useBusyErrors)(pageSlug);
34
+ if (!items || items.length === 0)
35
+ return null;
36
+ if (index && index)
37
+ return null;
38
+ return ((0, jsx_runtime_1.jsx)("div", { className: "relative px-4 pt-3 mt-8 text-sm text-red-600 border border-red-400 rounded border-1", children: items.map(({ notebookSlug, errors }) => {
39
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "font-bold", children: "Error" }), " in notebook ", (0, jsx_runtime_1.jsxs)("span", { children: ["\"", notebookSlug, "\""] })] }), (0, jsx_runtime_1.jsx)(ErrorTrayMessage, { errors: errors })] }));
40
+ }) }));
33
41
  }
34
42
  exports.ErrorTray = ErrorTray;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { GenericNode } from 'myst-common';
3
+ export declare function usePlaceholder(): GenericNode | undefined;
4
+ export declare function OutputDecoration({ outputId, placeholder, children, title, url, }: {
5
+ outputId: string;
6
+ placeholder?: GenericNode;
7
+ children?: React.ReactNode;
8
+ title?: string;
9
+ url?: string;
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ //# sourceMappingURL=decoration.d.ts.map
@@ -0,0 +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;AAqB/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,2CAyDA"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OutputDecoration = exports.usePlaceholder = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = __importDefault(require("react"));
9
+ const myst_spec_ext_1 = require("myst-spec-ext");
10
+ const execute_1 = require("./execute");
11
+ const ArticleCellControls_1 = require("./controls/ArticleCellControls");
12
+ const solid_1 = require("@scienceicons/react/24/solid");
13
+ const providers_1 = require("@myst-theme/providers");
14
+ const PlaceholderContext = react_1.default.createContext({});
15
+ function PlaceholderProvider({ placeholder, children, }) {
16
+ const value = react_1.default.useMemo(() => ({ placeholder }), [placeholder]);
17
+ return (0, jsx_runtime_1.jsx)(PlaceholderContext.Provider, { value: value, children: children });
18
+ }
19
+ function usePlaceholder() {
20
+ const context = react_1.default.useContext(PlaceholderContext);
21
+ return context.placeholder;
22
+ }
23
+ exports.usePlaceholder = usePlaceholder;
24
+ function OutputDecoration({ outputId, placeholder, children, title = 'Jupyter Notebook', url, }) {
25
+ const { canCompute, kind } = (0, execute_1.useCellExecution)(outputId);
26
+ const Link = (0, providers_1.useLinkProvider)();
27
+ const baseurl = (0, providers_1.useBaseurl)();
28
+ const showComputeControls = canCompute && kind === myst_spec_ext_1.SourceFileKind.Article;
29
+ if (showComputeControls) {
30
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4 shadow", children: [(0, jsx_runtime_1.jsx)("div", { className: "sticky top-[60px] z-[2] w-full bg-gray-100/80 backdrop-blur dark:bg-neutral-800/80 py-1 px-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsx)(solid_1.JupyterIcon, { className: "inline-block w-5 h-5" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-2", children: "Source:" }), url && ((0, jsx_runtime_1.jsx)(Link, { to: (0, providers_1.withBaseurl)(url, baseurl), className: "ml-2 no-underline text-normal hover:underline", children: title }))] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow" }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleStatusBadge, { id: outputId }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleRunNotebook, { id: outputId }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleResetNotebook, { id: outputId })] }) }), (0, jsx_runtime_1.jsx)(PlaceholderProvider, { placeholder: placeholder, children: children })] }));
31
+ }
32
+ // light
33
+ if (kind === myst_spec_ext_1.SourceFileKind.Article) {
34
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-end text-xs", children: [(0, jsx_runtime_1.jsx)(solid_1.JupyterIcon, { className: "inline-block w-3 h-3" }), (0, jsx_runtime_1.jsx)("div", { className: "ml-1", children: "Source:" }), url && ((0, jsx_runtime_1.jsx)(Link, { to: (0, providers_1.withBaseurl)(url, baseurl), className: "ml-1 no-underline text-normal hover:underline", children: title }))] }), (0, jsx_runtime_1.jsx)(PlaceholderProvider, { placeholder: placeholder, children: children })] }));
35
+ }
36
+ // Notebook outputs do not need any decoration
37
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
38
+ }
39
+ exports.OutputDecoration = OutputDecoration;
@@ -1,4 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { type GenericNode } from 'myst-common';
3
- export declare function Embed(node: GenericNode, children: React.ReactNode): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Embed({ node }: {
3
+ node: GenericNode;
4
+ }): import("react/jsx-runtime").JSX.Element;
4
5
  //# sourceMappingURL=embed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAwD/D,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,2CAajE"}
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,2CAkBpD"}
package/dist/cjs/embed.js CHANGED
@@ -2,24 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Embed = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const myst_common_1 = require("myst-common");
6
- const execute_1 = require("./execute");
7
- const ArticleCellControls_1 = require("./controls/ArticleCellControls");
8
- const solid_1 = require("@scienceicons/react/24/solid");
9
- const unist_util_select_1 = require("unist-util-select");
10
- const providers_1 = require("@myst-theme/providers");
11
- function EmbedWithControls({ outputKey, children, title = 'Jupyter Notebook', url, }) {
12
- const { kind } = (0, execute_1.useCellExecution)(outputKey);
13
- const Link = (0, providers_1.useLinkProvider)();
14
- const baseurl = (0, providers_1.useBaseurl)();
15
- const showControls = kind === myst_common_1.SourceFileKind.Article;
16
- return ((0, jsx_runtime_1.jsxs)("div", { className: "shadow", children: [showControls && ((0, jsx_runtime_1.jsx)("div", { className: "sticky top-[60px] z-[2] w-full bg-gray-100/80 backdrop-blur dark:bg-neutral-800/80 py-1 px-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsx)(solid_1.JupyterIcon, { className: "inline-block w-5 h-5" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-2", children: "Source:" }), url && ((0, jsx_runtime_1.jsx)(Link, { to: (0, providers_1.withBaseurl)(url, baseurl), className: "ml-2 no-underline text-normal hover:underline", children: title }))] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow" }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleStatusBadge, { id: outputKey }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleRunNotebook, { id: outputKey }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleResetNotebook, { id: outputKey })] }) })), (0, jsx_runtime_1.jsx)("div", { className: "mt-2", children: children })] }));
17
- }
18
- function Embed(node, children) {
19
- var _a, _b;
20
- const output = (0, unist_util_select_1.select)('output', node);
5
+ const output_1 = require("./output");
6
+ const decoration_1 = require("./decoration");
7
+ const myst_to_react_1 = require("myst-to-react");
8
+ function Embed({ node }) {
9
+ var _a, _b, _c;
10
+ const output = (_a = node.children) === null || _a === void 0 ? void 0 : _a.find((child) => child.type === 'output');
21
11
  if (!output)
22
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
23
- return ((0, jsx_runtime_1.jsx)(EmbedWithControls, { outputKey: output.key, title: (_a = node.source) === null || _a === void 0 ? void 0 : _a.title, url: (_b = node.source) === null || _b === void 0 ? void 0 : _b.url, children: children }, node.key));
12
+ return (0, jsx_runtime_1.jsx)(myst_to_react_1.MyST, { ast: node.children });
13
+ return ((0, jsx_runtime_1.jsx)(decoration_1.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: (0, jsx_runtime_1.jsx)(output_1.JupyterOutput, { outputId: output.id, identifier: output.identifier, align: node.align, data: node.data }) }, node.key));
24
14
  }
25
15
  exports.Embed = Embed;
@@ -1,4 +1,4 @@
1
- import type { Dependency, SourceFileKind } from 'myst-common';
1
+ import type { SourceFileKind, Dependency } from 'myst-spec-ext';
2
2
  import type { Root } from 'mdast';
3
3
  import type { BuildStatus, Computable } from './types';
4
4
  import type { IRenderMimeRegistry, ThebeNotebook, ThebeSession } from 'thebe-core';
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/execute/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,eAAe,CAQ9E;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,WAAW,CAEtE;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,iBAAiB,CAGlF;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,kBAAkB,CAEpF;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,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AAkB,CAQpF;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,mBAAmB,CAAC;CACjC;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,iBAAiB,CAOlF;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EACA,UAAU,GACV,eAAe,GACf,cAAc,GACd,aAAa,GACb,WAAW,GACX,cAAc,GACd,aAAa,GACb,qBAAqB,GACrB,qBAAqB,CAAC;IAC1B,OAAO,EACH,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,kBAAkB,GAClB,eAAe,GACf,kBAAkB,GAClB,iBAAiB,CAAC;CACvB"}
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { IThebeNotebookError } from 'thebe-react';
2
3
  export type BusyKind = 'execute' | 'reset';
3
4
  export interface BusyScopeState {
4
5
  execute: {
@@ -15,6 +16,11 @@ export interface BusyScopeState {
15
16
  };
16
17
  };
17
18
  };
19
+ error: {
20
+ [pageSlug: string]: {
21
+ [notebookSlug: string]: IThebeNotebookError[];
22
+ };
23
+ };
18
24
  }
19
25
  export interface BusyScopeContext {
20
26
  state: BusyScopeState;
@@ -37,9 +43,14 @@ export interface NotebookPayload {
37
43
  cellIds: string[];
38
44
  kind: BusyKind;
39
45
  }
46
+ export interface ErrorPayload {
47
+ pageSlug: string;
48
+ notebookSlug: string;
49
+ errors?: IThebeNotebookError[];
50
+ }
40
51
  type BusyScopeAction = {
41
- type: 'SET_CELL_BUSY' | 'CLEAR_CELL_BUSY' | 'SET_NOTEBOOK_BUSY' | 'CLEAR_NOTEBOOK_BUSY';
42
- payload: SlugPayload | CellPayload | NotebookPayload;
52
+ type: 'SET_CELL_BUSY' | 'CLEAR_CELL_BUSY' | 'SET_NOTEBOOK_BUSY' | 'CLEAR_NOTEBOOK_BUSY' | 'SET_ERROR' | 'CLEAR_ERROR';
53
+ payload: SlugPayload | CellPayload | NotebookPayload | ErrorPayload;
43
54
  };
44
55
  export declare function reducer(state: BusyScopeState, action: BusyScopeAction): BusyScopeState;
45
56
  export declare function BusyScopeProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
@@ -51,6 +62,17 @@ export declare function useBusyScope(): {
51
62
  clearCell: (pageSlug: string, notebookSlug: string, cellId: string, kind: BusyKind) => void;
52
63
  setNotebook: (pageSlug: string, notebookSlug: string, cellIds: string[], kind: BusyKind) => void;
53
64
  clearNotebook: (pageSlug: string, notebookSlug: string, kind: BusyKind) => void;
65
+ setError: (pageSlug: string, notebookSlug: string, errors: IThebeNotebookError[]) => void;
66
+ clearError: (pageSlug: string, notebookSlug: string) => void;
67
+ };
68
+ interface ErrorItem {
69
+ pageSlug: string;
70
+ notebookSlug: string;
71
+ errors: IThebeNotebookError[];
72
+ }
73
+ export declare function useBusyErrors(pageSlug: string): {
74
+ items: ErrorItem[] | undefined;
75
+ clearErrors: () => void;
54
76
  };
55
77
  export declare function selectCellIsBusy(state: BusyScopeState, pageSlug: string, notebookSlug: string, cellId: string, kind: BusyKind): boolean;
56
78
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"busy.d.ts","sourceRoot":"","sources":["../../../src/execute/busy.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAEvD,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE;QACP,CAAC,QAAQ,EAAE,MAAM,GAAG;YAClB,CAAC,YAAY,EAAE,MAAM,GAAG;gBACtB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;aAC3B,CAAC;SACH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Y;qBASb,MAAM,gBAAgB,MAAM,UAAU,MAAM,QAAQ,QAAQ;yBAK5D,MAAM,gBAAgB,MAAM,QAAQ,QAAQ;qBAK5C,MAAM,QAAQ,QAAQ;wBAKtB,MAAM,gBAAgB,MAAM,UAAU,MAAM,QAAQ,QAAQ;0BAO5D,MAAM,gBAAgB,MAAM,UAAU,MAAM,QAAQ,QAAQ;4BAM5D,MAAM,gBAAgB,MAAM,WAAW,MAAM,EAAE,QAAQ,QAAQ;8BAM/D,MAAM,gBAAgB,MAAM,QAAQ,QAAQ;yBAM5C,MAAM,gBAAgB,MAAM,UAAU,mBAAmB,EAAE;2BAM3D,MAAM,gBAAgB,MAAM;EAgB1C;AAED,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM;;;EAwB7C;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,WAGf;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,QAAQ,WAGf;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,WAEvF"}
@@ -34,7 +34,7 @@ var __rest = (this && this.__rest) || function (s, e) {
34
34
  return t;
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.selectPageIsBusy = exports.selectNotebookIsBusy = exports.selectCellIsBusy = exports.useBusyScope = exports.BusyScopeProvider = exports.reducer = void 0;
37
+ exports.selectPageIsBusy = exports.selectNotebookIsBusy = exports.selectCellIsBusy = exports.useBusyErrors = exports.useBusyScope = exports.BusyScopeProvider = exports.reducer = void 0;
38
38
  const jsx_runtime_1 = require("react/jsx-runtime");
39
39
  const react_1 = __importStar(require("react"));
40
40
  const BusyScopeContext = react_1.default.createContext(undefined);
@@ -54,8 +54,16 @@ function isNotebookPayload(payload) {
54
54
  payload.cellIds.every((id) => typeof id === 'string') &&
55
55
  typeof payload.kind === 'string');
56
56
  }
57
+ function isErrorPayload(payload) {
58
+ var _a, _b;
59
+ return ((typeof payload.pageSlug === 'string' &&
60
+ typeof payload.notebookSlug === 'string' &&
61
+ payload.errors === undefined) ||
62
+ ((_b = (Array.isArray(payload.errors) &&
63
+ ((_a = payload.errors) === null || _a === void 0 ? void 0 : _a.every((error) => typeof error === 'object')))) !== null && _b !== void 0 ? _b : false));
64
+ }
57
65
  function reducer(state, action) {
58
- var _a, _b, _c, _d, _e;
66
+ var _a, _b, _c, _d, _e, _f, _g;
59
67
  switch (action.type) {
60
68
  case 'SET_CELL_BUSY': {
61
69
  if (!isCellPayload(action.payload)) {
@@ -73,16 +81,16 @@ function reducer(state, action) {
73
81
  return state;
74
82
  }
75
83
  const { pageSlug, notebookSlug, cellId, kind } = action.payload;
76
- const _f = state[kind], _g = pageSlug, renderBusy = _f[_g], otherRenders = __rest(_f, [typeof _g === "symbol" ? _g : _g + ""]);
84
+ const _h = state[kind], _j = pageSlug, renderBusy = _h[_j], otherRenders = __rest(_h, [typeof _j === "symbol" ? _j : _j + ""]);
77
85
  if (!renderBusy)
78
86
  return state;
79
- const _h = renderBusy, _j = notebookSlug, notebookBusy = _h[_j], otherNotebooks = __rest(_h, [typeof _j === "symbol" ? _j : _j + ""]);
87
+ const _k = renderBusy, _l = notebookSlug, notebookBusy = _k[_l], otherNotebooks = __rest(_k, [typeof _l === "symbol" ? _l : _l + ""]);
80
88
  if (!notebookBusy)
81
89
  return state;
82
90
  if (!notebookBusy[cellId])
83
91
  return state;
84
92
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
85
- const _k = notebookBusy, _l = cellId, cellBusy = _k[_l], otherCells = __rest(_k, [typeof _l === "symbol" ? _l : _l + ""]);
93
+ const _m = notebookBusy, _o = cellId, cellBusy = _m[_o], otherCells = __rest(_m, [typeof _o === "symbol" ? _o : _o + ""]);
86
94
  // remove the render if it's empty
87
95
  if (Object.keys(otherCells).length === 0 && Object.keys(otherNotebooks).length === 0) {
88
96
  return Object.assign(Object.assign({}, state), { [kind]: otherRenders });
@@ -112,20 +120,55 @@ function reducer(state, action) {
112
120
  if (!((_e = state[kind][pageSlug]) === null || _e === void 0 ? void 0 : _e[notebookSlug]))
113
121
  return state;
114
122
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
115
- const _m = state[kind][pageSlug], _o = notebookSlug, notebookBusy = _m[_o], otherNotebooks = __rest(_m, [typeof _o === "symbol" ? _o : _o + ""]);
123
+ const _p = state[kind][pageSlug], _q = notebookSlug, notebookBusy = _p[_q], otherNotebooks = __rest(_p, [typeof _q === "symbol" ? _q : _q + ""]);
116
124
  if (Object.keys(otherNotebooks).length === 0) {
117
125
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
118
- const _p = state[kind], _q = pageSlug, renderBusy = _p[_q], otherRenders = __rest(_p, [typeof _q === "symbol" ? _q : _q + ""]);
126
+ const _r = state[kind], _s = pageSlug, renderBusy = _r[_s], otherRenders = __rest(_r, [typeof _s === "symbol" ? _s : _s + ""]);
119
127
  return Object.assign(Object.assign({}, state), { [kind]: otherRenders });
120
128
  }
121
129
  return Object.assign(Object.assign({}, state), { [kind]: Object.assign(Object.assign({}, state[kind]), { [pageSlug]: Object.assign({}, otherNotebooks) }) });
122
130
  }
131
+ case 'SET_ERROR': {
132
+ if (!isErrorPayload(action.payload)) {
133
+ console.error('SET_ERROR payload must be an error payload', action.payload);
134
+ return state;
135
+ }
136
+ const { pageSlug, notebookSlug, errors } = action.payload;
137
+ if (!errors) {
138
+ console.error('SET_ERROR payload must have errors', action.payload);
139
+ return state;
140
+ }
141
+ if (state.error[pageSlug])
142
+ return state;
143
+ if ((_f = state.error[pageSlug]) === null || _f === void 0 ? void 0 : _f[notebookSlug])
144
+ return state;
145
+ return Object.assign(Object.assign({}, state), { error: Object.assign(Object.assign({}, state.error), { [pageSlug]: Object.assign(Object.assign({}, state.error[pageSlug]), { [notebookSlug]: errors }) }) });
146
+ }
147
+ case 'CLEAR_ERROR': {
148
+ if (!isErrorPayload(action.payload)) {
149
+ console.error('CLEAR_ERROR payload must be a error payload', action.payload);
150
+ return state;
151
+ }
152
+ const { pageSlug, notebookSlug } = action.payload;
153
+ if (!state.error[pageSlug])
154
+ return state;
155
+ if (!((_g = state.error[pageSlug]) === null || _g === void 0 ? void 0 : _g[notebookSlug]))
156
+ return state;
157
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
+ const _t = state.error[pageSlug], _u = notebookSlug, notebookErrors = _t[_u], otherNotebooks = __rest(_t, [typeof _u === "symbol" ? _u : _u + ""]);
159
+ if (Object.keys(otherNotebooks).length > 0) {
160
+ return Object.assign(Object.assign({}, state), { error: Object.assign(Object.assign({}, state.error), { [pageSlug]: Object.assign({}, otherNotebooks) }) });
161
+ }
162
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
163
+ const _v = state.error, _w = pageSlug, renderErrors = _v[_w], otherRenders = __rest(_v, [typeof _w === "symbol" ? _w : _w + ""]);
164
+ return Object.assign(Object.assign({}, state), { error: otherRenders });
165
+ }
123
166
  }
124
167
  return state;
125
168
  }
126
169
  exports.reducer = reducer;
127
170
  function BusyScopeProvider({ children }) {
128
- const [state, dispatch] = (0, react_1.useReducer)(reducer, { execute: {}, reset: {} });
171
+ const [state, dispatch] = (0, react_1.useReducer)(reducer, { execute: {}, reset: {}, error: {} });
129
172
  const memo = react_1.default.useMemo(() => ({ state, dispatch }), [state]);
130
173
  if (typeof window !== 'undefined') {
131
174
  window.busyScopeState = memo.state;
@@ -148,9 +191,43 @@ function useBusyScope() {
148
191
  const clearCell = (0, react_1.useCallback)((pageSlug, notebookSlug, cellId, kind) => dispatch({ type: 'CLEAR_CELL_BUSY', payload: { pageSlug, notebookSlug, cellId, kind } }), [dispatch]);
149
192
  const setNotebook = (0, react_1.useCallback)((pageSlug, notebookSlug, cellIds, kind) => dispatch({ type: 'SET_NOTEBOOK_BUSY', payload: { pageSlug, notebookSlug, cellIds, kind } }), [dispatch]);
150
193
  const clearNotebook = (0, react_1.useCallback)((pageSlug, notebookSlug, kind) => dispatch({ type: 'CLEAR_NOTEBOOK_BUSY', payload: { pageSlug, notebookSlug, kind } }), [dispatch]);
151
- return { cell, notebook, page, setCell, clearCell, setNotebook, clearNotebook };
194
+ const setError = (0, react_1.useCallback)((pageSlug, notebookSlug, errors) => dispatch({ type: 'SET_ERROR', payload: { pageSlug, notebookSlug, errors } }), [dispatch]);
195
+ const clearError = (0, react_1.useCallback)((pageSlug, notebookSlug) => dispatch({ type: 'CLEAR_ERROR', payload: { pageSlug, notebookSlug } }), [dispatch]);
196
+ return {
197
+ cell,
198
+ notebook,
199
+ page,
200
+ setCell,
201
+ clearCell,
202
+ setNotebook,
203
+ clearNotebook,
204
+ setError,
205
+ clearError,
206
+ };
152
207
  }
153
208
  exports.useBusyScope = useBusyScope;
209
+ function useBusyErrors(pageSlug) {
210
+ const context = react_1.default.useContext(BusyScopeContext);
211
+ if (context === undefined) {
212
+ throw new Error('useBusyScope must be used within a BusyScopeProvider');
213
+ }
214
+ const { state, dispatch } = context;
215
+ const clearErrors = () => {
216
+ Object.keys(state.error[pageSlug]).forEach((notebookSlug) => {
217
+ dispatch({ type: 'CLEAR_ERROR', payload: { pageSlug, notebookSlug } });
218
+ });
219
+ };
220
+ let items;
221
+ if (Object.keys(state.error).length > 0 && state.error[pageSlug]) {
222
+ items = Object.entries(state.error[pageSlug]).map(([notebookSlug, errors]) => ({
223
+ pageSlug,
224
+ notebookSlug,
225
+ errors,
226
+ }));
227
+ }
228
+ return { items, clearErrors };
229
+ }
230
+ exports.useBusyErrors = useBusyErrors;
154
231
  function selectCellIsBusy(state, pageSlug, notebookSlug, cellId, kind) {
155
232
  var _a, _b;
156
233
  return !!((_b = (_a = state[kind][pageSlug]) === null || _a === void 0 ? void 0 : _a[notebookSlug]) === null || _b === void 0 ? void 0 : _b[cellId]);
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { IdOrKey } from './types';
3
3
  import type { IThebeCell } from 'thebe-core';
4
- import { SourceFileKind } from 'myst-common';
4
+ import { SourceFileKind } from 'myst-spec-ext';
5
5
  export declare function useExecutionScope({ clearOutputsOnExecute, }?: {
6
6
  clearOutputsOnExecute?: boolean;
7
7
  }): {
@@ -10,6 +10,7 @@ export declare function useExecutionScope({ clearOutputsOnExecute, }?: {
10
10
  clearAll: (pageSlug: string) => void;
11
11
  resetAll: (pageSlug: string) => void;
12
12
  execute: (slug: string) => void;
13
+ canCompute: boolean;
13
14
  slug: string;
14
15
  state: import("./types").ExecuteScopeState;
15
16
  dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
@@ -31,6 +32,7 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
31
32
  notebookIsResetting: boolean;
32
33
  notebookIsBusy: boolean;
33
34
  executionCount: number | null | undefined;
35
+ canCompute: boolean;
34
36
  slug: string;
35
37
  state: import("./types").ExecuteScopeState;
36
38
  dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
@@ -42,7 +44,8 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
42
44
  * @param id
43
45
  * @returns
44
46
  */
45
- export declare function useCellExecution(id: IdOrKey): {
47
+ export declare function useCellExecution(id: IdOrKey, clearOutputsOnExecute?: boolean): {
48
+ canCompute: boolean;
46
49
  kind: SourceFileKind;
47
50
  ready: boolean;
48
51
  execute: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/execute/hooks.ts"],"names":[],"mappings":"AAAA,OA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,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAqB,UAAQ;;;;;;;;;;;EAgE1E;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO;;;;EAc/C;AAED,wBAAgB,iBAAiB,YAOhC"}
@@ -37,7 +37,7 @@ const react_1 = __importStar(require("react"));
37
37
  const provider_1 = require("./provider");
38
38
  const busy_1 = require("./busy");
39
39
  const thebe_react_1 = require("thebe-react");
40
- const myst_common_1 = require("myst-common");
40
+ const myst_spec_ext_1 = require("myst-spec-ext");
41
41
  const selectors_1 = require("./selectors");
42
42
  function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
43
43
  var _a;
@@ -60,7 +60,8 @@ function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
60
60
  const execute = (slug) => {
61
61
  // set busy
62
62
  Object.entries(state.pages[slug].scopes).forEach(([notebookSlug, { notebook }]) => {
63
- busy.setNotebook(slug, notebookSlug, notebook.cells.map((c) => c.id), 'execute');
63
+ busy.clearError(slug, notebookSlug);
64
+ busy.setNotebook(slug, notebookSlug, notebook.code.map((c) => c.id), 'execute');
64
65
  });
65
66
  if (clearOutputsOnExecute) {
66
67
  // clear all notebook cell outputs
@@ -104,7 +105,8 @@ function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
104
105
  const resetAll = (0, react_1.useCallback)((pageSlug) => {
105
106
  var _a;
106
107
  Object.entries((_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes).forEach(([notebookSlug, { notebook, session }]) => {
107
- busy.setNotebook(pageSlug, notebookSlug, notebook.cells.map((c) => c.id), 'reset');
108
+ busy.clearError(pageSlug, notebookSlug);
109
+ busy.setNotebook(pageSlug, notebookSlug, notebook.code.map((c) => c.id), 'reset');
108
110
  setTimeout(() => {
109
111
  var _a;
110
112
  notebook.reset();
@@ -153,8 +155,9 @@ function useNotebookExecution(id, clearOutputsOnExecute = false) {
153
155
  }
154
156
  const execute = () => {
155
157
  const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
158
+ busy.clearError(pageSlug, notebookSlug);
156
159
  // set busy
157
- busy.setNotebook(pageSlug, notebookSlug, nb.cells.map((c) => c.id), 'execute');
160
+ busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'execute');
158
161
  if (clearOutputsOnExecute)
159
162
  nb.clear();
160
163
  // let busy state update prior to launching execute
@@ -169,8 +172,11 @@ function useNotebookExecution(id, clearOutputsOnExecute = false) {
169
172
  // execute all cells on the notebooks
170
173
  const execReturns = yield nb.executeAll(true);
171
174
  const errs = (0, thebe_react_1.findErrors)(execReturns);
172
- if (errs != null)
173
- console.error('errors', errs); // TODO: handle errors
175
+ if (errs != null) {
176
+ console.error('an error occurred during notebook execution');
177
+ busy.setError(pageSlug, notebookSlug, errs);
178
+ busy.clearNotebook(pageSlug, notebookSlug, 'execute');
179
+ }
174
180
  config === null || config === void 0 ? void 0 : config.events.off('status', handler);
175
181
  }), 100);
176
182
  };
@@ -187,7 +193,8 @@ function useNotebookExecution(id, clearOutputsOnExecute = false) {
187
193
  */
188
194
  const reset = (0, react_1.useCallback)(() => {
189
195
  const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
190
- busy.setNotebook(pageSlug, notebookSlug, nb.cells.map((c) => c.id), 'reset');
196
+ busy.clearError(pageSlug, notebookSlug);
197
+ busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'reset');
191
198
  setTimeout(() => {
192
199
  var _a, _b;
193
200
  nb.reset();
@@ -215,7 +222,7 @@ exports.useNotebookExecution = useNotebookExecution;
215
222
  * @param id
216
223
  * @returns
217
224
  */
218
- function useCellExecution(id) {
225
+ function useCellExecution(id, clearOutputsOnExecute = false) {
219
226
  var _a, _b, _c, _d;
220
227
  const busy = (0, busy_1.useBusyScope)();
221
228
  const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
@@ -233,7 +240,7 @@ function useCellExecution(id) {
233
240
  cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
234
241
  }
235
242
  const ready = (_b = context.state.pages[context.slug]) === null || _b === void 0 ? void 0 : _b.ready;
236
- const kind = (_d = (_c = context.state.pages[context.slug]) === null || _c === void 0 ? void 0 : _c.kind) !== null && _d !== void 0 ? _d : myst_common_1.SourceFileKind.Article;
243
+ const kind = (_d = (_c = context.state.pages[context.slug]) === null || _c === void 0 ? void 0 : _c.kind) !== null && _d !== void 0 ? _d : myst_spec_ext_1.SourceFileKind.Article;
237
244
  const execute = (0, react_1.useCallback)(() => {
238
245
  if (!cell) {
239
246
  console.error('no cell found on execute', { pageSlug, notebookSlug, cellId });
@@ -241,7 +248,8 @@ function useCellExecution(id) {
241
248
  }
242
249
  // set busy
243
250
  busy.setCell(pageSlug, notebookSlug, cell.id, 'execute');
244
- cell.clear();
251
+ if (clearOutputsOnExecute)
252
+ cell.clear();
245
253
  // let busy state update prior to launching execute
246
254
  setTimeout(() => {
247
255
  if (!cell)
@@ -264,6 +272,7 @@ function useCellExecution(id) {
264
272
  const notebookIsResetting = busy.notebook(pageSlug, notebookSlug, 'reset');
265
273
  const notebookIsBusy = notebookIsExecuting || notebookIsResetting;
266
274
  return {
275
+ canCompute: context.canCompute,
267
276
  kind,
268
277
  ready,
269
278
  execute,
@@ -1,10 +1,12 @@
1
- import type { Dependency } from 'myst-common';
2
- import { SourceFileKind } from 'myst-common';
1
+ import type { Dependency } from 'myst-spec-ext';
2
+ import { SourceFileKind } from 'myst-spec-ext';
3
3
  import type { Root } from 'mdast';
4
4
  import React from 'react';
5
5
  import type { ExecuteScopeAction } from './actions';
6
6
  import type { ExecuteScopeState, IdKeyMap } from './types';
7
+ import type { Thebe } from 'myst-frontmatter';
7
8
  export interface ExecuteScopeType {
9
+ canCompute: boolean;
8
10
  slug: string;
9
11
  state: ExecuteScopeState;
10
12
  dispatch: React.Dispatch<ExecuteScopeAction>;
@@ -16,6 +18,9 @@ type ArticleContents = {
16
18
  kind: SourceFileKind;
17
19
  mdast: Root;
18
20
  dependencies?: Dependency[];
21
+ frontmatter: {
22
+ thebe?: boolean | Thebe;
23
+ };
19
24
  };
20
25
  /**
21
26
  * The ExecuteScopeProvider is responsible for maintaining the state of the
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;CAC7B,CAAC;AA8DF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC,2CAgGxD"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AASvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG9C,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,WAAW,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE,CAAC;CAC1C,CAAC;AA8DF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC,2CAiGxD"}
@@ -25,12 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ExecuteScopeProvider = exports.ExecuteScopeContext = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
- const myst_common_1 = require("myst-common");
28
+ const myst_spec_ext_1 = require("myst-spec-ext");
29
29
  const react_1 = __importStar(require("react"));
30
30
  const unist_util_select_1 = require("unist-util-select");
31
31
  const reducer_1 = require("./reducer");
32
32
  const selectors_1 = require("./selectors");
33
33
  const leaf_1 = require("./leaf");
34
+ const providers_1 = require("../providers");
34
35
  exports.ExecuteScopeContext = react_1.default.createContext(undefined);
35
36
  function useScopeNavigate({ contents: { slug, kind, mdast, dependencies }, state, dispatch, }) {
36
37
  (0, react_1.useEffect)(() => {
@@ -82,6 +83,7 @@ function useExecutionScopeFetcher({ slug, state, dispatch, }) {
82
83
  */
83
84
  function ExecuteScopeProvider({ children, contents, }) {
84
85
  var _a;
86
+ const canCompute = (0, providers_1.useCanCompute)(contents);
85
87
  // compute incoming for first render
86
88
  const computables = (0, unist_util_select_1.selectAll)('container > embed', contents.mdast).map((node) => {
87
89
  const { key, label, source } = node;
@@ -98,7 +100,7 @@ function ExecuteScopeProvider({ children, contents, }) {
98
100
  },
99
101
  pages: {
100
102
  [contents.slug]: {
101
- computable: computables.length > 0 || contents.kind === myst_common_1.SourceFileKind.Notebook,
103
+ computable: computables.length > 0 || contents.kind === myst_spec_ext_1.SourceFileKind.Notebook,
102
104
  kind: contents.kind,
103
105
  slug: contents.slug,
104
106
  dependencies: (_a = contents.dependencies) !== null && _a !== void 0 ? _a : [],
@@ -117,7 +119,7 @@ function ExecuteScopeProvider({ children, contents, }) {
117
119
  const fetchTargets = (0, selectors_1.selectDependenciesToFetch)(state);
118
120
  const notebookBuildTargets = (0, selectors_1.selectScopeNotebooksToBuild)(state);
119
121
  const sessionStartTargets = (0, selectors_1.selectSessionsToStart)(state);
120
- const memo = react_1.default.useMemo(() => ({ slug: contents.slug, state, dispatch, idkmap: idkmap.current }), [state, contents.slug]);
122
+ const memo = react_1.default.useMemo(() => ({ canCompute, slug: contents.slug, state, dispatch, idkmap: idkmap.current }), [state, contents.slug]);
121
123
  if (typeof window !== 'undefined') {
122
124
  window.executeScope = memo;
123
125
  }