@amritk/nish-x86_64-linux 0.20.0 → 0.21.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 (70) hide show
  1. package/INSTALL.md +22 -10
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +2759 -0
  4. package/package.json +2 -1
  5. package/runtime/browser.d.ts +14 -0
  6. package/runtime/browser.mjs +88 -0
  7. package/runtime/core/arrays.d.ts +18 -0
  8. package/runtime/core/arrays.mjs +125 -0
  9. package/runtime/core/checks.mjs +20 -0
  10. package/runtime/core/host.d.ts +70 -0
  11. package/runtime/core/host.mjs +311 -0
  12. package/runtime/core/numbers.d.ts +53 -0
  13. package/runtime/core/numbers.mjs +316 -0
  14. package/runtime/core/result.d.ts +41 -0
  15. package/runtime/core/result.mjs +127 -0
  16. package/runtime/core/strings.d.ts +14 -0
  17. package/runtime/core/strings.mjs +169 -0
  18. package/runtime/core.d.ts +9 -0
  19. package/runtime/core.mjs +55 -0
  20. package/runtime/host.d.ts +6 -0
  21. package/runtime/nish.d.ts +44 -0
  22. package/runtime/nish.h +75 -2
  23. package/runtime/nish.mjs +23 -3
  24. package/runtime/node.mjs +383 -0
  25. package/runtime/runtime-bytes.c +401 -0
  26. package/runtime/runtime-cross.c +1 -1
  27. package/runtime/runtime-host.c +1 -1
  28. package/runtime/runtime-os.c +1 -1
  29. package/runtime/runtime-parallel.c +1 -1
  30. package/runtime/runtime-simd.c +231 -7
  31. package/runtime/runtime-term.c +504 -0
  32. package/runtime/runtime-wasm.c +0 -11
  33. package/runtime/runtime.c +190 -6
  34. package/runtime/shim.mjs +6 -985
  35. package/runtime/sqlite/LICENSE.md +85 -0
  36. package/runtime/sqlite/README.md +45 -0
  37. package/runtime/sqlite/nish-sqlite.c +359 -0
  38. package/runtime/sqlite/sqlite3.c +271131 -0
  39. package/runtime/sqlite/sqlite3.h +14447 -0
  40. package/scripts/build.sh +261 -53
  41. package/std/LICENSE-fast-float +23 -0
  42. package/std/LICENSE-fdlibm +8 -0
  43. package/std/README.md +31 -11
  44. package/std/base64.ts +116 -0
  45. package/std/bytes.ts +256 -0
  46. package/std/cli.ts +328 -0
  47. package/std/collections.ts +6 -5
  48. package/std/crypto/LICENSE-crypt_blowfish +26 -0
  49. package/std/crypto/base64url.ts +125 -0
  50. package/std/crypto/bcrypt.ts +760 -0
  51. package/std/crypto/hmac.ts +138 -2
  52. package/std/crypto/x509.ts +11 -122
  53. package/std/json-tokenizer.ts +2998 -57
  54. package/std/json-value.ts +22 -3
  55. package/std/json.ts +83 -1
  56. package/std/math.ts +608 -0
  57. package/std/net/http1-server.ts +85 -8
  58. package/std/net/http3-server.ts +50 -12
  59. package/std/net/postgres.ts +1875 -0
  60. package/std/net/quic-listener.ts +20 -4
  61. package/std/regex.ts +4274 -0
  62. package/std/sqlite.ts +391 -0
  63. package/std/term-io.ts +978 -0
  64. package/std/term-pixels.ts +874 -0
  65. package/std/term-probe.ts +459 -0
  66. package/std/term-rate.ts +993 -0
  67. package/std/term.ts +2453 -0
  68. package/std/text.ts +90 -7
  69. package/std/yaml-lines.ts +141 -0
  70. package/std/yaml.ts +4675 -0
@@ -68,7 +68,7 @@
68
68
  * of in one burst that overruns a queue on the path.
69
69
  *
70
70
  * let out: u8[] | null = quicListenerTakePaced(conn, now);
71
- * while (out !== null) { … send it … ; out = quicListenerTakePaced(conn, now); }
71
+ * while (out !== null) { … send it with conn.datagramEcn … ; out = quicListenerTakePaced(conn, now); }
72
72
  * … and wake at the earlier of conn.deadline() and quicListenerPaceTime(conn, now)
