nish 0.37.0 → 0.39.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 (79) hide show
  1. package/README.md +10 -8
  2. package/docs/AI.md +380 -47
  3. package/docs/INSTALL.md +28 -16
  4. package/package.json +8 -7
  5. package/runtime/core/arrays.d.ts +4 -0
  6. package/runtime/core/arrays.mjs +33 -0
  7. package/runtime/core/host.d.ts +11 -0
  8. package/runtime/core/host.mjs +35 -0
  9. package/runtime/nish.d.ts +645 -66
  10. package/runtime/nish.h +101 -15
  11. package/runtime/nish.mjs +69 -6
  12. package/runtime/node.mjs +117 -0
  13. package/runtime/runtime-aes.c +12 -4
  14. package/runtime/runtime-async.c +267 -51
  15. package/runtime/runtime-checksum.c +207 -15
  16. package/runtime/runtime-cross.c +2 -1
  17. package/runtime/runtime-net.c +32 -3
  18. package/runtime/runtime-os.c +174 -27
  19. package/runtime/runtime-region.c +170 -8
  20. package/runtime/runtime-sandbox.c +377 -17
  21. package/runtime/runtime-sha256.c +11 -4
  22. package/runtime/runtime-text.c +1068 -0
  23. package/runtime/runtime-wasm.c +18 -3
  24. package/runtime/runtime.c +55 -961
  25. package/runtime/vite.mjs +48 -11
  26. package/scripts/build.sh +113 -36
  27. package/scripts/fuzz.sh +58 -8
  28. package/scripts/gen-pow10-table.py +1 -1
  29. package/scripts/postinstall.mjs +8 -7
  30. package/scripts/shard-costs.mjs +429 -0
  31. package/scripts/size-report.sh +2 -2
  32. package/scripts/smoke.sh +12 -2
  33. package/std/LICENSE-fdlibm +8 -0
  34. package/std/README.md +7 -4
  35. package/std/array.ts +266 -0
  36. package/std/compress/checksum.ts +13 -0
  37. package/std/compress/deflate.ts +0 -2
  38. package/std/crypto/p256.ts +247 -74
  39. package/std/crypto/p384.ts +3 -1
  40. package/std/crypto/pki.ts +35 -9
  41. package/std/crypto/x25519.ts +153 -64
  42. package/std/crypto/x509.ts +113 -10
  43. package/std/host/text.ts +86 -0
  44. package/std/json-tokenizer.ts +20 -0
  45. package/std/json-typed.ts +217 -8
  46. package/std/math.ts +743 -41
  47. package/std/net/dns-resolver.ts +46 -6
  48. package/std/net/dns.ts +50 -13
  49. package/std/net/fetch.ts +691 -129
  50. package/std/net/handler.ts +142 -16
  51. package/std/net/http-compress.ts +17 -9
  52. package/std/net/http-fields.ts +19 -4
  53. package/std/net/http1-codec.ts +517 -154
  54. package/std/net/http1-server.ts +508 -25
  55. package/std/net/http2-cleartext.ts +526 -0
  56. package/std/net/http2-tls.ts +48 -0
  57. package/std/net/http2.ts +84 -0
  58. package/std/net/postgres-async.ts +2223 -0
  59. package/std/net/postgres-carrier.ts +343 -10
  60. package/std/net/postgres.ts +129 -11
  61. package/std/net/prefork.ts +195 -11
  62. package/std/net/quic-datagram.ts +30 -0
  63. package/std/net/quic-listener.ts +38 -12
  64. package/std/net/quic-packet.ts +19 -6
  65. package/std/net/quic-recovery.ts +134 -19
  66. package/std/net/quic-stream.ts +174 -36
  67. package/std/net/quic.ts +418 -18
  68. package/std/net/router.ts +39 -17
  69. package/std/net/serve.ts +867 -0
  70. package/std/net/tls/codec.ts +110 -32
  71. package/std/net/tls/record-server.ts +37 -7
  72. package/std/net/tls-tcp.ts +56 -1
  73. package/std/net/tls.ts +196 -50
  74. package/std/net/websocket.ts +55 -18
  75. package/std/net/webtransport.ts +179 -1
  76. package/std/regex.ts +69 -47
  77. package/std/region.ts +62 -11
  78. package/std/secret.ts +26 -59
  79. package/std/text.ts +464 -5
