@myst-theme/jupyter 0.0.2 → 0.1.22

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 (63) hide show
  1. package/dist/cjs/components.d.ts +0 -1
  2. package/dist/cjs/components.d.ts.map +1 -1
  3. package/dist/cjs/error.d.ts +0 -1
  4. package/dist/cjs/error.d.ts.map +1 -1
  5. package/dist/cjs/hooks.d.ts +0 -17
  6. package/dist/cjs/hooks.d.ts.map +1 -1
  7. package/dist/cjs/jupyter.d.ts +0 -1
  8. package/dist/cjs/jupyter.d.ts.map +1 -1
  9. package/dist/cjs/jupyter.js +25 -37
  10. package/dist/cjs/output.d.ts +0 -1
  11. package/dist/cjs/output.d.ts.map +1 -1
  12. package/dist/cjs/output.js +2 -1
  13. package/dist/cjs/safe.d.ts +0 -1
  14. package/dist/cjs/safe.d.ts.map +1 -1
  15. package/dist/cjs/stream.d.ts +0 -1
  16. package/dist/cjs/stream.d.ts.map +1 -1
  17. package/dist/cjs/thebe-provider.d.ts +7 -0
  18. package/dist/cjs/thebe-provider.d.ts.map +1 -0
  19. package/dist/cjs/thebe-provider.js +53 -0
  20. package/dist/esm/components.d.ts +0 -1
  21. package/dist/esm/components.d.ts.map +1 -1
  22. package/dist/esm/error.d.ts +0 -1
  23. package/dist/esm/error.d.ts.map +1 -1
  24. package/dist/esm/hooks.d.ts +0 -17
  25. package/dist/esm/hooks.d.ts.map +1 -1
  26. package/dist/esm/jupyter.d.ts +0 -1
  27. package/dist/esm/jupyter.d.ts.map +1 -1
  28. package/dist/esm/jupyter.js +26 -38
  29. package/dist/esm/output.d.ts +0 -1
  30. package/dist/esm/output.d.ts.map +1 -1
  31. package/dist/esm/output.js +2 -1
  32. package/dist/esm/safe.d.ts +0 -1
  33. package/dist/esm/safe.d.ts.map +1 -1
  34. package/dist/esm/stream.d.ts +0 -1
  35. package/dist/esm/stream.d.ts.map +1 -1
  36. package/dist/esm/thebe-provider.d.ts +7 -0
  37. package/dist/esm/thebe-provider.d.ts.map +1 -0
  38. package/dist/esm/thebe-provider.js +26 -0
  39. package/dist/types/components.d.ts +0 -1
  40. package/dist/types/components.d.ts.map +1 -1
  41. package/dist/types/error.d.ts +0 -1
  42. package/dist/types/error.d.ts.map +1 -1
  43. package/dist/types/hooks.d.ts +0 -17
  44. package/dist/types/hooks.d.ts.map +1 -1
  45. package/dist/types/jupyter.d.ts +0 -1
  46. package/dist/types/jupyter.d.ts.map +1 -1
  47. package/dist/types/output.d.ts +0 -1
  48. package/dist/types/output.d.ts.map +1 -1
  49. package/dist/types/safe.d.ts +0 -1
  50. package/dist/types/safe.d.ts.map +1 -1
  51. package/dist/types/stream.d.ts +0 -1
  52. package/dist/types/stream.d.ts.map +1 -1
  53. package/dist/types/thebe-provider.d.ts +7 -0
  54. package/dist/types/thebe-provider.d.ts.map +1 -0
  55. package/package.json +4 -4
  56. package/dist/cjs/selectors.d.ts +0 -10
  57. package/dist/cjs/selectors.d.ts.map +0 -1
  58. package/dist/cjs/selectors.js +0 -10
  59. package/dist/esm/selectors.d.ts +0 -10
  60. package/dist/esm/selectors.d.ts.map +0 -1
  61. package/dist/esm/selectors.js +0 -4
  62. package/dist/types/selectors.d.ts +0 -10
  63. package/dist/types/selectors.d.ts.map +0 -1
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const MaybeLongContent: ({ content, path, render, }: {
3
2
  content?: string | undefined;
4
3
  path?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,gBAAgB;;;sBAOT,MAAM,KAAK,WAAW;iBAUzC,CAAC;AAEF,eAAO,MAAM,aAAa;aAAqC,MAAM;iBAWpE,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;sBAOT,MAAM,KAAK,WAAW;iBAUzC,CAAC;AAEF,eAAO,MAAM,aAAa;aAAqC,MAAM;iBAWpE,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedErrorOutput } from 'nbtx';
3
2
  export default function Error({ output }: {
4
3
  output: MinifiedErrorOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,eAcxE"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,eAcxE"}
@@ -1,21 +1,4 @@
1
1
  import type { MinifiedOutput } from 'nbtx';
2
- /**
3
- * Truncation vs Summarization
4
- *
5
- * In Curvespace, we're decided to change our data structure for outputs to align it as
6
- * closely as possible with Jupyters nbformat.IOutput[] type, but in a way that still allows
7
- * us to truncate output content and push that to storage.
8
- *
9
- * This will be used only in the CLI and Curvespace initially but should be ported back to
10
- * the rest of the code base. This will mean
11
- *
12
- * - changing the DB schema
13
- * - migration
14
- * - changing API response
15
- * - changing the frontend
16
- * - changing the extension
17
- *
18
- */
19
2
  interface LongContent {
20
3
  content_type?: string;
21
4
  content: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAId;;;;;;;;;;;;;;;;GAgBG;AAEH,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,CAqCA;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa;;;EAapC"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAId,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,CAqCA;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa;;;EAapC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedOutput } from 'nbtx';
3
2
  export declare const NativeJupyterOutputs: ({ id, outputs, }: {
4
3
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAS3C,eAAO,MAAM,oBAAoB;QAI3B,MAAM;aACD,cAAc,EAAE;iBAoE1B,CAAC"}
1
+ {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAqB3C,eAAO,MAAM,oBAAoB;QAI3B,MAAM;aACD,cAAc,EAAE;iBA0B1B,CAAC"}
@@ -25,54 +25,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.NativeJupyterOutputs = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
- const react_1 = require("react");
29
- const hooks_1 = __importStar(require("./hooks"));
30
- const nanoid_1 = require("nanoid");
31
- const react_redux_1 = require("react-redux");
32
- const connect_1 = require("@curvenote/connect");
28
+ const react_1 = __importStar(require("react"));
29
+ const hooks_1 = require("./hooks");
33
30
  const nbtx_1 = require("nbtx");
34
- const outline_1 = require("@heroicons/react/24/outline");
35
31
  const convertImages_1 = require("./convertImages");
36
- const selectors_1 = require("./selectors");
37
- const PERCENT_OF_WINDOW = 0.9;
32
+ const thebe_provider_1 = require("./thebe-provider");
33
+ function OutputRenderer({ id, data, core }) {
34
+ const [cell] = (0, react_1.useState)(new core.PassiveCellRenderer(id));
35
+ const ref = (0, react_1.useRef)(null);
36
+ (0, react_1.useEffect)(() => {
37
+ cell.render(data);
38
+ }, [data, cell]);
39
+ (0, react_1.useEffect)(() => {
40
+ if (!ref.current)
41
+ return;
42
+ cell.attachToDOM(ref.current);
43
+ }, [ref]);
44
+ return (0, jsx_runtime_1.jsx)("div", { ref: ref });
45
+ }
46
+ const MemoOutputRenderer = react_1.default.memo(OutputRenderer);
38
47
  const NativeJupyterOutputs = ({ id, outputs, }) => {
39
- var _a;
40
- const windowSize = (0, hooks_1.default)();
48
+ const { core } = (0, thebe_provider_1.useThebeCore)();
41
49
  const { data, error } = (0, hooks_1.useFetchAnyTruncatedContent)(outputs);
42
- const [loading, setLoading] = (0, react_1.useState)(true);
43
- const [frameHeight, setFrameHeight] = (0, react_1.useState)(0);
44
- const [clamped, setClamped] = (0, react_1.useState)(false);
45
- const uid = (0, react_1.useMemo)(nanoid_1.nanoid, []);
46
- const { height } = (_a = (0, react_redux_1.useSelector)((state) => (0, selectors_1.selectIFrameHeight)(state, uid))) !== null && _a !== void 0 ? _a : {};
47
- const rendererReady = (0, react_redux_1.useSelector)((state) => (0, selectors_1.selectIFrameReady)(state, uid));
48
- const iframeRef = (0, react_1.useRef)(null);
50
+ const [loaded, setLoaded] = (0, react_1.useState)(false);
51
+ const [fullOutputs, setFullOutputs] = (0, react_1.useState)(null);
49
52
  (0, react_1.useEffect)(() => {
50
- if (iframeRef.current == null || !rendererReady || !data)
53
+ if (!data || loaded)
51
54
  return;
55
+ setLoaded(true);
52
56
  (0, convertImages_1.fetchAndEncodeOutputImages)(data).then((out) => {
53
57
  const compactOutputs = (0, nbtx_1.convertToIOutputs)(out, {});
54
- connect_1.host.commsDispatch(iframeRef.current, connect_1.actions.connectHostSendContent(uid, compactOutputs));
58
+ setFullOutputs(compactOutputs);
55
59
  });
56
- }, [id, iframeRef.current, rendererReady]);
57
- (0, react_1.useEffect)(() => {
58
- if (height == null)
59
- return;
60
- if (height > PERCENT_OF_WINDOW * windowSize.height) {
61
- setFrameHeight(PERCENT_OF_WINDOW * windowSize.height);
62
- setClamped(true);
63
- }
64
- else {
65
- setFrameHeight(height + 25);
66
- setClamped(false);
67
- }
68
- setLoading(false);
69
- }, [height]);
60
+ }, [id, data]);
70
61
  if (error) {
71
62
  return (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "text-red-500" }, { children: ["Error rendering output: ", error.message] }));
72
63
  }
73
- return ((0, jsx_runtime_1.jsxs)("div", { children: [loading && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), (0, jsx_runtime_1.jsx)("iframe", { ref: iframeRef, id: uid, name: uid, title: uid, src: "https://next.curvenote.run", width: '100%', height: frameHeight, sandbox: "allow-scripts" }), clamped && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "cursor-pointer p-1 pb-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-center text-gray-500 hover:text-gray-600 dark:text-gray-200 dark:hover:text-gray-50", title: "Expand", onClick: () => {
74
- setFrameHeight(height !== null && height !== void 0 ? height : 0);
75
- setClamped(false);
76
- } }, { children: (0, jsx_runtime_1.jsx)(outline_1.ChevronDoubleDownIcon, { className: "w-5 h-5 inline" }) })))] }));
64
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [!fullOutputs && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && core && (0, jsx_runtime_1.jsx)(MemoOutputRenderer, { id: id, core: core, data: fullOutputs })] }));
77
65
  };
