@evobug_com/safe-ts-feature-node 0.1.0 → 0.3.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.
Files changed (82) hide show
  1. package/README.md +4 -2
  2. package/node-api.json +48 -85
  3. package/package.json +162 -3
  4. package/safe/buffer.d.ts +155 -0
  5. package/safe/buffer.js +582 -0
  6. package/safe/child_process.d.ts +32 -0
  7. package/safe/child_process.js +21 -0
  8. package/safe/core.d.ts +36 -0
  9. package/safe/core.js +25 -0
  10. package/safe/crypto.d.ts +105 -0
  11. package/safe/crypto.js +205 -0
  12. package/safe/dgram.d.ts +26 -0
  13. package/safe/dgram.js +76 -0
  14. package/safe/dns/promises.d.ts +136 -0
  15. package/safe/dns/promises.js +262 -0
  16. package/safe/errors.d.ts +155 -0
  17. package/safe/errors.js +32 -0
  18. package/safe/events.d.ts +11 -0
  19. package/safe/events.js +14 -0
  20. package/safe/ffi.d.ts +23 -0
  21. package/safe/ffi.js +57 -0
  22. package/safe/fs/promises.d.ts +168 -0
  23. package/safe/fs/promises.js +366 -0
  24. package/safe/fs.d.ts +201 -0
  25. package/safe/fs.js +422 -0
  26. package/safe/globals.d.ts +87 -0
  27. package/safe/globals.js +232 -0
  28. package/safe/http.d.ts +34 -0
  29. package/safe/http.js +85 -0
  30. package/safe/http2.d.ts +26 -0
  31. package/safe/http2.js +61 -0
  32. package/safe/https.d.ts +21 -0
  33. package/safe/https.js +29 -0
  34. package/safe/inspector/promises.d.ts +200 -0
  35. package/safe/inspector/promises.js +13 -0
  36. package/safe/inspector.d.ts +8 -0
  37. package/safe/inspector.js +13 -0
  38. package/safe/module.d.ts +21 -0
  39. package/safe/module.js +45 -0
  40. package/safe/net.d.ts +11 -0
  41. package/safe/net.js +17 -0
  42. package/safe/os.d.ts +20 -0
  43. package/safe/os.js +29 -0
  44. package/safe/perf_hooks.d.ts +11 -0
  45. package/safe/perf_hooks.js +12 -0
  46. package/safe/process.d.ts +31 -0
  47. package/safe/process.js +97 -0
  48. package/safe/punycode.d.ts +10 -0
  49. package/safe/punycode.js +21 -0
  50. package/safe/querystring.d.ts +11 -0
  51. package/safe/querystring.js +21 -0
  52. package/safe/readline/promises.d.ts +12 -0
  53. package/safe/readline/promises.js +13 -0
  54. package/safe/runtime.d.ts +10 -0
  55. package/safe/runtime.js +16 -0
  56. package/safe/sqlite.d.ts +54 -0
  57. package/safe/sqlite.js +118 -0
  58. package/safe/stream/consumers.d.ts +19 -0
  59. package/safe/stream/consumers.js +54 -0
  60. package/safe/stream/promises.d.ts +26 -0
  61. package/safe/stream/promises.js +22 -0
  62. package/safe/stream/web.d.ts +18 -0
  63. package/safe/stream/web.js +37 -0
  64. package/safe/stream.d.ts +29 -0
  65. package/safe/stream.js +62 -0
  66. package/safe/tls.d.ts +27 -0
  67. package/safe/tls.js +65 -0
  68. package/safe/url.d.ts +28 -0
  69. package/safe/url.js +57 -0
  70. package/safe/util.d.ts +13 -0
  71. package/safe/util.js +25 -0
  72. package/safe/v8.d.ts +28 -0
  73. package/safe/v8.js +85 -0
  74. package/safe/vm.d.ts +23 -0
  75. package/safe/vm.js +69 -0
  76. package/safe/wasi.d.ts +10 -0
  77. package/safe/wasi.js +20 -0
  78. package/safe/worker_threads.d.ts +31 -0
  79. package/safe/worker_threads.js +62 -0
  80. package/safe/zlib.d.ts +61 -0
  81. package/safe/zlib.js +214 -0
  82. package/safe-ts.json +1722 -490
