nish 0.49.1 → 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.
Files changed (91) hide show
  1. package/README.md +27 -21
  2. package/docs/AI.md +233 -159
  3. package/docs/INSTALL.md +1 -1
  4. package/package.json +12 -12
  5. package/runtime/gfx/nish-gfx.h +373 -61
  6. package/runtime/nish.d.ts +12 -9
  7. package/std/README.md +8 -5
  8. package/std/base64.ts +74 -1
  9. package/std/bytes.ts +201 -93
  10. package/std/compress/deflate.ts +20 -15
  11. package/std/crypto/base64url.ts +93 -66
  12. package/std/crypto/bcrypt.ts +25 -21
  13. package/std/crypto/hmac.ts +1 -1
  14. package/std/crypto/jwt.ts +32 -19
  15. package/std/crypto/p256.ts +9 -12
  16. package/std/crypto/pki-roots.ts +7 -4
  17. package/std/crypto/pki.ts +43 -55
  18. package/std/crypto/rsa-sign.ts +1632 -0
  19. package/std/crypto/rsa.ts +26 -4
  20. package/std/crypto/sha256.ts +135 -68
  21. package/std/crypto/x25519.ts +12 -11
  22. package/std/crypto/x509.ts +164 -40
  23. package/std/gpu/sys.ts +490 -0
  24. package/std/json-equal.ts +33 -18
  25. package/std/json-format.ts +39 -8
  26. package/std/json-number.ts +15 -3
  27. package/std/json-tokenizer.ts +4 -3
  28. package/std/json-typed.ts +12 -6
  29. package/std/json-value.ts +222 -104
  30. package/std/json.ts +81 -46
  31. package/std/net/dns-config.ts +18 -5
  32. package/std/net/dns-message.ts +60 -27
  33. package/std/net/dns-resolver.ts +35 -16
  34. package/std/net/dns.ts +3 -2
  35. package/std/net/fetch.ts +120 -38
  36. package/std/net/handler.ts +178 -66
  37. package/std/net/hpack.ts +192 -98
  38. package/std/net/http-compress.ts +83 -30
  39. package/std/net/http-fields.ts +327 -31
  40. package/std/net/http-server.ts +317 -20
  41. package/std/net/http1-client-codec.ts +137 -40
  42. package/std/net/http1-codec.ts +391 -202
  43. package/std/net/http1-server.ts +220 -38
  44. package/std/net/http2-cleartext.ts +10 -4
  45. package/std/net/http2-frame.ts +2 -2
  46. package/std/net/http2-tls.ts +3 -3
  47. package/std/net/http2.ts +69 -15
  48. package/std/net/http3-frame.ts +11 -14
  49. package/std/net/http3-server.ts +12 -15
  50. package/std/net/http3.ts +41 -29
  51. package/std/net/multipart.ts +592 -0
  52. package/std/net/outbound.ts +24 -8
  53. package/std/net/postgres-async.ts +92 -54
  54. package/std/net/postgres-carrier.ts +28 -4
  55. package/std/net/postgres.ts +166 -65
  56. package/std/net/prefork.ts +86 -5
  57. package/std/net/protobuf.ts +6 -2
  58. package/std/net/qpack.ts +66 -25
  59. package/std/net/quic-conn-ack.ts +27 -7
  60. package/std/net/quic-conn-cid.ts +13 -7
  61. package/std/net/quic-datagram.ts +6 -5
  62. package/std/net/quic-frame.ts +67 -23
  63. package/std/net/quic-listener.ts +19 -12
  64. package/std/net/quic-recovery.ts +11 -9
  65. package/std/net/quic-stream.ts +7 -5
  66. package/std/net/quic.ts +36 -31
  67. package/std/net/router.ts +136 -24
  68. package/std/net/serve.ts +59 -5
  69. package/std/net/static.ts +81 -33
  70. package/std/net/tls/record.ts +26 -13
  71. package/std/net/tls/ticket.ts +6 -5
  72. package/std/net/tls-tcp.ts +69 -30
  73. package/std/net/tls.ts +152 -38
  74. package/std/net/upstream.ts +65 -19
  75. package/std/net/url.ts +97 -78
  76. package/std/net/websocket.ts +16 -9
  77. package/std/net/webtransport.ts +28 -12
  78. package/std/regex.ts +600 -388
  79. package/std/sqlite.ts +37 -19
  80. package/std/sync/ring.ts +232 -115
  81. package/std/sync/shm.ts +11 -4
  82. package/std/temporal.ts +232 -133
  83. package/std/term-io.ts +12 -6
  84. package/std/term-pixels.ts +158 -22
  85. package/std/term-rate.ts +8 -3
  86. package/std/term.ts +4 -4
  87. package/std/text.ts +33 -11
  88. package/std/yaml-json.ts +238 -106
  89. package/std/yaml-lines.ts +47 -27
  90. package/std/yaml-write.ts +58 -24
  91. package/std/yaml.ts +808 -395
package/README.md CHANGED
@@ -69,28 +69,34 @@ for (const side of sides) {
69
69
  }
70
70
  ```
71
71
 
72
- The IR is readable. `examples/add.ts`, `a + b` on two `number`s (32-bit
73
- integers by default), compiles to a checked add: an overflow panics instead
74
- of wrapping, and a sum the compiler proves fits is a plain `add nsw`. That
75
- check is a panic site, so the compiler's default, which holds a package to no
76
- panic, refuses the file on purpose and `nish --allow-panics` builds it; each
77
- example that keeps a panic site says why in its first lines.
78
-
79
- ```llvm
80
- define noundef i32 @add(i32 noundef %a, i32 noundef %b) #0 {
81
- entry:
82
- %0 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
83
- %1 = extractvalue { i32, i1 } %0, 0
84
- %2 = extractvalue { i32, i1 } %0, 1
85
- br i1 %2, label %ovf.fail, label %ovf.ok
86
-
87
- ovf.ok:
88
- ret i32 %1
89
-
90
- ovf.fail:
91
- call void @nish_panic_overflow(i32 0)
92
- unreachable
72
+ `examples/add.ts` adds two 32-bit integers. The sum can leave the `i32`
73
+ range, so `add` answers a `Result` whose `Err` arm is the overflow check, and the compiler's default, which
74
+ holds a package to no panic, builds it as it is:
75
+
76
+ ```ts
77
+ export const add = (a: i32, b: i32): Result<i32, i32> => {
78
+ const sum: i64 = toI64(a) + toI64(b)
79
+ if (sum > 2147483647) {
80
+ return Err(1)
81
+ }
82
+ if (sum < -2147483648) {
83
+ return Err(-1)
84
+ }
85
+ return Ok(toI32(sum))
86
+ }
87
+ ```
88
+
89
+ The widened sum is a plain `add nsw i64`, and the `Result` comes back in one
90
+ register. A C caller (`examples/main.c`) reads it as the word
91
+ `nish --emit-header` declares, and takes the `Err` arm as the overflow:
92
+
93
+ ```c
94
+ nish_result_i32_i32_word r = add(2, 3);
95
+ if (!r.ok) {
96
+ fprintf(stderr, "add(2, 3) overflows int32_t\n");
97
+ return 1;
93
98
  }
99
+ printf("add(2, 3) = %d\n", r.as.value);
94
100
  ```
95
101
 
96
102
  Next step: [Your first program](docs/guide/getting-started/first-program.md).