UNPKG

1.48 kBPlain TextView Raw
1import { Application, ModulesManager, PageMetaManager, Seance } from "neweb-browser";
2import { INITIAL_VAR, ISeanceInitialInfo } from "neweb-core";
3import { ClientPageRenderer } from "neweb-react/client";
4import React = require("react");
5import ReactDOM = require("react-dom");
6
7import SocketIOClient = require("socket.io-client");
8
9const initial: ISeanceInitialInfo = (window as any)[INITIAL_VAR];
10const socket = SocketIOClient(window.location.protocol + "//" + window.location.host);
11const 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});
28const app = new Application({
29 modulesManager,
30});
31const pageRenderer = new ClientPageRenderer({
32 app,
33 rootHtmlElement: document.getElementById("root"),
34});
35const pageMetaManager = new PageMetaManager();
36const seance = new Seance({
37 app,
38 seanceId: initial.seanceId,
39 socket,
40 pageRenderer,
41 pageMetaManager,
42});
43const logger = console;
44seance.initialize(initial).then(() => {
45 window.dispatchEvent(new Event("neweb-seans-initialized"));
46 logger.log("Initialized");
47});
48(window as any).global = window;