From 2877de03bfcda2f9cf43781573a9fcf9348b8619 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 10 Jun 2024 15:30:07 +0300 Subject: [PATCH] Rename to sobek See https://github.com/grafana/k6/issues/3772 --- README.md | 50 ++++++------- array.go | 4 +- array_sparse.go | 4 +- array_sparse_test.go | 2 +- array_test.go | 2 +- ast/README.markdown | 2 +- ast/node.go | 6 +- builtin_array.go | 2 +- builtin_arrray_test.go | 2 +- builtin_boolean.go | 2 +- builtin_date.go | 2 +- builtin_error.go | 4 +- builtin_function.go | 2 +- builtin_function_test.go | 2 +- builtin_global.go | 4 +- builtin_global_test.go | 2 +- builtin_json.go | 4 +- builtin_json_test.go | 2 +- builtin_map.go | 2 +- builtin_map_test.go | 2 +- builtin_math.go | 2 +- builtin_number.go | 4 +- builtin_object.go | 2 +- builtin_promise.go | 10 +-- builtin_proxy.go | 4 +- builtin_proxy_test.go | 2 +- builtin_reflect.go | 2 +- builtin_regexp.go | 4 +- builtin_set.go | 2 +- builtin_set_test.go | 2 +- builtin_string.go | 6 +- builtin_string_test.go | 2 +- builtin_symbol.go | 4 +- builtin_typedarrays.go | 4 +- builtin_typedarrays_test.go | 2 +- builtin_weakmap.go | 2 +- builtin_weakmap_test.go | 2 +- builtin_weakset.go | 2 +- builtin_weakset_test.go | 2 +- compiler.go | 10 +-- compiler_expr.go | 10 +-- compiler_stmt.go | 10 +-- compiler_test.go | 4 +- date.go | 2 +- date_parser.go | 2 +- date_parser_test.go | 2 +- date_test.go | 2 +- destruct.go | 4 +- file/README.markdown | 2 +- ftoa/ftostr.go | 2 +- func.go | 4 +- func_test.go | 2 +- go.mod | 9 ++- go.sum | 34 --------- goja/main.go | 127 --------------------------------- ipow.go | 2 +- map.go | 2 +- map_test.go | 2 +- object.go | 4 +- object_args.go | 4 +- object_dynamic.go | 4 +- object_dynamic_test.go | 2 +- object_goarray_reflect.go | 4 +- object_goarray_reflect_test.go | 2 +- object_gomap.go | 4 +- object_gomap_reflect.go | 4 +- object_gomap_reflect_test.go | 2 +- object_gomap_test.go | 2 +- object_goreflect.go | 6 +- object_goreflect_test.go | 2 +- object_goslice.go | 4 +- object_goslice_reflect.go | 4 +- object_goslice_reflect_test.go | 2 +- object_goslice_test.go | 2 +- object_template.go | 4 +- object_test.go | 2 +- parser/README.markdown | 4 +- parser/error.go | 4 +- parser/expression.go | 8 +-- parser/lexer.go | 6 +- parser/lexer_test.go | 6 +- parser/marshal_test.go | 2 +- parser/parser.go | 10 +-- parser/parser_test.go | 8 +-- parser/scope.go | 4 +- parser/statement.go | 6 +- profiler.go | 2 +- profiler_test.go | 2 +- proxy.go | 4 +- regexp.go | 4 +- regexp_test.go | 2 +- runtime.go | 14 ++-- runtime_test.go | 12 ++-- string.go | 4 +- string_ascii.go | 4 +- string_imported.go | 6 +- string_test.go | 2 +- string_unicode.go | 6 +- tc39_norace_test.go | 2 +- tc39_race_test.go | 2 +- tc39_test.go | 4 +- token/README.markdown | 2 +- typedarrays.go | 4 +- typedarrays_test.go | 2 +- value.go | 6 +- vm.go | 4 +- vm_test.go | 8 +-- 107 files changed, 224 insertions(+), 382 deletions(-) delete mode 100644 goja/main.go diff --git a/README.md b/README.md index a4d0c09..97e9d5c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -goja +sobek ==== ECMAScript 5.1(+) implementation in Go. -[![Go Reference](https://pkg.go.dev/badge/github.com/dop251/goja.svg)](https://pkg.go.dev/github.com/dop251/goja) +[![Go Reference](https://pkg.go.dev/badge/github.com/grafana/sobek.svg)](https://pkg.go.dev/github.com/grafana/sobek) Goja is an implementation of ECMAScript 5.1 in pure Go with emphasis on standard compliance and performance. @@ -20,7 +20,7 @@ Features pass all of them. See .tc39_test262_checkout.sh for the latest working commit id. * Capable of running Babel, Typescript compiler and pretty much anything written in ES5. * Sourcemaps. - * Most of ES6 functionality, still work in progress, see https://github.com/dop251/goja/milestone/1?closed=1 + * Most of ES6 functionality, still work in progress, see https://github.com/grafana/sobek/milestone/1?closed=1 Known incompatibilities and caveats ----------------------------------- @@ -98,7 +98,7 @@ It gives you a much better control over execution environment so can be useful f ### Is it goroutine-safe? -No. An instance of goja.Runtime can only be used by a single goroutine +No. An instance of sobek.Runtime can only be used by a single goroutine at a time. You can create as many instances of Runtime as you like but it's not possible to pass object values between runtimes. @@ -106,13 +106,13 @@ it's not possible to pass object values between runtimes. setTimeout() assumes concurrent execution of code which requires an execution environment, for example an event loop similar to nodejs or a browser. -There is a [separate project](https://github.com/dop251/goja_nodejs) aimed at providing some NodeJS functionality, +There is a [separate project](https://github.com/grafana/sobek_nodejs) aimed at providing some NodeJS functionality, and it includes an event loop. ### Can you implement (feature X from ES6 or higher)? I will be adding features in their dependency order and as quickly as time permits. Please do not ask -for ETAs. Features that are open in the [milestone](https://github.com/dop251/goja/milestone/1) are either in progress +for ETAs. Features that are open in the [milestone](https://github.com/grafana/sobek/milestone/1) are either in progress or will be worked on next. The ongoing work is done in separate feature branches which are merged into master when appropriate. @@ -141,7 +141,7 @@ Basic Example Run JavaScript and get the result value. ```go -vm := goja.New() +vm := sobek.New() v, err := vm.RunString("2 + 2") if err != nil { panic(err) @@ -153,13 +153,13 @@ if num := v.Export().(int64); num != 4 { Passing Values to JS -------------------- -Any Go value can be passed to JS using Runtime.ToValue() method. See the method's [documentation](https://pkg.go.dev/github.com/dop251/goja#Runtime.ToValue) for more details. +Any Go value can be passed to JS using Runtime.ToValue() method. See the method's [documentation](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ToValue) for more details. Exporting Values from JS ------------------------ A JS value can be exported into its default Go representation using Value.Export() method. -Alternatively it can be exported into a specific Go variable using [Runtime.ExportTo()](https://pkg.go.dev/github.com/dop251/goja#Runtime.ExportTo) method. +Alternatively it can be exported into a specific Go variable using [Runtime.ExportTo()](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ExportTo) method. Within a single export operation the same Object will be represented by the same Go value (either the same map, slice or a pointer to the same struct). This includes circular objects and makes it possible to export them. @@ -168,7 +168,7 @@ Calling JS functions from Go ---------------------------- There are 2 approaches: -- Using [AssertFunction()](https://pkg.go.dev/github.com/dop251/goja#AssertFunction): +- Using [AssertFunction()](https://pkg.go.dev/github.com/grafana/sobek#AssertFunction): ```go const SCRIPT = ` function sum(a, b) { @@ -176,24 +176,24 @@ function sum(a, b) { } ` -vm := goja.New() +vm := sobek.New() _, err := vm.RunString(SCRIPT) if err != nil { panic(err) } -sum, ok := goja.AssertFunction(vm.Get("sum")) +sum, ok := sobek.AssertFunction(vm.Get("sum")) if !ok { panic("Not a function") } -res, err := sum(goja.Undefined(), vm.ToValue(40), vm.ToValue(2)) +res, err := sum(sobek.Undefined(), vm.ToValue(40), vm.ToValue(2)) if err != nil { panic(err) } fmt.Println(res) // Output: 42 ``` -- Using [Runtime.ExportTo()](https://pkg.go.dev/github.com/dop251/goja#Runtime.ExportTo): +- Using [Runtime.ExportTo()](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ExportTo): ```go const SCRIPT = ` function sum(a, b) { @@ -201,7 +201,7 @@ function sum(a, b) { } ` -vm := goja.New() +vm := sobek.New() _, err := vm.RunString(SCRIPT) if err != nil { panic(err) @@ -224,10 +224,10 @@ Mapping struct field and method names ------------------------------------- By default, the names are passed through as is which means they are capitalised. This does not match the standard JavaScript naming convention, so if you need to make your JS code look more natural or if you are -dealing with a 3rd party library, you can use a [FieldNameMapper](https://pkg.go.dev/github.com/dop251/goja#FieldNameMapper): +dealing with a 3rd party library, you can use a [FieldNameMapper](https://pkg.go.dev/github.com/grafana/sobek#FieldNameMapper): ```go -vm := goja.New() +vm := sobek.New() vm.SetFieldNameMapper(TagFieldNameMapper("json", true)) type S struct { Field int `json:"field"` @@ -238,14 +238,14 @@ fmt.Println(res.Export()) // Output: 42 ``` -There are two standard mappers: [TagFieldNameMapper](https://pkg.go.dev/github.com/dop251/goja#TagFieldNameMapper) and -[UncapFieldNameMapper](https://pkg.go.dev/github.com/dop251/goja#UncapFieldNameMapper), or you can use your own implementation. +There are two standard mappers: [TagFieldNameMapper](https://pkg.go.dev/github.com/grafana/sobek#TagFieldNameMapper) and +[UncapFieldNameMapper](https://pkg.go.dev/github.com/grafana/sobek#UncapFieldNameMapper), or you can use your own implementation. Native Constructors ------------------- -In order to implement a constructor function in Go use `func (goja.ConstructorCall) *goja.Object`. -See [Runtime.ToValue()](https://pkg.go.dev/github.com/dop251/goja#Runtime.ToValue) documentation for more details. +In order to implement a constructor function in Go use `func (sobek.ConstructorCall) *sobek.Object`. +See [Runtime.ToValue()](https://pkg.go.dev/github.com/grafana/sobek#Runtime.ToValue) documentation for more details. Regular Expressions ------------------- @@ -259,7 +259,7 @@ Any exception thrown in JavaScript is returned as an error of type *Exception. I by using the Value() method: ```go -vm := goja.New() +vm := sobek.New() _, err := vm.RunString(` throw("Test"); @@ -284,7 +284,7 @@ func Test() { panic(vm.ToValue("Error")) } -vm = goja.New() +vm = sobek.New() vm.Set("Test", Test) _, err := vm.RunString(` @@ -315,7 +315,7 @@ func TestInterrupt(t *testing.T) { } ` - vm := goja.New() + vm := sobek.New() time.AfterFunc(200 * time.Millisecond, func() { vm.Interrupt("halt") }) @@ -331,4 +331,4 @@ func TestInterrupt(t *testing.T) { NodeJS Compatibility -------------------- -There is a [separate project](https://github.com/dop251/goja_nodejs) aimed at providing some of the NodeJS functionality. +There is a [separate project](https://github.com/grafana/sobek_nodejs) aimed at providing some of the NodeJS functionality. diff --git a/array.go b/array.go index 7a67a47..ef12dc5 100644 --- a/array.go +++ b/array.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -7,7 +7,7 @@ import ( "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type arrayIterObject struct { diff --git a/array_sparse.go b/array_sparse.go index f99afd7..877d281 100644 --- a/array_sparse.go +++ b/array_sparse.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -8,7 +8,7 @@ import ( "sort" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type sparseArrayItem struct { diff --git a/array_sparse_test.go b/array_sparse_test.go index 9a635cf..32f513e 100644 --- a/array_sparse_test.go +++ b/array_sparse_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/array_test.go b/array_test.go index fbbd4aa..baded42 100644 --- a/array_test.go +++ b/array_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "reflect" diff --git a/ast/README.markdown b/ast/README.markdown index aba088e..65aa001 100644 --- a/ast/README.markdown +++ b/ast/README.markdown @@ -1,6 +1,6 @@ # ast -- - import "github.com/dop251/goja/ast" + import "github.com/grafana/sobek/ast" Package ast declares types representing a JavaScript AST. diff --git a/ast/node.go b/ast/node.go index 3bec89d..0663ba8 100644 --- a/ast/node.go +++ b/ast/node.go @@ -9,9 +9,9 @@ node types are concerned) and may change in the future. package ast import ( - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) type PropertyKind string diff --git a/builtin_array.go b/builtin_array.go index 6ba8802..7121bfa 100644 --- a/builtin_array.go +++ b/builtin_array.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/builtin_arrray_test.go b/builtin_arrray_test.go index a190f1f..8418a95 100644 --- a/builtin_arrray_test.go +++ b/builtin_arrray_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import "testing" diff --git a/builtin_boolean.go b/builtin_boolean.go index 8476328..757f8ad 100644 --- a/builtin_boolean.go +++ b/builtin_boolean.go @@ -1,4 +1,4 @@ -package goja +package sobek func (r *Runtime) booleanproto_toString(call FunctionCall) Value { var b bool diff --git a/builtin_date.go b/builtin_date.go index 84a80ac..b67e7f0 100644 --- a/builtin_date.go +++ b/builtin_date.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/builtin_error.go b/builtin_error.go index b07bf6a..9953254 100644 --- a/builtin_error.go +++ b/builtin_error.go @@ -1,6 +1,6 @@ -package goja +package sobek -import "github.com/dop251/goja/unistring" +import "github.com/grafana/sobek/unistring" const propNameStack = "stack" diff --git a/builtin_function.go b/builtin_function.go index 26a1287..64332f9 100644 --- a/builtin_function.go +++ b/builtin_function.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/builtin_function_test.go b/builtin_function_test.go index f330821..e381a80 100644 --- a/builtin_function_test.go +++ b/builtin_function_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/builtin_global.go b/builtin_global.go index 5ef4176..d7ba9b4 100644 --- a/builtin_global.go +++ b/builtin_global.go @@ -1,8 +1,8 @@ -package goja +package sobek import ( "errors" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "io" "math" "regexp" diff --git a/builtin_global_test.go b/builtin_global_test.go index 5ac8d7f..cda46b5 100644 --- a/builtin_global_test.go +++ b/builtin_global_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/builtin_json.go b/builtin_json.go index e99771c..57f7ccd 100644 --- a/builtin_json.go +++ b/builtin_json.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "bytes" @@ -12,7 +12,7 @@ import ( "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const hex = "0123456789abcdef" diff --git a/builtin_json_test.go b/builtin_json_test.go index a71c54e..437a22c 100644 --- a/builtin_json_test.go +++ b/builtin_json_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "encoding/json" diff --git a/builtin_map.go b/builtin_map.go index 819d025..c0c887f 100644 --- a/builtin_map.go +++ b/builtin_map.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "reflect" diff --git a/builtin_map_test.go b/builtin_map_test.go index e6afafe..ef982ca 100644 --- a/builtin_map_test.go +++ b/builtin_map_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/builtin_math.go b/builtin_math.go index 169ea18..a31d7c3 100644 --- a/builtin_math.go +++ b/builtin_math.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/builtin_number.go b/builtin_number.go index 43add4f..f7b2ee0 100644 --- a/builtin_number.go +++ b/builtin_number.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "math" "sync" - "github.com/dop251/goja/ftoa" + "github.com/grafana/sobek/ftoa" ) func (r *Runtime) toNumber(v Value) Value { diff --git a/builtin_object.go b/builtin_object.go index 6bf1ff8..d7c5aa9 100644 --- a/builtin_object.go +++ b/builtin_object.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/builtin_promise.go b/builtin_promise.go index d51f27d..a4a1255 100644 --- a/builtin_promise.go +++ b/builtin_promise.go @@ -1,7 +1,7 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "reflect" ) @@ -605,18 +605,18 @@ func (r *Runtime) wrapPromiseReaction(fObj *Object) func(interface{}) { // NewPromise creates and returns a Promise and resolving functions for it. // // WARNING: The returned values are not goroutine-safe and must not be called in parallel with VM running. -// In order to make use of this method you need an event loop such as the one in goja_nodejs (https://github.com/dop251/goja_nodejs) +// In order to make use of this method you need an event loop such as the one in sobek_nodejs (https://github.com/grafana/sobek_nodejs) // where it can be used like this: // // loop := NewEventLoop() // loop.Start() // defer loop.Stop() -// loop.RunOnLoop(func(vm *goja.Runtime) { +// loop.RunOnLoop(func(vm *sobek.Runtime) { // p, resolve, _ := vm.NewPromise() // vm.Set("p", p) // go func() { // time.Sleep(500 * time.Millisecond) // or perform any other blocking operation -// loop.RunOnLoop(func(*goja.Runtime) { // resolve() must be called on the loop, cannot call it here +// loop.RunOnLoop(func(*sobek.Runtime) { // resolve() must be called on the loop, cannot call it here // resolve(result) // }) // }() diff --git a/builtin_proxy.go b/builtin_proxy.go index f589930..4ec5ba0 100644 --- a/builtin_proxy.go +++ b/builtin_proxy.go @@ -1,7 +1,7 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type nativeProxyHandler struct { diff --git a/builtin_proxy_test.go b/builtin_proxy_test.go index 64ccafd..214743f 100644 --- a/builtin_proxy_test.go +++ b/builtin_proxy_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "strconv" diff --git a/builtin_reflect.go b/builtin_reflect.go index 17bb11a..8ee0d7c 100644 --- a/builtin_reflect.go +++ b/builtin_reflect.go @@ -1,4 +1,4 @@ -package goja +package sobek func (r *Runtime) builtin_reflect_apply(call FunctionCall) Value { return r.toCallable(call.Argument(0))(FunctionCall{ diff --git a/builtin_regexp.go b/builtin_regexp.go index 8940282..a606da0 100644 --- a/builtin_regexp.go +++ b/builtin_regexp.go @@ -1,8 +1,8 @@ -package goja +package sobek import ( "fmt" - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" "regexp" "strings" "unicode/utf16" diff --git a/builtin_set.go b/builtin_set.go index eeedb88..45d956f 100644 --- a/builtin_set.go +++ b/builtin_set.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/builtin_set_test.go b/builtin_set_test.go index bd5fc6a..e05dc02 100644 --- a/builtin_set_test.go +++ b/builtin_set_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/builtin_string.go b/builtin_string.go index b2a0e4e..2343ed2 100644 --- a/builtin_string.go +++ b/builtin_string.go @@ -1,14 +1,14 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "math" "strings" "sync" "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" "golang.org/x/text/collate" "golang.org/x/text/language" "golang.org/x/text/unicode/norm" diff --git a/builtin_string_test.go b/builtin_string_test.go index c740cc7..e1b80ca 100644 --- a/builtin_string_test.go +++ b/builtin_string_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import "testing" diff --git a/builtin_symbol.go b/builtin_symbol.go index 8231b7b..b0c5fc8 100644 --- a/builtin_symbol.go +++ b/builtin_symbol.go @@ -1,6 +1,6 @@ -package goja +package sobek -import "github.com/dop251/goja/unistring" +import "github.com/grafana/sobek/unistring" var ( SymHasInstance = newSymbol(asciiString("Symbol.hasInstance")) diff --git a/builtin_typedarrays.go b/builtin_typedarrays.go index 1fd672c..7ad737f 100644 --- a/builtin_typedarrays.go +++ b/builtin_typedarrays.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -7,7 +7,7 @@ import ( "sync" "unsafe" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type typedArraySortCtx struct { diff --git a/builtin_typedarrays_test.go b/builtin_typedarrays_test.go index ad9f6d8..0253886 100644 --- a/builtin_typedarrays_test.go +++ b/builtin_typedarrays_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/builtin_weakmap.go b/builtin_weakmap.go index 40fc717..24bfdd2 100644 --- a/builtin_weakmap.go +++ b/builtin_weakmap.go @@ -1,4 +1,4 @@ -package goja +package sobek type weakMap uint64 diff --git a/builtin_weakmap_test.go b/builtin_weakmap_test.go index 648320d..579ea58 100644 --- a/builtin_weakmap_test.go +++ b/builtin_weakmap_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/builtin_weakset.go b/builtin_weakset.go index cd8183e..e1f842e 100644 --- a/builtin_weakset.go +++ b/builtin_weakset.go @@ -1,4 +1,4 @@ -package goja +package sobek type weakSetObject struct { baseObject diff --git a/builtin_weakset_test.go b/builtin_weakset_test.go index edd1b17..467f1f3 100644 --- a/builtin_weakset_test.go +++ b/builtin_weakset_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/compiler.go b/compiler.go index 2abd9ba..edebf8c 100644 --- a/compiler.go +++ b/compiler.go @@ -1,13 +1,13 @@ -package goja +package sobek import ( "fmt" - "github.com/dop251/goja/token" + "github.com/grafana/sobek/token" "sort" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/unistring" ) type blockType int diff --git a/compiler_expr.go b/compiler_expr.go index 477580a..69d3715 100644 --- a/compiler_expr.go +++ b/compiler_expr.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) type compiledExpr interface { diff --git a/compiler_stmt.go b/compiler_stmt.go index 2d3d83b..f9599b7 100644 --- a/compiler_stmt.go +++ b/compiler_stmt.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) func (c *compiler) compileStatement(v ast.Statement, needResult bool) { diff --git a/compiler_test.go b/compiler_test.go index 05d82ca..1cd9b16 100644 --- a/compiler_test.go +++ b/compiler_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "os" @@ -6,7 +6,7 @@ import ( "testing" "unsafe" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const TESTLIB = ` diff --git a/date.go b/date.go index ee29a21..d06841d 100644 --- a/date.go +++ b/date.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" diff --git a/date_parser.go b/date_parser.go index f836053..a956426 100644 --- a/date_parser.go +++ b/date_parser.go @@ -1,4 +1,4 @@ -package goja +package sobek // This is a slightly modified version of the standard Go parser to make it more compatible with ECMAScript 5.1 // Changes: diff --git a/date_parser_test.go b/date_parser_test.go index c9a5446..c996e84 100644 --- a/date_parser_test.go +++ b/date_parser_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/date_test.go b/date_test.go index fdaa0e7..21c4c4d 100644 --- a/date_test.go +++ b/date_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/destruct.go b/destruct.go index 66792dc..01e457a 100644 --- a/destruct.go +++ b/destruct.go @@ -1,7 +1,7 @@ -package goja +package sobek import ( - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "reflect" ) diff --git a/file/README.markdown b/file/README.markdown index e9228c2..f642100 100644 --- a/file/README.markdown +++ b/file/README.markdown @@ -1,6 +1,6 @@ # file -- - import "github.com/dop251/goja/file" + import "github.com/grafana/sobek/file" Package file encapsulates the file abstractions used by the ast & parser. diff --git a/ftoa/ftostr.go b/ftoa/ftostr.go index a9d2d24..d1d9c3f 100644 --- a/ftoa/ftostr.go +++ b/ftoa/ftostr.go @@ -4,7 +4,7 @@ import ( "math" "strconv" - "github.com/dop251/goja/ftoa/internal/fast" + "github.com/grafana/sobek/ftoa/internal/fast" ) type FToStrMode int diff --git a/func.go b/func.go index c046956..ef7c846 100644 --- a/func.go +++ b/func.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "fmt" "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type resultType uint8 diff --git a/func_test.go b/func_test.go index e3c8305..227493f 100644 --- a/func_test.go +++ b/func_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" diff --git a/go.mod b/go.mod index 4361fa0..52da223 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,16 @@ -module github.com/dop251/goja +module github.com/grafana/sobek go 1.20 require ( github.com/dlclark/regexp2 v1.7.0 - github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d github.com/go-sourcemap/sourcemap v2.1.3+incompatible github.com/google/pprof v0.0.0-20230207041349-798e818bf904 - github.com/kr/pretty v0.3.0 // indirect golang.org/x/text v0.3.8 gopkg.in/yaml.v2 v2.4.0 ) + +require ( + github.com/kr/pretty v0.3.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect +) diff --git a/go.sum b/go.sum index ad04f99..b584ed9 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,10 @@ -github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= -github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= -github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= -github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d h1:W1n4DvpzZGOISgp7wWNtraLcHtnmnTwBlJidqtMIuwQ= -github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U= github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= -github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -24,33 +15,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/goja/main.go b/goja/main.go deleted file mode 100644 index 1015f46..0000000 --- a/goja/main.go +++ /dev/null @@ -1,127 +0,0 @@ -package main - -import ( - crand "crypto/rand" - "encoding/binary" - "flag" - "fmt" - "io" - "log" - "math/rand" - "os" - "runtime/debug" - "runtime/pprof" - "time" - - "github.com/dop251/goja" - "github.com/dop251/goja_nodejs/console" - "github.com/dop251/goja_nodejs/require" -) - -var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") -var timelimit = flag.Int("timelimit", 0, "max time to run (in seconds)") - -func readSource(filename string) ([]byte, error) { - if filename == "" || filename == "-" { - return io.ReadAll(os.Stdin) - } - return os.ReadFile(filename) -} - -func load(vm *goja.Runtime, call goja.FunctionCall) goja.Value { - p := call.Argument(0).String() - b, err := readSource(p) - if err != nil { - panic(vm.ToValue(fmt.Sprintf("Could not read %s: %v", p, err))) - } - v, err := vm.RunScript(p, string(b)) - if err != nil { - panic(err) - } - return v -} - -func newRandSource() goja.RandSource { - var seed int64 - if err := binary.Read(crand.Reader, binary.LittleEndian, &seed); err != nil { - panic(fmt.Errorf("Could not read random bytes: %v", err)) - } - return rand.New(rand.NewSource(seed)).Float64 -} - -func run() error { - filename := flag.Arg(0) - src, err := readSource(filename) - if err != nil { - return err - } - - if filename == "" || filename == "-" { - filename = "" - } - - vm := goja.New() - vm.SetRandSource(newRandSource()) - - new(require.Registry).Enable(vm) - console.Enable(vm) - - vm.Set("load", func(call goja.FunctionCall) goja.Value { - return load(vm, call) - }) - - vm.Set("readFile", func(name string) (string, error) { - b, err := os.ReadFile(name) - if err != nil { - return "", err - } - return string(b), nil - }) - - if *timelimit > 0 { - time.AfterFunc(time.Duration(*timelimit)*time.Second, func() { - vm.Interrupt("timeout") - }) - } - - //log.Println("Compiling...") - prg, err := goja.Compile(filename, string(src), false) - if err != nil { - return err - } - //log.Println("Running...") - _, err = vm.RunProgram(prg) - //log.Println("Finished.") - return err -} - -func main() { - defer func() { - if x := recover(); x != nil { - debug.Stack() - panic(x) - } - }() - flag.Parse() - if *cpuprofile != "" { - f, err := os.Create(*cpuprofile) - if err != nil { - log.Fatal(err) - } - pprof.StartCPUProfile(f) - defer pprof.StopCPUProfile() - } - - if err := run(); err != nil { - //fmt.Printf("err type: %T\n", err) - switch err := err.(type) { - case *goja.Exception: - fmt.Println(err.String()) - case *goja.InterruptedError: - fmt.Println(err.String()) - default: - fmt.Println(err) - } - os.Exit(64) - } -} diff --git a/ipow.go b/ipow.go index 5ee0d4d..1d9ef0c 100644 --- a/ipow.go +++ b/ipow.go @@ -1,4 +1,4 @@ -package goja +package sobek // inspired by https://gist.github.com/orlp/3551590 diff --git a/map.go b/map.go index b092b0d..26dd400 100644 --- a/map.go +++ b/map.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "hash/maphash" diff --git a/map_test.go b/map_test.go index 7d41e76..fbd5b49 100644 --- a/map_test.go +++ b/map_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "hash/maphash" diff --git a/object.go b/object.go index 79bd67d..906fe42 100644 --- a/object.go +++ b/object.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -6,7 +6,7 @@ import ( "reflect" "sort" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const ( diff --git a/object_args.go b/object_args.go index eb41d01..3ef097f 100644 --- a/object_args.go +++ b/object_args.go @@ -1,6 +1,6 @@ -package goja +package sobek -import "github.com/dop251/goja/unistring" +import "github.com/grafana/sobek/unistring" type argumentsObject struct { baseObject diff --git a/object_dynamic.go b/object_dynamic.go index b1e3161..a2ebc97 100644 --- a/object_dynamic.go +++ b/object_dynamic.go @@ -1,11 +1,11 @@ -package goja +package sobek import ( "fmt" "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) /* diff --git a/object_dynamic_test.go b/object_dynamic_test.go index fedb8f6..8cd4fd9 100644 --- a/object_dynamic_test.go +++ b/object_dynamic_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "sync" diff --git a/object_goarray_reflect.go b/object_goarray_reflect.go index e40364d..05bb5d4 100644 --- a/object_goarray_reflect.go +++ b/object_goarray_reflect.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoArrayReflect struct { diff --git a/object_goarray_reflect_test.go b/object_goarray_reflect_test.go index 9d89aa7..ea16a4c 100644 --- a/object_goarray_reflect_test.go +++ b/object_goarray_reflect_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/object_gomap.go b/object_gomap.go index 82138c2..d526403 100644 --- a/object_gomap.go +++ b/object_gomap.go @@ -1,9 +1,9 @@ -package goja +package sobek import ( "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoMapSimple struct { diff --git a/object_gomap_reflect.go b/object_gomap_reflect.go index 531c165..bf8b41a 100644 --- a/object_gomap_reflect.go +++ b/object_gomap_reflect.go @@ -1,9 +1,9 @@ -package goja +package sobek import ( "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoMapReflect struct { diff --git a/object_gomap_reflect_test.go b/object_gomap_reflect_test.go index d9d06f3..d39b41b 100644 --- a/object_gomap_reflect_test.go +++ b/object_gomap_reflect_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/object_gomap_test.go b/object_gomap_test.go index 81225fe..5ee74a5 100644 --- a/object_gomap_test.go +++ b/object_gomap_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import "testing" diff --git a/object_goreflect.go b/object_goreflect.go index 7ad5970..143fc5c 100644 --- a/object_goreflect.go +++ b/object_goreflect.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -6,8 +6,8 @@ import ( "reflect" "strings" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" ) // JsonEncodable allows custom JSON encoding by JSON.stringify() diff --git a/object_goreflect_test.go b/object_goreflect_test.go index cf1e8f0..9807cd5 100644 --- a/object_goreflect_test.go +++ b/object_goreflect_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" diff --git a/object_goslice.go b/object_goslice.go index 1a52207..7f71dfd 100644 --- a/object_goslice.go +++ b/object_goslice.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" @@ -6,7 +6,7 @@ import ( "reflect" "strconv" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoSlice struct { diff --git a/object_goslice_reflect.go b/object_goslice_reflect.go index 4c28d8c..378322a 100644 --- a/object_goslice_reflect.go +++ b/object_goslice_reflect.go @@ -1,11 +1,11 @@ -package goja +package sobek import ( "math" "math/bits" "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type objectGoSliceReflect struct { diff --git a/object_goslice_reflect_test.go b/object_goslice_reflect_test.go index c6137c3..a9cac78 100644 --- a/object_goslice_reflect_test.go +++ b/object_goslice_reflect_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "reflect" diff --git a/object_goslice_test.go b/object_goslice_test.go index 1bef479..327b61a 100644 --- a/object_goslice_test.go +++ b/object_goslice_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/object_template.go b/object_template.go index 6d42f9f..fa39133 100644 --- a/object_template.go +++ b/object_template.go @@ -1,8 +1,8 @@ -package goja +package sobek import ( "fmt" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "math" "reflect" "sort" diff --git a/object_test.go b/object_test.go index f2b54ce..38e3e49 100644 --- a/object_test.go +++ b/object_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" diff --git a/parser/README.markdown b/parser/README.markdown index ec1186d..3d19db2 100644 --- a/parser/README.markdown +++ b/parser/README.markdown @@ -1,11 +1,11 @@ # parser -- - import "github.com/dop251/goja/parser" + import "github.com/grafana/sobek/parser" Package parser implements a parser for JavaScript. Borrowed from https://github.com/robertkrimen/otto/tree/master/parser import ( - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" ) Parse and return an AST diff --git a/parser/error.go b/parser/error.go index cf4d2c3..39d61fa 100644 --- a/parser/error.go +++ b/parser/error.go @@ -4,8 +4,8 @@ import ( "fmt" "sort" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" ) const ( diff --git a/parser/expression.go b/parser/expression.go index 305bed4..74d346a 100644 --- a/parser/expression.go +++ b/parser/expression.go @@ -3,10 +3,10 @@ package parser import ( "strings" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) func (self *_parser) parseIdentifier() *ast.Identifier { diff --git a/parser/lexer.go b/parser/lexer.go index 68d56d2..234d5b9 100644 --- a/parser/lexer.go +++ b/parser/lexer.go @@ -11,9 +11,9 @@ import ( "golang.org/x/text/unicode/rangetable" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) var ( diff --git a/parser/lexer_test.go b/parser/lexer_test.go index 31254df..d41b1fd 100644 --- a/parser/lexer_test.go +++ b/parser/lexer_test.go @@ -3,9 +3,9 @@ package parser import ( "testing" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) func TestLexer(t *testing.T) { diff --git a/parser/marshal_test.go b/parser/marshal_test.go index eb9a809..3f82e3c 100644 --- a/parser/marshal_test.go +++ b/parser/marshal_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/dop251/goja/ast" + "github.com/grafana/sobek/ast" ) func marshal(name string, children ...interface{}) interface{} { diff --git a/parser/parser.go b/parser/parser.go index 24b3802..9adfe3a 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -2,7 +2,7 @@ Package parser implements a parser for JavaScript. import ( - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" ) Parse and return an AST @@ -38,10 +38,10 @@ import ( "io" "os" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) // A Mode value is a set of flags (or 0). They control optional parser functionality. diff --git a/parser/parser_test.go b/parser/parser_test.go index 4392419..09ccdd2 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -6,10 +6,10 @@ import ( "strings" "testing" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" + "github.com/grafana/sobek/unistring" ) func firstErr(err error) error { diff --git a/parser/scope.go b/parser/scope.go index 5e28ef4..f9936da 100644 --- a/parser/scope.go +++ b/parser/scope.go @@ -1,8 +1,8 @@ package parser import ( - "github.com/dop251/goja/ast" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/unistring" ) type _scope struct { diff --git a/parser/statement.go b/parser/statement.go index 8ec5cde..7a36e29 100644 --- a/parser/statement.go +++ b/parser/statement.go @@ -6,9 +6,9 @@ import ( "os" "strings" - "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/token" + "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/token" "github.com/go-sourcemap/sourcemap" ) diff --git a/profiler.go b/profiler.go index 3d21ad1..01a33b1 100644 --- a/profiler.go +++ b/profiler.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" diff --git a/profiler_test.go b/profiler_test.go index 99478e6..50a1f99 100644 --- a/profiler_test.go +++ b/profiler_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "sync/atomic" diff --git a/proxy.go b/proxy.go index e9bd8c9..0662cde 100644 --- a/proxy.go +++ b/proxy.go @@ -1,10 +1,10 @@ -package goja +package sobek import ( "fmt" "reflect" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) // Proxy is a Go wrapper around ECMAScript Proxy. Calling Runtime.ToValue() on it diff --git a/regexp.go b/regexp.go index 1c3e7e0..bdc15a1 100644 --- a/regexp.go +++ b/regexp.go @@ -1,9 +1,9 @@ -package goja +package sobek import ( "fmt" "github.com/dlclark/regexp2" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" "io" "regexp" "sort" diff --git a/regexp_test.go b/regexp_test.go index 3ea2243..282f9b5 100644 --- a/regexp_test.go +++ b/regexp_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "testing" diff --git a/runtime.go b/runtime.go index 0139ef1..27404f5 100644 --- a/runtime.go +++ b/runtime.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "bytes" @@ -16,10 +16,10 @@ import ( "golang.org/x/text/collate" - js_ast "github.com/dop251/goja/ast" - "github.com/dop251/goja/file" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + js_ast "github.com/grafana/sobek/ast" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" ) const ( @@ -1613,7 +1613,7 @@ func(FunctionCall, *Runtime) Value is treated as above, except the *Runtime is a func(ConstructorCall) *Object is treated as a native constructor, allowing to use it with the new operator: - func MyObject(call goja.ConstructorCall) *goja.Object { + func MyObject(call sobek.ConstructorCall) *sobek.Object { // call.This contains the newly created object as per http://www.ecma-international.org/ecma-262/5.1/index.html#sec-13.2.2 // call.Arguments contain arguments passed to the function @@ -1623,7 +1623,7 @@ operator: // If return value is a non-nil *Object, it will be used instead of call.This // This way it is possible to return a Go struct or a map converted - // into goja.Value using ToValue(), however in this case + // into sobek.Value using ToValue(), however in this case // instanceof will not work as expected, unless you set the prototype: // // instance := &myCustomStruct{} diff --git a/runtime_test.go b/runtime_test.go index a834428..fed4336 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/dop251/goja/parser" + "github.com/grafana/sobek/parser" ) func TestGlobalObjectProto(t *testing.T) { @@ -1570,7 +1570,7 @@ func TestInterruptInWrappedFunction(t *testing.T) { func TestInterruptInWrappedFunction2(t *testing.T) { rt := New() - // this test panics as otherwise goja will recover and possibly loop + // this test panics as otherwise sobek will recover and possibly loop var called bool rt.Set("v", rt.ToValue(func() { if called { @@ -1626,7 +1626,7 @@ func TestInterruptInWrappedFunction2(t *testing.T) { func TestInterruptInWrappedFunction2Recover(t *testing.T) { rt := New() - // this test panics as otherwise goja will recover and possibly loop + // this test panics as otherwise sobek will recover and possibly loop var vCalled int rt.Set("v", rt.ToValue(func() { if vCalled == 0 { @@ -1685,7 +1685,7 @@ func TestInterruptInWrappedFunction2Recover(t *testing.T) { func TestInterruptInWrappedFunctionExpectInteruptError(t *testing.T) { rt := New() - // this test panics as otherwise goja will recover and possibly loop + // this test panics as otherwise sobek will recover and possibly loop rt.Set("v", rt.ToValue(func() { rt.Interrupt("here is the error") })) @@ -1714,7 +1714,7 @@ func TestInterruptInWrappedFunctionExpectInteruptError(t *testing.T) { func TestInterruptInWrappedFunctionExpectStackOverflowError(t *testing.T) { rt := New() rt.SetMaxCallStackSize(5) - // this test panics as otherwise goja will recover and possibly loop + // this test panics as otherwise sobek will recover and possibly loop rt.Set("v", rt.ToValue(func() { _, err := rt.RunString(` (function loop() { loop() })(); diff --git a/string.go b/string.go index 632f1e3..833bc3a 100644 --- a/string.go +++ b/string.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "io" @@ -6,7 +6,7 @@ import ( "strings" "unicode/utf8" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const ( diff --git a/string_ascii.go b/string_ascii.go index 5ff21bf..df622f4 100644 --- a/string_ascii.go +++ b/string_ascii.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "hash/maphash" @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type asciiString string diff --git a/string_imported.go b/string_imported.go index 1c6cae8..e61cb77 100644 --- a/string_imported.go +++ b/string_imported.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "hash/maphash" @@ -9,8 +9,8 @@ import ( "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" "golang.org/x/text/cases" "golang.org/x/text/language" diff --git a/string_test.go b/string_test.go index df242fc..4fc4a24 100644 --- a/string_test.go +++ b/string_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "strings" diff --git a/string_unicode.go b/string_unicode.go index 49e363f..b755978 100644 --- a/string_unicode.go +++ b/string_unicode.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" @@ -10,8 +10,8 @@ import ( "unicode/utf16" "unicode/utf8" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" "golang.org/x/text/cases" "golang.org/x/text/language" ) diff --git a/tc39_norace_test.go b/tc39_norace_test.go index 9a1a18c..ce77a75 100644 --- a/tc39_norace_test.go +++ b/tc39_norace_test.go @@ -1,7 +1,7 @@ //go:build !race // +build !race -package goja +package sobek import "testing" diff --git a/tc39_race_test.go b/tc39_race_test.go index e17bd12..3f562d0 100644 --- a/tc39_race_test.go +++ b/tc39_race_test.go @@ -1,7 +1,7 @@ //go:build race // +build race -package goja +package sobek import ( "testing" diff --git a/tc39_test.go b/tc39_test.go index ea9d223..05d5e9f 100644 --- a/tc39_test.go +++ b/tc39_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "errors" @@ -112,7 +112,7 @@ var ( "test/built-ins/RegExp/unicode_restricted_character_class_escape.js": true, "test/annexB/built-ins/RegExp/prototype/compile/pattern-string-invalid-u.js": true, - // Because goja parser works in UTF-8 it is not possible to pass strings containing invalid UTF-16 code points. + // Because sobek parser works in UTF-8 it is not possible to pass strings containing invalid UTF-16 code points. // This is mitigated by escaping them as \uXXXX, however because of this the RegExp source becomes // `\uXXXX` instead of ``. // The resulting RegExp will work exactly the same, but it causes these two tests to fail. diff --git a/token/README.markdown b/token/README.markdown index 66dd2ab..7b64366 100644 --- a/token/README.markdown +++ b/token/README.markdown @@ -1,6 +1,6 @@ # token -- - import "github.com/dop251/goja/token" + import "github.com/grafana/sobek/token" Package token defines constants representing the lexical tokens of JavaScript (ECMA5). diff --git a/typedarrays.go b/typedarrays.go index 9af0350..cfe19bc 100644 --- a/typedarrays.go +++ b/typedarrays.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "math" @@ -6,7 +6,7 @@ import ( "strconv" "unsafe" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) type byteOrder bool diff --git a/typedarrays_test.go b/typedarrays_test.go index 2da2e8a..f48b3a5 100644 --- a/typedarrays_test.go +++ b/typedarrays_test.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "bytes" diff --git a/value.go b/value.go index aeb9676..9faabef 100644 --- a/value.go +++ b/value.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -8,8 +8,8 @@ import ( "strconv" "unsafe" - "github.com/dop251/goja/ftoa" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/ftoa" + "github.com/grafana/sobek/unistring" ) var ( diff --git a/vm.go b/vm.go index 30b7933..8fa60e4 100644 --- a/vm.go +++ b/vm.go @@ -1,4 +1,4 @@ -package goja +package sobek import ( "fmt" @@ -9,7 +9,7 @@ import ( "sync/atomic" "time" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/unistring" ) const ( diff --git a/vm_test.go b/vm_test.go index a88ff47..022f2a5 100644 --- a/vm_test.go +++ b/vm_test.go @@ -1,9 +1,9 @@ -package goja +package sobek import ( - "github.com/dop251/goja/file" - "github.com/dop251/goja/parser" - "github.com/dop251/goja/unistring" + "github.com/grafana/sobek/file" + "github.com/grafana/sobek/parser" + "github.com/grafana/sobek/unistring" "testing" )