nish 0.39.0 → 0.41.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/README.md +190 -555
- package/docs/AI.md +112 -33
- package/docs/INSTALL.md +79 -133
- package/llms.txt +2 -9
- package/package.json +17 -19
- package/runtime/nish.d.ts +21 -17
- package/runtime/nish.h +10 -0
- package/runtime/page-frame.d.ts +123 -0
- package/runtime/page-frame.mjs +736 -0
- package/runtime/page-game.d.ts +132 -0
- package/runtime/page-game.mjs +738 -0
- package/runtime/runtime-aes.c +85 -8
- package/runtime/runtime-bytes.c +88 -4
- package/runtime/runtime-net.c +32 -0
- package/runtime/runtime-sandbox.c +55 -28
- package/runtime/runtime-uring.c +1194 -0
- package/runtime/runtime-wasm.c +422 -0
- package/runtime/vite.mjs +1 -1
- package/scripts/build.sh +22 -6
- package/std/README.md +74 -87
- package/std/array.ts +36 -3
- package/std/collections.ts +51 -0
- package/std/crypto/hmac.ts +37 -10
- package/std/crypto/p256.ts +1388 -2664
- package/std/crypto/pki.ts +116 -4
- package/std/crypto/sha256.ts +34 -6
- package/std/crypto/x509.ts +7 -0
- package/std/host/game.ts +273 -0
- package/std/input.ts +56 -0
- package/std/json-tokenizer.ts +325 -112
- package/std/json-typed.ts +43 -8
- package/std/json-value.ts +144 -3
- package/std/json.ts +63 -8
- package/std/net/fetch.ts +22 -4
- package/std/net/http-server.ts +3382 -0
- package/std/net/http1-client-codec.ts +6 -2
- package/std/net/http1-codec.ts +137 -12
- package/std/net/http1-server.ts +83 -29
- package/std/net/http2.ts +47 -14
- package/std/net/http3-server.ts +29 -3
- package/std/net/http3.ts +180 -7
- package/std/net/prefork.ts +49 -13
- package/std/net/quic-recovery.ts +240 -9
- package/std/net/quic-stream.ts +21 -1
- package/std/net/quic.ts +98 -4
- package/std/net/router.ts +378 -31
- package/std/net/serve.ts +873 -65
- package/std/net/tls/verify.ts +19 -1
- package/std/net/url.ts +83 -35
- package/std/net/websocket.ts +74 -1
- package/std/net/webtransport.ts +7 -1
- package/std/raster.ts +837 -0
- package/std/release.ts +593 -0
- package/std/synth.ts +143 -0
- package/std/temporal.ts +3091 -0
- package/std/threads.ts +298 -0
- package/std/yaml-json.ts +368 -28
- package/std/yaml.ts +122 -27
- package/scripts/bootstrap.sh +0 -375
- package/scripts/build-id-smoke.sh +0 -28
- package/scripts/changelog-gen.mjs +0 -649
- package/scripts/changelog-section.sh +0 -28
- package/scripts/check-hardening.mjs +0 -202
- package/scripts/ci-profile.mjs +0 -200
- package/scripts/codes-registry.js +0 -85
- package/scripts/fuzz.sh +0 -280
- package/scripts/gen-diagnostic-codes.mjs +0 -243
- package/scripts/gen-json-pow5.mjs +0 -130
- package/scripts/gen-p256-table.mjs +0 -177
- package/scripts/gen-pow10-table.py +0 -80
- package/scripts/gen-regex-unicode.mjs +0 -822
- package/scripts/gen-union-scale.mjs +0 -294
- package/scripts/nish-compiler.sh +0 -19
- package/scripts/platform-package.mjs +0 -93
- package/scripts/security-scope.mjs +0 -139
- package/scripts/shard-costs.mjs +0 -429
- package/scripts/size-report.sh +0 -84
- package/scripts/smoke.sh +0 -105
- package/scripts/std-module-paths.mjs +0 -25
- package/scripts/undocumented.txt +0 -14
- package/scripts/verify-binaries.sh +0 -214
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nish/page/frame`: puts a wasm module's 0xRRGGBB framebuffer on a canvas
|
|
3
|
+
* through WebGPU, WebGL 2 or Canvas 2D, and runs a fixed-step loop that
|
|
4
|
+
* renders on every animation frame (docs/guide/using-nish/interop.md).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** A way of drawing on the canvas, best first: WebGPU, WebGL 2, Canvas 2D. */
|
|
8
|
+
export type Backend = "webgpu" | "webgl2" | "canvas2d";
|
|
9
|
+
|
|
10
|
+
/** A tier given up, and why: refused when it was built, or lost later. */
|
|
11
|
+
export interface Attempt {
|
|
12
|
+
/** The tier given up. */
|
|
13
|
+
readonly backend: Backend;
|
|
14
|
+
/** What refused or lost it, as the browser reported it. */
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** What `createPresenter` takes beyond the canvas. */
|
|
19
|
+
export interface PresenterOptions {
|
|
20
|
+
/** The tier to start from; the tiers above it are not tried. WebGPU by default. */
|
|
21
|
+
readonly prefer?: Backend;
|
|
22
|
+
/**
|
|
23
|
+
* Called each time a tier is given up for the next one, when the presenter
|
|
24
|
+
* is created or later, on a lost device or context. An error it throws is
|
|
25
|
+
* passed to `reportError` and the fallback goes on.
|
|
26
|
+
*
|
|
27
|
+
* @param from - the tier given up
|
|
28
|
+
* @param to - the tier tried next
|
|
29
|
+
* @param reason - why `from` was given up
|
|
30
|
+
* @param canvas - the canvas `to` builds on: a fresh one when `from` had
|
|
31
|
+
* taken a context, the place to add the page's listeners again (during
|
|
32
|
+
* `createPresenter`, before `presenter` exists, the only way to reach it)
|
|
33
|
+
*/
|
|
34
|
+
onFallback?(from: Backend, to: Backend, reason: string, canvas: HTMLCanvasElement): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Draws a framebuffer on a canvas, letterboxed to keep its aspect, nearest-neighbour scaled. */
|
|
38
|
+
export interface Presenter {
|
|
39
|
+
/** The tier presenting now; after every tier is lost, the last one tried. */
|
|
40
|
+
readonly backend: Backend;
|
|
41
|
+
/** Every tier refused or lost so far, in order. */
|
|
42
|
+
readonly attempts: readonly Attempt[];
|
|
43
|
+
/**
|
|
44
|
+
* The canvas presented on. A fallback after a tier has taken a context puts
|
|
45
|
+
* a fresh canvas in the old one's place (same attributes, no listeners), so
|
|
46
|
+
* read this again after `onFallback`. A canvas outside the document has no
|
|
47
|
+
* place to give: its fresh canvas is outside the document too, for the page
|
|
48
|
+
* to put where it wants.
|
|
49
|
+
*/
|
|
50
|
+
readonly canvas: HTMLCanvasElement;
|
|
51
|
+
/**
|
|
52
|
+
* Draws `width` by `height` pixels of `pixels`, row-major 0xRRGGBB words; the
|
|
53
|
+
* top byte is ignored. Pass the view into the module's memory: it is read,
|
|
54
|
+
* never kept past the call or copied first.
|
|
55
|
+
*
|
|
56
|
+
* @param pixels - the framebuffer, at least `width * height` words
|
|
57
|
+
* @param width - its width in pixels, a whole number of at least 1
|
|
58
|
+
* @param height - its height in pixels, a whole number of at least 1
|
|
59
|
+
*/
|
|
60
|
+
present(pixels: Int32Array, width: number, height: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* Sizes the canvas's drawing buffer to its CSS size in device pixels, at
|
|
63
|
+
* least 1 by 1. A size that is not finite or is below 0, or a ratio that is
|
|
64
|
+
* not above 0, is a `RangeError`.
|
|
65
|
+
*
|
|
66
|
+
* @param cssWidth - the canvas's width in CSS pixels
|
|
67
|
+
* @param cssHeight - the canvas's height in CSS pixels
|
|
68
|
+
* @param devicePixelRatio - device pixels per CSS pixel
|
|
69
|
+
*/
|
|
70
|
+
resize(cssWidth: number, cssHeight: number, devicePixelRatio: number): void;
|
|
71
|
+
/** Releases the tier's device or context; `present` then draws nothing, and no fallback follows. */
|
|
72
|
+
destroy(): void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Makes a presenter on `canvas`, trying WebGPU, then WebGL 2, then Canvas 2D,
|
|
77
|
+
* and keeping the first that builds. A tier lost later is replaced by the next
|
|
78
|
+
* one down, on a fresh canvas element when the old one already holds a context.
|
|
79
|
+
*
|
|
80
|
+
* @param canvas - the canvas to present on
|
|
81
|
+
* @param options - the tier to start from and the fallback callback
|
|
82
|
+
* @returns the presenter; it rejects, naming every tier's reason, when no tier builds
|
|
83
|
+
*/
|
|
84
|
+
export declare function createPresenter(
|
|
85
|
+
canvas: HTMLCanvasElement,
|
|
86
|
+
options?: PresenterOptions
|
|
87
|
+
): Promise<Presenter>;
|
|
88
|
+
|
|
89
|
+
/** What `runFixedStep` takes. */
|
|
90
|
+
export interface FixedStepOptions {
|
|
91
|
+
/** How many times a second `step` runs. */
|
|
92
|
+
readonly stepsPerSecond: number;
|
|
93
|
+
/** The most steps one frame runs; the backlog past it is dropped. 8 by default. */
|
|
94
|
+
readonly maxStepsPerFrame?: number;
|
|
95
|
+
/** Advances the program one fixed step. */
|
|
96
|
+
step(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Draws a frame; called on every animation frame.
|
|
99
|
+
*
|
|
100
|
+
* @param alpha - how far into the next step this frame is, in [0, 1)
|
|
101
|
+
* @param frameMs - the frame's length in milliseconds, at most 250; 0 on the first frame
|
|
102
|
+
*/
|
|
103
|
+
render(alpha: number, frameMs: number): void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** A running loop. */
|
|
107
|
+
export interface FixedStepLoop {
|
|
108
|
+
/** Ends the loop and cancels its next frame. */
|
|
109
|
+
stop(): void;
|
|
110
|
+
/** The display's refresh rate, read from the fastest recent frame intervals; 0 before the second frame. */
|
|
111
|
+
readonly refreshHz: number;
|
|
112
|
+
/** Renders per second over the last half second or so; 0 until one has passed. */
|
|
113
|
+
readonly fps: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Runs `step` at a fixed rate and `render` on every animation frame. A frame
|
|
118
|
+
* longer than a quarter second counts as a quarter second.
|
|
119
|
+
*
|
|
120
|
+
* @param options - the step rate, the per-frame step limit and the callbacks
|
|
121
|
+
* @returns the running loop
|
|
122
|
+
*/
|
|
123
|
+
export declare function runFixedStep(options: FixedStepOptions): FixedStepLoop;
|