78
66
  exports.NativeJupyterOutputs = NativeJupyterOutputs;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { GenericNode } from 'myst-common';
3
2
  import type { MinifiedOutput } from 'nbtx';
4
3
  export declare function allOutputsAreSafe(outputs: MinifiedOutput[], directOutputTypes: Set<string>, directMimeTypes: Set<string>): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAgB/D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,eA6BvC"}
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAiB/D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,eA+BvC"}
@@ -10,6 +10,7 @@ const classnames_1 = __importDefault(require("classnames"));
10
10
  const safe_1 = require("./safe");
11
11
  const jupyter_1 = require("./jupyter");
12
12
  const ClientOnly_1 = __importDefault(require("./ClientOnly"));
13
+ const thebe_provider_1 = require("./thebe-provider");
13
14
  const DIRECT_OUTPUT_TYPES = new Set(['stream', 'error']);
14
15
  const DIRECT_MIME_TYPES = new Set([
15
16
  nbtx_1.KnownCellOutputMimeTypes.TextPlain,
@@ -40,7 +41,7 @@ function Output(node) {
40
41
  }
41
42
  else {
42
43
  // Hide the iframe if rendering on the server
43
- component = ((0, jsx_runtime_1.jsx)(ClientOnly_1.default, { children: (0, jsx_runtime_1.jsx)(jupyter_1.NativeJupyterOutputs, { id: node.key, outputs: outputs }) }));
44
+ component = ((0, jsx_runtime_1.jsx)(ClientOnly_1.default, { children: (0, jsx_runtime_1.jsx)(thebe_provider_1.ThebeCoreProvider, { children: (0, jsx_runtime_1.jsx)(jupyter_1.NativeJupyterOutputs, { id: node.key, outputs: outputs }) }) }));
44
45
  }
45
46
  return ((0, jsx_runtime_1.jsx)("figure", Object.assign({ id: node.identifier || undefined, className: (0, classnames_1.default)('max-w-full overflow-auto m-0 group not-prose relative', {
46
47
  'text-left': !node.align || node.align === 'left',
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedOutput } from 'nbtx';
3
2
  export declare function SafeOutputs({ keyStub, outputs }: {
4
3
  keyStub: string;
@@ -1 +1 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAA2C,cAAc,EAAE,MAAM,MAAM,CAAC;AAwEpF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,eAM/F"}
1
+ {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2C,cAAc,EAAE,MAAM,MAAM,CAAC;AAwEpF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,eAM/F"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedStreamOutput } from 'nbtx';
3
2
  export default function Stream({ output }: {
4
3
  output: MinifiedStreamOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,oBAAoB,CAAA;CAAE,eAY1E"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,oBAAoB,CAAA;CAAE,eAY1E"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export type ThebeCore = typeof import('thebe-core');
3
+ export declare function ThebeCoreProvider({ children }: React.PropsWithChildren): JSX.Element;
4
+ export declare function useThebeCore(): {
5
+ core?: typeof import("thebe-core") | undefined;
6
+ };
7
+ //# sourceMappingURL=thebe-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thebe-provider.d.ts","sourceRoot":"","sources":["../../src/thebe-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,MAAM,MAAM,SAAS,GAAG,cAAc,YAAY,CAAC,CAAC;AAKpD,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,eAoBtE;AAED,wBAAgB,YAAY;;EAM3B"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.useThebeCore = exports.ThebeCoreProvider = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = __importStar(require("react"));
29
+ // Don't know how to get rid of the undefined here in the case of an async provider
30
+ const ThebeCoreContext = react_1.default.createContext(undefined);
31
+ function ThebeCoreProvider({ children }) {
32
+ const [core, setCore] = (0, react_1.useState)();
33
+ (0, react_1.useEffect)(() => {
34
+ console.debug('importing thebe-core...');
35
+ Promise.resolve().then(() => __importStar(require('thebe-core'))).then((thebeCore) => {
36
+ console.debug('thebe-core loaded');
37
+ setCore(thebeCore);
38
+ })
39
+ .catch(({ reason }) => {
40
+ console.error(`thebe-core load failed ${reason}`);
41
+ });
42
+ }, []);
43
+ return ((0, jsx_runtime_1.jsx)(ThebeCoreContext.Provider, Object.assign({ value: { core } }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }) })));
44
+ }
45
+ exports.ThebeCoreProvider = ThebeCoreProvider;
46
+ function useThebeCore() {
47
+ const context = react_1.default.useContext(ThebeCoreContext);
48
+ if (context === undefined) {
49
+ throw new Error('useThebeCore must be used inside a ThebeCoreProvider');
50
+ }
51
+ return context;
52
+ }
53
+ exports.useThebeCore = useThebeCore;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const MaybeLongContent: ({ content, path, render, }: {
3
2
  content?: string | undefined;
4
3
  path?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,gBAAgB;;;sBAOT,MAAM,KAAK,WAAW;iBAUzC,CAAC;AAEF,eAAO,MAAM,aAAa;aAAqC,MAAM;iBAWpE,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;sBAOT,MAAM,KAAK,WAAW;iBAUzC,CAAC;AAEF,eAAO,MAAM,aAAa;aAAqC,MAAM;iBAWpE,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedErrorOutput } from 'nbtx';
3
2
  export default function Error({ output }: {
4
3
  output: MinifiedErrorOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,eAcxE"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,eAcxE"}
@@ -1,21 +1,4 @@
1
1
  import type { MinifiedOutput } from 'nbtx';
2
- /**
3
- * Truncation vs Summarization
4
- *
5
- * In Curvespace, we're decided to change our data structure for outputs to align it as
6
- * closely as possible with Jupyters nbformat.IOutput[] type, but in a way that still allows
7
- * us to truncate output content and push that to storage.
8
- *
9
- * This will be used only in the CLI and Curvespace initially but should be ported back to
10
- * the rest of the code base. This will mean
11
- *
12
- * - changing the DB schema
13
- * - migration
14
- * - changing API response
15
- * - changing the frontend
16
- * - changing the extension
17
- *
18
- */
19
2
  interface LongContent {
20
3
  content_type?: string;
21
4
  content: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAId;;;;;;;;;;;;;;;;GAgBG;AAEH,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,CAqCA;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa;;;EAapC"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAId,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,CAqCA;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa;;;EAapC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedOutput } from 'nbtx';
3
2
  export declare const NativeJupyterOutputs: ({ id, outputs, }: {
4
3
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAS3C,eAAO,MAAM,oBAAoB;QAI3B,MAAM;aACD,cAAc,EAAE;iBAoE1B,CAAC"}
1
+ {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAqB3C,eAAO,MAAM,oBAAoB;QAI3B,MAAM;aACD,cAAc,EAAE;iBA0B1B,CAAC"}
@@ -1,51 +1,39 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useRef, useState } from 'react';
3
- import useWindowSize, { useFetchAnyTruncatedContent } from './hooks';
4
- import { nanoid } from 'nanoid';
5
- import { useSelector } from 'react-redux';
6
- import { host, actions } from '@curvenote/connect';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ import { useFetchAnyTruncatedContent } from './hooks';
7
4
  import { convertToIOutputs } from 'nbtx';
8
- import { ChevronDoubleDownIcon } from '@heroicons/react/24/outline';
9
5
  import { fetchAndEncodeOutputImages } from './convertImages';
10
- import { selectIFrameHeight, selectIFrameReady } from './selectors';
11
- const PERCENT_OF_WINDOW = 0.9;
6
+ import { useThebeCore } from './thebe-provider';
7
+ function OutputRenderer({ id, data, core }) {
8
+ const [cell] = useState(new core.PassiveCellRenderer(id));
9
+ const ref = useRef(null);
10
+ useEffect(() => {
11
+ cell.render(data);
12
+ }, [data, cell]);
13
+ useEffect(() => {
14
+ if (!ref.current)
15
+ return;
16
+ cell.attachToDOM(ref.current);
17
+ }, [ref]);
18
+ return _jsx("div", { ref: ref });
19
+ }
20
+ const MemoOutputRenderer = React.memo(OutputRenderer);
12
21
  export const NativeJupyterOutputs = ({ id, outputs, }) => {
13
- var _a;
14
- const windowSize = useWindowSize();
22
+ const { core } = useThebeCore();
15
23
  const { data, error } = useFetchAnyTruncatedContent(outputs);
16
- const [loading, setLoading] = useState(true);
17
- const [frameHeight, setFrameHeight] = useState(0);
18
- const [clamped, setClamped] = useState(false);
19
- const uid = useMemo(nanoid, []);
20
- const { height } = (_a = useSelector((state) => selectIFrameHeight(state, uid))) !== null && _a !== void 0 ? _a : {};
21
- const rendererReady = useSelector((state) => selectIFrameReady(state, uid));
22
- const iframeRef = useRef(null);
24
+ const [loaded, setLoaded] = useState(false);
25
+ const [fullOutputs, setFullOutputs] = useState(null);
23
26
  useEffect(() => {
24
- if (iframeRef.current == null || !rendererReady || !data)
27
+ if (!data || loaded)
25
28
  return;
29
+ setLoaded(true);
26
30
  fetchAndEncodeOutputImages(data).then((out) => {
27
31
  const compactOutputs = convertToIOutputs(out, {});
28
- host.commsDispatch(iframeRef.current, actions.connectHostSendContent(uid, compactOutputs));
32
+ setFullOutputs(compactOutputs);
29
33
  });
30
- }, [id, iframeRef.current, rendererReady]);
31
- useEffect(() => {
32
- if (height == null)
33
- return;
34
- if (height > PERCENT_OF_WINDOW * windowSize.height) {
35
- setFrameHeight(PERCENT_OF_WINDOW * windowSize.height);
36
- setClamped(true);
37
- }
38
- else {
39
- setFrameHeight(height + 25);
40
- setClamped(false);
41
- }
42
- setLoading(false);
43
- }, [height]);
34
+ }, [id, data]);
44
35
  if (error) {
45
36
  return _jsxs("div", Object.assign({ className: "text-red-500" }, { children: ["Error rendering output: ", error.message] }));
46
37
  }
47
- return (_jsxs("div", { children: [loading && _jsx("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), _jsx("iframe", { ref: iframeRef, id: uid, name: uid, title: uid, src: "https://next.curvenote.run", width: '100%', height: frameHeight, sandbox: "allow-scripts" }), clamped && (_jsx("div", Object.assign({ className: "cursor-pointer p-1 pb-2 hover:bg-gray-50 dark:hover:bg-gray-700 text-center text-gray-500 hover:text-gray-600 dark:text-gray-200 dark:hover:text-gray-50", title: "Expand", onClick: () => {
48
- setFrameHeight(height !== null && height !== void 0 ? height : 0);
49
- setClamped(false);
50
- } }, { children: _jsx(ChevronDoubleDownIcon, { className: "w-5 h-5 inline" }) })))] }));
38
+ return (_jsxs("div", { children: [!fullOutputs && _jsx("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && core && _jsx(MemoOutputRenderer, { id: id, core: core, data: fullOutputs })] }));
51
39
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { GenericNode } from 'myst-common';
3
2
  import type { MinifiedOutput } from 'nbtx';
4
3
  export declare function allOutputsAreSafe(outputs: MinifiedOutput[], directOutputTypes: Set<string>, directMimeTypes: Set<string>): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAgB/D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,eA6BvC"}
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAiB/D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,eA+BvC"}
@@ -4,6 +4,7 @@ import classNames from 'classnames';
4
4
  import { SafeOutputs } from './safe';
5
5
  import { NativeJupyterOutputs as JupyterOutputs } from './jupyter';
6
6
  import ClientOnly from './ClientOnly';
7
+ import { ThebeCoreProvider } from './thebe-provider';
7
8
  const DIRECT_OUTPUT_TYPES = new Set(['stream', 'error']);
8
9
  const DIRECT_MIME_TYPES = new Set([
9
10
  KnownCellOutputMimeTypes.TextPlain,
@@ -33,7 +34,7 @@ export function Output(node) {
33
34
  }
34
35
  else {
35
36
  // Hide the iframe if rendering on the server
36
- component = (_jsx(ClientOnly, { children: _jsx(JupyterOutputs, { id: node.key, outputs: outputs }) }));
37
+ component = (_jsx(ClientOnly, { children: _jsx(ThebeCoreProvider, { children: _jsx(JupyterOutputs, { id: node.key, outputs: outputs }) }) }));
37
38
  }
38
39
  return (_jsx("figure", Object.assign({ id: node.identifier || undefined, className: classNames('max-w-full overflow-auto m-0 group not-prose relative', {
39
40
  'text-left': !node.align || node.align === 'left',
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedOutput } from 'nbtx';
3
2
  export declare function SafeOutputs({ keyStub, outputs }: {
4
3
  keyStub: string;
@@ -1 +1 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAA2C,cAAc,EAAE,MAAM,MAAM,CAAC;AAwEpF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,eAM/F"}
1
+ {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2C,cAAc,EAAE,MAAM,MAAM,CAAC;AAwEpF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,eAM/F"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedStreamOutput } from 'nbtx';
3
2
  export default function Stream({ output }: {
4
3
  output: MinifiedStreamOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,oBAAoB,CAAA;CAAE,eAY1E"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,oBAAoB,CAAA;CAAE,eAY1E"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export type ThebeCore = typeof import('thebe-core');
3
+ export declare function ThebeCoreProvider({ children }: React.PropsWithChildren): JSX.Element;
4
+ export declare function useThebeCore(): {
5
+ core?: typeof import("thebe-core") | undefined;
6
+ };
7
+ //# sourceMappingURL=thebe-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thebe-provider.d.ts","sourceRoot":"","sources":["../../src/thebe-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,MAAM,MAAM,SAAS,GAAG,cAAc,YAAY,CAAC,CAAC;AAKpD,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,eAoBtE;AAED,wBAAgB,YAAY;;EAM3B"}
@@ -0,0 +1,26 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useEffect, useState } from 'react';
3
+ // Don't know how to get rid of the undefined here in the case of an async provider
4
+ const ThebeCoreContext = React.createContext(undefined);
5
+ export function ThebeCoreProvider({ children }) {
6
+ const [core, setCore] = useState();
7
+ useEffect(() => {
8
+ console.debug('importing thebe-core...');
9
+ import('thebe-core')
10
+ .then((thebeCore) => {
11
+ console.debug('thebe-core loaded');
12
+ setCore(thebeCore);
13
+ })
14
+ .catch(({ reason }) => {
15
+ console.error(`thebe-core load failed ${reason}`);
16
+ });
17
+ }, []);
18
+ return (_jsx(ThebeCoreContext.Provider, Object.assign({ value: { core } }, { children: _jsx(_Fragment, { children: children }) })));
19
+ }
20
+ export function useThebeCore() {
21
+ const context = React.useContext(ThebeCoreContext);
22
+ if (context === undefined) {
23
+ throw new Error('useThebeCore must be used inside a ThebeCoreProvider');
24
+ }
25
+ return context;
26
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const MaybeLongContent: ({ content, path, render, }: {
3
2
  content?: string | undefined;
4
3
  path?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,gBAAgB;;;sBAOT,MAAM,KAAK,WAAW;iBAUzC,CAAC;AAEF,eAAO,MAAM,aAAa;aAAqC,MAAM;iBAWpE,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;sBAOT,MAAM,KAAK,WAAW;iBAUzC,CAAC;AAEF,eAAO,MAAM,aAAa;aAAqC,MAAM;iBAWpE,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedErrorOutput } from 'nbtx';
3
2
  export default function Error({ output }: {
4
3
  output: MinifiedErrorOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,eAcxE"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,eAcxE"}
@@ -1,21 +1,4 @@
1
1
  import type { MinifiedOutput } from 'nbtx';
2
- /**
3
- * Truncation vs Summarization
4
- *
5
- * In Curvespace, we're decided to change our data structure for outputs to align it as
6
- * closely as possible with Jupyters nbformat.IOutput[] type, but in a way that still allows
7
- * us to truncate output content and push that to storage.
8
- *
9
- * This will be used only in the CLI and Curvespace initially but should be ported back to
10
- * the rest of the code base. This will mean
11
- *
12
- * - changing the DB schema
13
- * - migration
14
- * - changing API response
15
- * - changing the frontend
16
- * - changing the extension
17
- *
18
- */
19
2
  interface LongContent {
20
3
  content_type?: string;
21
4
  content: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAId;;;;;;;;;;;;;;;;GAgBG;AAEH,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,CAqCA;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa;;;EAapC"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,MAAM,CAAC;AAId,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA0BD,wBAAgB,cAAc,CAC5B,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GACX;IAAE,IAAI,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAQvC;AAuBD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG;IACtE,IAAI,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC;CACxB,CAqCA;AAUD,MAAM,CAAC,OAAO,UAAU,aAAa;;;EAapC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedOutput } from 'nbtx';
3
2
  export declare const NativeJupyterOutputs: ({ id, outputs, }: {
4
3
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAS3C,eAAO,MAAM,oBAAoB;QAI3B,MAAM;aACD,cAAc,EAAE;iBAoE1B,CAAC"}
1
+ {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAqB3C,eAAO,MAAM,oBAAoB;QAI3B,MAAM;aACD,cAAc,EAAE;iBA0B1B,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { GenericNode } from 'myst-common';
3
2
  import type { MinifiedOutput } from 'nbtx';
4
3
  export declare function allOutputsAreSafe(outputs: MinifiedOutput[], directOutputTypes: Set<string>, directMimeTypes: Set<string>): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAgB/D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,eA6BvC"}
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAiB/D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,eA+BvC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedOutput } from 'nbtx';
3
2
  export declare function SafeOutputs({ keyStub, outputs }: {
4
3
  keyStub: string;
@@ -1 +1 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAA2C,cAAc,EAAE,MAAM,MAAM,CAAC;AAwEpF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,eAM/F"}
1
+ {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2C,cAAc,EAAE,MAAM,MAAM,CAAC;AAwEpF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,eAM/F"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MinifiedStreamOutput } from 'nbtx';
3
2
  export default function Stream({ output }: {
4
3
  output: MinifiedStreamOutput;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,oBAAoB,CAAA;CAAE,eAY1E"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAGjD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,oBAAoB,CAAA;CAAE,eAY1E"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export type ThebeCore = typeof import('thebe-core');
3
+ export declare function ThebeCoreProvider({ children }: React.PropsWithChildren): JSX.Element;
4
+ export declare function useThebeCore(): {
5
+ core?: typeof import("thebe-core") | undefined;
6
+ };
7
+ //# sourceMappingURL=thebe-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thebe-provider.d.ts","sourceRoot":"","sources":["../../src/thebe-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,MAAM,MAAM,SAAS,GAAG,cAAc,YAAY,CAAC,CAAC;AAKpD,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,eAoBtE;AAED,wBAAgB,YAAY;;EAM3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myst-theme/jupyter",
3
- "version": "0.0.2",
3
+ "version": "0.1.22",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -19,22 +19,22 @@
19
19
  "build": "npm-run-all -l clean -p build:cjs build:esm build:types"
20
20
  },
21
21
  "dependencies": {
22
- "@curvenote/connect": "^0.0.7",
23
22
  "@headlessui/react": "^1.7.7",
24
23
  "@heroicons/react": "^2.0.13",
25
- "@myst-theme/providers": "^0.1.20",
24
+ "@myst-theme/providers": "^0.1.22",
26
25
  "@popperjs/core": "^2.11.6",
27
26
  "ansi-to-react": "^6.1.6",
28
27
  "buffer": "^6.0.3",
29
28
  "classnames": "^2.3.2",
30
29
  "myst-common": "^0.0.12",
31
- "myst-config": "^0.0.6",
30
+ "myst-config": "^0.0.7",
32
31
  "myst-spec": "^0.0.4",
33
32
  "nanoid": "^4.0.0",
34
33
  "nbtx": "^0.2.3",
35
34
  "react-popper": "^2.3.0",
36
35
  "react-syntax-highlighter": "^15.5.0",
37
36
  "swr": "^1.3.0",
37
+ "thebe-core": "^0.1.1",
38
38
  "unist-util-select": "^4.0.1"
39
39
  },
40
40
  "peerDependencies": {
@@ -1,10 +0,0 @@
1
- import type { HostState } from '@curvenote/connect';
2
- export interface State {
3
- app: HostState;
4
- }
5
- export declare const selectIFrameHeight: (state: State, id: string) => Pick<import("@curvenote/connect").HostStateItem, "height" | "width"> | undefined;
6
- export declare const selectIFrameReady: (state: State, id: string) => Boolean;
7
- export declare const selectIFrameSendFailed: (state: State, id: string) => false | {
8
- message: string | undefined;
9
- };
10
- //# sourceMappingURL=selectors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,SAAS,CAAC;CAChB;AAED,eAAO,MAAM,kBAAkB,UAAW,KAAK,MAAM,MAAM,qFACX,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAW,KAAK,MAAM,MAAM,YACT,CAAC;AAElD,eAAO,MAAM,sBAAsB,UAAW,KAAK,MAAM,MAAM;;CACb,CAAC"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selectIFrameSendFailed = exports.selectIFrameReady = exports.selectIFrameHeight = void 0;
4
- const connect_1 = require("@curvenote/connect");
5
- const selectIFrameHeight = (state, id) => connect_1.host.selectors.selectIFrameSize(state.app, id);
6
- exports.selectIFrameHeight = selectIFrameHeight;
7
- const selectIFrameReady = (state, id) => connect_1.host.selectors.selectIFrameReady(state.app, id);
8
- exports.selectIFrameReady = selectIFrameReady;
9
- const selectIFrameSendFailed = (state, id) => connect_1.host.selectors.selectIFrameFailed(state.app, id);
10
- exports.selectIFrameSendFailed = selectIFrameSendFailed;
@@ -1,10 +0,0 @@
1
- import type { HostState } from '@curvenote/connect';
2
- export interface State {
3
- app: HostState;
4
- }
5
- export declare const selectIFrameHeight: (state: State, id: string) => Pick<import("@curvenote/connect").HostStateItem, "height" | "width"> | undefined;
6
- export declare const selectIFrameReady: (state: State, id: string) => Boolean;
7
- export declare const selectIFrameSendFailed: (state: State, id: string) => false | {
8
- message: string | undefined;
9
- };
10
- //# sourceMappingURL=selectors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,SAAS,CAAC;CAChB;AAED,eAAO,MAAM,kBAAkB,UAAW,KAAK,MAAM,MAAM,qFACX,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAW,KAAK,MAAM,MAAM,YACT,CAAC;AAElD,eAAO,MAAM,sBAAsB,UAAW,KAAK,MAAM,MAAM;;CACb,CAAC"}
@@ -1,4 +0,0 @@
1
- import { host } from '@curvenote/connect';
2
- export const selectIFrameHeight = (state, id) => host.selectors.selectIFrameSize(state.app, id);
3
- export const selectIFrameReady = (state, id) => host.selectors.selectIFrameReady(state.app, id);
4
- export const selectIFrameSendFailed = (state, id) => host.selectors.selectIFrameFailed(state.app, id);
@@ -1,10 +0,0 @@
1
- import type { HostState } from '@curvenote/connect';
2
- export interface State {
3
- app: HostState;
4
- }
5
- export declare const selectIFrameHeight: (state: State, id: string) => Pick<import("@curvenote/connect").HostStateItem, "height" | "width"> | undefined;
6
- export declare const selectIFrameReady: (state: State, id: string) => Boolean;
7
- export declare const selectIFrameSendFailed: (state: State, id: string) => false | {
8
- message: string | undefined;
9
- };
10
- //# sourceMappingURL=selectors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,SAAS,CAAC;CAChB;AAED,eAAO,MAAM,kBAAkB,UAAW,KAAK,MAAM,MAAM,qFACX,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAW,KAAK,MAAM,MAAM,YACT,CAAC;AAElD,eAAO,MAAM,sBAAsB,UAAW,KAAK,MAAM,MAAM;;CACb,CAAC"}