nish 0.49.1 → 0.51.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/README.md +27 -21
- package/docs/AI.md +237 -160
- package/docs/INSTALL.md +1 -1
- package/package.json +12 -12
- package/runtime/gfx/nish-gfx.h +373 -61
- package/runtime/nish.d.ts +94 -11
- package/runtime/nish.h +5 -0
- package/runtime/runtime-host.c +21 -5
- package/std/README.md +14 -11
- package/std/base64.ts +74 -35
- package/std/bytes.ts +207 -97
- package/std/cli-args.ts +150 -107
- package/std/compress/checksum.ts +68 -10
- package/std/compress/deflate.ts +213 -115
- package/std/compress/gzip.ts +124 -49
- package/std/compress/zlib.ts +57 -15
- package/std/crypto/aes.ts +51 -9
- package/std/crypto/base64url.ts +93 -66
- package/std/crypto/bcrypt.ts +25 -21
- package/std/crypto/ed25519.ts +12 -10
- package/std/crypto/hkdf.ts +405 -283
- package/std/crypto/hmac.ts +484 -149
- package/std/crypto/jwt.ts +51 -40
- package/std/crypto/p256.ts +14 -19
- package/std/crypto/pki-roots.ts +35 -12
- package/std/crypto/pki.ts +43 -55
- package/std/crypto/rsa-sign.ts +1635 -0
- package/std/crypto/rsa.ts +26 -4
- package/std/crypto/sha256.ts +212 -90
- package/std/crypto/sha512.ts +135 -49
- package/std/crypto/x25519.ts +12 -11
- package/std/crypto/x509.ts +164 -40
- package/std/gpu/sys.ts +490 -0
- package/std/json-equal.ts +33 -18
- package/std/json-format.ts +39 -8
- package/std/json-number.ts +15 -3
- package/std/json-tokenizer.ts +4 -3
- package/std/json-typed.ts +12 -6
- package/std/json-value.ts +236 -119
- package/std/json.ts +81 -46
- package/std/net/buffer-pool.ts +25 -14
- package/std/net/dns-config.ts +18 -5
- package/std/net/dns-message.ts +60 -27
- package/std/net/dns-resolver.ts +35 -16
- package/std/net/dns.ts +3 -2
- package/std/net/fetch.ts +224 -61
- package/std/net/handler.ts +189 -88
- package/std/net/hpack.ts +216 -103
- package/std/net/http-compress.ts +104 -42
- package/std/net/http-fields.ts +327 -31
- package/std/net/http-server.ts +326 -24
- package/std/net/http1-client-codec.ts +159 -55
- package/std/net/http1-codec.ts +427 -237
- package/std/net/http1-server.ts +220 -38
- package/std/net/http2-cleartext.ts +10 -4
- package/std/net/http2-frame.ts +2 -2
- package/std/net/http2-tls.ts +3 -3
- package/std/net/http2.ts +69 -15
- package/std/net/http3-frame.ts +11 -14
- package/std/net/http3-server.ts +139 -60
- package/std/net/http3.ts +140 -79
- package/std/net/multipart.ts +592 -0
- package/std/net/outbound.ts +24 -8
- package/std/net/postgres-async.ts +97 -64
- package/std/net/postgres-carrier.ts +28 -4
- package/std/net/postgres.ts +166 -65
- package/std/net/prefork.ts +86 -5
- package/std/net/protobuf.ts +6 -2
- package/std/net/qpack.ts +147 -40
- package/std/net/quic-conn-ack.ts +27 -7
- package/std/net/quic-conn-cid.ts +13 -7
- package/std/net/quic-datagram.ts +6 -5
- package/std/net/quic-frame.ts +67 -23
- package/std/net/quic-listener.ts +61 -39
- package/std/net/quic-packet.ts +91 -50
- package/std/net/quic-recovery.ts +11 -9
- package/std/net/quic-stream.ts +36 -27
- package/std/net/quic.ts +84 -54
- package/std/net/router.ts +136 -24
- package/std/net/serve.ts +59 -5
- package/std/net/static.ts +86 -36
- package/std/net/tls/client.ts +81 -34
- package/std/net/tls/codec.ts +3 -4
- package/std/net/tls/record.ts +80 -35
- package/std/net/tls/schedule.ts +339 -149
- package/std/net/tls/ticket.ts +6 -5
- package/std/net/tls-tcp.ts +69 -30
- package/std/net/tls.ts +194 -50
- package/std/net/upstream.ts +83 -38
- package/std/net/url.ts +170 -94
- package/std/net/websocket.ts +19 -20
- package/std/net/webtransport.ts +123 -33
- package/std/raster.ts +12 -2
- package/std/regex.ts +600 -388
- package/std/sqlite.ts +37 -19
- package/std/sync/ring.ts +232 -115
- package/std/sync/shm.ts +11 -4
- package/std/temporal.ts +232 -133
- package/std/term-io.ts +12 -6
- package/std/term-pixels.ts +176 -24
- package/std/term-rate.ts +8 -3
- package/std/term.ts +4 -4
- package/std/text.ts +38 -16
- package/std/yaml-json.ts +238 -106
- package/std/yaml-lines.ts +47 -27
- package/std/yaml-write.ts +58 -24
- package/std/yaml.ts +808 -395
package/std/sqlite.ts
CHANGED
|
@@ -787,6 +787,20 @@ declare function nishsqlite_cursor_count_at(h: i32, i: u64): i64
|
|
|
787
787
|
declare function nishsqlite_cursor_read_row(h: i32, io: u8[], n: u64, text: u8[], ntext: u64): i32
|
|
788
788
|
declare function nishsqlite_cursor_record(h: i32, buf: u8[], n: u64): i32
|
|
789
789
|
|
|
790
|
+
/**
|
|
791
|
+
* The SQLite result code the adapter answered as `n`, minus that code: `-n`,
|
|
792
|
+
* spelled `~n + 1`. The adapter only answers small codes; a stray
|
|
793
|
+
* `-2147483648`, whose negation is past an `i32`, answers `2147483647` rather
|
|
794
|
+
* than overflow, and the test with the literal is what proves the sum.
|
|
795
|
+
*/
|
|
796
|
+
const sqliteNegated = (n: i32): i32 => {
|
|
797
|
+
const m: i32 = ~n
|
|
798
|
+
if (m < 0 || m > 2147483646) {
|
|
799
|
+
return 2147483647
|
|
800
|
+
}
|
|
801
|
+
return m + 1
|
|
802
|
+
}
|
|
803
|
+
|
|
790
804
|
/**
|
|
791
805
|
* A B-tree cursor on a table or index, which reads rows without a statement.
|
|
792
806
|
* Columns count from 0 in the order `openCursor` named them. A call on a
|
|
@@ -963,9 +977,8 @@ export class Cursor {
|
|
|
963
977
|
countRange(lo: i64, hi: i64, out: i64[]): Result<i32, i32> {
|
|
964
978
|
const n: i32 = nishsqlite_cursor_count_range(this.handle, lo, hi, toU64(out.length))
|
|
965
979
|
if (n < 0) {
|
|
966
|
-
// The adapter answers minus a SQLite result code
|
|
967
|
-
|
|
968
|
-
return Err(toI32(toU32(~n) + toU32(1)))
|
|
980
|
+
// The adapter answers minus a SQLite result code.
|
|
981
|
+
return Err(sqliteNegated(n))
|
|
969
982
|
}
|
|
970
983
|
for (let i = 0; i < out.length; i++) {
|
|
971
984
|
const c: i64 = nishsqlite_cursor_count_at(this.handle, toU64(i))
|
|
@@ -1000,9 +1013,8 @@ export class Cursor {
|
|
|
1000
1013
|
record(buf: u8[]): Result<i32, i32> {
|
|
1001
1014
|
const n: i32 = nishsqlite_cursor_record(this.handle, buf, toU64(buf.length))
|
|
1002
1015
|
if (n < 0) {
|
|
1003
|
-
// The adapter answers minus a SQLite result code
|
|
1004
|
-
|
|
1005
|
-
return Err(toI32(toU32(~n) + toU32(1)))
|
|
1016
|
+
// The adapter answers minus a SQLite result code.
|
|
1017
|
+
return Err(sqliteNegated(n))
|
|
1006
1018
|
}
|
|
1007
1019
|
return Ok(n)
|
|
1008
1020
|
}
|
|
@@ -1136,9 +1148,8 @@ export class Cursor {
|
|
|
1136
1148
|
const io: u8[] = this.rowIo
|
|
1137
1149
|
const n: i32 = nishsqlite_cursor_read_row(this.handle, io, toU64(io.length), text, toU64(text.length))
|
|
1138
1150
|
if (n < 0) {
|
|
1139
|
-
// The adapter answers minus a SQLite result code
|
|
1140
|
-
|
|
1141
|
-
return Err(toI32(toU32(~n) + toU32(1)))
|
|
1151
|
+
// The adapter answers minus a SQLite result code.
|
|
1152
|
+
return Err(sqliteNegated(n))
|
|
1142
1153
|
}
|
|
1143
1154
|
if (n > toI32(text.length)) {
|
|
1144
1155
|
return Ok(n)
|
|
@@ -1341,21 +1352,27 @@ export class RowRecord {
|
|
|
1341
1352
|
if (t < toI64(0)) {
|
|
1342
1353
|
return false
|
|
1343
1354
|
}
|
|
1344
|
-
// A varint is at most 5 bytes, so the mask keeps its length.
|
|
1345
|
-
//
|
|
1346
|
-
//
|
|
1347
|
-
|
|
1355
|
+
// A varint is at most 5 bytes, so the mask keeps its length. `idx` is
|
|
1356
|
+
// below `hdr`, so only a header within 7 bytes of 2^31 could pass the
|
|
1357
|
+
// literal, which no record buffer reaches; the test is what proves the
|
|
1358
|
+
// sum, and a header that did would be refused: the walk answers false.
|
|
1359
|
+
if (idx > 2147483640) {
|
|
1360
|
+
return false
|
|
1361
|
+
}
|
|
1362
|
+
idx = idx + (this.vlen & 7)
|
|
1348
1363
|
const ty: i32 = toI32(t)
|
|
1349
1364
|
types[k] = ty
|
|
1350
|
-
|
|
1365
|
+
// At most the record's length, checked above, so it is exact in an i32.
|
|
1366
|
+
const at: i32 = toI32(d)
|
|
1367
|
+
offs[k] = at
|
|
1351
1368
|
let sz: i32 = 0
|
|
1352
1369
|
if (ty >= 12) {
|
|
1353
1370
|
sz = (ty - 12) >> 1
|
|
1354
1371
|
} else if (ty >= 0 && ty < toI32(sizes.length)) {
|
|
1355
1372
|
sz = sizes[ty] & 15
|
|
1356
1373
|
}
|
|
1357
|
-
//
|
|
1358
|
-
d = toI64(
|
|
1374
|
+
// Two i32s summed in i64, which cannot overflow.
|
|
1375
|
+
d = toI64(at) + toI64(sz)
|
|
1359
1376
|
u = k + 1
|
|
1360
1377
|
}
|
|
1361
1378
|
if (d > toI64(this.length) && u > 0 && u <= toI32(types.length)) {
|
|
@@ -1462,9 +1479,10 @@ export class RowRecord {
|
|
|
1462
1479
|
}
|
|
1463
1480
|
const first: i32 = toI32(b[at])
|
|
1464
1481
|
let v: i64 = signed && first >= 128 ? toI64(first - 256) : toI64(first)
|
|
1465
|
-
//
|
|
1466
|
-
|
|
1467
|
-
|
|
1482
|
+
// Two i32s summed in i64, which cannot overflow; the window was checked
|
|
1483
|
+
// to lie inside `buf`.
|
|
1484
|
+
const stop: i64 = toI64(at) + toI64(n)
|
|
1485
|
+
for (let i: i32 = at + 1; i >= 0 && toI64(i) < stop && i < toI32(b.length); i += 1) {
|
|
1468
1486
|
v = (v << toI64(8)) | toI64(b[i])
|
|
1469
1487
|
}
|
|
1470
1488
|
return v
|