@amritk/nish-aarch64-darwin 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/INSTALL.md
CHANGED
|
@@ -155,13 +155,15 @@ tarball's SHA-256 with the release's `SHA256SUMS` (or with the digest pinned
|
|
|
155
155
|
for releases that predate it) and refuses a mismatch. For releases after
|
|
156
156
|
0.21.0 it also checks the release's **build provenance attestation** when a
|
|
157
157
|
signed-in GitHub CLI is present whose `gh attestation verify` takes the
|
|
158
|
-
options below.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
options below.
|
|
159
|
+
|
|
160
|
+
The attestation is a Sigstore-signed statement, made by
|
|
161
|
+
`actions/attest-build-provenance` in the release workflow, that every file in
|
|
162
|
+
`SHA256SUMS` was built by `.github/workflows/release.yml` at the release's tag
|
|
163
|
+
on a GitHub-hosted runner. A failed verification refuses the install; with no
|
|
164
|
+
`gh`, a signed-out one or one too old for those options, the check is skipped
|
|
165
|
+
with a note saying so, and the SHA-256 still applies. The same command by hand,
|
|
166
|
+
on a tarball you downloaded:
|
|
165
167
|
|
|
166
168
|
```bash
|
|
167
169
|
gh attestation verify nish-<version>-<asset>.tar.gz \
|
|
@@ -405,11 +407,13 @@ header — and `runtime/sqlite/`, SQLite's vendored source),
|
|
|
405
407
|
`docs/AI.md` (the rules card). The
|
|
406
408
|
compiler itself is not in it: it arrives as one prebuilt
|
|
407
409
|
`@amritk/nish-<asset>` package per platform, and `bin/nish` hands over to
|
|
408
|
-
whichever one npm installed.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
410
|
+
whichever one npm installed.
|
|
411
|
+
|
|
412
|
+
That package carries its own copy of all of these, and its `docs/AI.md` is the
|
|
413
|
+
one an agent's `nish --help` names. `nish` locates the runtime, the script and
|
|
414
|
+
`std/` relative to its own install directory, so a global install works from
|
|
415
|
+
any working directory — and the binary runs from inside its own platform
|
|
416
|
+
package for exactly that reason.
|
|
413
417
|
|
|
414
418
|
Building the IR yourself rather than through `--link` means naming the runtime
|
|
415
419
|
on the `clang` line, and it is sixteen files:
|
|
@@ -425,26 +429,31 @@ clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
|
|
|
425
429
|
`runtime.c` is the part every program touches — the arena, strings, arrays,
|
|
426
430
|
number formatting, the panics — and `runtime-os.c` wraps the system calls:
|
|
427
431
|
files, directories, subprocesses, `getenv`, the monotonic clock.
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
`runtime-
|
|
435
|
-
`runtime-
|
|
436
|
-
blocks to on a CPU with the
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
`
|
|
441
|
-
|
|
442
|
-
`runtime-
|
|
443
|
-
`runtime-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
432
|
+
|
|
433
|
+
`runtime-parallel.c` divides work across threads for `nish/threads` (a program
|
|
434
|
+
built with `--threads`, as every importer of `nish/threads` is, also needs
|
|
435
|
+
`-DNISH_THREADS=1 -pthread` on the line), `runtime-cross.c` copies the strings
|
|
436
|
+
and arrays a task answers, a channel sends or a `Mutex` keeps out of the arena
|
|
437
|
+
they were made in, `runtime-host.c` holds the wall clock, entropy, file times
|
|
438
|
+
and signals, `runtime-net.c` the sockets of `nish:net`, `runtime-simd.c` and
|
|
439
|
+
`runtime-aes.c` the vector text search and AES-GCM, `runtime-sha256.c` the
|
|
440
|
+
SHA-256 block kernel `nish/crypto/sha256` hands its blocks to on a CPU with the
|
|
441
|
+
SHA instructions (`NISH_SHA256=soft` keeps the portable path),
|
|
442
|
+
`runtime-chacha20.c` the ChaCha20 keystream `nish/crypto/chacha20poly1305`
|
|
443
|
+
hands a message of 256 bytes or more to on a CPU with AVX2 or NEON
|
|
444
|
+
(`NISH_CHACHA20=soft` keeps the portable path), `runtime-term.c` the stdin
|
|
445
|
+
reads and terminal calls of `nish:term`, `runtime-bytes.c` the byte-class runs
|
|
446
|
+
of `nish/bytes`, which `nish/json` steps over, `runtime-checksum.c` the CRC-32
|
|
447
|
+
kernels of `nish/compress/checksum`, `runtime-sandbox.c` the confinement a
|
|
448
|
+
`--sandbox` build applies, and `runtime-shm.c` the shared-memory regions of
|
|
449
|
+
`nish/sync/shm`. They are separate so that each carries its own measured size
|
|
450
|
+
ceiling
|
|
451
|
+
([docs/wp7-runtime.md](https://github.com/amritk/nish/blob/main/docs/wp7-runtime.md));
|
|
452
|
+
nothing in the core calls into the others, so a line that names only
|
|
453
|
+
`runtime.c` and `runtime-os.c` still links a program that uses none of the
|
|
454
|
+
other nine.
|
|
455
|
+
|
|
456
|
+
`scripts/build.sh` compiles the other
|
|
448
457
|
nine beside any
|
|
449
458
|
`runtime.c` it is handed, so a build that goes through it — every `--link`,
|
|
450
459
|
and every `--profile` recipe in these documents — needs to name only the one.
|
|
@@ -473,19 +482,19 @@ The seed builds stage1, stage1 builds stage2, and stage2 is installed as
|
|
|
473
482
|
own IR is only reported beside them, because a codegen change since the
|
|
474
483
|
release is expected to move it. `--stages 1` stops one link sooner.
|
|
475
484
|
|
|
476
|
-
`build/nish` is then the compiler you run: it takes the same `-o`, `--link`
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
`
|
|
485
|
-
`
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
485
|
+
`build/nish` is then the compiler you run: it takes the same `-o`, `--link` and
|
|
486
|
+
`--profile` spellings as an installed `nish`, because it is the same program,
|
|
487
|
+
and makes every directory in the way of the IR, a sidecar or the binary itself.
|
|
488
|
+
It looks for `scripts/build.sh` and the `runtime/*.c` files one level up from
|
|
489
|
+
wherever it was invoked (and one level up from the file a symbolic link to it
|
|
490
|
+
names), so it wants a checkout or an installed package around it the way `nish`
|
|
491
|
+
does. It falls back to the working directory only when the compiler itself lies
|
|
492
|
+
inside that directory, so a checkout you merely `cd` into cannot hand it a
|
|
493
|
+
`scripts/build.sh` to run. Keep `bin/nish` beside `scripts/`, `runtime/` and
|
|
494
|
+
`std/`, as every install above does, and keep that directory's parent writable
|
|
495
|
+
only by you: the package root is the parent of the compiler's directory, so a
|
|
496
|
+
compiler at `/tmp/x/nish` would trust `/tmp/scripts/build.sh` (CLI-9 in
|
|
497
|
+
[docs/security/cli.md](security/cli.md)).
|
|
489
498
|
|
|
490
499
|
Because the seed is the last release, `src/` may only *use* in its own
|
|
491
500
|
source the constructs that release compiles. A new construct is implemented
|
|
@@ -537,24 +546,24 @@ nish run hello.ts
|
|
|
537
546
|
`nish run [options] <file.ts> [args ...]` compiles the file, links it into
|
|
538
547
|
`$XDG_CACHE_HOME/nish/run` (or `~/.cache/nish/run`) when that program has not
|
|
539
548
|
been linked before, and starts it with the arguments after the file. The first
|
|
540
|
-
run of a new edit pays for one link, and later runs start the cached binary.
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
run of a new edit pays for one link, and later runs start the cached binary. It
|
|
550
|
+
needs clang only for that link. It needs `HOME` or `XDG_CACHE_HOME` set to an
|
|
551
|
+
absolute path (a relative one is ignored, as if it were unset), and refuses the
|
|
552
|
+
run without one rather than keep a binary in a shared directory. The first run
|
|
553
|
+
that builds into the cache makes its root `0700`, so no other user can plant a
|
|
554
|
+
binary in it ([docs/security/cli.md](security/cli.md)).
|
|
546
555
|
|
|
547
556
|
Every link with the debug, speed or size profile, `nish run`'s and `--link`'s
|
|
548
557
|
alike, keeps the compiled C runtime in `$XDG_CACHE_HOME/nish/runtime` (or
|
|
549
558
|
`~/.cache/nish/runtime`), one entry per profile, `-g`, `--threads`, `CC` and
|
|
550
559
|
the version that compiler reports, made `0700` the same way. The first link
|
|
551
|
-
compiles the runtime's six files at once into it, and every later link
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
560
|
+
compiles the runtime's six files at once into it, and every later link compiles
|
|
561
|
+
only the program's modules, also at once, and links against the entry: a
|
|
562
|
+
`hello.ts` debug link goes from about half a second to about a tenth. `--link`
|
|
563
|
+
with no absolute `HOME` or `XDG_CACHE_HOME`, or with a root it cannot make
|
|
564
|
+
private, compiles the runtime itself as it always did; the wasi profile and
|
|
565
|
+
`scripts/build.sh` called directly never use the cache. Removing the directory
|
|
566
|
+
is always safe.
|
|
558
567
|
|
|
559
568
|
<a id="4-exit-codes" style="scroll-margin-top: 65px"></a>
|
|
560
569
|
|
package/bin/nish
CHANGED
|
Binary file
|
package/docs/AI.md
CHANGED
|
@@ -1484,8 +1484,8 @@ export const main = (): i32 => {
|
|
|
1484
1484
|
`--target`** (NL2666; `--target wasm32-wasi` keeps it): there a function the page
|
|
1485
1485
|
supplies is imported from a host module, the page's own TypeScript file
|
|
1486
1486
|
named by `--host`, and becomes a wasm import from module `host`. Only
|
|
1487
|
-
scalars, enums
|
|
1488
|
-
page keeps) cross; `import { Canvas, fill } from "./host.ts"`, no `type`
|
|
1487
|
+
scalars, enums, `HostHandle<"kind">` (a nominal `i32` for an object the
|
|
1488
|
+
page keeps) and buffer windows (an array, then `at: u32, n: u32`) cross; `import { Canvas, fill } from "./host.ts"`, no `type`
|
|
1489
1489
|
modifier.
|
|
1490
1490
|
- **A class with a `CPtr` field is a handle class: open one with `using`.**
|
|
1491
1491
|
`using f = new File(p)` closes `f` once at every exit of its block (falling
|
|
@@ -1520,12 +1520,51 @@ emitted and no initialiser runs** — every use lowers to the value itself.
|
|
|
1520
1520
|
array, class or interface constant would need an allocation, and there is no
|
|
1521
1521
|
code to run it.
|
|
1522
1522
|
- The initialiser is literals, other constants (declared anywhere, or
|
|
1523
|
-
imported), and arithmetic over them. A call, a
|
|
1524
|
-
|
|
1523
|
+
imported), and arithmetic over them. A call, a local — anything else — is
|
|
1524
|
+
rejected. The one `new` allowed is module storage, below.
|
|
1525
1525
|
- Folding uses the language's own arithmetic, so an overflowing fold is an
|
|
1526
1526
|
error rather than a wrap, and `1 / 0` in a constant is refused at compile
|
|
1527
1527
|
time.
|
|
1528
1528
|
|
|
1529
|
+
### Module storage
|
|
1530
|
+
|
|
1531
|
+
```ts nish:ok
|
|
1532
|
+
const SCORES = new Int32Array(4);
|
|
1533
|
+
|
|
1534
|
+
const sum = (xs: Int32Array): i32 => {
|
|
1535
|
+
let total: i32 = 0;
|
|
1536
|
+
for (let i = 0; i < xs.length; i++) {
|
|
1537
|
+
total += xs[i];
|
|
1538
|
+
}
|
|
1539
|
+
return total;
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
export const main = (): i32 => {
|
|
1543
|
+
SCORES[0] = 30;
|
|
1544
|
+
SCORES[3] = 4;
|
|
1545
|
+
console.log(`${sum(SCORES)} ${SCORES[1]}`); // 34 0
|
|
1546
|
+
return 0;
|
|
1547
|
+
};
|
|
1548
|
+
```
|
|
1549
|
+
|
|
1550
|
+
A top-level `const` holding `new Array<T>(n)` or a typed-array `new` of a
|
|
1551
|
+
constant length is **module storage**: a static, zero-filled array that keeps
|
|
1552
|
+
its values between calls, with no initialiser that runs. It is the only
|
|
1553
|
+
state a module keeps (there is no top-level `let`).
|
|
1554
|
+
|
|
1555
|
+
- The length is a constant from 1 to 16,777,216, at most 256 MiB in all. The element is pointer-free:
|
|
1556
|
+
a number, `boolean`, an enum or range whose zero is a member, a
|
|
1557
|
+
`HostHandle`, or an interface no class implements with fields of those.
|
|
1558
|
+
- **It never grows or moves**: no method call on it (`push`, `pop`, `sort`,
|
|
1559
|
+
NL2688) and no `length =`. Keep a count beside it.
|
|
1560
|
+
- **Its name is a place, not a value**: index it and read `length`; never bind,
|
|
1561
|
+
store or return it. Lend it only to a parameter spelled with a typed-array
|
|
1562
|
+
name (`xs: Int32Array`) or to a host function's buffer window. A record
|
|
1563
|
+
element is a place too: `bodies[i].x = 1` and `bodies[i] = bodies[j]` are
|
|
1564
|
+
fine, `const b = bodies[i]` is refused; pass the index.
|
|
1565
|
+
- Under `--profile wasm-host` the page reads and writes it through `layout`
|
|
1566
|
+
and `views()` in the `.d.ts`. The rules: `LANGUAGE.md` → "Module storage".
|
|
1567
|
+
|
|
1529
1568
|
### Classes and interfaces
|
|
1530
1569
|
|
|
1531
1570
|
```ts nish:ok
|
package/package.json
CHANGED
package/runtime/async.d.mts
CHANGED
|
@@ -45,5 +45,7 @@ export declare function awaitAll<A, B, C, D, E, F, G, H>(
|
|
|
45
45
|
g: Promise<G>,
|
|
46
46
|
h: Promise<H>,
|
|
47
47
|
): Promise<[A, B, C, D, E, F, G, H]>;
|
|
48
|
+
/** `true` once `ms` milliseconds have passed; `false` at once for a negative `ms`. */
|
|
49
|
+
export declare function sleep(ms: number): Promise<boolean>;
|
|
48
50
|
/** Waits for every task `spawn` started, the tasks those tasks start included. */
|
|
49
51
|
export declare function settleTasks(): Promise<void>;
|
package/runtime/async.mjs
CHANGED
|
@@ -19,6 +19,13 @@ export const spawn = (task) => {
|
|
|
19
19
|
|
|
20
20
|
export const awaitAll = (...tasks) => Promise.all(tasks);
|
|
21
21
|
|
|
22
|
+
// `sleep` is a timer: `true` once `ms` milliseconds have passed, `false` for a
|
|
23
|
+
// negative `ms`, as natively. `readable` and `writable` have no counterpart in
|
|
24
|
+
// Node, whose descriptors are not polled from JavaScript, so `--emit-ts`
|
|
25
|
+
// refuses them (NL4017) and this file does not export them.
|
|
26
|
+
export const sleep = (ms) =>
|
|
27
|
+
ms < 0 ? Promise.resolve(false) : new Promise((resolve) => setTimeout(() => resolve(true), ms));
|
|
28
|
+
|
|
22
29
|
export const settleTasks = async () => {
|
|
23
30
|
for (let i = 0; i < pending.length; i++) {
|
|
24
31
|
await pending[i];
|