@amritk/nish-aarch64-linux 0.37.0 → 0.39.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/INSTALL.md +28 -16
- package/bin/nish +0 -0
- package/docs/AI.md +380 -47
- package/package.json +1 -1
- package/runtime/core/arrays.d.ts +4 -0
- package/runtime/core/arrays.mjs +33 -0
- package/runtime/core/host.d.ts +11 -0
- package/runtime/core/host.mjs +35 -0
- package/runtime/nish.d.ts +645 -66
- package/runtime/nish.h +101 -15
- package/runtime/nish.mjs +69 -6
- package/runtime/node.mjs +117 -0
- package/runtime/runtime-aes.c +12 -4
- package/runtime/runtime-async.c +267 -51
- package/runtime/runtime-checksum.c +207 -15
- package/runtime/runtime-cross.c +2 -1
- package/runtime/runtime-net.c +32 -3
- package/runtime/runtime-os.c +174 -27
- package/runtime/runtime-region.c +170 -8
- package/runtime/runtime-sandbox.c +377 -17
- package/runtime/runtime-sha256.c +11 -4
- package/runtime/runtime-text.c +1068 -0
- package/runtime/runtime-wasm.c +18 -3
- package/runtime/runtime.c +55 -961
- package/runtime/vite.mjs +48 -11
- package/scripts/build.sh +113 -36
- package/std/LICENSE-fdlibm +8 -0
- package/std/README.md +7 -4
- package/std/array.ts +266 -0
- package/std/compress/checksum.ts +13 -0
- package/std/compress/deflate.ts +0 -2
- package/std/crypto/p256.ts +247 -74
- package/std/crypto/p384.ts +3 -1
- package/std/crypto/pki.ts +35 -9
- package/std/crypto/x25519.ts +153 -64
- package/std/crypto/x509.ts +113 -10
- package/std/host/text.ts +86 -0
- package/std/json-tokenizer.ts +20 -0
- package/std/json-typed.ts +217 -8
- package/std/math.ts +743 -41
- package/std/net/dns-resolver.ts +46 -6
- package/std/net/dns.ts +50 -13
- package/std/net/fetch.ts +691 -129
- package/std/net/handler.ts +142 -16
- package/std/net/http-compress.ts +17 -9
- package/std/net/http-fields.ts +19 -4
- package/std/net/http1-codec.ts +517 -154
- package/std/net/http1-server.ts +508 -25
- package/std/net/http2-cleartext.ts +526 -0
- package/std/net/http2-tls.ts +48 -0
- package/std/net/http2.ts +84 -0
- package/std/net/postgres-async.ts +2223 -0
- package/std/net/postgres-carrier.ts +343 -10
- package/std/net/postgres.ts +129 -11
- package/std/net/prefork.ts +195 -11
- package/std/net/quic-datagram.ts +30 -0
- package/std/net/quic-listener.ts +38 -12
- package/std/net/quic-packet.ts +19 -6
- package/std/net/quic-recovery.ts +134 -19
- package/std/net/quic-stream.ts +174 -36
- package/std/net/quic.ts +418 -18
- package/std/net/router.ts +39 -17
- package/std/net/serve.ts +867 -0
- package/std/net/tls/codec.ts +110 -32
- package/std/net/tls/record-server.ts +37 -7
- package/std/net/tls-tcp.ts +56 -1
- package/std/net/tls.ts +196 -50
- package/std/net/websocket.ts +55 -18
- package/std/net/webtransport.ts +179 -1
- package/std/regex.ts +69 -47
- package/std/region.ts +62 -11
- package/std/secret.ts +26 -59
- package/std/text.ts +464 -5
package/package.json
CHANGED
package/runtime/core/arrays.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export declare function storeIdx<T>(a: T[], i: number | bigint, v: T): T;
|
|
|
11
11
|
export declare function arraySet<T>(dst: T[], src: readonly T[], offset?: number): void;
|
|
12
12
|
/** `dst.set(src, offset)` as `--emit-ts` writes it: a 64-bit offset is a bigint, checked exactly. */
|
|
13
13
|
export declare function arraySetAt<T>(dst: T[], src: readonly T[], offset?: number | bigint): void;
|
|
14
|
+
/** `xs.slice(start, end)` as `--emit-ts` writes it: an out-of-range bound panics, as the native one does. */
|
|
15
|
+
export declare function sliceArray<T>(a: readonly T[], start?: number | bigint, end?: number | bigint): T[];
|
|
16
|
+
/** The answer of `xs.map`, `xs.filter` or `xs.slice` with each record copied, as an array holds it inline. */
|
|
17
|
+
export declare function copyRecords<T>(a: T[]): T[];
|
|
14
18
|
/** `new Array<T>(n)`: `--emit-ts` writes `T` out, so the zero it fills with is not what `T` is read from. */
|
|
15
19
|
export declare function newArray<T>(n: number | bigint, zero: unknown): T[];
|
|
16
20
|
export declare function arenaUsed(): i64;
|
package/runtime/core/arrays.mjs
CHANGED
|
@@ -66,6 +66,39 @@ export function copyIn(v) {
|
|
|
66
66
|
return isRecord(v) ? { ...v } : v;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* `xs.slice(start, end)` as `nish --emit-ts` writes it: the native rule, where
|
|
71
|
+
* the range must satisfy `0 <= start <= end <= xs.length` and anything else
|
|
72
|
+
* panics, not JavaScript's, which counts a negative bound from the end and
|
|
73
|
+
* clamps the rest.
|
|
74
|
+
*/
|
|
75
|
+
export function sliceArray(a, start, end) {
|
|
76
|
+
const from = start === undefined ? 0n : sliceBound(start);
|
|
77
|
+
const to = end === undefined ? BigInt(a.length) : sliceBound(end);
|
|
78
|
+
if (!(from >= 0n && from <= to && to <= BigInt(a.length))) panicSlice(from, to, a.length);
|
|
79
|
+
return a.slice(Number(from), Number(to));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// A `slice` bound as the native template converts it to `i64`: a `number` is
|
|
83
|
+
// truncated toward zero and saturates, NaN to 0 and an infinity to the i64
|
|
84
|
+
// limit, so a panic prints the same offsets natively and here.
|
|
85
|
+
function sliceBound(i) {
|
|
86
|
+
if (typeof i === "bigint") return i;
|
|
87
|
+
if (Number.isNaN(i)) return 0n;
|
|
88
|
+
if (i >= 2 ** 63) return (1n << 63n) - 1n;
|
|
89
|
+
if (i <= -(2 ** 63)) return -(1n << 63n);
|
|
90
|
+
return BigInt(Math.trunc(i));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The array `xs.map`, `xs.filter` or `xs.slice` answers, as the native one
|
|
95
|
+
* holds it: each record a fresh copy, as an array holds a record inline.
|
|
96
|
+
*/
|
|
97
|
+
export function copyRecords(a) {
|
|
98
|
+
for (let i = 0; i < a.length; i++) a[i] = copyIn(a[i]);
|
|
99
|
+
return a;
|
|
100
|
+
}
|
|
101
|
+
|
|
69
102
|
/**
|
|
70
103
|
* `a[i] = v` from a generic body: as `setIdx`, but a record is written field
|
|
71
104
|
* by field into the record already in the slot, as an inline element is.
|
package/runtime/core/host.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export declare function argv(): string[];
|
|
|
42
42
|
export declare function readFileSync(path: string): string;
|
|
43
43
|
export declare function readFileSyncOrNull(path: string): string | null;
|
|
44
44
|
export declare function readFileBytesSync(path: string): u8[] | null;
|
|
45
|
+
export declare function fileOpen(path: string): i32;
|
|
46
|
+
export declare function fileReadAt(fd: i32, buf: u8[], off: i32, len: i32, pos: i64): i32;
|
|
47
|
+
export declare function fileSize(fd: i32): i64;
|
|
48
|
+
export declare function fileClose(fd: i32): i32;
|
|
45
49
|
export declare function writeFileSync(path: string, data: string): void;
|
|
46
50
|
export declare function appendFileSync(path: string, data: string): void;
|
|
47
51
|
export declare function writeFileBytesSync(path: string, bytes: readonly u8[]): i32;
|
|
@@ -60,6 +64,13 @@ export declare function getenv(name: string): string | null;
|
|
|
60
64
|
export declare function spawnSync(argv: string[]): number;
|
|
61
65
|
export declare function spawnSyncTo(argv: string[], stdoutPath: string, stderrPath: string): number;
|
|
62
66
|
export declare function spawnPiped(argv: string[], stdin: readonly u8[], stdout: u8[], stderr: u8[]): i32;
|
|
67
|
+
export declare function spawnPipedWithin(
|
|
68
|
+
argv: string[],
|
|
69
|
+
stdin: readonly u8[],
|
|
70
|
+
stdout: u8[],
|
|
71
|
+
stderr: u8[],
|
|
72
|
+
timeoutMs: i32
|
|
73
|
+
): i32;
|
|
63
74
|
export declare function kill(pid: i32, sig: i32): i32;
|
|
64
75
|
export declare function availableParallelism(): i32;
|
|
65
76
|
export declare function totalMemory(): i64;
|
package/runtime/core/host.mjs
CHANGED
|
@@ -137,6 +137,30 @@ export function readFileBytesSync(path) {
|
|
|
137
137
|
return host.call("readFileBytesSync", [path]);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
export function fileOpen(path) {
|
|
141
|
+
return host.call("fileOpen", [path]);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* `fileReadAt(fd, buf, off, len, pos)`: the window checked as the compiled
|
|
146
|
+
* call checks it, `0 <= off <= off + len <= buf.length`, through the slice
|
|
147
|
+
* panic, then the host's positional read.
|
|
148
|
+
*/
|
|
149
|
+
export function fileReadAt(fd, buf, off, len, pos) {
|
|
150
|
+
const from = toIndex(off);
|
|
151
|
+
const to = from + toIndex(len);
|
|
152
|
+
if (!(from >= 0 && from <= to && to <= buf.length)) panicSlice(from, to, buf.length);
|
|
153
|
+
return host.call("fileReadAt", [fd, buf, from, to - from, BigInt(pos)]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function fileSize(fd) {
|
|
157
|
+
return host.call("fileSize", [fd]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function fileClose(fd) {
|
|
161
|
+
return host.call("fileClose", [fd]);
|
|
162
|
+
}
|
|
163
|
+
|
|
140
164
|
export function writeFileSync(path, data) {
|
|
141
165
|
return host.call("writeFileSync", [path, data]);
|
|
142
166
|
}
|
|
@@ -217,6 +241,17 @@ export function spawnPiped(argv, input, out, err) {
|
|
|
217
241
|
return status;
|
|
218
242
|
}
|
|
219
243
|
|
|
244
|
+
/**
|
|
245
|
+
* `spawnPipedWithin(argv, stdin, stdout, stderr, timeoutMs)`: `spawnPiped`
|
|
246
|
+
* with a deadline the host enforces, and -3 when it passed.
|
|
247
|
+
*/
|
|
248
|
+
export function spawnPipedWithin(argv, input, out, err, timeoutMs) {
|
|
249
|
+
const [status, outBytes, errBytes] = host.call("spawnPipedWithin", [argv, input, timeoutMs]);
|
|
250
|
+
for (const b of outBytes) out.push(b);
|
|
251
|
+
for (const b of errBytes) err.push(b);
|
|
252
|
+
return status;
|
|
253
|
+
}
|
|
254
|
+
|
|
220
255
|
export function kill(pid, sig) {
|
|
221
256
|
return host.call("kill", [pid, sig]);
|
|
222
257
|
}
|