nope/pages/_app.tsx

59 lines
1.7 KiB
TypeScript
Raw Normal View History

2020-12-01 12:05:35 +00:00
import "@fortawesome/fontawesome-svg-core/styles.css";
// import "bootstrap/dist/css/bootstrap.min.css";
// import "bootswatch/dist/materia/bootstrap.min.css";
2021-07-30 05:50:02 +00:00
import "bootswatch/dist/yeti/bootstrap.min.css";
// import "bootswatch/dist/darkly/bootstrap.min.css";
import { useEffect } from "react";
2020-12-01 12:05:35 +00:00
import "react-grid-layout/css/styles.css";
import "reflect-metadata";
import "swagger-ui-react/swagger-ui.css";
2021-04-14 09:58:41 +00:00
import { Bridge } from "../lib/communication/bridge";
import { IoSocketMirrorClient } from "../lib/communication/mirrors/ioSocketMirrorClient";
import { getDispatcher } from "../lib/dispatcher/getDispatcher";
2021-02-12 07:39:03 +00:00
import { nopeDispatcherManager } from "../lib/dispatcher/nopeDispatcherManager";
import { getNopeLogger } from "../lib/logger/getLogger";
2021-02-12 07:39:03 +00:00
import { ICommunicationBridge } from "../lib/types/nope/nopeCommunication.interface";
2020-08-19 06:36:59 +00:00
2020-12-30 18:59:00 +00:00
export default function App({ Component, pageProps, hostname }) {
2021-07-30 05:50:02 +00:00
const bridge = new Bridge(
2021-04-14 09:58:41 +00:00
"browser",
"bridge",
"info"
2021-07-30 05:50:02 +00:00
) as any as ICommunicationBridge;
2021-04-14 09:58:41 +00:00
bridge.addMirror(
new IoSocketMirrorClient(require("os").hostname() + ":7000", "info"),
true
);
2021-05-13 08:04:51 +00:00
const dispatcher: any = getDispatcher(
2021-03-24 06:50:36 +00:00
{
2021-04-14 09:58:41 +00:00
communicator: bridge,
2021-07-30 05:50:02 +00:00
logger: getNopeLogger("dispatcher", "info"),
2021-03-24 06:50:36 +00:00
},
nopeDispatcherManager
);
useEffect(() => {
2021-05-13 08:04:51 +00:00
const dispatcher: any = getDispatcher(
{
communicator: bridge,
2021-07-30 05:50:02 +00:00
logger: getNopeLogger("dispatcher", "info"),
2021-05-13 08:04:51 +00:00
},
nopeDispatcherManager
);
return () => {
// componentwillunmount in functional component.
// Anything in here is fired on component unmount.
dispatcher.dispose();
};
}, []);
const params = {
dispatcher,
2021-07-30 05:50:02 +00:00
...pageProps,
};
return <Component {...params} />;
2020-12-01 12:05:35 +00:00
}