Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import "@vite/env";2 3//#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js4function _typeof(o) {5 "@babel/helpers - typeof";6 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {7 return typeof o$1;8 } : function(o$1) {9 return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;10 }, _typeof(o);11}12 13//#endregion14//#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js15function toPrimitive(t, r) {16 if ("object" != _typeof(t) || !t) return t;17 var e = t[Symbol.toPrimitive];18 if (void 0 !== e) {19 var i = e.call(t, r || "default");20 if ("object" != _typeof(i)) return i;21 throw new TypeError("@@toPrimitive must return a primitive value.");22 }23 return ("string" === r ? String : Number)(t);24}25 26//#endregion27//#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js28function toPropertyKey(t) {29 var i = toPrimitive(t, "string");30 return "symbol" == _typeof(i) ? i : i + "";31}32 33//#endregion34//#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js35function _defineProperty(e, r, t) {36 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {37 value: t,38 enumerable: !0,39 configurable: !0,40 writable: !041 }) : e[r] = t, e;42}43 44//#endregion45//#region src/shared/hmr.ts46var HMRContext = class {47 constructor(hmrClient$1, ownerPath) {48 this.hmrClient = hmrClient$1;49 this.ownerPath = ownerPath;50 _defineProperty(this, "newListeners", void 0);51 if (!hmrClient$1.dataMap.has(ownerPath)) hmrClient$1.dataMap.set(ownerPath, {});52 const mod = hmrClient$1.hotModulesMap.get(ownerPath);53 if (mod) mod.callbacks = [];54 const staleListeners = hmrClient$1.ctxToListenersMap.get(ownerPath);55 if (staleListeners) for (const [event, staleFns] of staleListeners) {56 const listeners = hmrClient$1.customListenersMap.get(event);57 if (listeners) hmrClient$1.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));58 }59 this.newListeners = /* @__PURE__ */ new Map();60 hmrClient$1.ctxToListenersMap.set(ownerPath, this.newListeners);61 }62 get data() {63 return this.hmrClient.dataMap.get(this.ownerPath);64 }65 accept(deps, callback) {66 if (typeof deps === "function" || !deps) this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));67 else if (typeof deps === "string") this.acceptDeps([deps], ([mod]) => callback?.(mod));68 else if (Array.isArray(deps)) this.acceptDeps(deps, callback);69 else throw new Error(`invalid hot.accept() usage.`);70 }71 acceptExports(_, callback) {72 this.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));73 }74 dispose(cb) {75 this.hmrClient.disposeMap.set(this.ownerPath, cb);76 }77 prune(cb) {78 this.hmrClient.pruneMap.set(this.ownerPath, cb);79 }80 decline() {}81 invalidate(message) {82 const firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;83 this.hmrClient.notifyListeners("vite:invalidate", {84 path: this.ownerPath,85 message,86 firstInvalidatedBy87 });88 this.send("vite:invalidate", {89 path: this.ownerPath,90 message,91 firstInvalidatedBy92 });93 this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${message ? `: ${message}` : ""}`);94 }95 on(event, cb) {96 const addToMap = (map) => {97 const existing = map.get(event) || [];98 existing.push(cb);99 map.set(event, existing);100 };101 addToMap(this.hmrClient.customListenersMap);102 addToMap(this.newListeners);103 }104 off(event, cb) {105 const removeFromMap = (map) => {106 const existing = map.get(event);107 if (existing === void 0) return;108 const pruned = existing.filter((l) => l !== cb);109 if (pruned.length === 0) {110 map.delete(event);111 return;112 }113 map.set(event, pruned);114 };115 removeFromMap(this.hmrClient.customListenersMap);116 removeFromMap(this.newListeners);117 }118 send(event, data) {119 this.hmrClient.send({120 type: "custom",121 event,122 data123 });124 }125 acceptDeps(deps, callback = () => {}) {126 const mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {127 id: this.ownerPath,128 callbacks: []129 };130 mod.callbacks.push({131 deps,132 fn: callback133 });134 this.hmrClient.hotModulesMap.set(this.ownerPath, mod);135 }136};137var HMRClient = class {138 constructor(logger, transport$1, importUpdatedModule) {139 this.logger = logger;140 this.transport = transport$1;141 this.importUpdatedModule = importUpdatedModule;142 _defineProperty(this, "hotModulesMap", /* @__PURE__ */ new Map());143 _defineProperty(this, "disposeMap", /* @__PURE__ */ new Map());144 _defineProperty(this, "pruneMap", /* @__PURE__ */ new Map());145 _defineProperty(this, "dataMap", /* @__PURE__ */ new Map());146 _defineProperty(this, "customListenersMap", /* @__PURE__ */ new Map());147 _defineProperty(this, "ctxToListenersMap", /* @__PURE__ */ new Map());148 _defineProperty(this, "currentFirstInvalidatedBy", void 0);149 _defineProperty(this, "updateQueue", []);150 _defineProperty(this, "pendingUpdateQueue", false);151 }152 async notifyListeners(event, data) {153 const cbs = this.customListenersMap.get(event);154 if (cbs) await Promise.allSettled(cbs.map((cb) => cb(data)));155 }156 send(payload) {157 this.transport.send(payload).catch((err) => {158 this.logger.error(err);159 });160 }161 clear() {162 this.hotModulesMap.clear();163 this.disposeMap.clear();164 this.pruneMap.clear();165 this.dataMap.clear();166 this.customListenersMap.clear();167 this.ctxToListenersMap.clear();168 }169 async prunePaths(paths) {170 await Promise.all(paths.map((path) => {171 const disposer = this.disposeMap.get(path);172 if (disposer) return disposer(this.dataMap.get(path));173 }));174 await Promise.all(paths.map((path) => {175 const fn = this.pruneMap.get(path);176 if (fn) return fn(this.dataMap.get(path));177 }));178 }179 warnFailedUpdate(err, path) {180 if (!(err instanceof Error) || !err.message.includes("fetch")) this.logger.error(err);181 this.logger.error(`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);182 }183 /**184 * buffer multiple hot updates triggered by the same src change185 * so that they are invoked in the same order they were sent.186 * (otherwise the order may be inconsistent because of the http request round trip)187 */188 async queueUpdate(payload) {189 this.updateQueue.push(this.fetchUpdate(payload));190 if (!this.pendingUpdateQueue) {191 this.pendingUpdateQueue = true;192 await Promise.resolve();193 this.pendingUpdateQueue = false;194 const loading = [...this.updateQueue];195 this.updateQueue = [];196 (await Promise.all(loading)).forEach((fn) => fn && fn());197 }198 }199 async fetchUpdate(update) {200 const { path, acceptedPath, firstInvalidatedBy } = update;201 const mod = this.hotModulesMap.get(path);202 if (!mod) return;203 let fetchedModule;204 const isSelfUpdate = path === acceptedPath;205 const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));206 if (isSelfUpdate || qualifiedCallbacks.length > 0) {207 const disposer = this.disposeMap.get(acceptedPath);208 if (disposer) await disposer(this.dataMap.get(acceptedPath));209 try {210 fetchedModule = await this.importUpdatedModule(update);211 } catch (e) {212 this.warnFailedUpdate(e, acceptedPath);213 }214 }215 return () => {216 try {217 this.currentFirstInvalidatedBy = firstInvalidatedBy;218 for (const { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));219 const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;220 this.logger.debug(`hot updated: ${loggedPath}`);221 } finally {222 this.currentFirstInvalidatedBy = void 0;223 }224 };225 }226};227 228//#endregion229//#region ../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/non-secure/index.js230let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";231let nanoid = (size = 21) => {232 let id = "";233 let i = size | 0;234 while (i--) id += urlAlphabet[Math.random() * 64 | 0];235 return id;236};237 238//#endregion239//#region src/shared/constants.ts240let SOURCEMAPPING_URL = "sourceMa";241SOURCEMAPPING_URL += "ppingURL";242 243//#endregion244//#region src/shared/utils.ts245const isWindows = typeof process !== "undefined" && process.platform === "win32";246const AsyncFunction = async function() {}.constructor;247function promiseWithResolvers() {248 let resolve;249 let reject;250 return {251 promise: new Promise((_resolve, _reject) => {252 resolve = _resolve;253 reject = _reject;254 }),255 resolve,256 reject257 };258}259 260//#endregion261//#region src/shared/moduleRunnerTransport.ts262function reviveInvokeError(e) {263 const error = new Error(e.message || "Unknown invoke error");264 Object.assign(error, e, { runnerError: /* @__PURE__ */ new Error("RunnerError") });265 return error;266}267const createInvokeableTransport = (transport$1) => {268 if (transport$1.invoke) return {269 ...transport$1,270 async invoke(name, data) {271 const result = await transport$1.invoke({272 type: "custom",273 event: "vite:invoke",274 data: {275 id: "send",276 name,277 data278 }279 });280 if ("error" in result) throw reviveInvokeError(result.error);281 return result.result;282 }283 };284 if (!transport$1.send || !transport$1.connect) throw new Error("transport must implement send and connect when invoke is not implemented");285 const rpcPromises = /* @__PURE__ */ new Map();286 return {287 ...transport$1,288 connect({ onMessage, onDisconnection }) {289 return transport$1.connect({290 onMessage(payload) {291 if (payload.type === "custom" && payload.event === "vite:invoke") {292 const data = payload.data;293 if (data.id.startsWith("response:")) {294 const invokeId = data.id.slice(9);295 const promise = rpcPromises.get(invokeId);296 if (!promise) return;297 if (promise.timeoutId) clearTimeout(promise.timeoutId);298 rpcPromises.delete(invokeId);299 const { error, result } = data.data;300 if (error) promise.reject(error);301 else promise.resolve(result);302 return;303 }304 }305 onMessage(payload);306 },307 onDisconnection308 });309 },310 disconnect() {311 rpcPromises.forEach((promise) => {312 promise.reject(/* @__PURE__ */ new Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));313 });314 rpcPromises.clear();315 return transport$1.disconnect?.();316 },317 send(data) {318 return transport$1.send(data);319 },320 async invoke(name, data) {321 const promiseId = nanoid();322 const wrappedData = {323 type: "custom",324 event: "vite:invoke",325 data: {326 name,327 id: `send:${promiseId}`,328 data329 }330 };331 const sendPromise = transport$1.send(wrappedData);332 const { promise, resolve, reject } = promiseWithResolvers();333 const timeout = transport$1.timeout ?? 6e4;334 let timeoutId;335 if (timeout > 0) {336 timeoutId = setTimeout(() => {337 rpcPromises.delete(promiseId);338 reject(/* @__PURE__ */ new Error(`transport invoke timed out after ${timeout}ms (data: ${JSON.stringify(wrappedData)})`));339 }, timeout);340 timeoutId?.unref?.();341 }342 rpcPromises.set(promiseId, {343 resolve,344 reject,345 name,346 timeoutId347 });348 if (sendPromise) sendPromise.catch((err) => {349 clearTimeout(timeoutId);350 rpcPromises.delete(promiseId);351 reject(err);352 });353 try {354 return await promise;355 } catch (err) {356 throw reviveInvokeError(err);357 }358 }359 };360};361const normalizeModuleRunnerTransport = (transport$1) => {362 const invokeableTransport = createInvokeableTransport(transport$1);363 let isConnected = !invokeableTransport.connect;364 let connectingPromise;365 return {366 ...transport$1,367 ...invokeableTransport.connect ? { async connect(onMessage) {368 if (isConnected) return;369 if (connectingPromise) {370 await connectingPromise;371 return;372 }373 const maybePromise = invokeableTransport.connect({374 onMessage: onMessage ?? (() => {}),375 onDisconnection() {376 isConnected = false;377 }378 });379 if (maybePromise) {380 connectingPromise = maybePromise;381 await connectingPromise;382 connectingPromise = void 0;383 }384 isConnected = true;385 } } : {},386 ...invokeableTransport.disconnect ? { async disconnect() {387 if (!isConnected) return;388 if (connectingPromise) await connectingPromise;389 isConnected = false;390 await invokeableTransport.disconnect();391 } } : {},392 async send(data) {393 if (!invokeableTransport.send) return;394 if (!isConnected) if (connectingPromise) await connectingPromise;395 else throw new Error("send was called before connect");396 await invokeableTransport.send(data);397 },398 async invoke(name, data) {399 if (!isConnected) if (connectingPromise) await connectingPromise;400 else throw new Error("invoke was called before connect");401 return invokeableTransport.invoke(name, data);402 }403 };404};405const createWebSocketModuleRunnerTransport = (options) => {406 const pingInterval = options.pingInterval ?? 3e4;407 let ws;408 let pingIntervalId;409 return {410 async connect({ onMessage, onDisconnection }) {411 const socket = options.createConnection();412 socket.addEventListener("message", async ({ data }) => {413 onMessage(JSON.parse(data));414 });415 let isOpened = socket.readyState === socket.OPEN;416 if (!isOpened) await new Promise((resolve, reject) => {417 socket.addEventListener("open", () => {418 isOpened = true;419 resolve();420 }, { once: true });421 socket.addEventListener("close", async () => {422 if (!isOpened) {423 reject(/* @__PURE__ */ new Error("WebSocket closed without opened."));424 return;425 }426 onMessage({427 type: "custom",428 event: "vite:ws:disconnect",429 data: { webSocket: socket }430 });431 onDisconnection();432 });433 });434 onMessage({435 type: "custom",436 event: "vite:ws:connect",437 data: { webSocket: socket }438 });439 ws = socket;440 pingIntervalId = setInterval(() => {441 if (socket.readyState === socket.OPEN) socket.send(JSON.stringify({ type: "ping" }));442 }, pingInterval);443 },444 disconnect() {445 clearInterval(pingIntervalId);446 ws?.close();447 },448 send(data) {449 ws.send(JSON.stringify(data));450 }451 };452};453 454//#endregion455//#region src/shared/hmrHandler.ts456function createHMRHandler(handler) {457 const queue = new Queue();458 return (payload) => queue.enqueue(() => handler(payload));459}460var Queue = class {461 constructor() {462 _defineProperty(this, "queue", []);463 _defineProperty(this, "pending", false);464 }465 enqueue(promise) {466 return new Promise((resolve, reject) => {467 this.queue.push({468 promise,469 resolve,470 reject471 });472 this.dequeue();473 });474 }475 dequeue() {476 if (this.pending) return false;477 const item = this.queue.shift();478 if (!item) return false;479 this.pending = true;480 item.promise().then(item.resolve).catch(item.reject).finally(() => {481 this.pending = false;482 this.dequeue();483 });484 return true;485 }486};487 488//#endregion489//#region src/client/overlay.ts490const hmrConfigName = __HMR_CONFIG_NAME__;491const base$1 = __BASE__ || "/";492const cspNonce = "document" in globalThis ? document.querySelector("meta[property=csp-nonce]")?.nonce : void 0;493function h(e, attrs = {}, ...children) {494 const elem = document.createElement(e);495 for (const [k, v] of Object.entries(attrs)) if (v !== void 0) elem.setAttribute(k, v);496 elem.append(...children);497 return elem;498}499const templateStyle = `500:host {501 position: fixed;502 top: 0;503 left: 0;504 width: 100%;505 height: 100%;506 z-index: 99999;507 --monospace: 'SFMono-Regular', Consolas,508 'Liberation Mono', Menlo, Courier, monospace;509 --red: #ff5555;510 --yellow: #e2aa53;511 --purple: #cfa4ff;512 --cyan: #2dd9da;513 --dim: #c9c9c9;514 515 --window-background: #181818;516 --window-color: #d8d8d8;517}518 519.backdrop {520 position: fixed;521 z-index: 99999;522 top: 0;523 left: 0;524 width: 100%;525 height: 100%;526 overflow-y: scroll;527 margin: 0;528 background: rgba(0, 0, 0, 0.66);529}530 531.window {532 font-family: var(--monospace);533 line-height: 1.5;534 max-width: 80vw;535 color: var(--window-color);536 box-sizing: border-box;537 margin: 30px auto;538 padding: 2.5vh 4vw;539 position: relative;540 background: var(--window-background);541 border-radius: 6px 6px 8px 8px;542 box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);543 overflow: hidden;544 border-top: 8px solid var(--red);545 direction: ltr;546 text-align: left;547}548 549pre {550 font-family: var(--monospace);551 font-size: 16px;552 margin-top: 0;553 margin-bottom: 1em;554 overflow-x: scroll;555 scrollbar-width: none;556}557 558pre::-webkit-scrollbar {559 display: none;560}561 562pre.frame::-webkit-scrollbar {563 display: block;564 height: 5px;565}566 567pre.frame::-webkit-scrollbar-thumb {568 background: #999;569 border-radius: 5px;570}571 572pre.frame {573 scrollbar-width: thin;574}575 576.message {577 line-height: 1.3;578 font-weight: 600;579 white-space: pre-wrap;580}581 582.message-body {583 color: var(--red);584}585 586.plugin {587 color: var(--purple);588}589 590.file {591 color: var(--cyan);592 margin-bottom: 0;593 white-space: pre-wrap;594 word-break: break-all;595}596 597.frame {598 color: var(--yellow);599}600 601.stack {602 font-size: 13px;603 color: var(--dim);604}605 606.tip {607 font-size: 13px;608 color: #999;609 border-top: 1px dotted #999;610 padding-top: 13px;611 line-height: 1.8;612}613 614code {615 font-size: 13px;616 font-family: var(--monospace);617 color: var(--yellow);618}619 620.file-link {621 text-decoration: underline;622 cursor: pointer;623}624 625kbd {626 line-height: 1.5;627 font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;628 font-size: 0.75rem;629 font-weight: 700;630 background-color: rgb(38, 40, 44);631 color: rgb(166, 167, 171);632 padding: 0.15rem 0.3rem;633 border-radius: 0.25rem;634 border-width: 0.0625rem 0.0625rem 0.1875rem;635 border-style: solid;636 border-color: rgb(54, 57, 64);637 border-image: initial;638}639`;640const createTemplate = () => h("div", {641 class: "backdrop",642 part: "backdrop"643}, h("div", {644 class: "window",645 part: "window"646}, h("pre", {647 class: "message",648 part: "message"649}, h("span", {650 class: "plugin",651 part: "plugin"652}), h("span", {653 class: "message-body",654 part: "message-body"655})), h("pre", {656 class: "file",657 part: "file"658}), h("pre", {659 class: "frame",660 part: "frame"661}), h("pre", {662 class: "stack",663 part: "stack"664}), h("div", {665 class: "tip",666 part: "tip"667}, "Click outside, press ", h("kbd", {}, "Esc"), " key, or fix the code to dismiss.", h("br"), "You can also disable this overlay by setting ", h("code", { part: "config-option-name" }, "server.hmr.overlay"), " to ", h("code", { part: "config-option-value" }, "false"), " in ", h("code", { part: "config-file-name" }, hmrConfigName), ".")), h("style", { nonce: cspNonce }, templateStyle));668const fileRE = /(?:file:\/\/)?(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;669const codeframeRE = /^(?:>?\s*\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm;670const { HTMLElement = class {} } = globalThis;671var ErrorOverlay = class extends HTMLElement {672 constructor(err, links = true) {673 super();674 _defineProperty(this, "root", void 0);675 _defineProperty(this, "closeOnEsc", void 0);676 this.root = this.attachShadow({ mode: "open" });677 this.root.appendChild(createTemplate());678 codeframeRE.lastIndex = 0;679 const hasFrame = err.frame && codeframeRE.test(err.frame);680 const message = hasFrame ? err.message.replace(codeframeRE, "") : err.message;681 if (err.plugin) this.text(".plugin", `[plugin:${err.plugin}] `);682 this.text(".message-body", message.trim());683 const [file] = (err.loc?.file || err.id || "unknown file").split(`?`);684 if (err.loc) this.text(".file", `${file}:${err.loc.line}:${err.loc.column}`, links);685 else if (err.id) this.text(".file", file);686 if (hasFrame) this.text(".frame", err.frame.trim());687 this.text(".stack", err.stack, links);688 this.root.querySelector(".window").addEventListener("click", (e) => {689 e.stopPropagation();690 });691 this.addEventListener("click", () => {692 this.close();693 });694 this.closeOnEsc = (e) => {695 if (e.key === "Escape" || e.code === "Escape") this.close();696 };697 document.addEventListener("keydown", this.closeOnEsc);698 }699 text(selector, text, linkFiles = false) {700 const el = this.root.querySelector(selector);701 if (!linkFiles) el.textContent = text;702 else {703 let curIndex = 0;704 let match;705 fileRE.lastIndex = 0;706 while (match = fileRE.exec(text)) {707 const { 0: file, index } = match;708 const frag = text.slice(curIndex, index);709 el.appendChild(document.createTextNode(frag));710 const link = document.createElement("a");711 link.textContent = file;712 link.className = "file-link";713 link.onclick = () => {714 fetch(new URL(`${base$1}__open-in-editor?file=${encodeURIComponent(file)}`, import.meta.url));715 };716 el.appendChild(link);717 curIndex += frag.length + file.length;718 }719 if (curIndex < text.length) el.appendChild(document.createTextNode(text.slice(curIndex)));720 }721 }722 close() {723 this.parentNode?.removeChild(this);724 document.removeEventListener("keydown", this.closeOnEsc);725 }726};727const overlayId = "vite-error-overlay";728const { customElements } = globalThis;729if (customElements && !customElements.get(overlayId)) customElements.define(overlayId, ErrorOverlay);730 731//#endregion732//#region src/client/client.ts733console.debug("[vite] connecting...");734const importMetaUrl = new URL(import.meta.url);735const serverHost = __SERVER_HOST__;736const socketProtocol = __HMR_PROTOCOL__ || (importMetaUrl.protocol === "https:" ? "wss" : "ws");737const hmrPort = __HMR_PORT__;738const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${hmrPort || importMetaUrl.port}${__HMR_BASE__}`;739const directSocketHost = __HMR_DIRECT_TARGET__;740const base = __BASE__ || "/";741const hmrTimeout = __HMR_TIMEOUT__;742const wsToken = __WS_TOKEN__;743const transport = normalizeModuleRunnerTransport((() => {744 let wsTransport = createWebSocketModuleRunnerTransport({745 createConnection: () => new WebSocket(`${socketProtocol}://${socketHost}?token=${wsToken}`, "vite-hmr"),746 pingInterval: hmrTimeout747 });748 return {749 async connect(handlers) {750 try {751 await wsTransport.connect(handlers);752 } catch (e) {753 if (!hmrPort) {754 wsTransport = createWebSocketModuleRunnerTransport({755 createConnection: () => new WebSocket(`${socketProtocol}://${directSocketHost}?token=${wsToken}`, "vite-hmr"),756 pingInterval: hmrTimeout757 });758 try {759 await wsTransport.connect(handlers);760 console.info("[vite] Direct websocket connection fallback. Check out https://vite.dev/config/server-options.html#server-hmr to remove the previous connection error.");761 } catch (e$1) {762 if (e$1 instanceof Error && e$1.message.includes("WebSocket closed without opened.")) {763 const currentScriptHostURL = new URL(import.meta.url);764 const currentScriptHost = currentScriptHostURL.host + currentScriptHostURL.pathname.replace(/@vite\/client$/, "");765 console.error(`[vite] failed to connect to websocket.766your current setup:767 (browser) ${currentScriptHost} <--[HTTP]--> ${serverHost} (server)\n (browser) ${socketHost} <--[WebSocket (failing)]--> ${directSocketHost} (server)\nCheck out your Vite / network configuration and https://vite.dev/config/server-options.html#server-hmr .`);768 }769 }770 return;771 }772 console.error(`[vite] failed to connect to websocket (${e}). `);773 throw e;774 }775 },776 async disconnect() {777 await wsTransport.disconnect();778 },779 send(data) {780 wsTransport.send(data);781 }782 };783})());784let willUnload = false;785if (typeof window !== "undefined") window.addEventListener?.("beforeunload", () => {786 willUnload = true;787});788function cleanUrl(pathname) {789 const url = new URL(pathname, "http://vite.dev");790 url.searchParams.delete("direct");791 return url.pathname + url.search;792}793let isFirstUpdate = true;794const outdatedLinkTags = /* @__PURE__ */ new WeakSet();795const debounceReload = (time) => {796 let timer;797 return () => {798 if (timer) {799 clearTimeout(timer);800 timer = null;801 }802 timer = setTimeout(() => {803 location.reload();804 }, time);805 };806};807const pageReload = debounceReload(20);808const hmrClient = new HMRClient({809 error: (err) => console.error("[vite]", err),810 debug: (...msg) => console.debug("[vite]", ...msg)811}, transport, async function importUpdatedModule({ acceptedPath, timestamp, explicitImportRequired, isWithinCircularImport }) {812 const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);813 const importPromise = import(814 /* @vite-ignore */815 base + acceptedPathWithoutQuery.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`816);817 if (isWithinCircularImport) importPromise.catch(() => {818 console.info(`[hmr] ${acceptedPath} failed to apply HMR as it's within a circular import. Reloading page to reset the execution order. To debug and break the circular import, you can run \`vite --debug hmr\` to log the circular dependency path if a file change triggered it.`);819 pageReload();820 });821 return await importPromise;822});823transport.connect(createHMRHandler(handleMessage));824async function handleMessage(payload) {825 switch (payload.type) {826 case "connected":827 console.debug(`[vite] connected.`);828 break;829 case "update":830 await hmrClient.notifyListeners("vite:beforeUpdate", payload);831 if (hasDocument) if (isFirstUpdate && hasErrorOverlay()) {832 location.reload();833 return;834 } else {835 if (enableOverlay) clearErrorOverlay();836 isFirstUpdate = false;837 }838 await Promise.all(payload.updates.map(async (update) => {839 if (update.type === "js-update") return hmrClient.queueUpdate(update);840 const { path, timestamp } = update;841 const searchUrl = cleanUrl(path);842 const el = Array.from(document.querySelectorAll("link")).find((e) => !outdatedLinkTags.has(e) && cleanUrl(e.href).includes(searchUrl));843 if (!el) return;844 const newPath = `${base}${searchUrl.slice(1)}${searchUrl.includes("?") ? "&" : "?"}t=${timestamp}`;845 return new Promise((resolve) => {846 const newLinkTag = el.cloneNode();847 newLinkTag.href = new URL(newPath, el.href).href;848 const removeOldEl = () => {849 el.remove();850 console.debug(`[vite] css hot updated: ${searchUrl}`);851 resolve();852 };853 newLinkTag.addEventListener("load", removeOldEl);854 newLinkTag.addEventListener("error", removeOldEl);855 outdatedLinkTags.add(el);856 el.after(newLinkTag);857 });858 }));859 await hmrClient.notifyListeners("vite:afterUpdate", payload);860 break;861 case "custom":862 await hmrClient.notifyListeners(payload.event, payload.data);863 if (payload.event === "vite:ws:disconnect") {864 if (hasDocument && !willUnload) {865 console.log(`[vite] server connection lost. Polling for restart...`);866 const socket = payload.data.webSocket;867 const url = new URL(socket.url);868 url.search = "";869 await waitForSuccessfulPing(url.href);870 location.reload();871 }872 }873 break;874 case "full-reload":875 await hmrClient.notifyListeners("vite:beforeFullReload", payload);876 if (hasDocument) if (payload.path && payload.path.endsWith(".html")) {877 const pagePath = decodeURI(location.pathname);878 const payloadPath = base + payload.path.slice(1);879 if (pagePath === payloadPath || payload.path === "/index.html" || pagePath.endsWith("/") && pagePath + "index.html" === payloadPath) pageReload();880 return;881 } else pageReload();882 break;883 case "prune":884 await hmrClient.notifyListeners("vite:beforePrune", payload);885 await hmrClient.prunePaths(payload.paths);886 break;887 case "error":888 await hmrClient.notifyListeners("vite:error", payload);889 if (hasDocument) {890 const err = payload.err;891 if (enableOverlay) createErrorOverlay(err);892 else console.error(`[vite] Internal Server Error\n${err.message}\n${err.stack}`);893 }894 break;895 case "ping": break;896 default: return payload;897 }898}899const enableOverlay = __HMR_ENABLE_OVERLAY__;900const hasDocument = "document" in globalThis;901function createErrorOverlay(err) {902 clearErrorOverlay();903 const { customElements: customElements$1 } = globalThis;904 if (customElements$1) {905 const ErrorOverlayConstructor = customElements$1.get(overlayId);906 document.body.appendChild(new ErrorOverlayConstructor(err));907 }908}909function clearErrorOverlay() {910 document.querySelectorAll(overlayId).forEach((n) => n.close());911}912function hasErrorOverlay() {913 return document.querySelectorAll(overlayId).length;914}915function waitForSuccessfulPing(socketUrl) {916 if (typeof SharedWorker === "undefined") {917 const visibilityManager = {918 currentState: document.visibilityState,919 listeners: /* @__PURE__ */ new Set()920 };921 const onVisibilityChange = () => {922 visibilityManager.currentState = document.visibilityState;923 for (const listener of visibilityManager.listeners) listener(visibilityManager.currentState);924 };925 document.addEventListener("visibilitychange", onVisibilityChange);926 return waitForSuccessfulPingInternal(socketUrl, visibilityManager);927 }928 const blob = new Blob([929 "\"use strict\";",930 `const waitForSuccessfulPingInternal = ${waitForSuccessfulPingInternal.toString()};`,931 `const fn = ${pingWorkerContentMain.toString()};`,932 `fn(${JSON.stringify(socketUrl)})`933 ], { type: "application/javascript" });934 const objURL = URL.createObjectURL(blob);935 const sharedWorker = new SharedWorker(objURL);936 return new Promise((resolve, reject) => {937 const onVisibilityChange = () => {938 sharedWorker.port.postMessage({ visibility: document.visibilityState });939 };940 document.addEventListener("visibilitychange", onVisibilityChange);941 sharedWorker.port.addEventListener("message", (event) => {942 document.removeEventListener("visibilitychange", onVisibilityChange);943 sharedWorker.port.close();944 const data = event.data;945 if (data.type === "error") {946 reject(data.error);947 return;948 }949 resolve();950 });951 onVisibilityChange();952 sharedWorker.port.start();953 });954}955function pingWorkerContentMain(socketUrl) {956 self.addEventListener("connect", (_event) => {957 const port = _event.ports[0];958 if (!socketUrl) {959 port.postMessage({960 type: "error",961 error: /* @__PURE__ */ new Error("socketUrl not found")962 });963 return;964 }965 const visibilityManager = {966 currentState: "visible",967 listeners: /* @__PURE__ */ new Set()968 };969 port.addEventListener("message", (event) => {970 const { visibility } = event.data;971 visibilityManager.currentState = visibility;972 console.debug("[vite] new window visibility", visibility);973 for (const listener of visibilityManager.listeners) listener(visibility);974 });975 port.start();976 console.debug("[vite] connected from window");977 waitForSuccessfulPingInternal(socketUrl, visibilityManager).then(() => {978 console.debug("[vite] ping successful");979 try {980 port.postMessage({ type: "success" });981 } catch (error) {982 port.postMessage({983 type: "error",984 error985 });986 }987 }, (error) => {988 console.debug("[vite] error happened", error);989 try {990 port.postMessage({991 type: "error",992 error993 });994 } catch (error$1) {995 port.postMessage({996 type: "error",997 error: error$1998 });999 }1000 });1001 });1002}1003async function waitForSuccessfulPingInternal(socketUrl, visibilityManager, ms = 1e3) {1004 function wait(ms$1) {1005 return new Promise((resolve) => setTimeout(resolve, ms$1));1006 }1007 async function ping() {1008 try {1009 const socket = new WebSocket(socketUrl, "vite-ping");1010 return new Promise((resolve) => {1011 function onOpen() {1012 resolve(true);1013 close();1014 }1015 function onError() {1016 resolve(false);1017 close();1018 }1019 function close() {1020 socket.removeEventListener("open", onOpen);1021 socket.removeEventListener("error", onError);1022 socket.close();1023 }1024 socket.addEventListener("open", onOpen);1025 socket.addEventListener("error", onError);1026 });1027 } catch {1028 return false;1029 }1030 }1031 function waitForWindowShow(visibilityManager$1) {1032 return new Promise((resolve) => {1033 const onChange = (newVisibility) => {1034 if (newVisibility === "visible") {1035 resolve();1036 visibilityManager$1.listeners.delete(onChange);1037 }1038 };1039 visibilityManager$1.listeners.add(onChange);1040 });1041 }1042 if (await ping()) return;1043 await wait(ms);1044 while (true) if (visibilityManager.currentState === "visible") {1045 if (await ping()) break;1046 await wait(ms);1047 } else await waitForWindowShow(visibilityManager);1048}1049const sheetsMap = /* @__PURE__ */ new Map();1050const linkSheetsMap = /* @__PURE__ */ new Map();1051if ("document" in globalThis) {1052 document.querySelectorAll("style[data-vite-dev-id]").forEach((el) => {1053 sheetsMap.set(el.getAttribute("data-vite-dev-id"), el);1054 });1055 document.querySelectorAll("link[rel=\"stylesheet\"][data-vite-dev-id]").forEach((el) => {1056 linkSheetsMap.set(el.getAttribute("data-vite-dev-id"), el);1057 });1058}1059let lastInsertedStyle;1060function updateStyle(id, content) {1061 if (linkSheetsMap.has(id)) return;1062 let style = sheetsMap.get(id);1063 if (!style) {1064 style = document.createElement("style");1065 style.setAttribute("type", "text/css");1066 style.setAttribute("data-vite-dev-id", id);1067 style.textContent = content;1068 if (cspNonce) style.setAttribute("nonce", cspNonce);1069 if (!lastInsertedStyle) {1070 document.head.appendChild(style);1071 setTimeout(() => {1072 lastInsertedStyle = void 0;1073 }, 0);1074 } else lastInsertedStyle.insertAdjacentElement("afterend", style);1075 lastInsertedStyle = style;1076 } else style.textContent = content;1077 sheetsMap.set(id, style);1078}1079function removeStyle(id) {1080 if (linkSheetsMap.has(id)) {1081 document.querySelectorAll(`link[rel="stylesheet"][data-vite-dev-id]`).forEach((el) => {1082 if (el.getAttribute("data-vite-dev-id") === id) el.remove();1083 });1084 linkSheetsMap.delete(id);1085 }1086 const style = sheetsMap.get(id);1087 if (style) {1088 document.head.removeChild(style);1089 sheetsMap.delete(id);1090 }1091}1092function createHotContext(ownerPath) {1093 return new HMRContext(hmrClient, ownerPath);1094}1095/**1096* urls here are dynamic import() urls that couldn't be statically analyzed1097*/1098function injectQuery(url, queryToInject) {1099 if (url[0] !== "." && url[0] !== "/") return url;1100 const pathname = url.replace(/[?#].*$/, "");1101 const { search, hash } = new URL(url, "http://vite.dev");1102 return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ""}${hash || ""}`;1103}1104 1105//#endregion1106export { ErrorOverlay, createHotContext, injectQuery, removeStyle, updateStyle };