From 4aa99f1431413f1e7feca5458fd8d9f959f8ef3d Mon Sep 17 00:00:00 2001 From: magic-akari Date: Fri, 22 Nov 2024 17:51:47 +0800 Subject: [PATCH] chore(deps): update tinygo to v0.34.0 and go to v1.23.3 --- .github/workflows/publish.yml | 4 +-- .github/workflows/test.yml | 4 +-- go.mod | 2 +- gofmt.patch | 53 +++++++++++++++++------------------ 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dd5f223..6503d2a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,8 +21,8 @@ jobs: registry-url: "https://registry.npmjs.org" - run: | - wget -P ${{ runner.temp }} https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_amd64.deb - yes | sudo dpkg -i ${{ runner.temp }}/tinygo_0.31.2_amd64.deb + wget -P ${{ runner.temp }} https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb + yes | sudo dpkg -i ${{ runner.temp }}/tinygo_0.34.0_amd64.deb - name: Build run: scripts/build.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4e0316..3f4e197 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,8 +18,8 @@ jobs: node-version-file: ".node-version" - run: | - wget -P ${{ runner.temp }} https://github.com/tinygo-org/tinygo/releases/download/v0.31.2/tinygo_0.31.2_amd64.deb - yes | sudo dpkg -i ${{ runner.temp }}/tinygo_0.31.2_amd64.deb + wget -P ${{ runner.temp }} https://github.com/tinygo-org/tinygo/releases/download/v0.34.0/tinygo_0.34.0_amd64.deb + yes | sudo dpkg -i ${{ runner.temp }}/tinygo_0.34.0_amd64.deb - name: Build run: scripts/build.sh diff --git a/go.mod b/go.mod index 166b022..3078f33 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/wasm-fmt/gofmt -go 1.22.2 +go 1.23.3 diff --git a/gofmt.patch b/gofmt.patch index 0b989c5..d23cce8 100644 --- a/gofmt.patch +++ b/gofmt.patch @@ -1,11 +1,12 @@ diff --git a/gofmt.js b/gofmt.js -index a7f8c31..dcb950c 100644 +index c430cc2..fc0a1b7 100644 --- a/gofmt.js +++ b/gofmt.js -@@ -4,136 +4,12 @@ +@@ -3,137 +3,12 @@ + // license that can be found in the LICENSE file. // // This file has been modified for use by the TinyGo compiler. - +- -(() => { - // Map multiple JavaScript environments to a single common API, - // preferring web standards over Node.js API. @@ -31,7 +32,7 @@ index a7f8c31..dcb950c 100644 - } - - if (!global.fs && global.require) { -- global.fs = require("fs"); +- global.fs = require("node:fs"); - } - - const enosys = () => { @@ -103,7 +104,7 @@ index a7f8c31..dcb950c 100644 - } - - if (!global.crypto) { -- const nodeCrypto = require("crypto"); +- const nodeCrypto = require("node:crypto"); - global.crypto = { - getRandomValues(b) { - nodeCrypto.randomFillSync(b); @@ -121,11 +122,11 @@ index a7f8c31..dcb950c 100644 - } - - if (!global.TextEncoder) { -- global.TextEncoder = require("util").TextEncoder; +- global.TextEncoder = require("node:util").TextEncoder; - } - - if (!global.TextDecoder) { -- global.TextDecoder = require("util").TextDecoder; +- global.TextDecoder = require("node:util").TextDecoder; - } - - // End of polyfills for common API. @@ -134,13 +135,13 @@ index a7f8c31..dcb950c 100644 const decoder = new TextDecoder("utf-8"); let reinterpretBuf = new DataView(new ArrayBuffer(8)); var logLine = []; - + - global.Go = class { + class Go { constructor() { this._callbackTimeouts = new Map(); this._nextCallbackTimeoutID = 1; -@@ -239,50 +115,7 @@ +@@ -239,46 +114,7 @@ this.importObject = { wasi_snapshot_preview1: { // https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fd_write @@ -184,18 +185,14 @@ index a7f8c31..dcb950c 100644 - throw 'trying to exit with code ' + code; - } - }, -- random_get: (bufPtr, bufLen) => { -- crypto.getRandomValues(loadSlice(bufPtr, bufLen)); -- return 0; -- }, + fd_write: () => 0, // dummy - }, - gojs: { - // func ticks() float64 -@@ -290,17 +123,21 @@ + random_get: (bufPtr, bufLen) => { + crypto.getRandomValues(loadSlice(bufPtr, bufLen)); + return 0; +@@ -290,17 +126,21 @@ return timeOrigin + performance.now(); }, - + - // func sleepTicks(timeout float64) - "runtime.sleepTicks": (timeout) => { - // Do not sleep, only reactivate scheduler after the given timeout. @@ -221,12 +218,12 @@ index a7f8c31..dcb950c 100644 + this._idPool.push(id); + } }, - + // func stringVal(value string) ref -@@ -325,13 +162,6 @@ +@@ -325,13 +165,6 @@ Reflect.set(v, p, x); }, - + - // func valueDelete(v ref, p string) - "syscall/js.valueDelete": (v_ref, p_ptr, p_len) => { - const v = unboxValue(v_ref); @@ -237,10 +234,10 @@ index a7f8c31..dcb950c 100644 // func valueIndex(v ref, i int) ref "syscall/js.valueIndex": (v_ref, i) => { return boxValue(Reflect.get(unboxValue(v_ref), i)); -@@ -357,19 +187,6 @@ +@@ -357,19 +190,6 @@ } }, - + - // func valueInvoke(v ref, args []ref) (ref, bool) - "syscall/js.valueInvoke": (ret_addr, v_ref, args_ptr, args_len, args_cap) => { - try { @@ -257,7 +254,7 @@ index a7f8c31..dcb950c 100644 // func valueNew(v ref, args []ref) (ref, bool) "syscall/js.valueNew": (ret_addr, v_ref, args_ptr, args_len, args_cap) => { const v = unboxValue(v_ref); -@@ -401,47 +218,6 @@ +@@ -401,47 +221,6 @@ const str = unboxValue(v_ref); loadSlice(slice_ptr, slice_len, slice_cap).set(str); }, @@ -304,8 +301,8 @@ index a7f8c31..dcb950c 100644 - }, } }; - -@@ -458,7 +234,12 @@ + +@@ -458,7 +237,12 @@ null, true, false, @@ -319,10 +316,10 @@ index a7f8c31..dcb950c 100644 this, ]; this._goRefCounts = []; // number of references that Go has to a JS value, indexed by reference id -@@ -504,24 +285,71 @@ +@@ -497,24 +281,71 @@ } } - + - if ( - global.require && - global.require.main === module &&