@myst-theme/jupyter 0.1.35 → 0.1.37

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 (56) hide show
  1. package/dist/cjs/BinderBadge.d.ts +4 -0
  2. package/dist/cjs/BinderBadge.d.ts.map +1 -0
  3. package/dist/cjs/BinderBadge.js +13 -0
  4. package/dist/cjs/ClientOnly.d.ts +1 -1
  5. package/dist/cjs/ClientOnly.d.ts.map +1 -1
  6. package/dist/cjs/ClientOnly.js +2 -1
  7. package/dist/cjs/index.d.ts +2 -0
  8. package/dist/cjs/index.d.ts.map +1 -1
  9. package/dist/cjs/index.js +16 -0
  10. package/dist/cjs/jupyter.d.ts +1 -1
  11. package/dist/cjs/jupyter.d.ts.map +1 -1
  12. package/dist/cjs/jupyter.js +41 -12
  13. package/dist/cjs/output.d.ts.map +1 -1
  14. package/dist/cjs/output.js +5 -6
  15. package/dist/cjs/providers.d.ts +67 -0
  16. package/dist/cjs/providers.d.ts.map +1 -0
  17. package/dist/cjs/providers.js +232 -0
  18. package/dist/cjs/safe.js +1 -1
  19. package/dist/esm/BinderBadge.d.ts +4 -0
  20. package/dist/esm/BinderBadge.d.ts.map +1 -0
  21. package/dist/esm/BinderBadge.js +9 -0
  22. package/dist/esm/ClientOnly.d.ts +1 -1
  23. package/dist/esm/ClientOnly.d.ts.map +1 -1
  24. package/dist/esm/ClientOnly.js +1 -1
  25. package/dist/esm/index.d.ts +2 -0
  26. package/dist/esm/index.d.ts.map +1 -1
  27. package/dist/esm/index.js +2 -0
  28. package/dist/esm/jupyter.d.ts +1 -1
  29. package/dist/esm/jupyter.d.ts.map +1 -1
  30. package/dist/esm/jupyter.js +40 -11
  31. package/dist/esm/output.d.ts.map +1 -1
  32. package/dist/esm/output.js +6 -7
  33. package/dist/esm/providers.d.ts +67 -0
  34. package/dist/esm/providers.d.ts.map +1 -0
  35. package/dist/esm/providers.js +197 -0
  36. package/dist/esm/safe.js +1 -1
  37. package/dist/types/BinderBadge.d.ts +4 -0
  38. package/dist/types/BinderBadge.d.ts.map +1 -0
  39. package/dist/types/ClientOnly.d.ts +1 -1
  40. package/dist/types/ClientOnly.d.ts.map +1 -1
  41. package/dist/types/index.d.ts +2 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/jupyter.d.ts +1 -1
  44. package/dist/types/jupyter.d.ts.map +1 -1
  45. package/dist/types/output.d.ts.map +1 -1
  46. package/dist/types/providers.d.ts +67 -0
  47. package/dist/types/providers.d.ts.map +1 -0
  48. package/package.json +7 -6
  49. package/dist/cjs/thebe-provider.d.ts +0 -7
  50. package/dist/cjs/thebe-provider.d.ts.map +0 -1
  51. package/dist/cjs/thebe-provider.js +0 -53
  52. package/dist/esm/thebe-provider.d.ts +0 -7
  53. package/dist/esm/thebe-provider.d.ts.map +0 -1
  54. package/dist/esm/thebe-provider.js +0 -26
  55. package/dist/types/thebe-provider.d.ts +0 -7
  56. package/dist/types/thebe-provider.d.ts.map +0 -1
