typenative 0.4.1 → 0.6.0
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/.github/workflows/ci.yml +2 -2
- package/.github/workflows/npm-publish-github-packages.yml +2 -2
- package/CHANGELOG.md +442 -1
- package/CONTRIBUTION.md +2 -1
- package/README.md +73 -25
- package/bin/cli.js +2 -0
- package/bin/index.js +75 -5
- package/bin/main.js +2 -0
- package/bin/node/assert.js +2 -2
- package/bin/node/async_hooks.js +1 -1
- package/bin/node/buffer.js +16 -5
- package/bin/node/child_process.js +7 -7
- package/bin/node/cluster.js +3 -3
- package/bin/node/core.js +41 -0
- package/bin/node/crypto_keys.js +21 -21
- package/bin/node/dgram.js +1 -1
- package/bin/node/diagnostics_channel.js +3 -3
- package/bin/node/dns.js +2 -2
- package/bin/node/events.js +18 -13
- package/bin/node/fetch.js +2 -2
- package/bin/node/fs.js +3 -3
- package/bin/node/fs_watch.js +5 -5
- package/bin/node/http.js +3 -3
- package/bin/node/http2.js +3 -3
- package/bin/node/net.js +8 -8
- package/bin/node/path.js +17 -3
- package/bin/node/process.js +47 -11
- package/bin/node/punycode.js +2 -2
- package/bin/node/readline.js +1 -1
- package/bin/node/registry.js +4 -1
- package/bin/node/sqlite.js +6 -6
- package/bin/node/stream.js +81 -15
- package/bin/node/stream_web.js +10 -10
- package/bin/node/system_extra.js +3 -3
- package/bin/node/test.js +674 -366
- package/bin/node/test_coverage.js +187 -0
- package/bin/node/test_report.js +1392 -0
- package/bin/node/test_run.js +575 -0
- package/bin/node/timers.js +8 -6
- package/bin/node/tls.js +5 -5
- package/bin/node/url.js +1 -1
- package/bin/node/util.js +31 -7
- package/bin/node/util_extra.js +7 -7
- package/bin/node/webview.js +654 -0
- package/bin/node/worker_threads.js +1 -1
- package/bin/node/zlib.js +3 -3
- package/bin/parse-node.js +6 -2
- package/bin/regex_vm.js +2057 -0
- package/bin/transpiler.js +32872 -11265
- package/bin/typecheck-node.js +2 -1
- package/bin/version.js +1 -1
- package/conformance.md +515 -345
- package/examples/README.md +71 -11
- package/examples/angular-templates/README.md +139 -0
- package/examples/angular-templates/bench.mjs +173 -0
- package/examples/angular-templates/dom-type-globals.d.ts +21 -0
- package/examples/angular-templates/dom-type-stubs.ts +21 -0
- package/examples/angular-templates/main.ts +135 -0
- package/examples/angular-templates/parity.mjs +157 -0
- package/examples/angular-templates/run-node.mjs +69 -0
- package/examples/angular-templates/vendor/angular/compiler/LICENSE +21 -0
- package/examples/desktop-notes/README.md +106 -0
- package/examples/desktop-notes/bench.mjs +125 -0
- package/examples/desktop-notes/main.ts +131 -0
- package/examples/desktop-notes/package-lock.json +726 -0
- package/examples/desktop-notes/package.json +9 -0
- package/examples/desktop-notes/ui.ts +176 -0
- package/examples/dupe-finder/README.md +78 -0
- package/examples/dupe-finder/bench.mjs +120 -0
- package/examples/dupe-finder/main.ts +87 -0
- package/examples/fibonacci/README.md +7 -7
- package/examples/hello-world/README.md +6 -6
- package/examples/json-server/README.md +19 -18
- package/examples/mandelbrot-png/README.md +63 -0
- package/examples/mandelbrot-png/bench.mjs +95 -0
- package/examples/mandelbrot-png/main.ts +98 -0
- package/examples/mandelbrot-png/preview.png +0 -0
- package/examples/marked-cli/README.md +160 -0
- package/examples/marked-cli/bench.mjs +178 -0
- package/examples/marked-cli/main.ts +292 -0
- package/examples/marked-cli/parity.mjs +185 -0
- package/examples/marked-cli/vendor/marked/LICENSE +44 -0
- package/examples/marked-cli/vendor/marked/VENDOR.md +26 -0
- package/examples/openai-chat/README.md +148 -0
- package/examples/openai-chat/bench.mjs +175 -0
- package/examples/openai-chat/main.ts +488 -0
- package/examples/react-compiler/README.md +170 -0
- package/examples/react-compiler/bench.mjs +181 -0
- package/examples/react-compiler/main.ts +158 -0
- package/examples/react-compiler/parity.mjs +362 -0
- package/examples/react-compiler/run-node.mjs +88 -0
- package/examples/react-compiler/vendor/babel/LICENSE +22 -0
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +15 -0
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +51 -0
- package/examples/react-compiler/vendor/charcodes/package.json +25 -0
- package/examples/react-compiler/vendor/invariant/LICENSE +21 -0
- package/examples/react-compiler/vendor/invariant/invariant.cjs +51 -0
- package/examples/react-compiler/vendor/invariant/invariant.d.cts +11 -0
- package/examples/react-compiler/vendor/invariant/types/LICENSE +21 -0
- package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +19 -0
- package/examples/react-compiler/vendor/js-tokens/LICENSE +21 -0
- package/examples/react-compiler/vendor/js-tokens/index.cjs +23 -0
- package/examples/react-compiler/vendor/js-tokens/index.d.cts +13 -0
- package/examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt +20 -0
- package/examples/react-compiler/vendor/jsesc/jsesc.cjs +337 -0
- package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +384 -0
- package/examples/react-compiler/vendor/jsesc/types/LICENSE +21 -0
- package/examples/react-compiler/vendor/picocolors/LICENSE +15 -0
- package/examples/react-compiler/vendor/picocolors/picocolors.cjs +75 -0
- package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +5 -0
- package/examples/react-compiler/vendor/picocolors/types.d.ts +51 -0
- package/examples/react-compiler/vendor/react-compiler/LICENSE +21 -0
- package/examples/react-compiler/vendor/stubs/babel-core.ts +31 -0
- package/examples/react-compiler/vendor/stubs/debug.ts +18 -0
- package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +13 -0
- package/examples/react-compiler/vendor/stubs/pretty-format.ts +18 -0
- package/examples/react-compiler/vendor/zod/LICENSE +21 -0
- package/examples/react-compiler/vendor/zod-validation-error/LICENSE +9 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +5 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +49 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +48 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +50 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +6 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +126 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +39 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +78 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +2 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +131 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +54 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +40 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +76 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +76 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +27 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +27 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +13 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +61 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +38 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +20 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +5 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +8 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +11 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +20 -0
- package/examples/react-compiler/vendor.mjs +688 -0
- package/examples/todo-cli/README.md +69 -0
- package/examples/todo-cli/bench.mjs +89 -0
- package/examples/todo-cli/main.ts +92 -0
- package/examples/yaml-cli/README.md +146 -0
- package/examples/yaml-cli/bench.mjs +265 -0
- package/examples/yaml-cli/main.ts +29 -0
- package/examples/yaml-cli/parity.mjs +156 -0
- package/examples/yaml-cli/vendor/yaml/LICENSE +13 -0
- package/examples/yaml-cli/vendor/yaml/VENDOR.md +25 -0
- package/govendor/github.com/jchv/go-webview2/LICENSE +22 -0
- package/govendor/github.com/jchv/go-webview2/README.md +21 -0
- package/govendor/github.com/jchv/go-webview2/common.go +84 -0
- package/govendor/github.com/jchv/go-webview2/go.mod +3 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32.go +194 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32_386.go +14 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32_64bit.go +15 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_COLOR.go +8 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND.go +9 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_KEY_EVENT_KIND.go +10 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_MOVE_FOCUS_REASON.go +9 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_PHYSICAL_KEY_STATUS.go +10 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_WEB_RESOURCE_CONTEXT.go +23 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventArgs.go +78 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventHandler.go +52 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller.go +132 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller2.go +74 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventArgs.go +17 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Settings.go +270 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequest.go +43 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventArgs.go +51 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceResponse.go +21 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_2.go +21 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_3.go +60 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebViewSettings.go +396 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium.go +361 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_386.go +24 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_amd64.go +22 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_arm64.go +26 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc.go +13 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go17.go +51 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go18.go +16 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/corewebview2.go +411 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/guid.go +223 -0
- package/govendor/github.com/jchv/go-webview2/webview.go +482 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/README.md +3 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module.go +153 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_386.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_amd64.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_arm64.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/arm64/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x64/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x86/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-winloader/LICENSE.md +7 -0
- package/govendor/github.com/jchv/go-winloader/README.md +124 -0
- package/govendor/github.com/jchv/go-winloader/common.go +11 -0
- package/govendor/github.com/jchv/go-winloader/go.mod +3 -0
- package/govendor/github.com/jchv/go-winloader/internal/loader/loader.go +25 -0
- package/govendor/github.com/jchv/go-winloader/internal/loader/machine.go +53 -0
- package/govendor/github.com/jchv/go-winloader/internal/memloader/cache.go +42 -0
- package/govendor/github.com/jchv/go-winloader/internal/memloader/loader.go +253 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/export.go +76 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/format.go +522 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/import.go +106 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/module.go +91 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/reloc.go +177 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/util.go +40 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/common.go +55 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_other.go +71 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_windows.go +179 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go +17 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_windows.go +73 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go +64 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/machine_windows.go +32 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_386.go +9 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_amd64.go +9 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_arm64.go +9 -0
- package/govendor/github.com/jchv/go-winloader/loader_other.go +24 -0
- package/govendor/github.com/jchv/go-winloader/loader_windows.go +33 -0
- package/govendor/manifest.txt +3 -1
- package/package.json +8 -5
- package/performance/README.md +195 -0
- package/performance/any-dynamic.ts +21 -0
- package/performance/any-record-view.ts +20 -0
- package/performance/arr-hof.ts +21 -0
- package/performance/arr-push-index.ts +15 -0
- package/performance/arr-sort.ts +21 -0
- package/performance/async-await.ts +24 -0
- package/performance/class-dispatch.ts +52 -0
- package/performance/events-emit.ts +27 -0
- package/performance/exc-throw-rare.ts +25 -0
- package/performance/exc-try-catch.ts +26 -0
- package/performance/fn-closures.ts +29 -0
- package/performance/fn-recursion-tree.ts +31 -0
- package/performance/gen-for-of.ts +46 -0
- package/performance/json-roundtrip.ts +27 -0
- package/performance/map-delete.ts +24 -0
- package/performance/map-string-keys.ts +22 -0
- package/performance/num-arith-loop.ts +14 -0
- package/performance/num-bitwise.ts +21 -0
- package/performance/num-mod-int.ts +16 -0
- package/performance/num-to-string.ts +16 -0
- package/performance/obj-alloc.ts +32 -0
- package/performance/regex-exec.ts +29 -0
- package/performance/regex-site.ts +28 -0
- package/performance/set-ops.ts +20 -0
- package/performance/str-char-scan.ts +35 -0
- package/performance/str-concat-plus.ts +18 -0
- package/performance/str-concat.ts +24 -0
- package/performance/str-short-scan.ts +26 -0
- package/performance/str-split-join.ts +23 -0
- package/performance/str-template.ts +16 -0
- package/performance/union-switch.ts +57 -0
- package/tsparser/check.go +2 -1
- package/tsparser/main.go +5 -0
- package/types/typenative-npm.d.ts +193 -4
- package/types/typenative.d.ts +138 -41
package/bin/node/crypto_keys.js
CHANGED
|
@@ -272,19 +272,19 @@ func tnReadKeyInput(v interface{}) tnKeyInput {
|
|
|
272
272
|
if v == nil || TnIsNil(v) {
|
|
273
273
|
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"key\\" argument must be of type string or an instance of ArrayBuffer, Buffer, TypedArray, DataView, KeyObject, or CryptoKey. Received undefined"))
|
|
274
274
|
}
|
|
275
|
-
if f, ok :=
|
|
275
|
+
if f, ok := TnGetValue(v, "format").(string); ok && f != "" {
|
|
276
276
|
in.format = f
|
|
277
277
|
}
|
|
278
|
-
if t, ok :=
|
|
278
|
+
if t, ok := TnGetValue(v, "type").(string); ok {
|
|
279
279
|
in.typ = t
|
|
280
280
|
}
|
|
281
|
-
switch k :=
|
|
281
|
+
switch k := TnGetValue(v, "key").(type) {
|
|
282
282
|
case *TnKeyObject:
|
|
283
283
|
in.object = k
|
|
284
284
|
case *TnCryptoKey:
|
|
285
285
|
in.object = k.key
|
|
286
286
|
case string:
|
|
287
|
-
enc, _ :=
|
|
287
|
+
enc, _ := TnGetValue(v, "encoding").(string)
|
|
288
288
|
if enc != "" && in.format != "pem" {
|
|
289
289
|
in.data = TnBufferFromString(k, enc)
|
|
290
290
|
} else {
|
|
@@ -577,7 +577,7 @@ func tnJWK(pub tncrypto.PublicKey, priv tncrypto.PrivateKey) map[string]interfac
|
|
|
577
577
|
}
|
|
578
578
|
|
|
579
579
|
func tnJWKBytes(jwk interface{}, key string) []byte {
|
|
580
|
-
s, _ :=
|
|
580
|
+
s, _ := TnGetValue(jwk, key).(string)
|
|
581
581
|
if s == "" {
|
|
582
582
|
return nil
|
|
583
583
|
}
|
|
@@ -604,7 +604,7 @@ func tnBigFrom(b []byte) *tnbig.Int { return new(tnbig.Int).SetBytes(b) }
|
|
|
604
604
|
|
|
605
605
|
// Keys from a JWK object (RSA, EC, OKP Ed25519 / X25519)
|
|
606
606
|
func tnKeyFromJWK(jwk interface{}) (tncrypto.PublicKey, tncrypto.PrivateKey) {
|
|
607
|
-
kty, _ :=
|
|
607
|
+
kty, _ := TnGetValue(jwk, "kty").(string)
|
|
608
608
|
switch kty {
|
|
609
609
|
case "RSA":
|
|
610
610
|
pub := &rsa.PublicKey{N: tnBigFrom(tnJWKBytes(jwk, "n")), E: int(tnBigFrom(tnJWKBytes(jwk, "e")).Int64())}
|
|
@@ -616,7 +616,7 @@ func tnKeyFromJWK(jwk interface{}) (tncrypto.PublicKey, tncrypto.PrivateKey) {
|
|
|
616
616
|
priv.Precompute()
|
|
617
617
|
return &priv.PublicKey, priv
|
|
618
618
|
case "EC":
|
|
619
|
-
crv, _ :=
|
|
619
|
+
crv, _ := TnGetValue(jwk, "crv").(string)
|
|
620
620
|
pub := &ecdsa.PublicKey{Curve: tnNamedCurve(crv), X: tnBigFrom(tnJWKBytes(jwk, "x")), Y: tnBigFrom(tnJWKBytes(jwk, "y"))}
|
|
621
621
|
d := tnJWKBytes(jwk, "d")
|
|
622
622
|
if d == nil {
|
|
@@ -625,7 +625,7 @@ func tnKeyFromJWK(jwk interface{}) (tncrypto.PublicKey, tncrypto.PrivateKey) {
|
|
|
625
625
|
priv := &ecdsa.PrivateKey{PublicKey: *pub, D: tnBigFrom(d)}
|
|
626
626
|
return &priv.PublicKey, priv
|
|
627
627
|
case "OKP":
|
|
628
|
-
crv, _ :=
|
|
628
|
+
crv, _ := TnGetValue(jwk, "crv").(string)
|
|
629
629
|
x, d := tnJWKBytes(jwk, "x"), tnJWKBytes(jwk, "d")
|
|
630
630
|
switch crv {
|
|
631
631
|
case "Ed25519":
|
|
@@ -662,8 +662,8 @@ func tnKeyEncodingError(typ string) *TnError {
|
|
|
662
662
|
// export({ format: 'pem' | 'der' | 'jwk', type: 'spki' | 'pkcs1' | 'pkcs8' | 'sec1' })
|
|
663
663
|
func (k *TnKeyObject) export(options ...interface{}) interface{} {
|
|
664
664
|
opts := tnCryptoArg(options)
|
|
665
|
-
format, _ :=
|
|
666
|
-
typ, _ :=
|
|
665
|
+
format, _ := TnGetValue(opts, "format").(string)
|
|
666
|
+
typ, _ := TnGetValue(opts, "type").(string)
|
|
667
667
|
switch k.type_ {
|
|
668
668
|
case "secret":
|
|
669
669
|
if format == "jwk" {
|
|
@@ -756,7 +756,7 @@ func tnGenerateAsymmetric(kind string, options interface{}) tncrypto.PrivateKey
|
|
|
756
756
|
}
|
|
757
757
|
return k
|
|
758
758
|
case "ec":
|
|
759
|
-
name, _ :=
|
|
759
|
+
name, _ := TnGetValue(options, "namedCurve").(string)
|
|
760
760
|
k, err := ecdsa.GenerateKey(tnNamedCurve(name), cryptorand.Reader)
|
|
761
761
|
if err != nil {
|
|
762
762
|
panic(tnCryptoErr(err))
|
|
@@ -937,7 +937,7 @@ func tnReadSignOptions(key interface{}) tnSignOptions {
|
|
|
937
937
|
o.saltLength = int(v)
|
|
938
938
|
o.hasSalt = true
|
|
939
939
|
}
|
|
940
|
-
if s, ok :=
|
|
940
|
+
if s, ok := TnGetValue(key, "dsaEncoding").(string); ok && s != "" {
|
|
941
941
|
o.dsaEncoding = s
|
|
942
942
|
}
|
|
943
943
|
return o
|
|
@@ -1120,7 +1120,7 @@ func tnRSAPadding(key interface{}, def int) (int, tncrypto.Hash, []byte) {
|
|
|
1120
1120
|
if v, ok := tnCryptoNumber(TnGet(key, "padding")); ok {
|
|
1121
1121
|
padding = int(v)
|
|
1122
1122
|
}
|
|
1123
|
-
if s, ok :=
|
|
1123
|
+
if s, ok := TnGetValue(key, "oaepHash").(string); ok && s != "" {
|
|
1124
1124
|
h = tnCryptoHash(s)
|
|
1125
1125
|
}
|
|
1126
1126
|
if l := TnGet(key, "oaepLabel"); l != nil && !TnIsNil(l) {
|
|
@@ -1332,8 +1332,8 @@ func (e *TnECDH) computeSecret(other interface{}, args ...string) interface{} {
|
|
|
1332
1332
|
|
|
1333
1333
|
// diffieHellman({ privateKey, publicKey }): ec and x25519 KeyObjects
|
|
1334
1334
|
func TnDiffieHellman(options interface{}) []byte {
|
|
1335
|
-
priv, _ :=
|
|
1336
|
-
pub, _ :=
|
|
1335
|
+
priv, _ := TnGetValue(options, "privateKey").(*TnKeyObject)
|
|
1336
|
+
pub, _ := TnGetValue(options, "publicKey").(*TnKeyObject)
|
|
1337
1337
|
if priv == nil || pub == nil {
|
|
1338
1338
|
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"options.privateKey\\" and \\"options.publicKey\\" properties must be KeyObjects"))
|
|
1339
1339
|
}
|
|
@@ -1507,7 +1507,7 @@ func TnGeneratePrimeBig(size float64, options ...interface{}) *tnbig.Int {
|
|
|
1507
1507
|
panic(TnNodeError("RangeError", "ERR_OUT_OF_RANGE", "The value of \\"size\\" is out of range. It must be >= 2."))
|
|
1508
1508
|
}
|
|
1509
1509
|
opts := tnCryptoArg(options)
|
|
1510
|
-
safe, _ :=
|
|
1510
|
+
safe, _ := TnGetValue(opts, "safe").(bool)
|
|
1511
1511
|
add := tnPrimeBig(TnGet(opts, "add"))
|
|
1512
1512
|
rem := tnPrimeBig(TnGet(opts, "rem"))
|
|
1513
1513
|
if add == nil && !safe {
|
|
@@ -1834,7 +1834,7 @@ func tnAlgName(alg interface{}) string {
|
|
|
1834
1834
|
if s, ok := alg.(string); ok {
|
|
1835
1835
|
return s
|
|
1836
1836
|
}
|
|
1837
|
-
n, _ :=
|
|
1837
|
+
n, _ := TnGetValue(alg, "name").(string)
|
|
1838
1838
|
return n
|
|
1839
1839
|
}
|
|
1840
1840
|
|
|
@@ -1961,7 +1961,7 @@ func tnSubtleGenerate(alg interface{}, extractable bool, usages interface{}) int
|
|
|
1961
1961
|
pubUsages, privUsages = tnFilterUsages(us, "verify"), tnFilterUsages(us, "sign")
|
|
1962
1962
|
}
|
|
1963
1963
|
case "ECDSA", "ECDH":
|
|
1964
|
-
curve, _ :=
|
|
1964
|
+
curve, _ := TnGetValue(alg, "namedCurve").(string)
|
|
1965
1965
|
priv = tnGenerateAsymmetric("ec", map[string]interface{}{"namedCurve": curve})
|
|
1966
1966
|
algorithm["namedCurve"] = curve
|
|
1967
1967
|
if name == "ECDSA" {
|
|
@@ -2074,7 +2074,7 @@ func tnSubtleImport(format string, data interface{}, alg interface{}, extractabl
|
|
|
2074
2074
|
}
|
|
2075
2075
|
k = tnPrivateKeyObject(priv)
|
|
2076
2076
|
case "jwk":
|
|
2077
|
-
if kty, _ :=
|
|
2077
|
+
if kty, _ := TnGetValue(data, "kty").(string); kty == "oct" {
|
|
2078
2078
|
k = &TnKeyObject{type_: "secret", secret: tnJWKBytes(data, "k")}
|
|
2079
2079
|
} else {
|
|
2080
2080
|
pub, priv := tnKeyFromJWK(data)
|
|
@@ -2134,7 +2134,7 @@ func tnSubtleExport(format string, key *TnCryptoKey) interface{} {
|
|
|
2134
2134
|
if length, ok := key.algorithm["length"].(float64); ok {
|
|
2135
2135
|
switch key.algorithm["name"] {
|
|
2136
2136
|
case "HMAC":
|
|
2137
|
-
hash, _ :=
|
|
2137
|
+
hash, _ := TnGetValue(key.algorithm["hash"], "name").(string)
|
|
2138
2138
|
jwk["alg"] = "HS" + strings.TrimPrefix(hash, "SHA-")
|
|
2139
2139
|
case "AES-GCM":
|
|
2140
2140
|
jwk["alg"] = fmt.Sprintf("A%dGCM", int(length))
|
|
@@ -2352,7 +2352,7 @@ func tnSubtleDerive(alg interface{}, key *TnCryptoKey, length interface{}) []byt
|
|
|
2352
2352
|
}
|
|
2353
2353
|
return k
|
|
2354
2354
|
case "ECDH", "X25519":
|
|
2355
|
-
pub, _ :=
|
|
2355
|
+
pub, _ := TnGetValue(alg, "public").(*TnCryptoKey)
|
|
2356
2356
|
if pub == nil {
|
|
2357
2357
|
panic(tnDOMError("InvalidAccessError", "algorithm.public must be a public CryptoKey"))
|
|
2358
2358
|
}
|
package/bin/node/dgram.js
CHANGED
|
@@ -34,7 +34,7 @@ func TnCreateDgramSocket(kind interface{}, listener ...interface{}) *TnDgramSock
|
|
|
34
34
|
if t := tnNetString(TnGet(kind, "type")); t == "udp6" {
|
|
35
35
|
s.network = "udp6"
|
|
36
36
|
}
|
|
37
|
-
s.reuseAddr, _ =
|
|
37
|
+
s.reuseAddr, _ = TnGetValue(kind, "reuseAddr").(bool)
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
if len(listener) > 0 && tnIsFunc(listener[0]) {
|
|
@@ -122,7 +122,7 @@ func TnNewTracingChannel(nameOrChannels interface{}) *TnTracingChannel {
|
|
|
122
122
|
for i, event := range tnTracingEvents {
|
|
123
123
|
if name, ok := nameOrChannels.(string); ok {
|
|
124
124
|
channels[i] = TnDiagnosticsChannel("tracing:" + name + ":" + event)
|
|
125
|
-
} else if c, ok :=
|
|
125
|
+
} else if c, ok := TnGetValue(nameOrChannels, event).(*TnChannel); ok {
|
|
126
126
|
channels[i] = c
|
|
127
127
|
} else {
|
|
128
128
|
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"channels."+event+"\\" property must be an instance of Channel"))
|
|
@@ -393,10 +393,10 @@ func TnNewConsole(stdout interface{}, rest ...interface{}) *TnConsole {
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
} else if stdout != nil {
|
|
396
|
-
if s, ok :=
|
|
396
|
+
if s, ok := TnGetValue(stdout, "stdout").(tnStreamLike); ok {
|
|
397
397
|
c.stdout = s.tnStream()
|
|
398
398
|
}
|
|
399
|
-
if s, ok :=
|
|
399
|
+
if s, ok := TnGetValue(stdout, "stderr").(tnStreamLike); ok {
|
|
400
400
|
c.stderr = s.tnStream()
|
|
401
401
|
}
|
|
402
402
|
}
|
package/bin/node/dns.js
CHANGED
|
@@ -44,14 +44,14 @@ func tnLookupOptions(options interface{}) (float64, bool) {
|
|
|
44
44
|
if n, ok := tnNetNumber(TnGet(options, "family")); ok {
|
|
45
45
|
family = n
|
|
46
46
|
}
|
|
47
|
-
if s, ok :=
|
|
47
|
+
if s, ok := TnGetValue(options, "family").(string); ok {
|
|
48
48
|
if s == "IPv4" {
|
|
49
49
|
family = 4
|
|
50
50
|
} else if s == "IPv6" {
|
|
51
51
|
family = 6
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
all, _ :=
|
|
54
|
+
all, _ := TnGetValue(options, "all").(bool)
|
|
55
55
|
return family, all
|
|
56
56
|
}
|
|
57
57
|
|
package/bin/node/events.js
CHANGED
|
@@ -38,7 +38,7 @@ var TnDefaultMaxListeners = 10.0
|
|
|
38
38
|
func TnNewEventEmitter(options ...interface{}) *TnEventEmitter {
|
|
39
39
|
e := &TnEventEmitter{state: &tnEmitterState{events: map[string][]*tnListener{}, maxListeners: -1, warned: map[string]bool{}, captureRejections: TnCaptureRejections}}
|
|
40
40
|
if len(options) > 0 && options[0] != nil {
|
|
41
|
-
if b, ok :=
|
|
41
|
+
if b, ok := TnGetValue(options[0], "captureRejections").(bool); ok {
|
|
42
42
|
e.state.captureRejections = b
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -172,20 +172,25 @@ func (e *TnEventEmitter) removeAllListeners(event ...string) *TnEventEmitter {
|
|
|
172
172
|
func (e *TnEventEmitter) emit(event string, args ...interface{}) bool {
|
|
173
173
|
s := e.st()
|
|
174
174
|
s.mu.Lock()
|
|
175
|
-
|
|
175
|
+
// (listener lists are copy-on-write — adds append past this length, removals
|
|
176
|
+
// build a new slice — so the list as it is now is the emit's snapshot)
|
|
177
|
+
list := s.events[event]
|
|
176
178
|
// once listeners are removed before they run
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
for i, l := range list {
|
|
180
|
+
if l.once {
|
|
181
|
+
kept := append([]*tnListener{}, list[:i]...)
|
|
182
|
+
for _, rest := range list[i+1:] {
|
|
183
|
+
if !rest.once {
|
|
184
|
+
kept = append(kept, rest)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
e.setListeners(event, kept)
|
|
188
|
+
break
|
|
181
189
|
}
|
|
182
190
|
}
|
|
183
|
-
|
|
184
|
-
e.setListeners(event, kept)
|
|
185
|
-
}
|
|
186
|
-
monitors := []*tnListener{}
|
|
191
|
+
var monitors []*tnListener
|
|
187
192
|
if event == "error" {
|
|
188
|
-
monitors =
|
|
193
|
+
monitors = s.events[TnErrorMonitor]
|
|
189
194
|
}
|
|
190
195
|
capture := s.captureRejections
|
|
191
196
|
s.mu.Unlock()
|
|
@@ -380,7 +385,7 @@ type TnEvent struct {
|
|
|
380
385
|
func TnNewEvent(eventType string, options ...interface{}) *TnEvent {
|
|
381
386
|
ev := &TnEvent{eventType: eventType, timeStamp: float64(time.Now().UnixNano()) / 1e6}
|
|
382
387
|
if len(options) > 0 && options[0] != nil {
|
|
383
|
-
if c, ok :=
|
|
388
|
+
if c, ok := TnGetValue(options[0], "cancelable").(bool); ok {
|
|
384
389
|
ev.cancelable = c
|
|
385
390
|
}
|
|
386
391
|
}
|
|
@@ -418,7 +423,7 @@ func (t *TnEventTarget) addEventListener(eventType string, fn interface{}, optio
|
|
|
418
423
|
}
|
|
419
424
|
once := false
|
|
420
425
|
if len(options) > 0 && options[0] != nil {
|
|
421
|
-
if o, ok :=
|
|
426
|
+
if o, ok := TnGetValue(options[0], "once").(bool); ok {
|
|
422
427
|
once = o
|
|
423
428
|
}
|
|
424
429
|
}
|
package/bin/node/fetch.js
CHANGED
|
@@ -381,7 +381,7 @@ func tnResponseInit(r *TnResponse, init []interface{}) {
|
|
|
381
381
|
r.status = n
|
|
382
382
|
r.statusText = ""
|
|
383
383
|
}
|
|
384
|
-
if s, ok :=
|
|
384
|
+
if s, ok := TnGetValue(init[0], "statusText").(string); ok {
|
|
385
385
|
r.statusText = s
|
|
386
386
|
}
|
|
387
387
|
if h := TnGet(init[0], "headers"); h != nil {
|
|
@@ -489,7 +489,7 @@ func TnNewRequest(input interface{}, init ...interface{}) *TnRequest {
|
|
|
489
489
|
if rd := tnNetString(TnGet(opts, "redirect")); rd != "" {
|
|
490
490
|
req.redirect = rd
|
|
491
491
|
}
|
|
492
|
-
if sig, ok :=
|
|
492
|
+
if sig, ok := TnGetValue(opts, "signal").(*TnAbortSignal); ok && sig != nil {
|
|
493
493
|
req.signal = sig
|
|
494
494
|
}
|
|
495
495
|
if body := TnGet(opts, "body"); body != nil && !TnIsNil(body) {
|
package/bin/node/fs.js
CHANGED
|
@@ -529,13 +529,13 @@ func TnReadSync(fd float64, buf []byte, args ...interface{}) float64 {
|
|
|
529
529
|
if n, ok := a.(float64); ok {
|
|
530
530
|
nums = append(nums, n)
|
|
531
531
|
} else if a != nil {
|
|
532
|
-
if p, ok :=
|
|
532
|
+
if p, ok := TnGetValue(a, "position").(float64); ok {
|
|
533
533
|
position = int64(p)
|
|
534
534
|
}
|
|
535
|
-
if o, ok :=
|
|
535
|
+
if o, ok := TnGetValue(a, "offset").(float64); ok {
|
|
536
536
|
offset = int(o)
|
|
537
537
|
}
|
|
538
|
-
if l, ok :=
|
|
538
|
+
if l, ok := TnGetValue(a, "length").(float64); ok {
|
|
539
539
|
length = int(l)
|
|
540
540
|
}
|
|
541
541
|
}
|
package/bin/node/fs_watch.js
CHANGED
|
@@ -45,10 +45,10 @@ func tnFsWatchStart(path string, options interface{}, events chan *TnFsWatchEven
|
|
|
45
45
|
w := &TnFSWatcher{asyncCtx: TnAsyncSnapshot(), root: filepath.Clean(path), events: events}
|
|
46
46
|
persistent := true
|
|
47
47
|
if _, isString := options.(string); options != nil && !isString {
|
|
48
|
-
if p, ok :=
|
|
48
|
+
if p, ok := TnGetValue(options, "persistent").(bool); ok {
|
|
49
49
|
persistent = p
|
|
50
50
|
}
|
|
51
|
-
w.recursive, _ =
|
|
51
|
+
w.recursive, _ = TnGetValue(options, "recursive").(bool)
|
|
52
52
|
}
|
|
53
53
|
info, err := os.Stat(path)
|
|
54
54
|
if err != nil {
|
|
@@ -69,7 +69,7 @@ func tnFsWatchStart(path string, options interface{}, events chan *TnFsWatchEven
|
|
|
69
69
|
TnLoopRef()
|
|
70
70
|
}
|
|
71
71
|
if options != nil {
|
|
72
|
-
if signal, ok :=
|
|
72
|
+
if signal, ok := TnGetValue(options, "signal").(*TnAbortSignal); ok && signal != nil {
|
|
73
73
|
if signal.aborted {
|
|
74
74
|
TnLoopPost(func() { w.close() })
|
|
75
75
|
} else {
|
|
@@ -267,10 +267,10 @@ func TnWatchFile(path string, rest ...interface{}) *TnStatWatcher {
|
|
|
267
267
|
continue
|
|
268
268
|
}
|
|
269
269
|
if a != nil {
|
|
270
|
-
if n, ok :=
|
|
270
|
+
if n, ok := TnGetValue(a, "interval").(float64); ok && n > 0 {
|
|
271
271
|
interval = n
|
|
272
272
|
}
|
|
273
|
-
if p, ok :=
|
|
273
|
+
if p, ok := TnGetValue(a, "persistent").(bool); ok {
|
|
274
274
|
persistent = p
|
|
275
275
|
}
|
|
276
276
|
}
|
package/bin/node/http.js
CHANGED
|
@@ -895,7 +895,7 @@ func TnNewHttpAgent(options ...interface{}) *TnHttpAgent {
|
|
|
895
895
|
a := &TnHttpAgent{maxSockets: math.Inf(1)}
|
|
896
896
|
if len(options) > 0 && options[0] != nil {
|
|
897
897
|
a.options = options[0]
|
|
898
|
-
a.keepAlive, _ =
|
|
898
|
+
a.keepAlive, _ = TnGetValue(options[0], "keepAlive").(bool)
|
|
899
899
|
if n, ok := tnNetNumber(TnGet(options[0], "maxSockets")); ok {
|
|
900
900
|
a.maxSockets = n
|
|
901
901
|
}
|
|
@@ -1409,11 +1409,11 @@ func TnHttpRequest(secure bool, args ...interface{}) *TnClientRequest {
|
|
|
1409
1409
|
cr.timeoutMs = n
|
|
1410
1410
|
}
|
|
1411
1411
|
cr.store.setAll(TnGet(options, "headers"))
|
|
1412
|
-
if b, ok :=
|
|
1412
|
+
if b, ok := TnGetValue(options, "rejectUnauthorized").(bool); ok && !b {
|
|
1413
1413
|
insecure = true
|
|
1414
1414
|
}
|
|
1415
1415
|
ca = tnPemStrings(TnGet(options, "ca"))
|
|
1416
|
-
if sig, ok :=
|
|
1416
|
+
if sig, ok := TnGetValue(options, "signal").(*TnAbortSignal); ok && sig != nil {
|
|
1417
1417
|
cr.signal = sig
|
|
1418
1418
|
}
|
|
1419
1419
|
}
|
package/bin/node/http2.js
CHANGED
|
@@ -331,7 +331,7 @@ func (st *TnHttp2Stream) respond(args ...interface{}) {
|
|
|
331
331
|
st.headersSent = true
|
|
332
332
|
st.sentHeaders = sent
|
|
333
333
|
if len(args) > 1 && args[1] != nil {
|
|
334
|
-
if end, _ :=
|
|
334
|
+
if end, _ := TnGetValue(args[1], "endStream").(bool); end {
|
|
335
335
|
st.end()
|
|
336
336
|
}
|
|
337
337
|
}
|
|
@@ -463,7 +463,7 @@ func TnHttp2CreateServer(secure bool, args ...interface{}) *TnHttpServer {
|
|
|
463
463
|
allowHTTP1 := false
|
|
464
464
|
for _, a := range args {
|
|
465
465
|
if a != nil && !tnIsFunc(a) {
|
|
466
|
-
allowHTTP1, _ =
|
|
466
|
+
allowHTTP1, _ = TnGetValue(a, "allowHTTP1").(bool)
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
if hs.tlsConfig == nil {
|
|
@@ -521,7 +521,7 @@ func (s *TnHttp2Session) request(headers interface{}, options ...interface{}) *T
|
|
|
521
521
|
}
|
|
522
522
|
endStream := false
|
|
523
523
|
if len(options) > 0 && options[0] != nil {
|
|
524
|
-
endStream, _ =
|
|
524
|
+
endStream, _ = TnGetValue(options[0], "endStream").(bool)
|
|
525
525
|
}
|
|
526
526
|
// Requests without a body go out right away, as Node sends their headers at once
|
|
527
527
|
if endStream || st.method == "GET" || st.method == "HEAD" {
|
package/bin/node/net.js
CHANGED
|
@@ -265,7 +265,7 @@ func TnNewSocket(options ...interface{}) *TnSocket {
|
|
|
265
265
|
s.TnStream = *TnNewDuplex()
|
|
266
266
|
s.tnSelf = s
|
|
267
267
|
if len(options) > 0 && options[0] != nil {
|
|
268
|
-
if b, ok :=
|
|
268
|
+
if b, ok := TnGetValue(options[0], "allowHalfOpen").(bool); ok {
|
|
269
269
|
s.allowHalfOpen = b
|
|
270
270
|
}
|
|
271
271
|
}
|
|
@@ -417,7 +417,7 @@ func (s *TnSocket) connect(args ...interface{}) *TnSocket {
|
|
|
417
417
|
if p := tnNetString(TnGet(a, "path")); p != "" {
|
|
418
418
|
path, network = p, "unix"
|
|
419
419
|
}
|
|
420
|
-
if b, ok :=
|
|
420
|
+
if b, ok := TnGetValue(a, "allowHalfOpen").(bool); ok {
|
|
421
421
|
s.allowHalfOpen = b
|
|
422
422
|
}
|
|
423
423
|
if n, ok := tnNetNumber(TnGet(a, "timeout")); ok {
|
|
@@ -624,10 +624,10 @@ func TnNewNetServer(args ...interface{}) *TnNetServer {
|
|
|
624
624
|
if tnIsFunc(a) {
|
|
625
625
|
srv.on(srv.connectionEvent, a)
|
|
626
626
|
} else if a != nil {
|
|
627
|
-
if b, ok :=
|
|
627
|
+
if b, ok := TnGetValue(a, "allowHalfOpen").(bool); ok {
|
|
628
628
|
srv.allowHalfOpen = b
|
|
629
629
|
}
|
|
630
|
-
if b, ok :=
|
|
630
|
+
if b, ok := TnGetValue(a, "pauseOnConnect").(bool); ok {
|
|
631
631
|
srv.pauseOnConnect = b
|
|
632
632
|
}
|
|
633
633
|
}
|
|
@@ -865,7 +865,7 @@ func TnNewSocketAddress(options ...interface{}) *TnSocketAddress {
|
|
|
865
865
|
if len(options) > 0 {
|
|
866
866
|
opts = options[0]
|
|
867
867
|
}
|
|
868
|
-
if f, ok :=
|
|
868
|
+
if f, ok := TnGetValue(opts, "family").(string); ok {
|
|
869
869
|
sa.family = strings.ToLower(f)
|
|
870
870
|
}
|
|
871
871
|
if sa.family != "ipv4" && sa.family != "ipv6" {
|
|
@@ -875,13 +875,13 @@ func TnNewSocketAddress(options ...interface{}) *TnSocketAddress {
|
|
|
875
875
|
if sa.family == "ipv6" {
|
|
876
876
|
sa.address = "::"
|
|
877
877
|
}
|
|
878
|
-
if a, ok :=
|
|
878
|
+
if a, ok := TnGetValue(opts, "address").(string); ok {
|
|
879
879
|
sa.address = a
|
|
880
880
|
}
|
|
881
|
-
if p, ok :=
|
|
881
|
+
if p, ok := TnGetValue(opts, "port").(float64); ok {
|
|
882
882
|
sa.port = p
|
|
883
883
|
}
|
|
884
|
-
if fl, ok :=
|
|
884
|
+
if fl, ok := TnGetValue(opts, "flowlabel").(float64); ok {
|
|
885
885
|
sa.flowlabel = fl
|
|
886
886
|
}
|
|
887
887
|
addr, err := netip.ParseAddr(sa.address)
|
package/bin/node/path.js
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
// the platform's flavour, as in Node.
|
|
4
4
|
import { defineClass, defineHelper, defineModule, setResults, isObjectLiteral, getOption } from './registry.js';
|
|
5
5
|
const pathHelper = `// node:path — Node's posix and win32 algorithms (path is the platform's)
|
|
6
|
+
// A path argument held as any: a string, else Node's TypeError
|
|
7
|
+
func TnPathArg(v interface{}) string {
|
|
8
|
+
if s, ok := v.(string); ok {
|
|
9
|
+
return s
|
|
10
|
+
}
|
|
11
|
+
panic(TnNodeError("TypeError", "ERR_INVALID_ARG_TYPE", "The \\"path\\" argument must be of type string. Received "+TnTypeOf(v)))
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
type tnPathStyle struct {
|
|
7
15
|
win bool
|
|
8
16
|
sep string
|
|
@@ -99,6 +107,10 @@ func tnGlobRegexp(g string, escapes bool) string {
|
|
|
99
107
|
segStart = false
|
|
100
108
|
switch {
|
|
101
109
|
case c == '*' && i+1 < len(g) && g[i+1] == '*' && wasStart && (i+2 == len(g) || g[i+2] == '/'):
|
|
110
|
+
// a leading ** also matches an absolute path's root ('**/a.ts' matches '/x/a.ts')
|
|
111
|
+
if i == 0 {
|
|
112
|
+
b.WriteString("/?")
|
|
113
|
+
}
|
|
102
114
|
if i+2 == len(g) {
|
|
103
115
|
b.WriteString("(?:[^/.][^/]*(?:/[^/.][^/]*)*)?")
|
|
104
116
|
i++
|
|
@@ -700,7 +712,7 @@ func TnParsedPathOf(v interface{}) *TnParsedPath {
|
|
|
700
712
|
return p
|
|
701
713
|
}
|
|
702
714
|
str := func(key string) string {
|
|
703
|
-
if s, ok :=
|
|
715
|
+
if s, ok := TnGetValue(v, key).(string); ok {
|
|
704
716
|
return s
|
|
705
717
|
}
|
|
706
718
|
return ""
|
|
@@ -713,14 +725,16 @@ const PATH_STYLES = {
|
|
|
713
725
|
'path/win32': 'TnPathWin32'
|
|
714
726
|
};
|
|
715
727
|
export function registerPath(r) {
|
|
716
|
-
defineHelper(r, 'nodePath', ['os', 'regexp', 'runtime', 'strings'], ['dynamic'], pathHelper);
|
|
728
|
+
defineHelper(r, 'nodePath', ['os', 'regexp', 'runtime', 'strings'], ['dynamic', 'error', 'typeOf'], pathHelper);
|
|
717
729
|
defineClass(r, 'path.ParsedPath', '*TnParsedPath', 'class', '', 'root=string; dir=string; base=string; ext=string; name=string', '', '');
|
|
718
730
|
for (const mod of Object.keys(PATH_STYLES)) {
|
|
719
731
|
const style = PATH_STYLES[mod];
|
|
720
732
|
defineModule(r, mod);
|
|
721
733
|
const fn = (name) => (call) => {
|
|
722
734
|
r.helper('nodePath');
|
|
723
|
-
|
|
735
|
+
// (a dynamic argument must hold a string, as Node checks)
|
|
736
|
+
const args = call.args.map((a, i) => (call.types[i] === 'interface{}' ? `TnPathArg(${a})` : a));
|
|
737
|
+
return `${style}.${name}(${args.join(', ')})`;
|
|
724
738
|
};
|
|
725
739
|
for (const name of ['join', 'resolve', 'normalize', 'relative', 'dirname', 'basename', 'extname', 'isAbsolute', 'parse', 'toNamespacedPath', 'matchesGlob']) {
|
|
726
740
|
r.functions[`${mod}.${name}`] = fn(name);
|
package/bin/node/process.js
CHANGED
|
@@ -150,14 +150,31 @@ func TnProcessKill(pid float64, signal ...interface{}) bool {
|
|
|
150
150
|
return true
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
// process.emitWarning(warning, type = 'Warning'); an Error warning's own
|
|
154
|
+
// name is its type
|
|
155
|
+
func TnProcessEmitWarning(warning interface{}, typ string) {
|
|
154
156
|
msg := fmt.Sprint(warning)
|
|
155
157
|
if e, ok := warning.(*TnError); ok {
|
|
156
158
|
msg = e.message
|
|
159
|
+
if typ == "" {
|
|
160
|
+
if name, isString := e.prop("name").(string); isString && name != "" {
|
|
161
|
+
typ = name
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if typ == "" {
|
|
166
|
+
typ = "Warning"
|
|
167
|
+
}
|
|
168
|
+
fmt.Fprintf(os.Stderr, "(node:%d) %s: %s\\n", os.Getpid(), typ, msg)
|
|
169
|
+
// (Node's hint, after the first warning)
|
|
170
|
+
if !tnWarningHinted {
|
|
171
|
+
tnWarningHinted = true
|
|
172
|
+
fmt.Fprintln(os.Stderr, "(Use \`node --trace-warnings ...\` to show where the warning was created)")
|
|
157
173
|
}
|
|
158
|
-
fmt.Fprintf(os.Stderr, "(node:%d) Warning: %s\\n", os.Getpid(), msg)
|
|
159
174
|
}
|
|
160
175
|
|
|
176
|
+
var tnWarningHinted bool
|
|
177
|
+
|
|
161
178
|
func TnProcessVersions() *TnMap[string, string] {
|
|
162
179
|
m := TnNewMap[string, string]()
|
|
163
180
|
m.Set("node", "24.0.0")
|
|
@@ -398,6 +415,19 @@ export function registerProcess(r) {
|
|
|
398
415
|
return 'TnProcessArgv()';
|
|
399
416
|
});
|
|
400
417
|
value('execArgv', '[]string', () => '[]string{}');
|
|
418
|
+
// process itself as a value (let p = process || {}, picocolors'): an
|
|
419
|
+
// object of its common members, read dynamically
|
|
420
|
+
r.values['process'] = (_c) => {
|
|
421
|
+
use();
|
|
422
|
+
r.helper('osPlatform');
|
|
423
|
+
r.helper('dynamic');
|
|
424
|
+
r.pkg('os');
|
|
425
|
+
return 'func() *TnMap[string, interface{}] { __p := TnNewMap[string, interface{}](); __argv := []interface{}{}; for _, __a := range TnProcessArgv() { __argv = append(__argv, __a) }; __p.Set("argv", __argv); ' +
|
|
426
|
+
'__env := TnNewMap[string, interface{}](); __src := TnEnvMap(); for _, __k := range __src.Keys() { __env.Set(__k, __src.Get(__k)) }; __p.Set("env", __env); __p.Set("platform", TnOsPlatform()); ' +
|
|
427
|
+
'__out := TnNewMap[string, interface{}](); if TnIsTTY(os.Stdout) { __out.Set("isTTY", true) }; __p.Set("stdout", __out); ' +
|
|
428
|
+
'__p.Set("emitWarning", func(__w interface{}, __rest ...interface{}) { __t, _ := TnArg(__rest, 0).(string); TnProcessEmitWarning(__w, __t) }); return __p }()';
|
|
429
|
+
};
|
|
430
|
+
r.valueTypes['process'] = '*TnMap[string, interface{}]';
|
|
401
431
|
value('argv0', 'string', () => {
|
|
402
432
|
r.pkg('os');
|
|
403
433
|
return 'os.Args[0]';
|
|
@@ -511,14 +541,20 @@ export function registerProcess(r) {
|
|
|
511
541
|
use();
|
|
512
542
|
return 'TnProcessMemoryUsage().rss';
|
|
513
543
|
});
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
544
|
+
// write(data[, encoding][, callback]): the data is written at once; the
|
|
545
|
+
// callback runs as a later task, as Node calls it once the data is flushed
|
|
546
|
+
for (const [stream, file] of [['stdout', 'os.Stdout'], ['stderr', 'os.Stderr']]) {
|
|
547
|
+
fn(`${stream}.write`, 'bool', (call) => {
|
|
548
|
+
use();
|
|
549
|
+
const callback = call.nodes.length > 1 ? call.args[call.args.length - 1] : '';
|
|
550
|
+
const isCallback = call.nodes.length > 1 && (call.types[call.types.length - 1] ?? '').startsWith('func(');
|
|
551
|
+
if (!isCallback)
|
|
552
|
+
return `TnProcessWrite(${file}, ${call.args[0]})`;
|
|
553
|
+
r.helper('timerWait');
|
|
554
|
+
const takesError = (call.types[call.types.length - 1] ?? '').startsWith('func()') ? '' : 'nil';
|
|
555
|
+
return `func() bool { __ok := TnProcessWrite(${file}, ${call.args[0]}); __cb := ${callback}; TnSetImmediate(func() { __cb(${takesError}) }); return __ok }()`;
|
|
556
|
+
});
|
|
557
|
+
}
|
|
522
558
|
for (const stream of ['stdout', 'stderr']) {
|
|
523
559
|
const f = stream === 'stdout' ? 'os.Stdout' : 'os.Stderr';
|
|
524
560
|
fn(`${stream}.getWindowSize`, '[]float64', (_c) => {
|
|
@@ -545,7 +581,7 @@ export function registerProcess(r) {
|
|
|
545
581
|
});
|
|
546
582
|
fn('emitWarning', '', (call) => {
|
|
547
583
|
use();
|
|
548
|
-
return `TnProcessEmitWarning(${call.args[0]})`;
|
|
584
|
+
return `TnProcessEmitWarning(${call.args[0]}, ${call.args[1] ?? '""'})`;
|
|
549
585
|
});
|
|
550
586
|
for (const id of ['getuid', 'getgid', 'geteuid', 'getegid']) {
|
|
551
587
|
const goName = id === 'getuid' ? 'Getuid' : id === 'getgid' ? 'Getgid' : id === 'geteuid' ? 'Geteuid' : 'Getegid';
|
package/bin/node/punycode.js
CHANGED
|
@@ -140,7 +140,7 @@ func TnPunycodeDecode(input string) string {
|
|
|
140
140
|
return string(out)
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
func
|
|
143
|
+
func tnPunyIsASCII(s string) bool {
|
|
144
144
|
for i := 0; i < len(s); i++ {
|
|
145
145
|
if s[i] >= 0x80 {
|
|
146
146
|
return false
|
|
@@ -161,7 +161,7 @@ func tnMapDomainLabels(domain string, fn func(string) string) string {
|
|
|
161
161
|
|
|
162
162
|
func TnPunycodeToASCII(domain string) string {
|
|
163
163
|
return tnMapDomainLabels(domain, func(label string) string {
|
|
164
|
-
if
|
|
164
|
+
if tnPunyIsASCII(label) {
|
|
165
165
|
return label
|
|
166
166
|
}
|
|
167
167
|
return "xn--" + TnPunycodeEncode(label)
|
package/bin/node/readline.js
CHANGED
|
@@ -26,7 +26,7 @@ func TnCreateInterface(options interface{}, rest ...interface{}) *TnReadline {
|
|
|
26
26
|
} else if options != nil {
|
|
27
27
|
input = TnGet(options, "input")
|
|
28
28
|
output = TnGet(options, "output")
|
|
29
|
-
if p, ok :=
|
|
29
|
+
if p, ok := TnGetValue(options, "prompt").(string); ok {
|
|
30
30
|
rl.promptText = p
|
|
31
31
|
}
|
|
32
32
|
}
|
package/bin/node/registry.js
CHANGED
|
@@ -41,7 +41,10 @@ export function createNodeRegistry() {
|
|
|
41
41
|
visit: (_node) => '',
|
|
42
42
|
categoryOf: (_node) => '',
|
|
43
43
|
isArrayBuffer: (_node) => false,
|
|
44
|
-
entryPoint: (_node) => ''
|
|
44
|
+
entryPoint: (_node) => '',
|
|
45
|
+
callSite: (_node) => ({ file: '', line: 0, column: 0 }),
|
|
46
|
+
mockMember: (_call, _tracker, _kind) => '',
|
|
47
|
+
mockMemberType: (_call, _kind) => ''
|
|
45
48
|
};
|
|
46
49
|
return registry;
|
|
47
50
|
}
|