package/safe/url.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
2
+ /// <reference types="node" />
3
+ import type { Option, Result } from "@evobug_com/safe-ts-std/result";
4
+ import type { NodeError } from "./errors.js";
5
+ import type * as $buffer from "node:buffer";
6
+ import type * as $url from "node:url";
7
+ export * from "node:url";
8
+
9
+ /** `URLPattern#exec()` (node:url), with `null` returned as `undefined`. */
10
+ export declare function exec(urlPattern: $url.URLPattern, input?: $url.URLPatternInput, baseURL?: string | $url.URL): Option<$url.URLPatternResult>;
11
+ /** `fileURLToPath()` (node:url), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_INVALID_URL_SCHEME | ERR_INVALID_FILE_URL_HOST] | TypeError [ERR_INVALID_FILE_URL_PATH] {input?}`. */
12
+ export declare function fileURLToPath(url: string | $url.URL, options?: $url.FileUrlToPathOptions): Result<string, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_INVALID_URL_SCHEME" | "ERR_INVALID_FILE_URL_HOST", "TypeError"> | NodeError<"ERR_INVALID_FILE_URL_PATH", "TypeError", { input?: string }>>;
13
+ /** `fileURLToPathBuffer()` (node:url), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_INVALID_URL_SCHEME | ERR_INVALID_FILE_URL_HOST] | TypeError [ERR_INVALID_FILE_URL_PATH] {input?}`. */
14
+ export declare function fileURLToPathBuffer(url: string | $url.URL, options?: $url.FileUrlToPathOptions): Result<$buffer.NonSharedBuffer, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_INVALID_URL_SCHEME" | "ERR_INVALID_FILE_URL_HOST", "TypeError"> | NodeError<"ERR_INVALID_FILE_URL_PATH", "TypeError", { input?: string }>>;
15
+ /** `URLSearchParams#get()` (node:url), with `null` returned as `undefined`. */
16
+ export declare function get(urlSearchParams: $url.URLSearchParams, name: string): Option<string>;
17
+ /** `new URL()` (node:url), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input, base?}`. */
18
+ export declare function newURL(url: string | $url.URL, base?: string | $url.URL): Result<$url.URL, NodeError<"ERR_INVALID_URL", "TypeError", { input: string; base?: string }>>;
19
+ /** `parse()` (node:url), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_INVALID_ARG_VALUE]`. */
20
+ export declare function parse(urlString: string, parseQueryString?: false, slashesDenoteHost?: boolean): Result<$url.UrlWithStringQuery, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_INVALID_ARG_VALUE", "TypeError">>;
21
+ /** `parse()` (node:url), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_INVALID_ARG_VALUE]`. */
22
+ export declare function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): Result<$url.UrlWithParsedQuery, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_INVALID_ARG_VALUE", "TypeError">>;
23
+ /** `parse()` (node:url), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_INVALID_ARG_VALUE]`. */
24
+ export declare function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Result<$url.Url, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_INVALID_ARG_VALUE", "TypeError">>;
25
+ /** `resolve()` (node:url), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_URL] {input} | TypeError [ERR_INVALID_ARG_VALUE]`. */
26
+ export declare function resolve(from: string, to: string): Result<string, NodeError<"ERR_INVALID_URL", "TypeError", { input: string }> | NodeError<"ERR_INVALID_ARG_VALUE", "TypeError">>;
27
+ /** `URL.parse()` (node:url), with `null` returned as `undefined`. */
28
+ export declare function urlParse(input: string | $url.URL, base?: string | $url.URL): Option<$url.URL>;
package/safe/url.js ADDED
@@ -0,0 +1,57 @@
1
+ // @safe-ts std
2
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
3
+ import * as $module from "node:url";
4
+ import { Err } from "@evobug_com/safe-ts-std/result";
5
+ export * from "node:url";
6
+
7
+ export function exec(self, ...args) {
8
+ return self.exec(...args) ?? undefined;
9
+ }
10
+
11
+ export function fileURLToPath(...args) {
12
+ try {
13
+ return $module.fileURLToPath(...args);
14
+ } catch (error) {
15
+ return new Err(error);
16
+ }
17
+ }
18
+
19
+ export function fileURLToPathBuffer(...args) {
20
+ try {
21
+ return $module.fileURLToPathBuffer(...args);
22
+ } catch (error) {
23
+ return new Err(error);
24
+ }
25
+ }
26
+
27
+ export function get(self, ...args) {
28
+ return self.get(...args) ?? undefined;
29
+ }
30
+
31
+ export function newURL(...args) {
32
+ try {
33
+ return new $module.URL(...args);
34
+ } catch (error) {
35
+ return new Err(error);
36
+ }
37
+ }
38
+
39
+ export function parse(...args) {
40
+ try {
41
+ return $module.parse(...args);
42
+ } catch (error) {
43
+ return new Err(error);
44
+ }
45
+ }
46
+
47
+ export function resolve(...args) {
48
+ try {
49
+ return $module.resolve(...args);
50
+ } catch (error) {
51
+ return new Err(error);
52
+ }
53
+ }
54
+
55
+ export function urlParse(...args) {
56
+ return $module.URL.parse(...args) ?? undefined;
57
+ }
package/safe/util.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
2
+ /// <reference types="node" />
3
+ import type { Option, Result } from "@evobug_com/safe-ts-std/result";
4
+ import type { NodeError } from "./errors.js";
5
+ import type * as $util from "node:util";
6
+ export * from "node:util";
7
+
8
+ /** `TextDecoder#decode()` (node:util), with what it throws returned as an `Err`: `TypeError [ERR_ENCODING_INVALID_ENCODED_DATA]`. */
9
+ export declare function decode(textDecoder: $util.TextDecoder, input?: NodeJS.AllowSharedBufferSource, options?: $util.TextDecodeOptions): Result<string, NodeError<"ERR_ENCODING_INVALID_ENCODED_DATA", "TypeError">>;
10
+ /** `MIMEParams#get()` (node:util), with `null` returned as `undefined`. */
11
+ export declare function get(mimeParams: $util.MIMEParams, name: string): Option<string>;
12
+ /** `new MIMEType()` (node:util), with what it throws returned as an `Err`: `TypeError [ERR_INVALID_MIME_SYNTAX]`. */
13
+ export declare function newMIMEType(input: string | { toString: () => string }): Result<$util.MIMEType, NodeError<"ERR_INVALID_MIME_SYNTAX", "TypeError">>;
package/safe/util.js ADDED
@@ -0,0 +1,25 @@
1
+ // @safe-ts std
2
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
3
+ import * as $module from "node:util";
4
+ import { Err } from "@evobug_com/safe-ts-std/result";
5
+ export * from "node:util";
6
+
7
+ export function decode(self, ...args) {
8
+ try {
9
+ return self.decode(...args);
10
+ } catch (error) {
11
+ return new Err(error);
12
+ }
13
+ }
14
+
15
+ export function get(self, ...args) {
16
+ return self.get(...args) ?? undefined;
17
+ }
18
+
19
+ export function newMIMEType(...args) {
20
+ try {
21
+ return new $module.MIMEType(...args);
22
+ } catch (error) {
23
+ return new Err(error);
24
+ }
25
+ }
package/safe/v8.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
2
+ /// <reference types="node" />
3
+ import type { Result } from "@evobug_com/safe-ts-std/result";
4
+ import type { PlainError, SystemError } from "./errors.js";
5
+ import type * as $buffer from "node:buffer";
6
+ import type * as $v8 from "node:v8";
7
+ export * from "node:v8";
8
+
9
+ /** `deserialize()` (node:v8), with what it throws returned as an `Err`: `Error`. */
10
+ export declare function deserialize(buffer: NodeJS.ArrayBufferView): Result<any, PlainError<"Error">>;
11
+ /** `Deserializer#readDouble()` (node:v8), with what it throws returned as an `Err`: `Error`. */
12
+ export declare function readDouble(deserializer: $v8.Deserializer): Result<number, PlainError<"Error">>;
13
+ /** `Deserializer#readHeader()` (node:v8), with what it throws returned as an `Err`: `Error`. */
14
+ export declare function readHeader(deserializer: $v8.Deserializer): Result<boolean, PlainError<"Error">>;
15
+ /** `Deserializer#readRawBytes()` (node:v8), with what it throws returned as an `Err`: `Error`. */
16
+ export declare function readRawBytes(deserializer: $v8.Deserializer, length: number): Result<Buffer, PlainError<"Error">>;
17
+ /** `Deserializer#readUint32()` (node:v8), with what it throws returned as an `Err`: `Error`. */
18
+ export declare function readUint32(deserializer: $v8.Deserializer): Result<number, PlainError<"Error">>;
19
+ /** `Deserializer#readUint64()` (node:v8), with what it throws returned as an `Err`: `Error`. */
20
+ export declare function readUint64(deserializer: $v8.Deserializer): Result<[number, number], PlainError<"Error">>;
21
+ /** `Deserializer#readValue()` (node:v8), with what it throws returned as an `Err`: `Error`. */
22
+ export declare function readValue(deserializer: $v8.Deserializer): Result<any, PlainError<"Error">>;
23
+ /** `serialize()` (node:v8), with what it throws returned as an `Err`: `Error`. */
24
+ export declare function serialize(value: any): Result<$buffer.NonSharedBuffer, PlainError<"Error">>;
25
+ /** `writeHeapSnapshot()` (node:v8), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'open', path}`. */
26
+ export declare function writeHeapSnapshot(filename?: string, options?: $v8.HeapSnapshotOptions): Result<string, SystemError<"open", { path: string }>>;
27
+ /** `Serializer#writeValue()` (node:v8), with what it throws returned as an `Err`: `Error`. */
28
+ export declare function writeValue(serializer: $v8.Serializer, val: any): Result<boolean, PlainError<"Error">>;
package/safe/v8.js ADDED
@@ -0,0 +1,85 @@
1
+ // @safe-ts std
2
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
3
+ import * as $module from "node:v8";
4
+ import { Err } from "@evobug_com/safe-ts-std/result";
5
+ export * from "node:v8";
6
+
7
+ export function deserialize(...args) {
8
+ try {
9
+ return $module.deserialize(...args);
10
+ } catch (error) {
11
+ return new Err(error);
12
+ }
13
+ }
14
+
15
+ export function readDouble(self, ...args) {
16
+ try {
17
+ return self.readDouble(...args);
18
+ } catch (error) {
19
+ return new Err(error);
20
+ }
21
+ }
22
+
23
+ export function readHeader(self, ...args) {
24
+ try {
25
+ return self.readHeader(...args);
26
+ } catch (error) {
27
+ return new Err(error);
28
+ }
29
+ }
30
+
31
+ export function readRawBytes(self, ...args) {
32
+ try {
33
+ return self.readRawBytes(...args);
34
+ } catch (error) {
35
+ return new Err(error);
36
+ }
37
+ }
38
+
39
+ export function readUint32(self, ...args) {
40
+ try {
41
+ return self.readUint32(...args);
42
+ } catch (error) {
43
+ return new Err(error);
44
+ }
45
+ }
46
+
47
+ export function readUint64(self, ...args) {
48
+ try {
49
+ return self.readUint64(...args);
50
+ } catch (error) {
51
+ return new Err(error);
52
+ }
53
+ }
54
+
55
+ export function readValue(self, ...args) {
56
+ try {
57
+ return self.readValue(...args);
58
+ } catch (error) {
59
+ return new Err(error);
60
+ }
61
+ }
62
+
63
+ export function serialize(...args) {
64
+ try {
65
+ return $module.serialize(...args);
66
+ } catch (error) {
67
+ return new Err(error);
68
+ }
69
+ }
70
+
71
+ export function writeHeapSnapshot(...args) {
72
+ try {
73
+ return $module.writeHeapSnapshot(...args);
74
+ } catch (error) {
75
+ return new Err(error);
76
+ }
77
+ }
78
+
79
+ export function writeValue(self, ...args) {
80
+ try {
81
+ return self.writeValue(...args);
82
+ } catch (error) {
83
+ return new Err(error);
84
+ }
85
+ }
package/safe/vm.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
2
+ /// <reference types="node" />
3
+ import type { Result } from "@evobug_com/safe-ts-std/result";
4
+ import type { PlainError } from "./errors.js";
5
+ import type * as $vm from "node:vm";
6
+ export * from "node:vm";
7
+
8
+ /** `compileFunction()` (node:vm), with what it throws returned as an `Err`: `SyntaxError`. */
9
+ export declare function compileFunction(code: string, params?: readonly string[], options?: $vm.CompileFunctionOptions): Result<Function & Pick<$vm.Script, "cachedData" | "cachedDataProduced" | "cachedDataRejected">, PlainError<"SyntaxError">>;
10
+ /** `new Script()` (node:vm), with what it throws returned as an `Err`: `SyntaxError`. */
11
+ export declare function newScript(code: string, options?: $vm.ScriptOptions | string): Result<$vm.Script, PlainError<"SyntaxError">>;
12
+ /** `runInContext()` (node:vm), with what it throws returned as an `Err`: `SyntaxError | (what the code throws)`. */
13
+ export declare function runInContext(code: string, contextifiedObject: $vm.Context, options?: $vm.RunningCodeOptions | string): Result<any, unknown>;
14
+ /** `runInNewContext()` (node:vm), with what it throws returned as an `Err`: `SyntaxError | (what the code throws)`. */
15
+ export declare function runInNewContext(code: string, contextObject?: $vm.Context | typeof $vm.constants.DONT_CONTEXTIFY, options?: $vm.RunningCodeInNewContextOptions | string): Result<any, unknown>;
16
+ /** `runInThisContext()` (node:vm), with what it throws returned as an `Err`: `SyntaxError | (what the code throws)`. */
17
+ export declare function runInThisContext(code: string, options?: $vm.RunningCodeOptions | string): Result<any, unknown>;
18
+ /** `Script#runInContext()` (node:vm), with what it throws returned as an `Err`: `(what the code throws)`. */
19
+ export declare function scriptRunInContext(script: $vm.Script, contextifiedObject: $vm.Context, options?: $vm.RunningScriptOptions): Result<any, unknown>;
20
+ /** `Script#runInNewContext()` (node:vm), with what it throws returned as an `Err`: `(what the code throws)`. */
21
+ export declare function scriptRunInNewContext(script: $vm.Script, contextObject?: $vm.Context | typeof $vm.constants.DONT_CONTEXTIFY, options?: $vm.RunningScriptInNewContextOptions): Result<any, unknown>;
22
+ /** `Script#runInThisContext()` (node:vm), with what it throws returned as an `Err`: `(what the code throws)`. */
23
+ export declare function scriptRunInThisContext(script: $vm.Script, options?: $vm.RunningScriptOptions): Result<any, unknown>;
package/safe/vm.js ADDED
@@ -0,0 +1,69 @@
1
+ // @safe-ts std
2
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
3
+ import * as $module from "node:vm";
4
+ import { Err } from "@evobug_com/safe-ts-std/result";
5
+ export * from "node:vm";
6
+
7
+ export function compileFunction(...args) {
8
+ try {
9
+ return $module.compileFunction(...args);
10
+ } catch (error) {
11
+ return new Err(error);
12
+ }
13
+ }
14
+
15
+ export function newScript(...args) {
16
+ try {
17
+ return new $module.Script(...args);
18
+ } catch (error) {
19
+ return new Err(error);
20
+ }
21
+ }
22
+
23
+ export function runInContext(...args) {
24
+ try {
25
+ return $module.runInContext(...args);
26
+ } catch (error) {
27
+ return new Err(error);
28
+ }
29
+ }
30
+
31
+ export function runInNewContext(...args) {
32
+ try {
33
+ return $module.runInNewContext(...args);
34
+ } catch (error) {
35
+ return new Err(error);
36
+ }
37
+ }
38
+
39
+ export function runInThisContext(...args) {
40
+ try {
41
+ return $module.runInThisContext(...args);
42
+ } catch (error) {
43
+ return new Err(error);
44
+ }
45
+ }
46
+
47
+ export function scriptRunInContext(self, ...args) {
48
+ try {
49
+ return self.runInContext(...args);
50
+ } catch (error) {
51
+ return new Err(error);
52
+ }
53
+ }
54
+
55
+ export function scriptRunInNewContext(self, ...args) {
56
+ try {
57
+ return self.runInNewContext(...args);
58
+ } catch (error) {
59
+ return new Err(error);
60
+ }
61
+ }
62
+
63
+ export function scriptRunInThisContext(self, ...args) {
64
+ try {
65
+ return self.runInThisContext(...args);
66
+ } catch (error) {
67
+ return new Err(error);
68
+ }
69
+ }
package/safe/wasi.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
2
+ /// <reference types="node" />
3
+ import type { Result } from "@evobug_com/safe-ts-std/result";
4
+ import type * as $wasi from "node:wasi";
5
+ export * from "node:wasi";
6
+
7
+ /** `WASI#initialize()` (node:wasi), with what it throws returned as an `Err`: `RuntimeError | (what the program's imports throw)`. */
8
+ export declare function initialize(wasi: $wasi.WASI, instance: object): Result<void, unknown>;
9
+ /** `WASI#start()` (node:wasi), with what it throws returned as an `Err`: `RuntimeError | (what the program's imports throw)`. */
10
+ export declare function start(wasi: $wasi.WASI, instance: object): Result<number, unknown>;
package/safe/wasi.js ADDED
@@ -0,0 +1,20 @@
1
+ // @safe-ts std
2
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
3
+ import { Err } from "@evobug_com/safe-ts-std/result";
4
+ export * from "node:wasi";
5
+
6
+ export function initialize(self, ...args) {
7
+ try {
8
+ return self.initialize(...args);
9
+ } catch (error) {
10
+ return new Err(error);
11
+ }
12
+ }
13
+
14
+ export function start(self, ...args) {
15
+ try {
16
+ return self.start(...args);
17
+ } catch (error) {
18
+ return new Err(error);
19
+ }
20
+ }
@@ -0,0 +1,31 @@
1
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
2
+ /// <reference types="node" />
3
+ import type { Result } from "@evobug_com/safe-ts-std/result";
4
+ import type { DOMError, NodeError } from "./errors.js";
5
+ import type * as $stream from "node:stream";
6
+ import type * as $v8 from "node:v8";
7
+ import type * as $worker_threads from "node:worker_threads";
8
+ export * from "node:worker_threads";
9
+
10
+ /** `Worker#cpuUsage()` (node:worker_threads), with what it rejects with returned as an `Err`: `Error [ERR_WORKER_NOT_RUNNING]`. */
11
+ export declare function cpuUsage(worker: $worker_threads.Worker, prev?: NodeJS.CpuUsage): Promise<Result<NodeJS.CpuUsage, NodeError<"ERR_WORKER_NOT_RUNNING">>>;
12
+ /** `Worker#getHeapSnapshot()` (node:worker_threads), with what it rejects with returned as an `Err`: `Error [ERR_WORKER_NOT_RUNNING]`. */
13
+ export declare function getHeapSnapshot(worker: $worker_threads.Worker): Promise<Result<$stream.Readable, NodeError<"ERR_WORKER_NOT_RUNNING">>>;
14
+ /** `Worker#getHeapStatistics()` (node:worker_threads), with what it rejects with returned as an `Err`: `Error [ERR_WORKER_NOT_RUNNING]`. */
15
+ export declare function getHeapStatistics(worker: $worker_threads.Worker): Promise<Result<$v8.HeapInfo, NodeError<"ERR_WORKER_NOT_RUNNING">>>;
16
+ /** `MessagePort#postMessage()` (node:worker_threads), with what it throws returned as an `Err`: `DOMException [DataCloneError]`. */
17
+ export declare function postMessage(messagePort: $worker_threads.MessagePort, message: any, transfer: $worker_threads.Transferable[]): Result<void, DOMError<"DataCloneError">>;
18
+ /** `MessagePort#postMessage()` (node:worker_threads), with what it throws returned as an `Err`: `DOMException [DataCloneError]`. */
19
+ export declare function postMessage(messagePort: $worker_threads.MessagePort, message: any, options?: $worker_threads.StructuredSerializeOptions): Result<void, DOMError<"DataCloneError">>;
20
+ /** `Worker#postMessage()` (node:worker_threads), with what it throws returned as an `Err`: `DOMException [DataCloneError]`. */
21
+ export declare function postMessage(worker: $worker_threads.Worker, value: any, transferList?: readonly $worker_threads.Transferable[]): Result<void, DOMError<"DataCloneError">>;
22
+ /** `BroadcastChannel#postMessage()` (node:worker_threads), with what it throws returned as an `Err`: `DOMException [DataCloneError]`. */
23
+ export declare function postMessage(broadcastChannel: $worker_threads.BroadcastChannel, message: any): Result<void, DOMError<"DataCloneError">>;
24
+ /** `postMessageToThread()` (node:worker_threads), with what it rejects with returned as an `Err`: `Error [ERR_WORKER_MESSAGING_FAILED | ERR_WORKER_MESSAGING_TIMEOUT | ERR_WORKER_MESSAGING_ERRORED]`. */
25
+ export declare function postMessageToThread(threadId: number, value: any, timeout?: number): Promise<Result<void, NodeError<"ERR_WORKER_MESSAGING_FAILED" | "ERR_WORKER_MESSAGING_TIMEOUT" | "ERR_WORKER_MESSAGING_ERRORED">>>;
26
+ /** `postMessageToThread()` (node:worker_threads), with what it rejects with returned as an `Err`: `Error [ERR_WORKER_MESSAGING_FAILED | ERR_WORKER_MESSAGING_TIMEOUT | ERR_WORKER_MESSAGING_ERRORED]`. */
27
+ export declare function postMessageToThread(threadId: number, value: any, transferList: readonly $worker_threads.Transferable[], timeout?: number): Promise<Result<void, NodeError<"ERR_WORKER_MESSAGING_FAILED" | "ERR_WORKER_MESSAGING_TIMEOUT" | "ERR_WORKER_MESSAGING_ERRORED">>>;
28
+ /** `Worker#startCpuProfile()` (node:worker_threads), with what it rejects with returned as an `Err`: `Error [ERR_WORKER_NOT_RUNNING]`. */
29
+ export declare function startCpuProfile(worker: $worker_threads.Worker, options?: $v8.CPUProfileOptions): Promise<Result<$v8.CPUProfileHandle, NodeError<"ERR_WORKER_NOT_RUNNING">>>;
30
+ /** `Worker#startHeapProfile()` (node:worker_threads), with what it rejects with returned as an `Err`: `Error [ERR_WORKER_NOT_RUNNING]`. */
31
+ export declare function startHeapProfile(worker: $worker_threads.Worker, options?: $v8.HeapProfileOptions): Promise<Result<$v8.HeapProfileHandle, NodeError<"ERR_WORKER_NOT_RUNNING">>>;
@@ -0,0 +1,62 @@
1
+ // @safe-ts std
2
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
3
+ import * as $module from "node:worker_threads";
4
+ import { Err } from "@evobug_com/safe-ts-std/result";
5
+ import { failed, ok } from "./runtime.js";
6
+ export * from "node:worker_threads";
7
+
8
+ export function cpuUsage(self, ...args) {
9
+ try {
10
+ return Promise.resolve(self.cpuUsage(...args)).then(ok, failed);
11
+ } catch (error) {
12
+ return Promise.resolve(new Err(error));
13
+ }
14
+ }
15
+
16
+ export function getHeapSnapshot(self, ...args) {
17
+ try {
18
+ return Promise.resolve(self.getHeapSnapshot(...args)).then(ok, failed);
19
+ } catch (error) {
20
+ return Promise.resolve(new Err(error));
21
+ }
22
+ }
23
+
24
+ export function getHeapStatistics(self, ...args) {
25
+ try {
26
+ return Promise.resolve(self.getHeapStatistics(...args)).then(ok, failed);
27
+ } catch (error) {
28
+ return Promise.resolve(new Err(error));
29
+ }
30
+ }
31
+
32
+ export function postMessage(self, ...args) {
33
+ try {
34
+ return self.postMessage(...args);
35
+ } catch (error) {
36
+ return new Err(error);
37
+ }
38
+ }
39
+
40
+ export function postMessageToThread(...args) {
41
+ try {
42
+ return Promise.resolve($module.postMessageToThread(...args)).then(ok, failed);
43
+ } catch (error) {
44
+ return Promise.resolve(new Err(error));
45
+ }
46
+ }
47
+
48
+ export function startCpuProfile(self, ...args) {
49
+ try {
50
+ return Promise.resolve(self.startCpuProfile(...args)).then(ok, failed);
51
+ } catch (error) {
52
+ return Promise.resolve(new Err(error));
53
+ }
54
+ }
55
+
56
+ export function startHeapProfile(self, ...args) {
57
+ try {
58
+ return Promise.resolve(self.startHeapProfile(...args)).then(ok, failed);
59
+ } catch (error) {
60
+ return Promise.resolve(new Err(error));
61
+ }
62
+ }
package/safe/zlib.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ // Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
2
+ /// <reference types="node" />
3
+ import type { Result } from "@evobug_com/safe-ts-std/result";
4
+ import type { NodeError, SystemError } from "./errors.js";
5
+ import type * as $buffer from "node:buffer";
6
+ import type * as $stream from "node:stream";
7
+ import type * as $zlib from "node:zlib";
8
+ export * from "node:zlib";
9
+
10
+ /** `ZipFile#add()` (node:zlib), with what it rejects with returned as an `Err`: `Error [E*] {errno, syscall: 'read' | 'write' | 'ftruncate' | 'fsync'}`. */
11
+ export declare function add(zipFile: $zlib.ZipFile, filename: string, data: $zlib.ZipInputType, options?: $zlib.ZipEntryCreateOptions): Promise<Result<$zlib.ZipEntry, SystemError<"read" | "write" | "ftruncate" | "fsync">>>;
12
+ /** `ZipFile#addEntry()` (node:zlib), with what it rejects with returned as an `Err`: `Error [E*] {errno, syscall: 'read' | 'write' | 'ftruncate' | 'fsync'}`. */
13
+ export declare function addEntry(zipFile: $zlib.ZipFile, entry: $zlib.ZipEntry): Promise<Result<$zlib.ZipEntry, SystemError<"read" | "write" | "ftruncate" | "fsync">>>;
14
+ /** `ZipFile#addEntrySync()` (node:zlib), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'read' | 'write' | 'ftruncate' | 'fsync'}`. */
15
+ export declare function addEntrySync(zipFile: $zlib.ZipFile, entry: $zlib.ZipEntry): Result<$zlib.ZipEntry, SystemError<"read" | "write" | "ftruncate" | "fsync">>;
16
+ /** `ZipFile#addSync()` (node:zlib), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'read' | 'write' | 'ftruncate' | 'fsync'}`. */
17
+ export declare function addSync(zipFile: $zlib.ZipFile, filename: string, data: $zlib.ZipInputType, options?: $zlib.ZipEntryCreateOptions): Result<$zlib.ZipEntry, SystemError<"read" | "write" | "ftruncate" | "fsync">>;
18
+ /** `brotliDecompressSync()` (node:zlib), with what it throws returned as an `Err`: `Error [ERR__ERROR_* | Z_BUF_ERROR] {errno}`. */
19
+ export declare function brotliDecompressSync(buf: $zlib.InputType, options?: $zlib.BrotliOptions): Result<$buffer.NonSharedBuffer, NodeError<`ERR__ERROR_${string}` | "Z_BUF_ERROR", "Error", { errno: number }>>;
20
+ /** `ZipFile#close()` (node:zlib), with what it rejects with returned as an `Err`: `Error [E*] {errno, syscall: 'close'}`. */
21
+ export declare function close(zipFile: $zlib.ZipFile): Promise<Result<void, SystemError<"close">>>;
22
+ /** `ZipFile#closeSync()` (node:zlib), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'close'}`. */
23
+ export declare function closeSync(zipFile: $zlib.ZipFile): Result<void, SystemError<"close">>;
24
+ /** `ZipFile#compactSync()` (node:zlib), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'read' | 'write' | 'ftruncate' | 'fsync'}`. */
25
+ export declare function compactSync(zipFile: $zlib.ZipFile, comment?: string): Result<$buffer.NonSharedBuffer, SystemError<"read" | "write" | "ftruncate" | "fsync">>;
26
+ /** `ZipEntry#content()` (node:zlib), with what it rejects with returned as an `Err`: `Error [ERR_ZIP_ENTRY_CORRUPT | ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | RangeError [ERR_ZIP_ENTRY_TOO_LARGE] | Error [Z_*] {errno} | Error [E*] {errno, syscall: 'read'}`. */
27
+ export declare function content(zipEntry: $zlib.ZipEntry, options?: $zlib.ZipEntryContentOptions): Promise<Result<$buffer.NonSharedBuffer, NodeError<"ERR_ZIP_ENTRY_CORRUPT" | "ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | NodeError<"ERR_ZIP_ENTRY_TOO_LARGE", "RangeError"> | NodeError<`Z_${string}`, "Error", { errno: number }> | SystemError<"read">>>;
28
+ /** `ZipEntry#contentSync()` (node:zlib), with what it throws returned as an `Err`: `Error [ERR_ZIP_ENTRY_CORRUPT | ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | RangeError [ERR_ZIP_ENTRY_TOO_LARGE] | Error [Z_*] {errno} | Error [E*] {errno, syscall: 'read'}`. */
29
+ export declare function contentSync(zipEntry: $zlib.ZipEntry, options?: $zlib.ZipEntryContentOptions): Result<$buffer.NonSharedBuffer, NodeError<"ERR_ZIP_ENTRY_CORRUPT" | "ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | NodeError<"ERR_ZIP_ENTRY_TOO_LARGE", "RangeError"> | NodeError<`Z_${string}`, "Error", { errno: number }> | SystemError<"read">>;
30
+ /** `ZipFile#deleteSync()` (node:zlib), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'read' | 'write' | 'ftruncate' | 'fsync'}`. */
31
+ export declare function deleteSync(zipFile: $zlib.ZipFile, name: string): Result<boolean, SystemError<"read" | "write" | "ftruncate" | "fsync">>;
32
+ /** `ZipFile#getSync()` (node:zlib), with what it throws returned as an `Err`: `Error [ERR_ZIP_ENTRY_NOT_FOUND | ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | Error [E*] {errno, syscall: 'read'}`. */
33
+ export declare function getSync(zipFile: $zlib.ZipFile, name: string): Result<$zlib.ZipEntry, NodeError<"ERR_ZIP_ENTRY_NOT_FOUND" | "ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | SystemError<"read">>;
34
+ /** `gunzipSync()` (node:zlib), with what it throws returned as an `Err`: `Error [Z_*] {errno}`. */
35
+ export declare function gunzipSync(buf: $zlib.InputType, options?: $zlib.ZlibOptions): Result<$buffer.NonSharedBuffer, NodeError<`Z_${string}`, "Error", { errno: number }>>;
36
+ /** `inflateRawSync()` (node:zlib), with what it throws returned as an `Err`: `Error [Z_*] {errno}`. */
37
+ export declare function inflateRawSync(buf: $zlib.InputType, options?: $zlib.ZlibOptions): Result<$buffer.NonSharedBuffer, NodeError<`Z_${string}`, "Error", { errno: number }>>;
38
+ /** `inflateSync()` (node:zlib), with what it throws returned as an `Err`: `Error [Z_*] {errno}`. */
39
+ export declare function inflateSync(buf: $zlib.InputType, options?: $zlib.ZlibOptions): Result<$buffer.NonSharedBuffer, NodeError<`Z_${string}`, "Error", { errno: number }>>;
40
+ /** `new ZipBuffer()` (node:zlib), with what it throws returned as an `Err`: `Error [ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | RangeError [ERR_ZIP_ARCHIVE_TOO_LARGE]`. */
41
+ export declare function newZipBuffer(buffer: $zlib.ZipInputType): Result<$zlib.ZipBuffer, NodeError<"ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | NodeError<"ERR_ZIP_ARCHIVE_TOO_LARGE", "RangeError">>;
42
+ /** `ZipFile#stream()` (node:zlib), with what it rejects with returned as an `Err`: `Error [ERR_ZIP_ENTRY_NOT_FOUND | ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | Error [E*] {errno, syscall: 'read'}`. */
43
+ export declare function stream(zipFile: $zlib.ZipFile, name: string, options?: $zlib.ZipEntryContentIterOptions): Promise<Result<$stream.Readable, NodeError<"ERR_ZIP_ENTRY_NOT_FOUND" | "ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | SystemError<"read">>>;
44
+ /** `ZipBuffer#toBuffer()` (node:zlib), with what it rejects with returned as an `Err`: `(the entry source's error) | Error [E*] {errno, syscall: 'read'}`. */
45
+ export declare function toBuffer(zipBuffer: $zlib.ZipBuffer, options?: string | $zlib.CreateZipArchiveOptions): Promise<Result<$buffer.NonSharedBuffer, unknown>>;
46
+ /** `ZipBuffer#toBufferSync()` (node:zlib), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'read'}`. */
47
+ export declare function toBufferSync(zipBuffer: $zlib.ZipBuffer, options?: string | $zlib.CreateZipArchiveOptions): Result<$buffer.NonSharedBuffer, SystemError<"read">>;
48
+ /** `unzipSync()` (node:zlib), with what it throws returned as an `Err`: `Error [Z_*] {errno}`. */
49
+ export declare function unzipSync(buf: $zlib.InputType, options?: $zlib.ZlibOptions): Result<$buffer.NonSharedBuffer, NodeError<`Z_${string}`, "Error", { errno: number }>>;
50
+ /** `ZipBuffer#get()` (node:zlib), with what it throws returned as an `Err`: `Error [ERR_ZIP_ENTRY_NOT_FOUND]`. */
51
+ export declare function zipBufferGet(zipBuffer: $zlib.ZipBuffer, name: string): Result<$zlib.ZipEntry, NodeError<"ERR_ZIP_ENTRY_NOT_FOUND">>;
52
+ /** `ZipFile#delete()` (node:zlib), with what it rejects with returned as an `Err`: `Error [E*] {errno, syscall: 'read' | 'write' | 'ftruncate' | 'fsync'}`. */
53
+ export declare function zipFileDelete(zipFile: $zlib.ZipFile, name: string): Promise<Result<boolean, SystemError<"read" | "write" | "ftruncate" | "fsync">>>;
54
+ /** `ZipFile#get()` (node:zlib), with what it rejects with returned as an `Err`: `Error [ERR_ZIP_ENTRY_NOT_FOUND | ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | Error [E*] {errno, syscall: 'read'}`. */
55
+ export declare function zipFileGet(zipFile: $zlib.ZipFile, name: string): Promise<Result<$zlib.ZipEntry, NodeError<"ERR_ZIP_ENTRY_NOT_FOUND" | "ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | SystemError<"read">>>;
56
+ /** `ZipFile.open()` (node:zlib), with what it rejects with returned as an `Err`: `Error [E*] {errno, syscall: 'open' | 'fstat' | 'read', path} | Error [ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | RangeError [ERR_ZIP_ARCHIVE_TOO_LARGE]`. */
57
+ export declare function zipFileOpen(filename: string, options?: $zlib.ZipFileOpenOptions): Promise<Result<$zlib.ZipFile, SystemError<"open" | "fstat" | "read", { path: string }> | NodeError<"ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | NodeError<"ERR_ZIP_ARCHIVE_TOO_LARGE", "RangeError">>>;
58
+ /** `ZipFile.openSync()` (node:zlib), with what it throws returned as an `Err`: `Error [E*] {errno, syscall: 'open' | 'fstat' | 'read', path} | Error [ERR_ZIP_INVALID_ARCHIVE | ERR_ZIP_UNSUPPORTED_FEATURE] | RangeError [ERR_ZIP_ARCHIVE_TOO_LARGE]`. */
59
+ export declare function zipFileOpenSync(filename: string, options?: $zlib.ZipFileOpenOptions): Result<$zlib.ZipFile, SystemError<"open" | "fstat" | "read", { path: string }> | NodeError<"ERR_ZIP_INVALID_ARCHIVE" | "ERR_ZIP_UNSUPPORTED_FEATURE"> | NodeError<"ERR_ZIP_ARCHIVE_TOO_LARGE", "RangeError">>;
60
+ /** `zstdDecompressSync()` (node:zlib), with what it throws returned as an `Err`: `Error [ZSTD_error_* | Z_BUF_ERROR] {errno}`. */
61
+ export declare function zstdDecompressSync(buf: $zlib.InputType, options?: $zlib.ZstdOptions): Result<$buffer.NonSharedBuffer, NodeError<`ZSTD_error_${string}` | "Z_BUF_ERROR", "Error", { errno: number }>>;