@@ -0,0 +1,4 @@
1
+ export declare function BinderBadge({ binder }: {
2
+ binder?: string;
3
+ }): JSX.Element | null;
4
+ //# sourceMappingURL=BinderBadge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BinderBadge.d.ts","sourceRoot":"","sources":["../../src/BinderBadge.tsx"],"names":[],"mappings":"AA2DA,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,sBAe1D"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BinderBadge = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ function BinderBadgeLogo() {
6
+ return ((0, jsx_runtime_1.jsxs)("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "109", height: "20" }, { children: [(0, jsx_runtime_1.jsxs)("linearGradient", Object.assign({ id: "b", x2: "0", y2: "100%" }, { children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0", stopColor: "#bbb", stopOpacity: ".1" }), (0, jsx_runtime_1.jsx)("stop", { offset: "1", stopOpacity: ".1" })] })), (0, jsx_runtime_1.jsx)("clipPath", Object.assign({ id: "a" }, { children: (0, jsx_runtime_1.jsx)("rect", { width: "109", height: "20", fill: "#fff", rx: "3" }) })), (0, jsx_runtime_1.jsxs)("g", Object.assign({ clipPath: "url(#a)" }, { children: [(0, jsx_runtime_1.jsx)("path", { fill: "#555", d: "M0 0h64v20H0z" }), (0, jsx_runtime_1.jsx)("path", { fill: "#579aca", d: "M64 0h45v20H64z" }), (0, jsx_runtime_1.jsx)("path", { fill: "url(#b)", d: "M0 0h109v20H0z" })] })), (0, jsx_runtime_1.jsxs)("g", Object.assign({ fill: "#fff", fontFamily: "DejaVu Sans,Verdana,Geneva,sans-serif", fontSize: "110", textAnchor: "middle" }, { children: [(0, jsx_runtime_1.jsx)("image", { width: "14", height: "14", x: "5", y: "3", href: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFkAAABZCAMAAABi1XidAAAB8lBMVEX///9XmsrmZYH1olJXmsr1olJXmsrmZYH1olJXmsr1olJXmsrmZYH1olL1olJXmsr1olJXmsrmZYH1olL1olJXmsrmZYH1olJXmsr1olL1olJXmsrmZYH1olL1olJXmsrmZYH1olL1olL0nFf1olJXmsrmZYH1olJXmsq8dZb1olJXmsrmZYH1olJXmspXmspXmsr1olL1olJXmsrmZYH1olJXmsr1olL1olJXmsrmZYH1olL1olLeaIVXmsrmZYH1olL1olL1olJXmsrmZYH1olLna31Xmsr1olJXmsr1olJXmsrmZYH1olLqoVr1olJXmsr1olJXmsrmZYH1olL1olKkfaPobXvviGabgadXmsqThKuofKHmZ4Dobnr1olJXmsr1olJXmspXmsr1olJXmsrfZ4TuhWn1olL1olJXmsqBi7X1olJXmspZmslbmMhbmsdemsVfl8ZgmsNim8Jpk8F0m7R4m7F5nLB6jbh7jbiDirOEibOGnKaMhq+PnaC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2Prz7du3VID3/tzs/sSRs2w7ovVHKtjrX2pd7ZMlTxAYfBAL9jiDwfLkq55Tm7ifhMlTGPyCAs7RFRhn47JnlcB9RM5T97ASuZXIcVNuUDIndpDbdsfrqsOppeXl5Y+XVKdjFCTh+zGaVuj0d9zy05PPK3QzBamxdwtTCrzyg/2Rvf2EstUjordGwa/kx9mSJLr8mLLtCW8HHGJc2R5hS219IiF6PnTusOqcMl57gm0Z8kanKMAQg0qSyuZfn7zItsbGyO9QlnxY0eCuD1XL2ys/MsrQhltE7Ug0uFOzufJFE2PxBo/YAx8XPPdDwWN0MrDRYIZF0mSMKCNHgaIVFoBbNoLJ7tEQDKxGF0kcLQimojCZopv0OkNOyWCCg9XMVAi7ARJzQdM2QUh0gmBozjc3Skg6dSBRqDGYSUOu66Zg+I2fNZs/M3/f/Grl/XnyF1Gw3VKCez0PN5IUfFLqvgUN4C0qNqYs5YhPL+aVZYDE4IpUk57oSFnJm4FyCqqOE0jhY2SMyLFoo56zyo6becOS5UVDdj7Vih0zp+tcMhwRpBeLyqtIjlJKAIZSbI8SGSF3k0pA3mR5tHuwPFoa7N7reoq2bqCsAk1HqCu5uvI1n6JuRXI+S1Mco54YmYTwcn6Aeic+kssXi8XpXC4V3t7/ADuTNKaQJdScAAAAAElFTkSuQmCC" }), (0, jsx_runtime_1.jsx)("text", Object.assign({ x: "415", y: "150", fill: "#010101", fillOpacity: ".3", textLength: "370", transform: "scale(.1)" }, { children: "launch" })), (0, jsx_runtime_1.jsx)("text", Object.assign({ x: "415", y: "140", textLength: "370", transform: "scale(.1)" }, { children: "launch" })), (0, jsx_runtime_1.jsx)("text", Object.assign({ x: "855", y: "150", fill: "#010101", fillOpacity: ".3", textLength: "350", transform: "scale(.1)" }, { children: "binder" })), (0, jsx_runtime_1.jsx)("text", Object.assign({ x: "855", y: "140", textLength: "350", transform: "scale(.1)" }, { children: "binder" }))] }))] })));
7
+ }
8
+ function BinderBadge({ binder }) {
9
+ if (!binder)
10
+ return null;
11
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "inline-block mr-1 opacity-80 hover:opacity-100" }, { children: (0, jsx_runtime_1.jsx)("a", Object.assign({ 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
+ }
13
+ exports.BinderBadge = BinderBadge;
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- export default function ClientOnly({ children }: {
2
+ export declare function ClientOnly({ children }: {
3
3
  children: ReactNode;
4
4
  }): JSX.Element | null;
5
5
  //# sourceMappingURL=ClientOnly.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientOnly.d.ts","sourceRoot":"","sources":["../../src/ClientOnly.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,sBAMvE"}
1
+ {"version":3,"file":"ClientOnly.d.ts","sourceRoot":"","sources":["../../src/ClientOnly.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,sBAM/D"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientOnly = void 0;
3
4
  const jsx_runtime_1 = require("react/jsx-runtime");
4
5
  const react_1 = require("react");
5
6
  function ClientOnly({ children }) {
@@ -9,4 +10,4 @@ function ClientOnly({ children }) {
9
10
  }, []);
10
11
  return mounted ? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }) : null;
11
12
  }
12
- exports.default = ClientOnly;
13
+ exports.ClientOnly = ClientOnly;
@@ -2,5 +2,7 @@ import { Output } from './output';
2
2
  declare const OUTPUT_RENDERERS: {
3
3
  output: typeof Output;
4
4
  };
5
+ export * from './BinderBadge';
6
+ export * from './providers';
5
7
  export default OUTPUT_RENDERERS;
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAE5B,eAAe,gBAAgB,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,23 @@
1
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  const output_1 = require("./output");
4
18
  const OUTPUT_RENDERERS = {
5
19
  output: output_1.Output,
6
20
  };
21
+ __exportStar(require("./BinderBadge"), exports);
22
+ __exportStar(require("./providers"), exports);
7
23
  exports.default = OUTPUT_RENDERERS;
@@ -1,5 +1,5 @@
1
1
  import type { MinifiedOutput } from 'nbtx';
2
- export declare const NativeJupyterOutputs: ({ id, outputs, }: {
2
+ export declare const JupyterOutputs: ({ id, outputs }: {
3
3
  id: string;
4
4
  outputs: MinifiedOutput[];
5
5
  }) => JSX.Element;
@@ -1 +1 @@
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
+ {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAmD3C,eAAO,MAAM,cAAc;QAA2B,MAAM;aAAW,cAAc,EAAE;iBAgDtF,CAAC"}
@@ -23,32 +23,58 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.NativeJupyterOutputs = void 0;
26
+ exports.JupyterOutputs = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
28
  const react_1 = __importStar(require("react"));
29
29
  const hooks_1 = require("./hooks");
30
30
  const nbtx_1 = require("nbtx");
31
31
  const convertImages_1 = require("./convertImages");
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));
32
+ const thebe_react_1 = require("thebe-react");
33
+ const providers_1 = require("./providers");
34
+ const myst_common_1 = require("myst-common");
35
+ function ActiveOutputRenderer({ id, data }) {
36
+ const ref = (0, providers_1.useCellRef)(id);
37
+ const exec = (0, providers_1.useNotebookCellExecution)(id);
38
+ (0, react_1.useEffect)(() => {
39
+ if (!(ref === null || ref === void 0 ? void 0 : ref.el) || !(exec === null || exec === void 0 ? void 0 : exec.cell))
40
+ return;
41
+ console.debug(`Attaching cell ${exec.cell.id} to DOM at:`, {
42
+ el: ref.el,
43
+ connected: ref.el.isConnected,
44
+ data,
45
+ });
46
+ exec.cell.attachToDOM(ref.el);
47
+ exec.cell.render(data);
48
+ }, [ref === null || ref === void 0 ? void 0 : ref.el, exec === null || exec === void 0 ? void 0 : exec.cell]);
49
+ return null;
50
+ }
51
+ function PassiveOutputRenderer({ id, data, core, kind, }) {
52
+ const [cell] = (0, react_1.useState)(new core.PassiveCellRenderer(id, undefined, undefined));
35
53
  const ref = (0, react_1.useRef)(null);
36
54
  (0, react_1.useEffect)(() => {
37
- cell.render(data);
55
+ cell.render(data, kind === myst_common_1.SourceFileKind.Article);
38
56
  }, [data, cell]);
39
57
  (0, react_1.useEffect)(() => {
40
58
  if (!ref.current)
41
59
  return;
42
- cell.attachToDOM(ref.current);
60
+ cell.attachToDOM(ref.current, true);
43
61
  }, [ref]);
44
- return (0, jsx_runtime_1.jsx)("div", { ref: ref });
62
+ return (0, jsx_runtime_1.jsx)("div", { ref: ref, "data-thebe-passive-ref": "true" });
45
63
  }
46
- const MemoOutputRenderer = react_1.default.memo(OutputRenderer);
47
- const NativeJupyterOutputs = ({ id, outputs, }) => {
48
- const { core } = (0, thebe_provider_1.useThebeCore)();
64
+ const MemoPassiveOutputRenderer = react_1.default.memo(PassiveOutputRenderer);
65
+ const JupyterOutputs = ({ id, outputs }) => {
66
+ var _a;
67
+ const { core, load } = (0, thebe_react_1.useThebeCore)();
49
68
  const { data, error } = (0, hooks_1.useFetchAnyTruncatedContent)(outputs);
50
69
  const [loaded, setLoaded] = (0, react_1.useState)(false);
51
70
  const [fullOutputs, setFullOutputs] = (0, react_1.useState)(null);
71
+ const registry = (0, providers_1.useCellRefRegistry)();
72
+ const exec = (0, providers_1.useNotebookCellExecution)(id);
73
+ (0, react_1.useEffect)(() => {
74
+ if (core)
75
+ return;
76
+ load();
77
+ }, [core, load]);
52
78
  (0, react_1.useEffect)(() => {
53
79
  if (!data || loaded)
54
80
  return;
@@ -61,6 +87,9 @@ const NativeJupyterOutputs = ({ id, outputs, }) => {
61
87
  if (error) {
62
88
  return (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "text-red-500" }, { children: ["Error rendering output: ", error.message] }));
63
89
  }
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 })] }));
90
+ if (registry && (exec === null || exec === void 0 ? void 0 : exec.cell)) {
91
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ ref: registry === null || registry === void 0 ? void 0 : registry.register(id), "data-thebe-active-ref": "true" }, { children: [!fullOutputs && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && (0, jsx_runtime_1.jsx)(ActiveOutputRenderer, { id: id, data: fullOutputs })] })));
92
+ }
93
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!fullOutputs && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "p-2.5" }, { children: "Loading..." })), fullOutputs && core && ((0, jsx_runtime_1.jsx)(MemoPassiveOutputRenderer, { id: id, data: fullOutputs, core: core, kind: (_a = exec === null || exec === void 0 ? void 0 : exec.kind) !== null && _a !== void 0 ? _a : myst_common_1.SourceFileKind.Notebook }))] }));
65
94
  };
