@amritk/nish-x86_64-linux 0.34.1 → 0.36.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 +22 -13
- package/bin/nish +0 -0
- package/docs/AI.md +86 -16
- package/package.json +1 -1
- package/runtime/async.d.mts +49 -0
- package/runtime/async.mjs +27 -0
- package/runtime/nish.d.ts +4681 -427
- package/runtime/nish.h +6 -2
- package/runtime/nish.mjs +4 -0
- package/runtime/runtime-net.c +22 -0
- package/runtime/runtime-shm.c +93 -2
- package/runtime/vite.d.ts +30 -0
- package/runtime/vite.mjs +150 -0
- package/scripts/build.sh +108 -13
- package/std/README.md +131 -131
- package/std/base64.ts +34 -5
- package/std/bytes.ts +258 -42
- package/std/cli-args.ts +296 -70
- package/std/cli-flags.ts +184 -19
- package/std/cli.ts +475 -54
- package/std/collections.ts +121 -23
- package/std/compress/checksum.ts +44 -14
- package/std/compress/deflate.ts +224 -111
- package/std/compress/gzip.ts +217 -53
- package/std/compress/zlib.ts +63 -7
- package/std/crypto/aes.ts +80 -9
- package/std/crypto/base64url.ts +22 -0
- package/std/crypto/bcrypt-batch.ts +88 -21
- package/std/crypto/bcrypt.ts +60 -0
- package/std/crypto/chacha20poly1305.ts +53 -0
- package/std/crypto/ct.ts +32 -13
- package/std/crypto/ed25519.ts +47 -0
- package/std/crypto/hkdf.ts +198 -13
- package/std/crypto/hmac.ts +235 -31
- package/std/crypto/jwt.ts +192 -63
- package/std/crypto/p256.ts +159 -16
- package/std/crypto/p384.ts +28 -3
- package/std/crypto/pki-roots.ts +32 -2
- package/std/crypto/pki.ts +81 -15
- package/std/crypto/rsa.ts +33 -3
- package/std/crypto/sha1.ts +3 -0
- package/std/crypto/sha256.ts +24 -1
- package/std/crypto/sha512.ts +99 -14
- package/std/crypto/x25519.ts +152 -14
- package/std/crypto/x509-random.ts +10 -0
- package/std/crypto/x509.ts +67 -7
- package/std/json-equal.ts +19 -0
- package/std/json-format.ts +112 -13
- package/std/json-number.ts +64 -14
- package/std/json-pointer.ts +23 -1
- package/std/json-tokenizer.ts +100 -29
- package/std/json-typed.ts +713 -66
- package/std/json-value.ts +400 -124
- package/std/json.ts +138 -10
- package/std/map.ts +25 -7
- package/std/math.ts +36 -4
- package/std/net/buffer-pool.ts +42 -11
- package/std/net/dns-config.ts +109 -23
- package/std/net/dns-message.ts +62 -7
- package/std/net/dns-resolver.ts +247 -53
- package/std/net/dns.ts +203 -35
- package/std/net/fetch.ts +151 -61
- package/std/net/handler.ts +278 -80
- package/std/net/hpack.ts +262 -52
- package/std/net/http-compress.ts +125 -15
- package/std/net/http-fields.ts +85 -9
- package/std/net/http1-client-codec.ts +100 -19
- package/std/net/http1-codec.ts +297 -77
- package/std/net/http1-server.ts +430 -94
- package/std/net/http2-frame.ts +272 -35
- package/std/net/http2-tls.ts +135 -34
- package/std/net/http2.ts +247 -106
- package/std/net/http3-frame.ts +154 -17
- package/std/net/http3-server.ts +275 -101
- package/std/net/http3.ts +307 -115
- package/std/net/outbound.ts +37 -3
- package/std/net/postgres-carrier.ts +144 -8
- package/std/net/postgres.ts +801 -112
- package/std/net/prefork.ts +164 -31
- package/std/net/qpack.ts +105 -18
- package/std/net/quic-conn-ack.ts +59 -12
- package/std/net/quic-conn-cid.ts +124 -27
- package/std/net/quic-conn-params.ts +70 -10
- package/std/net/quic-datagram.ts +43 -3
- package/std/net/quic-frame.ts +286 -12
- package/std/net/quic-listener.ts +101 -32
- package/std/net/quic-packet.ts +302 -21
- package/std/net/quic-recovery.ts +264 -52
- package/std/net/quic-stream.ts +353 -91
- package/std/net/quic.ts +1124 -201
- package/std/net/router.ts +87 -40
- package/std/net/tls/client.ts +166 -51
- package/std/net/tls/codec.ts +413 -56
- package/std/net/tls/record-client.ts +110 -55
- package/std/net/tls/record-server.ts +159 -59
- package/std/net/tls/record.ts +109 -12
- package/std/net/tls/schedule.ts +235 -26
- package/std/net/tls/ticket.ts +159 -40
- package/std/net/tls/verify.ts +49 -3
- package/std/net/tls-tcp.ts +250 -45
- package/std/net/tls.ts +221 -59
- package/std/net/upstream.ts +81 -45
- package/std/net/url.ts +97 -13
- package/std/net/websocket.ts +122 -12
- package/std/net/webtransport.ts +220 -89
- package/std/pair.ts +10 -2
- package/std/random.ts +34 -9
- package/std/regex.ts +352 -198
- package/std/region.ts +70 -15
- package/std/secret.ts +52 -11
- package/std/sort.ts +17 -2
- package/std/sqlite.ts +256 -35
- package/std/sync/ring.ts +430 -40
- package/std/sync/shm.ts +222 -15
- package/std/term-io.ts +137 -64
- package/std/term-pixels.ts +144 -19
- package/std/term-probe.ts +66 -25
- package/std/term-rate.ts +128 -57
- package/std/term.ts +332 -121
- package/std/testing.ts +130 -32
- package/std/text.ts +73 -7
- package/std/threads.ts +229 -41
- package/std/yaml-json.ts +94 -82
- package/std/yaml-lines.ts +47 -15
- package/std/yaml-write.ts +24 -16
- package/std/yaml.ts +764 -384
package/std/net/quic-datagram.ts
CHANGED
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
* of `nish/net`; `nish/net/quic`'s `QuicConnection` owns both rings and the
|
|
7
7
|
* application reaches them through its `sendDatagram` and `readDatagram`.
|
|
8
8
|
*
|
|
9
|
+
* import { QuicDatagramQueue } from "nish/net/quic-datagram";
|
|
10
|
+
*
|
|
11
|
+
* const outgoing: QuicDatagramQueue = new QuicDatagramQueue(16, 1200); // 16 payloads, each 1200 bytes at most
|
|
12
|
+
* if (!outgoing.push(message, 0, toI32(message.length))) { … full or too big: dropped … }
|
|
13
|
+
* at = outgoing.putFrame(packet, at, packetEnd); // `at` again when nothing fit
|
|
14
|
+
*
|
|
15
|
+
* const incoming: QuicDatagramQueue = new QuicDatagramQueue(16, 1200);
|
|
16
|
+
* const length: i32 = incoming.pop(into, 0, toI32(into.length)); // -1 empty, -2 `into` too small
|
|
17
|
+
*
|
|
9
18
|
* **Fixed.** A ring is `entries` payloads of at most `entrySize` bytes,
|
|
10
19
|
* allocated once; a payload is copied in and out, and nothing allocates
|
|
11
20
|
* after the ring is made. A datagram is unreliable by definition (RFC 9221
|
|
@@ -31,6 +40,13 @@ export class QuicDatagramQueue {
|
|
|
31
40
|
/** Datagrams refused for want of room or for their size, which the peer's side counts as dropped. */
|
|
32
41
|
dropped: i32 = 0
|
|
33
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Makes an empty ring, allocating all of its storage now: `entries * entrySize` bytes of
|
|
45
|
+
* payload and a 4-byte length per entry.
|
|
46
|
+
*
|
|
47
|
+
* @param entries How many datagrams the ring holds at most before `push` refuses the next.
|
|
48
|
+
* @param entrySize The largest payload, in bytes, an entry holds; a longer one is dropped, not split.
|
|
49
|
+
*/
|
|
34
50
|
constructor(entries: i32, entrySize: i32) {
|
|
35
51
|
this.data = new Array<u8>(entries * entrySize)
|
|
36
52
|
this.lengths = new Array<i32>(entries)
|
|
@@ -44,7 +60,11 @@ export class QuicDatagramQueue {
|
|
|
44
60
|
this.dropped = 0
|
|
45
61
|
}
|
|
46
62
|
|
|
47
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* How many datagrams the ring holds at most.
|
|
65
|
+
*
|
|
66
|
+
* @returns The `entries` the ring was made with, however many it holds now (that is `count`).
|
|
67
|
+
*/
|
|
48
68
|
capacity(): i32 {
|
|
49
69
|
return toI32(this.lengths.length)
|
|
50
70
|
}
|
|
@@ -53,6 +73,11 @@ export class QuicDatagramQueue {
|
|
|
53
73
|
* Copies `buf[from .. from + length)` in as the newest datagram. Answers
|
|
54
74
|
* whether it could: not when the ring is full, nor for a payload past
|
|
55
75
|
* `entrySize` or a window outside `buf`, each of which counts in `dropped`.
|
|
76
|
+
*
|
|
77
|
+
* @param buf The bytes to take the payload from; copied, not kept.
|
|
78
|
+
* @param from The offset in `buf` of the payload's first byte.
|
|
79
|
+
* @param length The payload's size in bytes, 0 to `entrySize`.
|
|
80
|
+
* @returns True when the datagram was queued; false when it was dropped instead.
|
|
56
81
|
*/
|
|
57
82
|
push(buf: u8[], from: i32, length: i32): boolean {
|
|
58
83
|
const entries: i32 = this.capacity()
|
|
@@ -78,14 +103,18 @@ export class QuicDatagramQueue {
|
|
|
78
103
|
return true
|
|
79
104
|
}
|
|
80
105
|
|
|
81
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* The oldest datagram's length, or -1 when the ring is empty.
|
|
108
|
+
*
|
|
109
|
+
* @returns The size in bytes of the datagram `pop` or `putFrame` would take next, or -1 when there is none.
|
|
110
|
+
*/
|
|
82
111
|
peekLength(): i32 {
|
|
83
112
|
const k: i32 = this.head
|
|
84
113
|
return this.count > 0 && k >= 0 && k < toI32(this.lengths.length) ? this.lengths[k] : -1
|
|
85
114
|
}
|
|
86
115
|
|
|
87
116
|
/** Forgets the oldest datagram. */
|
|
88
|
-
drop(): void {
|
|
117
|
+
private drop(): void {
|
|
89
118
|
if (this.count > 0) {
|
|
90
119
|
this.head = (this.head + 1) % this.capacity()
|
|
91
120
|
this.count = this.count - 1
|
|
@@ -96,6 +125,12 @@ export class QuicDatagramQueue {
|
|
|
96
125
|
* Copies the oldest datagram into `buf` at `at` and forgets it. Answers
|
|
97
126
|
* its length, -1 when the ring is empty, or -2, keeping it, when it does
|
|
98
127
|
* not fit in `cap` bytes from `at` inside `buf`.
|
|
128
|
+
*
|
|
129
|
+
* @param buf The buffer to copy the payload into.
|
|
130
|
+
* @param at The offset in `buf` to copy it to.
|
|
131
|
+
* @param cap How many bytes from `at` the caller lets the payload take.
|
|
132
|
+
* @returns The payload's size in bytes, -1 when the ring is empty, or -2 when it does not fit in `cap` or
|
|
133
|
+
* `at` puts it outside `buf`, in which case it stays queued for a bigger buffer or a good window.
|
|
99
134
|
*/
|
|
100
135
|
pop(buf: u8[], at: i32, cap: i32): i32 {
|
|
101
136
|
const length: i32 = this.peekLength()
|
|
@@ -114,6 +149,11 @@ export class QuicDatagramQueue {
|
|
|
114
149
|
* Writes the oldest datagram as a DATAGRAM frame into `buf[at .. end)` and
|
|
115
150
|
* forgets it. Answers the offset past the frame, or `at` when the ring is
|
|
116
151
|
* empty or the frame does not fit, keeping it for the next packet.
|
|
152
|
+
*
|
|
153
|
+
* @param buf The packet payload being built.
|
|
154
|
+
* @param at The offset to write the frame at.
|
|
155
|
+
* @param end One past the last byte the frame may use, the packet's room or the congestion window's.
|
|
156
|
+
* @returns The offset past the DATAGRAM frame, or `at` itself when nothing was written.
|
|
117
157
|
*/
|
|
118
158
|
putFrame(buf: u8[], at: i32, end: i32): i32 {
|
|
119
159
|
const length: i32 = this.peekLength()
|