@amritk/nish-x86_64-linux 0.27.2 → 0.29.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 (54) hide show
  1. package/INSTALL.md +16 -8
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +118 -26
  4. package/package.json +1 -1
  5. package/runtime/core/host.d.ts +2 -1
  6. package/runtime/core/host.mjs +4 -0
  7. package/runtime/core.d.ts +47 -0
  8. package/runtime/core.mjs +67 -0
  9. package/runtime/nish.d.ts +176 -0
  10. package/runtime/nish.h +120 -6
  11. package/runtime/nish.mjs +24 -4
  12. package/runtime/runtime-checksum.c +270 -0
  13. package/runtime/runtime-net.c +386 -5
  14. package/runtime/runtime-os.c +59 -8
  15. package/runtime/runtime-parallel.c +81 -5
  16. package/runtime/runtime-sandbox.c +479 -0
  17. package/runtime/runtime-sha256.c +239 -0
  18. package/runtime/runtime-shm.c +541 -0
  19. package/runtime/runtime.c +827 -791
  20. package/scripts/build.sh +79 -28
  21. package/std/README.md +25 -13
  22. package/std/collections.ts +5 -5
  23. package/std/compress/checksum.ts +88 -75
  24. package/std/compress/deflate.ts +224 -0
  25. package/std/compress/gzip.ts +52 -0
  26. package/std/crypto/bcrypt.ts +816 -280
  27. package/std/crypto/hmac.ts +305 -2
  28. package/std/crypto/jwt.ts +1661 -0
  29. package/std/json-equal.ts +335 -0
  30. package/std/json-format.ts +1070 -0
  31. package/std/json-number.ts +428 -0
  32. package/std/json-pointer.ts +245 -0
  33. package/std/json-typed.ts +34 -0
  34. package/std/json-value.ts +510 -17
  35. package/std/json.ts +35 -6
  36. package/std/net/handler.ts +1348 -0
  37. package/std/net/http-client.ts +97 -16
  38. package/std/net/http-compress.ts +301 -16
  39. package/std/net/http1-client.ts +104 -19
  40. package/std/net/http1-server.ts +127 -24
  41. package/std/net/http1.ts +24 -4
  42. package/std/net/outbound.ts +409 -0
  43. package/std/net/postgres.ts +405 -0
  44. package/std/net/prefork.ts +344 -20
  45. package/std/net/websocket.ts +295 -14
  46. package/std/regex.ts +613 -52
  47. package/std/secret.ts +1 -1
  48. package/std/sync/ring.ts +587 -0
  49. package/std/sync/shm.ts +284 -0
  50. package/std/term-io.ts +35 -8
  51. package/std/term-rate.ts +13 -1
  52. package/std/threads.ts +35 -3
  53. package/std/yaml-json.ts +841 -0
  54. /package/runtime/{LICENSE-ryu → LICENSE-zmij} +0 -0
package/std/json.ts CHANGED
@@ -1791,16 +1791,45 @@ const jsonWriterPutDigits64 = (w: JsonWriter, v: i64): boolean => {
1791
1791
  }
1792
1792
 
1793
1793
  /**
1794
- * The digits `${v}` spells for a finite `v`, at the cursor. They are a string
1794
+ * The digits `${v}` spells for a finite `v`, in `buf` from `at`: the new end,
1795
+ * or -1, with nothing written, when `at` is negative or they do not fit —
1796
+ * `jsonWriterPutText`'s rule. Natively the compiler replaces the one call to
1797
+ * it with the runtime's `nish_json_put_f64` (`src/kernels.ts`), which formats
1798
+ * into the stack and copies, so no string is built at all; that is why the
1799
+ * walk takes the array and the cursor rather than the writer.
1800
+ *
1801
+ * As written, which is what Node and `--emit-ts` run, the digits are a string
1795
1802
  * the runtime builds, and nothing holds it once its bytes are copied, so the
1796
1803
  * function's automatic arena scope (LANGUAGE.md, "Memory model", item 2)
1797
1804
  * gives it back before the call returns: a loop of `f64` writes keeps
1798
- * `Arena.used()` flat like every other write, and `tests/link/std_json_writer`
1799
- * measures it. The scope is the compiler's rather than a `using a = arena()`
1800
- * block because this module also runs under Node, which `tests/run.js` holds
1801
- * to `JSON.stringify`, and Node 22 does not parse `using`.
1805
+ * `Arena.used()` flat like every other write either way, and
1806
+ * `tests/link/std_json_writer` measures it. The scope is the compiler's rather
1807
+ * than a `using a = arena()` block because this module also runs under Node,
1808
+ * which `tests/run.js` holds to `JSON.stringify`, and Node 22 does not parse
1809
+ * `using`.
1802
1810
  */
1803
- const jsonWriterPutF64 = (w: JsonWriter, v: f64): boolean => jsonWriterPutText(w, `${v}`)
1811
+ const jsonPutF64Walk = (buf: u8[], at: i32, v: f64): i32 => {
1812
+ const text: string = `${v}`
1813
+ const n: i32 = toI32(text.length)
1814
+ if (at < 0 || at > toI32(buf.length) - n) {
1815
+ return -1
1816
+ }
1817
+ for (let k: i32 = 0; k < n && at + k < toI32(buf.length); k += 1) {
1818
+ buf[at + k] = toU8(text.charCodeAt(k))
1819
+ }
1820
+ return at + n
1821
+ }
1822
+
1823
+ /** The digits `${v}` spells for a finite `v`, at the cursor; all of them or, with `JSON_WRITE_FULL`, none. */
1824
+ const jsonWriterPutF64 = (w: JsonWriter, v: f64): boolean => {
1825
+ const stop: i32 = jsonPutF64Walk(w.buf, w.end, v)
1826
+ if (stop < 0) {
1827
+ w.failed = JSON_WRITE_FULL
1828
+ return false
1829
+ }
1830
+ w.end = stop
1831
+ return true
1832
+ }
1804
1833
 
1805
1834
  /**
1806
1835
  * `s` as `JSON.stringify(s)` writes it — quoted, with the escapes