@myst-theme/jupyter 0.3.2 → 0.3.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.
Files changed (176) hide show
  1. package/dist/cjs/ConnectionStatusTray.d.ts +2 -0
  2. package/dist/cjs/ConnectionStatusTray.d.ts.map +1 -0
  3. package/dist/cjs/ConnectionStatusTray.js +56 -0
  4. package/dist/cjs/ErrorTray.d.ts +5 -0
  5. package/dist/cjs/ErrorTray.d.ts.map +1 -0
  6. package/dist/cjs/ErrorTray.js +34 -0
  7. package/dist/cjs/controls/ArticleCellControls.d.ts +10 -0
  8. package/dist/cjs/controls/ArticleCellControls.d.ts.map +1 -0
  9. package/dist/cjs/controls/ArticleCellControls.js +33 -0
  10. package/dist/cjs/controls/Buttons.d.ts +47 -0
  11. package/dist/cjs/controls/Buttons.d.ts.map +1 -0
  12. package/dist/cjs/controls/Buttons.js +70 -0
  13. package/dist/cjs/controls/NotebookCellControls.d.ts +10 -0
  14. package/dist/cjs/controls/NotebookCellControls.d.ts.map +1 -0
  15. package/dist/cjs/controls/NotebookCellControls.js +27 -0
  16. package/dist/cjs/controls/NotebookToolbar.d.ts +4 -0
  17. package/dist/cjs/controls/NotebookToolbar.d.ts.map +1 -0
  18. package/dist/cjs/controls/NotebookToolbar.js +47 -0
  19. package/dist/cjs/controls/Spinner.d.ts +4 -0
  20. package/dist/cjs/controls/Spinner.d.ts.map +1 -0
  21. package/dist/cjs/controls/Spinner.js +8 -0
  22. package/dist/cjs/controls/index.d.ts +5 -0
  23. package/dist/cjs/controls/index.d.ts.map +1 -0
  24. package/dist/cjs/controls/index.js +20 -0
  25. package/dist/cjs/execute/actions.d.ts +55 -0
  26. package/dist/cjs/execute/actions.d.ts.map +1 -0
  27. package/dist/cjs/execute/actions.js +49 -0
  28. package/dist/cjs/execute/busy.d.ts +74 -0
  29. package/dist/cjs/execute/busy.d.ts.map +1 -0
  30. package/dist/cjs/execute/busy.js +182 -0
  31. package/dist/cjs/execute/hooks.d.ts +62 -0
  32. package/dist/cjs/execute/hooks.d.ts.map +1 -0
  33. package/dist/cjs/execute/hooks.js +308 -0
  34. package/dist/cjs/execute/index.d.ts +7 -0
  35. package/dist/cjs/execute/index.d.ts.map +1 -0
  36. package/dist/cjs/execute/index.js +22 -0
  37. package/dist/cjs/execute/leaf.d.ts +26 -0
  38. package/dist/cjs/execute/leaf.d.ts.map +1 -0
  39. package/dist/cjs/execute/leaf.js +154 -0
  40. package/dist/cjs/execute/provider.d.ts +29 -0
  41. package/dist/cjs/execute/provider.d.ts.map +1 -0
  42. package/dist/cjs/execute/provider.js +126 -0
  43. package/dist/cjs/execute/reducer.d.ts +4 -0
  44. package/dist/cjs/execute/reducer.d.ts.map +1 -0
  45. package/dist/cjs/execute/reducer.js +136 -0
  46. package/dist/cjs/execute/selectors.d.ts +22 -0
  47. package/dist/cjs/execute/selectors.d.ts.map +1 -0
  48. package/dist/cjs/execute/selectors.js +89 -0
  49. package/dist/cjs/execute/types.d.ts +49 -0
  50. package/dist/cjs/execute/types.d.ts.map +1 -0
  51. package/dist/cjs/execute/types.js +2 -0
  52. package/dist/cjs/execute/utils.d.ts +23 -0
  53. package/dist/cjs/execute/utils.d.ts.map +1 -0
  54. package/dist/cjs/execute/utils.js +62 -0
  55. package/dist/cjs/index.d.ts +4 -0
  56. package/dist/cjs/index.d.ts.map +1 -1
  57. package/dist/cjs/index.js +4 -0
  58. package/dist/cjs/jupyter.d.ts.map +1 -1
  59. package/dist/cjs/jupyter.js +19 -17
  60. package/dist/cjs/output.d.ts +1 -1
  61. package/dist/cjs/output.d.ts.map +1 -1
  62. package/dist/cjs/output.js +7 -4
  63. package/dist/cjs/providers.d.ts +1 -48
  64. package/dist/cjs/providers.d.ts.map +1 -1
  65. package/dist/cjs/providers.js +4 -155
  66. package/dist/cjs/safe.js +1 -1
  67. package/dist/esm/ConnectionStatusTray.d.ts +2 -0
  68. package/dist/esm/ConnectionStatusTray.d.ts.map +1 -0
  69. package/dist/esm/ConnectionStatusTray.js +52 -0
  70. package/dist/esm/ErrorTray.d.ts +5 -0
  71. package/dist/esm/ErrorTray.d.ts.map +1 -0
  72. package/dist/esm/ErrorTray.js +30 -0
  73. package/dist/esm/controls/ArticleCellControls.d.ts +10 -0
  74. package/dist/esm/controls/ArticleCellControls.d.ts.map +1 -0
  75. package/dist/esm/controls/ArticleCellControls.js +27 -0
  76. package/dist/esm/controls/Buttons.d.ts +47 -0
  77. package/dist/esm/controls/Buttons.d.ts.map +1 -0
  78. package/dist/esm/controls/Buttons.js +57 -0
  79. package/dist/esm/controls/NotebookCellControls.d.ts +10 -0
  80. package/dist/esm/controls/NotebookCellControls.d.ts.map +1 -0
  81. package/dist/esm/controls/NotebookCellControls.js +21 -0
  82. package/dist/esm/controls/NotebookToolbar.d.ts +4 -0
  83. package/dist/esm/controls/NotebookToolbar.d.ts.map +1 -0
  84. package/dist/esm/controls/NotebookToolbar.js +40 -0
  85. package/dist/esm/controls/Spinner.d.ts +4 -0
  86. package/dist/esm/controls/Spinner.d.ts.map +1 -0
  87. package/dist/esm/controls/Spinner.js +4 -0
  88. package/dist/esm/controls/index.d.ts +5 -0
  89. package/dist/esm/controls/index.d.ts.map +1 -0
  90. package/dist/esm/controls/index.js +4 -0
  91. package/dist/esm/execute/actions.d.ts +55 -0
  92. package/dist/esm/execute/actions.d.ts.map +1 -0
  93. package/dist/esm/execute/actions.js +38 -0
  94. package/dist/esm/execute/busy.d.ts +74 -0
  95. package/dist/esm/execute/busy.d.ts.map +1 -0
  96. package/dist/esm/execute/busy.js +150 -0
  97. package/dist/esm/execute/hooks.d.ts +62 -0
  98. package/dist/esm/execute/hooks.d.ts.map +1 -0
  99. package/dist/esm/execute/hooks.js +277 -0
  100. package/dist/esm/execute/index.d.ts +7 -0
  101. package/dist/esm/execute/index.d.ts.map +1 -0
  102. package/dist/esm/execute/index.js +6 -0
  103. package/dist/esm/execute/leaf.d.ts +26 -0
  104. package/dist/esm/execute/leaf.d.ts.map +1 -0
  105. package/dist/esm/execute/leaf.js +147 -0
  106. package/dist/esm/execute/provider.d.ts +29 -0
  107. package/dist/esm/execute/provider.d.ts.map +1 -0
  108. package/dist/esm/execute/provider.js +99 -0
  109. package/dist/esm/execute/reducer.d.ts +4 -0
  110. package/dist/esm/execute/reducer.d.ts.map +1 -0
  111. package/dist/esm/execute/reducer.js +132 -0
  112. package/dist/esm/execute/selectors.d.ts +22 -0
  113. package/dist/esm/execute/selectors.d.ts.map +1 -0
  114. package/dist/esm/execute/selectors.js +77 -0
  115. package/dist/esm/execute/types.d.ts +49 -0
  116. package/dist/esm/execute/types.d.ts.map +1 -0
  117. package/dist/esm/execute/types.js +1 -0
  118. package/dist/esm/execute/utils.d.ts +23 -0
  119. package/dist/esm/execute/utils.d.ts.map +1 -0
  120. package/dist/esm/execute/utils.js +58 -0
  121. package/dist/esm/index.d.ts +4 -0
  122. package/dist/esm/index.d.ts.map +1 -1
  123. package/dist/esm/index.js +4 -0
  124. package/dist/esm/jupyter.d.ts.map +1 -1
  125. package/dist/esm/jupyter.js +17 -15
  126. package/dist/esm/output.d.ts +1 -1
  127. package/dist/esm/output.d.ts.map +1 -1
  128. package/dist/esm/output.js +8 -5
  129. package/dist/esm/providers.d.ts +1 -48
  130. package/dist/esm/providers.d.ts.map +1 -1
  131. package/dist/esm/providers.js +2 -126
  132. package/dist/esm/safe.js +1 -1
  133. package/dist/types/ConnectionStatusTray.d.ts +2 -0
  134. package/dist/types/ConnectionStatusTray.d.ts.map +1 -0
  135. package/dist/types/ErrorTray.d.ts +5 -0
  136. package/dist/types/ErrorTray.d.ts.map +1 -0
  137. package/dist/types/controls/ArticleCellControls.d.ts +10 -0
  138. package/dist/types/controls/ArticleCellControls.d.ts.map +1 -0
  139. package/dist/types/controls/Buttons.d.ts +47 -0
  140. package/dist/types/controls/Buttons.d.ts.map +1 -0
  141. package/dist/types/controls/NotebookCellControls.d.ts +10 -0
  142. package/dist/types/controls/NotebookCellControls.d.ts.map +1 -0
  143. package/dist/types/controls/NotebookToolbar.d.ts +4 -0
  144. package/dist/types/controls/NotebookToolbar.d.ts.map +1 -0
  145. package/dist/types/controls/Spinner.d.ts +4 -0
  146. package/dist/types/controls/Spinner.d.ts.map +1 -0
  147. package/dist/types/controls/index.d.ts +5 -0
  148. package/dist/types/controls/index.d.ts.map +1 -0
  149. package/dist/types/execute/actions.d.ts +55 -0
  150. package/dist/types/execute/actions.d.ts.map +1 -0
  151. package/dist/types/execute/busy.d.ts +74 -0
  152. package/dist/types/execute/busy.d.ts.map +1 -0
  153. package/dist/types/execute/hooks.d.ts +62 -0
  154. package/dist/types/execute/hooks.d.ts.map +1 -0
  155. package/dist/types/execute/index.d.ts +7 -0
  156. package/dist/types/execute/index.d.ts.map +1 -0
  157. package/dist/types/execute/leaf.d.ts +26 -0
  158. package/dist/types/execute/leaf.d.ts.map +1 -0
  159. package/dist/types/execute/provider.d.ts +29 -0
  160. package/dist/types/execute/provider.d.ts.map +1 -0
  161. package/dist/types/execute/reducer.d.ts +4 -0
  162. package/dist/types/execute/reducer.d.ts.map +1 -0
  163. package/dist/types/execute/selectors.d.ts +22 -0
  164. package/dist/types/execute/selectors.d.ts.map +1 -0
  165. package/dist/types/execute/types.d.ts +49 -0
  166. package/dist/types/execute/types.d.ts.map +1 -0
  167. package/dist/types/execute/utils.d.ts +23 -0
  168. package/dist/types/execute/utils.d.ts.map +1 -0
  169. package/dist/types/index.d.ts +4 -0
  170. package/dist/types/index.d.ts.map +1 -1
  171. package/dist/types/jupyter.d.ts.map +1 -1
  172. package/dist/types/output.d.ts +1 -1
  173. package/dist/types/output.d.ts.map +1 -1
  174. package/dist/types/providers.d.ts +1 -48
  175. package/dist/types/providers.d.ts.map +1 -1
  176. package/package.json +9 -8
