@amritk/nish-aarch64-linux 0.49.1 → 0.50.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 (91) hide show
  1. package/INSTALL.md +1 -1
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +233 -159
  4. package/package.json +1 -1
  5. package/runtime/gfx/nish-gfx.h +373 -61
  6. package/runtime/nish.d.ts +12 -9
  7. package/std/README.md +8 -5
  8. package/std/base64.ts +74 -1
  9. package/std/bytes.ts +201 -93
  10. package/std/compress/deflate.ts +20 -15
  11. package/std/crypto/base64url.ts +93 -66
  12. package/std/crypto/bcrypt.ts +25 -21
  13. package/std/crypto/hmac.ts +1 -1
  14. package/std/crypto/jwt.ts +32 -19
  15. package/std/crypto/p256.ts +9 -12
  16. package/std/crypto/pki-roots.ts +7 -4
  17. package/std/crypto/pki.ts +43 -55
  18. package/std/crypto/rsa-sign.ts +1632 -0
  19. package/std/crypto/rsa.ts +26 -4
  20. package/std/crypto/sha256.ts +135 -68
  21. package/std/crypto/x25519.ts +12 -11
  22. package/std/crypto/x509.ts +164 -40
  23. package/std/gpu/sys.ts +490 -0
  24. package/std/json-equal.ts +33 -18
  25. package/std/json-format.ts +39 -8
  26. package/std/json-number.ts +15 -3
  27. package/std/json-tokenizer.ts +4 -3
  28. package/std/json-typed.ts +12 -6
  29. package/std/json-value.ts +222 -104
  30. package/std/json.ts +81 -46
  31. package/std/net/dns-config.ts +18 -5
  32. package/std/net/dns-message.ts +60 -27
  33. package/std/net/dns-resolver.ts +35 -16
  34. package/std/net/dns.ts +3 -2
  35. package/std/net/fetch.ts +120 -38
  36. package/std/net/handler.ts +178 -66
  37. package/std/net/hpack.ts +192 -98
  38. package/std/net/http-compress.ts +83 -30
  39. package/std/net/http-fields.ts +327 -31
  40. package/std/net/http-server.ts +317 -20
  41. package/std/net/http1-client-codec.ts +137 -40
  42. package/std/net/http1-codec.ts +391 -202
  43. package/std/net/http1-server.ts +220 -38
  44. package/std/net/http2-cleartext.ts +10 -4
  45. package/std/net/http2-frame.ts +2 -2
  46. package/std/net/http2-tls.ts +3 -3
  47. package/std/net/http2.ts +69 -15
  48. package/std/net/http3-frame.ts +11 -14
  49. package/std/net/http3-server.ts +12 -15
  50. package/std/net/http3.ts +41 -29
  51. package/std/net/multipart.ts +592 -0
  52. package/std/net/outbound.ts +24 -8
  53. package/std/net/postgres-async.ts +92 -54
  54. package/std/net/postgres-carrier.ts +28 -4
  55. package/std/net/postgres.ts +166 -65
  56. package/std/net/prefork.ts +86 -5
  57. package/std/net/protobuf.ts +6 -2
  58. package/std/net/qpack.ts +66 -25
  59. package/std/net/quic-conn-ack.ts +27 -7
  60. package/std/net/quic-conn-cid.ts +13 -7
  61. package/std/net/quic-datagram.ts +6 -5
  62. package/std/net/quic-frame.ts +67 -23
  63. package/std/net/quic-listener.ts +19 -12
  64. package/std/net/quic-recovery.ts +11 -9
  65. package/std/net/quic-stream.ts +7 -5
  66. package/std/net/quic.ts +36 -31
  67. package/std/net/router.ts +136 -24
  68. package/std/net/serve.ts +59 -5
  69. package/std/net/static.ts +81 -33
  70. package/std/net/tls/record.ts +26 -13
  71. package/std/net/tls/ticket.ts +6 -5
  72. package/std/net/tls-tcp.ts +69 -30
  73. package/std/net/tls.ts +152 -38
  74. package/std/net/upstream.ts +65 -19
  75. package/std/net/url.ts +97 -78
  76. package/std/net/websocket.ts +16 -9
  77. package/std/net/webtransport.ts +28 -12
  78. package/std/regex.ts +600 -388
  79. package/std/sqlite.ts +37 -19
  80. package/std/sync/ring.ts +232 -115
  81. package/std/sync/shm.ts +11 -4
  82. package/std/temporal.ts +232 -133
  83. package/std/term-io.ts +12 -6
  84. package/std/term-pixels.ts +158 -22
  85. package/std/term-rate.ts +8 -3
  86. package/std/term.ts +4 -4
  87. package/std/text.ts +33 -11
  88. package/std/yaml-json.ts +238 -106
  89. package/std/yaml-lines.ts +47 -27
  90. package/std/yaml-write.ts +58 -24
  91. package/std/yaml.ts +808 -395
