typenative 0.4.1 → 0.5.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/CHANGELOG.md +171 -0
- package/README.md +62 -22
- package/ROUND2-HANDOFF.md +200 -0
- package/bin/cli.js +1 -0
- package/bin/index.js +13 -2
- package/bin/main.js +1 -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/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 +3 -3
- 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 +34 -11
- 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 +4 -4
- package/bin/node/tls.js +5 -5
- 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 +4 -0
- package/bin/transpiler.js +10390 -1178
- package/bin/version.js +1 -1
- package/conformance.md +468 -340
- package/examples/README.md +47 -10
- package/examples/desktop-notes/README.md +108 -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 +76 -0
- package/examples/dupe-finder/bench.mjs +120 -0
- package/examples/dupe-finder/main.ts +87 -0
- package/examples/mandelbrot-png/README.md +65 -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 +159 -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/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 +136 -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 +1 -1
- package/tsparser/main.go +4 -0
- package/types/typenative-npm.d.ts +190 -2
- package/types/typenative.d.ts +98 -31
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package winloader
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"syscall"
|
|
5
|
+
|
|
6
|
+
"github.com/jchv/go-winloader/internal/loader"
|
|
7
|
+
"golang.org/x/sys/windows"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// Proc is a Proc implementation using a native procedure.
|
|
11
|
+
type Proc uintptr
|
|
12
|
+
|
|
13
|
+
// Call calls a native procedure.
|
|
14
|
+
func (p Proc) Call(a ...uint64) (r1, r2 uint64, lastErr error) {
|
|
15
|
+
var ua []uintptr
|
|
16
|
+
for _, e := range a {
|
|
17
|
+
ua = append(ua, uintptr(e))
|
|
18
|
+
}
|
|
19
|
+
n1, n2, lastErr := syscall.SyscallN(uintptr(p), ua...)
|
|
20
|
+
return uint64(n1), uint64(n2), lastErr
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Addr gets the native address of the procedure.
|
|
24
|
+
func (p Proc) Addr() uint64 {
|
|
25
|
+
return uint64(p)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Library is a module implementation using the native Windows loader.
|
|
29
|
+
type Library windows.Handle
|
|
30
|
+
|
|
31
|
+
// Proc implements loader.Module
|
|
32
|
+
func (l Library) Proc(name string) loader.Proc {
|
|
33
|
+
proc, _ := windows.GetProcAddress(windows.Handle(l), name)
|
|
34
|
+
if proc == 0 {
|
|
35
|
+
return nil
|
|
36
|
+
}
|
|
37
|
+
return Proc(proc)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Ordinal implements loader.Module
|
|
41
|
+
func (l Library) Ordinal(ordinal uint64) loader.Proc {
|
|
42
|
+
proc, _ := windows.GetProcAddressByOrdinal(windows.Handle(l), uintptr(ordinal))
|
|
43
|
+
if proc == 0 {
|
|
44
|
+
return nil
|
|
45
|
+
}
|
|
46
|
+
return Proc(proc)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Free implements loader.Module
|
|
50
|
+
func (l Library) Free() error {
|
|
51
|
+
return windows.FreeLibrary(windows.Handle(l))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Loader is a loader that uses the native Windows library loader.
|
|
55
|
+
type Loader struct{}
|
|
56
|
+
|
|
57
|
+
// Load loads a module into memory.
|
|
58
|
+
func (Loader) Load(libname string) (loader.Module, error) {
|
|
59
|
+
handle, err := windows.LoadLibrary(libname)
|
|
60
|
+
if err != nil {
|
|
61
|
+
return nil, err
|
|
62
|
+
}
|
|
63
|
+
return Library(handle), nil
|
|
64
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package winloader
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/jchv/go-winloader/internal/loader"
|
|
5
|
+
"github.com/jchv/go-winloader/internal/vmem"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// NativeMachine is a loader.Machine implementation that uses the native
|
|
9
|
+
// machine the binary is running on.
|
|
10
|
+
type NativeMachine struct{}
|
|
11
|
+
|
|
12
|
+
// IsArchitectureSupported implements loader.Machine.
|
|
13
|
+
func (NativeMachine) IsArchitectureSupported(machine int) bool {
|
|
14
|
+
return machine == NativeArch
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func (NativeMachine) GetPageSize() uint64 {
|
|
18
|
+
return vmem.GetPageSize()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Alloc implements loader.Machine.
|
|
22
|
+
func (NativeMachine) Alloc(addr, size uint64, allocType, protect int) loader.Memory {
|
|
23
|
+
if mem := vmem.Alloc(addr, size, allocType, protect); mem != nil {
|
|
24
|
+
return mem
|
|
25
|
+
}
|
|
26
|
+
return nil
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// MemProc implements loader.MemProc.
|
|
30
|
+
func (NativeMachine) MemProc(addr uint64) loader.Proc {
|
|
31
|
+
return Proc(addr)
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package winloader
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/jchv/go-winloader/internal/pe"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
// NativeArch is a constant that will be equal to the PE machine type
|
|
8
|
+
// enumeration value that corresponds to the arch the binary is running as.
|
|
9
|
+
const NativeArch = pe.ImageFileMachinei386
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package winloader
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/jchv/go-winloader/internal/pe"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
// NativeArch is a constant that will be equal to the PE machine type
|
|
8
|
+
// enumeration value that corresponds to the arch the binary is running as.
|
|
9
|
+
const NativeArch = pe.ImageFileMachineAMD64
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
package winloader
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/jchv/go-winloader/internal/pe"
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
// NativeArch is a constant that will be equal to the PE machine type
|
|
8
|
+
// enumeration value that corresponds to the arch the binary is running as.
|
|
9
|
+
const NativeArch = pe.ImageFileMachineARM64
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//go:build !windows
|
|
2
|
+
// +build !windows
|
|
3
|
+
|
|
4
|
+
package winloader
|
|
5
|
+
|
|
6
|
+
import "fmt"
|
|
7
|
+
|
|
8
|
+
// LoadFromFile loads a Windows module from file using the native Windows
|
|
9
|
+
// loader.
|
|
10
|
+
func LoadFromFile(name string) (Module, error) {
|
|
11
|
+
return nil, fmt.Errorf("unsupported platform")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// LoadFromMemory loads a Windows module from memory.
|
|
15
|
+
func LoadFromMemory(data []byte) (Module, error) {
|
|
16
|
+
return nil, fmt.Errorf("unsupported platform")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// AddToCache adds a module to the loader cache, allowing in-memory libraries
|
|
20
|
+
// to link to it. Note that modules in the cache must exist in the same
|
|
21
|
+
// address space.
|
|
22
|
+
func AddToCache(name string, module Module) error {
|
|
23
|
+
return nil
|
|
24
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package winloader
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/jchv/go-winloader/internal/memloader"
|
|
5
|
+
"github.com/jchv/go-winloader/internal/winloader"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
var native = winloader.Loader{}
|
|
9
|
+
|
|
10
|
+
var cache = memloader.NewCache(native)
|
|
11
|
+
|
|
12
|
+
var ldr = memloader.New(memloader.Options{
|
|
13
|
+
Next: cache,
|
|
14
|
+
Machine: winloader.NativeMachine{},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
// LoadFromFile loads a Windows module from file using the native Windows
|
|
18
|
+
// loader.
|
|
19
|
+
func LoadFromFile(name string) (Module, error) {
|
|
20
|
+
return native.Load(name)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// LoadFromMemory loads a Windows module from memory.
|
|
24
|
+
func LoadFromMemory(data []byte) (Module, error) {
|
|
25
|
+
return ldr.LoadMem(data)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// AddToCache adds a module to the loader cache, allowing in-memory libraries
|
|
29
|
+
// to link to it. Note that modules in the cache must exist in the same
|
|
30
|
+
// address space.
|
|
31
|
+
func AddToCache(name string, module Module) error {
|
|
32
|
+
return cache.Add(name, module)
|
|
33
|
+
}
|
package/govendor/manifest.txt
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Generated by scripts/vendor-go.mjs — do not edit
|
|
2
|
-
version github.com/ncruces/go-sqlite3@v0.35.6,github.com/andybalholm/brotli@v1.2.6,github.com/fsnotify/fsnotify@v1.10.1
|
|
2
|
+
version github.com/ncruces/go-sqlite3@v0.35.6,github.com/andybalholm/brotli@v1.2.6,github.com/fsnotify/fsnotify@v1.10.1,github.com/jchv/go-webview2@v0.0.0-20260205173254-56598839c808
|
|
3
3
|
go 1.26.0
|
|
4
4
|
module github.com/andybalholm/brotli v1.2.6
|
|
5
5
|
module github.com/fsnotify/fsnotify v1.10.1
|
|
6
|
+
module github.com/jchv/go-webview2 v0.0.0-20260205173254-56598839c808
|
|
7
|
+
module github.com/jchv/go-winloader v0.0.0-20250406163304-c1995be93bd1
|
|
6
8
|
module github.com/ncruces/go-sqlite3 v0.35.6
|
|
7
9
|
module github.com/ncruces/go-sqlite3-wasm/v6 v6.3.35304
|
|
8
10
|
module github.com/ncruces/julianday v1.0.0
|
package/package.json
CHANGED
package/tsparser/main.go
CHANGED
|
@@ -221,6 +221,10 @@ func setPosition(n *ast.Node, obj map[string]any) {
|
|
|
221
221
|
line, character := scanner.GetECMALineAndUTF16CharacterOfPosition(parsedFile, scanner.GetTokenPosOfNode(n, parsedFile, false))
|
|
222
222
|
obj["line"] = line + 1
|
|
223
223
|
obj["column"] = int(character) + 1
|
|
224
|
+
// where it ends (exclusive): node:test coverage ranges
|
|
225
|
+
endLine, endCharacter := scanner.GetECMALineAndUTF16CharacterOfPosition(parsedFile, n.End())
|
|
226
|
+
obj["endLine"] = endLine + 1
|
|
227
|
+
obj["endColumn"] = int(endCharacter) + 1
|
|
224
228
|
}
|
|
225
229
|
|
|
226
230
|
// collectFields serializes a typed data struct's fields into obj, recursing
|
|
@@ -513,8 +513,15 @@ declare module 'node:util' {
|
|
|
513
513
|
value?: string;
|
|
514
514
|
inlineValue?: boolean;
|
|
515
515
|
}
|
|
516
|
-
|
|
517
|
-
|
|
516
|
+
// The parsed value of an option: its type, an array of them when multiple
|
|
517
|
+
type ParseArgsOptionValue<O extends ParseArgsOptionConfig> = O['type'] extends 'string'
|
|
518
|
+
? O['multiple'] extends true ? string[] : string
|
|
519
|
+
: O['multiple'] extends true ? boolean[] : boolean;
|
|
520
|
+
type ParseArgsValues<T extends ParseArgsConfig> = T['options'] extends Record<string, ParseArgsOptionConfig>
|
|
521
|
+
? { -readonly [K in keyof T['options']]?: ParseArgsOptionValue<T['options'][K]> }
|
|
522
|
+
: Record<string, string | boolean | (string | boolean)[] | undefined>;
|
|
523
|
+
function parseArgs<T extends ParseArgsConfig>(config?: T): {
|
|
524
|
+
values: ParseArgsValues<T>;
|
|
518
525
|
positionals: string[];
|
|
519
526
|
tokens?: ParseArgsToken[];
|
|
520
527
|
};
|
|
@@ -1247,6 +1254,8 @@ declare module 'node:stream' {
|
|
|
1247
1254
|
resume(): this;
|
|
1248
1255
|
isPaused(): boolean;
|
|
1249
1256
|
pipe<T extends Writable>(destination: T, options?: { end?: boolean }): T;
|
|
1257
|
+
/** A stream to pipe into, or a function given this stream (an async generator over its chunks, a node:test reporter) */
|
|
1258
|
+
compose(stream: Duplex | ((source: any) => any)): Duplex;
|
|
1250
1259
|
destroy(error?: Error): this;
|
|
1251
1260
|
[Symbol.asyncIterator](): AsyncIterator<any>;
|
|
1252
1261
|
static toWeb(streamReadable: Readable, options?: { strategy?: QueuingStrategy }): ReadableStream;
|
|
@@ -2463,6 +2472,7 @@ declare module 'node:async_hooks' {
|
|
|
2463
2472
|
}
|
|
2464
2473
|
|
|
2465
2474
|
declare module 'node:test' {
|
|
2475
|
+
import { Readable } from 'node:stream';
|
|
2466
2476
|
function test(name?: string, fn?: test.TestFn): Promise<void>;
|
|
2467
2477
|
function test(name?: string, options?: test.TestOptions, fn?: test.TestFn): Promise<void>;
|
|
2468
2478
|
function test(fn?: test.TestFn): Promise<void>;
|
|
@@ -2499,9 +2509,22 @@ declare module 'node:test' {
|
|
|
2499
2509
|
restore(): void;
|
|
2500
2510
|
}
|
|
2501
2511
|
export type Mock<F extends (...args: any[]) => any> = F & { mock: MockFunctionContext<F> };
|
|
2512
|
+
export interface MockFunctionOptions {
|
|
2513
|
+
times?: number;
|
|
2514
|
+
}
|
|
2515
|
+
export interface MockMethodOptions extends MockFunctionOptions {
|
|
2516
|
+
getter?: boolean;
|
|
2517
|
+
setter?: boolean;
|
|
2518
|
+
}
|
|
2519
|
+
type MockedMember<T> = T extends (...args: any[]) => any ? T : (...args: any[]) => any;
|
|
2502
2520
|
export interface MockTracker {
|
|
2503
2521
|
fn<F extends (...args: any[]) => any = (...args: any[]) => undefined>(original?: F): Mock<F>;
|
|
2504
2522
|
fn<F extends (...args: any[]) => any, Implementation extends (...args: any[]) => any = F>(original: F, implementation: Implementation): Mock<F | Implementation>;
|
|
2523
|
+
/** Replaces object[methodName] (an object-literal method, a class instance's method, a namespace function such as console.log) until restore() */
|
|
2524
|
+
method<O extends object, K extends keyof O>(object: O, methodName: K, options?: MockMethodOptions): Mock<MockedMember<O[K]>>;
|
|
2525
|
+
method<O extends object, K extends keyof O>(object: O, methodName: K, implementation: (...args: any[]) => any, options?: MockMethodOptions): Mock<MockedMember<O[K]>>;
|
|
2526
|
+
getter<O extends object, K extends keyof O>(object: O, methodName: K, implementation?: (...args: any[]) => any, options?: MockFunctionOptions): Mock<() => O[K]>;
|
|
2527
|
+
setter<O extends object, K extends keyof O>(object: O, methodName: K, implementation?: (...args: any[]) => any, options?: MockFunctionOptions): Mock<(value: O[K]) => void>;
|
|
2505
2528
|
reset(): void;
|
|
2506
2529
|
restoreAll(): void;
|
|
2507
2530
|
readonly timers: MockTimers;
|
|
@@ -2536,6 +2559,13 @@ declare module 'node:test' {
|
|
|
2536
2559
|
doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
|
2537
2560
|
fail(message?: string | Error): never;
|
|
2538
2561
|
ifError(value: unknown): void;
|
|
2562
|
+
/** Compares with (or, with --test-update-snapshots, writes) the test file's <file>.snapshot entry */
|
|
2563
|
+
snapshot(value: any, options?: AssertSnapshotOptions): void;
|
|
2564
|
+
/** Compares with (or, with --test-update-snapshots, writes) the file at path */
|
|
2565
|
+
fileSnapshot(value: any, path: string, options?: AssertSnapshotOptions): void;
|
|
2566
|
+
}
|
|
2567
|
+
export interface AssertSnapshotOptions {
|
|
2568
|
+
serializers?: ReadonlyArray<(value: any) => any>;
|
|
2539
2569
|
}
|
|
2540
2570
|
export interface TestContext {
|
|
2541
2571
|
readonly name: string;
|
|
@@ -2592,10 +2622,114 @@ declare module 'node:test' {
|
|
|
2592
2622
|
export function after(fn?: HookFn, options?: TestOptions): void;
|
|
2593
2623
|
export function beforeEach(fn?: HookFn, options?: TestOptions): void;
|
|
2594
2624
|
export function afterEach(fn?: HookFn, options?: TestOptions): void;
|
|
2625
|
+
export namespace snapshot {
|
|
2626
|
+
function setDefaultSnapshotSerializers(serializers: ReadonlyArray<(value: any) => any>): void;
|
|
2627
|
+
function setResolveSnapshotPath(fn: (path: string | undefined) => string): void;
|
|
2628
|
+
}
|
|
2629
|
+
/** Runs each file (a literal path, compiled into the program) in a child process */
|
|
2630
|
+
export function run(options?: RunOptions): TestsStream;
|
|
2631
|
+
export interface RunOptions {
|
|
2632
|
+
files?: readonly string[];
|
|
2633
|
+
concurrency?: number | boolean;
|
|
2634
|
+
timeout?: number;
|
|
2635
|
+
only?: boolean;
|
|
2636
|
+
testNamePatterns?: string | RegExp | ReadonlyArray<string | RegExp>;
|
|
2637
|
+
testSkipPatterns?: string | RegExp | ReadonlyArray<string | RegExp>;
|
|
2638
|
+
coverage?: boolean;
|
|
2639
|
+
updateSnapshots?: boolean;
|
|
2640
|
+
cwd?: string;
|
|
2641
|
+
argv?: readonly string[];
|
|
2642
|
+
setup?: (reporter: TestsStream) => void | Promise<void>;
|
|
2643
|
+
}
|
|
2644
|
+
export interface TestsStream extends Readable {
|
|
2645
|
+
on(event: 'test:pass' | 'test:fail' | 'test:start' | 'test:complete' | 'test:enqueue' | 'test:dequeue', listener: (data: EventData.Test) => void): this;
|
|
2646
|
+
on(event: 'test:plan', listener: (data: EventData.TestPlan) => void): this;
|
|
2647
|
+
on(event: 'test:diagnostic' | 'test:stdout' | 'test:stderr', listener: (data: EventData.TestMessage) => void): this;
|
|
2648
|
+
on(event: 'test:summary', listener: (data: EventData.TestSummary) => void): this;
|
|
2649
|
+
on(event: 'test:coverage', listener: (data: EventData.TestCoverage) => void): this;
|
|
2650
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
2651
|
+
once(event: 'test:pass' | 'test:fail' | 'test:start' | 'test:complete', listener: (data: EventData.Test) => void): this;
|
|
2652
|
+
once(event: 'test:summary', listener: (data: EventData.TestSummary) => void): this;
|
|
2653
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
2654
|
+
}
|
|
2655
|
+
export namespace EventData {
|
|
2656
|
+
interface Location {
|
|
2657
|
+
file?: string;
|
|
2658
|
+
line?: number;
|
|
2659
|
+
column?: number;
|
|
2660
|
+
}
|
|
2661
|
+
interface Test extends Location {
|
|
2662
|
+
name: string;
|
|
2663
|
+
nesting: number;
|
|
2664
|
+
testNumber: number;
|
|
2665
|
+
details: { duration_ms: number; type: 'suite' | 'test'; error?: Error; passed?: boolean };
|
|
2666
|
+
skip?: string | boolean;
|
|
2667
|
+
todo?: string | boolean;
|
|
2668
|
+
}
|
|
2669
|
+
interface TestPlan extends Location {
|
|
2670
|
+
nesting: number;
|
|
2671
|
+
count: number;
|
|
2672
|
+
}
|
|
2673
|
+
interface TestMessage extends Location {
|
|
2674
|
+
nesting: number;
|
|
2675
|
+
message: string;
|
|
2676
|
+
level?: 'info' | 'warn' | 'error';
|
|
2677
|
+
}
|
|
2678
|
+
interface TestSummary {
|
|
2679
|
+
counts: { tests: number; failed: number; passed: number; cancelled: number; skipped: number; todo: number; topLevel: number; suites: number };
|
|
2680
|
+
duration_ms: number;
|
|
2681
|
+
file: string | undefined;
|
|
2682
|
+
success: boolean;
|
|
2683
|
+
}
|
|
2684
|
+
interface CoverageCounts {
|
|
2685
|
+
totalLineCount: number;
|
|
2686
|
+
totalBranchCount: number;
|
|
2687
|
+
totalFunctionCount: number;
|
|
2688
|
+
coveredLineCount: number;
|
|
2689
|
+
coveredBranchCount: number;
|
|
2690
|
+
coveredFunctionCount: number;
|
|
2691
|
+
coveredLinePercent: number;
|
|
2692
|
+
coveredBranchPercent: number;
|
|
2693
|
+
coveredFunctionPercent: number;
|
|
2694
|
+
}
|
|
2695
|
+
interface CoverageFile extends CoverageCounts {
|
|
2696
|
+
path: string;
|
|
2697
|
+
functions: { name: string; line: number; count: number }[];
|
|
2698
|
+
branches: { line: number; count: number }[];
|
|
2699
|
+
lines: { line: number; count: number }[];
|
|
2700
|
+
}
|
|
2701
|
+
interface TestCoverage {
|
|
2702
|
+
nesting: number;
|
|
2703
|
+
summary: { files: CoverageFile[]; totals: CoverageCounts; workingDirectory: string };
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2595
2706
|
}
|
|
2596
2707
|
export = test;
|
|
2597
2708
|
}
|
|
2598
2709
|
|
|
2710
|
+
// The reporters of node:test (--test-reporter), over run() streams and event sources
|
|
2711
|
+
declare module 'node:test/reporters' {
|
|
2712
|
+
import { Duplex } from 'node:stream';
|
|
2713
|
+
import { EventData } from 'node:test';
|
|
2714
|
+
type TestEvent =
|
|
2715
|
+
| { type: 'test:pass' | 'test:fail' | 'test:start' | 'test:complete' | 'test:enqueue' | 'test:dequeue'; data: EventData.Test }
|
|
2716
|
+
| { type: 'test:plan'; data: EventData.TestPlan }
|
|
2717
|
+
| { type: 'test:diagnostic' | 'test:stdout' | 'test:stderr'; data: EventData.TestMessage }
|
|
2718
|
+
| { type: 'test:summary'; data: EventData.TestSummary }
|
|
2719
|
+
| { type: 'test:coverage'; data: EventData.TestCoverage };
|
|
2720
|
+
type TestEventSource = AsyncIterable<TestEvent> | Iterable<TestEvent>;
|
|
2721
|
+
function tap(source: TestEventSource): AsyncGenerator<string, void>;
|
|
2722
|
+
function dot(source: TestEventSource): AsyncGenerator<string, void>;
|
|
2723
|
+
function junit(source: TestEventSource): AsyncGenerator<string, void>;
|
|
2724
|
+
interface ReporterConstructor {
|
|
2725
|
+
new (): Duplex;
|
|
2726
|
+
(): Duplex;
|
|
2727
|
+
}
|
|
2728
|
+
const spec: ReporterConstructor;
|
|
2729
|
+
const lcov: ReporterConstructor;
|
|
2730
|
+
export { tap, dot, junit, spec, lcov, TestEvent };
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2599
2733
|
declare module 'node:worker_threads' {
|
|
2600
2734
|
import { EventEmitter } from 'node:events';
|
|
2601
2735
|
namespace worker_threads {
|
|
@@ -2893,3 +3027,57 @@ declare module 'async_hooks' { import m = require('node:async_hooks'); export =
|
|
|
2893
3027
|
declare module 'worker_threads' { import m = require('node:worker_threads'); export = m; }
|
|
2894
3028
|
declare module 'cluster' { import m = require('node:cluster'); export = m; }
|
|
2895
3029
|
declare module 'http2' { import m = require('node:http2'); export = m; }
|
|
3030
|
+
|
|
3031
|
+
// The npm package's API for native app windows, as far as compiled programs
|
|
3032
|
+
// implement it (under Node.js the real package runs). The real 'close' event can
|
|
3033
|
+
// be cancelled; compiled, the window is already gone, so preventDefault is absent.
|
|
3034
|
+
declare module '@webviewjs/webview' {
|
|
3035
|
+
interface ApplicationEvent {
|
|
3036
|
+
event: string;
|
|
3037
|
+
}
|
|
3038
|
+
interface WebContextOptions {
|
|
3039
|
+
// Where the webview keeps its profile. Needed under Node.js on Windows: the
|
|
3040
|
+
// default is beside node.exe, which Program Files makes read-only
|
|
3041
|
+
dataDirectory?: string;
|
|
3042
|
+
}
|
|
3043
|
+
interface BrowserWindowOptions {
|
|
3044
|
+
title?: string;
|
|
3045
|
+
width?: number;
|
|
3046
|
+
height?: number;
|
|
3047
|
+
// width and height in logical pixels, which follow the display's scaling, rather
|
|
3048
|
+
// than physical ones
|
|
3049
|
+
logical?: boolean;
|
|
3050
|
+
resizable?: boolean;
|
|
3051
|
+
}
|
|
3052
|
+
interface WebviewOptions {
|
|
3053
|
+
url?: string;
|
|
3054
|
+
html?: string;
|
|
3055
|
+
enableDevtools?: boolean;
|
|
3056
|
+
webContext?: WebContext | null;
|
|
3057
|
+
}
|
|
3058
|
+
class WebContext {}
|
|
3059
|
+
class Webview {
|
|
3060
|
+
loadUrl(url: string): void;
|
|
3061
|
+
loadHtml(html: string): void;
|
|
3062
|
+
evaluateScript(js: string): void;
|
|
3063
|
+
reload(): void;
|
|
3064
|
+
}
|
|
3065
|
+
class BrowserWindow {
|
|
3066
|
+
createWebview(options?: WebviewOptions): Webview;
|
|
3067
|
+
setTitle(title: string): void;
|
|
3068
|
+
close(): void;
|
|
3069
|
+
on(event: 'close', listener: (event: ApplicationEvent) => void): this;
|
|
3070
|
+
once(event: 'close', listener: (event: ApplicationEvent) => void): this;
|
|
3071
|
+
}
|
|
3072
|
+
type ApplicationEventName = 'ready' | 'window-close-requested' | 'application-close-requested';
|
|
3073
|
+
class Application {
|
|
3074
|
+
createWebContext(options?: WebContextOptions): WebContext;
|
|
3075
|
+
createBrowserWindow(options?: BrowserWindowOptions): BrowserWindow;
|
|
3076
|
+
isReady(): boolean;
|
|
3077
|
+
run(): void;
|
|
3078
|
+
whenReady(): Promise<void>;
|
|
3079
|
+
exit(): void;
|
|
3080
|
+
on(event: ApplicationEventName, listener: (event: ApplicationEvent) => void): this;
|
|
3081
|
+
once(event: ApplicationEventName, listener: (event: ApplicationEvent) => void): this;
|
|
3082
|
+
}
|
|
3083
|
+
}
|