@amritk/nish-x86_64-linux 0.36.0 → 0.38.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 (103) hide show
  1. package/INSTALL.md +92 -71
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +75 -14
  4. package/package.json +1 -1
  5. package/runtime/async.d.mts +2 -0
  6. package/runtime/async.mjs +7 -0
  7. package/runtime/core/arrays.d.ts +4 -0
  8. package/runtime/core/arrays.mjs +33 -0
  9. package/runtime/nish.d.ts +1045 -512
  10. package/runtime/nish.h +53 -6
  11. package/runtime/page.d.ts +53 -0
  12. package/runtime/page.mjs +146 -0
  13. package/runtime/runtime-async.c +740 -0
  14. package/runtime/runtime-cross.c +2 -1
  15. package/runtime/runtime-region.c +85 -7
  16. package/runtime/runtime-text.c +1068 -0
  17. package/runtime/runtime-wasm.c +65 -9
  18. package/runtime/runtime.c +50 -961
  19. package/runtime/vite.mjs +48 -11
  20. package/scripts/build.sh +231 -31
  21. package/std/LICENSE-fdlibm +8 -0
  22. package/std/README.md +109 -82
  23. package/std/array.ts +266 -0
  24. package/std/bytes.ts +23 -19
  25. package/std/compress/checksum.ts +1 -1
  26. package/std/crypto/aes.ts +48 -43
  27. package/std/crypto/base64url.ts +7 -5
  28. package/std/crypto/bcrypt-batch.ts +13 -13
  29. package/std/crypto/bcrypt.ts +33 -27
  30. package/std/crypto/chacha20poly1305.ts +16 -14
  31. package/std/crypto/ed25519.ts +19 -16
  32. package/std/crypto/hmac.ts +7 -6
  33. package/std/crypto/jwt.ts +23 -20
  34. package/std/crypto/p256.ts +63 -56
  35. package/std/crypto/p384.ts +23 -20
  36. package/std/crypto/pki.ts +18 -15
  37. package/std/crypto/rsa.ts +23 -19
  38. package/std/crypto/x25519.ts +11 -10
  39. package/std/crypto/x509.ts +69 -62
  40. package/std/host/ring.ts +124 -0
  41. package/std/host/text.ts +86 -0
  42. package/std/json-equal.ts +12 -11
  43. package/std/json-number.ts +12 -12
  44. package/std/json-tokenizer.ts +26 -22
  45. package/std/json-typed.ts +92 -78
  46. package/std/json-value.ts +38 -33
  47. package/std/json.ts +32 -28
  48. package/std/math.ts +743 -41
  49. package/std/net/dns-resolver.ts +46 -6
  50. package/std/net/dns.ts +50 -13
  51. package/std/net/fetch.ts +1744 -295
  52. package/std/net/handler.ts +30 -0
  53. package/std/net/hpack.ts +29 -26
  54. package/std/net/http-compress.ts +42 -28
  55. package/std/net/http-fields.ts +19 -4
  56. package/std/net/http1-client-codec.ts +29 -25
  57. package/std/net/http1-codec.ts +62 -91
  58. package/std/net/http1-server.ts +79 -57
  59. package/std/net/http2-frame.ts +17 -16
  60. package/std/net/http2-tls.ts +17 -15
  61. package/std/net/http2.ts +67 -54
  62. package/std/net/http3-frame.ts +11 -10
  63. package/std/net/http3-server.ts +36 -35
  64. package/std/net/http3.ts +70 -58
  65. package/std/net/postgres-async.ts +1005 -0
  66. package/std/net/postgres.ts +185 -164
  67. package/std/net/prefork.ts +38 -34
  68. package/std/net/qpack.ts +15 -14
  69. package/std/net/quic-conn-ack.ts +1 -0
  70. package/std/net/quic-conn-cid.ts +11 -0
  71. package/std/net/quic-conn-params.ts +41 -14
  72. package/std/net/quic-datagram.ts +7 -0
  73. package/std/net/quic-frame.ts +48 -12
  74. package/std/net/quic-listener.ts +61 -44
  75. package/std/net/quic-packet.ts +71 -52
  76. package/std/net/quic-recovery.ts +59 -21
  77. package/std/net/quic-stream.ts +83 -55
  78. package/std/net/quic.ts +204 -152
  79. package/std/net/serve.ts +763 -0
  80. package/std/net/tls/client.ts +1 -0
  81. package/std/net/tls/codec.ts +81 -12
  82. package/std/net/tls/record-client.ts +30 -18
  83. package/std/net/tls/record-server.ts +74 -46
  84. package/std/net/tls/record.ts +33 -24
  85. package/std/net/tls/ticket.ts +2 -0
  86. package/std/net/tls/verify.ts +8 -7
  87. package/std/net/tls-tcp.ts +58 -50
  88. package/std/net/tls.ts +55 -43
  89. package/std/net/url.ts +12 -9
  90. package/std/net/websocket.ts +23 -19
  91. package/std/net/webtransport.ts +24 -18
  92. package/std/random.ts +8 -6
  93. package/std/regex.ts +70 -59
  94. package/std/sync/ring.ts +24 -21
  95. package/std/sync/shm.ts +9 -7
  96. package/std/term-io.ts +17 -14
  97. package/std/term-probe.ts +11 -10
  98. package/std/term-rate.ts +71 -61
  99. package/std/term.ts +73 -59
  100. package/std/text.ts +242 -15
  101. package/std/threads.ts +19 -15
  102. package/std/yaml-json.ts +17 -15
  103. package/std/yaml-write.ts +21 -14
