UNPKG

1.76 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const debug = require("debug");
4const neweb_browser_1 = require("neweb-browser");
5const neweb_components_1 = require("neweb-components");
6const neweb_core_1 = require("neweb-core");
7const Neweb = require("./common");
8if (process.env.NODE_ENV === "development") {
9 debug.enable("*,-socket.io:*,-engine:*,-socket.io-client:*,-engine.io-client:*,-socket.io-client,-socket.io-parser");
10}
11const SocketIOClient = require("socket.io-client");
12const initial = window[neweb_core_1.INITIAL_VAR];
13const socket = SocketIOClient(window.location.protocol + "//" + window.location.host);
14const modulesManager = new neweb_browser_1.ModulesManager({
15 address: window.location.protocol + "//" + window.location.host + "/modules",
16 modules: [{
17 name: "neweb",
18 version: undefined,
19 type: "npm",
20 content: "",
21 exports: Neweb,
22 },
23 ],
24});
25const app = new neweb_browser_1.Application({
26 modulesManager,
27});
28const pageRenderer = new neweb_components_1.ClientPageRenderer({
29 app,
30 rootHtmlElement: document.getElementById("root"),
31});
32const pageMetaManager = new neweb_browser_1.PageMetaManager();
33const seance = new neweb_browser_1.Seance({
34 app,
35 seanceId: initial.seanceId,
36 socket,
37 pageRenderer,
38 pageMetaManager,
39});
40const realPushState = history.pushState.bind(history);
41history.pushState = (url) => {
42 seance.navigate(url);
43 realPushState(url, "", url);
44};
45const logger = console;
46seance.initialize(initial).then(() => {
47 window.dispatchEvent(new Event("neweb-seans-initialized"));
48 logger.log("Initialized");
49});
50window.global = window;