nish 0.41.0 → 0.44.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 (47) hide show
  1. package/README.md +16 -4
  2. package/bin/nish-skills.js +233 -0
  3. package/docs/AI.md +282 -126
  4. package/llms.txt +4 -0
  5. package/package.json +14 -11
  6. package/runtime/core.d.ts +16 -0
  7. package/runtime/core.mjs +5 -0
  8. package/runtime/nish.d.ts +204 -33
  9. package/runtime/nish.h +19 -3
  10. package/runtime/nish.mjs +5 -1
  11. package/runtime/runtime-cross.c +15 -0
  12. package/runtime/runtime-net.c +876 -10
  13. package/runtime/runtime-region.c +21 -0
  14. package/runtime/runtime-sandbox.c +112 -15
  15. package/runtime/runtime-text.c +11 -0
  16. package/runtime/runtime-uring.c +533 -77
  17. package/runtime/runtime-wasm.c +3 -0
  18. package/runtime/runtime.c +474 -5
  19. package/runtime/sqlite/README.md +16 -3
  20. package/runtime/sqlite/nish-sqlite.c +940 -29
  21. package/scripts/build.sh +125 -29
  22. package/scripts/link-skills.mjs +1039 -0
  23. package/scripts/postinstall.mjs +43 -0
  24. package/skills/writing-nish/SKILL.md +144 -0
  25. package/std/README.md +3 -3
  26. package/std/crypto/base64url.ts +102 -1
  27. package/std/crypto/scram.ts +142 -0
  28. package/std/crypto/sha1.ts +99 -41
  29. package/std/host/ring.ts +1 -1
  30. package/std/host/text.ts +1 -1
  31. package/std/net/fetch.ts +9 -1
  32. package/std/net/handler.ts +79 -15
  33. package/std/net/http-server.ts +2 -3
  34. package/std/net/http1-server.ts +294 -51
  35. package/std/net/http3-server.ts +26 -15
  36. package/std/net/http3.ts +2 -2
  37. package/std/net/oidc.ts +1107 -0
  38. package/std/net/postgres-async.ts +64 -33
  39. package/std/net/postgres.ts +65 -76
  40. package/std/net/quic-conn-ack.ts +57 -7
  41. package/std/net/quic-frame.ts +104 -2
  42. package/std/net/quic-listener.ts +9 -2
  43. package/std/net/quic.ts +16 -1
  44. package/std/net/serve.ts +10 -8
  45. package/std/net/websocket.ts +188 -49
  46. package/std/sqlite.ts +325 -0
  47. package/std/text.ts +80 -11
@@ -177,6 +177,12 @@ void nish_cross_end(void *state) {
177
177
  * in no chunk below the newest leaves the arena as it was, as the release
178
178
  * does. */
179
179
  static void nish_rewind(uint64_t mark) {
180
+ #ifdef NISH_ARENA_DEBUG
181
+ /* Keeping a chunk to bump in would let the next element's rewind stay in
182
+ compiled code, and never retire what it gave back. */
183
+ nish_arena_release(mark);
184
+ return;
185
+ #endif
180
186
  struct nish_arena *a = &nish_arena;
181
187
  nish_xchunk *top = a->chunks;
182
188
  char *buf = (char *)(top + 1);
@@ -210,6 +216,8 @@ void *nish_cross_keep(void *v, uint64_t esize, uint64_t mark) {
210
216
  if (!x) {
211
217
  v = nish_cross_copy(v, esize);
212
218
  } else {
219
+ /* `x->off` needs no realigning under NISH_ARENA_RANGE: only this
220
+ code bumps a transfer block, by `nish_cross_size`'s 8-byte multiples. */
213
221
  uint64_t n = nish_cross_size(v, esize);
214
222
  if (!x->block || x->block->cap - x->off < n) {
215
223
  uint64_t want = x->block && x->block->cap < 32768 ? x->block->cap * 2 : x->block ? 65536 : 4096;
@@ -237,7 +245,14 @@ void *nish_cross_in(void *p, uint64_t esize) {
237
245
  void *v = (void *)((uintptr_t)p & ~(uintptr_t)1);
238
246
  nish_xchunk *c = (nish_xchunk *)v - 1;
239
247
  uint64_t n = c->cap;
248
+ #ifdef NISH_ARENA_RANGE
249
+ /* What `nish_alloc_struct` would have left: it starts at `off` rounded up
250
+ to 8 (runtime.c gives the reason). */
251
+ uint64_t at = (nish_arena.off + 7) & ~(uint64_t)7;
252
+ if (n >= 65536 && (at > nish_arena.cap || n > nish_arena.cap - at)) {
253
+ #else
240
254
  if (n >= 65536 && n > nish_arena.cap - nish_arena.off) {
255
+ #endif
241
256
  nish_cross_link(c);
242
257
  return v;
243
258
  }