package/std/json-value.ts CHANGED
@@ -31,14 +31,15 @@
31
31
  * largest request seen, parsing allocates nothing.
32
32
  *
33
33
  * A handle carries the generation of the document's contents it was made in,
34
- * which moves on at every `parse` and `clear`, so a handle kept from an
35
- * earlier request names nothing in the next one, even when the next one has
36
- * the same shape: it is `JSON_VALUE_NONE` to `kind`, and every reader answers
37
- * its empty value for it rather than another document's. The generation has
38
- * 511 values and moves by one at a `clear`, one at a parse and two at a parse
39
- * that fails, so the check misses only a handle kept across exactly a
40
- * multiple of 511 of those steps; a program must not keep handles across
41
- * documents, and this catches the mistake rather than licensing it. A
34
+ * which moves on at every `parse` and `clear`, so a handle kept from an earlier
35
+ * request names nothing in the next one, even when the next one has the same
36
+ * shape: it is `JSON_VALUE_NONE` to `kind`, and every reader answers its empty
37
+ * value for it rather than another document's.
38
+ *
39
+ * The generation has 511 values and moves by one at a `clear`, one at a parse
40
+ * and two at a parse that fails, so the check misses only a handle kept across
41
+ * exactly a multiple of 511 of those steps; a program must not keep handles
42
+ * across documents, and this catches the mistake rather than licensing it. A
42
43
  * negative handle, or one past the last value, is `JSON_VALUE_NONE` too.
43
44
  *
44
45
  * **The document's size is bounded.** Each value costs about 46 bytes of the
@@ -67,25 +68,28 @@
67
68
  * the range of bytes it was read from: `start(v)` and `end(v)` bound a value,
68
69
  * `keyStart(o, i)` and `keyEnd(o, i)` the key of member `i`, its quotes
69
70
  * included. They are offsets into the bytes `parseRanged` was given, or