66
- exports.NativeJupyterOutputs = NativeJupyterOutputs;
95
+ exports.JupyterOutputs = JupyterOutputs;
@@ -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;AAO/D,eAAO,MAAM,mBAAmB,aAA+B,CAAC;AAEhE,eAAO,MAAM,iBAAiB,aAMb,CAAC;AAElB,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
+ {"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;AAM/D,eAAO,MAAM,mBAAmB,aAA+B,CAAC;AAEhE,eAAO,MAAM,iBAAiB,aAMb,CAAC;AAElB,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,eA2BvC"}
@@ -9,8 +9,7 @@ const nbtx_1 = require("nbtx");
9
9
  const classnames_1 = __importDefault(require("classnames"));
10
10
  const safe_1 = require("./safe");
11
11
  const jupyter_1 = require("./jupyter");
12
- const ClientOnly_1 = __importDefault(require("./ClientOnly"));
13
- const thebe_provider_1 = require("./thebe-provider");
12
+ const providers_1 = require("./providers");
14
13
  exports.DIRECT_OUTPUT_TYPES = new Set(['stream', 'error']);
15
14
  exports.DIRECT_MIME_TYPES = new Set([
16
15
  nbtx_1.KnownCellOutputMimeTypes.TextPlain,
@@ -33,17 +32,17 @@ function allOutputsAreSafe(outputs, directOutputTypes, directMimeTypes) {
33
32
  }
34
33
  exports.allOutputsAreSafe = allOutputsAreSafe;
35
34
  function Output(node) {
35
+ const exec = (0, providers_1.useNotebookCellExecution)(node.key);
36
36
  const outputs = node.data;
37
37
  const allSafe = allOutputsAreSafe(outputs, exports.DIRECT_OUTPUT_TYPES, exports.DIRECT_MIME_TYPES);
38
38
  let component;
39
- if (allSafe) {
39
+ if (allSafe && !(exec === null || exec === void 0 ? void 0 : exec.ready)) {
40
40
  component = (0, jsx_runtime_1.jsx)(safe_1.SafeOutputs, { keyStub: node.key, outputs: outputs });
41
41
  }
42
42
  else {
43
- // Hide the iframe if rendering on the server
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 }) }) }));
43
+ component = (0, jsx_runtime_1.jsx)(jupyter_1.JupyterOutputs, { id: node.key, outputs: outputs });
45
44
  }
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', {
45
+ return ((0, jsx_runtime_1.jsx)("figure", Object.assign({ id: node.identifier || undefined, "data-mdast-node-type": node.type, "data-mdast-node-id": node.key, className: (0, classnames_1.default)('max-w-full overflow-auto m-0 group not-prose relative', {
47
46
  'text-left': !node.align || node.align === 'left',
48
47
  'text-center': node.align === 'center',
49
48
  'text-right': node.align === 'right',
@@ -0,0 +1,67 @@
1
+ import type { GenericParent } from 'myst-common';
2
+ import { SourceFileKind } from 'myst-common';
3
+ import React from 'react';
4
+ import type { Config, IThebeCell, IThebeCellExecuteReturn, ThebeCore, ThebeNotebook } from 'thebe-core';
5
+ import type { IThebeNotebookError, NotebookExecuteOptions } from 'thebe-react';
6
+ import type { Root } from 'mdast';
7
+ export declare function ConfiguredThebeServerProvider({ children }: React.PropsWithChildren): JSX.Element;
8
+ export type PartialPage = {
9
+ kind: SourceFileKind;
10
+ file: string;
11
+ sha256: string;
12
+ slug: string;
13
+ mdast: Root;
14
+ };
15
+ export declare function notebookFromMdast(core: ThebeCore, config: Config, mdast: GenericParent, idkMap: Record<string, string>): ThebeNotebook;
16
+ type CellRefRegistry = Record<string, HTMLDivElement>;
17
+ type IdKeyMap = Record<string, string>;
18
+ interface NotebookContextType {
19
+ kind: SourceFileKind;
20
+ ready: boolean;
21
+ attached: boolean;
22
+ executing: boolean;
23
+ executed: boolean;
24
+ errors: IThebeNotebookError[] | null;
25
+ executeAll: (options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
26
+ executeSome: (predicate: (cell: IThebeCell) => boolean, options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
27
+ notebook: ThebeNotebook | undefined;
28
+ registry: CellRefRegistry;
29
+ idkMap: IdKeyMap;
30
+ register: (id: string) => (el: HTMLDivElement) => void;
31
+ restart: () => Promise<void>;
32
+ clear: () => void;
33
+ }
34
+ export declare function NotebookProvider({ siteConfig, page, children, }: React.PropsWithChildren<{
35
+ siteConfig: boolean;
36
+ page: PartialPage;
37
+ }>): JSX.Element;
38
+ export declare function useHasNotebookProvider(): boolean;
39
+ export declare function useCellRefRegistry(): {
40
+ register: (id: string) => (el: HTMLDivElement) => void;
41
+ } | undefined;
42
+ export declare function useCellRef(id: string): {
43
+ el: HTMLDivElement | null;
44
+ } | undefined;
45
+ export declare function useMDASTNotebook(): NotebookContextType | undefined;
46
+ export declare function useNotebookExecution(): {
47
+ ready: boolean;
48
+ attached: boolean;
49
+ executing: boolean;
50
+ executed: boolean;
51
+ errors: IThebeNotebookError[] | null;
52
+ execute: (options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
53
+ notebook: ThebeNotebook | undefined;
54
+ clear: () => void;
55
+ } | undefined;
56
+ export declare function useNotebookCellExecution(id: string): {
57
+ kind: SourceFileKind;
58
+ ready: boolean;
59
+ cell: IThebeCell | undefined;
60
+ executing: boolean;
61
+ notebookIsExecuting: boolean;
62
+ execute: (options?: NotebookExecuteOptions) => Promise<(IThebeCellExecuteReturn | null)[]>;
63
+ clear: () => void | undefined;
64
+ notebook: ThebeNotebook | undefined;
65
+ } | undefined;
66
+ export {};
67
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +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,EAEN,UAAU,EACV,uBAAuB,EAEvB,SAAS,EACT,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAoDlC,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,eAOlF;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,SAAS,EACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,iBAwC/B;AAGD,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AACtD,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE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MAAM;;;;;;wBAiBhB,sBAAsB;;;cAiBxD"}
@@ -0,0 +1,232 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.useNotebookCellExecution = exports.useNotebookExecution = exports.useMDASTNotebook = exports.useCellRef = exports.useCellRefRegistry = exports.useHasNotebookProvider = exports.NotebookProvider = exports.notebookFromMdast = exports.ConfiguredThebeServerProvider = void 0;
36
+ const jsx_runtime_1 = require("react/jsx-runtime");
37
+ const myst_common_1 = require("myst-common");
38
+ const react_1 = __importStar(require("react"));
39
+ const thebe_react_1 = require("thebe-react");
40
+ const providers_1 = require("@myst-theme/providers");
41
+ function getThebeOptions() {
42
+ var _a, _b, _c;
43
+ const { thebe, binderUrl } = (0, providers_1.useComputeOptions)();
44
+ const { mathjaxUrl, mathjaxConfig, binder, server, kernelName, sessionName, disableSessionSaving, local, } = (_a = thebe) !== null && _a !== void 0 ? _a : {};
45
+ const output = { mathjaxUrl, mathjaxConfig };
46
+ if (binder) {
47
+ const useBinder = binder === true ? {} : binder;
48
+ output.binderOptions = {
49
+ binderUrl: (_b = useBinder.url) !== null && _b !== void 0 ? _b : binderUrl,
50
+ ref: useBinder.ref,
51
+ repo: useBinder.repo,
52
+ repoProvider: useBinder.provider,
53
+ };
54
+ }
55
+ const useServer = (local !== null && local !== void 0 ? local : server);
56
+ if (server) {
57
+ const splitUrl = (_c = useServer.url) === null || _c === void 0 ? void 0 : _c.split('://');
58
+ const wsUrl = (splitUrl === null || splitUrl === void 0 ? void 0 : splitUrl.length) === 2 ? `ws://${splitUrl[1]}` : undefined;
59
+ output.serverSettings = {
60
+ baseUrl: useServer.url,
61
+ token: useServer.token,
62
+ wsUrl,
63
+ appendToken: true,
64
+ };
65
+ }
66
+ output.kernelOptions = {
67
+ kernelName: kernelName,
68
+ name: kernelName,
69
+ path: sessionName,
70
+ };
71
+ if (!disableSessionSaving) {
72
+ output.savedSessionOptions = {
73
+ enabled: true,
74
+ maxAge: 38300,
75
+ storagePrefix: 'thebe',
76
+ };
77
+ }
78
+ return output;
79
+ }
80
+ function ConfiguredThebeServerProvider({ children }) {
81
+ const thebe = getThebeOptions();
82
+ return ((0, jsx_runtime_1.jsx)(thebe_react_1.ThebeServerProvider, Object.assign({ connect: false, options: thebe }, { children: children })));
83
+ }
84
+ exports.ConfiguredThebeServerProvider = ConfiguredThebeServerProvider;
85
+ function notebookFromMdast(core, config, mdast, idkMap) {
86
+ const rendermime = undefined; // share rendermime beyond notebook scope?
87
+ const notebook = new core.ThebeNotebook(mdast.key, config, rendermime);
88
+ // no metadata included in mdast yet
89
+ //Object.assign(notebook.metadata, ipynb.metadata);
90
+ notebook.cells = mdast.children.map((block) => {
91
+ var _a, _b, _c;
92
+ if (block.type !== 'block')
93
+ console.warn(`Unexpected block type ${block.type}`);
94
+ if (block.children.length == 2 && block.children[0].type === 'code') {
95
+ const [codeCell, output] = block.children;
96
+ // use the block.key to identify the cell but maintain a mapping
97
+ // to allow code or output keys to look up cells and refs
98
+ idkMap[block.key] = block.key;
99
+ idkMap[codeCell.key] = block.key;
100
+ idkMap[output.key] = block.key;
101
+ 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);
102
+ }
103
+ else {
104
+ // assume content - concatenate it
105
+ // TODO inject cell metadata
106
+ 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);
107
+ return cell;
108
+ }
109
+ });
110
+ return notebook;
111
+ }
112
+ exports.notebookFromMdast = notebookFromMdast;
113
+ const NotebookContext = react_1.default.createContext(undefined);
114
+ function NotebookProvider({ siteConfig, page, children, }) {
115
+ // so at some point this gets the whole site config and can
116
+ // be use to lookup notebooks and recover ThebeNotebooks that
117
+ // can be used to execute notebook pages or blocks in articles
118
+ const { core } = (0, thebe_react_1.useThebeCore)();
119
+ const { config } = (0, thebe_react_1.useThebeConfig)();
120
+ const { ready, attached, executing, executed, errors, executeAll, executeSome, clear, session, notebook, setNotebook, } = (0, thebe_react_1.useNotebookBase)();
121
+ const registry = (0, react_1.useRef)({});
122
+ const idkMap = (0, react_1.useRef)({});
123
+ (0, react_1.useEffect)(() => {
124
+ if (!core || !config)
125
+ return;
126
+ registry.current = {};
127
+ idkMap.current = {};
128
+ if (page.kind === myst_common_1.SourceFileKind.Notebook) {
129
+ const nb = notebookFromMdast(core, config, page.mdast, idkMap.current);
130
+ setNotebook(nb);
131
+ }
132
+ else {
133
+ // TODO will need do article relative notebook loading as appropriate once that is supported
134
+ setNotebook(undefined);
135
+ }
136
+ }, [core, config, page]);
137
+ function register(id) {
138
+ return (el) => {
139
+ if (el != null && registry.current[idkMap.current[id]] !== el) {
140
+ if (!el.isConnected) {
141
+ console.debug(`skipping ref for cell ${id} as host is not connected`);
142
+ }
143
+ else {
144
+ console.debug(`new ref for cell ${id} registered`);
145
+ registry.current[idkMap.current[id]] = el;
146
+ }
147
+ }
148
+ };
149
+ }
150
+ return ((0, jsx_runtime_1.jsx)(NotebookContext.Provider, Object.assign({ value: {
151
+ kind: page.kind,
152
+ ready,
153
+ attached,
154
+ executing,
155
+ executed,
156
+ errors,
157
+ executeAll,
158
+ executeSome,
159
+ notebook,
160
+ registry: registry.current,
161
+ idkMap: idkMap.current,
162
+ register,
163
+ restart: () => { var _a; return (_a = session === null || session === void 0 ? void 0 : session.restart()) !== null && _a !== void 0 ? _a : Promise.resolve(); },
164
+ clear,
165
+ } }, { children: children })));
166
+ }
167
+ exports.NotebookProvider = NotebookProvider;
168
+ function useHasNotebookProvider() {
169
+ const notebookState = (0, react_1.useContext)(NotebookContext);
170
+ return notebookState !== undefined;
171
+ }
172
+ exports.useHasNotebookProvider = useHasNotebookProvider;
173
+ function useCellRefRegistry() {
174
+ const notebookState = (0, react_1.useContext)(NotebookContext);
175
+ if (notebookState === undefined)
176
+ return undefined;
177
+ return { register: notebookState.register };
178
+ }
179
+ exports.useCellRefRegistry = useCellRefRegistry;
180
+ function useCellRef(id) {
181
+ var _a;
182
+ const notebookState = (0, react_1.useContext)(NotebookContext);
183
+ if (notebookState === undefined)
184
+ return undefined;
185
+ const { registry, idkMap } = notebookState;
186
+ const entry = Object.entries(notebookState.registry).find(([cellId]) => cellId === idkMap[id]);
187
+ console.debug('useCellRef', { id, registry, idkMap, entry });
188
+ return { el: (_a = entry === null || entry === void 0 ? void 0 : entry[1]) !== null && _a !== void 0 ? _a : null };
189
+ }
190
+ exports.useCellRef = useCellRef;
191
+ function useMDASTNotebook() {
192
+ const notebookState = (0, react_1.useContext)(NotebookContext);
193
+ return notebookState;
194
+ }
195
+ exports.useMDASTNotebook = useMDASTNotebook;
196
+ function useNotebookExecution() {
197
+ const notebookState = (0, react_1.useContext)(NotebookContext);
198
+ if (!notebookState)
199
+ return undefined;
200
+ const { ready, attached, executing, executed, errors, executeAll, notebook, clear } = notebookState;
201
+ return { ready, attached, executing, executed, errors, execute: executeAll, notebook, clear };
202
+ }
203
+ exports.useNotebookExecution = useNotebookExecution;
204
+ function useNotebookCellExecution(id) {
205
+ // setup a cell only executing state
206
+ const [executing, setExecuting] = (0, react_1.useState)(false);
207
+ const notebookState = (0, react_1.useContext)(NotebookContext);
208
+ if (!notebookState)
209
+ return undefined;
210
+ const { kind, ready, notebook, executing: notebookIsExecuting, executeSome, idkMap, } = notebookState;
211
+ const cellId = idkMap[id];
212
+ function execute(options) {
213
+ return __awaiter(this, void 0, void 0, function* () {
214
+ setExecuting(true);
215
+ const execReturn = yield executeSome((cell) => cell.id === cellId, options);
216
+ setExecuting(false);
217
+ return execReturn;
218
+ });
219
+ }
220
+ const cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
221
+ return {
222
+ kind,
223
+ ready,
224
+ cell,
225
+ executing,
226
+ notebookIsExecuting,
227
+ execute,
228
+ clear: () => cell === null || cell === void 0 ? void 0 : cell.clear(),
229
+ notebook,
230
+ };
231
+ }
232
+ exports.useNotebookCellExecution = useNotebookCellExecution;
package/dist/cjs/safe.js CHANGED
@@ -61,7 +61,7 @@ function SafeOutput({ output }) {
61
61
  if (image)
62
62
  return (0, jsx_runtime_1.jsx)(OutputImage, { image: image, text: text });
63
63
  if (text)
64
- return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ansi_to_react_1.default, { children: text.content }) }));
64
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "whitespace-pre-wrap font-mono text-sm" }, { children: (0, jsx_runtime_1.jsx)(ansi_to_react_1.default, { children: text.content }) })));
65
65
  return null;
