nish 0.35.0 → 0.37.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/docs/AI.md +50 -4
- package/docs/INSTALL.md +73 -59
- package/package.json +19 -5
- package/runtime/async.d.mts +2 -0
- package/runtime/async.mjs +7 -0
- package/runtime/nish.d.ts +4849 -430
- package/runtime/nish.h +25 -0
- package/runtime/page.d.ts +53 -0
- package/runtime/page.mjs +146 -0
- package/runtime/runtime-async.c +557 -0
- package/runtime/runtime-wasm.c +63 -7
- package/runtime/vite.d.ts +30 -0
- package/runtime/vite.mjs +150 -0
- package/scripts/build.sh +252 -15
- package/scripts/fuzz.sh +1 -0
- package/scripts/undocumented.txt +14 -0
- package/std/README.md +107 -82
- package/std/base64.ts +34 -5
- package/std/bytes.ts +279 -59
- package/std/cli-args.ts +296 -70
- package/std/cli-flags.ts +184 -19
- package/std/cli.ts +475 -54
- package/std/collections.ts +121 -23
- package/std/compress/checksum.ts +44 -14
- package/std/compress/deflate.ts +224 -111
- package/std/compress/gzip.ts +217 -53
- package/std/compress/zlib.ts +63 -7
- package/std/crypto/aes.ts +128 -52
- package/std/crypto/base64url.ts +29 -5
- package/std/crypto/bcrypt-batch.ts +101 -34
- package/std/crypto/bcrypt.ts +93 -27
- package/std/crypto/chacha20poly1305.ts +69 -14
- package/std/crypto/ct.ts +32 -13
- package/std/crypto/ed25519.ts +66 -16
- package/std/crypto/hkdf.ts +198 -13
- package/std/crypto/hmac.ts +242 -37
- package/std/crypto/jwt.ts +204 -72
- package/std/crypto/p256.ts +222 -72
- package/std/crypto/p384.ts +51 -23
- package/std/crypto/pki-roots.ts +32 -2
- package/std/crypto/pki.ts +99 -30
- package/std/crypto/rsa.ts +56 -22
- package/std/crypto/sha1.ts +3 -0
- package/std/crypto/sha256.ts +24 -1
- package/std/crypto/sha512.ts +99 -14
- package/std/crypto/x25519.ts +163 -24
- package/std/crypto/x509-random.ts +10 -0
- package/std/crypto/x509.ts +133 -66
- package/std/host/ring.ts +124 -0
- package/std/json-equal.ts +31 -11
- package/std/json-format.ts +112 -13
- package/std/json-number.ts +76 -26
- package/std/json-pointer.ts +23 -1
- package/std/json-tokenizer.ts +126 -51
- package/std/json-typed.ts +757 -96
- package/std/json-value.ts +438 -157
- package/std/json.ts +170 -38
- package/std/map.ts +25 -7
- package/std/math.ts +36 -4
- package/std/net/buffer-pool.ts +42 -11
- package/std/net/dns-config.ts +109 -23
- package/std/net/dns-message.ts +62 -7
- package/std/net/dns-resolver.ts +247 -53
- package/std/net/dns.ts +203 -35
- package/std/net/fetch.ts +1267 -290
- package/std/net/handler.ts +296 -80
- package/std/net/hpack.ts +290 -77
- package/std/net/http-compress.ts +152 -36
- package/std/net/http-fields.ts +85 -9
- package/std/net/http1-client-codec.ts +129 -44
- package/std/net/http1-codec.ts +279 -114
- package/std/net/http1-server.ts +409 -139
- package/std/net/http2-frame.ts +289 -51
- package/std/net/http2-tls.ts +152 -49
- package/std/net/http2.ts +314 -160
- package/std/net/http3-frame.ts +165 -27
- package/std/net/http3-server.ts +282 -131
- package/std/net/http3.ts +377 -173
- package/std/net/outbound.ts +37 -3
- package/std/net/postgres-carrier.ts +144 -8
- package/std/net/postgres.ts +898 -260
- package/std/net/prefork.ts +202 -65
- package/std/net/qpack.ts +120 -32
- package/std/net/quic-conn-ack.ts +60 -12
- package/std/net/quic-conn-cid.ts +135 -27
- package/std/net/quic-conn-params.ts +109 -22
- package/std/net/quic-datagram.ts +50 -3
- package/std/net/quic-frame.ts +333 -23
- package/std/net/quic-listener.ts +161 -75
- package/std/net/quic-packet.ts +373 -73
- package/std/net/quic-recovery.ts +287 -65
- package/std/net/quic-stream.ts +436 -146
- package/std/net/quic.ts +693 -323
- package/std/net/router.ts +87 -40
- package/std/net/tls/client.ts +167 -51
- package/std/net/tls/codec.ts +494 -68
- package/std/net/tls/record-client.ts +140 -73
- package/std/net/tls/record-server.ts +233 -105
- package/std/net/tls/record.ts +142 -36
- package/std/net/tls/schedule.ts +235 -26
- package/std/net/tls/ticket.ts +161 -40
- package/std/net/tls/verify.ts +57 -10
- package/std/net/tls-tcp.ts +308 -95
- package/std/net/tls.ts +276 -102
- package/std/net/upstream.ts +81 -45
- package/std/net/url.ts +109 -22
- package/std/net/websocket.ts +140 -26
- package/std/net/webtransport.ts +243 -106
- package/std/pair.ts +10 -2
- package/std/random.ts +42 -15
- package/std/regex.ts +422 -257
- package/std/region.ts +70 -15
- package/std/secret.ts +52 -11
- package/std/sort.ts +17 -2
- package/std/sqlite.ts +256 -35
- package/std/sync/ring.ts +229 -56
- package/std/sync/shm.ts +203 -23
- package/std/term-io.ts +154 -78
- package/std/term-pixels.ts +144 -19
- package/std/term-probe.ts +77 -35
- package/std/term-rate.ts +199 -118
- package/std/term.ts +400 -175
- package/std/testing.ts +130 -32
- package/std/text.ts +84 -17
- package/std/threads.ts +248 -56
- package/std/yaml-json.ts +111 -97
- package/std/yaml-lines.ts +47 -15
- package/std/yaml-write.ts +45 -30
- package/std/yaml.ts +764 -384
package/std/yaml-write.ts
CHANGED
|
@@ -23,20 +23,27 @@
|
|
|
23
23
|
* as its text, which the core schema reads as an integer or a float. The text
|
|
24
24
|
* ends with a line break.
|
|
25
25
|
*
|
|
26
|
-
* **A string is plain unless it could read as something else.**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* or
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
26
|
+
* **A string is plain unless it could read as something else.**
|
|
27
|
+
*
|
|
28
|
+
* It is written double-quoted
|
|
29
|
+
* - when it is empty;
|
|
30
|
+
* - when it reads as null, a boolean or a number under YAML 1.2 or YAML 1.1
|
|
31
|
+
* (`~`, `null`, `yes`, `on`, `y`, `true` in any case; anything starting with
|
|
32
|
+
* a digit, or a sign or `.` and then a digit; `.inf` and `.nan`, signed or
|
|
33
|
+
* not);
|
|
34
|
+
* - when it starts with an indicator (`@`, `` ` ``, `\`, `*`, `&`, `!`, `|`,
|
|
35
|
+
* `>`, `%`, `'`, `"`, `#`, `,`, `[`, `]`, `{`, `}`, or `-`, `?` or `:` before
|
|
36
|
+
* a space or the end) or with `---` or `...`;
|
|
37
|
+
* - when it holds `: ` or ` #` or ends in `:`;
|
|
38
|
+
* - when it starts or ends with a space;
|
|
39
|
+
* - when it holds a control character, a line break, U+2028, U+2029, U+FEFF,
|
|
40
|
+
* U+FFFE or U+FFFF;
|
|
41
|
+
* - and, as a key, when it is `<<`, which YAML reads as a merge key.
|
|
42
|
+
*
|
|
43
|
+
* Keys and values follow the same rule. A quoted string escapes `"`, `\` and
|
|
44
|
+
* every character just listed, so it stays on one line. A key whose written
|
|
45
|
+
* form runs past the 1024 bytes YAML allows an implicit key is written as an
|
|
46
|
+
* explicit one, `? key` and then `: value`.
|
|
40
47
|
*
|
|
41
48
|
* **What it answers.** The YAML text, or `""` when `v` names no value or the
|
|
42
49
|
* tree nests deeper than `JSON_WRITER_MAX_DEPTH` collections, the limit
|
|
@@ -224,9 +231,13 @@ const yamlWriteLength = (text: string, quoted: boolean): i32 => {
|
|
|
224
231
|
|
|
225
232
|
/** Writes one JSON value as block YAML, byte by byte, into `out`. */
|
|
226
233
|
class YamlWriter {
|
|
227
|
-
doc: JsonDocument
|
|
234
|
+
private doc: JsonDocument
|
|
235
|
+
/** @internal Used by `stringifyYaml`. */
|
|
228
236
|
out: u8[]
|
|
229
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Whether a collection nested past `JSON_WRITER_MAX_DEPTH`.
|
|
239
|
+
* @internal Used by `stringifyYaml`.
|
|
240
|
+
*/
|
|
230
241
|
tooDeep: boolean = false
|
|
231
242
|
|
|
232
243
|
constructor(doc: JsonDocument) {
|
|
@@ -234,38 +245,38 @@ class YamlWriter {
|
|
|
234
245
|
this.out = []
|
|
235
246
|
}
|
|
236
247
|
|
|
237
|
-
byte(c: i32): void {
|
|
248
|
+
private byte(c: i32): void {
|
|
238
249
|
this.out.push(toU8(c))
|
|
239
250
|
}
|
|
240
251
|
|
|
241
252
|
/** Writes the bytes of `text` from `from` up to `to`. */
|
|
242
|
-
bytes(text: string, from: i32, to: i32): void {
|
|
253
|
+
private bytes(text: string, from: i32, to: i32): void {
|
|
243
254
|
for (let i: i32 = from; i < to; i += 1) {
|
|
244
255
|
this.byte(yamlWriteByte(text, i))
|
|
245
256
|
}
|
|
246
257
|
}
|
|
247
258
|
|
|
248
|
-
text(text: string): void {
|
|
259
|
+
private text(text: string): void {
|
|
249
260
|
const from: i32 = 0
|
|
250
261
|
this.bytes(text, from, toI32(text.length))
|
|
251
262
|
}
|
|
252
263
|
|
|
253
264
|
/** Writes `count` spaces. */
|
|
254
|
-
spaces(count: i32): void {
|
|
265
|
+
private spaces(count: i32): void {
|
|
255
266
|
for (let i: i32 = 0; i < count; i += 1) {
|
|
256
267
|
this.byte(YAML_WRITE_SPACE)
|
|
257
268
|
}
|
|
258
269
|
}
|
|
259
270
|
|
|
260
271
|
/** Writes `\xXX` for byte `c`. */
|
|
261
|
-
hex(c: i32): void {
|
|
272
|
+
private hex(c: i32): void {
|
|
262
273
|
this.text("\\x")
|
|
263
274
|
this.byte(yamlWriteByte(YAML_WRITE_HEX, c >> 4))
|
|
264
275
|
this.byte(yamlWriteByte(YAML_WRITE_HEX, c & 15))
|
|
265
276
|
}
|
|
266
277
|
|
|
267
278
|
/** Writes the escape for the `length` bytes at `i`, a character yamlWriteEscapedLength names. */
|
|
268
|
-
escape(text: string, i: i32, length: i32): void {
|
|
279
|
+
private escape(text: string, i: i32, length: i32): void {
|
|
269
280
|
const c: i32 = yamlWriteByte(text, i)
|
|
270
281
|
const second: i32 = yamlWriteByte(text, i + 1)
|
|
271
282
|
const third: i32 = yamlWriteByte(text, i + 2)
|
|
@@ -289,7 +300,7 @@ class YamlWriter {
|
|
|
289
300
|
}
|
|
290
301
|
|
|
291
302
|
/** Writes `text` as a double-quoted scalar on one line. */
|
|
292
|
-
quoted(text: string): void {
|
|
303
|
+
private quoted(text: string): void {
|
|
293
304
|
const n: i32 = toI32(text.length)
|
|
294
305
|
this.byte(YAML_WRITE_QUOTE)
|
|
295
306
|
let i: i32 = 0
|
|
@@ -312,7 +323,7 @@ class YamlWriter {
|
|
|
312
323
|
}
|
|
313
324
|
|
|
314
325
|
/** Writes `text` as a scalar: plain when that reads back as the same string, double-quoted otherwise. */
|
|
315
|
-
string(text: string, quoted: boolean): void {
|
|
326
|
+
private string(text: string, quoted: boolean): void {
|
|
316
327
|
if (quoted) {
|
|
317
328
|
this.quoted(text)
|
|
318
329
|
} else {
|
|
@@ -321,13 +332,13 @@ class YamlWriter {
|
|
|
321
332
|
}
|
|
322
333
|
|
|
323
334
|
/** Whether `v` is a collection with members, which takes lines of its own. */
|
|
324
|
-
isBlock(v: JsonValue): boolean {
|
|
335
|
+
private isBlock(v: JsonValue): boolean {
|
|
325
336
|
const kind: i32 = this.doc.kind(v)
|
|
326
337
|
return (kind === JSON_VALUE_ARRAY || kind === JSON_VALUE_OBJECT) && this.doc.length(v) > 0
|
|
327
338
|
}
|
|
328
339
|
|
|
329
340
|
/** Writes `v` on one line: a scalar, `{}` or `[]`. */
|
|
330
|
-
inline(v: JsonValue): void {
|
|
341
|
+
private inline(v: JsonValue): void {
|
|
331
342
|
const doc: JsonDocument = this.doc
|
|
332
343
|
const kind: i32 = doc.kind(v)
|
|
333
344
|
if (kind === JSON_VALUE_NULL) {
|
|
@@ -349,6 +360,7 @@ class YamlWriter {
|
|
|
349
360
|
/**
|
|
350
361
|
* Writes `v` starting at column `indent`, where the line has already reached
|
|
351
362
|
* it, and ends its last line; `depth` is how many collections hold it.
|
|
363
|
+
* @internal Called by `stringifyYaml`.
|
|
352
364
|
*/
|
|
353
365
|
node(v: JsonValue, indent: i32, depth: i32): void {
|
|
354
366
|
const doc: JsonDocument = this.doc
|
|
@@ -397,10 +409,13 @@ class YamlWriter {
|
|
|
397
409
|
}
|
|
398
410
|
|
|
399
411
|
/**
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
* that
|
|
412
|
+
* A value as block YAML text that `parseYaml` reads back as the same tree. See
|
|
413
|
+
* the module comment for the rule that quotes a string.
|
|
414
|
+
*
|
|
415
|
+
* @param doc The document that holds `v`.
|
|
416
|
+
* @param v The value to write, usually the document's root.
|
|
417
|
+
* @returns The text, ending in a line break; `""` when `v` names no value or nests deeper than
|
|
418
|
+
* `JSON_WRITER_MAX_DEPTH` collections.
|
|
404
419
|
*/
|
|
405
420
|
export const stringifyYaml = (doc: JsonDocument, v: JsonValue): string => {
|
|
406
421
|
if (doc.kind(v) === JSON_VALUE_NONE) {
|