Skip to content

Commit 3404597

Browse files
committed
🛠️ fix/direct import bug (#757)
* ✨keep types pure * 🙈 don't import objects from core to react * 📗changeset
1 parent 28080e5 commit 3404597

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

.changeset/pink-impalas-scream.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'thebe-react': patch
3+
'thebe-core': patch
4+
---
5+
6+
Fixes a cross package import from `core` to `react` that caused downstream SSR to fail

packages/core/src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { IRenderMimeRegistry } from '@jupyterlab/rendermime';
55
import type ThebeServer from './server';
66
import type { ServerStatusEvent } from './events';
77
import type { Config } from './config';
8-
import type ThebeNotebook from './notebook';
98
export type CellKind = 'code' | 'markdown';
109
export type JsonObject = Record<string, any>;
1110
export type SessionIModel = Session.IModel;
@@ -98,7 +97,7 @@ export interface IThebeCell extends IPassiveCell {
9897
source: string;
9998
session?: ThebeSession;
10099
metadata: JsonObject;
101-
notebook?: ThebeNotebook;
100+
notebookId?: string;
102101
readonly isBusy: boolean;
103102
readonly isAttached: boolean;
104103
readonly tags: string[];

packages/react/src/hooks/notebook.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import { createRef, useEffect, useState } from 'react';
2-
import {
3-
type ThebeNotebook,
4-
type ThebeSession,
5-
type IThebeCell,
6-
type IThebeCellExecuteReturn,
7-
ThebePassiveManager,
8-
WIDGET_VIEW_MIMETYPE,
9-
WIDGET_STATE_MIMETYPE,
10-
} from 'thebe-core';
2+
import type { ThebeNotebook, ThebeSession, IThebeCell, IThebeCellExecuteReturn } from 'thebe-core';
113
import { useThebeConfig } from '../ThebeServerProvider';
124
import { useThebeLoader } from '../ThebeLoaderProvider';
13-
import type { IExecuteResult, INotebookContent } from '@jupyterlab/nbformat';
5+
import type { INotebookContent } from '@jupyterlab/nbformat';
146
import { useThebeSession } from '../ThebeSessionProvider';
157
import { useRenderMimeRegistry } from '../ThebeRenderMimeRegistryProvider';
168
import type { IManagerState } from '@jupyter-widgets/base-manager';
179

10+
export const WIDGET_STATE_MIMETYPE = 'application/vnd.jupyter.widget-state+json';
11+
1812
export interface NotebookExecuteOptions {
1913
stopOnError?: boolean;
2014
before?: () => void;
@@ -168,7 +162,7 @@ export function useNotebook(
168162
})
169163
.then((nb: ThebeNotebook) => {
170164
const cells = opts?.refsForWidgetsOnly ? nb?.widgets ?? [] : nb?.cells ?? [];
171-
const manager = new ThebePassiveManager(rendermime);
165+
const manager = new core.ThebePassiveManager(rendermime);
172166
if (nb.metadata.widgets && (nb.metadata.widgets as any)[WIDGET_STATE_MIMETYPE]) {
173167
manager.load_state((nb.metadata.widgets as any)[WIDGET_STATE_MIMETYPE] as IManagerState);
174168
}

0 commit comments

Comments
 (0)