Skip to content

Commit

Permalink
👊🏽 bump thebe - consume passive manager
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejpurves committed Aug 26, 2024
1 parent 6ba31c5 commit 0eb2229
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 48 deletions.
33 changes: 15 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,5 @@
"npm": ">=7.0.0",
"node": ">=14.0.0"
},
"packageManager": "npm@8.10.0",
"dependencies": {
"thebe-core": "file:../../GitHub/thebe/thebe/packages/core/thebe-core-0.4.7.tgz"
}
"packageManager": "npm@8.10.0"
}
6 changes: 3 additions & 3 deletions packages/jupyter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"nbtx": "^0.2.3",
"react-syntax-highlighter": "^15.5.0",
"swr": "^2.1.5",
"thebe-core": "0.4.7",
"thebe-lite": "0.4.7",
"thebe-react": "0.4.7",
"thebe-core": "^0.4.9",
"thebe-lite": "^0.4.9",
"thebe-react": "^0.4.9",
"unist-util-select": "^4.0.3"
},
"peerDependencies": {
Expand Down
9 changes: 7 additions & 2 deletions packages/jupyter/src/execute/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { SourceFileKind, Dependency } from 'myst-spec-ext';
import type { BuildStatus, Computable } from './types.js';
import type { IRenderMimeRegistry, ThebeNotebook, ThebeSession } from 'thebe-core';
import type {
IRenderMimeRegistry,
ThebeNotebook,
ThebePassiveManager,
ThebeSession,
} from 'thebe-core';
import type { GenericParent } from 'myst-common';

export function isNavigatePayload(payload: unknown): payload is NavigatePayload {
Expand Down Expand Up @@ -90,7 +95,7 @@ interface AddNotebookPayload {
}

interface AddPassivePayload {
manager: any; //TODO ThebePassiveManager
manager: ThebePassiveManager;
rendermime: IRenderMimeRegistry;
pageSlug: string;
}
Expand Down
28 changes: 12 additions & 16 deletions packages/jupyter/src/execute/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
} from './selectors.js';
import { MdastFetcher, NotebookBuilder, ServerMonitor, SessionStarter } from './leaf.js';
import type { GenericParent } from 'myst-common';
import { WidgetsMetaData } from '../../../common/dist/types.js';
import {useThebeLoader} from 'thebe-react';
import type { WidgetsMetaData } from '@myst-theme/common';
import { useThebeLoader } from 'thebe-react';

export interface ExecuteScopeType {
canCompute: boolean;
Expand All @@ -32,7 +32,7 @@ type ArticleContents = {
mdast: GenericParent;
location?: string;
dependencies?: Dependency[];
widgets?:WidgetsMetaData;
widgets?: WidgetsMetaData;
};

function useScopeNavigate({
Expand Down Expand Up @@ -109,34 +109,30 @@ export function ExecuteScopeProvider({
children,
enable,
contents,
}: React.PropsWithChildren<{ enable: boolean; contents: ArticleContents ;}>) {
}: React.PropsWithChildren<{ enable: boolean; contents: ArticleContents }>) {
// compute incoming for first render
const computables: Computable[] = listComputables(contents.mdast);
const fallbackLocation = contents.kind === SourceFileKind.Notebook ? '/fallback.ipynb' : '/';

const { core } = useThebeLoader();
const [isCoreLoaded, setIsCoreLoaded] = useState(false);
useEffect(() => {
if (core) {
setIsCoreLoaded(true);
}
}, [core]);

useEffect(() => {
if (isCoreLoaded && core) {
if (core) {
const rendermime = core.makeRenderMimeRegistry();
const manager = new core.ThebePassiveManager(rendermime, contents?.widgets?.["application/vnd.jupyter.widget-state+json"]);
const manager = new core.ThebePassiveManager(
rendermime,
contents?.widgets?.['application/vnd.jupyter.widget-state+json'],
);

dispatch({
type: 'ADD_PASSIVE',
payload: {
rendermime,
manager,
pageSlug:contents.slug
pageSlug: contents.slug,
},
});
}
}, [isCoreLoaded, core, contents?.widgets]);
}, [core, contents?.widgets]);

const initialState: ExecuteScopeState = {
mdast: {
Expand All @@ -152,7 +148,7 @@ export function ExecuteScopeProvider({
computables,
ready: false,
scopes: {},
passive: undefined
passive: undefined,
},
},
builds: {},
Expand Down
13 changes: 9 additions & 4 deletions packages/jupyter/src/execute/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { GenericParent } from 'myst-common';
import type { SourceFileKind, Dependency } from 'myst-spec-ext';
import type { IRenderMimeRegistry, ThebeNotebook, ThebeSession, ThebePassiveManager } from 'thebe-core';
import type {
IRenderMimeRegistry,
ThebeNotebook,
ThebeSession,
ThebePassiveManager,
} from 'thebe-core';

export type BuildStatus =
| 'pending'
Expand Down Expand Up @@ -33,10 +38,10 @@ export interface ExecuteScopeState {
scopes: {
[notebookSlug: string]: ExecutionScope;
};
passive? : {
passive?: {
manager: ThebePassiveManager;
rendermime: IRenderMimeRegistry
}
rendermime: IRenderMimeRegistry;
};
};
};
builds: {
Expand Down
2 changes: 1 addition & 1 deletion packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"nbtx": "^0.2.3",
"node-cache": "^5.1.2",
"node-fetch": "^2.6.11",
"thebe-react": "0.4.7",
"thebe-react": "^0.4.9",
"unist-util-select": "^4.0.1"
},
"peerDependencies": {
Expand Down

0 comments on commit 0eb2229

Please sign in to comment.