怎么找到cocos定制colyseus sdk的0.16版本?

怎么找到cocos定制colyseus sdk的0.16版本?

0.17版有哪位微信小游戏测通了的?

import { Headers as PolyfillHeaders } from ‘headers-polyfill’;

const HEADER_NAME_TOKEN_RE = /^[!#%&'*+\-.^_`|~0-9A-Za-z]+/;

function normalizeHeaderName(name: any) {

if (name == null) return null;

const s = String(name).trim();

if (!s) return null;

return HEADER_NAME_TOKEN_RE.test(s) ? s : null;

}

class SafeHeaders extends PolyfillHeaders {

constructor(init?: any) {

    super();

    if (init == null) return;

    if (init instanceof PolyfillHeaders) {

        init.forEach((v: any, k: any) => this.set(k, v));

        return;

    }

    try {

        const tmp = new PolyfillHeaders(init);

        tmp.forEach((v: any, k: any) => this.set(k, v));

        return;

    } catch { }

    if (typeof init === "object") {

        for (const [k, v] of Object.entries(init)) {

            this.set(k, v as any);

        }

    }

}

append(name: any, value: any) {

    const key = normalizeHeaderName(name);

    if (!key) return;

    try { super.append(key, String(value)); } catch { }

}

set(name: any, value: any) {

    const key = normalizeHeaderName(name);

    if (!key) return;

    try { super.set(key, String(value)); } catch { }

}

has(name: any) {

    const key = normalizeHeaderName(name);

    if (!key) return false;

    try { return super.has(key); } catch { return false; }

}

get(name: any) {

    const key = normalizeHeaderName(name);

    if (!key) return null;

    try { return super.get(key); } catch { return null; }

}

delete(name: any) {

    const key = normalizeHeaderName(name);

    if (!key) return;

    try { super.delete(key); } catch { }

}

}

(globalThis as any).Headers = SafeHeaders as any;

if (typeof window !== “undefined”) (window as any).Headers = SafeHeaders as any;

/**

  • 微信小游戏 URL polyfill

*/

if (typeof globalThis.URL === “undefined”) {

class WXURL {

    href: string

    protocol = ""

    host = ""

    hostname = ""

    port = ""

    pathname = ""

    search = ""

    hash = ""

    username = ""

    password = ""

    origin = ""

    searchParams: URLSearchParams

    constructor(url: string) {

        this.href = url

        const match = url.match(

            /^((?:https?|wss?):)?\/\/(([^:@\/?#]+)(?::([^@\/?#]*))?@)?([^\/:?#]+)(:\d+)?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/

        )

        if (match) {

            this.protocol = match[1] || ""

            this.username = match[3] || ""

            this.password = match[4] || ""

            this.hostname = match[5] || ""

            this.port = match[6] || ""

            this.pathname = match[7] || "/"

            this.search = match[8] || ""

            this.hash = match[9] || ""

            this.host = this.hostname + this.port

            this.origin = `${this.protocol}//${this.host}`

        } else {

            this.pathname = url || "/"

        }

        this.searchParams = new globalThis.URLSearchParams(this.search)

    }

    toString() {

        return this.href

    }

    toJSON() {

        return this.href

    }

}

;(WXURL as any).createObjectURL = () => {

    throw new Error("URL.createObjectURL is not supported in this environment")

}

;(WXURL as any).revokeObjectURL = () => { }

globalThis.URL = WXURL as any

}

/**

  • URLSearchParams polyfill

*/

if (typeof globalThis.URLSearchParams === “undefined”) {

class WXURLSearchParams {

    private pairs: Array<[string, string]> = []

    constructor(query: string | string[][] | Record<string, string> | WXURLSearchParams = "") {

        if (query instanceof WXURLSearchParams) {

            for (const [k, v] of query.entries()) {

                this.pairs.push([k, v])

            }

            return

        }

        if (Array.isArray(query)) {

            for (const entry of query) {

                if (!entry || entry.length < 2) continue

                this.pairs.push([String(entry[0]), String(entry[1])])

            }

            return

        }

        if (typeof query === "object" && query !== null) {

            for (const k in query) {

                if (Object.prototype.hasOwnProperty.call(query, k)) {

                    this.pairs.push([k, String(query[k])])

                }

            }

            return

        }

        const queryString = String(query || "")

        if (queryString.startsWith("?")) {

            queryString.substring(1).split("&").forEach(pair => {

                if (!pair) return

                const [k, v] = pair.split("=")

                this.pairs.push([

                    decodeURIComponent(k),

                    decodeURIComponent(v || "")

                ])

            })

            return

        }

        queryString.split("&").forEach(pair => {

            if (!pair) return

            const [k, v] = pair.split("=")

            this.pairs.push([

                decodeURIComponent(k),

                decodeURIComponent(v || "")

            ])

        })

    }

    get size() {

        return this.pairs.length

    }

    get(key: string) {

        const found = this.pairs.find(([k]) => k === key)

        return found ? found[1] : null

    }

    getAll(key: string) {

        return this.pairs

            .filter(([k]) => k === key)

            .map(([, v]) => v)

    }

    set(key: string, value: string) {

        let replaced = false

        const next: Array<[string, string]> = []

        for (const [k, v] of this.pairs) {

            if (k === key) {

                if (!replaced) {

                    next.push([key, value])

                    replaced = true

                }

            } else {

                next.push([k, v])

            }

        }

        if (!replaced) {

            next.push([key, value])

        }

        this.pairs = next

    }

    append(key: string, value: string) {

        this.pairs.push([key, value])

    }

    has(key: string) {

        return this.pairs.some(([k]) => k === key)

    }

    delete(key: string) {

        this.pairs = this.pairs.filter(([k]) => k !== key)

    }

    forEach(callback: (value: string, key: string, parent: WXURLSearchParams) => void, thisArg?: any) {

        for (const [k, v] of this.pairs) {

            callback.call(thisArg, v, k, this)

        }

    }

    keys() {

        return this.pairs.map(([k]) => k)[Symbol.iterator]()

    }

    values() {

        return this.pairs.map(([, v]) => v)[Symbol.iterator]()

    }

    entries() {

        return this.pairs[Symbol.iterator]()

    }

    sort() {

        this.pairs.sort((a, b) => a[0].localeCompare(b[0]))

    }

    [Symbol.iterator]() {

        return this.entries()

    }

    toString() {

        return this.pairs

            .map(([k, v]) =>

                `${encodeURIComponent(k)}=${encodeURIComponent(v)}`

            )

            .join("&")

    }

}

globalThis.URLSearchParams = WXURLSearchParams as any

}

const WebSocket_send = WebSocket.prototype.send;

WebSocket.prototype.send = function (data) {

if (data instanceof Uint8Array) {

    WebSocket_send.call(this, data.slice().buffer);

} else if (Array.isArray(data)) {

    WebSocket_send.call(this, (new Uint8Array(data)).buffer);

} else {

    WebSocket_send.call(this, data);

}

};

console.log(“Colyseus Cocos Creator 适配完成”);

0.17版的

https://store.cocos.com/app/detail/5086

最近看到这里有更新,不知道是不是0.17版本.今年2月份的事情了.