Skip to content

godothub/godot-minigame / skills

godot-wechat-minigame-adapter

Unverified

Apply the bundled self-contained Godot WeChat Mini Game adapter kit to an official Godot checkout. Use when the user wants to port official Godot to WeChat Mini Game, refresh a nearby 4.6-based port, or inspect the shipped patch/source bundle for WXMEMFS, `wx.request`, audio cleanup, display/input, WXGLX dual-path rendering, `.wasm.br`, and `wx.exitMiniProgram`. This skill is version-locked to the bundled upstream base and must not be described as a generic “Godot 4.x” patch dump.

FileKindSize
SKILL.mdskill md6.0 KB
agents/openai.yamlconfig269 B
assets/min-runtime/godot-loader.jsscript16.6 KB
assets/min-runtime/godot-sdk.jsscript7.8 KB
patches/fixes/4.7-webgl-context/001-context-swap-control.patchother4.2 KB
patches/fixes/4.7-webgl-context/README.mdmarkdown1.5 KB
patches/godot-4.6.2-rc-a16e481cf4/core/001-build-and-runtime-glue.patchother12.4 KB
patches/godot-4.6.2-rc-a16e481cf4/core/002-native-audio-routing.patchother6.3 KB
patches/godot-4.6.2-rc-a16e481cf4/core/003-wxglx-nine-patch-expansion.patchother5.7 KB
patches/godot-4.6.2-rc-a16e481cf4/core/004-wxglx-nine-patch-runtime-scope.patchother7.2 KB
patches/godot-4.6.2-rc-a16e481cf4/core/series.txtmarkdown142 B
patches/godot-4.6.2-rc-a16e481cf4/manifest.jsonconfig993 B
patches/godot-4.6.2-rc-a16e481cf4/optional/001-audio-worker.patchother820 B
patches/godot-4.6.2-rc-a16e481cf4/optional/series.txtmarkdown23 B
references/compatibility-matrix.mdmarkdown1.2 KB
references/migration-modules.mdmarkdown5.8 KB
references/recent-commit-deltas.mdmarkdown2.2 KB
references/runtime-shell.mdmarkdown3.8 KB
references/validation-checklist.mdmarkdown3.4 KB
references/wxglx-adaptation.mdmarkdown8.8 KB
scripts/apply_godot_patchset.pyscript5.6 KB
scripts/compress_wasm.batscript100 B
scripts/compress_wasm.shscript91 B
scripts/godot_process.jsscript5.3 KB
scripts/install_min_runtime.pyscript1.1 KB
scripts/validate_template_runtime.jsscript2.8 KB
sources/godot-4.6.2-rc-a16e481cf4/compress_wasm.batscript237 B
sources/godot-4.6.2-rc-a16e481cf4/compress_wasm.shscript215 B
sources/godot-4.6.2-rc-a16e481cf4/godot_process.jsscript5.3 KB
sources/godot-4.6.2-rc-a16e481cf4/optional/platform/web/js/libs/audio.worker.jsscript6.6 KB
sources/godot-4.6.2-rc-a16e481cf4/optional/platform/web/js/libs/lib.wx.api.d.tsscript516.7 KB
sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_blob.jsscript27.1 KB
sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_godot_audio.jsscript88.8 KB
sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_godot_crypto.jsscript116 B
sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_godot_display.jsscript26.4 KB
sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_godot_fetch.jsscript8.9 KB
sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_godot_fs.jsscript29.4 KB
sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_godot_input.jsscript23.2 KB
tests/test_godot_process_commit_frame.jsscript2.6 KB
tests/test_min_runtime_loader.jsscript3.8 KB
tests/test_template_glx_config.jsscript1.3 KB
tests/test_wechat_audio_context_source_reuse.jsscript3.9 KB
tests/test_wxglx_nine_patch_patch.jsscript2.2 KB

sources/godot-4.6.2-rc-a16e481cf4/platform/web/js/libs/library_godot_fetch.js

