@myst-theme/jupyter 0.5.10 → 0.5.12

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.
@@ -4,7 +4,8 @@ import { useThebeServer } from 'thebe-react';
4
4
  import { useThebeOptions } from './providers.js';
5
5
  import { selectAreExecutionScopesBuilding, useExecutionScope } from './execute/index.js';
6
6
  export function ConnectionStatusTray({ waitForSessions }) {
7
- const { options } = useThebeOptions();
7
+ var _a, _b, _c;
8
+ const thebe = useThebeOptions();
8
9
  const { connecting, ready: serverReady, error: serverError, events } = useThebeServer();
9
10
  const { slug, ready: scopeReady, state } = useExecutionScope();
10
11
  const [show, setShow] = useState(false);
@@ -22,7 +23,7 @@ export function ConnectionStatusTray({ waitForSessions }) {
22
23
  events.on('status', handleStatus);
23
24
  }, [events]);
24
25
  useEffect(() => {
25
- if (!options)
26
+ if (!(thebe === null || thebe === void 0 ? void 0 : thebe.options))
26
27
  return;
27
28
  if (busy || error) {
28
29
  setShow(true);
@@ -34,17 +35,17 @@ export function ConnectionStatusTray({ waitForSessions }) {
34
35
  setUnsub(undefined);
35
36
  }, 1000);
36
37
  }
37
- }, [options, busy, ready, error]);
38
- const host = (options === null || options === void 0 ? void 0 : options.useBinder)
38
+ }, [thebe, busy, ready, error]);
39
+ const host = ((_a = thebe === null || thebe === void 0 ? void 0 : thebe.options) === null || _a === void 0 ? void 0 : _a.useBinder)
39
40
  ? 'Binder'
40
- : (options === null || options === void 0 ? void 0 : options.useJupyterLite)
41
+ : ((_b = thebe === null || thebe === void 0 ? void 0 : thebe.options) === null || _b === void 0 ? void 0 : _b.useJupyterLite)
41
42
  ? 'JupyterLite'
42
43
  : 'Local Server';
43
44
  // TODO radix ui toast!
44
45
  if (show && error) {
45
46
  return (_jsxs("div", { className: "fixed p-3 z-[11] text-sm text-gray-700 bg-white border rounded shadow-lg bottom-2 sm:right-2 max-w-[90%] md:max-w-[300px] min-w-0", children: [_jsxs("div", { className: "mb-2 font-semibold text-center", children: ["\u26D4\uFE0F Error connecting to ", host, " \u26D4\uFE0F"] }), _jsx("div", { className: "my-1 max-h-[15rem] mono overflow-hidden text-ellipsis", children: error }), _jsx("div", { className: "flex justify-end", children: _jsx("div", { className: "text-xs cursor-pointer hover:underline", role: "button", onClick: () => setShow(false), children: "dismiss" }) })] }));
46
47
  }
