typenative 0.7.0 → 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/bin/node/assert.js +2 -2
- package/bin/node/child_process.js +66 -8
- package/bin/node/fs.js +1012 -4
- package/bin/node/histogram.js +1991 -0
- package/bin/node/process.js +14 -2
- package/bin/node/sqlite.js +1488 -5
- package/bin/node/stream.js +2 -1
- package/bin/node/system_extra.js +3 -270
- package/bin/node/test.js +39 -1
- package/bin/node/test_report.js +47 -1
- package/bin/node/test_run.js +57 -2
- package/bin/node/util.js +8 -5
- package/bin/node/webassembly.js +20 -5
- package/bin/node/webview.js +3257 -244
- package/bin/node/zlib.js +118 -14
- package/bin/node/zlib_iter.js +585 -0
- package/bin/transpiler.js +1370 -258
- package/bin/version.js +1 -1
- 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 +10 -1
- package/types/tsconfig.json +17 -0
- package/types/typenative-npm.d.ts +492 -12
- package/types/typenative.d.ts +88 -2
- 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 -1746
- package/CONTRIBUTION.md +0 -133
- package/conformance.md +0 -1497
- package/examples/README.md +0 -114
- 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 -132
- 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 -174
- 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/LICENSE-MIT.txt +0 -20
- 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/LICENSE +0 -15
- 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/performance/README.md +0 -248
- package/performance/any-dynamic.ts +0 -21
- package/performance/any-record-view.ts +0 -20
- package/performance/arr-for-of.ts +0 -29
- package/performance/arr-hof.ts +0 -21
- package/performance/arr-push-index.ts +0 -15
- package/performance/arr-push-local.ts +0 -39
- package/performance/arr-slice-concat.ts +0 -24
- package/performance/arr-sort.ts +0 -21
- package/performance/async-await.ts +0 -24
- package/performance/async-promise-all.ts +0 -38
- package/performance/bigint-arith.ts +0 -36
- package/performance/buf-encode.ts +0 -29
- package/performance/class-accessors.ts +0 -48
- package/performance/class-dispatch.ts +0 -52
- package/performance/date-format.ts +0 -18
- 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/fn-rest-spread.ts +0 -43
- package/performance/gen-for-of.ts +0 -46
- package/performance/gen-next.ts +0 -32
- package/performance/iter-helpers.ts +0 -38
- package/performance/json-any.ts +0 -30
- package/performance/json-roundtrip.ts +0 -27
- package/performance/map-delete.ts +0 -24
- package/performance/map-iterate.ts +0 -26
- package/performance/map-number-keys.ts +0 -37
- 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-hash-imul.ts +0 -36
- 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/obj-keys-entries.ts +0 -44
- package/performance/obj-optional-chain.ts +0 -42
- package/performance/obj-record-dict.ts +0 -24
- package/performance/obj-spread-destructure.ts +0 -40
- package/performance/regex-exec.ts +0 -29
- package/performance/regex-replace-fn.ts +0 -24
- 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-methods.ts +0 -24
- package/performance/str-short-scan.ts +0 -26
- package/performance/str-split-join.ts +0 -23
- package/performance/str-switch-compare.ts +0 -50
- package/performance/str-template.ts +0 -16
- package/performance/str-unicode.ts +0 -25
- package/performance/typed-array.ts +0 -30
- package/performance/union-switch.ts +0 -57
- package/performance/union-typeof.ts +0 -40
- package/performance/wasm-call.ts +0 -63
- 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
package/bin/node/zlib.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// use them).
|
|
6
6
|
import { defineClass, defineHelper, defineModule, setResults } from './registry.js';
|
|
7
7
|
import { zipHelper, zipContainersHelper, zipStreamHelper } from './zlib_zip.js';
|
|
8
|
+
import { zlibIterHelper } from './zlib_iter.js';
|
|
8
9
|
const zlibHelper = `// node:zlib
|
|
9
10
|
func tnZlibInput(v interface{}) []byte {
|
|
10
11
|
switch x := v.(type) {
|
|
@@ -48,6 +49,8 @@ func tnZlibError(err error) *TnError {
|
|
|
48
49
|
// linked only into programs that use it
|
|
49
50
|
var tnBrotliEncode func(data []byte, options []interface{}) []byte
|
|
50
51
|
var tnBrotliDecode func(data []byte) []byte
|
|
52
|
+
var tnBrotliIterNewWriter func(w io.Writer, options []interface{}) io.WriteCloser
|
|
53
|
+
var tnBrotliIterNewReader func(r io.Reader) (io.Reader, func(error) *TnError)
|
|
51
54
|
|
|
52
55
|
// Set by the nodeZstd helper, so the Zstd codec (a vendored module) is
|
|
53
56
|
// linked only into programs that use it
|
|
@@ -55,6 +58,8 @@ var tnZstdEncode func(data []byte, options []interface{}) []byte
|
|
|
55
58
|
// The ZIP archive writer's Zstd method (nil unless the codec is linked)
|
|
56
59
|
var tnZipZstdEncode func(data []byte) []byte
|
|
57
60
|
var tnZstdDecode func(data []byte) []byte
|
|
61
|
+
var tnZstdIterNewWriter func(w io.Writer, options []interface{}) (io.WriteCloser, error)
|
|
62
|
+
var tnZstdIterNewReader func(r io.Reader) (io.ReadCloser, func(error) *TnError)
|
|
58
63
|
|
|
59
64
|
func tnCompress(format string, data []byte, options []interface{}) []byte {
|
|
60
65
|
if format == "brotli" {
|
|
@@ -209,12 +214,12 @@ const brotliHelper = `// node:zlib Brotli (github.com/andybalholm/brotli)
|
|
|
209
214
|
func init() {
|
|
210
215
|
tnBrotliEncode = tnBrotliCompress
|
|
211
216
|
tnBrotliDecode = tnBrotliDecompress
|
|
217
|
+
tnBrotliIterNewWriter = tnBrotliNewIterWriter
|
|
218
|
+
tnBrotliIterNewReader = tnBrotliNewIterReader
|
|
212
219
|
}
|
|
213
220
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
func tnBrotliCompress(data []byte, options []interface{}) []byte {
|
|
217
|
-
opts := brotli.WriterOptions{Quality: 11}
|
|
221
|
+
func tnBrotliOptions(options []interface{}, defaultQuality int) brotli.WriterOptions {
|
|
222
|
+
opts := brotli.WriterOptions{Quality: defaultQuality}
|
|
218
223
|
if len(options) > 0 && options[0] != nil {
|
|
219
224
|
if params := TnGet(options[0], "params"); params != nil {
|
|
220
225
|
if q, ok := TnGetValue(params, "1").(float64); ok {
|
|
@@ -225,8 +230,27 @@ func tnBrotliCompress(data []byte, options []interface{}) []byte {
|
|
|
225
230
|
}
|
|
226
231
|
}
|
|
227
232
|
}
|
|
233
|
+
return opts
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
func tnBrotliNewIterWriter(w io.Writer, options []interface{}) io.WriteCloser {
|
|
237
|
+
return brotli.NewWriterOptions(w, tnBrotliOptions(options, 6))
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
func tnBrotliNewIterReader(r io.Reader) (io.Reader, func(error) *TnError) {
|
|
241
|
+
return brotli.NewReader(r), func(err error) *TnError {
|
|
242
|
+
if err == nil || err == io.EOF || err.Error() == "brotli: excessive input" {
|
|
243
|
+
return nil
|
|
244
|
+
}
|
|
245
|
+
return tnBrotliError(err)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Options: { params: { [BROTLI_PARAM_QUALITY]: q, [BROTLI_PARAM_LGWIN]: w } };
|
|
250
|
+
// out-of-range values are clamped, as in Node
|
|
251
|
+
func tnBrotliCompress(data []byte, options []interface{}) []byte {
|
|
228
252
|
var buf bytes.Buffer
|
|
229
|
-
w := brotli.NewWriterOptions(&buf,
|
|
253
|
+
w := brotli.NewWriterOptions(&buf, tnBrotliOptions(options, 11))
|
|
230
254
|
w.Write(data)
|
|
231
255
|
w.Close()
|
|
232
256
|
return buf.Bytes()
|
|
@@ -243,16 +267,11 @@ var tnBrotliErrors = map[string]int{
|
|
|
243
267
|
"UNREACHABLE": -31,
|
|
244
268
|
}
|
|
245
269
|
|
|
246
|
-
func
|
|
247
|
-
out, err := io.ReadAll(brotli.NewReader(bytes.NewReader(data)))
|
|
248
|
-
if err == nil || err.Error() == "brotli: excessive input" {
|
|
249
|
-
// Node ignores bytes after the end of the stream
|
|
250
|
-
return out
|
|
251
|
-
}
|
|
270
|
+
func tnBrotliError(err error) *TnError {
|
|
252
271
|
if err == io.ErrUnexpectedEOF || err == io.EOF {
|
|
253
272
|
e := TnNodeError("Error", "Z_BUF_ERROR", "unexpected end of file")
|
|
254
273
|
e.props["errno"] = float64(-5)
|
|
255
|
-
|
|
274
|
+
return e
|
|
256
275
|
}
|
|
257
276
|
name := strings.TrimPrefix(err.Error(), "brotli: ")
|
|
258
277
|
errno, known := tnBrotliErrors[name]
|
|
@@ -269,7 +288,16 @@ func tnBrotliDecompress(data []byte) []byte {
|
|
|
269
288
|
}
|
|
270
289
|
e := TnNodeError("Error", "ERR__"+name, "Decompression failed")
|
|
271
290
|
e.props["errno"] = float64(errno)
|
|
272
|
-
|
|
291
|
+
return e
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
func tnBrotliDecompress(data []byte) []byte {
|
|
295
|
+
out, err := io.ReadAll(brotli.NewReader(bytes.NewReader(data)))
|
|
296
|
+
if err == nil || err.Error() == "brotli: excessive input" {
|
|
297
|
+
// Node ignores bytes after the end of the stream
|
|
298
|
+
return out
|
|
299
|
+
}
|
|
300
|
+
panic(tnBrotliError(err))
|
|
273
301
|
}`;
|
|
274
302
|
// Zstd's frames are located by hand before decoding: libzstd ignores bytes
|
|
275
303
|
// after the last complete frame (whatever they are) and reports a frame that
|
|
@@ -283,6 +311,50 @@ func init() {
|
|
|
283
311
|
// (the ZIP archive writer's method: 'zstd' entries use it when the codec
|
|
284
312
|
// is linked)
|
|
285
313
|
tnZipZstdEncode = func(data []byte) []byte { return tnZstdCompress(data, nil) }
|
|
314
|
+
tnZstdIterNewWriter = tnZstdNewIterWriter
|
|
315
|
+
tnZstdIterNewReader = tnZstdNewIterReader
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
func tnZstdNewIterWriter(w io.Writer, options []interface{}) (io.WriteCloser, error) {
|
|
319
|
+
opts := []zstd.EOption{zstd.WithEncoderLevel(zstd.EncoderLevelFromZstd(tnZstdLevel(options)))}
|
|
320
|
+
if len(options) > 0 && options[0] != nil {
|
|
321
|
+
if params := TnGet(options[0], "params"); params != nil {
|
|
322
|
+
if win, ok := TnGetValue(params, "101").(float64); ok && win >= 10 && win <= 31 {
|
|
323
|
+
opts = append(opts, zstd.WithWindowSize(1<<uint(win)))
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return zstd.NewWriter(w, opts...)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
func tnZstdNewIterReader(r io.Reader) (io.ReadCloser, func(error) *TnError) {
|
|
331
|
+
d, err := zstd.NewReader(r)
|
|
332
|
+
if err != nil {
|
|
333
|
+
panic(TnNodeError("Error", "ZSTD_error_GENERIC", "zstd decompression failed"))
|
|
334
|
+
}
|
|
335
|
+
return d.IOReadCloser(), func(err error) *TnError {
|
|
336
|
+
if err == nil || err == io.EOF {
|
|
337
|
+
return nil
|
|
338
|
+
}
|
|
339
|
+
if err == io.ErrUnexpectedEOF || strings.Contains(err.Error(), "unexpected EOF") {
|
|
340
|
+
e := TnNodeError("Error", "Z_BUF_ERROR", "unexpected end of file")
|
|
341
|
+
e.props["errno"] = float64(-5)
|
|
342
|
+
return e
|
|
343
|
+
}
|
|
344
|
+
if err == zstd.ErrMagicMismatch || strings.Contains(err.Error(), "magic") {
|
|
345
|
+
e := TnNodeError("Error", "ZSTD_error_prefix_unknown", "Unknown frame descriptor")
|
|
346
|
+
e.props["errno"] = float64(10)
|
|
347
|
+
return e
|
|
348
|
+
}
|
|
349
|
+
if strings.Contains(err.Error(), "checksum") || strings.Contains(err.Error(), "CRC") {
|
|
350
|
+
e := TnNodeError("Error", "ZSTD_error_checksum_wrong", "Restored data doesn't match checksum")
|
|
351
|
+
e.props["errno"] = float64(22)
|
|
352
|
+
return e
|
|
353
|
+
}
|
|
354
|
+
e := TnNodeError("Error", "ZSTD_error_corruption_detected", "Data corruption detected")
|
|
355
|
+
e.props["errno"] = float64(20)
|
|
356
|
+
return e
|
|
357
|
+
}
|
|
286
358
|
}
|
|
287
359
|
|
|
288
360
|
// The \`level\` option (default 3) or \`params[ZSTD_c_compressionLevel]\`;
|
|
@@ -574,9 +646,12 @@ const ZSTD_CONSTANTS = {
|
|
|
574
646
|
};
|
|
575
647
|
export function registerZlib(r) {
|
|
576
648
|
defineModule(r, 'zlib');
|
|
649
|
+
defineModule(r, 'zlib/iter');
|
|
577
650
|
defineHelper(r, 'nodeZlib', ['bytes', 'compress/flate', 'compress/gzip', 'compress/zlib', 'hash/crc32', 'io', 'strings'], ['error', 'buffer', 'dynamic', 'eventLoop', 'promise', 'nodeInvoke'], zlibHelper);
|
|
578
651
|
defineHelper(r, 'nodeBrotli', ['bytes', 'github.com/andybalholm/brotli', 'io', 'strings'], ['nodeZlib'], brotliHelper);
|
|
579
|
-
defineHelper(r, 'nodeZstd', ['bytes', 'github.com/klauspost/compress/zstd', 'strings'], ['nodeZlib'], zstdHelper);
|
|
652
|
+
defineHelper(r, 'nodeZstd', ['bytes', 'github.com/klauspost/compress/zstd', 'io', 'strings'], ['nodeZlib'], zstdHelper);
|
|
653
|
+
defineHelper(r, 'nodeZlibIter', ['bytes', 'compress/gzip', 'compress/zlib', 'io', 'iter', 'reflect'], ['nodeZlib', 'generatorStep', 'dynamic', 'error', 'buffer'], zlibIterHelper);
|
|
654
|
+
defineClass(r, 'zlib/iter.Transform', '*TnZlibIterTransform', 'class', 'transform=iter.Seq[[][]byte]', '', '', '');
|
|
580
655
|
// Codec entries pull in the codec's helper too
|
|
581
656
|
const use = (format) => r.helper(format === 'brotli' ? 'nodeBrotli' : format === 'zstd' ? 'nodeZstd' : 'nodeZlib');
|
|
582
657
|
const formats = {
|
|
@@ -646,6 +721,35 @@ export function registerZlib(r) {
|
|
|
646
721
|
return `TnCrc32(${call.args.join(', ')})`;
|
|
647
722
|
};
|
|
648
723
|
setResults(r, 'zlib', 'crc32=float64');
|
|
724
|
+
// node:zlib/iter — iterable compression / decompression transforms (sync + async)
|
|
725
|
+
const iterTransforms = {
|
|
726
|
+
compressGzipSync: ['gzip', true, false],
|
|
727
|
+
decompressGzipSync: ['gzip', false, false],
|
|
728
|
+
compressDeflateSync: ['deflate', true, false],
|
|
729
|
+
decompressDeflateSync: ['deflate', false, false],
|
|
730
|
+
compressBrotliSync: ['brotli', true, false],
|
|
731
|
+
decompressBrotliSync: ['brotli', false, false],
|
|
732
|
+
compressZstdSync: ['zstd', true, false],
|
|
733
|
+
decompressZstdSync: ['zstd', false, false],
|
|
734
|
+
compressGzip: ['gzip', true, true],
|
|
735
|
+
decompressGzip: ['gzip', false, true],
|
|
736
|
+
compressDeflate: ['deflate', true, true],
|
|
737
|
+
decompressDeflate: ['deflate', false, true],
|
|
738
|
+
compressBrotli: ['brotli', true, true],
|
|
739
|
+
decompressBrotli: ['brotli', false, true],
|
|
740
|
+
compressZstd: ['zstd', true, true],
|
|
741
|
+
decompressZstd: ['zstd', false, true]
|
|
742
|
+
};
|
|
743
|
+
for (const name of Object.keys(iterTransforms)) {
|
|
744
|
+
const [format, compress, async] = iterTransforms[name];
|
|
745
|
+
r.functions[`zlib/iter.${name}`] = (call) => {
|
|
746
|
+
use(format);
|
|
747
|
+
r.helper('nodeZlibIter');
|
|
748
|
+
const args = [JSON.stringify(format), compress ? 'true' : 'false', async ? 'true' : 'false', ...call.args];
|
|
749
|
+
return `TnNewZlibIterTransform(${args.join(', ')})`;
|
|
750
|
+
};
|
|
751
|
+
r.results[`zlib/iter.${name}`] = '*TnZlibIterTransform';
|
|
752
|
+
}
|
|
649
753
|
// ZIP archives (Node 26.8): ZipEntry / ZipBuffer / ZipFile, createZipArchive(Sync), zipFiles
|
|
650
754
|
defineHelper(r, 'nodeZip', ['bytes', 'compress/flate', 'encoding/binary', 'encoding/json', 'hash/crc32', 'io', 'math', 'os', 'reflect', 'sort', 'strconv', 'strings', 'time', 'unicode/utf8'], ['error', 'buffer', 'date', 'dynamic', 'eventLoop', 'promise', 'nodeZlib', 'nodeStream'], zipHelper);
|
|
651
755
|
defineHelper(r, 'nodeZipContainers', ['bytes', 'os', 'sync', 'sync/atomic'], ['nodeZip', 'fsErrors', 'nodeInvoke', 'nodeStream'], zipContainersHelper);
|