1 | import { Application, ModulesManager, PageMetaManager, Seance } from "neweb-browser";
|
2 | import { INITIAL_VAR, ISeanceInitialInfo } from "neweb-core";
|
3 | import { ClientPageRenderer } from "neweb-react/client";
|
4 | import React = require("react");
|
5 | import ReactDOM = require("react-dom");
|
6 |
|
7 | import SocketIOClient = require("socket.io-client");
|
8 |
|
9 | const initial: ISeanceInitialInfo = (window as any)[INITIAL_VAR];
|
10 | const socket = SocketIOClient(window.location.protocol + "//" + window.location.host);
|
11 | const modulesManager = new ModulesManager({
|
12 | address: window.location.protocol + "//" + window.location.host + "/modules",
|
13 | modules: [{
|
14 | name: "react",
|
15 | version: undefined,
|
16 | type: "npm",
|
17 | content: "",
|
18 | exports: React,
|
19 | },
|
20 | {
|
21 | name: "react-dom",
|
22 | version: undefined,
|
23 | type: "npm",
|
24 | content: "",
|
25 | exports: ReactDOM,
|
26 | }],
|
27 | });
|
28 | const app = new Application({
|
29 | modulesManager,
|
30 | });
|
31 | const pageRenderer = new ClientPageRenderer({
|
32 | app,
|
33 | rootHtmlElement: document.getElementById("root"),
|
34 | });
|
35 | const pageMetaManager = new PageMetaManager();
|
36 | const seance = new Seance({
|
37 | app,
|
38 | seanceId: initial.seanceId,
|
39 | socket,
|
40 | pageRenderer,
|
41 | pageMetaManager,
|
42 | });
|
43 | const logger = console;
|
44 | seance.initialize(initial).then(() => {
|
45 | window.dispatchEvent(new Event("neweb-seans-initialized"));
|
46 | logger.log("Initialized");
|
47 | });
|
48 | (window as any).global = window;
|