From a4a639568db06dce36076a5892b219517c11dcb0 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 22 Dec 2023 20:43:35 +0800 Subject: [PATCH 1/4] [add] Update V8Go repository in GitHub Actions workflows --- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-macos.yml | 2 +- .github/workflows/pr-test.yml | 2 +- .github/workflows/unit-test.yml | 2 +- .gitignore | 4 +++- sui/api/request.go | 7 ++++++- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 45a0274e..2827fb12 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -75,7 +75,7 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go + repository: yaoapp/v8go # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb path: v8go diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 36ce72a4..b63e15b9 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -56,7 +56,7 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go + repository: yaoapp/v8go # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb path: v8go diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 7cbcf9b2..66383e99 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -150,7 +150,7 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go + repository: yaoapp/v8go # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb path: v8go diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 02e89552..07b9e685 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -107,7 +107,7 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go + repository: yaoapp/v8go # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb path: v8go diff --git a/.gitignore b/.gitignore index 162dd4f1..b5bea6ba 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +*.log + # Dependency directories (remove the comment below to include it) # vendor/ .DS_Store @@ -35,4 +37,4 @@ xgen/v1.0/* !xgen/v1.0/index.html !xgen/v1.0/umi.js !xgen/v1.0/layouts__index.async.js -*-unit-test \ No newline at end of file +*-unit-test diff --git a/sui/api/request.go b/sui/api/request.go index 2a402a89..5e6fdf5b 100644 --- a/sui/api/request.go +++ b/sui/api/request.go @@ -102,7 +102,12 @@ func (r *Request) Render() (string, int, error) { } // Save to The Cache - c = core.SetCache(r.File, html, dataText, globalDataText) + // c = core.SetCache(r.File, html, dataText, globalDataText) + c = &core.Cache{ + Data: dataText, + Global: globalDataText, + HTML: html, + } log.Trace("The page %s is cached", r.File) } From f0b82721c03a5347c92ca5230c9c379a8cddcca1 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 22 Dec 2023 22:28:22 +0800 Subject: [PATCH 2/4] [_] --- config/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/types.go b/config/types.go index 6e2cccef..c3495d08 100644 --- a/config/types.go +++ b/config/types.go @@ -52,7 +52,7 @@ type Session struct { // Runtime Config type Runtime struct { - Mode string `json:"mode,omitempty" env:"YAO_RUNTIME_MODE" envDefault:"normal"` // the mode of the runtime, the default value is "normal" and the other value is "performance". "performance" mode need more memory but will run faster + Mode string `json:"mode,omitempty" env:"YAO_RUNTIME_MODE" envDefault:"standard"` // the mode of the runtime, the default value is "standard" and the other value is "performance". "performance" mode need more memory but will run faster MinSize int `json:"minSize,omitempty" env:"YAO_RUNTIME_MIN" envDefault:"10"` // the number of V8 VM when runtime start. max value is 100, the default value is 2 MaxSize int `json:"maxSize,omitempty" env:"YAO_RUNTIME_MAX" envDefault:"100"` // the maximum of V8 VM should be smaller than minSize, the default value is 10 DefaultTimeout int `json:"defaultTimeout,omitempty" env:"YAO_RUNTIME_TIMEOUT" envDefault:"200"` // the default timeout for the script, the default value is 200ms From 7c3fdbe09683fa9a4e4c01e88842926477d88893 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 26 Dec 2023 03:07:30 +0800 Subject: [PATCH 3/4] Refactor bridge functions in request.go --- neo/command/request.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/neo/command/request.go b/neo/command/request.go index 8d688fac..6e0da9ac 100644 --- a/neo/command/request.go +++ b/neo/command/request.go @@ -376,20 +376,18 @@ func (req *Request) runScript(id string, args []interface{}, cb func(msg *messag } defer v8ctx.Close() - // make a new bridge function ssWrite - ssWriteT := v8go.NewFunctionTemplate(v8ctx.Isolate(), func(info *v8go.FunctionCallbackInfo) *v8go.Value { + v8ctx.WithFunction("ssWrite", func(info *v8go.FunctionCallbackInfo) *v8go.Value { args := info.Args() if len(args) != 1 { - return v8go.Null(v8ctx.Isolate()) + return v8go.Null(info.Context().Isolate()) } text := args[0].String() cb(req.msg().Text(text)) - return v8go.Null(v8ctx.Isolate()) + return v8go.Null(info.Context().Isolate()) }) - // make a new bridge function done - doneT := v8go.NewFunctionTemplate(v8ctx.Isolate(), func(info *v8go.FunctionCallbackInfo) *v8go.Value { + v8ctx.WithFunction("done", func(info *v8go.FunctionCallbackInfo) *v8go.Value { args := info.Args() if len(args) == 1 { text := args[0].String() @@ -398,12 +396,9 @@ func (req *Request) runScript(id string, args []interface{}, cb func(msg *messag cb(req.msg().Done()) // req.Done() - return v8go.Null(v8ctx.Isolate()) + return v8go.Null(v8ctx.Context.Isolate()) }) - v8ctx.Global().Set("ssWrite", ssWriteT.GetFunction(v8ctx.Context)) - v8ctx.Global().Set("done", doneT.GetFunction(v8ctx.Context)) - res, err := v8ctx.CallWith(req.ctx, method, args...) if err != nil { return nil, err From c4b5da11bfecce7d3823c42b581ced171e5b3ccb Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 26 Dec 2023 03:13:18 +0800 Subject: [PATCH 4/4] Enable Git LFS for v8go repository --- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-macos.yml | 2 +- .github/workflows/pr-test.yml | 2 +- .github/workflows/unit-test.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 2827fb12..2092712f 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -76,7 +76,7 @@ jobs: uses: actions/checkout@v3 with: repository: yaoapp/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + lfs: true path: v8go - name: Checkout XGen v1.0 diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index b63e15b9..ab849781 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -57,7 +57,7 @@ jobs: uses: actions/checkout@v3 with: repository: yaoapp/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + lfs: true path: v8go - name: Checkout XGen v1.0 diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 66383e99..8ff75954 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -151,7 +151,7 @@ jobs: uses: actions/checkout@v3 with: repository: yaoapp/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + lfs: true path: v8go - name: Checkout Demo App diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 07b9e685..c8355e72 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -108,7 +108,7 @@ jobs: uses: actions/checkout@v3 with: repository: yaoapp/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + lfs: true path: v8go - name: Checkout Demo App