Team Ai
Datasetpublic

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.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
webSocketMockSource.js337 linesDownload Raw Back to generated
1"use strict";2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __hasOwnProp = Object.prototype.hasOwnProperty;6var __export = (target, all) => {7  for (var name in all)8    __defProp(target, name, { get: all[name], enumerable: true });9};10var __copyProps = (to, from, except, desc) => {11  if (from && typeof from === "object" || typeof from === "function") {12    for (let key of __getOwnPropNames(from))13      if (!__hasOwnProp.call(to, key) && key !== except)14        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });15  }16  return to;17};18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);19var webSocketMockSource_exports = {};20__export(webSocketMockSource_exports, {21  source: () => source22});23module.exports = __toCommonJS(webSocketMockSource_exports);24const source = `25var __commonJS = obj => {26  let required = false;27  let result;28  return function __require() {29    if (!required) {30      required = true;31      let fn;32      for (const name in obj) { fn = obj[name]; break; }33      const module = { exports: {} };34      fn(module.exports, module);35      result = module.exports;36    }37    return result;38  }39};40var __export = (target, all) => {for (var name in all) target[name] = all[name];};41var __toESM = mod => ({ ...mod, 'default': mod });42var __toCommonJS = mod => ({ ...mod, __esModule: true });43 44 45// packages/injected/src/webSocketMock.ts46var webSocketMock_exports = {};47__export(webSocketMock_exports, {48  inject: () => inject49});50module.exports = __toCommonJS(webSocketMock_exports);51function inject(globalThis) {52  if (globalThis.__pwWebSocketDispatch)53    return;54  function generateId() {55    const bytes = new Uint8Array(32);56    globalThis.crypto.getRandomValues(bytes);57    const hex = "0123456789abcdef";58    return [...bytes].map((value) => {59      const high = Math.floor(value / 16);60      const low = value % 16;61      return hex[high] + hex[low];62    }).join("");63  }64  function bufferToData(b) {65    let s = "";66    for (let i = 0; i < b.length; i++)67      s += String.fromCharCode(b[i]);68    return { data: globalThis.btoa(s), isBase64: true };69  }70  function stringToBuffer(s) {71    s = globalThis.atob(s);72    const b = new Uint8Array(s.length);73    for (let i = 0; i < s.length; i++)74      b[i] = s.charCodeAt(i);75    return b.buffer;76  }77  function messageToData(message, cb) {78    if (message instanceof globalThis.Blob)79      return message.arrayBuffer().then((buffer) => cb(bufferToData(new Uint8Array(buffer))));80    if (typeof message === "string")81      return cb({ data: message, isBase64: false });82    if (ArrayBuffer.isView(message))83      return cb(bufferToData(new Uint8Array(message.buffer, message.byteOffset, message.byteLength)));84    return cb(bufferToData(new Uint8Array(message)));85  }86  function dataToMessage(data, binaryType) {87    if (!data.isBase64)88      return data.data;89    const buffer = stringToBuffer(data.data);90    return binaryType === "arraybuffer" ? buffer : new Blob([buffer]);91  }92  const binding = globalThis.__pwWebSocketBinding;93  const NativeWebSocket = globalThis.WebSocket;94  const idToWebSocket = /* @__PURE__ */ new Map();95  globalThis.__pwWebSocketDispatch = (request) => {96    const ws = idToWebSocket.get(request.id);97    if (!ws)98      return;99    if (request.type === "connect")100      ws._apiConnect();101    if (request.type === "passthrough")102      ws._apiPassThrough();103    if (request.type === "ensureOpened")104      ws._apiEnsureOpened();105    if (request.type === "sendToPage")106      ws._apiSendToPage(dataToMessage(request.data, ws.binaryType));107    if (request.type === "closePage")108      ws._apiClosePage(request.code, request.reason, request.wasClean);109    if (request.type === "sendToServer")110      ws._apiSendToServer(dataToMessage(request.data, ws.binaryType));111    if (request.type === "closeServer")112      ws._apiCloseServer(request.code, request.reason, request.wasClean);113  };114  const _WebSocketMock = class _WebSocketMock extends EventTarget {115    constructor(url, protocols) {116      var _a, _b;117      super();118      // WebSocket.CLOSED119      this.CONNECTING = 0;120      // WebSocket.CONNECTING121      this.OPEN = 1;122      // WebSocket.OPEN123      this.CLOSING = 2;124      // WebSocket.CLOSING125      this.CLOSED = 3;126      // WebSocket.CLOSED127      this._oncloseListener = null;128      this._onerrorListener = null;129      this._onmessageListener = null;130      this._onopenListener = null;131      this.bufferedAmount = 0;132      this.extensions = "";133      this.protocol = "";134      this.readyState = 0;135      this._origin = "";136      this._passthrough = false;137      this._wsBufferedMessages = [];138      this._binaryType = "blob";139      this.url = new URL(url, globalThis.window.document.baseURI).href.replace(/^http/, "ws");140      this._origin = (_b = (_a = URL.parse(this.url)) == null ? void 0 : _a.origin) != null ? _b : "";141      this._protocols = protocols;142      this._id = generateId();143      idToWebSocket.set(this._id, this);144      binding({ type: "onCreate", id: this._id, url: this.url });145    }146    // --- native WebSocket implementation ---147    get binaryType() {148      return this._binaryType;149    }150    set binaryType(type) {151      this._binaryType = type;152      if (this._ws)153        this._ws.binaryType = type;154    }155    get onclose() {156      return this._oncloseListener;157    }158    set onclose(listener) {159      if (this._oncloseListener)160        this.removeEventListener("close", this._oncloseListener);161      this._oncloseListener = listener;162      if (this._oncloseListener)163        this.addEventListener("close", this._oncloseListener);164    }165    get onerror() {166      return this._onerrorListener;167    }168    set onerror(listener) {169      if (this._onerrorListener)170        this.removeEventListener("error", this._onerrorListener);171      this._onerrorListener = listener;172      if (this._onerrorListener)173        this.addEventListener("error", this._onerrorListener);174    }175    get onopen() {176      return this._onopenListener;177    }178    set onopen(listener) {179      if (this._onopenListener)180        this.removeEventListener("open", this._onopenListener);181      this._onopenListener = listener;182      if (this._onopenListener)183        this.addEventListener("open", this._onopenListener);184    }185    get onmessage() {186      return this._onmessageListener;187    }188    set onmessage(listener) {189      if (this._onmessageListener)190        this.removeEventListener("message", this._onmessageListener);191      this._onmessageListener = listener;192      if (this._onmessageListener)193        this.addEventListener("message", this._onmessageListener);194    }195    send(message) {196      if (this.readyState === _WebSocketMock.CONNECTING)197        throw new DOMException(\`Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.\`);198      if (this.readyState !== _WebSocketMock.OPEN)199        throw new DOMException(\`WebSocket is already in CLOSING or CLOSED state.\`);200      if (this._passthrough) {201        if (this._ws)202          this._apiSendToServer(message);203      } else {204        messageToData(message, (data) => binding({ type: "onMessageFromPage", id: this._id, data }));205      }206    }207    close(code, reason) {208      if (code !== void 0 && code !== 1e3 && (code < 3e3 || code > 4999))209        throw new DOMException(\`Failed to execute 'close' on 'WebSocket': The close code must be either 1000, or between 3000 and 4999. \${code} is neither.\`);210      if (this.readyState === _WebSocketMock.OPEN || this.readyState === _WebSocketMock.CONNECTING)211        this.readyState = _WebSocketMock.CLOSING;212      if (this._passthrough)213        this._apiCloseServer(code, reason, true);214      else215        binding({ type: "onClosePage", id: this._id, code, reason, wasClean: true });216    }217    // --- methods called from the routing API ---218    _apiEnsureOpened() {219      if (!this._ws)220        this._ensureOpened();221    }222    _apiSendToPage(message) {223      this._ensureOpened();224      if (this.readyState !== _WebSocketMock.OPEN)225        throw new DOMException(\`WebSocket is already in CLOSING or CLOSED state.\`);226      this.dispatchEvent(new MessageEvent("message", { data: message, origin: this._origin, cancelable: true }));227    }228    _apiSendToServer(message) {229      if (!this._ws)230        throw new Error("Cannot send a message before connecting to the server");231      if (this._ws.readyState === _WebSocketMock.CONNECTING)232        this._wsBufferedMessages.push(message);233      else234        this._ws.send(message);235    }236    _apiConnect() {237      if (this._ws)238        throw new Error("Can only connect to the server once");239      this._ws = new NativeWebSocket(this.url, this._protocols);240      this._ws.binaryType = this._binaryType;241      this._ws.onopen = () => {242        for (const message of this._wsBufferedMessages)243          this._ws.send(message);244        this._wsBufferedMessages = [];245        this._ensureOpened();246      };247      this._ws.onclose = (event) => {248        this._onWSClose(event.code, event.reason, event.wasClean);249      };250      this._ws.onmessage = (event) => {251        if (this._passthrough)252          this._apiSendToPage(event.data);253        else254          messageToData(event.data, (data) => binding({ type: "onMessageFromServer", id: this._id, data }));255      };256      this._ws.onerror = () => {257        const event = new Event("error", { cancelable: true });258        this.dispatchEvent(event);259      };260    }261    // This method connects to the server, and passes all messages through,262    // as if WebSocketMock was not engaged.263    _apiPassThrough() {264      this._passthrough = true;265      this._apiConnect();266    }267    _apiCloseServer(code, reason, wasClean) {268      if (!this._ws) {269        this._onWSClose(code, reason, wasClean);270        return;271      }272      if (this._ws.readyState === _WebSocketMock.CONNECTING || this._ws.readyState === _WebSocketMock.OPEN)273        this._ws.close(code, reason);274    }275    _apiClosePage(code, reason, wasClean) {276      if (this.readyState === _WebSocketMock.CLOSED)277        return;278      this.readyState = _WebSocketMock.CLOSED;279      this.dispatchEvent(new CloseEvent("close", { code, reason, wasClean, cancelable: true }));280      this._maybeCleanup();281      if (this._passthrough)282        this._apiCloseServer(code, reason, wasClean);283      else284        binding({ type: "onClosePage", id: this._id, code, reason, wasClean });285    }286    // --- internals ---287    _ensureOpened() {288      var _a;289      if (this.readyState !== _WebSocketMock.CONNECTING)290        return;291      this.extensions = ((_a = this._ws) == null ? void 0 : _a.extensions) || "";292      if (this._ws)293        this.protocol = this._ws.protocol;294      else if (Array.isArray(this._protocols))295        this.protocol = this._protocols[0] || "";296      else297        this.protocol = this._protocols || "";298      this.readyState = _WebSocketMock.OPEN;299      this.dispatchEvent(new Event("open", { cancelable: true }));300    }301    _onWSClose(code, reason, wasClean) {302      if (this._passthrough)303        this._apiClosePage(code, reason, wasClean);304      else305        binding({ type: "onCloseServer", id: this._id, code, reason, wasClean });306      if (this._ws) {307        this._ws.onopen = null;308        this._ws.onclose = null;309        this._ws.onmessage = null;310        this._ws.onerror = null;311        this._ws = void 0;312        this._wsBufferedMessages = [];313      }314      this._maybeCleanup();315    }316    _maybeCleanup() {317      if (this.readyState === _WebSocketMock.CLOSED && !this._ws)318        idToWebSocket.delete(this._id);319    }320  };321  _WebSocketMock.CONNECTING = 0;322  // WebSocket.CONNECTING323  _WebSocketMock.OPEN = 1;324  // WebSocket.OPEN325  _WebSocketMock.CLOSING = 2;326  // WebSocket.CLOSING327  _WebSocketMock.CLOSED = 3;328  let WebSocketMock = _WebSocketMock;329  globalThis.WebSocket = class WebSocket extends WebSocketMock {330  };331}332`;333// Annotate the CommonJS export names for ESM import in node:3340 && (module.exports = {335  source336});337 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai