Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/SOF-7291-1 #71

Merged
merged 10 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dist/index.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dist/index.js

This file was deleted.

15 changes: 0 additions & 15 deletions dist/mui/components/custom/alert/AlertContextProvider.d.ts

This file was deleted.

45 changes: 0 additions & 45 deletions dist/mui/components/custom/alert/AlertContextProvider.js

This file was deleted.

3 changes: 0 additions & 3 deletions dist/mui/components/custom/alert/hooks/useAlert.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions dist/mui/components/custom/alert/hooks/useAlert.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/mui/components/custom/alert/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion dist/mui/components/custom/alert/index.js

This file was deleted.

7 changes: 0 additions & 7 deletions dist/mui/components/stepper/StepIcon.d.ts

This file was deleted.

56 changes: 0 additions & 56 deletions dist/mui/components/stepper/StepIcon.js

This file was deleted.

2 changes: 0 additions & 2 deletions dist/mui/components/stepper/Stepper.styled.d.ts

This file was deleted.

45 changes: 0 additions & 45 deletions dist/mui/components/stepper/Stepper.styled.js

This file was deleted.

19 changes: 0 additions & 19 deletions dist/mui/components/textField/BasicTextField.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions dist/mui/components/textField/BasicTextField.js

This file was deleted.

2 changes: 0 additions & 2 deletions dist/mui/components/textField/index.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dist/mui/components/textField/index.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/other/fullscreen/test.d.ts

This file was deleted.

8 changes: 0 additions & 8 deletions dist/other/fullscreen/test.js

This file was deleted.

17 changes: 11 additions & 6 deletions dist/other/iframe-messaging/IframeToFromHostMessageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ class IframeToFromHostMessageHandler {
if (event.data.type === "from-iframe-to-host") {
const { action, payload } = event.data;
if (this.handlers[action]) {
this.handlers["set-data"].forEach((handler) => {
handler(payload);
});
this.handlers["get-data"].forEach((handler) => {
const data = handler();
this.sendData(data);
this.handlers[action].forEach((handler) => {
Promise.resolve(handler(payload))
.then((data) => {
// If the handler returns data, send it to the iframe
if (data !== undefined) {
this.sendData(data);
}
})
.catch((error) => {
console.error(`Error in handler for ${action}:`, error);
});
});
}
}
Expand Down
1 change: 0 additions & 1 deletion dist/other/iframe-messaging/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion dist/other/iframe-messaging/index.js

This file was deleted.

11 changes: 9 additions & 2 deletions dist/other/jupyterlite/JupyterLiteSession.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { IframeMessageSchema } from "@mat3ra/esse/dist/js/types";
import React from "react";
import IframeToFromHostMessageHandler from "../iframe-messaging/IframeToFromHostMessageHandler";
interface JupyterLiteSessionProps {
export interface IMessageHandlerConfigItem {
action: IframeMessageSchema["action"];
handlers: ((...args: any[]) => void)[];
}
export interface JupyterLiteSessionProps {
originURL: string;
defaultNotebookPath?: string;
iframeId: string;
messageHandler?: IframeToFromHostMessageHandler;
messageHandlerConfigs?: IMessageHandlerConfigItem[];
}
declare class JupyterLiteSession extends React.Component<JupyterLiteSessionProps> {
static defaultProps: JupyterLiteSessionProps;
messageHandler: IframeToFromHostMessageHandler;
constructor(props?: JupyterLiteSessionProps);
componentDidMount(): void;
componentWillUnmount(): void;
sendData: (data: any) => void;
render(): React.JSX.Element;
}
export default JupyterLiteSession;
16 changes: 12 additions & 4 deletions dist/other/jupyterlite/JupyterLiteSession.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import IframeToFromHostMessageHandler from "../iframe-messaging/IframeToFromHostMessageHandler";
const defaultProps = {
// eslint-disable-next-line react/default-props-match-prop-types
originURL: "https://jupyterlite.mat3ra.com",
Expand All @@ -8,14 +9,21 @@ const defaultProps = {
class JupyterLiteSession extends React.Component {
constructor(props = defaultProps) {
super(props);
this.messageHandler = new IframeToFromHostMessageHandler();
// eslint-disable-next-line react/no-unused-class-component-methods
this.sendData = (data) => {
this.messageHandler.sendData(data);
};
}
componentDidMount() {
const { messageHandler, originURL, iframeId } = this.props;
messageHandler === null || messageHandler === void 0 ? void 0 : messageHandler.init(originURL, iframeId);
const { originURL, iframeId, messageHandlerConfigs } = this.props;
this.messageHandler.init(originURL, iframeId);
messageHandlerConfigs === null || messageHandlerConfigs === void 0 ? void 0 : messageHandlerConfigs.forEach((config) => {
this.messageHandler.addHandlers(config.action, config.handlers);
});
}
componentWillUnmount() {
const { messageHandler } = this.props;
messageHandler === null || messageHandler === void 0 ? void 0 : messageHandler.destroy();
this.messageHandler.destroy();
}
render() {
const { defaultNotebookPath, originURL, iframeId } = this.props;
Expand Down
14 changes: 0 additions & 14 deletions dist/other/jupyterlite/MessageHandler.d.ts

This file was deleted.

57 changes: 0 additions & 57 deletions dist/other/jupyterlite/MessageHandler.js

This file was deleted.

Loading
Loading