@@ -289,16 +289,28 @@ class JsonNumberParts {
289
289
  this.count = toI32(toI64(last) - toI64(first) + toI64(1))
290
290
  // A digit's exponent is the exponent plus `intLen - 1 - place`. The parts
291
291
  // that add and the parts that take away are summed apart, each below
292
- // 2^51, so the one subtraction is exact in `u64` and its result an `i64`.
292
+ // 2^51 since `big` was refused above, and the larger side decides the sign.
293
293
  const up: u64 = toU64(intLen) + (minus ? toU64(0) : size)
294
294
  const down: u64 = minus ? size + toU64(1) : toU64(1)
295
- this.lead = toI64(up - (down + toU64(first)))
296
- this.last = toI64(up - (down + toU64(last)))
295
+ this.lead = jsonNumberDifference(up, down + toU64(first))
296
+ this.last = jsonNumberDifference(up, down + toU64(last))
297
297
  this.lastBiased = up + (toU64(1) << toU64(62)) - (down + toU64(last))
298
298
  return 0
299
299
  }
300
300
  }
301
301
 
302
+ /**
303
+ * `up - down` as an `i64`, both below 2^63: the smaller is taken from the
304
+ * larger, so no subtraction wraps, and a negative answer is `~(down - up - 1)`.
305
+ */
306
+ const jsonNumberDifference = (up: u64, down: u64): i64 => {
307
+ if (up >= down) {
308
+ return toI64(up - down)
309
+ }
310
+ const less: u64 = down - up - toU64(1)
311
+ return ~toI64(less)
312
+ }
313
+
302
314
  /** `-1`, `0` or `1` as `a`'s size is below, equal to or above `b`'s, signs aside. */
303
315
  const jsonNumberCompareSize = (a: JsonNumberParts, b: JsonNumberParts): i32 => {
304
316
  if (a.lead !== b.lead) {
@@ -323,7 +323,9 @@ const jsonTokSigned = (m: u64, negative: boolean): i64 => {
323
323
  if (m === toU64(0)) {
324
324
  return toI64(0)
325
325
  }
326
- return ~toI64(m - toU64(1))
326
+ // `m` is at least 1 here, so taking one away is exact.
327
+ const less: u64 = m - toU64(1)
328
+ return ~toI64(less)
327
329
  }
328
330
 
329
331
  /**
@@ -1841,8 +1843,7 @@ export class JsonTokenizer {
1841
1843
  const src: u8[] = this.src
1842
1844
  const start: i32 = this.tokStart
1843
1845
  const end: i32 = this.tokEnd
1844
- const n: i32 = toI32(src.length)
1845
- if (start < 0 || start > end || end > n) {
1846
+ if (start < 0 || start > end || end > toI32(src.length)) {
1846
1847
  return 0
1847
1848
  }
1848
1849
  return parseFloat(String.fromBytes(src, start, end))
package/std/json-typed.ts CHANGED
@@ -823,8 +823,9 @@ export class JsonDecoder {
823
823
  const src: u8[] = tok.src
824
824
  // The width between the quotes is in `i64`, where it cannot wrap. The
825
825
  // opening quote is a byte of `src`, so the `+ 1` fits, and a byte `at`
826
- // past it is in `src` only when `at` is below the bytes left; then the
827
- // `u32` sum of two non-negative `i32`s is exact and below the length.
826
+ // past it is in `src` only when `at` is below the bytes left; then its
827
+ // index, `from + at`, is spelled as the length less the bytes after it,
828
+ // differences `src/bounds.ts` proves once each operand's sign is tested.
828
829
  if (
829
830
  toI64(n) !== toI64(tok.tokEnd) - toI64(start) - toI64(2) ||
830
831
  at < 0 ||
@@ -834,13 +835,18 @@ export class JsonDecoder {
834
835
  ) {
835
836
  return -1
836
837
  }
838
+ const length: i32 = toI32(src.length)
837
839
  const from: i32 = start + 1
838
- const left: i32 = toI32(src.length) - from
839
- if (at >= left) {
840
+ const left: i32 = length - from
841
+ if (left < 0 || at >= left) {
840
842
  return -1
841
843
  }
842
- const i: i32 = toI32(toU32(from) + toU32(at))
843
- if (i < 0 || i >= toI32(src.length)) {
844
+ const after: i32 = left - at
845
+ if (after <= 0) {
846
+ return -1
847
+ }
848
+ const i: i32 = length - after
849
+ if (i < 0 || i >= length) {
844
850
  return -1
845
851
  }
846
852
  return toI32(src[i])