Skip to content

Commit

Permalink
Revert "🛠️ fix/direct import bug (#757)"
Browse files Browse the repository at this point in the history
This reverts commit 95eb9b5.
  • Loading branch information
stevejpurves committed Sep 5, 2024
1 parent 6d825e4 commit 3f07f0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { IRenderMimeRegistry } from '@jupyterlab/rendermime';
import type ThebeServer from './server';
import type { ServerStatusEvent } from './events';
import type { Config } from './config';
import type ThebeNotebook from './notebook';
export type CellKind = 'code' | 'markdown';
export type JsonObject = Record<string, any>;
export type SessionIModel = Session.IModel;
Expand Down Expand Up @@ -97,7 +98,7 @@ export interface IThebeCell extends IPassiveCell {
source: string;
session?: ThebeSession;
metadata: JsonObject;
notebookId?: string;
notebook?: ThebeNotebook;
readonly isBusy: boolean;
readonly isAttached: boolean;
readonly tags: string[];
Expand Down
16 changes: 11 additions & 5 deletions packages/react/src/hooks/notebook.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { createRef, useEffect, useState } from 'react';
import type { ThebeNotebook, ThebeSession, IThebeCell, IThebeCellExecuteReturn } from 'thebe-core';
import {
type ThebeNotebook,
type ThebeSession,
type IThebeCell,
type IThebeCellExecuteReturn,
ThebePassiveManager,
WIDGET_VIEW_MIMETYPE,
WIDGET_STATE_MIMETYPE,
} from 'thebe-core';
import { useThebeConfig } from '../ThebeServerProvider';
import { useThebeLoader } from '../ThebeLoaderProvider';
import type { INotebookContent } from '@jupyterlab/nbformat';
import type { IExecuteResult, INotebookContent } from '@jupyterlab/nbformat';
import { useThebeSession } from '../ThebeSessionProvider';
import { useRenderMimeRegistry } from '../ThebeRenderMimeRegistryProvider';
import type { IManagerState } from '@jupyter-widgets/base-manager';

export const WIDGET_STATE_MIMETYPE = 'application/vnd.jupyter.widget-state+json';

export interface NotebookExecuteOptions {
stopOnError?: boolean;
before?: () => void;
Expand Down Expand Up @@ -162,7 +168,7 @@ export function useNotebook(
})
.then((nb: ThebeNotebook) => {
const cells = opts?.refsForWidgetsOnly ? nb?.widgets ?? [] : nb?.cells ?? [];
const manager = new core.ThebePassiveManager(rendermime);
const manager = new ThebePassiveManager(rendermime);
if (nb.metadata.widgets && (nb.metadata.widgets as any)[WIDGET_STATE_MIMETYPE]) {
manager.load_state((nb.metadata.widgets as any)[WIDGET_STATE_MIMETYPE] as IManagerState);
}
Expand Down

0 comments on commit 3f07f0e

Please sign in to comment.