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.
- package/README.md +1 -1
- package/bin/cli.js +18 -8
- package/bin/go/overrides.js +21 -1
- package/bin/index.js +48 -25
- package/bin/main.js +2 -1
- package/bin/node/assert.js +56 -17
- package/bin/node/async_hooks.js +69 -10
- package/bin/node/buffer.js +321 -7
- package/bin/node/child_process.js +220 -16
- package/bin/node/cluster.js +436 -32
- package/bin/node/crypto.js +814 -5
- package/bin/node/crypto_curves.js +142 -0
- package/bin/node/crypto_keys.js +1147 -48
- package/bin/node/crypto_pem.js +313 -0
- package/bin/node/crypto_pkcs12.js +17 -0
- package/bin/node/dgram.js +161 -10
- package/bin/node/diagnostics_channel.js +5 -1
- package/bin/node/events.js +358 -8
- package/bin/node/ffi.js +933 -0
- package/bin/node/fs.js +1346 -10
- package/bin/node/histogram.js +1991 -0
- package/bin/node/http.js +630 -55
- package/bin/node/http2.js +1141 -88
- package/bin/node/intl.js +4576 -0
- package/bin/node/intl_data.js +65412 -0
- package/bin/node/module_v8.js +155 -16
- package/bin/node/net.js +59 -10
- package/bin/node/path.js +5 -1
- package/bin/node/process.js +355 -4
- package/bin/node/readline.js +558 -8
- package/bin/node/registry.js +2 -0
- package/bin/node/sqlite.js +1539 -7
- package/bin/node/stream.js +371 -32
- package/bin/node/stream_web.js +422 -15
- package/bin/node/system_extra.js +40 -154
- package/bin/node/temporal.js +96 -0
- package/bin/node/temporal_runtime.js +5075 -0
- package/bin/node/temporal_zones.js +460 -0
- package/bin/node/test.js +191 -8
- package/bin/node/test_coverage.js +58 -0
- package/bin/node/test_report.js +50 -4
- package/bin/node/test_run.js +64 -3
- package/bin/node/timers.js +123 -0
- package/bin/node/tls.js +346 -12
- package/bin/node/tls_roots.js +122 -0
- package/bin/node/typed_arrays.js +867 -93
- package/bin/node/url.js +657 -0
- package/bin/node/util.js +449 -7
- package/bin/node/util_extra.js +6 -0
- package/bin/node/wasi.js +214 -0
- package/bin/node/webassembly.js +1137 -0
- package/bin/node/websocket.js +763 -0
- package/bin/node/webview.js +3257 -244
- package/bin/node/worker_threads.js +434 -52
- package/bin/node/zlib.js +455 -22
- package/bin/node/zlib_iter.js +585 -0
- package/bin/node/zlib_zip.js +2392 -0
- package/bin/transpiler.js +3417 -501
- package/bin/typecheck-node.js +49 -17
- package/bin/version.js +1 -1
- package/govendor/github.com/cloudflare/circl/.golangci.yaml +64 -0
- package/govendor/github.com/cloudflare/circl/.semgrepignore +1 -0
- package/govendor/github.com/cloudflare/circl/AGENTS.md +91 -0
- package/govendor/github.com/cloudflare/circl/CITATION.cff +30 -0
- package/govendor/github.com/cloudflare/circl/LICENSE +57 -0
- package/govendor/github.com/cloudflare/circl/Makefile +70 -0
- package/govendor/github.com/cloudflare/circl/README.md +206 -0
- package/govendor/github.com/cloudflare/circl/REVIEW.md +83 -0
- package/govendor/github.com/cloudflare/circl/codecov.yml +21 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/curve.go +104 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.go +30 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.h +111 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.s +194 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/curve_generic.go +100 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/curve_noasm.go +11 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/doc.go +19 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/key.go +46 -0
- package/govendor/github.com/cloudflare/circl/dh/x448/table.go +460 -0
- package/govendor/github.com/cloudflare/circl/doc.go +8 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/constants.go +71 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/curve.go +90 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/isogeny.go +52 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/point.go +181 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/scalar.go +203 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist.go +138 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistPoint.go +135 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistTables.go +216 -0
- package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist_basemult.go +62 -0
- package/govendor/github.com/cloudflare/circl/go.mod +3 -0
- package/govendor/github.com/cloudflare/circl/internal/conv/conv.go +173 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/doc.go +62 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/hashes.go +69 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/keccakf.go +391 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/rc.go +29 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/sha3.go +200 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/sha3_s390x.s +33 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/shake.go +119 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/xor.go +15 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/xor_generic.go +33 -0
- package/govendor/github.com/cloudflare/circl/internal/sha3/xor_unaligned.go +61 -0
- package/govendor/github.com/cloudflare/circl/math/fp448/fp.go +164 -0
- package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.go +43 -0
- package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.h +591 -0
- package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.s +75 -0
- package/govendor/github.com/cloudflare/circl/math/fp448/fp_generic.go +339 -0
- package/govendor/github.com/cloudflare/circl/math/fp448/fp_noasm.go +12 -0
- package/govendor/github.com/cloudflare/circl/math/fp448/fuzzer.go +75 -0
- package/govendor/github.com/cloudflare/circl/math/integer.go +16 -0
- package/govendor/github.com/cloudflare/circl/math/mlsbset/mlsbset.go +145 -0
- package/govendor/github.com/cloudflare/circl/math/mlsbset/power.go +64 -0
- package/govendor/github.com/cloudflare/circl/math/primes.go +34 -0
- package/govendor/github.com/cloudflare/circl/math/wnaf.go +84 -0
- package/govendor/github.com/cloudflare/circl/sign/ed448/ed448.go +417 -0
- package/govendor/github.com/cloudflare/circl/sign/ed448/signapi.go +89 -0
- package/govendor/github.com/cloudflare/circl/sign/sign.go +119 -0
- package/{examples/react-compiler/vendor/picocolors → govendor/github.com/decred/dcrd/dcrec/secp256k1/v4}/LICENSE +4 -2
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/README.md +72 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/compressedbytepoints.go +18 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve.go +1310 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_embedded.go +14 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_precompute.go +14 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/doc.go +59 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdh.go +21 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/README.md +52 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/doc.go +42 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/error.go +134 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/signature.go +1001 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ellipticadaptor.go +296 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/error.go +67 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/field.go +1696 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/go.mod +3 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/loadprecomputed.go +91 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/modnscalar.go +1105 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/nonce.go +263 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/privkey.go +111 -0
- package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/pubkey.go +236 -0
- package/govendor/github.com/ebitengine/purego/LICENSE +201 -0
- package/govendor/github.com/ebitengine/purego/README.md +124 -0
- package/govendor/github.com/ebitengine/purego/abi_amd64.h +99 -0
- package/govendor/github.com/ebitengine/purego/abi_arm64.h +39 -0
- package/govendor/github.com/ebitengine/purego/abi_loong64.h +60 -0
- package/govendor/github.com/ebitengine/purego/cdecl.go +11 -0
- package/govendor/github.com/ebitengine/purego/cgo.go +19 -0
- package/govendor/github.com/ebitengine/purego/dlerror.go +17 -0
- package/govendor/github.com/ebitengine/purego/dlfcn.go +99 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_android.go +34 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_darwin.go +20 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_freebsd.go +14 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_linux.go +16 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_netbsd.go +15 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.go +11 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.go +19 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_netbsd.go +11 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_playground.go +24 -0
- package/govendor/github.com/ebitengine/purego/dlfcn_stubs.s +22 -0
- package/govendor/github.com/ebitengine/purego/func.go +780 -0
- package/govendor/github.com/ebitengine/purego/gen.go +6 -0
- package/govendor/github.com/ebitengine/purego/go.mod +3 -0
- package/govendor/github.com/ebitengine/purego/go_runtime.go +19 -0
- package/govendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +56 -0
- package/govendor/github.com/ebitengine/purego/internal/cgo/empty.go +6 -0
- package/govendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +49 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h +99 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h +39 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_loong64.h +60 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_ppc64x.h +195 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_riscv64.h +72 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_386.s +29 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s +39 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm.s +58 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s +35 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_loong64.s +38 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_ppc64le.s +79 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_riscv64.s +36 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_s390x.s +52 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +93 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +32 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/fakecgo.go +14 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go +27 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin.go +86 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd.go +77 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +72 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_linux.go +77 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_netbsd.go +83 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +18 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +38 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +19 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +37 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +37 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +27 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +27 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_netbsd.go +36 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/linux.go +189 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/netbsd.go +23 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +19 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_amd64.go +15 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_noasm.go +24 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_386.s +130 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s +124 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm.s +131 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s +81 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_386.s +78 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_amd64.s +69 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm.s +69 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm64.s +60 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_loong64.s +60 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_ppc64le.s +69 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_riscv64.s +60 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_s390x.s +51 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_loong64.s +78 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_ppc64le.s +132 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_riscv64.s +76 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_s390x.s +158 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols.go +165 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_darwin.go +59 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_freebsd.go +48 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_linux.go +158 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_netbsd.go +59 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_darwin.s +19 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_freebsd.s +16 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_linux.s +46 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_netbsd.s +19 -0
- package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_stubs.s +55 -0
- package/govendor/github.com/ebitengine/purego/internal/strings/strings.go +40 -0
- package/govendor/github.com/ebitengine/purego/is_ios.go +13 -0
- package/govendor/github.com/ebitengine/purego/nocgo.go +25 -0
- package/govendor/github.com/ebitengine/purego/struct_amd64.go +518 -0
- package/govendor/github.com/ebitengine/purego/struct_arm.go +100 -0
- package/govendor/github.com/ebitengine/purego/struct_arm64.go +757 -0
- package/govendor/github.com/ebitengine/purego/struct_loong64.go +244 -0
- package/govendor/github.com/ebitengine/purego/struct_other.go +54 -0
- package/govendor/github.com/ebitengine/purego/struct_ppc64le.go +180 -0
- package/govendor/github.com/ebitengine/purego/struct_riscv64.go +158 -0
- package/govendor/github.com/ebitengine/purego/struct_s390x.go +158 -0
- package/govendor/github.com/ebitengine/purego/sys_386.s +153 -0
- package/govendor/github.com/ebitengine/purego/sys_amd64.s +206 -0
- package/govendor/github.com/ebitengine/purego/sys_arm.s +153 -0
- package/govendor/github.com/ebitengine/purego/sys_arm64.s +133 -0
- package/govendor/github.com/ebitengine/purego/sys_loong64.s +131 -0
- package/govendor/github.com/ebitengine/purego/sys_ppc64le.s +126 -0
- package/govendor/github.com/ebitengine/purego/sys_riscv64.s +135 -0
- package/govendor/github.com/ebitengine/purego/sys_s390x.s +148 -0
- package/govendor/github.com/ebitengine/purego/sys_unix_386.s +234 -0
- package/govendor/github.com/ebitengine/purego/sys_unix_arm.s +99 -0
- package/govendor/github.com/ebitengine/purego/sys_unix_arm64.s +75 -0
- package/govendor/github.com/ebitengine/purego/sys_unix_loong64.s +79 -0
- package/govendor/github.com/ebitengine/purego/sys_unix_ppc64le.s +114 -0
- package/govendor/github.com/ebitengine/purego/sys_unix_riscv64.s +79 -0
- package/govendor/github.com/ebitengine/purego/sys_unix_s390x.s +111 -0
- package/govendor/github.com/ebitengine/purego/syscall.go +95 -0
- package/govendor/github.com/ebitengine/purego/syscall_32bit.go +97 -0
- package/govendor/github.com/ebitengine/purego/syscall_cgo_linux.go +20 -0
- package/govendor/github.com/ebitengine/purego/syscall_notstackargs.go +55 -0
- package/govendor/github.com/ebitengine/purego/syscall_ppc64le.go +73 -0
- package/govendor/github.com/ebitengine/purego/syscall_stackargs_ppc64le.go +38 -0
- package/govendor/github.com/ebitengine/purego/syscall_stackargs_s390x.go +38 -0
- package/govendor/github.com/ebitengine/purego/syscall_unix.go +392 -0
- package/govendor/github.com/ebitengine/purego/syscall_windows.go +54 -0
- package/govendor/github.com/ebitengine/purego/zcallback_386.s +4014 -0
- package/govendor/github.com/ebitengine/purego/zcallback_amd64.s +2014 -0
- package/govendor/github.com/ebitengine/purego/zcallback_arm.s +4014 -0
- package/govendor/github.com/ebitengine/purego/zcallback_arm64.s +4014 -0
- package/govendor/github.com/ebitengine/purego/zcallback_loong64.s +4014 -0
- package/govendor/github.com/ebitengine/purego/zcallback_ppc64le.s +4014 -0
- package/govendor/github.com/ebitengine/purego/zcallback_riscv64.s +4051 -0
- package/govendor/github.com/ebitengine/purego/zcallback_s390x.s +4015 -0
- package/govendor/github.com/klauspost/compress/.gitattributes +3 -0
- package/govendor/github.com/klauspost/compress/.goreleaser.yml +132 -0
- package/govendor/github.com/klauspost/compress/AGENTS.md +106 -0
- package/govendor/github.com/klauspost/compress/LICENSE +304 -0
- package/govendor/github.com/klauspost/compress/README.md +766 -0
- package/govendor/github.com/klauspost/compress/SECURITY.md +25 -0
- package/govendor/github.com/klauspost/compress/compressible.go +85 -0
- package/govendor/github.com/klauspost/compress/fse/README.md +79 -0
- package/govendor/github.com/klauspost/compress/fse/bitreader.go +122 -0
- package/govendor/github.com/klauspost/compress/fse/bitwriter.go +167 -0
- package/govendor/github.com/klauspost/compress/fse/bytereader.go +47 -0
- package/govendor/github.com/klauspost/compress/fse/compress.go +685 -0
- package/govendor/github.com/klauspost/compress/fse/decompress.go +383 -0
- package/govendor/github.com/klauspost/compress/fse/fse.go +150 -0
- package/govendor/github.com/klauspost/compress/gen.sh +4 -0
- package/govendor/github.com/klauspost/compress/go.mod +3 -0
- package/govendor/github.com/klauspost/compress/huff0/README.md +89 -0
- package/govendor/github.com/klauspost/compress/huff0/bitreader.go +323 -0
- package/govendor/github.com/klauspost/compress/huff0/bitwriter.go +97 -0
- package/govendor/github.com/klauspost/compress/huff0/build_table.go +168 -0
- package/govendor/github.com/klauspost/compress/huff0/compress.go +747 -0
- package/govendor/github.com/klauspost/compress/huff0/decompress.go +1188 -0
- package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.go +128 -0
- package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.s +3476 -0
- package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.go +72 -0
- package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.s +1648 -0
- package/govendor/github.com/klauspost/compress/huff0/decompress_asm.go +252 -0
- package/govendor/github.com/klauspost/compress/huff0/decompress_generic.go +278 -0
- package/govendor/github.com/klauspost/compress/huff0/huff0.go +337 -0
- package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo.go +34 -0
- package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.go +10 -0
- package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.s +34 -0
- package/govendor/github.com/klauspost/compress/internal/le/le.go +5 -0
- package/govendor/github.com/klauspost/compress/internal/le/unsafe_disabled.go +42 -0
- package/govendor/github.com/klauspost/compress/internal/le/unsafe_enabled.go +52 -0
- package/govendor/github.com/klauspost/compress/internal/regmask/regmask.go +50 -0
- package/govendor/github.com/klauspost/compress/internal/regmask/regmask_386.go +39 -0
- package/govendor/github.com/klauspost/compress/internal/snapref/LICENSE +27 -0
- package/govendor/github.com/klauspost/compress/internal/snapref/decode.go +264 -0
- package/govendor/github.com/klauspost/compress/internal/snapref/decode_other.go +113 -0
- package/govendor/github.com/klauspost/compress/internal/snapref/encode.go +291 -0
- package/govendor/github.com/klauspost/compress/internal/snapref/encode_other.go +250 -0
- package/govendor/github.com/klauspost/compress/internal/snapref/snappy.go +98 -0
- package/govendor/github.com/klauspost/compress/s2sx.mod +3 -0
- package/govendor/github.com/klauspost/compress/s2sx.sum +0 -0
- package/govendor/github.com/klauspost/compress/zstd/README.md +487 -0
- package/govendor/github.com/klauspost/compress/zstd/bitreader.go +176 -0
- package/govendor/github.com/klauspost/compress/zstd/bitwriter.go +151 -0
- package/govendor/github.com/klauspost/compress/zstd/blockdec.go +728 -0
- package/govendor/github.com/klauspost/compress/zstd/blockenc.go +923 -0
- package/govendor/github.com/klauspost/compress/zstd/blocktype_string.go +85 -0
- package/govendor/github.com/klauspost/compress/zstd/bytebuf.go +131 -0
- package/govendor/github.com/klauspost/compress/zstd/bytereader.go +82 -0
- package/govendor/github.com/klauspost/compress/zstd/decodeheader.go +261 -0
- package/govendor/github.com/klauspost/compress/zstd/decoder.go +995 -0
- package/govendor/github.com/klauspost/compress/zstd/decoder_options.go +213 -0
- package/govendor/github.com/klauspost/compress/zstd/dict.go +605 -0
- package/govendor/github.com/klauspost/compress/zstd/enc_base.go +200 -0
- package/govendor/github.com/klauspost/compress/zstd/enc_best.go +572 -0
- package/govendor/github.com/klauspost/compress/zstd/enc_better.go +1262 -0
- package/govendor/github.com/klauspost/compress/zstd/enc_dfast.go +1136 -0
- package/govendor/github.com/klauspost/compress/zstd/enc_fast.go +892 -0
- package/govendor/github.com/klauspost/compress/zstd/enc_jobs.go +352 -0
- package/govendor/github.com/klauspost/compress/zstd/encoder.go +881 -0
- package/govendor/github.com/klauspost/compress/zstd/encoder_options.go +422 -0
- package/govendor/github.com/klauspost/compress/zstd/framedec.go +404 -0
- package/govendor/github.com/klauspost/compress/zstd/frameenc.go +137 -0
- package/govendor/github.com/klauspost/compress/zstd/fse_decoder.go +333 -0
- package/govendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s +132 -0
- package/govendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s +148 -0
- package/govendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go +70 -0
- package/govendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go +71 -0
- package/govendor/github.com/klauspost/compress/zstd/fse_encoder.go +701 -0
- package/govendor/github.com/klauspost/compress/zstd/fse_predefined.go +168 -0
- package/govendor/github.com/klauspost/compress/zstd/hash.go +57 -0
- package/govendor/github.com/klauspost/compress/zstd/history.go +119 -0
- package/{examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt → govendor/github.com/klauspost/compress/zstd/internal/xxhash/LICENSE.txt} +3 -1
- package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/README.md +71 -0
- package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash.go +242 -0
- package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_amd64.s +210 -0
- package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s +184 -0
- package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_asm.go +11 -0
- package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_other.go +75 -0
- package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_safe.go +11 -0
- package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.go +15 -0
- package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.s +66 -0
- package/govendor/github.com/klauspost/compress/zstd/matchlen_generic.go +37 -0
- package/govendor/github.com/klauspost/compress/zstd/seqdec.go +620 -0
- package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.go +115 -0
- package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.s +4762 -0
- package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.go +81 -0
- package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.s +2919 -0
- package/govendor/github.com/klauspost/compress/zstd/seqdec_asm.go +327 -0
- package/govendor/github.com/klauspost/compress/zstd/seqdec_generic.go +258 -0
- package/govendor/github.com/klauspost/compress/zstd/seqenc.go +159 -0
- package/govendor/github.com/klauspost/compress/zstd/simple.go +54 -0
- package/govendor/github.com/klauspost/compress/zstd/snappy.go +447 -0
- package/govendor/github.com/klauspost/compress/zstd/zip.go +141 -0
- package/govendor/github.com/klauspost/compress/zstd/zstd.go +126 -0
- package/govendor/github.com/tetratelabs/wazero/.editorconfig +7 -0
- package/govendor/github.com/tetratelabs/wazero/.gitattributes +2 -0
- package/govendor/github.com/tetratelabs/wazero/.gitmodules +3 -0
- package/govendor/github.com/tetratelabs/wazero/CONTRIBUTING.md +75 -0
- package/govendor/github.com/tetratelabs/wazero/LICENSE +201 -0
- package/govendor/github.com/tetratelabs/wazero/Makefile +385 -0
- package/govendor/github.com/tetratelabs/wazero/NOTICE +2 -0
- package/govendor/github.com/tetratelabs/wazero/RATIONALE.md +1577 -0
- package/govendor/github.com/tetratelabs/wazero/README.md +135 -0
- package/govendor/github.com/tetratelabs/wazero/api/features.go +228 -0
- package/govendor/github.com/tetratelabs/wazero/api/wasm.go +766 -0
- package/govendor/github.com/tetratelabs/wazero/builder.go +367 -0
- package/govendor/github.com/tetratelabs/wazero/cache.go +123 -0
- package/govendor/github.com/tetratelabs/wazero/codecov.yml +9 -0
- package/govendor/github.com/tetratelabs/wazero/config.go +899 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/checkpoint.go +35 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/close.go +63 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/compilationworkers.go +19 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/experimental.go +41 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/features.go +39 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/importresolver.go +19 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/listener.go +324 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/memory.go +52 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/dir.go +92 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/errno.go +98 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/error.go +45 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/file.go +356 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/fs.go +292 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/oflag.go +70 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/poll.go +48 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno.go +106 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_notwindows.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_unsupported.go +7 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_windows.go +37 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/time.go +10 -0
- package/govendor/github.com/tetratelabs/wazero/experimental/sys/unimplemented.go +160 -0
- package/govendor/github.com/tetratelabs/wazero/fsconfig.go +213 -0
- package/govendor/github.com/tetratelabs/wazero/go.mod +3 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/args.go +97 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/clock.go +116 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/environ.go +100 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go +2015 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go +247 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/proc.go +44 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/random.go +55 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sched.go +22 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go +188 -0
- package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/wasi.go +314 -0
- package/govendor/github.com/tetratelabs/wazero/internal/descriptor/table.go +149 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/compiler.go +3884 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/format.go +22 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go +4963 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/operations.go +2978 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/signature.go +825 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/abi.go +170 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/backend.go +3 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler.go +402 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler_lower.go +226 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/go_call.go +33 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi.go +186 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.go +9 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.s +29 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_preamble.go +248 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_go_call.go +440 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/cond.go +168 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/ext.go +35 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr.go +2495 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr_encoding.go +1714 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_constant.go +71 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_mem.go +187 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go +3782 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_pro_epi_logue.go +334 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go +352 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_vec.go +992 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/operands.go +336 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/reg.go +181 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/stack.go +130 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi.go +376 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.go +9 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.s +29 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_preamble.go +233 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go +430 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/cond.go +215 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr.go +2562 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr_encoding.go +2357 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_constant.go +301 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr.go +2227 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr_operands.go +340 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_mem.go +451 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine.go +631 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_pro_epi_logue.go +486 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go +351 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go +128 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/reg.go +397 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/unwind_stack.go +84 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go +119 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/api.go +124 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/reg.go +123 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regalloc.go +1189 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regset.go +96 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/vdef.go +19 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/call_engine.go +884 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go +1008 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine_cache.go +347 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_amd64.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_arm64.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_other.go +15 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/frontend.go +663 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/lower.go +5045 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/misc.go +10 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/sort_id.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/hostmodule.go +88 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_amd64.go +30 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_arm64.go +32 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_other.go +29 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/memmove.go +11 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/module_engine.go +403 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block.go +381 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block_sort.go +32 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/builder.go +790 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/cmp.go +107 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/funcref.go +12 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/instructions.go +3024 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass.go +393 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_blk_layouts.go +334 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_cfg.go +313 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/signature.go +49 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/ssa.go +14 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/type.go +115 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/vs.go +114 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/debug_options.go +189 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/exitcode.go +150 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/offsetdata.go +248 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap.go +96 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_disabled.go +5 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_enabled.go +5 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/pool.go +215 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/ptr.go +15 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/queue.go +26 -0
- package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/resetmap.go +11 -0
- package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/checkpoint.go +10 -0
- package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/close.go +5 -0
- package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/compilationworkers.go +6 -0
- package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/expctxkeys.go +2 -0
- package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/importresolver.go +6 -0
- package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/listener.go +7 -0
- package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/memory.go +4 -0
- package/govendor/github.com/tetratelabs/wazero/internal/filecache/compilationcache.go +42 -0
- package/govendor/github.com/tetratelabs/wazero/internal/filecache/file_cache.go +76 -0
- package/govendor/github.com/tetratelabs/wazero/internal/ieee754/ieee754.go +29 -0
- package/govendor/github.com/tetratelabs/wazero/internal/internalapi/internal.go +9 -0
- package/govendor/github.com/tetratelabs/wazero/internal/leb128/leb128.go +285 -0
- package/govendor/github.com/tetratelabs/wazero/internal/moremath/moremath.go +271 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid.go +26 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_amd64.go +22 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_arm64.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_unsupported.go +5 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/crypto.go +17 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go +72 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go +19 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go +14 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unsupported.go +22 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go +31 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/path.go +6 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/path_windows.go +17 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/platform.go +71 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/time.go +76 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/time_notwindows.go +11 -0
- package/govendor/github.com/tetratelabs/wazero/internal/platform/time_windows.go +40 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sock/sock.go +89 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_supported.go +11 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_unsupported.go +10 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sys/fs.go +458 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sys/lazy.go +135 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sys/stdio.go +125 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sys/sys.go +228 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go +105 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go +12 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go +14 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go +24 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go +137 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file.go +576 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go +39 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go +28 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_windows.go +133 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go +29 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go +42 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.s +8 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go +38 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go +18 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go +42 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unix.go +22 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unsupported.go +17 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_windows.go +28 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go +17 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unsupported.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go +23 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/oflag.go +38 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_bsd.go +26 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_darwin.go +26 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_supported.go +30 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unix.go +20 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unsupported.go +16 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go +163 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go +318 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll.go +17 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.go +55 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.s +8 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_linux.go +57 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_unsupported.go +12 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_windows.go +224 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go +117 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unix.go +16 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unsupported.go +16 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go +55 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go +186 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_supported.go +76 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go +48 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go +79 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go +80 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go +16 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_supported.go +40 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go +40 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go +118 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go +20 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go +13 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go +6 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unix.go +17 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unsupported.go +14 -0
- package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go +25 -0
- package/govendor/github.com/tetratelabs/wazero/internal/u32/u32.go +11 -0
- package/govendor/github.com/tetratelabs/wazero/internal/u64/u64.go +15 -0
- package/govendor/github.com/tetratelabs/wazero/internal/version/version.go +52 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/args.go +6 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/clock.go +16 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/environ.go +6 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go +314 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/fs.go +164 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/poll.go +15 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/proc.go +6 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/random.go +3 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/rights.go +148 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sched.go +3 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go +71 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasip1/wasi.go +26 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/code.go +124 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/const_expr.go +116 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/custom.go +22 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/data.go +79 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/decoder.go +235 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go +250 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/errors.go +11 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/export.go +32 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/function.go +56 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/global.go +50 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/header.go +9 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/import.go +68 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/limits.go +47 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/memory.go +42 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/names.go +151 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/section.go +309 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/table.go +79 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/value.go +97 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/const_expr.go +259 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/counts.go +53 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/engine.go +76 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/exception.go +9 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go +2804 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go +210 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/global.go +55 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/gofunc.go +279 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/host.go +179 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/instruction.go +1962 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory.go +475 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory_definition.go +128 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/module.go +1359 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go +251 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance_lookup.go +73 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/store.go +726 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go +95 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasm/table.go +321 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/debug.go +170 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go +225 -0
- package/govendor/github.com/tetratelabs/wazero/internal/wasmruntime/errors.go +54 -0
- package/govendor/github.com/tetratelabs/wazero/netlify.toml +15 -0
- package/govendor/github.com/tetratelabs/wazero/runtime.go +399 -0
- package/govendor/github.com/tetratelabs/wazero/sys/clock.go +26 -0
- package/govendor/github.com/tetratelabs/wazero/sys/error.go +83 -0
- package/govendor/github.com/tetratelabs/wazero/sys/stat.go +105 -0
- package/govendor/github.com/tetratelabs/wazero/sys/stat_bsd.go +29 -0
- package/govendor/github.com/tetratelabs/wazero/sys/stat_posix.go +29 -0
- package/govendor/github.com/tetratelabs/wazero/sys/stat_unsupported.go +14 -0
- package/govendor/github.com/tetratelabs/wazero/sys/stat_windows.go +24 -0
- package/govendor/golang.org/x/crypto/LICENSE +27 -0
- package/govendor/golang.org/x/crypto/PATENTS +22 -0
- package/govendor/golang.org/x/crypto/cryptobyte/asn1/asn1.go +46 -0
- package/govendor/golang.org/x/crypto/cryptobyte/asn1.go +825 -0
- package/govendor/golang.org/x/crypto/cryptobyte/builder.go +350 -0
- package/govendor/golang.org/x/crypto/cryptobyte/string.go +183 -0
- package/govendor/golang.org/x/crypto/go.mod +3 -0
- package/govendor/golang.org/x/crypto/pbkdf2/pbkdf2.go +30 -0
- package/govendor/golang.org/x/net/LICENSE +27 -0
- package/govendor/golang.org/x/net/PATENTS +22 -0
- package/govendor/golang.org/x/net/dns/dnsmessage/message.go +2733 -0
- package/govendor/golang.org/x/net/dns/dnsmessage/svcb.go +333 -0
- package/govendor/golang.org/x/net/go.mod +3 -0
- package/govendor/golang.org/x/net/http/httpguts/guts.go +50 -0
- package/govendor/golang.org/x/net/http/httpguts/httplex.go +347 -0
- package/govendor/golang.org/x/net/http2/README.md +19 -0
- package/govendor/golang.org/x/net/http2/ascii.go +65 -0
- package/govendor/golang.org/x/net/http2/ciphers.go +641 -0
- package/govendor/golang.org/x/net/http2/client_conn_pool.go +301 -0
- package/govendor/golang.org/x/net/http2/client_priority_go126.go +20 -0
- package/govendor/golang.org/x/net/http2/client_priority_go127.go +13 -0
- package/govendor/golang.org/x/net/http2/clientconn.go +57 -0
- package/govendor/golang.org/x/net/http2/config.go +171 -0
- package/govendor/golang.org/x/net/http2/config_go125.go +15 -0
- package/govendor/golang.org/x/net/http2/config_go126.go +15 -0
- package/govendor/golang.org/x/net/http2/databuffer.go +146 -0
- package/govendor/golang.org/x/net/http2/errors.go +145 -0
- package/govendor/golang.org/x/net/http2/flow.go +175 -0
- package/govendor/golang.org/x/net/http2/frame.go +1887 -0
- package/govendor/golang.org/x/net/http2/gotrack.go +181 -0
- package/govendor/golang.org/x/net/http2/hpack/encode.go +244 -0
- package/govendor/golang.org/x/net/http2/hpack/hpack.go +522 -0
- package/govendor/golang.org/x/net/http2/hpack/huffman.go +226 -0
- package/govendor/golang.org/x/net/http2/hpack/static_table.go +188 -0
- package/govendor/golang.org/x/net/http2/hpack/tables.go +426 -0
- package/govendor/golang.org/x/net/http2/http2.go +415 -0
- package/govendor/golang.org/x/net/http2/pipe.go +184 -0
- package/govendor/golang.org/x/net/http2/server.go +3239 -0
- package/govendor/golang.org/x/net/http2/server_common.go +268 -0
- package/govendor/golang.org/x/net/http2/server_wrap.go +217 -0
- package/govendor/golang.org/x/net/http2/transport.go +3084 -0
- package/govendor/golang.org/x/net/http2/transport_common.go +516 -0
- package/govendor/golang.org/x/net/http2/transport_wrap.go +583 -0
- package/govendor/golang.org/x/net/http2/unencrypted.go +32 -0
- package/govendor/golang.org/x/net/http2/write.go +381 -0
- package/govendor/golang.org/x/net/http2/writesched.go +253 -0
- package/govendor/golang.org/x/net/http2/writesched_common.go +90 -0
- package/govendor/golang.org/x/net/http2/writesched_priority_rfc7540.go +420 -0
- package/govendor/golang.org/x/net/http2/writesched_priority_rfc9218.go +226 -0
- package/govendor/golang.org/x/net/http2/writesched_random.go +81 -0
- package/govendor/golang.org/x/net/http2/writesched_roundrobin.go +121 -0
- package/govendor/golang.org/x/net/idna/idna.go +884 -0
- package/govendor/golang.org/x/net/idna/punycode.go +220 -0
- package/govendor/golang.org/x/net/idna/tables15.0.0.go +5144 -0
- package/govendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
- package/govendor/golang.org/x/net/idna/trie.go +51 -0
- package/govendor/golang.org/x/net/idna/trieval.go +119 -0
- package/govendor/golang.org/x/net/internal/httpcommon/README.md +7 -0
- package/govendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
- package/govendor/golang.org/x/net/internal/httpcommon/gzip.go +132 -0
- package/govendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
- package/govendor/golang.org/x/net/internal/httpcommon/request.go +503 -0
- package/govendor/golang.org/x/net/internal/httpsfv/httpsfv.go +665 -0
- package/govendor/golang.org/x/sys/cpu/asm_aix_ppc64.s +17 -0
- package/govendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
- package/govendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s +17 -0
- package/govendor/golang.org/x/sys/cpu/byteorder.go +66 -0
- package/govendor/golang.org/x/sys/cpu/cpu.go +357 -0
- package/govendor/golang.org/x/sys/cpu/cpu_aix.go +33 -0
- package/govendor/golang.org/x/sys/cpu/cpu_arm.go +73 -0
- package/govendor/golang.org/x/sys/cpu/cpu_arm64.go +191 -0
- package/govendor/golang.org/x/sys/cpu/cpu_arm64.s +35 -0
- package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
- package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
- package/govendor/golang.org/x/sys/cpu/cpu_darwin_x86.go +61 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +12 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gc_riscv64.go +11 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +21 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.go +15 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.s +26 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +12 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +22 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c +37 -0
- package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +25 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux.go +15 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_arm.go +39 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +120 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_loong64.go +22 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +22 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +9 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +34 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +173 -0
- package/govendor/golang.org/x/sys/cpu/cpu_linux_s390x.go +40 -0
- package/govendor/golang.org/x/sys/cpu/cpu_loong64.go +62 -0
- package/govendor/golang.org/x/sys/cpu/cpu_loong64.s +13 -0
- package/govendor/golang.org/x/sys/cpu/cpu_mips64x.go +15 -0
- package/govendor/golang.org/x/sys/cpu/cpu_mipsx.go +11 -0
- package/govendor/golang.org/x/sys/cpu/cpu_netbsd_amd64.go +47 -0
- package/govendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go +173 -0
- package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go +65 -0
- package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s +11 -0
- package/govendor/golang.org/x/sys/cpu/cpu_other_arm.go +9 -0
- package/govendor/golang.org/x/sys/cpu/cpu_other_arm64.go +11 -0
- package/govendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +11 -0
- package/govendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +12 -0
- package/govendor/golang.org/x/sys/cpu/cpu_other_riscv64.go +11 -0
- package/govendor/golang.org/x/sys/cpu/cpu_other_x86.go +11 -0
- package/govendor/golang.org/x/sys/cpu/cpu_ppc64x.go +16 -0
- package/govendor/golang.org/x/sys/cpu/cpu_riscv64.go +33 -0
- package/govendor/golang.org/x/sys/cpu/cpu_riscv64.s +17 -0
- package/govendor/golang.org/x/sys/cpu/cpu_s390x.go +172 -0
- package/govendor/golang.org/x/sys/cpu/cpu_s390x.s +57 -0
- package/govendor/golang.org/x/sys/cpu/cpu_sparc64.go +12 -0
- package/govendor/golang.org/x/sys/cpu/cpu_wasm.go +17 -0
- package/govendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
- package/govendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
- package/govendor/golang.org/x/sys/cpu/cpu_x86.go +259 -0
- package/govendor/golang.org/x/sys/cpu/cpu_zos.go +10 -0
- package/govendor/golang.org/x/sys/cpu/cpu_zos_s390x.go +25 -0
- package/govendor/golang.org/x/sys/cpu/endian_big.go +10 -0
- package/govendor/golang.org/x/sys/cpu/endian_little.go +10 -0
- package/govendor/golang.org/x/sys/cpu/hwcap_linux.go +71 -0
- package/govendor/golang.org/x/sys/cpu/parse.go +55 -0
- package/govendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go +53 -0
- package/govendor/golang.org/x/sys/cpu/runtime_auxv.go +16 -0
- package/govendor/golang.org/x/sys/cpu/runtime_auxv_go121.go +18 -0
- package/govendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +26 -0
- package/govendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +35 -0
- package/govendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
- package/govendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go +98 -0
- package/govendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
- package/govendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +20 -0
- package/govendor/golang.org/x/sys/unix/asm_linux_sparc64.s +48 -0
- package/govendor/golang.org/x/sys/unix/asm_zos_s390x.s +4 -186
- package/govendor/golang.org/x/sys/unix/bpxsvc_zos.s +9 -9
- package/govendor/golang.org/x/sys/unix/fcntl_darwin.go +2 -2
- package/govendor/golang.org/x/sys/unix/mkerrors.sh +1 -1
- package/govendor/golang.org/x/sys/unix/ptrace_zos.go +537 -0
- package/govendor/golang.org/x/sys/unix/ptrace_zos_singlestep.go +425 -0
- package/govendor/golang.org/x/sys/unix/syscall_darwin.go +1 -0
- package/govendor/golang.org/x/sys/unix/syscall_freebsd.go +9 -0
- package/govendor/golang.org/x/sys/unix/syscall_linux.go +20 -1
- package/govendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +3 -3
- package/govendor/golang.org/x/sys/unix/syscall_netbsd.go +9 -0
- package/govendor/golang.org/x/sys/unix/syscall_unix_gc.go +1 -1
- package/govendor/golang.org/x/sys/unix/syscall_zos_s390x.go +0 -4
- package/govendor/golang.org/x/sys/unix/xattr_bsd.go +12 -12
- package/govendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +6 -0
- package/govendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +6 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux.go +32 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_386.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_arm.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_mips.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +2 -0
- package/govendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +2 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +11 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +11 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_linux.go +28 -1
- package/govendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +3 -3
- package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +159 -0
- package/govendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +13 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux.go +65 -36
- package/govendor/golang.org/x/sys/unix/ztypes_linux_386.go +6 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_arm.go +6 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_mips.go +6 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +6 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +6 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +7 -0
- package/govendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +10 -5
- package/govendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +78 -0
- package/govendor/golang.org/x/text/.gitattributes +10 -0
- package/govendor/golang.org/x/text/CONTRIBUTING.md +26 -0
- package/govendor/golang.org/x/text/LICENSE +27 -0
- package/govendor/golang.org/x/text/PATENTS +22 -0
- package/govendor/golang.org/x/text/README.md +81 -0
- package/govendor/golang.org/x/text/cases/cases.go +162 -0
- package/govendor/golang.org/x/text/cases/context.go +376 -0
- package/govendor/golang.org/x/text/cases/fold.go +34 -0
- package/govendor/golang.org/x/text/cases/icu.go +61 -0
- package/govendor/golang.org/x/text/cases/info.go +82 -0
- package/govendor/golang.org/x/text/cases/map.go +816 -0
- package/govendor/golang.org/x/text/cases/tables15.0.0.go +2527 -0
- package/govendor/golang.org/x/text/cases/tables17.0.0.go +2642 -0
- package/govendor/golang.org/x/text/cases/trieval.go +217 -0
- package/govendor/golang.org/x/text/codereview.cfg +1 -0
- package/govendor/golang.org/x/text/collate/collate.go +402 -0
- package/govendor/golang.org/x/text/collate/index.go +32 -0
- package/govendor/golang.org/x/text/collate/option.go +239 -0
- package/govendor/golang.org/x/text/collate/sort.go +81 -0
- package/govendor/golang.org/x/text/collate/tables.go +73789 -0
- package/govendor/golang.org/x/text/currency/common.go +67 -0
- package/govendor/golang.org/x/text/currency/currency.go +185 -0
- package/govendor/golang.org/x/text/currency/format.go +220 -0
- package/govendor/golang.org/x/text/currency/query.go +152 -0
- package/govendor/golang.org/x/text/currency/tables.go +2629 -0
- package/govendor/golang.org/x/text/doc.go +16 -0
- package/govendor/golang.org/x/text/feature/plural/common.go +70 -0
- package/govendor/golang.org/x/text/feature/plural/message.go +244 -0
- package/govendor/golang.org/x/text/feature/plural/plural.go +262 -0
- package/govendor/golang.org/x/text/feature/plural/tables.go +552 -0
- package/govendor/golang.org/x/text/go.mod +3 -0
- package/govendor/golang.org/x/text/internal/catmsg/catmsg.go +417 -0
- package/govendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
- package/govendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
- package/govendor/golang.org/x/text/internal/colltab/collelem.go +374 -0
- package/govendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
- package/govendor/golang.org/x/text/internal/colltab/contract.go +145 -0
- package/govendor/golang.org/x/text/internal/colltab/iter.go +178 -0
- package/govendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
- package/govendor/golang.org/x/text/internal/colltab/table.go +275 -0
- package/govendor/golang.org/x/text/internal/colltab/trie.go +159 -0
- package/govendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
- package/govendor/golang.org/x/text/internal/format/format.go +41 -0
- package/govendor/golang.org/x/text/internal/format/parser.go +358 -0
- package/govendor/golang.org/x/text/internal/internal.go +49 -0
- package/govendor/golang.org/x/text/internal/language/common.go +16 -0
- package/govendor/golang.org/x/text/internal/language/compact/compact.go +61 -0
- package/govendor/golang.org/x/text/internal/language/compact/language.go +260 -0
- package/govendor/golang.org/x/text/internal/language/compact/parents.go +120 -0
- package/govendor/golang.org/x/text/internal/language/compact/tables.go +1015 -0
- package/govendor/golang.org/x/text/internal/language/compact/tags.go +91 -0
- package/govendor/golang.org/x/text/internal/language/compact.go +29 -0
- package/govendor/golang.org/x/text/internal/language/compose.go +167 -0
- package/govendor/golang.org/x/text/internal/language/coverage.go +28 -0
- package/govendor/golang.org/x/text/internal/language/language.go +627 -0
- package/govendor/golang.org/x/text/internal/language/lookup.go +412 -0
- package/govendor/golang.org/x/text/internal/language/match.go +226 -0
- package/govendor/golang.org/x/text/internal/language/parse.go +608 -0
- package/govendor/golang.org/x/text/internal/language/tables.go +3494 -0
- package/govendor/golang.org/x/text/internal/language/tags.go +48 -0
- package/govendor/golang.org/x/text/internal/match.go +67 -0
- package/govendor/golang.org/x/text/internal/number/common.go +55 -0
- package/govendor/golang.org/x/text/internal/number/decimal.go +500 -0
- package/govendor/golang.org/x/text/internal/number/format.go +533 -0
- package/govendor/golang.org/x/text/internal/number/number.go +152 -0
- package/govendor/golang.org/x/text/internal/number/pattern.go +485 -0
- package/govendor/golang.org/x/text/internal/number/roundingmode_string.go +30 -0
- package/govendor/golang.org/x/text/internal/number/tables.go +1219 -0
- package/govendor/golang.org/x/text/internal/stringset/set.go +86 -0
- package/govendor/golang.org/x/text/internal/tag/tag.go +100 -0
- package/govendor/golang.org/x/text/language/coverage.go +187 -0
- package/govendor/golang.org/x/text/language/display/dict.go +92 -0
- package/govendor/golang.org/x/text/language/display/display.go +420 -0
- package/govendor/golang.org/x/text/language/display/lookup.go +253 -0
- package/govendor/golang.org/x/text/language/display/tables.go +53114 -0
- package/govendor/golang.org/x/text/language/doc.go +98 -0
- package/govendor/golang.org/x/text/language/language.go +605 -0
- package/govendor/golang.org/x/text/language/match.go +735 -0
- package/govendor/golang.org/x/text/language/parse.go +258 -0
- package/govendor/golang.org/x/text/language/tables.go +298 -0
- package/govendor/golang.org/x/text/language/tags.go +145 -0
- package/govendor/golang.org/x/text/message/catalog/catalog.go +365 -0
- package/govendor/golang.org/x/text/message/catalog/dict.go +133 -0
- package/govendor/golang.org/x/text/secure/bidirule/bidirule.go +346 -0
- package/govendor/golang.org/x/text/transform/transform.go +709 -0
- package/govendor/golang.org/x/text/unicode/bidi/bidi.go +359 -0
- package/govendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
- package/govendor/golang.org/x/text/unicode/bidi/core.go +1050 -0
- package/govendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
- package/govendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +2042 -0
- package/govendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
- package/govendor/golang.org/x/text/unicode/bidi/trieval.go +48 -0
- package/govendor/golang.org/x/text/unicode/norm/composition.go +524 -0
- package/govendor/golang.org/x/text/unicode/norm/forminfo.go +296 -0
- package/govendor/golang.org/x/text/unicode/norm/input.go +109 -0
- package/govendor/golang.org/x/text/unicode/norm/iter.go +454 -0
- package/govendor/golang.org/x/text/unicode/norm/normalize.go +613 -0
- package/govendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
- package/govendor/golang.org/x/text/unicode/norm/tables15.0.0.go +7907 -0
- package/govendor/golang.org/x/text/unicode/norm/tables17.0.0.go +8104 -0
- package/govendor/golang.org/x/text/unicode/norm/transform.go +89 -0
- package/govendor/golang.org/x/text/unicode/norm/trie.go +54 -0
- package/govendor/manifest.txt +11 -2
- package/govendor/software.sslmate.com/src/go-pkcs12/.gitattributes +10 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/LICENSE +28 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/README.md +31 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/bmp-string.go +63 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/crypto.go +331 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/errors.go +23 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/go.mod +3 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/internal/rc2/rc2.go +271 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/mac.go +202 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/pbkdf.go +184 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/pkcs12.go +1000 -0
- package/govendor/software.sslmate.com/src/go-pkcs12/safebags.go +107 -0
- package/package.json +11 -1
- package/types/tsconfig.json +17 -0
- package/types/typenative-npm.d.ts +1327 -80
- package/types/typenative.d.ts +1312 -25
- package/.gitattributes +0 -1
- package/.github/workflows/ci.yml +0 -68
- package/.github/workflows/npm-publish-github-packages.yml +0 -88
- package/CHANGELOG.md +0 -1358
- package/CONTRIBUTION.md +0 -133
- package/conformance.md +0 -1450
- package/examples/README.md +0 -113
- package/examples/angular-templates/README.md +0 -141
- package/examples/angular-templates/bench.mjs +0 -173
- package/examples/angular-templates/dom-type-globals.d.ts +0 -21
- package/examples/angular-templates/dom-type-stubs.ts +0 -21
- package/examples/angular-templates/main.ts +0 -135
- package/examples/angular-templates/parity.mjs +0 -157
- package/examples/angular-templates/run-node.mjs +0 -69
- package/examples/angular-templates/vendor/angular/compiler/LICENSE +0 -21
- package/examples/desktop-notes/README.md +0 -106
- package/examples/desktop-notes/bench.mjs +0 -125
- package/examples/desktop-notes/main.ts +0 -131
- package/examples/desktop-notes/package-lock.json +0 -726
- package/examples/desktop-notes/package.json +0 -9
- package/examples/desktop-notes/ui.ts +0 -176
- package/examples/dupe-finder/README.md +0 -78
- package/examples/dupe-finder/bench.mjs +0 -120
- package/examples/dupe-finder/main.ts +0 -87
- package/examples/fibonacci/README.md +0 -89
- package/examples/fibonacci/bench.mjs +0 -87
- package/examples/fibonacci/main.ts +0 -21
- package/examples/hello-world/README.md +0 -62
- package/examples/hello-world/bench.mjs +0 -66
- package/examples/hello-world/main.ts +0 -7
- package/examples/json-server/README.md +0 -131
- package/examples/json-server/bench.mjs +0 -263
- package/examples/json-server/main.ts +0 -67
- package/examples/mandelbrot-png/README.md +0 -63
- package/examples/mandelbrot-png/bench.mjs +0 -95
- package/examples/mandelbrot-png/main.ts +0 -98
- package/examples/mandelbrot-png/preview.png +0 -0
- package/examples/marked-cli/README.md +0 -175
- package/examples/marked-cli/bench.mjs +0 -178
- package/examples/marked-cli/main.ts +0 -410
- package/examples/marked-cli/parity.mjs +0 -185
- package/examples/marked-cli/vendor/marked/LICENSE +0 -44
- package/examples/marked-cli/vendor/marked/VENDOR.md +0 -26
- package/examples/openai-chat/README.md +0 -148
- package/examples/openai-chat/bench.mjs +0 -175
- package/examples/openai-chat/main.ts +0 -488
- package/examples/react-compiler/README.md +0 -185
- package/examples/react-compiler/bench.mjs +0 -181
- package/examples/react-compiler/main.ts +0 -324
- package/examples/react-compiler/parity.mjs +0 -362
- package/examples/react-compiler/run-node.mjs +0 -90
- package/examples/react-compiler/vendor/babel/LICENSE +0 -22
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +0 -15
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +0 -51
- package/examples/react-compiler/vendor/charcodes/package.json +0 -25
- package/examples/react-compiler/vendor/invariant/LICENSE +0 -21
- package/examples/react-compiler/vendor/invariant/invariant.cjs +0 -51
- package/examples/react-compiler/vendor/invariant/invariant.d.cts +0 -11
- package/examples/react-compiler/vendor/invariant/types/LICENSE +0 -21
- package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +0 -19
- package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +0 -19
- package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +0 -19
- package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +0 -19
- package/examples/react-compiler/vendor/js-tokens/LICENSE +0 -21
- package/examples/react-compiler/vendor/js-tokens/index.cjs +0 -23
- package/examples/react-compiler/vendor/js-tokens/index.d.cts +0 -13
- package/examples/react-compiler/vendor/jsesc/jsesc.cjs +0 -337
- package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +0 -384
- package/examples/react-compiler/vendor/jsesc/types/LICENSE +0 -21
- package/examples/react-compiler/vendor/picocolors/picocolors.cjs +0 -75
- package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +0 -5
- package/examples/react-compiler/vendor/picocolors/types.d.ts +0 -51
- package/examples/react-compiler/vendor/react-compiler/LICENSE +0 -21
- package/examples/react-compiler/vendor/stubs/babel-core.ts +0 -31
- package/examples/react-compiler/vendor/stubs/debug.ts +0 -18
- package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +0 -13
- package/examples/react-compiler/vendor/stubs/pretty-format.ts +0 -18
- package/examples/react-compiler/vendor/zod/LICENSE +0 -21
- package/examples/react-compiler/vendor/zod-validation-error/LICENSE +0 -9
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +0 -5
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +0 -49
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +0 -48
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +0 -50
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +0 -6
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +0 -126
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +0 -39
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +0 -78
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +0 -2
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +0 -131
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +0 -54
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +0 -40
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +0 -12
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +0 -76
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +0 -76
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +0 -27
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +0 -27
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +0 -13
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +0 -61
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +0 -38
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +0 -20
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +0 -5
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +0 -8
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +0 -11
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +0 -20
- package/examples/react-compiler/vendor.mjs +0 -688
- package/examples/todo-cli/README.md +0 -69
- package/examples/todo-cli/bench.mjs +0 -89
- package/examples/todo-cli/main.ts +0 -92
- package/examples/yaml-cli/README.md +0 -152
- package/examples/yaml-cli/bench.mjs +0 -265
- package/examples/yaml-cli/main.ts +0 -251
- package/examples/yaml-cli/parity.mjs +0 -156
- package/examples/yaml-cli/vendor/yaml/LICENSE +0 -13
- package/examples/yaml-cli/vendor/yaml/VENDOR.md +0 -25
- package/govendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +0 -22
- package/govendor/golang.org/x/sys/windows/types_windows_arm.go +0 -35
- package/performance/README.md +0 -196
- package/performance/any-dynamic.ts +0 -21
- package/performance/any-record-view.ts +0 -20
- package/performance/arr-hof.ts +0 -21
- package/performance/arr-push-index.ts +0 -15
- package/performance/arr-sort.ts +0 -21
- package/performance/async-await.ts +0 -24
- package/performance/class-dispatch.ts +0 -52
- package/performance/events-emit.ts +0 -27
- package/performance/exc-throw-rare.ts +0 -25
- package/performance/exc-try-catch.ts +0 -26
- package/performance/fn-closures.ts +0 -29
- package/performance/fn-recursion-tree.ts +0 -31
- package/performance/gen-for-of.ts +0 -46
- package/performance/json-roundtrip.ts +0 -27
- package/performance/map-delete.ts +0 -24
- package/performance/map-string-keys.ts +0 -22
- package/performance/num-arith-loop.ts +0 -14
- package/performance/num-bitwise.ts +0 -21
- package/performance/num-mod-int.ts +0 -16
- package/performance/num-to-string.ts +0 -16
- package/performance/obj-alloc.ts +0 -32
- package/performance/regex-exec.ts +0 -29
- package/performance/regex-site.ts +0 -28
- package/performance/set-ops.ts +0 -20
- package/performance/str-char-scan.ts +0 -35
- package/performance/str-concat-plus.ts +0 -18
- package/performance/str-concat.ts +0 -24
- package/performance/str-short-scan.ts +0 -26
- package/performance/str-split-join.ts +0 -23
- package/performance/str-template.ts +0 -16
- package/performance/union-switch.ts +0 -57
- package/tsparser/check.go +0 -158
- package/tsparser/go.mod +0 -14
- package/tsparser/go.sum +0 -22
- package/tsparser/main.go +0 -363
- package/tsparser/tsparser.exe +0 -4
|
@@ -0,0 +1,2392 @@
|
|
|
1
|
+
// node:zlib ZIP archives (Node 26.8): ZipEntry / ZipBuffer / ZipFile,
|
|
2
|
+
// createZipArchive(Sync), zipFiles and the content-size limit.
|
|
3
|
+
//
|
|
4
|
+
// Laid out byte for byte as Node writes them (lib/internal/zip): local headers
|
|
5
|
+
// with a Zip64 extra for streamed or oversized members, a Zip64 data
|
|
6
|
+
// descriptor after streamed content, an extended-timestamp extra when the DOS
|
|
7
|
+
// fields cannot hold the time, the same central-directory and trailer records.
|
|
8
|
+
// Members inflate / deflate with compress/flate. ZipFile edits the archive in
|
|
9
|
+
// place like Node: new members go where the central directory starts, which is
|
|
10
|
+
// rewritten after them; compact() drops the dead space.
|
|
11
|
+
export const zipHelper = `// node:zlib ZIP archives
|
|
12
|
+
var tnMaxZipContentSize = float64(268435456)
|
|
13
|
+
|
|
14
|
+
func TnGetMaxZipContentSize() float64 { return tnMaxZipContentSize }
|
|
15
|
+
|
|
16
|
+
func TnSetMaxZipContentSize(size float64) {
|
|
17
|
+
if math.IsNaN(size) || size != math.Trunc(size) || size < 0 || size > 9007199254740991 {
|
|
18
|
+
panic(TnNodeError("RangeError", "ERR_OUT_OF_RANGE", "The value of \\"size\\" is out of range. It must be >= 0 && <= 9007199254740991. Received "+TnNumStr(size)))
|
|
19
|
+
}
|
|
20
|
+
tnMaxZipContentSize = size
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const (
|
|
24
|
+
tnZipSigLocal = 0x04034b50
|
|
25
|
+
tnZipSigDesc = 0x08074b50
|
|
26
|
+
tnZipSigCentral = 0x02014b50
|
|
27
|
+
tnZipSigZ64End = 0x06064b50
|
|
28
|
+
tnZipSigZ64Loc = 0x07064b50
|
|
29
|
+
tnZipSigEnd = 0x06054b50
|
|
30
|
+
tnZipUnix = 3
|
|
31
|
+
tnZipZ64Extra = 0x0001
|
|
32
|
+
tnZipS16 = 0xffff
|
|
33
|
+
tnZipS32 = 0xffffffff
|
|
34
|
+
tnZipEncrypted = 0x0001
|
|
35
|
+
tnZipDescriptor = 0x0008
|
|
36
|
+
tnZipUTF8 = 0x0800
|
|
37
|
+
tnZipStore = 0
|
|
38
|
+
tnZipDeflate = 8
|
|
39
|
+
tnZipZstd = 93
|
|
40
|
+
tnZipTailLength = 22 + 0xffff + 20 + 56 + 4096
|
|
41
|
+
tnZipReadChunk = 4 * 1024 * 1024
|
|
42
|
+
tnZipIfReg = 0o100000
|
|
43
|
+
tnZipIfDir = 0o040000
|
|
44
|
+
tnZipIfLnk = 0o120000
|
|
45
|
+
tnZipIfMt = 0o170000
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
var tnZipZstdDecode func(data []byte, limit int) ([]byte, error)
|
|
49
|
+
|
|
50
|
+
func tnZipQuote(s string) string {
|
|
51
|
+
var buf bytes.Buffer
|
|
52
|
+
enc := json.NewEncoder(&buf)
|
|
53
|
+
enc.SetEscapeHTML(false)
|
|
54
|
+
enc.Encode(s)
|
|
55
|
+
return strings.TrimSuffix(buf.String(), "\\n")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// util.inspect's rendering of the values these errors quote
|
|
59
|
+
func tnZipInspect(v interface{}) string {
|
|
60
|
+
switch x := v.(type) {
|
|
61
|
+
case string:
|
|
62
|
+
return "'" + x + "'"
|
|
63
|
+
case []byte:
|
|
64
|
+
parts := []string{}
|
|
65
|
+
for i, c := range x {
|
|
66
|
+
if i == 50 {
|
|
67
|
+
parts = append(parts, "... "+strconv.Itoa(len(x)-50)+" more bytes")
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
parts = append(parts, strconv.FormatUint(uint64(c)|0x100, 16)[1:])
|
|
71
|
+
}
|
|
72
|
+
return "<Buffer " + strings.Join(parts, " ") + ">"
|
|
73
|
+
case bool:
|
|
74
|
+
return strconv.FormatBool(x)
|
|
75
|
+
case float64:
|
|
76
|
+
return TnNumStr(x)
|
|
77
|
+
case nil:
|
|
78
|
+
return "undefined"
|
|
79
|
+
}
|
|
80
|
+
return "[object Object]"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func tnZipErr(code string, message string) *TnError {
|
|
84
|
+
switch code {
|
|
85
|
+
case "ERR_ZIP_ENTRY_TOO_LARGE":
|
|
86
|
+
return TnNodeError("RangeError", code, "ZIP entry exceeds the allowed size: "+message)
|
|
87
|
+
case "ERR_ZIP_ARCHIVE_TOO_LARGE":
|
|
88
|
+
return TnNodeError("RangeError", code, "ZIP archive structure exceeds the allowed size: "+message)
|
|
89
|
+
case "ERR_ZIP_ENTRY_CORRUPT":
|
|
90
|
+
return TnNodeError("Error", code, "ZIP entry is corrupt: "+message)
|
|
91
|
+
case "ERR_ZIP_INVALID_ARCHIVE":
|
|
92
|
+
return TnNodeError("Error", code, "invalid ZIP archive: "+message)
|
|
93
|
+
case "ERR_ZIP_UNSUPPORTED_FEATURE":
|
|
94
|
+
return TnNodeError("Error", code, "unsupported ZIP feature: "+message)
|
|
95
|
+
case "ERR_ZIP_ENTRY_NOT_FOUND":
|
|
96
|
+
return TnNodeError("Error", code, "no such entry "+tnZipQuote(message)+" in the archive")
|
|
97
|
+
case "ERR_ZIP_NOT_WRITABLE":
|
|
98
|
+
return TnNodeError("TypeError", code, "this archive was not opened for writing")
|
|
99
|
+
case "ERR_INVALID_STATE":
|
|
100
|
+
return TnNodeError("Error", code, "Invalid state: "+message)
|
|
101
|
+
}
|
|
102
|
+
return TnNodeError("Error", code, message)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// An option's value (nil when absent), through pointers
|
|
106
|
+
func tnZipOpt(options interface{}, key string) interface{} {
|
|
107
|
+
if options == nil || TnIsNil(options) {
|
|
108
|
+
return nil
|
|
109
|
+
}
|
|
110
|
+
v := TnGetValue(options, key)
|
|
111
|
+
if v == nil || TnIsNil(v) {
|
|
112
|
+
return nil
|
|
113
|
+
}
|
|
114
|
+
rv := reflect.ValueOf(v)
|
|
115
|
+
for rv.Kind() == reflect.Pointer {
|
|
116
|
+
if rv.IsNil() {
|
|
117
|
+
return nil
|
|
118
|
+
}
|
|
119
|
+
rv = rv.Elem()
|
|
120
|
+
}
|
|
121
|
+
return rv.Interface()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
func tnZipFirst(options []interface{}) interface{} {
|
|
125
|
+
if len(options) == 0 {
|
|
126
|
+
return nil
|
|
127
|
+
}
|
|
128
|
+
return options[0]
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
func tnZipBytes(v interface{}) []byte {
|
|
132
|
+
if b, ok := v.([]byte); ok {
|
|
133
|
+
return b
|
|
134
|
+
}
|
|
135
|
+
return TnBufferFrom(v, "")
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ---- DOS times, text decoding, extra fields ----
|
|
139
|
+
|
|
140
|
+
func tnZipDosDecode(t uint16, d uint16) time.Time {
|
|
141
|
+
month := int((d >> 5) & 0x0f)
|
|
142
|
+
if month == 0 {
|
|
143
|
+
month = 1
|
|
144
|
+
}
|
|
145
|
+
day := int(d & 0x1f)
|
|
146
|
+
if day == 0 {
|
|
147
|
+
day = 1
|
|
148
|
+
}
|
|
149
|
+
return time.Date(int((d>>9)&0x7f)+1980, time.Month(month), day, int((t>>11)&0x1f), int((t>>5)&0x3f), int(t&0x1f)*2, 0, time.Local)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
func tnZipDosEncode(value time.Time) (uint16, uint16) {
|
|
153
|
+
if value.IsZero() {
|
|
154
|
+
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_VALUE", "The argument 'modified' must be a valid Date. Received Invalid Date"))
|
|
155
|
+
}
|
|
156
|
+
v := value.In(time.Local)
|
|
157
|
+
year := v.Year()
|
|
158
|
+
if year < 1980 {
|
|
159
|
+
return 0, (1 << 5) | 1
|
|
160
|
+
}
|
|
161
|
+
if year > 2107 {
|
|
162
|
+
return (23 << 11) | (59 << 5) | 29, (127 << 9) | (12 << 5) | 31
|
|
163
|
+
}
|
|
164
|
+
date := uint16(((year - 1980) << 9) | (int(v.Month()) << 5) | v.Day())
|
|
165
|
+
tm := uint16((v.Hour() << 11) | (v.Minute() << 5) | (v.Second() >> 1))
|
|
166
|
+
return tm, date
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
var tnZipCp437 = []rune{
|
|
170
|
+
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
|
|
171
|
+
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9, 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
|
|
172
|
+
0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba, 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
|
|
173
|
+
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
|
|
174
|
+
0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
|
|
175
|
+
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
|
|
176
|
+
0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
|
|
177
|
+
0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248, 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0,
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
func tnZipText(b []byte, flags uint16) string {
|
|
181
|
+
if flags&tnZipUTF8 != 0 || utf8.Valid(b) {
|
|
182
|
+
return string(b)
|
|
183
|
+
}
|
|
184
|
+
var sb strings.Builder
|
|
185
|
+
for _, c := range b {
|
|
186
|
+
if c < 0x80 {
|
|
187
|
+
sb.WriteByte(c)
|
|
188
|
+
} else {
|
|
189
|
+
sb.WriteRune(tnZipCp437[c-0x80])
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return sb.String()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
func tnZipEachExtra(extra []byte, fn func(id uint16, body []byte)) {
|
|
196
|
+
for pos := 0; pos+4 <= len(extra); {
|
|
197
|
+
id := binary.LittleEndian.Uint16(extra[pos:])
|
|
198
|
+
size := int(binary.LittleEndian.Uint16(extra[pos+2:]))
|
|
199
|
+
if pos+4+size > len(extra) {
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
fn(id, extra[pos+4:pos+4+size])
|
|
203
|
+
pos += 4 + size
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
func tnZipName(name []byte, flags uint16, extra []byte) string {
|
|
208
|
+
result := ""
|
|
209
|
+
found := false
|
|
210
|
+
tnZipEachExtra(extra, func(id uint16, body []byte) {
|
|
211
|
+
if found || id != 0x7075 || len(body) < 5 || body[0] != 1 {
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
if binary.LittleEndian.Uint32(body[1:]) != crc32.ChecksumIEEE(name) {
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
result, found = string(body[5:]), true
|
|
218
|
+
})
|
|
219
|
+
if found {
|
|
220
|
+
return result
|
|
221
|
+
}
|
|
222
|
+
return tnZipText(name, flags)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// The modification time an NTFS, extended-timestamp or old Unix extra records
|
|
226
|
+
func tnZipExtraMtime(extras ...[]byte) (time.Time, bool) {
|
|
227
|
+
var ntfs, ext, unix *time.Time
|
|
228
|
+
for _, extra := range extras {
|
|
229
|
+
tnZipEachExtra(extra, func(id uint16, body []byte) {
|
|
230
|
+
switch id {
|
|
231
|
+
case 0x000a:
|
|
232
|
+
if ntfs != nil || len(body) < 4 {
|
|
233
|
+
return
|
|
234
|
+
}
|
|
235
|
+
for pos := 4; pos+4 <= len(body); {
|
|
236
|
+
tag := binary.LittleEndian.Uint16(body[pos:])
|
|
237
|
+
size := int(binary.LittleEndian.Uint16(body[pos+2:]))
|
|
238
|
+
if tag == 1 && size >= 8 && pos+12 <= len(body) {
|
|
239
|
+
ticks := int64(binary.LittleEndian.Uint64(body[pos+4:]))
|
|
240
|
+
t := time.UnixMilli((ticks - 116444736000000000) / 10000)
|
|
241
|
+
ntfs = &t
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
pos += 4 + size
|
|
245
|
+
}
|
|
246
|
+
case 0x5455:
|
|
247
|
+
if ext != nil || len(body) < 5 || body[0]&1 == 0 {
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
t := time.Unix(int64(int32(binary.LittleEndian.Uint32(body[1:]))), 0)
|
|
251
|
+
ext = &t
|
|
252
|
+
case 0x5855:
|
|
253
|
+
if unix != nil || len(body) < 8 {
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
t := time.Unix(int64(int32(binary.LittleEndian.Uint32(body[4:]))), 0)
|
|
257
|
+
unix = &t
|
|
258
|
+
}
|
|
259
|
+
})
|
|
260
|
+
}
|
|
261
|
+
switch {
|
|
262
|
+
case ntfs != nil:
|
|
263
|
+
return ntfs.Local(), true
|
|
264
|
+
case ext != nil:
|
|
265
|
+
return ext.Local(), true
|
|
266
|
+
case unix != nil:
|
|
267
|
+
return unix.Local(), true
|
|
268
|
+
}
|
|
269
|
+
return time.Time{}, false
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
func tnZipStripZip64(extra []byte) []byte {
|
|
273
|
+
var out []byte
|
|
274
|
+
tnZipEachExtra(extra, func(id uint16, body []byte) {
|
|
275
|
+
if id == tnZipZ64Extra {
|
|
276
|
+
return
|
|
277
|
+
}
|
|
278
|
+
out = binary.LittleEndian.AppendUint16(out, id)
|
|
279
|
+
out = binary.LittleEndian.AppendUint16(out, uint16(len(body)))
|
|
280
|
+
out = append(out, body...)
|
|
281
|
+
})
|
|
282
|
+
if out == nil {
|
|
283
|
+
return []byte{}
|
|
284
|
+
}
|
|
285
|
+
return out
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ---- entry metadata and header records ----
|
|
289
|
+
|
|
290
|
+
type tnZipMeta struct {
|
|
291
|
+
name, comment, extra []byte
|
|
292
|
+
flags, method uint16
|
|
293
|
+
crc uint32
|
|
294
|
+
compressedSize int64
|
|
295
|
+
uncompressedSize int64
|
|
296
|
+
modified time.Time
|
|
297
|
+
extMtime int64
|
|
298
|
+
hasExtMtime bool
|
|
299
|
+
external uint32
|
|
300
|
+
internal uint16
|
|
301
|
+
madeBy uint16
|
|
302
|
+
pending bool
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
func tnZipExtendedMtime(t time.Time) (int64, bool) {
|
|
306
|
+
ms := TnDateMs(t)
|
|
307
|
+
seconds := math.Floor(ms / 1000)
|
|
308
|
+
if math.Mod(ms, 2000) != 0 && seconds >= -2147483648 && seconds <= 2147483647 {
|
|
309
|
+
return int64(seconds), true
|
|
310
|
+
}
|
|
311
|
+
return 0, false
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
func tnZipInvalidArg(name string, value interface{}, reason string) *TnError {
|
|
315
|
+
return TnNodeError("TypeError", "ERR_INVALID_ARG_VALUE", "The argument '"+name+"' "+reason+". Received "+tnZipInspect(value))
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
func tnZipCreateMeta(filename string, options interface{}, symlink bool) *tnZipMeta {
|
|
319
|
+
name := []byte(filename)
|
|
320
|
+
if len(name) == 0 {
|
|
321
|
+
panic(tnZipInvalidArg("filename", filename, "must not be empty"))
|
|
322
|
+
}
|
|
323
|
+
if len(name) > tnZipS16 {
|
|
324
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_TOO_LARGE", "the entry name must not exceed 65535 bytes when encoded as UTF-8"))
|
|
325
|
+
}
|
|
326
|
+
comment := []byte{}
|
|
327
|
+
if c := tnZipOpt(options, "comment"); c != nil {
|
|
328
|
+
text, _ := c.(string)
|
|
329
|
+
comment = []byte(text)
|
|
330
|
+
if len(comment) > tnZipS16 {
|
|
331
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_TOO_LARGE", "the entry comment must not exceed 65535 bytes when encoded as UTF-8"))
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
isDir := !symlink && strings.HasSuffix(filename, "/")
|
|
335
|
+
mode := float64(0o644)
|
|
336
|
+
if symlink {
|
|
337
|
+
mode = 0o777
|
|
338
|
+
} else if isDir {
|
|
339
|
+
mode = 0o755
|
|
340
|
+
}
|
|
341
|
+
if m, ok := tnZipOpt(options, "mode").(float64); ok {
|
|
342
|
+
if m != math.Trunc(m) || m < 0 || m > 4294967295 {
|
|
343
|
+
panic(TnNodeError("RangeError", "ERR_OUT_OF_RANGE", "The value of \\"options.mode\\" is out of range. It must be >= 0 && <= 4294967295. Received "+TnNumStr(m)))
|
|
344
|
+
}
|
|
345
|
+
mode = m
|
|
346
|
+
}
|
|
347
|
+
modified := TnDateFromMs(math.Floor(float64(time.Now().UnixMilli())/2000) * 2000)
|
|
348
|
+
if m := tnZipOpt(options, "modified"); m != nil {
|
|
349
|
+
t, ok := m.(time.Time)
|
|
350
|
+
if !ok {
|
|
351
|
+
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"options.modified\\" property must be an instance of Date."))
|
|
352
|
+
}
|
|
353
|
+
modified = t
|
|
354
|
+
}
|
|
355
|
+
if m := tnZipOpt(options, "method"); m != nil {
|
|
356
|
+
if s, _ := m.(string); s != "deflate" && s != "store" && s != "zstd" {
|
|
357
|
+
panic(tnZipInvalidArg("options.method", m, "must be 'deflate', 'store', or 'zstd'"))
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
typeBits := uint32(tnZipIfReg)
|
|
361
|
+
if symlink {
|
|
362
|
+
typeBits = tnZipIfLnk
|
|
363
|
+
} else if isDir {
|
|
364
|
+
typeBits = tnZipIfDir
|
|
365
|
+
}
|
|
366
|
+
unixAttrs := (typeBits | (uint32(mode) & 0o7777)) & tnZipS16
|
|
367
|
+
external := unixAttrs << 16
|
|
368
|
+
if isDir {
|
|
369
|
+
external |= 0x10
|
|
370
|
+
}
|
|
371
|
+
ext, hasExt := tnZipExtendedMtime(modified)
|
|
372
|
+
return &tnZipMeta{name: name, comment: comment, extra: []byte{}, flags: tnZipUTF8, modified: modified,
|
|
373
|
+
extMtime: ext, hasExtMtime: hasExt, external: external, madeBy: tnZipUnix, pending: true}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
func tnZipExtTimestamp(seconds int64) []byte {
|
|
377
|
+
b := []byte{0x55, 0x54, 5, 0, 1, 0, 0, 0, 0}
|
|
378
|
+
binary.LittleEndian.PutUint32(b[5:], uint32(int32(seconds)))
|
|
379
|
+
return b
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
func tnZipVersion(meta *tnZipMeta, zip64 bool) uint16 {
|
|
383
|
+
v := uint16(20)
|
|
384
|
+
if zip64 {
|
|
385
|
+
v = 45
|
|
386
|
+
}
|
|
387
|
+
if meta.method == tnZipZstd && v < 63 {
|
|
388
|
+
v = 63
|
|
389
|
+
}
|
|
390
|
+
return v
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
func tnZipCheckExtra(length int) {
|
|
394
|
+
if length > tnZipS16 {
|
|
395
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_TOO_LARGE", "the entry extra fields must not exceed 65535 bytes"))
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
func tnZipU16(b []byte, v uint16) []byte { return binary.LittleEndian.AppendUint16(b, v) }
|
|
400
|
+
func tnZipU32(b []byte, v uint32) []byte { return binary.LittleEndian.AppendUint32(b, v) }
|
|
401
|
+
func tnZipU64(b []byte, v int64) []byte { return binary.LittleEndian.AppendUint64(b, uint64(v)) }
|
|
402
|
+
|
|
403
|
+
func tnZipLocalHeader(meta *tnZipMeta) []byte {
|
|
404
|
+
streaming := meta.flags&tnZipDescriptor != 0
|
|
405
|
+
zip64 := streaming || meta.compressedSize >= tnZipS32 || meta.uncompressedSize >= tnZipS32
|
|
406
|
+
var ts []byte
|
|
407
|
+
if meta.hasExtMtime {
|
|
408
|
+
ts = tnZipExtTimestamp(meta.extMtime)
|
|
409
|
+
}
|
|
410
|
+
extraLength := len(ts) + len(meta.extra)
|
|
411
|
+
if zip64 {
|
|
412
|
+
extraLength += 20
|
|
413
|
+
}
|
|
414
|
+
tnZipCheckExtra(extraLength)
|
|
415
|
+
b := make([]byte, 0, 30+len(meta.name)+extraLength)
|
|
416
|
+
b = tnZipU32(b, tnZipSigLocal)
|
|
417
|
+
b = tnZipU16(b, tnZipVersion(meta, zip64))
|
|
418
|
+
b = tnZipU16(b, meta.flags)
|
|
419
|
+
b = tnZipU16(b, meta.method)
|
|
420
|
+
tm, date := tnZipDosEncode(meta.modified)
|
|
421
|
+
b = tnZipU16(b, tm)
|
|
422
|
+
b = tnZipU16(b, date)
|
|
423
|
+
if streaming {
|
|
424
|
+
b = tnZipU32(b, 0)
|
|
425
|
+
} else {
|
|
426
|
+
b = tnZipU32(b, meta.crc)
|
|
427
|
+
}
|
|
428
|
+
if zip64 {
|
|
429
|
+
b = tnZipU32(b, tnZipS32)
|
|
430
|
+
b = tnZipU32(b, tnZipS32)
|
|
431
|
+
} else {
|
|
432
|
+
b = tnZipU32(b, uint32(meta.compressedSize))
|
|
433
|
+
b = tnZipU32(b, uint32(meta.uncompressedSize))
|
|
434
|
+
}
|
|
435
|
+
b = tnZipU16(b, uint16(len(meta.name)))
|
|
436
|
+
b = tnZipU16(b, uint16(extraLength))
|
|
437
|
+
b = append(b, meta.name...)
|
|
438
|
+
if zip64 {
|
|
439
|
+
b = tnZipU16(b, tnZipZ64Extra)
|
|
440
|
+
b = tnZipU16(b, 16)
|
|
441
|
+
if streaming {
|
|
442
|
+
b = tnZipU64(b, 0)
|
|
443
|
+
b = tnZipU64(b, 0)
|
|
444
|
+
} else {
|
|
445
|
+
b = tnZipU64(b, meta.uncompressedSize)
|
|
446
|
+
b = tnZipU64(b, meta.compressedSize)
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
b = append(b, ts...)
|
|
450
|
+
return append(b, meta.extra...)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
func tnZipCentralHeader(meta *tnZipMeta, localOffset int64) []byte {
|
|
454
|
+
u64 := meta.uncompressedSize >= tnZipS32
|
|
455
|
+
c64 := meta.compressedSize >= tnZipS32
|
|
456
|
+
o64 := localOffset >= tnZipS32
|
|
457
|
+
fields := 0
|
|
458
|
+
for _, f := range []bool{u64, c64, o64} {
|
|
459
|
+
if f {
|
|
460
|
+
fields++
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
var ts []byte
|
|
464
|
+
if meta.hasExtMtime {
|
|
465
|
+
ts = tnZipExtTimestamp(meta.extMtime)
|
|
466
|
+
}
|
|
467
|
+
extraLength := len(ts) + len(meta.extra)
|
|
468
|
+
if fields > 0 {
|
|
469
|
+
extraLength += 4 + 8*fields
|
|
470
|
+
}
|
|
471
|
+
tnZipCheckExtra(extraLength)
|
|
472
|
+
version := tnZipVersion(meta, meta.flags&tnZipDescriptor != 0 || fields > 0)
|
|
473
|
+
b := make([]byte, 0, 46+len(meta.name)+extraLength+len(meta.comment))
|
|
474
|
+
b = tnZipU32(b, tnZipSigCentral)
|
|
475
|
+
b = tnZipU16(b, (meta.madeBy<<8)|version)
|
|
476
|
+
b = tnZipU16(b, version)
|
|
477
|
+
b = tnZipU16(b, meta.flags)
|
|
478
|
+
b = tnZipU16(b, meta.method)
|
|
479
|
+
tm, date := tnZipDosEncode(meta.modified)
|
|
480
|
+
b = tnZipU16(b, tm)
|
|
481
|
+
b = tnZipU16(b, date)
|
|
482
|
+
b = tnZipU32(b, meta.crc)
|
|
483
|
+
if c64 {
|
|
484
|
+
b = tnZipU32(b, tnZipS32)
|
|
485
|
+
} else {
|
|
486
|
+
b = tnZipU32(b, uint32(meta.compressedSize))
|
|
487
|
+
}
|
|
488
|
+
if u64 {
|
|
489
|
+
b = tnZipU32(b, tnZipS32)
|
|
490
|
+
} else {
|
|
491
|
+
b = tnZipU32(b, uint32(meta.uncompressedSize))
|
|
492
|
+
}
|
|
493
|
+
b = tnZipU16(b, uint16(len(meta.name)))
|
|
494
|
+
b = tnZipU16(b, uint16(extraLength))
|
|
495
|
+
b = tnZipU16(b, uint16(len(meta.comment)))
|
|
496
|
+
b = tnZipU16(b, 0)
|
|
497
|
+
b = tnZipU16(b, meta.internal)
|
|
498
|
+
b = tnZipU32(b, meta.external)
|
|
499
|
+
if o64 {
|
|
500
|
+
b = tnZipU32(b, tnZipS32)
|
|
501
|
+
} else {
|
|
502
|
+
b = tnZipU32(b, uint32(localOffset))
|
|
503
|
+
}
|
|
504
|
+
b = append(b, meta.name...)
|
|
505
|
+
if fields > 0 {
|
|
506
|
+
b = tnZipU16(b, tnZipZ64Extra)
|
|
507
|
+
b = tnZipU16(b, uint16(8*fields))
|
|
508
|
+
if u64 {
|
|
509
|
+
b = tnZipU64(b, meta.uncompressedSize)
|
|
510
|
+
}
|
|
511
|
+
if c64 {
|
|
512
|
+
b = tnZipU64(b, meta.compressedSize)
|
|
513
|
+
}
|
|
514
|
+
if o64 {
|
|
515
|
+
b = tnZipU64(b, localOffset)
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
b = append(b, ts...)
|
|
519
|
+
b = append(b, meta.extra...)
|
|
520
|
+
return append(b, meta.comment...)
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
func tnZipDataDescriptor(crc uint32, compressed int64, uncompressed int64) []byte {
|
|
524
|
+
b := tnZipU32(nil, tnZipSigDesc)
|
|
525
|
+
b = tnZipU32(b, crc)
|
|
526
|
+
b = tnZipU64(b, compressed)
|
|
527
|
+
return tnZipU64(b, uncompressed)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
func tnZipTrailer(count int64, size int64, offset int64, comment []byte) [][]byte {
|
|
531
|
+
var chunks [][]byte
|
|
532
|
+
if count >= tnZipS16 || offset >= tnZipS32 || size >= tnZipS32 {
|
|
533
|
+
rec := tnZipU32(nil, tnZipSigZ64End)
|
|
534
|
+
rec = tnZipU64(rec, 44)
|
|
535
|
+
rec = tnZipU16(rec, (tnZipUnix<<8)|45)
|
|
536
|
+
rec = tnZipU16(rec, 45)
|
|
537
|
+
rec = tnZipU32(rec, 0)
|
|
538
|
+
rec = tnZipU32(rec, 0)
|
|
539
|
+
rec = tnZipU64(rec, count)
|
|
540
|
+
rec = tnZipU64(rec, count)
|
|
541
|
+
rec = tnZipU64(rec, size)
|
|
542
|
+
rec = tnZipU64(rec, offset)
|
|
543
|
+
loc := tnZipU32(nil, tnZipSigZ64Loc)
|
|
544
|
+
loc = tnZipU32(loc, 0)
|
|
545
|
+
loc = tnZipU64(loc, offset+size)
|
|
546
|
+
loc = tnZipU32(loc, 1)
|
|
547
|
+
chunks = append(chunks, rec, loc)
|
|
548
|
+
}
|
|
549
|
+
end := tnZipU32(nil, tnZipSigEnd)
|
|
550
|
+
end = tnZipU16(end, 0)
|
|
551
|
+
end = tnZipU16(end, 0)
|
|
552
|
+
end = tnZipU16(end, uint16(min(count, tnZipS16)))
|
|
553
|
+
end = tnZipU16(end, uint16(min(count, tnZipS16)))
|
|
554
|
+
end = tnZipU32(end, uint32(min(size, tnZipS32)))
|
|
555
|
+
end = tnZipU32(end, uint32(min(offset, tnZipS32)))
|
|
556
|
+
end = tnZipU16(end, uint16(len(comment)))
|
|
557
|
+
end = append(end, comment...)
|
|
558
|
+
return append(chunks, end)
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// ---- parsing ----
|
|
562
|
+
|
|
563
|
+
type tnZipCentral struct {
|
|
564
|
+
version, flags, method, dosTime, dosDate, internal uint16
|
|
565
|
+
crc, external uint32
|
|
566
|
+
compressedSize, uncompressedSize, localOffset int64
|
|
567
|
+
disk int64
|
|
568
|
+
name, extra, comment []byte
|
|
569
|
+
length int
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
func tnZipRange(buf []byte, offset int, length int, what string) {
|
|
573
|
+
if offset < 0 || length < 0 || offset+length > len(buf) {
|
|
574
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", what+" is out of bounds"))
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
func tnZipParseCentral(buf []byte, pos int) *tnZipCentral {
|
|
579
|
+
tnZipRange(buf, pos, 46, "central directory header")
|
|
580
|
+
le := binary.LittleEndian
|
|
581
|
+
if le.Uint32(buf[pos:]) != tnZipSigCentral {
|
|
582
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory header signature is invalid"))
|
|
583
|
+
}
|
|
584
|
+
nameLen := int(le.Uint16(buf[pos+28:]))
|
|
585
|
+
extraLen := int(le.Uint16(buf[pos+30:]))
|
|
586
|
+
commentLen := int(le.Uint16(buf[pos+32:]))
|
|
587
|
+
length := 46 + nameLen + extraLen + commentLen
|
|
588
|
+
if pos+length > len(buf) {
|
|
589
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory header is truncated"))
|
|
590
|
+
}
|
|
591
|
+
c := &tnZipCentral{
|
|
592
|
+
version: le.Uint16(buf[pos+4:]), flags: le.Uint16(buf[pos+8:]), method: le.Uint16(buf[pos+10:]),
|
|
593
|
+
dosTime: le.Uint16(buf[pos+12:]), dosDate: le.Uint16(buf[pos+14:]), crc: le.Uint32(buf[pos+16:]),
|
|
594
|
+
compressedSize: int64(le.Uint32(buf[pos+20:])), uncompressedSize: int64(le.Uint32(buf[pos+24:])),
|
|
595
|
+
disk: int64(le.Uint16(buf[pos+34:])), internal: le.Uint16(buf[pos+36:]), external: le.Uint32(buf[pos+38:]),
|
|
596
|
+
localOffset: int64(le.Uint32(buf[pos+42:])), length: length,
|
|
597
|
+
}
|
|
598
|
+
c.name = buf[pos+46 : pos+46+nameLen]
|
|
599
|
+
c.extra = buf[pos+46+nameLen : pos+46+nameLen+extraLen]
|
|
600
|
+
c.comment = buf[pos+46+nameLen+extraLen : pos+length]
|
|
601
|
+
needU, needC, needO, needD := c.uncompressedSize == tnZipS32, c.compressedSize == tnZipS32, c.localOffset == tnZipS32, c.disk == tnZipS16
|
|
602
|
+
if needU || needC || needO || needD {
|
|
603
|
+
found := false
|
|
604
|
+
tnZipEachExtra(c.extra, func(id uint16, body []byte) {
|
|
605
|
+
if id != tnZipZ64Extra || found {
|
|
606
|
+
return
|
|
607
|
+
}
|
|
608
|
+
found = true
|
|
609
|
+
at := 0
|
|
610
|
+
read := func() int64 {
|
|
611
|
+
if at+8 > len(body) {
|
|
612
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "Zip64 extended information extra field is truncated"))
|
|
613
|
+
}
|
|
614
|
+
v := le.Uint64(body[at:])
|
|
615
|
+
at += 8
|
|
616
|
+
if v > 9007199254740991 {
|
|
617
|
+
panic(tnZipErr("ERR_ZIP_ARCHIVE_TOO_LARGE", "a Zip64 value exceeds Number.MAX_SAFE_INTEGER"))
|
|
618
|
+
}
|
|
619
|
+
return int64(v)
|
|
620
|
+
}
|
|
621
|
+
if needU {
|
|
622
|
+
c.uncompressedSize = read()
|
|
623
|
+
}
|
|
624
|
+
if needC {
|
|
625
|
+
c.compressedSize = read()
|
|
626
|
+
}
|
|
627
|
+
if needO {
|
|
628
|
+
c.localOffset = read()
|
|
629
|
+
}
|
|
630
|
+
if needD && at+4 <= len(body) {
|
|
631
|
+
c.disk = int64(le.Uint32(body[at:]))
|
|
632
|
+
}
|
|
633
|
+
})
|
|
634
|
+
if !found {
|
|
635
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "Zip64 extended information extra field is missing"))
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return c
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
func (c *tnZipCentral) fileName() string { return tnZipName(c.name, c.flags, c.extra) }
|
|
642
|
+
func (c *tnZipCentral) unixMode() bool { return c.version>>8 == tnZipUnix }
|
|
643
|
+
func (c *tnZipCentral) mode() float64 {
|
|
644
|
+
if !c.unixMode() {
|
|
645
|
+
return 0
|
|
646
|
+
}
|
|
647
|
+
return float64((c.external >> 16) & 0o7777)
|
|
648
|
+
}
|
|
649
|
+
func (c *tnZipCentral) symlink() bool {
|
|
650
|
+
return c.unixMode() && (c.external>>16)&tnZipIfMt == tnZipIfLnk
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
type tnZipEnd struct {
|
|
654
|
+
prefix, totalRecords, cdOffset, cdSize int64
|
|
655
|
+
comment []byte
|
|
656
|
+
needTailFrom int64
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
func tnZipPlausibleEnd(buf []byte, pos int, scanStart int) bool {
|
|
660
|
+
le := binary.LittleEndian
|
|
661
|
+
disk, cdDisk := le.Uint16(buf[pos+4:]), le.Uint16(buf[pos+6:])
|
|
662
|
+
diskRecords, total := le.Uint16(buf[pos+8:]), le.Uint16(buf[pos+10:])
|
|
663
|
+
size, offset := le.Uint32(buf[pos+12:]), le.Uint32(buf[pos+16:])
|
|
664
|
+
needs64 := disk == tnZipS16 || cdDisk == tnZipS16 || diskRecords == tnZipS16 || total == tnZipS16 || size == tnZipS32 || offset == tnZipS32
|
|
665
|
+
loc := pos - 20
|
|
666
|
+
hasLoc := loc >= 0 && le.Uint32(buf[loc:]) == tnZipSigZ64Loc
|
|
667
|
+
if needs64 {
|
|
668
|
+
return hasLoc
|
|
669
|
+
}
|
|
670
|
+
if hasLoc {
|
|
671
|
+
return true
|
|
672
|
+
}
|
|
673
|
+
if disk != 0 || cdDisk != 0 || diskRecords != total || int64(total)*46 > int64(size) {
|
|
674
|
+
return false
|
|
675
|
+
}
|
|
676
|
+
cdPos := pos - int(size)
|
|
677
|
+
if cdPos < scanStart {
|
|
678
|
+
return true
|
|
679
|
+
}
|
|
680
|
+
if total == 0 {
|
|
681
|
+
return size == 0
|
|
682
|
+
}
|
|
683
|
+
return le.Uint32(buf[cdPos:]) == tnZipSigCentral
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
func tnZipFindEnd(buf []byte, base int64) tnZipEnd {
|
|
687
|
+
le := binary.LittleEndian
|
|
688
|
+
if len(buf) < 22 {
|
|
689
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "no end of central directory record found"))
|
|
690
|
+
}
|
|
691
|
+
floor := max(0, len(buf)-tnZipTailLength)
|
|
692
|
+
eocd, fallback, exact := -1, -1, -1
|
|
693
|
+
for pos := len(buf) - 22; pos >= floor; pos-- {
|
|
694
|
+
if le.Uint32(buf[pos:]) != tnZipSigEnd {
|
|
695
|
+
continue
|
|
696
|
+
}
|
|
697
|
+
end := pos + 22 + int(le.Uint16(buf[pos+20:]))
|
|
698
|
+
if end > len(buf) {
|
|
699
|
+
continue
|
|
700
|
+
}
|
|
701
|
+
if fallback < 0 {
|
|
702
|
+
fallback = pos
|
|
703
|
+
}
|
|
704
|
+
if end == len(buf) && exact < 0 {
|
|
705
|
+
exact = pos
|
|
706
|
+
}
|
|
707
|
+
if !tnZipPlausibleEnd(buf, pos, floor) {
|
|
708
|
+
continue
|
|
709
|
+
}
|
|
710
|
+
if eocd >= 0 {
|
|
711
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "ambiguous end of central directory records"))
|
|
712
|
+
}
|
|
713
|
+
eocd = pos
|
|
714
|
+
}
|
|
715
|
+
if eocd < 0 {
|
|
716
|
+
if exact >= 0 {
|
|
717
|
+
eocd = exact
|
|
718
|
+
} else {
|
|
719
|
+
eocd = fallback
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
if eocd < 0 {
|
|
723
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "no end of central directory record found"))
|
|
724
|
+
}
|
|
725
|
+
disk, cdDisk := le.Uint16(buf[eocd+4:]), le.Uint16(buf[eocd+6:])
|
|
726
|
+
diskRecords := int64(le.Uint16(buf[eocd+8:]))
|
|
727
|
+
total := int64(le.Uint16(buf[eocd+10:]))
|
|
728
|
+
size := int64(le.Uint32(buf[eocd+12:]))
|
|
729
|
+
offset := int64(le.Uint32(buf[eocd+16:]))
|
|
730
|
+
comment := buf[eocd+22 : eocd+22+int(le.Uint16(buf[eocd+20:]))]
|
|
731
|
+
needs64 := disk == tnZipS16 || cdDisk == tnZipS16 || diskRecords == tnZipS16 || total == tnZipS16 || size == tnZipS32 || offset == tnZipS32
|
|
732
|
+
recordPos := -1
|
|
733
|
+
loc := eocd - 20
|
|
734
|
+
multi := func() { panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "multi-disk archives are not supported")) }
|
|
735
|
+
var prefix int64
|
|
736
|
+
if loc >= 0 && le.Uint32(buf[loc:]) == tnZipSigZ64Loc {
|
|
737
|
+
raw := le.Uint64(buf[loc+8:])
|
|
738
|
+
recordOffset := int64(-1)
|
|
739
|
+
if raw <= 9007199254740991 {
|
|
740
|
+
recordOffset = int64(raw)
|
|
741
|
+
}
|
|
742
|
+
if recordOffset >= 0 {
|
|
743
|
+
recordPos = int(recordOffset - base)
|
|
744
|
+
}
|
|
745
|
+
if !(recordPos >= 0 && recordPos+56 <= loc && le.Uint32(buf[recordPos:]) == tnZipSigZ64End) {
|
|
746
|
+
recordPos = -1
|
|
747
|
+
for pos := loc - 56; pos >= max(0, loc-56-tnZipS16); pos-- {
|
|
748
|
+
if le.Uint32(buf[pos:]) != tnZipSigZ64End {
|
|
749
|
+
continue
|
|
750
|
+
}
|
|
751
|
+
if sz := le.Uint64(buf[pos+4:]); sz >= 44 && int64(pos)+12+int64(sz) == int64(loc) {
|
|
752
|
+
recordPos = pos
|
|
753
|
+
break
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if recordPos < 0 && needs64 {
|
|
758
|
+
if recordOffset >= 0 && recordOffset < base && base+int64(loc)-recordOffset <= 56+1024*1024 {
|
|
759
|
+
return tnZipEnd{needTailFrom: recordOffset}
|
|
760
|
+
}
|
|
761
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "Zip64 end of central directory record not found"))
|
|
762
|
+
}
|
|
763
|
+
if recordPos >= 0 {
|
|
764
|
+
if le.Uint32(buf[loc+16:]) > 1 || le.Uint32(buf[loc+4:]) != 0 {
|
|
765
|
+
multi()
|
|
766
|
+
}
|
|
767
|
+
if le.Uint32(buf[recordPos+16:]) != 0 || le.Uint32(buf[recordPos+20:]) != 0 || le.Uint64(buf[recordPos+24:]) != le.Uint64(buf[recordPos+32:]) {
|
|
768
|
+
multi()
|
|
769
|
+
}
|
|
770
|
+
t64, s64, o64 := int64(le.Uint64(buf[recordPos+32:])), int64(le.Uint64(buf[recordPos+40:])), int64(le.Uint64(buf[recordPos+48:]))
|
|
771
|
+
if (total != tnZipS16 && total != t64) || (size != tnZipS32 && size != s64) || (offset != tnZipS32 && offset != o64) {
|
|
772
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "Zip64 and classic end-of-central-directory records disagree"))
|
|
773
|
+
}
|
|
774
|
+
total, size, offset = t64, s64, o64
|
|
775
|
+
prefix = base + int64(recordPos) - (offset + size)
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
if recordPos < 0 {
|
|
779
|
+
if disk != 0 || cdDisk != 0 || diskRecords != total {
|
|
780
|
+
multi()
|
|
781
|
+
}
|
|
782
|
+
prefix = base + int64(eocd) - (offset + size)
|
|
783
|
+
}
|
|
784
|
+
if prefix < 0 {
|
|
785
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory does not fit inside the archive"))
|
|
786
|
+
}
|
|
787
|
+
if (total == 0 && size != 0) || total*46 > size {
|
|
788
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory record count is inconsistent with its size"))
|
|
789
|
+
}
|
|
790
|
+
return tnZipEnd{prefix: prefix, totalRecords: total, cdOffset: offset + prefix, cdSize: size, comment: comment, needTailFrom: -1}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// A local header's length, after checking its signature
|
|
794
|
+
func tnZipLocalLength(buf []byte, pos int, name string) int {
|
|
795
|
+
if pos < 0 || pos+30 > len(buf) || binary.LittleEndian.Uint32(buf[pos:]) != tnZipSigLocal {
|
|
796
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "entry "+tnZipQuote(name)+" has an invalid local file header"))
|
|
797
|
+
}
|
|
798
|
+
length := 30 + int(binary.LittleEndian.Uint16(buf[pos+26:])) + int(binary.LittleEndian.Uint16(buf[pos+28:]))
|
|
799
|
+
tnZipRange(buf, pos, length, "local file header")
|
|
800
|
+
return length
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
func tnZipReadEntries(buf []byte, end tnZipEnd) []*TnZipEntry {
|
|
804
|
+
type parsed struct {
|
|
805
|
+
entry *TnZipEntry
|
|
806
|
+
start, end int64
|
|
807
|
+
}
|
|
808
|
+
var all []parsed
|
|
809
|
+
pos := int(end.cdOffset)
|
|
810
|
+
cdEnd := int(end.cdOffset + end.cdSize)
|
|
811
|
+
for i := int64(0); i < end.totalRecords; i++ {
|
|
812
|
+
central := tnZipParseCentral(buf, pos)
|
|
813
|
+
if pos+central.length > cdEnd {
|
|
814
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory header is out of bounds"))
|
|
815
|
+
}
|
|
816
|
+
if central.disk != 0 {
|
|
817
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "multi-disk archives are not supported"))
|
|
818
|
+
}
|
|
819
|
+
localOffset := central.localOffset + end.prefix
|
|
820
|
+
length := tnZipLocalLength(buf, int(localOffset), central.fileName())
|
|
821
|
+
local := buf[localOffset : int(localOffset)+length]
|
|
822
|
+
dataStart := int(localOffset) + length
|
|
823
|
+
tnZipRange(buf, dataStart, int(central.compressedSize), "entry data")
|
|
824
|
+
e := &TnZipEntry{central: central, localExtra: local[30+int(binary.LittleEndian.Uint16(local[26:])):], localRead: true,
|
|
825
|
+
raw: buf[dataStart : dataStart+int(central.compressedSize)], inMemory: true, localFlags: binary.LittleEndian.Uint16(local[6:])}
|
|
826
|
+
all = append(all, parsed{e, localOffset, int64(dataStart) + central.compressedSize})
|
|
827
|
+
pos += central.length
|
|
828
|
+
}
|
|
829
|
+
if pos != cdEnd {
|
|
830
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory record count is inconsistent with its size"))
|
|
831
|
+
}
|
|
832
|
+
ranges := append([]parsed{}, all...)
|
|
833
|
+
sort.SliceStable(ranges, func(i, j int) bool { return ranges[i].start < ranges[j].start })
|
|
834
|
+
for i := range ranges {
|
|
835
|
+
bound := end.cdOffset
|
|
836
|
+
if i+1 < len(ranges) {
|
|
837
|
+
bound = ranges[i+1].start
|
|
838
|
+
}
|
|
839
|
+
if ranges[i].end > bound {
|
|
840
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "entry "+tnZipQuote(ranges[i].entry.Get_name())+" overlaps the next entry or the central directory (possible zip bomb)"))
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
out := make([]*TnZipEntry, len(all))
|
|
844
|
+
for i, p := range all {
|
|
845
|
+
out[i] = p.entry
|
|
846
|
+
}
|
|
847
|
+
return out
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// ---- ZipEntry ----
|
|
851
|
+
|
|
852
|
+
// The descriptor a ZipFile shares with the entries it hands out
|
|
853
|
+
type tnZipHandle struct {
|
|
854
|
+
f *os.File
|
|
855
|
+
closed bool
|
|
856
|
+
closing bool
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
type TnZipEntry struct {
|
|
860
|
+
central *tnZipCentral
|
|
861
|
+
localExtra []byte
|
|
862
|
+
localFlags uint16
|
|
863
|
+
localRead bool
|
|
864
|
+
raw []byte
|
|
865
|
+
inMemory bool
|
|
866
|
+
meta *tnZipMeta
|
|
867
|
+
source interface{}
|
|
868
|
+
sourceChan reflect.Value
|
|
869
|
+
serialized bool
|
|
870
|
+
handle *tnZipHandle
|
|
871
|
+
localOff int64
|
|
872
|
+
contentOff int64
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
func (e *TnZipEntry) tnPending() {
|
|
876
|
+
if e.meta != nil && e.meta.pending {
|
|
877
|
+
panic(tnZipErr("ERR_INVALID_STATE", "this streaming entry has not finished serializing yet"))
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
func (e *TnZipEntry) Get_compressed() bool { return e.Get_method() != tnZipStore }
|
|
882
|
+
func (e *TnZipEntry) Get_rawContent() []byte {
|
|
883
|
+
if !e.inMemory {
|
|
884
|
+
return nil
|
|
885
|
+
}
|
|
886
|
+
if e.raw == nil {
|
|
887
|
+
return []byte{}
|
|
888
|
+
}
|
|
889
|
+
return e.raw
|
|
890
|
+
}
|
|
891
|
+
func (e *TnZipEntry) Get_method() float64 {
|
|
892
|
+
if e.meta != nil {
|
|
893
|
+
return float64(e.meta.method)
|
|
894
|
+
}
|
|
895
|
+
return float64(e.central.method)
|
|
896
|
+
}
|
|
897
|
+
func (e *TnZipEntry) Get_flags() float64 {
|
|
898
|
+
if e.meta != nil {
|
|
899
|
+
return float64(e.meta.flags)
|
|
900
|
+
}
|
|
901
|
+
if e.localRead {
|
|
902
|
+
return float64(e.localFlags)
|
|
903
|
+
}
|
|
904
|
+
return float64(e.central.flags)
|
|
905
|
+
}
|
|
906
|
+
func (e *TnZipEntry) Get_crc32() float64 {
|
|
907
|
+
if e.meta != nil {
|
|
908
|
+
e.tnPending()
|
|
909
|
+
return float64(e.meta.crc)
|
|
910
|
+
}
|
|
911
|
+
return float64(e.central.crc)
|
|
912
|
+
}
|
|
913
|
+
func (e *TnZipEntry) Get_name() string {
|
|
914
|
+
if e.meta != nil {
|
|
915
|
+
return tnZipName(e.meta.name, e.meta.flags, e.meta.extra)
|
|
916
|
+
}
|
|
917
|
+
return e.central.fileName()
|
|
918
|
+
}
|
|
919
|
+
func (e *TnZipEntry) Get_nameBuffer() []byte {
|
|
920
|
+
if e.meta != nil {
|
|
921
|
+
return e.meta.name
|
|
922
|
+
}
|
|
923
|
+
return e.central.name
|
|
924
|
+
}
|
|
925
|
+
func (e *TnZipEntry) Get_comment() string {
|
|
926
|
+
if e.meta != nil {
|
|
927
|
+
return tnZipText(e.meta.comment, e.meta.flags)
|
|
928
|
+
}
|
|
929
|
+
return tnZipText(e.central.comment, e.central.flags)
|
|
930
|
+
}
|
|
931
|
+
func (e *TnZipEntry) Get_size() float64 {
|
|
932
|
+
if e.meta != nil {
|
|
933
|
+
e.tnPending()
|
|
934
|
+
return float64(e.meta.uncompressedSize)
|
|
935
|
+
}
|
|
936
|
+
return float64(e.central.uncompressedSize)
|
|
937
|
+
}
|
|
938
|
+
func (e *TnZipEntry) Get_compressedSize() float64 {
|
|
939
|
+
if e.meta != nil {
|
|
940
|
+
e.tnPending()
|
|
941
|
+
return float64(e.meta.compressedSize)
|
|
942
|
+
}
|
|
943
|
+
return float64(e.central.compressedSize)
|
|
944
|
+
}
|
|
945
|
+
func (e *TnZipEntry) Get_modified() time.Time {
|
|
946
|
+
if e.meta != nil {
|
|
947
|
+
return e.meta.modified
|
|
948
|
+
}
|
|
949
|
+
if e.handle != nil && !e.localRead {
|
|
950
|
+
func() {
|
|
951
|
+
defer func() { recover() }()
|
|
952
|
+
e.tnResolveLocal()
|
|
953
|
+
}()
|
|
954
|
+
}
|
|
955
|
+
if t, ok := tnZipExtraMtime(e.central.extra, e.localExtra); ok {
|
|
956
|
+
return t
|
|
957
|
+
}
|
|
958
|
+
return tnZipDosDecode(e.central.dosTime, e.central.dosDate)
|
|
959
|
+
}
|
|
960
|
+
func (e *TnZipEntry) Get_mode() float64 {
|
|
961
|
+
if e.meta != nil {
|
|
962
|
+
if e.meta.madeBy == tnZipUnix {
|
|
963
|
+
return float64((e.meta.external >> 16) & 0o7777)
|
|
964
|
+
}
|
|
965
|
+
return 0
|
|
966
|
+
}
|
|
967
|
+
return e.central.mode()
|
|
968
|
+
}
|
|
969
|
+
func (e *TnZipEntry) Get_isSymlink() bool {
|
|
970
|
+
if e.meta != nil {
|
|
971
|
+
return e.meta.madeBy == tnZipUnix && (e.meta.external>>16)&tnZipIfMt == tnZipIfLnk
|
|
972
|
+
}
|
|
973
|
+
return e.central.symlink()
|
|
974
|
+
}
|
|
975
|
+
func (e *TnZipEntry) Get_isFile() bool { return !e.Get_isDirectory() && !e.Get_isSymlink() }
|
|
976
|
+
func (e *TnZipEntry) Get_isDirectory() bool { return strings.HasSuffix(e.Get_name(), "/") }
|
|
977
|
+
|
|
978
|
+
func (e *TnZipEntry) tnFinalizeMeta() *tnZipMeta {
|
|
979
|
+
if e.meta != nil {
|
|
980
|
+
e.tnPending()
|
|
981
|
+
return e.meta
|
|
982
|
+
}
|
|
983
|
+
c := e.central
|
|
984
|
+
extra := tnZipStripZip64(c.extra)
|
|
985
|
+
modified := e.Get_modified()
|
|
986
|
+
ext, hasExt := int64(0), false
|
|
987
|
+
if _, ok := tnZipExtraMtime(extra); !ok {
|
|
988
|
+
ext, hasExt = tnZipExtendedMtime(modified)
|
|
989
|
+
}
|
|
990
|
+
e.meta = &tnZipMeta{name: c.name, comment: c.comment, extra: extra, flags: c.flags &^ tnZipDescriptor, method: c.method,
|
|
991
|
+
crc: c.crc, compressedSize: c.compressedSize, uncompressedSize: c.uncompressedSize, modified: modified,
|
|
992
|
+
extMtime: ext, hasExtMtime: hasExt, external: c.external, internal: c.internal, madeBy: c.version >> 8}
|
|
993
|
+
return e.meta
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
func (e *TnZipEntry) tnLive() *os.File {
|
|
997
|
+
if e.handle.closed {
|
|
998
|
+
panic(tnZipErr("ERR_INVALID_STATE", "cannot read a ZipEntry after its backing ZipFile has been closed"))
|
|
999
|
+
}
|
|
1000
|
+
return e.handle.f
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
func (e *TnZipEntry) tnResolveLocal() {
|
|
1004
|
+
if e.localRead {
|
|
1005
|
+
return
|
|
1006
|
+
}
|
|
1007
|
+
f := e.tnLive()
|
|
1008
|
+
fixed := make([]byte, 30)
|
|
1009
|
+
if _, err := f.ReadAt(fixed, e.localOff); err != nil || binary.LittleEndian.Uint32(fixed) != tnZipSigLocal {
|
|
1010
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "entry "+tnZipQuote(e.Get_name())+" has an invalid local file header"))
|
|
1011
|
+
}
|
|
1012
|
+
nameLen := int64(binary.LittleEndian.Uint16(fixed[26:]))
|
|
1013
|
+
extraLen := int64(binary.LittleEndian.Uint16(fixed[28:]))
|
|
1014
|
+
extra := make([]byte, extraLen)
|
|
1015
|
+
if extraLen > 0 {
|
|
1016
|
+
f.ReadAt(extra, e.localOff+30+nameLen)
|
|
1017
|
+
}
|
|
1018
|
+
e.localExtra = extra
|
|
1019
|
+
e.localFlags = binary.LittleEndian.Uint16(fixed[6:])
|
|
1020
|
+
e.localRead = true
|
|
1021
|
+
e.contentOff = e.localOff + 30 + nameLen + extraLen
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
func (e *TnZipEntry) tnInMemory() []byte {
|
|
1025
|
+
if !e.inMemory {
|
|
1026
|
+
panic(tnZipErr("ERR_INVALID_STATE", "the content of a streaming entry is not available for reading"))
|
|
1027
|
+
}
|
|
1028
|
+
return e.raw
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
func (e *TnZipEntry) tnCompressedBytes() []byte {
|
|
1032
|
+
if e.handle == nil {
|
|
1033
|
+
return e.tnInMemory()
|
|
1034
|
+
}
|
|
1035
|
+
size := int64(e.Get_compressedSize())
|
|
1036
|
+
e.tnResolveLocal()
|
|
1037
|
+
out := make([]byte, size)
|
|
1038
|
+
if _, err := e.tnLive().ReadAt(out, e.contentOff); err != nil && size > 0 {
|
|
1039
|
+
panic(TnNodeError("Error", "EIO", err.Error()))
|
|
1040
|
+
}
|
|
1041
|
+
return out
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
func tnZipMaxSize(options interface{}) (float64, bool) {
|
|
1045
|
+
if m, ok := tnZipOpt(options, "maxSize").(float64); ok {
|
|
1046
|
+
return m, true
|
|
1047
|
+
}
|
|
1048
|
+
return 0, false
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
func (e *TnZipEntry) tnDecode(compressed []byte, options interface{}, limit float64, hasLimit bool) []byte {
|
|
1052
|
+
name := e.Get_name()
|
|
1053
|
+
flags := uint16(e.Get_flags())
|
|
1054
|
+
method := uint16(e.Get_method())
|
|
1055
|
+
declared := int64(e.Get_size())
|
|
1056
|
+
if flags&tnZipEncrypted != 0 {
|
|
1057
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "entry "+tnZipQuote(name)+" is encrypted"))
|
|
1058
|
+
}
|
|
1059
|
+
if method != tnZipStore && method != tnZipDeflate && method != tnZipZstd {
|
|
1060
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "entry "+tnZipQuote(name)+" uses compression method "+strconv.Itoa(int(method))))
|
|
1061
|
+
}
|
|
1062
|
+
if hasLimit && float64(declared) > limit {
|
|
1063
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_TOO_LARGE", "entry "+tnZipQuote(name)+" declares "+strconv.FormatInt(declared, 10)+" bytes, exceeding the "+TnNumStr(limit)+" byte limit"))
|
|
1064
|
+
}
|
|
1065
|
+
capacity := declared + 1
|
|
1066
|
+
if hasLimit && int64(limit) < capacity {
|
|
1067
|
+
capacity = int64(limit)
|
|
1068
|
+
}
|
|
1069
|
+
data := compressed
|
|
1070
|
+
verb := "inflate"
|
|
1071
|
+
switch method {
|
|
1072
|
+
case tnZipDeflate:
|
|
1073
|
+
r := flate.NewReader(bytes.NewReader(compressed))
|
|
1074
|
+
out, err := io.ReadAll(io.LimitReader(r, capacity+1))
|
|
1075
|
+
if err != nil {
|
|
1076
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_CORRUPT", "entry "+tnZipQuote(name)+" failed to inflate: "+tnZlibError(err).message))
|
|
1077
|
+
}
|
|
1078
|
+
data = out
|
|
1079
|
+
case tnZipZstd:
|
|
1080
|
+
verb = "decompress"
|
|
1081
|
+
if tnZipZstdDecode == nil {
|
|
1082
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "entry "+tnZipQuote(name)+" uses compression method 93"))
|
|
1083
|
+
}
|
|
1084
|
+
out, err := tnZipZstdDecode(compressed, int(capacity+1))
|
|
1085
|
+
if err != nil {
|
|
1086
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_CORRUPT", "entry "+tnZipQuote(name)+" failed to decompress: "+err.Error()))
|
|
1087
|
+
}
|
|
1088
|
+
data = out
|
|
1089
|
+
}
|
|
1090
|
+
if method != tnZipStore && int64(len(data)) > capacity {
|
|
1091
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_CORRUPT", "entry "+tnZipQuote(name)+" "+verb+"s beyond its declared size of "+strconv.FormatInt(declared, 10)+" bytes"))
|
|
1092
|
+
}
|
|
1093
|
+
if int64(len(data)) != declared {
|
|
1094
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_CORRUPT", "entry "+tnZipQuote(name)+" produced "+strconv.Itoa(len(data))+" bytes, expected "+strconv.FormatInt(declared, 10)))
|
|
1095
|
+
}
|
|
1096
|
+
if verify, ok := tnZipOpt(options, "verify").(bool); (!ok || verify) && crc32.ChecksumIEEE(data) != uint32(e.Get_crc32()) {
|
|
1097
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_CORRUPT", "entry "+tnZipQuote(name)+" failed CRC-32 verification"))
|
|
1098
|
+
}
|
|
1099
|
+
if method == tnZipStore && e.handle == nil {
|
|
1100
|
+
return append([]byte{}, data...)
|
|
1101
|
+
}
|
|
1102
|
+
return data
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
func (e *TnZipEntry) contentSync(options ...interface{}) []byte {
|
|
1106
|
+
opts := tnZipFirst(options)
|
|
1107
|
+
limit, has := tnZipMaxSize(opts)
|
|
1108
|
+
if !has {
|
|
1109
|
+
limit = tnMaxZipContentSize
|
|
1110
|
+
}
|
|
1111
|
+
if declared := e.Get_size(); declared > limit {
|
|
1112
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_TOO_LARGE", "entry "+tnZipQuote(e.Get_name())+" declares "+TnNumStr(declared)+" bytes, exceeding the "+TnNumStr(limit)+" byte limit"))
|
|
1113
|
+
}
|
|
1114
|
+
if e.handle != nil && e.handle.closing {
|
|
1115
|
+
panic(tnZipErr("ERR_INVALID_STATE", "cannot read a ZipEntry after its backing ZipFile has been closed"))
|
|
1116
|
+
}
|
|
1117
|
+
return e.tnDecode(e.tnCompressedBytes(), opts, limit, true)
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
func (e *TnZipEntry) content(options ...interface{}) chan []byte {
|
|
1121
|
+
return tnZipSettle(func() []byte { return e.contentSync(options...) })
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// The decoded content as an async iterator of chunks (no default size limit)
|
|
1125
|
+
func (e *TnZipEntry) contentIterator(options ...interface{}) chan []byte {
|
|
1126
|
+
opts := tnZipFirst(options)
|
|
1127
|
+
if e.handle == nil {
|
|
1128
|
+
e.tnInMemory()
|
|
1129
|
+
}
|
|
1130
|
+
ch := make(chan []byte, 64)
|
|
1131
|
+
TnLoopRef()
|
|
1132
|
+
go func() {
|
|
1133
|
+
var failure interface{}
|
|
1134
|
+
var data []byte
|
|
1135
|
+
func() {
|
|
1136
|
+
defer func() {
|
|
1137
|
+
if r := recover(); r != nil {
|
|
1138
|
+
failure = r
|
|
1139
|
+
}
|
|
1140
|
+
}()
|
|
1141
|
+
limit, has := tnZipMaxSize(opts)
|
|
1142
|
+
data = e.tnDecode(e.tnCompressedBytes(), opts, limit, has)
|
|
1143
|
+
}()
|
|
1144
|
+
TnLoopPost(func() {
|
|
1145
|
+
defer TnLoopUnref()
|
|
1146
|
+
if failure != nil {
|
|
1147
|
+
TnReject(ch, failure)
|
|
1148
|
+
return
|
|
1149
|
+
}
|
|
1150
|
+
for len(data) > 0 {
|
|
1151
|
+
n := min(len(data), 65536)
|
|
1152
|
+
ch <- data[:n:n]
|
|
1153
|
+
data = data[n:]
|
|
1154
|
+
}
|
|
1155
|
+
close(ch)
|
|
1156
|
+
})
|
|
1157
|
+
}()
|
|
1158
|
+
return ch
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// The member's local header and raw bytes (a streaming entry cannot)
|
|
1162
|
+
func (e *TnZipEntry) tnSerializeSync() [][]byte {
|
|
1163
|
+
if e.source != nil {
|
|
1164
|
+
panic(tnZipErr("ERR_INVALID_STATE", "a streaming entry cannot be serialized synchronously"))
|
|
1165
|
+
}
|
|
1166
|
+
meta := e.tnFinalizeMeta()
|
|
1167
|
+
out := [][]byte{tnZipLocalHeader(meta)}
|
|
1168
|
+
if e.handle != nil {
|
|
1169
|
+
raw := e.tnCompressedBytes()
|
|
1170
|
+
for len(raw) > 0 {
|
|
1171
|
+
n := min(len(raw), tnZipReadChunk)
|
|
1172
|
+
out = append(out, raw[:n])
|
|
1173
|
+
raw = raw[n:]
|
|
1174
|
+
}
|
|
1175
|
+
} else if len(e.raw) > 0 {
|
|
1176
|
+
out = append(out, e.raw)
|
|
1177
|
+
}
|
|
1178
|
+
return out
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
// A streaming entry's source as a channel, taken on the loop goroutine
|
|
1182
|
+
func (e *TnZipEntry) tnPrepareSource() {
|
|
1183
|
+
if e.source == nil || e.sourceChan.IsValid() {
|
|
1184
|
+
return
|
|
1185
|
+
}
|
|
1186
|
+
switch s := e.source.(type) {
|
|
1187
|
+
case interface{ tnIterator() chan interface{} }:
|
|
1188
|
+
e.sourceChan = reflect.ValueOf(s.tnIterator())
|
|
1189
|
+
case *tnZipFileSource:
|
|
1190
|
+
default:
|
|
1191
|
+
rv := reflect.ValueOf(s)
|
|
1192
|
+
if rv.Kind() == reflect.Chan {
|
|
1193
|
+
e.sourceChan = rv
|
|
1194
|
+
} else if rv.Kind() == reflect.Slice || rv.Kind() == reflect.Array {
|
|
1195
|
+
ch := make(chan interface{}, rv.Len())
|
|
1196
|
+
for i := 0; i < rv.Len(); i++ {
|
|
1197
|
+
ch <- rv.Index(i).Interface()
|
|
1198
|
+
}
|
|
1199
|
+
close(ch)
|
|
1200
|
+
e.sourceChan = reflect.ValueOf(ch)
|
|
1201
|
+
} else {
|
|
1202
|
+
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"source\\" argument must be an AsyncIterable"))
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
// A file zipFiles streams (opened when the archive reaches it)
|
|
1208
|
+
type tnZipFileSource struct{ path string }
|
|
1209
|
+
|
|
1210
|
+
// Any entry's serialization, off the loop: a streaming entry drains its
|
|
1211
|
+
// source, compressing on the fly, then writes a Zip64 data descriptor
|
|
1212
|
+
func (e *TnZipEntry) tnSerialize(emit func([]byte)) {
|
|
1213
|
+
if e.source == nil {
|
|
1214
|
+
if e.handle == nil && !e.inMemory {
|
|
1215
|
+
panic(tnZipErr("ERR_INVALID_STATE", "a streaming entry can only be serialized once"))
|
|
1216
|
+
}
|
|
1217
|
+
for _, chunk := range e.tnSerializeSync() {
|
|
1218
|
+
emit(chunk)
|
|
1219
|
+
}
|
|
1220
|
+
return
|
|
1221
|
+
}
|
|
1222
|
+
if e.serialized {
|
|
1223
|
+
panic(tnZipErr("ERR_INVALID_STATE", "a streaming entry can only be serialized once"))
|
|
1224
|
+
}
|
|
1225
|
+
e.serialized = true
|
|
1226
|
+
meta := e.meta
|
|
1227
|
+
emit(tnZipLocalHeader(meta))
|
|
1228
|
+
var crc uint32
|
|
1229
|
+
var uncompressed, compressed int64
|
|
1230
|
+
out := func(b []byte) {
|
|
1231
|
+
if len(b) > 0 {
|
|
1232
|
+
compressed += int64(len(b))
|
|
1233
|
+
emit(append([]byte{}, b...))
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
var sink io.Writer
|
|
1237
|
+
var fw *flate.Writer
|
|
1238
|
+
var zbuf bytes.Buffer
|
|
1239
|
+
var zstdData []byte
|
|
1240
|
+
switch meta.method {
|
|
1241
|
+
case tnZipDeflate:
|
|
1242
|
+
fw, _ = flate.NewWriter(tnZipWriterFunc(out), -1)
|
|
1243
|
+
sink = fw
|
|
1244
|
+
case tnZipZstd:
|
|
1245
|
+
sink = &zbuf
|
|
1246
|
+
default:
|
|
1247
|
+
sink = tnZipWriterFunc(out)
|
|
1248
|
+
}
|
|
1249
|
+
feed := func(chunk []byte) {
|
|
1250
|
+
if len(chunk) == 0 {
|
|
1251
|
+
return
|
|
1252
|
+
}
|
|
1253
|
+
crc = crc32.Update(crc, crc32.IEEETable, chunk)
|
|
1254
|
+
uncompressed += int64(len(chunk))
|
|
1255
|
+
sink.Write(chunk)
|
|
1256
|
+
}
|
|
1257
|
+
if fs, ok := e.source.(*tnZipFileSource); ok {
|
|
1258
|
+
file, err := os.Open(fs.path)
|
|
1259
|
+
if err != nil {
|
|
1260
|
+
panic(TnNodeError("Error", "EIO", err.Error()))
|
|
1261
|
+
}
|
|
1262
|
+
buf := make([]byte, 65536)
|
|
1263
|
+
for {
|
|
1264
|
+
n, err := file.Read(buf)
|
|
1265
|
+
feed(buf[:n])
|
|
1266
|
+
if err != nil {
|
|
1267
|
+
break
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
file.Close()
|
|
1271
|
+
} else {
|
|
1272
|
+
ch := e.sourceChan
|
|
1273
|
+
for {
|
|
1274
|
+
v, ok := ch.Recv()
|
|
1275
|
+
if !ok {
|
|
1276
|
+
if reason, rejected := tnRejections.Load(ch.Interface()); rejected {
|
|
1277
|
+
panic(reason)
|
|
1278
|
+
}
|
|
1279
|
+
break
|
|
1280
|
+
}
|
|
1281
|
+
chunk, isBytes := v.Interface().([]byte)
|
|
1282
|
+
if !isBytes {
|
|
1283
|
+
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"chunk\\" argument must be an instance of Uint8Array. Received "+tnZipInspect(v.Interface())))
|
|
1284
|
+
}
|
|
1285
|
+
feed(chunk)
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
if fw != nil {
|
|
1289
|
+
fw.Close()
|
|
1290
|
+
}
|
|
1291
|
+
if meta.method == tnZipZstd {
|
|
1292
|
+
if tnZipZstdEncode == nil {
|
|
1293
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "Zstandard compression is not available"))
|
|
1294
|
+
}
|
|
1295
|
+
zstdData = tnZipZstdEncode(zbuf.Bytes())
|
|
1296
|
+
out(zstdData)
|
|
1297
|
+
}
|
|
1298
|
+
meta.crc = crc
|
|
1299
|
+
meta.uncompressedSize = uncompressed
|
|
1300
|
+
meta.compressedSize = compressed
|
|
1301
|
+
meta.pending = false
|
|
1302
|
+
emit(tnZipDataDescriptor(crc, compressed, uncompressed))
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
type tnZipWriterFunc func([]byte)
|
|
1306
|
+
|
|
1307
|
+
func (w tnZipWriterFunc) Write(b []byte) (int, error) {
|
|
1308
|
+
w(b)
|
|
1309
|
+
return len(b), nil
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
func (e *TnZipEntry) tnFinalize(localOffset int64, preserveDescriptor bool) []byte {
|
|
1313
|
+
meta := e.tnFinalizeMeta()
|
|
1314
|
+
if preserveDescriptor && e.central != nil && e.central.flags&tnZipDescriptor != 0 {
|
|
1315
|
+
copied := *meta
|
|
1316
|
+
copied.flags |= tnZipDescriptor
|
|
1317
|
+
return tnZipCentralHeader(&copied, localOffset)
|
|
1318
|
+
}
|
|
1319
|
+
return tnZipCentralHeader(meta, localOffset)
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
func (e *TnZipEntry) tnPromote(handle *tnZipHandle, localOffset int64) {
|
|
1323
|
+
if e.inMemory || e.handle != nil {
|
|
1324
|
+
return
|
|
1325
|
+
}
|
|
1326
|
+
e.handle = handle
|
|
1327
|
+
e.localOff = localOffset
|
|
1328
|
+
e.localRead = false
|
|
1329
|
+
e.source = nil
|
|
1330
|
+
e.sourceChan = reflect.Value{}
|
|
1331
|
+
e.serialized = false
|
|
1332
|
+
e.meta.flags &^= tnZipDescriptor
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
func (e *TnZipEntry) tnDisposeSource() {
|
|
1336
|
+
source := e.source
|
|
1337
|
+
e.source = nil
|
|
1338
|
+
e.serialized = true
|
|
1339
|
+
if d, ok := source.(interface{ destroy(...interface{}) *TnStream }); ok {
|
|
1340
|
+
d.destroy()
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
func (e *TnZipEntry) dispose() { e.tnDisposeSource() }
|
|
1345
|
+
|
|
1346
|
+
func tnZipNewEntry(filename string, data interface{}, options interface{}) (*tnZipMeta, []byte, uint16) {
|
|
1347
|
+
meta := tnZipCreateMeta(filename, options, false)
|
|
1348
|
+
content := tnZipBytes(data)
|
|
1349
|
+
isDir := strings.HasSuffix(filename, "/")
|
|
1350
|
+
if isDir && len(content) > 0 {
|
|
1351
|
+
panic(tnZipInvalidArg("data", data, "must be empty for a directory entry"))
|
|
1352
|
+
}
|
|
1353
|
+
meta.crc = crc32.ChecksumIEEE(content)
|
|
1354
|
+
meta.uncompressedSize = int64(len(content))
|
|
1355
|
+
method := uint16(tnZipDeflate)
|
|
1356
|
+
m, _ := tnZipOpt(options, "method").(string)
|
|
1357
|
+
if isDir || len(content) == 0 || m == "store" {
|
|
1358
|
+
method = tnZipStore
|
|
1359
|
+
} else if m == "zstd" {
|
|
1360
|
+
method = tnZipZstd
|
|
1361
|
+
}
|
|
1362
|
+
return meta, content, method
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
func tnZipFinishEntry(meta *tnZipMeta, content []byte, method uint16) *TnZipEntry {
|
|
1366
|
+
final := content
|
|
1367
|
+
switch method {
|
|
1368
|
+
case tnZipDeflate:
|
|
1369
|
+
var buf bytes.Buffer
|
|
1370
|
+
w, _ := flate.NewWriter(&buf, -1)
|
|
1371
|
+
w.Write(content)
|
|
1372
|
+
w.Close()
|
|
1373
|
+
if buf.Len() < len(content) {
|
|
1374
|
+
final = buf.Bytes()
|
|
1375
|
+
} else {
|
|
1376
|
+
method = tnZipStore
|
|
1377
|
+
}
|
|
1378
|
+
case tnZipZstd:
|
|
1379
|
+
if tnZipZstdEncode == nil {
|
|
1380
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "Zstandard compression is not available"))
|
|
1381
|
+
}
|
|
1382
|
+
if z := tnZipZstdEncode(content); len(z) < len(content) {
|
|
1383
|
+
final = z
|
|
1384
|
+
} else {
|
|
1385
|
+
method = tnZipStore
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
meta.method = method
|
|
1389
|
+
meta.compressedSize = int64(len(final))
|
|
1390
|
+
meta.pending = false
|
|
1391
|
+
return &TnZipEntry{raw: final, inMemory: true, meta: meta}
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
func TnZipEntryCreateSync(filename string, data interface{}, options ...interface{}) *TnZipEntry {
|
|
1395
|
+
meta, content, method := tnZipNewEntry(filename, data, tnZipFirst(options))
|
|
1396
|
+
return tnZipFinishEntry(meta, content, method)
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
func TnZipEntryCreate(filename string, data interface{}, options ...interface{}) chan *TnZipEntry {
|
|
1400
|
+
return tnZipSettle(func() *TnZipEntry { return TnZipEntryCreateSync(filename, data, options...) })
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
func TnZipEntryCreateStream(filename string, source interface{}, options ...interface{}) *TnZipEntry {
|
|
1404
|
+
opts := tnZipFirst(options)
|
|
1405
|
+
meta := tnZipCreateMeta(filename, opts, false)
|
|
1406
|
+
if strings.HasSuffix(filename, "/") {
|
|
1407
|
+
panic(tnZipInvalidArg("filename", filename, "a directory entry cannot be streamed"))
|
|
1408
|
+
}
|
|
1409
|
+
meta.flags |= tnZipDescriptor
|
|
1410
|
+
meta.method = tnZipDeflate
|
|
1411
|
+
switch m, _ := tnZipOpt(opts, "method").(string); m {
|
|
1412
|
+
case "store":
|
|
1413
|
+
meta.method = tnZipStore
|
|
1414
|
+
case "zstd":
|
|
1415
|
+
meta.method = tnZipZstd
|
|
1416
|
+
}
|
|
1417
|
+
meta.pending = true
|
|
1418
|
+
return &TnZipEntry{meta: meta, source: source}
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
func TnZipEntrySymlink(filename string, target string, options ...interface{}) *TnZipEntry {
|
|
1422
|
+
opts := tnZipFirst(options)
|
|
1423
|
+
meta := tnZipCreateMeta(filename, opts, true)
|
|
1424
|
+
content := []byte(target)
|
|
1425
|
+
meta.crc = crc32.ChecksumIEEE(content)
|
|
1426
|
+
meta.uncompressedSize = int64(len(content))
|
|
1427
|
+
meta.method = tnZipStore
|
|
1428
|
+
meta.compressedSize = int64(len(content))
|
|
1429
|
+
meta.pending = false
|
|
1430
|
+
return &TnZipEntry{raw: content, inMemory: true, meta: meta}
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
// ZipEntry.read(buffer): one read-only entry per member
|
|
1434
|
+
func TnZipEntryRead(buffer interface{}) []*TnZipEntry {
|
|
1435
|
+
buf := tnZipBytes(buffer)
|
|
1436
|
+
return tnZipReadEntries(buf, tnZipFindEnd(buf, 0))
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// A promise settled now: fn's result, or its throw as a rejection
|
|
1440
|
+
func tnZipSettle[T any](fn func() T) chan T {
|
|
1441
|
+
ch := make(chan T, 1)
|
|
1442
|
+
var failure interface{}
|
|
1443
|
+
var result T
|
|
1444
|
+
func() {
|
|
1445
|
+
defer func() {
|
|
1446
|
+
if r := recover(); r != nil {
|
|
1447
|
+
failure = r
|
|
1448
|
+
}
|
|
1449
|
+
}()
|
|
1450
|
+
result = fn()
|
|
1451
|
+
}()
|
|
1452
|
+
if failure != nil {
|
|
1453
|
+
TnReject(ch, failure)
|
|
1454
|
+
} else {
|
|
1455
|
+
ch <- result
|
|
1456
|
+
}
|
|
1457
|
+
return ch
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
// A promise for work done off the loop
|
|
1461
|
+
func tnZipBackground[T any](fn func() T) chan T {
|
|
1462
|
+
ch := make(chan T, 1)
|
|
1463
|
+
TnLoopRef()
|
|
1464
|
+
go func() {
|
|
1465
|
+
var failure interface{}
|
|
1466
|
+
var result T
|
|
1467
|
+
func() {
|
|
1468
|
+
defer func() {
|
|
1469
|
+
if r := recover(); r != nil {
|
|
1470
|
+
failure = r
|
|
1471
|
+
}
|
|
1472
|
+
}()
|
|
1473
|
+
result = fn()
|
|
1474
|
+
}()
|
|
1475
|
+
TnLoopPost(func() {
|
|
1476
|
+
defer TnLoopUnref()
|
|
1477
|
+
if failure != nil {
|
|
1478
|
+
TnReject(ch, failure)
|
|
1479
|
+
return
|
|
1480
|
+
}
|
|
1481
|
+
ch <- result
|
|
1482
|
+
})
|
|
1483
|
+
}()
|
|
1484
|
+
return ch
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
// ---- archives ----
|
|
1488
|
+
|
|
1489
|
+
func tnZipArchiveOptions(options interface{}) ([]byte, bool, int64) {
|
|
1490
|
+
if options == nil || TnIsNil(options) {
|
|
1491
|
+
return nil, false, 0
|
|
1492
|
+
}
|
|
1493
|
+
if s, ok := options.(string); ok {
|
|
1494
|
+
return []byte(s), true, 0
|
|
1495
|
+
}
|
|
1496
|
+
if p, ok := options.(*string); ok {
|
|
1497
|
+
return []byte(*p), true, 0
|
|
1498
|
+
}
|
|
1499
|
+
var comment []byte
|
|
1500
|
+
has := false
|
|
1501
|
+
switch c := tnZipOpt(options, "comment").(type) {
|
|
1502
|
+
case string:
|
|
1503
|
+
comment, has = []byte(c), true
|
|
1504
|
+
case []byte:
|
|
1505
|
+
comment, has = c, true
|
|
1506
|
+
}
|
|
1507
|
+
offset := int64(0)
|
|
1508
|
+
if o, ok := tnZipOpt(options, "baseOffset").(float64); ok {
|
|
1509
|
+
if o != math.Trunc(o) || o < 0 || o > 9007199254740991 {
|
|
1510
|
+
panic(TnNodeError("RangeError", "ERR_OUT_OF_RANGE", "The value of \\"options.baseOffset\\" is out of range. It must be >= 0 && <= 9007199254740991. Received "+TnNumStr(o)))
|
|
1511
|
+
}
|
|
1512
|
+
offset = int64(o)
|
|
1513
|
+
}
|
|
1514
|
+
return comment, has, offset
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
func tnZipCommentBytes(comment []byte) []byte {
|
|
1518
|
+
if len(comment) > tnZipS16 {
|
|
1519
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_TOO_LARGE", "the archive comment must not exceed 65535 bytes when encoded as UTF-8"))
|
|
1520
|
+
}
|
|
1521
|
+
return comment
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
func tnZipEntryList(entries interface{}) []*TnZipEntry {
|
|
1525
|
+
switch x := entries.(type) {
|
|
1526
|
+
case []*TnZipEntry:
|
|
1527
|
+
return x
|
|
1528
|
+
case interface{ tnValues() []*TnZipEntry }: // (a *TnZipBuffer, without naming its type)
|
|
1529
|
+
return x.tnValues()
|
|
1530
|
+
}
|
|
1531
|
+
var out []*TnZipEntry
|
|
1532
|
+
rv := reflect.ValueOf(entries)
|
|
1533
|
+
if rv.Kind() == reflect.Slice || rv.Kind() == reflect.Array {
|
|
1534
|
+
for i := 0; i < rv.Len(); i++ {
|
|
1535
|
+
if e, ok := rv.Index(i).Interface().(*TnZipEntry); ok {
|
|
1536
|
+
out = append(out, e)
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return out
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// Serializes entries through emit: members, central directory, trailer
|
|
1544
|
+
func tnZipWriteArchive(next func() (*TnZipEntry, bool), comment []byte, baseOffset int64, sync bool, emit func([]byte)) {
|
|
1545
|
+
var headers [][]byte
|
|
1546
|
+
pos := baseOffset
|
|
1547
|
+
for {
|
|
1548
|
+
entry, ok := next()
|
|
1549
|
+
if !ok {
|
|
1550
|
+
break
|
|
1551
|
+
}
|
|
1552
|
+
start := pos
|
|
1553
|
+
write := func(chunk []byte) {
|
|
1554
|
+
emit(chunk)
|
|
1555
|
+
pos += int64(len(chunk))
|
|
1556
|
+
}
|
|
1557
|
+
if sync {
|
|
1558
|
+
for _, chunk := range entry.tnSerializeSync() {
|
|
1559
|
+
write(chunk)
|
|
1560
|
+
}
|
|
1561
|
+
} else {
|
|
1562
|
+
entry.tnSerialize(write)
|
|
1563
|
+
}
|
|
1564
|
+
headers = append(headers, entry.tnFinalize(start, false))
|
|
1565
|
+
}
|
|
1566
|
+
cdOffset := pos
|
|
1567
|
+
for _, h := range headers {
|
|
1568
|
+
emit(h)
|
|
1569
|
+
pos += int64(len(h))
|
|
1570
|
+
}
|
|
1571
|
+
for _, chunk := range tnZipTrailer(int64(len(headers)), pos-cdOffset, cdOffset, comment) {
|
|
1572
|
+
emit(chunk)
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
func tnZipSliceNext(entries []*TnZipEntry) func() (*TnZipEntry, bool) {
|
|
1577
|
+
i := 0
|
|
1578
|
+
return func() (*TnZipEntry, bool) {
|
|
1579
|
+
if i >= len(entries) {
|
|
1580
|
+
return nil, false
|
|
1581
|
+
}
|
|
1582
|
+
i++
|
|
1583
|
+
return entries[i-1], true
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
func TnCreateZipArchiveSync(entries interface{}, options ...interface{}) [][]byte {
|
|
1588
|
+
comment, _, base := tnZipArchiveOptions(tnZipFirst(options))
|
|
1589
|
+
comment = tnZipCommentBytes(comment)
|
|
1590
|
+
list := tnZipEntryList(entries)
|
|
1591
|
+
var out [][]byte
|
|
1592
|
+
done := false
|
|
1593
|
+
defer func() {
|
|
1594
|
+
if !done {
|
|
1595
|
+
for _, e := range list {
|
|
1596
|
+
e.tnDisposeSource()
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
}()
|
|
1600
|
+
tnZipWriteArchive(tnZipSliceNext(list), comment, base, true, func(b []byte) { out = append(out, b) })
|
|
1601
|
+
done = true
|
|
1602
|
+
return out
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
// The entries of an async archive: a list (sources taken now) or an async
|
|
1606
|
+
// iterable of entries
|
|
1607
|
+
func tnZipEntrySource(entries interface{}) func() (*TnZipEntry, bool) {
|
|
1608
|
+
rv := reflect.ValueOf(entries)
|
|
1609
|
+
if rv.Kind() == reflect.Chan {
|
|
1610
|
+
return func() (*TnZipEntry, bool) {
|
|
1611
|
+
v, ok := rv.Recv()
|
|
1612
|
+
if !ok {
|
|
1613
|
+
if reason, rejected := tnRejections.Load(entries); rejected {
|
|
1614
|
+
panic(reason)
|
|
1615
|
+
}
|
|
1616
|
+
return nil, false
|
|
1617
|
+
}
|
|
1618
|
+
e, _ := v.Interface().(*TnZipEntry)
|
|
1619
|
+
if e == nil {
|
|
1620
|
+
return nil, false
|
|
1621
|
+
}
|
|
1622
|
+
done := make(chan struct{})
|
|
1623
|
+
TnLoopPost(func() {
|
|
1624
|
+
defer close(done)
|
|
1625
|
+
e.tnPrepareSource()
|
|
1626
|
+
})
|
|
1627
|
+
<-done
|
|
1628
|
+
return e, true
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
list := tnZipEntryList(entries)
|
|
1632
|
+
for _, e := range list {
|
|
1633
|
+
e.tnPrepareSource()
|
|
1634
|
+
}
|
|
1635
|
+
return tnZipSliceNext(list)
|
|
1636
|
+
}
|
|
1637
|
+
`;
|
|
1638
|
+
// Archive output as a Readable (pulls in node:stream)
|
|
1639
|
+
export const zipStreamHelper = `// node:zlib ZIP archive streams
|
|
1640
|
+
func tnZipReadable(run func(emit func([]byte))) *TnStream {
|
|
1641
|
+
s := TnNewReadable()
|
|
1642
|
+
s.objectMode = false
|
|
1643
|
+
s.source = func(st *TnStream) {
|
|
1644
|
+
TnLoopRef()
|
|
1645
|
+
go func() {
|
|
1646
|
+
var failure interface{}
|
|
1647
|
+
func() {
|
|
1648
|
+
defer func() {
|
|
1649
|
+
if r := recover(); r != nil {
|
|
1650
|
+
failure = r
|
|
1651
|
+
}
|
|
1652
|
+
}()
|
|
1653
|
+
run(func(chunk []byte) {
|
|
1654
|
+
c := chunk
|
|
1655
|
+
TnLoopPost(func() { st.push(c) })
|
|
1656
|
+
})
|
|
1657
|
+
}()
|
|
1658
|
+
TnLoopPost(func() {
|
|
1659
|
+
defer TnLoopUnref()
|
|
1660
|
+
if failure != nil {
|
|
1661
|
+
st.destroy(failure)
|
|
1662
|
+
return
|
|
1663
|
+
}
|
|
1664
|
+
st.push(nil)
|
|
1665
|
+
})
|
|
1666
|
+
}()
|
|
1667
|
+
}
|
|
1668
|
+
return s
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
func TnCreateZipArchive(entries interface{}, options ...interface{}) *TnStream {
|
|
1672
|
+
comment, _, base := tnZipArchiveOptions(tnZipFirst(options))
|
|
1673
|
+
comment = tnZipCommentBytes(comment)
|
|
1674
|
+
next := tnZipEntrySource(entries)
|
|
1675
|
+
return tnZipReadable(func(emit func([]byte)) {
|
|
1676
|
+
tnZipWriteArchive(next, comment, base, false, emit)
|
|
1677
|
+
})
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
// zipFiles([[source, name], ...]): stats each source (following links unless
|
|
1681
|
+
// followSymlinks: false), streams regular files
|
|
1682
|
+
func TnZipFiles(files interface{}, options ...interface{}) *TnStream {
|
|
1683
|
+
opts := tnZipFirst(options)
|
|
1684
|
+
follow := true
|
|
1685
|
+
if f, ok := tnZipOpt(opts, "followSymlinks").(bool); ok {
|
|
1686
|
+
follow = f
|
|
1687
|
+
}
|
|
1688
|
+
comment, _, base := tnZipArchiveOptions(opts)
|
|
1689
|
+
comment = tnZipCommentBytes(comment)
|
|
1690
|
+
var pairs [][2]string
|
|
1691
|
+
rv := reflect.ValueOf(files)
|
|
1692
|
+
for i := 0; rv.Kind() == reflect.Slice && i < rv.Len(); i++ {
|
|
1693
|
+
pair := reflect.ValueOf(rv.Index(i).Interface())
|
|
1694
|
+
if pair.Kind() == reflect.Slice && pair.Len() >= 2 {
|
|
1695
|
+
source, _ := pair.Index(0).Interface().(string)
|
|
1696
|
+
name, _ := pair.Index(1).Interface().(string)
|
|
1697
|
+
pairs = append(pairs, [2]string{source, name})
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
i := 0
|
|
1701
|
+
next := func() (*TnZipEntry, bool) {
|
|
1702
|
+
if i >= len(pairs) {
|
|
1703
|
+
return nil, false
|
|
1704
|
+
}
|
|
1705
|
+
source, name := pairs[i][0], pairs[i][1]
|
|
1706
|
+
i++
|
|
1707
|
+
var info os.FileInfo
|
|
1708
|
+
var err error
|
|
1709
|
+
if follow {
|
|
1710
|
+
info, err = os.Stat(source)
|
|
1711
|
+
} else {
|
|
1712
|
+
info, err = os.Lstat(source)
|
|
1713
|
+
}
|
|
1714
|
+
if err != nil {
|
|
1715
|
+
panic(TnSysError(err, "stat", source))
|
|
1716
|
+
}
|
|
1717
|
+
mode := float64(info.Mode().Perm())
|
|
1718
|
+
if runtime.GOOS == "windows" {
|
|
1719
|
+
if info.IsDir() {
|
|
1720
|
+
mode = 0o777
|
|
1721
|
+
} else if info.Mode().Perm()&0o200 != 0 {
|
|
1722
|
+
mode = 0o666
|
|
1723
|
+
} else {
|
|
1724
|
+
mode = 0o444
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
opts := map[string]interface{}{"mode": mode, "modified": info.ModTime()}
|
|
1728
|
+
switch {
|
|
1729
|
+
case info.Mode()&os.ModeSymlink != 0:
|
|
1730
|
+
target, _ := os.Readlink(source)
|
|
1731
|
+
return TnZipEntrySymlink(name, target, opts), true
|
|
1732
|
+
case info.IsDir():
|
|
1733
|
+
if !strings.HasSuffix(name, "/") {
|
|
1734
|
+
name += "/"
|
|
1735
|
+
}
|
|
1736
|
+
return TnZipEntryCreateSync(name, []byte{}, opts), true
|
|
1737
|
+
case !info.Mode().IsRegular():
|
|
1738
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "cannot archive "+tnZipQuote(source)+": not a regular file"))
|
|
1739
|
+
}
|
|
1740
|
+
return TnZipEntryCreateStream(name, &tnZipFileSource{path: source}, opts), true
|
|
1741
|
+
}
|
|
1742
|
+
return tnZipReadable(func(emit func([]byte)) {
|
|
1743
|
+
tnZipWriteArchive(next, comment, base, false, emit)
|
|
1744
|
+
})
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
func (f *TnZipFile) compact(comment ...interface{}) *TnStream {
|
|
1748
|
+
entries := f.tnCompactEntries()
|
|
1749
|
+
text := f.comment
|
|
1750
|
+
if len(comment) > 0 && comment[0] != nil {
|
|
1751
|
+
if s, ok := comment[0].(string); ok {
|
|
1752
|
+
text = []byte(s)
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
return tnZipReadable(func(emit func([]byte)) {
|
|
1756
|
+
tnZipWriteArchive(tnZipSliceNext(entries), text, 0, false, emit)
|
|
1757
|
+
})
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
// zipFile.stream(name[, options]): the decoded member as a Readable
|
|
1761
|
+
func (f *TnZipFile) stream(name string, options ...interface{}) chan *TnStream {
|
|
1762
|
+
return tnZipSettle(func() *TnStream {
|
|
1763
|
+
entry := f.getSync(name)
|
|
1764
|
+
ch := entry.contentIterator(options...)
|
|
1765
|
+
return tnZipReadable(func(emit func([]byte)) {
|
|
1766
|
+
for {
|
|
1767
|
+
chunk, ok := <-ch
|
|
1768
|
+
if !ok {
|
|
1769
|
+
if reason, rejected := tnRejections.Load(ch); rejected {
|
|
1770
|
+
panic(reason)
|
|
1771
|
+
}
|
|
1772
|
+
return
|
|
1773
|
+
}
|
|
1774
|
+
emit(chunk)
|
|
1775
|
+
}
|
|
1776
|
+
})
|
|
1777
|
+
})
|
|
1778
|
+
}
|
|
1779
|
+
`;
|
|
1780
|
+
export const zipContainersHelper = `// node:zlib ZipBuffer / ZipFile
|
|
1781
|
+
type TnZipBuffer struct {
|
|
1782
|
+
order []string
|
|
1783
|
+
byName map[string]*TnZipEntry
|
|
1784
|
+
comment []byte
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
func TnNewZipBuffer(buffer interface{}) *TnZipBuffer {
|
|
1788
|
+
buf := tnZipBytes(buffer)
|
|
1789
|
+
end := tnZipFindEnd(buf, 0)
|
|
1790
|
+
b := &TnZipBuffer{byName: map[string]*TnZipEntry{}, comment: end.comment}
|
|
1791
|
+
for _, entry := range tnZipReadEntries(buf, end) {
|
|
1792
|
+
b.addEntry(entry)
|
|
1793
|
+
}
|
|
1794
|
+
return b
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
func (b *TnZipBuffer) Get_writable() bool { return true }
|
|
1798
|
+
func (b *TnZipBuffer) Get_comment() string { return tnZipText(b.comment, 0) }
|
|
1799
|
+
func (b *TnZipBuffer) Get_size() float64 { return float64(len(b.order)) }
|
|
1800
|
+
|
|
1801
|
+
func (b *TnZipBuffer) has(name string) bool {
|
|
1802
|
+
_, ok := b.byName[name]
|
|
1803
|
+
return ok
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
func (b *TnZipBuffer) get(name string) *TnZipEntry {
|
|
1807
|
+
entry, ok := b.byName[name]
|
|
1808
|
+
if !ok {
|
|
1809
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_NOT_FOUND", name))
|
|
1810
|
+
}
|
|
1811
|
+
return entry
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
func (b *TnZipBuffer) addEntry(entry *TnZipEntry) *TnZipEntry {
|
|
1815
|
+
if entry == nil {
|
|
1816
|
+
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"entry\\" argument must be an instance of ZipEntry."))
|
|
1817
|
+
}
|
|
1818
|
+
name := entry.Get_name()
|
|
1819
|
+
if _, ok := b.byName[name]; !ok {
|
|
1820
|
+
b.order = append(b.order, name)
|
|
1821
|
+
}
|
|
1822
|
+
b.byName[name] = entry
|
|
1823
|
+
return entry
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
func (b *TnZipBuffer) addSync(filename string, data interface{}, options ...interface{}) *TnZipEntry {
|
|
1827
|
+
return b.addEntry(TnZipEntryCreateSync(filename, data, options...))
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
func (b *TnZipBuffer) add(filename string, data interface{}, options ...interface{}) chan *TnZipEntry {
|
|
1831
|
+
return tnZipSettle(func() *TnZipEntry { return b.addSync(filename, data, options...) })
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
func (b *TnZipBuffer) delete(name string) bool {
|
|
1835
|
+
if _, ok := b.byName[name]; !ok {
|
|
1836
|
+
return false
|
|
1837
|
+
}
|
|
1838
|
+
delete(b.byName, name)
|
|
1839
|
+
for i, n := range b.order {
|
|
1840
|
+
if n == name {
|
|
1841
|
+
b.order = append(b.order[:i:i], b.order[i+1:]...)
|
|
1842
|
+
break
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
return true
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
func (b *TnZipBuffer) clear() {
|
|
1849
|
+
b.order = nil
|
|
1850
|
+
b.byName = map[string]*TnZipEntry{}
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
func (b *TnZipBuffer) dispose() { b.clear() }
|
|
1854
|
+
|
|
1855
|
+
func (b *TnZipBuffer) keys() []string { return append([]string{}, b.order...) }
|
|
1856
|
+
|
|
1857
|
+
func (b *TnZipBuffer) tnValues() []*TnZipEntry {
|
|
1858
|
+
out := make([]*TnZipEntry, len(b.order))
|
|
1859
|
+
for i, name := range b.order {
|
|
1860
|
+
out[i] = b.byName[name]
|
|
1861
|
+
}
|
|
1862
|
+
return out
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
func (b *TnZipBuffer) values() []*TnZipEntry { return b.tnValues() }
|
|
1866
|
+
|
|
1867
|
+
func (b *TnZipBuffer) entries() [][]interface{} {
|
|
1868
|
+
out := make([][]interface{}, len(b.order))
|
|
1869
|
+
for i, name := range b.order {
|
|
1870
|
+
out[i] = []interface{}{name, b.byName[name]}
|
|
1871
|
+
}
|
|
1872
|
+
return out
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
func (b *TnZipBuffer) forEach(callback interface{}, thisArg ...interface{}) {
|
|
1876
|
+
for _, name := range b.keys() {
|
|
1877
|
+
if entry, ok := b.byName[name]; ok {
|
|
1878
|
+
TnInvoke(callback, entry, name, b)
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
func (b *TnZipBuffer) tnArchiveComment(options []interface{}) ([]byte, int64) {
|
|
1884
|
+
comment, has, base := tnZipArchiveOptions(tnZipFirst(options))
|
|
1885
|
+
if !has {
|
|
1886
|
+
comment = b.comment
|
|
1887
|
+
}
|
|
1888
|
+
return tnZipCommentBytes(comment), base
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
func (b *TnZipBuffer) toBufferSync(options ...interface{}) []byte {
|
|
1892
|
+
comment, base := b.tnArchiveComment(options)
|
|
1893
|
+
var out bytes.Buffer
|
|
1894
|
+
tnZipWriteArchive(tnZipSliceNext(b.tnValues()), comment, base, true, func(c []byte) { out.Write(c) })
|
|
1895
|
+
return out.Bytes()
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
func (b *TnZipBuffer) toBuffer(options ...interface{}) chan []byte {
|
|
1899
|
+
comment, base := b.tnArchiveComment(options)
|
|
1900
|
+
next := tnZipEntrySource(b.tnValues())
|
|
1901
|
+
return tnZipBackground(func() []byte {
|
|
1902
|
+
var out bytes.Buffer
|
|
1903
|
+
tnZipWriteArchive(next, comment, base, false, func(c []byte) { out.Write(c) })
|
|
1904
|
+
return out.Bytes()
|
|
1905
|
+
})
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
type tnZipInfo struct {
|
|
1909
|
+
central *tnZipCentral
|
|
1910
|
+
entry *TnZipEntry
|
|
1911
|
+
localOffset int64
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
type TnZipFile struct {
|
|
1915
|
+
handle *tnZipHandle
|
|
1916
|
+
closing bool
|
|
1917
|
+
writable bool
|
|
1918
|
+
comment []byte
|
|
1919
|
+
cdOffset int64
|
|
1920
|
+
mu sync.Mutex
|
|
1921
|
+
order []string
|
|
1922
|
+
infos map[string]*tnZipInfo
|
|
1923
|
+
pending int32
|
|
1924
|
+
last chan struct{}
|
|
1925
|
+
closed chan struct{}
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
func tnZipOpenFile(filename string, options []interface{}) *TnZipFile {
|
|
1929
|
+
writable := false
|
|
1930
|
+
if w := tnZipOpt(tnZipFirst(options), "writable"); w != nil {
|
|
1931
|
+
flag, ok := w.(bool)
|
|
1932
|
+
if !ok {
|
|
1933
|
+
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"options.writable\\" property must be of type boolean. Received "+tnZipInspect(w)))
|
|
1934
|
+
}
|
|
1935
|
+
writable = flag
|
|
1936
|
+
}
|
|
1937
|
+
flag := os.O_RDONLY
|
|
1938
|
+
if writable {
|
|
1939
|
+
flag = os.O_RDWR
|
|
1940
|
+
}
|
|
1941
|
+
f, err := os.OpenFile(filename, flag, 0)
|
|
1942
|
+
if err != nil {
|
|
1943
|
+
panic(TnSysError(err, "open", filename))
|
|
1944
|
+
}
|
|
1945
|
+
ok := false
|
|
1946
|
+
defer func() {
|
|
1947
|
+
if !ok {
|
|
1948
|
+
f.Close()
|
|
1949
|
+
}
|
|
1950
|
+
}()
|
|
1951
|
+
info, _ := f.Stat()
|
|
1952
|
+
size := info.Size()
|
|
1953
|
+
tailLength := min(size, int64(tnZipTailLength))
|
|
1954
|
+
tail := make([]byte, tailLength)
|
|
1955
|
+
f.ReadAt(tail, size-tailLength)
|
|
1956
|
+
end := tnZipFindEnd(tail, size-tailLength)
|
|
1957
|
+
if end.needTailFrom >= 0 {
|
|
1958
|
+
retry := make([]byte, size-end.needTailFrom)
|
|
1959
|
+
f.ReadAt(retry, end.needTailFrom)
|
|
1960
|
+
end = tnZipFindEnd(retry, end.needTailFrom)
|
|
1961
|
+
if end.needTailFrom >= 0 {
|
|
1962
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "Zip64 end of central directory record not found"))
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
if end.cdOffset+end.cdSize > size {
|
|
1966
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory is out of bounds"))
|
|
1967
|
+
}
|
|
1968
|
+
directory := make([]byte, end.cdSize)
|
|
1969
|
+
f.ReadAt(directory, end.cdOffset)
|
|
1970
|
+
zf := &TnZipFile{handle: &tnZipHandle{f: f}, writable: writable, comment: append([]byte{}, end.comment...), cdOffset: end.cdOffset, infos: map[string]*tnZipInfo{}}
|
|
1971
|
+
pos := 0
|
|
1972
|
+
for i := int64(0); i < end.totalRecords; i++ {
|
|
1973
|
+
central := tnZipParseCentral(directory, pos)
|
|
1974
|
+
if central.disk != 0 {
|
|
1975
|
+
panic(tnZipErr("ERR_ZIP_UNSUPPORTED_FEATURE", "multi-disk archives are not supported"))
|
|
1976
|
+
}
|
|
1977
|
+
local := central.localOffset + end.prefix
|
|
1978
|
+
if local < 0 || local+30+central.compressedSize > end.cdOffset {
|
|
1979
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "entry "+tnZipQuote(central.fileName())+" is out of bounds"))
|
|
1980
|
+
}
|
|
1981
|
+
name := central.fileName()
|
|
1982
|
+
if _, seen := zf.infos[name]; !seen {
|
|
1983
|
+
zf.order = append(zf.order, name)
|
|
1984
|
+
}
|
|
1985
|
+
zf.infos[name] = &tnZipInfo{central: central, localOffset: local}
|
|
1986
|
+
pos += central.length
|
|
1987
|
+
}
|
|
1988
|
+
if pos != len(directory) {
|
|
1989
|
+
panic(tnZipErr("ERR_ZIP_INVALID_ARCHIVE", "central directory record count is inconsistent with its size"))
|
|
1990
|
+
}
|
|
1991
|
+
ok = true
|
|
1992
|
+
return zf
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
func TnZipFileOpenSync(filename string, options ...interface{}) *TnZipFile {
|
|
1996
|
+
return tnZipOpenFile(filename, options)
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
func TnZipFileOpen(filename string, options ...interface{}) chan *TnZipFile {
|
|
2000
|
+
return tnZipBackground(func() *TnZipFile { return tnZipOpenFile(filename, options) })
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
func (f *TnZipFile) Get_writable() bool { return f.writable }
|
|
2004
|
+
func (f *TnZipFile) Get_comment() string { return tnZipText(f.comment, 0) }
|
|
2005
|
+
func (f *TnZipFile) Get_size() float64 {
|
|
2006
|
+
f.tnOpen()
|
|
2007
|
+
f.mu.Lock()
|
|
2008
|
+
defer f.mu.Unlock()
|
|
2009
|
+
return float64(len(f.order))
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
func (f *TnZipFile) tnWritable() {
|
|
2013
|
+
if !f.writable {
|
|
2014
|
+
panic(tnZipErr("ERR_ZIP_NOT_WRITABLE", ""))
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
func (f *TnZipFile) tnOpen() {
|
|
2019
|
+
if f.closing {
|
|
2020
|
+
panic(tnZipErr("ERR_INVALID_STATE", "the ZipFile has been closed"))
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
func (f *TnZipFile) tnNotBusy() {
|
|
2025
|
+
if atomic.LoadInt32(&f.pending) > 0 {
|
|
2026
|
+
panic(tnZipErr("ERR_INVALID_STATE", "cannot call a synchronous ZipFile method while an asynchronous add(), addEntry(), delete(), or close() call has not settled yet"))
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
// Async mutations run one after another, off the loop
|
|
2031
|
+
func tnZipEnqueue[T any](f *TnZipFile, job func() T) chan T {
|
|
2032
|
+
ch := make(chan T, 1)
|
|
2033
|
+
atomic.AddInt32(&f.pending, 1)
|
|
2034
|
+
prev := f.last
|
|
2035
|
+
done := make(chan struct{})
|
|
2036
|
+
f.last = done
|
|
2037
|
+
TnLoopRef()
|
|
2038
|
+
go func() {
|
|
2039
|
+
if prev != nil {
|
|
2040
|
+
<-prev
|
|
2041
|
+
}
|
|
2042
|
+
var failure interface{}
|
|
2043
|
+
var result T
|
|
2044
|
+
func() {
|
|
2045
|
+
defer func() {
|
|
2046
|
+
if r := recover(); r != nil {
|
|
2047
|
+
failure = r
|
|
2048
|
+
}
|
|
2049
|
+
}()
|
|
2050
|
+
result = job()
|
|
2051
|
+
}()
|
|
2052
|
+
close(done)
|
|
2053
|
+
TnLoopPost(func() {
|
|
2054
|
+
defer TnLoopUnref()
|
|
2055
|
+
atomic.AddInt32(&f.pending, -1)
|
|
2056
|
+
if failure != nil {
|
|
2057
|
+
TnReject(ch, failure)
|
|
2058
|
+
return
|
|
2059
|
+
}
|
|
2060
|
+
ch <- result
|
|
2061
|
+
})
|
|
2062
|
+
}()
|
|
2063
|
+
return ch
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
func (f *TnZipFile) has(name string) bool {
|
|
2067
|
+
f.tnOpen()
|
|
2068
|
+
f.mu.Lock()
|
|
2069
|
+
defer f.mu.Unlock()
|
|
2070
|
+
_, ok := f.infos[name]
|
|
2071
|
+
return ok
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
func (f *TnZipFile) tnHandleFor(info *tnZipInfo) *TnZipEntry {
|
|
2075
|
+
if info.entry == nil {
|
|
2076
|
+
info.entry = &TnZipEntry{central: info.central, handle: f.handle, localOff: info.localOffset}
|
|
2077
|
+
}
|
|
2078
|
+
return info.entry
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
func (f *TnZipFile) tnLookup(name string) *TnZipEntry {
|
|
2082
|
+
f.mu.Lock()
|
|
2083
|
+
defer f.mu.Unlock()
|
|
2084
|
+
info, ok := f.infos[name]
|
|
2085
|
+
if !ok {
|
|
2086
|
+
panic(tnZipErr("ERR_ZIP_ENTRY_NOT_FOUND", name))
|
|
2087
|
+
}
|
|
2088
|
+
return f.tnHandleFor(info)
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
func (f *TnZipFile) getSync(name string) *TnZipEntry {
|
|
2092
|
+
f.tnOpen()
|
|
2093
|
+
f.tnNotBusy()
|
|
2094
|
+
return f.tnLookup(name)
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
func (f *TnZipFile) get(name string) chan *TnZipEntry {
|
|
2098
|
+
return tnZipSettle(func() *TnZipEntry {
|
|
2099
|
+
f.tnOpen()
|
|
2100
|
+
return f.tnLookup(name)
|
|
2101
|
+
})
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
func (f *TnZipFile) tnRewrite() {
|
|
2105
|
+
f.mu.Lock()
|
|
2106
|
+
type record struct {
|
|
2107
|
+
entry *TnZipEntry
|
|
2108
|
+
local int64
|
|
2109
|
+
}
|
|
2110
|
+
records := make([]record, len(f.order))
|
|
2111
|
+
names := append([]string{}, f.order...)
|
|
2112
|
+
for i, name := range names {
|
|
2113
|
+
info := f.infos[name]
|
|
2114
|
+
entry := info.entry
|
|
2115
|
+
if entry == nil {
|
|
2116
|
+
entry = &TnZipEntry{central: info.central}
|
|
2117
|
+
}
|
|
2118
|
+
records[i] = record{entry, info.localOffset}
|
|
2119
|
+
}
|
|
2120
|
+
f.mu.Unlock()
|
|
2121
|
+
var headers [][]byte
|
|
2122
|
+
var size int64
|
|
2123
|
+
for _, r := range records {
|
|
2124
|
+
h := r.entry.tnFinalize(r.local, true)
|
|
2125
|
+
headers = append(headers, h)
|
|
2126
|
+
size += int64(len(h))
|
|
2127
|
+
}
|
|
2128
|
+
chunks := append(append([][]byte{}, headers...), tnZipTrailer(int64(len(records)), size, f.cdOffset, f.comment)...)
|
|
2129
|
+
pos := f.cdOffset
|
|
2130
|
+
for _, chunk := range chunks {
|
|
2131
|
+
if _, err := f.handle.f.WriteAt(chunk, pos); err != nil {
|
|
2132
|
+
panic(TnNodeError("Error", "EIO", err.Error()))
|
|
2133
|
+
}
|
|
2134
|
+
pos += int64(len(chunk))
|
|
2135
|
+
}
|
|
2136
|
+
f.handle.f.Truncate(pos)
|
|
2137
|
+
f.mu.Lock()
|
|
2138
|
+
for i, name := range names {
|
|
2139
|
+
f.infos[name] = &tnZipInfo{central: tnZipParseCentral(headers[i], 0), localOffset: records[i].local}
|
|
2140
|
+
}
|
|
2141
|
+
f.mu.Unlock()
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
func (f *TnZipFile) tnAdd(entry *TnZipEntry, sync bool) *TnZipEntry {
|
|
2145
|
+
localOffset := f.cdOffset
|
|
2146
|
+
written := int64(0)
|
|
2147
|
+
write := func(chunk []byte) {
|
|
2148
|
+
if _, err := f.handle.f.WriteAt(chunk, localOffset+written); err != nil {
|
|
2149
|
+
panic(TnNodeError("Error", "EIO", err.Error()))
|
|
2150
|
+
}
|
|
2151
|
+
written += int64(len(chunk))
|
|
2152
|
+
}
|
|
2153
|
+
func() {
|
|
2154
|
+
defer func() {
|
|
2155
|
+
if r := recover(); r != nil {
|
|
2156
|
+
func() {
|
|
2157
|
+
defer func() { recover() }()
|
|
2158
|
+
f.tnRewrite()
|
|
2159
|
+
}()
|
|
2160
|
+
panic(r)
|
|
2161
|
+
}
|
|
2162
|
+
}()
|
|
2163
|
+
if sync {
|
|
2164
|
+
for _, chunk := range entry.tnSerializeSync() {
|
|
2165
|
+
write(chunk)
|
|
2166
|
+
}
|
|
2167
|
+
} else {
|
|
2168
|
+
entry.tnSerialize(write)
|
|
2169
|
+
}
|
|
2170
|
+
}()
|
|
2171
|
+
name := entry.Get_name()
|
|
2172
|
+
f.mu.Lock()
|
|
2173
|
+
previous, existed := f.infos[name]
|
|
2174
|
+
if !existed {
|
|
2175
|
+
f.order = append(f.order, name)
|
|
2176
|
+
}
|
|
2177
|
+
f.infos[name] = &tnZipInfo{entry: entry, localOffset: localOffset}
|
|
2178
|
+
f.mu.Unlock()
|
|
2179
|
+
f.cdOffset = localOffset + written
|
|
2180
|
+
func() {
|
|
2181
|
+
defer func() {
|
|
2182
|
+
if r := recover(); r != nil {
|
|
2183
|
+
f.cdOffset = localOffset
|
|
2184
|
+
f.mu.Lock()
|
|
2185
|
+
if existed {
|
|
2186
|
+
f.infos[name] = previous
|
|
2187
|
+
} else {
|
|
2188
|
+
delete(f.infos, name)
|
|
2189
|
+
f.order = f.order[:len(f.order)-1]
|
|
2190
|
+
}
|
|
2191
|
+
f.mu.Unlock()
|
|
2192
|
+
func() {
|
|
2193
|
+
defer func() { recover() }()
|
|
2194
|
+
f.tnRewrite()
|
|
2195
|
+
}()
|
|
2196
|
+
panic(r)
|
|
2197
|
+
}
|
|
2198
|
+
}()
|
|
2199
|
+
f.tnRewrite()
|
|
2200
|
+
}()
|
|
2201
|
+
entry.tnPromote(f.handle, localOffset)
|
|
2202
|
+
return entry
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
func (f *TnZipFile) addEntrySync(entry *TnZipEntry) *TnZipEntry {
|
|
2206
|
+
f.tnWritable()
|
|
2207
|
+
f.tnOpen()
|
|
2208
|
+
f.tnNotBusy()
|
|
2209
|
+
return f.tnAdd(entry, true)
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
func (f *TnZipFile) addSync(filename string, data interface{}, options ...interface{}) *TnZipEntry {
|
|
2213
|
+
f.tnWritable()
|
|
2214
|
+
return f.addEntrySync(TnZipEntryCreateSync(filename, data, options...))
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
func (f *TnZipFile) addEntry(entry *TnZipEntry) chan *TnZipEntry {
|
|
2218
|
+
return tnZipSettleChan(func() chan *TnZipEntry {
|
|
2219
|
+
f.tnWritable()
|
|
2220
|
+
f.tnOpen()
|
|
2221
|
+
entry.tnPrepareSource()
|
|
2222
|
+
return tnZipEnqueue(f, func() *TnZipEntry { return f.tnAdd(entry, false) })
|
|
2223
|
+
})
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
func (f *TnZipFile) add(filename string, data interface{}, options ...interface{}) chan *TnZipEntry {
|
|
2227
|
+
return tnZipSettleChan(func() chan *TnZipEntry {
|
|
2228
|
+
f.tnWritable()
|
|
2229
|
+
f.tnOpen()
|
|
2230
|
+
return tnZipEnqueue(f, func() *TnZipEntry {
|
|
2231
|
+
return f.tnAdd(TnZipEntryCreateSync(filename, data, options...), false)
|
|
2232
|
+
})
|
|
2233
|
+
})
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
func (f *TnZipFile) tnDelete(name string) bool {
|
|
2237
|
+
f.mu.Lock()
|
|
2238
|
+
_, existed := f.infos[name]
|
|
2239
|
+
if existed {
|
|
2240
|
+
delete(f.infos, name)
|
|
2241
|
+
for i, n := range f.order {
|
|
2242
|
+
if n == name {
|
|
2243
|
+
f.order = append(f.order[:i:i], f.order[i+1:]...)
|
|
2244
|
+
break
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
f.mu.Unlock()
|
|
2249
|
+
if existed {
|
|
2250
|
+
f.tnRewrite()
|
|
2251
|
+
}
|
|
2252
|
+
return existed
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
func (f *TnZipFile) deleteSync(name string) bool {
|
|
2256
|
+
f.tnWritable()
|
|
2257
|
+
f.tnOpen()
|
|
2258
|
+
f.tnNotBusy()
|
|
2259
|
+
return f.tnDelete(name)
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
func (f *TnZipFile) delete(name string) chan bool {
|
|
2263
|
+
return tnZipSettleChan(func() chan bool {
|
|
2264
|
+
f.tnWritable()
|
|
2265
|
+
f.tnOpen()
|
|
2266
|
+
return tnZipEnqueue(f, func() bool { return f.tnDelete(name) })
|
|
2267
|
+
})
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
func (f *TnZipFile) tnCompactEntries() []*TnZipEntry {
|
|
2271
|
+
f.tnOpen()
|
|
2272
|
+
f.mu.Lock()
|
|
2273
|
+
defer f.mu.Unlock()
|
|
2274
|
+
out := make([]*TnZipEntry, len(f.order))
|
|
2275
|
+
for i, name := range f.order {
|
|
2276
|
+
out[i] = f.tnHandleFor(f.infos[name])
|
|
2277
|
+
}
|
|
2278
|
+
return out
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
func (f *TnZipFile) compactSync(comment ...interface{}) []byte {
|
|
2282
|
+
f.tnOpen()
|
|
2283
|
+
f.tnNotBusy()
|
|
2284
|
+
entries := f.tnCompactEntries()
|
|
2285
|
+
text := f.comment
|
|
2286
|
+
if len(comment) > 0 && comment[0] != nil {
|
|
2287
|
+
if s, ok := comment[0].(string); ok {
|
|
2288
|
+
text = []byte(s)
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
var out bytes.Buffer
|
|
2292
|
+
tnZipWriteArchive(tnZipSliceNext(entries), tnZipCommentBytes(text), 0, true, func(c []byte) { out.Write(c) })
|
|
2293
|
+
return out.Bytes()
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
func (f *TnZipFile) keys() []string {
|
|
2297
|
+
f.tnOpen()
|
|
2298
|
+
f.mu.Lock()
|
|
2299
|
+
defer f.mu.Unlock()
|
|
2300
|
+
return append([]string{}, f.order...)
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
func (f *TnZipFile) values() []chan *TnZipEntry {
|
|
2304
|
+
var out []chan *TnZipEntry
|
|
2305
|
+
for _, name := range f.keys() {
|
|
2306
|
+
out = append(out, f.get(name))
|
|
2307
|
+
}
|
|
2308
|
+
return out
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
func (f *TnZipFile) valuesSync() []*TnZipEntry {
|
|
2312
|
+
var out []*TnZipEntry
|
|
2313
|
+
for _, name := range f.keys() {
|
|
2314
|
+
out = append(out, f.getSync(name))
|
|
2315
|
+
}
|
|
2316
|
+
return out
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
func (f *TnZipFile) entries() [][]interface{} {
|
|
2320
|
+
var out [][]interface{}
|
|
2321
|
+
for _, name := range f.keys() {
|
|
2322
|
+
out = append(out, []interface{}{name, f.get(name)})
|
|
2323
|
+
}
|
|
2324
|
+
return out
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
func (f *TnZipFile) entriesSync() [][]interface{} {
|
|
2328
|
+
var out [][]interface{}
|
|
2329
|
+
for _, name := range f.keys() {
|
|
2330
|
+
out = append(out, []interface{}{name, f.getSync(name)})
|
|
2331
|
+
}
|
|
2332
|
+
return out
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
func (f *TnZipFile) forEach(callback interface{}, thisArg ...interface{}) {
|
|
2336
|
+
for _, pair := range f.entries() {
|
|
2337
|
+
TnInvoke(callback, pair[1], pair[0], f)
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
func (f *TnZipFile) forEachSync(callback interface{}, thisArg ...interface{}) {
|
|
2342
|
+
for _, pair := range f.entriesSync() {
|
|
2343
|
+
TnInvoke(callback, pair[1], pair[0], f)
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
func (f *TnZipFile) closeSync() {
|
|
2348
|
+
if f.closing {
|
|
2349
|
+
return
|
|
2350
|
+
}
|
|
2351
|
+
f.tnNotBusy()
|
|
2352
|
+
f.closing = true
|
|
2353
|
+
f.handle.closing = true
|
|
2354
|
+
f.handle.closed = true
|
|
2355
|
+
f.mu.Lock()
|
|
2356
|
+
f.order = nil
|
|
2357
|
+
f.infos = map[string]*tnZipInfo{}
|
|
2358
|
+
f.mu.Unlock()
|
|
2359
|
+
f.handle.f.Close()
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
func (f *TnZipFile) close() chan struct{} {
|
|
2363
|
+
if f.closing {
|
|
2364
|
+
ch := make(chan struct{}, 1)
|
|
2365
|
+
ch <- struct{}{}
|
|
2366
|
+
return ch
|
|
2367
|
+
}
|
|
2368
|
+
f.closing = true
|
|
2369
|
+
f.handle.closing = true
|
|
2370
|
+
return tnZipEnqueue(f, func() struct{} {
|
|
2371
|
+
f.handle.closed = true
|
|
2372
|
+
f.mu.Lock()
|
|
2373
|
+
f.order = nil
|
|
2374
|
+
f.infos = map[string]*tnZipInfo{}
|
|
2375
|
+
f.mu.Unlock()
|
|
2376
|
+
f.handle.f.Close()
|
|
2377
|
+
return struct{}{}
|
|
2378
|
+
})
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
func (f *TnZipFile) dispose() { f.closeSync() }
|
|
2382
|
+
|
|
2383
|
+
// An async method's synchronous throw, as a rejection
|
|
2384
|
+
func tnZipSettleChan[T any](fn func() chan T) (ch chan T) {
|
|
2385
|
+
defer func() {
|
|
2386
|
+
if r := recover(); r != nil {
|
|
2387
|
+
ch = TnPromiseReject[T](r)
|
|
2388
|
+
}
|
|
2389
|
+
}()
|
|
2390
|
+
return fn()
|
|
2391
|
+
}
|
|
2392
|
+
`;
|