70
- * `parseTextRanged`'s string, so a line index over that text
71
- * (`YamlLineIndex` is one) turns them into a line and a column. Under Node,
72
- * where `parseTextRanged` takes one byte per UTF-16 code unit (below), its
73
- * offsets count code units, so past the first non-ASCII character they differ
74
- * from a native build's, which count UTF-8 bytes. Ranges cost about 20 bytes
75
- * per value more: two offsets for the value, two for its key and about one on
76
- * the parse's stacks, which grow with the nesting and the members pending.
77
- * They are entry points of their own rather than a flag `parse` tests, so
78
- * that `parse` keeps the loop it had before ranges existed. A plain `parse`
79
- * writes nothing for them: ranges carry the generation they were written in,
80
- * which `clear` moves anyway, so after a `parse` every reader answers `-1`,
81
- * and their arrays are made on first use, so a document that never keeps
82
- * ranges allocates none. A
83
- * loader that builds a document from another text `clear`s, then gives each
84
- * value it makes its range with `setRange` and each key with `setKeyRange`;
85
- * until then a built value or key answers `-1`. `set` over an existing key
86
- * keeps the member's key range and takes the new value's own. Under
87
- * `JSON_VALUE_DUPLICATE_LAST` a repeated key's member keeps its first key's
88
- * range and holds the last value, with that value's.
71
+ * `parseTextRanged`'s string, so a line index over that text (`YamlLineIndex`
72
+ * is one) turns them into a line and a column.
73
+ *
74
+ * Under Node, where `parseTextRanged` takes one byte per UTF-16 code unit
75
+ * (below), its offsets count code units, so past the first non-ASCII character
76
+ * they differ from a native build's, which count UTF-8 bytes. Ranges cost about
77
+ * 20 bytes per value more: two offsets for the value, two for its key and about
78
+ * one on the parse's stacks, which grow with the nesting and the members
79
+ * pending. They are entry points of their own rather than a flag `parse` tests,
80
+ * so that `parse` keeps the loop it had before ranges existed.
81
+ *
82
+ * A plain `parse` writes nothing for them: ranges carry the generation they
83
+ * were written in, which `clear` moves anyway, so after a `parse` every reader
84
+ * answers `-1`, and their arrays are made on first use, so a document that
85
+ * never keeps ranges allocates none. A loader that builds a document from
86
+ * another text `clear`s, then gives each value it makes its range with
87
+ * `setRange` and each key with `setKeyRange`; until then a built value or key
88
+ * answers `-1`. `set` over an existing key keeps the member's key range and
89
+ * takes the new value's own.
90
+ *
91
+ * Under `JSON_VALUE_DUPLICATE_LAST` a repeated key's member keeps its first
92
+ * key's range and holds the last value, with that value's.
89
93
  *
90
94
  * **Objects keep insertion order**, the order the members were written in or
91
95
  * added. `get` finds a member by its key with a scan, so it is for a handful of
@@ -125,12 +129,13 @@
125
129
  * `set` can never contain itself: adding a value that is already in a
126
130
  * container, or a container to itself or to anything inside it, is
127
131
  * `JSON_VALUE_ERR_ATTACHED`, and writing always ends.
128
- * Strings handed to a builder are taken as their bytes, as `JsonWriter` takes
129
- * them, and a string read back is made from the stored bytes in one
130
- * allocation (`String.fromBytes`). Under Node a string is UTF-16, and
131
- * `parseText` and the builders take one byte per code unit, so non-ASCII text
132
- * is stored differently there than natively, where a string is its UTF-8
133
- * bytes; `parse` over a `u8[]` reads the same bytes both ways.
132
+ *
133
+ * Strings handed to a builder are taken as their bytes, as `JsonWriter` takes
134
+ * them, and a string read back is made from the stored bytes in one allocation
135
+ * (`String.fromBytes`). Under Node a string is UTF-16, and `parseText` and the
136
+ * builders take one byte per code unit, so non-ASCII text is stored differently
137
+ * there than natively, where a string is its UTF-8 bytes; `parse` over a `u8[]`
138
+ * reads the same bytes both ways.
134
139
  *
135
140
  * **Public is not the whole API.** The compiler ignores `private`, so every
136
141
  * member is reachable by a program; `private` and `@internal` mark what is
package/std/json.ts CHANGED
@@ -70,28 +70,31 @@
70
70
  * infinities as `null`. `jsonStringifyString` is the same string rule
71
71
  * answered as a string.
72
72
  *
73
- * **Two modes**, both off by default and both kept across `reset`, so a
74
- * server sets them once. `setIndent(n)` and `setIndentTab()` write what
75
- * `JSON.stringify(v, null, n)` and `JSON.stringify(v, null, "\t")` write:
76
- * one member or element a line, `": "` after a key, an empty `{}` or `[]` on
77
- * one line, and `n` clamped to 10. The indent is one byte stored as many times
78
- * as the depth asks, so the indented text allocates no more than the minified
79
- * one, and a `raw` fragment is copied as it is, not re-indented.
80
- * `setStrict(true)` makes NaN and the infinities, which JSON cannot
81
- * spell, the sticky `JSON_WRITE_NON_FINITE` instead of `null`: for a caller
82
- * to whom a `null` where a number was due would be a silently corrupt record.
73
+ * **Two modes**, both off by default and both kept across `reset`, so a server
74
+ * sets them once. `setIndent(n)` and `setIndentTab()` write what
75
+ * `JSON.stringify(v, null, n)` and `JSON.stringify(v, null, "\t")` write: one
76
+ * member or element a line, `": "` after a key, an empty `{}` or `[]` on one
77
+ * line, and `n` clamped to 10. The indent is one byte stored as many times as
78
+ * the depth asks, so the indented text allocates no more than the minified one,
79
+ * and a `raw` fragment is copied as it is, not re-indented.
80
+ *
81
+ * `setStrict(true)` makes NaN and the infinities, which JSON cannot spell, the
82
+ * sticky `JSON_WRITE_NON_FINITE` instead of `null`: for a caller to whom a
83
+ * `null` where a number was due would be a silently corrupt record.
83
84
  *
