buke / quickjs-go Goto Github PK
View Code? Open in Web Editor NEWGo bindings to QuickJS
License: MIT License
Go bindings to QuickJS
License: MIT License
如果需要支持debug,原始的quickjs源码并不支持,找了下 https://github.com/koush/quickjs 这个是支持的,但是或许需要更改构建目标?
// hello.js
function hello() {
return 'hello'
}
export default hello
//mian.go
package main
import (
"fmt"
"time"
"github.com/buke/quickjs-go"
polyfill "github.com/buke/quickjs-go-polyfill"
)
func main() {
// Create a new runtime
rt := quickjs.NewRuntime()
defer rt.Close()
// Create a new context
ctx := rt.NewContext()
defer ctx.Close()
// Inject polyfills to the context
polyfill.InjectAll(ctx)
ret, err := ctx.Eval(console.log("aaaa"); import {hello} from './hello'; console.log("22222"+hello())
)
defer ret.Free()
fmt.Println("error:", ret, err)
// Wait for the timeout to finish
time.Sleep(time.Millisecond * 100)
rt.ExecuteAllPendingJobs()
// Output:
// error: SyntaxError: expecting '('
}
想要实现 fetch 的 arrayBuffer 和 blob , 发现没有进行绑定,是否有计划实现,或者是否接受 pr
Can we have support for JS_SetInterruptHandler
? I would like to use it to enforce a timeout.
感谢作者的努力,这是一个非常好的项目,但是实际使用下来发现少了一些针对js集合相关的操作,我在fork的基础上简单实现了下,已经通过了大部分的测试,请问作者是否需要这部分代码?如果可以的话,我将会提一个PR
This is the error message I'm seeing.
$ go build
# example/hello
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/allai/go/pkg/mod/github.com/buke/[email protected]/deps/libs/windows_amd64/libquickjs.a(quickjs.nolto.o): in function `js_atomics_wait':
D:\a\quickjs-go\quickjs-go\deps\quickjs/quickjs.c:55522: undefined reference to `clock_gettime'
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/allai/go/pkg/mod/github.com/buke/[email protected]/deps/libs/windows_amd64/libquickjs.a(quickjs-libc.nolto.o): in function `js_std_getenviron':
D:\a\quickjs-go\quickjs-go\deps\quickjs/quickjs-libc.c:703: undefined reference to `__imp___p__environ'
collect2.exe: error: ld returned 1 exit status
If it helps I'm using mingw and this is the info I get from gcc:
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\TDM-GCC-64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/10.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-git-10.3.0/configure --build=x86_64-w64-mingw32 --enable-targets=all --enable-languages=ada,c,c++,fortran,jit,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --enable-libstdcxx-threads --enable-libstdcxx-time=yes --enable-mingw-wildcard --with-gnu-ld --disable-werror --enable-nls --disable-win32-registry --enable-large-address-aware --disable-rpath --disable-symvers --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=https://github.com/jmeubank/tdm-gcc/issues
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (tdm64-1)
Let me know if I can help with anything.
Is it possible to write a file or import the std library?
Need support for setTimeout
速度怎么样?
D:/c/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Dwarf Error: Can't find .debug_ranges section.
D:/Users/111/go/pkg/mod/github.com/buke/[email protected]/deps/libs/windows_amd64/libquickjs.a(quickjs-libc.nolto.o):quickjs-libc.c:(.text+0x2c5e): undefined reference to `__imp___p__environ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.