index.js 20 KB

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