@amritk/nish-aarch64-linux 0.49.0 → 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.
- package/INSTALL.md +1 -1
- package/bin/nish +0 -0
- package/docs/AI.md +233 -159
- package/package.json +1 -1
- package/runtime/gfx/nish-gfx.h +373 -61
- package/runtime/nish.d.ts +12 -9
- package/std/README.md +8 -5
- package/std/base64.ts +74 -1
- package/std/bytes.ts +201 -93
- package/std/compress/deflate.ts +20 -15
- package/std/crypto/base64url.ts +93 -66
- package/std/crypto/bcrypt.ts +25 -21
- package/std/crypto/hmac.ts +1 -1
- package/std/crypto/jwt.ts +32 -19
- package/std/crypto/p256.ts +9 -12
- package/std/crypto/pki-roots.ts +7 -4
- package/std/crypto/pki.ts +43 -55
- package/std/crypto/rsa-sign.ts +1632 -0
- package/std/crypto/rsa.ts +26 -4
- package/std/crypto/sha256.ts +135 -68
- 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 +29 -12
- package/std/json-value.ts +222 -104
- package/std/json.ts +81 -46
- 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 +120 -38
- package/std/net/handler.ts +178 -66
- package/std/net/hpack.ts +192 -98
- package/std/net/http-compress.ts +83 -30
- package/std/net/http-fields.ts +327 -31
- package/std/net/http-server.ts +317 -20
- package/std/net/http1-client-codec.ts +137 -40
- package/std/net/http1-codec.ts +391 -202
- 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 +12 -15
- package/std/net/http3.ts +41 -29
- package/std/net/multipart.ts +592 -0
- package/std/net/outbound.ts +24 -8
- package/std/net/postgres-async.ts +92 -54
- 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 +66 -25
- 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 +19 -12
- package/std/net/quic-recovery.ts +11 -9
- package/std/net/quic-stream.ts +7 -5
- package/std/net/quic.ts +36 -31
- package/std/net/router.ts +136 -24
- package/std/net/serve.ts +59 -5
- package/std/net/static.ts +81 -33
- package/std/net/tls/record.ts +26 -13
- package/std/net/tls/ticket.ts +6 -5
- package/std/net/tls-tcp.ts +69 -30
- package/std/net/tls.ts +152 -38
- package/std/net/upstream.ts +65 -19
- package/std/net/url.ts +97 -78
- package/std/net/websocket.ts +33 -15
- package/std/net/webtransport.ts +28 -12
- 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 +158 -22
- package/std/term-rate.ts +8 -3
- package/std/term.ts +4 -4
- package/std/text.ts +33 -11
- package/std/threads.ts +52 -8
- 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/yaml-lines.ts
CHANGED
|
@@ -31,6 +31,8 @@ const YAML_LINES_LF: i32 = 10
|
|
|
31
31
|
/** A UTF-8 continuation byte is `10xxxxxx`: at least this and below `0xC0`. */
|
|
32
32
|
const YAML_LINES_CONTINUATION: i32 = 128
|
|
33
33
|
const YAML_LINES_LEAD: i32 = 192
|
|
34
|
+
/** The largest column an `i32` holds; one past a line this long has none. */
|
|
35
|
+
const YAML_LINES_MAX_COLUMN: i32 = 2147483647
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Where each line of one text starts, for turning byte offsets into lines and
|
|
@@ -53,19 +55,23 @@ export class YamlLineIndex {
|
|
|
53
55
|
const length: i32 = toI32(text.length)
|
|
54
56
|
let nl: i32 = toI32(text.indexOf("\n"))
|
|
55
57
|
let cr: i32 = toI32(text.indexOf("\r"))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
// A search's answer is a break only from 0 to below `length`; anything
|
|
59
|
+
// else is none left, and the scan stops when neither search has one.
|
|
60
|
+
while (true) {
|
|
61
|
+
if (cr >= 0 && cr < length && (nl < 0 || cr < nl)) {
|
|
58
62
|
// CR LF is one break: step over both, and move the LF search past it.
|
|
59
|
-
if (cr
|
|
63
|
+
if (cr < length - 1 && toI32(text.charCodeAt(cr + 1)) === YAML_LINES_LF) {
|
|
60
64
|
this.starts.push(cr + 2)
|
|
61
65
|
nl = toI32(text.indexOf("\n", cr + 2))
|
|
62
66
|
} else {
|
|
63
67
|
this.starts.push(cr + 1)
|
|
64
68
|
}
|
|
65
69
|
cr = toI32(text.indexOf("\r", cr + 1))
|
|
66
|
-
} else {
|
|
70
|
+
} else if (nl >= 0 && nl < length) {
|
|
67
71
|
this.starts.push(nl + 1)
|
|
68
72
|
nl = toI32(text.indexOf("\n", nl + 1))
|
|
73
|
+
} else {
|
|
74
|
+
break
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
}
|
|
@@ -86,15 +92,18 @@ export class YamlLineIndex {
|
|
|
86
92
|
* @returns The byte offset of the line's first byte.
|
|
87
93
|
*/
|
|
88
94
|
lineStart(line: i32): i32 {
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
95
|
+
const starts: i32[] = this.starts
|
|
96
|
+
const count: i32 = toI32(starts.length)
|
|
97
|
+
if (line > count) {
|
|
98
|
+
return count > 0 ? starts[count - 1] : 0
|
|
93
99
|
}
|
|
94
|
-
if (
|
|
95
|
-
|
|
100
|
+
if (line > 1) {
|
|
101
|
+
const at: i32 = line - 1
|
|
102
|
+
if (at < count) {
|
|
103
|
+
return starts[at]
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
|
-
return
|
|
106
|
+
return 0
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
/**
|
|
@@ -104,7 +113,7 @@ export class YamlLineIndex {
|
|
|
104
113
|
* @returns The 1-based line; a break belongs to the line it ends.
|
|
105
114
|
*/
|
|
106
115
|
line(offset: i32): i32 {
|
|
107
|
-
return this.
|
|
116
|
+
return this.linesFrom(this.clamp(offset))
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
/**
|
|
@@ -113,19 +122,21 @@ export class YamlLineIndex {
|
|
|
113
122
|
* @param offset A byte offset into the text; clamped to `[0, text.length]`.
|
|
114
123
|
* @returns The 1-based column: one more than the characters between the line's start and
|
|
115
124
|
* `offset`, a UTF-8 continuation byte not counting (under Node, a UTF-16 unit from `0x80` to `0xBF`
|
|
116
|
-
* not counting either, so `©` is not a column)
|
|
125
|
+
* not counting either, so `©` is not a column); `-1` past a line of 2^31 - 1 characters, whose
|
|
126
|
+
* next column no `i32` holds.
|
|
117
127
|
*/
|
|
118
128
|
column(offset: i32): i32 {
|
|
119
129
|
const at: i32 = this.clamp(offset)
|
|
120
|
-
const index: i32 = this.lineIndexOf(at)
|
|
121
|
-
const starts: i32[] = this.starts
|
|
122
|
-
let i: i32 = index >= 0 && index < toI32(starts.length) ? starts[index] : 0
|
|
123
130
|
const text: string = this.text
|
|
124
131
|
const length: i32 = toI32(text.length)
|
|
132
|
+
let i: i32 = this.lineStart(this.linesFrom(at))
|
|
125
133
|
let column: i32 = 1
|
|
126
134
|
while (i >= 0 && i < at && i < length) {
|
|
127
135
|
const code: i32 = toI32(text.charCodeAt(i))
|
|
128
136
|
if (code < YAML_LINES_CONTINUATION || code >= YAML_LINES_LEAD) {
|
|
137
|
+
if (column >= YAML_LINES_MAX_COLUMN) {
|
|
138
|
+
return -1
|
|
139
|
+
}
|
|
129
140
|
column += 1
|
|
130
141
|
}
|
|
131
142
|
i += 1
|
|
@@ -138,11 +149,17 @@ export class YamlLineIndex {
|
|
|
138
149
|
*
|
|
139
150
|
* @param offset A byte offset into the text; clamped to `[0, text.length]`.
|
|
140
151
|
* @returns The 1-based column: one more than the bytes between the line's start and `offset`
|
|
141
|
-
* (under Node, UTF-16 units)
|
|
152
|
+
* (under Node, UTF-16 units); `-1` past a line of 2^31 - 1 bytes, whose next column no `i32`
|
|
153
|
+
* holds.
|
|
142
154
|
*/
|
|
143
155
|
byteColumn(offset: i32): i32 {
|
|
144
156
|
const at: i32 = this.clamp(offset)
|
|
145
|
-
|
|
157
|
+
const start: i32 = this.lineStart(this.linesFrom(at))
|
|
158
|
+
if (start < 0 || start > at) {
|
|
159
|
+
return -1
|
|
160
|
+
}
|
|
161
|
+
const span: i32 = at - start
|
|
162
|
+
return span < YAML_LINES_MAX_COLUMN ? span + 1 : -1
|
|
146
163
|
}
|
|
147
164
|
|
|
148
165
|
/** `offset` clamped to `[0, text.length]`. */
|
|
@@ -154,18 +171,21 @@ export class YamlLineIndex {
|
|
|
154
171
|
return offset > length ? length : offset
|
|
155
172
|
}
|
|
156
173
|
|
|
157
|
-
/**
|
|
158
|
-
|
|
174
|
+
/**
|
|
175
|
+
* How many lines start at or before byte `at`, by binary search over
|
|
176
|
+
* `starts`: the 1-based line holding `at`, since line 1 starts at 0.
|
|
177
|
+
*/
|
|
178
|
+
private linesFrom(at: i32): i32 {
|
|
159
179
|
const starts: i32[] = this.starts
|
|
180
|
+
const count: i32 = toI32(starts.length)
|
|
160
181
|
let low: i32 = 0
|
|
161
|
-
let high: i32 =
|
|
162
|
-
while (low < high) {
|
|
163
|
-
const mid: i32 = (low + high
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
low = mid
|
|
182
|
+
let high: i32 = count
|
|
183
|
+
while (low >= 0 && low < high && high <= count) {
|
|
184
|
+
const mid: i32 = toI32((toI64(low) + toI64(high)) >> toI64(1))
|
|
185
|
+
if (mid >= 0 && mid < count && starts[mid] <= at) {
|
|
186
|
+
low = mid + 1
|
|
167
187
|
} else {
|
|
168
|
-
high = mid
|
|
188
|
+
high = mid
|
|
169
189
|
}
|
|
170
190
|
}
|
|
171
191
|
return low
|
package/std/yaml-write.ts
CHANGED
|
@@ -82,6 +82,16 @@ const YAML_WRITE_BACKSLASH: i32 = 92
|
|
|
82
82
|
const yamlWriteByte = (text: string, i: i32): i32 =>
|
|
83
83
|
i >= 0 && i < toI32(text.length) ? toI32(text.charCodeAt(i)) : -1
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Where a scan of `text` that stands at `i` goes next: past the `step` bytes of
|
|
87
|
+
* one character, `n` at most. Summed in `i64`, so `i + step` cannot overflow; the
|
|
88
|
+
* cap never binds, as a character's bytes are all in `text`.
|
|
89
|
+
*/
|
|
90
|
+
const yamlWriteStep = (i: i32, step: i32, n: i32): i32 => {
|
|
91
|
+
const next: i64 = toI64(i) + toI64(step)
|
|
92
|
+
return next < toI64(n) ? toI32(next) : n
|
|
93
|
+
}
|
|
94
|
+
|
|
85
95
|
const yamlWriteIsDigit = (c: i32): boolean => c >= 48 && c <= 57
|
|
86
96
|
|
|
87
97
|
/** Whether `c` is an indicator that cannot start a plain scalar, whatever follows it. */
|
|
@@ -166,7 +176,11 @@ const yamlWriteEscapedLength = (text: string, i: i32): i32 => {
|
|
|
166
176
|
if (c === 194 && next >= 128 && next <= 159) {
|
|
167
177
|
return 2
|
|
168
178
|
}
|
|
169
|
-
|
|
179
|
+
if (c !== 226 && c !== 239) {
|
|
180
|
+
return 0
|
|
181
|
+
}
|
|
182
|
+
// Below `text.length - 2`, `i + 2` is at most 2^31 - 2.
|
|
183
|
+
const third: i32 = i < toI32(text.length) - 2 ? yamlWriteByte(text, i + 2) : -1
|
|
170
184
|
if (c === 226 && next === 128 && (third === 168 || third === 169)) {
|
|
171
185
|
return 3
|
|
172
186
|
}
|
|
@@ -204,29 +218,39 @@ const yamlWriteNeedsQuotes = (text: string, key: boolean): boolean => {
|
|
|
204
218
|
}
|
|
205
219
|
|
|
206
220
|
/**
|
|
207
|
-
*
|
|
208
|
-
* quotes and, for each escape, the bytes
|
|
221
|
+
* Whether `text` as written takes more than `YAML_WRITE_MAX_KEY_LENGTH` bytes:
|
|
222
|
+
* its own, or quoted, two more for the quotes and, for each escape, the bytes
|
|
223
|
+
* it adds to the character it replaces. The count stops once it is past the
|
|
224
|
+
* limit, so it stays far below 2^31.
|
|
209
225
|
*/
|
|
210
|
-
const
|
|
226
|
+
const yamlWriteKeyTooLong = (text: string, quoted: boolean): boolean => {
|
|
211
227
|
const n: i32 = toI32(text.length)
|
|
212
228
|
if (!quoted) {
|
|
213
|
-
return n
|
|
229
|
+
return n > YAML_WRITE_MAX_KEY_LENGTH
|
|
214
230
|
}
|
|
215
|
-
let length: i32 =
|
|
231
|
+
let length: i32 = 2
|
|
216
232
|
let i: i32 = 0
|
|
217
|
-
while (i < n) {
|
|
233
|
+
while (i >= 0 && i < n && length <= YAML_WRITE_MAX_KEY_LENGTH) {
|
|
218
234
|
const c: i32 = yamlWriteByte(text, i)
|
|
219
235
|
const escaped: i32 = yamlWriteEscapedLength(text, i)
|
|
220
236
|
if (c === 34 || c === 92 || c === 10 || c === 9 || c === 13) {
|
|
221
|
-
length +=
|
|
237
|
+
length += 2
|
|
222
238
|
} else if (escaped === 1) {
|
|
223
|
-
length +=
|
|
224
|
-
} else if (escaped
|
|
225
|
-
length +=
|
|
239
|
+
length += 4
|
|
240
|
+
} else if (escaped === 2) {
|
|
241
|
+
length += 4
|
|
242
|
+
} else if (escaped === 3) {
|
|
243
|
+
length += 6
|
|
244
|
+
} else {
|
|
245
|
+
length += 1
|
|
246
|
+
}
|
|
247
|
+
if (escaped > 1) {
|
|
248
|
+
i = yamlWriteStep(i, escaped, n)
|
|
249
|
+
} else {
|
|
250
|
+
i += 1
|
|
226
251
|
}
|
|
227
|
-
i += escaped > 1 ? escaped : 1
|
|
228
252
|
}
|
|
229
|
-
return length
|
|
253
|
+
return length > YAML_WRITE_MAX_KEY_LENGTH
|
|
230
254
|
}
|
|
231
255
|
|
|
232
256
|
/** Writes one JSON value as block YAML, byte by byte, into `out`. */
|
|
@@ -279,7 +303,7 @@ class YamlWriter {
|
|
|
279
303
|
private escape(text: string, i: i32, length: i32): void {
|
|
280
304
|
const c: i32 = yamlWriteByte(text, i)
|
|
281
305
|
const second: i32 = yamlWriteByte(text, i + 1)
|
|
282
|
-
const third: i32 = yamlWriteByte(text, i + 2)
|
|
306
|
+
const third: i32 = i < toI32(text.length) - 2 ? yamlWriteByte(text, i + 2) : -1
|
|
283
307
|
if (length === 2) {
|
|
284
308
|
this.hex(second)
|
|
285
309
|
} else if (length === 3 && second === 128) {
|
|
@@ -313,7 +337,7 @@ class YamlWriter {
|
|
|
313
337
|
i += 1
|
|
314
338
|
} else if (length > 0) {
|
|
315
339
|
this.escape(text, i, length)
|
|
316
|
-
i
|
|
340
|
+
i = yamlWriteStep(i, length, n)
|
|
317
341
|
} else {
|
|
318
342
|
this.byte(c)
|
|
319
343
|
i += 1
|
|
@@ -358,11 +382,12 @@ class YamlWriter {
|
|
|
358
382
|
}
|
|
359
383
|
|
|
360
384
|
/**
|
|
361
|
-
* Writes `v` starting at column `
|
|
362
|
-
* it, and ends its last line; `depth` is how many collections hold
|
|
385
|
+
* Writes `v` starting at column `2 * depth`, where the line has already
|
|
386
|
+
* reached it, and ends its last line; `depth` is how many collections hold
|
|
387
|
+
* it, and each indents its members two spaces.
|
|
363
388
|
* @internal Called by `stringifyYaml`.
|
|
364
389
|
*/
|
|
365
|
-
node(v: JsonValue,
|
|
390
|
+
node(v: JsonValue, depth: i32): void {
|
|
366
391
|
const doc: JsonDocument = this.doc
|
|
367
392
|
const kind: i32 = doc.kind(v)
|
|
368
393
|
if ((kind === JSON_VALUE_ARRAY || kind === JSON_VALUE_OBJECT) && depth >= JSON_WRITER_MAX_DEPTH) {
|
|
@@ -374,6 +399,16 @@ class YamlWriter {
|
|
|
374
399
|
this.byte(YAML_WRITE_LF)
|
|
375
400
|
return
|
|
376
401
|
}
|
|
402
|
+
// Never taken: a block is a collection, refused above at this depth, and
|
|
403
|
+
// `depth` starts at 0 and only grows. The literal, under 2^30, is what the
|
|
404
|
+
// prover reads to bound the indent's arithmetic; it does not read a constant's value.
|
|
405
|
+
if (depth < 0 || depth >= JSON_WRITER_MAX_DEPTH || depth >= 1073741823) {
|
|
406
|
+
this.tooDeep = true
|
|
407
|
+
return
|
|
408
|
+
}
|
|
409
|
+
const indent: i32 = depth * 2
|
|
410
|
+
const inner: i32 = indent + 2
|
|
411
|
+
const deeper: i32 = depth + 1
|
|
377
412
|
const object: boolean = kind === JSON_VALUE_OBJECT
|
|
378
413
|
for (let i: i32 = 0; i < doc.length(v) && !this.tooDeep; i += 1) {
|
|
379
414
|
if (i > 0) {
|
|
@@ -382,12 +417,12 @@ class YamlWriter {
|
|
|
382
417
|
const member: JsonValue = doc.at(v, i)
|
|
383
418
|
if (!object) {
|
|
384
419
|
this.text("- ")
|
|
385
|
-
this.node(member,
|
|
420
|
+
this.node(member, deeper)
|
|
386
421
|
continue
|
|
387
422
|
}
|
|
388
423
|
const key: string = doc.keyAt(v, i)
|
|
389
424
|
const quoted: boolean = yamlWriteNeedsQuotes(key, true)
|
|
390
|
-
const explicit: boolean =
|
|
425
|
+
const explicit: boolean = yamlWriteKeyTooLong(key, quoted)
|
|
391
426
|
if (explicit) {
|
|
392
427
|
this.text("? ")
|
|
393
428
|
}
|
|
@@ -399,11 +434,11 @@ class YamlWriter {
|
|
|
399
434
|
this.byte(YAML_WRITE_COLON)
|
|
400
435
|
if (this.isBlock(member)) {
|
|
401
436
|
this.byte(YAML_WRITE_LF)
|
|
402
|
-
this.spaces(
|
|
437
|
+
this.spaces(inner)
|
|
403
438
|
} else {
|
|
404
439
|
this.byte(YAML_WRITE_SPACE)
|
|
405
440
|
}
|
|
406
|
-
this.node(member,
|
|
441
|
+
this.node(member, deeper)
|
|
407
442
|
}
|
|
408
443
|
}
|
|
409
444
|
}
|
|
@@ -422,9 +457,8 @@ export const stringifyYaml = (doc: JsonDocument, v: JsonValue): string => {
|
|
|
422
457
|
return ""
|
|
423
458
|
}
|
|
424
459
|
const writer: YamlWriter = new YamlWriter(doc)
|
|
425
|
-
const indent: i32 = 0
|
|
426
460
|
const depth: i32 = 0
|
|
427
|
-
writer.node(v,
|
|
461
|
+
writer.node(v, depth)
|
|
428
462
|
const from: i32 = 0
|
|
429
463
|
return writer.tooDeep ? "" : String.fromBytes(writer.out, from, toI32(writer.out.length))
|
|
430
464
|
}
|