• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple implementation of Web Container

Labor

Implementation of Web Container

Run

$ cd demo
$ yarn build
$ yarn dev

Detail

code => js runtime => rust/go wasm API

举个例子

const res = await readFile('a.js')

这一句代码中的 readFile 最终是要执行到 rust/go 中的 API 的,但到底怎么将 go 的 API 注入进去的呢?

此时就需要 go 注入到全局一个 API

js.Global().Set("readFile", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
    readFile(args[0].String()) // 相当于 eval
    return nil
}))

我们在 js 侧,只需要直接调用,不需要发接口

new Function('readFile', `const res = await readFile('a.js')`)(readFile)

大功告成,就是如此简单,在 wasm 端实现 API,然后在 js 侧注入到字符串里即可

但还没完,那么问题来了,文件系统呢?http呢?

这就得看 go 对 WASI 的支持程度了,亲测 net/http 包大部分支持良好,但不能启端口,osutil 包内存 API 是支持的

demo 只是打个比方,这个项目我会用 go 写,因为 docker 也是用 go 写的

值得一提的是,为了获得更好的性能和大小,我们接下来会使用类似 tinygo 的编译器

但是 trip worker 我还是会用 rust 实现,理由和 deno 一样,所以本质上,同一套标准库,我得写两遍了,呜呜呜

More Repositories

1

asta

🐙 Resumable SSR framework.
JavaScript
694
star
2

eplayer

🔮 A web-component html5 video player facing future
JavaScript
269
star
3

smallapp

🎃 基于 fre 的小程序架构
JavaScript
163
star
4

fard2

🎅 fre 转小程序的新思路 ♂ learn once, write anywhere.
JavaScript
114
star
5

homo

Lightweight Rendering engine similar to Harmony, but use Fre and quickjs
C
59
star
6

deku

⛄️ No-bundle Dev Server for ES modules with deno.
JavaScript
51
star
7

joke

🎃 Tiny Javascript engine, does not support Typescript (yet).
Rust
45
star
8

peacecss

Golang implement of postcss.
Go
43
star
9

soga

Tiny layout engine.
Rust
40
star
10

wxml

wxml parser rust implement
Rust
39
star
11

oplayer

👾 react native video player for expo
JavaScript
25
star
12

node_swc

swc node binding use wasm
Rust
23
star
13

venti

Simple Vue SSR framework
JavaScript
21
star
14

loki-admin

Admin app build by KokiUI
JavaScript
14
star
15

fremix

Remix for fre
JavaScript
13
star
16

gei

👾 Fast 1kb sprites system with webgl.
JavaScript
13
star
17

tinyMDE

1kb markdown 编辑器
JavaScript
12
star
18

picopack

📦 Simple Typescript library bundler.
TypeScript
11
star
19

dirty-check

reactivity system with dirty checking
JavaScript
10
star
20

bad-scroll

100 lines scroll for mobile UI
JavaScript
8
star
21

m3u8.js

🌀 m3u8 client using WebAssembly and Media Source Extension
JavaScript
8
star
22

frekit

Streaming rendering for fre SSR
6
star
23

smox-counter

A redux-like state management which based on New context api
JavaScript
5
star
24

color-picker

Auto pick the primary color.
JavaScript
5
star
25

uraban-typecho-themes

typecho themes
PHP
4
star
26

fplayer

flutter player for clicli.tv
4
star
27

bale

Zero configuration builder.
4
star
28

voe2

Concurrent rendering engine.
JavaScript
4
star
29

TinyScript

Tiny javascript engine writted by rust.
4
star
30

gan

👾 A web framework packaged Go native which use fasthttp and httprouter
Go
3
star
31

vue-ssr

A vue-ssr demo
JavaScript
3
star
32

js-parser

Coarse-grained JavaScript block parser.
3
star
33

hello_wasm

hello wasm
JavaScript
3
star
34

remix-client

JavaScript
3
star
35

voe-ide

A ide for mini programs
3
star
36

kiana

the moe plugin of kiana
JavaScript
2
star
37

fre-sortable-tree

2
star
38

1990

2
star
39

opration-task-queue

JavaScript
2
star
40

rexpr

JavaScript expression parser
2
star
41

juvenile

Simple CICD
Go
2
star
42

fre3

fre3 临时仓库
Rust
2
star
43

moe-comment

1kb severless comment system
2
star
44

varix

Remix for vue
2
star
45

immix

Create next immutable patch by mutating the current.
JavaScript
2
star
46

yisar

2
star
47

cplayer

Simple video player UI for clicli app.
2
star
48

browser-cjs

JavaScript
2
star
49

esbuild-module-federation

2
star
50

requestIdlePromise

A POC for requestIdleCallback used Promise
JavaScript
2
star
51

fre-jotal

2
star
52

easy-crypto

Easy crpto use WebAssembly
JavaScript
2
star
53

ukagaka

this is a ukagaka plugin
JavaScript
2
star
54

blockchain-cli

cli for blockchain
JavaScript
2
star
55

tiga

Faster taro alternative.
Go
2
star
56

acgzone-moblie

acgzone mobile app written by react native
2
star
57

smox-todo

todolist for react and smox
2
star
58

fre-server-component

1
star
59

xiuno

Xino is a lightweight PHP forum system.
1
star
60

fre-counter

A demo for Fre
TypeScript
1
star
61

super-element

JSX alternative with swiftUI like syntax.
1
star
62

webpack-vemix--manifest

1
star
63

typeditor

🍡 A markdown editor rewriting of typecho's
TypeScript
1
star
64

webview_video_player

Flutter video player with webview plugin.
1
star
65

jio

sm app build by react-native
1
star
66

fre-realword

A real world APP for Fre
1
star
67

UIwidgets

this is a simple slider
JavaScript
1
star
68

wean-demo-tuchong

A wean demo for tuchong.com
JavaScript
1
star
69

hvec

A simple javascript hvec_H265 muxer.
1
star
70

demon

A javascript framework for deno
1
star
71

danmu

danmuku for clicli
JavaScript
1
star
72

priority-scheduler

React scheduler implement.
1
star
73

snel

Html-first framework
JavaScript
1
star
74

js-basic-skill

js-basic-skill
1
star
75

gap

A simple and lightweight REST server framework.
1
star
76

duex

Another state manager make Redux use Vuex-like syntax
1
star
77

phpbb1

phpbb1 for php8
PHP
1
star