66
66
  }
67
67
  default:
@@ -0,0 +1,4 @@
1
+ export declare function BinderBadge({ binder }: {
2
+ binder?: string;
3
+ }): JSX.Element | null;
4
+ //# sourceMappingURL=BinderBadge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BinderBadge.d.ts","sourceRoot":"","sources":["../../src/BinderBadge.tsx"],"names":[],"mappings":"AA2DA,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,sBAe1D"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ function BinderBadgeLogo() {
3
+ return (_jsxs("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "109", height: "20" }, { children: [_jsxs("linearGradient", Object.assign({ id: "b", x2: "0", y2: "100%" }, { children: [_jsx("stop", { offset: "0", stopColor: "#bbb", stopOpacity: ".1" }), _jsx("stop", { offset: "1", stopOpacity: ".1" })] })), _jsx("clipPath", Object.assign({ id: "a" }, { children: _jsx("rect", { width: "109", height: "20", fill: "#fff", rx: "3" }) })), _jsxs("g", Object.assign({ clipPath: "url(#a)" }, { children: [_jsx("path", { fill: "#555", d: "M0 0h64v20H0z" }), _jsx("path", { fill: "#579aca", d: "M64 0h45v20H64z" }), _jsx("path", { fill: "url(#b)", d: "M0 0h109v20H0z" })] })), _jsxs("g", Object.assign({ fill: "#fff", fontFamily: "DejaVu Sans,Verdana,Geneva,sans-serif", fontSize: "110", textAnchor: "middle" }, { children: [_jsx("image", { width: "14", height: "14", x: "5", y: "3", href: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFkAA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AIZSbI8SGSF3k0pA3mR5tHuwPFoa7N7reoq2bqCsAk1HqCu5uvI1n6JuRXI+S1Mco54YmYTwcn6Aeic+kssXi8XpXC4V3t7/ADuTNKaQJdScAAAAAElFTkSuQmCC" }), _jsx("text", Object.assign({ x: "415", y: "150", fill: "#010101", fillOpacity: ".3", textLength: "370", transform: "scale(.1)" }, { children: "launch" })), _jsx("text", Object.assign({ x: "415", y: "140", textLength: "370", transform: "scale(.1)" }, { children: "launch" })), _jsx("text", Object.assign({ x: "855", y: "150", fill: "#010101", fillOpacity: ".3", textLength: "350", transform: "scale(.1)" }, { children: "binder" })), _jsx("text", Object.assign({ x: "855", y: "140", textLength: "350", transform: "scale(.1)" }, { children: "binder" }))] }))] })));
4
+ }
5
+ export function BinderBadge({ binder }) {
6
+ if (!binder)
7
+ return null;
8
+ return (_jsx("div", Object.assign({ className: "inline-block mr-1 opacity-80 hover:opacity-100" }, { children: _jsx("a", Object.assign({ href: binder, title: `Launch Binder Session: ${binder}`, target: "_blank", rel: "noopener noreferrer", className: "text-inherit hover:text-inherit" }, { children: _jsx(BinderBadgeLogo, {}) })) })));
9
+ }
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- export default function ClientOnly({ children }: {
2
+ export declare function ClientOnly({ children }: {
3
3
  children: ReactNode;
4
4
  }): JSX.Element | null;
5
5
  //# sourceMappingURL=ClientOnly.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientOnly.d.ts","sourceRoot":"","sources":["../../src/ClientOnly.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,sBAMvE"}
1
+ {"version":3,"file":"ClientOnly.d.ts","sourceRoot":"","sources":["../../src/ClientOnly.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,sBAM/D"}
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
- export default function ClientOnly({ children }) {
3
+ export function ClientOnly({ children }) {
4
4
  const [mounted, setMounted] = useState(false);
5
5
  useEffect(() => {
6
6
  setMounted(true);
@@ -2,5 +2,7 @@ import { Output } from './output';
2
2
  declare const OUTPUT_RENDERERS: {
3
3
  output: typeof Output;
4
4
  };
5
+ export * from './BinderBadge';
6
+ export * from './providers';
5
7
  export default OUTPUT_RENDERERS;
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAE5B,eAAe,gBAAgB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -2,4 +2,6 @@ import { Output } from './output';
2
2
  const OUTPUT_RENDERERS = {
3
3
  output: Output,
4
4
  };
5
+ export * from './BinderBadge';
6
+ export * from './providers';
5
7
  export default OUTPUT_RENDERERS;
@@ -1,5 +1,5 @@
1
1
  import type { MinifiedOutput } from 'nbtx';
2
- export declare const NativeJupyterOutputs: ({ id, outputs, }: {
2
+ export declare const JupyterOutputs: ({ id, outputs }: {
3
3
  id: string;
4
4
  outputs: MinifiedOutput[];
5
5
  }) => JSX.Element;
@@ -1 +1 @@
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
+ {"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAmD3C,eAAO,MAAM,cAAc;QAA2B,MAAM;aAAW,cAAc,EAAE;iBAgDtF,CAAC"}