47
- if (show && (options === null || options === void 0 ? void 0 : options.useJupyterLite)) {
48
+ if (show && ((_c = thebe === null || thebe === void 0 ? void 0 : thebe.options) === null || _c === void 0 ? void 0 : _c.useJupyterLite)) {
48
49
  return (_jsxs("div", { className: "fixed p-3 z-[11] text-sm text-gray-700 bg-white border rounded shadow-lg bottom-2 sm:right-2 max-w-[90%] md:max-w-[300px] min-w-0", children: [_jsxs("div", { className: "mb-1 font-semibold text-center", children: ["\u26A1\uFE0F Connecting to ", host, " \u26A1\uFE0F"] }), !ready && _jsx("div", { className: "max-h-[5rem] mono overflow-hidden text-ellipsis", children: status }), ready && (_jsx("div", { className: "max-h-[15rem] mono overflow-hidden text-ellipsis", children: "The in-browser JupyterLite server is ready, press run anytime." }))] }));
49
50
  }
50
51
  if (show) {
@@ -3,7 +3,6 @@ import { SourceFileKind } from 'myst-spec-ext';
3
3
  import React from 'react';
4
4
  import type { ExecuteScopeAction } from './actions.js';
5
5
  import type { ExecuteScopeState, IdKeyMap } from './types.js';
6
- import type { Thebe } from 'myst-frontmatter';
7
6
  import type { GenericParent } from 'myst-common';
8
7
  export interface ExecuteScopeType {
9
8
  canCompute: boolean;
@@ -19,9 +18,6 @@ type ArticleContents = {
19
18
  mdast: GenericParent;
20
19
  location?: string;
21
20
  dependencies?: Dependency[];
22
- frontmatter: {
23
- thebe?: boolean | Thebe;
24
- };
25
21
  };
26
22
  /**
27
23
  * The ExecuteScopeProvider is responsible for maintaining the state of the
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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,eAAe,CAAC;AAC/C,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAU1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;CAC7B,CAAC;AAmEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC,2CAmGxD"}
@@ -44,7 +44,7 @@ function useExecutionScopeFetcher({ slug, state, dispatch, }) {
44
44
  }, [state.builds, state.mdast]);
45
45
  }
46
46
  function listComputables(mdast) {
47
- return selectAll('container[kind=figure] > output, embed > output', mdast).map((node) => {
47
+ return selectAll('container[kind=figure]:has(output), embed:has(output)', mdast).map((node) => {
48
48
  const { key, label, source } = node;
49
49
  const output = selectAll('output', node);
50
50
  return { embedKey: key, outputKey: output[0].key, label, source };
@@ -57,7 +57,7 @@ function listComputables(mdast) {
57
57
  */
58
58
  export function ExecuteScopeProvider({ children, contents, }) {
59
59
  var _a, _b;
60
- const canCompute = useCanCompute(contents);
60
+ const canCompute = useCanCompute();
61
61
  // compute incoming for first render
62
62
  const computables = listComputables(contents.mdast);
63
63
  const fallbackLocation = contents.kind === SourceFileKind.Notebook ? '/fallback.ipynb' : '/';
@@ -14,12 +14,8 @@ export declare function ConfiguredThebeServerProvider({ siteManifest, optionOver
14
14
  optionOverrideFn?: (opts: ExtendedCoreOptions) => ExtendedCoreOptions;
15
15
  customRepoProviders?: RepoProviderSpec[];
16
16
  }>): import("react/jsx-runtime").JSX.Element;
17
- export declare function useCanCompute(article: {
18
- frontmatter: {
19
- thebe?: boolean | Record<string, any>;
20
- };
21
- }): boolean;
22
- export declare function useThebeOptions(): ThebeOptionsContextType;
17
+ export declare function useCanCompute(): boolean;
18
+ export declare function useThebeOptions(): ThebeOptionsContextType | undefined;
23
19
  export type PartialPage = {
24
20
  kind: SourceFileKind;
25
21
  file: string;
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,mBAAmB,EAA6B,MAAM,YAAY,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAiCnD,KAAK,uBAAuB,GAAG;IAC7B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF,wBAAgB,6BAA6B,CAAC,EAC5C,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,C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AAC,iBAAiB,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,mBAAmB,CAAC;IACtE,mBAAmB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC1C,CAAC,2CAqBD;AAED,wBAAgB,aAAa,YAG5B;AAED,wBAAgB,eAAe,wCAE9B;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC"}
package/dist/providers.js CHANGED
@@ -22,7 +22,7 @@ function makeThebeOptions(siteManifest, optionsOverrideFn = (opts) => opts) {
22
22
  binderBadgeUrl,
23
23
  };
24
24
  }
25
- const ThebeOptionsContext = React.createContext({});
25
+ const ThebeOptionsContext = React.createContext(undefined);
26
26
  export function ConfiguredThebeServerProvider({ siteManifest, optionOverrideFn, customRepoProviders, children, }) {
27
27
  var _a, _b, _c, _d;
28
28
  const thebe = React.useMemo(() => makeThebeOptions(siteManifest, optionOverrideFn), [siteManifest, optionOverrideFn]);
@@ -30,10 +30,9 @@ export function ConfiguredThebeServerProvider({ siteManifest, optionOverrideFn,
30
30
  return _jsx(_Fragment, { children: children });
31
31
  return (_jsx(ThebeOptionsContext.Provider, { value: thebe, children: _jsx(ThebeServerProvider, { connect: false, options: thebe.options, useBinder: (_b = (_a = thebe.options) === null || _a === void 0 ? void 0 : _a.useBinder) !== null && _b !== void 0 ? _b : false, useJupyterLite: (_d = (_c = thebe.options) === null || _c === void 0 ? void 0 : _c.useJupyterLite) !== null && _d !== void 0 ? _d : false, customRepoProviders: customRepoProviders, children: _jsx(_Fragment, { children: children }) }) }));
32
32
  }
33
- export function useCanCompute(article) {
34
- var _a;
33
+ export function useCanCompute() {
35
34
  const thebe = useContext(ThebeOptionsContext);
36
- return !!thebe && ((_a = article.frontmatter) === null || _a === void 0 ? void 0 : _a.thebe) !== false;
35
+ return !!(thebe === null || thebe === void 0 ? void 0 : thebe.options);
37
36
  }
38
37
  export function useThebeOptions() {
39
38
  return useContext(ThebeOptionsContext);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EAIN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAyDF,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,EAC/B,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,mBAAmB,GAAG,SAAS,CA+IjC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAA0C,MAAM,kBAAkB,CAAC;AACtF,OAAO,KAAK,EAAE,WAAW,EAAyB,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAyDF,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,EAC/B,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,mBAAmB,GAAG,SAAS,CAgHjC"}
package/dist/utils.js CHANGED
@@ -42,35 +42,11 @@ export function thebeFrontmatterToOptions(fm, githubBadgeUrl, binderBadgeUrl) {
42
42
  var _a;
43
43
  if (fm === undefined || fm === false)
44
44
  return undefined;
45
- const { binder, server, lite, local, kernelName, disableSessionSaving, mathjaxConfig, mathjaxUrl, } = (_a = fm) !== null && _a !== void 0 ? _a : {};
45
+ const { binder, server, lite, kernelName, disableSessionSaving, mathjaxConfig, mathjaxUrl } = (_a = fm) !== null && _a !== void 0 ? _a : {};
46
46
  const thebeOptions = { mathjaxConfig, mathjaxUrl };
47
47
  if (disableSessionSaving) {
48
48
  thebeOptions.savedSessionOptions = { enabled: false };
49
49
  }
50
- // handle thebe.local.*
51
- // as local OVERRIDES other binder and server settings, handle these first
52
- // TODO need to expose NODE_ENV somehow via a loader
53
- let NODE_ENV = 'development';
54
- if (typeof window !== 'undefined') {
55
- NODE_ENV = window.NODE_ENV;
56
- }
57
- if (NODE_ENV !== 'production' && local) {
58
- if (isObject(local)) {
59
- const { url, token, kernelName: localKernelName } = local;
60
- if (url || token) {
61
- thebeOptions.serverSettings = {};
62
- if (url)
63
- thebeOptions.serverSettings.baseUrl = url;
64
- if (token)
65
- thebeOptions.serverSettings.token = token;
66
- }
67
- if (localKernelName) {
68
- thebeOptions.kernelOptions = { kernelName: localKernelName };
69
- }
70
- }
71
- return thebeOptions;
72
- // else just fall through & return - TODO return early?
73
- }
74
50
  // handle additional options
75
51
  if (kernelName) {
76
52
  thebeOptions.kernelOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myst-theme/jupyter",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -25,16 +25,16 @@
25
25
  "@curvenote/ansi-to-react": "^7.0.0",
26
26
  "@headlessui/react": "^1.7.15",
27
27
  "@heroicons/react": "^2.0.18",
28
- "@myst-theme/providers": "^0.5.10",
28
+ "@myst-theme/providers": "^0.5.12",
29
29
  "@scienceicons/react": "^0.0.6",
30
30
  "buffer": "^6.0.3",
31
31
  "classnames": "^2.3.2",
32
- "myst-common": "^1.1.8",
33
- "myst-config": "^1.1.8",
34
- "myst-frontmatter": "^1.1.8",
32
+ "myst-common": "^1.1.12",
33
+ "myst-config": "^1.1.12",
34
+ "myst-frontmatter": "^1.1.12",
35
35
  "myst-spec": "^0.0.4",
36
- "myst-spec-ext": "^1.1.8",
37
- "myst-to-react": "^0.5.10",
36
+ "myst-spec-ext": "^1.1.12",
37
+ "myst-to-react": "^0.5.12",
38
38
  "nanoid": "^4.0.2",
39
39
  "nbtx": "^0.2.3",
40
40
  "react-syntax-highlighter": "^15.5.0",