Skip to content

Commit

Permalink
🛠️ fix/direct import bug (#757)
Browse files Browse the repository at this point in the history
* ✨keep types pure

* 🙈 don't import objects from core to react

* 📗changeset
  • Loading branch information
stevejpurves authored Jul 19, 2024
1 parent a16c823 commit 95eb9b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changeset/pink-impalas-scream.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>;
export type SessionIModel = Session.IModel;
Expand Down Expand Up @@ -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[];
Expand Down
16 changes: 5 additions & 11 deletions packages/react/src/hooks/notebook.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 95eb9b5

Please sign in to comment.