Upload 30 files
Browse files- README.md +5 -0
- index.html +13 -0
- package-lock.json +1017 -0
- package.json +22 -0
- public/llama2.c/tokenizer.bin +3 -0
- public/llama2c-worker.js +100 -0
- public/llama2c.wasm +3 -0
- public/model.bin +3 -0
- public/tokenizer.bin +3 -0
- public/vendor/vendor/wasi.js +1595 -0
- public/vendor/vendor/wasi.js.original +1591 -0
- public/vendor/wasi.js +1595 -0
- public/vendor/wasi.js.original +1591 -0
- public/vite.svg +1 -0
- src/App.vue +65 -0
- src/assets/vue.svg +1 -0
- src/components/HelloWorld.vue +40 -0
- src/llama2.c/tokenizer.bin +3 -0
- src/llama2c-worker.js +100 -0
- src/llama2c.wasm +3 -0
- src/main.js +4 -0
- src/md5.js +243 -0
- src/model.bin +3 -0
- src/style.css +90 -0
- src/tokenizer.bin +3 -0
- src/vendor/vendor/wasi.js +1595 -0
- src/vendor/vendor/wasi.js.original +1591 -0
- src/vendor/wasi.js +1595 -0
- src/vendor/wasi.js.original +1591 -0
- vite.config.js +7 -0
README.md
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Markdown编辑器
|
2 |
+
|
3 |
+
基本功能应该都能支持吧...
|
4 |
+
|
5 |
+
![website](./website.png)
|
index.html
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
+
<title>Chatxu-Story</title>
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
<div id="app"></div>
|
11 |
+
<script type="module" src="./src/main.js"></script>
|
12 |
+
</body>
|
13 |
+
</html>
|
package-lock.json
ADDED
@@ -0,0 +1,1017 @@
|
|
|
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
|
3 |
+
"version": "0.0.0",
|
4 |
+
"lockfileVersion": 3,
|
5 |
+
"requires": true,
|
6 |
+
"packages": {
|
7 |
+
"": {
|
8 |
+
"name": "Github-Identicon",
|
9 |
+
"version": "0.0.0",
|
10 |
+
"dependencies": {
|
11 |
+
"@primer/css": "^20.4.1",
|
12 |
+
"identicon.js": "^2.3.3",
|
13 |
+
"scss": "^0.2.4",
|
14 |
+
"vue": "^3.2.37"
|
15 |
+
},
|
16 |
+
"devDependencies": {
|
17 |
+
"@vitejs/plugin-vue": "^3.0.0",
|
18 |
+
"sass": "^1.54.3",
|
19 |
+
"vite": "^3.0.0"
|
20 |
+
}
|
21 |
+
},
|
22 |
+
"node_modules/@babel/parser": {
|
23 |
+
"version": "7.20.3",
|
24 |
+
"resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.20.3.tgz",
|
25 |
+
"integrity": "sha512-OP/s5a94frIPXwjzEcv5S/tpQfc6XhxYUnmWpgdqMWGgYCuErA3SzozaRAMQgSZWKeTJxht9aWAkUY+0UzvOFg==",
|
26 |
+
"bin": {
|
27 |
+
"parser": "bin/babel-parser.js"
|
28 |
+
},
|
29 |
+
"engines": {
|
30 |
+
"node": ">=6.0.0"
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"node_modules/@esbuild/android-arm": {
|
34 |
+
"version": "0.15.15",
|
35 |
+
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.15.15.tgz",
|
36 |
+
"integrity": "sha512-JJjZjJi2eBL01QJuWjfCdZxcIgot+VoK6Fq7eKF9w4YHm9hwl7nhBR1o2Wnt/WcANk5l9SkpvrldW1PLuXxcbw==",
|
37 |
+
"cpu": [
|
38 |
+
"arm"
|
39 |
+
],
|
40 |
+
"dev": true,
|
41 |
+
"optional": true,
|
42 |
+
"os": [
|
43 |
+
"android"
|
44 |
+
],
|
45 |
+
"engines": {
|
46 |
+
"node": ">=12"
|
47 |
+
}
|
48 |
+
},
|
49 |
+
"node_modules/@esbuild/linux-loong64": {
|
50 |
+
"version": "0.15.15",
|
51 |
+
"resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.15.15.tgz",
|
52 |
+
"integrity": "sha512-lhz6UNPMDXUhtXSulw8XlFAtSYO26WmHQnCi2Lg2p+/TMiJKNLtZCYUxV4wG6rZMzXmr8InGpNwk+DLT2Hm0PA==",
|
53 |
+
"cpu": [
|
54 |
+
"loong64"
|
55 |
+
],
|
56 |
+
"dev": true,
|
57 |
+
"optional": true,
|
58 |
+
"os": [
|
59 |
+
"linux"
|
60 |
+
],
|
61 |
+
"engines": {
|
62 |
+
"node": ">=12"
|
63 |
+
}
|
64 |
+
},
|
65 |
+
"node_modules/@primer/css": {
|
66 |
+
"version": "20.7.1",
|
67 |
+
"resolved": "https://registry.npmmirror.com/@primer/css/-/css-20.7.1.tgz",
|
68 |
+
"integrity": "sha512-NcTKs6PZtT7btF8GlYvoRMq8XBJ8TWGA8VBPG+dAYHm/38gx8JwKSiZG0Dt2Ue1AYoV/75Slp/mUPDnFCmbOOQ==",
|
69 |
+
"dependencies": {
|
70 |
+
"@primer/primitives": "^7.9.0"
|
71 |
+
},
|
72 |
+
"engines": {
|
73 |
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
74 |
+
}
|
75 |
+
},
|
76 |
+
"node_modules/@primer/primitives": {
|
77 |
+
"version": "7.10.0",
|
78 |
+
"resolved": "https://registry.npmmirror.com/@primer/primitives/-/primitives-7.10.0.tgz",
|
79 |
+
"integrity": "sha512-DdLHq21e93R9qDHyRuRpytBLY0Up9IwNWMOUgPNW6lRSng4N4+IdUlLS3Ekbasmxfs8Z8vKS8aezeYovQ5qsxQ=="
|
80 |
+
},
|
81 |
+
"node_modules/@vitejs/plugin-vue": {
|
82 |
+
"version": "3.2.0",
|
83 |
+
"resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-3.2.0.tgz",
|
84 |
+
"integrity": "sha512-E0tnaL4fr+qkdCNxJ+Xd0yM31UwMkQje76fsDVBBUCoGOUPexu2VDUYHL8P4CwV+zMvWw6nlRw19OnRKmYAJpw==",
|
85 |
+
"dev": true,
|
86 |
+
"engines": {
|
87 |
+
"node": "^14.18.0 || >=16.0.0"
|
88 |
+
},
|
89 |
+
"peerDependencies": {
|
90 |
+
"vite": "^3.0.0",
|
91 |
+
"vue": "^3.2.25"
|
92 |
+
}
|
93 |
+
},
|
94 |
+
"node_modules/@vue/compiler-core": {
|
95 |
+
"version": "3.2.45",
|
96 |
+
"resolved": "https://registry.npmmirror.com/@vue/compiler-core/-/compiler-core-3.2.45.tgz",
|
97 |
+
"integrity": "sha512-rcMj7H+PYe5wBV3iYeUgbCglC+pbpN8hBLTJvRiK2eKQiWqu+fG9F+8sW99JdL4LQi7Re178UOxn09puSXvn4A==",
|
98 |
+
"dependencies": {
|
99 |
+
"@babel/parser": "^7.16.4",
|
100 |
+
"@vue/shared": "3.2.45",
|
101 |
+
"estree-walker": "^2.0.2",
|
102 |
+
"source-map": "^0.6.1"
|
103 |
+
}
|
104 |
+
},
|
105 |
+
"node_modules/@vue/compiler-dom": {
|
106 |
+
"version": "3.2.45",
|
107 |
+
"resolved": "https://registry.npmmirror.com/@vue/compiler-dom/-/compiler-dom-3.2.45.tgz",
|
108 |
+
"integrity": "sha512-tyYeUEuKqqZO137WrZkpwfPCdiiIeXYCcJ8L4gWz9vqaxzIQRccTSwSWZ/Axx5YR2z+LvpUbmPNXxuBU45lyRw==",
|
109 |
+
"dependencies": {
|
110 |
+
"@vue/compiler-core": "3.2.45",
|
111 |
+
"@vue/shared": "3.2.45"
|
112 |
+
}
|
113 |
+
},
|
114 |
+
"node_modules/@vue/compiler-sfc": {
|
115 |
+
"version": "3.2.45",
|
116 |
+
"resolved": "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-3.2.45.tgz",
|
117 |
+
"integrity": "sha512-1jXDuWah1ggsnSAOGsec8cFjT/K6TMZ0sPL3o3d84Ft2AYZi2jWJgRMjw4iaK0rBfA89L5gw427H4n1RZQBu6Q==",
|
118 |
+
"dependencies": {
|
119 |
+
"@babel/parser": "^7.16.4",
|
120 |
+
"@vue/compiler-core": "3.2.45",
|
121 |
+
"@vue/compiler-dom": "3.2.45",
|
122 |
+
"@vue/compiler-ssr": "3.2.45",
|
123 |
+
"@vue/reactivity-transform": "3.2.45",
|
124 |
+
"@vue/shared": "3.2.45",
|
125 |
+
"estree-walker": "^2.0.2",
|
126 |
+
"magic-string": "^0.25.7",
|
127 |
+
"postcss": "^8.1.10",
|
128 |
+
"source-map": "^0.6.1"
|
129 |
+
}
|
130 |
+
},
|
131 |
+
"node_modules/@vue/compiler-ssr": {
|
132 |
+
"version": "3.2.45",
|
133 |
+
"resolved": "https://registry.npmmirror.com/@vue/compiler-ssr/-/compiler-ssr-3.2.45.tgz",
|
134 |
+
"integrity": "sha512-6BRaggEGqhWht3lt24CrIbQSRD5O07MTmd+LjAn5fJj568+R9eUD2F7wMQJjX859seSlrYog7sUtrZSd7feqrQ==",
|
135 |
+
"dependencies": {
|
136 |
+
"@vue/compiler-dom": "3.2.45",
|
137 |
+
"@vue/shared": "3.2.45"
|
138 |
+
}
|
139 |
+
},
|
140 |
+
"node_modules/@vue/reactivity": {
|
141 |
+
"version": "3.2.45",
|
142 |
+
"resolved": "https://registry.npmmirror.com/@vue/reactivity/-/reactivity-3.2.45.tgz",
|
143 |
+
"integrity": "sha512-PRvhCcQcyEVohW0P8iQ7HDcIOXRjZfAsOds3N99X/Dzewy8TVhTCT4uXpAHfoKjVTJRA0O0K+6QNkDIZAxNi3A==",
|
144 |
+
"dependencies": {
|
145 |
+
"@vue/shared": "3.2.45"
|
146 |
+
}
|
147 |
+
},
|
148 |
+
"node_modules/@vue/reactivity-transform": {
|
149 |
+
"version": "3.2.45",
|
150 |
+
"resolved": "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.2.45.tgz",
|
151 |
+
"integrity": "sha512-BHVmzYAvM7vcU5WmuYqXpwaBHjsS8T63jlKGWVtHxAHIoMIlmaMyurUSEs1Zcg46M4AYT5MtB1U274/2aNzjJQ==",
|
152 |
+
"dependencies": {
|
153 |
+
"@babel/parser": "^7.16.4",
|
154 |
+
"@vue/compiler-core": "3.2.45",
|
155 |
+
"@vue/shared": "3.2.45",
|
156 |
+
"estree-walker": "^2.0.2",
|
157 |
+
"magic-string": "^0.25.7"
|
158 |
+
}
|
159 |
+
},
|
160 |
+
"node_modules/@vue/runtime-core": {
|
161 |
+
"version": "3.2.45",
|
162 |
+
"resolved": "https://registry.npmmirror.com/@vue/runtime-core/-/runtime-core-3.2.45.tgz",
|
163 |
+
"integrity": "sha512-gzJiTA3f74cgARptqzYswmoQx0fIA+gGYBfokYVhF8YSXjWTUA2SngRzZRku2HbGbjzB6LBYSbKGIaK8IW+s0A==",
|
164 |
+
"dependencies": {
|
165 |
+
"@vue/reactivity": "3.2.45",
|
166 |
+
"@vue/shared": "3.2.45"
|
167 |
+
}
|
168 |
+
},
|
169 |
+
"node_modules/@vue/runtime-dom": {
|
170 |
+
"version": "3.2.45",
|
171 |
+
"resolved": "https://registry.npmmirror.com/@vue/runtime-dom/-/runtime-dom-3.2.45.tgz",
|
172 |
+
"integrity": "sha512-cy88YpfP5Ue2bDBbj75Cb4bIEZUMM/mAkDMfqDTpUYVgTf/kuQ2VQ8LebuZ8k6EudgH8pYhsGWHlY0lcxlvTwA==",
|
173 |
+
"dependencies": {
|
174 |
+
"@vue/runtime-core": "3.2.45",
|
175 |
+
"@vue/shared": "3.2.45",
|
176 |
+
"csstype": "^2.6.8"
|
177 |
+
}
|
178 |
+
},
|
179 |
+
"node_modules/@vue/server-renderer": {
|
180 |
+
"version": "3.2.45",
|
181 |
+
"resolved": "https://registry.npmmirror.com/@vue/server-renderer/-/server-renderer-3.2.45.tgz",
|
182 |
+
"integrity": "sha512-ebiMq7q24WBU1D6uhPK//2OTR1iRIyxjF5iVq/1a5I1SDMDyDu4Ts6fJaMnjrvD3MqnaiFkKQj+LKAgz5WIK3g==",
|
183 |
+
"dependencies": {
|
184 |
+
"@vue/compiler-ssr": "3.2.45",
|
185 |
+
"@vue/shared": "3.2.45"
|
186 |
+
},
|
187 |
+
"peerDependencies": {
|
188 |
+
"vue": "3.2.45"
|
189 |
+
}
|
190 |
+
},
|
191 |
+
"node_modules/@vue/shared": {
|
192 |
+
"version": "3.2.45",
|
193 |
+
"resolved": "https://registry.npmmirror.com/@vue/shared/-/shared-3.2.45.tgz",
|
194 |
+
"integrity": "sha512-Ewzq5Yhimg7pSztDV+RH1UDKBzmtqieXQlpTVm2AwraoRL/Rks96mvd8Vgi7Lj+h+TH8dv7mXD3FRZR3TUvbSg=="
|
195 |
+
},
|
196 |
+
"node_modules/anymatch": {
|
197 |
+
"version": "3.1.3",
|
198 |
+
"resolved": "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz",
|
199 |
+
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
|
200 |
+
"dev": true,
|
201 |
+
"dependencies": {
|
202 |
+
"normalize-path": "^3.0.0",
|
203 |
+
"picomatch": "^2.0.4"
|
204 |
+
},
|
205 |
+
"engines": {
|
206 |
+
"node": ">= 8"
|
207 |
+
}
|
208 |
+
},
|
209 |
+
"node_modules/binary-extensions": {
|
210 |
+
"version": "2.2.0",
|
211 |
+
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
212 |
+
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
213 |
+
"dev": true,
|
214 |
+
"engines": {
|
215 |
+
"node": ">=8"
|
216 |
+
}
|
217 |
+
},
|
218 |
+
"node_modules/braces": {
|
219 |
+
"version": "3.0.2",
|
220 |
+
"resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.2.tgz",
|
221 |
+
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
222 |
+
"dev": true,
|
223 |
+
"dependencies": {
|
224 |
+
"fill-range": "^7.0.1"
|
225 |
+
},
|
226 |
+
"engines": {
|
227 |
+
"node": ">=8"
|
228 |
+
}
|
229 |
+
},
|
230 |
+
"node_modules/chokidar": {
|
231 |
+
"version": "3.5.3",
|
232 |
+
"resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.5.3.tgz",
|
233 |
+
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
|
234 |
+
"dev": true,
|
235 |
+
"funding": [
|
236 |
+
{
|
237 |
+
"type": "individual",
|
238 |
+
"url": "https://paulmillr.com/funding/"
|
239 |
+
}
|
240 |
+
],
|
241 |
+
"dependencies": {
|
242 |
+
"anymatch": "~3.1.2",
|
243 |
+
"braces": "~3.0.2",
|
244 |
+
"glob-parent": "~5.1.2",
|
245 |
+
"is-binary-path": "~2.1.0",
|
246 |
+
"is-glob": "~4.0.1",
|
247 |
+
"normalize-path": "~3.0.0",
|
248 |
+
"readdirp": "~3.6.0"
|
249 |
+
},
|
250 |
+
"engines": {
|
251 |
+
"node": ">= 8.10.0"
|
252 |
+
},
|
253 |
+
"optionalDependencies": {
|
254 |
+
"fsevents": "~2.3.2"
|
255 |
+
}
|
256 |
+
},
|
257 |
+
"node_modules/csstype": {
|
258 |
+
"version": "2.6.21",
|
259 |
+
"resolved": "https://registry.npmmirror.com/csstype/-/csstype-2.6.21.tgz",
|
260 |
+
"integrity": "sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w=="
|
261 |
+
},
|
262 |
+
"node_modules/esbuild": {
|
263 |
+
"version": "0.15.15",
|
264 |
+
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.15.15.tgz",
|
265 |
+
"integrity": "sha512-TEw/lwK4Zzld9x3FedV6jy8onOUHqcEX3ADFk4k+gzPUwrxn8nWV62tH0udo8jOtjFodlEfc4ypsqX3e+WWO6w==",
|
266 |
+
"dev": true,
|
267 |
+
"hasInstallScript": true,
|
268 |
+
"bin": {
|
269 |
+
"esbuild": "bin/esbuild"
|
270 |
+
},
|
271 |
+
"engines": {
|
272 |
+
"node": ">=12"
|
273 |
+
},
|
274 |
+
"optionalDependencies": {
|
275 |
+
"@esbuild/android-arm": "0.15.15",
|
276 |
+
"@esbuild/linux-loong64": "0.15.15",
|
277 |
+
"esbuild-android-64": "0.15.15",
|
278 |
+
"esbuild-android-arm64": "0.15.15",
|
279 |
+
"esbuild-darwin-64": "0.15.15",
|
280 |
+
"esbuild-darwin-arm64": "0.15.15",
|
281 |
+
"esbuild-freebsd-64": "0.15.15",
|
282 |
+
"esbuild-freebsd-arm64": "0.15.15",
|
283 |
+
"esbuild-linux-32": "0.15.15",
|
284 |
+
"esbuild-linux-64": "0.15.15",
|
285 |
+
"esbuild-linux-arm": "0.15.15",
|
286 |
+
"esbuild-linux-arm64": "0.15.15",
|
287 |
+
"esbuild-linux-mips64le": "0.15.15",
|
288 |
+
"esbuild-linux-ppc64le": "0.15.15",
|
289 |
+
"esbuild-linux-riscv64": "0.15.15",
|
290 |
+
"esbuild-linux-s390x": "0.15.15",
|
291 |
+
"esbuild-netbsd-64": "0.15.15",
|
292 |
+
"esbuild-openbsd-64": "0.15.15",
|
293 |
+
"esbuild-sunos-64": "0.15.15",
|
294 |
+
"esbuild-windows-32": "0.15.15",
|
295 |
+
"esbuild-windows-64": "0.15.15",
|
296 |
+
"esbuild-windows-arm64": "0.15.15"
|
297 |
+
}
|
298 |
+
},
|
299 |
+
"node_modules/esbuild-android-64": {
|
300 |
+
"version": "0.15.15",
|
301 |
+
"resolved": "https://registry.npmmirror.com/esbuild-android-64/-/esbuild-android-64-0.15.15.tgz",
|
302 |
+
"integrity": "sha512-F+WjjQxO+JQOva3tJWNdVjouFMLK6R6i5gjDvgUthLYJnIZJsp1HlF523k73hELY20WPyEO8xcz7aaYBVkeg5Q==",
|
303 |
+
"cpu": [
|
304 |
+
"x64"
|
305 |
+
],
|
306 |
+
"dev": true,
|
307 |
+
"optional": true,
|
308 |
+
"os": [
|
309 |
+
"android"
|
310 |
+
],
|
311 |
+
"engines": {
|
312 |
+
"node": ">=12"
|
313 |
+
}
|
314 |
+
},
|
315 |
+
"node_modules/esbuild-android-arm64": {
|
316 |
+
"version": "0.15.15",
|
317 |
+
"resolved": "https://registry.npmmirror.com/esbuild-android-arm64/-/esbuild-android-arm64-0.15.15.tgz",
|
318 |
+
"integrity": "sha512-attlyhD6Y22jNyQ0fIIQ7mnPvDWKw7k6FKnsXlBvQE6s3z6s6cuEHcSgoirquQc7TmZgVCK5fD/2uxmRN+ZpcQ==",
|
319 |
+
"cpu": [
|
320 |
+
"arm64"
|
321 |
+
],
|
322 |
+
"dev": true,
|
323 |
+
"optional": true,
|
324 |
+
"os": [
|
325 |
+
"android"
|
326 |
+
],
|
327 |
+
"engines": {
|
328 |
+
"node": ">=12"
|
329 |
+
}
|
330 |
+
},
|
331 |
+
"node_modules/esbuild-darwin-64": {
|
332 |
+
"version": "0.15.15",
|
333 |
+
"resolved": "https://registry.npmmirror.com/esbuild-darwin-64/-/esbuild-darwin-64-0.15.15.tgz",
|
334 |
+
"integrity": "sha512-ohZtF8W1SHJ4JWldsPVdk8st0r9ExbAOSrBOh5L+Mq47i696GVwv1ab/KlmbUoikSTNoXEhDzVpxUR/WIO19FQ==",
|
335 |
+
"cpu": [
|
336 |
+
"x64"
|
337 |
+
],
|
338 |
+
"dev": true,
|
339 |
+
"optional": true,
|
340 |
+
"os": [
|
341 |
+
"darwin"
|
342 |
+
],
|
343 |
+
"engines": {
|
344 |
+
"node": ">=12"
|
345 |
+
}
|
346 |
+
},
|
347 |
+
"node_modules/esbuild-darwin-arm64": {
|
348 |
+
"version": "0.15.15",
|
349 |
+
"resolved": "https://registry.npmmirror.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.15.tgz",
|
350 |
+
"integrity": "sha512-P8jOZ5zshCNIuGn+9KehKs/cq5uIniC+BeCykvdVhx/rBXSxmtj3CUIKZz4sDCuESMbitK54drf/2QX9QHG5Ag==",
|
351 |
+
"cpu": [
|
352 |
+
"arm64"
|
353 |
+
],
|
354 |
+
"dev": true,
|
355 |
+
"optional": true,
|
356 |
+
"os": [
|
357 |
+
"darwin"
|
358 |
+
],
|
359 |
+
"engines": {
|
360 |
+
"node": ">=12"
|
361 |
+
}
|
362 |
+
},
|
363 |
+
"node_modules/esbuild-freebsd-64": {
|
364 |
+
"version": "0.15.15",
|
365 |
+
"resolved": "https://registry.npmmirror.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.15.tgz",
|
366 |
+
"integrity": "sha512-KkTg+AmDXz1IvA9S1gt8dE24C8Thx0X5oM0KGF322DuP+P3evwTL9YyusHAWNsh4qLsR80nvBr/EIYs29VSwuA==",
|
367 |
+
"cpu": [
|
368 |
+
"x64"
|
369 |
+
],
|
370 |
+
"dev": true,
|
371 |
+
"optional": true,
|
372 |
+
"os": [
|
373 |
+
"freebsd"
|
374 |
+
],
|
375 |
+
"engines": {
|
376 |
+
"node": ">=12"
|
377 |
+
}
|
378 |
+
},
|
379 |
+
"node_modules/esbuild-freebsd-arm64": {
|
380 |
+
"version": "0.15.15",
|
381 |
+
"resolved": "https://registry.npmmirror.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.15.tgz",
|
382 |
+
"integrity": "sha512-FUcML0DRsuyqCMfAC+HoeAqvWxMeq0qXvclZZ/lt2kLU6XBnDA5uKTLUd379WYEyVD4KKFctqWd9tTuk8C/96g==",
|
383 |
+
"cpu": [
|
384 |
+
"arm64"
|
385 |
+
],
|
386 |
+
"dev": true,
|
387 |
+
"optional": true,
|
388 |
+
"os": [
|
389 |
+
"freebsd"
|
390 |
+
],
|
391 |
+
"engines": {
|
392 |
+
"node": ">=12"
|
393 |
+
}
|
394 |
+
},
|
395 |
+
"node_modules/esbuild-linux-32": {
|
396 |
+
"version": "0.15.15",
|
397 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-32/-/esbuild-linux-32-0.15.15.tgz",
|
398 |
+
"integrity": "sha512-q28Qn5pZgHNqug02aTkzw5sW9OklSo96b5nm17Mq0pDXrdTBcQ+M6Q9A1B+dalFeynunwh/pvfrNucjzwDXj+Q==",
|
399 |
+
"cpu": [
|
400 |
+
"ia32"
|
401 |
+
],
|
402 |
+
"dev": true,
|
403 |
+
"optional": true,
|
404 |
+
"os": [
|
405 |
+
"linux"
|
406 |
+
],
|
407 |
+
"engines": {
|
408 |
+
"node": ">=12"
|
409 |
+
}
|
410 |
+
},
|
411 |
+
"node_modules/esbuild-linux-64": {
|
412 |
+
"version": "0.15.15",
|
413 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-64/-/esbuild-linux-64-0.15.15.tgz",
|
414 |
+
"integrity": "sha512-217KPmWMirkf8liO+fj2qrPwbIbhNTGNVtvqI1TnOWJgcMjUWvd677Gq3fTzXEjilkx2yWypVnTswM2KbXgoAg==",
|
415 |
+
"cpu": [
|
416 |
+
"x64"
|
417 |
+
],
|
418 |
+
"dev": true,
|
419 |
+
"optional": true,
|
420 |
+
"os": [
|
421 |
+
"linux"
|
422 |
+
],
|
423 |
+
"engines": {
|
424 |
+
"node": ">=12"
|
425 |
+
}
|
426 |
+
},
|
427 |
+
"node_modules/esbuild-linux-arm": {
|
428 |
+
"version": "0.15.15",
|
429 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-arm/-/esbuild-linux-arm-0.15.15.tgz",
|
430 |
+
"integrity": "sha512-RYVW9o2yN8yM7SB1yaWr378CwrjvGCyGybX3SdzPHpikUHkME2AP55Ma20uNwkNyY2eSYFX9D55kDrfQmQBR4w==",
|
431 |
+
"cpu": [
|
432 |
+
"arm"
|
433 |
+
],
|
434 |
+
"dev": true,
|
435 |
+
"optional": true,
|
436 |
+
"os": [
|
437 |
+
"linux"
|
438 |
+
],
|
439 |
+
"engines": {
|
440 |
+
"node": ">=12"
|
441 |
+
}
|
442 |
+
},
|
443 |
+
"node_modules/esbuild-linux-arm64": {
|
444 |
+
"version": "0.15.15",
|
445 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.15.tgz",
|
446 |
+
"integrity": "sha512-/ltmNFs0FivZkYsTzAsXIfLQX38lFnwJTWCJts0IbCqWZQe+jjj0vYBNbI0kmXLb3y5NljiM5USVAO1NVkdh2g==",
|
447 |
+
"cpu": [
|
448 |
+
"arm64"
|
449 |
+
],
|
450 |
+
"dev": true,
|
451 |
+
"optional": true,
|
452 |
+
"os": [
|
453 |
+
"linux"
|
454 |
+
],
|
455 |
+
"engines": {
|
456 |
+
"node": ">=12"
|
457 |
+
}
|
458 |
+
},
|
459 |
+
"node_modules/esbuild-linux-mips64le": {
|
460 |
+
"version": "0.15.15",
|
461 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.15.tgz",
|
462 |
+
"integrity": "sha512-PksEPb321/28GFFxtvL33yVPfnMZihxkEv5zME2zapXGp7fA1X2jYeiTUK+9tJ/EGgcNWuwvtawPxJG7Mmn86A==",
|
463 |
+
"cpu": [
|
464 |
+
"mips64el"
|
465 |
+
],
|
466 |
+
"dev": true,
|
467 |
+
"optional": true,
|
468 |
+
"os": [
|
469 |
+
"linux"
|
470 |
+
],
|
471 |
+
"engines": {
|
472 |
+
"node": ">=12"
|
473 |
+
}
|
474 |
+
},
|
475 |
+
"node_modules/esbuild-linux-ppc64le": {
|
476 |
+
"version": "0.15.15",
|
477 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.15.tgz",
|
478 |
+
"integrity": "sha512-ek8gJBEIhcpGI327eAZigBOHl58QqrJrYYIZBWQCnH3UnXoeWMrMZLeeZL8BI2XMBhP+sQ6ERctD5X+ajL/AIA==",
|
479 |
+
"cpu": [
|
480 |
+
"ppc64"
|
481 |
+
],
|
482 |
+
"dev": true,
|
483 |
+
"optional": true,
|
484 |
+
"os": [
|
485 |
+
"linux"
|
486 |
+
],
|
487 |
+
"engines": {
|
488 |
+
"node": ">=12"
|
489 |
+
}
|
490 |
+
},
|
491 |
+
"node_modules/esbuild-linux-riscv64": {
|
492 |
+
"version": "0.15.15",
|
493 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.15.tgz",
|
494 |
+
"integrity": "sha512-H5ilTZb33/GnUBrZMNJtBk7/OXzDHDXjIzoLXHSutwwsLxSNaLxzAaMoDGDd/keZoS+GDBqNVxdCkpuiRW4OSw==",
|
495 |
+
"cpu": [
|
496 |
+
"riscv64"
|
497 |
+
],
|
498 |
+
"dev": true,
|
499 |
+
"optional": true,
|
500 |
+
"os": [
|
501 |
+
"linux"
|
502 |
+
],
|
503 |
+
"engines": {
|
504 |
+
"node": ">=12"
|
505 |
+
}
|
506 |
+
},
|
507 |
+
"node_modules/esbuild-linux-s390x": {
|
508 |
+
"version": "0.15.15",
|
509 |
+
"resolved": "https://registry.npmmirror.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.15.tgz",
|
510 |
+
"integrity": "sha512-jKaLUg78mua3rrtrkpv4Or2dNTJU7bgHN4bEjT4OX4GR7nLBSA9dfJezQouTxMmIW7opwEC5/iR9mpC18utnxQ==",
|
511 |
+
"cpu": [
|
512 |
+
"s390x"
|
513 |
+
],
|
514 |
+
"dev": true,
|
515 |
+
"optional": true,
|
516 |
+
"os": [
|
517 |
+
"linux"
|
518 |
+
],
|
519 |
+
"engines": {
|
520 |
+
"node": ">=12"
|
521 |
+
}
|
522 |
+
},
|
523 |
+
"node_modules/esbuild-netbsd-64": {
|
524 |
+
"version": "0.15.15",
|
525 |
+
"resolved": "https://registry.npmmirror.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.15.tgz",
|
526 |
+
"integrity": "sha512-aOvmF/UkjFuW6F36HbIlImJTTx45KUCHJndtKo+KdP8Dhq3mgLRKW9+6Ircpm8bX/RcS3zZMMmaBLkvGY06Gvw==",
|
527 |
+
"cpu": [
|
528 |
+
"x64"
|
529 |
+
],
|
530 |
+
"dev": true,
|
531 |
+
"optional": true,
|
532 |
+
"os": [
|
533 |
+
"netbsd"
|
534 |
+
],
|
535 |
+
"engines": {
|
536 |
+
"node": ">=12"
|
537 |
+
}
|
538 |
+
},
|
539 |
+
"node_modules/esbuild-openbsd-64": {
|
540 |
+
"version": "0.15.15",
|
541 |
+
"resolved": "https://registry.npmmirror.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.15.tgz",
|
542 |
+
"integrity": "sha512-HFFX+WYedx1w2yJ1VyR1Dfo8zyYGQZf1cA69bLdrHzu9svj6KH6ZLK0k3A1/LFPhcEY9idSOhsB2UyU0tHPxgQ==",
|
543 |
+
"cpu": [
|
544 |
+
"x64"
|
545 |
+
],
|
546 |
+
"dev": true,
|
547 |
+
"optional": true,
|
548 |
+
"os": [
|
549 |
+
"openbsd"
|
550 |
+
],
|
551 |
+
"engines": {
|
552 |
+
"node": ">=12"
|
553 |
+
}
|
554 |
+
},
|
555 |
+
"node_modules/esbuild-sunos-64": {
|
556 |
+
"version": "0.15.15",
|
557 |
+
"resolved": "https://registry.npmmirror.com/esbuild-sunos-64/-/esbuild-sunos-64-0.15.15.tgz",
|
558 |
+
"integrity": "sha512-jOPBudffG4HN8yJXcK9rib/ZTFoTA5pvIKbRrt3IKAGMq1EpBi4xoVoSRrq/0d4OgZLaQbmkHp8RO9eZIn5atA==",
|
559 |
+
"cpu": [
|
560 |
+
"x64"
|
561 |
+
],
|
562 |
+
"dev": true,
|
563 |
+
"optional": true,
|
564 |
+
"os": [
|
565 |
+
"sunos"
|
566 |
+
],
|
567 |
+
"engines": {
|
568 |
+
"node": ">=12"
|
569 |
+
}
|
570 |
+
},
|
571 |
+
"node_modules/esbuild-windows-32": {
|
572 |
+
"version": "0.15.15",
|
573 |
+
"resolved": "https://registry.npmmirror.com/esbuild-windows-32/-/esbuild-windows-32-0.15.15.tgz",
|
574 |
+
"integrity": "sha512-MDkJ3QkjnCetKF0fKxCyYNBnOq6dmidcwstBVeMtXSgGYTy8XSwBeIE4+HuKiSsG6I/mXEb++px3IGSmTN0XiA==",
|
575 |
+
"cpu": [
|
576 |
+
"ia32"
|
577 |
+
],
|
578 |
+
"dev": true,
|
579 |
+
"optional": true,
|
580 |
+
"os": [
|
581 |
+
"win32"
|
582 |
+
],
|
583 |
+
"engines": {
|
584 |
+
"node": ">=12"
|
585 |
+
}
|
586 |
+
},
|
587 |
+
"node_modules/esbuild-windows-64": {
|
588 |
+
"version": "0.15.15",
|
589 |
+
"resolved": "https://registry.npmmirror.com/esbuild-windows-64/-/esbuild-windows-64-0.15.15.tgz",
|
590 |
+
"integrity": "sha512-xaAUIB2qllE888SsMU3j9nrqyLbkqqkpQyWVkfwSil6BBPgcPk3zOFitTTncEKCLTQy3XV9RuH7PDj3aJDljWA==",
|
591 |
+
"cpu": [
|
592 |
+
"x64"
|
593 |
+
],
|
594 |
+
"dev": true,
|
595 |
+
"optional": true,
|
596 |
+
"os": [
|
597 |
+
"win32"
|
598 |
+
],
|
599 |
+
"engines": {
|
600 |
+
"node": ">=12"
|
601 |
+
}
|
602 |
+
},
|
603 |
+
"node_modules/esbuild-windows-arm64": {
|
604 |
+
"version": "0.15.15",
|
605 |
+
"resolved": "https://registry.npmmirror.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.15.tgz",
|
606 |
+
"integrity": "sha512-ttuoCYCIJAFx4UUKKWYnFdrVpoXa3+3WWkXVI6s09U+YjhnyM5h96ewTq/WgQj9LFSIlABQvadHSOQyAVjW5xQ==",
|
607 |
+
"cpu": [
|
608 |
+
"arm64"
|
609 |
+
],
|
610 |
+
"dev": true,
|
611 |
+
"optional": true,
|
612 |
+
"os": [
|
613 |
+
"win32"
|
614 |
+
],
|
615 |
+
"engines": {
|
616 |
+
"node": ">=12"
|
617 |
+
}
|
618 |
+
},
|
619 |
+
"node_modules/estree-walker": {
|
620 |
+
"version": "2.0.2",
|
621 |
+
"resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-2.0.2.tgz",
|
622 |
+
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="
|
623 |
+
},
|
624 |
+
"node_modules/fill-range": {
|
625 |
+
"version": "7.0.1",
|
626 |
+
"resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.0.1.tgz",
|
627 |
+
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
628 |
+
"dev": true,
|
629 |
+
"dependencies": {
|
630 |
+
"to-regex-range": "^5.0.1"
|
631 |
+
},
|
632 |
+
"engines": {
|
633 |
+
"node": ">=8"
|
634 |
+
}
|
635 |
+
},
|
636 |
+
"node_modules/fsevents": {
|
637 |
+
"version": "2.3.2",
|
638 |
+
"resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz",
|
639 |
+
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
640 |
+
"dev": true,
|
641 |
+
"hasInstallScript": true,
|
642 |
+
"optional": true,
|
643 |
+
"os": [
|
644 |
+
"darwin"
|
645 |
+
],
|
646 |
+
"engines": {
|
647 |
+
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
648 |
+
}
|
649 |
+
},
|
650 |
+
"node_modules/function-bind": {
|
651 |
+
"version": "1.1.1",
|
652 |
+
"resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.1.tgz",
|
653 |
+
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
|
654 |
+
"dev": true
|
655 |
+
},
|
656 |
+
"node_modules/glob-parent": {
|
657 |
+
"version": "5.1.2",
|
658 |
+
"resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz",
|
659 |
+
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
660 |
+
"dev": true,
|
661 |
+
"dependencies": {
|
662 |
+
"is-glob": "^4.0.1"
|
663 |
+
},
|
664 |
+
"engines": {
|
665 |
+
"node": ">= 6"
|
666 |
+
}
|
667 |
+
},
|
668 |
+
"node_modules/has": {
|
669 |
+
"version": "1.0.3",
|
670 |
+
"resolved": "https://registry.npmmirror.com/has/-/has-1.0.3.tgz",
|
671 |
+
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
672 |
+
"dev": true,
|
673 |
+
"dependencies": {
|
674 |
+
"function-bind": "^1.1.1"
|
675 |
+
},
|
676 |
+
"engines": {
|
677 |
+
"node": ">= 0.4.0"
|
678 |
+
}
|
679 |
+
},
|
680 |
+
"node_modules/identicon.js": {
|
681 |
+
"version": "2.3.3",
|
682 |
+
"resolved": "https://registry.npmmirror.com/identicon.js/-/identicon.js-2.3.3.tgz",
|
683 |
+
"integrity": "sha512-/qgOkXKZ7YbeCYbawJ9uQQ3XJ3uBg9VDpvHjabCAPp6aRMhjLaFAxG90+1TxzrhKaj6AYpVGrx6UXQfQA41UEA=="
|
684 |
+
},
|
685 |
+
"node_modules/immutable": {
|
686 |
+
"version": "4.1.0",
|
687 |
+
"resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.1.0.tgz",
|
688 |
+
"integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==",
|
689 |
+
"dev": true
|
690 |
+
},
|
691 |
+
"node_modules/is-binary-path": {
|
692 |
+
"version": "2.1.0",
|
693 |
+
"resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
694 |
+
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
|
695 |
+
"dev": true,
|
696 |
+
"dependencies": {
|
697 |
+
"binary-extensions": "^2.0.0"
|
698 |
+
},
|
699 |
+
"engines": {
|
700 |
+
"node": ">=8"
|
701 |
+
}
|
702 |
+
},
|
703 |
+
"node_modules/is-core-module": {
|
704 |
+
"version": "2.11.0",
|
705 |
+
"resolved": "https://registry.npmmirror.com/is-core-module/-/is-core-module-2.11.0.tgz",
|
706 |
+
"integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==",
|
707 |
+
"dev": true,
|
708 |
+
"dependencies": {
|
709 |
+
"has": "^1.0.3"
|
710 |
+
},
|
711 |
+
"funding": {
|
712 |
+
"url": "https://github.com/sponsors/ljharb"
|
713 |
+
}
|
714 |
+
},
|
715 |
+
"node_modules/is-extglob": {
|
716 |
+
"version": "2.1.1",
|
717 |
+
"resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz",
|
718 |
+
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
719 |
+
"dev": true,
|
720 |
+
"engines": {
|
721 |
+
"node": ">=0.10.0"
|
722 |
+
}
|
723 |
+
},
|
724 |
+
"node_modules/is-glob": {
|
725 |
+
"version": "4.0.3",
|
726 |
+
"resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz",
|
727 |
+
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
728 |
+
"dev": true,
|
729 |
+
"dependencies": {
|
730 |
+
"is-extglob": "^2.1.1"
|
731 |
+
},
|
732 |
+
"engines": {
|
733 |
+
"node": ">=0.10.0"
|
734 |
+
}
|
735 |
+
},
|
736 |
+
"node_modules/is-number": {
|
737 |
+
"version": "7.0.0",
|
738 |
+
"resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz",
|
739 |
+
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
740 |
+
"dev": true,
|
741 |
+
"engines": {
|
742 |
+
"node": ">=0.12.0"
|
743 |
+
}
|
744 |
+
},
|
745 |
+
"node_modules/magic-string": {
|
746 |
+
"version": "0.25.9",
|
747 |
+
"resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.25.9.tgz",
|
748 |
+
"integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==",
|
749 |
+
"dependencies": {
|
750 |
+
"sourcemap-codec": "^1.4.8"
|
751 |
+
}
|
752 |
+
},
|
753 |
+
"node_modules/nanoid": {
|
754 |
+
"version": "3.3.7",
|
755 |
+
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
756 |
+
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
|
757 |
+
"funding": [
|
758 |
+
{
|
759 |
+
"type": "github",
|
760 |
+
"url": "https://github.com/sponsors/ai"
|
761 |
+
}
|
762 |
+
],
|
763 |
+
"bin": {
|
764 |
+
"nanoid": "bin/nanoid.cjs"
|
765 |
+
},
|
766 |
+
"engines": {
|
767 |
+
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
768 |
+
}
|
769 |
+
},
|
770 |
+
"node_modules/normalize-path": {
|
771 |
+
"version": "3.0.0",
|
772 |
+
"resolved": "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz",
|
773 |
+
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
|
774 |
+
"dev": true,
|
775 |
+
"engines": {
|
776 |
+
"node": ">=0.10.0"
|
777 |
+
}
|
778 |
+
},
|
779 |
+
"node_modules/ometa": {
|
780 |
+
"version": "0.2.2",
|
781 |
+
"resolved": "https://registry.npmmirror.com/ometa/-/ometa-0.2.2.tgz",
|
782 |
+
"integrity": "sha512-LZuoK/yjU3FvrxPjUXUlZ1bavCfBPqauA7fsNdwi+AVhRdyk2IzgP3JRnevvjzQ6fKHdUw8YISshf53FmpHrng==",
|
783 |
+
"engines": {
|
784 |
+
"node": ">= 0.2.0"
|
785 |
+
}
|
786 |
+
},
|
787 |
+
"node_modules/path-parse": {
|
788 |
+
"version": "1.0.7",
|
789 |
+
"resolved": "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz",
|
790 |
+
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
791 |
+
"dev": true
|
792 |
+
},
|
793 |
+
"node_modules/picocolors": {
|
794 |
+
"version": "1.0.0",
|
795 |
+
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz",
|
796 |
+
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
|
797 |
+
},
|
798 |
+
"node_modules/picomatch": {
|
799 |
+
"version": "2.3.1",
|
800 |
+
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz",
|
801 |
+
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
802 |
+
"dev": true,
|
803 |
+
"engines": {
|
804 |
+
"node": ">=8.6"
|
805 |
+
},
|
806 |
+
"funding": {
|
807 |
+
"url": "https://github.com/sponsors/jonschlinkert"
|
808 |
+
}
|
809 |
+
},
|
810 |
+
"node_modules/postcss": {
|
811 |
+
"version": "8.4.32",
|
812 |
+
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.32.tgz",
|
813 |
+
"integrity": "sha512-D/kj5JNu6oo2EIy+XL/26JEDTlIbB8hw85G8StOE6L74RQAVVP5rej6wxCNqyMbR4RkPfqvezVbPw81Ngd6Kcw==",
|
814 |
+
"funding": [
|
815 |
+
{
|
816 |
+
"type": "opencollective",
|
817 |
+
"url": "https://opencollective.com/postcss/"
|
818 |
+
},
|
819 |
+
{
|
820 |
+
"type": "tidelift",
|
821 |
+
"url": "https://tidelift.com/funding/github/npm/postcss"
|
822 |
+
},
|
823 |
+
{
|
824 |
+
"type": "github",
|
825 |
+
"url": "https://github.com/sponsors/ai"
|
826 |
+
}
|
827 |
+
],
|
828 |
+
"dependencies": {
|
829 |
+
"nanoid": "^3.3.7",
|
830 |
+
"picocolors": "^1.0.0",
|
831 |
+
"source-map-js": "^1.0.2"
|
832 |
+
},
|
833 |
+
"engines": {
|
834 |
+
"node": "^10 || ^12 || >=14"
|
835 |
+
}
|
836 |
+
},
|
837 |
+
"node_modules/readdirp": {
|
838 |
+
"version": "3.6.0",
|
839 |
+
"resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz",
|
840 |
+
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
|
841 |
+
"dev": true,
|
842 |
+
"dependencies": {
|
843 |
+
"picomatch": "^2.2.1"
|
844 |
+
},
|
845 |
+
"engines": {
|
846 |
+
"node": ">=8.10.0"
|
847 |
+
}
|
848 |
+
},
|
849 |
+
"node_modules/resolve": {
|
850 |
+
"version": "1.22.1",
|
851 |
+
"resolved": "https://registry.npmmirror.com/resolve/-/resolve-1.22.1.tgz",
|
852 |
+
"integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==",
|
853 |
+
"dev": true,
|
854 |
+
"dependencies": {
|
855 |
+
"is-core-module": "^2.9.0",
|
856 |
+
"path-parse": "^1.0.7",
|
857 |
+
"supports-preserve-symlinks-flag": "^1.0.0"
|
858 |
+
},
|
859 |
+
"bin": {
|
860 |
+
"resolve": "bin/resolve"
|
861 |
+
},
|
862 |
+
"funding": {
|
863 |
+
"url": "https://github.com/sponsors/ljharb"
|
864 |
+
}
|
865 |
+
},
|
866 |
+
"node_modules/rollup": {
|
867 |
+
"version": "2.79.1",
|
868 |
+
"resolved": "https://registry.npmmirror.com/rollup/-/rollup-2.79.1.tgz",
|
869 |
+
"integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==",
|
870 |
+
"dev": true,
|
871 |
+
"bin": {
|
872 |
+
"rollup": "dist/bin/rollup"
|
873 |
+
},
|
874 |
+
"engines": {
|
875 |
+
"node": ">=10.0.0"
|
876 |
+
},
|
877 |
+
"optionalDependencies": {
|
878 |
+
"fsevents": "~2.3.2"
|
879 |
+
}
|
880 |
+
},
|
881 |
+
"node_modules/sass": {
|
882 |
+
"version": "1.56.1",
|
883 |
+
"resolved": "https://registry.npmmirror.com/sass/-/sass-1.56.1.tgz",
|
884 |
+
"integrity": "sha512-VpEyKpyBPCxE7qGDtOcdJ6fFbcpOM+Emu7uZLxVrkX8KVU/Dp5UF7WLvzqRuUhB6mqqQt1xffLoG+AndxTZrCQ==",
|
885 |
+
"dev": true,
|
886 |
+
"dependencies": {
|
887 |
+
"chokidar": ">=3.0.0 <4.0.0",
|
888 |
+
"immutable": "^4.0.0",
|
889 |
+
"source-map-js": ">=0.6.2 <2.0.0"
|
890 |
+
},
|
891 |
+
"bin": {
|
892 |
+
"sass": "sass.js"
|
893 |
+
},
|
894 |
+
"engines": {
|
895 |
+
"node": ">=12.0.0"
|
896 |
+
}
|
897 |
+
},
|
898 |
+
"node_modules/scss": {
|
899 |
+
"version": "0.2.4",
|
900 |
+
"resolved": "https://registry.npmmirror.com/scss/-/scss-0.2.4.tgz",
|
901 |
+
"integrity": "sha512-4u8V87F+Q/upVhUmhPnB4C1R11xojkRkWjExL2v0CX2EXTg18VrKd+9JWoeyCp2VEMdSpJsyAvVU+rVjogh51A==",
|
902 |
+
"dependencies": {
|
903 |
+
"ometa": "0.2.2"
|
904 |
+
},
|
905 |
+
"engines": {
|
906 |
+
"node": ">= 0.2.0"
|
907 |
+
}
|
908 |
+
},
|
909 |
+
"node_modules/source-map": {
|
910 |
+
"version": "0.6.1",
|
911 |
+
"resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz",
|
912 |
+
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
913 |
+
"engines": {
|
914 |
+
"node": ">=0.10.0"
|
915 |
+
}
|
916 |
+
},
|
917 |
+
"node_modules/source-map-js": {
|
918 |
+
"version": "1.0.2",
|
919 |
+
"resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.0.2.tgz",
|
920 |
+
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
921 |
+
"engines": {
|
922 |
+
"node": ">=0.10.0"
|
923 |
+
}
|
924 |
+
},
|
925 |
+
"node_modules/sourcemap-codec": {
|
926 |
+
"version": "1.4.8",
|
927 |
+
"resolved": "https://registry.npmmirror.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
|
928 |
+
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
929 |
+
"deprecated": "Please use @jridgewell/sourcemap-codec instead"
|
930 |
+
},
|
931 |
+
"node_modules/supports-preserve-symlinks-flag": {
|
932 |
+
"version": "1.0.0",
|
933 |
+
"resolved": "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
|
934 |
+
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
|
935 |
+
"dev": true,
|
936 |
+
"engines": {
|
937 |
+
"node": ">= 0.4"
|
938 |
+
},
|
939 |
+
"funding": {
|
940 |
+
"url": "https://github.com/sponsors/ljharb"
|
941 |
+
}
|
942 |
+
},
|
943 |
+
"node_modules/to-regex-range": {
|
944 |
+
"version": "5.0.1",
|
945 |
+
"resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
946 |
+
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
947 |
+
"dev": true,
|
948 |
+
"dependencies": {
|
949 |
+
"is-number": "^7.0.0"
|
950 |
+
},
|
951 |
+
"engines": {
|
952 |
+
"node": ">=8.0"
|
953 |
+
}
|
954 |
+
},
|
955 |
+
"node_modules/vite": {
|
956 |
+
"version": "3.2.7",
|
957 |
+
"resolved": "https://registry.npmjs.org/vite/-/vite-3.2.7.tgz",
|
958 |
+
"integrity": "sha512-29pdXjk49xAP0QBr0xXqu2s5jiQIXNvE/xwd0vUizYT2Hzqe4BksNNoWllFVXJf4eLZ+UlVQmXfB4lWrc+t18g==",
|
959 |
+
"dev": true,
|
960 |
+
"dependencies": {
|
961 |
+
"esbuild": "^0.15.9",
|
962 |
+
"postcss": "^8.4.18",
|
963 |
+
"resolve": "^1.22.1",
|
964 |
+
"rollup": "^2.79.1"
|
965 |
+
},
|
966 |
+
"bin": {
|
967 |
+
"vite": "bin/vite.js"
|
968 |
+
},
|
969 |
+
"engines": {
|
970 |
+
"node": "^14.18.0 || >=16.0.0"
|
971 |
+
},
|
972 |
+
"optionalDependencies": {
|
973 |
+
"fsevents": "~2.3.2"
|
974 |
+
},
|
975 |
+
"peerDependencies": {
|
976 |
+
"@types/node": ">= 14",
|
977 |
+
"less": "*",
|
978 |
+
"sass": "*",
|
979 |
+
"stylus": "*",
|
980 |
+
"sugarss": "*",
|
981 |
+
"terser": "^5.4.0"
|
982 |
+
},
|
983 |
+
"peerDependenciesMeta": {
|
984 |
+
"@types/node": {
|
985 |
+
"optional": true
|
986 |
+
},
|
987 |
+
"less": {
|
988 |
+
"optional": true
|
989 |
+
},
|
990 |
+
"sass": {
|
991 |
+
"optional": true
|
992 |
+
},
|
993 |
+
"stylus": {
|
994 |
+
"optional": true
|
995 |
+
},
|
996 |
+
"sugarss": {
|
997 |
+
"optional": true
|
998 |
+
},
|
999 |
+
"terser": {
|
1000 |
+
"optional": true
|
1001 |
+
}
|
1002 |
+
}
|
1003 |
+
},
|
1004 |
+
"node_modules/vue": {
|
1005 |
+
"version": "3.2.45",
|
1006 |
+
"resolved": "https://registry.npmmirror.com/vue/-/vue-3.2.45.tgz",
|
1007 |
+
"integrity": "sha512-9Nx/Mg2b2xWlXykmCwiTUCWHbWIj53bnkizBxKai1g61f2Xit700A1ljowpTIM11e3uipOeiPcSqnmBg6gyiaA==",
|
1008 |
+
"dependencies": {
|
1009 |
+
"@vue/compiler-dom": "3.2.45",
|
1010 |
+
"@vue/compiler-sfc": "3.2.45",
|
1011 |
+
"@vue/runtime-dom": "3.2.45",
|
1012 |
+
"@vue/server-renderer": "3.2.45",
|
1013 |
+
"@vue/shared": "3.2.45"
|
1014 |
+
}
|
1015 |
+
}
|
1016 |
+
}
|
1017 |
+
}
|
package.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "Chatxu-Story",
|
3 |
+
"private": true,
|
4 |
+
"version": "0.0.0",
|
5 |
+
"type": "module",
|
6 |
+
"scripts": {
|
7 |
+
"dev": "vite",
|
8 |
+
"build": "vite build",
|
9 |
+
"preview": "vite preview"
|
10 |
+
},
|
11 |
+
"dependencies": {
|
12 |
+
"@primer/css": "^20.4.1",
|
13 |
+
"identicon.js": "^2.3.3",
|
14 |
+
"scss": "^0.2.4",
|
15 |
+
"vue": "^3.2.37"
|
16 |
+
},
|
17 |
+
"devDependencies": {
|
18 |
+
"@vitejs/plugin-vue": "^3.0.0",
|
19 |
+
"sass": "^1.54.3",
|
20 |
+
"vite": "^3.0.0"
|
21 |
+
}
|
22 |
+
}
|
public/llama2.c/tokenizer.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:50a52ef822ee9e83de5ce9d0be0a025a773d019437f58b5ff9dcafb063ece361
|
3 |
+
size 433869
|
public/llama2c-worker.js
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
self.addEventListener('message', async function(e){
|
2 |
+
var pageDirectory = self.location.href.substr(0, self.location.href.lastIndexOf('/'));
|
3 |
+
var wasiModule = await import(pageDirectory + '/vendor/wasi.js');
|
4 |
+
var WASIJS = wasiModule.WASI;
|
5 |
+
var WASIContext = wasiModule.WASIContext;
|
6 |
+
|
7 |
+
var context;
|
8 |
+
var result;
|
9 |
+
|
10 |
+
// Initialize WASM memory.
|
11 |
+
var wasmMemory = new WebAssembly.Memory({initial:32, maximum: 10000});
|
12 |
+
var wasmImports = {
|
13 |
+
JS: {},
|
14 |
+
env: {memory: wasmMemory, table: new WebAssembly.Table({initial: 2, element: 'anyfunc'})},
|
15 |
+
};
|
16 |
+
var fileRequest = await fetch(pageDirectory + '/' + 'tokenizer.bin');
|
17 |
+
var fileContent = await fileRequest.arrayBuffer();
|
18 |
+
|
19 |
+
var modelURL = pageDirectory + '/' + 'model.bin';
|
20 |
+
if (isLocalhost()) { modelURL = pageDirectory + '/' + 'model.bin'; }
|
21 |
+
|
22 |
+
var modelFileRequest = await fetch(modelURL);
|
23 |
+
var contentLength = modelFileRequest.headers.get('Content-Length');
|
24 |
+
|
25 |
+
var responseSize = 0;
|
26 |
+
let chunksAll = new Uint8Array(contentLength); // (4.1)
|
27 |
+
|
28 |
+
for await (var chunk of streamAsyncIterable(modelFileRequest.body)) {
|
29 |
+
chunksAll.set(chunk, responseSize); // (4.2)
|
30 |
+
responseSize += chunk.length;
|
31 |
+
self.postMessage({
|
32 |
+
eventType: "MODELDOWNLOADPROGRESS",
|
33 |
+
eventData: responseSize / contentLength
|
34 |
+
});
|
35 |
+
}
|
36 |
+
|
37 |
+
async function* streamAsyncIterable(stream) {
|
38 |
+
const reader = stream.getReader()
|
39 |
+
try {
|
40 |
+
while (true) {
|
41 |
+
const { done, value } = await reader.read()
|
42 |
+
if (done) return
|
43 |
+
yield value
|
44 |
+
}
|
45 |
+
} finally {
|
46 |
+
reader.releaseLock()
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
var output = '';
|
51 |
+
|
52 |
+
context = new WASIContext({
|
53 |
+
args: ['run', 'model.bin', '-i', '标题:'+e.data, '-t',0.8,'-n',1024],
|
54 |
+
stdout: function (out) {
|
55 |
+
console.log(out)
|
56 |
+
output += out;
|
57 |
+
self.postMessage({
|
58 |
+
eventType: "STDOUT",
|
59 |
+
eventData: out
|
60 |
+
});
|
61 |
+
},
|
62 |
+
stderr: function (err) {
|
63 |
+
self.postMessage({
|
64 |
+
eventType: "STDERR",
|
65 |
+
eventData: err
|
66 |
+
});
|
67 |
+
console.error('stderr', err);
|
68 |
+
},
|
69 |
+
stdin: () => prompt('stdin:'),
|
70 |
+
fs: {
|
71 |
+
'/model.bin': {
|
72 |
+
path: modelFileRequest.name,
|
73 |
+
timestamps: {
|
74 |
+
change: new Date(modelFileRequest.headers.get('Last-Modified')),
|
75 |
+
access: new Date(modelFileRequest.headers.get('Last-Modified')),
|
76 |
+
modification: new Date(modelFileRequest.headers.get('Last-Modified')),
|
77 |
+
},
|
78 |
+
mode: 'binary',
|
79 |
+
content: new Uint8Array(chunksAll),
|
80 |
+
},
|
81 |
+
'/tokenizer.bin': {
|
82 |
+
path: 'tokenizer.bin',
|
83 |
+
timestamps: {
|
84 |
+
change: new Date(fileRequest.headers.get('Last-Modified')),
|
85 |
+
access: new Date(fileRequest.headers.get('Last-Modified')),
|
86 |
+
modification: new Date(fileRequest.headers.get('Last-Modified')),
|
87 |
+
},
|
88 |
+
mode: 'binary',
|
89 |
+
content: new Uint8Array(fileContent),
|
90 |
+
}
|
91 |
+
}
|
92 |
+
});
|
93 |
+
|
94 |
+
function isLocalhost() {
|
95 |
+
var url = self.location.origin;
|
96 |
+
return url.indexOf('127.0.0.1') !== -1 || url.indexOf('localhost') !== -1;
|
97 |
+
}
|
98 |
+
|
99 |
+
result = await WASIJS.start(fetch('llama2c.wasm'), context, wasmImports);
|
100 |
+
})
|
public/llama2c.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eea46dcbedcc1fdc2552a62e99d82bbdd5de325bb0857e8a1fc19847db85e097
|
3 |
+
size 90154
|
public/model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e0f719ca15cfce20afaba40a97b196212de65efe3b5466f0c685cd9c509d7bcd
|
3 |
+
size 121630876
|
public/tokenizer.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:53ce5eebafdb985d678b1fbe0d294b5e6a51516ba275c5d85c284637c5d34691
|
3 |
+
size 797568
|
public/vendor/vendor/wasi.js
ADDED
@@ -0,0 +1,1595 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i, mm) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
env: mm.env,
|
514 |
+
JS: mm.JS,
|
515 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
516 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
517 |
+
});
|
518 |
+
n.memory = mm.env.memory;
|
519 |
+
return n.init(l), n.start();
|
520 |
+
}
|
521 |
+
init(t) {
|
522 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.memory || this.instance.exports.memory, this.initialized = !0;
|
523 |
+
}
|
524 |
+
start() {
|
525 |
+
if (!this.initialized)
|
526 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
527 |
+
const t = this.instance.exports._start;
|
528 |
+
try {
|
529 |
+
t();
|
530 |
+
} catch (i) {
|
531 |
+
if (i instanceof w)
|
532 |
+
return {
|
533 |
+
exitCode: i.code,
|
534 |
+
fs: this.drive.fs
|
535 |
+
};
|
536 |
+
if (i instanceof WebAssembly.RuntimeError)
|
537 |
+
return {
|
538 |
+
exitCode: 134,
|
539 |
+
fs: this.drive.fs
|
540 |
+
};
|
541 |
+
throw i;
|
542 |
+
}
|
543 |
+
return {
|
544 |
+
instance: this.instance,
|
545 |
+
exitCode: 0,
|
546 |
+
fs: this.drive.fs
|
547 |
+
};
|
548 |
+
}
|
549 |
+
getImports(t, i) {
|
550 |
+
const n = {
|
551 |
+
args_get: this.args_get.bind(this),
|
552 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
553 |
+
clock_res_get: this.clock_res_get.bind(this),
|
554 |
+
clock_time_get: this.clock_time_get.bind(this),
|
555 |
+
environ_get: this.environ_get.bind(this),
|
556 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
557 |
+
proc_exit: this.proc_exit.bind(this),
|
558 |
+
random_get: this.random_get.bind(this),
|
559 |
+
sched_yield: this.sched_yield.bind(this),
|
560 |
+
// File Descriptors
|
561 |
+
fd_advise: this.fd_advise.bind(this),
|
562 |
+
fd_allocate: this.fd_allocate.bind(this),
|
563 |
+
fd_close: this.fd_close.bind(this),
|
564 |
+
fd_datasync: this.fd_datasync.bind(this),
|
565 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
566 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
567 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
568 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
569 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
570 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
571 |
+
fd_pread: this.fd_pread.bind(this),
|
572 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
573 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
574 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
575 |
+
fd_read: this.fd_read.bind(this),
|
576 |
+
fd_readdir: this.fd_readdir.bind(this),
|
577 |
+
fd_renumber: this.fd_renumber.bind(this),
|
578 |
+
fd_seek: this.fd_seek.bind(this),
|
579 |
+
fd_sync: this.fd_sync.bind(this),
|
580 |
+
fd_tell: this.fd_tell.bind(this),
|
581 |
+
fd_write: this.fd_write.bind(this),
|
582 |
+
// Paths
|
583 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
584 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
585 |
+
path_open: this.path_open.bind(this),
|
586 |
+
path_rename: this.path_rename.bind(this),
|
587 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
588 |
+
path_create_directory: this.path_create_directory.bind(this),
|
589 |
+
// Unimplemented
|
590 |
+
path_link: this.path_link.bind(this),
|
591 |
+
path_readlink: this.path_readlink.bind(this),
|
592 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
593 |
+
path_symlink: this.path_symlink.bind(this),
|
594 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
595 |
+
proc_raise: this.proc_raise.bind(this),
|
596 |
+
sock_accept: this.sock_accept.bind(this),
|
597 |
+
sock_recv: this.sock_recv.bind(this),
|
598 |
+
sock_send: this.sock_send.bind(this),
|
599 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
600 |
+
// Unimplemented - WASMEdge compatibility
|
601 |
+
sock_open: this.sock_open.bind(this),
|
602 |
+
sock_listen: this.sock_listen.bind(this),
|
603 |
+
sock_connect: this.sock_connect.bind(this),
|
604 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
605 |
+
sock_bind: this.sock_bind.bind(this),
|
606 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
607 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
608 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
609 |
+
};
|
610 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
611 |
+
for (const [l, s] of Object.entries(n))
|
612 |
+
n[l] = function() {
|
613 |
+
let d = s.apply(this, arguments);
|
614 |
+
if (i) {
|
615 |
+
const V = Vt();
|
616 |
+
d = i(l, [...arguments], d, V) ?? d;
|
617 |
+
}
|
618 |
+
return d;
|
619 |
+
};
|
620 |
+
return n;
|
621 |
+
}
|
622 |
+
//
|
623 |
+
// Helpers
|
624 |
+
//
|
625 |
+
get envArray() {
|
626 |
+
return Object.entries(this.context.env).map(
|
627 |
+
([t, i]) => `${t}=${i}`
|
628 |
+
);
|
629 |
+
}
|
630 |
+
//
|
631 |
+
// WASI Implementation
|
632 |
+
//
|
633 |
+
/**
|
634 |
+
* Read command-line argument data. The size of the array should match that
|
635 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
636 |
+
*/
|
637 |
+
args_get(t, i) {
|
638 |
+
const n = new DataView(this.memory.buffer);
|
639 |
+
for (const l of this.context.args) {
|
640 |
+
n.setUint32(t, i, !0), t += 4;
|
641 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
642 |
+
new Uint8Array(
|
643 |
+
this.memory.buffer,
|
644 |
+
i,
|
645 |
+
s.byteLength
|
646 |
+
).set(s), i += s.byteLength;
|
647 |
+
}
|
648 |
+
return c.SUCCESS;
|
649 |
+
}
|
650 |
+
/**
|
651 |
+
* Return command-line argument data sizes.
|
652 |
+
*/
|
653 |
+
args_sizes_get(t, i) {
|
654 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
655 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
656 |
+
}
|
657 |
+
/**
|
658 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
659 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
660 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
661 |
+
*/
|
662 |
+
clock_res_get(t, i) {
|
663 |
+
switch (t) {
|
664 |
+
case p.REALTIME:
|
665 |
+
case p.MONOTONIC:
|
666 |
+
case p.PROCESS_CPUTIME_ID:
|
667 |
+
case p.THREAD_CPUTIME_ID:
|
668 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
669 |
+
}
|
670 |
+
return c.EINVAL;
|
671 |
+
}
|
672 |
+
/**
|
673 |
+
* Return the time value of a clock.
|
674 |
+
* Note: This is similar to clock_gettime in POSIX.
|
675 |
+
*/
|
676 |
+
clock_time_get(t, i, n) {
|
677 |
+
switch (t) {
|
678 |
+
case p.REALTIME:
|
679 |
+
case p.MONOTONIC:
|
680 |
+
case p.PROCESS_CPUTIME_ID:
|
681 |
+
case p.THREAD_CPUTIME_ID:
|
682 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
683 |
+
}
|
684 |
+
return c.EINVAL;
|
685 |
+
}
|
686 |
+
/**
|
687 |
+
* Read environment variable data. The sizes of the buffers should match that
|
688 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
689 |
+
* with =s, and terminated with \0s.
|
690 |
+
*/
|
691 |
+
environ_get(t, i) {
|
692 |
+
const n = new DataView(this.memory.buffer);
|
693 |
+
for (const l of this.envArray) {
|
694 |
+
n.setUint32(t, i, !0), t += 4;
|
695 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
696 |
+
new Uint8Array(
|
697 |
+
this.memory.buffer,
|
698 |
+
i,
|
699 |
+
s.byteLength
|
700 |
+
).set(s), i += s.byteLength;
|
701 |
+
}
|
702 |
+
return c.SUCCESS;
|
703 |
+
}
|
704 |
+
/**
|
705 |
+
* Return environment variable data sizes.
|
706 |
+
*/
|
707 |
+
environ_sizes_get(t, i) {
|
708 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
709 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
710 |
+
}
|
711 |
+
/**
|
712 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
713 |
+
* termination of the program. The meanings of other values is dependent on
|
714 |
+
* the environment.
|
715 |
+
*/
|
716 |
+
proc_exit(t) {
|
717 |
+
throw new w(t);
|
718 |
+
}
|
719 |
+
/**
|
720 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
721 |
+
* implementation is unable to immediately provide sufficient high-quality
|
722 |
+
* random data. This function may execute slowly, so when large mounts of
|
723 |
+
* random data are required, it's advisable to use this function to seed a
|
724 |
+
* pseudo-random number generator, rather than to provide the random data
|
725 |
+
* directly.
|
726 |
+
*/
|
727 |
+
random_get(t, i) {
|
728 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
729 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
730 |
+
}
|
731 |
+
/**
|
732 |
+
* Temporarily yield execution of the calling thread.
|
733 |
+
* Note: This is similar to sched_yield in POSIX.
|
734 |
+
*/
|
735 |
+
sched_yield() {
|
736 |
+
return c.SUCCESS;
|
737 |
+
}
|
738 |
+
//
|
739 |
+
// File Descriptors
|
740 |
+
//
|
741 |
+
/**
|
742 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
743 |
+
*/
|
744 |
+
fd_read(t, i, n, l) {
|
745 |
+
if (t === 1 || t === 2)
|
746 |
+
return c.ENOTSUP;
|
747 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
748 |
+
let a = 0, Z = c.SUCCESS;
|
749 |
+
for (const h of d) {
|
750 |
+
let r;
|
751 |
+
if (t === 0) {
|
752 |
+
const R = this.context.stdin(h.byteLength);
|
753 |
+
if (!R)
|
754 |
+
break;
|
755 |
+
r = V.encode(R);
|
756 |
+
} else {
|
757 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
758 |
+
if (R) {
|
759 |
+
Z = R;
|
760 |
+
break;
|
761 |
+
} else
|
762 |
+
r = k;
|
763 |
+
}
|
764 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
765 |
+
h.set(r.subarray(0, o)), a += o;
|
766 |
+
}
|
767 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
768 |
+
}
|
769 |
+
/**
|
770 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
771 |
+
*/
|
772 |
+
fd_write(t, i, n, l) {
|
773 |
+
if (t === 0)
|
774 |
+
return c.ENOTSUP;
|
775 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
776 |
+
let a = 0, Z = c.SUCCESS;
|
777 |
+
for (const h of d)
|
778 |
+
if (h.byteLength !== 0) {
|
779 |
+
if (t === 1 || t === 2) {
|
780 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
781 |
+
r(o), f({ output: o });
|
782 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
783 |
+
break;
|
784 |
+
a += h.byteLength;
|
785 |
+
}
|
786 |
+
return s.setUint32(l, a, !0), Z;
|
787 |
+
}
|
788 |
+
/**
|
789 |
+
* Provide file advisory information on a file descriptor.
|
790 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
791 |
+
*/
|
792 |
+
fd_advise() {
|
793 |
+
return c.SUCCESS;
|
794 |
+
}
|
795 |
+
/**
|
796 |
+
* Force the allocation of space in a file.
|
797 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
798 |
+
*/
|
799 |
+
fd_allocate(t, i, n) {
|
800 |
+
return this.drive.pwrite(
|
801 |
+
t,
|
802 |
+
new Uint8Array(Number(n)),
|
803 |
+
Number(i)
|
804 |
+
);
|
805 |
+
}
|
806 |
+
/**
|
807 |
+
* Close a file descriptor.
|
808 |
+
* Note: This is similar to close in POSIX.
|
809 |
+
*
|
810 |
+
* @param fd
|
811 |
+
*/
|
812 |
+
fd_close(t) {
|
813 |
+
return this.drive.close(t);
|
814 |
+
}
|
815 |
+
/**
|
816 |
+
* Synchronize the data of a file to disk.
|
817 |
+
* Note: This is similar to fdatasync in POSIX.
|
818 |
+
*
|
819 |
+
* @param fd
|
820 |
+
*/
|
821 |
+
fd_datasync(t) {
|
822 |
+
return this.drive.sync(t);
|
823 |
+
}
|
824 |
+
/**
|
825 |
+
* Get the attributes of a file descriptor.
|
826 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
827 |
+
* as well as additional fields.
|
828 |
+
*
|
829 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
830 |
+
* are stored.
|
831 |
+
*
|
832 |
+
* @returns Result<fdstat, errno>
|
833 |
+
*/
|
834 |
+
fd_fdstat_get(t, i) {
|
835 |
+
if (t < 3) {
|
836 |
+
let V;
|
837 |
+
if (this.context.isTTY) {
|
838 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
839 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
840 |
+
} else
|
841 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
842 |
+
return new Uint8Array(
|
843 |
+
this.memory.buffer,
|
844 |
+
i,
|
845 |
+
V.byteLength
|
846 |
+
).set(V), c.SUCCESS;
|
847 |
+
}
|
848 |
+
if (!this.drive.exists(t))
|
849 |
+
return c.EBADF;
|
850 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
851 |
+
return new Uint8Array(
|
852 |
+
this.memory.buffer,
|
853 |
+
i,
|
854 |
+
s.byteLength
|
855 |
+
).set(s), c.SUCCESS;
|
856 |
+
}
|
857 |
+
/**
|
858 |
+
* Adjust the flags associated with a file descriptor.
|
859 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
860 |
+
*/
|
861 |
+
fd_fdstat_set_flags(t, i) {
|
862 |
+
return this.drive.setFlags(t, i);
|
863 |
+
}
|
864 |
+
/**
|
865 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
866 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
867 |
+
* would attempt to add rights
|
868 |
+
*/
|
869 |
+
fd_fdstat_set_rights() {
|
870 |
+
return c.SUCCESS;
|
871 |
+
}
|
872 |
+
/**
|
873 |
+
* Return the attributes of an open file.
|
874 |
+
*/
|
875 |
+
fd_filestat_get(t, i) {
|
876 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
877 |
+
}
|
878 |
+
/**
|
879 |
+
* Return the attributes of an open file.
|
880 |
+
* This version is used
|
881 |
+
*/
|
882 |
+
unstable_fd_filestat_get(t, i) {
|
883 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
884 |
+
}
|
885 |
+
/**
|
886 |
+
* Return the attributes of an open file.
|
887 |
+
*/
|
888 |
+
shared_fd_filestat_get(t, i, n) {
|
889 |
+
const l = n === "unstable" ? A : _;
|
890 |
+
if (t < 3) {
|
891 |
+
let Z;
|
892 |
+
switch (t) {
|
893 |
+
case 0:
|
894 |
+
Z = "/dev/stdin";
|
895 |
+
break;
|
896 |
+
case 1:
|
897 |
+
Z = "/dev/stdout";
|
898 |
+
break;
|
899 |
+
case 2:
|
900 |
+
Z = "/dev/stderr";
|
901 |
+
break;
|
902 |
+
default:
|
903 |
+
Z = "/dev/undefined";
|
904 |
+
break;
|
905 |
+
}
|
906 |
+
const h = l({
|
907 |
+
path: Z,
|
908 |
+
byteLength: 0,
|
909 |
+
timestamps: {
|
910 |
+
access: /* @__PURE__ */ new Date(),
|
911 |
+
modification: /* @__PURE__ */ new Date(),
|
912 |
+
change: /* @__PURE__ */ new Date()
|
913 |
+
},
|
914 |
+
type: X.CHARACTER_DEVICE
|
915 |
+
});
|
916 |
+
return new Uint8Array(
|
917 |
+
this.memory.buffer,
|
918 |
+
i,
|
919 |
+
h.byteLength
|
920 |
+
).set(h), c.SUCCESS;
|
921 |
+
}
|
922 |
+
const [s, d] = this.drive.stat(t);
|
923 |
+
if (s != c.SUCCESS)
|
924 |
+
return s;
|
925 |
+
f({ resolvedPath: d.path, stat: d });
|
926 |
+
const V = l(d);
|
927 |
+
return new Uint8Array(
|
928 |
+
this.memory.buffer,
|
929 |
+
i,
|
930 |
+
V.byteLength
|
931 |
+
).set(V), c.SUCCESS;
|
932 |
+
}
|
933 |
+
/**
|
934 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
935 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
936 |
+
* POSIX.
|
937 |
+
*/
|
938 |
+
fd_filestat_set_size(t, i) {
|
939 |
+
return this.drive.setSize(t, i);
|
940 |
+
}
|
941 |
+
/**
|
942 |
+
* Adjust the timestamps of an open file or directory.
|
943 |
+
* Note: This is similar to futimens in POSIX.
|
944 |
+
*/
|
945 |
+
fd_filestat_set_times(t, i, n, l) {
|
946 |
+
let s = null;
|
947 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
948 |
+
let d = null;
|
949 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
950 |
+
const V = this.drive.setAccessTime(t, s);
|
951 |
+
if (V != c.SUCCESS)
|
952 |
+
return V;
|
953 |
+
}
|
954 |
+
if (d) {
|
955 |
+
const V = this.drive.setModificationTime(t, d);
|
956 |
+
if (V != c.SUCCESS)
|
957 |
+
return V;
|
958 |
+
}
|
959 |
+
return c.SUCCESS;
|
960 |
+
}
|
961 |
+
/**
|
962 |
+
* Read from a file descriptor, without using and updating the file
|
963 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
964 |
+
*/
|
965 |
+
fd_pread(t, i, n, l, s) {
|
966 |
+
if (t === 1 || t === 2)
|
967 |
+
return c.ENOTSUP;
|
968 |
+
if (t === 0)
|
969 |
+
return this.fd_read(t, i, n, s);
|
970 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
971 |
+
let a = 0, Z = c.SUCCESS;
|
972 |
+
for (const h of V) {
|
973 |
+
const [r, o] = this.drive.pread(
|
974 |
+
t,
|
975 |
+
h.byteLength,
|
976 |
+
Number(l) + a
|
977 |
+
);
|
978 |
+
if (r !== c.SUCCESS) {
|
979 |
+
Z = r;
|
980 |
+
break;
|
981 |
+
}
|
982 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
983 |
+
h.set(o.subarray(0, R)), a += R;
|
984 |
+
}
|
985 |
+
return d.setUint32(s, a, !0), Z;
|
986 |
+
}
|
987 |
+
/**
|
988 |
+
* Return a description of the given preopened file descriptor.
|
989 |
+
*/
|
990 |
+
fd_prestat_dir_name(t, i, n) {
|
991 |
+
if (t !== 3)
|
992 |
+
return c.EBADF;
|
993 |
+
const l = new TextEncoder().encode("/");
|
994 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
995 |
+
}
|
996 |
+
/**
|
997 |
+
* Return a description of the given preopened file descriptor.
|
998 |
+
*/
|
999 |
+
fd_prestat_get(t, i) {
|
1000 |
+
if (t !== 3)
|
1001 |
+
return c.EBADF;
|
1002 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
1003 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1004 |
+
}
|
1005 |
+
/**
|
1006 |
+
* Write to a file descriptor, without using and updating the file
|
1007 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1008 |
+
*/
|
1009 |
+
fd_pwrite(t, i, n, l, s) {
|
1010 |
+
if (t === 0)
|
1011 |
+
return c.ENOTSUP;
|
1012 |
+
if (t === 1 || t === 2)
|
1013 |
+
return this.fd_write(t, i, n, s);
|
1014 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1015 |
+
let a = 0, Z = c.SUCCESS;
|
1016 |
+
for (const h of V)
|
1017 |
+
if (h.byteLength !== 0) {
|
1018 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1019 |
+
break;
|
1020 |
+
a += h.byteLength;
|
1021 |
+
}
|
1022 |
+
return d.setUint32(s, a, !0), Z;
|
1023 |
+
}
|
1024 |
+
/**
|
1025 |
+
* Read directory entries from a directory. When successful, the contents of
|
1026 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1027 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1028 |
+
* bytes holding the name of the directory entry. This function fills the
|
1029 |
+
* output buffer as much as possible, potentially truncating the last
|
1030 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1031 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1032 |
+
* oversized directory entry.
|
1033 |
+
*/
|
1034 |
+
fd_readdir(t, i, n, l, s) {
|
1035 |
+
const [d, V] = this.drive.list(t);
|
1036 |
+
if (d != c.SUCCESS)
|
1037 |
+
return d;
|
1038 |
+
let a = [], Z = 0;
|
1039 |
+
for (const { name: N, type: F } of V) {
|
1040 |
+
const g = ht(N, F, Z);
|
1041 |
+
a.push(g), Z++;
|
1042 |
+
}
|
1043 |
+
a = a.slice(Number(l));
|
1044 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1045 |
+
let o = 0;
|
1046 |
+
for (const N of a)
|
1047 |
+
r.set(N, o), o += N.byteLength;
|
1048 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1049 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1050 |
+
}
|
1051 |
+
/**
|
1052 |
+
* Atomically replace a file descriptor by renumbering another file
|
1053 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1054 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1055 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1056 |
+
* an actual file descriptor with the same number could be allocated by a
|
1057 |
+
* different thread at the same time. This function provides a way to
|
1058 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1059 |
+
* to be removed entirely.
|
1060 |
+
*/
|
1061 |
+
fd_renumber(t, i) {
|
1062 |
+
return this.drive.renumber(t, i);
|
1063 |
+
}
|
1064 |
+
/**
|
1065 |
+
* Move the offset of a file descriptor.
|
1066 |
+
*
|
1067 |
+
* The offset is specified as a bigint here
|
1068 |
+
* Note: This is similar to lseek in POSIX.
|
1069 |
+
*
|
1070 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1071 |
+
* bigint in JavaScript.
|
1072 |
+
*/
|
1073 |
+
fd_seek(t, i, n, l) {
|
1074 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1075 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1076 |
+
}
|
1077 |
+
unstable_fd_seek(t, i, n, l) {
|
1078 |
+
const s = mt[n];
|
1079 |
+
return this.fd_seek(t, i, s, l);
|
1080 |
+
}
|
1081 |
+
/**
|
1082 |
+
* Synchronize the data and metadata of a file to disk.
|
1083 |
+
* Note: This is similar to fsync in POSIX.
|
1084 |
+
*/
|
1085 |
+
fd_sync(t) {
|
1086 |
+
return this.drive.sync(t);
|
1087 |
+
}
|
1088 |
+
/**
|
1089 |
+
* Return the current offset of a file descriptor.
|
1090 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1091 |
+
*
|
1092 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1093 |
+
*
|
1094 |
+
*/
|
1095 |
+
fd_tell(t, i) {
|
1096 |
+
const [n, l] = this.drive.tell(t);
|
1097 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1098 |
+
}
|
1099 |
+
//
|
1100 |
+
// Paths
|
1101 |
+
//
|
1102 |
+
path_filestat_get(t, i, n, l, s) {
|
1103 |
+
return this.shared_path_filestat_get(
|
1104 |
+
t,
|
1105 |
+
i,
|
1106 |
+
n,
|
1107 |
+
l,
|
1108 |
+
s,
|
1109 |
+
"preview1"
|
1110 |
+
);
|
1111 |
+
}
|
1112 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1113 |
+
return this.shared_path_filestat_get(
|
1114 |
+
t,
|
1115 |
+
i,
|
1116 |
+
n,
|
1117 |
+
l,
|
1118 |
+
s,
|
1119 |
+
"unstable"
|
1120 |
+
);
|
1121 |
+
}
|
1122 |
+
/**
|
1123 |
+
* Return the attributes of a file or directory.
|
1124 |
+
* Note: This is similar to stat in POSIX.
|
1125 |
+
*/
|
1126 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1127 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1128 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1129 |
+
);
|
1130 |
+
f({ path: a });
|
1131 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1132 |
+
if (Z != c.SUCCESS)
|
1133 |
+
return Z;
|
1134 |
+
const r = V(h);
|
1135 |
+
return new Uint8Array(
|
1136 |
+
this.memory.buffer,
|
1137 |
+
s,
|
1138 |
+
r.byteLength
|
1139 |
+
).set(r), Z;
|
1140 |
+
}
|
1141 |
+
/**
|
1142 |
+
* Adjust the timestamps of a file or directory.
|
1143 |
+
* Note: This is similar to utimensat in POSIX.
|
1144 |
+
*/
|
1145 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1146 |
+
let a = null;
|
1147 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1148 |
+
let Z = null;
|
1149 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1150 |
+
const h = new TextDecoder().decode(
|
1151 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1152 |
+
);
|
1153 |
+
if (a) {
|
1154 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1155 |
+
if (r != c.SUCCESS)
|
1156 |
+
return r;
|
1157 |
+
}
|
1158 |
+
if (Z) {
|
1159 |
+
const r = this.drive.pathSetModificationTime(
|
1160 |
+
t,
|
1161 |
+
h,
|
1162 |
+
Z
|
1163 |
+
);
|
1164 |
+
if (r != c.SUCCESS)
|
1165 |
+
return r;
|
1166 |
+
}
|
1167 |
+
return c.SUCCESS;
|
1168 |
+
}
|
1169 |
+
/**
|
1170 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1171 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1172 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1173 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1174 |
+
* descriptor is guaranteed to be less than 2**31.
|
1175 |
+
* Note: This is similar to openat in POSIX.
|
1176 |
+
* @param fd: fd
|
1177 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1178 |
+
* is resolved. Not supported by Runno (symlinks)
|
1179 |
+
* @param path: string The relative path of the file or directory to open,
|
1180 |
+
* relative to the path_open::fd directory.
|
1181 |
+
* @param oflags: oflags The method by which to open the file.
|
1182 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1183 |
+
* descriptor. The implementation is allowed to return
|
1184 |
+
* a file descriptor with fewer rights than specified,
|
1185 |
+
* if and only if those rights do not apply to the type
|
1186 |
+
* of file being opened. The base rights are rights
|
1187 |
+
* that will apply to operations using the file
|
1188 |
+
* descriptor itself, while the inheriting rights are
|
1189 |
+
* rights that apply to file descriptors derived from
|
1190 |
+
* it.
|
1191 |
+
* @param fs_rights_inheriting: rights
|
1192 |
+
* @param fdflags: fdflags
|
1193 |
+
*
|
1194 |
+
*/
|
1195 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1196 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1197 |
+
f({
|
1198 |
+
path: r,
|
1199 |
+
openFlags: {
|
1200 |
+
createFileIfNone: o,
|
1201 |
+
failIfNotDir: R,
|
1202 |
+
failIfFileExists: k,
|
1203 |
+
truncateFile: P
|
1204 |
+
},
|
1205 |
+
fileDescriptorFlags: {
|
1206 |
+
flagAppend: N,
|
1207 |
+
flagDSync: F,
|
1208 |
+
flagNonBlock: g,
|
1209 |
+
flagRSync: et,
|
1210 |
+
flagSync: it
|
1211 |
+
}
|
1212 |
+
});
|
1213 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1214 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1215 |
+
}
|
1216 |
+
/**
|
1217 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1218 |
+
*/
|
1219 |
+
path_rename(t, i, n, l, s, d) {
|
1220 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1221 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1222 |
+
}
|
1223 |
+
/**
|
1224 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1225 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1226 |
+
*/
|
1227 |
+
path_unlink_file(t, i, n) {
|
1228 |
+
const l = I(this.memory, i, n);
|
1229 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1230 |
+
}
|
1231 |
+
/**
|
1232 |
+
* Concurrently poll for the occurrence of a set of events.
|
1233 |
+
*/
|
1234 |
+
poll_oneoff(t, i, n, l) {
|
1235 |
+
for (let d = 0; d < n; d++) {
|
1236 |
+
const V = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
t + d * M,
|
1239 |
+
M
|
1240 |
+
), a = Zt(V), Z = new Uint8Array(
|
1241 |
+
this.memory.buffer,
|
1242 |
+
i + d * x,
|
1243 |
+
x
|
1244 |
+
);
|
1245 |
+
let h = 0, r = c.SUCCESS;
|
1246 |
+
switch (a.type) {
|
1247 |
+
case G.CLOCK:
|
1248 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1249 |
+
;
|
1250 |
+
Z.set(
|
1251 |
+
rt(a.userdata, c.SUCCESS)
|
1252 |
+
);
|
1253 |
+
break;
|
1254 |
+
case G.FD_READ:
|
1255 |
+
if (a.fd < 3)
|
1256 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1257 |
+
else {
|
1258 |
+
const [o, R] = this.drive.stat(a.fd);
|
1259 |
+
r = o, h = R ? R.byteLength : 0;
|
1260 |
+
}
|
1261 |
+
Z.set(
|
1262 |
+
v(
|
1263 |
+
a.userdata,
|
1264 |
+
r,
|
1265 |
+
G.FD_READ,
|
1266 |
+
BigInt(h)
|
1267 |
+
)
|
1268 |
+
);
|
1269 |
+
break;
|
1270 |
+
case G.FD_WRITE:
|
1271 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1272 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1273 |
+
else {
|
1274 |
+
const [o, R] = this.drive.stat(a.fd);
|
1275 |
+
r = o, h = R ? R.byteLength : 0;
|
1276 |
+
}
|
1277 |
+
Z.set(
|
1278 |
+
v(
|
1279 |
+
a.userdata,
|
1280 |
+
r,
|
1281 |
+
G.FD_READ,
|
1282 |
+
BigInt(h)
|
1283 |
+
)
|
1284 |
+
);
|
1285 |
+
break;
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1289 |
+
}
|
1290 |
+
/**
|
1291 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1292 |
+
*/
|
1293 |
+
path_create_directory(t, i, n) {
|
1294 |
+
const l = I(this.memory, i, n);
|
1295 |
+
return this.drive.pathCreateDir(t, l);
|
1296 |
+
}
|
1297 |
+
//
|
1298 |
+
// Unimplemented - these operations are not supported by Runno
|
1299 |
+
//
|
1300 |
+
/**
|
1301 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1302 |
+
*/
|
1303 |
+
path_link() {
|
1304 |
+
return c.ENOSYS;
|
1305 |
+
}
|
1306 |
+
/**
|
1307 |
+
* Read the contents of a symbolic link.
|
1308 |
+
* Note: This is similar to readlinkat in POSIX.
|
1309 |
+
*/
|
1310 |
+
path_readlink() {
|
1311 |
+
return c.ENOSYS;
|
1312 |
+
}
|
1313 |
+
/**
|
1314 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1315 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1316 |
+
*/
|
1317 |
+
path_remove_directory() {
|
1318 |
+
return c.ENOSYS;
|
1319 |
+
}
|
1320 |
+
/**
|
1321 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1322 |
+
*/
|
1323 |
+
path_symlink() {
|
1324 |
+
return c.ENOSYS;
|
1325 |
+
}
|
1326 |
+
/**
|
1327 |
+
* Send a signal to the process of the calling thread.
|
1328 |
+
* Note: This is similar to raise in POSIX.
|
1329 |
+
*/
|
1330 |
+
proc_raise() {
|
1331 |
+
return c.ENOSYS;
|
1332 |
+
}
|
1333 |
+
/**
|
1334 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1335 |
+
*/
|
1336 |
+
sock_accept() {
|
1337 |
+
return c.ENOSYS;
|
1338 |
+
}
|
1339 |
+
/**
|
1340 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1341 |
+
* though it also supports reading the data into multiple buffers in the
|
1342 |
+
* manner of readv.
|
1343 |
+
*/
|
1344 |
+
sock_recv() {
|
1345 |
+
return c.ENOSYS;
|
1346 |
+
}
|
1347 |
+
/**
|
1348 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1349 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1350 |
+
* writev.
|
1351 |
+
*/
|
1352 |
+
sock_send() {
|
1353 |
+
return c.ENOSYS;
|
1354 |
+
}
|
1355 |
+
/**
|
1356 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1357 |
+
* shutdown in POSIX.
|
1358 |
+
*/
|
1359 |
+
sock_shutdown() {
|
1360 |
+
return c.ENOSYS;
|
1361 |
+
}
|
1362 |
+
//
|
1363 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1364 |
+
//
|
1365 |
+
sock_open() {
|
1366 |
+
return c.ENOSYS;
|
1367 |
+
}
|
1368 |
+
sock_listen() {
|
1369 |
+
return c.ENOSYS;
|
1370 |
+
}
|
1371 |
+
sock_connect() {
|
1372 |
+
return c.ENOSYS;
|
1373 |
+
}
|
1374 |
+
sock_setsockopt() {
|
1375 |
+
return c.ENOSYS;
|
1376 |
+
}
|
1377 |
+
sock_bind() {
|
1378 |
+
return c.ENOSYS;
|
1379 |
+
}
|
1380 |
+
sock_getlocaladdr() {
|
1381 |
+
return c.ENOSYS;
|
1382 |
+
}
|
1383 |
+
sock_getpeeraddr() {
|
1384 |
+
return c.ENOSYS;
|
1385 |
+
}
|
1386 |
+
sock_getaddrinfo() {
|
1387 |
+
return c.ENOSYS;
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1391 |
+
class w extends Error {
|
1392 |
+
constructor(i) {
|
1393 |
+
super();
|
1394 |
+
m(this, "code");
|
1395 |
+
this.code = i;
|
1396 |
+
}
|
1397 |
+
}
|
1398 |
+
function I(e, t, i) {
|
1399 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1400 |
+
}
|
1401 |
+
function K(e, t, i) {
|
1402 |
+
let n = Array(i);
|
1403 |
+
for (let l = 0; l < i; l++) {
|
1404 |
+
const s = e.getUint32(t, !0);
|
1405 |
+
t += 4;
|
1406 |
+
const d = e.getUint32(t, !0);
|
1407 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1408 |
+
}
|
1409 |
+
return n;
|
1410 |
+
}
|
1411 |
+
function Zt(e) {
|
1412 |
+
const t = new Uint8Array(8);
|
1413 |
+
t.set(e.subarray(0, 8));
|
1414 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1415 |
+
switch (i) {
|
1416 |
+
case G.FD_READ:
|
1417 |
+
case G.FD_WRITE:
|
1418 |
+
return {
|
1419 |
+
userdata: t,
|
1420 |
+
type: i,
|
1421 |
+
fd: n.getUint32(0, !0)
|
1422 |
+
};
|
1423 |
+
case G.CLOCK:
|
1424 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1425 |
+
return {
|
1426 |
+
userdata: t,
|
1427 |
+
type: i,
|
1428 |
+
id: n.getUint32(0, !0),
|
1429 |
+
timeout: W(a),
|
1430 |
+
precision: W(a + V)
|
1431 |
+
};
|
1432 |
+
}
|
1433 |
+
}
|
1434 |
+
function _(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function A(e) {
|
1439 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1440 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1441 |
+
}
|
1442 |
+
function J(e, t, i) {
|
1443 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1444 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1445 |
+
}
|
1446 |
+
function ht(e, t, i) {
|
1447 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1448 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1449 |
+
}
|
1450 |
+
function rt(e, t) {
|
1451 |
+
const i = new Uint8Array(32);
|
1452 |
+
i.set(e, 0);
|
1453 |
+
const n = new DataView(i.buffer);
|
1454 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1455 |
+
}
|
1456 |
+
function v(e, t, i, n) {
|
1457 |
+
const l = new Uint8Array(32);
|
1458 |
+
l.set(e, 0);
|
1459 |
+
const s = new DataView(l.buffer);
|
1460 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1461 |
+
}
|
1462 |
+
function H(e, t = 0) {
|
1463 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1464 |
+
for (let l = 0, s; l < e.length; l++)
|
1465 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1466 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1467 |
+
}
|
1468 |
+
function L(e) {
|
1469 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1470 |
+
}
|
1471 |
+
function W(e) {
|
1472 |
+
return new Date(Number(e / BigInt(1e6)));
|
1473 |
+
}
|
1474 |
+
const mt = {
|
1475 |
+
[Y.CUR]: y.CUR,
|
1476 |
+
[Y.END]: y.END,
|
1477 |
+
[Y.SET]: y.SET
|
1478 |
+
};
|
1479 |
+
class Xt {
|
1480 |
+
constructor(t) {
|
1481 |
+
m(this, "fs");
|
1482 |
+
m(this, "args");
|
1483 |
+
// Program args (like from a terminal program)
|
1484 |
+
m(this, "env");
|
1485 |
+
// Environment (like a .env file)
|
1486 |
+
m(this, "stdin");
|
1487 |
+
m(this, "stdout");
|
1488 |
+
m(this, "stderr");
|
1489 |
+
m(this, "debug");
|
1490 |
+
m(this, "isTTY");
|
1491 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1492 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1493 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NVUFBPUlQiLGVbZS5FQUdBSU49Nl09IkVBR0FJTiIsZVtlLkVBTFJFQURZPTddPSJFQUxSRUFEWSIsZVtlLkVCQURGPThdPSJFQkFERiIsZVtlLkVCQURNU0c9OV09IkVCQURNU0ciLGVbZS5FQlVTWT0xMF09IkVCVVNZIixlW2UuRUNBTkNFTEVEPTExXT0iRUNBTkNFTEVEIixlW2UuRUNISUxEPTEyXT0iRUNISUxEIixlW2UuRUNPTk5BQk9SVEVEPTEzXT0iRUNPTk5BQk9SVEVEIixlW2UuRUNPTk5SRUZVU0VEPTE0XT0iRUNPTk5SRUZVU0VEIixlW2UuRUNPTk5SRVNFVD0xNV09IkVDT05OUkVTRVQiLGVbZS5FREVBRExLPTE2XT0iRURFQURMSy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lTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1497 |
+
function ut() {
|
1498 |
+
let e;
|
1499 |
+
try {
|
1500 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1501 |
+
throw "";
|
1502 |
+
return new Worker(e);
|
1503 |
+
} catch {
|
1504 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1505 |
+
} finally {
|
1506 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1507 |
+
}
|
1508 |
+
}
|
1509 |
+
function ot(e, t) {
|
1510 |
+
e.postMessage(t);
|
1511 |
+
}
|
1512 |
+
class St extends Error {
|
1513 |
+
}
|
1514 |
+
class Gt {
|
1515 |
+
constructor(t, i) {
|
1516 |
+
m(this, "binaryURL");
|
1517 |
+
// 8kb should be big enough
|
1518 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1519 |
+
m(this, "context");
|
1520 |
+
m(this, "result");
|
1521 |
+
m(this, "worker");
|
1522 |
+
m(this, "reject");
|
1523 |
+
this.binaryURL = t, this.context = i;
|
1524 |
+
}
|
1525 |
+
async start() {
|
1526 |
+
if (this.result)
|
1527 |
+
throw new Error("WASIWorker Host can only be started once");
|
1528 |
+
return this.result = new Promise((t, i) => {
|
1529 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1530 |
+
var s, d, V, a, Z, h;
|
1531 |
+
const l = n.data;
|
1532 |
+
switch (l.type) {
|
1533 |
+
case "stdout":
|
1534 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1535 |
+
break;
|
1536 |
+
case "stderr":
|
1537 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1538 |
+
break;
|
1539 |
+
case "debug":
|
1540 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1541 |
+
Z,
|
1542 |
+
l.name,
|
1543 |
+
l.args,
|
1544 |
+
l.ret,
|
1545 |
+
l.data
|
1546 |
+
);
|
1547 |
+
break;
|
1548 |
+
case "result":
|
1549 |
+
t(l.result);
|
1550 |
+
break;
|
1551 |
+
case "crash":
|
1552 |
+
i(l.error);
|
1553 |
+
break;
|
1554 |
+
}
|
1555 |
+
}), ot(this.worker, {
|
1556 |
+
target: "client",
|
1557 |
+
type: "start",
|
1558 |
+
binaryURL: this.binaryURL,
|
1559 |
+
stdinBuffer: this.stdinBuffer,
|
1560 |
+
// Unfortunately can't just splat these because it includes types
|
1561 |
+
// that can't be sent as a message.
|
1562 |
+
args: this.context.args,
|
1563 |
+
env: this.context.env,
|
1564 |
+
fs: this.context.fs,
|
1565 |
+
isTTY: this.context.isTTY
|
1566 |
+
});
|
1567 |
+
}), this.result;
|
1568 |
+
}
|
1569 |
+
kill() {
|
1570 |
+
var t;
|
1571 |
+
if (!this.worker)
|
1572 |
+
throw new Error("WASIWorker has not started");
|
1573 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1574 |
+
}
|
1575 |
+
async pushStdin(t) {
|
1576 |
+
const i = new DataView(this.stdinBuffer);
|
1577 |
+
for (; i.getInt32(0) !== 0; )
|
1578 |
+
await new Promise((s) => setTimeout(s, 0));
|
1579 |
+
const n = new TextEncoder().encode(t);
|
1580 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1581 |
+
}
|
1582 |
+
async pushEOF() {
|
1583 |
+
const t = new DataView(this.stdinBuffer);
|
1584 |
+
for (; t.getInt32(0) !== 0; )
|
1585 |
+
await new Promise((i) => setTimeout(i, 0));
|
1586 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1587 |
+
}
|
1588 |
+
}
|
1589 |
+
export {
|
1590 |
+
q as WASI,
|
1591 |
+
Xt as WASIContext,
|
1592 |
+
bt as WASISnapshotPreview1,
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
514 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
515 |
+
});
|
516 |
+
return n.init(l), n.start();
|
517 |
+
}
|
518 |
+
init(t) {
|
519 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.instance.exports.memory, this.initialized = !0;
|
520 |
+
}
|
521 |
+
start() {
|
522 |
+
if (!this.initialized)
|
523 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
524 |
+
const t = this.instance.exports._start;
|
525 |
+
try {
|
526 |
+
t();
|
527 |
+
} catch (i) {
|
528 |
+
if (i instanceof w)
|
529 |
+
return {
|
530 |
+
exitCode: i.code,
|
531 |
+
fs: this.drive.fs
|
532 |
+
};
|
533 |
+
if (i instanceof WebAssembly.RuntimeError)
|
534 |
+
return {
|
535 |
+
exitCode: 134,
|
536 |
+
fs: this.drive.fs
|
537 |
+
};
|
538 |
+
throw i;
|
539 |
+
}
|
540 |
+
return {
|
541 |
+
exitCode: 0,
|
542 |
+
fs: this.drive.fs
|
543 |
+
};
|
544 |
+
}
|
545 |
+
getImports(t, i) {
|
546 |
+
const n = {
|
547 |
+
args_get: this.args_get.bind(this),
|
548 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
549 |
+
clock_res_get: this.clock_res_get.bind(this),
|
550 |
+
clock_time_get: this.clock_time_get.bind(this),
|
551 |
+
environ_get: this.environ_get.bind(this),
|
552 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
553 |
+
proc_exit: this.proc_exit.bind(this),
|
554 |
+
random_get: this.random_get.bind(this),
|
555 |
+
sched_yield: this.sched_yield.bind(this),
|
556 |
+
// File Descriptors
|
557 |
+
fd_advise: this.fd_advise.bind(this),
|
558 |
+
fd_allocate: this.fd_allocate.bind(this),
|
559 |
+
fd_close: this.fd_close.bind(this),
|
560 |
+
fd_datasync: this.fd_datasync.bind(this),
|
561 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
562 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
563 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
564 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
565 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
566 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
567 |
+
fd_pread: this.fd_pread.bind(this),
|
568 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
569 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
570 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
571 |
+
fd_read: this.fd_read.bind(this),
|
572 |
+
fd_readdir: this.fd_readdir.bind(this),
|
573 |
+
fd_renumber: this.fd_renumber.bind(this),
|
574 |
+
fd_seek: this.fd_seek.bind(this),
|
575 |
+
fd_sync: this.fd_sync.bind(this),
|
576 |
+
fd_tell: this.fd_tell.bind(this),
|
577 |
+
fd_write: this.fd_write.bind(this),
|
578 |
+
// Paths
|
579 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
580 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
581 |
+
path_open: this.path_open.bind(this),
|
582 |
+
path_rename: this.path_rename.bind(this),
|
583 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
584 |
+
path_create_directory: this.path_create_directory.bind(this),
|
585 |
+
// Unimplemented
|
586 |
+
path_link: this.path_link.bind(this),
|
587 |
+
path_readlink: this.path_readlink.bind(this),
|
588 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
589 |
+
path_symlink: this.path_symlink.bind(this),
|
590 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
591 |
+
proc_raise: this.proc_raise.bind(this),
|
592 |
+
sock_accept: this.sock_accept.bind(this),
|
593 |
+
sock_recv: this.sock_recv.bind(this),
|
594 |
+
sock_send: this.sock_send.bind(this),
|
595 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
596 |
+
// Unimplemented - WASMEdge compatibility
|
597 |
+
sock_open: this.sock_open.bind(this),
|
598 |
+
sock_listen: this.sock_listen.bind(this),
|
599 |
+
sock_connect: this.sock_connect.bind(this),
|
600 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
601 |
+
sock_bind: this.sock_bind.bind(this),
|
602 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
603 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
604 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
605 |
+
};
|
606 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
607 |
+
for (const [l, s] of Object.entries(n))
|
608 |
+
n[l] = function() {
|
609 |
+
let d = s.apply(this, arguments);
|
610 |
+
if (i) {
|
611 |
+
const V = Vt();
|
612 |
+
d = i(l, [...arguments], d, V) ?? d;
|
613 |
+
}
|
614 |
+
return d;
|
615 |
+
};
|
616 |
+
return n;
|
617 |
+
}
|
618 |
+
//
|
619 |
+
// Helpers
|
620 |
+
//
|
621 |
+
get envArray() {
|
622 |
+
return Object.entries(this.context.env).map(
|
623 |
+
([t, i]) => `${t}=${i}`
|
624 |
+
);
|
625 |
+
}
|
626 |
+
//
|
627 |
+
// WASI Implementation
|
628 |
+
//
|
629 |
+
/**
|
630 |
+
* Read command-line argument data. The size of the array should match that
|
631 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
632 |
+
*/
|
633 |
+
args_get(t, i) {
|
634 |
+
const n = new DataView(this.memory.buffer);
|
635 |
+
for (const l of this.context.args) {
|
636 |
+
n.setUint32(t, i, !0), t += 4;
|
637 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
638 |
+
new Uint8Array(
|
639 |
+
this.memory.buffer,
|
640 |
+
i,
|
641 |
+
s.byteLength
|
642 |
+
).set(s), i += s.byteLength;
|
643 |
+
}
|
644 |
+
return c.SUCCESS;
|
645 |
+
}
|
646 |
+
/**
|
647 |
+
* Return command-line argument data sizes.
|
648 |
+
*/
|
649 |
+
args_sizes_get(t, i) {
|
650 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
651 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
652 |
+
}
|
653 |
+
/**
|
654 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
655 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
656 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
657 |
+
*/
|
658 |
+
clock_res_get(t, i) {
|
659 |
+
switch (t) {
|
660 |
+
case p.REALTIME:
|
661 |
+
case p.MONOTONIC:
|
662 |
+
case p.PROCESS_CPUTIME_ID:
|
663 |
+
case p.THREAD_CPUTIME_ID:
|
664 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
665 |
+
}
|
666 |
+
return c.EINVAL;
|
667 |
+
}
|
668 |
+
/**
|
669 |
+
* Return the time value of a clock.
|
670 |
+
* Note: This is similar to clock_gettime in POSIX.
|
671 |
+
*/
|
672 |
+
clock_time_get(t, i, n) {
|
673 |
+
switch (t) {
|
674 |
+
case p.REALTIME:
|
675 |
+
case p.MONOTONIC:
|
676 |
+
case p.PROCESS_CPUTIME_ID:
|
677 |
+
case p.THREAD_CPUTIME_ID:
|
678 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
679 |
+
}
|
680 |
+
return c.EINVAL;
|
681 |
+
}
|
682 |
+
/**
|
683 |
+
* Read environment variable data. The sizes of the buffers should match that
|
684 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
685 |
+
* with =s, and terminated with \0s.
|
686 |
+
*/
|
687 |
+
environ_get(t, i) {
|
688 |
+
const n = new DataView(this.memory.buffer);
|
689 |
+
for (const l of this.envArray) {
|
690 |
+
n.setUint32(t, i, !0), t += 4;
|
691 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
692 |
+
new Uint8Array(
|
693 |
+
this.memory.buffer,
|
694 |
+
i,
|
695 |
+
s.byteLength
|
696 |
+
).set(s), i += s.byteLength;
|
697 |
+
}
|
698 |
+
return c.SUCCESS;
|
699 |
+
}
|
700 |
+
/**
|
701 |
+
* Return environment variable data sizes.
|
702 |
+
*/
|
703 |
+
environ_sizes_get(t, i) {
|
704 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
705 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
706 |
+
}
|
707 |
+
/**
|
708 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
709 |
+
* termination of the program. The meanings of other values is dependent on
|
710 |
+
* the environment.
|
711 |
+
*/
|
712 |
+
proc_exit(t) {
|
713 |
+
throw new w(t);
|
714 |
+
}
|
715 |
+
/**
|
716 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
717 |
+
* implementation is unable to immediately provide sufficient high-quality
|
718 |
+
* random data. This function may execute slowly, so when large mounts of
|
719 |
+
* random data are required, it's advisable to use this function to seed a
|
720 |
+
* pseudo-random number generator, rather than to provide the random data
|
721 |
+
* directly.
|
722 |
+
*/
|
723 |
+
random_get(t, i) {
|
724 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
725 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
726 |
+
}
|
727 |
+
/**
|
728 |
+
* Temporarily yield execution of the calling thread.
|
729 |
+
* Note: This is similar to sched_yield in POSIX.
|
730 |
+
*/
|
731 |
+
sched_yield() {
|
732 |
+
return c.SUCCESS;
|
733 |
+
}
|
734 |
+
//
|
735 |
+
// File Descriptors
|
736 |
+
//
|
737 |
+
/**
|
738 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
739 |
+
*/
|
740 |
+
fd_read(t, i, n, l) {
|
741 |
+
if (t === 1 || t === 2)
|
742 |
+
return c.ENOTSUP;
|
743 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
744 |
+
let a = 0, Z = c.SUCCESS;
|
745 |
+
for (const h of d) {
|
746 |
+
let r;
|
747 |
+
if (t === 0) {
|
748 |
+
const R = this.context.stdin(h.byteLength);
|
749 |
+
if (!R)
|
750 |
+
break;
|
751 |
+
r = V.encode(R);
|
752 |
+
} else {
|
753 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
754 |
+
if (R) {
|
755 |
+
Z = R;
|
756 |
+
break;
|
757 |
+
} else
|
758 |
+
r = k;
|
759 |
+
}
|
760 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
761 |
+
h.set(r.subarray(0, o)), a += o;
|
762 |
+
}
|
763 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
764 |
+
}
|
765 |
+
/**
|
766 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
767 |
+
*/
|
768 |
+
fd_write(t, i, n, l) {
|
769 |
+
if (t === 0)
|
770 |
+
return c.ENOTSUP;
|
771 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
772 |
+
let a = 0, Z = c.SUCCESS;
|
773 |
+
for (const h of d)
|
774 |
+
if (h.byteLength !== 0) {
|
775 |
+
if (t === 1 || t === 2) {
|
776 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
777 |
+
r(o), f({ output: o });
|
778 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
779 |
+
break;
|
780 |
+
a += h.byteLength;
|
781 |
+
}
|
782 |
+
return s.setUint32(l, a, !0), Z;
|
783 |
+
}
|
784 |
+
/**
|
785 |
+
* Provide file advisory information on a file descriptor.
|
786 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
787 |
+
*/
|
788 |
+
fd_advise() {
|
789 |
+
return c.SUCCESS;
|
790 |
+
}
|
791 |
+
/**
|
792 |
+
* Force the allocation of space in a file.
|
793 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
794 |
+
*/
|
795 |
+
fd_allocate(t, i, n) {
|
796 |
+
return this.drive.pwrite(
|
797 |
+
t,
|
798 |
+
new Uint8Array(Number(n)),
|
799 |
+
Number(i)
|
800 |
+
);
|
801 |
+
}
|
802 |
+
/**
|
803 |
+
* Close a file descriptor.
|
804 |
+
* Note: This is similar to close in POSIX.
|
805 |
+
*
|
806 |
+
* @param fd
|
807 |
+
*/
|
808 |
+
fd_close(t) {
|
809 |
+
return this.drive.close(t);
|
810 |
+
}
|
811 |
+
/**
|
812 |
+
* Synchronize the data of a file to disk.
|
813 |
+
* Note: This is similar to fdatasync in POSIX.
|
814 |
+
*
|
815 |
+
* @param fd
|
816 |
+
*/
|
817 |
+
fd_datasync(t) {
|
818 |
+
return this.drive.sync(t);
|
819 |
+
}
|
820 |
+
/**
|
821 |
+
* Get the attributes of a file descriptor.
|
822 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
823 |
+
* as well as additional fields.
|
824 |
+
*
|
825 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
826 |
+
* are stored.
|
827 |
+
*
|
828 |
+
* @returns Result<fdstat, errno>
|
829 |
+
*/
|
830 |
+
fd_fdstat_get(t, i) {
|
831 |
+
if (t < 3) {
|
832 |
+
let V;
|
833 |
+
if (this.context.isTTY) {
|
834 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
835 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
836 |
+
} else
|
837 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
838 |
+
return new Uint8Array(
|
839 |
+
this.memory.buffer,
|
840 |
+
i,
|
841 |
+
V.byteLength
|
842 |
+
).set(V), c.SUCCESS;
|
843 |
+
}
|
844 |
+
if (!this.drive.exists(t))
|
845 |
+
return c.EBADF;
|
846 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
847 |
+
return new Uint8Array(
|
848 |
+
this.memory.buffer,
|
849 |
+
i,
|
850 |
+
s.byteLength
|
851 |
+
).set(s), c.SUCCESS;
|
852 |
+
}
|
853 |
+
/**
|
854 |
+
* Adjust the flags associated with a file descriptor.
|
855 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
856 |
+
*/
|
857 |
+
fd_fdstat_set_flags(t, i) {
|
858 |
+
return this.drive.setFlags(t, i);
|
859 |
+
}
|
860 |
+
/**
|
861 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
862 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
863 |
+
* would attempt to add rights
|
864 |
+
*/
|
865 |
+
fd_fdstat_set_rights() {
|
866 |
+
return c.SUCCESS;
|
867 |
+
}
|
868 |
+
/**
|
869 |
+
* Return the attributes of an open file.
|
870 |
+
*/
|
871 |
+
fd_filestat_get(t, i) {
|
872 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
873 |
+
}
|
874 |
+
/**
|
875 |
+
* Return the attributes of an open file.
|
876 |
+
* This version is used
|
877 |
+
*/
|
878 |
+
unstable_fd_filestat_get(t, i) {
|
879 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
880 |
+
}
|
881 |
+
/**
|
882 |
+
* Return the attributes of an open file.
|
883 |
+
*/
|
884 |
+
shared_fd_filestat_get(t, i, n) {
|
885 |
+
const l = n === "unstable" ? A : _;
|
886 |
+
if (t < 3) {
|
887 |
+
let Z;
|
888 |
+
switch (t) {
|
889 |
+
case 0:
|
890 |
+
Z = "/dev/stdin";
|
891 |
+
break;
|
892 |
+
case 1:
|
893 |
+
Z = "/dev/stdout";
|
894 |
+
break;
|
895 |
+
case 2:
|
896 |
+
Z = "/dev/stderr";
|
897 |
+
break;
|
898 |
+
default:
|
899 |
+
Z = "/dev/undefined";
|
900 |
+
break;
|
901 |
+
}
|
902 |
+
const h = l({
|
903 |
+
path: Z,
|
904 |
+
byteLength: 0,
|
905 |
+
timestamps: {
|
906 |
+
access: /* @__PURE__ */ new Date(),
|
907 |
+
modification: /* @__PURE__ */ new Date(),
|
908 |
+
change: /* @__PURE__ */ new Date()
|
909 |
+
},
|
910 |
+
type: X.CHARACTER_DEVICE
|
911 |
+
});
|
912 |
+
return new Uint8Array(
|
913 |
+
this.memory.buffer,
|
914 |
+
i,
|
915 |
+
h.byteLength
|
916 |
+
).set(h), c.SUCCESS;
|
917 |
+
}
|
918 |
+
const [s, d] = this.drive.stat(t);
|
919 |
+
if (s != c.SUCCESS)
|
920 |
+
return s;
|
921 |
+
f({ resolvedPath: d.path, stat: d });
|
922 |
+
const V = l(d);
|
923 |
+
return new Uint8Array(
|
924 |
+
this.memory.buffer,
|
925 |
+
i,
|
926 |
+
V.byteLength
|
927 |
+
).set(V), c.SUCCESS;
|
928 |
+
}
|
929 |
+
/**
|
930 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
931 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
932 |
+
* POSIX.
|
933 |
+
*/
|
934 |
+
fd_filestat_set_size(t, i) {
|
935 |
+
return this.drive.setSize(t, i);
|
936 |
+
}
|
937 |
+
/**
|
938 |
+
* Adjust the timestamps of an open file or directory.
|
939 |
+
* Note: This is similar to futimens in POSIX.
|
940 |
+
*/
|
941 |
+
fd_filestat_set_times(t, i, n, l) {
|
942 |
+
let s = null;
|
943 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
944 |
+
let d = null;
|
945 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
946 |
+
const V = this.drive.setAccessTime(t, s);
|
947 |
+
if (V != c.SUCCESS)
|
948 |
+
return V;
|
949 |
+
}
|
950 |
+
if (d) {
|
951 |
+
const V = this.drive.setModificationTime(t, d);
|
952 |
+
if (V != c.SUCCESS)
|
953 |
+
return V;
|
954 |
+
}
|
955 |
+
return c.SUCCESS;
|
956 |
+
}
|
957 |
+
/**
|
958 |
+
* Read from a file descriptor, without using and updating the file
|
959 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
960 |
+
*/
|
961 |
+
fd_pread(t, i, n, l, s) {
|
962 |
+
if (t === 1 || t === 2)
|
963 |
+
return c.ENOTSUP;
|
964 |
+
if (t === 0)
|
965 |
+
return this.fd_read(t, i, n, s);
|
966 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
967 |
+
let a = 0, Z = c.SUCCESS;
|
968 |
+
for (const h of V) {
|
969 |
+
const [r, o] = this.drive.pread(
|
970 |
+
t,
|
971 |
+
h.byteLength,
|
972 |
+
Number(l) + a
|
973 |
+
);
|
974 |
+
if (r !== c.SUCCESS) {
|
975 |
+
Z = r;
|
976 |
+
break;
|
977 |
+
}
|
978 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
979 |
+
h.set(o.subarray(0, R)), a += R;
|
980 |
+
}
|
981 |
+
return d.setUint32(s, a, !0), Z;
|
982 |
+
}
|
983 |
+
/**
|
984 |
+
* Return a description of the given preopened file descriptor.
|
985 |
+
*/
|
986 |
+
fd_prestat_dir_name(t, i, n) {
|
987 |
+
if (t !== 3)
|
988 |
+
return c.EBADF;
|
989 |
+
const l = new TextEncoder().encode("/");
|
990 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
991 |
+
}
|
992 |
+
/**
|
993 |
+
* Return a description of the given preopened file descriptor.
|
994 |
+
*/
|
995 |
+
fd_prestat_get(t, i) {
|
996 |
+
if (t !== 3)
|
997 |
+
return c.EBADF;
|
998 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
999 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1000 |
+
}
|
1001 |
+
/**
|
1002 |
+
* Write to a file descriptor, without using and updating the file
|
1003 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1004 |
+
*/
|
1005 |
+
fd_pwrite(t, i, n, l, s) {
|
1006 |
+
if (t === 0)
|
1007 |
+
return c.ENOTSUP;
|
1008 |
+
if (t === 1 || t === 2)
|
1009 |
+
return this.fd_write(t, i, n, s);
|
1010 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1011 |
+
let a = 0, Z = c.SUCCESS;
|
1012 |
+
for (const h of V)
|
1013 |
+
if (h.byteLength !== 0) {
|
1014 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1015 |
+
break;
|
1016 |
+
a += h.byteLength;
|
1017 |
+
}
|
1018 |
+
return d.setUint32(s, a, !0), Z;
|
1019 |
+
}
|
1020 |
+
/**
|
1021 |
+
* Read directory entries from a directory. When successful, the contents of
|
1022 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1023 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1024 |
+
* bytes holding the name of the directory entry. This function fills the
|
1025 |
+
* output buffer as much as possible, potentially truncating the last
|
1026 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1027 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1028 |
+
* oversized directory entry.
|
1029 |
+
*/
|
1030 |
+
fd_readdir(t, i, n, l, s) {
|
1031 |
+
const [d, V] = this.drive.list(t);
|
1032 |
+
if (d != c.SUCCESS)
|
1033 |
+
return d;
|
1034 |
+
let a = [], Z = 0;
|
1035 |
+
for (const { name: N, type: F } of V) {
|
1036 |
+
const g = ht(N, F, Z);
|
1037 |
+
a.push(g), Z++;
|
1038 |
+
}
|
1039 |
+
a = a.slice(Number(l));
|
1040 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1041 |
+
let o = 0;
|
1042 |
+
for (const N of a)
|
1043 |
+
r.set(N, o), o += N.byteLength;
|
1044 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1045 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1046 |
+
}
|
1047 |
+
/**
|
1048 |
+
* Atomically replace a file descriptor by renumbering another file
|
1049 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1050 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1051 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1052 |
+
* an actual file descriptor with the same number could be allocated by a
|
1053 |
+
* different thread at the same time. This function provides a way to
|
1054 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1055 |
+
* to be removed entirely.
|
1056 |
+
*/
|
1057 |
+
fd_renumber(t, i) {
|
1058 |
+
return this.drive.renumber(t, i);
|
1059 |
+
}
|
1060 |
+
/**
|
1061 |
+
* Move the offset of a file descriptor.
|
1062 |
+
*
|
1063 |
+
* The offset is specified as a bigint here
|
1064 |
+
* Note: This is similar to lseek in POSIX.
|
1065 |
+
*
|
1066 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1067 |
+
* bigint in JavaScript.
|
1068 |
+
*/
|
1069 |
+
fd_seek(t, i, n, l) {
|
1070 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1071 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1072 |
+
}
|
1073 |
+
unstable_fd_seek(t, i, n, l) {
|
1074 |
+
const s = mt[n];
|
1075 |
+
return this.fd_seek(t, i, s, l);
|
1076 |
+
}
|
1077 |
+
/**
|
1078 |
+
* Synchronize the data and metadata of a file to disk.
|
1079 |
+
* Note: This is similar to fsync in POSIX.
|
1080 |
+
*/
|
1081 |
+
fd_sync(t) {
|
1082 |
+
return this.drive.sync(t);
|
1083 |
+
}
|
1084 |
+
/**
|
1085 |
+
* Return the current offset of a file descriptor.
|
1086 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1087 |
+
*
|
1088 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1089 |
+
*
|
1090 |
+
*/
|
1091 |
+
fd_tell(t, i) {
|
1092 |
+
const [n, l] = this.drive.tell(t);
|
1093 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1094 |
+
}
|
1095 |
+
//
|
1096 |
+
// Paths
|
1097 |
+
//
|
1098 |
+
path_filestat_get(t, i, n, l, s) {
|
1099 |
+
return this.shared_path_filestat_get(
|
1100 |
+
t,
|
1101 |
+
i,
|
1102 |
+
n,
|
1103 |
+
l,
|
1104 |
+
s,
|
1105 |
+
"preview1"
|
1106 |
+
);
|
1107 |
+
}
|
1108 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1109 |
+
return this.shared_path_filestat_get(
|
1110 |
+
t,
|
1111 |
+
i,
|
1112 |
+
n,
|
1113 |
+
l,
|
1114 |
+
s,
|
1115 |
+
"unstable"
|
1116 |
+
);
|
1117 |
+
}
|
1118 |
+
/**
|
1119 |
+
* Return the attributes of a file or directory.
|
1120 |
+
* Note: This is similar to stat in POSIX.
|
1121 |
+
*/
|
1122 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1123 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1124 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1125 |
+
);
|
1126 |
+
f({ path: a });
|
1127 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1128 |
+
if (Z != c.SUCCESS)
|
1129 |
+
return Z;
|
1130 |
+
const r = V(h);
|
1131 |
+
return new Uint8Array(
|
1132 |
+
this.memory.buffer,
|
1133 |
+
s,
|
1134 |
+
r.byteLength
|
1135 |
+
).set(r), Z;
|
1136 |
+
}
|
1137 |
+
/**
|
1138 |
+
* Adjust the timestamps of a file or directory.
|
1139 |
+
* Note: This is similar to utimensat in POSIX.
|
1140 |
+
*/
|
1141 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1142 |
+
let a = null;
|
1143 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1144 |
+
let Z = null;
|
1145 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1146 |
+
const h = new TextDecoder().decode(
|
1147 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1148 |
+
);
|
1149 |
+
if (a) {
|
1150 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1151 |
+
if (r != c.SUCCESS)
|
1152 |
+
return r;
|
1153 |
+
}
|
1154 |
+
if (Z) {
|
1155 |
+
const r = this.drive.pathSetModificationTime(
|
1156 |
+
t,
|
1157 |
+
h,
|
1158 |
+
Z
|
1159 |
+
);
|
1160 |
+
if (r != c.SUCCESS)
|
1161 |
+
return r;
|
1162 |
+
}
|
1163 |
+
return c.SUCCESS;
|
1164 |
+
}
|
1165 |
+
/**
|
1166 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1167 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1168 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1169 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1170 |
+
* descriptor is guaranteed to be less than 2**31.
|
1171 |
+
* Note: This is similar to openat in POSIX.
|
1172 |
+
* @param fd: fd
|
1173 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1174 |
+
* is resolved. Not supported by Runno (symlinks)
|
1175 |
+
* @param path: string The relative path of the file or directory to open,
|
1176 |
+
* relative to the path_open::fd directory.
|
1177 |
+
* @param oflags: oflags The method by which to open the file.
|
1178 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1179 |
+
* descriptor. The implementation is allowed to return
|
1180 |
+
* a file descriptor with fewer rights than specified,
|
1181 |
+
* if and only if those rights do not apply to the type
|
1182 |
+
* of file being opened. The base rights are rights
|
1183 |
+
* that will apply to operations using the file
|
1184 |
+
* descriptor itself, while the inheriting rights are
|
1185 |
+
* rights that apply to file descriptors derived from
|
1186 |
+
* it.
|
1187 |
+
* @param fs_rights_inheriting: rights
|
1188 |
+
* @param fdflags: fdflags
|
1189 |
+
*
|
1190 |
+
*/
|
1191 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1192 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1193 |
+
f({
|
1194 |
+
path: r,
|
1195 |
+
openFlags: {
|
1196 |
+
createFileIfNone: o,
|
1197 |
+
failIfNotDir: R,
|
1198 |
+
failIfFileExists: k,
|
1199 |
+
truncateFile: P
|
1200 |
+
},
|
1201 |
+
fileDescriptorFlags: {
|
1202 |
+
flagAppend: N,
|
1203 |
+
flagDSync: F,
|
1204 |
+
flagNonBlock: g,
|
1205 |
+
flagRSync: et,
|
1206 |
+
flagSync: it
|
1207 |
+
}
|
1208 |
+
});
|
1209 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1210 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1211 |
+
}
|
1212 |
+
/**
|
1213 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1214 |
+
*/
|
1215 |
+
path_rename(t, i, n, l, s, d) {
|
1216 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1217 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1218 |
+
}
|
1219 |
+
/**
|
1220 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1221 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1222 |
+
*/
|
1223 |
+
path_unlink_file(t, i, n) {
|
1224 |
+
const l = I(this.memory, i, n);
|
1225 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1226 |
+
}
|
1227 |
+
/**
|
1228 |
+
* Concurrently poll for the occurrence of a set of events.
|
1229 |
+
*/
|
1230 |
+
poll_oneoff(t, i, n, l) {
|
1231 |
+
for (let d = 0; d < n; d++) {
|
1232 |
+
const V = new Uint8Array(
|
1233 |
+
this.memory.buffer,
|
1234 |
+
t + d * M,
|
1235 |
+
M
|
1236 |
+
), a = Zt(V), Z = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
i + d * x,
|
1239 |
+
x
|
1240 |
+
);
|
1241 |
+
let h = 0, r = c.SUCCESS;
|
1242 |
+
switch (a.type) {
|
1243 |
+
case G.CLOCK:
|
1244 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1245 |
+
;
|
1246 |
+
Z.set(
|
1247 |
+
rt(a.userdata, c.SUCCESS)
|
1248 |
+
);
|
1249 |
+
break;
|
1250 |
+
case G.FD_READ:
|
1251 |
+
if (a.fd < 3)
|
1252 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1253 |
+
else {
|
1254 |
+
const [o, R] = this.drive.stat(a.fd);
|
1255 |
+
r = o, h = R ? R.byteLength : 0;
|
1256 |
+
}
|
1257 |
+
Z.set(
|
1258 |
+
v(
|
1259 |
+
a.userdata,
|
1260 |
+
r,
|
1261 |
+
G.FD_READ,
|
1262 |
+
BigInt(h)
|
1263 |
+
)
|
1264 |
+
);
|
1265 |
+
break;
|
1266 |
+
case G.FD_WRITE:
|
1267 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1268 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1269 |
+
else {
|
1270 |
+
const [o, R] = this.drive.stat(a.fd);
|
1271 |
+
r = o, h = R ? R.byteLength : 0;
|
1272 |
+
}
|
1273 |
+
Z.set(
|
1274 |
+
v(
|
1275 |
+
a.userdata,
|
1276 |
+
r,
|
1277 |
+
G.FD_READ,
|
1278 |
+
BigInt(h)
|
1279 |
+
)
|
1280 |
+
);
|
1281 |
+
break;
|
1282 |
+
}
|
1283 |
+
}
|
1284 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1285 |
+
}
|
1286 |
+
/**
|
1287 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1288 |
+
*/
|
1289 |
+
path_create_directory(t, i, n) {
|
1290 |
+
const l = I(this.memory, i, n);
|
1291 |
+
return this.drive.pathCreateDir(t, l);
|
1292 |
+
}
|
1293 |
+
//
|
1294 |
+
// Unimplemented - these operations are not supported by Runno
|
1295 |
+
//
|
1296 |
+
/**
|
1297 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1298 |
+
*/
|
1299 |
+
path_link() {
|
1300 |
+
return c.ENOSYS;
|
1301 |
+
}
|
1302 |
+
/**
|
1303 |
+
* Read the contents of a symbolic link.
|
1304 |
+
* Note: This is similar to readlinkat in POSIX.
|
1305 |
+
*/
|
1306 |
+
path_readlink() {
|
1307 |
+
return c.ENOSYS;
|
1308 |
+
}
|
1309 |
+
/**
|
1310 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1311 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1312 |
+
*/
|
1313 |
+
path_remove_directory() {
|
1314 |
+
return c.ENOSYS;
|
1315 |
+
}
|
1316 |
+
/**
|
1317 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1318 |
+
*/
|
1319 |
+
path_symlink() {
|
1320 |
+
return c.ENOSYS;
|
1321 |
+
}
|
1322 |
+
/**
|
1323 |
+
* Send a signal to the process of the calling thread.
|
1324 |
+
* Note: This is similar to raise in POSIX.
|
1325 |
+
*/
|
1326 |
+
proc_raise() {
|
1327 |
+
return c.ENOSYS;
|
1328 |
+
}
|
1329 |
+
/**
|
1330 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1331 |
+
*/
|
1332 |
+
sock_accept() {
|
1333 |
+
return c.ENOSYS;
|
1334 |
+
}
|
1335 |
+
/**
|
1336 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1337 |
+
* though it also supports reading the data into multiple buffers in the
|
1338 |
+
* manner of readv.
|
1339 |
+
*/
|
1340 |
+
sock_recv() {
|
1341 |
+
return c.ENOSYS;
|
1342 |
+
}
|
1343 |
+
/**
|
1344 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1345 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1346 |
+
* writev.
|
1347 |
+
*/
|
1348 |
+
sock_send() {
|
1349 |
+
return c.ENOSYS;
|
1350 |
+
}
|
1351 |
+
/**
|
1352 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1353 |
+
* shutdown in POSIX.
|
1354 |
+
*/
|
1355 |
+
sock_shutdown() {
|
1356 |
+
return c.ENOSYS;
|
1357 |
+
}
|
1358 |
+
//
|
1359 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1360 |
+
//
|
1361 |
+
sock_open() {
|
1362 |
+
return c.ENOSYS;
|
1363 |
+
}
|
1364 |
+
sock_listen() {
|
1365 |
+
return c.ENOSYS;
|
1366 |
+
}
|
1367 |
+
sock_connect() {
|
1368 |
+
return c.ENOSYS;
|
1369 |
+
}
|
1370 |
+
sock_setsockopt() {
|
1371 |
+
return c.ENOSYS;
|
1372 |
+
}
|
1373 |
+
sock_bind() {
|
1374 |
+
return c.ENOSYS;
|
1375 |
+
}
|
1376 |
+
sock_getlocaladdr() {
|
1377 |
+
return c.ENOSYS;
|
1378 |
+
}
|
1379 |
+
sock_getpeeraddr() {
|
1380 |
+
return c.ENOSYS;
|
1381 |
+
}
|
1382 |
+
sock_getaddrinfo() {
|
1383 |
+
return c.ENOSYS;
|
1384 |
+
}
|
1385 |
+
}
|
1386 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1387 |
+
class w extends Error {
|
1388 |
+
constructor(i) {
|
1389 |
+
super();
|
1390 |
+
m(this, "code");
|
1391 |
+
this.code = i;
|
1392 |
+
}
|
1393 |
+
}
|
1394 |
+
function I(e, t, i) {
|
1395 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1396 |
+
}
|
1397 |
+
function K(e, t, i) {
|
1398 |
+
let n = Array(i);
|
1399 |
+
for (let l = 0; l < i; l++) {
|
1400 |
+
const s = e.getUint32(t, !0);
|
1401 |
+
t += 4;
|
1402 |
+
const d = e.getUint32(t, !0);
|
1403 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1404 |
+
}
|
1405 |
+
return n;
|
1406 |
+
}
|
1407 |
+
function Zt(e) {
|
1408 |
+
const t = new Uint8Array(8);
|
1409 |
+
t.set(e.subarray(0, 8));
|
1410 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1411 |
+
switch (i) {
|
1412 |
+
case G.FD_READ:
|
1413 |
+
case G.FD_WRITE:
|
1414 |
+
return {
|
1415 |
+
userdata: t,
|
1416 |
+
type: i,
|
1417 |
+
fd: n.getUint32(0, !0)
|
1418 |
+
};
|
1419 |
+
case G.CLOCK:
|
1420 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1421 |
+
return {
|
1422 |
+
userdata: t,
|
1423 |
+
type: i,
|
1424 |
+
id: n.getUint32(0, !0),
|
1425 |
+
timeout: W(a),
|
1426 |
+
precision: W(a + V)
|
1427 |
+
};
|
1428 |
+
}
|
1429 |
+
}
|
1430 |
+
function _(e) {
|
1431 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1432 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1433 |
+
}
|
1434 |
+
function A(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function J(e, t, i) {
|
1439 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1440 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1441 |
+
}
|
1442 |
+
function ht(e, t, i) {
|
1443 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1444 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1445 |
+
}
|
1446 |
+
function rt(e, t) {
|
1447 |
+
const i = new Uint8Array(32);
|
1448 |
+
i.set(e, 0);
|
1449 |
+
const n = new DataView(i.buffer);
|
1450 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1451 |
+
}
|
1452 |
+
function v(e, t, i, n) {
|
1453 |
+
const l = new Uint8Array(32);
|
1454 |
+
l.set(e, 0);
|
1455 |
+
const s = new DataView(l.buffer);
|
1456 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1457 |
+
}
|
1458 |
+
function H(e, t = 0) {
|
1459 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1460 |
+
for (let l = 0, s; l < e.length; l++)
|
1461 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1462 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1463 |
+
}
|
1464 |
+
function L(e) {
|
1465 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1466 |
+
}
|
1467 |
+
function W(e) {
|
1468 |
+
return new Date(Number(e / BigInt(1e6)));
|
1469 |
+
}
|
1470 |
+
const mt = {
|
1471 |
+
[Y.CUR]: y.CUR,
|
1472 |
+
[Y.END]: y.END,
|
1473 |
+
[Y.SET]: y.SET
|
1474 |
+
};
|
1475 |
+
class Xt {
|
1476 |
+
constructor(t) {
|
1477 |
+
m(this, "fs");
|
1478 |
+
m(this, "args");
|
1479 |
+
// Program args (like from a terminal program)
|
1480 |
+
m(this, "env");
|
1481 |
+
// Environment (like a .env file)
|
1482 |
+
m(this, "stdin");
|
1483 |
+
m(this, "stdout");
|
1484 |
+
m(this, "stderr");
|
1485 |
+
m(this, "debug");
|
1486 |
+
m(this, "isTTY");
|
1487 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1488 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1489 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1490 |
+
}
|
1491 |
+
}
|
1492 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NVUFBPUlQiLGVbZS5FQUdBSU49Nl09IkVBR0FJTiIsZVtlLkVBTFJFQURZPTddPSJFQUxSRUFEWSIsZVtlLkVCQURGPThdPSJFQkFERiIsZVtlLkVCQURNU0c9OV09IkVCQURNU0ciLGVbZS5FQlVTWT0xMF09IkVCVVNZIixlW2UuRUNBTkNFTEVEPTExXT0iRUNBTkNFTEVEIixlW2UuRUNISUxEPTEyXT0iRUNISUxEIixlW2UuRUNPTk5BQk9SVEVEPTEzXT0iRUNPTk5BQk9SVEVEIixlW2UuRUNPTk5SRUZVU0VEPTE0XT0iRUNPTk5SRUZVU0VEIixlW2UuRUNPTk5SRVNFVD0xNV09I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GUscy5sZW5ndGgpO3JldHVybiBpLnNldEludDMyKDAsZi5ieXRlTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1493 |
+
function ut() {
|
1494 |
+
let e;
|
1495 |
+
try {
|
1496 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1497 |
+
throw "";
|
1498 |
+
return new Worker(e);
|
1499 |
+
} catch {
|
1500 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1501 |
+
} finally {
|
1502 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1503 |
+
}
|
1504 |
+
}
|
1505 |
+
function ot(e, t) {
|
1506 |
+
e.postMessage(t);
|
1507 |
+
}
|
1508 |
+
class St extends Error {
|
1509 |
+
}
|
1510 |
+
class Gt {
|
1511 |
+
constructor(t, i) {
|
1512 |
+
m(this, "binaryURL");
|
1513 |
+
// 8kb should be big enough
|
1514 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1515 |
+
m(this, "context");
|
1516 |
+
m(this, "result");
|
1517 |
+
m(this, "worker");
|
1518 |
+
m(this, "reject");
|
1519 |
+
this.binaryURL = t, this.context = i;
|
1520 |
+
}
|
1521 |
+
async start() {
|
1522 |
+
if (this.result)
|
1523 |
+
throw new Error("WASIWorker Host can only be started once");
|
1524 |
+
return this.result = new Promise((t, i) => {
|
1525 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1526 |
+
var s, d, V, a, Z, h;
|
1527 |
+
const l = n.data;
|
1528 |
+
switch (l.type) {
|
1529 |
+
case "stdout":
|
1530 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1531 |
+
break;
|
1532 |
+
case "stderr":
|
1533 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1534 |
+
break;
|
1535 |
+
case "debug":
|
1536 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1537 |
+
Z,
|
1538 |
+
l.name,
|
1539 |
+
l.args,
|
1540 |
+
l.ret,
|
1541 |
+
l.data
|
1542 |
+
);
|
1543 |
+
break;
|
1544 |
+
case "result":
|
1545 |
+
t(l.result);
|
1546 |
+
break;
|
1547 |
+
case "crash":
|
1548 |
+
i(l.error);
|
1549 |
+
break;
|
1550 |
+
}
|
1551 |
+
}), ot(this.worker, {
|
1552 |
+
target: "client",
|
1553 |
+
type: "start",
|
1554 |
+
binaryURL: this.binaryURL,
|
1555 |
+
stdinBuffer: this.stdinBuffer,
|
1556 |
+
// Unfortunately can't just splat these because it includes types
|
1557 |
+
// that can't be sent as a message.
|
1558 |
+
args: this.context.args,
|
1559 |
+
env: this.context.env,
|
1560 |
+
fs: this.context.fs,
|
1561 |
+
isTTY: this.context.isTTY
|
1562 |
+
});
|
1563 |
+
}), this.result;
|
1564 |
+
}
|
1565 |
+
kill() {
|
1566 |
+
var t;
|
1567 |
+
if (!this.worker)
|
1568 |
+
throw new Error("WASIWorker has not started");
|
1569 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1570 |
+
}
|
1571 |
+
async pushStdin(t) {
|
1572 |
+
const i = new DataView(this.stdinBuffer);
|
1573 |
+
for (; i.getInt32(0) !== 0; )
|
1574 |
+
await new Promise((s) => setTimeout(s, 0));
|
1575 |
+
const n = new TextEncoder().encode(t);
|
1576 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1577 |
+
}
|
1578 |
+
async pushEOF() {
|
1579 |
+
const t = new DataView(this.stdinBuffer);
|
1580 |
+
for (; t.getInt32(0) !== 0; )
|
1581 |
+
await new Promise((i) => setTimeout(i, 0));
|
1582 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1583 |
+
}
|
1584 |
+
}
|
1585 |
+
export {
|
1586 |
+
q as WASI,
|
1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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i, mm) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
env: mm.env,
|
514 |
+
JS: mm.JS,
|
515 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
516 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
517 |
+
});
|
518 |
+
n.memory = mm.env.memory;
|
519 |
+
return n.init(l), n.start();
|
520 |
+
}
|
521 |
+
init(t) {
|
522 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.memory || this.instance.exports.memory, this.initialized = !0;
|
523 |
+
}
|
524 |
+
start() {
|
525 |
+
if (!this.initialized)
|
526 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
527 |
+
const t = this.instance.exports._start;
|
528 |
+
try {
|
529 |
+
t();
|
530 |
+
} catch (i) {
|
531 |
+
if (i instanceof w)
|
532 |
+
return {
|
533 |
+
exitCode: i.code,
|
534 |
+
fs: this.drive.fs
|
535 |
+
};
|
536 |
+
if (i instanceof WebAssembly.RuntimeError)
|
537 |
+
return {
|
538 |
+
exitCode: 134,
|
539 |
+
fs: this.drive.fs
|
540 |
+
};
|
541 |
+
throw i;
|
542 |
+
}
|
543 |
+
return {
|
544 |
+
instance: this.instance,
|
545 |
+
exitCode: 0,
|
546 |
+
fs: this.drive.fs
|
547 |
+
};
|
548 |
+
}
|
549 |
+
getImports(t, i) {
|
550 |
+
const n = {
|
551 |
+
args_get: this.args_get.bind(this),
|
552 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
553 |
+
clock_res_get: this.clock_res_get.bind(this),
|
554 |
+
clock_time_get: this.clock_time_get.bind(this),
|
555 |
+
environ_get: this.environ_get.bind(this),
|
556 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
557 |
+
proc_exit: this.proc_exit.bind(this),
|
558 |
+
random_get: this.random_get.bind(this),
|
559 |
+
sched_yield: this.sched_yield.bind(this),
|
560 |
+
// File Descriptors
|
561 |
+
fd_advise: this.fd_advise.bind(this),
|
562 |
+
fd_allocate: this.fd_allocate.bind(this),
|
563 |
+
fd_close: this.fd_close.bind(this),
|
564 |
+
fd_datasync: this.fd_datasync.bind(this),
|
565 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
566 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
567 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
568 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
569 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
570 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
571 |
+
fd_pread: this.fd_pread.bind(this),
|
572 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
573 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
574 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
575 |
+
fd_read: this.fd_read.bind(this),
|
576 |
+
fd_readdir: this.fd_readdir.bind(this),
|
577 |
+
fd_renumber: this.fd_renumber.bind(this),
|
578 |
+
fd_seek: this.fd_seek.bind(this),
|
579 |
+
fd_sync: this.fd_sync.bind(this),
|
580 |
+
fd_tell: this.fd_tell.bind(this),
|
581 |
+
fd_write: this.fd_write.bind(this),
|
582 |
+
// Paths
|
583 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
584 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
585 |
+
path_open: this.path_open.bind(this),
|
586 |
+
path_rename: this.path_rename.bind(this),
|
587 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
588 |
+
path_create_directory: this.path_create_directory.bind(this),
|
589 |
+
// Unimplemented
|
590 |
+
path_link: this.path_link.bind(this),
|
591 |
+
path_readlink: this.path_readlink.bind(this),
|
592 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
593 |
+
path_symlink: this.path_symlink.bind(this),
|
594 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
595 |
+
proc_raise: this.proc_raise.bind(this),
|
596 |
+
sock_accept: this.sock_accept.bind(this),
|
597 |
+
sock_recv: this.sock_recv.bind(this),
|
598 |
+
sock_send: this.sock_send.bind(this),
|
599 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
600 |
+
// Unimplemented - WASMEdge compatibility
|
601 |
+
sock_open: this.sock_open.bind(this),
|
602 |
+
sock_listen: this.sock_listen.bind(this),
|
603 |
+
sock_connect: this.sock_connect.bind(this),
|
604 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
605 |
+
sock_bind: this.sock_bind.bind(this),
|
606 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
607 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
608 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
609 |
+
};
|
610 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
611 |
+
for (const [l, s] of Object.entries(n))
|
612 |
+
n[l] = function() {
|
613 |
+
let d = s.apply(this, arguments);
|
614 |
+
if (i) {
|
615 |
+
const V = Vt();
|
616 |
+
d = i(l, [...arguments], d, V) ?? d;
|
617 |
+
}
|
618 |
+
return d;
|
619 |
+
};
|
620 |
+
return n;
|
621 |
+
}
|
622 |
+
//
|
623 |
+
// Helpers
|
624 |
+
//
|
625 |
+
get envArray() {
|
626 |
+
return Object.entries(this.context.env).map(
|
627 |
+
([t, i]) => `${t}=${i}`
|
628 |
+
);
|
629 |
+
}
|
630 |
+
//
|
631 |
+
// WASI Implementation
|
632 |
+
//
|
633 |
+
/**
|
634 |
+
* Read command-line argument data. The size of the array should match that
|
635 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
636 |
+
*/
|
637 |
+
args_get(t, i) {
|
638 |
+
const n = new DataView(this.memory.buffer);
|
639 |
+
for (const l of this.context.args) {
|
640 |
+
n.setUint32(t, i, !0), t += 4;
|
641 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
642 |
+
new Uint8Array(
|
643 |
+
this.memory.buffer,
|
644 |
+
i,
|
645 |
+
s.byteLength
|
646 |
+
).set(s), i += s.byteLength;
|
647 |
+
}
|
648 |
+
return c.SUCCESS;
|
649 |
+
}
|
650 |
+
/**
|
651 |
+
* Return command-line argument data sizes.
|
652 |
+
*/
|
653 |
+
args_sizes_get(t, i) {
|
654 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
655 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
656 |
+
}
|
657 |
+
/**
|
658 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
659 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
660 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
661 |
+
*/
|
662 |
+
clock_res_get(t, i) {
|
663 |
+
switch (t) {
|
664 |
+
case p.REALTIME:
|
665 |
+
case p.MONOTONIC:
|
666 |
+
case p.PROCESS_CPUTIME_ID:
|
667 |
+
case p.THREAD_CPUTIME_ID:
|
668 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
669 |
+
}
|
670 |
+
return c.EINVAL;
|
671 |
+
}
|
672 |
+
/**
|
673 |
+
* Return the time value of a clock.
|
674 |
+
* Note: This is similar to clock_gettime in POSIX.
|
675 |
+
*/
|
676 |
+
clock_time_get(t, i, n) {
|
677 |
+
switch (t) {
|
678 |
+
case p.REALTIME:
|
679 |
+
case p.MONOTONIC:
|
680 |
+
case p.PROCESS_CPUTIME_ID:
|
681 |
+
case p.THREAD_CPUTIME_ID:
|
682 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
683 |
+
}
|
684 |
+
return c.EINVAL;
|
685 |
+
}
|
686 |
+
/**
|
687 |
+
* Read environment variable data. The sizes of the buffers should match that
|
688 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
689 |
+
* with =s, and terminated with \0s.
|
690 |
+
*/
|
691 |
+
environ_get(t, i) {
|
692 |
+
const n = new DataView(this.memory.buffer);
|
693 |
+
for (const l of this.envArray) {
|
694 |
+
n.setUint32(t, i, !0), t += 4;
|
695 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
696 |
+
new Uint8Array(
|
697 |
+
this.memory.buffer,
|
698 |
+
i,
|
699 |
+
s.byteLength
|
700 |
+
).set(s), i += s.byteLength;
|
701 |
+
}
|
702 |
+
return c.SUCCESS;
|
703 |
+
}
|
704 |
+
/**
|
705 |
+
* Return environment variable data sizes.
|
706 |
+
*/
|
707 |
+
environ_sizes_get(t, i) {
|
708 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
709 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
710 |
+
}
|
711 |
+
/**
|
712 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
713 |
+
* termination of the program. The meanings of other values is dependent on
|
714 |
+
* the environment.
|
715 |
+
*/
|
716 |
+
proc_exit(t) {
|
717 |
+
throw new w(t);
|
718 |
+
}
|
719 |
+
/**
|
720 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
721 |
+
* implementation is unable to immediately provide sufficient high-quality
|
722 |
+
* random data. This function may execute slowly, so when large mounts of
|
723 |
+
* random data are required, it's advisable to use this function to seed a
|
724 |
+
* pseudo-random number generator, rather than to provide the random data
|
725 |
+
* directly.
|
726 |
+
*/
|
727 |
+
random_get(t, i) {
|
728 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
729 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
730 |
+
}
|
731 |
+
/**
|
732 |
+
* Temporarily yield execution of the calling thread.
|
733 |
+
* Note: This is similar to sched_yield in POSIX.
|
734 |
+
*/
|
735 |
+
sched_yield() {
|
736 |
+
return c.SUCCESS;
|
737 |
+
}
|
738 |
+
//
|
739 |
+
// File Descriptors
|
740 |
+
//
|
741 |
+
/**
|
742 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
743 |
+
*/
|
744 |
+
fd_read(t, i, n, l) {
|
745 |
+
if (t === 1 || t === 2)
|
746 |
+
return c.ENOTSUP;
|
747 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
748 |
+
let a = 0, Z = c.SUCCESS;
|
749 |
+
for (const h of d) {
|
750 |
+
let r;
|
751 |
+
if (t === 0) {
|
752 |
+
const R = this.context.stdin(h.byteLength);
|
753 |
+
if (!R)
|
754 |
+
break;
|
755 |
+
r = V.encode(R);
|
756 |
+
} else {
|
757 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
758 |
+
if (R) {
|
759 |
+
Z = R;
|
760 |
+
break;
|
761 |
+
} else
|
762 |
+
r = k;
|
763 |
+
}
|
764 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
765 |
+
h.set(r.subarray(0, o)), a += o;
|
766 |
+
}
|
767 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
768 |
+
}
|
769 |
+
/**
|
770 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
771 |
+
*/
|
772 |
+
fd_write(t, i, n, l) {
|
773 |
+
if (t === 0)
|
774 |
+
return c.ENOTSUP;
|
775 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
776 |
+
let a = 0, Z = c.SUCCESS;
|
777 |
+
for (const h of d)
|
778 |
+
if (h.byteLength !== 0) {
|
779 |
+
if (t === 1 || t === 2) {
|
780 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
781 |
+
r(o), f({ output: o });
|
782 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
783 |
+
break;
|
784 |
+
a += h.byteLength;
|
785 |
+
}
|
786 |
+
return s.setUint32(l, a, !0), Z;
|
787 |
+
}
|
788 |
+
/**
|
789 |
+
* Provide file advisory information on a file descriptor.
|
790 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
791 |
+
*/
|
792 |
+
fd_advise() {
|
793 |
+
return c.SUCCESS;
|
794 |
+
}
|
795 |
+
/**
|
796 |
+
* Force the allocation of space in a file.
|
797 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
798 |
+
*/
|
799 |
+
fd_allocate(t, i, n) {
|
800 |
+
return this.drive.pwrite(
|
801 |
+
t,
|
802 |
+
new Uint8Array(Number(n)),
|
803 |
+
Number(i)
|
804 |
+
);
|
805 |
+
}
|
806 |
+
/**
|
807 |
+
* Close a file descriptor.
|
808 |
+
* Note: This is similar to close in POSIX.
|
809 |
+
*
|
810 |
+
* @param fd
|
811 |
+
*/
|
812 |
+
fd_close(t) {
|
813 |
+
return this.drive.close(t);
|
814 |
+
}
|
815 |
+
/**
|
816 |
+
* Synchronize the data of a file to disk.
|
817 |
+
* Note: This is similar to fdatasync in POSIX.
|
818 |
+
*
|
819 |
+
* @param fd
|
820 |
+
*/
|
821 |
+
fd_datasync(t) {
|
822 |
+
return this.drive.sync(t);
|
823 |
+
}
|
824 |
+
/**
|
825 |
+
* Get the attributes of a file descriptor.
|
826 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
827 |
+
* as well as additional fields.
|
828 |
+
*
|
829 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
830 |
+
* are stored.
|
831 |
+
*
|
832 |
+
* @returns Result<fdstat, errno>
|
833 |
+
*/
|
834 |
+
fd_fdstat_get(t, i) {
|
835 |
+
if (t < 3) {
|
836 |
+
let V;
|
837 |
+
if (this.context.isTTY) {
|
838 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
839 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
840 |
+
} else
|
841 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
842 |
+
return new Uint8Array(
|
843 |
+
this.memory.buffer,
|
844 |
+
i,
|
845 |
+
V.byteLength
|
846 |
+
).set(V), c.SUCCESS;
|
847 |
+
}
|
848 |
+
if (!this.drive.exists(t))
|
849 |
+
return c.EBADF;
|
850 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
851 |
+
return new Uint8Array(
|
852 |
+
this.memory.buffer,
|
853 |
+
i,
|
854 |
+
s.byteLength
|
855 |
+
).set(s), c.SUCCESS;
|
856 |
+
}
|
857 |
+
/**
|
858 |
+
* Adjust the flags associated with a file descriptor.
|
859 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
860 |
+
*/
|
861 |
+
fd_fdstat_set_flags(t, i) {
|
862 |
+
return this.drive.setFlags(t, i);
|
863 |
+
}
|
864 |
+
/**
|
865 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
866 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
867 |
+
* would attempt to add rights
|
868 |
+
*/
|
869 |
+
fd_fdstat_set_rights() {
|
870 |
+
return c.SUCCESS;
|
871 |
+
}
|
872 |
+
/**
|
873 |
+
* Return the attributes of an open file.
|
874 |
+
*/
|
875 |
+
fd_filestat_get(t, i) {
|
876 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
877 |
+
}
|
878 |
+
/**
|
879 |
+
* Return the attributes of an open file.
|
880 |
+
* This version is used
|
881 |
+
*/
|
882 |
+
unstable_fd_filestat_get(t, i) {
|
883 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
884 |
+
}
|
885 |
+
/**
|
886 |
+
* Return the attributes of an open file.
|
887 |
+
*/
|
888 |
+
shared_fd_filestat_get(t, i, n) {
|
889 |
+
const l = n === "unstable" ? A : _;
|
890 |
+
if (t < 3) {
|
891 |
+
let Z;
|
892 |
+
switch (t) {
|
893 |
+
case 0:
|
894 |
+
Z = "/dev/stdin";
|
895 |
+
break;
|
896 |
+
case 1:
|
897 |
+
Z = "/dev/stdout";
|
898 |
+
break;
|
899 |
+
case 2:
|
900 |
+
Z = "/dev/stderr";
|
901 |
+
break;
|
902 |
+
default:
|
903 |
+
Z = "/dev/undefined";
|
904 |
+
break;
|
905 |
+
}
|
906 |
+
const h = l({
|
907 |
+
path: Z,
|
908 |
+
byteLength: 0,
|
909 |
+
timestamps: {
|
910 |
+
access: /* @__PURE__ */ new Date(),
|
911 |
+
modification: /* @__PURE__ */ new Date(),
|
912 |
+
change: /* @__PURE__ */ new Date()
|
913 |
+
},
|
914 |
+
type: X.CHARACTER_DEVICE
|
915 |
+
});
|
916 |
+
return new Uint8Array(
|
917 |
+
this.memory.buffer,
|
918 |
+
i,
|
919 |
+
h.byteLength
|
920 |
+
).set(h), c.SUCCESS;
|
921 |
+
}
|
922 |
+
const [s, d] = this.drive.stat(t);
|
923 |
+
if (s != c.SUCCESS)
|
924 |
+
return s;
|
925 |
+
f({ resolvedPath: d.path, stat: d });
|
926 |
+
const V = l(d);
|
927 |
+
return new Uint8Array(
|
928 |
+
this.memory.buffer,
|
929 |
+
i,
|
930 |
+
V.byteLength
|
931 |
+
).set(V), c.SUCCESS;
|
932 |
+
}
|
933 |
+
/**
|
934 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
935 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
936 |
+
* POSIX.
|
937 |
+
*/
|
938 |
+
fd_filestat_set_size(t, i) {
|
939 |
+
return this.drive.setSize(t, i);
|
940 |
+
}
|
941 |
+
/**
|
942 |
+
* Adjust the timestamps of an open file or directory.
|
943 |
+
* Note: This is similar to futimens in POSIX.
|
944 |
+
*/
|
945 |
+
fd_filestat_set_times(t, i, n, l) {
|
946 |
+
let s = null;
|
947 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
948 |
+
let d = null;
|
949 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
950 |
+
const V = this.drive.setAccessTime(t, s);
|
951 |
+
if (V != c.SUCCESS)
|
952 |
+
return V;
|
953 |
+
}
|
954 |
+
if (d) {
|
955 |
+
const V = this.drive.setModificationTime(t, d);
|
956 |
+
if (V != c.SUCCESS)
|
957 |
+
return V;
|
958 |
+
}
|
959 |
+
return c.SUCCESS;
|
960 |
+
}
|
961 |
+
/**
|
962 |
+
* Read from a file descriptor, without using and updating the file
|
963 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
964 |
+
*/
|
965 |
+
fd_pread(t, i, n, l, s) {
|
966 |
+
if (t === 1 || t === 2)
|
967 |
+
return c.ENOTSUP;
|
968 |
+
if (t === 0)
|
969 |
+
return this.fd_read(t, i, n, s);
|
970 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
971 |
+
let a = 0, Z = c.SUCCESS;
|
972 |
+
for (const h of V) {
|
973 |
+
const [r, o] = this.drive.pread(
|
974 |
+
t,
|
975 |
+
h.byteLength,
|
976 |
+
Number(l) + a
|
977 |
+
);
|
978 |
+
if (r !== c.SUCCESS) {
|
979 |
+
Z = r;
|
980 |
+
break;
|
981 |
+
}
|
982 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
983 |
+
h.set(o.subarray(0, R)), a += R;
|
984 |
+
}
|
985 |
+
return d.setUint32(s, a, !0), Z;
|
986 |
+
}
|
987 |
+
/**
|
988 |
+
* Return a description of the given preopened file descriptor.
|
989 |
+
*/
|
990 |
+
fd_prestat_dir_name(t, i, n) {
|
991 |
+
if (t !== 3)
|
992 |
+
return c.EBADF;
|
993 |
+
const l = new TextEncoder().encode("/");
|
994 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
995 |
+
}
|
996 |
+
/**
|
997 |
+
* Return a description of the given preopened file descriptor.
|
998 |
+
*/
|
999 |
+
fd_prestat_get(t, i) {
|
1000 |
+
if (t !== 3)
|
1001 |
+
return c.EBADF;
|
1002 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
1003 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1004 |
+
}
|
1005 |
+
/**
|
1006 |
+
* Write to a file descriptor, without using and updating the file
|
1007 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1008 |
+
*/
|
1009 |
+
fd_pwrite(t, i, n, l, s) {
|
1010 |
+
if (t === 0)
|
1011 |
+
return c.ENOTSUP;
|
1012 |
+
if (t === 1 || t === 2)
|
1013 |
+
return this.fd_write(t, i, n, s);
|
1014 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1015 |
+
let a = 0, Z = c.SUCCESS;
|
1016 |
+
for (const h of V)
|
1017 |
+
if (h.byteLength !== 0) {
|
1018 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1019 |
+
break;
|
1020 |
+
a += h.byteLength;
|
1021 |
+
}
|
1022 |
+
return d.setUint32(s, a, !0), Z;
|
1023 |
+
}
|
1024 |
+
/**
|
1025 |
+
* Read directory entries from a directory. When successful, the contents of
|
1026 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1027 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1028 |
+
* bytes holding the name of the directory entry. This function fills the
|
1029 |
+
* output buffer as much as possible, potentially truncating the last
|
1030 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1031 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1032 |
+
* oversized directory entry.
|
1033 |
+
*/
|
1034 |
+
fd_readdir(t, i, n, l, s) {
|
1035 |
+
const [d, V] = this.drive.list(t);
|
1036 |
+
if (d != c.SUCCESS)
|
1037 |
+
return d;
|
1038 |
+
let a = [], Z = 0;
|
1039 |
+
for (const { name: N, type: F } of V) {
|
1040 |
+
const g = ht(N, F, Z);
|
1041 |
+
a.push(g), Z++;
|
1042 |
+
}
|
1043 |
+
a = a.slice(Number(l));
|
1044 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1045 |
+
let o = 0;
|
1046 |
+
for (const N of a)
|
1047 |
+
r.set(N, o), o += N.byteLength;
|
1048 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1049 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1050 |
+
}
|
1051 |
+
/**
|
1052 |
+
* Atomically replace a file descriptor by renumbering another file
|
1053 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1054 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1055 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1056 |
+
* an actual file descriptor with the same number could be allocated by a
|
1057 |
+
* different thread at the same time. This function provides a way to
|
1058 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1059 |
+
* to be removed entirely.
|
1060 |
+
*/
|
1061 |
+
fd_renumber(t, i) {
|
1062 |
+
return this.drive.renumber(t, i);
|
1063 |
+
}
|
1064 |
+
/**
|
1065 |
+
* Move the offset of a file descriptor.
|
1066 |
+
*
|
1067 |
+
* The offset is specified as a bigint here
|
1068 |
+
* Note: This is similar to lseek in POSIX.
|
1069 |
+
*
|
1070 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1071 |
+
* bigint in JavaScript.
|
1072 |
+
*/
|
1073 |
+
fd_seek(t, i, n, l) {
|
1074 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1075 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1076 |
+
}
|
1077 |
+
unstable_fd_seek(t, i, n, l) {
|
1078 |
+
const s = mt[n];
|
1079 |
+
return this.fd_seek(t, i, s, l);
|
1080 |
+
}
|
1081 |
+
/**
|
1082 |
+
* Synchronize the data and metadata of a file to disk.
|
1083 |
+
* Note: This is similar to fsync in POSIX.
|
1084 |
+
*/
|
1085 |
+
fd_sync(t) {
|
1086 |
+
return this.drive.sync(t);
|
1087 |
+
}
|
1088 |
+
/**
|
1089 |
+
* Return the current offset of a file descriptor.
|
1090 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1091 |
+
*
|
1092 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1093 |
+
*
|
1094 |
+
*/
|
1095 |
+
fd_tell(t, i) {
|
1096 |
+
const [n, l] = this.drive.tell(t);
|
1097 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1098 |
+
}
|
1099 |
+
//
|
1100 |
+
// Paths
|
1101 |
+
//
|
1102 |
+
path_filestat_get(t, i, n, l, s) {
|
1103 |
+
return this.shared_path_filestat_get(
|
1104 |
+
t,
|
1105 |
+
i,
|
1106 |
+
n,
|
1107 |
+
l,
|
1108 |
+
s,
|
1109 |
+
"preview1"
|
1110 |
+
);
|
1111 |
+
}
|
1112 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1113 |
+
return this.shared_path_filestat_get(
|
1114 |
+
t,
|
1115 |
+
i,
|
1116 |
+
n,
|
1117 |
+
l,
|
1118 |
+
s,
|
1119 |
+
"unstable"
|
1120 |
+
);
|
1121 |
+
}
|
1122 |
+
/**
|
1123 |
+
* Return the attributes of a file or directory.
|
1124 |
+
* Note: This is similar to stat in POSIX.
|
1125 |
+
*/
|
1126 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1127 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1128 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1129 |
+
);
|
1130 |
+
f({ path: a });
|
1131 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1132 |
+
if (Z != c.SUCCESS)
|
1133 |
+
return Z;
|
1134 |
+
const r = V(h);
|
1135 |
+
return new Uint8Array(
|
1136 |
+
this.memory.buffer,
|
1137 |
+
s,
|
1138 |
+
r.byteLength
|
1139 |
+
).set(r), Z;
|
1140 |
+
}
|
1141 |
+
/**
|
1142 |
+
* Adjust the timestamps of a file or directory.
|
1143 |
+
* Note: This is similar to utimensat in POSIX.
|
1144 |
+
*/
|
1145 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1146 |
+
let a = null;
|
1147 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1148 |
+
let Z = null;
|
1149 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1150 |
+
const h = new TextDecoder().decode(
|
1151 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1152 |
+
);
|
1153 |
+
if (a) {
|
1154 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1155 |
+
if (r != c.SUCCESS)
|
1156 |
+
return r;
|
1157 |
+
}
|
1158 |
+
if (Z) {
|
1159 |
+
const r = this.drive.pathSetModificationTime(
|
1160 |
+
t,
|
1161 |
+
h,
|
1162 |
+
Z
|
1163 |
+
);
|
1164 |
+
if (r != c.SUCCESS)
|
1165 |
+
return r;
|
1166 |
+
}
|
1167 |
+
return c.SUCCESS;
|
1168 |
+
}
|
1169 |
+
/**
|
1170 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1171 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1172 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1173 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1174 |
+
* descriptor is guaranteed to be less than 2**31.
|
1175 |
+
* Note: This is similar to openat in POSIX.
|
1176 |
+
* @param fd: fd
|
1177 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1178 |
+
* is resolved. Not supported by Runno (symlinks)
|
1179 |
+
* @param path: string The relative path of the file or directory to open,
|
1180 |
+
* relative to the path_open::fd directory.
|
1181 |
+
* @param oflags: oflags The method by which to open the file.
|
1182 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1183 |
+
* descriptor. The implementation is allowed to return
|
1184 |
+
* a file descriptor with fewer rights than specified,
|
1185 |
+
* if and only if those rights do not apply to the type
|
1186 |
+
* of file being opened. The base rights are rights
|
1187 |
+
* that will apply to operations using the file
|
1188 |
+
* descriptor itself, while the inheriting rights are
|
1189 |
+
* rights that apply to file descriptors derived from
|
1190 |
+
* it.
|
1191 |
+
* @param fs_rights_inheriting: rights
|
1192 |
+
* @param fdflags: fdflags
|
1193 |
+
*
|
1194 |
+
*/
|
1195 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1196 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1197 |
+
f({
|
1198 |
+
path: r,
|
1199 |
+
openFlags: {
|
1200 |
+
createFileIfNone: o,
|
1201 |
+
failIfNotDir: R,
|
1202 |
+
failIfFileExists: k,
|
1203 |
+
truncateFile: P
|
1204 |
+
},
|
1205 |
+
fileDescriptorFlags: {
|
1206 |
+
flagAppend: N,
|
1207 |
+
flagDSync: F,
|
1208 |
+
flagNonBlock: g,
|
1209 |
+
flagRSync: et,
|
1210 |
+
flagSync: it
|
1211 |
+
}
|
1212 |
+
});
|
1213 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1214 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1215 |
+
}
|
1216 |
+
/**
|
1217 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1218 |
+
*/
|
1219 |
+
path_rename(t, i, n, l, s, d) {
|
1220 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1221 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1222 |
+
}
|
1223 |
+
/**
|
1224 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1225 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1226 |
+
*/
|
1227 |
+
path_unlink_file(t, i, n) {
|
1228 |
+
const l = I(this.memory, i, n);
|
1229 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1230 |
+
}
|
1231 |
+
/**
|
1232 |
+
* Concurrently poll for the occurrence of a set of events.
|
1233 |
+
*/
|
1234 |
+
poll_oneoff(t, i, n, l) {
|
1235 |
+
for (let d = 0; d < n; d++) {
|
1236 |
+
const V = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
t + d * M,
|
1239 |
+
M
|
1240 |
+
), a = Zt(V), Z = new Uint8Array(
|
1241 |
+
this.memory.buffer,
|
1242 |
+
i + d * x,
|
1243 |
+
x
|
1244 |
+
);
|
1245 |
+
let h = 0, r = c.SUCCESS;
|
1246 |
+
switch (a.type) {
|
1247 |
+
case G.CLOCK:
|
1248 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1249 |
+
;
|
1250 |
+
Z.set(
|
1251 |
+
rt(a.userdata, c.SUCCESS)
|
1252 |
+
);
|
1253 |
+
break;
|
1254 |
+
case G.FD_READ:
|
1255 |
+
if (a.fd < 3)
|
1256 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1257 |
+
else {
|
1258 |
+
const [o, R] = this.drive.stat(a.fd);
|
1259 |
+
r = o, h = R ? R.byteLength : 0;
|
1260 |
+
}
|
1261 |
+
Z.set(
|
1262 |
+
v(
|
1263 |
+
a.userdata,
|
1264 |
+
r,
|
1265 |
+
G.FD_READ,
|
1266 |
+
BigInt(h)
|
1267 |
+
)
|
1268 |
+
);
|
1269 |
+
break;
|
1270 |
+
case G.FD_WRITE:
|
1271 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1272 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1273 |
+
else {
|
1274 |
+
const [o, R] = this.drive.stat(a.fd);
|
1275 |
+
r = o, h = R ? R.byteLength : 0;
|
1276 |
+
}
|
1277 |
+
Z.set(
|
1278 |
+
v(
|
1279 |
+
a.userdata,
|
1280 |
+
r,
|
1281 |
+
G.FD_READ,
|
1282 |
+
BigInt(h)
|
1283 |
+
)
|
1284 |
+
);
|
1285 |
+
break;
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1289 |
+
}
|
1290 |
+
/**
|
1291 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1292 |
+
*/
|
1293 |
+
path_create_directory(t, i, n) {
|
1294 |
+
const l = I(this.memory, i, n);
|
1295 |
+
return this.drive.pathCreateDir(t, l);
|
1296 |
+
}
|
1297 |
+
//
|
1298 |
+
// Unimplemented - these operations are not supported by Runno
|
1299 |
+
//
|
1300 |
+
/**
|
1301 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1302 |
+
*/
|
1303 |
+
path_link() {
|
1304 |
+
return c.ENOSYS;
|
1305 |
+
}
|
1306 |
+
/**
|
1307 |
+
* Read the contents of a symbolic link.
|
1308 |
+
* Note: This is similar to readlinkat in POSIX.
|
1309 |
+
*/
|
1310 |
+
path_readlink() {
|
1311 |
+
return c.ENOSYS;
|
1312 |
+
}
|
1313 |
+
/**
|
1314 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1315 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1316 |
+
*/
|
1317 |
+
path_remove_directory() {
|
1318 |
+
return c.ENOSYS;
|
1319 |
+
}
|
1320 |
+
/**
|
1321 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1322 |
+
*/
|
1323 |
+
path_symlink() {
|
1324 |
+
return c.ENOSYS;
|
1325 |
+
}
|
1326 |
+
/**
|
1327 |
+
* Send a signal to the process of the calling thread.
|
1328 |
+
* Note: This is similar to raise in POSIX.
|
1329 |
+
*/
|
1330 |
+
proc_raise() {
|
1331 |
+
return c.ENOSYS;
|
1332 |
+
}
|
1333 |
+
/**
|
1334 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1335 |
+
*/
|
1336 |
+
sock_accept() {
|
1337 |
+
return c.ENOSYS;
|
1338 |
+
}
|
1339 |
+
/**
|
1340 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1341 |
+
* though it also supports reading the data into multiple buffers in the
|
1342 |
+
* manner of readv.
|
1343 |
+
*/
|
1344 |
+
sock_recv() {
|
1345 |
+
return c.ENOSYS;
|
1346 |
+
}
|
1347 |
+
/**
|
1348 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1349 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1350 |
+
* writev.
|
1351 |
+
*/
|
1352 |
+
sock_send() {
|
1353 |
+
return c.ENOSYS;
|
1354 |
+
}
|
1355 |
+
/**
|
1356 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1357 |
+
* shutdown in POSIX.
|
1358 |
+
*/
|
1359 |
+
sock_shutdown() {
|
1360 |
+
return c.ENOSYS;
|
1361 |
+
}
|
1362 |
+
//
|
1363 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1364 |
+
//
|
1365 |
+
sock_open() {
|
1366 |
+
return c.ENOSYS;
|
1367 |
+
}
|
1368 |
+
sock_listen() {
|
1369 |
+
return c.ENOSYS;
|
1370 |
+
}
|
1371 |
+
sock_connect() {
|
1372 |
+
return c.ENOSYS;
|
1373 |
+
}
|
1374 |
+
sock_setsockopt() {
|
1375 |
+
return c.ENOSYS;
|
1376 |
+
}
|
1377 |
+
sock_bind() {
|
1378 |
+
return c.ENOSYS;
|
1379 |
+
}
|
1380 |
+
sock_getlocaladdr() {
|
1381 |
+
return c.ENOSYS;
|
1382 |
+
}
|
1383 |
+
sock_getpeeraddr() {
|
1384 |
+
return c.ENOSYS;
|
1385 |
+
}
|
1386 |
+
sock_getaddrinfo() {
|
1387 |
+
return c.ENOSYS;
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1391 |
+
class w extends Error {
|
1392 |
+
constructor(i) {
|
1393 |
+
super();
|
1394 |
+
m(this, "code");
|
1395 |
+
this.code = i;
|
1396 |
+
}
|
1397 |
+
}
|
1398 |
+
function I(e, t, i) {
|
1399 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1400 |
+
}
|
1401 |
+
function K(e, t, i) {
|
1402 |
+
let n = Array(i);
|
1403 |
+
for (let l = 0; l < i; l++) {
|
1404 |
+
const s = e.getUint32(t, !0);
|
1405 |
+
t += 4;
|
1406 |
+
const d = e.getUint32(t, !0);
|
1407 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1408 |
+
}
|
1409 |
+
return n;
|
1410 |
+
}
|
1411 |
+
function Zt(e) {
|
1412 |
+
const t = new Uint8Array(8);
|
1413 |
+
t.set(e.subarray(0, 8));
|
1414 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1415 |
+
switch (i) {
|
1416 |
+
case G.FD_READ:
|
1417 |
+
case G.FD_WRITE:
|
1418 |
+
return {
|
1419 |
+
userdata: t,
|
1420 |
+
type: i,
|
1421 |
+
fd: n.getUint32(0, !0)
|
1422 |
+
};
|
1423 |
+
case G.CLOCK:
|
1424 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1425 |
+
return {
|
1426 |
+
userdata: t,
|
1427 |
+
type: i,
|
1428 |
+
id: n.getUint32(0, !0),
|
1429 |
+
timeout: W(a),
|
1430 |
+
precision: W(a + V)
|
1431 |
+
};
|
1432 |
+
}
|
1433 |
+
}
|
1434 |
+
function _(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function A(e) {
|
1439 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1440 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1441 |
+
}
|
1442 |
+
function J(e, t, i) {
|
1443 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1444 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1445 |
+
}
|
1446 |
+
function ht(e, t, i) {
|
1447 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1448 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1449 |
+
}
|
1450 |
+
function rt(e, t) {
|
1451 |
+
const i = new Uint8Array(32);
|
1452 |
+
i.set(e, 0);
|
1453 |
+
const n = new DataView(i.buffer);
|
1454 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1455 |
+
}
|
1456 |
+
function v(e, t, i, n) {
|
1457 |
+
const l = new Uint8Array(32);
|
1458 |
+
l.set(e, 0);
|
1459 |
+
const s = new DataView(l.buffer);
|
1460 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1461 |
+
}
|
1462 |
+
function H(e, t = 0) {
|
1463 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1464 |
+
for (let l = 0, s; l < e.length; l++)
|
1465 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1466 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1467 |
+
}
|
1468 |
+
function L(e) {
|
1469 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1470 |
+
}
|
1471 |
+
function W(e) {
|
1472 |
+
return new Date(Number(e / BigInt(1e6)));
|
1473 |
+
}
|
1474 |
+
const mt = {
|
1475 |
+
[Y.CUR]: y.CUR,
|
1476 |
+
[Y.END]: y.END,
|
1477 |
+
[Y.SET]: y.SET
|
1478 |
+
};
|
1479 |
+
class Xt {
|
1480 |
+
constructor(t) {
|
1481 |
+
m(this, "fs");
|
1482 |
+
m(this, "args");
|
1483 |
+
// Program args (like from a terminal program)
|
1484 |
+
m(this, "env");
|
1485 |
+
// Environment (like a .env file)
|
1486 |
+
m(this, "stdin");
|
1487 |
+
m(this, "stdout");
|
1488 |
+
m(this, "stderr");
|
1489 |
+
m(this, "debug");
|
1490 |
+
m(this, "isTTY");
|
1491 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1492 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1493 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NVUFBPUlQiLGVbZS5FQUdBSU49Nl09IkVBR0FJTiIsZVtlLkVBTFJFQURZPTddPSJFQUxSRUFEWSIsZVtlLkVCQURGPThdPSJFQkFERiIsZVtlLkVCQURNU0c9OV09IkVCQURNU0ciLGVbZS5FQlVTWT0xMF09IkVCVVNZIixlW2UuRUNBTkNFTEVEPTExXT0iRUNBTkNFTEVEIixlW2UuRUNIS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mV0dXJuIGkuc2V0SW50MzIoMCwwKSxudWxsO2NvbnN0IHM9bmV3IFVpbnQ4QXJyYXkodCw0LG4pLGE9bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKHMuc2xpY2UoMCxlKSksZj1zLnNsaWNlKGUscy5sZW5ndGgpO3JldHVybiBpLnNldEludDMyKDAsZi5ieXRlTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1497 |
+
function ut() {
|
1498 |
+
let e;
|
1499 |
+
try {
|
1500 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1501 |
+
throw "";
|
1502 |
+
return new Worker(e);
|
1503 |
+
} catch {
|
1504 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1505 |
+
} finally {
|
1506 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1507 |
+
}
|
1508 |
+
}
|
1509 |
+
function ot(e, t) {
|
1510 |
+
e.postMessage(t);
|
1511 |
+
}
|
1512 |
+
class St extends Error {
|
1513 |
+
}
|
1514 |
+
class Gt {
|
1515 |
+
constructor(t, i) {
|
1516 |
+
m(this, "binaryURL");
|
1517 |
+
// 8kb should be big enough
|
1518 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1519 |
+
m(this, "context");
|
1520 |
+
m(this, "result");
|
1521 |
+
m(this, "worker");
|
1522 |
+
m(this, "reject");
|
1523 |
+
this.binaryURL = t, this.context = i;
|
1524 |
+
}
|
1525 |
+
async start() {
|
1526 |
+
if (this.result)
|
1527 |
+
throw new Error("WASIWorker Host can only be started once");
|
1528 |
+
return this.result = new Promise((t, i) => {
|
1529 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1530 |
+
var s, d, V, a, Z, h;
|
1531 |
+
const l = n.data;
|
1532 |
+
switch (l.type) {
|
1533 |
+
case "stdout":
|
1534 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1535 |
+
break;
|
1536 |
+
case "stderr":
|
1537 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1538 |
+
break;
|
1539 |
+
case "debug":
|
1540 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1541 |
+
Z,
|
1542 |
+
l.name,
|
1543 |
+
l.args,
|
1544 |
+
l.ret,
|
1545 |
+
l.data
|
1546 |
+
);
|
1547 |
+
break;
|
1548 |
+
case "result":
|
1549 |
+
t(l.result);
|
1550 |
+
break;
|
1551 |
+
case "crash":
|
1552 |
+
i(l.error);
|
1553 |
+
break;
|
1554 |
+
}
|
1555 |
+
}), ot(this.worker, {
|
1556 |
+
target: "client",
|
1557 |
+
type: "start",
|
1558 |
+
binaryURL: this.binaryURL,
|
1559 |
+
stdinBuffer: this.stdinBuffer,
|
1560 |
+
// Unfortunately can't just splat these because it includes types
|
1561 |
+
// that can't be sent as a message.
|
1562 |
+
args: this.context.args,
|
1563 |
+
env: this.context.env,
|
1564 |
+
fs: this.context.fs,
|
1565 |
+
isTTY: this.context.isTTY
|
1566 |
+
});
|
1567 |
+
}), this.result;
|
1568 |
+
}
|
1569 |
+
kill() {
|
1570 |
+
var t;
|
1571 |
+
if (!this.worker)
|
1572 |
+
throw new Error("WASIWorker has not started");
|
1573 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1574 |
+
}
|
1575 |
+
async pushStdin(t) {
|
1576 |
+
const i = new DataView(this.stdinBuffer);
|
1577 |
+
for (; i.getInt32(0) !== 0; )
|
1578 |
+
await new Promise((s) => setTimeout(s, 0));
|
1579 |
+
const n = new TextEncoder().encode(t);
|
1580 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1581 |
+
}
|
1582 |
+
async pushEOF() {
|
1583 |
+
const t = new DataView(this.stdinBuffer);
|
1584 |
+
for (; t.getInt32(0) !== 0; )
|
1585 |
+
await new Promise((i) => setTimeout(i, 0));
|
1586 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1587 |
+
}
|
1588 |
+
}
|
1589 |
+
export {
|
1590 |
+
q as WASI,
|
1591 |
+
Xt as WASIContext,
|
1592 |
+
bt as WASISnapshotPreview1,
|
1593 |
+
Gt as WASIWorkerHost,
|
1594 |
+
St as WASIWorkerHostKilledError
|
1595 |
+
};
|
public/vendor/wasi.js.original
ADDED
@@ -0,0 +1,1591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
514 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
515 |
+
});
|
516 |
+
return n.init(l), n.start();
|
517 |
+
}
|
518 |
+
init(t) {
|
519 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.instance.exports.memory, this.initialized = !0;
|
520 |
+
}
|
521 |
+
start() {
|
522 |
+
if (!this.initialized)
|
523 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
524 |
+
const t = this.instance.exports._start;
|
525 |
+
try {
|
526 |
+
t();
|
527 |
+
} catch (i) {
|
528 |
+
if (i instanceof w)
|
529 |
+
return {
|
530 |
+
exitCode: i.code,
|
531 |
+
fs: this.drive.fs
|
532 |
+
};
|
533 |
+
if (i instanceof WebAssembly.RuntimeError)
|
534 |
+
return {
|
535 |
+
exitCode: 134,
|
536 |
+
fs: this.drive.fs
|
537 |
+
};
|
538 |
+
throw i;
|
539 |
+
}
|
540 |
+
return {
|
541 |
+
exitCode: 0,
|
542 |
+
fs: this.drive.fs
|
543 |
+
};
|
544 |
+
}
|
545 |
+
getImports(t, i) {
|
546 |
+
const n = {
|
547 |
+
args_get: this.args_get.bind(this),
|
548 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
549 |
+
clock_res_get: this.clock_res_get.bind(this),
|
550 |
+
clock_time_get: this.clock_time_get.bind(this),
|
551 |
+
environ_get: this.environ_get.bind(this),
|
552 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
553 |
+
proc_exit: this.proc_exit.bind(this),
|
554 |
+
random_get: this.random_get.bind(this),
|
555 |
+
sched_yield: this.sched_yield.bind(this),
|
556 |
+
// File Descriptors
|
557 |
+
fd_advise: this.fd_advise.bind(this),
|
558 |
+
fd_allocate: this.fd_allocate.bind(this),
|
559 |
+
fd_close: this.fd_close.bind(this),
|
560 |
+
fd_datasync: this.fd_datasync.bind(this),
|
561 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
562 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
563 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
564 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
565 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
566 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
567 |
+
fd_pread: this.fd_pread.bind(this),
|
568 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
569 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
570 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
571 |
+
fd_read: this.fd_read.bind(this),
|
572 |
+
fd_readdir: this.fd_readdir.bind(this),
|
573 |
+
fd_renumber: this.fd_renumber.bind(this),
|
574 |
+
fd_seek: this.fd_seek.bind(this),
|
575 |
+
fd_sync: this.fd_sync.bind(this),
|
576 |
+
fd_tell: this.fd_tell.bind(this),
|
577 |
+
fd_write: this.fd_write.bind(this),
|
578 |
+
// Paths
|
579 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
580 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
581 |
+
path_open: this.path_open.bind(this),
|
582 |
+
path_rename: this.path_rename.bind(this),
|
583 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
584 |
+
path_create_directory: this.path_create_directory.bind(this),
|
585 |
+
// Unimplemented
|
586 |
+
path_link: this.path_link.bind(this),
|
587 |
+
path_readlink: this.path_readlink.bind(this),
|
588 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
589 |
+
path_symlink: this.path_symlink.bind(this),
|
590 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
591 |
+
proc_raise: this.proc_raise.bind(this),
|
592 |
+
sock_accept: this.sock_accept.bind(this),
|
593 |
+
sock_recv: this.sock_recv.bind(this),
|
594 |
+
sock_send: this.sock_send.bind(this),
|
595 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
596 |
+
// Unimplemented - WASMEdge compatibility
|
597 |
+
sock_open: this.sock_open.bind(this),
|
598 |
+
sock_listen: this.sock_listen.bind(this),
|
599 |
+
sock_connect: this.sock_connect.bind(this),
|
600 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
601 |
+
sock_bind: this.sock_bind.bind(this),
|
602 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
603 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
604 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
605 |
+
};
|
606 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
607 |
+
for (const [l, s] of Object.entries(n))
|
608 |
+
n[l] = function() {
|
609 |
+
let d = s.apply(this, arguments);
|
610 |
+
if (i) {
|
611 |
+
const V = Vt();
|
612 |
+
d = i(l, [...arguments], d, V) ?? d;
|
613 |
+
}
|
614 |
+
return d;
|
615 |
+
};
|
616 |
+
return n;
|
617 |
+
}
|
618 |
+
//
|
619 |
+
// Helpers
|
620 |
+
//
|
621 |
+
get envArray() {
|
622 |
+
return Object.entries(this.context.env).map(
|
623 |
+
([t, i]) => `${t}=${i}`
|
624 |
+
);
|
625 |
+
}
|
626 |
+
//
|
627 |
+
// WASI Implementation
|
628 |
+
//
|
629 |
+
/**
|
630 |
+
* Read command-line argument data. The size of the array should match that
|
631 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
632 |
+
*/
|
633 |
+
args_get(t, i) {
|
634 |
+
const n = new DataView(this.memory.buffer);
|
635 |
+
for (const l of this.context.args) {
|
636 |
+
n.setUint32(t, i, !0), t += 4;
|
637 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
638 |
+
new Uint8Array(
|
639 |
+
this.memory.buffer,
|
640 |
+
i,
|
641 |
+
s.byteLength
|
642 |
+
).set(s), i += s.byteLength;
|
643 |
+
}
|
644 |
+
return c.SUCCESS;
|
645 |
+
}
|
646 |
+
/**
|
647 |
+
* Return command-line argument data sizes.
|
648 |
+
*/
|
649 |
+
args_sizes_get(t, i) {
|
650 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
651 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
652 |
+
}
|
653 |
+
/**
|
654 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
655 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
656 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
657 |
+
*/
|
658 |
+
clock_res_get(t, i) {
|
659 |
+
switch (t) {
|
660 |
+
case p.REALTIME:
|
661 |
+
case p.MONOTONIC:
|
662 |
+
case p.PROCESS_CPUTIME_ID:
|
663 |
+
case p.THREAD_CPUTIME_ID:
|
664 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
665 |
+
}
|
666 |
+
return c.EINVAL;
|
667 |
+
}
|
668 |
+
/**
|
669 |
+
* Return the time value of a clock.
|
670 |
+
* Note: This is similar to clock_gettime in POSIX.
|
671 |
+
*/
|
672 |
+
clock_time_get(t, i, n) {
|
673 |
+
switch (t) {
|
674 |
+
case p.REALTIME:
|
675 |
+
case p.MONOTONIC:
|
676 |
+
case p.PROCESS_CPUTIME_ID:
|
677 |
+
case p.THREAD_CPUTIME_ID:
|
678 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
679 |
+
}
|
680 |
+
return c.EINVAL;
|
681 |
+
}
|
682 |
+
/**
|
683 |
+
* Read environment variable data. The sizes of the buffers should match that
|
684 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
685 |
+
* with =s, and terminated with \0s.
|
686 |
+
*/
|
687 |
+
environ_get(t, i) {
|
688 |
+
const n = new DataView(this.memory.buffer);
|
689 |
+
for (const l of this.envArray) {
|
690 |
+
n.setUint32(t, i, !0), t += 4;
|
691 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
692 |
+
new Uint8Array(
|
693 |
+
this.memory.buffer,
|
694 |
+
i,
|
695 |
+
s.byteLength
|
696 |
+
).set(s), i += s.byteLength;
|
697 |
+
}
|
698 |
+
return c.SUCCESS;
|
699 |
+
}
|
700 |
+
/**
|
701 |
+
* Return environment variable data sizes.
|
702 |
+
*/
|
703 |
+
environ_sizes_get(t, i) {
|
704 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
705 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
706 |
+
}
|
707 |
+
/**
|
708 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
709 |
+
* termination of the program. The meanings of other values is dependent on
|
710 |
+
* the environment.
|
711 |
+
*/
|
712 |
+
proc_exit(t) {
|
713 |
+
throw new w(t);
|
714 |
+
}
|
715 |
+
/**
|
716 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
717 |
+
* implementation is unable to immediately provide sufficient high-quality
|
718 |
+
* random data. This function may execute slowly, so when large mounts of
|
719 |
+
* random data are required, it's advisable to use this function to seed a
|
720 |
+
* pseudo-random number generator, rather than to provide the random data
|
721 |
+
* directly.
|
722 |
+
*/
|
723 |
+
random_get(t, i) {
|
724 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
725 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
726 |
+
}
|
727 |
+
/**
|
728 |
+
* Temporarily yield execution of the calling thread.
|
729 |
+
* Note: This is similar to sched_yield in POSIX.
|
730 |
+
*/
|
731 |
+
sched_yield() {
|
732 |
+
return c.SUCCESS;
|
733 |
+
}
|
734 |
+
//
|
735 |
+
// File Descriptors
|
736 |
+
//
|
737 |
+
/**
|
738 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
739 |
+
*/
|
740 |
+
fd_read(t, i, n, l) {
|
741 |
+
if (t === 1 || t === 2)
|
742 |
+
return c.ENOTSUP;
|
743 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
744 |
+
let a = 0, Z = c.SUCCESS;
|
745 |
+
for (const h of d) {
|
746 |
+
let r;
|
747 |
+
if (t === 0) {
|
748 |
+
const R = this.context.stdin(h.byteLength);
|
749 |
+
if (!R)
|
750 |
+
break;
|
751 |
+
r = V.encode(R);
|
752 |
+
} else {
|
753 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
754 |
+
if (R) {
|
755 |
+
Z = R;
|
756 |
+
break;
|
757 |
+
} else
|
758 |
+
r = k;
|
759 |
+
}
|
760 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
761 |
+
h.set(r.subarray(0, o)), a += o;
|
762 |
+
}
|
763 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
764 |
+
}
|
765 |
+
/**
|
766 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
767 |
+
*/
|
768 |
+
fd_write(t, i, n, l) {
|
769 |
+
if (t === 0)
|
770 |
+
return c.ENOTSUP;
|
771 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
772 |
+
let a = 0, Z = c.SUCCESS;
|
773 |
+
for (const h of d)
|
774 |
+
if (h.byteLength !== 0) {
|
775 |
+
if (t === 1 || t === 2) {
|
776 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
777 |
+
r(o), f({ output: o });
|
778 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
779 |
+
break;
|
780 |
+
a += h.byteLength;
|
781 |
+
}
|
782 |
+
return s.setUint32(l, a, !0), Z;
|
783 |
+
}
|
784 |
+
/**
|
785 |
+
* Provide file advisory information on a file descriptor.
|
786 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
787 |
+
*/
|
788 |
+
fd_advise() {
|
789 |
+
return c.SUCCESS;
|
790 |
+
}
|
791 |
+
/**
|
792 |
+
* Force the allocation of space in a file.
|
793 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
794 |
+
*/
|
795 |
+
fd_allocate(t, i, n) {
|
796 |
+
return this.drive.pwrite(
|
797 |
+
t,
|
798 |
+
new Uint8Array(Number(n)),
|
799 |
+
Number(i)
|
800 |
+
);
|
801 |
+
}
|
802 |
+
/**
|
803 |
+
* Close a file descriptor.
|
804 |
+
* Note: This is similar to close in POSIX.
|
805 |
+
*
|
806 |
+
* @param fd
|
807 |
+
*/
|
808 |
+
fd_close(t) {
|
809 |
+
return this.drive.close(t);
|
810 |
+
}
|
811 |
+
/**
|
812 |
+
* Synchronize the data of a file to disk.
|
813 |
+
* Note: This is similar to fdatasync in POSIX.
|
814 |
+
*
|
815 |
+
* @param fd
|
816 |
+
*/
|
817 |
+
fd_datasync(t) {
|
818 |
+
return this.drive.sync(t);
|
819 |
+
}
|
820 |
+
/**
|
821 |
+
* Get the attributes of a file descriptor.
|
822 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
823 |
+
* as well as additional fields.
|
824 |
+
*
|
825 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
826 |
+
* are stored.
|
827 |
+
*
|
828 |
+
* @returns Result<fdstat, errno>
|
829 |
+
*/
|
830 |
+
fd_fdstat_get(t, i) {
|
831 |
+
if (t < 3) {
|
832 |
+
let V;
|
833 |
+
if (this.context.isTTY) {
|
834 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
835 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
836 |
+
} else
|
837 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
838 |
+
return new Uint8Array(
|
839 |
+
this.memory.buffer,
|
840 |
+
i,
|
841 |
+
V.byteLength
|
842 |
+
).set(V), c.SUCCESS;
|
843 |
+
}
|
844 |
+
if (!this.drive.exists(t))
|
845 |
+
return c.EBADF;
|
846 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
847 |
+
return new Uint8Array(
|
848 |
+
this.memory.buffer,
|
849 |
+
i,
|
850 |
+
s.byteLength
|
851 |
+
).set(s), c.SUCCESS;
|
852 |
+
}
|
853 |
+
/**
|
854 |
+
* Adjust the flags associated with a file descriptor.
|
855 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
856 |
+
*/
|
857 |
+
fd_fdstat_set_flags(t, i) {
|
858 |
+
return this.drive.setFlags(t, i);
|
859 |
+
}
|
860 |
+
/**
|
861 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
862 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
863 |
+
* would attempt to add rights
|
864 |
+
*/
|
865 |
+
fd_fdstat_set_rights() {
|
866 |
+
return c.SUCCESS;
|
867 |
+
}
|
868 |
+
/**
|
869 |
+
* Return the attributes of an open file.
|
870 |
+
*/
|
871 |
+
fd_filestat_get(t, i) {
|
872 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
873 |
+
}
|
874 |
+
/**
|
875 |
+
* Return the attributes of an open file.
|
876 |
+
* This version is used
|
877 |
+
*/
|
878 |
+
unstable_fd_filestat_get(t, i) {
|
879 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
880 |
+
}
|
881 |
+
/**
|
882 |
+
* Return the attributes of an open file.
|
883 |
+
*/
|
884 |
+
shared_fd_filestat_get(t, i, n) {
|
885 |
+
const l = n === "unstable" ? A : _;
|
886 |
+
if (t < 3) {
|
887 |
+
let Z;
|
888 |
+
switch (t) {
|
889 |
+
case 0:
|
890 |
+
Z = "/dev/stdin";
|
891 |
+
break;
|
892 |
+
case 1:
|
893 |
+
Z = "/dev/stdout";
|
894 |
+
break;
|
895 |
+
case 2:
|
896 |
+
Z = "/dev/stderr";
|
897 |
+
break;
|
898 |
+
default:
|
899 |
+
Z = "/dev/undefined";
|
900 |
+
break;
|
901 |
+
}
|
902 |
+
const h = l({
|
903 |
+
path: Z,
|
904 |
+
byteLength: 0,
|
905 |
+
timestamps: {
|
906 |
+
access: /* @__PURE__ */ new Date(),
|
907 |
+
modification: /* @__PURE__ */ new Date(),
|
908 |
+
change: /* @__PURE__ */ new Date()
|
909 |
+
},
|
910 |
+
type: X.CHARACTER_DEVICE
|
911 |
+
});
|
912 |
+
return new Uint8Array(
|
913 |
+
this.memory.buffer,
|
914 |
+
i,
|
915 |
+
h.byteLength
|
916 |
+
).set(h), c.SUCCESS;
|
917 |
+
}
|
918 |
+
const [s, d] = this.drive.stat(t);
|
919 |
+
if (s != c.SUCCESS)
|
920 |
+
return s;
|
921 |
+
f({ resolvedPath: d.path, stat: d });
|
922 |
+
const V = l(d);
|
923 |
+
return new Uint8Array(
|
924 |
+
this.memory.buffer,
|
925 |
+
i,
|
926 |
+
V.byteLength
|
927 |
+
).set(V), c.SUCCESS;
|
928 |
+
}
|
929 |
+
/**
|
930 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
931 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
932 |
+
* POSIX.
|
933 |
+
*/
|
934 |
+
fd_filestat_set_size(t, i) {
|
935 |
+
return this.drive.setSize(t, i);
|
936 |
+
}
|
937 |
+
/**
|
938 |
+
* Adjust the timestamps of an open file or directory.
|
939 |
+
* Note: This is similar to futimens in POSIX.
|
940 |
+
*/
|
941 |
+
fd_filestat_set_times(t, i, n, l) {
|
942 |
+
let s = null;
|
943 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
944 |
+
let d = null;
|
945 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
946 |
+
const V = this.drive.setAccessTime(t, s);
|
947 |
+
if (V != c.SUCCESS)
|
948 |
+
return V;
|
949 |
+
}
|
950 |
+
if (d) {
|
951 |
+
const V = this.drive.setModificationTime(t, d);
|
952 |
+
if (V != c.SUCCESS)
|
953 |
+
return V;
|
954 |
+
}
|
955 |
+
return c.SUCCESS;
|
956 |
+
}
|
957 |
+
/**
|
958 |
+
* Read from a file descriptor, without using and updating the file
|
959 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
960 |
+
*/
|
961 |
+
fd_pread(t, i, n, l, s) {
|
962 |
+
if (t === 1 || t === 2)
|
963 |
+
return c.ENOTSUP;
|
964 |
+
if (t === 0)
|
965 |
+
return this.fd_read(t, i, n, s);
|
966 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
967 |
+
let a = 0, Z = c.SUCCESS;
|
968 |
+
for (const h of V) {
|
969 |
+
const [r, o] = this.drive.pread(
|
970 |
+
t,
|
971 |
+
h.byteLength,
|
972 |
+
Number(l) + a
|
973 |
+
);
|
974 |
+
if (r !== c.SUCCESS) {
|
975 |
+
Z = r;
|
976 |
+
break;
|
977 |
+
}
|
978 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
979 |
+
h.set(o.subarray(0, R)), a += R;
|
980 |
+
}
|
981 |
+
return d.setUint32(s, a, !0), Z;
|
982 |
+
}
|
983 |
+
/**
|
984 |
+
* Return a description of the given preopened file descriptor.
|
985 |
+
*/
|
986 |
+
fd_prestat_dir_name(t, i, n) {
|
987 |
+
if (t !== 3)
|
988 |
+
return c.EBADF;
|
989 |
+
const l = new TextEncoder().encode("/");
|
990 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
991 |
+
}
|
992 |
+
/**
|
993 |
+
* Return a description of the given preopened file descriptor.
|
994 |
+
*/
|
995 |
+
fd_prestat_get(t, i) {
|
996 |
+
if (t !== 3)
|
997 |
+
return c.EBADF;
|
998 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
999 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1000 |
+
}
|
1001 |
+
/**
|
1002 |
+
* Write to a file descriptor, without using and updating the file
|
1003 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1004 |
+
*/
|
1005 |
+
fd_pwrite(t, i, n, l, s) {
|
1006 |
+
if (t === 0)
|
1007 |
+
return c.ENOTSUP;
|
1008 |
+
if (t === 1 || t === 2)
|
1009 |
+
return this.fd_write(t, i, n, s);
|
1010 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1011 |
+
let a = 0, Z = c.SUCCESS;
|
1012 |
+
for (const h of V)
|
1013 |
+
if (h.byteLength !== 0) {
|
1014 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1015 |
+
break;
|
1016 |
+
a += h.byteLength;
|
1017 |
+
}
|
1018 |
+
return d.setUint32(s, a, !0), Z;
|
1019 |
+
}
|
1020 |
+
/**
|
1021 |
+
* Read directory entries from a directory. When successful, the contents of
|
1022 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1023 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1024 |
+
* bytes holding the name of the directory entry. This function fills the
|
1025 |
+
* output buffer as much as possible, potentially truncating the last
|
1026 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1027 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1028 |
+
* oversized directory entry.
|
1029 |
+
*/
|
1030 |
+
fd_readdir(t, i, n, l, s) {
|
1031 |
+
const [d, V] = this.drive.list(t);
|
1032 |
+
if (d != c.SUCCESS)
|
1033 |
+
return d;
|
1034 |
+
let a = [], Z = 0;
|
1035 |
+
for (const { name: N, type: F } of V) {
|
1036 |
+
const g = ht(N, F, Z);
|
1037 |
+
a.push(g), Z++;
|
1038 |
+
}
|
1039 |
+
a = a.slice(Number(l));
|
1040 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1041 |
+
let o = 0;
|
1042 |
+
for (const N of a)
|
1043 |
+
r.set(N, o), o += N.byteLength;
|
1044 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1045 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1046 |
+
}
|
1047 |
+
/**
|
1048 |
+
* Atomically replace a file descriptor by renumbering another file
|
1049 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1050 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1051 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1052 |
+
* an actual file descriptor with the same number could be allocated by a
|
1053 |
+
* different thread at the same time. This function provides a way to
|
1054 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1055 |
+
* to be removed entirely.
|
1056 |
+
*/
|
1057 |
+
fd_renumber(t, i) {
|
1058 |
+
return this.drive.renumber(t, i);
|
1059 |
+
}
|
1060 |
+
/**
|
1061 |
+
* Move the offset of a file descriptor.
|
1062 |
+
*
|
1063 |
+
* The offset is specified as a bigint here
|
1064 |
+
* Note: This is similar to lseek in POSIX.
|
1065 |
+
*
|
1066 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1067 |
+
* bigint in JavaScript.
|
1068 |
+
*/
|
1069 |
+
fd_seek(t, i, n, l) {
|
1070 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1071 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1072 |
+
}
|
1073 |
+
unstable_fd_seek(t, i, n, l) {
|
1074 |
+
const s = mt[n];
|
1075 |
+
return this.fd_seek(t, i, s, l);
|
1076 |
+
}
|
1077 |
+
/**
|
1078 |
+
* Synchronize the data and metadata of a file to disk.
|
1079 |
+
* Note: This is similar to fsync in POSIX.
|
1080 |
+
*/
|
1081 |
+
fd_sync(t) {
|
1082 |
+
return this.drive.sync(t);
|
1083 |
+
}
|
1084 |
+
/**
|
1085 |
+
* Return the current offset of a file descriptor.
|
1086 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1087 |
+
*
|
1088 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1089 |
+
*
|
1090 |
+
*/
|
1091 |
+
fd_tell(t, i) {
|
1092 |
+
const [n, l] = this.drive.tell(t);
|
1093 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1094 |
+
}
|
1095 |
+
//
|
1096 |
+
// Paths
|
1097 |
+
//
|
1098 |
+
path_filestat_get(t, i, n, l, s) {
|
1099 |
+
return this.shared_path_filestat_get(
|
1100 |
+
t,
|
1101 |
+
i,
|
1102 |
+
n,
|
1103 |
+
l,
|
1104 |
+
s,
|
1105 |
+
"preview1"
|
1106 |
+
);
|
1107 |
+
}
|
1108 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1109 |
+
return this.shared_path_filestat_get(
|
1110 |
+
t,
|
1111 |
+
i,
|
1112 |
+
n,
|
1113 |
+
l,
|
1114 |
+
s,
|
1115 |
+
"unstable"
|
1116 |
+
);
|
1117 |
+
}
|
1118 |
+
/**
|
1119 |
+
* Return the attributes of a file or directory.
|
1120 |
+
* Note: This is similar to stat in POSIX.
|
1121 |
+
*/
|
1122 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1123 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1124 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1125 |
+
);
|
1126 |
+
f({ path: a });
|
1127 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1128 |
+
if (Z != c.SUCCESS)
|
1129 |
+
return Z;
|
1130 |
+
const r = V(h);
|
1131 |
+
return new Uint8Array(
|
1132 |
+
this.memory.buffer,
|
1133 |
+
s,
|
1134 |
+
r.byteLength
|
1135 |
+
).set(r), Z;
|
1136 |
+
}
|
1137 |
+
/**
|
1138 |
+
* Adjust the timestamps of a file or directory.
|
1139 |
+
* Note: This is similar to utimensat in POSIX.
|
1140 |
+
*/
|
1141 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1142 |
+
let a = null;
|
1143 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1144 |
+
let Z = null;
|
1145 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1146 |
+
const h = new TextDecoder().decode(
|
1147 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1148 |
+
);
|
1149 |
+
if (a) {
|
1150 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1151 |
+
if (r != c.SUCCESS)
|
1152 |
+
return r;
|
1153 |
+
}
|
1154 |
+
if (Z) {
|
1155 |
+
const r = this.drive.pathSetModificationTime(
|
1156 |
+
t,
|
1157 |
+
h,
|
1158 |
+
Z
|
1159 |
+
);
|
1160 |
+
if (r != c.SUCCESS)
|
1161 |
+
return r;
|
1162 |
+
}
|
1163 |
+
return c.SUCCESS;
|
1164 |
+
}
|
1165 |
+
/**
|
1166 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1167 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1168 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1169 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1170 |
+
* descriptor is guaranteed to be less than 2**31.
|
1171 |
+
* Note: This is similar to openat in POSIX.
|
1172 |
+
* @param fd: fd
|
1173 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1174 |
+
* is resolved. Not supported by Runno (symlinks)
|
1175 |
+
* @param path: string The relative path of the file or directory to open,
|
1176 |
+
* relative to the path_open::fd directory.
|
1177 |
+
* @param oflags: oflags The method by which to open the file.
|
1178 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1179 |
+
* descriptor. The implementation is allowed to return
|
1180 |
+
* a file descriptor with fewer rights than specified,
|
1181 |
+
* if and only if those rights do not apply to the type
|
1182 |
+
* of file being opened. The base rights are rights
|
1183 |
+
* that will apply to operations using the file
|
1184 |
+
* descriptor itself, while the inheriting rights are
|
1185 |
+
* rights that apply to file descriptors derived from
|
1186 |
+
* it.
|
1187 |
+
* @param fs_rights_inheriting: rights
|
1188 |
+
* @param fdflags: fdflags
|
1189 |
+
*
|
1190 |
+
*/
|
1191 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1192 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1193 |
+
f({
|
1194 |
+
path: r,
|
1195 |
+
openFlags: {
|
1196 |
+
createFileIfNone: o,
|
1197 |
+
failIfNotDir: R,
|
1198 |
+
failIfFileExists: k,
|
1199 |
+
truncateFile: P
|
1200 |
+
},
|
1201 |
+
fileDescriptorFlags: {
|
1202 |
+
flagAppend: N,
|
1203 |
+
flagDSync: F,
|
1204 |
+
flagNonBlock: g,
|
1205 |
+
flagRSync: et,
|
1206 |
+
flagSync: it
|
1207 |
+
}
|
1208 |
+
});
|
1209 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1210 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1211 |
+
}
|
1212 |
+
/**
|
1213 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1214 |
+
*/
|
1215 |
+
path_rename(t, i, n, l, s, d) {
|
1216 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1217 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1218 |
+
}
|
1219 |
+
/**
|
1220 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1221 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1222 |
+
*/
|
1223 |
+
path_unlink_file(t, i, n) {
|
1224 |
+
const l = I(this.memory, i, n);
|
1225 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1226 |
+
}
|
1227 |
+
/**
|
1228 |
+
* Concurrently poll for the occurrence of a set of events.
|
1229 |
+
*/
|
1230 |
+
poll_oneoff(t, i, n, l) {
|
1231 |
+
for (let d = 0; d < n; d++) {
|
1232 |
+
const V = new Uint8Array(
|
1233 |
+
this.memory.buffer,
|
1234 |
+
t + d * M,
|
1235 |
+
M
|
1236 |
+
), a = Zt(V), Z = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
i + d * x,
|
1239 |
+
x
|
1240 |
+
);
|
1241 |
+
let h = 0, r = c.SUCCESS;
|
1242 |
+
switch (a.type) {
|
1243 |
+
case G.CLOCK:
|
1244 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1245 |
+
;
|
1246 |
+
Z.set(
|
1247 |
+
rt(a.userdata, c.SUCCESS)
|
1248 |
+
);
|
1249 |
+
break;
|
1250 |
+
case G.FD_READ:
|
1251 |
+
if (a.fd < 3)
|
1252 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1253 |
+
else {
|
1254 |
+
const [o, R] = this.drive.stat(a.fd);
|
1255 |
+
r = o, h = R ? R.byteLength : 0;
|
1256 |
+
}
|
1257 |
+
Z.set(
|
1258 |
+
v(
|
1259 |
+
a.userdata,
|
1260 |
+
r,
|
1261 |
+
G.FD_READ,
|
1262 |
+
BigInt(h)
|
1263 |
+
)
|
1264 |
+
);
|
1265 |
+
break;
|
1266 |
+
case G.FD_WRITE:
|
1267 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1268 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1269 |
+
else {
|
1270 |
+
const [o, R] = this.drive.stat(a.fd);
|
1271 |
+
r = o, h = R ? R.byteLength : 0;
|
1272 |
+
}
|
1273 |
+
Z.set(
|
1274 |
+
v(
|
1275 |
+
a.userdata,
|
1276 |
+
r,
|
1277 |
+
G.FD_READ,
|
1278 |
+
BigInt(h)
|
1279 |
+
)
|
1280 |
+
);
|
1281 |
+
break;
|
1282 |
+
}
|
1283 |
+
}
|
1284 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1285 |
+
}
|
1286 |
+
/**
|
1287 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1288 |
+
*/
|
1289 |
+
path_create_directory(t, i, n) {
|
1290 |
+
const l = I(this.memory, i, n);
|
1291 |
+
return this.drive.pathCreateDir(t, l);
|
1292 |
+
}
|
1293 |
+
//
|
1294 |
+
// Unimplemented - these operations are not supported by Runno
|
1295 |
+
//
|
1296 |
+
/**
|
1297 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1298 |
+
*/
|
1299 |
+
path_link() {
|
1300 |
+
return c.ENOSYS;
|
1301 |
+
}
|
1302 |
+
/**
|
1303 |
+
* Read the contents of a symbolic link.
|
1304 |
+
* Note: This is similar to readlinkat in POSIX.
|
1305 |
+
*/
|
1306 |
+
path_readlink() {
|
1307 |
+
return c.ENOSYS;
|
1308 |
+
}
|
1309 |
+
/**
|
1310 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1311 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1312 |
+
*/
|
1313 |
+
path_remove_directory() {
|
1314 |
+
return c.ENOSYS;
|
1315 |
+
}
|
1316 |
+
/**
|
1317 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1318 |
+
*/
|
1319 |
+
path_symlink() {
|
1320 |
+
return c.ENOSYS;
|
1321 |
+
}
|
1322 |
+
/**
|
1323 |
+
* Send a signal to the process of the calling thread.
|
1324 |
+
* Note: This is similar to raise in POSIX.
|
1325 |
+
*/
|
1326 |
+
proc_raise() {
|
1327 |
+
return c.ENOSYS;
|
1328 |
+
}
|
1329 |
+
/**
|
1330 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1331 |
+
*/
|
1332 |
+
sock_accept() {
|
1333 |
+
return c.ENOSYS;
|
1334 |
+
}
|
1335 |
+
/**
|
1336 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1337 |
+
* though it also supports reading the data into multiple buffers in the
|
1338 |
+
* manner of readv.
|
1339 |
+
*/
|
1340 |
+
sock_recv() {
|
1341 |
+
return c.ENOSYS;
|
1342 |
+
}
|
1343 |
+
/**
|
1344 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1345 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1346 |
+
* writev.
|
1347 |
+
*/
|
1348 |
+
sock_send() {
|
1349 |
+
return c.ENOSYS;
|
1350 |
+
}
|
1351 |
+
/**
|
1352 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1353 |
+
* shutdown in POSIX.
|
1354 |
+
*/
|
1355 |
+
sock_shutdown() {
|
1356 |
+
return c.ENOSYS;
|
1357 |
+
}
|
1358 |
+
//
|
1359 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1360 |
+
//
|
1361 |
+
sock_open() {
|
1362 |
+
return c.ENOSYS;
|
1363 |
+
}
|
1364 |
+
sock_listen() {
|
1365 |
+
return c.ENOSYS;
|
1366 |
+
}
|
1367 |
+
sock_connect() {
|
1368 |
+
return c.ENOSYS;
|
1369 |
+
}
|
1370 |
+
sock_setsockopt() {
|
1371 |
+
return c.ENOSYS;
|
1372 |
+
}
|
1373 |
+
sock_bind() {
|
1374 |
+
return c.ENOSYS;
|
1375 |
+
}
|
1376 |
+
sock_getlocaladdr() {
|
1377 |
+
return c.ENOSYS;
|
1378 |
+
}
|
1379 |
+
sock_getpeeraddr() {
|
1380 |
+
return c.ENOSYS;
|
1381 |
+
}
|
1382 |
+
sock_getaddrinfo() {
|
1383 |
+
return c.ENOSYS;
|
1384 |
+
}
|
1385 |
+
}
|
1386 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1387 |
+
class w extends Error {
|
1388 |
+
constructor(i) {
|
1389 |
+
super();
|
1390 |
+
m(this, "code");
|
1391 |
+
this.code = i;
|
1392 |
+
}
|
1393 |
+
}
|
1394 |
+
function I(e, t, i) {
|
1395 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1396 |
+
}
|
1397 |
+
function K(e, t, i) {
|
1398 |
+
let n = Array(i);
|
1399 |
+
for (let l = 0; l < i; l++) {
|
1400 |
+
const s = e.getUint32(t, !0);
|
1401 |
+
t += 4;
|
1402 |
+
const d = e.getUint32(t, !0);
|
1403 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1404 |
+
}
|
1405 |
+
return n;
|
1406 |
+
}
|
1407 |
+
function Zt(e) {
|
1408 |
+
const t = new Uint8Array(8);
|
1409 |
+
t.set(e.subarray(0, 8));
|
1410 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1411 |
+
switch (i) {
|
1412 |
+
case G.FD_READ:
|
1413 |
+
case G.FD_WRITE:
|
1414 |
+
return {
|
1415 |
+
userdata: t,
|
1416 |
+
type: i,
|
1417 |
+
fd: n.getUint32(0, !0)
|
1418 |
+
};
|
1419 |
+
case G.CLOCK:
|
1420 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1421 |
+
return {
|
1422 |
+
userdata: t,
|
1423 |
+
type: i,
|
1424 |
+
id: n.getUint32(0, !0),
|
1425 |
+
timeout: W(a),
|
1426 |
+
precision: W(a + V)
|
1427 |
+
};
|
1428 |
+
}
|
1429 |
+
}
|
1430 |
+
function _(e) {
|
1431 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1432 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1433 |
+
}
|
1434 |
+
function A(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function J(e, t, i) {
|
1439 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1440 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1441 |
+
}
|
1442 |
+
function ht(e, t, i) {
|
1443 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1444 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1445 |
+
}
|
1446 |
+
function rt(e, t) {
|
1447 |
+
const i = new Uint8Array(32);
|
1448 |
+
i.set(e, 0);
|
1449 |
+
const n = new DataView(i.buffer);
|
1450 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1451 |
+
}
|
1452 |
+
function v(e, t, i, n) {
|
1453 |
+
const l = new Uint8Array(32);
|
1454 |
+
l.set(e, 0);
|
1455 |
+
const s = new DataView(l.buffer);
|
1456 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1457 |
+
}
|
1458 |
+
function H(e, t = 0) {
|
1459 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1460 |
+
for (let l = 0, s; l < e.length; l++)
|
1461 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1462 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1463 |
+
}
|
1464 |
+
function L(e) {
|
1465 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1466 |
+
}
|
1467 |
+
function W(e) {
|
1468 |
+
return new Date(Number(e / BigInt(1e6)));
|
1469 |
+
}
|
1470 |
+
const mt = {
|
1471 |
+
[Y.CUR]: y.CUR,
|
1472 |
+
[Y.END]: y.END,
|
1473 |
+
[Y.SET]: y.SET
|
1474 |
+
};
|
1475 |
+
class Xt {
|
1476 |
+
constructor(t) {
|
1477 |
+
m(this, "fs");
|
1478 |
+
m(this, "args");
|
1479 |
+
// Program args (like from a terminal program)
|
1480 |
+
m(this, "env");
|
1481 |
+
// Environment (like a .env file)
|
1482 |
+
m(this, "stdin");
|
1483 |
+
m(this, "stdout");
|
1484 |
+
m(this, "stderr");
|
1485 |
+
m(this, "debug");
|
1486 |
+
m(this, "isTTY");
|
1487 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1488 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1489 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1490 |
+
}
|
1491 |
+
}
|
1492 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NVUFBPUlQiLGVbZS5FQUdBSU49Nl09IkVBR0FJTiIsZVtlLkVBTFJFQURZPTddPSJFQUxSRUFEWSIsZVtlLkVCQURGPThdPSJFQkFERiIsZVtlLkVCQURNU0c9OV09IkVCQURNU0ciLGVbZS5FQlVTWT0xMF09IkVCVVNZIixlW2UuRU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GFWaWV3KHQpLG49aS5nZXRJbnQzMigwKTtpZihuPDApcmV0dXJuIGkuc2V0SW50MzIoMCwwKSxudWxsO2NvbnN0IHM9bmV3IFVpbnQ4QXJyYXkodCw0LG4pLGE9bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKHMuc2xpY2UoMCxlKSksZj1zLnNsaWNlKGUscy5sZW5ndGgpO3JldHVybiBpLnNldEludDMyKDAsZi5ieXRlTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1493 |
+
function ut() {
|
1494 |
+
let e;
|
1495 |
+
try {
|
1496 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1497 |
+
throw "";
|
1498 |
+
return new Worker(e);
|
1499 |
+
} catch {
|
1500 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1501 |
+
} finally {
|
1502 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1503 |
+
}
|
1504 |
+
}
|
1505 |
+
function ot(e, t) {
|
1506 |
+
e.postMessage(t);
|
1507 |
+
}
|
1508 |
+
class St extends Error {
|
1509 |
+
}
|
1510 |
+
class Gt {
|
1511 |
+
constructor(t, i) {
|
1512 |
+
m(this, "binaryURL");
|
1513 |
+
// 8kb should be big enough
|
1514 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1515 |
+
m(this, "context");
|
1516 |
+
m(this, "result");
|
1517 |
+
m(this, "worker");
|
1518 |
+
m(this, "reject");
|
1519 |
+
this.binaryURL = t, this.context = i;
|
1520 |
+
}
|
1521 |
+
async start() {
|
1522 |
+
if (this.result)
|
1523 |
+
throw new Error("WASIWorker Host can only be started once");
|
1524 |
+
return this.result = new Promise((t, i) => {
|
1525 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1526 |
+
var s, d, V, a, Z, h;
|
1527 |
+
const l = n.data;
|
1528 |
+
switch (l.type) {
|
1529 |
+
case "stdout":
|
1530 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1531 |
+
break;
|
1532 |
+
case "stderr":
|
1533 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1534 |
+
break;
|
1535 |
+
case "debug":
|
1536 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1537 |
+
Z,
|
1538 |
+
l.name,
|
1539 |
+
l.args,
|
1540 |
+
l.ret,
|
1541 |
+
l.data
|
1542 |
+
);
|
1543 |
+
break;
|
1544 |
+
case "result":
|
1545 |
+
t(l.result);
|
1546 |
+
break;
|
1547 |
+
case "crash":
|
1548 |
+
i(l.error);
|
1549 |
+
break;
|
1550 |
+
}
|
1551 |
+
}), ot(this.worker, {
|
1552 |
+
target: "client",
|
1553 |
+
type: "start",
|
1554 |
+
binaryURL: this.binaryURL,
|
1555 |
+
stdinBuffer: this.stdinBuffer,
|
1556 |
+
// Unfortunately can't just splat these because it includes types
|
1557 |
+
// that can't be sent as a message.
|
1558 |
+
args: this.context.args,
|
1559 |
+
env: this.context.env,
|
1560 |
+
fs: this.context.fs,
|
1561 |
+
isTTY: this.context.isTTY
|
1562 |
+
});
|
1563 |
+
}), this.result;
|
1564 |
+
}
|
1565 |
+
kill() {
|
1566 |
+
var t;
|
1567 |
+
if (!this.worker)
|
1568 |
+
throw new Error("WASIWorker has not started");
|
1569 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1570 |
+
}
|
1571 |
+
async pushStdin(t) {
|
1572 |
+
const i = new DataView(this.stdinBuffer);
|
1573 |
+
for (; i.getInt32(0) !== 0; )
|
1574 |
+
await new Promise((s) => setTimeout(s, 0));
|
1575 |
+
const n = new TextEncoder().encode(t);
|
1576 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1577 |
+
}
|
1578 |
+
async pushEOF() {
|
1579 |
+
const t = new DataView(this.stdinBuffer);
|
1580 |
+
for (; t.getInt32(0) !== 0; )
|
1581 |
+
await new Promise((i) => setTimeout(i, 0));
|
1582 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1583 |
+
}
|
1584 |
+
}
|
1585 |
+
export {
|
1586 |
+
q as WASI,
|
1587 |
+
Xt as WASIContext,
|
1588 |
+
bt as WASISnapshotPreview1,
|
1589 |
+
Gt as WASIWorkerHost,
|
1590 |
+
St as WASIWorkerHostKilledError
|
1591 |
+
};
|
public/vite.svg
ADDED
src/App.vue
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<template>
|
2 |
+
<div>
|
3 |
+
<div class="markdown-body" style="margin-top: 15px;margin-inline-start: 15px;">
|
4 |
+
<h1>Chatxu-Story</h1>
|
5 |
+
<div>
|
6 |
+
<h2>请输入标题:</h2>
|
7 |
+
<input v-model="story" class="form-control input" type="text" placeholder="标题" aria-label="标题" />
|
8 |
+
<button class="btn btn-primary" :disabled="run123" @click="run() ">生成</button>
|
9 |
+
</div>
|
10 |
+
<h2>生成结果:</h2>
|
11 |
+
<br />
|
12 |
+
<div v-text="output" style="white-space: pre-wrap;"></div>
|
13 |
+
</div>
|
14 |
+
|
15 |
+
</div>
|
16 |
+
</template>
|
17 |
+
|
18 |
+
<style lang="scss">
|
19 |
+
@import "@primer/css/index.scss";
|
20 |
+
|
21 |
+
html,
|
22 |
+
body {
|
23 |
+
display: block;
|
24 |
+
margin: 0px;
|
25 |
+
margin-top: 0px;
|
26 |
+
margin-right: 0px;
|
27 |
+
margin-bottom: 0px;
|
28 |
+
margin-left: 0px;
|
29 |
+
}
|
30 |
+
</style>
|
31 |
+
|
32 |
+
<script>
|
33 |
+
export default {
|
34 |
+
data() {
|
35 |
+
return {
|
36 |
+
story: "",
|
37 |
+
output:"",
|
38 |
+
run123:false
|
39 |
+
};
|
40 |
+
},
|
41 |
+
methods: {
|
42 |
+
run() {
|
43 |
+
this.run123 = true
|
44 |
+
this.output = ""
|
45 |
+
var thus = this
|
46 |
+
var workerURL = window.location.href + 'llama2c-worker.js';
|
47 |
+
var worker = new Worker(workerURL, {type: 'module'});
|
48 |
+
worker.postMessage(this.story+"\n")
|
49 |
+
worker.addEventListener('message', function(event) {
|
50 |
+
var eventData = event.data;
|
51 |
+
console.log([event.data.eventType,event.data.eventData])
|
52 |
+
if (event.data.eventType == 'STDOUT') {
|
53 |
+
thus.output += event.data.eventData;
|
54 |
+
}
|
55 |
+
|
56 |
+
if (event.data.eventType == 'STDERR') {
|
57 |
+
thus.output += event.data.eventData;
|
58 |
+
thus.run123 = false
|
59 |
+
}
|
60 |
+
});
|
61 |
+
|
62 |
+
},
|
63 |
+
},
|
64 |
+
}
|
65 |
+
</script>
|
src/assets/vue.svg
ADDED
src/components/HelloWorld.vue
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script setup>
|
2 |
+
import { ref } from 'vue'
|
3 |
+
|
4 |
+
defineProps({
|
5 |
+
msg: String
|
6 |
+
})
|
7 |
+
|
8 |
+
const count = ref(0)
|
9 |
+
</script>
|
10 |
+
|
11 |
+
<template>
|
12 |
+
<h1>{{ msg }}</h1>
|
13 |
+
|
14 |
+
<div class="card">
|
15 |
+
<button type="button" @click="count++">count is {{ count }}</button>
|
16 |
+
<p>
|
17 |
+
Edit
|
18 |
+
<code>components/HelloWorld.vue</code> to test HMR
|
19 |
+
</p>
|
20 |
+
</div>
|
21 |
+
|
22 |
+
<p>
|
23 |
+
Check out
|
24 |
+
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
25 |
+
>create-vue</a
|
26 |
+
>, the official Vue + Vite starter
|
27 |
+
</p>
|
28 |
+
<p>
|
29 |
+
Install
|
30 |
+
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
|
31 |
+
in your IDE for a better DX
|
32 |
+
</p>
|
33 |
+
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
34 |
+
</template>
|
35 |
+
|
36 |
+
<style scoped>
|
37 |
+
.read-the-docs {
|
38 |
+
color: #888;
|
39 |
+
}
|
40 |
+
</style>
|
src/llama2.c/tokenizer.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:50a52ef822ee9e83de5ce9d0be0a025a773d019437f58b5ff9dcafb063ece361
|
3 |
+
size 433869
|
src/llama2c-worker.js
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
self.addEventListener('message', async function(e){
|
2 |
+
var pageDirectory = self.location.href.substr(0, self.location.href.lastIndexOf('/'));
|
3 |
+
var wasiModule = await import(pageDirectory + '/vendor/wasi.js');
|
4 |
+
var WASIJS = wasiModule.WASI;
|
5 |
+
var WASIContext = wasiModule.WASIContext;
|
6 |
+
|
7 |
+
var context;
|
8 |
+
var result;
|
9 |
+
|
10 |
+
// Initialize WASM memory.
|
11 |
+
var wasmMemory = new WebAssembly.Memory({initial:32, maximum: 10000});
|
12 |
+
var wasmImports = {
|
13 |
+
JS: {},
|
14 |
+
env: {memory: wasmMemory, table: new WebAssembly.Table({initial: 2, element: 'anyfunc'})},
|
15 |
+
};
|
16 |
+
var fileRequest = await fetch(pageDirectory + '/' + 'tokenizer.bin');
|
17 |
+
var fileContent = await fileRequest.arrayBuffer();
|
18 |
+
|
19 |
+
var modelURL = pageDirectory + '/' + 'model.bin';
|
20 |
+
if (isLocalhost()) { modelURL = pageDirectory + '/' + 'model.bin'; }
|
21 |
+
|
22 |
+
var modelFileRequest = await fetch(modelURL);
|
23 |
+
var contentLength = modelFileRequest.headers.get('Content-Length');
|
24 |
+
|
25 |
+
var responseSize = 0;
|
26 |
+
let chunksAll = new Uint8Array(contentLength); // (4.1)
|
27 |
+
|
28 |
+
for await (var chunk of streamAsyncIterable(modelFileRequest.body)) {
|
29 |
+
chunksAll.set(chunk, responseSize); // (4.2)
|
30 |
+
responseSize += chunk.length;
|
31 |
+
self.postMessage({
|
32 |
+
eventType: "MODELDOWNLOADPROGRESS",
|
33 |
+
eventData: responseSize / contentLength
|
34 |
+
});
|
35 |
+
}
|
36 |
+
|
37 |
+
async function* streamAsyncIterable(stream) {
|
38 |
+
const reader = stream.getReader()
|
39 |
+
try {
|
40 |
+
while (true) {
|
41 |
+
const { done, value } = await reader.read()
|
42 |
+
if (done) return
|
43 |
+
yield value
|
44 |
+
}
|
45 |
+
} finally {
|
46 |
+
reader.releaseLock()
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
var output = '';
|
51 |
+
|
52 |
+
context = new WASIContext({
|
53 |
+
args: ['run', 'model.bin', '-i', '标题:'+e.data, '-t',0.8,'-n',1024],
|
54 |
+
stdout: function (out) {
|
55 |
+
console.log(out)
|
56 |
+
output += out;
|
57 |
+
self.postMessage({
|
58 |
+
eventType: "STDOUT",
|
59 |
+
eventData: out
|
60 |
+
});
|
61 |
+
},
|
62 |
+
stderr: function (err) {
|
63 |
+
self.postMessage({
|
64 |
+
eventType: "STDERR",
|
65 |
+
eventData: err
|
66 |
+
});
|
67 |
+
console.error('stderr', err);
|
68 |
+
},
|
69 |
+
stdin: () => prompt('stdin:'),
|
70 |
+
fs: {
|
71 |
+
'/model.bin': {
|
72 |
+
path: modelFileRequest.name,
|
73 |
+
timestamps: {
|
74 |
+
change: new Date(modelFileRequest.headers.get('Last-Modified')),
|
75 |
+
access: new Date(modelFileRequest.headers.get('Last-Modified')),
|
76 |
+
modification: new Date(modelFileRequest.headers.get('Last-Modified')),
|
77 |
+
},
|
78 |
+
mode: 'binary',
|
79 |
+
content: new Uint8Array(chunksAll),
|
80 |
+
},
|
81 |
+
'/tokenizer.bin': {
|
82 |
+
path: 'tokenizer.bin',
|
83 |
+
timestamps: {
|
84 |
+
change: new Date(fileRequest.headers.get('Last-Modified')),
|
85 |
+
access: new Date(fileRequest.headers.get('Last-Modified')),
|
86 |
+
modification: new Date(fileRequest.headers.get('Last-Modified')),
|
87 |
+
},
|
88 |
+
mode: 'binary',
|
89 |
+
content: new Uint8Array(fileContent),
|
90 |
+
}
|
91 |
+
}
|
92 |
+
});
|
93 |
+
|
94 |
+
function isLocalhost() {
|
95 |
+
var url = self.location.origin;
|
96 |
+
return url.indexOf('127.0.0.1') !== -1 || url.indexOf('localhost') !== -1;
|
97 |
+
}
|
98 |
+
|
99 |
+
result = await WASIJS.start(fetch('llama2c.wasm'), context, wasmImports);
|
100 |
+
})
|
src/llama2c.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eea46dcbedcc1fdc2552a62e99d82bbdd5de325bb0857e8a1fc19847db85e097
|
3 |
+
size 90154
|
src/main.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createApp } from 'vue'
|
2 |
+
import App from './App.vue'
|
3 |
+
|
4 |
+
createApp(App).mount('#app')
|
src/md5.js
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
/*
|
3 |
+
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
4 |
+
* to work around bugs in some JS interpreters.
|
5 |
+
*/
|
6 |
+
function safe_add(x, y) {
|
7 |
+
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
|
8 |
+
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
9 |
+
return (msw << 16) | (lsw & 0xFFFF);
|
10 |
+
}
|
11 |
+
|
12 |
+
/*
|
13 |
+
* Bitwise rotate a 32-bit number to the left.
|
14 |
+
*/
|
15 |
+
function bit_rol(num, cnt) {
|
16 |
+
return (num << cnt) | (num >>> (32 - cnt));
|
17 |
+
}
|
18 |
+
|
19 |
+
/*
|
20 |
+
* These functions implement the four basic operations the algorithm uses.
|
21 |
+
*/
|
22 |
+
function md5_cmn(q, a, b, x, s, t) {
|
23 |
+
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
|
24 |
+
}
|
25 |
+
function md5_ff(a, b, c, d, x, s, t) {
|
26 |
+
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
27 |
+
}
|
28 |
+
function md5_gg(a, b, c, d, x, s, t) {
|
29 |
+
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
30 |
+
}
|
31 |
+
function md5_hh(a, b, c, d, x, s, t) {
|
32 |
+
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
33 |
+
}
|
34 |
+
function md5_ii(a, b, c, d, x, s, t) {
|
35 |
+
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
|
36 |
+
}
|
37 |
+
|
38 |
+
/*
|
39 |
+
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
40 |
+
*/
|
41 |
+
function binl_md5(x, len) {
|
42 |
+
/* append padding */
|
43 |
+
x[len >> 5] |= 0x80 << (len % 32);
|
44 |
+
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
45 |
+
|
46 |
+
var i, olda, oldb, oldc, oldd,
|
47 |
+
a = 1732584193,
|
48 |
+
b = -271733879,
|
49 |
+
c = -1732584194,
|
50 |
+
d = 271733878;
|
51 |
+
|
52 |
+
for (i = 0; i < x.length; i += 16) {
|
53 |
+
olda = a;
|
54 |
+
oldb = b;
|
55 |
+
oldc = c;
|
56 |
+
oldd = d;
|
57 |
+
|
58 |
+
a = md5_ff(a, b, c, d, x[i], 7, -680876936);
|
59 |
+
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
|
60 |
+
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
|
61 |
+
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
62 |
+
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
|
63 |
+
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
64 |
+
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
65 |
+
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
|
66 |
+
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
67 |
+
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
68 |
+
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
|
69 |
+
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
70 |
+
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
71 |
+
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
|
72 |
+
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
73 |
+
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
74 |
+
|
75 |
+
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
|
76 |
+
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
77 |
+
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
|
78 |
+
b = md5_gg(b, c, d, a, x[i], 20, -373897302);
|
79 |
+
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
|
80 |
+
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
|
81 |
+
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
|
82 |
+
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
|
83 |
+
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
|
84 |
+
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
85 |
+
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
|
86 |
+
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
87 |
+
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
88 |
+
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
|
89 |
+
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
90 |
+
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
91 |
+
|
92 |
+
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
|
93 |
+
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
94 |
+
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
95 |
+
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
|
96 |
+
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
97 |
+
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
98 |
+
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
|
99 |
+
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
100 |
+
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
|
101 |
+
d = md5_hh(d, a, b, c, x[i], 11, -358537222);
|
102 |
+
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
|
103 |
+
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
|
104 |
+
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
|
105 |
+
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
|
106 |
+
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
|
107 |
+
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
|
108 |
+
|
109 |
+
a = md5_ii(a, b, c, d, x[i], 6, -198630844);
|
110 |
+
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
111 |
+
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
112 |
+
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
|
113 |
+
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
114 |
+
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
115 |
+
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
|
116 |
+
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
117 |
+
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
118 |
+
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
|
119 |
+
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
120 |
+
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
121 |
+
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
|
122 |
+
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
123 |
+
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
|
124 |
+
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
|
125 |
+
|
126 |
+
a = safe_add(a, olda);
|
127 |
+
b = safe_add(b, oldb);
|
128 |
+
c = safe_add(c, oldc);
|
129 |
+
d = safe_add(d, oldd);
|
130 |
+
}
|
131 |
+
return [a, b, c, d];
|
132 |
+
}
|
133 |
+
|
134 |
+
/*
|
135 |
+
* Convert an array of little-endian words to a string
|
136 |
+
*/
|
137 |
+
function binl2rstr(input) {
|
138 |
+
var i,
|
139 |
+
output = '';
|
140 |
+
for (i = 0; i < input.length * 32; i += 8) {
|
141 |
+
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
|
142 |
+
}
|
143 |
+
return output;
|
144 |
+
}
|
145 |
+
|
146 |
+
/*
|
147 |
+
* Convert a raw string to an array of little-endian words
|
148 |
+
* Characters >255 have their high-byte silently ignored.
|
149 |
+
*/
|
150 |
+
function rstr2binl(input) {
|
151 |
+
var i,
|
152 |
+
output = [];
|
153 |
+
output[(input.length >> 2) - 1] = undefined;
|
154 |
+
for (i = 0; i < output.length; i += 1) {
|
155 |
+
output[i] = 0;
|
156 |
+
}
|
157 |
+
for (i = 0; i < input.length * 8; i += 8) {
|
158 |
+
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
|
159 |
+
}
|
160 |
+
return output;
|
161 |
+
}
|
162 |
+
|
163 |
+
/*
|
164 |
+
* Calculate the MD5 of a raw string
|
165 |
+
*/
|
166 |
+
function rstr_md5(s) {
|
167 |
+
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
|
168 |
+
}
|
169 |
+
|
170 |
+
/*
|
171 |
+
* Calculate the HMAC-MD5, of a key and some data (raw strings)
|
172 |
+
*/
|
173 |
+
function rstr_hmac_md5(key, data) {
|
174 |
+
var i,
|
175 |
+
bkey = rstr2binl(key),
|
176 |
+
ipad = [],
|
177 |
+
opad = [],
|
178 |
+
hash;
|
179 |
+
ipad[15] = opad[15] = undefined;
|
180 |
+
if (bkey.length > 16) {
|
181 |
+
bkey = binl_md5(bkey, key.length * 8);
|
182 |
+
}
|
183 |
+
for (i = 0; i < 16; i += 1) {
|
184 |
+
ipad[i] = bkey[i] ^ 0x36363636;
|
185 |
+
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
186 |
+
}
|
187 |
+
hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
|
188 |
+
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
|
189 |
+
}
|
190 |
+
|
191 |
+
/*
|
192 |
+
* Convert a raw string to a hex string
|
193 |
+
*/
|
194 |
+
function rstr2hex(input) {
|
195 |
+
var hex_tab = '0123456789abcdef',
|
196 |
+
output = '',
|
197 |
+
x,
|
198 |
+
i;
|
199 |
+
for (i = 0; i < input.length; i += 1) {
|
200 |
+
x = input.charCodeAt(i);
|
201 |
+
output += hex_tab.charAt((x >>> 4) & 0x0F) +
|
202 |
+
hex_tab.charAt(x & 0x0F);
|
203 |
+
}
|
204 |
+
return output;
|
205 |
+
}
|
206 |
+
|
207 |
+
/*
|
208 |
+
* Encode a string as utf-8
|
209 |
+
*/
|
210 |
+
function str2rstr_utf8(input) {
|
211 |
+
return unescape(encodeURIComponent(input));
|
212 |
+
}
|
213 |
+
|
214 |
+
/*
|
215 |
+
* Take string arguments and return either raw or hex encoded strings
|
216 |
+
*/
|
217 |
+
function raw_md5(s) {
|
218 |
+
return rstr_md5(str2rstr_utf8(s));
|
219 |
+
}
|
220 |
+
function hex_md5(s) {
|
221 |
+
return rstr2hex(raw_md5(s));
|
222 |
+
}
|
223 |
+
function raw_hmac_md5(k, d) {
|
224 |
+
return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d));
|
225 |
+
}
|
226 |
+
function hex_hmac_md5(k, d) {
|
227 |
+
return rstr2hex(raw_hmac_md5(k, d));
|
228 |
+
}
|
229 |
+
|
230 |
+
export function md5(string, key, raw) {
|
231 |
+
if (!key) {
|
232 |
+
if (!raw) {
|
233 |
+
return hex_md5(string);
|
234 |
+
}
|
235 |
+
return raw_md5(string);
|
236 |
+
}
|
237 |
+
if (!raw) {
|
238 |
+
return hex_hmac_md5(key, string);
|
239 |
+
}
|
240 |
+
return raw_hmac_md5(key, string);
|
241 |
+
}
|
242 |
+
|
243 |
+
|
src/model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e0f719ca15cfce20afaba40a97b196212de65efe3b5466f0c685cd9c509d7bcd
|
3 |
+
size 121630876
|
src/style.css
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
:root {
|
2 |
+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
3 |
+
font-size: 16px;
|
4 |
+
line-height: 24px;
|
5 |
+
font-weight: 400;
|
6 |
+
|
7 |
+
color-scheme: light dark;
|
8 |
+
color: rgba(255, 255, 255, 0.87);
|
9 |
+
background-color: #242424;
|
10 |
+
|
11 |
+
font-synthesis: none;
|
12 |
+
text-rendering: optimizeLegibility;
|
13 |
+
-webkit-font-smoothing: antialiased;
|
14 |
+
-moz-osx-font-smoothing: grayscale;
|
15 |
+
-webkit-text-size-adjust: 100%;
|
16 |
+
}
|
17 |
+
|
18 |
+
a {
|
19 |
+
font-weight: 500;
|
20 |
+
color: #646cff;
|
21 |
+
text-decoration: inherit;
|
22 |
+
}
|
23 |
+
a:hover {
|
24 |
+
color: #535bf2;
|
25 |
+
}
|
26 |
+
|
27 |
+
a {
|
28 |
+
font-weight: 500;
|
29 |
+
color: #646cff;
|
30 |
+
text-decoration: inherit;
|
31 |
+
}
|
32 |
+
a:hover {
|
33 |
+
color: #535bf2;
|
34 |
+
}
|
35 |
+
|
36 |
+
body {
|
37 |
+
margin: 0;
|
38 |
+
display: flex;
|
39 |
+
place-items: center;
|
40 |
+
min-width: 320px;
|
41 |
+
min-height: 100vh;
|
42 |
+
}
|
43 |
+
|
44 |
+
h1 {
|
45 |
+
font-size: 3.2em;
|
46 |
+
line-height: 1.1;
|
47 |
+
}
|
48 |
+
|
49 |
+
button {
|
50 |
+
border-radius: 8px;
|
51 |
+
border: 1px solid transparent;
|
52 |
+
padding: 0.6em 1.2em;
|
53 |
+
font-size: 1em;
|
54 |
+
font-weight: 500;
|
55 |
+
font-family: inherit;
|
56 |
+
background-color: #1a1a1a;
|
57 |
+
cursor: pointer;
|
58 |
+
transition: border-color 0.25s;
|
59 |
+
}
|
60 |
+
button:hover {
|
61 |
+
border-color: #646cff;
|
62 |
+
}
|
63 |
+
button:focus,
|
64 |
+
button:focus-visible {
|
65 |
+
outline: 4px auto -webkit-focus-ring-color;
|
66 |
+
}
|
67 |
+
|
68 |
+
.card {
|
69 |
+
padding: 2em;
|
70 |
+
}
|
71 |
+
|
72 |
+
#app {
|
73 |
+
max-width: 1280px;
|
74 |
+
margin: 0 auto;
|
75 |
+
padding: 2rem;
|
76 |
+
text-align: center;
|
77 |
+
}
|
78 |
+
|
79 |
+
@media (prefers-color-scheme: light) {
|
80 |
+
:root {
|
81 |
+
color: #213547;
|
82 |
+
background-color: #ffffff;
|
83 |
+
}
|
84 |
+
a:hover {
|
85 |
+
color: #747bff;
|
86 |
+
}
|
87 |
+
button {
|
88 |
+
background-color: #f9f9f9;
|
89 |
+
}
|
90 |
+
}
|
src/tokenizer.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i, mm) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
env: mm.env,
|
514 |
+
JS: mm.JS,
|
515 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
516 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
517 |
+
});
|
518 |
+
n.memory = mm.env.memory;
|
519 |
+
return n.init(l), n.start();
|
520 |
+
}
|
521 |
+
init(t) {
|
522 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.memory || this.instance.exports.memory, this.initialized = !0;
|
523 |
+
}
|
524 |
+
start() {
|
525 |
+
if (!this.initialized)
|
526 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
527 |
+
const t = this.instance.exports._start;
|
528 |
+
try {
|
529 |
+
t();
|
530 |
+
} catch (i) {
|
531 |
+
if (i instanceof w)
|
532 |
+
return {
|
533 |
+
exitCode: i.code,
|
534 |
+
fs: this.drive.fs
|
535 |
+
};
|
536 |
+
if (i instanceof WebAssembly.RuntimeError)
|
537 |
+
return {
|
538 |
+
exitCode: 134,
|
539 |
+
fs: this.drive.fs
|
540 |
+
};
|
541 |
+
throw i;
|
542 |
+
}
|
543 |
+
return {
|
544 |
+
instance: this.instance,
|
545 |
+
exitCode: 0,
|
546 |
+
fs: this.drive.fs
|
547 |
+
};
|
548 |
+
}
|
549 |
+
getImports(t, i) {
|
550 |
+
const n = {
|
551 |
+
args_get: this.args_get.bind(this),
|
552 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
553 |
+
clock_res_get: this.clock_res_get.bind(this),
|
554 |
+
clock_time_get: this.clock_time_get.bind(this),
|
555 |
+
environ_get: this.environ_get.bind(this),
|
556 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
557 |
+
proc_exit: this.proc_exit.bind(this),
|
558 |
+
random_get: this.random_get.bind(this),
|
559 |
+
sched_yield: this.sched_yield.bind(this),
|
560 |
+
// File Descriptors
|
561 |
+
fd_advise: this.fd_advise.bind(this),
|
562 |
+
fd_allocate: this.fd_allocate.bind(this),
|
563 |
+
fd_close: this.fd_close.bind(this),
|
564 |
+
fd_datasync: this.fd_datasync.bind(this),
|
565 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
566 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
567 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
568 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
569 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
570 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
571 |
+
fd_pread: this.fd_pread.bind(this),
|
572 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
573 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
574 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
575 |
+
fd_read: this.fd_read.bind(this),
|
576 |
+
fd_readdir: this.fd_readdir.bind(this),
|
577 |
+
fd_renumber: this.fd_renumber.bind(this),
|
578 |
+
fd_seek: this.fd_seek.bind(this),
|
579 |
+
fd_sync: this.fd_sync.bind(this),
|
580 |
+
fd_tell: this.fd_tell.bind(this),
|
581 |
+
fd_write: this.fd_write.bind(this),
|
582 |
+
// Paths
|
583 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
584 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
585 |
+
path_open: this.path_open.bind(this),
|
586 |
+
path_rename: this.path_rename.bind(this),
|
587 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
588 |
+
path_create_directory: this.path_create_directory.bind(this),
|
589 |
+
// Unimplemented
|
590 |
+
path_link: this.path_link.bind(this),
|
591 |
+
path_readlink: this.path_readlink.bind(this),
|
592 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
593 |
+
path_symlink: this.path_symlink.bind(this),
|
594 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
595 |
+
proc_raise: this.proc_raise.bind(this),
|
596 |
+
sock_accept: this.sock_accept.bind(this),
|
597 |
+
sock_recv: this.sock_recv.bind(this),
|
598 |
+
sock_send: this.sock_send.bind(this),
|
599 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
600 |
+
// Unimplemented - WASMEdge compatibility
|
601 |
+
sock_open: this.sock_open.bind(this),
|
602 |
+
sock_listen: this.sock_listen.bind(this),
|
603 |
+
sock_connect: this.sock_connect.bind(this),
|
604 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
605 |
+
sock_bind: this.sock_bind.bind(this),
|
606 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
607 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
608 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
609 |
+
};
|
610 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
611 |
+
for (const [l, s] of Object.entries(n))
|
612 |
+
n[l] = function() {
|
613 |
+
let d = s.apply(this, arguments);
|
614 |
+
if (i) {
|
615 |
+
const V = Vt();
|
616 |
+
d = i(l, [...arguments], d, V) ?? d;
|
617 |
+
}
|
618 |
+
return d;
|
619 |
+
};
|
620 |
+
return n;
|
621 |
+
}
|
622 |
+
//
|
623 |
+
// Helpers
|
624 |
+
//
|
625 |
+
get envArray() {
|
626 |
+
return Object.entries(this.context.env).map(
|
627 |
+
([t, i]) => `${t}=${i}`
|
628 |
+
);
|
629 |
+
}
|
630 |
+
//
|
631 |
+
// WASI Implementation
|
632 |
+
//
|
633 |
+
/**
|
634 |
+
* Read command-line argument data. The size of the array should match that
|
635 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
636 |
+
*/
|
637 |
+
args_get(t, i) {
|
638 |
+
const n = new DataView(this.memory.buffer);
|
639 |
+
for (const l of this.context.args) {
|
640 |
+
n.setUint32(t, i, !0), t += 4;
|
641 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
642 |
+
new Uint8Array(
|
643 |
+
this.memory.buffer,
|
644 |
+
i,
|
645 |
+
s.byteLength
|
646 |
+
).set(s), i += s.byteLength;
|
647 |
+
}
|
648 |
+
return c.SUCCESS;
|
649 |
+
}
|
650 |
+
/**
|
651 |
+
* Return command-line argument data sizes.
|
652 |
+
*/
|
653 |
+
args_sizes_get(t, i) {
|
654 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
655 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
656 |
+
}
|
657 |
+
/**
|
658 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
659 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
660 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
661 |
+
*/
|
662 |
+
clock_res_get(t, i) {
|
663 |
+
switch (t) {
|
664 |
+
case p.REALTIME:
|
665 |
+
case p.MONOTONIC:
|
666 |
+
case p.PROCESS_CPUTIME_ID:
|
667 |
+
case p.THREAD_CPUTIME_ID:
|
668 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
669 |
+
}
|
670 |
+
return c.EINVAL;
|
671 |
+
}
|
672 |
+
/**
|
673 |
+
* Return the time value of a clock.
|
674 |
+
* Note: This is similar to clock_gettime in POSIX.
|
675 |
+
*/
|
676 |
+
clock_time_get(t, i, n) {
|
677 |
+
switch (t) {
|
678 |
+
case p.REALTIME:
|
679 |
+
case p.MONOTONIC:
|
680 |
+
case p.PROCESS_CPUTIME_ID:
|
681 |
+
case p.THREAD_CPUTIME_ID:
|
682 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
683 |
+
}
|
684 |
+
return c.EINVAL;
|
685 |
+
}
|
686 |
+
/**
|
687 |
+
* Read environment variable data. The sizes of the buffers should match that
|
688 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
689 |
+
* with =s, and terminated with \0s.
|
690 |
+
*/
|
691 |
+
environ_get(t, i) {
|
692 |
+
const n = new DataView(this.memory.buffer);
|
693 |
+
for (const l of this.envArray) {
|
694 |
+
n.setUint32(t, i, !0), t += 4;
|
695 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
696 |
+
new Uint8Array(
|
697 |
+
this.memory.buffer,
|
698 |
+
i,
|
699 |
+
s.byteLength
|
700 |
+
).set(s), i += s.byteLength;
|
701 |
+
}
|
702 |
+
return c.SUCCESS;
|
703 |
+
}
|
704 |
+
/**
|
705 |
+
* Return environment variable data sizes.
|
706 |
+
*/
|
707 |
+
environ_sizes_get(t, i) {
|
708 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
709 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
710 |
+
}
|
711 |
+
/**
|
712 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
713 |
+
* termination of the program. The meanings of other values is dependent on
|
714 |
+
* the environment.
|
715 |
+
*/
|
716 |
+
proc_exit(t) {
|
717 |
+
throw new w(t);
|
718 |
+
}
|
719 |
+
/**
|
720 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
721 |
+
* implementation is unable to immediately provide sufficient high-quality
|
722 |
+
* random data. This function may execute slowly, so when large mounts of
|
723 |
+
* random data are required, it's advisable to use this function to seed a
|
724 |
+
* pseudo-random number generator, rather than to provide the random data
|
725 |
+
* directly.
|
726 |
+
*/
|
727 |
+
random_get(t, i) {
|
728 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
729 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
730 |
+
}
|
731 |
+
/**
|
732 |
+
* Temporarily yield execution of the calling thread.
|
733 |
+
* Note: This is similar to sched_yield in POSIX.
|
734 |
+
*/
|
735 |
+
sched_yield() {
|
736 |
+
return c.SUCCESS;
|
737 |
+
}
|
738 |
+
//
|
739 |
+
// File Descriptors
|
740 |
+
//
|
741 |
+
/**
|
742 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
743 |
+
*/
|
744 |
+
fd_read(t, i, n, l) {
|
745 |
+
if (t === 1 || t === 2)
|
746 |
+
return c.ENOTSUP;
|
747 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
748 |
+
let a = 0, Z = c.SUCCESS;
|
749 |
+
for (const h of d) {
|
750 |
+
let r;
|
751 |
+
if (t === 0) {
|
752 |
+
const R = this.context.stdin(h.byteLength);
|
753 |
+
if (!R)
|
754 |
+
break;
|
755 |
+
r = V.encode(R);
|
756 |
+
} else {
|
757 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
758 |
+
if (R) {
|
759 |
+
Z = R;
|
760 |
+
break;
|
761 |
+
} else
|
762 |
+
r = k;
|
763 |
+
}
|
764 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
765 |
+
h.set(r.subarray(0, o)), a += o;
|
766 |
+
}
|
767 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
768 |
+
}
|
769 |
+
/**
|
770 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
771 |
+
*/
|
772 |
+
fd_write(t, i, n, l) {
|
773 |
+
if (t === 0)
|
774 |
+
return c.ENOTSUP;
|
775 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
776 |
+
let a = 0, Z = c.SUCCESS;
|
777 |
+
for (const h of d)
|
778 |
+
if (h.byteLength !== 0) {
|
779 |
+
if (t === 1 || t === 2) {
|
780 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
781 |
+
r(o), f({ output: o });
|
782 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
783 |
+
break;
|
784 |
+
a += h.byteLength;
|
785 |
+
}
|
786 |
+
return s.setUint32(l, a, !0), Z;
|
787 |
+
}
|
788 |
+
/**
|
789 |
+
* Provide file advisory information on a file descriptor.
|
790 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
791 |
+
*/
|
792 |
+
fd_advise() {
|
793 |
+
return c.SUCCESS;
|
794 |
+
}
|
795 |
+
/**
|
796 |
+
* Force the allocation of space in a file.
|
797 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
798 |
+
*/
|
799 |
+
fd_allocate(t, i, n) {
|
800 |
+
return this.drive.pwrite(
|
801 |
+
t,
|
802 |
+
new Uint8Array(Number(n)),
|
803 |
+
Number(i)
|
804 |
+
);
|
805 |
+
}
|
806 |
+
/**
|
807 |
+
* Close a file descriptor.
|
808 |
+
* Note: This is similar to close in POSIX.
|
809 |
+
*
|
810 |
+
* @param fd
|
811 |
+
*/
|
812 |
+
fd_close(t) {
|
813 |
+
return this.drive.close(t);
|
814 |
+
}
|
815 |
+
/**
|
816 |
+
* Synchronize the data of a file to disk.
|
817 |
+
* Note: This is similar to fdatasync in POSIX.
|
818 |
+
*
|
819 |
+
* @param fd
|
820 |
+
*/
|
821 |
+
fd_datasync(t) {
|
822 |
+
return this.drive.sync(t);
|
823 |
+
}
|
824 |
+
/**
|
825 |
+
* Get the attributes of a file descriptor.
|
826 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
827 |
+
* as well as additional fields.
|
828 |
+
*
|
829 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
830 |
+
* are stored.
|
831 |
+
*
|
832 |
+
* @returns Result<fdstat, errno>
|
833 |
+
*/
|
834 |
+
fd_fdstat_get(t, i) {
|
835 |
+
if (t < 3) {
|
836 |
+
let V;
|
837 |
+
if (this.context.isTTY) {
|
838 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
839 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
840 |
+
} else
|
841 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
842 |
+
return new Uint8Array(
|
843 |
+
this.memory.buffer,
|
844 |
+
i,
|
845 |
+
V.byteLength
|
846 |
+
).set(V), c.SUCCESS;
|
847 |
+
}
|
848 |
+
if (!this.drive.exists(t))
|
849 |
+
return c.EBADF;
|
850 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
851 |
+
return new Uint8Array(
|
852 |
+
this.memory.buffer,
|
853 |
+
i,
|
854 |
+
s.byteLength
|
855 |
+
).set(s), c.SUCCESS;
|
856 |
+
}
|
857 |
+
/**
|
858 |
+
* Adjust the flags associated with a file descriptor.
|
859 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
860 |
+
*/
|
861 |
+
fd_fdstat_set_flags(t, i) {
|
862 |
+
return this.drive.setFlags(t, i);
|
863 |
+
}
|
864 |
+
/**
|
865 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
866 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
867 |
+
* would attempt to add rights
|
868 |
+
*/
|
869 |
+
fd_fdstat_set_rights() {
|
870 |
+
return c.SUCCESS;
|
871 |
+
}
|
872 |
+
/**
|
873 |
+
* Return the attributes of an open file.
|
874 |
+
*/
|
875 |
+
fd_filestat_get(t, i) {
|
876 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
877 |
+
}
|
878 |
+
/**
|
879 |
+
* Return the attributes of an open file.
|
880 |
+
* This version is used
|
881 |
+
*/
|
882 |
+
unstable_fd_filestat_get(t, i) {
|
883 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
884 |
+
}
|
885 |
+
/**
|
886 |
+
* Return the attributes of an open file.
|
887 |
+
*/
|
888 |
+
shared_fd_filestat_get(t, i, n) {
|
889 |
+
const l = n === "unstable" ? A : _;
|
890 |
+
if (t < 3) {
|
891 |
+
let Z;
|
892 |
+
switch (t) {
|
893 |
+
case 0:
|
894 |
+
Z = "/dev/stdin";
|
895 |
+
break;
|
896 |
+
case 1:
|
897 |
+
Z = "/dev/stdout";
|
898 |
+
break;
|
899 |
+
case 2:
|
900 |
+
Z = "/dev/stderr";
|
901 |
+
break;
|
902 |
+
default:
|
903 |
+
Z = "/dev/undefined";
|
904 |
+
break;
|
905 |
+
}
|
906 |
+
const h = l({
|
907 |
+
path: Z,
|
908 |
+
byteLength: 0,
|
909 |
+
timestamps: {
|
910 |
+
access: /* @__PURE__ */ new Date(),
|
911 |
+
modification: /* @__PURE__ */ new Date(),
|
912 |
+
change: /* @__PURE__ */ new Date()
|
913 |
+
},
|
914 |
+
type: X.CHARACTER_DEVICE
|
915 |
+
});
|
916 |
+
return new Uint8Array(
|
917 |
+
this.memory.buffer,
|
918 |
+
i,
|
919 |
+
h.byteLength
|
920 |
+
).set(h), c.SUCCESS;
|
921 |
+
}
|
922 |
+
const [s, d] = this.drive.stat(t);
|
923 |
+
if (s != c.SUCCESS)
|
924 |
+
return s;
|
925 |
+
f({ resolvedPath: d.path, stat: d });
|
926 |
+
const V = l(d);
|
927 |
+
return new Uint8Array(
|
928 |
+
this.memory.buffer,
|
929 |
+
i,
|
930 |
+
V.byteLength
|
931 |
+
).set(V), c.SUCCESS;
|
932 |
+
}
|
933 |
+
/**
|
934 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
935 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
936 |
+
* POSIX.
|
937 |
+
*/
|
938 |
+
fd_filestat_set_size(t, i) {
|
939 |
+
return this.drive.setSize(t, i);
|
940 |
+
}
|
941 |
+
/**
|
942 |
+
* Adjust the timestamps of an open file or directory.
|
943 |
+
* Note: This is similar to futimens in POSIX.
|
944 |
+
*/
|
945 |
+
fd_filestat_set_times(t, i, n, l) {
|
946 |
+
let s = null;
|
947 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
948 |
+
let d = null;
|
949 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
950 |
+
const V = this.drive.setAccessTime(t, s);
|
951 |
+
if (V != c.SUCCESS)
|
952 |
+
return V;
|
953 |
+
}
|
954 |
+
if (d) {
|
955 |
+
const V = this.drive.setModificationTime(t, d);
|
956 |
+
if (V != c.SUCCESS)
|
957 |
+
return V;
|
958 |
+
}
|
959 |
+
return c.SUCCESS;
|
960 |
+
}
|
961 |
+
/**
|
962 |
+
* Read from a file descriptor, without using and updating the file
|
963 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
964 |
+
*/
|
965 |
+
fd_pread(t, i, n, l, s) {
|
966 |
+
if (t === 1 || t === 2)
|
967 |
+
return c.ENOTSUP;
|
968 |
+
if (t === 0)
|
969 |
+
return this.fd_read(t, i, n, s);
|
970 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
971 |
+
let a = 0, Z = c.SUCCESS;
|
972 |
+
for (const h of V) {
|
973 |
+
const [r, o] = this.drive.pread(
|
974 |
+
t,
|
975 |
+
h.byteLength,
|
976 |
+
Number(l) + a
|
977 |
+
);
|
978 |
+
if (r !== c.SUCCESS) {
|
979 |
+
Z = r;
|
980 |
+
break;
|
981 |
+
}
|
982 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
983 |
+
h.set(o.subarray(0, R)), a += R;
|
984 |
+
}
|
985 |
+
return d.setUint32(s, a, !0), Z;
|
986 |
+
}
|
987 |
+
/**
|
988 |
+
* Return a description of the given preopened file descriptor.
|
989 |
+
*/
|
990 |
+
fd_prestat_dir_name(t, i, n) {
|
991 |
+
if (t !== 3)
|
992 |
+
return c.EBADF;
|
993 |
+
const l = new TextEncoder().encode("/");
|
994 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
995 |
+
}
|
996 |
+
/**
|
997 |
+
* Return a description of the given preopened file descriptor.
|
998 |
+
*/
|
999 |
+
fd_prestat_get(t, i) {
|
1000 |
+
if (t !== 3)
|
1001 |
+
return c.EBADF;
|
1002 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
1003 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1004 |
+
}
|
1005 |
+
/**
|
1006 |
+
* Write to a file descriptor, without using and updating the file
|
1007 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1008 |
+
*/
|
1009 |
+
fd_pwrite(t, i, n, l, s) {
|
1010 |
+
if (t === 0)
|
1011 |
+
return c.ENOTSUP;
|
1012 |
+
if (t === 1 || t === 2)
|
1013 |
+
return this.fd_write(t, i, n, s);
|
1014 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1015 |
+
let a = 0, Z = c.SUCCESS;
|
1016 |
+
for (const h of V)
|
1017 |
+
if (h.byteLength !== 0) {
|
1018 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1019 |
+
break;
|
1020 |
+
a += h.byteLength;
|
1021 |
+
}
|
1022 |
+
return d.setUint32(s, a, !0), Z;
|
1023 |
+
}
|
1024 |
+
/**
|
1025 |
+
* Read directory entries from a directory. When successful, the contents of
|
1026 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1027 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1028 |
+
* bytes holding the name of the directory entry. This function fills the
|
1029 |
+
* output buffer as much as possible, potentially truncating the last
|
1030 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1031 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1032 |
+
* oversized directory entry.
|
1033 |
+
*/
|
1034 |
+
fd_readdir(t, i, n, l, s) {
|
1035 |
+
const [d, V] = this.drive.list(t);
|
1036 |
+
if (d != c.SUCCESS)
|
1037 |
+
return d;
|
1038 |
+
let a = [], Z = 0;
|
1039 |
+
for (const { name: N, type: F } of V) {
|
1040 |
+
const g = ht(N, F, Z);
|
1041 |
+
a.push(g), Z++;
|
1042 |
+
}
|
1043 |
+
a = a.slice(Number(l));
|
1044 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1045 |
+
let o = 0;
|
1046 |
+
for (const N of a)
|
1047 |
+
r.set(N, o), o += N.byteLength;
|
1048 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1049 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1050 |
+
}
|
1051 |
+
/**
|
1052 |
+
* Atomically replace a file descriptor by renumbering another file
|
1053 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1054 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1055 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1056 |
+
* an actual file descriptor with the same number could be allocated by a
|
1057 |
+
* different thread at the same time. This function provides a way to
|
1058 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1059 |
+
* to be removed entirely.
|
1060 |
+
*/
|
1061 |
+
fd_renumber(t, i) {
|
1062 |
+
return this.drive.renumber(t, i);
|
1063 |
+
}
|
1064 |
+
/**
|
1065 |
+
* Move the offset of a file descriptor.
|
1066 |
+
*
|
1067 |
+
* The offset is specified as a bigint here
|
1068 |
+
* Note: This is similar to lseek in POSIX.
|
1069 |
+
*
|
1070 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1071 |
+
* bigint in JavaScript.
|
1072 |
+
*/
|
1073 |
+
fd_seek(t, i, n, l) {
|
1074 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1075 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1076 |
+
}
|
1077 |
+
unstable_fd_seek(t, i, n, l) {
|
1078 |
+
const s = mt[n];
|
1079 |
+
return this.fd_seek(t, i, s, l);
|
1080 |
+
}
|
1081 |
+
/**
|
1082 |
+
* Synchronize the data and metadata of a file to disk.
|
1083 |
+
* Note: This is similar to fsync in POSIX.
|
1084 |
+
*/
|
1085 |
+
fd_sync(t) {
|
1086 |
+
return this.drive.sync(t);
|
1087 |
+
}
|
1088 |
+
/**
|
1089 |
+
* Return the current offset of a file descriptor.
|
1090 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1091 |
+
*
|
1092 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1093 |
+
*
|
1094 |
+
*/
|
1095 |
+
fd_tell(t, i) {
|
1096 |
+
const [n, l] = this.drive.tell(t);
|
1097 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1098 |
+
}
|
1099 |
+
//
|
1100 |
+
// Paths
|
1101 |
+
//
|
1102 |
+
path_filestat_get(t, i, n, l, s) {
|
1103 |
+
return this.shared_path_filestat_get(
|
1104 |
+
t,
|
1105 |
+
i,
|
1106 |
+
n,
|
1107 |
+
l,
|
1108 |
+
s,
|
1109 |
+
"preview1"
|
1110 |
+
);
|
1111 |
+
}
|
1112 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1113 |
+
return this.shared_path_filestat_get(
|
1114 |
+
t,
|
1115 |
+
i,
|
1116 |
+
n,
|
1117 |
+
l,
|
1118 |
+
s,
|
1119 |
+
"unstable"
|
1120 |
+
);
|
1121 |
+
}
|
1122 |
+
/**
|
1123 |
+
* Return the attributes of a file or directory.
|
1124 |
+
* Note: This is similar to stat in POSIX.
|
1125 |
+
*/
|
1126 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1127 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1128 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1129 |
+
);
|
1130 |
+
f({ path: a });
|
1131 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1132 |
+
if (Z != c.SUCCESS)
|
1133 |
+
return Z;
|
1134 |
+
const r = V(h);
|
1135 |
+
return new Uint8Array(
|
1136 |
+
this.memory.buffer,
|
1137 |
+
s,
|
1138 |
+
r.byteLength
|
1139 |
+
).set(r), Z;
|
1140 |
+
}
|
1141 |
+
/**
|
1142 |
+
* Adjust the timestamps of a file or directory.
|
1143 |
+
* Note: This is similar to utimensat in POSIX.
|
1144 |
+
*/
|
1145 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1146 |
+
let a = null;
|
1147 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1148 |
+
let Z = null;
|
1149 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1150 |
+
const h = new TextDecoder().decode(
|
1151 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1152 |
+
);
|
1153 |
+
if (a) {
|
1154 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1155 |
+
if (r != c.SUCCESS)
|
1156 |
+
return r;
|
1157 |
+
}
|
1158 |
+
if (Z) {
|
1159 |
+
const r = this.drive.pathSetModificationTime(
|
1160 |
+
t,
|
1161 |
+
h,
|
1162 |
+
Z
|
1163 |
+
);
|
1164 |
+
if (r != c.SUCCESS)
|
1165 |
+
return r;
|
1166 |
+
}
|
1167 |
+
return c.SUCCESS;
|
1168 |
+
}
|
1169 |
+
/**
|
1170 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1171 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1172 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1173 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1174 |
+
* descriptor is guaranteed to be less than 2**31.
|
1175 |
+
* Note: This is similar to openat in POSIX.
|
1176 |
+
* @param fd: fd
|
1177 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1178 |
+
* is resolved. Not supported by Runno (symlinks)
|
1179 |
+
* @param path: string The relative path of the file or directory to open,
|
1180 |
+
* relative to the path_open::fd directory.
|
1181 |
+
* @param oflags: oflags The method by which to open the file.
|
1182 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1183 |
+
* descriptor. The implementation is allowed to return
|
1184 |
+
* a file descriptor with fewer rights than specified,
|
1185 |
+
* if and only if those rights do not apply to the type
|
1186 |
+
* of file being opened. The base rights are rights
|
1187 |
+
* that will apply to operations using the file
|
1188 |
+
* descriptor itself, while the inheriting rights are
|
1189 |
+
* rights that apply to file descriptors derived from
|
1190 |
+
* it.
|
1191 |
+
* @param fs_rights_inheriting: rights
|
1192 |
+
* @param fdflags: fdflags
|
1193 |
+
*
|
1194 |
+
*/
|
1195 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1196 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1197 |
+
f({
|
1198 |
+
path: r,
|
1199 |
+
openFlags: {
|
1200 |
+
createFileIfNone: o,
|
1201 |
+
failIfNotDir: R,
|
1202 |
+
failIfFileExists: k,
|
1203 |
+
truncateFile: P
|
1204 |
+
},
|
1205 |
+
fileDescriptorFlags: {
|
1206 |
+
flagAppend: N,
|
1207 |
+
flagDSync: F,
|
1208 |
+
flagNonBlock: g,
|
1209 |
+
flagRSync: et,
|
1210 |
+
flagSync: it
|
1211 |
+
}
|
1212 |
+
});
|
1213 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1214 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1215 |
+
}
|
1216 |
+
/**
|
1217 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1218 |
+
*/
|
1219 |
+
path_rename(t, i, n, l, s, d) {
|
1220 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1221 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1222 |
+
}
|
1223 |
+
/**
|
1224 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1225 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1226 |
+
*/
|
1227 |
+
path_unlink_file(t, i, n) {
|
1228 |
+
const l = I(this.memory, i, n);
|
1229 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1230 |
+
}
|
1231 |
+
/**
|
1232 |
+
* Concurrently poll for the occurrence of a set of events.
|
1233 |
+
*/
|
1234 |
+
poll_oneoff(t, i, n, l) {
|
1235 |
+
for (let d = 0; d < n; d++) {
|
1236 |
+
const V = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
t + d * M,
|
1239 |
+
M
|
1240 |
+
), a = Zt(V), Z = new Uint8Array(
|
1241 |
+
this.memory.buffer,
|
1242 |
+
i + d * x,
|
1243 |
+
x
|
1244 |
+
);
|
1245 |
+
let h = 0, r = c.SUCCESS;
|
1246 |
+
switch (a.type) {
|
1247 |
+
case G.CLOCK:
|
1248 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1249 |
+
;
|
1250 |
+
Z.set(
|
1251 |
+
rt(a.userdata, c.SUCCESS)
|
1252 |
+
);
|
1253 |
+
break;
|
1254 |
+
case G.FD_READ:
|
1255 |
+
if (a.fd < 3)
|
1256 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1257 |
+
else {
|
1258 |
+
const [o, R] = this.drive.stat(a.fd);
|
1259 |
+
r = o, h = R ? R.byteLength : 0;
|
1260 |
+
}
|
1261 |
+
Z.set(
|
1262 |
+
v(
|
1263 |
+
a.userdata,
|
1264 |
+
r,
|
1265 |
+
G.FD_READ,
|
1266 |
+
BigInt(h)
|
1267 |
+
)
|
1268 |
+
);
|
1269 |
+
break;
|
1270 |
+
case G.FD_WRITE:
|
1271 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1272 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1273 |
+
else {
|
1274 |
+
const [o, R] = this.drive.stat(a.fd);
|
1275 |
+
r = o, h = R ? R.byteLength : 0;
|
1276 |
+
}
|
1277 |
+
Z.set(
|
1278 |
+
v(
|
1279 |
+
a.userdata,
|
1280 |
+
r,
|
1281 |
+
G.FD_READ,
|
1282 |
+
BigInt(h)
|
1283 |
+
)
|
1284 |
+
);
|
1285 |
+
break;
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1289 |
+
}
|
1290 |
+
/**
|
1291 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1292 |
+
*/
|
1293 |
+
path_create_directory(t, i, n) {
|
1294 |
+
const l = I(this.memory, i, n);
|
1295 |
+
return this.drive.pathCreateDir(t, l);
|
1296 |
+
}
|
1297 |
+
//
|
1298 |
+
// Unimplemented - these operations are not supported by Runno
|
1299 |
+
//
|
1300 |
+
/**
|
1301 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1302 |
+
*/
|
1303 |
+
path_link() {
|
1304 |
+
return c.ENOSYS;
|
1305 |
+
}
|
1306 |
+
/**
|
1307 |
+
* Read the contents of a symbolic link.
|
1308 |
+
* Note: This is similar to readlinkat in POSIX.
|
1309 |
+
*/
|
1310 |
+
path_readlink() {
|
1311 |
+
return c.ENOSYS;
|
1312 |
+
}
|
1313 |
+
/**
|
1314 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1315 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1316 |
+
*/
|
1317 |
+
path_remove_directory() {
|
1318 |
+
return c.ENOSYS;
|
1319 |
+
}
|
1320 |
+
/**
|
1321 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1322 |
+
*/
|
1323 |
+
path_symlink() {
|
1324 |
+
return c.ENOSYS;
|
1325 |
+
}
|
1326 |
+
/**
|
1327 |
+
* Send a signal to the process of the calling thread.
|
1328 |
+
* Note: This is similar to raise in POSIX.
|
1329 |
+
*/
|
1330 |
+
proc_raise() {
|
1331 |
+
return c.ENOSYS;
|
1332 |
+
}
|
1333 |
+
/**
|
1334 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1335 |
+
*/
|
1336 |
+
sock_accept() {
|
1337 |
+
return c.ENOSYS;
|
1338 |
+
}
|
1339 |
+
/**
|
1340 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1341 |
+
* though it also supports reading the data into multiple buffers in the
|
1342 |
+
* manner of readv.
|
1343 |
+
*/
|
1344 |
+
sock_recv() {
|
1345 |
+
return c.ENOSYS;
|
1346 |
+
}
|
1347 |
+
/**
|
1348 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1349 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1350 |
+
* writev.
|
1351 |
+
*/
|
1352 |
+
sock_send() {
|
1353 |
+
return c.ENOSYS;
|
1354 |
+
}
|
1355 |
+
/**
|
1356 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1357 |
+
* shutdown in POSIX.
|
1358 |
+
*/
|
1359 |
+
sock_shutdown() {
|
1360 |
+
return c.ENOSYS;
|
1361 |
+
}
|
1362 |
+
//
|
1363 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1364 |
+
//
|
1365 |
+
sock_open() {
|
1366 |
+
return c.ENOSYS;
|
1367 |
+
}
|
1368 |
+
sock_listen() {
|
1369 |
+
return c.ENOSYS;
|
1370 |
+
}
|
1371 |
+
sock_connect() {
|
1372 |
+
return c.ENOSYS;
|
1373 |
+
}
|
1374 |
+
sock_setsockopt() {
|
1375 |
+
return c.ENOSYS;
|
1376 |
+
}
|
1377 |
+
sock_bind() {
|
1378 |
+
return c.ENOSYS;
|
1379 |
+
}
|
1380 |
+
sock_getlocaladdr() {
|
1381 |
+
return c.ENOSYS;
|
1382 |
+
}
|
1383 |
+
sock_getpeeraddr() {
|
1384 |
+
return c.ENOSYS;
|
1385 |
+
}
|
1386 |
+
sock_getaddrinfo() {
|
1387 |
+
return c.ENOSYS;
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1391 |
+
class w extends Error {
|
1392 |
+
constructor(i) {
|
1393 |
+
super();
|
1394 |
+
m(this, "code");
|
1395 |
+
this.code = i;
|
1396 |
+
}
|
1397 |
+
}
|
1398 |
+
function I(e, t, i) {
|
1399 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1400 |
+
}
|
1401 |
+
function K(e, t, i) {
|
1402 |
+
let n = Array(i);
|
1403 |
+
for (let l = 0; l < i; l++) {
|
1404 |
+
const s = e.getUint32(t, !0);
|
1405 |
+
t += 4;
|
1406 |
+
const d = e.getUint32(t, !0);
|
1407 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1408 |
+
}
|
1409 |
+
return n;
|
1410 |
+
}
|
1411 |
+
function Zt(e) {
|
1412 |
+
const t = new Uint8Array(8);
|
1413 |
+
t.set(e.subarray(0, 8));
|
1414 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1415 |
+
switch (i) {
|
1416 |
+
case G.FD_READ:
|
1417 |
+
case G.FD_WRITE:
|
1418 |
+
return {
|
1419 |
+
userdata: t,
|
1420 |
+
type: i,
|
1421 |
+
fd: n.getUint32(0, !0)
|
1422 |
+
};
|
1423 |
+
case G.CLOCK:
|
1424 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1425 |
+
return {
|
1426 |
+
userdata: t,
|
1427 |
+
type: i,
|
1428 |
+
id: n.getUint32(0, !0),
|
1429 |
+
timeout: W(a),
|
1430 |
+
precision: W(a + V)
|
1431 |
+
};
|
1432 |
+
}
|
1433 |
+
}
|
1434 |
+
function _(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function A(e) {
|
1439 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1440 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1441 |
+
}
|
1442 |
+
function J(e, t, i) {
|
1443 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1444 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1445 |
+
}
|
1446 |
+
function ht(e, t, i) {
|
1447 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1448 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1449 |
+
}
|
1450 |
+
function rt(e, t) {
|
1451 |
+
const i = new Uint8Array(32);
|
1452 |
+
i.set(e, 0);
|
1453 |
+
const n = new DataView(i.buffer);
|
1454 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1455 |
+
}
|
1456 |
+
function v(e, t, i, n) {
|
1457 |
+
const l = new Uint8Array(32);
|
1458 |
+
l.set(e, 0);
|
1459 |
+
const s = new DataView(l.buffer);
|
1460 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1461 |
+
}
|
1462 |
+
function H(e, t = 0) {
|
1463 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1464 |
+
for (let l = 0, s; l < e.length; l++)
|
1465 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1466 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1467 |
+
}
|
1468 |
+
function L(e) {
|
1469 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1470 |
+
}
|
1471 |
+
function W(e) {
|
1472 |
+
return new Date(Number(e / BigInt(1e6)));
|
1473 |
+
}
|
1474 |
+
const mt = {
|
1475 |
+
[Y.CUR]: y.CUR,
|
1476 |
+
[Y.END]: y.END,
|
1477 |
+
[Y.SET]: y.SET
|
1478 |
+
};
|
1479 |
+
class Xt {
|
1480 |
+
constructor(t) {
|
1481 |
+
m(this, "fs");
|
1482 |
+
m(this, "args");
|
1483 |
+
// Program args (like from a terminal program)
|
1484 |
+
m(this, "env");
|
1485 |
+
// Environment (like a .env file)
|
1486 |
+
m(this, "stdin");
|
1487 |
+
m(this, "stdout");
|
1488 |
+
m(this, "stderr");
|
1489 |
+
m(this, "debug");
|
1490 |
+
m(this, "isTTY");
|
1491 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1492 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1493 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NVUFBPUlQiLGVbZS5FQUdBSU49Nl09IkVBR0FJTiIsZVtlLkVBTFJFQURZPTddPSJFQUxSRUFEWSIsZVtlLkVCQURGPThdPSJFQkFERiIsZVtlLkVCQURNU0c9OV09IkVCQURNU0ciLGVbZS5FQlVTWT0xMF09IkVCVVNZIixlW2UuRUNBTkNFTEVEPTExXT0iRUNBTkNFTEVEIixlW2UuRUNISUxEPTEyXT0iRUNISUxEIix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IoMCwwKSxudWxsO2NvbnN0IHM9bmV3IFVpbnQ4QXJyYXkodCw0LG4pLGE9bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKHMuc2xpY2UoMCxlKSksZj1zLnNsaWNlKGUscy5sZW5ndGgpO3JldHVybiBpLnNldEludDMyKDAsZi5ieXRlTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1497 |
+
function ut() {
|
1498 |
+
let e;
|
1499 |
+
try {
|
1500 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1501 |
+
throw "";
|
1502 |
+
return new Worker(e);
|
1503 |
+
} catch {
|
1504 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1505 |
+
} finally {
|
1506 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1507 |
+
}
|
1508 |
+
}
|
1509 |
+
function ot(e, t) {
|
1510 |
+
e.postMessage(t);
|
1511 |
+
}
|
1512 |
+
class St extends Error {
|
1513 |
+
}
|
1514 |
+
class Gt {
|
1515 |
+
constructor(t, i) {
|
1516 |
+
m(this, "binaryURL");
|
1517 |
+
// 8kb should be big enough
|
1518 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1519 |
+
m(this, "context");
|
1520 |
+
m(this, "result");
|
1521 |
+
m(this, "worker");
|
1522 |
+
m(this, "reject");
|
1523 |
+
this.binaryURL = t, this.context = i;
|
1524 |
+
}
|
1525 |
+
async start() {
|
1526 |
+
if (this.result)
|
1527 |
+
throw new Error("WASIWorker Host can only be started once");
|
1528 |
+
return this.result = new Promise((t, i) => {
|
1529 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1530 |
+
var s, d, V, a, Z, h;
|
1531 |
+
const l = n.data;
|
1532 |
+
switch (l.type) {
|
1533 |
+
case "stdout":
|
1534 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1535 |
+
break;
|
1536 |
+
case "stderr":
|
1537 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1538 |
+
break;
|
1539 |
+
case "debug":
|
1540 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1541 |
+
Z,
|
1542 |
+
l.name,
|
1543 |
+
l.args,
|
1544 |
+
l.ret,
|
1545 |
+
l.data
|
1546 |
+
);
|
1547 |
+
break;
|
1548 |
+
case "result":
|
1549 |
+
t(l.result);
|
1550 |
+
break;
|
1551 |
+
case "crash":
|
1552 |
+
i(l.error);
|
1553 |
+
break;
|
1554 |
+
}
|
1555 |
+
}), ot(this.worker, {
|
1556 |
+
target: "client",
|
1557 |
+
type: "start",
|
1558 |
+
binaryURL: this.binaryURL,
|
1559 |
+
stdinBuffer: this.stdinBuffer,
|
1560 |
+
// Unfortunately can't just splat these because it includes types
|
1561 |
+
// that can't be sent as a message.
|
1562 |
+
args: this.context.args,
|
1563 |
+
env: this.context.env,
|
1564 |
+
fs: this.context.fs,
|
1565 |
+
isTTY: this.context.isTTY
|
1566 |
+
});
|
1567 |
+
}), this.result;
|
1568 |
+
}
|
1569 |
+
kill() {
|
1570 |
+
var t;
|
1571 |
+
if (!this.worker)
|
1572 |
+
throw new Error("WASIWorker has not started");
|
1573 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1574 |
+
}
|
1575 |
+
async pushStdin(t) {
|
1576 |
+
const i = new DataView(this.stdinBuffer);
|
1577 |
+
for (; i.getInt32(0) !== 0; )
|
1578 |
+
await new Promise((s) => setTimeout(s, 0));
|
1579 |
+
const n = new TextEncoder().encode(t);
|
1580 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1581 |
+
}
|
1582 |
+
async pushEOF() {
|
1583 |
+
const t = new DataView(this.stdinBuffer);
|
1584 |
+
for (; t.getInt32(0) !== 0; )
|
1585 |
+
await new Promise((i) => setTimeout(i, 0));
|
1586 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1587 |
+
}
|
1588 |
+
}
|
1589 |
+
export {
|
1590 |
+
q as WASI,
|
1591 |
+
Xt as WASIContext,
|
1592 |
+
bt as WASISnapshotPreview1,
|
1593 |
+
Gt as WASIWorkerHost,
|
1594 |
+
St as WASIWorkerHostKilledError
|
1595 |
+
};
|
src/vendor/vendor/wasi.js.original
ADDED
@@ -0,0 +1,1591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
514 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
515 |
+
});
|
516 |
+
return n.init(l), n.start();
|
517 |
+
}
|
518 |
+
init(t) {
|
519 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.instance.exports.memory, this.initialized = !0;
|
520 |
+
}
|
521 |
+
start() {
|
522 |
+
if (!this.initialized)
|
523 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
524 |
+
const t = this.instance.exports._start;
|
525 |
+
try {
|
526 |
+
t();
|
527 |
+
} catch (i) {
|
528 |
+
if (i instanceof w)
|
529 |
+
return {
|
530 |
+
exitCode: i.code,
|
531 |
+
fs: this.drive.fs
|
532 |
+
};
|
533 |
+
if (i instanceof WebAssembly.RuntimeError)
|
534 |
+
return {
|
535 |
+
exitCode: 134,
|
536 |
+
fs: this.drive.fs
|
537 |
+
};
|
538 |
+
throw i;
|
539 |
+
}
|
540 |
+
return {
|
541 |
+
exitCode: 0,
|
542 |
+
fs: this.drive.fs
|
543 |
+
};
|
544 |
+
}
|
545 |
+
getImports(t, i) {
|
546 |
+
const n = {
|
547 |
+
args_get: this.args_get.bind(this),
|
548 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
549 |
+
clock_res_get: this.clock_res_get.bind(this),
|
550 |
+
clock_time_get: this.clock_time_get.bind(this),
|
551 |
+
environ_get: this.environ_get.bind(this),
|
552 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
553 |
+
proc_exit: this.proc_exit.bind(this),
|
554 |
+
random_get: this.random_get.bind(this),
|
555 |
+
sched_yield: this.sched_yield.bind(this),
|
556 |
+
// File Descriptors
|
557 |
+
fd_advise: this.fd_advise.bind(this),
|
558 |
+
fd_allocate: this.fd_allocate.bind(this),
|
559 |
+
fd_close: this.fd_close.bind(this),
|
560 |
+
fd_datasync: this.fd_datasync.bind(this),
|
561 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
562 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
563 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
564 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
565 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
566 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
567 |
+
fd_pread: this.fd_pread.bind(this),
|
568 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
569 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
570 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
571 |
+
fd_read: this.fd_read.bind(this),
|
572 |
+
fd_readdir: this.fd_readdir.bind(this),
|
573 |
+
fd_renumber: this.fd_renumber.bind(this),
|
574 |
+
fd_seek: this.fd_seek.bind(this),
|
575 |
+
fd_sync: this.fd_sync.bind(this),
|
576 |
+
fd_tell: this.fd_tell.bind(this),
|
577 |
+
fd_write: this.fd_write.bind(this),
|
578 |
+
// Paths
|
579 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
580 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
581 |
+
path_open: this.path_open.bind(this),
|
582 |
+
path_rename: this.path_rename.bind(this),
|
583 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
584 |
+
path_create_directory: this.path_create_directory.bind(this),
|
585 |
+
// Unimplemented
|
586 |
+
path_link: this.path_link.bind(this),
|
587 |
+
path_readlink: this.path_readlink.bind(this),
|
588 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
589 |
+
path_symlink: this.path_symlink.bind(this),
|
590 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
591 |
+
proc_raise: this.proc_raise.bind(this),
|
592 |
+
sock_accept: this.sock_accept.bind(this),
|
593 |
+
sock_recv: this.sock_recv.bind(this),
|
594 |
+
sock_send: this.sock_send.bind(this),
|
595 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
596 |
+
// Unimplemented - WASMEdge compatibility
|
597 |
+
sock_open: this.sock_open.bind(this),
|
598 |
+
sock_listen: this.sock_listen.bind(this),
|
599 |
+
sock_connect: this.sock_connect.bind(this),
|
600 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
601 |
+
sock_bind: this.sock_bind.bind(this),
|
602 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
603 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
604 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
605 |
+
};
|
606 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
607 |
+
for (const [l, s] of Object.entries(n))
|
608 |
+
n[l] = function() {
|
609 |
+
let d = s.apply(this, arguments);
|
610 |
+
if (i) {
|
611 |
+
const V = Vt();
|
612 |
+
d = i(l, [...arguments], d, V) ?? d;
|
613 |
+
}
|
614 |
+
return d;
|
615 |
+
};
|
616 |
+
return n;
|
617 |
+
}
|
618 |
+
//
|
619 |
+
// Helpers
|
620 |
+
//
|
621 |
+
get envArray() {
|
622 |
+
return Object.entries(this.context.env).map(
|
623 |
+
([t, i]) => `${t}=${i}`
|
624 |
+
);
|
625 |
+
}
|
626 |
+
//
|
627 |
+
// WASI Implementation
|
628 |
+
//
|
629 |
+
/**
|
630 |
+
* Read command-line argument data. The size of the array should match that
|
631 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
632 |
+
*/
|
633 |
+
args_get(t, i) {
|
634 |
+
const n = new DataView(this.memory.buffer);
|
635 |
+
for (const l of this.context.args) {
|
636 |
+
n.setUint32(t, i, !0), t += 4;
|
637 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
638 |
+
new Uint8Array(
|
639 |
+
this.memory.buffer,
|
640 |
+
i,
|
641 |
+
s.byteLength
|
642 |
+
).set(s), i += s.byteLength;
|
643 |
+
}
|
644 |
+
return c.SUCCESS;
|
645 |
+
}
|
646 |
+
/**
|
647 |
+
* Return command-line argument data sizes.
|
648 |
+
*/
|
649 |
+
args_sizes_get(t, i) {
|
650 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
651 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
652 |
+
}
|
653 |
+
/**
|
654 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
655 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
656 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
657 |
+
*/
|
658 |
+
clock_res_get(t, i) {
|
659 |
+
switch (t) {
|
660 |
+
case p.REALTIME:
|
661 |
+
case p.MONOTONIC:
|
662 |
+
case p.PROCESS_CPUTIME_ID:
|
663 |
+
case p.THREAD_CPUTIME_ID:
|
664 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
665 |
+
}
|
666 |
+
return c.EINVAL;
|
667 |
+
}
|
668 |
+
/**
|
669 |
+
* Return the time value of a clock.
|
670 |
+
* Note: This is similar to clock_gettime in POSIX.
|
671 |
+
*/
|
672 |
+
clock_time_get(t, i, n) {
|
673 |
+
switch (t) {
|
674 |
+
case p.REALTIME:
|
675 |
+
case p.MONOTONIC:
|
676 |
+
case p.PROCESS_CPUTIME_ID:
|
677 |
+
case p.THREAD_CPUTIME_ID:
|
678 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
679 |
+
}
|
680 |
+
return c.EINVAL;
|
681 |
+
}
|
682 |
+
/**
|
683 |
+
* Read environment variable data. The sizes of the buffers should match that
|
684 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
685 |
+
* with =s, and terminated with \0s.
|
686 |
+
*/
|
687 |
+
environ_get(t, i) {
|
688 |
+
const n = new DataView(this.memory.buffer);
|
689 |
+
for (const l of this.envArray) {
|
690 |
+
n.setUint32(t, i, !0), t += 4;
|
691 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
692 |
+
new Uint8Array(
|
693 |
+
this.memory.buffer,
|
694 |
+
i,
|
695 |
+
s.byteLength
|
696 |
+
).set(s), i += s.byteLength;
|
697 |
+
}
|
698 |
+
return c.SUCCESS;
|
699 |
+
}
|
700 |
+
/**
|
701 |
+
* Return environment variable data sizes.
|
702 |
+
*/
|
703 |
+
environ_sizes_get(t, i) {
|
704 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
705 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
706 |
+
}
|
707 |
+
/**
|
708 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
709 |
+
* termination of the program. The meanings of other values is dependent on
|
710 |
+
* the environment.
|
711 |
+
*/
|
712 |
+
proc_exit(t) {
|
713 |
+
throw new w(t);
|
714 |
+
}
|
715 |
+
/**
|
716 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
717 |
+
* implementation is unable to immediately provide sufficient high-quality
|
718 |
+
* random data. This function may execute slowly, so when large mounts of
|
719 |
+
* random data are required, it's advisable to use this function to seed a
|
720 |
+
* pseudo-random number generator, rather than to provide the random data
|
721 |
+
* directly.
|
722 |
+
*/
|
723 |
+
random_get(t, i) {
|
724 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
725 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
726 |
+
}
|
727 |
+
/**
|
728 |
+
* Temporarily yield execution of the calling thread.
|
729 |
+
* Note: This is similar to sched_yield in POSIX.
|
730 |
+
*/
|
731 |
+
sched_yield() {
|
732 |
+
return c.SUCCESS;
|
733 |
+
}
|
734 |
+
//
|
735 |
+
// File Descriptors
|
736 |
+
//
|
737 |
+
/**
|
738 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
739 |
+
*/
|
740 |
+
fd_read(t, i, n, l) {
|
741 |
+
if (t === 1 || t === 2)
|
742 |
+
return c.ENOTSUP;
|
743 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
744 |
+
let a = 0, Z = c.SUCCESS;
|
745 |
+
for (const h of d) {
|
746 |
+
let r;
|
747 |
+
if (t === 0) {
|
748 |
+
const R = this.context.stdin(h.byteLength);
|
749 |
+
if (!R)
|
750 |
+
break;
|
751 |
+
r = V.encode(R);
|
752 |
+
} else {
|
753 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
754 |
+
if (R) {
|
755 |
+
Z = R;
|
756 |
+
break;
|
757 |
+
} else
|
758 |
+
r = k;
|
759 |
+
}
|
760 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
761 |
+
h.set(r.subarray(0, o)), a += o;
|
762 |
+
}
|
763 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
764 |
+
}
|
765 |
+
/**
|
766 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
767 |
+
*/
|
768 |
+
fd_write(t, i, n, l) {
|
769 |
+
if (t === 0)
|
770 |
+
return c.ENOTSUP;
|
771 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
772 |
+
let a = 0, Z = c.SUCCESS;
|
773 |
+
for (const h of d)
|
774 |
+
if (h.byteLength !== 0) {
|
775 |
+
if (t === 1 || t === 2) {
|
776 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
777 |
+
r(o), f({ output: o });
|
778 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
779 |
+
break;
|
780 |
+
a += h.byteLength;
|
781 |
+
}
|
782 |
+
return s.setUint32(l, a, !0), Z;
|
783 |
+
}
|
784 |
+
/**
|
785 |
+
* Provide file advisory information on a file descriptor.
|
786 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
787 |
+
*/
|
788 |
+
fd_advise() {
|
789 |
+
return c.SUCCESS;
|
790 |
+
}
|
791 |
+
/**
|
792 |
+
* Force the allocation of space in a file.
|
793 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
794 |
+
*/
|
795 |
+
fd_allocate(t, i, n) {
|
796 |
+
return this.drive.pwrite(
|
797 |
+
t,
|
798 |
+
new Uint8Array(Number(n)),
|
799 |
+
Number(i)
|
800 |
+
);
|
801 |
+
}
|
802 |
+
/**
|
803 |
+
* Close a file descriptor.
|
804 |
+
* Note: This is similar to close in POSIX.
|
805 |
+
*
|
806 |
+
* @param fd
|
807 |
+
*/
|
808 |
+
fd_close(t) {
|
809 |
+
return this.drive.close(t);
|
810 |
+
}
|
811 |
+
/**
|
812 |
+
* Synchronize the data of a file to disk.
|
813 |
+
* Note: This is similar to fdatasync in POSIX.
|
814 |
+
*
|
815 |
+
* @param fd
|
816 |
+
*/
|
817 |
+
fd_datasync(t) {
|
818 |
+
return this.drive.sync(t);
|
819 |
+
}
|
820 |
+
/**
|
821 |
+
* Get the attributes of a file descriptor.
|
822 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
823 |
+
* as well as additional fields.
|
824 |
+
*
|
825 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
826 |
+
* are stored.
|
827 |
+
*
|
828 |
+
* @returns Result<fdstat, errno>
|
829 |
+
*/
|
830 |
+
fd_fdstat_get(t, i) {
|
831 |
+
if (t < 3) {
|
832 |
+
let V;
|
833 |
+
if (this.context.isTTY) {
|
834 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
835 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
836 |
+
} else
|
837 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
838 |
+
return new Uint8Array(
|
839 |
+
this.memory.buffer,
|
840 |
+
i,
|
841 |
+
V.byteLength
|
842 |
+
).set(V), c.SUCCESS;
|
843 |
+
}
|
844 |
+
if (!this.drive.exists(t))
|
845 |
+
return c.EBADF;
|
846 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
847 |
+
return new Uint8Array(
|
848 |
+
this.memory.buffer,
|
849 |
+
i,
|
850 |
+
s.byteLength
|
851 |
+
).set(s), c.SUCCESS;
|
852 |
+
}
|
853 |
+
/**
|
854 |
+
* Adjust the flags associated with a file descriptor.
|
855 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
856 |
+
*/
|
857 |
+
fd_fdstat_set_flags(t, i) {
|
858 |
+
return this.drive.setFlags(t, i);
|
859 |
+
}
|
860 |
+
/**
|
861 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
862 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
863 |
+
* would attempt to add rights
|
864 |
+
*/
|
865 |
+
fd_fdstat_set_rights() {
|
866 |
+
return c.SUCCESS;
|
867 |
+
}
|
868 |
+
/**
|
869 |
+
* Return the attributes of an open file.
|
870 |
+
*/
|
871 |
+
fd_filestat_get(t, i) {
|
872 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
873 |
+
}
|
874 |
+
/**
|
875 |
+
* Return the attributes of an open file.
|
876 |
+
* This version is used
|
877 |
+
*/
|
878 |
+
unstable_fd_filestat_get(t, i) {
|
879 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
880 |
+
}
|
881 |
+
/**
|
882 |
+
* Return the attributes of an open file.
|
883 |
+
*/
|
884 |
+
shared_fd_filestat_get(t, i, n) {
|
885 |
+
const l = n === "unstable" ? A : _;
|
886 |
+
if (t < 3) {
|
887 |
+
let Z;
|
888 |
+
switch (t) {
|
889 |
+
case 0:
|
890 |
+
Z = "/dev/stdin";
|
891 |
+
break;
|
892 |
+
case 1:
|
893 |
+
Z = "/dev/stdout";
|
894 |
+
break;
|
895 |
+
case 2:
|
896 |
+
Z = "/dev/stderr";
|
897 |
+
break;
|
898 |
+
default:
|
899 |
+
Z = "/dev/undefined";
|
900 |
+
break;
|
901 |
+
}
|
902 |
+
const h = l({
|
903 |
+
path: Z,
|
904 |
+
byteLength: 0,
|
905 |
+
timestamps: {
|
906 |
+
access: /* @__PURE__ */ new Date(),
|
907 |
+
modification: /* @__PURE__ */ new Date(),
|
908 |
+
change: /* @__PURE__ */ new Date()
|
909 |
+
},
|
910 |
+
type: X.CHARACTER_DEVICE
|
911 |
+
});
|
912 |
+
return new Uint8Array(
|
913 |
+
this.memory.buffer,
|
914 |
+
i,
|
915 |
+
h.byteLength
|
916 |
+
).set(h), c.SUCCESS;
|
917 |
+
}
|
918 |
+
const [s, d] = this.drive.stat(t);
|
919 |
+
if (s != c.SUCCESS)
|
920 |
+
return s;
|
921 |
+
f({ resolvedPath: d.path, stat: d });
|
922 |
+
const V = l(d);
|
923 |
+
return new Uint8Array(
|
924 |
+
this.memory.buffer,
|
925 |
+
i,
|
926 |
+
V.byteLength
|
927 |
+
).set(V), c.SUCCESS;
|
928 |
+
}
|
929 |
+
/**
|
930 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
931 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
932 |
+
* POSIX.
|
933 |
+
*/
|
934 |
+
fd_filestat_set_size(t, i) {
|
935 |
+
return this.drive.setSize(t, i);
|
936 |
+
}
|
937 |
+
/**
|
938 |
+
* Adjust the timestamps of an open file or directory.
|
939 |
+
* Note: This is similar to futimens in POSIX.
|
940 |
+
*/
|
941 |
+
fd_filestat_set_times(t, i, n, l) {
|
942 |
+
let s = null;
|
943 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
944 |
+
let d = null;
|
945 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
946 |
+
const V = this.drive.setAccessTime(t, s);
|
947 |
+
if (V != c.SUCCESS)
|
948 |
+
return V;
|
949 |
+
}
|
950 |
+
if (d) {
|
951 |
+
const V = this.drive.setModificationTime(t, d);
|
952 |
+
if (V != c.SUCCESS)
|
953 |
+
return V;
|
954 |
+
}
|
955 |
+
return c.SUCCESS;
|
956 |
+
}
|
957 |
+
/**
|
958 |
+
* Read from a file descriptor, without using and updating the file
|
959 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
960 |
+
*/
|
961 |
+
fd_pread(t, i, n, l, s) {
|
962 |
+
if (t === 1 || t === 2)
|
963 |
+
return c.ENOTSUP;
|
964 |
+
if (t === 0)
|
965 |
+
return this.fd_read(t, i, n, s);
|
966 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
967 |
+
let a = 0, Z = c.SUCCESS;
|
968 |
+
for (const h of V) {
|
969 |
+
const [r, o] = this.drive.pread(
|
970 |
+
t,
|
971 |
+
h.byteLength,
|
972 |
+
Number(l) + a
|
973 |
+
);
|
974 |
+
if (r !== c.SUCCESS) {
|
975 |
+
Z = r;
|
976 |
+
break;
|
977 |
+
}
|
978 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
979 |
+
h.set(o.subarray(0, R)), a += R;
|
980 |
+
}
|
981 |
+
return d.setUint32(s, a, !0), Z;
|
982 |
+
}
|
983 |
+
/**
|
984 |
+
* Return a description of the given preopened file descriptor.
|
985 |
+
*/
|
986 |
+
fd_prestat_dir_name(t, i, n) {
|
987 |
+
if (t !== 3)
|
988 |
+
return c.EBADF;
|
989 |
+
const l = new TextEncoder().encode("/");
|
990 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
991 |
+
}
|
992 |
+
/**
|
993 |
+
* Return a description of the given preopened file descriptor.
|
994 |
+
*/
|
995 |
+
fd_prestat_get(t, i) {
|
996 |
+
if (t !== 3)
|
997 |
+
return c.EBADF;
|
998 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
999 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1000 |
+
}
|
1001 |
+
/**
|
1002 |
+
* Write to a file descriptor, without using and updating the file
|
1003 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1004 |
+
*/
|
1005 |
+
fd_pwrite(t, i, n, l, s) {
|
1006 |
+
if (t === 0)
|
1007 |
+
return c.ENOTSUP;
|
1008 |
+
if (t === 1 || t === 2)
|
1009 |
+
return this.fd_write(t, i, n, s);
|
1010 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1011 |
+
let a = 0, Z = c.SUCCESS;
|
1012 |
+
for (const h of V)
|
1013 |
+
if (h.byteLength !== 0) {
|
1014 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1015 |
+
break;
|
1016 |
+
a += h.byteLength;
|
1017 |
+
}
|
1018 |
+
return d.setUint32(s, a, !0), Z;
|
1019 |
+
}
|
1020 |
+
/**
|
1021 |
+
* Read directory entries from a directory. When successful, the contents of
|
1022 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1023 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1024 |
+
* bytes holding the name of the directory entry. This function fills the
|
1025 |
+
* output buffer as much as possible, potentially truncating the last
|
1026 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1027 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1028 |
+
* oversized directory entry.
|
1029 |
+
*/
|
1030 |
+
fd_readdir(t, i, n, l, s) {
|
1031 |
+
const [d, V] = this.drive.list(t);
|
1032 |
+
if (d != c.SUCCESS)
|
1033 |
+
return d;
|
1034 |
+
let a = [], Z = 0;
|
1035 |
+
for (const { name: N, type: F } of V) {
|
1036 |
+
const g = ht(N, F, Z);
|
1037 |
+
a.push(g), Z++;
|
1038 |
+
}
|
1039 |
+
a = a.slice(Number(l));
|
1040 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1041 |
+
let o = 0;
|
1042 |
+
for (const N of a)
|
1043 |
+
r.set(N, o), o += N.byteLength;
|
1044 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1045 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1046 |
+
}
|
1047 |
+
/**
|
1048 |
+
* Atomically replace a file descriptor by renumbering another file
|
1049 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1050 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1051 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1052 |
+
* an actual file descriptor with the same number could be allocated by a
|
1053 |
+
* different thread at the same time. This function provides a way to
|
1054 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1055 |
+
* to be removed entirely.
|
1056 |
+
*/
|
1057 |
+
fd_renumber(t, i) {
|
1058 |
+
return this.drive.renumber(t, i);
|
1059 |
+
}
|
1060 |
+
/**
|
1061 |
+
* Move the offset of a file descriptor.
|
1062 |
+
*
|
1063 |
+
* The offset is specified as a bigint here
|
1064 |
+
* Note: This is similar to lseek in POSIX.
|
1065 |
+
*
|
1066 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1067 |
+
* bigint in JavaScript.
|
1068 |
+
*/
|
1069 |
+
fd_seek(t, i, n, l) {
|
1070 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1071 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1072 |
+
}
|
1073 |
+
unstable_fd_seek(t, i, n, l) {
|
1074 |
+
const s = mt[n];
|
1075 |
+
return this.fd_seek(t, i, s, l);
|
1076 |
+
}
|
1077 |
+
/**
|
1078 |
+
* Synchronize the data and metadata of a file to disk.
|
1079 |
+
* Note: This is similar to fsync in POSIX.
|
1080 |
+
*/
|
1081 |
+
fd_sync(t) {
|
1082 |
+
return this.drive.sync(t);
|
1083 |
+
}
|
1084 |
+
/**
|
1085 |
+
* Return the current offset of a file descriptor.
|
1086 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1087 |
+
*
|
1088 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1089 |
+
*
|
1090 |
+
*/
|
1091 |
+
fd_tell(t, i) {
|
1092 |
+
const [n, l] = this.drive.tell(t);
|
1093 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1094 |
+
}
|
1095 |
+
//
|
1096 |
+
// Paths
|
1097 |
+
//
|
1098 |
+
path_filestat_get(t, i, n, l, s) {
|
1099 |
+
return this.shared_path_filestat_get(
|
1100 |
+
t,
|
1101 |
+
i,
|
1102 |
+
n,
|
1103 |
+
l,
|
1104 |
+
s,
|
1105 |
+
"preview1"
|
1106 |
+
);
|
1107 |
+
}
|
1108 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1109 |
+
return this.shared_path_filestat_get(
|
1110 |
+
t,
|
1111 |
+
i,
|
1112 |
+
n,
|
1113 |
+
l,
|
1114 |
+
s,
|
1115 |
+
"unstable"
|
1116 |
+
);
|
1117 |
+
}
|
1118 |
+
/**
|
1119 |
+
* Return the attributes of a file or directory.
|
1120 |
+
* Note: This is similar to stat in POSIX.
|
1121 |
+
*/
|
1122 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1123 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1124 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1125 |
+
);
|
1126 |
+
f({ path: a });
|
1127 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1128 |
+
if (Z != c.SUCCESS)
|
1129 |
+
return Z;
|
1130 |
+
const r = V(h);
|
1131 |
+
return new Uint8Array(
|
1132 |
+
this.memory.buffer,
|
1133 |
+
s,
|
1134 |
+
r.byteLength
|
1135 |
+
).set(r), Z;
|
1136 |
+
}
|
1137 |
+
/**
|
1138 |
+
* Adjust the timestamps of a file or directory.
|
1139 |
+
* Note: This is similar to utimensat in POSIX.
|
1140 |
+
*/
|
1141 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1142 |
+
let a = null;
|
1143 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1144 |
+
let Z = null;
|
1145 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1146 |
+
const h = new TextDecoder().decode(
|
1147 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1148 |
+
);
|
1149 |
+
if (a) {
|
1150 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1151 |
+
if (r != c.SUCCESS)
|
1152 |
+
return r;
|
1153 |
+
}
|
1154 |
+
if (Z) {
|
1155 |
+
const r = this.drive.pathSetModificationTime(
|
1156 |
+
t,
|
1157 |
+
h,
|
1158 |
+
Z
|
1159 |
+
);
|
1160 |
+
if (r != c.SUCCESS)
|
1161 |
+
return r;
|
1162 |
+
}
|
1163 |
+
return c.SUCCESS;
|
1164 |
+
}
|
1165 |
+
/**
|
1166 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1167 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1168 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1169 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1170 |
+
* descriptor is guaranteed to be less than 2**31.
|
1171 |
+
* Note: This is similar to openat in POSIX.
|
1172 |
+
* @param fd: fd
|
1173 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1174 |
+
* is resolved. Not supported by Runno (symlinks)
|
1175 |
+
* @param path: string The relative path of the file or directory to open,
|
1176 |
+
* relative to the path_open::fd directory.
|
1177 |
+
* @param oflags: oflags The method by which to open the file.
|
1178 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1179 |
+
* descriptor. The implementation is allowed to return
|
1180 |
+
* a file descriptor with fewer rights than specified,
|
1181 |
+
* if and only if those rights do not apply to the type
|
1182 |
+
* of file being opened. The base rights are rights
|
1183 |
+
* that will apply to operations using the file
|
1184 |
+
* descriptor itself, while the inheriting rights are
|
1185 |
+
* rights that apply to file descriptors derived from
|
1186 |
+
* it.
|
1187 |
+
* @param fs_rights_inheriting: rights
|
1188 |
+
* @param fdflags: fdflags
|
1189 |
+
*
|
1190 |
+
*/
|
1191 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1192 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1193 |
+
f({
|
1194 |
+
path: r,
|
1195 |
+
openFlags: {
|
1196 |
+
createFileIfNone: o,
|
1197 |
+
failIfNotDir: R,
|
1198 |
+
failIfFileExists: k,
|
1199 |
+
truncateFile: P
|
1200 |
+
},
|
1201 |
+
fileDescriptorFlags: {
|
1202 |
+
flagAppend: N,
|
1203 |
+
flagDSync: F,
|
1204 |
+
flagNonBlock: g,
|
1205 |
+
flagRSync: et,
|
1206 |
+
flagSync: it
|
1207 |
+
}
|
1208 |
+
});
|
1209 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1210 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1211 |
+
}
|
1212 |
+
/**
|
1213 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1214 |
+
*/
|
1215 |
+
path_rename(t, i, n, l, s, d) {
|
1216 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1217 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1218 |
+
}
|
1219 |
+
/**
|
1220 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1221 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1222 |
+
*/
|
1223 |
+
path_unlink_file(t, i, n) {
|
1224 |
+
const l = I(this.memory, i, n);
|
1225 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1226 |
+
}
|
1227 |
+
/**
|
1228 |
+
* Concurrently poll for the occurrence of a set of events.
|
1229 |
+
*/
|
1230 |
+
poll_oneoff(t, i, n, l) {
|
1231 |
+
for (let d = 0; d < n; d++) {
|
1232 |
+
const V = new Uint8Array(
|
1233 |
+
this.memory.buffer,
|
1234 |
+
t + d * M,
|
1235 |
+
M
|
1236 |
+
), a = Zt(V), Z = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
i + d * x,
|
1239 |
+
x
|
1240 |
+
);
|
1241 |
+
let h = 0, r = c.SUCCESS;
|
1242 |
+
switch (a.type) {
|
1243 |
+
case G.CLOCK:
|
1244 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1245 |
+
;
|
1246 |
+
Z.set(
|
1247 |
+
rt(a.userdata, c.SUCCESS)
|
1248 |
+
);
|
1249 |
+
break;
|
1250 |
+
case G.FD_READ:
|
1251 |
+
if (a.fd < 3)
|
1252 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1253 |
+
else {
|
1254 |
+
const [o, R] = this.drive.stat(a.fd);
|
1255 |
+
r = o, h = R ? R.byteLength : 0;
|
1256 |
+
}
|
1257 |
+
Z.set(
|
1258 |
+
v(
|
1259 |
+
a.userdata,
|
1260 |
+
r,
|
1261 |
+
G.FD_READ,
|
1262 |
+
BigInt(h)
|
1263 |
+
)
|
1264 |
+
);
|
1265 |
+
break;
|
1266 |
+
case G.FD_WRITE:
|
1267 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1268 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1269 |
+
else {
|
1270 |
+
const [o, R] = this.drive.stat(a.fd);
|
1271 |
+
r = o, h = R ? R.byteLength : 0;
|
1272 |
+
}
|
1273 |
+
Z.set(
|
1274 |
+
v(
|
1275 |
+
a.userdata,
|
1276 |
+
r,
|
1277 |
+
G.FD_READ,
|
1278 |
+
BigInt(h)
|
1279 |
+
)
|
1280 |
+
);
|
1281 |
+
break;
|
1282 |
+
}
|
1283 |
+
}
|
1284 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1285 |
+
}
|
1286 |
+
/**
|
1287 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1288 |
+
*/
|
1289 |
+
path_create_directory(t, i, n) {
|
1290 |
+
const l = I(this.memory, i, n);
|
1291 |
+
return this.drive.pathCreateDir(t, l);
|
1292 |
+
}
|
1293 |
+
//
|
1294 |
+
// Unimplemented - these operations are not supported by Runno
|
1295 |
+
//
|
1296 |
+
/**
|
1297 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1298 |
+
*/
|
1299 |
+
path_link() {
|
1300 |
+
return c.ENOSYS;
|
1301 |
+
}
|
1302 |
+
/**
|
1303 |
+
* Read the contents of a symbolic link.
|
1304 |
+
* Note: This is similar to readlinkat in POSIX.
|
1305 |
+
*/
|
1306 |
+
path_readlink() {
|
1307 |
+
return c.ENOSYS;
|
1308 |
+
}
|
1309 |
+
/**
|
1310 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1311 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1312 |
+
*/
|
1313 |
+
path_remove_directory() {
|
1314 |
+
return c.ENOSYS;
|
1315 |
+
}
|
1316 |
+
/**
|
1317 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1318 |
+
*/
|
1319 |
+
path_symlink() {
|
1320 |
+
return c.ENOSYS;
|
1321 |
+
}
|
1322 |
+
/**
|
1323 |
+
* Send a signal to the process of the calling thread.
|
1324 |
+
* Note: This is similar to raise in POSIX.
|
1325 |
+
*/
|
1326 |
+
proc_raise() {
|
1327 |
+
return c.ENOSYS;
|
1328 |
+
}
|
1329 |
+
/**
|
1330 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1331 |
+
*/
|
1332 |
+
sock_accept() {
|
1333 |
+
return c.ENOSYS;
|
1334 |
+
}
|
1335 |
+
/**
|
1336 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1337 |
+
* though it also supports reading the data into multiple buffers in the
|
1338 |
+
* manner of readv.
|
1339 |
+
*/
|
1340 |
+
sock_recv() {
|
1341 |
+
return c.ENOSYS;
|
1342 |
+
}
|
1343 |
+
/**
|
1344 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1345 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1346 |
+
* writev.
|
1347 |
+
*/
|
1348 |
+
sock_send() {
|
1349 |
+
return c.ENOSYS;
|
1350 |
+
}
|
1351 |
+
/**
|
1352 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1353 |
+
* shutdown in POSIX.
|
1354 |
+
*/
|
1355 |
+
sock_shutdown() {
|
1356 |
+
return c.ENOSYS;
|
1357 |
+
}
|
1358 |
+
//
|
1359 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1360 |
+
//
|
1361 |
+
sock_open() {
|
1362 |
+
return c.ENOSYS;
|
1363 |
+
}
|
1364 |
+
sock_listen() {
|
1365 |
+
return c.ENOSYS;
|
1366 |
+
}
|
1367 |
+
sock_connect() {
|
1368 |
+
return c.ENOSYS;
|
1369 |
+
}
|
1370 |
+
sock_setsockopt() {
|
1371 |
+
return c.ENOSYS;
|
1372 |
+
}
|
1373 |
+
sock_bind() {
|
1374 |
+
return c.ENOSYS;
|
1375 |
+
}
|
1376 |
+
sock_getlocaladdr() {
|
1377 |
+
return c.ENOSYS;
|
1378 |
+
}
|
1379 |
+
sock_getpeeraddr() {
|
1380 |
+
return c.ENOSYS;
|
1381 |
+
}
|
1382 |
+
sock_getaddrinfo() {
|
1383 |
+
return c.ENOSYS;
|
1384 |
+
}
|
1385 |
+
}
|
1386 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1387 |
+
class w extends Error {
|
1388 |
+
constructor(i) {
|
1389 |
+
super();
|
1390 |
+
m(this, "code");
|
1391 |
+
this.code = i;
|
1392 |
+
}
|
1393 |
+
}
|
1394 |
+
function I(e, t, i) {
|
1395 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1396 |
+
}
|
1397 |
+
function K(e, t, i) {
|
1398 |
+
let n = Array(i);
|
1399 |
+
for (let l = 0; l < i; l++) {
|
1400 |
+
const s = e.getUint32(t, !0);
|
1401 |
+
t += 4;
|
1402 |
+
const d = e.getUint32(t, !0);
|
1403 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1404 |
+
}
|
1405 |
+
return n;
|
1406 |
+
}
|
1407 |
+
function Zt(e) {
|
1408 |
+
const t = new Uint8Array(8);
|
1409 |
+
t.set(e.subarray(0, 8));
|
1410 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1411 |
+
switch (i) {
|
1412 |
+
case G.FD_READ:
|
1413 |
+
case G.FD_WRITE:
|
1414 |
+
return {
|
1415 |
+
userdata: t,
|
1416 |
+
type: i,
|
1417 |
+
fd: n.getUint32(0, !0)
|
1418 |
+
};
|
1419 |
+
case G.CLOCK:
|
1420 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1421 |
+
return {
|
1422 |
+
userdata: t,
|
1423 |
+
type: i,
|
1424 |
+
id: n.getUint32(0, !0),
|
1425 |
+
timeout: W(a),
|
1426 |
+
precision: W(a + V)
|
1427 |
+
};
|
1428 |
+
}
|
1429 |
+
}
|
1430 |
+
function _(e) {
|
1431 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1432 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1433 |
+
}
|
1434 |
+
function A(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function J(e, t, i) {
|
1439 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1440 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1441 |
+
}
|
1442 |
+
function ht(e, t, i) {
|
1443 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1444 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1445 |
+
}
|
1446 |
+
function rt(e, t) {
|
1447 |
+
const i = new Uint8Array(32);
|
1448 |
+
i.set(e, 0);
|
1449 |
+
const n = new DataView(i.buffer);
|
1450 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1451 |
+
}
|
1452 |
+
function v(e, t, i, n) {
|
1453 |
+
const l = new Uint8Array(32);
|
1454 |
+
l.set(e, 0);
|
1455 |
+
const s = new DataView(l.buffer);
|
1456 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1457 |
+
}
|
1458 |
+
function H(e, t = 0) {
|
1459 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1460 |
+
for (let l = 0, s; l < e.length; l++)
|
1461 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1462 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1463 |
+
}
|
1464 |
+
function L(e) {
|
1465 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1466 |
+
}
|
1467 |
+
function W(e) {
|
1468 |
+
return new Date(Number(e / BigInt(1e6)));
|
1469 |
+
}
|
1470 |
+
const mt = {
|
1471 |
+
[Y.CUR]: y.CUR,
|
1472 |
+
[Y.END]: y.END,
|
1473 |
+
[Y.SET]: y.SET
|
1474 |
+
};
|
1475 |
+
class Xt {
|
1476 |
+
constructor(t) {
|
1477 |
+
m(this, "fs");
|
1478 |
+
m(this, "args");
|
1479 |
+
// Program args (like from a terminal program)
|
1480 |
+
m(this, "env");
|
1481 |
+
// Environment (like a .env file)
|
1482 |
+
m(this, "stdin");
|
1483 |
+
m(this, "stdout");
|
1484 |
+
m(this, "stderr");
|
1485 |
+
m(this, "debug");
|
1486 |
+
m(this, "isTTY");
|
1487 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1488 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1489 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1490 |
+
}
|
1491 |
+
}
|
1492 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NVUFBPUlQiLGVbZS5FQUdBSU49Nl09IkVBR0FJTiIsZVtlLkVBTFJFQURZPTddPSJFQUxSRUFEWSIsZVtlLkVCQURGPThdPSJFQkFERiIsZVtlLkVCQURNU0c9OV09IkVCQURNU0ciLGVbZS5FQlVTWT0xMF09IkVCVVNZIixlW2UuRUNBTkNFTEVEPTExXT0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5nZXRJbnQzMigwKTtpZihuPDApcmV0dXJuIGkuc2V0SW50MzIoMCwwKSxudWxsO2NvbnN0IHM9bmV3IFVpbnQ4QXJyYXkodCw0LG4pLGE9bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKHMuc2xpY2UoMCxlKSksZj1zLnNsaWNlKGUscy5sZW5ndGgpO3JldHVybiBpLnNldEludDMyKDAsZi5ieXRlTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1493 |
+
function ut() {
|
1494 |
+
let e;
|
1495 |
+
try {
|
1496 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1497 |
+
throw "";
|
1498 |
+
return new Worker(e);
|
1499 |
+
} catch {
|
1500 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1501 |
+
} finally {
|
1502 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1503 |
+
}
|
1504 |
+
}
|
1505 |
+
function ot(e, t) {
|
1506 |
+
e.postMessage(t);
|
1507 |
+
}
|
1508 |
+
class St extends Error {
|
1509 |
+
}
|
1510 |
+
class Gt {
|
1511 |
+
constructor(t, i) {
|
1512 |
+
m(this, "binaryURL");
|
1513 |
+
// 8kb should be big enough
|
1514 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1515 |
+
m(this, "context");
|
1516 |
+
m(this, "result");
|
1517 |
+
m(this, "worker");
|
1518 |
+
m(this, "reject");
|
1519 |
+
this.binaryURL = t, this.context = i;
|
1520 |
+
}
|
1521 |
+
async start() {
|
1522 |
+
if (this.result)
|
1523 |
+
throw new Error("WASIWorker Host can only be started once");
|
1524 |
+
return this.result = new Promise((t, i) => {
|
1525 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1526 |
+
var s, d, V, a, Z, h;
|
1527 |
+
const l = n.data;
|
1528 |
+
switch (l.type) {
|
1529 |
+
case "stdout":
|
1530 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1531 |
+
break;
|
1532 |
+
case "stderr":
|
1533 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1534 |
+
break;
|
1535 |
+
case "debug":
|
1536 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1537 |
+
Z,
|
1538 |
+
l.name,
|
1539 |
+
l.args,
|
1540 |
+
l.ret,
|
1541 |
+
l.data
|
1542 |
+
);
|
1543 |
+
break;
|
1544 |
+
case "result":
|
1545 |
+
t(l.result);
|
1546 |
+
break;
|
1547 |
+
case "crash":
|
1548 |
+
i(l.error);
|
1549 |
+
break;
|
1550 |
+
}
|
1551 |
+
}), ot(this.worker, {
|
1552 |
+
target: "client",
|
1553 |
+
type: "start",
|
1554 |
+
binaryURL: this.binaryURL,
|
1555 |
+
stdinBuffer: this.stdinBuffer,
|
1556 |
+
// Unfortunately can't just splat these because it includes types
|
1557 |
+
// that can't be sent as a message.
|
1558 |
+
args: this.context.args,
|
1559 |
+
env: this.context.env,
|
1560 |
+
fs: this.context.fs,
|
1561 |
+
isTTY: this.context.isTTY
|
1562 |
+
});
|
1563 |
+
}), this.result;
|
1564 |
+
}
|
1565 |
+
kill() {
|
1566 |
+
var t;
|
1567 |
+
if (!this.worker)
|
1568 |
+
throw new Error("WASIWorker has not started");
|
1569 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1570 |
+
}
|
1571 |
+
async pushStdin(t) {
|
1572 |
+
const i = new DataView(this.stdinBuffer);
|
1573 |
+
for (; i.getInt32(0) !== 0; )
|
1574 |
+
await new Promise((s) => setTimeout(s, 0));
|
1575 |
+
const n = new TextEncoder().encode(t);
|
1576 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1577 |
+
}
|
1578 |
+
async pushEOF() {
|
1579 |
+
const t = new DataView(this.stdinBuffer);
|
1580 |
+
for (; t.getInt32(0) !== 0; )
|
1581 |
+
await new Promise((i) => setTimeout(i, 0));
|
1582 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1583 |
+
}
|
1584 |
+
}
|
1585 |
+
export {
|
1586 |
+
q as WASI,
|
1587 |
+
Xt as WASIContext,
|
1588 |
+
bt as WASISnapshotPreview1,
|
1589 |
+
Gt as WASIWorkerHost,
|
1590 |
+
St as WASIWorkerHostKilledError
|
1591 |
+
};
|
src/vendor/wasi.js
ADDED
@@ -0,0 +1,1595 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i, mm) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
env: mm.env,
|
514 |
+
JS: mm.JS,
|
515 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
516 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
517 |
+
});
|
518 |
+
n.memory = mm.env.memory;
|
519 |
+
return n.init(l), n.start();
|
520 |
+
}
|
521 |
+
init(t) {
|
522 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.memory || this.instance.exports.memory, this.initialized = !0;
|
523 |
+
}
|
524 |
+
start() {
|
525 |
+
if (!this.initialized)
|
526 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
527 |
+
const t = this.instance.exports._start;
|
528 |
+
try {
|
529 |
+
t();
|
530 |
+
} catch (i) {
|
531 |
+
if (i instanceof w)
|
532 |
+
return {
|
533 |
+
exitCode: i.code,
|
534 |
+
fs: this.drive.fs
|
535 |
+
};
|
536 |
+
if (i instanceof WebAssembly.RuntimeError)
|
537 |
+
return {
|
538 |
+
exitCode: 134,
|
539 |
+
fs: this.drive.fs
|
540 |
+
};
|
541 |
+
throw i;
|
542 |
+
}
|
543 |
+
return {
|
544 |
+
instance: this.instance,
|
545 |
+
exitCode: 0,
|
546 |
+
fs: this.drive.fs
|
547 |
+
};
|
548 |
+
}
|
549 |
+
getImports(t, i) {
|
550 |
+
const n = {
|
551 |
+
args_get: this.args_get.bind(this),
|
552 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
553 |
+
clock_res_get: this.clock_res_get.bind(this),
|
554 |
+
clock_time_get: this.clock_time_get.bind(this),
|
555 |
+
environ_get: this.environ_get.bind(this),
|
556 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
557 |
+
proc_exit: this.proc_exit.bind(this),
|
558 |
+
random_get: this.random_get.bind(this),
|
559 |
+
sched_yield: this.sched_yield.bind(this),
|
560 |
+
// File Descriptors
|
561 |
+
fd_advise: this.fd_advise.bind(this),
|
562 |
+
fd_allocate: this.fd_allocate.bind(this),
|
563 |
+
fd_close: this.fd_close.bind(this),
|
564 |
+
fd_datasync: this.fd_datasync.bind(this),
|
565 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
566 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
567 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
568 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
569 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
570 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
571 |
+
fd_pread: this.fd_pread.bind(this),
|
572 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
573 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
574 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
575 |
+
fd_read: this.fd_read.bind(this),
|
576 |
+
fd_readdir: this.fd_readdir.bind(this),
|
577 |
+
fd_renumber: this.fd_renumber.bind(this),
|
578 |
+
fd_seek: this.fd_seek.bind(this),
|
579 |
+
fd_sync: this.fd_sync.bind(this),
|
580 |
+
fd_tell: this.fd_tell.bind(this),
|
581 |
+
fd_write: this.fd_write.bind(this),
|
582 |
+
// Paths
|
583 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
584 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
585 |
+
path_open: this.path_open.bind(this),
|
586 |
+
path_rename: this.path_rename.bind(this),
|
587 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
588 |
+
path_create_directory: this.path_create_directory.bind(this),
|
589 |
+
// Unimplemented
|
590 |
+
path_link: this.path_link.bind(this),
|
591 |
+
path_readlink: this.path_readlink.bind(this),
|
592 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
593 |
+
path_symlink: this.path_symlink.bind(this),
|
594 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
595 |
+
proc_raise: this.proc_raise.bind(this),
|
596 |
+
sock_accept: this.sock_accept.bind(this),
|
597 |
+
sock_recv: this.sock_recv.bind(this),
|
598 |
+
sock_send: this.sock_send.bind(this),
|
599 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
600 |
+
// Unimplemented - WASMEdge compatibility
|
601 |
+
sock_open: this.sock_open.bind(this),
|
602 |
+
sock_listen: this.sock_listen.bind(this),
|
603 |
+
sock_connect: this.sock_connect.bind(this),
|
604 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
605 |
+
sock_bind: this.sock_bind.bind(this),
|
606 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
607 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
608 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
609 |
+
};
|
610 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
611 |
+
for (const [l, s] of Object.entries(n))
|
612 |
+
n[l] = function() {
|
613 |
+
let d = s.apply(this, arguments);
|
614 |
+
if (i) {
|
615 |
+
const V = Vt();
|
616 |
+
d = i(l, [...arguments], d, V) ?? d;
|
617 |
+
}
|
618 |
+
return d;
|
619 |
+
};
|
620 |
+
return n;
|
621 |
+
}
|
622 |
+
//
|
623 |
+
// Helpers
|
624 |
+
//
|
625 |
+
get envArray() {
|
626 |
+
return Object.entries(this.context.env).map(
|
627 |
+
([t, i]) => `${t}=${i}`
|
628 |
+
);
|
629 |
+
}
|
630 |
+
//
|
631 |
+
// WASI Implementation
|
632 |
+
//
|
633 |
+
/**
|
634 |
+
* Read command-line argument data. The size of the array should match that
|
635 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
636 |
+
*/
|
637 |
+
args_get(t, i) {
|
638 |
+
const n = new DataView(this.memory.buffer);
|
639 |
+
for (const l of this.context.args) {
|
640 |
+
n.setUint32(t, i, !0), t += 4;
|
641 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
642 |
+
new Uint8Array(
|
643 |
+
this.memory.buffer,
|
644 |
+
i,
|
645 |
+
s.byteLength
|
646 |
+
).set(s), i += s.byteLength;
|
647 |
+
}
|
648 |
+
return c.SUCCESS;
|
649 |
+
}
|
650 |
+
/**
|
651 |
+
* Return command-line argument data sizes.
|
652 |
+
*/
|
653 |
+
args_sizes_get(t, i) {
|
654 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
655 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
656 |
+
}
|
657 |
+
/**
|
658 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
659 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
660 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
661 |
+
*/
|
662 |
+
clock_res_get(t, i) {
|
663 |
+
switch (t) {
|
664 |
+
case p.REALTIME:
|
665 |
+
case p.MONOTONIC:
|
666 |
+
case p.PROCESS_CPUTIME_ID:
|
667 |
+
case p.THREAD_CPUTIME_ID:
|
668 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
669 |
+
}
|
670 |
+
return c.EINVAL;
|
671 |
+
}
|
672 |
+
/**
|
673 |
+
* Return the time value of a clock.
|
674 |
+
* Note: This is similar to clock_gettime in POSIX.
|
675 |
+
*/
|
676 |
+
clock_time_get(t, i, n) {
|
677 |
+
switch (t) {
|
678 |
+
case p.REALTIME:
|
679 |
+
case p.MONOTONIC:
|
680 |
+
case p.PROCESS_CPUTIME_ID:
|
681 |
+
case p.THREAD_CPUTIME_ID:
|
682 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
683 |
+
}
|
684 |
+
return c.EINVAL;
|
685 |
+
}
|
686 |
+
/**
|
687 |
+
* Read environment variable data. The sizes of the buffers should match that
|
688 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
689 |
+
* with =s, and terminated with \0s.
|
690 |
+
*/
|
691 |
+
environ_get(t, i) {
|
692 |
+
const n = new DataView(this.memory.buffer);
|
693 |
+
for (const l of this.envArray) {
|
694 |
+
n.setUint32(t, i, !0), t += 4;
|
695 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
696 |
+
new Uint8Array(
|
697 |
+
this.memory.buffer,
|
698 |
+
i,
|
699 |
+
s.byteLength
|
700 |
+
).set(s), i += s.byteLength;
|
701 |
+
}
|
702 |
+
return c.SUCCESS;
|
703 |
+
}
|
704 |
+
/**
|
705 |
+
* Return environment variable data sizes.
|
706 |
+
*/
|
707 |
+
environ_sizes_get(t, i) {
|
708 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
709 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
710 |
+
}
|
711 |
+
/**
|
712 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
713 |
+
* termination of the program. The meanings of other values is dependent on
|
714 |
+
* the environment.
|
715 |
+
*/
|
716 |
+
proc_exit(t) {
|
717 |
+
throw new w(t);
|
718 |
+
}
|
719 |
+
/**
|
720 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
721 |
+
* implementation is unable to immediately provide sufficient high-quality
|
722 |
+
* random data. This function may execute slowly, so when large mounts of
|
723 |
+
* random data are required, it's advisable to use this function to seed a
|
724 |
+
* pseudo-random number generator, rather than to provide the random data
|
725 |
+
* directly.
|
726 |
+
*/
|
727 |
+
random_get(t, i) {
|
728 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
729 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
730 |
+
}
|
731 |
+
/**
|
732 |
+
* Temporarily yield execution of the calling thread.
|
733 |
+
* Note: This is similar to sched_yield in POSIX.
|
734 |
+
*/
|
735 |
+
sched_yield() {
|
736 |
+
return c.SUCCESS;
|
737 |
+
}
|
738 |
+
//
|
739 |
+
// File Descriptors
|
740 |
+
//
|
741 |
+
/**
|
742 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
743 |
+
*/
|
744 |
+
fd_read(t, i, n, l) {
|
745 |
+
if (t === 1 || t === 2)
|
746 |
+
return c.ENOTSUP;
|
747 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
748 |
+
let a = 0, Z = c.SUCCESS;
|
749 |
+
for (const h of d) {
|
750 |
+
let r;
|
751 |
+
if (t === 0) {
|
752 |
+
const R = this.context.stdin(h.byteLength);
|
753 |
+
if (!R)
|
754 |
+
break;
|
755 |
+
r = V.encode(R);
|
756 |
+
} else {
|
757 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
758 |
+
if (R) {
|
759 |
+
Z = R;
|
760 |
+
break;
|
761 |
+
} else
|
762 |
+
r = k;
|
763 |
+
}
|
764 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
765 |
+
h.set(r.subarray(0, o)), a += o;
|
766 |
+
}
|
767 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
768 |
+
}
|
769 |
+
/**
|
770 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
771 |
+
*/
|
772 |
+
fd_write(t, i, n, l) {
|
773 |
+
if (t === 0)
|
774 |
+
return c.ENOTSUP;
|
775 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
776 |
+
let a = 0, Z = c.SUCCESS;
|
777 |
+
for (const h of d)
|
778 |
+
if (h.byteLength !== 0) {
|
779 |
+
if (t === 1 || t === 2) {
|
780 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
781 |
+
r(o), f({ output: o });
|
782 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
783 |
+
break;
|
784 |
+
a += h.byteLength;
|
785 |
+
}
|
786 |
+
return s.setUint32(l, a, !0), Z;
|
787 |
+
}
|
788 |
+
/**
|
789 |
+
* Provide file advisory information on a file descriptor.
|
790 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
791 |
+
*/
|
792 |
+
fd_advise() {
|
793 |
+
return c.SUCCESS;
|
794 |
+
}
|
795 |
+
/**
|
796 |
+
* Force the allocation of space in a file.
|
797 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
798 |
+
*/
|
799 |
+
fd_allocate(t, i, n) {
|
800 |
+
return this.drive.pwrite(
|
801 |
+
t,
|
802 |
+
new Uint8Array(Number(n)),
|
803 |
+
Number(i)
|
804 |
+
);
|
805 |
+
}
|
806 |
+
/**
|
807 |
+
* Close a file descriptor.
|
808 |
+
* Note: This is similar to close in POSIX.
|
809 |
+
*
|
810 |
+
* @param fd
|
811 |
+
*/
|
812 |
+
fd_close(t) {
|
813 |
+
return this.drive.close(t);
|
814 |
+
}
|
815 |
+
/**
|
816 |
+
* Synchronize the data of a file to disk.
|
817 |
+
* Note: This is similar to fdatasync in POSIX.
|
818 |
+
*
|
819 |
+
* @param fd
|
820 |
+
*/
|
821 |
+
fd_datasync(t) {
|
822 |
+
return this.drive.sync(t);
|
823 |
+
}
|
824 |
+
/**
|
825 |
+
* Get the attributes of a file descriptor.
|
826 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
827 |
+
* as well as additional fields.
|
828 |
+
*
|
829 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
830 |
+
* are stored.
|
831 |
+
*
|
832 |
+
* @returns Result<fdstat, errno>
|
833 |
+
*/
|
834 |
+
fd_fdstat_get(t, i) {
|
835 |
+
if (t < 3) {
|
836 |
+
let V;
|
837 |
+
if (this.context.isTTY) {
|
838 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
839 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
840 |
+
} else
|
841 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
842 |
+
return new Uint8Array(
|
843 |
+
this.memory.buffer,
|
844 |
+
i,
|
845 |
+
V.byteLength
|
846 |
+
).set(V), c.SUCCESS;
|
847 |
+
}
|
848 |
+
if (!this.drive.exists(t))
|
849 |
+
return c.EBADF;
|
850 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
851 |
+
return new Uint8Array(
|
852 |
+
this.memory.buffer,
|
853 |
+
i,
|
854 |
+
s.byteLength
|
855 |
+
).set(s), c.SUCCESS;
|
856 |
+
}
|
857 |
+
/**
|
858 |
+
* Adjust the flags associated with a file descriptor.
|
859 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
860 |
+
*/
|
861 |
+
fd_fdstat_set_flags(t, i) {
|
862 |
+
return this.drive.setFlags(t, i);
|
863 |
+
}
|
864 |
+
/**
|
865 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
866 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
867 |
+
* would attempt to add rights
|
868 |
+
*/
|
869 |
+
fd_fdstat_set_rights() {
|
870 |
+
return c.SUCCESS;
|
871 |
+
}
|
872 |
+
/**
|
873 |
+
* Return the attributes of an open file.
|
874 |
+
*/
|
875 |
+
fd_filestat_get(t, i) {
|
876 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
877 |
+
}
|
878 |
+
/**
|
879 |
+
* Return the attributes of an open file.
|
880 |
+
* This version is used
|
881 |
+
*/
|
882 |
+
unstable_fd_filestat_get(t, i) {
|
883 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
884 |
+
}
|
885 |
+
/**
|
886 |
+
* Return the attributes of an open file.
|
887 |
+
*/
|
888 |
+
shared_fd_filestat_get(t, i, n) {
|
889 |
+
const l = n === "unstable" ? A : _;
|
890 |
+
if (t < 3) {
|
891 |
+
let Z;
|
892 |
+
switch (t) {
|
893 |
+
case 0:
|
894 |
+
Z = "/dev/stdin";
|
895 |
+
break;
|
896 |
+
case 1:
|
897 |
+
Z = "/dev/stdout";
|
898 |
+
break;
|
899 |
+
case 2:
|
900 |
+
Z = "/dev/stderr";
|
901 |
+
break;
|
902 |
+
default:
|
903 |
+
Z = "/dev/undefined";
|
904 |
+
break;
|
905 |
+
}
|
906 |
+
const h = l({
|
907 |
+
path: Z,
|
908 |
+
byteLength: 0,
|
909 |
+
timestamps: {
|
910 |
+
access: /* @__PURE__ */ new Date(),
|
911 |
+
modification: /* @__PURE__ */ new Date(),
|
912 |
+
change: /* @__PURE__ */ new Date()
|
913 |
+
},
|
914 |
+
type: X.CHARACTER_DEVICE
|
915 |
+
});
|
916 |
+
return new Uint8Array(
|
917 |
+
this.memory.buffer,
|
918 |
+
i,
|
919 |
+
h.byteLength
|
920 |
+
).set(h), c.SUCCESS;
|
921 |
+
}
|
922 |
+
const [s, d] = this.drive.stat(t);
|
923 |
+
if (s != c.SUCCESS)
|
924 |
+
return s;
|
925 |
+
f({ resolvedPath: d.path, stat: d });
|
926 |
+
const V = l(d);
|
927 |
+
return new Uint8Array(
|
928 |
+
this.memory.buffer,
|
929 |
+
i,
|
930 |
+
V.byteLength
|
931 |
+
).set(V), c.SUCCESS;
|
932 |
+
}
|
933 |
+
/**
|
934 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
935 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
936 |
+
* POSIX.
|
937 |
+
*/
|
938 |
+
fd_filestat_set_size(t, i) {
|
939 |
+
return this.drive.setSize(t, i);
|
940 |
+
}
|
941 |
+
/**
|
942 |
+
* Adjust the timestamps of an open file or directory.
|
943 |
+
* Note: This is similar to futimens in POSIX.
|
944 |
+
*/
|
945 |
+
fd_filestat_set_times(t, i, n, l) {
|
946 |
+
let s = null;
|
947 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
948 |
+
let d = null;
|
949 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
950 |
+
const V = this.drive.setAccessTime(t, s);
|
951 |
+
if (V != c.SUCCESS)
|
952 |
+
return V;
|
953 |
+
}
|
954 |
+
if (d) {
|
955 |
+
const V = this.drive.setModificationTime(t, d);
|
956 |
+
if (V != c.SUCCESS)
|
957 |
+
return V;
|
958 |
+
}
|
959 |
+
return c.SUCCESS;
|
960 |
+
}
|
961 |
+
/**
|
962 |
+
* Read from a file descriptor, without using and updating the file
|
963 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
964 |
+
*/
|
965 |
+
fd_pread(t, i, n, l, s) {
|
966 |
+
if (t === 1 || t === 2)
|
967 |
+
return c.ENOTSUP;
|
968 |
+
if (t === 0)
|
969 |
+
return this.fd_read(t, i, n, s);
|
970 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
971 |
+
let a = 0, Z = c.SUCCESS;
|
972 |
+
for (const h of V) {
|
973 |
+
const [r, o] = this.drive.pread(
|
974 |
+
t,
|
975 |
+
h.byteLength,
|
976 |
+
Number(l) + a
|
977 |
+
);
|
978 |
+
if (r !== c.SUCCESS) {
|
979 |
+
Z = r;
|
980 |
+
break;
|
981 |
+
}
|
982 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
983 |
+
h.set(o.subarray(0, R)), a += R;
|
984 |
+
}
|
985 |
+
return d.setUint32(s, a, !0), Z;
|
986 |
+
}
|
987 |
+
/**
|
988 |
+
* Return a description of the given preopened file descriptor.
|
989 |
+
*/
|
990 |
+
fd_prestat_dir_name(t, i, n) {
|
991 |
+
if (t !== 3)
|
992 |
+
return c.EBADF;
|
993 |
+
const l = new TextEncoder().encode("/");
|
994 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
995 |
+
}
|
996 |
+
/**
|
997 |
+
* Return a description of the given preopened file descriptor.
|
998 |
+
*/
|
999 |
+
fd_prestat_get(t, i) {
|
1000 |
+
if (t !== 3)
|
1001 |
+
return c.EBADF;
|
1002 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
1003 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1004 |
+
}
|
1005 |
+
/**
|
1006 |
+
* Write to a file descriptor, without using and updating the file
|
1007 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1008 |
+
*/
|
1009 |
+
fd_pwrite(t, i, n, l, s) {
|
1010 |
+
if (t === 0)
|
1011 |
+
return c.ENOTSUP;
|
1012 |
+
if (t === 1 || t === 2)
|
1013 |
+
return this.fd_write(t, i, n, s);
|
1014 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1015 |
+
let a = 0, Z = c.SUCCESS;
|
1016 |
+
for (const h of V)
|
1017 |
+
if (h.byteLength !== 0) {
|
1018 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1019 |
+
break;
|
1020 |
+
a += h.byteLength;
|
1021 |
+
}
|
1022 |
+
return d.setUint32(s, a, !0), Z;
|
1023 |
+
}
|
1024 |
+
/**
|
1025 |
+
* Read directory entries from a directory. When successful, the contents of
|
1026 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1027 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1028 |
+
* bytes holding the name of the directory entry. This function fills the
|
1029 |
+
* output buffer as much as possible, potentially truncating the last
|
1030 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1031 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1032 |
+
* oversized directory entry.
|
1033 |
+
*/
|
1034 |
+
fd_readdir(t, i, n, l, s) {
|
1035 |
+
const [d, V] = this.drive.list(t);
|
1036 |
+
if (d != c.SUCCESS)
|
1037 |
+
return d;
|
1038 |
+
let a = [], Z = 0;
|
1039 |
+
for (const { name: N, type: F } of V) {
|
1040 |
+
const g = ht(N, F, Z);
|
1041 |
+
a.push(g), Z++;
|
1042 |
+
}
|
1043 |
+
a = a.slice(Number(l));
|
1044 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1045 |
+
let o = 0;
|
1046 |
+
for (const N of a)
|
1047 |
+
r.set(N, o), o += N.byteLength;
|
1048 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1049 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1050 |
+
}
|
1051 |
+
/**
|
1052 |
+
* Atomically replace a file descriptor by renumbering another file
|
1053 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1054 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1055 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1056 |
+
* an actual file descriptor with the same number could be allocated by a
|
1057 |
+
* different thread at the same time. This function provides a way to
|
1058 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1059 |
+
* to be removed entirely.
|
1060 |
+
*/
|
1061 |
+
fd_renumber(t, i) {
|
1062 |
+
return this.drive.renumber(t, i);
|
1063 |
+
}
|
1064 |
+
/**
|
1065 |
+
* Move the offset of a file descriptor.
|
1066 |
+
*
|
1067 |
+
* The offset is specified as a bigint here
|
1068 |
+
* Note: This is similar to lseek in POSIX.
|
1069 |
+
*
|
1070 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1071 |
+
* bigint in JavaScript.
|
1072 |
+
*/
|
1073 |
+
fd_seek(t, i, n, l) {
|
1074 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1075 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1076 |
+
}
|
1077 |
+
unstable_fd_seek(t, i, n, l) {
|
1078 |
+
const s = mt[n];
|
1079 |
+
return this.fd_seek(t, i, s, l);
|
1080 |
+
}
|
1081 |
+
/**
|
1082 |
+
* Synchronize the data and metadata of a file to disk.
|
1083 |
+
* Note: This is similar to fsync in POSIX.
|
1084 |
+
*/
|
1085 |
+
fd_sync(t) {
|
1086 |
+
return this.drive.sync(t);
|
1087 |
+
}
|
1088 |
+
/**
|
1089 |
+
* Return the current offset of a file descriptor.
|
1090 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1091 |
+
*
|
1092 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1093 |
+
*
|
1094 |
+
*/
|
1095 |
+
fd_tell(t, i) {
|
1096 |
+
const [n, l] = this.drive.tell(t);
|
1097 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1098 |
+
}
|
1099 |
+
//
|
1100 |
+
// Paths
|
1101 |
+
//
|
1102 |
+
path_filestat_get(t, i, n, l, s) {
|
1103 |
+
return this.shared_path_filestat_get(
|
1104 |
+
t,
|
1105 |
+
i,
|
1106 |
+
n,
|
1107 |
+
l,
|
1108 |
+
s,
|
1109 |
+
"preview1"
|
1110 |
+
);
|
1111 |
+
}
|
1112 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1113 |
+
return this.shared_path_filestat_get(
|
1114 |
+
t,
|
1115 |
+
i,
|
1116 |
+
n,
|
1117 |
+
l,
|
1118 |
+
s,
|
1119 |
+
"unstable"
|
1120 |
+
);
|
1121 |
+
}
|
1122 |
+
/**
|
1123 |
+
* Return the attributes of a file or directory.
|
1124 |
+
* Note: This is similar to stat in POSIX.
|
1125 |
+
*/
|
1126 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1127 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1128 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1129 |
+
);
|
1130 |
+
f({ path: a });
|
1131 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1132 |
+
if (Z != c.SUCCESS)
|
1133 |
+
return Z;
|
1134 |
+
const r = V(h);
|
1135 |
+
return new Uint8Array(
|
1136 |
+
this.memory.buffer,
|
1137 |
+
s,
|
1138 |
+
r.byteLength
|
1139 |
+
).set(r), Z;
|
1140 |
+
}
|
1141 |
+
/**
|
1142 |
+
* Adjust the timestamps of a file or directory.
|
1143 |
+
* Note: This is similar to utimensat in POSIX.
|
1144 |
+
*/
|
1145 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1146 |
+
let a = null;
|
1147 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1148 |
+
let Z = null;
|
1149 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1150 |
+
const h = new TextDecoder().decode(
|
1151 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1152 |
+
);
|
1153 |
+
if (a) {
|
1154 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1155 |
+
if (r != c.SUCCESS)
|
1156 |
+
return r;
|
1157 |
+
}
|
1158 |
+
if (Z) {
|
1159 |
+
const r = this.drive.pathSetModificationTime(
|
1160 |
+
t,
|
1161 |
+
h,
|
1162 |
+
Z
|
1163 |
+
);
|
1164 |
+
if (r != c.SUCCESS)
|
1165 |
+
return r;
|
1166 |
+
}
|
1167 |
+
return c.SUCCESS;
|
1168 |
+
}
|
1169 |
+
/**
|
1170 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1171 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1172 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1173 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1174 |
+
* descriptor is guaranteed to be less than 2**31.
|
1175 |
+
* Note: This is similar to openat in POSIX.
|
1176 |
+
* @param fd: fd
|
1177 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1178 |
+
* is resolved. Not supported by Runno (symlinks)
|
1179 |
+
* @param path: string The relative path of the file or directory to open,
|
1180 |
+
* relative to the path_open::fd directory.
|
1181 |
+
* @param oflags: oflags The method by which to open the file.
|
1182 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1183 |
+
* descriptor. The implementation is allowed to return
|
1184 |
+
* a file descriptor with fewer rights than specified,
|
1185 |
+
* if and only if those rights do not apply to the type
|
1186 |
+
* of file being opened. The base rights are rights
|
1187 |
+
* that will apply to operations using the file
|
1188 |
+
* descriptor itself, while the inheriting rights are
|
1189 |
+
* rights that apply to file descriptors derived from
|
1190 |
+
* it.
|
1191 |
+
* @param fs_rights_inheriting: rights
|
1192 |
+
* @param fdflags: fdflags
|
1193 |
+
*
|
1194 |
+
*/
|
1195 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1196 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1197 |
+
f({
|
1198 |
+
path: r,
|
1199 |
+
openFlags: {
|
1200 |
+
createFileIfNone: o,
|
1201 |
+
failIfNotDir: R,
|
1202 |
+
failIfFileExists: k,
|
1203 |
+
truncateFile: P
|
1204 |
+
},
|
1205 |
+
fileDescriptorFlags: {
|
1206 |
+
flagAppend: N,
|
1207 |
+
flagDSync: F,
|
1208 |
+
flagNonBlock: g,
|
1209 |
+
flagRSync: et,
|
1210 |
+
flagSync: it
|
1211 |
+
}
|
1212 |
+
});
|
1213 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1214 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1215 |
+
}
|
1216 |
+
/**
|
1217 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1218 |
+
*/
|
1219 |
+
path_rename(t, i, n, l, s, d) {
|
1220 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1221 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1222 |
+
}
|
1223 |
+
/**
|
1224 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1225 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1226 |
+
*/
|
1227 |
+
path_unlink_file(t, i, n) {
|
1228 |
+
const l = I(this.memory, i, n);
|
1229 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1230 |
+
}
|
1231 |
+
/**
|
1232 |
+
* Concurrently poll for the occurrence of a set of events.
|
1233 |
+
*/
|
1234 |
+
poll_oneoff(t, i, n, l) {
|
1235 |
+
for (let d = 0; d < n; d++) {
|
1236 |
+
const V = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
t + d * M,
|
1239 |
+
M
|
1240 |
+
), a = Zt(V), Z = new Uint8Array(
|
1241 |
+
this.memory.buffer,
|
1242 |
+
i + d * x,
|
1243 |
+
x
|
1244 |
+
);
|
1245 |
+
let h = 0, r = c.SUCCESS;
|
1246 |
+
switch (a.type) {
|
1247 |
+
case G.CLOCK:
|
1248 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1249 |
+
;
|
1250 |
+
Z.set(
|
1251 |
+
rt(a.userdata, c.SUCCESS)
|
1252 |
+
);
|
1253 |
+
break;
|
1254 |
+
case G.FD_READ:
|
1255 |
+
if (a.fd < 3)
|
1256 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1257 |
+
else {
|
1258 |
+
const [o, R] = this.drive.stat(a.fd);
|
1259 |
+
r = o, h = R ? R.byteLength : 0;
|
1260 |
+
}
|
1261 |
+
Z.set(
|
1262 |
+
v(
|
1263 |
+
a.userdata,
|
1264 |
+
r,
|
1265 |
+
G.FD_READ,
|
1266 |
+
BigInt(h)
|
1267 |
+
)
|
1268 |
+
);
|
1269 |
+
break;
|
1270 |
+
case G.FD_WRITE:
|
1271 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1272 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1273 |
+
else {
|
1274 |
+
const [o, R] = this.drive.stat(a.fd);
|
1275 |
+
r = o, h = R ? R.byteLength : 0;
|
1276 |
+
}
|
1277 |
+
Z.set(
|
1278 |
+
v(
|
1279 |
+
a.userdata,
|
1280 |
+
r,
|
1281 |
+
G.FD_READ,
|
1282 |
+
BigInt(h)
|
1283 |
+
)
|
1284 |
+
);
|
1285 |
+
break;
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1289 |
+
}
|
1290 |
+
/**
|
1291 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1292 |
+
*/
|
1293 |
+
path_create_directory(t, i, n) {
|
1294 |
+
const l = I(this.memory, i, n);
|
1295 |
+
return this.drive.pathCreateDir(t, l);
|
1296 |
+
}
|
1297 |
+
//
|
1298 |
+
// Unimplemented - these operations are not supported by Runno
|
1299 |
+
//
|
1300 |
+
/**
|
1301 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1302 |
+
*/
|
1303 |
+
path_link() {
|
1304 |
+
return c.ENOSYS;
|
1305 |
+
}
|
1306 |
+
/**
|
1307 |
+
* Read the contents of a symbolic link.
|
1308 |
+
* Note: This is similar to readlinkat in POSIX.
|
1309 |
+
*/
|
1310 |
+
path_readlink() {
|
1311 |
+
return c.ENOSYS;
|
1312 |
+
}
|
1313 |
+
/**
|
1314 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1315 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1316 |
+
*/
|
1317 |
+
path_remove_directory() {
|
1318 |
+
return c.ENOSYS;
|
1319 |
+
}
|
1320 |
+
/**
|
1321 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1322 |
+
*/
|
1323 |
+
path_symlink() {
|
1324 |
+
return c.ENOSYS;
|
1325 |
+
}
|
1326 |
+
/**
|
1327 |
+
* Send a signal to the process of the calling thread.
|
1328 |
+
* Note: This is similar to raise in POSIX.
|
1329 |
+
*/
|
1330 |
+
proc_raise() {
|
1331 |
+
return c.ENOSYS;
|
1332 |
+
}
|
1333 |
+
/**
|
1334 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1335 |
+
*/
|
1336 |
+
sock_accept() {
|
1337 |
+
return c.ENOSYS;
|
1338 |
+
}
|
1339 |
+
/**
|
1340 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1341 |
+
* though it also supports reading the data into multiple buffers in the
|
1342 |
+
* manner of readv.
|
1343 |
+
*/
|
1344 |
+
sock_recv() {
|
1345 |
+
return c.ENOSYS;
|
1346 |
+
}
|
1347 |
+
/**
|
1348 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1349 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1350 |
+
* writev.
|
1351 |
+
*/
|
1352 |
+
sock_send() {
|
1353 |
+
return c.ENOSYS;
|
1354 |
+
}
|
1355 |
+
/**
|
1356 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1357 |
+
* shutdown in POSIX.
|
1358 |
+
*/
|
1359 |
+
sock_shutdown() {
|
1360 |
+
return c.ENOSYS;
|
1361 |
+
}
|
1362 |
+
//
|
1363 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1364 |
+
//
|
1365 |
+
sock_open() {
|
1366 |
+
return c.ENOSYS;
|
1367 |
+
}
|
1368 |
+
sock_listen() {
|
1369 |
+
return c.ENOSYS;
|
1370 |
+
}
|
1371 |
+
sock_connect() {
|
1372 |
+
return c.ENOSYS;
|
1373 |
+
}
|
1374 |
+
sock_setsockopt() {
|
1375 |
+
return c.ENOSYS;
|
1376 |
+
}
|
1377 |
+
sock_bind() {
|
1378 |
+
return c.ENOSYS;
|
1379 |
+
}
|
1380 |
+
sock_getlocaladdr() {
|
1381 |
+
return c.ENOSYS;
|
1382 |
+
}
|
1383 |
+
sock_getpeeraddr() {
|
1384 |
+
return c.ENOSYS;
|
1385 |
+
}
|
1386 |
+
sock_getaddrinfo() {
|
1387 |
+
return c.ENOSYS;
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1391 |
+
class w extends Error {
|
1392 |
+
constructor(i) {
|
1393 |
+
super();
|
1394 |
+
m(this, "code");
|
1395 |
+
this.code = i;
|
1396 |
+
}
|
1397 |
+
}
|
1398 |
+
function I(e, t, i) {
|
1399 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1400 |
+
}
|
1401 |
+
function K(e, t, i) {
|
1402 |
+
let n = Array(i);
|
1403 |
+
for (let l = 0; l < i; l++) {
|
1404 |
+
const s = e.getUint32(t, !0);
|
1405 |
+
t += 4;
|
1406 |
+
const d = e.getUint32(t, !0);
|
1407 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1408 |
+
}
|
1409 |
+
return n;
|
1410 |
+
}
|
1411 |
+
function Zt(e) {
|
1412 |
+
const t = new Uint8Array(8);
|
1413 |
+
t.set(e.subarray(0, 8));
|
1414 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1415 |
+
switch (i) {
|
1416 |
+
case G.FD_READ:
|
1417 |
+
case G.FD_WRITE:
|
1418 |
+
return {
|
1419 |
+
userdata: t,
|
1420 |
+
type: i,
|
1421 |
+
fd: n.getUint32(0, !0)
|
1422 |
+
};
|
1423 |
+
case G.CLOCK:
|
1424 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1425 |
+
return {
|
1426 |
+
userdata: t,
|
1427 |
+
type: i,
|
1428 |
+
id: n.getUint32(0, !0),
|
1429 |
+
timeout: W(a),
|
1430 |
+
precision: W(a + V)
|
1431 |
+
};
|
1432 |
+
}
|
1433 |
+
}
|
1434 |
+
function _(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function A(e) {
|
1439 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1440 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1441 |
+
}
|
1442 |
+
function J(e, t, i) {
|
1443 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1444 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1445 |
+
}
|
1446 |
+
function ht(e, t, i) {
|
1447 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1448 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1449 |
+
}
|
1450 |
+
function rt(e, t) {
|
1451 |
+
const i = new Uint8Array(32);
|
1452 |
+
i.set(e, 0);
|
1453 |
+
const n = new DataView(i.buffer);
|
1454 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1455 |
+
}
|
1456 |
+
function v(e, t, i, n) {
|
1457 |
+
const l = new Uint8Array(32);
|
1458 |
+
l.set(e, 0);
|
1459 |
+
const s = new DataView(l.buffer);
|
1460 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1461 |
+
}
|
1462 |
+
function H(e, t = 0) {
|
1463 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1464 |
+
for (let l = 0, s; l < e.length; l++)
|
1465 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1466 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1467 |
+
}
|
1468 |
+
function L(e) {
|
1469 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1470 |
+
}
|
1471 |
+
function W(e) {
|
1472 |
+
return new Date(Number(e / BigInt(1e6)));
|
1473 |
+
}
|
1474 |
+
const mt = {
|
1475 |
+
[Y.CUR]: y.CUR,
|
1476 |
+
[Y.END]: y.END,
|
1477 |
+
[Y.SET]: y.SET
|
1478 |
+
};
|
1479 |
+
class Xt {
|
1480 |
+
constructor(t) {
|
1481 |
+
m(this, "fs");
|
1482 |
+
m(this, "args");
|
1483 |
+
// Program args (like from a terminal program)
|
1484 |
+
m(this, "env");
|
1485 |
+
// Environment (like a .env file)
|
1486 |
+
m(this, "stdin");
|
1487 |
+
m(this, "stdout");
|
1488 |
+
m(this, "stderr");
|
1489 |
+
m(this, "debug");
|
1490 |
+
m(this, "isTTY");
|
1491 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1492 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1493 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NVUFBPUlQiLGVbZS5FQUdBSU49Nl09IkVBR0FJTiIsZ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ciLG5hbWU6ZSxhcmdzOnQscmV0OmksZGF0YTpufSksaX1mdW5jdGlvbiBodChlLHQpe0F0b21pY3Mud2FpdChuZXcgSW50MzJBcnJheSh0KSwwLDApO2NvbnN0IGk9bmV3IERhdGFWaWV3KHQpLG49aS5nZXRJbnQzMigwKTtpZihuPDApcmV0dXJuIGkuc2V0SW50MzIoMCwwKSxudWxsO2NvbnN0IHM9bmV3IFVpbnQ4QXJyYXkodCw0LG4pLGE9bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKHMuc2xpY2UoMCxlKSksZj1zLnNsaWNlKGUscy5sZW5ndGgpO3JldHVybiBpLnNldEludDMyKDAsZi5ieXRlTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1497 |
+
function ut() {
|
1498 |
+
let e;
|
1499 |
+
try {
|
1500 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1501 |
+
throw "";
|
1502 |
+
return new Worker(e);
|
1503 |
+
} catch {
|
1504 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1505 |
+
} finally {
|
1506 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1507 |
+
}
|
1508 |
+
}
|
1509 |
+
function ot(e, t) {
|
1510 |
+
e.postMessage(t);
|
1511 |
+
}
|
1512 |
+
class St extends Error {
|
1513 |
+
}
|
1514 |
+
class Gt {
|
1515 |
+
constructor(t, i) {
|
1516 |
+
m(this, "binaryURL");
|
1517 |
+
// 8kb should be big enough
|
1518 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1519 |
+
m(this, "context");
|
1520 |
+
m(this, "result");
|
1521 |
+
m(this, "worker");
|
1522 |
+
m(this, "reject");
|
1523 |
+
this.binaryURL = t, this.context = i;
|
1524 |
+
}
|
1525 |
+
async start() {
|
1526 |
+
if (this.result)
|
1527 |
+
throw new Error("WASIWorker Host can only be started once");
|
1528 |
+
return this.result = new Promise((t, i) => {
|
1529 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1530 |
+
var s, d, V, a, Z, h;
|
1531 |
+
const l = n.data;
|
1532 |
+
switch (l.type) {
|
1533 |
+
case "stdout":
|
1534 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1535 |
+
break;
|
1536 |
+
case "stderr":
|
1537 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1538 |
+
break;
|
1539 |
+
case "debug":
|
1540 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1541 |
+
Z,
|
1542 |
+
l.name,
|
1543 |
+
l.args,
|
1544 |
+
l.ret,
|
1545 |
+
l.data
|
1546 |
+
);
|
1547 |
+
break;
|
1548 |
+
case "result":
|
1549 |
+
t(l.result);
|
1550 |
+
break;
|
1551 |
+
case "crash":
|
1552 |
+
i(l.error);
|
1553 |
+
break;
|
1554 |
+
}
|
1555 |
+
}), ot(this.worker, {
|
1556 |
+
target: "client",
|
1557 |
+
type: "start",
|
1558 |
+
binaryURL: this.binaryURL,
|
1559 |
+
stdinBuffer: this.stdinBuffer,
|
1560 |
+
// Unfortunately can't just splat these because it includes types
|
1561 |
+
// that can't be sent as a message.
|
1562 |
+
args: this.context.args,
|
1563 |
+
env: this.context.env,
|
1564 |
+
fs: this.context.fs,
|
1565 |
+
isTTY: this.context.isTTY
|
1566 |
+
});
|
1567 |
+
}), this.result;
|
1568 |
+
}
|
1569 |
+
kill() {
|
1570 |
+
var t;
|
1571 |
+
if (!this.worker)
|
1572 |
+
throw new Error("WASIWorker has not started");
|
1573 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1574 |
+
}
|
1575 |
+
async pushStdin(t) {
|
1576 |
+
const i = new DataView(this.stdinBuffer);
|
1577 |
+
for (; i.getInt32(0) !== 0; )
|
1578 |
+
await new Promise((s) => setTimeout(s, 0));
|
1579 |
+
const n = new TextEncoder().encode(t);
|
1580 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1581 |
+
}
|
1582 |
+
async pushEOF() {
|
1583 |
+
const t = new DataView(this.stdinBuffer);
|
1584 |
+
for (; t.getInt32(0) !== 0; )
|
1585 |
+
await new Promise((i) => setTimeout(i, 0));
|
1586 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1587 |
+
}
|
1588 |
+
}
|
1589 |
+
export {
|
1590 |
+
q as WASI,
|
1591 |
+
Xt as WASIContext,
|
1592 |
+
bt as WASISnapshotPreview1,
|
1593 |
+
Gt as WASIWorkerHost,
|
1594 |
+
St as WASIWorkerHostKilledError
|
1595 |
+
};
|
src/vendor/wasi.js.original
ADDED
@@ -0,0 +1,1591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var lt = Object.defineProperty;
|
2 |
+
var ct = (e, t, i) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
3 |
+
var m = (e, t, i) => (ct(e, typeof t != "symbol" ? t + "" : t, i), i);
|
4 |
+
var c = /* @__PURE__ */ ((e) => (e[e.SUCCESS = 0] = "SUCCESS", e[e.E2BIG = 1] = "E2BIG", e[e.EACCESS = 2] = "EACCESS", e[e.EADDRINUSE = 3] = "EADDRINUSE", e[e.EADDRNOTAVAIL = 4] = "EADDRNOTAVAIL", e[e.EAFNOSUPPORT = 5] = "EAFNOSUPPORT", e[e.EAGAIN = 6] = "EAGAIN", e[e.EALREADY = 7] = "EALREADY", e[e.EBADF = 8] = "EBADF", e[e.EBADMSG = 9] = "EBADMSG", e[e.EBUSY = 10] = "EBUSY", e[e.ECANCELED = 11] = "ECANCELED", e[e.ECHILD = 12] = "ECHILD", e[e.ECONNABORTED = 13] = "ECONNABORTED", e[e.ECONNREFUSED = 14] = "ECONNREFUSED", e[e.ECONNRESET = 15] = "ECONNRESET", e[e.EDEADLK = 16] = "EDEADLK", e[e.EDESTADDRREQ = 17] = "EDESTADDRREQ", e[e.EDOM = 18] = "EDOM", e[e.EDQUOT = 19] = "EDQUOT", e[e.EEXIST = 20] = "EEXIST", e[e.EFAULT = 21] = "EFAULT", e[e.EFBIG = 22] = "EFBIG", e[e.EHOSTUNREACH = 23] = "EHOSTUNREACH", e[e.EIDRM = 24] = "EIDRM", e[e.EILSEQ = 25] = "EILSEQ", e[e.EINPROGRESS = 26] = "EINPROGRESS", e[e.EINTR = 27] = "EINTR", e[e.EINVAL = 28] = "EINVAL", e[e.EIO = 29] = "EIO", e[e.EISCONN = 30] = "EISCONN", e[e.EISDIR = 31] = "EISDIR", e[e.ELOOP = 32] = "ELOOP", e[e.EMFILE = 33] = "EMFILE", e[e.EMLINK = 34] = "EMLINK", e[e.EMSGSIZE = 35] = "EMSGSIZE", e[e.EMULTIHOP = 36] = "EMULTIHOP", e[e.ENAMETOOLONG = 37] = "ENAMETOOLONG", e[e.ENETDOWN = 38] = "ENETDOWN", e[e.ENETRESET = 39] = "ENETRESET", e[e.ENETUNREACH = 40] = "ENETUNREACH", e[e.ENFILE = 41] = "ENFILE", e[e.ENOBUFS = 42] = "ENOBUFS", e[e.ENODEV = 43] = "ENODEV", e[e.ENOENT = 44] = "ENOENT", e[e.ENOEXEC = 45] = "ENOEXEC", e[e.ENOLCK = 46] = "ENOLCK", e[e.ENOLINK = 47] = "ENOLINK", e[e.ENOMEM = 48] = "ENOMEM", e[e.ENOMSG = 49] = "ENOMSG", e[e.ENOPROTOOPT = 50] = "ENOPROTOOPT", e[e.ENOSPC = 51] = "ENOSPC", e[e.ENOSYS = 52] = "ENOSYS", e[e.ENOTCONN = 53] = "ENOTCONN", e[e.ENOTDIR = 54] = "ENOTDIR", e[e.ENOTEMPTY = 55] = "ENOTEMPTY", e[e.ENOTRECOVERABLE = 56] = "ENOTRECOVERABLE", e[e.ENOTSOCK = 57] = "ENOTSOCK", e[e.ENOTSUP = 58] = "ENOTSUP", e[e.ENOTTY = 59] = "ENOTTY", e[e.ENXIO = 60] = "ENXIO", e[e.EOVERFLOW = 61] = "EOVERFLOW", e[e.EOWNERDEAD = 62] = "EOWNERDEAD", e[e.EPERM = 63] = "EPERM", e[e.EPIPE = 64] = "EPIPE", e[e.EPROTO = 65] = "EPROTO", e[e.EPROTONOSUPPORT = 66] = "EPROTONOSUPPORT", e[e.EPROTOTYPE = 67] = "EPROTOTYPE", e[e.ERANGE = 68] = "ERANGE", e[e.EROFS = 69] = "EROFS", e[e.ESPIPE = 70] = "ESPIPE", e[e.ESRCH = 71] = "ESRCH", e[e.ESTALE = 72] = "ESTALE", e[e.ETIMEDOUT = 73] = "ETIMEDOUT", e[e.ETXTBSY = 74] = "ETXTBSY", e[e.EXDEV = 75] = "EXDEV", e[e.ENOTCAPABLE = 76] = "ENOTCAPABLE", e))(c || {}), p = /* @__PURE__ */ ((e) => (e[e.REALTIME = 0] = "REALTIME", e[e.MONOTONIC = 1] = "MONOTONIC", e[e.PROCESS_CPUTIME_ID = 2] = "PROCESS_CPUTIME_ID", e[e.THREAD_CPUTIME_ID = 3] = "THREAD_CPUTIME_ID", e))(p || {}), y = /* @__PURE__ */ ((e) => (e[e.SET = 0] = "SET", e[e.CUR = 1] = "CUR", e[e.END = 2] = "END", e))(y || {}), X = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.BLOCK_DEVICE = 1] = "BLOCK_DEVICE", e[e.CHARACTER_DEVICE = 2] = "CHARACTER_DEVICE", e[e.DIRECTORY = 3] = "DIRECTORY", e[e.REGULAR_FILE = 4] = "REGULAR_FILE", e[e.SOCKET_DGRAM = 5] = "SOCKET_DGRAM", e[e.SOCKET_STREAM = 6] = "SOCKET_STREAM", e[e.SYMBOLIC_LINK = 7] = "SYMBOLIC_LINK", e))(X || {}), D = /* @__PURE__ */ ((e) => (e[e.DIR = 0] = "DIR", e))(D || {}), G = /* @__PURE__ */ ((e) => (e[e.CLOCK = 0] = "CLOCK", e[e.FD_READ = 1] = "FD_READ", e[e.FD_WRITE = 2] = "FD_WRITE", e))(G || {});
|
5 |
+
const st = {
|
6 |
+
SYMLINK_FOLLOW: 1
|
7 |
+
// As long as the resolved path corresponds to a symbolic
|
8 |
+
// link, it is expanded.
|
9 |
+
}, T = {
|
10 |
+
CREAT: 1,
|
11 |
+
// Create file if it does not exist.
|
12 |
+
DIRECTORY: 2,
|
13 |
+
// Fail if not a directory.
|
14 |
+
EXCL: 4,
|
15 |
+
// Fail if file already exists.
|
16 |
+
TRUNC: 8
|
17 |
+
// Truncate file to size 0.
|
18 |
+
}, E = {
|
19 |
+
APPEND: 1,
|
20 |
+
// Append mode: Data written to the file is always appended to the file's end.
|
21 |
+
DSYNC: 2,
|
22 |
+
// Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
23 |
+
NONBLOCK: 4,
|
24 |
+
// Non-blocking mode.
|
25 |
+
RSYNC: 8,
|
26 |
+
// Synchronized read I/O operations.
|
27 |
+
SYNC: 16
|
28 |
+
// Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata.
|
29 |
+
}, u = {
|
30 |
+
FD_DATASYNC: BigInt(1) << BigInt(0),
|
31 |
+
FD_READ: BigInt(1) << BigInt(1),
|
32 |
+
FD_SEEK: BigInt(1) << BigInt(2),
|
33 |
+
FD_FDSTAT_SET_FLAGS: BigInt(1) << BigInt(3),
|
34 |
+
FD_SYNC: BigInt(1) << BigInt(4),
|
35 |
+
FD_TELL: BigInt(1) << BigInt(5),
|
36 |
+
FD_WRITE: BigInt(1) << BigInt(6),
|
37 |
+
FD_ADVISE: BigInt(1) << BigInt(7),
|
38 |
+
FD_ALLOCATE: BigInt(1) << BigInt(8),
|
39 |
+
PATH_CREATE_DIRECTORY: BigInt(1) << BigInt(9),
|
40 |
+
PATH_CREATE_FILE: BigInt(1) << BigInt(10),
|
41 |
+
PATH_LINK_SOURCE: BigInt(1) << BigInt(11),
|
42 |
+
PATH_LINK_TARGET: BigInt(1) << BigInt(12),
|
43 |
+
PATH_OPEN: BigInt(1) << BigInt(13),
|
44 |
+
FD_READDIR: BigInt(1) << BigInt(14),
|
45 |
+
PATH_READLINK: BigInt(1) << BigInt(15),
|
46 |
+
PATH_RENAME_SOURCE: BigInt(1) << BigInt(16),
|
47 |
+
PATH_RENAME_TARGET: BigInt(1) << BigInt(17),
|
48 |
+
PATH_FILESTAT_GET: BigInt(1) << BigInt(18),
|
49 |
+
PATH_FILESTAT_SET_SIZE: BigInt(1) << BigInt(19),
|
50 |
+
PATH_FILESTAT_SET_TIMES: BigInt(1) << BigInt(20),
|
51 |
+
FD_FILESTAT_GET: BigInt(1) << BigInt(21),
|
52 |
+
FD_FILESTAT_SET_SIZE: BigInt(1) << BigInt(22),
|
53 |
+
FD_FILESTAT_SET_TIMES: BigInt(1) << BigInt(23),
|
54 |
+
PATH_SYMLINK: BigInt(1) << BigInt(24),
|
55 |
+
PATH_REMOVE_DIRECTORY: BigInt(1) << BigInt(25),
|
56 |
+
PATH_UNLINK_FILE: BigInt(1) << BigInt(26),
|
57 |
+
POLL_FD_READWRITE: BigInt(1) << BigInt(27),
|
58 |
+
SOCK_SHUTDOWN: BigInt(1) << BigInt(28),
|
59 |
+
SOCK_ACCEPT: BigInt(1) << BigInt(29)
|
60 |
+
}, U = {
|
61 |
+
ATIM: 1,
|
62 |
+
// Adjust the last data access timestamp to the value stored in filestat::atim.
|
63 |
+
ATIM_NOW: 2,
|
64 |
+
// Adjust the last data access timestamp to the time of clock clockid::realtime.
|
65 |
+
MTIM: 4,
|
66 |
+
// Adjust the last data modification timestamp to the value stored in filestat::mtim.
|
67 |
+
MTIM_NOW: 8
|
68 |
+
// Adjust the last data modification timestamp to the time of clock clockid::realtime.
|
69 |
+
}, $ = {
|
70 |
+
SUBSCRIPTION_CLOCK_ABSTIME: 1
|
71 |
+
// If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
|
72 |
+
}, dt = {
|
73 |
+
FD_READWRITE_HANGUP: 1
|
74 |
+
// The peer of this socket has closed or disconnected.
|
75 |
+
}, O = 64, M = 48, x = 32, bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
76 |
+
__proto__: null,
|
77 |
+
Clock: p,
|
78 |
+
EVENT_SIZE: x,
|
79 |
+
EventReadWriteFlags: dt,
|
80 |
+
EventType: G,
|
81 |
+
FILESTAT_SIZE: O,
|
82 |
+
FileDescriptorFlags: E,
|
83 |
+
FileStatTimestampFlags: U,
|
84 |
+
FileType: X,
|
85 |
+
LookupFlags: st,
|
86 |
+
OpenFlags: T,
|
87 |
+
PreopenType: D,
|
88 |
+
Result: c,
|
89 |
+
RightsFlags: u,
|
90 |
+
SUBSCRIPTION_SIZE: M,
|
91 |
+
SubscriptionClockFlags: $,
|
92 |
+
Whence: y
|
93 |
+
}, Symbol.toStringTag, { value: "Module" }));
|
94 |
+
var Y = /* @__PURE__ */ ((e) => (e[e.CUR = 0] = "CUR", e[e.END = 1] = "END", e[e.SET = 2] = "SET", e))(Y || {});
|
95 |
+
class at {
|
96 |
+
constructor(t) {
|
97 |
+
m(this, "fs");
|
98 |
+
m(this, "nextFD", 10);
|
99 |
+
m(this, "openMap", /* @__PURE__ */ new Map());
|
100 |
+
this.fs = { ...t }, this.openMap.set(3, new S(this.fs, "/"));
|
101 |
+
}
|
102 |
+
//
|
103 |
+
// Helpers
|
104 |
+
//
|
105 |
+
openFile(t, i, n) {
|
106 |
+
const l = new b(t, n);
|
107 |
+
i && (l.buffer = new Uint8Array(new ArrayBuffer(1024), 0, 0));
|
108 |
+
const s = this.nextFD;
|
109 |
+
return this.openMap.set(s, l), this.nextFD++, [c.SUCCESS, s];
|
110 |
+
}
|
111 |
+
openDir(t, i) {
|
112 |
+
const n = new S(t, i), l = this.nextFD;
|
113 |
+
return this.openMap.set(l, n), this.nextFD++, [c.SUCCESS, l];
|
114 |
+
}
|
115 |
+
hasDir(t, i) {
|
116 |
+
return i === "." ? !0 : t.containsDirectory(i);
|
117 |
+
}
|
118 |
+
//
|
119 |
+
// Public Interface
|
120 |
+
//
|
121 |
+
open(t, i, n, l) {
|
122 |
+
const s = !!(n & T.CREAT), d = !!(n & T.DIRECTORY), V = !!(n & T.EXCL), a = !!(n & T.TRUNC), Z = this.openMap.get(t);
|
123 |
+
if (!(Z instanceof S))
|
124 |
+
return [c.EBADF];
|
125 |
+
if (Z.containsFile(i))
|
126 |
+
return d ? [c.ENOTDIR] : V ? [c.EEXIST] : this.openFile(Z.get(i), a, l);
|
127 |
+
if (this.hasDir(Z, i)) {
|
128 |
+
if (i === ".")
|
129 |
+
return this.openDir(this.fs, "/");
|
130 |
+
const h = `/${i}/`, r = Object.entries(this.fs).filter(([o]) => o.startsWith(h));
|
131 |
+
return this.openDir(Object.fromEntries(r), h);
|
132 |
+
} else {
|
133 |
+
if (s) {
|
134 |
+
const h = Z.fullPath(i);
|
135 |
+
return this.fs[h] = {
|
136 |
+
path: h,
|
137 |
+
mode: "binary",
|
138 |
+
content: new Uint8Array(),
|
139 |
+
timestamps: {
|
140 |
+
access: /* @__PURE__ */ new Date(),
|
141 |
+
modification: /* @__PURE__ */ new Date(),
|
142 |
+
change: /* @__PURE__ */ new Date()
|
143 |
+
}
|
144 |
+
}, this.openFile(this.fs[h], a, l);
|
145 |
+
}
|
146 |
+
return [c.ENOTCAPABLE];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
close(t) {
|
150 |
+
if (!this.openMap.has(t))
|
151 |
+
return c.EBADF;
|
152 |
+
const i = this.openMap.get(t);
|
153 |
+
return i instanceof b && i.sync(), this.openMap.delete(t), c.SUCCESS;
|
154 |
+
}
|
155 |
+
read(t, i) {
|
156 |
+
const n = this.openMap.get(t);
|
157 |
+
return !n || n instanceof S ? [c.EBADF] : [c.SUCCESS, n.read(i)];
|
158 |
+
}
|
159 |
+
pread(t, i, n) {
|
160 |
+
const l = this.openMap.get(t);
|
161 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.pread(i, n)];
|
162 |
+
}
|
163 |
+
write(t, i) {
|
164 |
+
const n = this.openMap.get(t);
|
165 |
+
return !n || n instanceof S ? c.EBADF : (n.write(i), c.SUCCESS);
|
166 |
+
}
|
167 |
+
pwrite(t, i, n) {
|
168 |
+
const l = this.openMap.get(t);
|
169 |
+
return !l || l instanceof S ? c.EBADF : (l.pwrite(i, n), c.SUCCESS);
|
170 |
+
}
|
171 |
+
sync(t) {
|
172 |
+
const i = this.openMap.get(t);
|
173 |
+
return !i || i instanceof S ? c.EBADF : (i.sync(), c.SUCCESS);
|
174 |
+
}
|
175 |
+
seek(t, i, n) {
|
176 |
+
const l = this.openMap.get(t);
|
177 |
+
return !l || l instanceof S ? [c.EBADF] : [c.SUCCESS, l.seek(i, n)];
|
178 |
+
}
|
179 |
+
tell(t) {
|
180 |
+
const i = this.openMap.get(t);
|
181 |
+
return !i || i instanceof S ? [c.EBADF] : [c.SUCCESS, i.tell()];
|
182 |
+
}
|
183 |
+
renumber(t, i) {
|
184 |
+
return !this.exists(t) || !this.exists(i) ? c.EBADF : (t === i || (this.close(i), this.openMap.set(i, this.openMap.get(t))), c.SUCCESS);
|
185 |
+
}
|
186 |
+
unlink(t, i) {
|
187 |
+
const n = this.openMap.get(t);
|
188 |
+
if (!(n instanceof S))
|
189 |
+
return c.EBADF;
|
190 |
+
if (!n.contains(i))
|
191 |
+
return c.ENOENT;
|
192 |
+
for (const l of Object.keys(this.fs))
|
193 |
+
(l === n.fullPath(i) || l.startsWith(`${n.fullPath(i)}/`)) && delete this.fs[l];
|
194 |
+
return c.SUCCESS;
|
195 |
+
}
|
196 |
+
rename(t, i, n, l) {
|
197 |
+
const s = this.openMap.get(t), d = this.openMap.get(n);
|
198 |
+
if (!(s instanceof S) || !(d instanceof S))
|
199 |
+
return c.EBADF;
|
200 |
+
if (!s.contains(i))
|
201 |
+
return c.ENOENT;
|
202 |
+
if (d.contains(l))
|
203 |
+
return c.EEXIST;
|
204 |
+
const V = s.fullPath(i), a = d.fullPath(l);
|
205 |
+
for (const Z of Object.keys(this.fs))
|
206 |
+
if (Z.startsWith(V)) {
|
207 |
+
const h = Z.replace(V, a);
|
208 |
+
this.fs[h] = this.fs[Z], this.fs[h].path = h, delete this.fs[Z];
|
209 |
+
}
|
210 |
+
return c.SUCCESS;
|
211 |
+
}
|
212 |
+
list(t) {
|
213 |
+
const i = this.openMap.get(t);
|
214 |
+
return i instanceof S ? [c.SUCCESS, i.list()] : [c.EBADF];
|
215 |
+
}
|
216 |
+
stat(t) {
|
217 |
+
const i = this.openMap.get(t);
|
218 |
+
return i instanceof b ? [c.SUCCESS, i.stat()] : [c.EBADF];
|
219 |
+
}
|
220 |
+
pathStat(t, i) {
|
221 |
+
const n = this.openMap.get(t);
|
222 |
+
if (!(n instanceof S))
|
223 |
+
return [c.EBADF];
|
224 |
+
if (n.containsFile(i)) {
|
225 |
+
const l = n.fullPath(i), s = new b(this.fs[l], 0).stat();
|
226 |
+
return [c.SUCCESS, s];
|
227 |
+
} else if (this.hasDir(n, i)) {
|
228 |
+
if (i === ".")
|
229 |
+
return [c.SUCCESS, new S(this.fs, "/").stat()];
|
230 |
+
const l = `/${i}/`, s = Object.entries(this.fs).filter(([V]) => V.startsWith(l)), d = new S(Object.fromEntries(s), l).stat();
|
231 |
+
return [c.SUCCESS, d];
|
232 |
+
} else
|
233 |
+
return [c.ENOTCAPABLE];
|
234 |
+
}
|
235 |
+
setFlags(t, i) {
|
236 |
+
const n = this.openMap.get(t);
|
237 |
+
return n instanceof b ? (n.setFlags(i), c.SUCCESS) : c.EBADF;
|
238 |
+
}
|
239 |
+
setSize(t, i) {
|
240 |
+
const n = this.openMap.get(t);
|
241 |
+
return n instanceof b ? (n.setSize(Number(i)), c.SUCCESS) : c.EBADF;
|
242 |
+
}
|
243 |
+
setAccessTime(t, i) {
|
244 |
+
const n = this.openMap.get(t);
|
245 |
+
return n instanceof b ? (n.setAccessTime(i), c.SUCCESS) : c.EBADF;
|
246 |
+
}
|
247 |
+
setModificationTime(t, i) {
|
248 |
+
const n = this.openMap.get(t);
|
249 |
+
return n instanceof b ? (n.setModificationTime(i), c.SUCCESS) : c.EBADF;
|
250 |
+
}
|
251 |
+
pathSetAccessTime(t, i, n) {
|
252 |
+
const l = this.openMap.get(t);
|
253 |
+
if (!(l instanceof S))
|
254 |
+
return c.EBADF;
|
255 |
+
const s = l.get(i);
|
256 |
+
if (!s)
|
257 |
+
return c.ENOTCAPABLE;
|
258 |
+
const d = new b(s, 0);
|
259 |
+
return d.setAccessTime(n), d.sync(), c.SUCCESS;
|
260 |
+
}
|
261 |
+
pathSetModificationTime(t, i, n) {
|
262 |
+
const l = this.openMap.get(t);
|
263 |
+
if (!(l instanceof S))
|
264 |
+
return c.EBADF;
|
265 |
+
const s = l.get(i);
|
266 |
+
if (!s)
|
267 |
+
return c.ENOTCAPABLE;
|
268 |
+
const d = new b(s, 0);
|
269 |
+
return d.setModificationTime(n), d.sync(), c.SUCCESS;
|
270 |
+
}
|
271 |
+
pathCreateDir(t, i) {
|
272 |
+
const n = this.openMap.get(t);
|
273 |
+
if (!(n instanceof S))
|
274 |
+
return c.EBADF;
|
275 |
+
if (n.contains(i))
|
276 |
+
return c.ENOTCAPABLE;
|
277 |
+
const l = `${n.fullPath(i)}/.runno`;
|
278 |
+
return this.fs[l] = {
|
279 |
+
path: l,
|
280 |
+
timestamps: {
|
281 |
+
access: /* @__PURE__ */ new Date(),
|
282 |
+
modification: /* @__PURE__ */ new Date(),
|
283 |
+
change: /* @__PURE__ */ new Date()
|
284 |
+
},
|
285 |
+
mode: "string",
|
286 |
+
content: ""
|
287 |
+
}, c.SUCCESS;
|
288 |
+
}
|
289 |
+
//
|
290 |
+
// Public Helpers
|
291 |
+
//
|
292 |
+
exists(t) {
|
293 |
+
return this.openMap.has(t);
|
294 |
+
}
|
295 |
+
fileType(t) {
|
296 |
+
const i = this.openMap.get(t);
|
297 |
+
return i ? i instanceof b ? X.REGULAR_FILE : X.DIRECTORY : X.UNKNOWN;
|
298 |
+
}
|
299 |
+
fileFdflags(t) {
|
300 |
+
const i = this.openMap.get(t);
|
301 |
+
return i instanceof b ? i.fdflags : 0;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
class b {
|
305 |
+
constructor(t, i) {
|
306 |
+
m(this, "file");
|
307 |
+
m(this, "buffer");
|
308 |
+
m(this, "_offset", BigInt(0));
|
309 |
+
m(this, "isDirty", !1);
|
310 |
+
m(this, "fdflags");
|
311 |
+
m(this, "flagAppend");
|
312 |
+
m(this, "flagDSync");
|
313 |
+
m(this, "flagNonBlock");
|
314 |
+
m(this, "flagRSync");
|
315 |
+
m(this, "flagSync");
|
316 |
+
if (this.file = t, this.file.mode === "string") {
|
317 |
+
const n = new TextEncoder();
|
318 |
+
this.buffer = n.encode(this.file.content);
|
319 |
+
} else
|
320 |
+
this.buffer = this.file.content;
|
321 |
+
this.fdflags = i, this.flagAppend = !!(i & E.APPEND), this.flagDSync = !!(i & E.DSYNC), this.flagNonBlock = !!(i & E.NONBLOCK), this.flagRSync = !!(i & E.RSYNC), this.flagSync = !!(i & E.SYNC);
|
322 |
+
}
|
323 |
+
get offset() {
|
324 |
+
return Number(this._offset);
|
325 |
+
}
|
326 |
+
read(t) {
|
327 |
+
const i = this.buffer.subarray(this.offset, this.offset + t);
|
328 |
+
return this._offset += BigInt(i.length), i;
|
329 |
+
}
|
330 |
+
pread(t, i) {
|
331 |
+
return this.buffer.subarray(i, i + t);
|
332 |
+
}
|
333 |
+
write(t) {
|
334 |
+
if (this.isDirty = !0, this.flagAppend) {
|
335 |
+
const i = this.buffer.length;
|
336 |
+
this.resize(i + t.byteLength), this.buffer.set(t, i);
|
337 |
+
} else {
|
338 |
+
const i = Math.max(
|
339 |
+
this.offset + t.byteLength,
|
340 |
+
this.buffer.byteLength
|
341 |
+
);
|
342 |
+
this.resize(i), this.buffer.set(t, this.offset), this._offset += BigInt(t.byteLength);
|
343 |
+
}
|
344 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
345 |
+
}
|
346 |
+
pwrite(t, i) {
|
347 |
+
if (this.isDirty = !0, this.flagAppend) {
|
348 |
+
const n = this.buffer.length;
|
349 |
+
this.resize(n + t.byteLength), this.buffer.set(t, n);
|
350 |
+
} else {
|
351 |
+
const n = Math.max(
|
352 |
+
i + t.byteLength,
|
353 |
+
this.buffer.byteLength
|
354 |
+
);
|
355 |
+
this.resize(n), this.buffer.set(t, i);
|
356 |
+
}
|
357 |
+
(this.flagDSync || this.flagSync) && this.sync();
|
358 |
+
}
|
359 |
+
sync() {
|
360 |
+
if (!this.isDirty)
|
361 |
+
return;
|
362 |
+
if (this.isDirty = !1, this.file.mode === "binary") {
|
363 |
+
this.file.content = new Uint8Array(this.buffer);
|
364 |
+
return;
|
365 |
+
}
|
366 |
+
const t = new TextDecoder();
|
367 |
+
this.file.content = t.decode(this.buffer);
|
368 |
+
}
|
369 |
+
seek(t, i) {
|
370 |
+
switch (i) {
|
371 |
+
case y.SET:
|
372 |
+
this._offset = t;
|
373 |
+
break;
|
374 |
+
case y.CUR:
|
375 |
+
this._offset += t;
|
376 |
+
break;
|
377 |
+
case y.END:
|
378 |
+
this._offset = BigInt(this.buffer.length) + t;
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return this._offset;
|
382 |
+
}
|
383 |
+
tell() {
|
384 |
+
return this._offset;
|
385 |
+
}
|
386 |
+
stat() {
|
387 |
+
return {
|
388 |
+
path: this.file.path,
|
389 |
+
timestamps: this.file.timestamps,
|
390 |
+
type: X.REGULAR_FILE,
|
391 |
+
byteLength: this.buffer.length
|
392 |
+
};
|
393 |
+
}
|
394 |
+
setFlags(t) {
|
395 |
+
this.fdflags = t;
|
396 |
+
}
|
397 |
+
setSize(t) {
|
398 |
+
this.resize(t);
|
399 |
+
}
|
400 |
+
setAccessTime(t) {
|
401 |
+
this.file.timestamps.access = t;
|
402 |
+
}
|
403 |
+
setModificationTime(t) {
|
404 |
+
this.file.timestamps.modification = t;
|
405 |
+
}
|
406 |
+
/**
|
407 |
+
* Resizes the buffer to be exactly requiredBytes length, while resizing the
|
408 |
+
* underlying buffer to be larger if necessary.
|
409 |
+
*
|
410 |
+
* Resizing will internally double the buffer size to reduce the need for
|
411 |
+
* resizing often.
|
412 |
+
*
|
413 |
+
* @param requiredBytes how many bytes the buffer needs to have available
|
414 |
+
*/
|
415 |
+
resize(t) {
|
416 |
+
if (t <= this.buffer.buffer.byteLength) {
|
417 |
+
this.buffer = new Uint8Array(this.buffer.buffer, 0, t);
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
let i;
|
421 |
+
this.buffer.buffer.byteLength === 0 ? i = new ArrayBuffer(t < 1024 ? 1024 : t * 2) : t > this.buffer.buffer.byteLength * 2 ? i = new ArrayBuffer(t * 2) : i = new ArrayBuffer(this.buffer.buffer.byteLength * 2);
|
422 |
+
const n = new Uint8Array(i, 0, t);
|
423 |
+
n.set(this.buffer), this.buffer = n;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
function C(e, t) {
|
427 |
+
const i = t.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&"), n = new RegExp(`^${i}`);
|
428 |
+
return e.replace(n, "");
|
429 |
+
}
|
430 |
+
class S {
|
431 |
+
// full folder path including /
|
432 |
+
constructor(t, i) {
|
433 |
+
m(this, "dir");
|
434 |
+
m(this, "prefix");
|
435 |
+
this.dir = t, this.prefix = i;
|
436 |
+
}
|
437 |
+
containsFile(t) {
|
438 |
+
for (const i of Object.keys(this.dir))
|
439 |
+
if (C(i, this.prefix) === t)
|
440 |
+
return !0;
|
441 |
+
return !1;
|
442 |
+
}
|
443 |
+
containsDirectory(t) {
|
444 |
+
for (const i of Object.keys(this.dir))
|
445 |
+
if (C(i, this.prefix).startsWith(`${t}/`))
|
446 |
+
return !0;
|
447 |
+
return !1;
|
448 |
+
}
|
449 |
+
contains(t) {
|
450 |
+
for (const i of Object.keys(this.dir)) {
|
451 |
+
const n = C(i, this.prefix);
|
452 |
+
if (n === t || n.startsWith(`${t}/`))
|
453 |
+
return !0;
|
454 |
+
}
|
455 |
+
return !1;
|
456 |
+
}
|
457 |
+
get(t) {
|
458 |
+
return this.dir[this.fullPath(t)];
|
459 |
+
}
|
460 |
+
fullPath(t) {
|
461 |
+
return `${this.prefix}${t}`;
|
462 |
+
}
|
463 |
+
list() {
|
464 |
+
const t = [], i = /* @__PURE__ */ new Set();
|
465 |
+
for (const n of Object.keys(this.dir)) {
|
466 |
+
const l = C(n, this.prefix);
|
467 |
+
if (l.includes("/")) {
|
468 |
+
const s = l.split("/")[0];
|
469 |
+
if (i.has(s))
|
470 |
+
continue;
|
471 |
+
i.add(s), t.push({ name: s, type: X.DIRECTORY });
|
472 |
+
} else
|
473 |
+
t.push({
|
474 |
+
name: l,
|
475 |
+
type: X.REGULAR_FILE
|
476 |
+
});
|
477 |
+
}
|
478 |
+
return t;
|
479 |
+
}
|
480 |
+
stat() {
|
481 |
+
return {
|
482 |
+
path: this.prefix,
|
483 |
+
timestamps: {
|
484 |
+
access: /* @__PURE__ */ new Date(),
|
485 |
+
modification: /* @__PURE__ */ new Date(),
|
486 |
+
change: /* @__PURE__ */ new Date()
|
487 |
+
},
|
488 |
+
type: X.DIRECTORY,
|
489 |
+
byteLength: 0
|
490 |
+
};
|
491 |
+
}
|
492 |
+
}
|
493 |
+
let z = [];
|
494 |
+
function f(e) {
|
495 |
+
z.push(e);
|
496 |
+
}
|
497 |
+
function Vt() {
|
498 |
+
const e = z;
|
499 |
+
return z = [], e;
|
500 |
+
}
|
501 |
+
class q {
|
502 |
+
constructor(t) {
|
503 |
+
m(this, "instance");
|
504 |
+
m(this, "module");
|
505 |
+
m(this, "memory");
|
506 |
+
m(this, "context");
|
507 |
+
m(this, "drive");
|
508 |
+
m(this, "initialized", !1);
|
509 |
+
this.context = t, this.drive = new at(t.fs);
|
510 |
+
}
|
511 |
+
static async start(t, i) {
|
512 |
+
const n = new q(i), l = await WebAssembly.instantiateStreaming(t, {
|
513 |
+
wasi_snapshot_preview1: n.getImports("preview1", i.debug),
|
514 |
+
wasi_unstable: n.getImports("unstable", i.debug)
|
515 |
+
});
|
516 |
+
return n.init(l), n.start();
|
517 |
+
}
|
518 |
+
init(t) {
|
519 |
+
this.instance = t.instance, this.module = t.module, this.memory = this.instance.exports.memory, this.initialized = !0;
|
520 |
+
}
|
521 |
+
start() {
|
522 |
+
if (!this.initialized)
|
523 |
+
throw new Error("WASI must be initialized with init(wasm) first");
|
524 |
+
const t = this.instance.exports._start;
|
525 |
+
try {
|
526 |
+
t();
|
527 |
+
} catch (i) {
|
528 |
+
if (i instanceof w)
|
529 |
+
return {
|
530 |
+
exitCode: i.code,
|
531 |
+
fs: this.drive.fs
|
532 |
+
};
|
533 |
+
if (i instanceof WebAssembly.RuntimeError)
|
534 |
+
return {
|
535 |
+
exitCode: 134,
|
536 |
+
fs: this.drive.fs
|
537 |
+
};
|
538 |
+
throw i;
|
539 |
+
}
|
540 |
+
return {
|
541 |
+
exitCode: 0,
|
542 |
+
fs: this.drive.fs
|
543 |
+
};
|
544 |
+
}
|
545 |
+
getImports(t, i) {
|
546 |
+
const n = {
|
547 |
+
args_get: this.args_get.bind(this),
|
548 |
+
args_sizes_get: this.args_sizes_get.bind(this),
|
549 |
+
clock_res_get: this.clock_res_get.bind(this),
|
550 |
+
clock_time_get: this.clock_time_get.bind(this),
|
551 |
+
environ_get: this.environ_get.bind(this),
|
552 |
+
environ_sizes_get: this.environ_sizes_get.bind(this),
|
553 |
+
proc_exit: this.proc_exit.bind(this),
|
554 |
+
random_get: this.random_get.bind(this),
|
555 |
+
sched_yield: this.sched_yield.bind(this),
|
556 |
+
// File Descriptors
|
557 |
+
fd_advise: this.fd_advise.bind(this),
|
558 |
+
fd_allocate: this.fd_allocate.bind(this),
|
559 |
+
fd_close: this.fd_close.bind(this),
|
560 |
+
fd_datasync: this.fd_datasync.bind(this),
|
561 |
+
fd_fdstat_get: this.fd_fdstat_get.bind(this),
|
562 |
+
fd_fdstat_set_flags: this.fd_fdstat_set_flags.bind(this),
|
563 |
+
fd_fdstat_set_rights: this.fd_fdstat_set_rights.bind(this),
|
564 |
+
fd_filestat_get: this.fd_filestat_get.bind(this),
|
565 |
+
fd_filestat_set_size: this.fd_filestat_set_size.bind(this),
|
566 |
+
fd_filestat_set_times: this.fd_filestat_set_times.bind(this),
|
567 |
+
fd_pread: this.fd_pread.bind(this),
|
568 |
+
fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this),
|
569 |
+
fd_prestat_get: this.fd_prestat_get.bind(this),
|
570 |
+
fd_pwrite: this.fd_pwrite.bind(this),
|
571 |
+
fd_read: this.fd_read.bind(this),
|
572 |
+
fd_readdir: this.fd_readdir.bind(this),
|
573 |
+
fd_renumber: this.fd_renumber.bind(this),
|
574 |
+
fd_seek: this.fd_seek.bind(this),
|
575 |
+
fd_sync: this.fd_sync.bind(this),
|
576 |
+
fd_tell: this.fd_tell.bind(this),
|
577 |
+
fd_write: this.fd_write.bind(this),
|
578 |
+
// Paths
|
579 |
+
path_filestat_get: this.path_filestat_get.bind(this),
|
580 |
+
path_filestat_set_times: this.path_filestat_set_times.bind(this),
|
581 |
+
path_open: this.path_open.bind(this),
|
582 |
+
path_rename: this.path_rename.bind(this),
|
583 |
+
path_unlink_file: this.path_unlink_file.bind(this),
|
584 |
+
path_create_directory: this.path_create_directory.bind(this),
|
585 |
+
// Unimplemented
|
586 |
+
path_link: this.path_link.bind(this),
|
587 |
+
path_readlink: this.path_readlink.bind(this),
|
588 |
+
path_remove_directory: this.path_remove_directory.bind(this),
|
589 |
+
path_symlink: this.path_symlink.bind(this),
|
590 |
+
poll_oneoff: this.poll_oneoff.bind(this),
|
591 |
+
proc_raise: this.proc_raise.bind(this),
|
592 |
+
sock_accept: this.sock_accept.bind(this),
|
593 |
+
sock_recv: this.sock_recv.bind(this),
|
594 |
+
sock_send: this.sock_send.bind(this),
|
595 |
+
sock_shutdown: this.sock_shutdown.bind(this),
|
596 |
+
// Unimplemented - WASMEdge compatibility
|
597 |
+
sock_open: this.sock_open.bind(this),
|
598 |
+
sock_listen: this.sock_listen.bind(this),
|
599 |
+
sock_connect: this.sock_connect.bind(this),
|
600 |
+
sock_setsockopt: this.sock_setsockopt.bind(this),
|
601 |
+
sock_bind: this.sock_bind.bind(this),
|
602 |
+
sock_getlocaladdr: this.sock_getlocaladdr.bind(this),
|
603 |
+
sock_getpeeraddr: this.sock_getpeeraddr.bind(this),
|
604 |
+
sock_getaddrinfo: this.sock_getaddrinfo.bind(this)
|
605 |
+
};
|
606 |
+
t === "unstable" && (n.path_filestat_get = this.unstable_path_filestat_get.bind(this), n.fd_filestat_get = this.unstable_fd_filestat_get.bind(this), n.fd_seek = this.unstable_fd_seek.bind(this));
|
607 |
+
for (const [l, s] of Object.entries(n))
|
608 |
+
n[l] = function() {
|
609 |
+
let d = s.apply(this, arguments);
|
610 |
+
if (i) {
|
611 |
+
const V = Vt();
|
612 |
+
d = i(l, [...arguments], d, V) ?? d;
|
613 |
+
}
|
614 |
+
return d;
|
615 |
+
};
|
616 |
+
return n;
|
617 |
+
}
|
618 |
+
//
|
619 |
+
// Helpers
|
620 |
+
//
|
621 |
+
get envArray() {
|
622 |
+
return Object.entries(this.context.env).map(
|
623 |
+
([t, i]) => `${t}=${i}`
|
624 |
+
);
|
625 |
+
}
|
626 |
+
//
|
627 |
+
// WASI Implementation
|
628 |
+
//
|
629 |
+
/**
|
630 |
+
* Read command-line argument data. The size of the array should match that
|
631 |
+
* returned by args_sizes_get. Each argument is expected to be \0 terminated.
|
632 |
+
*/
|
633 |
+
args_get(t, i) {
|
634 |
+
const n = new DataView(this.memory.buffer);
|
635 |
+
for (const l of this.context.args) {
|
636 |
+
n.setUint32(t, i, !0), t += 4;
|
637 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
638 |
+
new Uint8Array(
|
639 |
+
this.memory.buffer,
|
640 |
+
i,
|
641 |
+
s.byteLength
|
642 |
+
).set(s), i += s.byteLength;
|
643 |
+
}
|
644 |
+
return c.SUCCESS;
|
645 |
+
}
|
646 |
+
/**
|
647 |
+
* Return command-line argument data sizes.
|
648 |
+
*/
|
649 |
+
args_sizes_get(t, i) {
|
650 |
+
const n = this.context.args, l = n.reduce((d, V) => d + new TextEncoder().encode(`${V}\0`).byteLength, 0), s = new DataView(this.memory.buffer);
|
651 |
+
return s.setUint32(t, n.length, !0), s.setUint32(i, l, !0), c.SUCCESS;
|
652 |
+
}
|
653 |
+
/**
|
654 |
+
* Return the resolution of a clock. Implementations are required to provide a
|
655 |
+
* non-zero value for supported clocks. For unsupported clocks, return
|
656 |
+
* errno::inval. Note: This is similar to clock_getres in POSIX.
|
657 |
+
*/
|
658 |
+
clock_res_get(t, i) {
|
659 |
+
switch (t) {
|
660 |
+
case p.REALTIME:
|
661 |
+
case p.MONOTONIC:
|
662 |
+
case p.PROCESS_CPUTIME_ID:
|
663 |
+
case p.THREAD_CPUTIME_ID:
|
664 |
+
return new DataView(this.memory.buffer).setBigUint64(i, BigInt(1e6), !0), c.SUCCESS;
|
665 |
+
}
|
666 |
+
return c.EINVAL;
|
667 |
+
}
|
668 |
+
/**
|
669 |
+
* Return the time value of a clock.
|
670 |
+
* Note: This is similar to clock_gettime in POSIX.
|
671 |
+
*/
|
672 |
+
clock_time_get(t, i, n) {
|
673 |
+
switch (t) {
|
674 |
+
case p.REALTIME:
|
675 |
+
case p.MONOTONIC:
|
676 |
+
case p.PROCESS_CPUTIME_ID:
|
677 |
+
case p.THREAD_CPUTIME_ID:
|
678 |
+
return new DataView(this.memory.buffer).setBigUint64(n, L(/* @__PURE__ */ new Date()), !0), c.SUCCESS;
|
679 |
+
}
|
680 |
+
return c.EINVAL;
|
681 |
+
}
|
682 |
+
/**
|
683 |
+
* Read environment variable data. The sizes of the buffers should match that
|
684 |
+
* returned by environ_sizes_get. Key/value pairs are expected to be joined
|
685 |
+
* with =s, and terminated with \0s.
|
686 |
+
*/
|
687 |
+
environ_get(t, i) {
|
688 |
+
const n = new DataView(this.memory.buffer);
|
689 |
+
for (const l of this.envArray) {
|
690 |
+
n.setUint32(t, i, !0), t += 4;
|
691 |
+
const s = new TextEncoder().encode(`${l}\0`);
|
692 |
+
new Uint8Array(
|
693 |
+
this.memory.buffer,
|
694 |
+
i,
|
695 |
+
s.byteLength
|
696 |
+
).set(s), i += s.byteLength;
|
697 |
+
}
|
698 |
+
return c.SUCCESS;
|
699 |
+
}
|
700 |
+
/**
|
701 |
+
* Return environment variable data sizes.
|
702 |
+
*/
|
703 |
+
environ_sizes_get(t, i) {
|
704 |
+
const n = this.envArray.reduce((s, d) => s + new TextEncoder().encode(`${d}\0`).byteLength, 0), l = new DataView(this.memory.buffer);
|
705 |
+
return l.setUint32(t, this.envArray.length, !0), l.setUint32(i, n, !0), c.SUCCESS;
|
706 |
+
}
|
707 |
+
/**
|
708 |
+
* Terminate the process normally. An exit code of 0 indicates successful
|
709 |
+
* termination of the program. The meanings of other values is dependent on
|
710 |
+
* the environment.
|
711 |
+
*/
|
712 |
+
proc_exit(t) {
|
713 |
+
throw new w(t);
|
714 |
+
}
|
715 |
+
/**
|
716 |
+
* Write high-quality random data into a buffer. This function blocks when the
|
717 |
+
* implementation is unable to immediately provide sufficient high-quality
|
718 |
+
* random data. This function may execute slowly, so when large mounts of
|
719 |
+
* random data are required, it's advisable to use this function to seed a
|
720 |
+
* pseudo-random number generator, rather than to provide the random data
|
721 |
+
* directly.
|
722 |
+
*/
|
723 |
+
random_get(t, i) {
|
724 |
+
const n = new Uint8Array(this.memory.buffer, t, i);
|
725 |
+
return crypto.getRandomValues(n), c.SUCCESS;
|
726 |
+
}
|
727 |
+
/**
|
728 |
+
* Temporarily yield execution of the calling thread.
|
729 |
+
* Note: This is similar to sched_yield in POSIX.
|
730 |
+
*/
|
731 |
+
sched_yield() {
|
732 |
+
return c.SUCCESS;
|
733 |
+
}
|
734 |
+
//
|
735 |
+
// File Descriptors
|
736 |
+
//
|
737 |
+
/**
|
738 |
+
* Read from a file descriptor. Note: This is similar to readv in POSIX.
|
739 |
+
*/
|
740 |
+
fd_read(t, i, n, l) {
|
741 |
+
if (t === 1 || t === 2)
|
742 |
+
return c.ENOTSUP;
|
743 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextEncoder();
|
744 |
+
let a = 0, Z = c.SUCCESS;
|
745 |
+
for (const h of d) {
|
746 |
+
let r;
|
747 |
+
if (t === 0) {
|
748 |
+
const R = this.context.stdin(h.byteLength);
|
749 |
+
if (!R)
|
750 |
+
break;
|
751 |
+
r = V.encode(R);
|
752 |
+
} else {
|
753 |
+
const [R, k] = this.drive.read(t, h.byteLength);
|
754 |
+
if (R) {
|
755 |
+
Z = R;
|
756 |
+
break;
|
757 |
+
} else
|
758 |
+
r = k;
|
759 |
+
}
|
760 |
+
const o = Math.min(h.byteLength, r.byteLength);
|
761 |
+
h.set(r.subarray(0, o)), a += o;
|
762 |
+
}
|
763 |
+
return f({ bytesRead: a }), s.setUint32(l, a, !0), Z;
|
764 |
+
}
|
765 |
+
/**
|
766 |
+
* Write to a file descriptor. Note: This is similar to writev in POSIX.
|
767 |
+
*/
|
768 |
+
fd_write(t, i, n, l) {
|
769 |
+
if (t === 0)
|
770 |
+
return c.ENOTSUP;
|
771 |
+
const s = new DataView(this.memory.buffer), d = K(s, i, n), V = new TextDecoder();
|
772 |
+
let a = 0, Z = c.SUCCESS;
|
773 |
+
for (const h of d)
|
774 |
+
if (h.byteLength !== 0) {
|
775 |
+
if (t === 1 || t === 2) {
|
776 |
+
const r = t === 1 ? this.context.stdout : this.context.stderr, o = V.decode(h);
|
777 |
+
r(o), f({ output: o });
|
778 |
+
} else if (Z = this.drive.write(t, h), Z != c.SUCCESS)
|
779 |
+
break;
|
780 |
+
a += h.byteLength;
|
781 |
+
}
|
782 |
+
return s.setUint32(l, a, !0), Z;
|
783 |
+
}
|
784 |
+
/**
|
785 |
+
* Provide file advisory information on a file descriptor.
|
786 |
+
* Note: This is similar to posix_fadvise in POSIX.
|
787 |
+
*/
|
788 |
+
fd_advise() {
|
789 |
+
return c.SUCCESS;
|
790 |
+
}
|
791 |
+
/**
|
792 |
+
* Force the allocation of space in a file.
|
793 |
+
* Note: This is similar to posix_fallocate in POSIX.
|
794 |
+
*/
|
795 |
+
fd_allocate(t, i, n) {
|
796 |
+
return this.drive.pwrite(
|
797 |
+
t,
|
798 |
+
new Uint8Array(Number(n)),
|
799 |
+
Number(i)
|
800 |
+
);
|
801 |
+
}
|
802 |
+
/**
|
803 |
+
* Close a file descriptor.
|
804 |
+
* Note: This is similar to close in POSIX.
|
805 |
+
*
|
806 |
+
* @param fd
|
807 |
+
*/
|
808 |
+
fd_close(t) {
|
809 |
+
return this.drive.close(t);
|
810 |
+
}
|
811 |
+
/**
|
812 |
+
* Synchronize the data of a file to disk.
|
813 |
+
* Note: This is similar to fdatasync in POSIX.
|
814 |
+
*
|
815 |
+
* @param fd
|
816 |
+
*/
|
817 |
+
fd_datasync(t) {
|
818 |
+
return this.drive.sync(t);
|
819 |
+
}
|
820 |
+
/**
|
821 |
+
* Get the attributes of a file descriptor.
|
822 |
+
* Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX,
|
823 |
+
* as well as additional fields.
|
824 |
+
*
|
825 |
+
* Returns fdstat - the buffer where the file descriptor's attributes
|
826 |
+
* are stored.
|
827 |
+
*
|
828 |
+
* @returns Result<fdstat, errno>
|
829 |
+
*/
|
830 |
+
fd_fdstat_get(t, i) {
|
831 |
+
if (t < 3) {
|
832 |
+
let V;
|
833 |
+
if (this.context.isTTY) {
|
834 |
+
const Z = B ^ u.FD_SEEK ^ u.FD_TELL;
|
835 |
+
V = J(X.CHARACTER_DEVICE, 0, Z);
|
836 |
+
} else
|
837 |
+
V = J(X.CHARACTER_DEVICE, 0);
|
838 |
+
return new Uint8Array(
|
839 |
+
this.memory.buffer,
|
840 |
+
i,
|
841 |
+
V.byteLength
|
842 |
+
).set(V), c.SUCCESS;
|
843 |
+
}
|
844 |
+
if (!this.drive.exists(t))
|
845 |
+
return c.EBADF;
|
846 |
+
const n = this.drive.fileType(t), l = this.drive.fileFdflags(t), s = J(n, l);
|
847 |
+
return new Uint8Array(
|
848 |
+
this.memory.buffer,
|
849 |
+
i,
|
850 |
+
s.byteLength
|
851 |
+
).set(s), c.SUCCESS;
|
852 |
+
}
|
853 |
+
/**
|
854 |
+
* Adjust the flags associated with a file descriptor.
|
855 |
+
* Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
|
856 |
+
*/
|
857 |
+
fd_fdstat_set_flags(t, i) {
|
858 |
+
return this.drive.setFlags(t, i);
|
859 |
+
}
|
860 |
+
/**
|
861 |
+
* Adjust the rights associated with a file descriptor. This can only be used
|
862 |
+
* to remove rights, and returns errno::notcapable if called in a way that
|
863 |
+
* would attempt to add rights
|
864 |
+
*/
|
865 |
+
fd_fdstat_set_rights() {
|
866 |
+
return c.SUCCESS;
|
867 |
+
}
|
868 |
+
/**
|
869 |
+
* Return the attributes of an open file.
|
870 |
+
*/
|
871 |
+
fd_filestat_get(t, i) {
|
872 |
+
return this.shared_fd_filestat_get(t, i, "preview1");
|
873 |
+
}
|
874 |
+
/**
|
875 |
+
* Return the attributes of an open file.
|
876 |
+
* This version is used
|
877 |
+
*/
|
878 |
+
unstable_fd_filestat_get(t, i) {
|
879 |
+
return this.shared_fd_filestat_get(t, i, "unstable");
|
880 |
+
}
|
881 |
+
/**
|
882 |
+
* Return the attributes of an open file.
|
883 |
+
*/
|
884 |
+
shared_fd_filestat_get(t, i, n) {
|
885 |
+
const l = n === "unstable" ? A : _;
|
886 |
+
if (t < 3) {
|
887 |
+
let Z;
|
888 |
+
switch (t) {
|
889 |
+
case 0:
|
890 |
+
Z = "/dev/stdin";
|
891 |
+
break;
|
892 |
+
case 1:
|
893 |
+
Z = "/dev/stdout";
|
894 |
+
break;
|
895 |
+
case 2:
|
896 |
+
Z = "/dev/stderr";
|
897 |
+
break;
|
898 |
+
default:
|
899 |
+
Z = "/dev/undefined";
|
900 |
+
break;
|
901 |
+
}
|
902 |
+
const h = l({
|
903 |
+
path: Z,
|
904 |
+
byteLength: 0,
|
905 |
+
timestamps: {
|
906 |
+
access: /* @__PURE__ */ new Date(),
|
907 |
+
modification: /* @__PURE__ */ new Date(),
|
908 |
+
change: /* @__PURE__ */ new Date()
|
909 |
+
},
|
910 |
+
type: X.CHARACTER_DEVICE
|
911 |
+
});
|
912 |
+
return new Uint8Array(
|
913 |
+
this.memory.buffer,
|
914 |
+
i,
|
915 |
+
h.byteLength
|
916 |
+
).set(h), c.SUCCESS;
|
917 |
+
}
|
918 |
+
const [s, d] = this.drive.stat(t);
|
919 |
+
if (s != c.SUCCESS)
|
920 |
+
return s;
|
921 |
+
f({ resolvedPath: d.path, stat: d });
|
922 |
+
const V = l(d);
|
923 |
+
return new Uint8Array(
|
924 |
+
this.memory.buffer,
|
925 |
+
i,
|
926 |
+
V.byteLength
|
927 |
+
).set(V), c.SUCCESS;
|
928 |
+
}
|
929 |
+
/**
|
930 |
+
* Adjust the size of an open file. If this increases the file's size, the
|
931 |
+
* extra bytes are filled with zeros. Note: This is similar to ftruncate in
|
932 |
+
* POSIX.
|
933 |
+
*/
|
934 |
+
fd_filestat_set_size(t, i) {
|
935 |
+
return this.drive.setSize(t, i);
|
936 |
+
}
|
937 |
+
/**
|
938 |
+
* Adjust the timestamps of an open file or directory.
|
939 |
+
* Note: This is similar to futimens in POSIX.
|
940 |
+
*/
|
941 |
+
fd_filestat_set_times(t, i, n, l) {
|
942 |
+
let s = null;
|
943 |
+
l & U.ATIM && (s = W(i)), l & U.ATIM_NOW && (s = /* @__PURE__ */ new Date());
|
944 |
+
let d = null;
|
945 |
+
if (l & U.MTIM && (d = W(n)), l & U.MTIM_NOW && (d = /* @__PURE__ */ new Date()), s) {
|
946 |
+
const V = this.drive.setAccessTime(t, s);
|
947 |
+
if (V != c.SUCCESS)
|
948 |
+
return V;
|
949 |
+
}
|
950 |
+
if (d) {
|
951 |
+
const V = this.drive.setModificationTime(t, d);
|
952 |
+
if (V != c.SUCCESS)
|
953 |
+
return V;
|
954 |
+
}
|
955 |
+
return c.SUCCESS;
|
956 |
+
}
|
957 |
+
/**
|
958 |
+
* Read from a file descriptor, without using and updating the file
|
959 |
+
* descriptor's offset. Note: This is similar to preadv in POSIX.
|
960 |
+
*/
|
961 |
+
fd_pread(t, i, n, l, s) {
|
962 |
+
if (t === 1 || t === 2)
|
963 |
+
return c.ENOTSUP;
|
964 |
+
if (t === 0)
|
965 |
+
return this.fd_read(t, i, n, s);
|
966 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
967 |
+
let a = 0, Z = c.SUCCESS;
|
968 |
+
for (const h of V) {
|
969 |
+
const [r, o] = this.drive.pread(
|
970 |
+
t,
|
971 |
+
h.byteLength,
|
972 |
+
Number(l) + a
|
973 |
+
);
|
974 |
+
if (r !== c.SUCCESS) {
|
975 |
+
Z = r;
|
976 |
+
break;
|
977 |
+
}
|
978 |
+
const R = Math.min(h.byteLength, o.byteLength);
|
979 |
+
h.set(o.subarray(0, R)), a += R;
|
980 |
+
}
|
981 |
+
return d.setUint32(s, a, !0), Z;
|
982 |
+
}
|
983 |
+
/**
|
984 |
+
* Return a description of the given preopened file descriptor.
|
985 |
+
*/
|
986 |
+
fd_prestat_dir_name(t, i, n) {
|
987 |
+
if (t !== 3)
|
988 |
+
return c.EBADF;
|
989 |
+
const l = new TextEncoder().encode("/");
|
990 |
+
return new Uint8Array(this.memory.buffer, i, n).set(l.subarray(0, n)), c.SUCCESS;
|
991 |
+
}
|
992 |
+
/**
|
993 |
+
* Return a description of the given preopened file descriptor.
|
994 |
+
*/
|
995 |
+
fd_prestat_get(t, i) {
|
996 |
+
if (t !== 3)
|
997 |
+
return c.EBADF;
|
998 |
+
const n = new TextEncoder().encode("."), l = new DataView(this.memory.buffer, i);
|
999 |
+
return l.setUint8(0, D.DIR), l.setUint32(4, n.byteLength, !0), c.SUCCESS;
|
1000 |
+
}
|
1001 |
+
/**
|
1002 |
+
* Write to a file descriptor, without using and updating the file
|
1003 |
+
* descriptor's offset. Note: This is similar to pwritev in POSIX.
|
1004 |
+
*/
|
1005 |
+
fd_pwrite(t, i, n, l, s) {
|
1006 |
+
if (t === 0)
|
1007 |
+
return c.ENOTSUP;
|
1008 |
+
if (t === 1 || t === 2)
|
1009 |
+
return this.fd_write(t, i, n, s);
|
1010 |
+
const d = new DataView(this.memory.buffer), V = K(d, i, n);
|
1011 |
+
let a = 0, Z = c.SUCCESS;
|
1012 |
+
for (const h of V)
|
1013 |
+
if (h.byteLength !== 0) {
|
1014 |
+
if (Z = this.drive.pwrite(t, h, Number(l)), Z != c.SUCCESS)
|
1015 |
+
break;
|
1016 |
+
a += h.byteLength;
|
1017 |
+
}
|
1018 |
+
return d.setUint32(s, a, !0), Z;
|
1019 |
+
}
|
1020 |
+
/**
|
1021 |
+
* Read directory entries from a directory. When successful, the contents of
|
1022 |
+
* the output buffer consist of a sequence of directory entries. Each
|
1023 |
+
* directory entry consists of a dirent object, followed by dirent::d_namlen
|
1024 |
+
* bytes holding the name of the directory entry. This function fills the
|
1025 |
+
* output buffer as much as possible, potentially truncating the last
|
1026 |
+
* directory entry. This allows the caller to grow its read buffer size in
|
1027 |
+
* case it's too small to fit a single large directory entry, or skip the
|
1028 |
+
* oversized directory entry.
|
1029 |
+
*/
|
1030 |
+
fd_readdir(t, i, n, l, s) {
|
1031 |
+
const [d, V] = this.drive.list(t);
|
1032 |
+
if (d != c.SUCCESS)
|
1033 |
+
return d;
|
1034 |
+
let a = [], Z = 0;
|
1035 |
+
for (const { name: N, type: F } of V) {
|
1036 |
+
const g = ht(N, F, Z);
|
1037 |
+
a.push(g), Z++;
|
1038 |
+
}
|
1039 |
+
a = a.slice(Number(l));
|
1040 |
+
const h = a.reduce((N, F) => N + F.byteLength, 0), r = new Uint8Array(h);
|
1041 |
+
let o = 0;
|
1042 |
+
for (const N of a)
|
1043 |
+
r.set(N, o), o += N.byteLength;
|
1044 |
+
const R = new Uint8Array(this.memory.buffer, i, n), k = r.subarray(0, n);
|
1045 |
+
return R.set(k), new DataView(this.memory.buffer).setUint32(s, k.byteLength, !0), c.SUCCESS;
|
1046 |
+
}
|
1047 |
+
/**
|
1048 |
+
* Atomically replace a file descriptor by renumbering another file
|
1049 |
+
* descriptor. Due to the strong focus on thread safety, this environment does
|
1050 |
+
* not provide a mechanism to duplicate or renumber a file descriptor to an
|
1051 |
+
* arbitrary number, like dup2(). This would be prone to race conditions, as
|
1052 |
+
* an actual file descriptor with the same number could be allocated by a
|
1053 |
+
* different thread at the same time. This function provides a way to
|
1054 |
+
* atomically renumber file descriptors, which would disappear if dup2() were
|
1055 |
+
* to be removed entirely.
|
1056 |
+
*/
|
1057 |
+
fd_renumber(t, i) {
|
1058 |
+
return this.drive.renumber(t, i);
|
1059 |
+
}
|
1060 |
+
/**
|
1061 |
+
* Move the offset of a file descriptor.
|
1062 |
+
*
|
1063 |
+
* The offset is specified as a bigint here
|
1064 |
+
* Note: This is similar to lseek in POSIX.
|
1065 |
+
*
|
1066 |
+
* The offset, and return type are FileSize (u64) which is represented by
|
1067 |
+
* bigint in JavaScript.
|
1068 |
+
*/
|
1069 |
+
fd_seek(t, i, n, l) {
|
1070 |
+
const [s, d] = this.drive.seek(t, i, n);
|
1071 |
+
return s !== c.SUCCESS || (f({ newOffset: d.toString() }), new DataView(this.memory.buffer).setBigUint64(l, d, !0)), s;
|
1072 |
+
}
|
1073 |
+
unstable_fd_seek(t, i, n, l) {
|
1074 |
+
const s = mt[n];
|
1075 |
+
return this.fd_seek(t, i, s, l);
|
1076 |
+
}
|
1077 |
+
/**
|
1078 |
+
* Synchronize the data and metadata of a file to disk.
|
1079 |
+
* Note: This is similar to fsync in POSIX.
|
1080 |
+
*/
|
1081 |
+
fd_sync(t) {
|
1082 |
+
return this.drive.sync(t);
|
1083 |
+
}
|
1084 |
+
/**
|
1085 |
+
* Return the current offset of a file descriptor.
|
1086 |
+
* Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
|
1087 |
+
*
|
1088 |
+
* The return type is FileSize (u64) which is represented by bigint in JS.
|
1089 |
+
*
|
1090 |
+
*/
|
1091 |
+
fd_tell(t, i) {
|
1092 |
+
const [n, l] = this.drive.tell(t);
|
1093 |
+
return n !== c.SUCCESS || new DataView(this.memory.buffer).setBigUint64(i, l, !0), n;
|
1094 |
+
}
|
1095 |
+
//
|
1096 |
+
// Paths
|
1097 |
+
//
|
1098 |
+
path_filestat_get(t, i, n, l, s) {
|
1099 |
+
return this.shared_path_filestat_get(
|
1100 |
+
t,
|
1101 |
+
i,
|
1102 |
+
n,
|
1103 |
+
l,
|
1104 |
+
s,
|
1105 |
+
"preview1"
|
1106 |
+
);
|
1107 |
+
}
|
1108 |
+
unstable_path_filestat_get(t, i, n, l, s) {
|
1109 |
+
return this.shared_path_filestat_get(
|
1110 |
+
t,
|
1111 |
+
i,
|
1112 |
+
n,
|
1113 |
+
l,
|
1114 |
+
s,
|
1115 |
+
"unstable"
|
1116 |
+
);
|
1117 |
+
}
|
1118 |
+
/**
|
1119 |
+
* Return the attributes of a file or directory.
|
1120 |
+
* Note: This is similar to stat in POSIX.
|
1121 |
+
*/
|
1122 |
+
shared_path_filestat_get(t, i, n, l, s, d) {
|
1123 |
+
const V = d === "unstable" ? A : _, a = new TextDecoder().decode(
|
1124 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1125 |
+
);
|
1126 |
+
f({ path: a });
|
1127 |
+
const [Z, h] = this.drive.pathStat(t, a);
|
1128 |
+
if (Z != c.SUCCESS)
|
1129 |
+
return Z;
|
1130 |
+
const r = V(h);
|
1131 |
+
return new Uint8Array(
|
1132 |
+
this.memory.buffer,
|
1133 |
+
s,
|
1134 |
+
r.byteLength
|
1135 |
+
).set(r), Z;
|
1136 |
+
}
|
1137 |
+
/**
|
1138 |
+
* Adjust the timestamps of a file or directory.
|
1139 |
+
* Note: This is similar to utimensat in POSIX.
|
1140 |
+
*/
|
1141 |
+
path_filestat_set_times(t, i, n, l, s, d, V) {
|
1142 |
+
let a = null;
|
1143 |
+
V & U.ATIM && (a = W(s)), V & U.ATIM_NOW && (a = /* @__PURE__ */ new Date());
|
1144 |
+
let Z = null;
|
1145 |
+
V & U.MTIM && (Z = W(d)), V & U.MTIM_NOW && (Z = /* @__PURE__ */ new Date());
|
1146 |
+
const h = new TextDecoder().decode(
|
1147 |
+
new Uint8Array(this.memory.buffer, n, l)
|
1148 |
+
);
|
1149 |
+
if (a) {
|
1150 |
+
const r = this.drive.pathSetAccessTime(t, h, a);
|
1151 |
+
if (r != c.SUCCESS)
|
1152 |
+
return r;
|
1153 |
+
}
|
1154 |
+
if (Z) {
|
1155 |
+
const r = this.drive.pathSetModificationTime(
|
1156 |
+
t,
|
1157 |
+
h,
|
1158 |
+
Z
|
1159 |
+
);
|
1160 |
+
if (r != c.SUCCESS)
|
1161 |
+
return r;
|
1162 |
+
}
|
1163 |
+
return c.SUCCESS;
|
1164 |
+
}
|
1165 |
+
/**
|
1166 |
+
* Open a file or directory. The returned file descriptor is not guaranteed to
|
1167 |
+
* be the lowest-numbered file descriptor not currently open; it is randomized
|
1168 |
+
* to prevent applications from depending on making assumptions about indexes,
|
1169 |
+
* since this is error-prone in multi-threaded contexts. The returned file
|
1170 |
+
* descriptor is guaranteed to be less than 2**31.
|
1171 |
+
* Note: This is similar to openat in POSIX.
|
1172 |
+
* @param fd: fd
|
1173 |
+
* @param dirflags: lookupflags Flags determining the method of how the path
|
1174 |
+
* is resolved. Not supported by Runno (symlinks)
|
1175 |
+
* @param path: string The relative path of the file or directory to open,
|
1176 |
+
* relative to the path_open::fd directory.
|
1177 |
+
* @param oflags: oflags The method by which to open the file.
|
1178 |
+
* @param fs_rights_base: rights The initial rights of the newly created file
|
1179 |
+
* descriptor. The implementation is allowed to return
|
1180 |
+
* a file descriptor with fewer rights than specified,
|
1181 |
+
* if and only if those rights do not apply to the type
|
1182 |
+
* of file being opened. The base rights are rights
|
1183 |
+
* that will apply to operations using the file
|
1184 |
+
* descriptor itself, while the inheriting rights are
|
1185 |
+
* rights that apply to file descriptors derived from
|
1186 |
+
* it.
|
1187 |
+
* @param fs_rights_inheriting: rights
|
1188 |
+
* @param fdflags: fdflags
|
1189 |
+
*
|
1190 |
+
*/
|
1191 |
+
path_open(t, i, n, l, s, d, V, a, Z) {
|
1192 |
+
const h = new DataView(this.memory.buffer), r = I(this.memory, n, l), o = !!(s & T.CREAT), R = !!(s & T.DIRECTORY), k = !!(s & T.EXCL), P = !!(s & T.TRUNC), N = !!(a & E.APPEND), F = !!(a & E.DSYNC), g = !!(a & E.NONBLOCK), et = !!(a & E.RSYNC), it = !!(a & E.SYNC);
|
1193 |
+
f({
|
1194 |
+
path: r,
|
1195 |
+
openFlags: {
|
1196 |
+
createFileIfNone: o,
|
1197 |
+
failIfNotDir: R,
|
1198 |
+
failIfFileExists: k,
|
1199 |
+
truncateFile: P
|
1200 |
+
},
|
1201 |
+
fileDescriptorFlags: {
|
1202 |
+
flagAppend: N,
|
1203 |
+
flagDSync: F,
|
1204 |
+
flagNonBlock: g,
|
1205 |
+
flagRSync: et,
|
1206 |
+
flagSync: it
|
1207 |
+
}
|
1208 |
+
});
|
1209 |
+
const [Q, nt] = this.drive.open(t, r, s, a);
|
1210 |
+
return Q || (h.setUint32(Z, nt, !0), Q);
|
1211 |
+
}
|
1212 |
+
/**
|
1213 |
+
* Rename a file or directory. Note: This is similar to renameat in POSIX.
|
1214 |
+
*/
|
1215 |
+
path_rename(t, i, n, l, s, d) {
|
1216 |
+
const V = I(this.memory, i, n), a = I(this.memory, s, d);
|
1217 |
+
return f({ oldPath: V, newPath: a }), this.drive.rename(t, V, l, a);
|
1218 |
+
}
|
1219 |
+
/**
|
1220 |
+
* Unlink a file. Return errno::isdir if the path refers to a directory.
|
1221 |
+
* Note: This is similar to unlinkat(fd, path, 0) in POSIX.
|
1222 |
+
*/
|
1223 |
+
path_unlink_file(t, i, n) {
|
1224 |
+
const l = I(this.memory, i, n);
|
1225 |
+
return f({ path: l }), this.drive.unlink(t, l);
|
1226 |
+
}
|
1227 |
+
/**
|
1228 |
+
* Concurrently poll for the occurrence of a set of events.
|
1229 |
+
*/
|
1230 |
+
poll_oneoff(t, i, n, l) {
|
1231 |
+
for (let d = 0; d < n; d++) {
|
1232 |
+
const V = new Uint8Array(
|
1233 |
+
this.memory.buffer,
|
1234 |
+
t + d * M,
|
1235 |
+
M
|
1236 |
+
), a = Zt(V), Z = new Uint8Array(
|
1237 |
+
this.memory.buffer,
|
1238 |
+
i + d * x,
|
1239 |
+
x
|
1240 |
+
);
|
1241 |
+
let h = 0, r = c.SUCCESS;
|
1242 |
+
switch (a.type) {
|
1243 |
+
case G.CLOCK:
|
1244 |
+
for (; /* @__PURE__ */ new Date() < a.timeout; )
|
1245 |
+
;
|
1246 |
+
Z.set(
|
1247 |
+
rt(a.userdata, c.SUCCESS)
|
1248 |
+
);
|
1249 |
+
break;
|
1250 |
+
case G.FD_READ:
|
1251 |
+
if (a.fd < 3)
|
1252 |
+
a.fd === 0 ? (r = c.SUCCESS, h = 32) : r = c.EBADF;
|
1253 |
+
else {
|
1254 |
+
const [o, R] = this.drive.stat(a.fd);
|
1255 |
+
r = o, h = R ? R.byteLength : 0;
|
1256 |
+
}
|
1257 |
+
Z.set(
|
1258 |
+
v(
|
1259 |
+
a.userdata,
|
1260 |
+
r,
|
1261 |
+
G.FD_READ,
|
1262 |
+
BigInt(h)
|
1263 |
+
)
|
1264 |
+
);
|
1265 |
+
break;
|
1266 |
+
case G.FD_WRITE:
|
1267 |
+
if (h = 0, r = c.SUCCESS, a.fd < 3)
|
1268 |
+
a.fd === 0 ? r = c.EBADF : (r = c.SUCCESS, h = 1024);
|
1269 |
+
else {
|
1270 |
+
const [o, R] = this.drive.stat(a.fd);
|
1271 |
+
r = o, h = R ? R.byteLength : 0;
|
1272 |
+
}
|
1273 |
+
Z.set(
|
1274 |
+
v(
|
1275 |
+
a.userdata,
|
1276 |
+
r,
|
1277 |
+
G.FD_READ,
|
1278 |
+
BigInt(h)
|
1279 |
+
)
|
1280 |
+
);
|
1281 |
+
break;
|
1282 |
+
}
|
1283 |
+
}
|
1284 |
+
return new DataView(this.memory.buffer, l, 4).setUint32(0, n, !0), c.SUCCESS;
|
1285 |
+
}
|
1286 |
+
/**
|
1287 |
+
* Create a directory. Note: This is similar to mkdirat in POSIX.
|
1288 |
+
*/
|
1289 |
+
path_create_directory(t, i, n) {
|
1290 |
+
const l = I(this.memory, i, n);
|
1291 |
+
return this.drive.pathCreateDir(t, l);
|
1292 |
+
}
|
1293 |
+
//
|
1294 |
+
// Unimplemented - these operations are not supported by Runno
|
1295 |
+
//
|
1296 |
+
/**
|
1297 |
+
* Create a hard link. Note: This is similar to linkat in POSIX.
|
1298 |
+
*/
|
1299 |
+
path_link() {
|
1300 |
+
return c.ENOSYS;
|
1301 |
+
}
|
1302 |
+
/**
|
1303 |
+
* Read the contents of a symbolic link.
|
1304 |
+
* Note: This is similar to readlinkat in POSIX.
|
1305 |
+
*/
|
1306 |
+
path_readlink() {
|
1307 |
+
return c.ENOSYS;
|
1308 |
+
}
|
1309 |
+
/**
|
1310 |
+
* Remove a directory. Return errno::notempty if the directory is not empty.
|
1311 |
+
* Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
|
1312 |
+
*/
|
1313 |
+
path_remove_directory() {
|
1314 |
+
return c.ENOSYS;
|
1315 |
+
}
|
1316 |
+
/**
|
1317 |
+
* Create a symbolic link. Note: This is similar to symlinkat in POSIX.
|
1318 |
+
*/
|
1319 |
+
path_symlink() {
|
1320 |
+
return c.ENOSYS;
|
1321 |
+
}
|
1322 |
+
/**
|
1323 |
+
* Send a signal to the process of the calling thread.
|
1324 |
+
* Note: This is similar to raise in POSIX.
|
1325 |
+
*/
|
1326 |
+
proc_raise() {
|
1327 |
+
return c.ENOSYS;
|
1328 |
+
}
|
1329 |
+
/**
|
1330 |
+
* Accept a new incoming connection. Note: This is similar to accept in POSIX.
|
1331 |
+
*/
|
1332 |
+
sock_accept() {
|
1333 |
+
return c.ENOSYS;
|
1334 |
+
}
|
1335 |
+
/**
|
1336 |
+
* Receive a message from a socket. Note: This is similar to recv in POSIX,
|
1337 |
+
* though it also supports reading the data into multiple buffers in the
|
1338 |
+
* manner of readv.
|
1339 |
+
*/
|
1340 |
+
sock_recv() {
|
1341 |
+
return c.ENOSYS;
|
1342 |
+
}
|
1343 |
+
/**
|
1344 |
+
* Send a message on a socket. Note: This is similar to send in POSIX, though
|
1345 |
+
* it also supports writing the data from multiple buffers in the manner of
|
1346 |
+
* writev.
|
1347 |
+
*/
|
1348 |
+
sock_send() {
|
1349 |
+
return c.ENOSYS;
|
1350 |
+
}
|
1351 |
+
/**
|
1352 |
+
* Shut down socket send and receive channels. Note: This is similar to
|
1353 |
+
* shutdown in POSIX.
|
1354 |
+
*/
|
1355 |
+
sock_shutdown() {
|
1356 |
+
return c.ENOSYS;
|
1357 |
+
}
|
1358 |
+
//
|
1359 |
+
// Unimplemented - these are for compatibility with Wasmedge
|
1360 |
+
//
|
1361 |
+
sock_open() {
|
1362 |
+
return c.ENOSYS;
|
1363 |
+
}
|
1364 |
+
sock_listen() {
|
1365 |
+
return c.ENOSYS;
|
1366 |
+
}
|
1367 |
+
sock_connect() {
|
1368 |
+
return c.ENOSYS;
|
1369 |
+
}
|
1370 |
+
sock_setsockopt() {
|
1371 |
+
return c.ENOSYS;
|
1372 |
+
}
|
1373 |
+
sock_bind() {
|
1374 |
+
return c.ENOSYS;
|
1375 |
+
}
|
1376 |
+
sock_getlocaladdr() {
|
1377 |
+
return c.ENOSYS;
|
1378 |
+
}
|
1379 |
+
sock_getpeeraddr() {
|
1380 |
+
return c.ENOSYS;
|
1381 |
+
}
|
1382 |
+
sock_getaddrinfo() {
|
1383 |
+
return c.ENOSYS;
|
1384 |
+
}
|
1385 |
+
}
|
1386 |
+
const B = u.FD_DATASYNC | u.FD_READ | u.FD_SEEK | u.FD_FDSTAT_SET_FLAGS | u.FD_SYNC | u.FD_TELL | u.FD_WRITE | u.FD_ADVISE | u.FD_ALLOCATE | u.PATH_CREATE_DIRECTORY | u.PATH_CREATE_FILE | u.PATH_LINK_SOURCE | u.PATH_LINK_TARGET | u.PATH_OPEN | u.FD_READDIR | u.PATH_READLINK | u.PATH_RENAME_SOURCE | u.PATH_RENAME_TARGET | u.PATH_FILESTAT_GET | u.PATH_FILESTAT_SET_SIZE | u.PATH_FILESTAT_SET_TIMES | u.FD_FILESTAT_GET | u.FD_FILESTAT_SET_SIZE | u.FD_FILESTAT_SET_TIMES | u.PATH_SYMLINK | u.PATH_REMOVE_DIRECTORY | u.PATH_UNLINK_FILE | u.POLL_FD_READWRITE | u.SOCK_SHUTDOWN | u.SOCK_ACCEPT;
|
1387 |
+
class w extends Error {
|
1388 |
+
constructor(i) {
|
1389 |
+
super();
|
1390 |
+
m(this, "code");
|
1391 |
+
this.code = i;
|
1392 |
+
}
|
1393 |
+
}
|
1394 |
+
function I(e, t, i) {
|
1395 |
+
return new TextDecoder().decode(new Uint8Array(e.buffer, t, i));
|
1396 |
+
}
|
1397 |
+
function K(e, t, i) {
|
1398 |
+
let n = Array(i);
|
1399 |
+
for (let l = 0; l < i; l++) {
|
1400 |
+
const s = e.getUint32(t, !0);
|
1401 |
+
t += 4;
|
1402 |
+
const d = e.getUint32(t, !0);
|
1403 |
+
t += 4, n[l] = new Uint8Array(e.buffer, s, d);
|
1404 |
+
}
|
1405 |
+
return n;
|
1406 |
+
}
|
1407 |
+
function Zt(e) {
|
1408 |
+
const t = new Uint8Array(8);
|
1409 |
+
t.set(e.subarray(0, 8));
|
1410 |
+
const i = e[8], n = new DataView(e.buffer, e.byteOffset + 9);
|
1411 |
+
switch (i) {
|
1412 |
+
case G.FD_READ:
|
1413 |
+
case G.FD_WRITE:
|
1414 |
+
return {
|
1415 |
+
userdata: t,
|
1416 |
+
type: i,
|
1417 |
+
fd: n.getUint32(0, !0)
|
1418 |
+
};
|
1419 |
+
case G.CLOCK:
|
1420 |
+
const l = n.getUint16(24, !0), s = L(/* @__PURE__ */ new Date()), d = n.getBigUint64(8, !0), V = n.getBigUint64(16, !0), a = l & $.SUBSCRIPTION_CLOCK_ABSTIME ? d : s + d;
|
1421 |
+
return {
|
1422 |
+
userdata: t,
|
1423 |
+
type: i,
|
1424 |
+
id: n.getUint32(0, !0),
|
1425 |
+
timeout: W(a),
|
1426 |
+
precision: W(a + V)
|
1427 |
+
};
|
1428 |
+
}
|
1429 |
+
}
|
1430 |
+
function _(e) {
|
1431 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1432 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setBigUint64(24, BigInt(1), !0), i.setBigUint64(32, BigInt(e.byteLength), !0), i.setBigUint64(40, L(e.timestamps.access), !0), i.setBigUint64(48, L(e.timestamps.modification), !0), i.setBigUint64(56, L(e.timestamps.change), !0), t;
|
1433 |
+
}
|
1434 |
+
function A(e) {
|
1435 |
+
const t = new Uint8Array(O), i = new DataView(t.buffer);
|
1436 |
+
return i.setBigUint64(0, BigInt(0), !0), i.setBigUint64(8, BigInt(H(e.path)), !0), i.setUint8(16, e.type), i.setUint32(20, 1, !0), i.setBigUint64(24, BigInt(e.byteLength), !0), i.setBigUint64(32, L(e.timestamps.access), !0), i.setBigUint64(40, L(e.timestamps.modification), !0), i.setBigUint64(48, L(e.timestamps.change), !0), t;
|
1437 |
+
}
|
1438 |
+
function J(e, t, i) {
|
1439 |
+
const n = i ?? B, l = i ?? B, s = new Uint8Array(24), d = new DataView(s.buffer, 0, 24);
|
1440 |
+
return d.setUint8(0, e), d.setUint32(2, t, !0), d.setBigUint64(8, n, !0), d.setBigUint64(16, l, !0), s;
|
1441 |
+
}
|
1442 |
+
function ht(e, t, i) {
|
1443 |
+
const n = new TextEncoder().encode(e), l = 24 + n.byteLength, s = new Uint8Array(l), d = new DataView(s.buffer);
|
1444 |
+
return d.setBigUint64(0, BigInt(i + 1), !0), d.setBigUint64(8, BigInt(H(e)), !0), d.setUint32(16, n.length, !0), d.setUint8(20, t), s.set(n, 24), s;
|
1445 |
+
}
|
1446 |
+
function rt(e, t) {
|
1447 |
+
const i = new Uint8Array(32);
|
1448 |
+
i.set(e, 0);
|
1449 |
+
const n = new DataView(i.buffer);
|
1450 |
+
return n.setUint16(8, t, !0), n.setUint16(10, G.CLOCK, !0), i;
|
1451 |
+
}
|
1452 |
+
function v(e, t, i, n) {
|
1453 |
+
const l = new Uint8Array(32);
|
1454 |
+
l.set(e, 0);
|
1455 |
+
const s = new DataView(l.buffer);
|
1456 |
+
return s.setUint16(8, t, !0), s.setUint16(10, i, !0), s.setBigUint64(16, n, !0), l;
|
1457 |
+
}
|
1458 |
+
function H(e, t = 0) {
|
1459 |
+
let i = 3735928559 ^ t, n = 1103547991 ^ t;
|
1460 |
+
for (let l = 0, s; l < e.length; l++)
|
1461 |
+
s = e.charCodeAt(l), i = Math.imul(i ^ s, 2654435761), n = Math.imul(n ^ s, 1597334677);
|
1462 |
+
return i = Math.imul(i ^ i >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(i ^ i >>> 13, 3266489909), 4294967296 * (2097151 & n) + (i >>> 0);
|
1463 |
+
}
|
1464 |
+
function L(e) {
|
1465 |
+
return BigInt(e.getTime()) * BigInt(1e6);
|
1466 |
+
}
|
1467 |
+
function W(e) {
|
1468 |
+
return new Date(Number(e / BigInt(1e6)));
|
1469 |
+
}
|
1470 |
+
const mt = {
|
1471 |
+
[Y.CUR]: y.CUR,
|
1472 |
+
[Y.END]: y.END,
|
1473 |
+
[Y.SET]: y.SET
|
1474 |
+
};
|
1475 |
+
class Xt {
|
1476 |
+
constructor(t) {
|
1477 |
+
m(this, "fs");
|
1478 |
+
m(this, "args");
|
1479 |
+
// Program args (like from a terminal program)
|
1480 |
+
m(this, "env");
|
1481 |
+
// Environment (like a .env file)
|
1482 |
+
m(this, "stdin");
|
1483 |
+
m(this, "stdout");
|
1484 |
+
m(this, "stderr");
|
1485 |
+
m(this, "debug");
|
1486 |
+
m(this, "isTTY");
|
1487 |
+
this.fs = (t == null ? void 0 : t.fs) ?? {}, this.args = (t == null ? void 0 : t.args) ?? [], this.env = (t == null ? void 0 : t.env) ?? {}, this.stdin = (t == null ? void 0 : t.stdin) ?? (() => null), this.stdout = (t == null ? void 0 : t.stdout) ?? (() => {
|
1488 |
+
}), this.stderr = (t == null ? void 0 : t.stderr) ?? (() => {
|
1489 |
+
}), this.debug = t == null ? void 0 : t.debug, this.isTTY = !!(t != null && t.isTTY);
|
1490 |
+
}
|
1491 |
+
}
|
1492 |
+
const tt = "dmFyIHV0PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgZ3Q9KHIsVCxEKT0+VCBpbiByP3V0KHIsVCx7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6RH0pOnJbVF09RDt2YXIgZD0ocixULEQpPT4oZ3Qocix0eXBlb2YgVCE9InN5bWJvbCI/VCsiIjpULEQpLEQpOyhmdW5jdGlvbigpeyJ1c2Ugc3RyaWN0Ijt2YXIgcj0oZT0+KGVbZS5TVUNDRVNTPTBdPSJTVUNDRVNTIixlW2UuRTJCSUc9MV09IkUyQklHIixlW2UuRUFDQ0VTUz0yXT0iRUFDQ0VTUyIsZVtlLkVBRERSSU5VU0U9M109IkVBRERSSU5VU0UiLGVbZS5FQUREUk5PVEFWQUlMPTRdPSJFQUREUk5PVEFWQUlMIixlW2UuRUFGTk9TVVBQT1JUPTVdPSJFQUZOT1NV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nkobikpLEwoe3RhcmdldDoiaG9zdCIsdHlwZToiZGVidWciLG5hbWU6ZSxhcmdzOnQscmV0OmksZGF0YTpufSksaX1mdW5jdGlvbiBodChlLHQpe0F0b21pY3Mud2FpdChuZXcgSW50MzJBcnJheSh0KSwwLDApO2NvbnN0IGk9bmV3IERhdGFWaWV3KHQpLG49aS5nZXRJbnQzMigwKTtpZihuPDApcmV0dXJuIGkuc2V0SW50MzIoMCwwKSxudWxsO2NvbnN0IHM9bmV3IFVpbnQ4QXJyYXkodCw0LG4pLGE9bmV3IFRleHREZWNvZGVyKCkuZGVjb2RlKHMuc2xpY2UoMCxlKSksZj1zLnNsaWNlKGUscy5sZW5ndGgpO3JldHVybiBpLnNldEludDMyKDAsZi5ieXRlTGVuZ3RoKSxzLnNldChmKSxhfX0pKCk7Cg==", j = typeof window < "u" && window.Blob && new Blob([atob(tt)], { type: "text/javascript;charset=utf-8" });
|
1493 |
+
function ut() {
|
1494 |
+
let e;
|
1495 |
+
try {
|
1496 |
+
if (e = j && (window.URL || window.webkitURL).createObjectURL(j), !e)
|
1497 |
+
throw "";
|
1498 |
+
return new Worker(e);
|
1499 |
+
} catch {
|
1500 |
+
return new Worker("data:application/javascript;base64," + tt);
|
1501 |
+
} finally {
|
1502 |
+
e && (window.URL || window.webkitURL).revokeObjectURL(e);
|
1503 |
+
}
|
1504 |
+
}
|
1505 |
+
function ot(e, t) {
|
1506 |
+
e.postMessage(t);
|
1507 |
+
}
|
1508 |
+
class St extends Error {
|
1509 |
+
}
|
1510 |
+
class Gt {
|
1511 |
+
constructor(t, i) {
|
1512 |
+
m(this, "binaryURL");
|
1513 |
+
// 8kb should be big enough
|
1514 |
+
m(this, "stdinBuffer", new SharedArrayBuffer(8 * 1024));
|
1515 |
+
m(this, "context");
|
1516 |
+
m(this, "result");
|
1517 |
+
m(this, "worker");
|
1518 |
+
m(this, "reject");
|
1519 |
+
this.binaryURL = t, this.context = i;
|
1520 |
+
}
|
1521 |
+
async start() {
|
1522 |
+
if (this.result)
|
1523 |
+
throw new Error("WASIWorker Host can only be started once");
|
1524 |
+
return this.result = new Promise((t, i) => {
|
1525 |
+
this.reject = i, this.worker = new ut(), this.worker.addEventListener("message", (n) => {
|
1526 |
+
var s, d, V, a, Z, h;
|
1527 |
+
const l = n.data;
|
1528 |
+
switch (l.type) {
|
1529 |
+
case "stdout":
|
1530 |
+
(d = (s = this.context).stdout) == null || d.call(s, l.text);
|
1531 |
+
break;
|
1532 |
+
case "stderr":
|
1533 |
+
(a = (V = this.context).stderr) == null || a.call(V, l.text);
|
1534 |
+
break;
|
1535 |
+
case "debug":
|
1536 |
+
(h = (Z = this.context).debug) == null || h.call(
|
1537 |
+
Z,
|
1538 |
+
l.name,
|
1539 |
+
l.args,
|
1540 |
+
l.ret,
|
1541 |
+
l.data
|
1542 |
+
);
|
1543 |
+
break;
|
1544 |
+
case "result":
|
1545 |
+
t(l.result);
|
1546 |
+
break;
|
1547 |
+
case "crash":
|
1548 |
+
i(l.error);
|
1549 |
+
break;
|
1550 |
+
}
|
1551 |
+
}), ot(this.worker, {
|
1552 |
+
target: "client",
|
1553 |
+
type: "start",
|
1554 |
+
binaryURL: this.binaryURL,
|
1555 |
+
stdinBuffer: this.stdinBuffer,
|
1556 |
+
// Unfortunately can't just splat these because it includes types
|
1557 |
+
// that can't be sent as a message.
|
1558 |
+
args: this.context.args,
|
1559 |
+
env: this.context.env,
|
1560 |
+
fs: this.context.fs,
|
1561 |
+
isTTY: this.context.isTTY
|
1562 |
+
});
|
1563 |
+
}), this.result;
|
1564 |
+
}
|
1565 |
+
kill() {
|
1566 |
+
var t;
|
1567 |
+
if (!this.worker)
|
1568 |
+
throw new Error("WASIWorker has not started");
|
1569 |
+
this.worker.terminate(), (t = this.reject) == null || t.call(this, new St("WASI Worker was killed"));
|
1570 |
+
}
|
1571 |
+
async pushStdin(t) {
|
1572 |
+
const i = new DataView(this.stdinBuffer);
|
1573 |
+
for (; i.getInt32(0) !== 0; )
|
1574 |
+
await new Promise((s) => setTimeout(s, 0));
|
1575 |
+
const n = new TextEncoder().encode(t);
|
1576 |
+
new Uint8Array(this.stdinBuffer, 4).set(n), i.setInt32(0, n.byteLength), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1577 |
+
}
|
1578 |
+
async pushEOF() {
|
1579 |
+
const t = new DataView(this.stdinBuffer);
|
1580 |
+
for (; t.getInt32(0) !== 0; )
|
1581 |
+
await new Promise((i) => setTimeout(i, 0));
|
1582 |
+
t.setInt32(0, -1), Atomics.notify(new Int32Array(this.stdinBuffer), 0);
|
1583 |
+
}
|
1584 |
+
}
|
1585 |
+
export {
|
1586 |
+
q as WASI,
|
1587 |
+
Xt as WASIContext,
|
1588 |
+
bt as WASISnapshotPreview1,
|
1589 |
+
Gt as WASIWorkerHost,
|
1590 |
+
St as WASIWorkerHostKilledError
|
1591 |
+
};
|
vite.config.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { defineConfig } from 'vite'
|
2 |
+
import vue from '@vitejs/plugin-vue'
|
3 |
+
|
4 |
+
// https://vitejs.dev/config/
|
5 |
+
export default defineConfig({
|
6 |
+
plugins: [vue()]
|
7 |
+
})
|