diff --git a/Dockerfile b/Dockerfile index bec1bb6bf..8d0e93d11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,8 +25,6 @@ RUN gop build -trimpath -o spx-backend ./cmd/spx-backend FROM ${GO_BASE_IMAGE} AS go-builder ARG GOPROXY -# Pre-install Go toolchain for 1.21.3, which will be used by tools/ispx -RUN GOTOOLCHAIN=go1.21.3 go version WORKDIR /app COPY tools ./tools diff --git a/spx-gui/build-wasm.bat b/spx-gui/build-wasm.bat deleted file mode 100644 index 6d7a47a19..000000000 --- a/spx-gui/build-wasm.bat +++ /dev/null @@ -1,30 +0,0 @@ -@REM **NOTE**: This script is outdated. Update it based on `./build-wasm.sh` before using it. - -@echo off -setlocal -echo Run this script from 'spx-gui' directory - -REM Change directory to ../tools/fmt -cd ..\tools\fmt - -REM Call build script -call build.bat - -REM Change directory to ../ispx -cd ..\ispx - -REM Call build script -call build.bat - -REM Change directory to .. -cd .. - -REM Copy files to the destination -copy fmt\static\main.wasm ..\spx-gui\src\assets\format.wasm -copy ispx\main.wasm ..\spx-gui\src\assets\ispx\main.wasm - -REM Get GOROOT environment variable -for /f "tokens=*" %%i in ('go env GOROOT') do set GOROOT=%%i - -echo Build WASM complete -endlocal diff --git a/spx-gui/build-wasm.sh b/spx-gui/build-wasm.sh index 7c1dcfb9e..215126a7c 100755 --- a/spx-gui/build-wasm.sh +++ b/spx-gui/build-wasm.sh @@ -1,12 +1,12 @@ #!/bin/bash set -e -echo Run this script from 'spx-gui' directory +echo "Run this script from 'spx-gui' directory" -cd ../tools/ispx -source ./build.sh -cp ./main.wasm ../../spx-gui/src/assets/ispx/main.wasm +# Build and copy ispx.wasm +( cd ../tools/ispx && ./build.sh ) +cp ../tools/ispx/ispx.wasm src/assets/wasm/ispx.wasm -cd ../spxls -source ./build.sh -cp ./spxls.wasm ../../spx-gui/src/assets/spxls.wasm +# Build and copy spxls.wasm +( cd ../tools/spxls && ./build.sh ) +cp ../tools/spxls/spxls.wasm src/assets/wasm/spxls.wasm diff --git a/spx-gui/src/assets/stage-bg.svg b/spx-gui/src/assets/images/stage-bg.svg similarity index 100% rename from spx-gui/src/assets/stage-bg.svg rename to spx-gui/src/assets/images/stage-bg.svg diff --git a/spx-gui/src/assets/ispx/runner.html b/spx-gui/src/assets/ispx/runner.html deleted file mode 120000 index e9dc87c15..000000000 --- a/spx-gui/src/assets/ispx/runner.html +++ /dev/null @@ -1 +0,0 @@ -../../../../tools/ispx/runner.html \ No newline at end of file diff --git a/spx-gui/src/assets/wasm/.gitignore b/spx-gui/src/assets/wasm/.gitignore new file mode 100644 index 000000000..d3eaa58e6 --- /dev/null +++ b/spx-gui/src/assets/wasm/.gitignore @@ -0,0 +1,9 @@ +# This directory is populated by executing the `@/build-wasm.sh` script at build time. +* +*/* +!.gitignore + +# TODO: `wasm_exec.js` is temporarily tracked due to GOTOOLCHAIN compatibility +# issues in Go 1.23. This exception can be removed once Go 1.24 becomes the +# minimum supported version. +!wasm_exec.js diff --git a/spx-gui/src/assets/wasm_exec.js b/spx-gui/src/assets/wasm/wasm_exec.js similarity index 100% rename from spx-gui/src/assets/wasm_exec.js rename to spx-gui/src/assets/wasm/wasm_exec.js diff --git a/spx-gui/src/components/editor/code-editor/lsp/index.ts b/spx-gui/src/components/editor/code-editor/lsp/index.ts index b9ad30aef..29254987f 100644 --- a/spx-gui/src/components/editor/code-editor/lsp/index.ts +++ b/spx-gui/src/components/editor/code-editor/lsp/index.ts @@ -5,8 +5,8 @@ import { timeout, until, untilNotNull } from '@/utils/utils' import { extname } from '@/utils/path' import { toText } from '@/models/common/file' import type { Project } from '@/models/project' -import wasmExecScriptUrl from '@/assets/wasm_exec.js?url' -import spxlsWasmUrl from '@/assets/spxls.wasm?url' +import wasmExecScriptUrl from '@/assets/wasm/wasm_exec.js?url' +import spxlsWasmUrl from '@/assets/wasm/spxls.wasm?url' import { fromLSPRange, type DefinitionIdentifier, diff --git a/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue b/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue index 3fff87da4..ad04e81e8 100644 --- a/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue +++ b/spx-gui/src/components/editor/preview/stage-viewer/StageViewer.vue @@ -267,7 +267,7 @@ watchEffect((onCleanup) => { align-items: center; justify-content: center; - background-image: url(@/assets/stage-bg.svg); + background-image: url(@/assets/images/stage-bg.svg); background-position: center; background-repeat: repeat; background-size: contain; diff --git a/spx-gui/src/components/project/ProjectItem.vue b/spx-gui/src/components/project/ProjectItem.vue index 762eaa511..3681a2919 100644 --- a/spx-gui/src/components/project/ProjectItem.vue +++ b/spx-gui/src/components/project/ProjectItem.vue @@ -207,7 +207,7 @@ const handleRemove = useMessageHandle( height: 172px; background-position: center; background-size: contain; - background-image: url(@/assets/stage-bg.svg); + background-image: url(@/assets/images/stage-bg.svg); .thumbnail { width: 100%; diff --git a/spx-gui/src/components/project/ProjectPublishModal.vue b/spx-gui/src/components/project/ProjectPublishModal.vue index cb29ab6b3..6cdd51159 100644 --- a/spx-gui/src/components/project/ProjectPublishModal.vue +++ b/spx-gui/src/components/project/ProjectPublishModal.vue @@ -151,7 +151,7 @@ const handleSubmit = useMessageHandle( margin-bottom: 24px; width: 100%; height: 224px; - background: url(@/assets/stage-bg.svg) center / cover no-repeat; + background: url(@/assets/images/stage-bg.svg) center / cover no-repeat; border-radius: var(--ui-border-radius-1); overflow: hidden; diff --git a/spx-gui/src/components/project/runner/v1/IframeDisplay.vue b/spx-gui/src/components/project/runner/v1/IframeDisplay.vue index 0e48d8137..26d3be8e4 100644 --- a/spx-gui/src/components/project/runner/v1/IframeDisplay.vue +++ b/spx-gui/src/components/project/runner/v1/IframeDisplay.vue @@ -4,9 +4,9 @@ @@ -42,7 +42,7 @@ watch(iframe, () => { if (!iframeWindow) { return } - const runnerHtml = rawRunnerHtml.replace('/wasm_exec.js', wasmExecUrl).replace('main.wasm', wasmUrl) + const runnerHtml = ispxRunnerHtml.replace('/wasm_exec.js', wasmExecUrl).replace('ispx.wasm', ispxWasmUrl) iframeWindow.document.write(runnerHtml) // This resets the iframe's content, including its window object diff --git a/spx-gui/src/components/project/runner/v1/ispx/runner.html b/spx-gui/src/components/project/runner/v1/ispx/runner.html new file mode 120000 index 000000000..1d335f0ee --- /dev/null +++ b/spx-gui/src/components/project/runner/v1/ispx/runner.html @@ -0,0 +1 @@ +../../../../../../../tools/ispx/runner.html \ No newline at end of file diff --git a/spx-gui/vercel-build.sh b/spx-gui/vercel-build.sh index 03abc5836..5fec4fa77 100644 --- a/spx-gui/vercel-build.sh +++ b/spx-gui/vercel-build.sh @@ -1,5 +1,7 @@ #!/bin/bash set -e -export PATH=$PATH:/usr/local/go/bin && ./build-wasm.sh +export PATH=/usr/local/go/bin:$PATH + +./build-wasm.sh npm run build diff --git a/spx-gui/vercel-install.sh b/spx-gui/vercel-install.sh index b07425c4a..71ad9049d 100755 --- a/spx-gui/vercel-install.sh +++ b/spx-gui/vercel-install.sh @@ -11,4 +11,4 @@ tar -C /usr/local -xzf ./go1.23.4.linux-amd64.tar.gz /usr/local/go/bin/go version npm install -source ./install-spx.sh +./install-spx.sh diff --git a/tools/ispx/.gitignore b/tools/ispx/.gitignore deleted file mode 100644 index 671839559..000000000 --- a/tools/ispx/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# We build / Copy-paste them before running project -main.wasm -wasm_exec.js diff --git a/tools/ispx/.vscode/settings.json b/tools/ispx/.vscode/settings.json deleted file mode 100644 index 255414f8f..000000000 --- a/tools/ispx/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "gopls": { - "build.env": { - "GOOS": "js", - "GOARCH": "wasm" - } - } -} \ No newline at end of file diff --git a/tools/ispx/build.bat b/tools/ispx/build.bat deleted file mode 100644 index 2e3cbf57f..000000000 --- a/tools/ispx/build.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -setlocal - -set GOOS=js -set GOARCH=wasm - -go build -tags canvas -trimpath -o main.wasm - -endlocal diff --git a/tools/ispx/build.sh b/tools/ispx/build.sh index c030fa9d9..b7163711c 100755 --- a/tools/ispx/build.sh +++ b/tools/ispx/build.sh @@ -1,3 +1,4 @@ -#!/bin/sh +#!/bin/bash +set -e -GOTOOLCHAIN=go1.21.3 GOOS=js GOARCH=wasm go build -tags canvas -trimpath -o main.wasm +GOOS=js GOARCH=wasm go build -tags canvas -trimpath -ldflags -checklinkname=0 -o ispx.wasm diff --git a/tools/ispx/embedded_pkgs.go b/tools/ispx/embedded_pkgs.go index 9df0fcd23..e2100479f 100644 --- a/tools/ispx/embedded_pkgs.go +++ b/tools/ispx/embedded_pkgs.go @@ -71,6 +71,7 @@ import ( _ "github.com/goplus/igop/pkg/io" _ "github.com/goplus/igop/pkg/io/fs" _ "github.com/goplus/igop/pkg/io/ioutil" + _ "github.com/goplus/igop/pkg/iter" _ "github.com/goplus/igop/pkg/log" _ "github.com/goplus/igop/pkg/log/slog" _ "github.com/goplus/igop/pkg/maps" @@ -79,6 +80,7 @@ import ( _ "github.com/goplus/igop/pkg/math/bits" _ "github.com/goplus/igop/pkg/math/cmplx" _ "github.com/goplus/igop/pkg/math/rand" + _ "github.com/goplus/igop/pkg/math/rand/v2" _ "github.com/goplus/igop/pkg/mime" _ "github.com/goplus/igop/pkg/net/http" _ "github.com/goplus/igop/pkg/net/netip" @@ -106,6 +108,7 @@ import ( _ "github.com/goplus/igop/pkg/unicode" _ "github.com/goplus/igop/pkg/unicode/utf16" _ "github.com/goplus/igop/pkg/unicode/utf8" + _ "github.com/goplus/igop/pkg/unique" // Excluded stdlib packages. // _ "github.com/goplus/igop/pkg/container/heap" @@ -140,6 +143,7 @@ import ( // _ "github.com/goplus/igop/pkg/go/scanner" // _ "github.com/goplus/igop/pkg/go/token" // _ "github.com/goplus/igop/pkg/go/types" + // _ "github.com/goplus/igop/pkg/go/version" // _ "github.com/goplus/igop/pkg/index/suffixarray" // _ "github.com/goplus/igop/pkg/log/syslog" // _ "github.com/goplus/igop/pkg/mime/multipart" @@ -160,12 +164,12 @@ import ( // _ "github.com/goplus/igop/pkg/os/exec" // _ "github.com/goplus/igop/pkg/os/signal" // _ "github.com/goplus/igop/pkg/os/user" - // _ "github.com/goplus/igop/pkg/plugin" // _ "github.com/goplus/igop/pkg/runtime/coverage" // _ "github.com/goplus/igop/pkg/runtime/debug" // _ "github.com/goplus/igop/pkg/runtime/metrics" // _ "github.com/goplus/igop/pkg/runtime/pprof" // _ "github.com/goplus/igop/pkg/runtime/trace" + // _ "github.com/goplus/igop/pkg/structs" // _ "github.com/goplus/igop/pkg/syscall" // _ "github.com/goplus/igop/pkg/testing" // _ "github.com/goplus/igop/pkg/testing/fstest" diff --git a/tools/ispx/go.mod b/tools/ispx/go.mod index 61d0e2834..75b4c80fc 100644 --- a/tools/ispx/go.mod +++ b/tools/ispx/go.mod @@ -1,9 +1,9 @@ module github.com/goplus/builder/ispx -go 1.21.0 +go 1.23.0 require ( - github.com/goplus/igop v0.32.0 + github.com/goplus/igop v0.32.1 github.com/goplus/reflectx v1.3.2 github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499 github.com/hajimehoshi/ebiten/v2 v2.8.0-alpha.3 diff --git a/tools/ispx/go.sum b/tools/ispx/go.sum index fed6a7a9e..df58207da 100644 --- a/tools/ispx/go.sum +++ b/tools/ispx/go.sum @@ -31,8 +31,8 @@ github.com/goplus/gogen v1.16.6 h1:Zwv18HoTbPDk8s2ajxgVeqZE5i4/GMV722KHl6GS8Yk= github.com/goplus/gogen v1.16.6/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8= github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972 h1:wA4+I+DDfoNwR+zCnaeckt5pxZgLAuaKvVkC+T9GdiQ= github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972/go.mod h1:lcW75c0a5v361jId1Vxs4lRrsasWsQDH0k3dG3Z7wH0= -github.com/goplus/igop v0.32.0 h1:2m/RjkkFLPzRJ0ERyNCh8Abk0XuLSlxFkEFaygnpHgM= -github.com/goplus/igop v0.32.0/go.mod h1:GCJA4qASZ1IU8MNNgDiW+Yf+eKf2G8fJWrx3arSBm8A= +github.com/goplus/igop v0.32.1 h1:GbI9ThqEUDX9f18jO1xx9NWRb3XnTIgg+byr3JnCpAA= +github.com/goplus/igop v0.32.1/go.mod h1:GCJA4qASZ1IU8MNNgDiW+Yf+eKf2G8fJWrx3arSBm8A= github.com/goplus/llgo v0.9.9/go.mod h1:udcq+s6tGOdhJq7I8fXPTv4qT2j17/KrlvtcJrMZAoM= github.com/goplus/llvm v0.8.0/go.mod h1:PeVK8GgzxwAYCiMiUAJb5wJR6xbhj989tu9oulKLLT4= github.com/goplus/mod v0.13.13/go.mod h1:invR72Rz2+qpOOsXqxz830MX8/aR2GDR2EAow/WgfHI= diff --git a/tools/ispx/runner.html b/tools/ispx/runner.html index aafb0119e..663dc7824 100644 --- a/tools/ispx/runner.html +++ b/tools/ispx/runner.html @@ -8,7 +8,7 @@ (async () => { const go = new Go(); - const { instance } = await WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject) + const { instance } = await WebAssembly.instantiateStreaming(fetch("ispx.wasm"), go.importObject) go.run(instance); window.startWithZipBuffer = (buffer) => { diff --git a/tools/spxls/go.mod b/tools/spxls/go.mod index 81bd3ca1f..74ce75eb1 100644 --- a/tools/spxls/go.mod +++ b/tools/spxls/go.mod @@ -4,8 +4,8 @@ go 1.23.4 require ( github.com/goplus/gogen v1.16.6 - github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972 - github.com/goplus/mod v0.13.15 + github.com/goplus/gop v1.3.0 + github.com/goplus/mod v0.13.17 github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499 github.com/stretchr/testify v1.9.0 golang.org/x/tools v0.23.0 diff --git a/tools/spxls/go.sum b/tools/spxls/go.sum index 602137759..47dc2ae0a 100644 --- a/tools/spxls/go.sum +++ b/tools/spxls/go.sum @@ -22,10 +22,10 @@ github.com/goplus/canvas v0.1.0 h1:Vx3f2+U8UANvWf5/01YsQYKNbZDm1GZCjhlEBFrQkeU= github.com/goplus/canvas v0.1.0/go.mod h1:Rhcvo5qkpD9WuXFnvnXtrBSY97l6h7sXQuofrmiLNdM= github.com/goplus/gogen v1.16.6 h1:Zwv18HoTbPDk8s2ajxgVeqZE5i4/GMV722KHl6GS8Yk= github.com/goplus/gogen v1.16.6/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8= -github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972 h1:wA4+I+DDfoNwR+zCnaeckt5pxZgLAuaKvVkC+T9GdiQ= -github.com/goplus/gop v1.2.0-pre.1.0.20250112163018-5fb12b1b2972/go.mod h1:lcW75c0a5v361jId1Vxs4lRrsasWsQDH0k3dG3Z7wH0= -github.com/goplus/mod v0.13.15 h1:IyneSjwm1VpwvHGz6hSHnFxZCuO6ULHcu74IAZcW9nw= -github.com/goplus/mod v0.13.15/go.mod h1:invR72Rz2+qpOOsXqxz830MX8/aR2GDR2EAow/WgfHI= +github.com/goplus/gop v1.3.0 h1:RDOTn+VZc9jB1qF3mkgB0f1LuAbzRKz4pNVGzkH7Ii8= +github.com/goplus/gop v1.3.0/go.mod h1:BnMzJG+PYoOWjKT4Q7CwxLUTBRnTFuuxW8W4O3vq/TU= +github.com/goplus/mod v0.13.17 h1:aWp14xosENrh7t0/0qcIejDmQEiTgI3ou2+KoLDlSlE= +github.com/goplus/mod v0.13.17/go.mod h1:XlHf8mnQ4QkRDX14Of2tpywuHDd+JVpPStvh3egog+0= github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499 h1:wt9bXZWSZ6MKgLw0c87GSbKrXjj69aCt7JVM1RwLp3c= github.com/goplus/spx v1.1.1-0.20250214074125-e9e1f6362499/go.mod h1:ng8mGU/k+1pXjG5zpeczzLOyDD0RhvOv35bxmpiTPGQ= github.com/hajimehoshi/ebiten/v2 v2.7.9 h1:DYH/usAa9dMHcGkBIIEApJsVqDekrJBxYHmsBuly8Iw=