Skip to content

Commit

Permalink
update: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Mar 14, 2024
1 parent 04aece5 commit 618f517
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/other/jupyterlite/JupyterLiteSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface JupyterLiteSessionProps {
originURL: string;
defaultNotebookPath?: string;
frameId: string;
receiveData?: (data: any) => void;
onMessage?: (message: JupyterliteMessageSchema) => void;
}

class JupyterLiteSession extends React.Component<JupyterLiteSessionProps> {
Expand All @@ -26,12 +26,12 @@ class JupyterLiteSession extends React.Component<JupyterLiteSessionProps> {
if (event.origin !== new URL(this.props.originURL).origin) return;
if (event.data) {
if (event.data.type === "from-iframe-to-host") {
if (this.props.receiveData) this.props.receiveData(event.data);
if (this.props.onMessage) this.props.onMessage(event.data);
}
}
};

sendData = (data: Record<string, unknown>[], variableName: string) => {
sendData = (data: never, variableName: string) => {
const message: JupyterliteMessageSchema = {
type: "from-host-to-iframe",
payload: {data: data, variableName: variableName},
Expand All @@ -45,14 +45,15 @@ class JupyterLiteSession extends React.Component<JupyterLiteSessionProps> {
};

render() {
const src = this.props.defaultNotebookPath
? `${this.props.originURL}/lab/tree?path=${this.props.defaultNotebookPath}`
: `${this.props.originURL}/lab`;
const {defaultNotebookPath, originURL, frameId} = this.props;
const src = defaultNotebookPath
? `${originURL}/lab/tree?path=${defaultNotebookPath}`
: `${originURL}/lab`;
return (
<iframe
name="jupyterlite"
title="JupyterLite"
id={this.props.frameId}
id={frameId}
src={src}
sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-top-navigation-by-user-activation allow-downloads"
width="100%"
Expand Down

0 comments on commit 618f517

Please sign in to comment.