Skip to content

Commit

Permalink
chore(deps): update tinygo to v0.34.0 and go to v1.23.3
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Nov 22, 2024
1 parent d7e8d8f commit 4aa99f1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/wasm-fmt/gofmt

go 1.22.2
go 1.23.3
53 changes: 25 additions & 28 deletions gofmt.patch
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -31,7 +32,7 @@ index a7f8c31..dcb950c 100644
- }
-
- if (!global.fs && global.require) {
- global.fs = require("fs");
- global.fs = require("node:fs");
- }
-
- const enosys = () => {
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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 {
Expand All @@ -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);
},
Expand Down Expand Up @@ -304,8 +301,8 @@ index a7f8c31..dcb950c 100644
- },
}
};

@@ -458,7 +234,12 @@
@@ -458,7 +237,12 @@
null,
true,
false,
Expand All @@ -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 &&
Expand Down

0 comments on commit 4aa99f1

Please sign in to comment.