diff --git a/.changeset/pink-impalas-scream.md b/.changeset/pink-impalas-scream.md new file mode 100644 index 00000000..0ca861df --- /dev/null +++ b/.changeset/pink-impalas-scream.md @@ -0,0 +1,6 @@ +--- +'thebe-react': patch +'thebe-core': patch +--- + +Fixes a cross package import from `core` to `react` that caused downstream SSR to fail diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 88010854..5b5de244 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -5,7 +5,6 @@ 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; export type SessionIModel = Session.IModel; @@ -98,7 +97,7 @@ export interface IThebeCell extends IPassiveCell { source: string; session?: ThebeSession; metadata: JsonObject; - notebook?: ThebeNotebook; + notebookId?: string; readonly isBusy: boolean; readonly isAttached: boolean; readonly tags: string[]; diff --git a/packages/react/src/hooks/notebook.ts b/packages/react/src/hooks/notebook.ts index 1a8a2831..162e3275 100644 --- a/packages/react/src/hooks/notebook.ts +++ b/packages/react/src/hooks/notebook.ts @@ -1,20 +1,14 @@ import { createRef, useEffect, useState } from 'react'; -import { - type ThebeNotebook, - type ThebeSession, - type IThebeCell, - type IThebeCellExecuteReturn, - ThebePassiveManager, - WIDGET_VIEW_MIMETYPE, - WIDGET_STATE_MIMETYPE, -} from 'thebe-core'; +import type { ThebeNotebook, ThebeSession, IThebeCell, IThebeCellExecuteReturn } from 'thebe-core'; import { useThebeConfig } from '../ThebeServerProvider'; import { useThebeLoader } from '../ThebeLoaderProvider'; -import type { IExecuteResult, INotebookContent } from '@jupyterlab/nbformat'; +import type { 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; @@ -168,7 +162,7 @@ export function useNotebook( }) .then((nb: ThebeNotebook) => { const cells = opts?.refsForWidgetsOnly ? nb?.widgets ?? [] : nb?.cells ?? []; - const manager = new ThebePassiveManager(rendermime); + const manager = new core.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); }