View on GitHub
const GodotFetch = {
    $GodotFetch__deps: ['$IDHandler', '$GodotRuntime'],
    $GodotFetch: {
        // Convert various data types to Uint8Array
        convertToUint8Array: function (data) {
            if (!data) {
                return new Uint8Array(0);
            }

            // Already ArrayBuffer or TypedArray
            if (data instanceof ArrayBuffer) {
                return new Uint8Array(data);
            }
            if (ArrayBuffer.isView(data)) {
                return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
            }

            // String - encode to UTF-8
            if (typeof data === 'string') {
                const encoder = new TextEncoder();
                return encoder.encode(data);
            }

            // Object - convert to JSON string then encode
            if (typeof data === 'object') {
                const jsonStr = JSON.stringify(data);
                const encoder = new TextEncoder();
                return encoder.encode(jsonStr);
            }

            // Fallback - convert to string
            const str = String(data);
            const encoder = new TextEncoder();
            return encoder.encode(str);
        },

        onheaders: function (id, response) {
            const obj = IDHandler.get(id);
            if (!obj) {
                return;
            }
            // Set status code (default to 0 if not present)
            obj.status = response.statusCode || 0;
            
            // If we already have a response object (e.g. from partial headers), merge or update
            if (obj.response) {
                if (response.header) {
                    obj.response.header = response.header;
                }
                // Update other fields if needed
            } else {
                obj.response = response;
            }
        },

        onchunk: function (id, data) {
            const obj = IDHandler.get(id);
            if (!obj) {
                return;
            }
            // data is ArrayBuffer
            if (data && data.byteLength > 0) {
                const uint8Data = new Uint8Array(data);
                obj.chunks.push(uint8Data);
                if (obj.bodySize === -1) obj.bodySize = 0;
                obj.bodySize += uint8Data.byteLength;
            }
        },

        ondone: function (id) {
            const obj = IDHandler.get(id);
            if (!obj) {
                return;
            }
            obj.done = true;
            obj.reading = false;
        },

        onerror: function (id, err) {
            GodotRuntime.error(err);
            const obj = IDHandler.get(id);
            if (!obj) {
                return;
            }
            obj.error = err;
        },

        create: function (method, url, headers, body) {
            const obj = {
                requestTask: null,
                response: null,
                error: null,
                done: false,
                reading: false,
                status: 0,
                chunks: [],
                bodySize: -1,
            };
            const id = IDHandler.add(obj);

            try {
                const requestTask = wx.request({
                    url: url,
                    method: method,
                    data: body,
                    header: headers,
                    responseType: 'arraybuffer',
                    enableChunked: true,
                    success: (res) => {
                        const obj = IDHandler.get(id);
                        if (obj) {
                            // Fallback: if onHeadersReceived didn't fire or didn't set response
                            if (!obj.response) {
                                GodotFetch.onheaders(id, res);
                            }
                            
                            // Fallback: if no chunks were received via onChunkReceived, check res.data
                            // This handles cases where enableChunked might be ignored or data is small
                            if (obj.chunks.length === 0 && res.data) {
                                GodotFetch.onchunk(id, res.data);
                            }
                        }
                        GodotFetch.ondone(id);
                    },
                    fail: (err) => {
                        GodotFetch.onerror(id, err);
                    }
                });

                obj.requestTask = requestTask;

                requestTask.onHeadersReceived((res) => {
                    GodotFetch.onheaders(id, res);
                });

                requestTask.onChunkReceived((res) => {
                    if (res.data) {
                        GodotFetch.onchunk(id, res.data);
                    }
                });

            } catch (e) {
                GodotFetch.onerror(id, { errMsg: 'Exception: ' + e.message, errno: -1 });
            }

            return id;
        },

        free: function (id) {
            const obj = IDHandler.get(id);
            if (obj && obj.requestTask) {
                obj.requestTask.abort();
            }
            IDHandler.remove(id);
        },

        read: function (id) {
            // wx.request doesn't support streaming, so we don't need to implement this
        },
    },

    godot_js_fetch_create__sig: 'iiiiiii',
    godot_js_fetch_create: function (p_method, p_url, p_headers, p_headers_size, p_body, p_body_size) {
        const method = GodotRuntime.parseString(p_method);
        const url = GodotRuntime.parseString(p_url);
        const headers = GodotRuntime.parseStringArray(p_headers, p_headers_size);
        const body = p_body_size ? GodotRuntime.heapSlice(HEAP8, p_body, p_body_size) : null;
        return GodotFetch.create(method, url, headers.reduce((acc, hv) => {
            const idx = hv.indexOf(':');
            if (idx > 0) {
                acc[hv.slice(0, idx).trim()] = hv.slice(idx + 1).trim();
            }
            return acc;
        }, {}), body);
    },

    godot_js_fetch_state_get__sig: 'ii',
    godot_js_fetch_state_get: function (p_id) {
        const obj = IDHandler.get(p_id);
        if (!obj) {
            return -1;
        }

        let state = -1;
        if (obj.error) {
            state = -1;
        } else if (!obj.response) {
            state = 0; // Request in progress
        } else if (obj.done && obj.chunks.length === 0) {
            state = 2; // Done
        } else {
            state = 1; // Reading
        }

        return state;
    },

    godot_js_fetch_http_status_get__sig: 'ii',
    godot_js_fetch_http_status_get: function (p_id) {
        const obj = IDHandler.get(p_id);
        if (!obj || !obj.response) {
            return 0;
        }
        return obj.status;
    },

    godot_js_fetch_read_headers__sig: 'iiii',
    godot_js_fetch_read_headers: function (p_id, p_parse_cb, p_ref) {
        const obj = IDHandler.get(p_id);
        if (!obj || !obj.response) {
            return 1;
        }

        // Check if header exists and is an object
        if (!obj.response.header || typeof obj.response.header !== 'object') {
            return 1;
        }

        try {
            const cb = GodotRuntime.get_func(p_parse_cb);
            const arr = Object.entries(obj.response.header).map(([h, v]) => `${h}:${v}`);

            const c_ptr = GodotRuntime.allocStringArray(arr);

            const result = cb(arr.length, c_ptr, p_ref);

            GodotRuntime.freeStringArray(c_ptr, arr.length);
            return 0;
        } catch (e) {
            return 1;
        }
    },

    godot_js_fetch_read_chunk__sig: 'iiii',
    godot_js_fetch_read_chunk: function (p_id, p_buf, p_buf_size) {
        const obj = IDHandler.get(p_id);
        if (!obj || !obj.response) {
            return 0;
        }
        let to_read = p_buf_size;
        let write_offset = 0;
        const chunks = obj.chunks;
        while (to_read && chunks.length) {
            const chunk = chunks[0];
            if (chunk.length > to_read) {
                GodotRuntime.heapCopy(HEAP8, chunk.slice(0, to_read), p_buf + write_offset);
                chunks[0] = chunk.slice(to_read);
                write_offset += to_read;
                to_read = 0;
            } else {
                GodotRuntime.heapCopy(HEAP8, chunk, p_buf + write_offset);
                to_read -= chunk.length;
                write_offset += chunk.length;
                chunks.shift();
            }
        }
        return p_buf_size - to_read;
    },

    godot_js_fetch_body_length_get__sig: 'ii',
    godot_js_fetch_body_length_get: function (p_id) {
        const obj = IDHandler.get(p_id);
        if (!obj || !obj.response) {
            return -1;
        }
        return obj.bodySize;
    },

    godot_js_fetch_is_chunked__sig: 'ii',
    godot_js_fetch_is_chunked: function (p_id) {
        return 1;
    },

    godot_js_fetch_free__sig: 'vi',
    godot_js_fetch_free: function (id) {
        GodotFetch.free(id);
    },
};

autoAddDeps(GodotFetch, '$GodotFetch');
mergeInto(LibraryManager.library, GodotFetch);
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall