diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 45a0274e..2092712f 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -75,8 +75,8 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + repository: yaoapp/v8go + lfs: true path: v8go - name: Checkout XGen v1.0 diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 36ce72a4..ab849781 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -56,8 +56,8 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + repository: yaoapp/v8go + lfs: true path: v8go - name: Checkout XGen v1.0 diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 7cbcf9b2..8ff75954 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -150,8 +150,8 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + repository: yaoapp/v8go + lfs: true path: v8go - name: Checkout Demo App diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 02e89552..c8355e72 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -107,8 +107,8 @@ jobs: - name: Checkout V8Go uses: actions/checkout@v3 with: - repository: rogchap/v8go - # ref: aac4923ed74083e58ae7b42b1acb0fa0d11a26cb + repository: yaoapp/v8go + lfs: true path: v8go - name: Checkout Demo App 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/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 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 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) }