typenative 0.6.2 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1131) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +18 -8
  3. package/bin/go/overrides.js +21 -1
  4. package/bin/index.js +48 -25
  5. package/bin/main.js +2 -1
  6. package/bin/node/assert.js +56 -17
  7. package/bin/node/async_hooks.js +69 -10
  8. package/bin/node/buffer.js +321 -7
  9. package/bin/node/child_process.js +220 -16
  10. package/bin/node/cluster.js +436 -32
  11. package/bin/node/crypto.js +814 -5
  12. package/bin/node/crypto_curves.js +142 -0
  13. package/bin/node/crypto_keys.js +1147 -48
  14. package/bin/node/crypto_pem.js +313 -0
  15. package/bin/node/crypto_pkcs12.js +17 -0
  16. package/bin/node/dgram.js +161 -10
  17. package/bin/node/diagnostics_channel.js +5 -1
  18. package/bin/node/events.js +358 -8
  19. package/bin/node/ffi.js +933 -0
  20. package/bin/node/fs.js +1346 -10
  21. package/bin/node/histogram.js +1991 -0
  22. package/bin/node/http.js +630 -55
  23. package/bin/node/http2.js +1141 -88
  24. package/bin/node/intl.js +4576 -0
  25. package/bin/node/intl_data.js +65412 -0
  26. package/bin/node/module_v8.js +155 -16
  27. package/bin/node/net.js +59 -10
  28. package/bin/node/path.js +5 -1
  29. package/bin/node/process.js +355 -4
  30. package/bin/node/readline.js +558 -8
  31. package/bin/node/registry.js +2 -0
  32. package/bin/node/sqlite.js +1539 -7
  33. package/bin/node/stream.js +371 -32
  34. package/bin/node/stream_web.js +422 -15
  35. package/bin/node/system_extra.js +40 -154
  36. package/bin/node/temporal.js +96 -0
  37. package/bin/node/temporal_runtime.js +5075 -0
  38. package/bin/node/temporal_zones.js +460 -0
  39. package/bin/node/test.js +191 -8
  40. package/bin/node/test_coverage.js +58 -0
  41. package/bin/node/test_report.js +50 -4
  42. package/bin/node/test_run.js +64 -3
  43. package/bin/node/timers.js +123 -0
  44. package/bin/node/tls.js +346 -12
  45. package/bin/node/tls_roots.js +122 -0
  46. package/bin/node/typed_arrays.js +867 -93
  47. package/bin/node/url.js +657 -0
  48. package/bin/node/util.js +449 -7
  49. package/bin/node/util_extra.js +6 -0
  50. package/bin/node/wasi.js +214 -0
  51. package/bin/node/webassembly.js +1137 -0
  52. package/bin/node/websocket.js +763 -0
  53. package/bin/node/webview.js +3257 -244
  54. package/bin/node/worker_threads.js +434 -52
  55. package/bin/node/zlib.js +455 -22
  56. package/bin/node/zlib_iter.js +585 -0
  57. package/bin/node/zlib_zip.js +2392 -0
  58. package/bin/transpiler.js +3417 -501
  59. package/bin/typecheck-node.js +49 -17
  60. package/bin/version.js +1 -1
  61. package/govendor/github.com/cloudflare/circl/.golangci.yaml +64 -0
  62. package/govendor/github.com/cloudflare/circl/.semgrepignore +1 -0
  63. package/govendor/github.com/cloudflare/circl/AGENTS.md +91 -0
  64. package/govendor/github.com/cloudflare/circl/CITATION.cff +30 -0
  65. package/govendor/github.com/cloudflare/circl/LICENSE +57 -0
  66. package/govendor/github.com/cloudflare/circl/Makefile +70 -0
  67. package/govendor/github.com/cloudflare/circl/README.md +206 -0
  68. package/govendor/github.com/cloudflare/circl/REVIEW.md +83 -0
  69. package/govendor/github.com/cloudflare/circl/codecov.yml +21 -0
  70. package/govendor/github.com/cloudflare/circl/dh/x448/curve.go +104 -0
  71. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.go +30 -0
  72. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.h +111 -0
  73. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.s +194 -0
  74. package/govendor/github.com/cloudflare/circl/dh/x448/curve_generic.go +100 -0
  75. package/govendor/github.com/cloudflare/circl/dh/x448/curve_noasm.go +11 -0
  76. package/govendor/github.com/cloudflare/circl/dh/x448/doc.go +19 -0
  77. package/govendor/github.com/cloudflare/circl/dh/x448/key.go +46 -0
  78. package/govendor/github.com/cloudflare/circl/dh/x448/table.go +460 -0
  79. package/govendor/github.com/cloudflare/circl/doc.go +8 -0
  80. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/constants.go +71 -0
  81. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/curve.go +90 -0
  82. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/isogeny.go +52 -0
  83. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/point.go +181 -0
  84. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/scalar.go +203 -0
  85. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist.go +138 -0
  86. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistPoint.go +135 -0
  87. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistTables.go +216 -0
  88. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist_basemult.go +62 -0
  89. package/govendor/github.com/cloudflare/circl/go.mod +3 -0
  90. package/govendor/github.com/cloudflare/circl/internal/conv/conv.go +173 -0
  91. package/govendor/github.com/cloudflare/circl/internal/sha3/doc.go +62 -0
  92. package/govendor/github.com/cloudflare/circl/internal/sha3/hashes.go +69 -0
  93. package/govendor/github.com/cloudflare/circl/internal/sha3/keccakf.go +391 -0
  94. package/govendor/github.com/cloudflare/circl/internal/sha3/rc.go +29 -0
  95. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3.go +200 -0
  96. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3_s390x.s +33 -0
  97. package/govendor/github.com/cloudflare/circl/internal/sha3/shake.go +119 -0
  98. package/govendor/github.com/cloudflare/circl/internal/sha3/xor.go +15 -0
  99. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_generic.go +33 -0
  100. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_unaligned.go +61 -0
  101. package/govendor/github.com/cloudflare/circl/math/fp448/fp.go +164 -0
  102. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.go +43 -0
  103. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.h +591 -0
  104. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.s +75 -0
  105. package/govendor/github.com/cloudflare/circl/math/fp448/fp_generic.go +339 -0
  106. package/govendor/github.com/cloudflare/circl/math/fp448/fp_noasm.go +12 -0
  107. package/govendor/github.com/cloudflare/circl/math/fp448/fuzzer.go +75 -0
  108. package/govendor/github.com/cloudflare/circl/math/integer.go +16 -0
  109. package/govendor/github.com/cloudflare/circl/math/mlsbset/mlsbset.go +145 -0
  110. package/govendor/github.com/cloudflare/circl/math/mlsbset/power.go +64 -0
  111. package/govendor/github.com/cloudflare/circl/math/primes.go +34 -0
  112. package/govendor/github.com/cloudflare/circl/math/wnaf.go +84 -0
  113. package/govendor/github.com/cloudflare/circl/sign/ed448/ed448.go +417 -0
  114. package/govendor/github.com/cloudflare/circl/sign/ed448/signapi.go +89 -0
  115. package/govendor/github.com/cloudflare/circl/sign/sign.go +119 -0
  116. package/{examples/react-compiler/vendor/picocolors → govendor/github.com/decred/dcrd/dcrec/secp256k1/v4}/LICENSE +4 -2
  117. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/README.md +72 -0
  118. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/compressedbytepoints.go +18 -0
  119. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve.go +1310 -0
  120. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_embedded.go +14 -0
  121. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_precompute.go +14 -0
  122. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/doc.go +59 -0
  123. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdh.go +21 -0
  124. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/README.md +52 -0
  125. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/doc.go +42 -0
  126. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/error.go +134 -0
  127. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/signature.go +1001 -0
  128. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ellipticadaptor.go +296 -0
  129. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/error.go +67 -0
  130. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/field.go +1696 -0
  131. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/go.mod +3 -0
  132. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/loadprecomputed.go +91 -0
  133. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/modnscalar.go +1105 -0
  134. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/nonce.go +263 -0
  135. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/privkey.go +111 -0
  136. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/pubkey.go +236 -0
  137. package/govendor/github.com/ebitengine/purego/LICENSE +201 -0
  138. package/govendor/github.com/ebitengine/purego/README.md +124 -0
  139. package/govendor/github.com/ebitengine/purego/abi_amd64.h +99 -0
  140. package/govendor/github.com/ebitengine/purego/abi_arm64.h +39 -0
  141. package/govendor/github.com/ebitengine/purego/abi_loong64.h +60 -0
  142. package/govendor/github.com/ebitengine/purego/cdecl.go +11 -0
  143. package/govendor/github.com/ebitengine/purego/cgo.go +19 -0
  144. package/govendor/github.com/ebitengine/purego/dlerror.go +17 -0
  145. package/govendor/github.com/ebitengine/purego/dlfcn.go +99 -0
  146. package/govendor/github.com/ebitengine/purego/dlfcn_android.go +34 -0
  147. package/govendor/github.com/ebitengine/purego/dlfcn_darwin.go +20 -0
  148. package/govendor/github.com/ebitengine/purego/dlfcn_freebsd.go +14 -0
  149. package/govendor/github.com/ebitengine/purego/dlfcn_linux.go +16 -0
  150. package/govendor/github.com/ebitengine/purego/dlfcn_netbsd.go +15 -0
  151. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.go +11 -0
  152. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.go +19 -0
  153. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_netbsd.go +11 -0
  154. package/govendor/github.com/ebitengine/purego/dlfcn_playground.go +24 -0
  155. package/govendor/github.com/ebitengine/purego/dlfcn_stubs.s +22 -0
  156. package/govendor/github.com/ebitengine/purego/func.go +780 -0
  157. package/govendor/github.com/ebitengine/purego/gen.go +6 -0
  158. package/govendor/github.com/ebitengine/purego/go.mod +3 -0
  159. package/govendor/github.com/ebitengine/purego/go_runtime.go +19 -0
  160. package/govendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +56 -0
  161. package/govendor/github.com/ebitengine/purego/internal/cgo/empty.go +6 -0
  162. package/govendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +49 -0
  163. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h +99 -0
  164. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h +39 -0
  165. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_loong64.h +60 -0
  166. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_ppc64x.h +195 -0
  167. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_riscv64.h +72 -0
  168. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_386.s +29 -0
  169. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s +39 -0
  170. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm.s +58 -0
  171. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s +35 -0
  172. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_loong64.s +38 -0
  173. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_ppc64le.s +79 -0
  174. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_riscv64.s +36 -0
  175. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_s390x.s +52 -0
  176. package/govendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +93 -0
  177. package/govendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +32 -0
  178. package/govendor/github.com/ebitengine/purego/internal/fakecgo/fakecgo.go +14 -0
  179. package/govendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go +27 -0
  180. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin.go +86 -0
  181. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd.go +77 -0
  182. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +72 -0
  183. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_linux.go +77 -0
  184. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_netbsd.go +83 -0
  185. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +18 -0
  186. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +38 -0
  187. package/govendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +19 -0
  188. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +37 -0
  189. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +37 -0
  190. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +27 -0
  191. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +27 -0
  192. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_netbsd.go +36 -0
  193. package/govendor/github.com/ebitengine/purego/internal/fakecgo/linux.go +189 -0
  194. package/govendor/github.com/ebitengine/purego/internal/fakecgo/netbsd.go +23 -0
  195. package/govendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +19 -0
  196. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_amd64.go +15 -0
  197. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_noasm.go +24 -0
  198. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_386.s +130 -0
  199. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s +124 -0
  200. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm.s +131 -0
  201. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s +81 -0
  202. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_386.s +78 -0
  203. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_amd64.s +69 -0
  204. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm.s +69 -0
  205. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm64.s +60 -0
  206. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_loong64.s +60 -0
  207. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_ppc64le.s +69 -0
  208. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_riscv64.s +60 -0
  209. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_s390x.s +51 -0
  210. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_loong64.s +78 -0
  211. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_ppc64le.s +132 -0
  212. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_riscv64.s +76 -0
  213. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_s390x.s +158 -0
  214. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols.go +165 -0
  215. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_darwin.go +59 -0
  216. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_freebsd.go +48 -0
  217. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_linux.go +158 -0
  218. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_netbsd.go +59 -0
  219. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_darwin.s +19 -0
  220. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_freebsd.s +16 -0
  221. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_linux.s +46 -0
  222. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_netbsd.s +19 -0
  223. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_stubs.s +55 -0
  224. package/govendor/github.com/ebitengine/purego/internal/strings/strings.go +40 -0
  225. package/govendor/github.com/ebitengine/purego/is_ios.go +13 -0
  226. package/govendor/github.com/ebitengine/purego/nocgo.go +25 -0
  227. package/govendor/github.com/ebitengine/purego/struct_amd64.go +518 -0
  228. package/govendor/github.com/ebitengine/purego/struct_arm.go +100 -0
  229. package/govendor/github.com/ebitengine/purego/struct_arm64.go +757 -0
  230. package/govendor/github.com/ebitengine/purego/struct_loong64.go +244 -0
  231. package/govendor/github.com/ebitengine/purego/struct_other.go +54 -0
  232. package/govendor/github.com/ebitengine/purego/struct_ppc64le.go +180 -0
  233. package/govendor/github.com/ebitengine/purego/struct_riscv64.go +158 -0
  234. package/govendor/github.com/ebitengine/purego/struct_s390x.go +158 -0
  235. package/govendor/github.com/ebitengine/purego/sys_386.s +153 -0
  236. package/govendor/github.com/ebitengine/purego/sys_amd64.s +206 -0
  237. package/govendor/github.com/ebitengine/purego/sys_arm.s +153 -0
  238. package/govendor/github.com/ebitengine/purego/sys_arm64.s +133 -0
  239. package/govendor/github.com/ebitengine/purego/sys_loong64.s +131 -0
  240. package/govendor/github.com/ebitengine/purego/sys_ppc64le.s +126 -0
  241. package/govendor/github.com/ebitengine/purego/sys_riscv64.s +135 -0
  242. package/govendor/github.com/ebitengine/purego/sys_s390x.s +148 -0
  243. package/govendor/github.com/ebitengine/purego/sys_unix_386.s +234 -0
  244. package/govendor/github.com/ebitengine/purego/sys_unix_arm.s +99 -0
  245. package/govendor/github.com/ebitengine/purego/sys_unix_arm64.s +75 -0
  246. package/govendor/github.com/ebitengine/purego/sys_unix_loong64.s +79 -0
  247. package/govendor/github.com/ebitengine/purego/sys_unix_ppc64le.s +114 -0
  248. package/govendor/github.com/ebitengine/purego/sys_unix_riscv64.s +79 -0
  249. package/govendor/github.com/ebitengine/purego/sys_unix_s390x.s +111 -0
  250. package/govendor/github.com/ebitengine/purego/syscall.go +95 -0
  251. package/govendor/github.com/ebitengine/purego/syscall_32bit.go +97 -0
  252. package/govendor/github.com/ebitengine/purego/syscall_cgo_linux.go +20 -0
  253. package/govendor/github.com/ebitengine/purego/syscall_notstackargs.go +55 -0
  254. package/govendor/github.com/ebitengine/purego/syscall_ppc64le.go +73 -0
  255. package/govendor/github.com/ebitengine/purego/syscall_stackargs_ppc64le.go +38 -0
  256. package/govendor/github.com/ebitengine/purego/syscall_stackargs_s390x.go +38 -0
  257. package/govendor/github.com/ebitengine/purego/syscall_unix.go +392 -0
  258. package/govendor/github.com/ebitengine/purego/syscall_windows.go +54 -0
  259. package/govendor/github.com/ebitengine/purego/zcallback_386.s +4014 -0
  260. package/govendor/github.com/ebitengine/purego/zcallback_amd64.s +2014 -0
  261. package/govendor/github.com/ebitengine/purego/zcallback_arm.s +4014 -0
  262. package/govendor/github.com/ebitengine/purego/zcallback_arm64.s +4014 -0
  263. package/govendor/github.com/ebitengine/purego/zcallback_loong64.s +4014 -0
  264. package/govendor/github.com/ebitengine/purego/zcallback_ppc64le.s +4014 -0
  265. package/govendor/github.com/ebitengine/purego/zcallback_riscv64.s +4051 -0
  266. package/govendor/github.com/ebitengine/purego/zcallback_s390x.s +4015 -0
  267. package/govendor/github.com/klauspost/compress/.gitattributes +3 -0
  268. package/govendor/github.com/klauspost/compress/.goreleaser.yml +132 -0
  269. package/govendor/github.com/klauspost/compress/AGENTS.md +106 -0
  270. package/govendor/github.com/klauspost/compress/LICENSE +304 -0
  271. package/govendor/github.com/klauspost/compress/README.md +766 -0
  272. package/govendor/github.com/klauspost/compress/SECURITY.md +25 -0
  273. package/govendor/github.com/klauspost/compress/compressible.go +85 -0
  274. package/govendor/github.com/klauspost/compress/fse/README.md +79 -0
  275. package/govendor/github.com/klauspost/compress/fse/bitreader.go +122 -0
  276. package/govendor/github.com/klauspost/compress/fse/bitwriter.go +167 -0
  277. package/govendor/github.com/klauspost/compress/fse/bytereader.go +47 -0
  278. package/govendor/github.com/klauspost/compress/fse/compress.go +685 -0
  279. package/govendor/github.com/klauspost/compress/fse/decompress.go +383 -0
  280. package/govendor/github.com/klauspost/compress/fse/fse.go +150 -0
  281. package/govendor/github.com/klauspost/compress/gen.sh +4 -0
  282. package/govendor/github.com/klauspost/compress/go.mod +3 -0
  283. package/govendor/github.com/klauspost/compress/huff0/README.md +89 -0
  284. package/govendor/github.com/klauspost/compress/huff0/bitreader.go +323 -0
  285. package/govendor/github.com/klauspost/compress/huff0/bitwriter.go +97 -0
  286. package/govendor/github.com/klauspost/compress/huff0/build_table.go +168 -0
  287. package/govendor/github.com/klauspost/compress/huff0/compress.go +747 -0
  288. package/govendor/github.com/klauspost/compress/huff0/decompress.go +1188 -0
  289. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.go +128 -0
  290. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.s +3476 -0
  291. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.go +72 -0
  292. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.s +1648 -0
  293. package/govendor/github.com/klauspost/compress/huff0/decompress_asm.go +252 -0
  294. package/govendor/github.com/klauspost/compress/huff0/decompress_generic.go +278 -0
  295. package/govendor/github.com/klauspost/compress/huff0/huff0.go +337 -0
  296. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo.go +34 -0
  297. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.go +10 -0
  298. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.s +34 -0
  299. package/govendor/github.com/klauspost/compress/internal/le/le.go +5 -0
  300. package/govendor/github.com/klauspost/compress/internal/le/unsafe_disabled.go +42 -0
  301. package/govendor/github.com/klauspost/compress/internal/le/unsafe_enabled.go +52 -0
  302. package/govendor/github.com/klauspost/compress/internal/regmask/regmask.go +50 -0
  303. package/govendor/github.com/klauspost/compress/internal/regmask/regmask_386.go +39 -0
  304. package/govendor/github.com/klauspost/compress/internal/snapref/LICENSE +27 -0
  305. package/govendor/github.com/klauspost/compress/internal/snapref/decode.go +264 -0
  306. package/govendor/github.com/klauspost/compress/internal/snapref/decode_other.go +113 -0
  307. package/govendor/github.com/klauspost/compress/internal/snapref/encode.go +291 -0
  308. package/govendor/github.com/klauspost/compress/internal/snapref/encode_other.go +250 -0
  309. package/govendor/github.com/klauspost/compress/internal/snapref/snappy.go +98 -0
  310. package/govendor/github.com/klauspost/compress/s2sx.mod +3 -0
  311. package/govendor/github.com/klauspost/compress/s2sx.sum +0 -0
  312. package/govendor/github.com/klauspost/compress/zstd/README.md +487 -0
  313. package/govendor/github.com/klauspost/compress/zstd/bitreader.go +176 -0
  314. package/govendor/github.com/klauspost/compress/zstd/bitwriter.go +151 -0
  315. package/govendor/github.com/klauspost/compress/zstd/blockdec.go +728 -0
  316. package/govendor/github.com/klauspost/compress/zstd/blockenc.go +923 -0
  317. package/govendor/github.com/klauspost/compress/zstd/blocktype_string.go +85 -0
  318. package/govendor/github.com/klauspost/compress/zstd/bytebuf.go +131 -0
  319. package/govendor/github.com/klauspost/compress/zstd/bytereader.go +82 -0
  320. package/govendor/github.com/klauspost/compress/zstd/decodeheader.go +261 -0
  321. package/govendor/github.com/klauspost/compress/zstd/decoder.go +995 -0
  322. package/govendor/github.com/klauspost/compress/zstd/decoder_options.go +213 -0
  323. package/govendor/github.com/klauspost/compress/zstd/dict.go +605 -0
  324. package/govendor/github.com/klauspost/compress/zstd/enc_base.go +200 -0
  325. package/govendor/github.com/klauspost/compress/zstd/enc_best.go +572 -0
  326. package/govendor/github.com/klauspost/compress/zstd/enc_better.go +1262 -0
  327. package/govendor/github.com/klauspost/compress/zstd/enc_dfast.go +1136 -0
  328. package/govendor/github.com/klauspost/compress/zstd/enc_fast.go +892 -0
  329. package/govendor/github.com/klauspost/compress/zstd/enc_jobs.go +352 -0
  330. package/govendor/github.com/klauspost/compress/zstd/encoder.go +881 -0
  331. package/govendor/github.com/klauspost/compress/zstd/encoder_options.go +422 -0
  332. package/govendor/github.com/klauspost/compress/zstd/framedec.go +404 -0
  333. package/govendor/github.com/klauspost/compress/zstd/frameenc.go +137 -0
  334. package/govendor/github.com/klauspost/compress/zstd/fse_decoder.go +333 -0
  335. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s +132 -0
  336. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s +148 -0
  337. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go +70 -0
  338. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go +71 -0
  339. package/govendor/github.com/klauspost/compress/zstd/fse_encoder.go +701 -0
  340. package/govendor/github.com/klauspost/compress/zstd/fse_predefined.go +168 -0
  341. package/govendor/github.com/klauspost/compress/zstd/hash.go +57 -0
  342. package/govendor/github.com/klauspost/compress/zstd/history.go +119 -0
  343. package/{examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt → govendor/github.com/klauspost/compress/zstd/internal/xxhash/LICENSE.txt} +3 -1
  344. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/README.md +71 -0
  345. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash.go +242 -0
  346. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_amd64.s +210 -0
  347. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s +184 -0
  348. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_asm.go +11 -0
  349. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_other.go +75 -0
  350. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_safe.go +11 -0
  351. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.go +15 -0
  352. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.s +66 -0
  353. package/govendor/github.com/klauspost/compress/zstd/matchlen_generic.go +37 -0
  354. package/govendor/github.com/klauspost/compress/zstd/seqdec.go +620 -0
  355. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.go +115 -0
  356. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.s +4762 -0
  357. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.go +81 -0
  358. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.s +2919 -0
  359. package/govendor/github.com/klauspost/compress/zstd/seqdec_asm.go +327 -0
  360. package/govendor/github.com/klauspost/compress/zstd/seqdec_generic.go +258 -0
  361. package/govendor/github.com/klauspost/compress/zstd/seqenc.go +159 -0
  362. package/govendor/github.com/klauspost/compress/zstd/simple.go +54 -0
  363. package/govendor/github.com/klauspost/compress/zstd/snappy.go +447 -0
  364. package/govendor/github.com/klauspost/compress/zstd/zip.go +141 -0
  365. package/govendor/github.com/klauspost/compress/zstd/zstd.go +126 -0
  366. package/govendor/github.com/tetratelabs/wazero/.editorconfig +7 -0
  367. package/govendor/github.com/tetratelabs/wazero/.gitattributes +2 -0
  368. package/govendor/github.com/tetratelabs/wazero/.gitmodules +3 -0
  369. package/govendor/github.com/tetratelabs/wazero/CONTRIBUTING.md +75 -0
  370. package/govendor/github.com/tetratelabs/wazero/LICENSE +201 -0
  371. package/govendor/github.com/tetratelabs/wazero/Makefile +385 -0
  372. package/govendor/github.com/tetratelabs/wazero/NOTICE +2 -0
  373. package/govendor/github.com/tetratelabs/wazero/RATIONALE.md +1577 -0
  374. package/govendor/github.com/tetratelabs/wazero/README.md +135 -0
  375. package/govendor/github.com/tetratelabs/wazero/api/features.go +228 -0
  376. package/govendor/github.com/tetratelabs/wazero/api/wasm.go +766 -0
  377. package/govendor/github.com/tetratelabs/wazero/builder.go +367 -0
  378. package/govendor/github.com/tetratelabs/wazero/cache.go +123 -0
  379. package/govendor/github.com/tetratelabs/wazero/codecov.yml +9 -0
  380. package/govendor/github.com/tetratelabs/wazero/config.go +899 -0
  381. package/govendor/github.com/tetratelabs/wazero/experimental/checkpoint.go +35 -0
  382. package/govendor/github.com/tetratelabs/wazero/experimental/close.go +63 -0
  383. package/govendor/github.com/tetratelabs/wazero/experimental/compilationworkers.go +19 -0
  384. package/govendor/github.com/tetratelabs/wazero/experimental/experimental.go +41 -0
  385. package/govendor/github.com/tetratelabs/wazero/experimental/features.go +39 -0
  386. package/govendor/github.com/tetratelabs/wazero/experimental/importresolver.go +19 -0
  387. package/govendor/github.com/tetratelabs/wazero/experimental/listener.go +324 -0
  388. package/govendor/github.com/tetratelabs/wazero/experimental/memory.go +52 -0
  389. package/govendor/github.com/tetratelabs/wazero/experimental/sys/dir.go +92 -0
  390. package/govendor/github.com/tetratelabs/wazero/experimental/sys/errno.go +98 -0
  391. package/govendor/github.com/tetratelabs/wazero/experimental/sys/error.go +45 -0
  392. package/govendor/github.com/tetratelabs/wazero/experimental/sys/file.go +356 -0
  393. package/govendor/github.com/tetratelabs/wazero/experimental/sys/fs.go +292 -0
  394. package/govendor/github.com/tetratelabs/wazero/experimental/sys/oflag.go +70 -0
  395. package/govendor/github.com/tetratelabs/wazero/experimental/sys/poll.go +48 -0
  396. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno.go +106 -0
  397. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_notwindows.go +13 -0
  398. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_unsupported.go +7 -0
  399. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_windows.go +37 -0
  400. package/govendor/github.com/tetratelabs/wazero/experimental/sys/time.go +10 -0
  401. package/govendor/github.com/tetratelabs/wazero/experimental/sys/unimplemented.go +160 -0
  402. package/govendor/github.com/tetratelabs/wazero/fsconfig.go +213 -0
  403. package/govendor/github.com/tetratelabs/wazero/go.mod +3 -0
  404. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/args.go +97 -0
  405. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/clock.go +116 -0
  406. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/environ.go +100 -0
  407. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go +2015 -0
  408. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go +247 -0
  409. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/proc.go +44 -0
  410. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/random.go +55 -0
  411. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sched.go +22 -0
  412. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go +188 -0
  413. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/wasi.go +314 -0
  414. package/govendor/github.com/tetratelabs/wazero/internal/descriptor/table.go +149 -0
  415. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/compiler.go +3884 -0
  416. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/format.go +22 -0
  417. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go +4963 -0
  418. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/operations.go +2978 -0
  419. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/signature.go +825 -0
  420. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/abi.go +170 -0
  421. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/backend.go +3 -0
  422. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler.go +402 -0
  423. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler_lower.go +226 -0
  424. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/go_call.go +33 -0
  425. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi.go +186 -0
  426. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.go +9 -0
  427. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.s +29 -0
  428. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_preamble.go +248 -0
  429. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_go_call.go +440 -0
  430. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/cond.go +168 -0
  431. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/ext.go +35 -0
  432. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr.go +2495 -0
  433. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr_encoding.go +1714 -0
  434. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_constant.go +71 -0
  435. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_mem.go +187 -0
  436. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go +3782 -0
  437. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_pro_epi_logue.go +334 -0
  438. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go +352 -0
  439. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_vec.go +992 -0
  440. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/operands.go +336 -0
  441. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/reg.go +181 -0
  442. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/stack.go +130 -0
  443. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi.go +376 -0
  444. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.go +9 -0
  445. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.s +29 -0
  446. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_preamble.go +233 -0
  447. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go +430 -0
  448. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/cond.go +215 -0
  449. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr.go +2562 -0
  450. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr_encoding.go +2357 -0
  451. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_constant.go +301 -0
  452. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr.go +2227 -0
  453. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr_operands.go +340 -0
  454. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_mem.go +451 -0
  455. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine.go +631 -0
  456. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_pro_epi_logue.go +486 -0
  457. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go +351 -0
  458. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go +128 -0
  459. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/reg.go +397 -0
  460. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/unwind_stack.go +84 -0
  461. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go +119 -0
  462. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/api.go +124 -0
  463. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/reg.go +123 -0
  464. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regalloc.go +1189 -0
  465. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regset.go +96 -0
  466. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/vdef.go +19 -0
  467. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/call_engine.go +884 -0
  468. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go +1008 -0
  469. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine_cache.go +347 -0
  470. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_amd64.go +13 -0
  471. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_arm64.go +13 -0
  472. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_other.go +15 -0
  473. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/frontend.go +663 -0
  474. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/lower.go +5045 -0
  475. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/misc.go +10 -0
  476. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/sort_id.go +13 -0
  477. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/hostmodule.go +88 -0
  478. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_amd64.go +30 -0
  479. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_arm64.go +32 -0
  480. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_other.go +29 -0
  481. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/memmove.go +11 -0
  482. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/module_engine.go +403 -0
  483. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block.go +381 -0
  484. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block_sort.go +32 -0
  485. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/builder.go +790 -0
  486. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/cmp.go +107 -0
  487. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/funcref.go +12 -0
  488. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/instructions.go +3024 -0
  489. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass.go +393 -0
  490. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_blk_layouts.go +334 -0
  491. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_cfg.go +313 -0
  492. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/signature.go +49 -0
  493. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/ssa.go +14 -0
  494. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/type.go +115 -0
  495. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/vs.go +114 -0
  496. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/debug_options.go +189 -0
  497. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/exitcode.go +150 -0
  498. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/offsetdata.go +248 -0
  499. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap.go +96 -0
  500. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_disabled.go +5 -0
  501. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_enabled.go +5 -0
  502. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/pool.go +215 -0
  503. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/ptr.go +15 -0
  504. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/queue.go +26 -0
  505. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/resetmap.go +11 -0
  506. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/checkpoint.go +10 -0
  507. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/close.go +5 -0
  508. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/compilationworkers.go +6 -0
  509. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/expctxkeys.go +2 -0
  510. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/importresolver.go +6 -0
  511. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/listener.go +7 -0
  512. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/memory.go +4 -0
  513. package/govendor/github.com/tetratelabs/wazero/internal/filecache/compilationcache.go +42 -0
  514. package/govendor/github.com/tetratelabs/wazero/internal/filecache/file_cache.go +76 -0
  515. package/govendor/github.com/tetratelabs/wazero/internal/ieee754/ieee754.go +29 -0
  516. package/govendor/github.com/tetratelabs/wazero/internal/internalapi/internal.go +9 -0
  517. package/govendor/github.com/tetratelabs/wazero/internal/leb128/leb128.go +285 -0
  518. package/govendor/github.com/tetratelabs/wazero/internal/moremath/moremath.go +271 -0
  519. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid.go +26 -0
  520. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_amd64.go +22 -0
  521. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_arm64.go +13 -0
  522. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_unsupported.go +5 -0
  523. package/govendor/github.com/tetratelabs/wazero/internal/platform/crypto.go +17 -0
  524. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go +72 -0
  525. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go +19 -0
  526. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go +14 -0
  527. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unsupported.go +22 -0
  528. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go +31 -0
  529. package/govendor/github.com/tetratelabs/wazero/internal/platform/path.go +6 -0
  530. package/govendor/github.com/tetratelabs/wazero/internal/platform/path_windows.go +17 -0
  531. package/govendor/github.com/tetratelabs/wazero/internal/platform/platform.go +71 -0
  532. package/govendor/github.com/tetratelabs/wazero/internal/platform/time.go +76 -0
  533. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_notwindows.go +11 -0
  534. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_windows.go +40 -0
  535. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock.go +89 -0
  536. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_supported.go +11 -0
  537. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_unsupported.go +10 -0
  538. package/govendor/github.com/tetratelabs/wazero/internal/sys/fs.go +458 -0
  539. package/govendor/github.com/tetratelabs/wazero/internal/sys/lazy.go +135 -0
  540. package/govendor/github.com/tetratelabs/wazero/internal/sys/stdio.go +125 -0
  541. package/govendor/github.com/tetratelabs/wazero/internal/sys/sys.go +228 -0
  542. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go +105 -0
  543. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go +12 -0
  544. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go +14 -0
  545. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go +24 -0
  546. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go +137 -0
  547. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file.go +576 -0
  548. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go +39 -0
  549. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go +28 -0
  550. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_windows.go +133 -0
  551. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go +29 -0
  552. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go +42 -0
  553. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.s +8 -0
  554. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go +38 -0
  555. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go +18 -0
  556. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go +42 -0
  557. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unix.go +22 -0
  558. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unsupported.go +17 -0
  559. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_windows.go +28 -0
  560. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go +17 -0
  561. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unsupported.go +13 -0
  562. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go +23 -0
  563. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/oflag.go +38 -0
  564. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_bsd.go +26 -0
  565. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_darwin.go +26 -0
  566. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_supported.go +30 -0
  567. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unix.go +20 -0
  568. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unsupported.go +16 -0
  569. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go +163 -0
  570. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go +318 -0
  571. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll.go +17 -0
  572. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.go +55 -0
  573. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.s +8 -0
  574. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_linux.go +57 -0
  575. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_unsupported.go +12 -0
  576. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_windows.go +224 -0
  577. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go +117 -0
  578. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unix.go +16 -0
  579. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unsupported.go +16 -0
  580. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go +55 -0
  581. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go +186 -0
  582. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_supported.go +76 -0
  583. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go +48 -0
  584. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go +79 -0
  585. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go +80 -0
  586. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go +16 -0
  587. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_supported.go +40 -0
  588. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go +40 -0
  589. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go +118 -0
  590. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go +13 -0
  591. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go +20 -0
  592. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go +13 -0
  593. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go +6 -0
  594. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unix.go +17 -0
  595. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unsupported.go +14 -0
  596. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go +25 -0
  597. package/govendor/github.com/tetratelabs/wazero/internal/u32/u32.go +11 -0
  598. package/govendor/github.com/tetratelabs/wazero/internal/u64/u64.go +15 -0
  599. package/govendor/github.com/tetratelabs/wazero/internal/version/version.go +52 -0
  600. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/args.go +6 -0
  601. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/clock.go +16 -0
  602. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/environ.go +6 -0
  603. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go +314 -0
  604. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/fs.go +164 -0
  605. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/poll.go +15 -0
  606. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/proc.go +6 -0
  607. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/random.go +3 -0
  608. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/rights.go +148 -0
  609. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sched.go +3 -0
  610. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go +71 -0
  611. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/wasi.go +26 -0
  612. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/code.go +124 -0
  613. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/const_expr.go +116 -0
  614. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/custom.go +22 -0
  615. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/data.go +79 -0
  616. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/decoder.go +235 -0
  617. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go +250 -0
  618. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/errors.go +11 -0
  619. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/export.go +32 -0
  620. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/function.go +56 -0
  621. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/global.go +50 -0
  622. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/header.go +9 -0
  623. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/import.go +68 -0
  624. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/limits.go +47 -0
  625. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/memory.go +42 -0
  626. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/names.go +151 -0
  627. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/section.go +309 -0
  628. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/table.go +79 -0
  629. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/value.go +97 -0
  630. package/govendor/github.com/tetratelabs/wazero/internal/wasm/const_expr.go +259 -0
  631. package/govendor/github.com/tetratelabs/wazero/internal/wasm/counts.go +53 -0
  632. package/govendor/github.com/tetratelabs/wazero/internal/wasm/engine.go +76 -0
  633. package/govendor/github.com/tetratelabs/wazero/internal/wasm/exception.go +9 -0
  634. package/govendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go +2804 -0
  635. package/govendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go +210 -0
  636. package/govendor/github.com/tetratelabs/wazero/internal/wasm/global.go +55 -0
  637. package/govendor/github.com/tetratelabs/wazero/internal/wasm/gofunc.go +279 -0
  638. package/govendor/github.com/tetratelabs/wazero/internal/wasm/host.go +179 -0
  639. package/govendor/github.com/tetratelabs/wazero/internal/wasm/instruction.go +1962 -0
  640. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory.go +475 -0
  641. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory_definition.go +128 -0
  642. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module.go +1359 -0
  643. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go +251 -0
  644. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance_lookup.go +73 -0
  645. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store.go +726 -0
  646. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go +95 -0
  647. package/govendor/github.com/tetratelabs/wazero/internal/wasm/table.go +321 -0
  648. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/debug.go +170 -0
  649. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go +225 -0
  650. package/govendor/github.com/tetratelabs/wazero/internal/wasmruntime/errors.go +54 -0
  651. package/govendor/github.com/tetratelabs/wazero/netlify.toml +15 -0
  652. package/govendor/github.com/tetratelabs/wazero/runtime.go +399 -0
  653. package/govendor/github.com/tetratelabs/wazero/sys/clock.go +26 -0
  654. package/govendor/github.com/tetratelabs/wazero/sys/error.go +83 -0
  655. package/govendor/github.com/tetratelabs/wazero/sys/stat.go +105 -0
  656. package/govendor/github.com/tetratelabs/wazero/sys/stat_bsd.go +29 -0
  657. package/govendor/github.com/tetratelabs/wazero/sys/stat_posix.go +29 -0
  658. package/govendor/github.com/tetratelabs/wazero/sys/stat_unsupported.go +14 -0
  659. package/govendor/github.com/tetratelabs/wazero/sys/stat_windows.go +24 -0
  660. package/govendor/golang.org/x/crypto/LICENSE +27 -0
  661. package/govendor/golang.org/x/crypto/PATENTS +22 -0
  662. package/govendor/golang.org/x/crypto/cryptobyte/asn1/asn1.go +46 -0
  663. package/govendor/golang.org/x/crypto/cryptobyte/asn1.go +825 -0
  664. package/govendor/golang.org/x/crypto/cryptobyte/builder.go +350 -0
  665. package/govendor/golang.org/x/crypto/cryptobyte/string.go +183 -0
  666. package/govendor/golang.org/x/crypto/go.mod +3 -0
  667. package/govendor/golang.org/x/crypto/pbkdf2/pbkdf2.go +30 -0
  668. package/govendor/golang.org/x/net/LICENSE +27 -0
  669. package/govendor/golang.org/x/net/PATENTS +22 -0
  670. package/govendor/golang.org/x/net/dns/dnsmessage/message.go +2733 -0
  671. package/govendor/golang.org/x/net/dns/dnsmessage/svcb.go +333 -0
  672. package/govendor/golang.org/x/net/go.mod +3 -0
  673. package/govendor/golang.org/x/net/http/httpguts/guts.go +50 -0
  674. package/govendor/golang.org/x/net/http/httpguts/httplex.go +347 -0
  675. package/govendor/golang.org/x/net/http2/README.md +19 -0
  676. package/govendor/golang.org/x/net/http2/ascii.go +65 -0
  677. package/govendor/golang.org/x/net/http2/ciphers.go +641 -0
  678. package/govendor/golang.org/x/net/http2/client_conn_pool.go +301 -0
  679. package/govendor/golang.org/x/net/http2/client_priority_go126.go +20 -0
  680. package/govendor/golang.org/x/net/http2/client_priority_go127.go +13 -0
  681. package/govendor/golang.org/x/net/http2/clientconn.go +57 -0
  682. package/govendor/golang.org/x/net/http2/config.go +171 -0
  683. package/govendor/golang.org/x/net/http2/config_go125.go +15 -0
  684. package/govendor/golang.org/x/net/http2/config_go126.go +15 -0
  685. package/govendor/golang.org/x/net/http2/databuffer.go +146 -0
  686. package/govendor/golang.org/x/net/http2/errors.go +145 -0
  687. package/govendor/golang.org/x/net/http2/flow.go +175 -0
  688. package/govendor/golang.org/x/net/http2/frame.go +1887 -0
  689. package/govendor/golang.org/x/net/http2/gotrack.go +181 -0
  690. package/govendor/golang.org/x/net/http2/hpack/encode.go +244 -0
  691. package/govendor/golang.org/x/net/http2/hpack/hpack.go +522 -0
  692. package/govendor/golang.org/x/net/http2/hpack/huffman.go +226 -0
  693. package/govendor/golang.org/x/net/http2/hpack/static_table.go +188 -0
  694. package/govendor/golang.org/x/net/http2/hpack/tables.go +426 -0
  695. package/govendor/golang.org/x/net/http2/http2.go +415 -0
  696. package/govendor/golang.org/x/net/http2/pipe.go +184 -0
  697. package/govendor/golang.org/x/net/http2/server.go +3239 -0
  698. package/govendor/golang.org/x/net/http2/server_common.go +268 -0
  699. package/govendor/golang.org/x/net/http2/server_wrap.go +217 -0
  700. package/govendor/golang.org/x/net/http2/transport.go +3084 -0
  701. package/govendor/golang.org/x/net/http2/transport_common.go +516 -0
  702. package/govendor/golang.org/x/net/http2/transport_wrap.go +583 -0
  703. package/govendor/golang.org/x/net/http2/unencrypted.go +32 -0
  704. package/govendor/golang.org/x/net/http2/write.go +381 -0
  705. package/govendor/golang.org/x/net/http2/writesched.go +253 -0
  706. package/govendor/golang.org/x/net/http2/writesched_common.go +90 -0
  707. package/govendor/golang.org/x/net/http2/writesched_priority_rfc7540.go +420 -0
  708. package/govendor/golang.org/x/net/http2/writesched_priority_rfc9218.go +226 -0
  709. package/govendor/golang.org/x/net/http2/writesched_random.go +81 -0
  710. package/govendor/golang.org/x/net/http2/writesched_roundrobin.go +121 -0
  711. package/govendor/golang.org/x/net/idna/idna.go +884 -0
  712. package/govendor/golang.org/x/net/idna/punycode.go +220 -0
  713. package/govendor/golang.org/x/net/idna/tables15.0.0.go +5144 -0
  714. package/govendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
  715. package/govendor/golang.org/x/net/idna/trie.go +51 -0
  716. package/govendor/golang.org/x/net/idna/trieval.go +119 -0
  717. package/govendor/golang.org/x/net/internal/httpcommon/README.md +7 -0
  718. package/govendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  719. package/govendor/golang.org/x/net/internal/httpcommon/gzip.go +132 -0
  720. package/govendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  721. package/govendor/golang.org/x/net/internal/httpcommon/request.go +503 -0
  722. package/govendor/golang.org/x/net/internal/httpsfv/httpsfv.go +665 -0
  723. package/govendor/golang.org/x/sys/cpu/asm_aix_ppc64.s +17 -0
  724. package/govendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
  725. package/govendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s +17 -0
  726. package/govendor/golang.org/x/sys/cpu/byteorder.go +66 -0
  727. package/govendor/golang.org/x/sys/cpu/cpu.go +357 -0
  728. package/govendor/golang.org/x/sys/cpu/cpu_aix.go +33 -0
  729. package/govendor/golang.org/x/sys/cpu/cpu_arm.go +73 -0
  730. package/govendor/golang.org/x/sys/cpu/cpu_arm64.go +191 -0
  731. package/govendor/golang.org/x/sys/cpu/cpu_arm64.s +35 -0
  732. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
  733. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
  734. package/govendor/golang.org/x/sys/cpu/cpu_darwin_x86.go +61 -0
  735. package/govendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +12 -0
  736. package/govendor/golang.org/x/sys/cpu/cpu_gc_riscv64.go +11 -0
  737. package/govendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +21 -0
  738. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.go +15 -0
  739. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.s +26 -0
  740. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +12 -0
  741. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +22 -0
  742. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c +37 -0
  743. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +25 -0
  744. package/govendor/golang.org/x/sys/cpu/cpu_linux.go +15 -0
  745. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm.go +39 -0
  746. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +120 -0
  747. package/govendor/golang.org/x/sys/cpu/cpu_linux_loong64.go +22 -0
  748. package/govendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +22 -0
  749. package/govendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +9 -0
  750. package/govendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +34 -0
  751. package/govendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +173 -0
  752. package/govendor/golang.org/x/sys/cpu/cpu_linux_s390x.go +40 -0
  753. package/govendor/golang.org/x/sys/cpu/cpu_loong64.go +62 -0
  754. package/govendor/golang.org/x/sys/cpu/cpu_loong64.s +13 -0
  755. package/govendor/golang.org/x/sys/cpu/cpu_mips64x.go +15 -0
  756. package/govendor/golang.org/x/sys/cpu/cpu_mipsx.go +11 -0
  757. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_amd64.go +47 -0
  758. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go +173 -0
  759. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go +65 -0
  760. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s +11 -0
  761. package/govendor/golang.org/x/sys/cpu/cpu_other_arm.go +9 -0
  762. package/govendor/golang.org/x/sys/cpu/cpu_other_arm64.go +11 -0
  763. package/govendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +11 -0
  764. package/govendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +12 -0
  765. package/govendor/golang.org/x/sys/cpu/cpu_other_riscv64.go +11 -0
  766. package/govendor/golang.org/x/sys/cpu/cpu_other_x86.go +11 -0
  767. package/govendor/golang.org/x/sys/cpu/cpu_ppc64x.go +16 -0
  768. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.go +33 -0
  769. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.s +17 -0
  770. package/govendor/golang.org/x/sys/cpu/cpu_s390x.go +172 -0
  771. package/govendor/golang.org/x/sys/cpu/cpu_s390x.s +57 -0
  772. package/govendor/golang.org/x/sys/cpu/cpu_sparc64.go +12 -0
  773. package/govendor/golang.org/x/sys/cpu/cpu_wasm.go +17 -0
  774. package/govendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
  775. package/govendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
  776. package/govendor/golang.org/x/sys/cpu/cpu_x86.go +259 -0
  777. package/govendor/golang.org/x/sys/cpu/cpu_zos.go +10 -0
  778. package/govendor/golang.org/x/sys/cpu/cpu_zos_s390x.go +25 -0
  779. package/govendor/golang.org/x/sys/cpu/endian_big.go +10 -0
  780. package/govendor/golang.org/x/sys/cpu/endian_little.go +10 -0
  781. package/govendor/golang.org/x/sys/cpu/hwcap_linux.go +71 -0
  782. package/govendor/golang.org/x/sys/cpu/parse.go +55 -0
  783. package/govendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go +53 -0
  784. package/govendor/golang.org/x/sys/cpu/runtime_auxv.go +16 -0
  785. package/govendor/golang.org/x/sys/cpu/runtime_auxv_go121.go +18 -0
  786. package/govendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +26 -0
  787. package/govendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +35 -0
  788. package/govendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
  789. package/govendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go +98 -0
  790. package/govendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
  791. package/govendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +20 -0
  792. package/govendor/golang.org/x/sys/unix/asm_linux_sparc64.s +48 -0
  793. package/govendor/golang.org/x/sys/unix/asm_zos_s390x.s +4 -186
  794. package/govendor/golang.org/x/sys/unix/bpxsvc_zos.s +9 -9
  795. package/govendor/golang.org/x/sys/unix/fcntl_darwin.go +2 -2
  796. package/govendor/golang.org/x/sys/unix/mkerrors.sh +1 -1
  797. package/govendor/golang.org/x/sys/unix/ptrace_zos.go +537 -0
  798. package/govendor/golang.org/x/sys/unix/ptrace_zos_singlestep.go +425 -0
  799. package/govendor/golang.org/x/sys/unix/syscall_darwin.go +1 -0
  800. package/govendor/golang.org/x/sys/unix/syscall_freebsd.go +9 -0
  801. package/govendor/golang.org/x/sys/unix/syscall_linux.go +20 -1
  802. package/govendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +3 -3
  803. package/govendor/golang.org/x/sys/unix/syscall_netbsd.go +9 -0
  804. package/govendor/golang.org/x/sys/unix/syscall_unix_gc.go +1 -1
  805. package/govendor/golang.org/x/sys/unix/syscall_zos_s390x.go +0 -4
  806. package/govendor/golang.org/x/sys/unix/xattr_bsd.go +12 -12
  807. package/govendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +6 -0
  808. package/govendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +6 -0
  809. package/govendor/golang.org/x/sys/unix/zerrors_linux.go +32 -0
  810. package/govendor/golang.org/x/sys/unix/zerrors_linux_386.go +2 -0
  811. package/govendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +2 -0
  812. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm.go +2 -0
  813. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +2 -0
  814. package/govendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +2 -0
  815. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips.go +2 -0
  816. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +2 -0
  817. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +2 -0
  818. package/govendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +2 -0
  819. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +2 -0
  820. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +2 -0
  821. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +2 -0
  822. package/govendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +2 -0
  823. package/govendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +2 -0
  824. package/govendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +2 -0
  825. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +11 -0
  826. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +11 -0
  827. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +159 -0
  828. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +159 -0
  829. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +159 -0
  830. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +159 -0
  831. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +159 -0
  832. package/govendor/golang.org/x/sys/unix/zsyscall_linux.go +28 -1
  833. package/govendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +3 -3
  834. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +159 -0
  835. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +159 -0
  836. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +159 -0
  837. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +159 -0
  838. package/govendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +13 -0
  839. package/govendor/golang.org/x/sys/unix/ztypes_linux.go +65 -36
  840. package/govendor/golang.org/x/sys/unix/ztypes_linux_386.go +6 -0
  841. package/govendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +7 -0
  842. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm.go +6 -0
  843. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +7 -0
  844. package/govendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +7 -0
  845. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips.go +6 -0
  846. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +7 -0
  847. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +7 -0
  848. package/govendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +6 -0
  849. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +6 -0
  850. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +7 -0
  851. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +7 -0
  852. package/govendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +7 -0
  853. package/govendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +7 -0
  854. package/govendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +10 -5
  855. package/govendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +78 -0
  856. package/govendor/golang.org/x/text/.gitattributes +10 -0
  857. package/govendor/golang.org/x/text/CONTRIBUTING.md +26 -0
  858. package/govendor/golang.org/x/text/LICENSE +27 -0
  859. package/govendor/golang.org/x/text/PATENTS +22 -0
  860. package/govendor/golang.org/x/text/README.md +81 -0
  861. package/govendor/golang.org/x/text/cases/cases.go +162 -0
  862. package/govendor/golang.org/x/text/cases/context.go +376 -0
  863. package/govendor/golang.org/x/text/cases/fold.go +34 -0
  864. package/govendor/golang.org/x/text/cases/icu.go +61 -0
  865. package/govendor/golang.org/x/text/cases/info.go +82 -0
  866. package/govendor/golang.org/x/text/cases/map.go +816 -0
  867. package/govendor/golang.org/x/text/cases/tables15.0.0.go +2527 -0
  868. package/govendor/golang.org/x/text/cases/tables17.0.0.go +2642 -0
  869. package/govendor/golang.org/x/text/cases/trieval.go +217 -0
  870. package/govendor/golang.org/x/text/codereview.cfg +1 -0
  871. package/govendor/golang.org/x/text/collate/collate.go +402 -0
  872. package/govendor/golang.org/x/text/collate/index.go +32 -0
  873. package/govendor/golang.org/x/text/collate/option.go +239 -0
  874. package/govendor/golang.org/x/text/collate/sort.go +81 -0
  875. package/govendor/golang.org/x/text/collate/tables.go +73789 -0
  876. package/govendor/golang.org/x/text/currency/common.go +67 -0
  877. package/govendor/golang.org/x/text/currency/currency.go +185 -0
  878. package/govendor/golang.org/x/text/currency/format.go +220 -0
  879. package/govendor/golang.org/x/text/currency/query.go +152 -0
  880. package/govendor/golang.org/x/text/currency/tables.go +2629 -0
  881. package/govendor/golang.org/x/text/doc.go +16 -0
  882. package/govendor/golang.org/x/text/feature/plural/common.go +70 -0
  883. package/govendor/golang.org/x/text/feature/plural/message.go +244 -0
  884. package/govendor/golang.org/x/text/feature/plural/plural.go +262 -0
  885. package/govendor/golang.org/x/text/feature/plural/tables.go +552 -0
  886. package/govendor/golang.org/x/text/go.mod +3 -0
  887. package/govendor/golang.org/x/text/internal/catmsg/catmsg.go +417 -0
  888. package/govendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
  889. package/govendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
  890. package/govendor/golang.org/x/text/internal/colltab/collelem.go +374 -0
  891. package/govendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
  892. package/govendor/golang.org/x/text/internal/colltab/contract.go +145 -0
  893. package/govendor/golang.org/x/text/internal/colltab/iter.go +178 -0
  894. package/govendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
  895. package/govendor/golang.org/x/text/internal/colltab/table.go +275 -0
  896. package/govendor/golang.org/x/text/internal/colltab/trie.go +159 -0
  897. package/govendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
  898. package/govendor/golang.org/x/text/internal/format/format.go +41 -0
  899. package/govendor/golang.org/x/text/internal/format/parser.go +358 -0
  900. package/govendor/golang.org/x/text/internal/internal.go +49 -0
  901. package/govendor/golang.org/x/text/internal/language/common.go +16 -0
  902. package/govendor/golang.org/x/text/internal/language/compact/compact.go +61 -0
  903. package/govendor/golang.org/x/text/internal/language/compact/language.go +260 -0
  904. package/govendor/golang.org/x/text/internal/language/compact/parents.go +120 -0
  905. package/govendor/golang.org/x/text/internal/language/compact/tables.go +1015 -0
  906. package/govendor/golang.org/x/text/internal/language/compact/tags.go +91 -0
  907. package/govendor/golang.org/x/text/internal/language/compact.go +29 -0
  908. package/govendor/golang.org/x/text/internal/language/compose.go +167 -0
  909. package/govendor/golang.org/x/text/internal/language/coverage.go +28 -0
  910. package/govendor/golang.org/x/text/internal/language/language.go +627 -0
  911. package/govendor/golang.org/x/text/internal/language/lookup.go +412 -0
  912. package/govendor/golang.org/x/text/internal/language/match.go +226 -0
  913. package/govendor/golang.org/x/text/internal/language/parse.go +608 -0
  914. package/govendor/golang.org/x/text/internal/language/tables.go +3494 -0
  915. package/govendor/golang.org/x/text/internal/language/tags.go +48 -0
  916. package/govendor/golang.org/x/text/internal/match.go +67 -0
  917. package/govendor/golang.org/x/text/internal/number/common.go +55 -0
  918. package/govendor/golang.org/x/text/internal/number/decimal.go +500 -0
  919. package/govendor/golang.org/x/text/internal/number/format.go +533 -0
  920. package/govendor/golang.org/x/text/internal/number/number.go +152 -0
  921. package/govendor/golang.org/x/text/internal/number/pattern.go +485 -0
  922. package/govendor/golang.org/x/text/internal/number/roundingmode_string.go +30 -0
  923. package/govendor/golang.org/x/text/internal/number/tables.go +1219 -0
  924. package/govendor/golang.org/x/text/internal/stringset/set.go +86 -0
  925. package/govendor/golang.org/x/text/internal/tag/tag.go +100 -0
  926. package/govendor/golang.org/x/text/language/coverage.go +187 -0
  927. package/govendor/golang.org/x/text/language/display/dict.go +92 -0
  928. package/govendor/golang.org/x/text/language/display/display.go +420 -0
  929. package/govendor/golang.org/x/text/language/display/lookup.go +253 -0
  930. package/govendor/golang.org/x/text/language/display/tables.go +53114 -0
  931. package/govendor/golang.org/x/text/language/doc.go +98 -0
  932. package/govendor/golang.org/x/text/language/language.go +605 -0
  933. package/govendor/golang.org/x/text/language/match.go +735 -0
  934. package/govendor/golang.org/x/text/language/parse.go +258 -0
  935. package/govendor/golang.org/x/text/language/tables.go +298 -0
  936. package/govendor/golang.org/x/text/language/tags.go +145 -0
  937. package/govendor/golang.org/x/text/message/catalog/catalog.go +365 -0
  938. package/govendor/golang.org/x/text/message/catalog/dict.go +133 -0
  939. package/govendor/golang.org/x/text/secure/bidirule/bidirule.go +346 -0
  940. package/govendor/golang.org/x/text/transform/transform.go +709 -0
  941. package/govendor/golang.org/x/text/unicode/bidi/bidi.go +359 -0
  942. package/govendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  943. package/govendor/golang.org/x/text/unicode/bidi/core.go +1050 -0
  944. package/govendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  945. package/govendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +2042 -0
  946. package/govendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
  947. package/govendor/golang.org/x/text/unicode/bidi/trieval.go +48 -0
  948. package/govendor/golang.org/x/text/unicode/norm/composition.go +524 -0
  949. package/govendor/golang.org/x/text/unicode/norm/forminfo.go +296 -0
  950. package/govendor/golang.org/x/text/unicode/norm/input.go +109 -0
  951. package/govendor/golang.org/x/text/unicode/norm/iter.go +454 -0
  952. package/govendor/golang.org/x/text/unicode/norm/normalize.go +613 -0
  953. package/govendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  954. package/govendor/golang.org/x/text/unicode/norm/tables15.0.0.go +7907 -0
  955. package/govendor/golang.org/x/text/unicode/norm/tables17.0.0.go +8104 -0
  956. package/govendor/golang.org/x/text/unicode/norm/transform.go +89 -0
  957. package/govendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  958. package/govendor/manifest.txt +11 -2
  959. package/govendor/software.sslmate.com/src/go-pkcs12/.gitattributes +10 -0
  960. package/govendor/software.sslmate.com/src/go-pkcs12/LICENSE +28 -0
  961. package/govendor/software.sslmate.com/src/go-pkcs12/README.md +31 -0
  962. package/govendor/software.sslmate.com/src/go-pkcs12/bmp-string.go +63 -0
  963. package/govendor/software.sslmate.com/src/go-pkcs12/crypto.go +331 -0
  964. package/govendor/software.sslmate.com/src/go-pkcs12/errors.go +23 -0
  965. package/govendor/software.sslmate.com/src/go-pkcs12/go.mod +3 -0
  966. package/govendor/software.sslmate.com/src/go-pkcs12/internal/rc2/rc2.go +271 -0
  967. package/govendor/software.sslmate.com/src/go-pkcs12/mac.go +202 -0
  968. package/govendor/software.sslmate.com/src/go-pkcs12/pbkdf.go +184 -0
  969. package/govendor/software.sslmate.com/src/go-pkcs12/pkcs12.go +1000 -0
  970. package/govendor/software.sslmate.com/src/go-pkcs12/safebags.go +107 -0
  971. package/package.json +11 -1
  972. package/types/tsconfig.json +17 -0
  973. package/types/typenative-npm.d.ts +1327 -80
  974. package/types/typenative.d.ts +1312 -25
  975. package/.gitattributes +0 -1
  976. package/.github/workflows/ci.yml +0 -68
  977. package/.github/workflows/npm-publish-github-packages.yml +0 -88
  978. package/CHANGELOG.md +0 -1358
  979. package/CONTRIBUTION.md +0 -133
  980. package/conformance.md +0 -1450
  981. package/examples/README.md +0 -113
  982. package/examples/angular-templates/README.md +0 -141
  983. package/examples/angular-templates/bench.mjs +0 -173
  984. package/examples/angular-templates/dom-type-globals.d.ts +0 -21
  985. package/examples/angular-templates/dom-type-stubs.ts +0 -21
  986. package/examples/angular-templates/main.ts +0 -135
  987. package/examples/angular-templates/parity.mjs +0 -157
  988. package/examples/angular-templates/run-node.mjs +0 -69
  989. package/examples/angular-templates/vendor/angular/compiler/LICENSE +0 -21
  990. package/examples/desktop-notes/README.md +0 -106
  991. package/examples/desktop-notes/bench.mjs +0 -125
  992. package/examples/desktop-notes/main.ts +0 -131
  993. package/examples/desktop-notes/package-lock.json +0 -726
  994. package/examples/desktop-notes/package.json +0 -9
  995. package/examples/desktop-notes/ui.ts +0 -176
  996. package/examples/dupe-finder/README.md +0 -78
  997. package/examples/dupe-finder/bench.mjs +0 -120
  998. package/examples/dupe-finder/main.ts +0 -87
  999. package/examples/fibonacci/README.md +0 -89
  1000. package/examples/fibonacci/bench.mjs +0 -87
  1001. package/examples/fibonacci/main.ts +0 -21
  1002. package/examples/hello-world/README.md +0 -62
  1003. package/examples/hello-world/bench.mjs +0 -66
  1004. package/examples/hello-world/main.ts +0 -7
  1005. package/examples/json-server/README.md +0 -131
  1006. package/examples/json-server/bench.mjs +0 -263
  1007. package/examples/json-server/main.ts +0 -67
  1008. package/examples/mandelbrot-png/README.md +0 -63
  1009. package/examples/mandelbrot-png/bench.mjs +0 -95
  1010. package/examples/mandelbrot-png/main.ts +0 -98
  1011. package/examples/mandelbrot-png/preview.png +0 -0
  1012. package/examples/marked-cli/README.md +0 -175
  1013. package/examples/marked-cli/bench.mjs +0 -178
  1014. package/examples/marked-cli/main.ts +0 -410
  1015. package/examples/marked-cli/parity.mjs +0 -185
  1016. package/examples/marked-cli/vendor/marked/LICENSE +0 -44
  1017. package/examples/marked-cli/vendor/marked/VENDOR.md +0 -26
  1018. package/examples/openai-chat/README.md +0 -148
  1019. package/examples/openai-chat/bench.mjs +0 -175
  1020. package/examples/openai-chat/main.ts +0 -488
  1021. package/examples/react-compiler/README.md +0 -185
  1022. package/examples/react-compiler/bench.mjs +0 -181
  1023. package/examples/react-compiler/main.ts +0 -324
  1024. package/examples/react-compiler/parity.mjs +0 -362
  1025. package/examples/react-compiler/run-node.mjs +0 -90
  1026. package/examples/react-compiler/vendor/babel/LICENSE +0 -22
  1027. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +0 -15
  1028. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +0 -51
  1029. package/examples/react-compiler/vendor/charcodes/package.json +0 -25
  1030. package/examples/react-compiler/vendor/invariant/LICENSE +0 -21
  1031. package/examples/react-compiler/vendor/invariant/invariant.cjs +0 -51
  1032. package/examples/react-compiler/vendor/invariant/invariant.d.cts +0 -11
  1033. package/examples/react-compiler/vendor/invariant/types/LICENSE +0 -21
  1034. package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +0 -19
  1035. package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +0 -19
  1036. package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +0 -19
  1037. package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +0 -19
  1038. package/examples/react-compiler/vendor/js-tokens/LICENSE +0 -21
  1039. package/examples/react-compiler/vendor/js-tokens/index.cjs +0 -23
  1040. package/examples/react-compiler/vendor/js-tokens/index.d.cts +0 -13
  1041. package/examples/react-compiler/vendor/jsesc/jsesc.cjs +0 -337
  1042. package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +0 -384
  1043. package/examples/react-compiler/vendor/jsesc/types/LICENSE +0 -21
  1044. package/examples/react-compiler/vendor/picocolors/picocolors.cjs +0 -75
  1045. package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +0 -5
  1046. package/examples/react-compiler/vendor/picocolors/types.d.ts +0 -51
  1047. package/examples/react-compiler/vendor/react-compiler/LICENSE +0 -21
  1048. package/examples/react-compiler/vendor/stubs/babel-core.ts +0 -31
  1049. package/examples/react-compiler/vendor/stubs/debug.ts +0 -18
  1050. package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +0 -13
  1051. package/examples/react-compiler/vendor/stubs/pretty-format.ts +0 -18
  1052. package/examples/react-compiler/vendor/zod/LICENSE +0 -21
  1053. package/examples/react-compiler/vendor/zod-validation-error/LICENSE +0 -9
  1054. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +0 -5
  1055. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +0 -49
  1056. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +0 -48
  1057. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +0 -50
  1058. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +0 -6
  1059. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +0 -126
  1060. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +0 -39
  1061. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +0 -12
  1062. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +0 -78
  1063. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +0 -2
  1064. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +0 -12
  1065. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +0 -12
  1066. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +0 -131
  1067. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +0 -54
  1068. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +0 -12
  1069. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +0 -40
  1070. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +0 -12
  1071. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +0 -76
  1072. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +0 -76
  1073. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +0 -27
  1074. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +0 -27
  1075. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +0 -13
  1076. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +0 -61
  1077. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +0 -38
  1078. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +0 -20
  1079. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +0 -5
  1080. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +0 -8
  1081. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +0 -11
  1082. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +0 -20
  1083. package/examples/react-compiler/vendor.mjs +0 -688
  1084. package/examples/todo-cli/README.md +0 -69
  1085. package/examples/todo-cli/bench.mjs +0 -89
  1086. package/examples/todo-cli/main.ts +0 -92
  1087. package/examples/yaml-cli/README.md +0 -152
  1088. package/examples/yaml-cli/bench.mjs +0 -265
  1089. package/examples/yaml-cli/main.ts +0 -251
  1090. package/examples/yaml-cli/parity.mjs +0 -156
  1091. package/examples/yaml-cli/vendor/yaml/LICENSE +0 -13
  1092. package/examples/yaml-cli/vendor/yaml/VENDOR.md +0 -25
  1093. package/govendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +0 -22
  1094. package/govendor/golang.org/x/sys/windows/types_windows_arm.go +0 -35
  1095. package/performance/README.md +0 -196
  1096. package/performance/any-dynamic.ts +0 -21
  1097. package/performance/any-record-view.ts +0 -20
  1098. package/performance/arr-hof.ts +0 -21
  1099. package/performance/arr-push-index.ts +0 -15
  1100. package/performance/arr-sort.ts +0 -21
  1101. package/performance/async-await.ts +0 -24
  1102. package/performance/class-dispatch.ts +0 -52
  1103. package/performance/events-emit.ts +0 -27
  1104. package/performance/exc-throw-rare.ts +0 -25
  1105. package/performance/exc-try-catch.ts +0 -26
  1106. package/performance/fn-closures.ts +0 -29
  1107. package/performance/fn-recursion-tree.ts +0 -31
  1108. package/performance/gen-for-of.ts +0 -46
  1109. package/performance/json-roundtrip.ts +0 -27
  1110. package/performance/map-delete.ts +0 -24
  1111. package/performance/map-string-keys.ts +0 -22
  1112. package/performance/num-arith-loop.ts +0 -14
  1113. package/performance/num-bitwise.ts +0 -21
  1114. package/performance/num-mod-int.ts +0 -16
  1115. package/performance/num-to-string.ts +0 -16
  1116. package/performance/obj-alloc.ts +0 -32
  1117. package/performance/regex-exec.ts +0 -29
  1118. package/performance/regex-site.ts +0 -28
  1119. package/performance/set-ops.ts +0 -20
  1120. package/performance/str-char-scan.ts +0 -35
  1121. package/performance/str-concat-plus.ts +0 -18
  1122. package/performance/str-concat.ts +0 -24
  1123. package/performance/str-short-scan.ts +0 -26
  1124. package/performance/str-split-join.ts +0 -23
  1125. package/performance/str-template.ts +0 -16
  1126. package/performance/union-switch.ts +0 -57
  1127. package/tsparser/check.go +0 -158
  1128. package/tsparser/go.mod +0 -14
  1129. package/tsparser/go.sum +0 -22
  1130. package/tsparser/main.go +0 -363
  1131. package/tsparser/tsparser.exe +0 -4