84
85
  * **Misuse is a sticky code**, as in `nish/net/hpack`: never a panic, and no
85
86
  * `Result` to carry on the hot path. The first call that cannot be honoured
86
- * sets `failed` to a negative `JSON_WRITE_*` code — a value where a key is
87
- * due, a key where a value is due, an unbalanced or mismatched `end*`,
88
- * nesting past `JSON_WRITER_MAX_DEPTH`, a buffer with no room, a second
89
- * top-level value, a bad `raw` window or `start`, a non-finite `f64` in strict
90
- * mode — and every later call does nothing. A call that fails writes nothing
91
- * past `buf.length` (a full buffer is checked before the bytes go in, never
92
- * by the bounds check), so the caller writes the whole value, reads `failed`
93
- * once at the end, and grows the buffer and retries or answers a 500. `complete()` says whether one
94
- * whole value was written with every container closed.
87
+ * sets `failed` to a negative `JSON_WRITE_*` code — a value where a key is due,
88
+ * a key where a value is due, an unbalanced or mismatched `end*`, nesting past
89
+ * `JSON_WRITER_MAX_DEPTH`, a buffer with no room, a second top-level value, a
90
+ * bad `raw` window or `start`, a non-finite `f64` in strict mode — and every
91
+ * later call does nothing.
92
+ *
93
+ * A call that fails writes nothing past `buf.length` (a full buffer is checked
94
+ * before the bytes go in, never by the bounds check), so the caller writes the
95
+ * whole value, reads `failed` once at the end, and grows the buffer and retries
96
+ * or answers a 500. `complete()` says whether one whole value was written with
97
+ * every container closed.
95
98
  *
96
99
  * **A string is its bytes** (WP33 class C, `docs/wp33-round-trip.md` §3.2,
97
100
  * the first row). The writer escapes by byte and copies every byte at or
@@ -754,15 +757,16 @@ export const jsonField = (object: string, name: string): string | null => {
754
757
  *
755
758
  * The answer is a fresh array and the only allocation besides the values. Each
756
759
  * value is stored into it by a plain `values[k] = text` statement, and the
757
- * array is only stored into, tested and returned, so the values travel with
758
- * the array: the call lets nothing else out (LANGUAGE.md, "Memory model", a
759
- * value stored into an array that is returned with it). A loop calling this
760
- * keeps its per-pass release on a line older than the pass, as `jsonField`'s
761
- * does, and a `using a = arena()` block may hold the call. On a line built in
762
- * the pass neither reader keeps the release (LANGUAGE.md, "Memory model").
763
- * Reading `values` back, passing it to a function, or storing it anywhere
764
- * before the return would undo this; `tests/link/std_json` pins the flat
765
- * arena and the `using` block.
760
+ * array is only stored into, tested and returned, so the values travel with the
761
+ * array: the call lets nothing else out (LANGUAGE.md, "Memory model", a value
762
+ * stored into an array that is returned with it). A loop calling this keeps its
763
+ * per-pass release on a line older than the pass, as `jsonField`'s does, and a
764
+ * `using a = arena()` block may hold the call.
765
+ *
766
+ * On a line built in the pass neither reader keeps the release (LANGUAGE.md,
767
+ * "Memory model"). Reading `values` back, passing it to a function, or storing
768
+ * it anywhere before the return would undo this; `tests/link/std_json` pins the
769
+ * flat arena and the `using` block.
766
770
  *
767
771
  * @param object - the text of one JSON object.
768
772
  * @param names - the fields to look for.