nish 0.47.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.
- package/package.json +5 -5
- package/runtime/gfx/README.md +55 -0
- package/runtime/gfx/nish-gfx.c +1063 -0
- package/runtime/gfx/nish-gfx.h +221 -0
- package/runtime/gfx/nish-gfx.overrides.json +14 -0
- package/runtime/nish.d.ts +22 -5
- package/runtime/nish.mjs +1 -0
- package/runtime/runtime-net.c +53 -27
- package/runtime/runtime-uring.c +39 -7
- package/scripts/build.sh +88 -3
- package/std/compress/deflate.ts +1371 -704
- package/std/net/handler.ts +24 -6
- package/std/net/http-server.ts +358 -141
- package/std/net/http1-server.ts +8 -2
- package/std/raster.ts +35 -21
- package/std/synth.ts +9 -1
package/std/net/http1-server.ts
CHANGED
|
@@ -141,6 +141,7 @@ import {
|
|
|
141
141
|
} from "nish/net/http-compress"
|
|
142
142
|
import { netClose, netMss, netRead, netShutdown, netWrite, netWrite2, tcpAccept } from "nish:net"
|
|
143
143
|
import {
|
|
144
|
+
HTTP1_BAD_WINDOW,
|
|
144
145
|
HTTP1_BODY,
|
|
145
146
|
HTTP1_CHUNKED,
|
|
146
147
|
HTTP1_CLOSED,
|
|
@@ -154,7 +155,7 @@ import {
|
|
|
154
155
|
HTTP1_UPGRADE,
|
|
155
156
|
Http1Parser,
|
|
156
157
|
http1BytesAre,
|
|
157
|
-
|
|
158
|
+
http1TryWriteChunk,
|
|
158
159
|
http1WriteLastChunk,
|
|
159
160
|
http1WriteResponseHead,
|
|
160
161
|
} from "nish/net/http1-codec"
|
|
@@ -2090,7 +2091,12 @@ export class Http1Connection {
|
|
|
2090
2091
|
return H1_AGAIN
|
|
2091
2092
|
}
|
|
2092
2093
|
if (chunked) {
|
|
2093
|
-
|
|
2094
|
+
// The window was checked on entry, and `take` only shortens it.
|
|
2095
|
+
const end: i32 = http1TryWriteChunk(this.output, this.outputEnd, buf, off, take)
|
|
2096
|
+
if (end === HTTP1_BAD_WINDOW) {
|
|
2097
|
+
return H1_INVALID
|
|
2098
|
+
}
|
|
2099
|
+
this.outputEnd = end
|
|
2094
2100
|
} else {
|
|
2095
2101
|
this.outputEnd = http1ServerCopy(this.output, this.outputEnd, buf, off, take)
|
|
2096
2102
|
if (this.responseFraming >= 0) {
|
package/std/raster.ts
CHANGED
|
@@ -730,7 +730,9 @@ export const rasterPushTrail = (trail: RasterTrail, x: f64, y: f64): void => {
|
|
|
730
730
|
/**
|
|
731
731
|
* A trail as a line of discs from oldest to newest, each larger and more
|
|
732
732
|
* opaque than the one before: a streak that fades out behind what made it.
|
|
733
|
-
* A point at `v` is drawn at pixel `offset + v * scale`.
|
|
733
|
+
* A point at `v` is drawn at pixel `offset + v * scale`. A `head` set
|
|
734
|
+
* outside the ring still draws the points `count` slots behind it that land
|
|
735
|
+
* in the ring, as an in-range head does, and no others.
|
|
734
736
|
*
|
|
735
737
|
* @param pixels - the frame, row-major
|
|
736
738
|
* @param width - the frame's width in pixels
|
|
@@ -760,29 +762,41 @@ export const rasterTrail = (
|
|
|
760
762
|
const n: i32 = toI32(xs.length)
|
|
761
763
|
const count: i32 = Math.min(trail.count, n)
|
|
762
764
|
const head: i32 = trail.head
|
|
763
|
-
|
|
765
|
+
// The oldest point is `count` slots behind the head, wrapping once. A head
|
|
766
|
+
// out of the ring (a caller can set the field) still has the slots that land
|
|
767
|
+
// in it drawn. Point i sits at `head - count + i`, counted in f64, where it
|
|
768
|
+
// is exact for any head, so no sum can overflow. The points before slot 0
|
|
769
|
+
// wrap to the ring's end and are older than the rest, so they are drawn
|
|
770
|
+
// first, as one run of slots, and the others as a second.
|
|
771
|
+
if (count <= 0) {
|
|
764
772
|
return
|
|
765
773
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
if (
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
774
|
+
const size: f64 = toF64(n)
|
|
775
|
+
const ysLength: i32 = toI32(ys.length)
|
|
776
|
+
const first: f64 = toF64(head) - toF64(count)
|
|
777
|
+
const steps: f64 = toF64(count) + 1.0
|
|
778
|
+
for (let pass: i32 = 0; pass < 2; pass++) {
|
|
779
|
+
// Point i of this run sits at slot `base + i`.
|
|
780
|
+
const base: f64 = pass === 0 ? first + size : first
|
|
781
|
+
const lo: f64 = Math.max(base, 0.0)
|
|
782
|
+
const hi: f64 = Math.min(base + toF64(count), size)
|
|
783
|
+
if (lo < hi) {
|
|
784
|
+
const end: i32 = toI32(hi)
|
|
785
|
+
// How far along the trail the point is, from 1 for the oldest.
|
|
786
|
+
let step: f64 = lo - base + 1.0
|
|
787
|
+
for (let slot: i32 = toI32(lo); slot < end; slot++) {
|
|
788
|
+
// The first two are always true in the run and prove the indexes; the
|
|
789
|
+
// third skips a slot a shorter `ys` does not hold.
|
|
790
|
+
if (slot >= 0 && slot < n && slot < ysLength) {
|
|
791
|
+
const f: f64 = step / steps
|
|
792
|
+
const radius: f64 = r * (f * 0.6 + 0.4)
|
|
793
|
+
const cx: f64 = offsetX + xs[slot] * scale
|
|
794
|
+
const cy: f64 = offsetY + ys[slot] * scale
|
|
795
|
+
rasterDisc(pixels, width, height, cx, cy, radius * scale, colour, alpha * f)
|
|
796
|
+
}
|
|
797
|
+
step = step + 1.0
|
|
798
|
+
}
|
|
784
799
|
}
|
|
785
|
-
slot = slot + 1 >= n ? 0 : slot + 1
|
|
786
800
|
}
|
|
787
801
|
}
|
|
788
802
|
|
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
|
-
|
|
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
|