├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .npmrc ├── LICENSE ├── README.md ├── esbuild.config.mjs ├── main.css ├── main.js ├── main.ts ├── manifest.json ├── media └── plot3d_demo.gif ├── package-lock.json ├── package.json ├── postcss.config.js ├── styles.css ├── tailwind.config.js ├── tsconfig.json ├── version-bump.mjs └── versions.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | insert_final_newline = true 7 | indent_style = tab 8 | indent_size = 4 9 | tab_width = 4 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | npm node_modules 2 | build -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "env": { "node": true }, 5 | "plugins": [ 6 | "@typescript-eslint" 7 | ], 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-unused-vars": "off", 18 | "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], 19 | "@typescript-eslint/ban-ts-comment": "off", 20 | "no-prototype-builtins": "off", 21 | "@typescript-eslint/no-empty-function": "off" 22 | } 23 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | .vscode 3 | 4 | # Intellij 5 | *.iml 6 | .idea 7 | 8 | # npm 9 | node_modules 10 | 11 | # Don't include the compiled main.js file in the repo. 12 | # They should be uploaded to GitHub releases instead. 13 | #main.js # TODO: commenting out because this has not been published yet 14 | 15 | # Exclude sourcemaps 16 | *.map 17 | 18 | # obsidian 19 | data.json 20 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix="" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Exr0n 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Obsidian Sage 2 | 3 | ![demo gif](./media/plot3d_demo.gif) 4 | 5 | Live-preview ready Sage Math codeblocks for [Obsidian](https://obsidian.md). Heavily inspired by [the original obsidian-sagecell](https://github.com/EricR/obsidian-sagecell). 6 | 7 | To use, create a code block with the custom `sage` language marker, then write some valid Sage. 8 | 9 | ### Installing 10 | 11 | `cd /path/to/vault/.obsidian/plugins`, clone this repo, then `npm i && npm run build` inside. Or, find the plugin on the [showcase](TODO). 12 | 13 | ### Usage 14 | Create a code block with the custom `sage` language marker, then write some valid Sage. The interactive output will show up once you close the code block and move your cursor out of it. 15 | 16 | Errors may not render properly--if nothing shows up, try copying your SageMath code into the [sagecell server](https://sagecell.sagemath.org/) directly. 17 | 18 | ### Self Hosting 19 | 20 | This plugin uses [the public sagecell server](https://sagecell.sagemath.org/) run by SageMath, Inc (as described on the sagecell server website). You can also [host your own SageCell server](https://github.com/sagemath/sagecell/blob/master/contrib/vm/README.md), then point the `obsidian-sage` plugin to use it in the plugin settings. 21 | 22 | -------------------------------------------------------------------------------- /esbuild.config.mjs: -------------------------------------------------------------------------------- 1 | import esbuild from "esbuild"; 2 | import process from "process"; 3 | import builtins from 'builtin-modules' 4 | 5 | const banner = 6 | `/* 7 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 8 | if you want to view the source, please visit the github repository of this plugin 9 | */ 10 | `; 11 | 12 | const prod = (process.argv[2] === 'production'); 13 | 14 | esbuild.build({ 15 | banner: { 16 | js: banner, 17 | }, 18 | entryPoints: ['main.ts'], 19 | bundle: true, 20 | external: [ 21 | 'obsidian', 22 | 'electron', 23 | '@codemirror/autocomplete', 24 | '@codemirror/closebrackets', 25 | '@codemirror/collab', 26 | '@codemirror/commands', 27 | '@codemirror/comment', 28 | '@codemirror/fold', 29 | '@codemirror/gutter', 30 | '@codemirror/highlight', 31 | '@codemirror/history', 32 | '@codemirror/language', 33 | '@codemirror/lint', 34 | '@codemirror/matchbrackets', 35 | '@codemirror/panel', 36 | '@codemirror/rangeset', 37 | '@codemirror/rectangular-selection', 38 | '@codemirror/search', 39 | '@codemirror/state', 40 | '@codemirror/stream-parser', 41 | '@codemirror/text', 42 | '@codemirror/tooltip', 43 | '@codemirror/view', 44 | ...builtins], 45 | format: 'cjs', 46 | watch: !prod, 47 | target: 'es2016', 48 | logLevel: "info", 49 | sourcemap: prod ? false : 'inline', 50 | treeShaking: true, 51 | outfile: 'main.js', 52 | }).catch(() => process.exit(1)); 53 | -------------------------------------------------------------------------------- /main.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | /* 2 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 3 | if you want to view the source, please visit the github repository of this plugin 4 | */ 5 | 6 | var __create = Object.create; 7 | var __defProp = Object.defineProperty; 8 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 9 | var __getOwnPropNames = Object.getOwnPropertyNames; 10 | var __getProtoOf = Object.getPrototypeOf; 11 | var __hasOwnProp = Object.prototype.hasOwnProperty; 12 | var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); 13 | var __commonJS = (cb, mod) => function __require() { 14 | return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 15 | }; 16 | var __export = (target, all) => { 17 | __markAsModule(target); 18 | for (var name in all) 19 | __defProp(target, name, { get: all[name], enumerable: true }); 20 | }; 21 | var __reExport = (target, module2, desc) => { 22 | if (module2 && typeof module2 === "object" || typeof module2 === "function") { 23 | for (let key of __getOwnPropNames(module2)) 24 | if (!__hasOwnProp.call(target, key) && key !== "default") 25 | __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); 26 | } 27 | return target; 28 | }; 29 | var __toModule = (module2) => { 30 | return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); 31 | }; 32 | var __async = (__this, __arguments, generator) => { 33 | return new Promise((resolve, reject) => { 34 | var fulfilled = (value) => { 35 | try { 36 | step(generator.next(value)); 37 | } catch (e) { 38 | reject(e); 39 | } 40 | }; 41 | var rejected = (value) => { 42 | try { 43 | step(generator.throw(value)); 44 | } catch (e) { 45 | reject(e); 46 | } 47 | }; 48 | var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); 49 | step((generator = generator.apply(__this, __arguments)).next()); 50 | }); 51 | }; 52 | 53 | // node_modules/sockjs-client/lib/utils/random.js 54 | var require_random = __commonJS({ 55 | "node_modules/sockjs-client/lib/utils/random.js"(exports, module2) { 56 | "use strict"; 57 | var crypto2 = require("crypto"); 58 | var _randomStringChars = "abcdefghijklmnopqrstuvwxyz012345"; 59 | module2.exports = { 60 | string: function(length) { 61 | var max = _randomStringChars.length; 62 | var bytes = crypto2.randomBytes(length); 63 | var ret = []; 64 | for (var i = 0; i < length; i++) { 65 | ret.push(_randomStringChars.substr(bytes[i] % max, 1)); 66 | } 67 | return ret.join(""); 68 | }, 69 | number: function(max) { 70 | return Math.floor(Math.random() * max); 71 | }, 72 | numberString: function(max) { 73 | var t = ("" + (max - 1)).length; 74 | var p = new Array(t + 1).join("0"); 75 | return (p + this.number(max)).slice(-t); 76 | } 77 | }; 78 | } 79 | }); 80 | 81 | // node_modules/sockjs-client/lib/utils/event.js 82 | var require_event = __commonJS({ 83 | "node_modules/sockjs-client/lib/utils/event.js"(exports, module2) { 84 | "use strict"; 85 | var random = require_random(); 86 | var onUnload = {}; 87 | var afterUnload = false; 88 | var isChromePackagedApp = global.chrome && global.chrome.app && global.chrome.app.runtime; 89 | module2.exports = { 90 | attachEvent: function(event, listener) { 91 | if (typeof global.addEventListener !== "undefined") { 92 | global.addEventListener(event, listener, false); 93 | } else if (global.document && global.attachEvent) { 94 | global.document.attachEvent("on" + event, listener); 95 | global.attachEvent("on" + event, listener); 96 | } 97 | }, 98 | detachEvent: function(event, listener) { 99 | if (typeof global.addEventListener !== "undefined") { 100 | global.removeEventListener(event, listener, false); 101 | } else if (global.document && global.detachEvent) { 102 | global.document.detachEvent("on" + event, listener); 103 | global.detachEvent("on" + event, listener); 104 | } 105 | }, 106 | unloadAdd: function(listener) { 107 | if (isChromePackagedApp) { 108 | return null; 109 | } 110 | var ref = random.string(8); 111 | onUnload[ref] = listener; 112 | if (afterUnload) { 113 | setTimeout(this.triggerUnloadCallbacks, 0); 114 | } 115 | return ref; 116 | }, 117 | unloadDel: function(ref) { 118 | if (ref in onUnload) { 119 | delete onUnload[ref]; 120 | } 121 | }, 122 | triggerUnloadCallbacks: function() { 123 | for (var ref in onUnload) { 124 | onUnload[ref](); 125 | delete onUnload[ref]; 126 | } 127 | } 128 | }; 129 | var unloadTriggered = function() { 130 | if (afterUnload) { 131 | return; 132 | } 133 | afterUnload = true; 134 | module2.exports.triggerUnloadCallbacks(); 135 | }; 136 | if (!isChromePackagedApp) { 137 | module2.exports.attachEvent("unload", unloadTriggered); 138 | } 139 | } 140 | }); 141 | 142 | // node_modules/requires-port/index.js 143 | var require_requires_port = __commonJS({ 144 | "node_modules/requires-port/index.js"(exports, module2) { 145 | "use strict"; 146 | module2.exports = function required(port, protocol) { 147 | protocol = protocol.split(":")[0]; 148 | port = +port; 149 | if (!port) 150 | return false; 151 | switch (protocol) { 152 | case "http": 153 | case "ws": 154 | return port !== 80; 155 | case "https": 156 | case "wss": 157 | return port !== 443; 158 | case "ftp": 159 | return port !== 21; 160 | case "gopher": 161 | return port !== 70; 162 | case "file": 163 | return false; 164 | } 165 | return port !== 0; 166 | }; 167 | } 168 | }); 169 | 170 | // node_modules/querystringify/index.js 171 | var require_querystringify = __commonJS({ 172 | "node_modules/querystringify/index.js"(exports) { 173 | "use strict"; 174 | var has = Object.prototype.hasOwnProperty; 175 | var undef; 176 | function decode(input) { 177 | try { 178 | return decodeURIComponent(input.replace(/\+/g, " ")); 179 | } catch (e) { 180 | return null; 181 | } 182 | } 183 | function encode(input) { 184 | try { 185 | return encodeURIComponent(input); 186 | } catch (e) { 187 | return null; 188 | } 189 | } 190 | function querystring(query) { 191 | var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part; 192 | while (part = parser.exec(query)) { 193 | var key = decode(part[1]), value = decode(part[2]); 194 | if (key === null || value === null || key in result) 195 | continue; 196 | result[key] = value; 197 | } 198 | return result; 199 | } 200 | function querystringify(obj, prefix) { 201 | prefix = prefix || ""; 202 | var pairs = [], value, key; 203 | if (typeof prefix !== "string") 204 | prefix = "?"; 205 | for (key in obj) { 206 | if (has.call(obj, key)) { 207 | value = obj[key]; 208 | if (!value && (value === null || value === undef || isNaN(value))) { 209 | value = ""; 210 | } 211 | key = encode(key); 212 | value = encode(value); 213 | if (key === null || value === null) 214 | continue; 215 | pairs.push(key + "=" + value); 216 | } 217 | } 218 | return pairs.length ? prefix + pairs.join("&") : ""; 219 | } 220 | exports.stringify = querystringify; 221 | exports.parse = querystring; 222 | } 223 | }); 224 | 225 | // node_modules/url-parse/index.js 226 | var require_url_parse = __commonJS({ 227 | "node_modules/url-parse/index.js"(exports, module2) { 228 | "use strict"; 229 | var required = require_requires_port(); 230 | var qs = require_querystringify(); 231 | var controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/; 232 | var CRHTLF = /[\n\r\t]/g; 233 | var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//; 234 | var port = /:\d+$/; 235 | var protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i; 236 | var windowsDriveLetter = /^[a-zA-Z]:/; 237 | function trimLeft(str) { 238 | return (str ? str : "").toString().replace(controlOrWhitespace, ""); 239 | } 240 | var rules = [ 241 | ["#", "hash"], 242 | ["?", "query"], 243 | function sanitize(address, url) { 244 | return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address; 245 | }, 246 | ["/", "pathname"], 247 | ["@", "auth", 1], 248 | [NaN, "host", void 0, 1, 1], 249 | [/:(\d*)$/, "port", void 0, 1], 250 | [NaN, "hostname", void 0, 1, 1] 251 | ]; 252 | var ignore = { hash: 1, query: 1 }; 253 | function lolcation(loc) { 254 | var globalVar; 255 | if (typeof window !== "undefined") 256 | globalVar = window; 257 | else if (typeof global !== "undefined") 258 | globalVar = global; 259 | else if (typeof self !== "undefined") 260 | globalVar = self; 261 | else 262 | globalVar = {}; 263 | var location = globalVar.location || {}; 264 | loc = loc || location; 265 | var finaldestination = {}, type = typeof loc, key; 266 | if (loc.protocol === "blob:") { 267 | finaldestination = new Url(unescape(loc.pathname), {}); 268 | } else if (type === "string") { 269 | finaldestination = new Url(loc, {}); 270 | for (key in ignore) 271 | delete finaldestination[key]; 272 | } else if (type === "object") { 273 | for (key in loc) { 274 | if (key in ignore) 275 | continue; 276 | finaldestination[key] = loc[key]; 277 | } 278 | if (finaldestination.slashes === void 0) { 279 | finaldestination.slashes = slashes.test(loc.href); 280 | } 281 | } 282 | return finaldestination; 283 | } 284 | function isSpecial(scheme) { 285 | return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:"; 286 | } 287 | function extractProtocol(address, location) { 288 | address = trimLeft(address); 289 | address = address.replace(CRHTLF, ""); 290 | location = location || {}; 291 | var match = protocolre.exec(address); 292 | var protocol = match[1] ? match[1].toLowerCase() : ""; 293 | var forwardSlashes = !!match[2]; 294 | var otherSlashes = !!match[3]; 295 | var slashesCount = 0; 296 | var rest; 297 | if (forwardSlashes) { 298 | if (otherSlashes) { 299 | rest = match[2] + match[3] + match[4]; 300 | slashesCount = match[2].length + match[3].length; 301 | } else { 302 | rest = match[2] + match[4]; 303 | slashesCount = match[2].length; 304 | } 305 | } else { 306 | if (otherSlashes) { 307 | rest = match[3] + match[4]; 308 | slashesCount = match[3].length; 309 | } else { 310 | rest = match[4]; 311 | } 312 | } 313 | if (protocol === "file:") { 314 | if (slashesCount >= 2) { 315 | rest = rest.slice(2); 316 | } 317 | } else if (isSpecial(protocol)) { 318 | rest = match[4]; 319 | } else if (protocol) { 320 | if (forwardSlashes) { 321 | rest = rest.slice(2); 322 | } 323 | } else if (slashesCount >= 2 && isSpecial(location.protocol)) { 324 | rest = match[4]; 325 | } 326 | return { 327 | protocol, 328 | slashes: forwardSlashes || isSpecial(protocol), 329 | slashesCount, 330 | rest 331 | }; 332 | } 333 | function resolve(relative, base) { 334 | if (relative === "") 335 | return base; 336 | var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0; 337 | while (i--) { 338 | if (path[i] === ".") { 339 | path.splice(i, 1); 340 | } else if (path[i] === "..") { 341 | path.splice(i, 1); 342 | up++; 343 | } else if (up) { 344 | if (i === 0) 345 | unshift = true; 346 | path.splice(i, 1); 347 | up--; 348 | } 349 | } 350 | if (unshift) 351 | path.unshift(""); 352 | if (last === "." || last === "..") 353 | path.push(""); 354 | return path.join("/"); 355 | } 356 | function Url(address, location, parser) { 357 | address = trimLeft(address); 358 | address = address.replace(CRHTLF, ""); 359 | if (!(this instanceof Url)) { 360 | return new Url(address, location, parser); 361 | } 362 | var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0; 363 | if (type !== "object" && type !== "string") { 364 | parser = location; 365 | location = null; 366 | } 367 | if (parser && typeof parser !== "function") 368 | parser = qs.parse; 369 | location = lolcation(location); 370 | extracted = extractProtocol(address || "", location); 371 | relative = !extracted.protocol && !extracted.slashes; 372 | url.slashes = extracted.slashes || relative && location.slashes; 373 | url.protocol = extracted.protocol || location.protocol || ""; 374 | address = extracted.rest; 375 | if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) { 376 | instructions[3] = [/(.*)/, "pathname"]; 377 | } 378 | for (; i < instructions.length; i++) { 379 | instruction = instructions[i]; 380 | if (typeof instruction === "function") { 381 | address = instruction(address, url); 382 | continue; 383 | } 384 | parse = instruction[0]; 385 | key = instruction[1]; 386 | if (parse !== parse) { 387 | url[key] = address; 388 | } else if (typeof parse === "string") { 389 | index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse); 390 | if (~index) { 391 | if (typeof instruction[2] === "number") { 392 | url[key] = address.slice(0, index); 393 | address = address.slice(index + instruction[2]); 394 | } else { 395 | url[key] = address.slice(index); 396 | address = address.slice(0, index); 397 | } 398 | } 399 | } else if (index = parse.exec(address)) { 400 | url[key] = index[1]; 401 | address = address.slice(0, index.index); 402 | } 403 | url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : ""); 404 | if (instruction[4]) 405 | url[key] = url[key].toLowerCase(); 406 | } 407 | if (parser) 408 | url.query = parser(url.query); 409 | if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) { 410 | url.pathname = resolve(url.pathname, location.pathname); 411 | } 412 | if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) { 413 | url.pathname = "/" + url.pathname; 414 | } 415 | if (!required(url.port, url.protocol)) { 416 | url.host = url.hostname; 417 | url.port = ""; 418 | } 419 | url.username = url.password = ""; 420 | if (url.auth) { 421 | index = url.auth.indexOf(":"); 422 | if (~index) { 423 | url.username = url.auth.slice(0, index); 424 | url.username = encodeURIComponent(decodeURIComponent(url.username)); 425 | url.password = url.auth.slice(index + 1); 426 | url.password = encodeURIComponent(decodeURIComponent(url.password)); 427 | } else { 428 | url.username = encodeURIComponent(decodeURIComponent(url.auth)); 429 | } 430 | url.auth = url.password ? url.username + ":" + url.password : url.username; 431 | } 432 | url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null"; 433 | url.href = url.toString(); 434 | } 435 | function set(part, value, fn) { 436 | var url = this; 437 | switch (part) { 438 | case "query": 439 | if (typeof value === "string" && value.length) { 440 | value = (fn || qs.parse)(value); 441 | } 442 | url[part] = value; 443 | break; 444 | case "port": 445 | url[part] = value; 446 | if (!required(value, url.protocol)) { 447 | url.host = url.hostname; 448 | url[part] = ""; 449 | } else if (value) { 450 | url.host = url.hostname + ":" + value; 451 | } 452 | break; 453 | case "hostname": 454 | url[part] = value; 455 | if (url.port) 456 | value += ":" + url.port; 457 | url.host = value; 458 | break; 459 | case "host": 460 | url[part] = value; 461 | if (port.test(value)) { 462 | value = value.split(":"); 463 | url.port = value.pop(); 464 | url.hostname = value.join(":"); 465 | } else { 466 | url.hostname = value; 467 | url.port = ""; 468 | } 469 | break; 470 | case "protocol": 471 | url.protocol = value.toLowerCase(); 472 | url.slashes = !fn; 473 | break; 474 | case "pathname": 475 | case "hash": 476 | if (value) { 477 | var char = part === "pathname" ? "/" : "#"; 478 | url[part] = value.charAt(0) !== char ? char + value : value; 479 | } else { 480 | url[part] = value; 481 | } 482 | break; 483 | case "username": 484 | case "password": 485 | url[part] = encodeURIComponent(value); 486 | break; 487 | case "auth": 488 | var index = value.indexOf(":"); 489 | if (~index) { 490 | url.username = value.slice(0, index); 491 | url.username = encodeURIComponent(decodeURIComponent(url.username)); 492 | url.password = value.slice(index + 1); 493 | url.password = encodeURIComponent(decodeURIComponent(url.password)); 494 | } else { 495 | url.username = encodeURIComponent(decodeURIComponent(value)); 496 | } 497 | } 498 | for (var i = 0; i < rules.length; i++) { 499 | var ins = rules[i]; 500 | if (ins[4]) 501 | url[ins[1]] = url[ins[1]].toLowerCase(); 502 | } 503 | url.auth = url.password ? url.username + ":" + url.password : url.username; 504 | url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null"; 505 | url.href = url.toString(); 506 | return url; 507 | } 508 | function toString(stringify) { 509 | if (!stringify || typeof stringify !== "function") 510 | stringify = qs.stringify; 511 | var query, url = this, host = url.host, protocol = url.protocol; 512 | if (protocol && protocol.charAt(protocol.length - 1) !== ":") 513 | protocol += ":"; 514 | var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : ""); 515 | if (url.username) { 516 | result += url.username; 517 | if (url.password) 518 | result += ":" + url.password; 519 | result += "@"; 520 | } else if (url.password) { 521 | result += ":" + url.password; 522 | result += "@"; 523 | } else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") { 524 | result += "@"; 525 | } 526 | if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) { 527 | host += ":"; 528 | } 529 | result += host + url.pathname; 530 | query = typeof url.query === "object" ? stringify(url.query) : url.query; 531 | if (query) 532 | result += query.charAt(0) !== "?" ? "?" + query : query; 533 | if (url.hash) 534 | result += url.hash; 535 | return result; 536 | } 537 | Url.prototype = { set, toString }; 538 | Url.extractProtocol = extractProtocol; 539 | Url.location = lolcation; 540 | Url.trimLeft = trimLeft; 541 | Url.qs = qs; 542 | module2.exports = Url; 543 | } 544 | }); 545 | 546 | // node_modules/sockjs-client/node_modules/ms/index.js 547 | var require_ms = __commonJS({ 548 | "node_modules/sockjs-client/node_modules/ms/index.js"(exports, module2) { 549 | var s = 1e3; 550 | var m = s * 60; 551 | var h = m * 60; 552 | var d = h * 24; 553 | var w = d * 7; 554 | var y = d * 365.25; 555 | module2.exports = function(val, options) { 556 | options = options || {}; 557 | var type = typeof val; 558 | if (type === "string" && val.length > 0) { 559 | return parse(val); 560 | } else if (type === "number" && isFinite(val)) { 561 | return options.long ? fmtLong(val) : fmtShort(val); 562 | } 563 | throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val)); 564 | }; 565 | function parse(str) { 566 | str = String(str); 567 | if (str.length > 100) { 568 | return; 569 | } 570 | var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str); 571 | if (!match) { 572 | return; 573 | } 574 | var n = parseFloat(match[1]); 575 | var type = (match[2] || "ms").toLowerCase(); 576 | switch (type) { 577 | case "years": 578 | case "year": 579 | case "yrs": 580 | case "yr": 581 | case "y": 582 | return n * y; 583 | case "weeks": 584 | case "week": 585 | case "w": 586 | return n * w; 587 | case "days": 588 | case "day": 589 | case "d": 590 | return n * d; 591 | case "hours": 592 | case "hour": 593 | case "hrs": 594 | case "hr": 595 | case "h": 596 | return n * h; 597 | case "minutes": 598 | case "minute": 599 | case "mins": 600 | case "min": 601 | case "m": 602 | return n * m; 603 | case "seconds": 604 | case "second": 605 | case "secs": 606 | case "sec": 607 | case "s": 608 | return n * s; 609 | case "milliseconds": 610 | case "millisecond": 611 | case "msecs": 612 | case "msec": 613 | case "ms": 614 | return n; 615 | default: 616 | return void 0; 617 | } 618 | } 619 | function fmtShort(ms) { 620 | var msAbs = Math.abs(ms); 621 | if (msAbs >= d) { 622 | return Math.round(ms / d) + "d"; 623 | } 624 | if (msAbs >= h) { 625 | return Math.round(ms / h) + "h"; 626 | } 627 | if (msAbs >= m) { 628 | return Math.round(ms / m) + "m"; 629 | } 630 | if (msAbs >= s) { 631 | return Math.round(ms / s) + "s"; 632 | } 633 | return ms + "ms"; 634 | } 635 | function fmtLong(ms) { 636 | var msAbs = Math.abs(ms); 637 | if (msAbs >= d) { 638 | return plural(ms, msAbs, d, "day"); 639 | } 640 | if (msAbs >= h) { 641 | return plural(ms, msAbs, h, "hour"); 642 | } 643 | if (msAbs >= m) { 644 | return plural(ms, msAbs, m, "minute"); 645 | } 646 | if (msAbs >= s) { 647 | return plural(ms, msAbs, s, "second"); 648 | } 649 | return ms + " ms"; 650 | } 651 | function plural(ms, msAbs, n, name) { 652 | var isPlural = msAbs >= n * 1.5; 653 | return Math.round(ms / n) + " " + name + (isPlural ? "s" : ""); 654 | } 655 | } 656 | }); 657 | 658 | // node_modules/sockjs-client/node_modules/debug/src/common.js 659 | var require_common = __commonJS({ 660 | "node_modules/sockjs-client/node_modules/debug/src/common.js"(exports, module2) { 661 | "use strict"; 662 | function setup(env) { 663 | createDebug.debug = createDebug; 664 | createDebug.default = createDebug; 665 | createDebug.coerce = coerce; 666 | createDebug.disable = disable; 667 | createDebug.enable = enable; 668 | createDebug.enabled = enabled; 669 | createDebug.humanize = require_ms(); 670 | Object.keys(env).forEach(function(key) { 671 | createDebug[key] = env[key]; 672 | }); 673 | createDebug.instances = []; 674 | createDebug.names = []; 675 | createDebug.skips = []; 676 | createDebug.formatters = {}; 677 | function selectColor(namespace) { 678 | var hash = 0; 679 | for (var i = 0; i < namespace.length; i++) { 680 | hash = (hash << 5) - hash + namespace.charCodeAt(i); 681 | hash |= 0; 682 | } 683 | return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; 684 | } 685 | createDebug.selectColor = selectColor; 686 | function createDebug(namespace) { 687 | var prevTime; 688 | function debug() { 689 | if (!debug.enabled) { 690 | return; 691 | } 692 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 693 | args[_key] = arguments[_key]; 694 | } 695 | var self2 = debug; 696 | var curr = Number(new Date()); 697 | var ms = curr - (prevTime || curr); 698 | self2.diff = ms; 699 | self2.prev = prevTime; 700 | self2.curr = curr; 701 | prevTime = curr; 702 | args[0] = createDebug.coerce(args[0]); 703 | if (typeof args[0] !== "string") { 704 | args.unshift("%O"); 705 | } 706 | var index = 0; 707 | args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { 708 | if (match === "%%") { 709 | return match; 710 | } 711 | index++; 712 | var formatter = createDebug.formatters[format]; 713 | if (typeof formatter === "function") { 714 | var val = args[index]; 715 | match = formatter.call(self2, val); 716 | args.splice(index, 1); 717 | index--; 718 | } 719 | return match; 720 | }); 721 | createDebug.formatArgs.call(self2, args); 722 | var logFn = self2.log || createDebug.log; 723 | logFn.apply(self2, args); 724 | } 725 | debug.namespace = namespace; 726 | debug.enabled = createDebug.enabled(namespace); 727 | debug.useColors = createDebug.useColors(); 728 | debug.color = selectColor(namespace); 729 | debug.destroy = destroy; 730 | debug.extend = extend; 731 | if (typeof createDebug.init === "function") { 732 | createDebug.init(debug); 733 | } 734 | createDebug.instances.push(debug); 735 | return debug; 736 | } 737 | function destroy() { 738 | var index = createDebug.instances.indexOf(this); 739 | if (index !== -1) { 740 | createDebug.instances.splice(index, 1); 741 | return true; 742 | } 743 | return false; 744 | } 745 | function extend(namespace, delimiter) { 746 | return createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); 747 | } 748 | function enable(namespaces) { 749 | createDebug.save(namespaces); 750 | createDebug.names = []; 751 | createDebug.skips = []; 752 | var i; 753 | var split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); 754 | var len = split.length; 755 | for (i = 0; i < len; i++) { 756 | if (!split[i]) { 757 | continue; 758 | } 759 | namespaces = split[i].replace(/\*/g, ".*?"); 760 | if (namespaces[0] === "-") { 761 | createDebug.skips.push(new RegExp("^" + namespaces.substr(1) + "$")); 762 | } else { 763 | createDebug.names.push(new RegExp("^" + namespaces + "$")); 764 | } 765 | } 766 | for (i = 0; i < createDebug.instances.length; i++) { 767 | var instance = createDebug.instances[i]; 768 | instance.enabled = createDebug.enabled(instance.namespace); 769 | } 770 | } 771 | function disable() { 772 | createDebug.enable(""); 773 | } 774 | function enabled(name) { 775 | if (name[name.length - 1] === "*") { 776 | return true; 777 | } 778 | var i; 779 | var len; 780 | for (i = 0, len = createDebug.skips.length; i < len; i++) { 781 | if (createDebug.skips[i].test(name)) { 782 | return false; 783 | } 784 | } 785 | for (i = 0, len = createDebug.names.length; i < len; i++) { 786 | if (createDebug.names[i].test(name)) { 787 | return true; 788 | } 789 | } 790 | return false; 791 | } 792 | function coerce(val) { 793 | if (val instanceof Error) { 794 | return val.stack || val.message; 795 | } 796 | return val; 797 | } 798 | createDebug.enable(createDebug.load()); 799 | return createDebug; 800 | } 801 | module2.exports = setup; 802 | } 803 | }); 804 | 805 | // node_modules/sockjs-client/node_modules/debug/src/browser.js 806 | var require_browser = __commonJS({ 807 | "node_modules/sockjs-client/node_modules/debug/src/browser.js"(exports, module2) { 808 | "use strict"; 809 | function _typeof(obj) { 810 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 811 | _typeof = function _typeof2(obj2) { 812 | return typeof obj2; 813 | }; 814 | } else { 815 | _typeof = function _typeof2(obj2) { 816 | return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; 817 | }; 818 | } 819 | return _typeof(obj); 820 | } 821 | exports.log = log; 822 | exports.formatArgs = formatArgs; 823 | exports.save = save; 824 | exports.load = load; 825 | exports.useColors = useColors; 826 | exports.storage = localstorage(); 827 | exports.colors = ["#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33"]; 828 | function useColors() { 829 | if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { 830 | return true; 831 | } 832 | if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { 833 | return false; 834 | } 835 | return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); 836 | } 837 | function formatArgs(args) { 838 | args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff); 839 | if (!this.useColors) { 840 | return; 841 | } 842 | var c = "color: " + this.color; 843 | args.splice(1, 0, c, "color: inherit"); 844 | var index = 0; 845 | var lastC = 0; 846 | args[0].replace(/%[a-zA-Z%]/g, function(match) { 847 | if (match === "%%") { 848 | return; 849 | } 850 | index++; 851 | if (match === "%c") { 852 | lastC = index; 853 | } 854 | }); 855 | args.splice(lastC, 0, c); 856 | } 857 | function log() { 858 | var _console; 859 | return (typeof console === "undefined" ? "undefined" : _typeof(console)) === "object" && console.log && (_console = console).log.apply(_console, arguments); 860 | } 861 | function save(namespaces) { 862 | try { 863 | if (namespaces) { 864 | exports.storage.setItem("debug", namespaces); 865 | } else { 866 | exports.storage.removeItem("debug"); 867 | } 868 | } catch (error) { 869 | } 870 | } 871 | function load() { 872 | var r; 873 | try { 874 | r = exports.storage.getItem("debug"); 875 | } catch (error) { 876 | } 877 | if (!r && typeof process !== "undefined" && "env" in process) { 878 | r = process.env.DEBUG; 879 | } 880 | return r; 881 | } 882 | function localstorage() { 883 | try { 884 | return localStorage; 885 | } catch (error) { 886 | } 887 | } 888 | module2.exports = require_common()(exports); 889 | var formatters = module2.exports.formatters; 890 | formatters.j = function(v) { 891 | try { 892 | return JSON.stringify(v); 893 | } catch (error) { 894 | return "[UnexpectedJSONParseError]: " + error.message; 895 | } 896 | }; 897 | } 898 | }); 899 | 900 | // node_modules/sockjs-client/lib/utils/url.js 901 | var require_url = __commonJS({ 902 | "node_modules/sockjs-client/lib/utils/url.js"(exports, module2) { 903 | "use strict"; 904 | var URL = require_url_parse(); 905 | var debug = function() { 906 | }; 907 | if (true) { 908 | debug = require_browser()("sockjs-client:utils:url"); 909 | } 910 | module2.exports = { 911 | getOrigin: function(url) { 912 | if (!url) { 913 | return null; 914 | } 915 | var p = new URL(url); 916 | if (p.protocol === "file:") { 917 | return null; 918 | } 919 | var port = p.port; 920 | if (!port) { 921 | port = p.protocol === "https:" ? "443" : "80"; 922 | } 923 | return p.protocol + "//" + p.hostname + ":" + port; 924 | }, 925 | isOriginEqual: function(a, b) { 926 | var res = this.getOrigin(a) === this.getOrigin(b); 927 | debug("same", a, b, res); 928 | return res; 929 | }, 930 | isSchemeEqual: function(a, b) { 931 | return a.split(":")[0] === b.split(":")[0]; 932 | }, 933 | addPath: function(url, path) { 934 | var qs = url.split("?"); 935 | return qs[0] + path + (qs[1] ? "?" + qs[1] : ""); 936 | }, 937 | addQuery: function(url, q) { 938 | return url + (url.indexOf("?") === -1 ? "?" + q : "&" + q); 939 | }, 940 | isLoopbackAddr: function(addr) { 941 | return /^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) || /^\[::1\]$/.test(addr); 942 | } 943 | }; 944 | } 945 | }); 946 | 947 | // node_modules/inherits/inherits_browser.js 948 | var require_inherits_browser = __commonJS({ 949 | "node_modules/inherits/inherits_browser.js"(exports, module2) { 950 | if (typeof Object.create === "function") { 951 | module2.exports = function inherits(ctor, superCtor) { 952 | if (superCtor) { 953 | ctor.super_ = superCtor; 954 | ctor.prototype = Object.create(superCtor.prototype, { 955 | constructor: { 956 | value: ctor, 957 | enumerable: false, 958 | writable: true, 959 | configurable: true 960 | } 961 | }); 962 | } 963 | }; 964 | } else { 965 | module2.exports = function inherits(ctor, superCtor) { 966 | if (superCtor) { 967 | ctor.super_ = superCtor; 968 | var TempCtor = function() { 969 | }; 970 | TempCtor.prototype = superCtor.prototype; 971 | ctor.prototype = new TempCtor(); 972 | ctor.prototype.constructor = ctor; 973 | } 974 | }; 975 | } 976 | } 977 | }); 978 | 979 | // node_modules/sockjs-client/lib/transport/browser/websocket.js 980 | var require_websocket = __commonJS({ 981 | "node_modules/sockjs-client/lib/transport/browser/websocket.js"(exports, module2) { 982 | "use strict"; 983 | var Driver = global.WebSocket || global.MozWebSocket; 984 | if (Driver) { 985 | module2.exports = function WebSocketBrowserDriver(url) { 986 | return new Driver(url); 987 | }; 988 | } else { 989 | module2.exports = void 0; 990 | } 991 | } 992 | }); 993 | 994 | // node_modules/sockjs-client/lib/transport/websocket.js 995 | var require_websocket2 = __commonJS({ 996 | "node_modules/sockjs-client/lib/transport/websocket.js"(exports, module2) { 997 | "use strict"; 998 | var utils = require_event(); 999 | var urlUtils = require_url(); 1000 | var inherits = require_inherits_browser(); 1001 | var EventEmitter = require("events").EventEmitter; 1002 | var WebsocketDriver = require_websocket(); 1003 | var debug = function() { 1004 | }; 1005 | if (true) { 1006 | debug = require_browser()("sockjs-client:websocket"); 1007 | } 1008 | function WebSocketTransport(transUrl, ignore, options) { 1009 | if (!WebSocketTransport.enabled()) { 1010 | throw new Error("Transport created when disabled"); 1011 | } 1012 | EventEmitter.call(this); 1013 | debug("constructor", transUrl); 1014 | var self2 = this; 1015 | var url = urlUtils.addPath(transUrl, "/websocket"); 1016 | if (url.slice(0, 5) === "https") { 1017 | url = "wss" + url.slice(5); 1018 | } else { 1019 | url = "ws" + url.slice(4); 1020 | } 1021 | this.url = url; 1022 | this.ws = new WebsocketDriver(this.url, [], options); 1023 | this.ws.onmessage = function(e) { 1024 | debug("message event", e.data); 1025 | self2.emit("message", e.data); 1026 | }; 1027 | this.unloadRef = utils.unloadAdd(function() { 1028 | debug("unload"); 1029 | self2.ws.close(); 1030 | }); 1031 | this.ws.onclose = function(e) { 1032 | debug("close event", e.code, e.reason); 1033 | self2.emit("close", e.code, e.reason); 1034 | self2._cleanup(); 1035 | }; 1036 | this.ws.onerror = function(e) { 1037 | debug("error event", e); 1038 | self2.emit("close", 1006, "WebSocket connection broken"); 1039 | self2._cleanup(); 1040 | }; 1041 | } 1042 | inherits(WebSocketTransport, EventEmitter); 1043 | WebSocketTransport.prototype.send = function(data) { 1044 | var msg = "[" + data + "]"; 1045 | debug("send", msg); 1046 | this.ws.send(msg); 1047 | }; 1048 | WebSocketTransport.prototype.close = function() { 1049 | debug("close"); 1050 | var ws = this.ws; 1051 | this._cleanup(); 1052 | if (ws) { 1053 | ws.close(); 1054 | } 1055 | }; 1056 | WebSocketTransport.prototype._cleanup = function() { 1057 | debug("_cleanup"); 1058 | var ws = this.ws; 1059 | if (ws) { 1060 | ws.onmessage = ws.onclose = ws.onerror = null; 1061 | } 1062 | utils.unloadDel(this.unloadRef); 1063 | this.unloadRef = this.ws = null; 1064 | this.removeAllListeners(); 1065 | }; 1066 | WebSocketTransport.enabled = function() { 1067 | debug("enabled"); 1068 | return !!WebsocketDriver; 1069 | }; 1070 | WebSocketTransport.transportName = "websocket"; 1071 | WebSocketTransport.roundTrips = 2; 1072 | module2.exports = WebSocketTransport; 1073 | } 1074 | }); 1075 | 1076 | // node_modules/sockjs-client/lib/transport/lib/buffered-sender.js 1077 | var require_buffered_sender = __commonJS({ 1078 | "node_modules/sockjs-client/lib/transport/lib/buffered-sender.js"(exports, module2) { 1079 | "use strict"; 1080 | var inherits = require_inherits_browser(); 1081 | var EventEmitter = require("events").EventEmitter; 1082 | var debug = function() { 1083 | }; 1084 | if (true) { 1085 | debug = require_browser()("sockjs-client:buffered-sender"); 1086 | } 1087 | function BufferedSender(url, sender) { 1088 | debug(url); 1089 | EventEmitter.call(this); 1090 | this.sendBuffer = []; 1091 | this.sender = sender; 1092 | this.url = url; 1093 | } 1094 | inherits(BufferedSender, EventEmitter); 1095 | BufferedSender.prototype.send = function(message) { 1096 | debug("send", message); 1097 | this.sendBuffer.push(message); 1098 | if (!this.sendStop) { 1099 | this.sendSchedule(); 1100 | } 1101 | }; 1102 | BufferedSender.prototype.sendScheduleWait = function() { 1103 | debug("sendScheduleWait"); 1104 | var self2 = this; 1105 | var tref; 1106 | this.sendStop = function() { 1107 | debug("sendStop"); 1108 | self2.sendStop = null; 1109 | clearTimeout(tref); 1110 | }; 1111 | tref = setTimeout(function() { 1112 | debug("timeout"); 1113 | self2.sendStop = null; 1114 | self2.sendSchedule(); 1115 | }, 25); 1116 | }; 1117 | BufferedSender.prototype.sendSchedule = function() { 1118 | debug("sendSchedule", this.sendBuffer.length); 1119 | var self2 = this; 1120 | if (this.sendBuffer.length > 0) { 1121 | var payload = "[" + this.sendBuffer.join(",") + "]"; 1122 | this.sendStop = this.sender(this.url, payload, function(err) { 1123 | self2.sendStop = null; 1124 | if (err) { 1125 | debug("error", err); 1126 | self2.emit("close", err.code || 1006, "Sending error: " + err); 1127 | self2.close(); 1128 | } else { 1129 | self2.sendScheduleWait(); 1130 | } 1131 | }); 1132 | this.sendBuffer = []; 1133 | } 1134 | }; 1135 | BufferedSender.prototype._cleanup = function() { 1136 | debug("_cleanup"); 1137 | this.removeAllListeners(); 1138 | }; 1139 | BufferedSender.prototype.close = function() { 1140 | debug("close"); 1141 | this._cleanup(); 1142 | if (this.sendStop) { 1143 | this.sendStop(); 1144 | this.sendStop = null; 1145 | } 1146 | }; 1147 | module2.exports = BufferedSender; 1148 | } 1149 | }); 1150 | 1151 | // node_modules/sockjs-client/lib/transport/lib/polling.js 1152 | var require_polling = __commonJS({ 1153 | "node_modules/sockjs-client/lib/transport/lib/polling.js"(exports, module2) { 1154 | "use strict"; 1155 | var inherits = require_inherits_browser(); 1156 | var EventEmitter = require("events").EventEmitter; 1157 | var debug = function() { 1158 | }; 1159 | if (true) { 1160 | debug = require_browser()("sockjs-client:polling"); 1161 | } 1162 | function Polling(Receiver, receiveUrl, AjaxObject) { 1163 | debug(receiveUrl); 1164 | EventEmitter.call(this); 1165 | this.Receiver = Receiver; 1166 | this.receiveUrl = receiveUrl; 1167 | this.AjaxObject = AjaxObject; 1168 | this._scheduleReceiver(); 1169 | } 1170 | inherits(Polling, EventEmitter); 1171 | Polling.prototype._scheduleReceiver = function() { 1172 | debug("_scheduleReceiver"); 1173 | var self2 = this; 1174 | var poll = this.poll = new this.Receiver(this.receiveUrl, this.AjaxObject); 1175 | poll.on("message", function(msg) { 1176 | debug("message", msg); 1177 | self2.emit("message", msg); 1178 | }); 1179 | poll.once("close", function(code, reason) { 1180 | debug("close", code, reason, self2.pollIsClosing); 1181 | self2.poll = poll = null; 1182 | if (!self2.pollIsClosing) { 1183 | if (reason === "network") { 1184 | self2._scheduleReceiver(); 1185 | } else { 1186 | self2.emit("close", code || 1006, reason); 1187 | self2.removeAllListeners(); 1188 | } 1189 | } 1190 | }); 1191 | }; 1192 | Polling.prototype.abort = function() { 1193 | debug("abort"); 1194 | this.removeAllListeners(); 1195 | this.pollIsClosing = true; 1196 | if (this.poll) { 1197 | this.poll.abort(); 1198 | } 1199 | }; 1200 | module2.exports = Polling; 1201 | } 1202 | }); 1203 | 1204 | // node_modules/sockjs-client/lib/transport/lib/sender-receiver.js 1205 | var require_sender_receiver = __commonJS({ 1206 | "node_modules/sockjs-client/lib/transport/lib/sender-receiver.js"(exports, module2) { 1207 | "use strict"; 1208 | var inherits = require_inherits_browser(); 1209 | var urlUtils = require_url(); 1210 | var BufferedSender = require_buffered_sender(); 1211 | var Polling = require_polling(); 1212 | var debug = function() { 1213 | }; 1214 | if (true) { 1215 | debug = require_browser()("sockjs-client:sender-receiver"); 1216 | } 1217 | function SenderReceiver(transUrl, urlSuffix, senderFunc, Receiver, AjaxObject) { 1218 | var pollUrl = urlUtils.addPath(transUrl, urlSuffix); 1219 | debug(pollUrl); 1220 | var self2 = this; 1221 | BufferedSender.call(this, transUrl, senderFunc); 1222 | this.poll = new Polling(Receiver, pollUrl, AjaxObject); 1223 | this.poll.on("message", function(msg) { 1224 | debug("poll message", msg); 1225 | self2.emit("message", msg); 1226 | }); 1227 | this.poll.once("close", function(code, reason) { 1228 | debug("poll close", code, reason); 1229 | self2.poll = null; 1230 | self2.emit("close", code, reason); 1231 | self2.close(); 1232 | }); 1233 | } 1234 | inherits(SenderReceiver, BufferedSender); 1235 | SenderReceiver.prototype.close = function() { 1236 | BufferedSender.prototype.close.call(this); 1237 | debug("close"); 1238 | this.removeAllListeners(); 1239 | if (this.poll) { 1240 | this.poll.abort(); 1241 | this.poll = null; 1242 | } 1243 | }; 1244 | module2.exports = SenderReceiver; 1245 | } 1246 | }); 1247 | 1248 | // node_modules/sockjs-client/lib/transport/lib/ajax-based.js 1249 | var require_ajax_based = __commonJS({ 1250 | "node_modules/sockjs-client/lib/transport/lib/ajax-based.js"(exports, module2) { 1251 | "use strict"; 1252 | var inherits = require_inherits_browser(); 1253 | var urlUtils = require_url(); 1254 | var SenderReceiver = require_sender_receiver(); 1255 | var debug = function() { 1256 | }; 1257 | if (true) { 1258 | debug = require_browser()("sockjs-client:ajax-based"); 1259 | } 1260 | function createAjaxSender(AjaxObject) { 1261 | return function(url, payload, callback) { 1262 | debug("create ajax sender", url, payload); 1263 | var opt = {}; 1264 | if (typeof payload === "string") { 1265 | opt.headers = { "Content-type": "text/plain" }; 1266 | } 1267 | var ajaxUrl = urlUtils.addPath(url, "/xhr_send"); 1268 | var xo = new AjaxObject("POST", ajaxUrl, payload, opt); 1269 | xo.once("finish", function(status) { 1270 | debug("finish", status); 1271 | xo = null; 1272 | if (status !== 200 && status !== 204) { 1273 | return callback(new Error("http status " + status)); 1274 | } 1275 | callback(); 1276 | }); 1277 | return function() { 1278 | debug("abort"); 1279 | xo.close(); 1280 | xo = null; 1281 | var err = new Error("Aborted"); 1282 | err.code = 1e3; 1283 | callback(err); 1284 | }; 1285 | }; 1286 | } 1287 | function AjaxBasedTransport(transUrl, urlSuffix, Receiver, AjaxObject) { 1288 | SenderReceiver.call(this, transUrl, urlSuffix, createAjaxSender(AjaxObject), Receiver, AjaxObject); 1289 | } 1290 | inherits(AjaxBasedTransport, SenderReceiver); 1291 | module2.exports = AjaxBasedTransport; 1292 | } 1293 | }); 1294 | 1295 | // node_modules/sockjs-client/lib/transport/receiver/xhr.js 1296 | var require_xhr = __commonJS({ 1297 | "node_modules/sockjs-client/lib/transport/receiver/xhr.js"(exports, module2) { 1298 | "use strict"; 1299 | var inherits = require_inherits_browser(); 1300 | var EventEmitter = require("events").EventEmitter; 1301 | var debug = function() { 1302 | }; 1303 | if (true) { 1304 | debug = require_browser()("sockjs-client:receiver:xhr"); 1305 | } 1306 | function XhrReceiver(url, AjaxObject) { 1307 | debug(url); 1308 | EventEmitter.call(this); 1309 | var self2 = this; 1310 | this.bufferPosition = 0; 1311 | this.xo = new AjaxObject("POST", url, null); 1312 | this.xo.on("chunk", this._chunkHandler.bind(this)); 1313 | this.xo.once("finish", function(status, text) { 1314 | debug("finish", status, text); 1315 | self2._chunkHandler(status, text); 1316 | self2.xo = null; 1317 | var reason = status === 200 ? "network" : "permanent"; 1318 | debug("close", reason); 1319 | self2.emit("close", null, reason); 1320 | self2._cleanup(); 1321 | }); 1322 | } 1323 | inherits(XhrReceiver, EventEmitter); 1324 | XhrReceiver.prototype._chunkHandler = function(status, text) { 1325 | debug("_chunkHandler", status); 1326 | if (status !== 200 || !text) { 1327 | return; 1328 | } 1329 | for (var idx = -1; ; this.bufferPosition += idx + 1) { 1330 | var buf = text.slice(this.bufferPosition); 1331 | idx = buf.indexOf("\n"); 1332 | if (idx === -1) { 1333 | break; 1334 | } 1335 | var msg = buf.slice(0, idx); 1336 | if (msg) { 1337 | debug("message", msg); 1338 | this.emit("message", msg); 1339 | } 1340 | } 1341 | }; 1342 | XhrReceiver.prototype._cleanup = function() { 1343 | debug("_cleanup"); 1344 | this.removeAllListeners(); 1345 | }; 1346 | XhrReceiver.prototype.abort = function() { 1347 | debug("abort"); 1348 | if (this.xo) { 1349 | this.xo.close(); 1350 | debug("close"); 1351 | this.emit("close", null, "user"); 1352 | this.xo = null; 1353 | } 1354 | this._cleanup(); 1355 | }; 1356 | module2.exports = XhrReceiver; 1357 | } 1358 | }); 1359 | 1360 | // node_modules/sockjs-client/lib/transport/browser/abstract-xhr.js 1361 | var require_abstract_xhr = __commonJS({ 1362 | "node_modules/sockjs-client/lib/transport/browser/abstract-xhr.js"(exports, module2) { 1363 | "use strict"; 1364 | var EventEmitter = require("events").EventEmitter; 1365 | var inherits = require_inherits_browser(); 1366 | var utils = require_event(); 1367 | var urlUtils = require_url(); 1368 | var XHR = global.XMLHttpRequest; 1369 | var debug = function() { 1370 | }; 1371 | if (true) { 1372 | debug = require_browser()("sockjs-client:browser:xhr"); 1373 | } 1374 | function AbstractXHRObject(method, url, payload, opts) { 1375 | debug(method, url); 1376 | var self2 = this; 1377 | EventEmitter.call(this); 1378 | setTimeout(function() { 1379 | self2._start(method, url, payload, opts); 1380 | }, 0); 1381 | } 1382 | inherits(AbstractXHRObject, EventEmitter); 1383 | AbstractXHRObject.prototype._start = function(method, url, payload, opts) { 1384 | var self2 = this; 1385 | try { 1386 | this.xhr = new XHR(); 1387 | } catch (x) { 1388 | } 1389 | if (!this.xhr) { 1390 | debug("no xhr"); 1391 | this.emit("finish", 0, "no xhr support"); 1392 | this._cleanup(); 1393 | return; 1394 | } 1395 | url = urlUtils.addQuery(url, "t=" + +new Date()); 1396 | this.unloadRef = utils.unloadAdd(function() { 1397 | debug("unload cleanup"); 1398 | self2._cleanup(true); 1399 | }); 1400 | try { 1401 | this.xhr.open(method, url, true); 1402 | if (this.timeout && "timeout" in this.xhr) { 1403 | this.xhr.timeout = this.timeout; 1404 | this.xhr.ontimeout = function() { 1405 | debug("xhr timeout"); 1406 | self2.emit("finish", 0, ""); 1407 | self2._cleanup(false); 1408 | }; 1409 | } 1410 | } catch (e) { 1411 | debug("exception", e); 1412 | this.emit("finish", 0, ""); 1413 | this._cleanup(false); 1414 | return; 1415 | } 1416 | if ((!opts || !opts.noCredentials) && AbstractXHRObject.supportsCORS) { 1417 | debug("withCredentials"); 1418 | this.xhr.withCredentials = true; 1419 | } 1420 | if (opts && opts.headers) { 1421 | for (var key in opts.headers) { 1422 | this.xhr.setRequestHeader(key, opts.headers[key]); 1423 | } 1424 | } 1425 | this.xhr.onreadystatechange = function() { 1426 | if (self2.xhr) { 1427 | var x = self2.xhr; 1428 | var text, status; 1429 | debug("readyState", x.readyState); 1430 | switch (x.readyState) { 1431 | case 3: 1432 | try { 1433 | status = x.status; 1434 | text = x.responseText; 1435 | } catch (e) { 1436 | } 1437 | debug("status", status); 1438 | if (status === 1223) { 1439 | status = 204; 1440 | } 1441 | if (status === 200 && text && text.length > 0) { 1442 | debug("chunk"); 1443 | self2.emit("chunk", status, text); 1444 | } 1445 | break; 1446 | case 4: 1447 | status = x.status; 1448 | debug("status", status); 1449 | if (status === 1223) { 1450 | status = 204; 1451 | } 1452 | if (status === 12005 || status === 12029) { 1453 | status = 0; 1454 | } 1455 | debug("finish", status, x.responseText); 1456 | self2.emit("finish", status, x.responseText); 1457 | self2._cleanup(false); 1458 | break; 1459 | } 1460 | } 1461 | }; 1462 | try { 1463 | self2.xhr.send(payload); 1464 | } catch (e) { 1465 | self2.emit("finish", 0, ""); 1466 | self2._cleanup(false); 1467 | } 1468 | }; 1469 | AbstractXHRObject.prototype._cleanup = function(abort) { 1470 | debug("cleanup"); 1471 | if (!this.xhr) { 1472 | return; 1473 | } 1474 | this.removeAllListeners(); 1475 | utils.unloadDel(this.unloadRef); 1476 | this.xhr.onreadystatechange = function() { 1477 | }; 1478 | if (this.xhr.ontimeout) { 1479 | this.xhr.ontimeout = null; 1480 | } 1481 | if (abort) { 1482 | try { 1483 | this.xhr.abort(); 1484 | } catch (x) { 1485 | } 1486 | } 1487 | this.unloadRef = this.xhr = null; 1488 | }; 1489 | AbstractXHRObject.prototype.close = function() { 1490 | debug("close"); 1491 | this._cleanup(true); 1492 | }; 1493 | AbstractXHRObject.enabled = !!XHR; 1494 | var axo = ["Active"].concat("Object").join("X"); 1495 | if (!AbstractXHRObject.enabled && axo in global) { 1496 | debug("overriding xmlhttprequest"); 1497 | XHR = function() { 1498 | try { 1499 | return new global[axo]("Microsoft.XMLHTTP"); 1500 | } catch (e) { 1501 | return null; 1502 | } 1503 | }; 1504 | AbstractXHRObject.enabled = !!new XHR(); 1505 | } 1506 | var cors = false; 1507 | try { 1508 | cors = "withCredentials" in new XHR(); 1509 | } catch (ignored) { 1510 | } 1511 | AbstractXHRObject.supportsCORS = cors; 1512 | module2.exports = AbstractXHRObject; 1513 | } 1514 | }); 1515 | 1516 | // node_modules/sockjs-client/lib/transport/sender/xhr-cors.js 1517 | var require_xhr_cors = __commonJS({ 1518 | "node_modules/sockjs-client/lib/transport/sender/xhr-cors.js"(exports, module2) { 1519 | "use strict"; 1520 | var inherits = require_inherits_browser(); 1521 | var XhrDriver = require_abstract_xhr(); 1522 | function XHRCorsObject(method, url, payload, opts) { 1523 | XhrDriver.call(this, method, url, payload, opts); 1524 | } 1525 | inherits(XHRCorsObject, XhrDriver); 1526 | XHRCorsObject.enabled = XhrDriver.enabled && XhrDriver.supportsCORS; 1527 | module2.exports = XHRCorsObject; 1528 | } 1529 | }); 1530 | 1531 | // node_modules/sockjs-client/lib/transport/sender/xhr-local.js 1532 | var require_xhr_local = __commonJS({ 1533 | "node_modules/sockjs-client/lib/transport/sender/xhr-local.js"(exports, module2) { 1534 | "use strict"; 1535 | var inherits = require_inherits_browser(); 1536 | var XhrDriver = require_abstract_xhr(); 1537 | function XHRLocalObject(method, url, payload) { 1538 | XhrDriver.call(this, method, url, payload, { 1539 | noCredentials: true 1540 | }); 1541 | } 1542 | inherits(XHRLocalObject, XhrDriver); 1543 | XHRLocalObject.enabled = XhrDriver.enabled; 1544 | module2.exports = XHRLocalObject; 1545 | } 1546 | }); 1547 | 1548 | // node_modules/sockjs-client/lib/utils/browser.js 1549 | var require_browser2 = __commonJS({ 1550 | "node_modules/sockjs-client/lib/utils/browser.js"(exports, module2) { 1551 | "use strict"; 1552 | module2.exports = { 1553 | isOpera: function() { 1554 | return global.navigator && /opera/i.test(global.navigator.userAgent); 1555 | }, 1556 | isKonqueror: function() { 1557 | return global.navigator && /konqueror/i.test(global.navigator.userAgent); 1558 | }, 1559 | hasDomain: function() { 1560 | if (!global.document) { 1561 | return true; 1562 | } 1563 | try { 1564 | return !!global.document.domain; 1565 | } catch (e) { 1566 | return false; 1567 | } 1568 | } 1569 | }; 1570 | } 1571 | }); 1572 | 1573 | // node_modules/sockjs-client/lib/transport/xhr-streaming.js 1574 | var require_xhr_streaming = __commonJS({ 1575 | "node_modules/sockjs-client/lib/transport/xhr-streaming.js"(exports, module2) { 1576 | "use strict"; 1577 | var inherits = require_inherits_browser(); 1578 | var AjaxBasedTransport = require_ajax_based(); 1579 | var XhrReceiver = require_xhr(); 1580 | var XHRCorsObject = require_xhr_cors(); 1581 | var XHRLocalObject = require_xhr_local(); 1582 | var browser = require_browser2(); 1583 | function XhrStreamingTransport(transUrl) { 1584 | if (!XHRLocalObject.enabled && !XHRCorsObject.enabled) { 1585 | throw new Error("Transport created when disabled"); 1586 | } 1587 | AjaxBasedTransport.call(this, transUrl, "/xhr_streaming", XhrReceiver, XHRCorsObject); 1588 | } 1589 | inherits(XhrStreamingTransport, AjaxBasedTransport); 1590 | XhrStreamingTransport.enabled = function(info) { 1591 | if (info.nullOrigin) { 1592 | return false; 1593 | } 1594 | if (browser.isOpera()) { 1595 | return false; 1596 | } 1597 | return XHRCorsObject.enabled; 1598 | }; 1599 | XhrStreamingTransport.transportName = "xhr-streaming"; 1600 | XhrStreamingTransport.roundTrips = 2; 1601 | XhrStreamingTransport.needBody = !!global.document; 1602 | module2.exports = XhrStreamingTransport; 1603 | } 1604 | }); 1605 | 1606 | // node_modules/sockjs-client/lib/transport/sender/xdr.js 1607 | var require_xdr = __commonJS({ 1608 | "node_modules/sockjs-client/lib/transport/sender/xdr.js"(exports, module2) { 1609 | "use strict"; 1610 | var EventEmitter = require("events").EventEmitter; 1611 | var inherits = require_inherits_browser(); 1612 | var eventUtils = require_event(); 1613 | var browser = require_browser2(); 1614 | var urlUtils = require_url(); 1615 | var debug = function() { 1616 | }; 1617 | if (true) { 1618 | debug = require_browser()("sockjs-client:sender:xdr"); 1619 | } 1620 | function XDRObject(method, url, payload) { 1621 | debug(method, url); 1622 | var self2 = this; 1623 | EventEmitter.call(this); 1624 | setTimeout(function() { 1625 | self2._start(method, url, payload); 1626 | }, 0); 1627 | } 1628 | inherits(XDRObject, EventEmitter); 1629 | XDRObject.prototype._start = function(method, url, payload) { 1630 | debug("_start"); 1631 | var self2 = this; 1632 | var xdr = new global.XDomainRequest(); 1633 | url = urlUtils.addQuery(url, "t=" + +new Date()); 1634 | xdr.onerror = function() { 1635 | debug("onerror"); 1636 | self2._error(); 1637 | }; 1638 | xdr.ontimeout = function() { 1639 | debug("ontimeout"); 1640 | self2._error(); 1641 | }; 1642 | xdr.onprogress = function() { 1643 | debug("progress", xdr.responseText); 1644 | self2.emit("chunk", 200, xdr.responseText); 1645 | }; 1646 | xdr.onload = function() { 1647 | debug("load"); 1648 | self2.emit("finish", 200, xdr.responseText); 1649 | self2._cleanup(false); 1650 | }; 1651 | this.xdr = xdr; 1652 | this.unloadRef = eventUtils.unloadAdd(function() { 1653 | self2._cleanup(true); 1654 | }); 1655 | try { 1656 | this.xdr.open(method, url); 1657 | if (this.timeout) { 1658 | this.xdr.timeout = this.timeout; 1659 | } 1660 | this.xdr.send(payload); 1661 | } catch (x) { 1662 | this._error(); 1663 | } 1664 | }; 1665 | XDRObject.prototype._error = function() { 1666 | this.emit("finish", 0, ""); 1667 | this._cleanup(false); 1668 | }; 1669 | XDRObject.prototype._cleanup = function(abort) { 1670 | debug("cleanup", abort); 1671 | if (!this.xdr) { 1672 | return; 1673 | } 1674 | this.removeAllListeners(); 1675 | eventUtils.unloadDel(this.unloadRef); 1676 | this.xdr.ontimeout = this.xdr.onerror = this.xdr.onprogress = this.xdr.onload = null; 1677 | if (abort) { 1678 | try { 1679 | this.xdr.abort(); 1680 | } catch (x) { 1681 | } 1682 | } 1683 | this.unloadRef = this.xdr = null; 1684 | }; 1685 | XDRObject.prototype.close = function() { 1686 | debug("close"); 1687 | this._cleanup(true); 1688 | }; 1689 | XDRObject.enabled = !!(global.XDomainRequest && browser.hasDomain()); 1690 | module2.exports = XDRObject; 1691 | } 1692 | }); 1693 | 1694 | // node_modules/sockjs-client/lib/transport/xdr-streaming.js 1695 | var require_xdr_streaming = __commonJS({ 1696 | "node_modules/sockjs-client/lib/transport/xdr-streaming.js"(exports, module2) { 1697 | "use strict"; 1698 | var inherits = require_inherits_browser(); 1699 | var AjaxBasedTransport = require_ajax_based(); 1700 | var XhrReceiver = require_xhr(); 1701 | var XDRObject = require_xdr(); 1702 | function XdrStreamingTransport(transUrl) { 1703 | if (!XDRObject.enabled) { 1704 | throw new Error("Transport created when disabled"); 1705 | } 1706 | AjaxBasedTransport.call(this, transUrl, "/xhr_streaming", XhrReceiver, XDRObject); 1707 | } 1708 | inherits(XdrStreamingTransport, AjaxBasedTransport); 1709 | XdrStreamingTransport.enabled = function(info) { 1710 | if (info.cookie_needed || info.nullOrigin) { 1711 | return false; 1712 | } 1713 | return XDRObject.enabled && info.sameScheme; 1714 | }; 1715 | XdrStreamingTransport.transportName = "xdr-streaming"; 1716 | XdrStreamingTransport.roundTrips = 2; 1717 | module2.exports = XdrStreamingTransport; 1718 | } 1719 | }); 1720 | 1721 | // node_modules/sockjs-client/lib/transport/browser/eventsource.js 1722 | var require_eventsource = __commonJS({ 1723 | "node_modules/sockjs-client/lib/transport/browser/eventsource.js"(exports, module2) { 1724 | module2.exports = global.EventSource; 1725 | } 1726 | }); 1727 | 1728 | // node_modules/sockjs-client/lib/transport/receiver/eventsource.js 1729 | var require_eventsource2 = __commonJS({ 1730 | "node_modules/sockjs-client/lib/transport/receiver/eventsource.js"(exports, module2) { 1731 | "use strict"; 1732 | var inherits = require_inherits_browser(); 1733 | var EventEmitter = require("events").EventEmitter; 1734 | var EventSourceDriver = require_eventsource(); 1735 | var debug = function() { 1736 | }; 1737 | if (true) { 1738 | debug = require_browser()("sockjs-client:receiver:eventsource"); 1739 | } 1740 | function EventSourceReceiver(url) { 1741 | debug(url); 1742 | EventEmitter.call(this); 1743 | var self2 = this; 1744 | var es = this.es = new EventSourceDriver(url); 1745 | es.onmessage = function(e) { 1746 | debug("message", e.data); 1747 | self2.emit("message", decodeURI(e.data)); 1748 | }; 1749 | es.onerror = function(e) { 1750 | debug("error", es.readyState, e); 1751 | var reason = es.readyState !== 2 ? "network" : "permanent"; 1752 | self2._cleanup(); 1753 | self2._close(reason); 1754 | }; 1755 | } 1756 | inherits(EventSourceReceiver, EventEmitter); 1757 | EventSourceReceiver.prototype.abort = function() { 1758 | debug("abort"); 1759 | this._cleanup(); 1760 | this._close("user"); 1761 | }; 1762 | EventSourceReceiver.prototype._cleanup = function() { 1763 | debug("cleanup"); 1764 | var es = this.es; 1765 | if (es) { 1766 | es.onmessage = es.onerror = null; 1767 | es.close(); 1768 | this.es = null; 1769 | } 1770 | }; 1771 | EventSourceReceiver.prototype._close = function(reason) { 1772 | debug("close", reason); 1773 | var self2 = this; 1774 | setTimeout(function() { 1775 | self2.emit("close", null, reason); 1776 | self2.removeAllListeners(); 1777 | }, 200); 1778 | }; 1779 | module2.exports = EventSourceReceiver; 1780 | } 1781 | }); 1782 | 1783 | // node_modules/sockjs-client/lib/transport/eventsource.js 1784 | var require_eventsource3 = __commonJS({ 1785 | "node_modules/sockjs-client/lib/transport/eventsource.js"(exports, module2) { 1786 | "use strict"; 1787 | var inherits = require_inherits_browser(); 1788 | var AjaxBasedTransport = require_ajax_based(); 1789 | var EventSourceReceiver = require_eventsource2(); 1790 | var XHRCorsObject = require_xhr_cors(); 1791 | var EventSourceDriver = require_eventsource(); 1792 | function EventSourceTransport(transUrl) { 1793 | if (!EventSourceTransport.enabled()) { 1794 | throw new Error("Transport created when disabled"); 1795 | } 1796 | AjaxBasedTransport.call(this, transUrl, "/eventsource", EventSourceReceiver, XHRCorsObject); 1797 | } 1798 | inherits(EventSourceTransport, AjaxBasedTransport); 1799 | EventSourceTransport.enabled = function() { 1800 | return !!EventSourceDriver; 1801 | }; 1802 | EventSourceTransport.transportName = "eventsource"; 1803 | EventSourceTransport.roundTrips = 2; 1804 | module2.exports = EventSourceTransport; 1805 | } 1806 | }); 1807 | 1808 | // node_modules/sockjs-client/lib/version.js 1809 | var require_version = __commonJS({ 1810 | "node_modules/sockjs-client/lib/version.js"(exports, module2) { 1811 | module2.exports = "1.6.0"; 1812 | } 1813 | }); 1814 | 1815 | // node_modules/sockjs-client/lib/utils/iframe.js 1816 | var require_iframe = __commonJS({ 1817 | "node_modules/sockjs-client/lib/utils/iframe.js"(exports, module2) { 1818 | "use strict"; 1819 | var eventUtils = require_event(); 1820 | var browser = require_browser2(); 1821 | var debug = function() { 1822 | }; 1823 | if (true) { 1824 | debug = require_browser()("sockjs-client:utils:iframe"); 1825 | } 1826 | module2.exports = { 1827 | WPrefix: "_jp", 1828 | currentWindowId: null, 1829 | polluteGlobalNamespace: function() { 1830 | if (!(module2.exports.WPrefix in global)) { 1831 | global[module2.exports.WPrefix] = {}; 1832 | } 1833 | }, 1834 | postMessage: function(type, data) { 1835 | if (global.parent !== global) { 1836 | global.parent.postMessage(JSON.stringify({ 1837 | windowId: module2.exports.currentWindowId, 1838 | type, 1839 | data: data || "" 1840 | }), "*"); 1841 | } else { 1842 | debug("Cannot postMessage, no parent window.", type, data); 1843 | } 1844 | }, 1845 | createIframe: function(iframeUrl, errorCallback) { 1846 | var iframe = global.document.createElement("iframe"); 1847 | var tref, unloadRef; 1848 | var unattach = function() { 1849 | debug("unattach"); 1850 | clearTimeout(tref); 1851 | try { 1852 | iframe.onload = null; 1853 | } catch (x) { 1854 | } 1855 | iframe.onerror = null; 1856 | }; 1857 | var cleanup = function() { 1858 | debug("cleanup"); 1859 | if (iframe) { 1860 | unattach(); 1861 | setTimeout(function() { 1862 | if (iframe) { 1863 | iframe.parentNode.removeChild(iframe); 1864 | } 1865 | iframe = null; 1866 | }, 0); 1867 | eventUtils.unloadDel(unloadRef); 1868 | } 1869 | }; 1870 | var onerror = function(err) { 1871 | debug("onerror", err); 1872 | if (iframe) { 1873 | cleanup(); 1874 | errorCallback(err); 1875 | } 1876 | }; 1877 | var post = function(msg, origin) { 1878 | debug("post", msg, origin); 1879 | setTimeout(function() { 1880 | try { 1881 | if (iframe && iframe.contentWindow) { 1882 | iframe.contentWindow.postMessage(msg, origin); 1883 | } 1884 | } catch (x) { 1885 | } 1886 | }, 0); 1887 | }; 1888 | iframe.src = iframeUrl; 1889 | iframe.style.display = "none"; 1890 | iframe.style.position = "absolute"; 1891 | iframe.onerror = function() { 1892 | onerror("onerror"); 1893 | }; 1894 | iframe.onload = function() { 1895 | debug("onload"); 1896 | clearTimeout(tref); 1897 | tref = setTimeout(function() { 1898 | onerror("onload timeout"); 1899 | }, 2e3); 1900 | }; 1901 | global.document.body.appendChild(iframe); 1902 | tref = setTimeout(function() { 1903 | onerror("timeout"); 1904 | }, 15e3); 1905 | unloadRef = eventUtils.unloadAdd(cleanup); 1906 | return { 1907 | post, 1908 | cleanup, 1909 | loaded: unattach 1910 | }; 1911 | }, 1912 | createHtmlfile: function(iframeUrl, errorCallback) { 1913 | var axo = ["Active"].concat("Object").join("X"); 1914 | var doc = new global[axo]("htmlfile"); 1915 | var tref, unloadRef; 1916 | var iframe; 1917 | var unattach = function() { 1918 | clearTimeout(tref); 1919 | iframe.onerror = null; 1920 | }; 1921 | var cleanup = function() { 1922 | if (doc) { 1923 | unattach(); 1924 | eventUtils.unloadDel(unloadRef); 1925 | iframe.parentNode.removeChild(iframe); 1926 | iframe = doc = null; 1927 | CollectGarbage(); 1928 | } 1929 | }; 1930 | var onerror = function(r) { 1931 | debug("onerror", r); 1932 | if (doc) { 1933 | cleanup(); 1934 | errorCallback(r); 1935 | } 1936 | }; 1937 | var post = function(msg, origin) { 1938 | try { 1939 | setTimeout(function() { 1940 | if (iframe && iframe.contentWindow) { 1941 | iframe.contentWindow.postMessage(msg, origin); 1942 | } 1943 | }, 0); 1944 | } catch (x) { 1945 | } 1946 | }; 1947 | doc.open(); 1948 | doc.write('