@amritk/nish-x86_64-linux 0.46.0 → 0.48.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 (46) hide show
  1. package/bin/nish +0 -0
  2. package/docs/AI.md +29 -18
  3. package/package.json +1 -1
  4. package/runtime/gfx/README.md +55 -0
  5. package/runtime/gfx/nish-gfx.c +1063 -0
  6. package/runtime/gfx/nish-gfx.h +221 -0
  7. package/runtime/gfx/nish-gfx.overrides.json +14 -0
  8. package/runtime/nish.d.ts +22 -5
  9. package/runtime/nish.h +1 -0
  10. package/runtime/nish.mjs +1 -0
  11. package/runtime/runtime-bytes.c +167 -7
  12. package/runtime/runtime-net.c +122 -52
  13. package/runtime/runtime-uring.c +150 -69
  14. package/runtime/sqlite/nish-sqlite.c +166 -39
  15. package/scripts/build.sh +88 -3
  16. package/std/README.md +2 -2
  17. package/std/base64.ts +28 -30
  18. package/std/compress/deflate.ts +1371 -704
  19. package/std/crypto/aes.ts +81 -45
  20. package/std/crypto/bcrypt-batch.ts +23 -4
  21. package/std/crypto/bcrypt.ts +36 -11
  22. package/std/crypto/chacha20poly1305.ts +93 -52
  23. package/std/crypto/x25519.ts +7 -4
  24. package/std/host/game.ts +52 -20
  25. package/std/host/ring.ts +115 -31
  26. package/std/host/text.ts +9 -3
  27. package/std/json.ts +83 -0
  28. package/std/math.ts +161 -131
  29. package/std/net/handler.ts +24 -6
  30. package/std/net/http-server.ts +358 -141
  31. package/std/net/http1-server.ts +44 -13
  32. package/std/net/prefork.ts +1 -2
  33. package/std/net/static.ts +7 -2
  34. package/std/random.ts +34 -51
  35. package/std/raster.ts +377 -113
  36. package/std/regex.ts +46 -15
  37. package/std/release.ts +19 -13
  38. package/std/sqlite.ts +380 -16
  39. package/std/synth.ts +20 -3
  40. package/std/temporal.ts +740 -363
  41. package/std/term-io.ts +81 -33
  42. package/std/term-pixels.ts +287 -112
  43. package/std/term-probe.ts +7 -3
  44. package/std/term-rate.ts +142 -66
  45. package/std/term.ts +782 -406
  46. package/std/testing.ts +14 -7
package/std/synth.ts CHANGED
@@ -47,7 +47,15 @@ const SYNTH_SAMPLE_LIMIT: f64 = 2147483647.0
47
47
  */
48
48
  export const synthSilence = (seconds: f64, sampleRate: i32): f64[] => {
49
49
  const want: f64 = seconds * toF64(sampleRate)
50
- const n: i32 = want >= 1.0 && want < SYNTH_SAMPLE_LIMIT ? toI32(want) : 1
50
+ let n: i32 = 1
51
+ if (want >= 1.0 && want < SYNTH_SAMPLE_LIMIT) {
52
+ const k: i32 = toI32(want)
53
+ // Never false: `want` is at least 1 here. The test is what proves the
54
+ // array length is not negative.
55
+ if (k >= 1) {
56
+ n = k
57
+ }
58
+ }
51
59
  const out: f64[] = new Array<f64>(n)
52
60
  out.fill(0.0)
53
61
  return out
@@ -101,11 +109,19 @@ export const synthTone = (
101
109
  }
102
110
  const from: i32 = toI32(start * rate)
103
111
  const n: i32 = toI32(length * rate)
112
+ // Never true: `start` is not negative here. The test is what proves `from + i`
113
+ // stays a sample index.
114
+ if (from < 0) {
115
+ return
116
+ }
117
+ const size: i32 = toI32(out.length)
104
118
  const ratio: f64 = Math.log(f1 / f0)
105
119
  let phase: f64 = 0.0
106
120
  let noise: i32 = SYNTH_NOISE_SEED
107
121
  let held: f64 = 0.0
108
- for (let i: i32 = 0; i < n && from + i < toI32(out.length); i++) {
122
+ // `at` is `from + i`, counted on its own so the test against `size` bounds it.
123
+ let at: i32 = from
124
+ for (let i: i32 = 0; i < n && at < size; i++) {
109
125
  const t: f64 = toF64(i) / rate
110
126
  const f: f64 = f0 * Math.exp((ratio * toF64(i)) / toF64(n))
111
127
  const before: f64 = phase
@@ -128,7 +144,8 @@ export const synthTone = (
128
144
  }
129
145
  const attack: f64 = Math.min(t / 0.002, 1.0)
130
146
  const release: f64 = Math.min((length - t) / 0.005, 1.0)
131
- out[from + i] = out[from + i] + v * volume * attack * release * Math.exp(-t * decay)
147
+ out[at] = out[at] + v * volume * attack * release * Math.exp(-t * decay)
148
+ at = at + 1
132
149
  }
133
150
  }
134
151