@@ -0,0 +1,2015 @@
1
+ package wasi_snapshot_preview1
2
+
3
+ import (
4
+ "context"
5
+ "io"
6
+ "io/fs"
7
+ "math"
8
+ "path"
9
+ "strings"
10
+ "unsafe"
11
+
12
+ "github.com/tetratelabs/wazero/api"
13
+ experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
14
+ socketapi "github.com/tetratelabs/wazero/internal/sock"
15
+ "github.com/tetratelabs/wazero/internal/sys"
16
+ "github.com/tetratelabs/wazero/internal/wasip1"
17
+ "github.com/tetratelabs/wazero/internal/wasm"
18
+ sysapi "github.com/tetratelabs/wazero/sys"
19
+ )
20
+
21
+ // fdAdvise is the WASI function named FdAdviseName which provides file
22
+ // advisory information on a file descriptor.
23
+ //
24
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_advisefd-fd-offset-filesize-len-filesize-advice-advice---errno
25
+ var fdAdvise = newHostFunc(
26
+ wasip1.FdAdviseName, fdAdviseFn,
27
+ []wasm.ValueType{i32, i64, i64, i32},
28
+ "fd", "offset", "len", "advice",
29
+ )
30
+
31
+ func fdAdviseFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
32
+ fd := int32(params[0])
33
+ _ = params[1]
34
+ _ = params[2]
35
+ advice := byte(params[3])
36
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
37
+
38
+ _, ok := fsc.LookupFile(fd)
39
+ if !ok {
40
+ return experimentalsys.EBADF
41
+ }
42
+
43
+ switch advice {
44
+ case wasip1.FdAdviceNormal,
45
+ wasip1.FdAdviceSequential,
46
+ wasip1.FdAdviceRandom,
47
+ wasip1.FdAdviceWillNeed,
48
+ wasip1.FdAdviceDontNeed,
49
+ wasip1.FdAdviceNoReuse:
50
+ default:
51
+ return experimentalsys.EINVAL
52
+ }
53
+
54
+ // FdAdvice corresponds to posix_fadvise, but it can only be supported on linux.
55
+ // However, the purpose of the call is just to do best-effort optimization on OS kernels,
56
+ // so just making this noop rather than returning NoSup error makes sense and doesn't affect
57
+ // the semantics of Wasm applications.
58
+ // TODO: invoke posix_fadvise on linux, and partially on darwin.
59
+ // - https://gitlab.com/cznic/fileutil/-/blob/v1.1.2/fileutil_linux.go#L87-95
60
+ // - https://github.com/bytecodealliance/system-interface/blob/62b97f9776b86235f318c3a6e308395a1187439b/src/fs/file_io_ext.rs#L430-L442
61
+ return 0
62
+ }
63
+
64
+ // fdAllocate is the WASI function named FdAllocateName which forces the
65
+ // allocation of space in a file.
66
+ //
67
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_allocatefd-fd-offset-filesize-len-filesize---errno
68
+ var fdAllocate = newHostFunc(
69
+ wasip1.FdAllocateName, fdAllocateFn,
70
+ []wasm.ValueType{i32, i64, i64},
71
+ "fd", "offset", "len",
72
+ )
73
+
74
+ func fdAllocateFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
75
+ fd := int32(params[0])
76
+ offset := params[1]
77
+ length := params[2]
78
+
79
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
80
+ f, ok := fsc.LookupFile(fd)
81
+ if !ok {
82
+ return experimentalsys.EBADF
83
+ }
84
+
85
+ tail := int64(offset + length)
86
+ if tail < 0 {
87
+ return experimentalsys.EINVAL
88
+ }
89
+
90
+ st, errno := f.File.Stat()
91
+ if errno != 0 {
92
+ return errno
93
+ }
94
+
95
+ if st.Size >= tail {
96
+ return 0 // We already have enough space.
97
+ }
98
+
99
+ return f.File.Truncate(tail)
100
+ }
101
+
102
+ // fdClose is the WASI function named FdCloseName which closes a file
103
+ // descriptor.
104
+ //
105
+ // # Parameters
106
+ //
107
+ // - fd: file descriptor to close
108
+ //
109
+ // Result (Errno)
110
+ //
111
+ // The return value is 0 except the following error conditions:
112
+ // - sys.EBADF: the fd was not open.
113
+ // - sys.ENOTSUP: the fs was a pre-open
114
+ //
115
+ // Note: This is similar to `close` in POSIX.
116
+ // See https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fd_close
117
+ // and https://linux.die.net/man/3/close
118
+ var fdClose = newHostFunc(wasip1.FdCloseName, fdCloseFn, []wasm.ValueType{i32}, "fd")
119
+
120
+ func fdCloseFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
121
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
122
+ fd := int32(params[0])
123
+
124
+ return fsc.CloseFile(fd)
125
+ }
126
+
127
+ // fdDatasync is the WASI function named FdDatasyncName which synchronizes
128
+ // the data of a file to disk.
129
+ //
130
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_datasyncfd-fd---errno
131
+ var fdDatasync = newHostFunc(wasip1.FdDatasyncName, fdDatasyncFn, []wasm.ValueType{i32}, "fd")
132
+
133
+ func fdDatasyncFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
134
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
135
+ fd := int32(params[0])
136
+
137
+ // Check to see if the file descriptor is available
138
+ if f, ok := fsc.LookupFile(fd); !ok {
139
+ return experimentalsys.EBADF
140
+ } else {
141
+ return f.File.Datasync()
142
+ }
143
+ }
144
+
145
+ // fdFdstatGet is the WASI function named FdFdstatGetName which returns the
146
+ // attributes of a file descriptor.
147
+ //
148
+ // # Parameters
149
+ //
150
+ // - fd: file descriptor to get the fdstat attributes data
151
+ // - resultFdstat: offset to write the result fdstat data
152
+ //
153
+ // Result (Errno)
154
+ //
155
+ // The return value is 0 except the following error conditions:
156
+ // - sys.EBADF: `fd` is invalid
157
+ // - sys.EFAULT: `resultFdstat` points to an offset out of memory
158
+ //
159
+ // fdstat byte layout is 24-byte size, with the following fields:
160
+ // - fs_filetype 1 byte: the file type
161
+ // - fs_flags 2 bytes: the file descriptor flag
162
+ // - 5 pad bytes
163
+ // - fs_right_base 8 bytes: ignored as rights were removed from WASI.
164
+ // - fs_right_inheriting 8 bytes: ignored as rights were removed from WASI.
165
+ //
166
+ // For example, with a file corresponding with `fd` was a directory (=3) opened
167
+ // with `fd_read` right (=1) and no fs_flags (=0), parameter resultFdstat=1,
168
+ // this function writes the below to api.Memory:
169
+ //
170
+ // uint16le padding uint64le uint64le
171
+ // uint8 --+ +--+ +-----------+ +--------------------+ +--------------------+
172
+ // | | | | | | | | |
173
+ // []byte{?, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}
174
+ // resultFdstat --^ ^-- fs_flags ^-- fs_right_base ^-- fs_right_inheriting
175
+ // |
176
+ // +-- fs_filetype
177
+ //
178
+ // Note: fdFdstatGet returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as
179
+ // well as additional fields.
180
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fdstat
181
+ // and https://linux.die.net/man/3/fsync
182
+ var fdFdstatGet = newHostFunc(wasip1.FdFdstatGetName, fdFdstatGetFn, []wasm.ValueType{i32, i32}, "fd", "result.stat")
183
+
184
+ // fdFdstatGetFn cannot currently use proxyResultParams because fdstat is larger
185
+ // than api.ValueTypeI64 (i64 == 8 bytes, but fdstat is 24).
186
+ func fdFdstatGetFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
187
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
188
+
189
+ fd, resultFdstat := int32(params[0]), uint32(params[1])
190
+
191
+ // Ensure we can write the fdstat
192
+ buf, ok := mod.Memory().Read(resultFdstat, 24)
193
+ if !ok {
194
+ return experimentalsys.EFAULT
195
+ }
196
+
197
+ var fdflags uint16
198
+ var st sysapi.Stat_t
199
+ var errno experimentalsys.Errno
200
+ f, ok := fsc.LookupFile(fd)
201
+ if !ok {
202
+ return experimentalsys.EBADF
203
+ } else if st, errno = f.File.Stat(); errno != 0 {
204
+ return errno
205
+ } else if f.File.IsAppend() {
206
+ fdflags |= wasip1.FD_APPEND
207
+ }
208
+
209
+ if isNonblock(f.File) {
210
+ fdflags |= wasip1.FD_NONBLOCK
211
+ }
212
+
213
+ var fsRightsBase uint32
214
+ var fsRightsInheriting uint32
215
+ fileType := getExtendedWasiFiletype(f.File, st.Mode)
216
+
217
+ switch fileType {
218
+ case wasip1.FILETYPE_DIRECTORY:
219
+ // To satisfy wasi-testsuite, we must advertise that directories cannot
220
+ // be given seek permission (RIGHT_FD_SEEK).
221
+ fsRightsBase = dirRightsBase
222
+ fsRightsInheriting = fileRightsBase | dirRightsBase
223
+ case wasip1.FILETYPE_CHARACTER_DEVICE:
224
+ // According to wasi-libc,
225
+ // > A tty is a character device that we can't seek or tell on.
226
+ // See https://github.com/WebAssembly/wasi-libc/blob/a6f871343313220b76009827ed0153586361c0d5/libc-bottom-half/sources/isatty.c#L13-L18
227
+ fsRightsBase = fileRightsBase &^ wasip1.RIGHT_FD_SEEK &^ wasip1.RIGHT_FD_TELL
228
+ default:
229
+ fsRightsBase = fileRightsBase
230
+ }
231
+
232
+ writeFdstat(buf, fileType, fdflags, fsRightsBase, fsRightsInheriting)
233
+ return 0
234
+ }
235
+
236
+ // isPreopenedStdio returns true if the FD is sys.FdStdin, sys.FdStdout or
237
+ // sys.FdStderr and pre-opened. This double check is needed in case the guest
238
+ // closes stdin and re-opens it with a random alternative file.
239
+ //
240
+ // Currently, we only support non-blocking mode for standard I/O streams.
241
+ // Non-blocking mode is rarely supported for regular files, and we don't
242
+ // yet have support for sockets, so we make a special case.
243
+ //
244
+ // Note: this to get or set FD_NONBLOCK, but skip FD_APPEND. Our current
245
+ // implementation can't set FD_APPEND, without re-opening files. As stdio are
246
+ // pre-opened, we don't know how to re-open them, neither should we close the
247
+ // underlying file. Later, we could add support for setting FD_APPEND, similar
248
+ // to SetNonblock.
249
+ func isPreopenedStdio(fd int32, f *sys.FileEntry) bool {
250
+ return fd <= sys.FdStderr && f.IsPreopen
251
+ }
252
+
253
+ const fileRightsBase = wasip1.RIGHT_FD_DATASYNC |
254
+ wasip1.RIGHT_FD_READ |
255
+ wasip1.RIGHT_FD_SEEK |
256
+ wasip1.RIGHT_FDSTAT_SET_FLAGS |
257
+ wasip1.RIGHT_FD_SYNC |
258
+ wasip1.RIGHT_FD_TELL |
259
+ wasip1.RIGHT_FD_WRITE |
260
+ wasip1.RIGHT_FD_ADVISE |
261
+ wasip1.RIGHT_FD_ALLOCATE |
262
+ wasip1.RIGHT_FD_FILESTAT_GET |
263
+ wasip1.RIGHT_FD_FILESTAT_SET_SIZE |
264
+ wasip1.RIGHT_FD_FILESTAT_SET_TIMES |
265
+ wasip1.RIGHT_POLL_FD_READWRITE
266
+
267
+ const dirRightsBase = wasip1.RIGHT_FD_DATASYNC |
268
+ wasip1.RIGHT_FDSTAT_SET_FLAGS |
269
+ wasip1.RIGHT_FD_SYNC |
270
+ wasip1.RIGHT_PATH_CREATE_DIRECTORY |
271
+ wasip1.RIGHT_PATH_CREATE_FILE |
272
+ wasip1.RIGHT_PATH_LINK_SOURCE |
273
+ wasip1.RIGHT_PATH_LINK_TARGET |
274
+ wasip1.RIGHT_PATH_OPEN |
275
+ wasip1.RIGHT_FD_READDIR |
276
+ wasip1.RIGHT_PATH_READLINK |
277
+ wasip1.RIGHT_PATH_RENAME_SOURCE |
278
+ wasip1.RIGHT_PATH_RENAME_TARGET |
279
+ wasip1.RIGHT_PATH_FILESTAT_GET |
280
+ wasip1.RIGHT_PATH_FILESTAT_SET_SIZE |
281
+ wasip1.RIGHT_PATH_FILESTAT_SET_TIMES |
282
+ wasip1.RIGHT_FD_FILESTAT_GET |
283
+ wasip1.RIGHT_FD_FILESTAT_SET_TIMES |
284
+ wasip1.RIGHT_PATH_SYMLINK |
285
+ wasip1.RIGHT_PATH_REMOVE_DIRECTORY |
286
+ wasip1.RIGHT_PATH_UNLINK_FILE
287
+
288
+ func writeFdstat(buf []byte, fileType uint8, fdflags uint16, fsRightsBase, fsRightsInheriting uint32) {
289
+ b := (*[24]byte)(buf)
290
+ le.PutUint16(b[0:], uint16(fileType))
291
+ le.PutUint16(b[2:], fdflags)
292
+ le.PutUint32(b[4:], 0)
293
+ le.PutUint64(b[8:], uint64(fsRightsBase))
294
+ le.PutUint64(b[16:], uint64(fsRightsInheriting))
295
+ }
296
+
297
+ // fdFdstatSetFlags is the WASI function named FdFdstatSetFlagsName which
298
+ // adjusts the flags associated with a file descriptor.
299
+ var fdFdstatSetFlags = newHostFunc(wasip1.FdFdstatSetFlagsName, fdFdstatSetFlagsFn, []wasm.ValueType{i32, i32}, "fd", "flags")
300
+
301
+ func fdFdstatSetFlagsFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
302
+ fd, wasiFlag := int32(params[0]), uint16(params[1])
303
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
304
+
305
+ // Currently we only support APPEND and NONBLOCK.
306
+ if wasip1.FD_DSYNC&wasiFlag != 0 || wasip1.FD_RSYNC&wasiFlag != 0 || wasip1.FD_SYNC&wasiFlag != 0 {
307
+ return experimentalsys.EINVAL
308
+ }
309
+
310
+ if f, ok := fsc.LookupFile(fd); !ok {
311
+ return experimentalsys.EBADF
312
+ } else {
313
+ nonblock := wasip1.FD_NONBLOCK&wasiFlag != 0
314
+ if pf, ok := f.File.(experimentalsys.PollableFile); ok {
315
+ if errno := pf.SetNonblock(nonblock); errno != 0 {
316
+ return errno
317
+ }
318
+ } else if isDir, errno := f.File.IsDir(); errno == 0 && isDir {
319
+ return experimentalsys.EISDIR
320
+ } else if nonblock {
321
+ return experimentalsys.ENOSYS
322
+ }
323
+ if stat, err := f.File.Stat(); err == 0 && stat.Mode.IsRegular() {
324
+ // For normal files, proceed to apply an append flag.
325
+ append := wasip1.FD_APPEND&wasiFlag != 0
326
+ return f.File.SetAppend(append)
327
+ }
328
+ }
329
+
330
+ return 0
331
+ }
332
+
333
+ // fdFdstatSetRights will not be implemented as rights were removed from WASI.
334
+ //
335
+ // See https://github.com/bytecodealliance/wasmtime/pull/4666
336
+ var fdFdstatSetRights = stubFunction(
337
+ wasip1.FdFdstatSetRightsName,
338
+ []wasm.ValueType{i32, i64, i64},
339
+ "fd", "fs_rights_base", "fs_rights_inheriting",
340
+ )
341
+
342
+ // fdFilestatGet is the WASI function named FdFilestatGetName which returns
343
+ // the stat attributes of an open file.
344
+ //
345
+ // # Parameters
346
+ //
347
+ // - fd: file descriptor to get the filestat attributes data for
348
+ // - resultFilestat: offset to write the result filestat data
349
+ //
350
+ // Result (Errno)
351
+ //
352
+ // The return value is 0 except the following error conditions:
353
+ // - sys.EBADF: `fd` is invalid
354
+ // - sys.EIO: could not stat `fd` on filesystem
355
+ // - sys.EFAULT: `resultFilestat` points to an offset out of memory
356
+ //
357
+ // filestat byte layout is 64-byte size, with the following fields:
358
+ // - dev 8 bytes: the device ID of device containing the file
359
+ // - ino 8 bytes: the file serial number
360
+ // - filetype 1 byte: the type of the file
361
+ // - 7 pad bytes
362
+ // - nlink 8 bytes: number of hard links to the file
363
+ // - size 8 bytes: for regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link
364
+ // - atim 8 bytes: ast data access timestamp
365
+ // - mtim 8 bytes: last data modification timestamp
366
+ // - ctim 8 bytes: ast file status change timestamp
367
+ //
368
+ // For example, with a regular file this function writes the below to api.Memory:
369
+ //
370
+ // uint8 --+
371
+ // uint64le uint64le | padding uint64le uint64le uint64le uint64le uint64le
372
+ // +--------------------+ +--------------------+ | +-----------------+ +--------------------+ +-----------------------+ +----------------------------------+ +----------------------------------+ +----------------------------------+
373
+ // | | | | | | | | | | | | | | | | |
374
+ // []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 117, 80, 0, 0, 0, 0, 0, 0, 160, 153, 212, 128, 110, 221, 35, 23, 160, 153, 212, 128, 110, 221, 35, 23, 160, 153, 212, 128, 110, 221, 35, 23}
375
+ // resultFilestat ^-- dev ^-- ino ^ ^-- nlink ^-- size ^-- atim ^-- mtim ^-- ctim
376
+ // |
377
+ // +-- filetype
378
+ //
379
+ // The following properties of filestat are not implemented:
380
+ // - dev: not supported by Golang FS
381
+ // - ino: not supported by Golang FS
382
+ // - nlink: not supported by Golang FS, we use 1
383
+ // - atime: not supported by Golang FS, we use mtim for this
384
+ // - ctim: not supported by Golang FS, we use mtim for this
385
+ //
386
+ // Note: This is similar to `fstat` in POSIX.
387
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_filestat_getfd-fd---errno-filestat
388
+ // and https://linux.die.net/man/3/fstat
389
+ var fdFilestatGet = newHostFunc(wasip1.FdFilestatGetName, fdFilestatGetFn, []wasm.ValueType{i32, i32}, "fd", "result.filestat")
390
+
391
+ // fdFilestatGetFn cannot currently use proxyResultParams because filestat is
392
+ // larger than api.ValueTypeI64 (i64 == 8 bytes, but filestat is 64).
393
+ func fdFilestatGetFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
394
+ return fdFilestatGetFunc(mod, int32(params[0]), uint32(params[1]))
395
+ }
396
+
397
+ func fdFilestatGetFunc(mod api.Module, fd int32, resultBuf uint32) experimentalsys.Errno {
398
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
399
+
400
+ // Ensure we can write the filestat
401
+ buf, ok := mod.Memory().Read(resultBuf, 64)
402
+ if !ok {
403
+ return experimentalsys.EFAULT
404
+ }
405
+
406
+ f, ok := fsc.LookupFile(fd)
407
+ if !ok {
408
+ return experimentalsys.EBADF
409
+ }
410
+
411
+ st, errno := f.File.Stat()
412
+ if errno != 0 {
413
+ return errno
414
+ }
415
+
416
+ filetype := getExtendedWasiFiletype(f.File, st.Mode)
417
+ return writeFilestat(buf, &st, filetype)
418
+ }
419
+
420
+ func getExtendedWasiFiletype(file experimentalsys.File, fm fs.FileMode) (ftype uint8) {
421
+ ftype = getWasiFiletype(fm)
422
+ if ftype == wasip1.FILETYPE_UNKNOWN {
423
+ if _, ok := file.(socketapi.TCPSock); ok {
424
+ ftype = wasip1.FILETYPE_SOCKET_STREAM
425
+ } else if _, ok = file.(socketapi.TCPConn); ok {
426
+ ftype = wasip1.FILETYPE_SOCKET_STREAM
427
+ }
428
+ }
429
+ return
430
+ }
431
+
432
+ func getWasiFiletype(fm fs.FileMode) uint8 {
433
+ switch {
434
+ case fm.IsRegular():
435
+ return wasip1.FILETYPE_REGULAR_FILE
436
+ case fm.IsDir():
437
+ return wasip1.FILETYPE_DIRECTORY
438
+ case fm&fs.ModeSymlink != 0:
439
+ return wasip1.FILETYPE_SYMBOLIC_LINK
440
+ case fm&fs.ModeDevice != 0:
441
+ // Unlike ModeDevice and ModeCharDevice, FILETYPE_CHARACTER_DEVICE and
442
+ // FILETYPE_BLOCK_DEVICE are set mutually exclusively.
443
+ if fm&fs.ModeCharDevice != 0 {
444
+ return wasip1.FILETYPE_CHARACTER_DEVICE
445
+ }
446
+ return wasip1.FILETYPE_BLOCK_DEVICE
447
+ default: // unknown
448
+ return wasip1.FILETYPE_UNKNOWN
449
+ }
450
+ }
451
+
452
+ func writeFilestat(buf []byte, st *sysapi.Stat_t, ftype uint8) (errno experimentalsys.Errno) {
453
+ le.PutUint64(buf, st.Dev)
454
+ le.PutUint64(buf[8:], st.Ino)
455
+ le.PutUint64(buf[16:], uint64(ftype))
456
+ le.PutUint64(buf[24:], st.Nlink)
457
+ le.PutUint64(buf[32:], uint64(st.Size))
458
+ le.PutUint64(buf[40:], uint64(st.Atim))
459
+ le.PutUint64(buf[48:], uint64(st.Mtim))
460
+ le.PutUint64(buf[56:], uint64(st.Ctim))
461
+ return
462
+ }
463
+
464
+ // fdFilestatSetSize is the WASI function named FdFilestatSetSizeName which
465
+ // adjusts the size of an open file.
466
+ //
467
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_filestat_set_sizefd-fd-size-filesize---errno
468
+ var fdFilestatSetSize = newHostFunc(wasip1.FdFilestatSetSizeName, fdFilestatSetSizeFn, []wasm.ValueType{i32, i64}, "fd", "size")
469
+
470
+ func fdFilestatSetSizeFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
471
+ fd := int32(params[0])
472
+ size := int64(params[1])
473
+
474
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
475
+
476
+ // Check to see if the file descriptor is available
477
+ if f, ok := fsc.LookupFile(fd); !ok {
478
+ return experimentalsys.EBADF
479
+ } else {
480
+ return f.File.Truncate(size)
481
+ }
482
+ }
483
+
484
+ // fdFilestatSetTimes is the WASI function named functionFdFilestatSetTimes
485
+ // which adjusts the times of an open file.
486
+ //
487
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_filestat_set_timesfd-fd-atim-timestamp-mtim-timestamp-fst_flags-fstflags---errno
488
+ var fdFilestatSetTimes = newHostFunc(
489
+ wasip1.FdFilestatSetTimesName, fdFilestatSetTimesFn,
490
+ []wasm.ValueType{i32, i64, i64, i32},
491
+ "fd", "atim", "mtim", "fst_flags",
492
+ )
493
+
494
+ func fdFilestatSetTimesFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
495
+ fd := int32(params[0])
496
+ atim := int64(params[1])
497
+ mtim := int64(params[2])
498
+ fstFlags := uint16(params[3])
499
+
500
+ sys := mod.(*wasm.ModuleInstance).Sys
501
+ fsc := sys.FS()
502
+
503
+ f, ok := fsc.LookupFile(fd)
504
+ if !ok {
505
+ return experimentalsys.EBADF
506
+ }
507
+
508
+ atim, mtim, errno := toTimes(sys.WalltimeNanos, atim, mtim, fstFlags)
509
+ if errno != 0 {
510
+ return errno
511
+ }
512
+
513
+ // Try to update the file timestamps by file-descriptor.
514
+ errno = f.File.Utimens(atim, mtim)
515
+
516
+ // Fall back to path based, despite it being less precise.
517
+ switch errno {
518
+ case experimentalsys.EPERM, experimentalsys.ENOSYS:
519
+ errno = f.FS.Utimens(f.Name, atim, mtim)
520
+ }
521
+
522
+ return errno
523
+ }
524
+
525
+ func toTimes(walltime func() int64, atim, mtim int64, fstFlags uint16) (int64, int64, experimentalsys.Errno) {
526
+ // times[0] == atim, times[1] == mtim
527
+
528
+ var nowTim int64
529
+
530
+ // coerce atim into a timespec
531
+ if set, now := fstFlags&wasip1.FstflagsAtim != 0, fstFlags&wasip1.FstflagsAtimNow != 0; set && now {
532
+ return 0, 0, experimentalsys.EINVAL
533
+ } else if set {
534
+ // atim is already correct
535
+ } else if now {
536
+ nowTim = walltime()
537
+ atim = nowTim
538
+ } else {
539
+ atim = experimentalsys.UTIME_OMIT
540
+ }
541
+
542
+ // coerce mtim into a timespec
543
+ if set, now := fstFlags&wasip1.FstflagsMtim != 0, fstFlags&wasip1.FstflagsMtimNow != 0; set && now {
544
+ return 0, 0, experimentalsys.EINVAL
545
+ } else if set {
546
+ // mtim is already correct
547
+ } else if now {
548
+ if nowTim != 0 {
549
+ mtim = nowTim
550
+ } else {
551
+ mtim = walltime()
552
+ }
553
+ } else {
554
+ mtim = experimentalsys.UTIME_OMIT
555
+ }
556
+ return atim, mtim, 0
557
+ }
558
+
559
+ // fdPread is the WASI function named FdPreadName which reads from a file
560
+ // descriptor, without using and updating the file descriptor's offset.
561
+ //
562
+ // Except for handling offset, this implementation is identical to fdRead.
563
+ //
564
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_preadfd-fd-iovs-iovec_array-offset-filesize---errno-size
565
+ var fdPread = newHostFunc(
566
+ wasip1.FdPreadName, fdPreadFn,
567
+ []wasm.ValueType{i32, i32, i32, i64, i32},
568
+ "fd", "iovs", "iovs_len", "offset", "result.nread",
569
+ )
570
+
571
+ func fdPreadFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
572
+ return fdReadOrPread(mod, params, true)
573
+ }
574
+
575
+ // fdPrestatGet is the WASI function named FdPrestatGetName which returns
576
+ // the prestat data of a file descriptor.
577
+ //
578
+ // # Parameters
579
+ //
580
+ // - fd: file descriptor to get the prestat
581
+ // - resultPrestat: offset to write the result prestat data
582
+ //
583
+ // Result (Errno)
584
+ //
585
+ // The return value is 0 except the following error conditions:
586
+ // - sys.EBADF: `fd` is invalid or the `fd` is not a pre-opened directory
587
+ // - sys.EFAULT: `resultPrestat` points to an offset out of memory
588
+ //
589
+ // prestat byte layout is 8 bytes, beginning with an 8-bit tag and 3 pad bytes.
590
+ // The only valid tag is `prestat_dir`, which is tag zero. This simplifies the
591
+ // byte layout to 4 empty bytes followed by the uint32le encoded path length.
592
+ //
593
+ // For example, the directory name corresponding with `fd` was "/tmp" and
594
+ // parameter resultPrestat=1, this function writes the below to api.Memory:
595
+ //
596
+ // padding uint32le
597
+ // uint8 --+ +-----+ +--------+
598
+ // | | | | |
599
+ // []byte{?, 0, 0, 0, 0, 4, 0, 0, 0, ?}
600
+ // resultPrestat --^ ^
601
+ // tag --+ |
602
+ // +-- size in bytes of the string "/tmp"
603
+ //
604
+ // See fdPrestatDirName and
605
+ // https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#prestat
606
+ var fdPrestatGet = newHostFunc(wasip1.FdPrestatGetName, fdPrestatGetFn, []wasm.ValueType{i32, i32}, "fd", "result.prestat")
607
+
608
+ func fdPrestatGetFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
609
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
610
+ fd, resultPrestat := int32(params[0]), uint32(params[1])
611
+
612
+ name, errno := preopenPath(fsc, fd)
613
+ if errno != 0 {
614
+ return errno
615
+ }
616
+
617
+ // Upper 32-bits are zero because...
618
+ // * Zero-value 8-bit tag, and 3-byte zero-value padding
619
+ prestat := uint64(len(name)) << 32
620
+ if !mod.Memory().WriteUint64Le(resultPrestat, prestat) {
621
+ return experimentalsys.EFAULT
622
+ }
623
+ return 0
624
+ }
625
+
626
+ // fdPrestatDirName is the WASI function named FdPrestatDirNameName which
627
+ // returns the path of the pre-opened directory of a file descriptor.
628
+ //
629
+ // # Parameters
630
+ //
631
+ // - fd: file descriptor to get the path of the pre-opened directory
632
+ // - path: offset in api.Memory to write the result path
633
+ // - pathLen: count of bytes to write to `path`
634
+ // - This should match the uint32le fdPrestatGet writes to offset
635
+ // `resultPrestat`+4
636
+ //
637
+ // Result (Errno)
638
+ //
639
+ // The return value is 0 except the following error conditions:
640
+ // - sys.EBADF: `fd` is invalid
641
+ // - sys.EFAULT: `path` points to an offset out of memory
642
+ // - sys.ENAMETOOLONG: `pathLen` is longer than the actual length of the result
643
+ //
644
+ // For example, the directory name corresponding with `fd` was "/tmp" and
645
+ // # Parameters path=1 pathLen=4 (correct), this function will write the below to
646
+ // api.Memory:
647
+ //
648
+ // pathLen
649
+ // +--------------+
650
+ // | |
651
+ // []byte{?, '/', 't', 'm', 'p', ?}
652
+ // path --^
653
+ //
654
+ // See fdPrestatGet
655
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_prestat_dir_name
656
+ var fdPrestatDirName = newHostFunc(
657
+ wasip1.FdPrestatDirNameName, fdPrestatDirNameFn,
658
+ []wasm.ValueType{i32, i32, i32},
659
+ "fd", "result.path", "result.path_len",
660
+ )
661
+
662
+ func fdPrestatDirNameFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
663
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
664
+ fd, path, pathLen := int32(params[0]), uint32(params[1]), uint32(params[2])
665
+
666
+ name, errno := preopenPath(fsc, fd)
667
+ if errno != 0 {
668
+ return errno
669
+ }
670
+
671
+ // Some runtimes may have another semantics. See /RATIONALE.md
672
+ if uint32(len(name)) < pathLen {
673
+ return experimentalsys.ENAMETOOLONG
674
+ }
675
+
676
+ if !mod.Memory().Write(path, []byte(name)[:pathLen]) {
677
+ return experimentalsys.EFAULT
678
+ }
679
+ return 0
680
+ }
681
+
682
+ // fdPwrite is the WASI function named FdPwriteName which writes to a file
683
+ // descriptor, without using and updating the file descriptor's offset.
684
+ //
685
+ // Except for handling offset, this implementation is identical to fdWrite.
686
+ //
687
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_pwritefd-fd-iovs-ciovec_array-offset-filesize---errno-size
688
+ var fdPwrite = newHostFunc(
689
+ wasip1.FdPwriteName, fdPwriteFn,
690
+ []wasm.ValueType{i32, i32, i32, i64, i32},
691
+ "fd", "iovs", "iovs_len", "offset", "result.nwritten",
692
+ )
693
+
694
+ func fdPwriteFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
695
+ return fdWriteOrPwrite(mod, params, true)
696
+ }
697
+
698
+ // fdRead is the WASI function named FdReadName which reads from a file
699
+ // descriptor.
700
+ //
701
+ // # Parameters
702
+ //
703
+ // - fd: an opened file descriptor to read data from
704
+ // - iovs: offset in api.Memory to read offset, size pairs representing where
705
+ // to write file data
706
+ // - Both offset and length are encoded as uint32le
707
+ // - iovsCount: count of memory offset, size pairs to read sequentially
708
+ // starting at iovs
709
+ // - resultNread: offset in api.Memory to write the number of bytes read
710
+ //
711
+ // Result (Errno)
712
+ //
713
+ // The return value is 0 except the following error conditions:
714
+ // - sys.EBADF: `fd` is invalid
715
+ // - sys.EFAULT: `iovs` or `resultNread` point to an offset out of memory
716
+ // - sys.EIO: a file system error
717
+ //
718
+ // For example, this function needs to first read `iovs` to determine where
719
+ // to write contents. If parameters iovs=1 iovsCount=2, this function reads two
720
+ // offset/length pairs from api.Memory:
721
+ //
722
+ // iovs[0] iovs[1]
723
+ // +---------------------+ +--------------------+
724
+ // | uint32le uint32le| |uint32le uint32le|
725
+ // +---------+ +--------+ +--------+ +--------+
726
+ // | | | | | | | |
727
+ // []byte{?, 18, 0, 0, 0, 4, 0, 0, 0, 23, 0, 0, 0, 2, 0, 0, 0, ?... }
728
+ // iovs --^ ^ ^ ^
729
+ // | | | |
730
+ // offset --+ length --+ offset --+ length --+
731
+ //
732
+ // If the contents of the `fd` parameter was "wazero" (6 bytes) and parameter
733
+ // resultNread=26, this function writes the below to api.Memory:
734
+ //
735
+ // iovs[0].length iovs[1].length
736
+ // +--------------+ +----+ uint32le
737
+ // | | | | +--------+
738
+ // []byte{ 0..16, ?, 'w', 'a', 'z', 'e', ?, 'r', 'o', ?, 6, 0, 0, 0 }
739
+ // iovs[0].offset --^ ^ ^
740
+ // iovs[1].offset --+ |
741
+ // resultNread --+
742
+ //
743
+ // Note: This is similar to `readv` in POSIX. https://linux.die.net/man/3/readv
744
+ //
745
+ // See fdWrite
746
+ // and https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_read
747
+ var fdRead = newHostFunc(
748
+ wasip1.FdReadName, fdReadFn,
749
+ []wasm.ValueType{i32, i32, i32, i32},
750
+ "fd", "iovs", "iovs_len", "result.nread",
751
+ )
752
+
753
+ // preader tracks an offset across multiple reads.
754
+ type preader struct {
755
+ f experimentalsys.File
756
+ offset int64
757
+ }
758
+
759
+ // Read implements the same function as documented on sys.File.
760
+ func (w *preader) Read(buf []byte) (n int, errno experimentalsys.Errno) {
761
+ if len(buf) == 0 {
762
+ return 0, 0 // less overhead on zero-length reads.
763
+ }
764
+
765
+ n, err := w.f.Pread(buf, w.offset)
766
+ w.offset += int64(n)
767
+ return n, err
768
+ }
769
+
770
+ func fdReadFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
771
+ return fdReadOrPread(mod, params, false)
772
+ }
773
+
774
+ func fdReadOrPread(mod api.Module, params []uint64, isPread bool) experimentalsys.Errno {
775
+ mem := mod.Memory()
776
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
777
+
778
+ fd := int32(params[0])
779
+ iovs := uint32(params[1])
780
+ iovsCount := uint32(params[2])
781
+
782
+ var resultNread uint32
783
+ var reader func(buf []byte) (n int, errno experimentalsys.Errno)
784
+ if f, ok := fsc.LookupFile(fd); !ok {
785
+ return experimentalsys.EBADF
786
+ } else if isPread {
787
+ offset := int64(params[3])
788
+ reader = (&preader{f: f.File, offset: offset}).Read
789
+ resultNread = uint32(params[4])
790
+ } else {
791
+ reader = f.File.Read
792
+ resultNread = uint32(params[3])
793
+ }
794
+
795
+ nread, errno := readv(mem, iovs, iovsCount, reader)
796
+ if errno != 0 {
797
+ return errno
798
+ }
799
+ if !mem.WriteUint32Le(resultNread, nread) {
800
+ return experimentalsys.EFAULT
801
+ } else {
802
+ return 0
803
+ }
804
+ }
805
+
806
+ func readv(mem api.Memory, iovs uint32, iovsCount uint32, reader func(buf []byte) (nread int, errno experimentalsys.Errno)) (uint32, experimentalsys.Errno) {
807
+ var nread uint32
808
+ iovsStop := iovsCount << 3 // iovsCount * 8
809
+ iovsBuf, ok := mem.Read(iovs, iovsStop)
810
+ if !ok {
811
+ return 0, experimentalsys.EFAULT
812
+ }
813
+
814
+ for iovsPos := uint32(0); iovsPos < iovsStop; iovsPos += 8 {
815
+ offset := le.Uint32(iovsBuf[iovsPos:])
816
+ l := le.Uint32(iovsBuf[iovsPos+4:])
817
+
818
+ if l == 0 { // A zero length iovec could be ahead of another.
819
+ continue
820
+ }
821
+
822
+ b, ok := mem.Read(offset, l)
823
+ if !ok {
824
+ return 0, experimentalsys.EFAULT
825
+ }
826
+
827
+ n, errno := reader(b)
828
+ nread += uint32(n)
829
+
830
+ if errno == experimentalsys.ENOSYS {
831
+ return 0, experimentalsys.EBADF // e.g. unimplemented for read
832
+ } else if errno != 0 {
833
+ return 0, errno
834
+ } else if n < int(l) {
835
+ break // stop when we read less than capacity.
836
+ }
837
+ }
838
+ return nread, 0
839
+ }
840
+
841
+ // fdReaddir is the WASI function named wasip1.FdReaddirName which reads
842
+ // directory entries from a directory. Special behaviors required by this
843
+ // function are implemented in sys.DirentCache.
844
+ //
845
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_readdirfd-fd-buf-pointeru8-buf_len-size-cookie-dircookie---errno-size
846
+ //
847
+ // # Result (Errno)
848
+ //
849
+ // The return value is 0 except the following known error conditions:
850
+ // - sys.ENOSYS: the implementation does not support this function.
851
+ // - sys.EBADF: the file was closed or not a directory.
852
+ // - sys.EFAULT: `buf` or `buf_len` point to an offset out of memory.
853
+ // - sys.ENOENT: `cookie` was invalid.
854
+ // - sys.EINVAL: `buf_len` was not large enough to write a dirent header.
855
+ //
856
+ // # End of Directory (EOF)
857
+ //
858
+ // More entries are available when `result.bufused` == `buf_len`. See
859
+ // https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_readdir
860
+ // https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c#L44
861
+ var fdReaddir = newHostFunc(
862
+ wasip1.FdReaddirName, fdReaddirFn,
863
+ []wasm.ValueType{i32, i32, i32, i64, i32},
864
+ "fd", "buf", "buf_len", "cookie", "result.bufused",
865
+ )
866
+
867
+ func fdReaddirFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
868
+ mem := mod.Memory()
869
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
870
+
871
+ fd := int32(params[0])
872
+ buf := uint32(params[1])
873
+ bufLen := uint32(params[2])
874
+ cookie := params[3]
875
+ resultBufused := uint32(params[4])
876
+
877
+ // The bufLen must be enough to write a dirent header.
878
+ if bufLen < wasip1.DirentSize {
879
+ // This is a bug in the caller, as unless `buf_len` is large enough to
880
+ // write a dirent, it can't read the `d_namlen` from it.
881
+ return experimentalsys.EINVAL
882
+ }
883
+
884
+ // Get or open a dirent cache for this file descriptor.
885
+ dir, errno := direntCache(fsc, fd)
886
+ if errno != 0 {
887
+ return errno
888
+ }
889
+
890
+ // First, determine the maximum directory entries that can be encoded as
891
+ // dirents. The total size is DirentSize(24) + nameSize, for each file.
892
+ // Since a zero-length file name is invalid, the minimum size entry is
893
+ // 25 (DirentSize + 1 character).
894
+ maxDirEntries := bufLen/wasip1.DirentSize + 1
895
+
896
+ // While unlikely maxDirEntries will fit into bufLen, add one more just in
897
+ // case, as we need to know if we hit the end of the directory or not to
898
+ // write the correct bufused (e.g. == bufLen unless EOF).
899
+ // >> If less than the size of the read buffer, the end of the
900
+ // >> directory has been reached.
901
+ maxDirEntries += 1
902
+
903
+ // Read up to max entries. The underlying implementation will cache these,
904
+ // starting at the current location, so that they can be re-read. This is
905
+ // important because even the first could end up larger than bufLen due to
906
+ // the size of its name.
907
+ dirents, errno := dir.Read(cookie, maxDirEntries)
908
+ if errno != 0 {
909
+ return errno
910
+ }
911
+
912
+ // Determine how many dirents we can write, including a potentially
913
+ // truncated last entry.
914
+ bufToWrite, direntCount, truncatedLen := maxDirents(dirents, bufLen)
915
+
916
+ // Now, write entries to the underlying buffer.
917
+ if bufToWrite > 0 {
918
+
919
+ // d_next is the index of the next file in the list, so it should
920
+ // always be one higher than the requested cookie.
921
+ d_next := cookie + 1
922
+ // ^^ yes this can overflow to negative, which means our implementation
923
+ // doesn't support writing greater than max int64 entries.
924
+
925
+ buf, ok := mem.Read(buf, bufToWrite)
926
+ if !ok {
927
+ return experimentalsys.EFAULT
928
+ }
929
+
930
+ writeDirents(buf, dirents, d_next, direntCount, truncatedLen)
931
+ }
932
+
933
+ // bufused == bufLen means more dirents exist, which is the case when one
934
+ // is truncated.
935
+ bufused := bufToWrite
936
+ if truncatedLen > 0 {
937
+ bufused = bufLen
938
+ }
939
+
940
+ if !mem.WriteUint32Le(resultBufused, bufused) {
941
+ return experimentalsys.EFAULT
942
+ }
943
+ return 0
944
+ }
945
+
946
+ const largestDirent = int64(math.MaxUint32 - wasip1.DirentSize)
947
+
948
+ // maxDirents returns the dirents to write.
949
+ //
950
+ // `bufToWrite` is the amount of memory needed to write direntCount, which
951
+ // includes up to wasip1.DirentSize of a last truncated entry.
952
+ func maxDirents(dirents []experimentalsys.Dirent, bufLen uint32) (bufToWrite uint32, direntCount int, truncatedLen uint32) {
953
+ lenRemaining := bufLen
954
+ for i := range dirents {
955
+ if lenRemaining == 0 {
956
+ break
957
+ }
958
+ d := dirents[i]
959
+ direntCount++
960
+
961
+ // use int64 to guard against huge filenames
962
+ nameLen := int64(len(d.Name))
963
+ var entryLen uint32
964
+
965
+ // Check to see if DirentSize + nameLen overflows, or if it would be
966
+ // larger than possible to encode.
967
+ if el := int64(wasip1.DirentSize) + nameLen; el < 0 || el > largestDirent {
968
+ // panic, as testing is difficult. ex we would have to extract a
969
+ // function to get size of a string or allocate a 2^32 size one!
970
+ panic("invalid filename: too large")
971
+ } else { // we know this can fit into a uint32
972
+ entryLen = uint32(el)
973
+ }
974
+
975
+ if entryLen > lenRemaining {
976
+ // We haven't room to write the entry, and docs say to write the
977
+ // header. This helps especially when there is an entry with a very
978
+ // long filename. Ex if bufLen is 4096 and the filename is 4096,
979
+ // we need to write DirentSize(24) + 4096 bytes to write the entry.
980
+ // In this case, we only write up to DirentSize(24) to allow the
981
+ // caller to resize.
982
+ if lenRemaining >= wasip1.DirentSize {
983
+ truncatedLen = wasip1.DirentSize
984
+ } else {
985
+ truncatedLen = lenRemaining
986
+ }
987
+ bufToWrite += truncatedLen
988
+ break
989
+ }
990
+
991
+ // This won't go negative because we checked entryLen <= lenRemaining.
992
+ lenRemaining -= entryLen
993
+ bufToWrite += entryLen
994
+ }
995
+ return
996
+ }
997
+
998
+ // writeDirents writes the directory entries to the buffer, which is pre-sized
999
+ // based on maxDirents. truncatedEntryLen means the last is written without its
1000
+ // name.
1001
+ func writeDirents(buf []byte, dirents []experimentalsys.Dirent, d_next uint64, direntCount int, truncatedLen uint32) {
1002
+ pos := uint32(0)
1003
+ skipNameI := -1
1004
+
1005
+ // If the last entry was truncated, we either skip it or write it without
1006
+ // its name, depending on the length.
1007
+ if truncatedLen > 0 {
1008
+ if truncatedLen < wasip1.DirentSize {
1009
+ direntCount-- // skip as too small to write the header.
1010
+ } else {
1011
+ skipNameI = direntCount - 1 // write the header, but not the name.
1012
+ }
1013
+ }
1014
+
1015
+ for i := 0; i < direntCount; i++ {
1016
+ e := dirents[i]
1017
+ nameLen := uint32(len(e.Name))
1018
+ writeDirent(buf[pos:], d_next, e.Ino, nameLen, e.Type)
1019
+ d_next++
1020
+ pos += wasip1.DirentSize
1021
+
1022
+ if i != skipNameI {
1023
+ copy(buf[pos:], e.Name)
1024
+ pos += nameLen
1025
+ }
1026
+ }
1027
+ }
1028
+
1029
+ // writeDirent writes DirentSize bytes
1030
+ func writeDirent(buf []byte, dNext uint64, ino sysapi.Inode, dNamlen uint32, dType fs.FileMode) {
1031
+ le.PutUint64(buf, dNext) // d_next
1032
+ le.PutUint64(buf[8:], ino) // d_ino
1033
+ le.PutUint32(buf[16:], dNamlen) // d_namlen
1034
+ filetype := getWasiFiletype(dType)
1035
+ le.PutUint32(buf[20:], uint32(filetype)) // d_type
1036
+ }
1037
+
1038
+ // direntCache lazy opens a sys.DirentCache for this directory or returns an
1039
+ // error.
1040
+ func direntCache(fsc *sys.FSContext, fd int32) (*sys.DirentCache, experimentalsys.Errno) {
1041
+ if f, ok := fsc.LookupFile(fd); !ok {
1042
+ return nil, experimentalsys.EBADF
1043
+ } else if dir, errno := f.DirentCache(); errno == 0 {
1044
+ return dir, 0
1045
+ } else if errno == experimentalsys.ENOTDIR {
1046
+ // fd_readdir docs don't indicate whether to return sys.ENOTDIR or
1047
+ // sys.EBADF. It has been noticed that rust will crash on sys.ENOTDIR,
1048
+ // and POSIX C ref seems to not return this, so we don't either.
1049
+ //
1050
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_readdir
1051
+ // and https://en.wikibooks.org/wiki/C_Programming/POSIX_Reference/dirent.h
1052
+ return nil, experimentalsys.EBADF
1053
+ } else {
1054
+ return nil, errno
1055
+ }
1056
+ }
1057
+
1058
+ // fdRenumber is the WASI function named FdRenumberName which atomically
1059
+ // replaces a file descriptor by renumbering another file descriptor.
1060
+ //
1061
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_renumberfd-fd-to-fd---errno
1062
+ var fdRenumber = newHostFunc(wasip1.FdRenumberName, fdRenumberFn, []wasm.ValueType{i32, i32}, "fd", "to")
1063
+
1064
+ func fdRenumberFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1065
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1066
+
1067
+ from := int32(params[0])
1068
+ to := int32(params[1])
1069
+
1070
+ if errno := fsc.Renumber(from, to); errno != 0 {
1071
+ return errno
1072
+ }
1073
+ return 0
1074
+ }
1075
+
1076
+ // fdSeek is the WASI function named FdSeekName which moves the offset of a
1077
+ // file descriptor.
1078
+ //
1079
+ // # Parameters
1080
+ //
1081
+ // - fd: file descriptor to move the offset of
1082
+ // - offset: signed int64, which is encoded as uint64, input argument to
1083
+ // `whence`, which results in a new offset
1084
+ // - whence: operator that creates the new offset, given `offset` bytes
1085
+ // - If io.SeekStart, new offset == `offset`.
1086
+ // - If io.SeekCurrent, new offset == existing offset + `offset`.
1087
+ // - If io.SeekEnd, new offset == file size of `fd` + `offset`.
1088
+ // - resultNewoffset: offset in api.Memory to write the new offset to,
1089
+ // relative to start of the file
1090
+ //
1091
+ // Result (Errno)
1092
+ //
1093
+ // The return value is 0 except the following error conditions:
1094
+ // - sys.EBADF: `fd` is invalid
1095
+ // - sys.EFAULT: `resultNewoffset` points to an offset out of memory
1096
+ // - sys.EINVAL: `whence` is an invalid value
1097
+ // - sys.EIO: a file system error
1098
+ // - sys.EISDIR: the file was a directory.
1099
+ //
1100
+ // For example, if fd 3 is a file with offset 0, and parameters fd=3, offset=4,
1101
+ // whence=0 (=io.SeekStart), resultNewOffset=1, this function writes the below
1102
+ // to api.Memory:
1103
+ //
1104
+ // uint64le
1105
+ // +--------------------+
1106
+ // | |
1107
+ // []byte{?, 4, 0, 0, 0, 0, 0, 0, 0, ? }
1108
+ // resultNewoffset --^
1109
+ //
1110
+ // Note: This is similar to `lseek` in POSIX. https://linux.die.net/man/3/lseek
1111
+ //
1112
+ // See io.Seeker
1113
+ // and https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_seek
1114
+ var fdSeek = newHostFunc(
1115
+ wasip1.FdSeekName, fdSeekFn,
1116
+ []wasm.ValueType{i32, i64, i32, i32},
1117
+ "fd", "offset", "whence", "result.newoffset",
1118
+ )
1119
+
1120
+ func fdSeekFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1121
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1122
+ fd := int32(params[0])
1123
+ offset := params[1]
1124
+ whence := uint32(params[2])
1125
+ resultNewoffset := uint32(params[3])
1126
+
1127
+ if f, ok := fsc.LookupFile(fd); !ok {
1128
+ return experimentalsys.EBADF
1129
+ } else if isDir, _ := f.File.IsDir(); isDir {
1130
+ return experimentalsys.EISDIR // POSIX doesn't forbid seeking a directory, but wasi-testsuite does.
1131
+ } else if newOffset, errno := f.File.Seek(int64(offset), int(whence)); errno != 0 {
1132
+ return errno
1133
+ } else if !mod.Memory().WriteUint64Le(resultNewoffset, uint64(newOffset)) {
1134
+ return experimentalsys.EFAULT
1135
+ }
1136
+ return 0
1137
+ }
1138
+
1139
+ // fdSync is the WASI function named FdSyncName which synchronizes the data
1140
+ // and metadata of a file to disk.
1141
+ //
1142
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_syncfd-fd---errno
1143
+ var fdSync = newHostFunc(wasip1.FdSyncName, fdSyncFn, []wasm.ValueType{i32}, "fd")
1144
+
1145
+ func fdSyncFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1146
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1147
+ fd := int32(params[0])
1148
+
1149
+ // Check to see if the file descriptor is available
1150
+ if f, ok := fsc.LookupFile(fd); !ok {
1151
+ return experimentalsys.EBADF
1152
+ } else {
1153
+ return f.File.Sync()
1154
+ }
1155
+ }
1156
+
1157
+ // fdTell is the WASI function named FdTellName which returns the current
1158
+ // offset of a file descriptor.
1159
+ //
1160
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-fd_tellfd-fd---errno-filesize
1161
+ var fdTell = newHostFunc(wasip1.FdTellName, fdTellFn, []wasm.ValueType{i32, i32}, "fd", "result.offset")
1162
+
1163
+ func fdTellFn(ctx context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1164
+ fd := params[0]
1165
+ offset := uint64(0)
1166
+ whence := uint64(io.SeekCurrent)
1167
+ resultNewoffset := params[1]
1168
+
1169
+ fdSeekParams := []uint64{fd, offset, whence, resultNewoffset}
1170
+ return fdSeekFn(ctx, mod, fdSeekParams)
1171
+ }
1172
+
1173
+ // fdWrite is the WASI function named FdWriteName which writes to a file
1174
+ // descriptor.
1175
+ //
1176
+ // # Parameters
1177
+ //
1178
+ // - fd: an opened file descriptor to write data to
1179
+ // - iovs: offset in api.Memory to read offset, size pairs representing the
1180
+ // data to write to `fd`
1181
+ // - Both offset and length are encoded as uint32le.
1182
+ // - iovsCount: count of memory offset, size pairs to read sequentially
1183
+ // starting at iovs
1184
+ // - resultNwritten: offset in api.Memory to write the number of bytes
1185
+ // written
1186
+ //
1187
+ // Result (Errno)
1188
+ //
1189
+ // The return value is 0 except the following error conditions:
1190
+ // - sys.EBADF: `fd` is invalid
1191
+ // - sys.EFAULT: `iovs` or `resultNwritten` point to an offset out of memory
1192
+ // - sys.EIO: a file system error
1193
+ //
1194
+ // For example, this function needs to first read `iovs` to determine what to
1195
+ // write to `fd`. If parameters iovs=1 iovsCount=2, this function reads two
1196
+ // offset/length pairs from api.Memory:
1197
+ //
1198
+ // iovs[0] iovs[1]
1199
+ // +---------------------+ +--------------------+
1200
+ // | uint32le uint32le| |uint32le uint32le|
1201
+ // +---------+ +--------+ +--------+ +--------+
1202
+ // | | | | | | | |
1203
+ // []byte{?, 18, 0, 0, 0, 4, 0, 0, 0, 23, 0, 0, 0, 2, 0, 0, 0, ?... }
1204
+ // iovs --^ ^ ^ ^
1205
+ // | | | |
1206
+ // offset --+ length --+ offset --+ length --+
1207
+ //
1208
+ // This function reads those chunks api.Memory into the `fd` sequentially.
1209
+ //
1210
+ // iovs[0].length iovs[1].length
1211
+ // +--------------+ +----+
1212
+ // | | | |
1213
+ // []byte{ 0..16, ?, 'w', 'a', 'z', 'e', ?, 'r', 'o', ? }
1214
+ // iovs[0].offset --^ ^
1215
+ // iovs[1].offset --+
1216
+ //
1217
+ // Since "wazero" was written, if parameter resultNwritten=26, this function
1218
+ // writes the below to api.Memory:
1219
+ //
1220
+ // uint32le
1221
+ // +--------+
1222
+ // | |
1223
+ // []byte{ 0..24, ?, 6, 0, 0, 0', ? }
1224
+ // resultNwritten --^
1225
+ //
1226
+ // Note: This is similar to `writev` in POSIX. https://linux.die.net/man/3/writev
1227
+ //
1228
+ // See fdRead
1229
+ // https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#ciovec
1230
+ // and https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#fd_write
1231
+ var fdWrite = newHostFunc(
1232
+ wasip1.FdWriteName, fdWriteFn,
1233
+ []wasm.ValueType{i32, i32, i32, i32},
1234
+ "fd", "iovs", "iovs_len", "result.nwritten",
1235
+ )
1236
+
1237
+ func fdWriteFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1238
+ return fdWriteOrPwrite(mod, params, false)
1239
+ }
1240
+
1241
+ // pwriter tracks an offset across multiple writes.
1242
+ type pwriter struct {
1243
+ f experimentalsys.File
1244
+ offset int64
1245
+ }
1246
+
1247
+ // Write implements the same function as documented on sys.File.
1248
+ func (w *pwriter) Write(buf []byte) (n int, errno experimentalsys.Errno) {
1249
+ if len(buf) == 0 {
1250
+ return 0, 0 // less overhead on zero-length writes.
1251
+ }
1252
+
1253
+ n, err := w.f.Pwrite(buf, w.offset)
1254
+ w.offset += int64(n)
1255
+ return n, err
1256
+ }
1257
+
1258
+ func fdWriteOrPwrite(mod api.Module, params []uint64, isPwrite bool) experimentalsys.Errno {
1259
+ mem := mod.Memory()
1260
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1261
+
1262
+ fd := int32(params[0])
1263
+ iovs := uint32(params[1])
1264
+ iovsCount := uint32(params[2])
1265
+
1266
+ var resultNwritten uint32
1267
+ var writer func(buf []byte) (n int, errno experimentalsys.Errno)
1268
+ if f, ok := fsc.LookupFile(fd); !ok {
1269
+ return experimentalsys.EBADF
1270
+ } else if isPwrite {
1271
+ offset := int64(params[3])
1272
+ writer = (&pwriter{f: f.File, offset: offset}).Write
1273
+ resultNwritten = uint32(params[4])
1274
+ } else {
1275
+ writer = f.File.Write
1276
+ resultNwritten = uint32(params[3])
1277
+ }
1278
+
1279
+ nwritten, errno := writev(mem, iovs, iovsCount, writer)
1280
+ if errno != 0 {
1281
+ return errno
1282
+ }
1283
+
1284
+ if !mod.Memory().WriteUint32Le(resultNwritten, nwritten) {
1285
+ return experimentalsys.EFAULT
1286
+ }
1287
+ return 0
1288
+ }
1289
+
1290
+ func writev(mem api.Memory, iovs uint32, iovsCount uint32, writer func(buf []byte) (n int, errno experimentalsys.Errno)) (uint32, experimentalsys.Errno) {
1291
+ var nwritten uint32
1292
+ iovsStop := iovsCount << 3 // iovsCount * 8
1293
+ iovsBuf, ok := mem.Read(iovs, iovsStop)
1294
+ if !ok {
1295
+ return 0, experimentalsys.EFAULT
1296
+ }
1297
+
1298
+ for iovsPos := uint32(0); iovsPos < iovsStop; iovsPos += 8 {
1299
+ offset := le.Uint32(iovsBuf[iovsPos:])
1300
+ l := le.Uint32(iovsBuf[iovsPos+4:])
1301
+
1302
+ b, ok := mem.Read(offset, l)
1303
+ if !ok {
1304
+ return 0, experimentalsys.EFAULT
1305
+ }
1306
+ n, errno := writer(b)
1307
+ nwritten += uint32(n)
1308
+ if errno == experimentalsys.ENOSYS {
1309
+ return 0, experimentalsys.EBADF // e.g. unimplemented for write
1310
+ } else if errno != 0 {
1311
+ return 0, errno
1312
+ }
1313
+ }
1314
+ return nwritten, 0
1315
+ }
1316
+
1317
+ // pathCreateDirectory is the WASI function named PathCreateDirectoryName which
1318
+ // creates a directory.
1319
+ //
1320
+ // # Parameters
1321
+ //
1322
+ // - fd: file descriptor of a directory that `path` is relative to
1323
+ // - path: offset in api.Memory to read the path string from
1324
+ // - pathLen: length of `path`
1325
+ //
1326
+ // # Result (Errno)
1327
+ //
1328
+ // The return value is 0 except the following error conditions:
1329
+ // - sys.EBADF: `fd` is invalid
1330
+ // - sys.ENOENT: `path` does not exist.
1331
+ // - sys.ENOTDIR: `path` is a file
1332
+ //
1333
+ // # Notes
1334
+ // - This is similar to mkdirat in POSIX.
1335
+ // See https://linux.die.net/man/2/mkdirat
1336
+ //
1337
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-path_create_directoryfd-fd-path-string---errno
1338
+ var pathCreateDirectory = newHostFunc(
1339
+ wasip1.PathCreateDirectoryName, pathCreateDirectoryFn,
1340
+ []wasm.ValueType{i32, i32, i32},
1341
+ "fd", "path", "path_len",
1342
+ )
1343
+
1344
+ func pathCreateDirectoryFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1345
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1346
+
1347
+ fd := int32(params[0])
1348
+ path := uint32(params[1])
1349
+ pathLen := uint32(params[2])
1350
+
1351
+ preopen, pathName, errno := atPath(fsc, mod.Memory(), fd, path, pathLen)
1352
+ if errno != 0 {
1353
+ return errno
1354
+ }
1355
+
1356
+ if errno = preopen.Mkdir(pathName, 0o700); errno != 0 {
1357
+ return errno
1358
+ }
1359
+
1360
+ return 0
1361
+ }
1362
+
1363
+ // pathFilestatGet is the WASI function named PathFilestatGetName which
1364
+ // returns the stat attributes of a file or directory.
1365
+ //
1366
+ // # Parameters
1367
+ //
1368
+ // - fd: file descriptor of the folder to look in for the path
1369
+ // - flags: flags determining the method of how paths are resolved
1370
+ // - path: path under fd to get the filestat attributes data for
1371
+ // - path_len: length of the path that was given
1372
+ // - resultFilestat: offset to write the result filestat data
1373
+ //
1374
+ // Result (Errno)
1375
+ //
1376
+ // The return value is 0 except the following error conditions:
1377
+ // - sys.EBADF: `fd` is invalid
1378
+ // - sys.ENOTDIR: `fd` points to a file not a directory
1379
+ // - sys.EIO: could not stat `fd` on filesystem
1380
+ // - sys.EINVAL: the path contained "../"
1381
+ // - sys.ENAMETOOLONG: `path` + `path_len` is out of memory
1382
+ // - sys.EFAULT: `resultFilestat` points to an offset out of memory
1383
+ // - sys.ENOENT: could not find the path
1384
+ //
1385
+ // The rest of this implementation matches that of fdFilestatGet, so is not
1386
+ // repeated here.
1387
+ //
1388
+ // Note: This is similar to `fstatat` in POSIX.
1389
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-path_filestat_getfd-fd-flags-lookupflags-path-string---errno-filestat
1390
+ // and https://linux.die.net/man/2/fstatat
1391
+ var pathFilestatGet = newHostFunc(
1392
+ wasip1.PathFilestatGetName, pathFilestatGetFn,
1393
+ []wasm.ValueType{i32, i32, i32, i32, i32},
1394
+ "fd", "flags", "path", "path_len", "result.filestat",
1395
+ )
1396
+
1397
+ func pathFilestatGetFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1398
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1399
+
1400
+ fd := int32(params[0])
1401
+ flags := uint16(params[1])
1402
+ path := uint32(params[2])
1403
+ pathLen := uint32(params[3])
1404
+
1405
+ preopen, pathName, errno := atPath(fsc, mod.Memory(), fd, path, pathLen)
1406
+ if errno != 0 {
1407
+ return errno
1408
+ }
1409
+
1410
+ // Stat the file without allocating a file descriptor.
1411
+ var st sysapi.Stat_t
1412
+
1413
+ if (flags & wasip1.LOOKUP_SYMLINK_FOLLOW) == 0 {
1414
+ st, errno = preopen.Lstat(pathName)
1415
+ } else {
1416
+ st, errno = preopen.Stat(pathName)
1417
+ }
1418
+ if errno != 0 {
1419
+ return errno
1420
+ }
1421
+
1422
+ // Write the stat result to memory
1423
+ resultBuf := uint32(params[4])
1424
+ buf, ok := mod.Memory().Read(resultBuf, 64)
1425
+ if !ok {
1426
+ return experimentalsys.EFAULT
1427
+ }
1428
+
1429
+ filetype := getWasiFiletype(st.Mode)
1430
+ return writeFilestat(buf, &st, filetype)
1431
+ }
1432
+
1433
+ // pathFilestatSetTimes is the WASI function named PathFilestatSetTimesName
1434
+ // which adjusts the timestamps of a file or directory.
1435
+ //
1436
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-path_filestat_set_timesfd-fd-flags-lookupflags-path-string-atim-timestamp-mtim-timestamp-fst_flags-fstflags---errno
1437
+ var pathFilestatSetTimes = newHostFunc(
1438
+ wasip1.PathFilestatSetTimesName, pathFilestatSetTimesFn,
1439
+ []wasm.ValueType{i32, i32, i32, i32, i64, i64, i32},
1440
+ "fd", "flags", "path", "path_len", "atim", "mtim", "fst_flags",
1441
+ )
1442
+
1443
+ func pathFilestatSetTimesFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1444
+ fd := int32(params[0])
1445
+ flags := uint16(params[1])
1446
+ path := uint32(params[2])
1447
+ pathLen := uint32(params[3])
1448
+ atim := int64(params[4])
1449
+ mtim := int64(params[5])
1450
+ fstFlags := uint16(params[6])
1451
+
1452
+ sys := mod.(*wasm.ModuleInstance).Sys
1453
+ fsc := sys.FS()
1454
+
1455
+ atim, mtim, errno := toTimes(sys.WalltimeNanos, atim, mtim, fstFlags)
1456
+ if errno != 0 {
1457
+ return errno
1458
+ }
1459
+
1460
+ preopen, pathName, errno := atPath(fsc, mod.Memory(), fd, path, pathLen)
1461
+ if errno != 0 {
1462
+ return errno
1463
+ }
1464
+
1465
+ symlinkFollow := flags&wasip1.LOOKUP_SYMLINK_FOLLOW != 0
1466
+ if symlinkFollow {
1467
+ return preopen.Utimens(pathName, atim, mtim)
1468
+ }
1469
+ // Otherwise, we need to emulate don't follow by opening the file by path.
1470
+ if f, errno := preopen.OpenFile(pathName, experimentalsys.O_WRONLY, 0); errno != 0 {
1471
+ return errno
1472
+ } else {
1473
+ defer f.Close()
1474
+ return f.Utimens(atim, mtim)
1475
+ }
1476
+ }
1477
+
1478
+ // pathLink is the WASI function named PathLinkName which adjusts the
1479
+ // timestamps of a file or directory.
1480
+ //
1481
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#path_link
1482
+ var pathLink = newHostFunc(
1483
+ wasip1.PathLinkName, pathLinkFn,
1484
+ []wasm.ValueType{i32, i32, i32, i32, i32, i32, i32},
1485
+ "old_fd", "old_flags", "old_path", "old_path_len", "new_fd", "new_path", "new_path_len",
1486
+ )
1487
+
1488
+ func pathLinkFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1489
+ mem := mod.Memory()
1490
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1491
+
1492
+ oldFD := int32(params[0])
1493
+ // TODO: use old_flags?
1494
+ _ = uint32(params[1])
1495
+ oldPath := uint32(params[2])
1496
+ oldPathLen := uint32(params[3])
1497
+
1498
+ oldFS, oldName, errno := atPath(fsc, mem, oldFD, oldPath, oldPathLen)
1499
+ if errno != 0 {
1500
+ return errno
1501
+ }
1502
+
1503
+ newFD := int32(params[4])
1504
+ newPath := uint32(params[5])
1505
+ newPathLen := uint32(params[6])
1506
+
1507
+ newFS, newName, errno := atPath(fsc, mem, newFD, newPath, newPathLen)
1508
+ if errno != 0 {
1509
+ return errno
1510
+ }
1511
+
1512
+ if oldFS != newFS { // TODO: handle link across filesystems
1513
+ return experimentalsys.ENOSYS
1514
+ }
1515
+
1516
+ return oldFS.Link(oldName, newName)
1517
+ }
1518
+
1519
+ // pathOpen is the WASI function named PathOpenName which opens a file or
1520
+ // directory. This returns sys.EBADF if the fd is invalid.
1521
+ //
1522
+ // # Parameters
1523
+ //
1524
+ // - fd: file descriptor of a directory that `path` is relative to
1525
+ // - dirflags: flags to indicate how to resolve `path`
1526
+ // - path: offset in api.Memory to read the path string from
1527
+ // - pathLen: length of `path`
1528
+ // - oFlags: open flags to indicate the method by which to open the file
1529
+ // - fsRightsBase: interpret RIGHT_FD_WRITE to set O_RDWR
1530
+ // - fsRightsInheriting: ignored as rights were removed from WASI.
1531
+ // created file descriptor for `path`
1532
+ // - fdFlags: file descriptor flags
1533
+ // - resultOpenedFD: offset in api.Memory to write the newly created file
1534
+ // descriptor to.
1535
+ // - The result FD value is guaranteed to be less than 2**31
1536
+ //
1537
+ // Result (Errno)
1538
+ //
1539
+ // The return value is 0 except the following error conditions:
1540
+ // - sys.EBADF: `fd` is invalid
1541
+ // - sys.EFAULT: `resultOpenedFD` points to an offset out of memory
1542
+ // - sys.ENOENT: `path` does not exist.
1543
+ // - sys.EEXIST: `path` exists, while `oFlags` requires that it must not.
1544
+ // - sys.ENOTDIR: `path` is not a directory, while `oFlags` requires it.
1545
+ // - sys.EIO: a file system error
1546
+ //
1547
+ // For example, this function needs to first read `path` to determine the file
1548
+ // to open. If parameters `path` = 1, `pathLen` = 6, and the path is "wazero",
1549
+ // pathOpen reads the path from api.Memory:
1550
+ //
1551
+ // pathLen
1552
+ // +------------------------+
1553
+ // | |
1554
+ // []byte{ ?, 'w', 'a', 'z', 'e', 'r', 'o', ?... }
1555
+ // path --^
1556
+ //
1557
+ // Then, if parameters resultOpenedFD = 8, and this function opened a new file
1558
+ // descriptor 5 with the given flags, this function writes the below to
1559
+ // api.Memory:
1560
+ //
1561
+ // uint32le
1562
+ // +--------+
1563
+ // | |
1564
+ // []byte{ 0..6, ?, 5, 0, 0, 0, ?}
1565
+ // resultOpenedFD --^
1566
+ //
1567
+ // # Notes
1568
+ // - This is similar to `openat` in POSIX. https://linux.die.net/man/3/openat
1569
+ // - The returned file descriptor is not guaranteed to be the lowest-number
1570
+ //
1571
+ // See https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#path_open
1572
+ var pathOpen = newHostFunc(
1573
+ wasip1.PathOpenName, pathOpenFn,
1574
+ []wasm.ValueType{i32, i32, i32, i32, i32, i64, i64, i32, i32},
1575
+ "fd", "dirflags", "path", "path_len", "oflags", "fs_rights_base", "fs_rights_inheriting", "fdflags", "result.opened_fd",
1576
+ )
1577
+
1578
+ func pathOpenFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1579
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1580
+
1581
+ preopenFD := int32(params[0])
1582
+
1583
+ // TODO: dirflags is a lookupflags, and it only has one bit: symlink_follow
1584
+ // https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#lookupflags
1585
+ dirflags := uint16(params[1])
1586
+
1587
+ path := uint32(params[2])
1588
+ pathLen := uint32(params[3])
1589
+
1590
+ oflags := uint16(params[4])
1591
+
1592
+ rights := uint32(params[5])
1593
+ // inherited rights aren't used
1594
+ _ = params[6]
1595
+
1596
+ fdflags := uint16(params[7])
1597
+ resultOpenedFD := uint32(params[8])
1598
+
1599
+ preopen, pathName, errno := atPath(fsc, mod.Memory(), preopenFD, path, pathLen)
1600
+ if errno != 0 {
1601
+ return errno
1602
+ }
1603
+
1604
+ if pathLen == 0 {
1605
+ return experimentalsys.EINVAL
1606
+ }
1607
+
1608
+ fileOpenFlags := openFlags(dirflags, oflags, fdflags, rights)
1609
+ isDir := fileOpenFlags&experimentalsys.O_DIRECTORY != 0
1610
+
1611
+ if isDir && oflags&wasip1.O_CREAT != 0 {
1612
+ return experimentalsys.EINVAL // use pathCreateDirectory!
1613
+ }
1614
+
1615
+ newFD, errno := fsc.OpenFile(preopen, pathName, fileOpenFlags, 0o600)
1616
+ if errno != 0 {
1617
+ return errno
1618
+ }
1619
+
1620
+ // Check any flags that require the file to evaluate.
1621
+ if isDir {
1622
+ if f, ok := fsc.LookupFile(newFD); !ok {
1623
+ return experimentalsys.EBADF // unexpected
1624
+ } else if isDir, errno := f.File.IsDir(); errno != 0 {
1625
+ _ = fsc.CloseFile(newFD)
1626
+ return errno
1627
+ } else if !isDir {
1628
+ _ = fsc.CloseFile(newFD)
1629
+ return experimentalsys.ENOTDIR
1630
+ }
1631
+ }
1632
+
1633
+ if !mod.Memory().WriteUint32Le(resultOpenedFD, uint32(newFD)) {
1634
+ _ = fsc.CloseFile(newFD)
1635
+ return experimentalsys.EFAULT
1636
+ }
1637
+ return 0
1638
+ }
1639
+
1640
+ // atPath returns the pre-open specific path after verifying it is a directory.
1641
+ //
1642
+ // # Notes
1643
+ //
1644
+ // Languages including Zig and Rust use only pre-opens for the FD because
1645
+ // wasi-libc `__wasilibc_find_relpath` will only return a preopen. That said,
1646
+ // our wasi.c example shows other languages act differently and can use a non
1647
+ // pre-opened file descriptor.
1648
+ //
1649
+ // We don't handle `AT_FDCWD`, as that's resolved in the compiler. There's no
1650
+ // working directory function in WASI, so most assume CWD is "/". Notably, Zig
1651
+ // has different behavior which assumes it is whatever the first pre-open name
1652
+ // is.
1653
+ //
1654
+ // See https://github.com/WebAssembly/wasi-libc/blob/659ff414560721b1660a19685110e484a081c3d4/libc-bottom-half/sources/at_fdcwd.c
1655
+ // See https://linux.die.net/man/2/openat
1656
+ func atPath(fsc *sys.FSContext, mem api.Memory, fd int32, p, pathLen uint32) (experimentalsys.FS, string, experimentalsys.Errno) {
1657
+ b, ok := mem.Read(p, pathLen)
1658
+ if !ok {
1659
+ return nil, "", experimentalsys.EFAULT
1660
+ }
1661
+ pathName := string(b)
1662
+
1663
+ // interesting_paths wants us to break on trailing slash if the input ends
1664
+ // up a file, not a directory!
1665
+ hasTrailingSlash := strings.HasSuffix(pathName, "/")
1666
+
1667
+ // interesting_paths includes paths that include relative links but end up
1668
+ // not escaping
1669
+ pathName = path.Clean(pathName)
1670
+
1671
+ // interesting_paths wants to break on root paths or anything that escapes.
1672
+ // This part is the same as fs.FS.Open()
1673
+ if !fs.ValidPath(pathName) {
1674
+ return nil, "", experimentalsys.EPERM
1675
+ }
1676
+
1677
+ // add the trailing slash back
1678
+ if hasTrailingSlash {
1679
+ pathName = pathName + "/"
1680
+ }
1681
+
1682
+ if f, ok := fsc.LookupFile(fd); !ok {
1683
+ return nil, "", experimentalsys.EBADF // closed or invalid
1684
+ } else if isDir, errno := f.File.IsDir(); errno != 0 {
1685
+ return nil, "", errno
1686
+ } else if !isDir {
1687
+ return nil, "", experimentalsys.ENOTDIR
1688
+ } else if f.IsPreopen { // don't append the pre-open name
1689
+ return f.FS, pathName, 0
1690
+ } else {
1691
+ // Join via concat to avoid name conflict on path.Join
1692
+ return f.FS, f.Name + "/" + pathName, 0
1693
+ }
1694
+ }
1695
+
1696
+ func preopenPath(fsc *sys.FSContext, fd int32) (string, experimentalsys.Errno) {
1697
+ if f, ok := fsc.LookupFile(fd); !ok {
1698
+ return "", experimentalsys.EBADF // closed
1699
+ } else if !f.IsPreopen {
1700
+ return "", experimentalsys.EBADF
1701
+ } else if isDir, errno := f.File.IsDir(); errno != 0 || !isDir {
1702
+ // In wasip1, only directories can be returned by fd_prestat_get as
1703
+ // there are no prestat types defined for files or sockets.
1704
+ return "", errno
1705
+ } else {
1706
+ return f.Name, 0
1707
+ }
1708
+ }
1709
+
1710
+ func openFlags(dirflags, oflags, fdflags uint16, rights uint32) (openFlags experimentalsys.Oflag) {
1711
+ if dirflags&wasip1.LOOKUP_SYMLINK_FOLLOW == 0 {
1712
+ openFlags |= experimentalsys.O_NOFOLLOW
1713
+ }
1714
+ if oflags&wasip1.O_DIRECTORY != 0 {
1715
+ openFlags |= experimentalsys.O_DIRECTORY
1716
+ } else if oflags&wasip1.O_EXCL != 0 {
1717
+ openFlags |= experimentalsys.O_EXCL
1718
+ }
1719
+ // Because we don't implement rights, we partially rely on the open flags
1720
+ // to determine the mode in which the file will be opened. This will create
1721
+ // divergent behavior compared to WASI runtimes which have a more strict
1722
+ // interpretation of the WASI capabilities model; for example, a program
1723
+ // which sets O_CREAT but does not give read or write permissions will
1724
+ // successfully create a file when running with wazero, but might get a
1725
+ // permission denied error on other runtimes.
1726
+ defaultMode := experimentalsys.O_RDONLY
1727
+ if oflags&wasip1.O_TRUNC != 0 {
1728
+ openFlags |= experimentalsys.O_TRUNC
1729
+ defaultMode = experimentalsys.O_RDWR
1730
+ }
1731
+ if oflags&wasip1.O_CREAT != 0 {
1732
+ openFlags |= experimentalsys.O_CREAT
1733
+ defaultMode = experimentalsys.O_RDWR
1734
+ }
1735
+ if fdflags&wasip1.FD_NONBLOCK != 0 {
1736
+ openFlags |= experimentalsys.O_NONBLOCK
1737
+ }
1738
+ if fdflags&wasip1.FD_APPEND != 0 {
1739
+ openFlags |= experimentalsys.O_APPEND
1740
+ defaultMode = experimentalsys.O_RDWR
1741
+ }
1742
+ if fdflags&wasip1.FD_DSYNC != 0 {
1743
+ openFlags |= experimentalsys.O_DSYNC
1744
+ }
1745
+ if fdflags&wasip1.FD_RSYNC != 0 {
1746
+ openFlags |= experimentalsys.O_RSYNC
1747
+ }
1748
+ if fdflags&wasip1.FD_SYNC != 0 {
1749
+ openFlags |= experimentalsys.O_SYNC
1750
+ }
1751
+
1752
+ // Since rights were discontinued in wasi, we only interpret RIGHT_FD_WRITE
1753
+ // because it is the only way to know that we need to set write permissions
1754
+ // on a file if the application did not pass any of O_CREAT, O_APPEND, nor
1755
+ // O_TRUNC.
1756
+ const r = wasip1.RIGHT_FD_READ
1757
+ const w = wasip1.RIGHT_FD_WRITE
1758
+ const rw = r | w
1759
+ switch {
1760
+ case (rights & rw) == rw:
1761
+ openFlags |= experimentalsys.O_RDWR
1762
+ case (rights & w) == w:
1763
+ openFlags |= experimentalsys.O_WRONLY
1764
+ case (rights & r) == r:
1765
+ openFlags |= experimentalsys.O_RDONLY
1766
+ default:
1767
+ openFlags |= defaultMode
1768
+ }
1769
+ return
1770
+ }
1771
+
1772
+ // pathReadlink is the WASI function named PathReadlinkName that reads the
1773
+ // contents of a symbolic link.
1774
+ //
1775
+ // See: https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-path_readlinkfd-fd-path-string-buf-pointeru8-buf_len-size---errno-size
1776
+ var pathReadlink = newHostFunc(
1777
+ wasip1.PathReadlinkName, pathReadlinkFn,
1778
+ []wasm.ValueType{i32, i32, i32, i32, i32, i32},
1779
+ "fd", "path", "path_len", "buf", "buf_len", "result.bufused",
1780
+ )
1781
+
1782
+ func pathReadlinkFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1783
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1784
+
1785
+ fd := int32(params[0])
1786
+ path := uint32(params[1])
1787
+ pathLen := uint32(params[2])
1788
+ buf := uint32(params[3])
1789
+ bufLen := uint32(params[4])
1790
+ resultBufused := uint32(params[5])
1791
+
1792
+ if pathLen == 0 || bufLen == 0 {
1793
+ return experimentalsys.EINVAL
1794
+ }
1795
+
1796
+ mem := mod.Memory()
1797
+ preopen, p, errno := atPath(fsc, mem, fd, path, pathLen)
1798
+ if errno != 0 {
1799
+ return errno
1800
+ }
1801
+
1802
+ dst, errno := preopen.Readlink(p)
1803
+ if errno != 0 {
1804
+ return errno
1805
+ }
1806
+
1807
+ if len(dst) > int(bufLen) {
1808
+ return experimentalsys.ERANGE
1809
+ }
1810
+
1811
+ if ok := mem.WriteString(buf, dst); !ok {
1812
+ return experimentalsys.EFAULT
1813
+ }
1814
+
1815
+ if !mem.WriteUint32Le(resultBufused, uint32(len(dst))) {
1816
+ return experimentalsys.EFAULT
1817
+ }
1818
+ return 0
1819
+ }
1820
+
1821
+ // pathRemoveDirectory is the WASI function named PathRemoveDirectoryName which
1822
+ // removes a directory.
1823
+ //
1824
+ // # Parameters
1825
+ //
1826
+ // - fd: file descriptor of a directory that `path` is relative to
1827
+ // - path: offset in api.Memory to read the path string from
1828
+ // - pathLen: length of `path`
1829
+ //
1830
+ // # Result (Errno)
1831
+ //
1832
+ // The return value is 0 except the following error conditions:
1833
+ // - sys.EBADF: `fd` is invalid
1834
+ // - sys.ENOENT: `path` does not exist.
1835
+ // - sys.ENOTEMPTY: `path` is not empty
1836
+ // - sys.ENOTDIR: `path` is a file
1837
+ //
1838
+ // # Notes
1839
+ // - This is similar to unlinkat with AT_REMOVEDIR in POSIX.
1840
+ // See https://linux.die.net/man/2/unlinkat
1841
+ //
1842
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-path_remove_directoryfd-fd-path-string---errno
1843
+ var pathRemoveDirectory = newHostFunc(
1844
+ wasip1.PathRemoveDirectoryName, pathRemoveDirectoryFn,
1845
+ []wasm.ValueType{i32, i32, i32},
1846
+ "fd", "path", "path_len",
1847
+ )
1848
+
1849
+ func pathRemoveDirectoryFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1850
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1851
+
1852
+ fd := int32(params[0])
1853
+ path := uint32(params[1])
1854
+ pathLen := uint32(params[2])
1855
+
1856
+ preopen, pathName, errno := atPath(fsc, mod.Memory(), fd, path, pathLen)
1857
+ if errno != 0 {
1858
+ return errno
1859
+ }
1860
+
1861
+ return preopen.Rmdir(pathName)
1862
+ }
1863
+
1864
+ // pathRename is the WASI function named PathRenameName which renames a file or
1865
+ // directory.
1866
+ //
1867
+ // # Parameters
1868
+ //
1869
+ // - fd: file descriptor of a directory that `old_path` is relative to
1870
+ // - old_path: offset in api.Memory to read the old path string from
1871
+ // - old_path_len: length of `old_path`
1872
+ // - new_fd: file descriptor of a directory that `new_path` is relative to
1873
+ // - new_path: offset in api.Memory to read the new path string from
1874
+ // - new_path_len: length of `new_path`
1875
+ //
1876
+ // # Result (Errno)
1877
+ //
1878
+ // The return value is 0 except the following error conditions:
1879
+ // - sys.EBADF: `fd` or `new_fd` are invalid
1880
+ // - sys.ENOENT: `old_path` does not exist.
1881
+ // - sys.ENOTDIR: `old` is a directory and `new` exists, but is a file.
1882
+ // - sys.EISDIR: `old` is a file and `new` exists, but is a directory.
1883
+ //
1884
+ // # Notes
1885
+ // - This is similar to unlinkat in POSIX.
1886
+ // See https://linux.die.net/man/2/renameat
1887
+ //
1888
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-path_renamefd-fd-old_path-string-new_fd-fd-new_path-string---errno
1889
+ var pathRename = newHostFunc(
1890
+ wasip1.PathRenameName, pathRenameFn,
1891
+ []wasm.ValueType{i32, i32, i32, i32, i32, i32},
1892
+ "fd", "old_path", "old_path_len", "new_fd", "new_path", "new_path_len",
1893
+ )
1894
+
1895
+ func pathRenameFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1896
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1897
+
1898
+ fd := int32(params[0])
1899
+ oldPath := uint32(params[1])
1900
+ oldPathLen := uint32(params[2])
1901
+
1902
+ newFD := int32(params[3])
1903
+ newPath := uint32(params[4])
1904
+ newPathLen := uint32(params[5])
1905
+
1906
+ oldFS, oldPathName, errno := atPath(fsc, mod.Memory(), fd, oldPath, oldPathLen)
1907
+ if errno != 0 {
1908
+ return errno
1909
+ }
1910
+
1911
+ newFS, newPathName, errno := atPath(fsc, mod.Memory(), newFD, newPath, newPathLen)
1912
+ if errno != 0 {
1913
+ return errno
1914
+ }
1915
+
1916
+ if oldFS != newFS { // TODO: handle renames across filesystems
1917
+ return experimentalsys.ENOSYS
1918
+ }
1919
+
1920
+ return oldFS.Rename(oldPathName, newPathName)
1921
+ }
1922
+
1923
+ // pathSymlink is the WASI function named PathSymlinkName which creates a
1924
+ // symbolic link.
1925
+ //
1926
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#path_symlink
1927
+ var pathSymlink = newHostFunc(
1928
+ wasip1.PathSymlinkName, pathSymlinkFn,
1929
+ []wasm.ValueType{i32, i32, i32, i32, i32},
1930
+ "old_path", "old_path_len", "fd", "new_path", "new_path_len",
1931
+ )
1932
+
1933
+ func pathSymlinkFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
1934
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
1935
+
1936
+ oldPath := uint32(params[0])
1937
+ oldPathLen := uint32(params[1])
1938
+ fd := int32(params[2])
1939
+ newPath := uint32(params[3])
1940
+ newPathLen := uint32(params[4])
1941
+
1942
+ mem := mod.Memory()
1943
+
1944
+ dir, ok := fsc.LookupFile(fd)
1945
+ if !ok {
1946
+ return experimentalsys.EBADF // closed
1947
+ } else if isDir, errno := dir.File.IsDir(); errno != 0 {
1948
+ return errno
1949
+ } else if !isDir {
1950
+ return experimentalsys.ENOTDIR
1951
+ }
1952
+
1953
+ if oldPathLen == 0 || newPathLen == 0 {
1954
+ return experimentalsys.EINVAL
1955
+ }
1956
+
1957
+ oldPathBuf, ok := mem.Read(oldPath, oldPathLen)
1958
+ if !ok {
1959
+ return experimentalsys.EFAULT
1960
+ }
1961
+
1962
+ _, newPathName, errno := atPath(fsc, mod.Memory(), fd, newPath, newPathLen)
1963
+ if errno != 0 {
1964
+ return errno
1965
+ }
1966
+
1967
+ return dir.FS.Symlink(
1968
+ // Do not join old path since it's only resolved when dereference the link created here.
1969
+ // And the dereference result depends on the opening directory's file descriptor at that point.
1970
+ unsafe.String(&oldPathBuf[0], int(oldPathLen)),
1971
+ newPathName,
1972
+ )
1973
+ }
1974
+
1975
+ // pathUnlinkFile is the WASI function named PathUnlinkFileName which unlinks a
1976
+ // file.
1977
+ //
1978
+ // # Parameters
1979
+ //
1980
+ // - fd: file descriptor of a directory that `path` is relative to
1981
+ // - path: offset in api.Memory to read the path string from
1982
+ // - pathLen: length of `path`
1983
+ //
1984
+ // # Result (Errno)
1985
+ //
1986
+ // The return value is 0 except the following error conditions:
1987
+ // - sys.EBADF: `fd` is invalid
1988
+ // - sys.ENOENT: `path` does not exist.
1989
+ // - sys.EISDIR: `path` is a directory
1990
+ //
1991
+ // # Notes
1992
+ // - This is similar to unlinkat without AT_REMOVEDIR in POSIX.
1993
+ // See https://linux.die.net/man/2/unlinkat
1994
+ //
1995
+ // See https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-path_unlink_filefd-fd-path-string---errno
1996
+ var pathUnlinkFile = newHostFunc(
1997
+ wasip1.PathUnlinkFileName, pathUnlinkFileFn,
1998
+ []wasm.ValueType{i32, i32, i32},
1999
+ "fd", "path", "path_len",
2000
+ )
2001
+
2002
+ func pathUnlinkFileFn(_ context.Context, mod api.Module, params []uint64) experimentalsys.Errno {
2003
+ fsc := mod.(*wasm.ModuleInstance).Sys.FS()
2004
+
2005
+ fd := int32(params[0])
2006
+ path := uint32(params[1])
2007
+ pathLen := uint32(params[2])
2008
+
2009
+ preopen, pathName, errno := atPath(fsc, mod.Memory(), fd, path, pathLen)
2010
+ if errno != 0 {
2011
+ return errno
2012
+ }
2013
+
2014
+ return preopen.Unlink(pathName)
2015
+ }