@@ -1,10 +1,12 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SourceFileKind } from 'myst-common';
2
3
  import { KnownCellOutputMimeTypes } from 'nbtx';
3
4
  import classNames from 'classnames';
4
5
  import { SafeOutputs } from './safe';
5
6
  import { JupyterOutputs } from './jupyter';
6
- import { useReadyToExecute } from './providers';
7
7
  import { useMemo } from 'react';
8
+ import { useCellExecution } from './execute';
9
+ import { ArticleResetNotebook, ArticleRunNotebook, ArticleStatusBadge, } from './controls/ArticleCellControls';
8
10
  export const DIRECT_OUTPUT_TYPES = new Set(['stream', 'error']);
9
11
  export const DIRECT_MIME_TYPES = new Set([
10
12
  KnownCellOutputMimeTypes.TextPlain,
@@ -26,7 +28,7 @@ export function allOutputsAreSafe(outputs, directOutputTypes, directMimeTypes) {
26
28
  }, true);
27
29
  }
28
30
  function JupyterOutput({ nodeKey, nodeType, identifier, data, align, }) {
29
- const ready = useReadyToExecute();
31
+ const { kind, ready } = useCellExecution(nodeKey);
30
32
  const outputs = data;
31
33
  const allSafe = useMemo(() => allOutputsAreSafe(outputs, DIRECT_OUTPUT_TYPES, DIRECT_MIME_TYPES), [outputs]);
32
34
  let component;
@@ -36,11 +38,12 @@ function JupyterOutput({ nodeKey, nodeType, identifier, data, align, }) {
36
38
  else {
37
39
  component = _jsx(JupyterOutputs, { id: nodeKey, outputs: outputs });
38
40
  }
39
- return (_jsx("figure", { id: identifier || undefined, "data-mdast-node-type": nodeType, "data-mdast-node-id": nodeKey, className: classNames('max-w-full overflow-visible m-0 group not-prose relative', {
41
+ const showControls = kind === SourceFileKind.Article;
42
+ return (_jsxs("figure", { id: identifier || undefined, "data-mdast-node-type": nodeType, "data-mdast-node-id": nodeKey, className: classNames('max-w-full overflow-visible m-0 group not-prose relative', {
40
43
  'text-left': !align || align === 'left',
41
44
  'text-center': align === 'center',
42
45
  'text-right': align === 'right',
43
- }), children: component }));
46
+ }), children: [showControls && (_jsx("div", { className: "sticky top-[60px]", children: _jsxs("div", { className: "absolute -top-[28px] md:top-[30px] right-0 md:-right-[28px]", children: [_jsx(ArticleStatusBadge, { id: nodeKey }), _jsx(ArticleRunNotebook, { id: nodeKey }), _jsx(ArticleResetNotebook, { id: nodeKey })] }) })), component] }));
44
47
  }
45
48
  export function Output(node) {
46
49
  // Note, NodeRenderer's can't have hooks in it directly!
@@ -1,8 +1,5 @@
1
- import type { GenericParent } from 'myst-common';
2
- import { SourceFileKind } from 'myst-common';
1
+ import type { SourceFileKind } from 'myst-common';
3
2
  import React from 'react';
4
- import type { Config, IRenderMimeRegistry, IThebeCell, IThebeCellExecuteReturn, ThebeCore, ThebeNotebook } from 'thebe-core';
5
- import type { IThebeNotebookError, NotebookExecuteOptions } from 'thebe-react';
6
3
  import type { Root } from 'mdast';
7
4
  export declare function useComputeOptions(): {
8
5
  canCompute: boolean;
@@ -23,48 +20,4 @@ export type PartialPage = {
23
20
  slug: string;
24
21
  mdast: Root;
25
22
  };
26
- export declare function notebookFromMdast(core: ThebeCore, config: Config, mdast: GenericParent, idkMap: Record<string, string>, rendermime: IRenderMimeRegistry): ThebeNotebook;
27
- type IdKeyMap = Record<string, string>;
28
- interface NotebookContextType {
29
- kind: SourceFileKind;
30
- ready: boolean;
31
- attached: boolean;
32
- executing: boolean;
33
- executed: boolean;
34
- errors: IThebeNotebookError[] | null;
35
- executeAll: (options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
36
- executeSome: (predicate: (cell: IThebeCell) => boolean, options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
37
- notebook: ThebeNotebook | undefined;
38
- idkMap: IdKeyMap;
39
- restart: () => Promise<void>;
40
- clear: () => void;
41
- }
42
- export declare function NotebookProvider({ siteConfig, page, children, }: React.PropsWithChildren<{
43
- siteConfig: boolean;
44
- page: PartialPage;
45
- }>): import("react/jsx-runtime").JSX.Element;
46
- export declare function useHasNotebookProvider(): boolean;
47
- export declare function useMDASTNotebook(): NotebookContextType | undefined;
48
- export declare function useNotebookExecution(): {
49
- ready: boolean;
50
- attached: boolean;
51
- executing: boolean;
52
- executed: boolean;
53
- errors: IThebeNotebookError[] | null;
54
- execute: (options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
55
- notebook: ThebeNotebook | undefined;
56
- clear: () => void;
57
- } | undefined;
58
- export declare function useReadyToExecute(): boolean;
59
- export declare function useNotebookCellExecution(id: string): {
60
- kind: SourceFileKind;
61
- ready: boolean;
62
- cell: IThebeCell | undefined;
63
- executing: boolean;
64
- notebookIsExecuting: boolean;
65
- execute: (options?: NotebookExecuteOptions) => Promise<(IThebeCellExecuteReturn | null)[]>;
66
- clear: () => void | undefined;
67
- notebook: ThebeNotebook;
68
- } | undefined;
69
- export {};
70
23
  //# 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,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,S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,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM;;;;;;wBAiBhB,sBAAsB;;;cAmBxD"}
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,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"}
@@ -1,16 +1,6 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { jsx as _jsx } from "react/jsx-runtime";
11
- import { SourceFileKind } from 'myst-common';
12
- import React, { useContext, useEffect, useRef, useState } from 'react';
13
- import { useThebeLoader, useRenderMimeRegistry, useNotebookBase, useThebeConfig, ThebeServerProvider, } from 'thebe-react';
2
+ import React from 'react';
3
+ import { ThebeServerProvider } from 'thebe-react';
14
4
  import { useSiteManifest } from '@myst-theme/providers';
15
5
  import { thebeFrontmatterToOptions } from './utils';
16
6
  export function useComputeOptions() {
@@ -39,117 +29,3 @@ export function ConfiguredThebeServerProvider({ children }) {
39
29
  const { thebe } = useComputeOptions();
40
30
  return (_jsx(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 }));
41
31
  }
42
- export function notebookFromMdast(core, config, mdast, idkMap, rendermime) {
43
- const notebook = new core.ThebeNotebook(mdast.key, config, rendermime);
44
- // no metadata included in mdast yet
45
- //Object.assign(notebook.metadata, ipynb.metadata);
46
- notebook.cells = mdast.children.map((block) => {
47
- var _a, _b, _c;
48
- if (block.type !== 'block')
49
- console.warn(`Unexpected block type ${block.type}`);
50
- if (block.children.length == 2 && block.children[0].type === 'code') {
51
- const [codeCell, output] = block.children;
52
- // use the block.key to identify the cell but maintain a mapping
53
- // to allow code or output keys to look up cells and refs
54
- idkMap[block.key] = block.key;
55
- idkMap[codeCell.key] = block.key;
56
- idkMap[output.key] = block.key;
57
- return new core.ThebeCell(block.key, notebook.id, (_a = codeCell.value) !== null && _a !== void 0 ? _a : '', config, (_b = block.data) !== null && _b !== void 0 ? _b : {}, notebook.rendermime);
58
- }
59
- else {
60
- // assume content - concatenate it
61
- // TODO inject cell metadata
62
- const cell = new core.ThebeNonExecutableCell(block.key, notebook.id, block.children.reduce((acc, child) => { var _a; return acc + '\n' + ((_a = child.value) !== null && _a !== void 0 ? _a : ''); }, ''), (_c = block.data) !== null && _c !== void 0 ? _c : {}, notebook.rendermime);
63
- return cell;
64
- }
65
- });
66
- return notebook;
67
- }
68
- const NotebookContext = React.createContext(undefined);
69
- export function NotebookProvider({ siteConfig, page, children, }) {
70
- // so at some point this gets the whole site config and can
71
- // be use to lookup notebooks and recover ThebeNotebooks that
72
- // can be used to execute notebook pages or blocks in articles
73
- const { core } = useThebeLoader();
74
- const { config } = useThebeConfig();
75
- const rendermime = useRenderMimeRegistry();
76
- const { ready, attached, executing, executed, errors, executeAll, executeSome, clear, session, notebook, setNotebook, } = useNotebookBase();
77
- const idkMap = useRef({});
78
- useEffect(() => {
79
- if (!core || !config)
80
- return;
81
- idkMap.current = {};
82
- if (page.kind === SourceFileKind.Notebook) {
83
- const nb = notebookFromMdast(core, config, page.mdast, idkMap.current, rendermime);
84
- setNotebook(nb);
85
- }
86
- else {
87
- // TODO will need do article relative notebook loading as appropriate once that is supported
88
- setNotebook(undefined);
89
- }
90
- }, [core, config, page]);
91
- return (_jsx(NotebookContext.Provider, { value: {
92
- kind: page.kind,
93
- ready,
94
- attached,
95
- executing,
96
- executed,
97
- errors,
98
- executeAll,
99
- executeSome,
100
- notebook,
101
- idkMap: idkMap.current,
102
- restart: () => { var _a; return (_a = session === null || session === void 0 ? void 0 : session.restart()) !== null && _a !== void 0 ? _a : Promise.resolve(); },
103
- clear,
104
- }, children: children }));
105
- }
106
- export function useHasNotebookProvider() {
107
- const notebookState = useContext(NotebookContext);
108
- return notebookState !== undefined;
109
- }
110
- export function useMDASTNotebook() {
111
- const notebookState = useContext(NotebookContext);
112
- return notebookState;
113
- }
114
- export function useNotebookExecution() {
115
- const notebookState = useContext(NotebookContext);
116
- if (!notebookState)
117
- return undefined;
118
- const { ready, attached, executing, executed, errors, executeAll, notebook, clear } = notebookState;
119
- return { ready, attached, executing, executed, errors, execute: executeAll, notebook, clear };
120
- }
121
- export function useReadyToExecute() {
122
- var _a;
123
- const notebookState = useContext(NotebookContext);
124
- return (_a = notebookState === null || notebookState === void 0 ? void 0 : notebookState.ready) !== null && _a !== void 0 ? _a : false;
125
- }
126
- export function useNotebookCellExecution(id) {
127
- // setup a cell only executing state
128
- const [executing, setExecuting] = useState(false);
129
- const notebookState = useContext(NotebookContext);
130
- if (!notebookState)
131
- return undefined;
132
- const { kind, ready, notebook, executing: notebookIsExecuting, executeSome, idkMap, } = notebookState;
133
- const cellId = idkMap[id];
134
- function execute(options) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- setExecuting(true);
137
- const execReturn = yield executeSome((cell) => cell.id === cellId, options);
138
- setExecuting(false);
139
- return execReturn;
140
- });
141
- }
142
- const cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
143
- return notebook
144
- ? {
145
- kind,
146
- ready,
147
- cell,
148
- executing,
149
- notebookIsExecuting,
150
- execute,
151
- clear: () => cell === null || cell === void 0 ? void 0 : cell.clear(),
152
- notebook,
153
- }
154
- : undefined;
155
- }
package/dist/esm/safe.js CHANGED
@@ -55,7 +55,7 @@ function SafeOutput({ output }) {
55
55
  if (image)
56
56
  return _jsx(OutputImage, { image: image, text: text });
57
57
  if (text)
58
- return (_jsx("div", { className: "whitespace-pre-wrap font-mono text-sm", children: _jsx(Ansi, { children: text.content }) }));
58
+ return (_jsx("div", { className: "font-mono text-sm whitespace-pre-wrap", children: _jsx(Ansi, { children: text.content }) }));
59
59
  return null;
60
60
  }
61
61
  default:
@@ -0,0 +1,2 @@
1
+ export declare function ConnectionStatusTray(): import("react/jsx-runtime").JSX.Element | null;
2
+ //# sourceMappingURL=ConnectionStatusTray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionStatusTray.d.ts","sourceRoot":"","sources":["../../src/ConnectionStatusTray.tsx"],"names":[],"mappings":"AAMA,wBAAgB,oBAAoB,mDAoFnC"}
@@ -0,0 +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;
5
+ //# sourceMappingURL=ErrorTray.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ export declare function ArticleStatusBadge({ id }: {
2
+ id: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
+ export declare function ArticleRunNotebook({ id }: {
5
+ id: string;
6
+ }): import("react/jsx-runtime").JSX.Element | null;
7
+ export declare function ArticleResetNotebook({ id }: {
8
+ id: string;
9
+ }): import("react/jsx-runtime").JSX.Element | null;
10
+ //# sourceMappingURL=ArticleCellControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArticleCellControls.d.ts","sourceRoot":"","sources":["../../../src/controls/ArticleCellControls.tsx"],"names":[],"mappings":"AAMA,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,2CAmBxD;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,kDAYxD;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,kDAY1D"}
@@ -0,0 +1,47 @@
1
+ export declare function SpinnerStatusButton({ ready, busy, modified, onClick, }: {
2
+ ready: boolean;
3
+ modified: boolean;
4
+ busy: boolean;
5
+ onClick?: () => void;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ export declare function Run({ ready, executing, disabled, title, onClick, }: {
8
+ ready: boolean;
9
+ executing: boolean;
10
+ title?: string;
11
+ disabled?: boolean;
12
+ onClick: () => void;
13
+ }): import("react/jsx-runtime").JSX.Element;
14
+ export declare function Power({ ready, executing, disabled, title, onClick, }: {
15
+ ready: boolean;
16
+ executing: boolean;
17
+ title?: string;
18
+ disabled?: boolean;
19
+ onClick: () => void;
20
+ }): import("react/jsx-runtime").JSX.Element;
21
+ export declare function ReRun({ ready, executing, disabled, title, onClick, }: {
22
+ ready: boolean;
23
+ executing: boolean;
24
+ title?: string;
25
+ disabled?: boolean;
26
+ onClick: () => void;
27
+ }): import("react/jsx-runtime").JSX.Element;
28
+ export declare function Reset({ ready, resetting, disabled, title, onClick, }: {
29
+ ready: boolean;
30
+ resetting: boolean;
31
+ title?: string;
32
+ disabled?: boolean;
33
+ onClick: () => void;
34
+ }): import("react/jsx-runtime").JSX.Element;
35
+ export declare function Clear({ ready, disabled, title, onClick, }: {
36
+ ready: boolean;
37
+ disabled?: boolean;
38
+ title?: string;
39
+ onClick: () => void;
40
+ }): import("react/jsx-runtime").JSX.Element;
41
+ export declare function Launch({ ready, disabled, title, onClick, }: {
42
+ ready: boolean;
43
+ disabled?: boolean;
44
+ title?: string;
45
+ onClick: () => void;
46
+ }): import("react/jsx-runtime").JSX.Element;
47
+ //# sourceMappingURL=Buttons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Buttons.d.ts","sourceRoot":"","sources":["../../../src/controls/Buttons.tsx"],"names":[],"mappings":"AAWA,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,GACR,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,2CAuCA;AA2CD,wBAAgB,GAAG,CAAC,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAWA;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAWA;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAWA;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAWA;AAED,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAeA;AAED,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,2CAYA"}
@@ -0,0 +1,10 @@
1
+ export declare function NotebookRunCell({ id }: {
2
+ id: string;
3
+ }): import("react/jsx-runtime").JSX.Element | null;
4
+ export declare function NotebookRunCellSpinnerOnly({ id }: {
5
+ id: string;
6
+ }): import("react/jsx-runtime").JSX.Element | null;
7
+ export declare function NotebookClearCell({ id }: {
8
+ id: string;
9
+ }): import("react/jsx-runtime").JSX.Element | null;
10
+ //# sourceMappingURL=NotebookCellControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotebookCellControls.d.ts","sourceRoot":"","sources":["../../../src/controls/NotebookCellControls.tsx"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,kDAMrD;AAED,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,kDAYhE;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,kDAMvD"}
@@ -0,0 +1,4 @@
1
+ export declare function NotebookToolbar({ showLaunch }: {
2
+ showLaunch?: boolean;
3
+ }): import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=NotebookToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotebookToolbar.d.ts","sourceRoot":"","sources":["../../../src/controls/NotebookToolbar.tsx"],"names":[],"mappings":"AAaA,wBAAgB,eAAe,CAAC,EAAE,UAAkB,EAAE,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,kDA6F/E"}
@@ -0,0 +1,4 @@
1
+ export declare function Spinner({ size }: {
2
+ size: number;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=Spinner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../src/controls/Spinner.tsx"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,2CAsBjD"}
@@ -0,0 +1,5 @@
1
+ export * from './Buttons';
2
+ export * from './NotebookCellControls';
3
+ export * from './NotebookToolbar';
4
+ export * from './Spinner';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { Dependency, SourceFileKind } from 'myst-common';
2
+ import type { Root } from 'mdast';
3
+ import type { BuildStatus, Computable } from './types';
4
+ import type { IRenderMimeRegistry, ThebeNotebook, ThebeSession } from 'thebe-core';
5
+ export declare function isNavigatePayload(payload: unknown): payload is NavigatePayload;
6
+ interface NavigatePayload {
7
+ kind: SourceFileKind;
8
+ slug: string;
9
+ mdast: Root;
10
+ dependencies: Dependency[];
11
+ computables: Computable[];
12
+ }
13
+ export declare function isSlugPayload(payload: unknown): payload is SlugPayload;
14
+ interface SlugPayload {
15
+ slug: string;
16
+ }
17
+ export declare function isDoubleSlugPayload(payload: unknown): payload is DoubleSlugPayload;
18
+ interface DoubleSlugPayload {
19
+ pageSlug: string;
20
+ notebookSlug: string;
21
+ }
22
+ export declare function isBuildStatusPayload(payload: unknown): payload is BuildStatusPayload;
23
+ interface BuildStatusPayload {
24
+ slug: string;
25
+ status: BuildStatus;
26
+ }
27
+ export declare function isEnableScopePayload(payload: unknown): payload is EnableScopePayload;
28
+ interface EnableScopePayload {
29
+ renderingSlug: string;
30
+ scopeSlug: string;
31
+ }
32
+ export declare function isAddMdastPayload(payload: unknown): payload is AddMdastPayload;
33
+ interface AddMdastPayload {
34
+ slug: string;
35
+ mdast: Root;
36
+ }
37
+ export declare function isAddNotebookPayload(payload: unknown): payload is AddNotebookPayload;
38
+ interface AddNotebookPayload {
39
+ pageSlug: string;
40
+ notebookSlug: string;
41
+ notebook: ThebeNotebook;
42
+ rendermime: IRenderMimeRegistry;
43
+ }
44
+ export declare function isAddSessionPayload(payload: unknown): payload is AddSessionPayload;
45
+ interface AddSessionPayload {
46
+ pageSlug: string;
47
+ notebookSlug: string;
48
+ session: ThebeSession;
49
+ }
50
+ export interface ExecuteScopeAction {
51
+ type: 'NAVIGATE' | 'REQUEST_BUILD' | 'BUILD_STATUS' | 'CLEAR_BUILD' | 'ADD_MDAST' | 'ADD_NOTEBOOK' | 'ADD_SESSION' | 'SET_FIRST_EXECUTION' | 'SET_RENDERING_READY';
52
+ payload: NavigatePayload | SlugPayload | DoubleSlugPayload | BuildStatusPayload | AddMdastPayload | AddNotebookPayload | AddSessionPayload;
53
+ }
54
+ export {};
55
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +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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qBAAqB,CAAC;IAC1B,OAAO,EACH,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,kBAAkB,GAClB,eAAe,GACf,kBAAkB,GAClB,iBAAiB,CAAC;CACvB"}
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ export type BusyKind = 'execute' | 'reset';
3
+ export interface BusyScopeState {
4
+ execute: {
5
+ [pageSlug: string]: {
6
+ [notebookSlug: string]: {
7
+ [cellId: string]: boolean;
8
+ };
9
+ };
10
+ };
11
+ reset: {
12
+ [pageSlug: string]: {
13
+ [notebookSlug: string]: {
14
+ [cellId: string]: boolean;
15
+ };
16
+ };
17
+ };
18
+ }
19
+ export interface BusyScopeContext {
20
+ state: BusyScopeState;
21
+ dispatch: React.Dispatch<BusyScopeAction>;
22
+ }
23
+ export interface SlugPayload {
24
+ pageSlug: string;
25
+ notebookSlug: string;
26
+ kind: BusyKind;
27
+ }
28
+ export interface CellPayload {
29
+ pageSlug: string;
30
+ notebookSlug: string;
31
+ cellId: string;
32
+ kind: BusyKind;
33
+ }
34
+ export interface NotebookPayload {
35
+ pageSlug: string;
36
+ notebookSlug: string;
37
+ cellIds: string[];
38
+ kind: BusyKind;
39
+ }
40
+ type BusyScopeAction = {
41
+ type: 'SET_CELL_BUSY' | 'CLEAR_CELL_BUSY' | 'SET_NOTEBOOK_BUSY' | 'CLEAR_NOTEBOOK_BUSY';
42
+ payload: SlugPayload | CellPayload | NotebookPayload;
43
+ };
44
+ export declare function reducer(state: BusyScopeState, action: BusyScopeAction): BusyScopeState;
45
+ export declare function BusyScopeProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
46
+ export declare function useBusyScope(): {
47
+ cell: (pageSlug: string, notebookSlug: string, cellId: string, kind: BusyKind) => boolean;
48
+ notebook: (pageSlug: string, notebookSlug: string, kind: BusyKind) => boolean;
49
+ page: (pageSlug: string, kind: BusyKind) => boolean;
50
+ setCell: (pageSlug: string, notebookSlug: string, cellId: string, kind: BusyKind) => void;
51
+ clearCell: (pageSlug: string, notebookSlug: string, cellId: string, kind: BusyKind) => void;
52
+ setNotebook: (pageSlug: string, notebookSlug: string, cellIds: string[], kind: BusyKind) => void;
53
+ clearNotebook: (pageSlug: string, notebookSlug: string, kind: BusyKind) => void;
54
+ };
55
+ export declare function selectCellIsBusy(state: BusyScopeState, pageSlug: string, notebookSlug: string, cellId: string, kind: BusyKind): boolean;
56
+ /**
57
+ * a fast selector relying on the fact that if at least one cell is present, the notebook is busy
58
+ *
59
+ * @param state
60
+ * @param pageSlug
61
+ * @param notebookSlug
62
+ * @returns
63
+ */
64
+ export declare function selectNotebookIsBusy(state: BusyScopeState, pageSlug: string, notebookSlug: string, kind: BusyKind): boolean;
65
+ /**
66
+ * a fast selector relying on the fact that if at least one notebook is present, the render is busy
67
+ *
68
+ * @param state
69
+ * @param pageSlug
70
+ * @returns
71
+ */
72
+ export declare function selectPageIsBusy(state: BusyScopeState, pageSlug: string, kind: BusyKind): boolean;
73
+ export {};
74
+ //# sourceMappingURL=busy.d.ts.map
@@ -0,0 +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,CAAC;KACH,CAAC;IACF,KAAK,EAAE;QACL,CAAC,QAAQ,EAAE,MAAM,GAAG;YAClB,CAAC,YAAY,EAAE,MAAM,GAAG;gBACtB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;aAC3B,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/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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"}
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import type { IdOrKey } from './types';
3
+ import type { IThebeCell } from 'thebe-core';
4
+ import { SourceFileKind } from 'myst-common';
5
+ export declare function useExecutionScope({ clearOutputsOnExecute, }?: {
6
+ clearOutputsOnExecute?: boolean;
7
+ }): {
8
+ ready: boolean;
9
+ start: (slug: string) => void;
10
+ clearAll: (pageSlug: string) => void;
11
+ resetAll: (pageSlug: string) => void;
12
+ execute: (slug: string) => void;
13
+ slug: string;
14
+ state: import("./types").ExecuteScopeState;
15
+ dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
16
+ idkmap: import("./types").IdKeyMap;
17
+ };
18
+ /**
19
+ * useNotebookExecution a hook to govern notebook execution in the context of a single
20
+ * cell embedded in an article
21
+ *
22
+ */
23
+ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?: boolean): {
24
+ ready: boolean;
25
+ start: () => void;
26
+ clear: () => void;
27
+ reset: () => void;
28
+ execute: () => void;
29
+ cellIsExecuting: boolean;
30
+ notebookIsExecuting: boolean;
31
+ notebookIsResetting: boolean;
32
+ notebookIsBusy: boolean;
33
+ executionCount: number | null | undefined;
34
+ slug: string;
35
+ state: import("./types").ExecuteScopeState;
36
+ dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
37
+ idkmap: import("./types").IdKeyMap;
38
+ };
39
+ /**
40
+ * useCellExecution a hook to govern the execute status and actions for a single cell
41
+ *
42
+ * @param id
43
+ * @returns
44
+ */
45
+ export declare function useCellExecution(id: IdOrKey): {
46
+ kind: SourceFileKind;
47
+ ready: boolean;
48
+ execute: () => void;
49
+ clear: () => void;
50
+ cellIsExecuting: boolean;
51
+ notebookIsExecuting: boolean;
52
+ notebookIsResetting: boolean;
53
+ notebookIsBusy: boolean;
54
+ cell: IThebeCell | undefined;
55
+ };
56
+ export declare function useIsAComputableCell(id: IdOrKey): {
57
+ slug: string;
58
+ computable: boolean;
59
+ ready: boolean;
60
+ };
61
+ export declare function useReadyToExecute(): boolean;
62
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/execute/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAA0C,MAAM,YAAY,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,iBAAiB,CAAC,EAChC,qBAA6B,GAC9B,GAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO;;kBAUR,MAAM;yBAsD1B,MAAM;yBAYN,MAAM;oBAxDI,MAAM;;;;;EAgF9B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAqB,UAAQ;;;;;;;;;;;;;;;EA4G9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO;;;;;;;;;;EAiE3C;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO;;;;EAc/C;AAED,wBAAgB,iBAAiB,YAOhC"}
@@ -0,0 +1,7 @@
1
+ export * from './hooks';
2
+ export * from './actions';
3
+ export * from './provider';
4
+ export * from './selectors';
5
+ export * from './types';
6
+ export * from './busy';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execute/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import type { ExecuteScopeAction } from './actions';
3
+ import type { IdKeyMap, ExecuteScopeState } from './types';
4
+ export declare function MdastFetcher({ slug, url, dispatch, }: {
5
+ slug: string;
6
+ url: string;
7
+ dispatch: React.Dispatch<ExecuteScopeAction>;
8
+ }): import("react/jsx-runtime").JSX.Element | null;
9
+ export declare function NotebookBuilder({ pageSlug, notebookSlug, idkmap, state, dispatch, }: {
10
+ pageSlug: string;
11
+ notebookSlug: string;
12
+ idkmap: IdKeyMap;
13
+ state: ExecuteScopeState;
14
+ dispatch: React.Dispatch<ExecuteScopeAction>;
15
+ }): null;
16
+ export declare function SessionStarter({ pageSlug, notebookSlug, state, dispatch, }: {
17
+ pageSlug: string;
18
+ notebookSlug: string;
19
+ state: ExecuteScopeState;
20
+ dispatch: React.Dispatch<ExecuteScopeAction>;
21
+ }): null;
22
+ export declare function ServerMonitor({ state, dispatch, }: {
23
+ state: ExecuteScopeState;
24
+ dispatch: React.Dispatch<ExecuteScopeAction>;
25
+ }): null;
26
+ //# sourceMappingURL=leaf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaf.d.ts","sourceRoot":"","sources":["../../../src/execute/leaf.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAO3D,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,GAAG,EACH,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,kDAkBA;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QA8CA;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QAoEA;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QA4BA"}