73
73
  *
74
74
  * A carrier that sends whole flights with `quicListenerTakeFlight`, below,
@@ -90,9 +90,16 @@
90
90
  * side, `quicListenerReceiveSegments` hands a connection the datagrams of
91
91
  * one GRO receive, segment by segment, in place.
92
92
  *
93
+ * **ECN** (RFC 9000 §13.4). A carrier whose platform sends the ECN bits it
94
+ * is given sets the connection's `ecnMarking` and sends each datagram with
95
+ * the codepoint the connection marked it with: `conn.datagramEcn` after a
96
+ * `takeDatagramInto` or `quicListenerTakePaced`, `flight.ecn` for a flight.
97
+ * One send carries one codepoint, so a flight ends before a datagram the
98
+ * connection would mark otherwise. The listener's own answers go unmarked.
99
+ *
93
100
  * const flight = new QuicFlight();
94
101
  * const n: i32 = quicListenerTakeFlight(conn, now, buf, 0, toI32(buf.length), flight);
95
- * if (n > 0) { udpSendTo(fd, buf, 0, n, peer, flight.count > 1 ? flight.segment : 0, 0); }
102
+ * if (n > 0) { udpSendTo(fd, buf, 0, n, peer, flight.count > 1 ? flight.segment : 0, flight.ecn); }
96
103
  *
97
104
  * **Sans-IO and deterministic.** The caller gives the time, the client's
98
105
  * address and, once, `QUIC_LISTENER_ENTROPY_SIZE` random bytes: every
@@ -928,6 +935,8 @@ export class QuicFlight {
928
935
  count: i32 = 0
929
936
  /** Every datagram's size but the last's, which may be shorter: the `UDP_SEGMENT` to send with. */
930
937
  segment: i32 = 0
938
+ /** The ECN codepoint every datagram of the flight was marked with: the one to send with. */
939
+ ecn: i32 = 0
931
940
  }
932
941
 
933
942
  /**
@@ -941,8 +950,8 @@ export class QuicFlight {
941
950
  * `quicListenerTakePaced` does, so the flight is the pacer's whole credit
942
951
  * and no more. It stops at the first datagram shorter than
943
952
  * `QUIC_CONN_DATAGRAM_SIZE`, which can only be the last of a segmented send,
944
- * at `QUIC_LISTENER_FLIGHT_MAX` datagrams, and when `cap` has no room for
945
- * another.
953
+ * at `QUIC_LISTENER_FLIGHT_MAX` datagrams, when `cap` has no room for
954
+ * another, and before a datagram whose ECN codepoint would not be the first's.
946
955
  */
947
956
  export const quicListenerTakeFlight = (
948
957
  conn: QuicConnection,
@@ -954,6 +963,7 @@ export const quicListenerTakeFlight = (
954
963
  ): i32 => {
955
964
  flight.count = 0
956
965
  flight.segment = 0
966
+ flight.ecn = 0
957
967
  let length: i32 = 0
958
968
  if (conn.recovery.pacerDelay(now, quicListenerQuantum(conn)) > 0) {
959
969
  return length
@@ -963,6 +973,11 @@ export const quicListenerTakeFlight = (
963
973
  length + QUIC_CONN_DATAGRAM_SIZE <= cap &&
964
974
  conn.recovery.pacerDelay(now, QUIC_CONN_DATAGRAM_SIZE) <= 0
965
975
  ) {
976
+ // The codepoint `takeDatagramInto` would mark the next datagram with: one send carries one.
977
+ const next: i32 = conn.ecnMarking ? conn.recovery.ecnCodepoint() : 0
978
+ if (flight.count > 0 && next !== flight.ecn) {
979
+ return length
980
+ }
966
981
  const n: i32 = conn.takeDatagramInto(buf, at + length, now)
967
982
  if (n <= 0) {
968
983
  return length
@@ -970,6 +985,7 @@ export const quicListenerTakeFlight = (
970
985
  conn.recovery.onPaced(now, n)
971
986
  if (flight.count === 0) {
972
987
  flight.segment = n
988
+ flight.ecn = conn.datagramEcn
973
989
  }
974
990
  flight.count = flight.count + 1
975
991
  length = length + n