@amritk/nish-aarch64-linux 0.36.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/INSTALL.md +67 -58
- package/bin/nish +0 -0
- package/docs/AI.md +43 -4
- package/package.json +1 -1
- package/runtime/async.d.mts +2 -0
- package/runtime/async.mjs +7 -0
- package/runtime/nish.d.ts +736 -499
- 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/scripts/build.sh +147 -5
- package/std/README.md +107 -82
- package/std/bytes.ts +23 -19
- package/std/compress/checksum.ts +1 -1
- package/std/crypto/aes.ts +48 -43
- package/std/crypto/base64url.ts +7 -5
- package/std/crypto/bcrypt-batch.ts +13 -13
- package/std/crypto/bcrypt.ts +33 -27
- package/std/crypto/chacha20poly1305.ts +16 -14
- package/std/crypto/ed25519.ts +19 -16
- package/std/crypto/hmac.ts +7 -6
- package/std/crypto/jwt.ts +23 -20
- package/std/crypto/p256.ts +63 -56
- package/std/crypto/p384.ts +23 -20
- package/std/crypto/pki.ts +18 -15
- package/std/crypto/rsa.ts +23 -19
- package/std/crypto/x25519.ts +11 -10
- package/std/crypto/x509.ts +69 -62
- package/std/host/ring.ts +124 -0
- package/std/json-equal.ts +12 -11
- package/std/json-number.ts +12 -12
- package/std/json-tokenizer.ts +26 -22
- package/std/json-typed.ts +92 -78
- package/std/json-value.ts +38 -33
- package/std/json.ts +32 -28
- package/std/net/fetch.ts +1117 -230
- package/std/net/handler.ts +18 -0
- package/std/net/hpack.ts +29 -26
- package/std/net/http-compress.ts +27 -21
- package/std/net/http1-client-codec.ts +29 -25
- package/std/net/http1-codec.ts +44 -87
- package/std/net/http1-server.ts +66 -54
- package/std/net/http2-frame.ts +17 -16
- package/std/net/http2-tls.ts +17 -15
- package/std/net/http2.ts +67 -54
- package/std/net/http3-frame.ts +11 -10
- package/std/net/http3-server.ts +36 -35
- package/std/net/http3.ts +70 -58
- package/std/net/postgres.ts +178 -160
- package/std/net/prefork.ts +38 -34
- package/std/net/qpack.ts +15 -14
- package/std/net/quic-conn-ack.ts +1 -0
- package/std/net/quic-conn-cid.ts +11 -0
- package/std/net/quic-conn-params.ts +41 -14
- package/std/net/quic-datagram.ts +7 -0
- package/std/net/quic-frame.ts +48 -12
- package/std/net/quic-listener.ts +61 -44
- package/std/net/quic-packet.ts +71 -52
- package/std/net/quic-recovery.ts +59 -21
- package/std/net/quic-stream.ts +83 -55
- package/std/net/quic.ts +204 -152
- package/std/net/tls/client.ts +1 -0
- package/std/net/tls/codec.ts +81 -12
- package/std/net/tls/record-client.ts +30 -18
- package/std/net/tls/record-server.ts +74 -46
- package/std/net/tls/record.ts +33 -24
- package/std/net/tls/ticket.ts +2 -0
- package/std/net/tls/verify.ts +8 -7
- package/std/net/tls-tcp.ts +58 -50
- package/std/net/tls.ts +55 -43
- package/std/net/url.ts +12 -9
- package/std/net/websocket.ts +23 -19
- package/std/net/webtransport.ts +24 -18
- package/std/random.ts +8 -6
- package/std/regex.ts +70 -59
- package/std/sync/ring.ts +24 -21
- package/std/sync/shm.ts +9 -7
- package/std/term-io.ts +17 -14
- package/std/term-probe.ts +11 -10
- package/std/term-rate.ts +71 -61
- package/std/term.ts +73 -59
- package/std/text.ts +11 -10
- package/std/threads.ts +19 -15
- package/std/yaml-json.ts +17 -15
- package/std/yaml-write.ts +21 -14
package/std/term.ts
CHANGED
|
@@ -79,33 +79,40 @@
|
|
|
79
79
|
* sends no releases, so while `releasesAreSynthetic` is set (until the first
|
|
80
80
|
* real release) a key counts as let go when its repeats stop: `firstRepeatMs`
|
|
81
81
|
* (700 ms) after a press that has not repeated and `releaseGapMs` (100 ms)
|
|
82
|
-
* after its last repeat.
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* the
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
82
|
+
* after its last repeat.
|
|
83
|
+
*
|
|
84
|
+
* Silence is measured in stream time when the caller has one: term-io sends an
|
|
85
|
+
* in-order query after each frame and calls `delivered` with the send time of
|
|
86
|
+
* each one answered, since by then everything the terminal generated before it
|
|
87
|
+
* has arrived. Measured that way a stall, a burst or jittery reads delay the
|
|
88
|
+
* watermark as much as the keys, so a held key never flickers and a tap comes
|
|
89
|
+
* up 700 ms plus one round trip after its press.
|
|
90
|
+
*
|
|
91
|
+
* With no watermark yet, silence is wall-clock time between `apply`s, which a
|
|
92
|
+
* link that reads in bursts more than `releaseGapMs` apart can mistake for a
|
|
93
|
+
* key let go. While acks stop, nothing is released: there is no wall-clock
|
|
94
|
+
* backstop, and a caller that stops getting answers clears `watermarked` to
|
|
95
|
+
* fall back to the wall clock. term-io does so once 1000 ms pass with no query
|
|
96
|
+
* answered, frames sent or not, which no working link reaches while it draws.
|
|
97
|
+
*
|
|
98
|
+
* Within one read the caller `apply`s its events before calling `delivered` for
|
|
99
|
+
* the answer it carries: a `tick` between the two would judge keys against a
|
|
100
|
+
* watermark that already covers repeats not yet applied, and report a release
|
|
101
|
+
* and then a press. A non-finite time is ignored. Under X11 and Windows only
|
|
102
|
+
* the last key pressed auto-repeats, so holding W and then pressing D lets W go
|
|
103
|
+
* `releaseGapMs` after its last repeat.
|
|
104
|
+
*
|
|
105
|
+
* A real release of a key not down is dropped, so one arriving after its key
|
|
106
|
+
* was made up as released is not reported twice. Under kitty a real release
|
|
107
|
+
* that is lost leaves its key down until focus is lost, and for good without
|
|
108
|
+
* focus reporting. A key the batch `apply` takes names stays down. A made-up
|
|
109
|
+
* release carries the code and modifiers the key last came with. Losing focus
|
|
110
|
+
* lets every key go, and Ctrl-C becomes `EVENT_QUIT` while `quitOnCtrlC` is
|
|
111
|
+
* set.
|
|
112
|
+
*
|
|
113
|
+
* Under the kitty protocol a non-Latin layout sends Ctrl-C as its own letter
|
|
114
|
+
* (`ESC [ 1089 ; 5 u` for Russian С), which is not read as a quit: the
|
|
115
|
+
* base-layout key that flag 4 (report alternate keys) adds is not read yet.
|
|
109
116
|
*
|
|
110
117
|
* **The same bytes under Node.** Natively a string is UTF-8 bytes, and `flush`
|
|
111
118
|
* builds its answer as bytes and makes one string of them. Under Node a string
|
|
@@ -114,10 +121,11 @@
|
|
|
114
121
|
* way, which `tests/run.js` checks ("nish/term prints the same bytes under
|
|
115
122
|
* runtime/nish.mjs"). `text` reads a string's code points as UTF-8 natively and
|
|
116
123
|
* as UTF-16 under Node, so a string literal draws the same cells both ways.
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
124
|
+
*
|
|
125
|
+
* A `TermEvent`'s `text` is made from bytes the terminal sent: natively it
|
|
126
|
+
* holds them as they came, and under Node they are decoded as UTF-8 without
|
|
127
|
+
* checking, so malformed UTF-8 in a paste or reply can differ between the two.
|
|
128
|
+
* Integer division is spelled `(a / b) | 0`, which truncates in both.
|
|
121
129
|
*/
|
|
122
130
|
|
|
123
131
|
/** The terminal's own colour, foreground or background: SGR 39 and 49. */
|
|
@@ -902,11 +910,12 @@ export class Screen {
|
|
|
902
910
|
* otherwise — and a gap of up to three unchanged ASCII cells in the current
|
|
903
911
|
* style is rewritten instead, which is shorter than the move. A style is sent
|
|
904
912
|
* only when it differs from the previous cell's, and only the parts that
|
|
905
|
-
* differ, from a reset when an attribute has to be turned off.
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
*
|
|
913
|
+
* differ, from a reset when an attribute has to be turned off.
|
|
914
|
+
*
|
|
915
|
+
* A flush that leaves the terminal in a style other than the default ends
|
|
916
|
+
* with `ESC [ 0 m`, so what the caller writes next starts plain. With `sync`
|
|
917
|
+
* set, a flush that changes anything is wrapped in `beginSync` and `endSync`,
|
|
918
|
+
* in the same string, so the terminal paints the frame whole.
|
|
910
919
|
*
|
|
911
920
|
* @returns The escapes and glyphs, to `write`; `""` when nothing changed.
|
|
912
921
|
*/
|
|
@@ -1361,16 +1370,18 @@ export class TermEvent {
|
|
|
1361
1370
|
}
|
|
1362
1371
|
|
|
1363
1372
|
/**
|
|
1364
|
-
* Bytes from a terminal in raw mode, turned into key events. A read can end
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1373
|
+
* Bytes from a terminal in raw mode, turned into key events. A read can end in
|
|
1374
|
+
* the middle of an escape sequence or a UTF-8 character; the decoder keeps the
|
|
1375
|
+
* start and finishes it with the next `feed`. An ESC on its own is both the
|
|
1367
1376
|
* escape key and the start of every arrow, so it is held until either more
|
|
1368
1377
|
* bytes complete a sequence or `escapeTimeoutMs` passes with none, and then it
|
|
1369
|
-
* is `KEY_ESCAPE`.
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1378
|
+
* is `KEY_ESCAPE`.
|
|
1379
|
+
*
|
|
1380
|
+
* Whatever is held past the timeout is given up the same way: the ESC as
|
|
1381
|
+
* `KEY_ESCAPE`, the bytes after it as keys of their own, and an unfinished
|
|
1382
|
+
* UTF-8 character as U+FFFD. The clock is the caller's: each call takes the
|
|
1383
|
+
* time now in milliseconds, from any origin, so long as it does not go
|
|
1384
|
+
* backwards.
|
|
1374
1385
|
*
|
|
1375
1386
|
* `feedEvents` and `pollEvents` decode the same bytes into `TermEvent`s
|
|
1376
1387
|
* instead: keys with their modifiers and press, repeat or release, the mouse,
|
|
@@ -1551,21 +1562,24 @@ export class KeyDecoder {
|
|
|
1551
1562
|
/**
|
|
1552
1563
|
* Which keys are down, from the events a `KeyDecoder` made — what a game asks
|
|
1553
1564
|
* each frame. Under the kitty protocol with event types (flag 2) a terminal
|
|
1554
|
-
* sends real releases. Without it a terminal sends nothing when a key comes
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1560
|
-
*
|
|
1561
|
-
*
|
|
1562
|
-
*
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
*
|
|
1565
|
+
* sends real releases. Without it a terminal sends nothing when a key comes up,
|
|
1566
|
+
* only the press again as it auto-repeats, so a key is let go once its repeats
|
|
1567
|
+
* stop: `releaseGapMs` after its last repeat, and `firstRepeatMs` after a press
|
|
1568
|
+
* that has not repeated.
|
|
1569
|
+
*
|
|
1570
|
+
* The system waits before its first repeat — 660 ms under X11 by default, 500
|
|
1571
|
+
* under Windows, shorter under macOS — and repeats every 30–40 ms; a longer
|
|
1572
|
+
* delay needs `firstRepeatMs` raised, and a slower rate `releaseGapMs`. Input
|
|
1573
|
+
* arrives late and in bursts (over SSH, reads 150–250 ms apart are usual), so
|
|
1574
|
+
* when the reads alone are known the silence is not: a caller that sends
|
|
1575
|
+
* in-order queries calls `delivered(sentAtMs)` as each is answered, and silence
|
|
1576
|
+
* is then measured against that watermark rather than the clock.
|
|
1577
|
+
*
|
|
1578
|
+
* A key last seen in a read at `A` is let go once the watermark reaches `A +
|
|
1579
|
+
* gap`: had it still been down, the terminal would have generated a repeat
|
|
1580
|
+
* before then, and it would have arrived ahead of the answer. Until the first
|
|
1581
|
+
* `delivered`, and after the caller clears `watermarked`, the gap is measured
|
|
1582
|
+
* against `nowMs`. Pure, with the caller's clock, as `KeyDecoder` is.
|
|
1569
1583
|
*/
|
|
1570
1584
|
export class KeyState {
|
|
1571
1585
|
/** How long after its last repeat a key is let go, in milliseconds (100 by default). */
|
package/std/text.ts
CHANGED
|
@@ -373,16 +373,17 @@ const textUnitsAreBytes = (): boolean => toI32("\u00e9".length) === 2
|
|
|
373
373
|
* rule would miscount: `"©®±"` is three units in `0x80`–`0xBF`, which are
|
|
374
374
|
* continuation bytes in UTF-8 but whole characters here. So the function asks
|
|
375
375
|
* which host it is on (`textUnitsAreBytes`) and, under Node, counts every unit
|
|
376
|
-
* except the low half of a surrogate pair.
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* unit
|
|
381
|
-
*
|
|
382
|
-
* that
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
376
|
+
* except the low half of a surrogate pair.
|
|
377
|
+
*
|
|
378
|
+
* Both walks answer the same for any string literal, a lone surrogate escape
|
|
379
|
+
* included: it is three WTF-8 bytes with one leading byte natively, and one
|
|
380
|
+
* unit under Node. They differ for text built from bytes: `String.fromBytes`
|
|
381
|
+
* and `String.fromCharCode` give one unit per byte under Node, so a string
|
|
382
|
+
* decoded that way, as `nish/json` decodes a `\u` escape, counts its UTF-8
|
|
383
|
+
* bytes there. They also differ for text that is not well-formed — bytes that
|
|
384
|
+
* are not UTF-8 natively, where each stray continuation byte counts nothing, or
|
|
385
|
+
* the two halves of a pair joined at run time, which are one string under Node
|
|
386
|
+
* and two lone surrogates natively.
|
|
386
387
|
*
|
|
387
388
|
* @param text The text whose code points are counted.
|
|
388
389
|
* @returns How many code points `text` holds, counted as above.
|
package/std/threads.ts
CHANGED
|
@@ -34,17 +34,18 @@
|
|
|
34
34
|
* };
|
|
35
35
|
*
|
|
36
36
|
* **What is written here is the meaning, not the implementation.** Each body
|
|
37
|
-
* below is the sequential program, and it is what runs under Node, what
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* `
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* are this file's,
|
|
37
|
+
* below is the sequential program, and it is what runs under Node, what `npm
|
|
38
|
+
* run check` type-checks, and what the compiler checks the call against.
|
|
39
|
+
*
|
|
40
|
+
* The compiler then recognises the exported templates by module and name and
|
|
41
|
+
* lowers an instance of `parallelMapInto`, `parallelFrom` or `parallelReduce`
|
|
42
|
+
* onto `nish_parallel_range` (runtime/runtime-parallel.c): it replaces the one
|
|
43
|
+
* call that walks the whole range — `mapRange` for a map, `fromRange` for a
|
|
44
|
+
* `parallelFrom`, `reduceBlocks` for a reduce — with a region that hands each
|
|
45
|
+
* thread a contiguous piece of it, and emits the rest of the body as written.
|
|
46
|
+
* `parallelMap` is `parallelMapInto` into an array it allocates first. So the
|
|
47
|
+
* length check, its message and the order a reduce combines in are this file's,
|
|
48
|
+
* whichever way the program is compiled.
|
|
48
49
|
*
|
|
49
50
|
* **What makes the region safe is checked at the call, not trusted**
|
|
50
51
|
* (docs/LANGUAGE.md, "Data parallelism"): the function passed as `f` may write
|
|
@@ -52,10 +53,13 @@
|
|
|
52
53
|
* before it returns — they are given back after every element — `dst` may not
|
|
53
54
|
* be reachable from an element of `src`, and the result type is a number, a
|
|
54
55
|
* `boolean` or an enum — or, for a map, a `string` or an array of those
|
|
55
|
-
* scalars, which the join copies out of the worker's arena.
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
56
|
+
* scalars, which the join copies out of the worker's arena.
|
|
57
|
+
*
|
|
58
|
+
* An arrow written at the call may read the `const` locals and the parameters
|
|
59
|
+
* of the function it is written in: each one is handed to the body as a
|
|
60
|
+
* parameter of its own, which no body may write through. Importing this module
|
|
61
|
+
* compiles the program with `--threads`, because every worker needs an arena of
|
|
62
|
+
* its own.
|
|
59
63
|
*
|
|
60
64
|
* **A reduce is deterministic.** `src` is split into `min(64, ceil(n / BLOCK))`
|
|
61
65
|
* blocks, each block is folded from `identity`, and the block results are
|
package/std/yaml-json.ts
CHANGED
|
@@ -43,21 +43,23 @@
|
|
|
43
43
|
* the alias's range, where it is used.
|
|
44
44
|
*
|
|
45
45
|
* **An alias bomb is refused before anything is built.** The values the
|
|
46
|
-
* document expands to are counted first, from the nodes, with each node's
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
46
|
+
* document expands to are counted first, from the nodes, with each node's count
|
|
47
|
+
* kept, so the count costs one step per node however far the aliases multiply
|
|
48
|
+
* it. Past the document's `maxValues` the load is `YAML_JSON_ERR_EXPANSION`, at
|
|
49
|
+
* the first alias whose copy is the largest (the first whose copy alone is past
|
|
50
|
+
* the limit, in a bomb), or `JSON_VALUE_ERR_VALUES` when the document has no
|
|
51
|
+
* alias.
|
|
52
|
+
*
|
|
53
|
+
* A merged map counts all its keys, also those the merging map overrides, so a
|
|
54
|
+
* document within a few values of the limit can be refused for merges that
|
|
55
|
+
* would have fit. The loader's merging is linear too: a map is merged into a
|
|
56
|
+
* given map at most once, however many paths through the merge keys reach it,
|
|
57
|
+
* and the pairs every merge visits and the items of every merge sequence it
|
|
58
|
+
* walks are charged to a budget of `maxValues` plus the stream's node count,
|
|
59
|
+
* past which the load is `YAML_JSON_ERR_EXPANSION` at the merge key.
|
|
60
|
+
*
|
|
61
|
+
* `parseYaml`'s own merge check is not bounded this way: it walks a shared
|
|
62
|
+
* merge sequence once for each merge key that names it.
|
|
61
63
|
*
|
|
62
64
|
* **A merge key's value** is a mapping, an alias to one, or a sequence of
|
|
63
65
|
* those; anything else is refused at the value, by the parser as
|
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
|