package/README.md CHANGED
@@ -175,7 +175,7 @@ ship in the npm package, and [llms.txt](llms.txt) indexes them.
175
175
  | Control flow | `if`/`else`, `while`, `do`, `for`, `for...of` (arrays, `Map` keys and values, `Set`), `switch` (exhaustive over a union's tag, a clause may fall into the next), `break`/`continue`, labelled or not, boolean-only conditions, definite return, unreachable-code errors | [Statements](docs/LANGUAGE.md#statements) |
176
176
  | Expressions | `+ - * / %` (integer `/` and `%` checked: zero divisor or `MIN / -1` panics), shifts and bitwise operators, numeric-only ordering, `=== !==` (strings by content), `&& \|\|`, `?:`, `??` on a `T \| null` and a `?.` chain that ends in `??`, `op=`, `++`/`--`, template literals, contextual numeric literals | [Expressions](docs/LANGUAGE.md#expressions) |
177
177
  | Strings | immutable UTF-8 (`.length` is the byte length), literals as constant data, `+`, `===`, templates, `console.log` | [Builtins](docs/LANGUAGE.md#builtins), [Semantics](docs/LANGUAGE.md#semantics-decisions) |
178
- | Arrays | `T[]` with one element type, literals, `new Array<T>(n)` zero-filled, bounds-checked `a[i]` (panic, or `uncheckedGet` from `nish:unsafe`), `.length`, `push`/`pop`, `set`/`fill`, `for...of`; arrays of records stored contiguously and fixed-length array fields inline | [Arrays](docs/LANGUAGE.md#array-literals) |
178
+ | Arrays | `T[]` with one element type, literals, `new Array<T>(n)` zero-filled, bounds-checked `a[i]` (panic, or `uncheckedGet` from `nish:unsafe`), `.length`, `push`/`pop`, `set`/`fill`, `sort`, `map`/`filter`/`some`/`every`/`findIndex`/`slice`, `for...of`; arrays of records stored contiguously and fixed-length array fields inline | [Arrays](docs/LANGUAGE.md#array-literals) |
179
179
  | `Map` and `Set` | the global `Map<K, V>` and `Set<T>`, insertion-ordered, one probe per `get`/`set`/`has`/`delete`; `get` is `V \| undefined` and narrowed as TypeScript does | [`Map` and `Set`](docs/LANGUAGE.md#map-and-set) |
180
180
  | Classes and interfaces | LLVM structs with clang's layout, constructors, methods, `readonly`, definite assignment, object literals, `implements` by identical layout; no inheritance | [Classes](docs/LANGUAGE.md#classes) |
181
181
  | Generics | generic functions, classes, interfaces and methods by monomorphisation: one specialised `define` per instantiation, type arguments inferred at a call and written after `new` or in an annotation, `<T extends Shape>` constraints, exported instantiations callable from C and JavaScript as `nish_gen_identity_i32` | [Generic functions](docs/LANGUAGE.md#generic-functions) |
@@ -393,7 +393,7 @@ recompile of the runtime. `-o`, `--link`, `--target`, the `--emit-*` sidecars an
393
393
  errors there, and performance warnings are not printed, because stderr belongs
394
394
  to the program.
395
395
 
396
- Without `--link`, build the IR yourself: `clang add.ll examples/main.c runtime/runtime.c runtime/runtime-os.c -o app`
396
+ Without `--link`, build the IR yourself: `clang add.ll examples/main.c runtime/runtime.c runtime/runtime-text.c runtime/runtime-os.c -ffp-contract=off -o app`
397
397
  (a program that uses threads, the host calls or `nish:net` also names
398
398
  `runtime/runtime-parallel.c`, `runtime-host.c` or `runtime-net.c`; the
399
399
  `overriding the module target triple` warning is harmless: the IR is
@@ -424,13 +424,14 @@ dynamically linked (`npm run size-report`):
424
424
  | `wasm` | 279 | Freestanding `wasm32` module, every function exported, stripped. |
425
425
  | `wasi` | 42,228 (`argv.ts`) | `wasm32-wasi` command module: the runtime linked against wasi-libc, `_start` runs `main`; needs a WASI sysroot ([INSTALL.md](docs/INSTALL.md#wasi-optional-for---profile-wasi)). |
426
426
 
427
- `hello.ts` with `--link` is 4,712 bytes. The runtime is sixteen translation units
427
+ `hello.ts` with `--link` is 4,712 bytes. The runtime is seventeen translation units
428
428
  with a measured ceiling each, so that the core does not grow every time the
429
429
  language reaches further into the operating system, and section GC drops
430
- whatever a program does not call: `runtime.c` is the 3,606 bytes every program
431
- touches (one chunked bump arena with O(1) reset and mark/release, strings,
432
- JavaScript-exact number formatting, string parsing, `Math.random`,
433
- `process.argv`, array growth, the panic paths), `runtime-os.c` the 1,530 bytes
430
+ whatever a program does not call: `runtime.c` is the 1,723 bytes every program
431
+ touches (one chunked bump arena with O(1) reset and mark/release, string
432
+ parsing, `Math.random`, `process.argv`, array growth, the panic paths),
433
+ `runtime-text.c` the 1,787 bytes of strings and JavaScript-exact number
434
+ formatting, which a wasm module links too, `runtime-os.c` the 1,530 bytes
434
435
  that wrap a system call (exit, files, directories, subprocesses, the
435
436
  environment, the clock), and `runtime-parallel.c`, `runtime-cross.c`,
436
437
  `runtime-host.c`, `runtime-net.c`, `runtime-simd.c`, `runtime-aes.c`,
@@ -593,7 +594,8 @@ rather than gaps, each with the message and the idiom to use instead
593
594
  Release engineering (`--version`, exit codes, npm packaging, tag-driven
594
595
  releases) landed with WP12; see [CHANGELOG.md](CHANGELOG.md) and
595
596
  [docs/wp12-release.md](docs/wp12-release.md). The plan itself is
596
- [docs/MASTER_PLAN.md](docs/MASTER_PLAN.md).
597
+ [docs/MASTER_PLAN.md](docs/MASTER_PLAN.md), and what is built and what is next is
598
+ the [roadmap](docs/roadmap/index.md).
597
599
 
598
600
  ---
599
601