index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
  2. function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
  3. function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
  4. function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  5. function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  6. /* global __resourceQuery, __webpack_hash__ */
  7. /// <reference types="webpack/module" />
  8. import webpackHotLog from "webpack/hot/log.js";
  9. import hotEmitter from "webpack/hot/emitter.js";
  10. import socket from "./socket.js";
  11. import { formatProblem, createOverlay } from "./overlay.js";
  12. import { log, setLogLevel } from "./utils/log.js";
  13. import sendMessage from "./utils/sendMessage.js";
  14. import { isProgressSupported, defineProgressElement } from "./progress.js";
  15. /**
  16. * @typedef {Object} OverlayOptions
  17. * @property {boolean | (error: Error) => boolean} [warnings]
  18. * @property {boolean | (error: Error) => boolean} [errors]
  19. * @property {boolean | (error: Error) => boolean} [runtimeErrors]
  20. * @property {string} [trustedTypesPolicyName]
  21. */
  22. /**
  23. * @typedef {Object} Options
  24. * @property {boolean} hot
  25. * @property {boolean} liveReload
  26. * @property {boolean} progress
  27. * @property {boolean | OverlayOptions} overlay
  28. * @property {string} [logging]
  29. * @property {number} [reconnect]
  30. */
  31. /**
  32. * @typedef {Object} Status
  33. * @property {boolean} isUnloading
  34. * @property {string} currentHash
  35. * @property {string} [previousHash]
  36. */
  37. /**
  38. * @param {boolean | { warnings?: boolean | string; errors?: boolean | string; runtimeErrors?: boolean | string; }} overlayOptions
  39. */
  40. var decodeOverlayOptions = function decodeOverlayOptions(overlayOptions) {
  41. if (typeof overlayOptions === "object") {
  42. ["warnings", "errors", "runtimeErrors"].forEach(function (property) {
  43. if (typeof overlayOptions[property] === "string") {
  44. var overlayFilterFunctionString = decodeURIComponent(overlayOptions[property]);
  45. // eslint-disable-next-line no-new-func
  46. overlayOptions[property] = new Function("message", "var callback = ".concat(overlayFilterFunctionString, "\n return callback(message)"));
  47. }
  48. });
  49. }
  50. };
  51. /**
  52. * @type {Status}
  53. */
  54. var status = {
  55. isUnloading: false,
  56. // eslint-disable-next-line camelcase
  57. currentHash: __webpack_hash__
  58. };
  59. /**
  60. * @returns {string}
  61. */
  62. var getCurrentScriptSource = function getCurrentScriptSource() {
  63. // `document.currentScript` is the most accurate way to find the current script,
  64. // but is not supported in all browsers.
  65. if (document.currentScript) {
  66. return document.currentScript.getAttribute("src");
  67. }
  68. // Fallback to getting all scripts running in the document.
  69. var scriptElements = document.scripts || [];
  70. var scriptElementsWithSrc = Array.prototype.filter.call(scriptElements, function (element) {
  71. return element.getAttribute("src");
  72. });
  73. if (scriptElementsWithSrc.length > 0) {
  74. var currentScript = scriptElementsWithSrc[scriptElementsWithSrc.length - 1];
  75. return currentScript.getAttribute("src");
  76. }
  77. // Fail as there was no script to use.
  78. throw new Error("[webpack-dev-server] Failed to get current script source.");
  79. };
  80. /**
  81. * @param {string} resourceQuery
  82. * @returns {{ [key: string]: string | boolean }}
  83. */
  84. var parseURL = function parseURL(resourceQuery) {
  85. /** @type {{ [key: string]: string }} */
  86. var result = {};
  87. if (typeof resourceQuery === "string" && resourceQuery !== "") {
  88. var searchParams = resourceQuery.slice(1).split("&");
  89. for (var i = 0; i < searchParams.length; i++) {
  90. var pair = searchParams[i].split("=");
  91. result[pair[0]] = decodeURIComponent(pair[1]);
  92. }
  93. } else {
  94. // Else, get the url from the <script> this file was called with.
  95. var scriptSource = getCurrentScriptSource();
  96. var scriptSourceURL;
  97. try {
  98. // The placeholder `baseURL` with `window.location.href`,
  99. // is to allow parsing of path-relative or protocol-relative URLs,
  100. // and will have no effect if `scriptSource` is a fully valid URL.
  101. scriptSourceURL = new URL(scriptSource, self.location.href);
  102. } catch (error) {
  103. // URL parsing failed, do nothing.
  104. // We will still proceed to see if we can recover using `resourceQuery`
  105. }
  106. if (scriptSourceURL) {
  107. result = scriptSourceURL;
  108. result.fromCurrentScript = true;
  109. }
  110. }
  111. return result;
  112. };
  113. var parsedResourceQuery = parseURL(__resourceQuery);
  114. var enabledFeatures = {
  115. "Hot Module Replacement": false,
  116. "Live Reloading": false,
  117. Progress: false,
  118. Overlay: false
  119. };
  120. /** @type {Options} */
  121. var options = {
  122. hot: false,
  123. liveReload: false,
  124. progress: false,
  125. overlay: false
  126. };
  127. if (parsedResourceQuery.hot === "true") {
  128. options.hot = true;
  129. enabledFeatures["Hot Module Replacement"] = true;
  130. }
  131. if (parsedResourceQuery["live-reload"] === "true") {
  132. options.liveReload = true;
  133. enabledFeatures["Live Reloading"] = true;
  134. }
  135. if (parsedResourceQuery.progress === "true") {
  136. options.progress = true;
  137. enabledFeatures.Progress = true;
  138. }
  139. if (parsedResourceQuery.overlay) {
  140. try {
  141. options.overlay = JSON.parse(parsedResourceQuery.overlay);
  142. } catch (e) {
  143. log.error("Error parsing overlay options from resource query:", e);
  144. }
  145. // Fill in default "true" params for partially-specified objects.
  146. if (typeof options.overlay === "object") {
  147. options.overlay = _objectSpread({
  148. errors: true,
  149. warnings: true,
  150. runtimeErrors: true
  151. }, options.overlay);
  152. decodeOverlayOptions(options.overlay);
  153. }
  154. enabledFeatures.Overlay = true;
  155. }
  156. if (parsedResourceQuery.logging) {
  157. options.logging = parsedResourceQuery.logging;
  158. }
  159. if (typeof parsedResourceQuery.reconnect !== "undefined") {
  160. options.reconnect = Number(parsedResourceQuery.reconnect);
  161. }
  162. /**
  163. * @param {string} level
  164. */
  165. var setAllLogLevel = function setAllLogLevel(level) {
  166. // This is needed because the HMR logger operate separately from dev server logger
  167. webpackHotLog.setLogLevel(level === "verbose" || level === "log" ? "info" : level);
  168. setLogLevel(level);
  169. };
  170. if (options.logging) {
  171. setAllLogLevel(options.logging);
  172. }
  173. var logEnabledFeatures = function logEnabledFeatures(features) {
  174. var listEnabledFeatures = Object.keys(features);
  175. if (!features || listEnabledFeatures.length === 0) {
  176. return;
  177. }
  178. var logString = "Server started:";
  179. // Server started: Hot Module Replacement enabled, Live Reloading enabled, Overlay disabled.
  180. for (var i = 0; i < listEnabledFeatures.length; i++) {
  181. var key = listEnabledFeatures[i];
  182. logString += " ".concat(key, " ").concat(features[key] ? "enabled" : "disabled", ",");
  183. }
  184. // replace last comma with a period
  185. logString = logString.slice(0, -1).concat(".");
  186. log.info(logString);
  187. };
  188. logEnabledFeatures(enabledFeatures);
  189. self.addEventListener("beforeunload", function () {
  190. status.isUnloading = true;
  191. });
  192. var overlay = typeof window !== "undefined" ? createOverlay(typeof options.overlay === "object" ? {
  193. trustedTypesPolicyName: options.overlay.trustedTypesPolicyName,
  194. catchRuntimeError: options.overlay.runtimeErrors
  195. } : {
  196. trustedTypesPolicyName: false,
  197. catchRuntimeError: options.overlay
  198. }) : {
  199. send: function send() {}
  200. };
  201. /**
  202. * @param {Options} options
  203. * @param {Status} currentStatus
  204. */
  205. var reloadApp = function reloadApp(_ref, currentStatus) {
  206. var hot = _ref.hot,
  207. liveReload = _ref.liveReload;
  208. if (currentStatus.isUnloading) {
  209. return;
  210. }
  211. var currentHash = currentStatus.currentHash,
  212. previousHash = currentStatus.previousHash;
  213. var isInitial = currentHash.indexOf(/** @type {string} */previousHash) >= 0;
  214. if (isInitial) {
  215. return;
  216. }
  217. /**
  218. * @param {Window} rootWindow
  219. * @param {number} intervalId
  220. */
  221. function applyReload(rootWindow, intervalId) {
  222. clearInterval(intervalId);
  223. log.info("App updated. Reloading...");
  224. rootWindow.location.reload();
  225. }
  226. var search = self.location.search.toLowerCase();
  227. var allowToHot = search.indexOf("webpack-dev-server-hot=false") === -1;
  228. var allowToLiveReload = search.indexOf("webpack-dev-server-live-reload=false") === -1;
  229. if (hot && allowToHot) {
  230. log.info("App hot update...");
  231. hotEmitter.emit("webpackHotUpdate", currentStatus.currentHash);
  232. if (typeof self !== "undefined" && self.window) {
  233. // broadcast update to window
  234. self.postMessage("webpackHotUpdate".concat(currentStatus.currentHash), "*");
  235. }
  236. }
  237. // allow refreshing the page only if liveReload isn't disabled
  238. else if (liveReload && allowToLiveReload) {
  239. var rootWindow = self;
  240. // use parent window for reload (in case we're in an iframe with no valid src)
  241. var intervalId = self.setInterval(function () {
  242. if (rootWindow.location.protocol !== "about:") {
  243. // reload immediately if protocol is valid
  244. applyReload(rootWindow, intervalId);
  245. } else {
  246. rootWindow = rootWindow.parent;
  247. if (rootWindow.parent === rootWindow) {
  248. // if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways
  249. applyReload(rootWindow, intervalId);
  250. }
  251. }
  252. });
  253. }
  254. };
  255. var ansiRegex = new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|"), "g");
  256. /**
  257. *
  258. * Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
  259. * Adapted from code originally released by Sindre Sorhus
  260. * Licensed the MIT License
  261. *
  262. * @param {string} string
  263. * @return {string}
  264. */
  265. var stripAnsi = function stripAnsi(string) {
  266. if (typeof string !== "string") {
  267. throw new TypeError("Expected a `string`, got `".concat(typeof string, "`"));
  268. }
  269. return string.replace(ansiRegex, "");
  270. };
  271. var onSocketMessage = {
  272. hot: function hot() {
  273. if (parsedResourceQuery.hot === "false") {
  274. return;
  275. }
  276. options.hot = true;
  277. },
  278. liveReload: function liveReload() {
  279. if (parsedResourceQuery["live-reload"] === "false") {
  280. return;
  281. }
  282. options.liveReload = true;
  283. },
  284. invalid: function invalid() {
  285. log.info("App updated. Recompiling...");
  286. // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
  287. if (options.overlay) {
  288. overlay.send({
  289. type: "DISMISS"
  290. });
  291. }
  292. sendMessage("Invalid");
  293. },
  294. /**
  295. * @param {string} hash
  296. */
  297. hash: function hash(_hash) {
  298. status.previousHash = status.currentHash;
  299. status.currentHash = _hash;
  300. },
  301. logging: setAllLogLevel,
  302. /**
  303. * @param {boolean} value
  304. */
  305. overlay: function overlay(value) {
  306. if (typeof document === "undefined") {
  307. return;
  308. }
  309. options.overlay = value;
  310. decodeOverlayOptions(options.overlay);
  311. },
  312. /**
  313. * @param {number} value
  314. */
  315. reconnect: function reconnect(value) {
  316. if (parsedResourceQuery.reconnect === "false") {
  317. return;
  318. }
  319. options.reconnect = value;
  320. },
  321. /**
  322. * @param {boolean} value
  323. */
  324. progress: function progress(value) {
  325. options.progress = value;
  326. },
  327. /**
  328. * @param {{ pluginName?: string, percent: number, msg: string }} data
  329. */
  330. "progress-update": function progressUpdate(data) {
  331. if (options.progress) {
  332. log.info("".concat(data.pluginName ? "[".concat(data.pluginName, "] ") : "").concat(data.percent, "% - ").concat(data.msg, "."));
  333. }
  334. if (isProgressSupported()) {
  335. if (typeof options.progress === "string") {
  336. var progress = document.querySelector("wds-progress");
  337. if (!progress) {
  338. defineProgressElement();
  339. progress = document.createElement("wds-progress");
  340. document.body.appendChild(progress);
  341. }
  342. progress.setAttribute("progress", data.percent);
  343. progress.setAttribute("type", options.progress);
  344. }
  345. }
  346. sendMessage("Progress", data);
  347. },
  348. "still-ok": function stillOk() {
  349. log.info("Nothing changed.");
  350. if (options.overlay) {
  351. overlay.send({
  352. type: "DISMISS"
  353. });
  354. }
  355. sendMessage("StillOk");
  356. },
  357. ok: function ok() {
  358. sendMessage("Ok");
  359. if (options.overlay) {
  360. overlay.send({
  361. type: "DISMISS"
  362. });
  363. }
  364. reloadApp(options, status);
  365. },
  366. /**
  367. * @param {string} file
  368. */
  369. "static-changed": function staticChanged(file) {
  370. log.info("".concat(file ? "\"".concat(file, "\"") : "Content", " from static directory was changed. Reloading..."));
  371. self.location.reload();
  372. },
  373. /**
  374. * @param {Error[]} warnings
  375. * @param {any} params
  376. */
  377. warnings: function warnings(_warnings, params) {
  378. log.warn("Warnings while compiling.");
  379. var printableWarnings = _warnings.map(function (error) {
  380. var _formatProblem = formatProblem("warning", error),
  381. header = _formatProblem.header,
  382. body = _formatProblem.body;
  383. return "".concat(header, "\n").concat(stripAnsi(body));
  384. });
  385. sendMessage("Warnings", printableWarnings);
  386. for (var i = 0; i < printableWarnings.length; i++) {
  387. log.warn(printableWarnings[i]);
  388. }
  389. var overlayWarningsSetting = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.warnings;
  390. if (overlayWarningsSetting) {
  391. var warningsToDisplay = typeof overlayWarningsSetting === "function" ? _warnings.filter(overlayWarningsSetting) : _warnings;
  392. if (warningsToDisplay.length) {
  393. overlay.send({
  394. type: "BUILD_ERROR",
  395. level: "warning",
  396. messages: _warnings
  397. });
  398. }
  399. }
  400. if (params && params.preventReloading) {
  401. return;
  402. }
  403. reloadApp(options, status);
  404. },
  405. /**
  406. * @param {Error[]} errors
  407. */
  408. errors: function errors(_errors) {
  409. log.error("Errors while compiling. Reload prevented.");
  410. var printableErrors = _errors.map(function (error) {
  411. var _formatProblem2 = formatProblem("error", error),
  412. header = _formatProblem2.header,
  413. body = _formatProblem2.body;
  414. return "".concat(header, "\n").concat(stripAnsi(body));
  415. });
  416. sendMessage("Errors", printableErrors);
  417. for (var i = 0; i < printableErrors.length; i++) {
  418. log.error(printableErrors[i]);
  419. }
  420. var overlayErrorsSettings = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.errors;
  421. if (overlayErrorsSettings) {
  422. var errorsToDisplay = typeof overlayErrorsSettings === "function" ? _errors.filter(overlayErrorsSettings) : _errors;
  423. if (errorsToDisplay.length) {
  424. overlay.send({
  425. type: "BUILD_ERROR",
  426. level: "error",
  427. messages: _errors
  428. });
  429. }
  430. }
  431. },
  432. /**
  433. * @param {Error} error
  434. */
  435. error: function error(_error) {
  436. log.error(_error);
  437. },
  438. close: function close() {
  439. log.info("Disconnected!");
  440. if (options.overlay) {
  441. overlay.send({
  442. type: "DISMISS"
  443. });
  444. }
  445. sendMessage("Close");
  446. }
  447. };
  448. /**
  449. * @param {{ protocol?: string, auth?: string, hostname?: string, port?: string, pathname?: string, search?: string, hash?: string, slashes?: boolean }} objURL
  450. * @returns {string}
  451. */
  452. var formatURL = function formatURL(objURL) {
  453. var protocol = objURL.protocol || "";
  454. if (protocol && protocol.substr(-1) !== ":") {
  455. protocol += ":";
  456. }
  457. var auth = objURL.auth || "";
  458. if (auth) {
  459. auth = encodeURIComponent(auth);
  460. auth = auth.replace(/%3A/i, ":");
  461. auth += "@";
  462. }
  463. var host = "";
  464. if (objURL.hostname) {
  465. host = auth + (objURL.hostname.indexOf(":") === -1 ? objURL.hostname : "[".concat(objURL.hostname, "]"));
  466. if (objURL.port) {
  467. host += ":".concat(objURL.port);
  468. }
  469. }
  470. var pathname = objURL.pathname || "";
  471. if (objURL.slashes) {
  472. host = "//".concat(host || "");
  473. if (pathname && pathname.charAt(0) !== "/") {
  474. pathname = "/".concat(pathname);
  475. }
  476. } else if (!host) {
  477. host = "";
  478. }
  479. var search = objURL.search || "";
  480. if (search && search.charAt(0) !== "?") {
  481. search = "?".concat(search);
  482. }
  483. var hash = objURL.hash || "";
  484. if (hash && hash.charAt(0) !== "#") {
  485. hash = "#".concat(hash);
  486. }
  487. pathname = pathname.replace(/[?#]/g,
  488. /**
  489. * @param {string} match
  490. * @returns {string}
  491. */
  492. function (match) {
  493. return encodeURIComponent(match);
  494. });
  495. search = search.replace("#", "%23");
  496. return "".concat(protocol).concat(host).concat(pathname).concat(search).concat(hash);
  497. };
  498. /**
  499. * @param {URL & { fromCurrentScript?: boolean }} parsedURL
  500. * @returns {string}
  501. */
  502. var createSocketURL = function createSocketURL(parsedURL) {
  503. var hostname = parsedURL.hostname;
  504. // Node.js module parses it as `::`
  505. // `new URL(urlString, [baseURLString])` parses it as '[::]'
  506. var isInAddrAny = hostname === "0.0.0.0" || hostname === "::" || hostname === "[::]";
  507. // why do we need this check?
  508. // hostname n/a for file protocol (example, when using electron, ionic)
  509. // see: https://github.com/webpack/webpack-dev-server/pull/384
  510. if (isInAddrAny && self.location.hostname && self.location.protocol.indexOf("http") === 0) {
  511. hostname = self.location.hostname;
  512. }
  513. var socketURLProtocol = parsedURL.protocol || self.location.protocol;
  514. // When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets.
  515. if (socketURLProtocol === "auto:" || hostname && isInAddrAny && self.location.protocol === "https:") {
  516. socketURLProtocol = self.location.protocol;
  517. }
  518. socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, "ws");
  519. var socketURLAuth = "";
  520. // `new URL(urlString, [baseURLstring])` doesn't have `auth` property
  521. // Parse authentication credentials in case we need them
  522. if (parsedURL.username) {
  523. socketURLAuth = parsedURL.username;
  524. // Since HTTP basic authentication does not allow empty username,
  525. // we only include password if the username is not empty.
  526. if (parsedURL.password) {
  527. // Result: <username>:<password>
  528. socketURLAuth = socketURLAuth.concat(":", parsedURL.password);
  529. }
  530. }
  531. // In case the host is a raw IPv6 address, it can be enclosed in
  532. // the brackets as the brackets are needed in the final URL string.
  533. // Need to remove those as url.format blindly adds its own set of brackets
  534. // if the host string contains colons. That would lead to non-working
  535. // double brackets (e.g. [[::]]) host
  536. //
  537. // All of these web socket url params are optionally passed in through resourceQuery,
  538. // so we need to fall back to the default if they are not provided
  539. var socketURLHostname = (hostname || self.location.hostname || "localhost").replace(/^\[(.*)\]$/, "$1");
  540. var socketURLPort = parsedURL.port;
  541. if (!socketURLPort || socketURLPort === "0") {
  542. socketURLPort = self.location.port;
  543. }
  544. // If path is provided it'll be passed in via the resourceQuery as a
  545. // query param so it has to be parsed out of the querystring in order for the
  546. // client to open the socket to the correct location.
  547. var socketURLPathname = "/ws";
  548. if (parsedURL.pathname && !parsedURL.fromCurrentScript) {
  549. socketURLPathname = parsedURL.pathname;
  550. }
  551. return formatURL({
  552. protocol: socketURLProtocol,
  553. auth: socketURLAuth,
  554. hostname: socketURLHostname,
  555. port: socketURLPort,
  556. pathname: socketURLPathname,
  557. slashes: true
  558. });
  559. };
  560. var socketURL = createSocketURL(parsedResourceQuery);
  561. socket(socketURL, onSocketMessage, options.reconnect);
  562. export { getCurrentScriptSource, parseURL, createSocketURL };