@amritk/nish-aarch64-linux 0.49.1 → 0.50.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 (91) hide show
  1. package/INSTALL.md +1 -1
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +233 -159
  4. package/package.json +1 -1
  5. package/runtime/gfx/nish-gfx.h +373 -61
  6. package/runtime/nish.d.ts +12 -9
  7. package/std/README.md +8 -5
  8. package/std/base64.ts +74 -1
  9. package/std/bytes.ts +201 -93
  10. package/std/compress/deflate.ts +20 -15
  11. package/std/crypto/base64url.ts +93 -66
  12. package/std/crypto/bcrypt.ts +25 -21
  13. package/std/crypto/hmac.ts +1 -1
  14. package/std/crypto/jwt.ts +32 -19
  15. package/std/crypto/p256.ts +9 -12
  16. package/std/crypto/pki-roots.ts +7 -4
  17. package/std/crypto/pki.ts +43 -55
  18. package/std/crypto/rsa-sign.ts +1632 -0
  19. package/std/crypto/rsa.ts +26 -4
  20. package/std/crypto/sha256.ts +135 -68
  21. package/std/crypto/x25519.ts +12 -11
  22. package/std/crypto/x509.ts +164 -40
  23. package/std/gpu/sys.ts +490 -0
  24. package/std/json-equal.ts +33 -18
  25. package/std/json-format.ts +39 -8
  26. package/std/json-number.ts +15 -3
  27. package/std/json-tokenizer.ts +4 -3
  28. package/std/json-typed.ts +12 -6
  29. package/std/json-value.ts +222 -104
  30. package/std/json.ts +81 -46
  31. package/std/net/dns-config.ts +18 -5
  32. package/std/net/dns-message.ts +60 -27
  33. package/std/net/dns-resolver.ts +35 -16
  34. package/std/net/dns.ts +3 -2
  35. package/std/net/fetch.ts +120 -38
  36. package/std/net/handler.ts +178 -66
  37. package/std/net/hpack.ts +192 -98
  38. package/std/net/http-compress.ts +83 -30
  39. package/std/net/http-fields.ts +327 -31
  40. package/std/net/http-server.ts +317 -20
  41. package/std/net/http1-client-codec.ts +137 -40
  42. package/std/net/http1-codec.ts +391 -202
  43. package/std/net/http1-server.ts +220 -38
  44. package/std/net/http2-cleartext.ts +10 -4
  45. package/std/net/http2-frame.ts +2 -2
  46. package/std/net/http2-tls.ts +3 -3
  47. package/std/net/http2.ts +69 -15
  48. package/std/net/http3-frame.ts +11 -14
  49. package/std/net/http3-server.ts +12 -15
  50. package/std/net/http3.ts +41 -29
  51. package/std/net/multipart.ts +592 -0
  52. package/std/net/outbound.ts +24 -8
  53. package/std/net/postgres-async.ts +92 -54
  54. package/std/net/postgres-carrier.ts +28 -4
  55. package/std/net/postgres.ts +166 -65
  56. package/std/net/prefork.ts +86 -5
  57. package/std/net/protobuf.ts +6 -2
  58. package/std/net/qpack.ts +66 -25
  59. package/std/net/quic-conn-ack.ts +27 -7
  60. package/std/net/quic-conn-cid.ts +13 -7
  61. package/std/net/quic-datagram.ts +6 -5
  62. package/std/net/quic-frame.ts +67 -23
  63. package/std/net/quic-listener.ts +19 -12
  64. package/std/net/quic-recovery.ts +11 -9
  65. package/std/net/quic-stream.ts +7 -5
  66. package/std/net/quic.ts +36 -31
  67. package/std/net/router.ts +136 -24
  68. package/std/net/serve.ts +59 -5
  69. package/std/net/static.ts +81 -33
  70. package/std/net/tls/record.ts +26 -13
  71. package/std/net/tls/ticket.ts +6 -5
  72. package/std/net/tls-tcp.ts +69 -30
  73. package/std/net/tls.ts +152 -38
  74. package/std/net/upstream.ts +65 -19
  75. package/std/net/url.ts +97 -78
  76. package/std/net/websocket.ts +16 -9
  77. package/std/net/webtransport.ts +28 -12
  78. package/std/regex.ts +600 -388
  79. package/std/sqlite.ts +37 -19
  80. package/std/sync/ring.ts +232 -115
  81. package/std/sync/shm.ts +11 -4
  82. package/std/temporal.ts +232 -133
  83. package/std/term-io.ts +12 -6
  84. package/std/term-pixels.ts +158 -22
  85. package/std/term-rate.ts +8 -3
  86. package/std/term.ts +4 -4
  87. package/std/text.ts +33 -11
  88. package/std/yaml-json.ts +238 -106
  89. package/std/yaml-lines.ts +47 -27
  90. package/std/yaml-write.ts +58 -24
  91. package/std/yaml.ts +808 -395
package/std/gpu/sys.ts ADDED
@@ -0,0 +1,490 @@
1
+ // Generated by nish c-import from ../../runtime/gfx/nish-gfx.h. Do not edit; regenerate it.
2
+ // Target: x86_64-unknown-linux-gnu
3
+ // Data model: LP64
4
+ // Regenerate: nish c-import ../../runtime/gfx/nish-gfx.h --overrides ../../runtime/gfx/nish-gfx.overrides.json --target x86_64-unknown-linux-gnu -o sys.ts
5
+
6
+ /** A WebGPU instance: the root every surface, adapter and device is made from. */
7
+ export declare class NishGfxInstance {}
8
+
9
+ /** An SDL3 window, with the ring its input and window events queue in. */
10
+ export declare class NishGfxWindow {}
11
+
12
+ /** A WebGPU surface that presents frames into a window. */
13
+ export declare class NishGfxSurface {}
14
+
15
+ /** A WebGPU adapter: one GPU, or a software rasteriser, that devices are requested from. */
16
+ export declare class NishGfxAdapter {}
17
+
18
+ /** A WebGPU device and its queue, with the ring its errors queue in. */
19
+ export declare class NishGfxDevice {}
20
+
21
+ /** A WebGPU buffer on a device. */
22
+ export declare class NishGfxBuffer {}
23
+
24
+ /** A WebGPU shader module compiled from WGSL. */
25
+ export declare class NishGfxShader {}
26
+
27
+ /** A render pipeline builder, freed by nishgfx_pipeline_create(). */
28
+ export declare class NishGfxPipelineDesc {}
29
+
30
+ /** A render pipeline: a shader's two stages, its vertex layout and one color target. */
31
+ export declare class NishGfxPipeline {}
32
+
33
+ /** A bind group builder, freed by nishgfx_bind_group_create(). */
34
+ export declare class NishGfxBindGroupDesc {}
35
+
36
+ /** A bind group: the buffers a pipeline's group of bindings reads. */
37
+ export declare class NishGfxBindGroup {}
38
+
39
+ /** A command encoder, freed when it is submitted. */
40
+ export declare class NishGfxEncoder {}
41
+
42
+ /** A render pass on one color view, freed when it ends. */
43
+ export declare class NishGfxPass {}
44
+
45
+ /** A texture view a render pass draws into: a surface's frame or an offscreen target. */
46
+ export declare class NishGfxView {}
47
+
48
+ /** A render target with no window, whose pixels can be read back. */
49
+ export declare class NishGfxOffscreen {}
50
+
51
+ /** One input or window event. Fields a kind does not use are zero. */
52
+ declare class NishGfxEvent {
53
+ kind: u32
54
+ key: u32
55
+ button: u32
56
+ modifiers: u32
57
+ x: f32
58
+ y: f32
59
+ dx: f32
60
+ dy: f32
61
+ width: u32
62
+ height: u32
63
+ }
64
+
65
+ /** A buffer to create. `usage` is WGPUBufferUsage bits. */
66
+ declare class NishGfxBufferDesc {
67
+ size: u64
68
+ usage: u32
69
+ mapped_at_creation: u32
70
+ }
71
+
72
+ /** No error was queued. */
73
+ export const NISHGFX_ERROR_NONE: i32 = 0
74
+ /** A WebGPU validation error. */
75
+ export const NISHGFX_ERROR_VALIDATION: i32 = 1
76
+ /** A WebGPU out-of-memory error. */
77
+ export const NISHGFX_ERROR_OUT_OF_MEMORY: i32 = 2
78
+ /** A WebGPU internal error, or a failure of the shim's own. */
79
+ export const NISHGFX_ERROR_INTERNAL: i32 = 3
80
+ /** The device was lost. */
81
+ export const NISHGFX_ERROR_DEVICE_LOST: i32 = 4
82
+ /** The error ring's size, per instance and per device. */
83
+ export const NISHGFX_ERROR_RING: i32 = 16
84
+ /** The longest message an entry keeps, without its NUL. */
85
+ export const NISHGFX_ERROR_MESSAGE_MAX: i32 = 255
86
+ /** No event was queued. */
87
+ export const NISHGFX_EVENT_NONE: i32 = 0
88
+ /** The window was asked to close. */
89
+ export const NISHGFX_EVENT_QUIT: i32 = 1
90
+ /** A key went down. */
91
+ export const NISHGFX_EVENT_KEY_DOWN: i32 = 2
92
+ /** A key came up. */
93
+ export const NISHGFX_EVENT_KEY_UP: i32 = 3
94
+ /** The pointer moved. */
95
+ export const NISHGFX_EVENT_MOUSE_MOVE: i32 = 4
96
+ /** A mouse button went down. */
97
+ export const NISHGFX_EVENT_MOUSE_DOWN: i32 = 5
98
+ /** A mouse button came up. */
99
+ export const NISHGFX_EVENT_MOUSE_UP: i32 = 6
100
+ /** The wheel turned. */
101
+ export const NISHGFX_EVENT_WHEEL: i32 = 7
102
+ /** The window's pixel size changed. */
103
+ export const NISHGFX_EVENT_RESIZED: i32 = 8
104
+ /** The event ring's size, per window. */
105
+ export const NISHGFX_EVENT_RING: i32 = 64
106
+
107
+ /**
108
+ * A WebGPU instance.
109
+ *
110
+ * @returns the instance, or null if wgpu-native refuses one
111
+ */
112
+ export declare function nishgfx_instance_create(): NishGfxInstance | null
113
+ /**
114
+ * Release an instance. Release it last: every surface, adapter and device
115
+ * made from it keeps it, and a device's readback drives events through it.
116
+ *
117
+ * @param instance the instance to release
118
+ */
119
+ export declare function nishgfx_instance_release(instance: NishGfxInstance): void
120
+ /**
121
+ * Drain one queued instance error (an adapter or device refusal) into msg,
122
+ * NUL-terminated and cut to cap - 1 bytes.
123
+ *
124
+ * @param instance the instance whose ring is drained
125
+ * @param msg the buffer the message is copied into
126
+ * @param cap the bytes msg holds
127
+ * @returns the error's kind, a NISHGFX_ERROR_* value, or 0 when the ring is empty
128
+ */
129
+ export declare function nishgfx_instance_error_next(instance: NishGfxInstance, msg: u8[], cap: u64): i32
130
+ /**
131
+ * An SDL3 window of width x height pixels.
132
+ *
133
+ * @param title the window's title, NUL-terminated UTF-8
134
+ * @param width the width in pixels
135
+ * @param height the height in pixels
136
+ * @returns the window, or null for a 0 side or one past INT32_MAX, when SDL
137
+ * has no video driver, when memory or SDL's window properties run out, and
138
+ * when SDL refuses the window; SDL_GetError() says why for the SDL failures
139
+ */
140
+ export declare function nishgfx_window_create(title: string, width: u32, height: u32): NishGfxWindow | null
141
+ /**
142
+ * Release a window. Release a surface made on the window first: it reads the
143
+ * window's size.
144
+ *
145
+ * @param window the window to release
146
+ */
147
+ export declare function nishgfx_window_release(window: NishGfxWindow): void
148
+ /**
149
+ * Move every pending SDL event into the window's ring. Events past the ring's
150
+ * size are dropped and counted.
151
+ *
152
+ * @param window the window whose ring is filled
153
+ * @returns how many events were queued
154
+ */
155
+ export declare function nishgfx_events_poll(window: NishGfxWindow): u32
156
+ /**
157
+ * Take the oldest queued event.
158
+ *
159
+ * @param window the window whose ring is drained
160
+ * @param out where the event is written
161
+ * @returns the event's kind, a NISHGFX_EVENT_* value, or 0 when the ring is empty
162
+ */
163
+ declare function nishgfx_event_next(window: NishGfxWindow, out: NishGfxEvent): u32
164
+ /**
165
+ * How many events found the window's ring full and were dropped.
166
+ *
167
+ * @param window the window to ask
168
+ * @returns the count since the window was made, or 0 for a null window
169
+ */
170
+ export declare function nishgfx_events_dropped(window: NishGfxWindow): u32
171
+ /**
172
+ * A surface on the window, through Metal, Wayland or X11 as SDL's current
173
+ * video driver says.
174
+ *
175
+ * @param instance the instance the surface is made from
176
+ * @param window the window it presents into
177
+ * @returns the surface, or null (and an instance error is queued) on any
178
+ * other video driver or failure
179
+ */
180
+ export declare function nishgfx_surface_create(instance: NishGfxInstance, window: NishGfxWindow): NishGfxSurface | null
181
+ /**
182
+ * Release a surface.
183
+ *
184
+ * @param surface the surface to release
185
+ */
186
+ export declare function nishgfx_surface_release(surface: NishGfxSurface): void
187
+ /**
188
+ * Configure a surface for width x height. vsync != 0 is Fifo; otherwise
189
+ * Mailbox, then Immediate, then Fifo, whichever the surface offers first.
190
+ *
191
+ * @param surface the surface to configure
192
+ * @param adapter the adapter the device came from
193
+ * @param device the device that draws into the surface
194
+ * @param width the width in pixels
195
+ * @param height the height in pixels
196
+ * @param vsync nonzero to wait for the display
197
+ * @returns 0, or -1 (and a device error is queued) for a 0 side or a surface
198
+ * with no format
199
+ */
200
+ export declare function nishgfx_surface_configure(surface: NishGfxSurface, adapter: NishGfxAdapter, device: NishGfxDevice, width: u32, height: u32, vsync: u32): i32
201
+ /**
202
+ * The texture format nishgfx_surface_configure() picked.
203
+ *
204
+ * @param surface the surface to ask
205
+ * @returns a WGPUTextureFormat, or 0 for a null surface
206
+ */
207
+ export declare function nishgfx_surface_format(surface: NishGfxSurface): u32
208
+ /**
209
+ * The next frame's view, which lives until nishgfx_surface_present().
210
+ *
211
+ * @param surface the configured surface
212
+ * @returns the view, or null to skip this frame: an outdated, lost or
213
+ * timed-out surface is reconfigured at the window's pixel size, or left
214
+ * until a frame where that size is above 0; any other failure queues a
215
+ * device error
216
+ */
217
+ export declare function nishgfx_surface_acquire(surface: NishGfxSurface): NishGfxView | null
218
+ /**
219
+ * Present the frame nishgfx_surface_acquire() answered.
220
+ *
221
+ * @param surface the surface to present
222
+ */
223
+ export declare function nishgfx_surface_present(surface: NishGfxSurface): void
224
+ /**
225
+ * Request an adapter.
226
+ *
227
+ * @param instance the instance to request it from
228
+ * @param surface a surface the adapter must be able to present to, or null
229
+ * @param power a WGPUPowerPreference
230
+ * @returns the adapter, or null (and an instance error is queued) on failure
231
+ */
232
+ export declare function nishgfx_adapter_request(instance: NishGfxInstance, surface: NishGfxSurface | null, power: u32): NishGfxAdapter | null
233
+ /**
234
+ * Release an adapter.
235
+ *
236
+ * @param adapter the adapter to release
237
+ */
238
+ export declare function nishgfx_adapter_release(adapter: NishGfxAdapter): void
239
+ /**
240
+ * Request a device with default limits. Its device-lost and uncaptured-error
241
+ * reports go to its ring.
242
+ *
243
+ * @param instance the instance the adapter came from
244
+ * @param adapter the adapter to request it from
245
+ * @returns the device, or null (and an instance error is queued) on failure
246
+ */
247
+ export declare function nishgfx_device_request(instance: NishGfxInstance, adapter: NishGfxAdapter): NishGfxDevice | null
248
+ /**
249
+ * Release a device. Release every buffer, shader, pipeline, bind group,
250
+ * offscreen target and surface made from the device first: one used after
251
+ * this can report an error into the freed device.
252
+ *
253
+ * @param device the device to release
254
+ */
255
+ export declare function nishgfx_device_release(device: NishGfxDevice): void
256
+ /**
257
+ * Drain one queued device error into msg, NUL-terminated and cut to cap - 1
258
+ * bytes.
259
+ *
260
+ * @param device the device whose ring is drained
261
+ * @param msg the buffer the message is copied into
262
+ * @param cap the bytes msg holds
263
+ * @returns the error's kind, a NISHGFX_ERROR_* value, or 0 when the ring is empty
264
+ */
265
+ export declare function nishgfx_error_next(device: NishGfxDevice, msg: u8[], cap: u64): i32
266
+ /**
267
+ * How many reports found the device's ring full.
268
+ *
269
+ * @param device the device to ask
270
+ * @returns the count since the device was made
271
+ */
272
+ export declare function nishgfx_errors_dropped(device: NishGfxDevice): u32
273
+ /**
274
+ * Create a buffer.
275
+ *
276
+ * @param device the device it lives on
277
+ * @param desc its size, usage and whether it starts mapped
278
+ * @param label a debug label, or null
279
+ * @returns the buffer, or null when wgpu-native answers none
280
+ */
281
+ declare function nishgfx_buffer_create(device: NishGfxDevice, desc: NishGfxBufferDesc, label: string | null): NishGfxBuffer | null
282
+ /**
283
+ * Release a buffer.
284
+ *
285
+ * @param buffer the buffer to release
286
+ */
287
+ export declare function nishgfx_buffer_release(buffer: NishGfxBuffer): void
288
+ /**
289
+ * Copy len bytes of data into buffer at offset, on the device's queue.
290
+ *
291
+ * @param device the device whose queue writes
292
+ * @param buffer the buffer written
293
+ * @param offset the byte offset into buffer
294
+ * @param data the bytes to copy
295
+ * @param len how many bytes of data to copy
296
+ */
297
+ export declare function nishgfx_queue_write(device: NishGfxDevice, buffer: NishGfxBuffer, offset: u64, data: readonly u8[], len: u64): void
298
+ /**
299
+ * A shader module from WGSL. A compile error is queued on the device; the
300
+ * module answered is then invalid but safe to pass on.
301
+ *
302
+ * @param device the device it lives on
303
+ * @param wgsl the shader's source, NUL-terminated
304
+ * @returns the module, or null when wgpu-native answers none
305
+ */
306
+ export declare function nishgfx_shader_create(device: NishGfxDevice, wgsl: string): NishGfxShader | null
307
+ /**
308
+ * Release a shader module.
309
+ *
310
+ * @param shader the module to release
311
+ */
312
+ export declare function nishgfx_shader_release(shader: NishGfxShader): void
313
+ /**
314
+ * A render pipeline builder: one vertex buffer of `stride` bytes (0 for no
315
+ * vertex buffer), one color target of `color_format`, triangle list.
316
+ *
317
+ * @param shader the module both stages come from
318
+ * @param vs_entry the vertex stage's entry point, NUL-terminated
319
+ * @param fs_entry the fragment stage's entry point, NUL-terminated
320
+ * @param color_format the color target's WGPUTextureFormat
321
+ * @param stride the vertex buffer's stride in bytes, or 0 for none
322
+ * @returns the builder, or null when memory runs out
323
+ */
324
+ export declare function nishgfx_pipeline_desc_new(shader: NishGfxShader, vs_entry: string, fs_entry: string, color_format: u32, stride: u64): NishGfxPipelineDesc | null
325
+ /**
326
+ * Add a vertex attribute to a pipeline builder.
327
+ *
328
+ * @param desc the builder
329
+ * @param format the attribute's WGPUVertexFormat
330
+ * @param offset its byte offset in a vertex
331
+ * @param location its shader location
332
+ * @returns 0, or -1 once the builder holds 16
333
+ */
334
+ export declare function nishgfx_pipeline_desc_attribute(desc: NishGfxPipelineDesc, format: u32, offset: u64, location: u32): i32
335
+ /**
336
+ * Build the pipeline and free the builder, either way.
337
+ *
338
+ * @param device the device it lives on
339
+ * @param desc the builder, freed by this call
340
+ * @returns the pipeline, or null when it cannot be built
341
+ */
342
+ export declare function nishgfx_pipeline_create(device: NishGfxDevice, desc: NishGfxPipelineDesc): NishGfxPipeline | null
343
+ /**
344
+ * Release a pipeline.
345
+ *
346
+ * @param pipeline the pipeline to release
347
+ */
348
+ export declare function nishgfx_pipeline_release(pipeline: NishGfxPipeline): void
349
+ /**
350
+ * A bind group builder for group `index` of the pipeline's layout.
351
+ *
352
+ * @param pipeline the pipeline whose layout the group follows
353
+ * @param index the group's index in that layout
354
+ * @returns the builder, or null when memory runs out
355
+ */
356
+ export declare function nishgfx_bind_group_desc_new(pipeline: NishGfxPipeline, index: u32): NishGfxBindGroupDesc | null
357
+ /**
358
+ * Bind size bytes of buffer at offset to `binding`; size 0 binds the rest of
359
+ * the buffer from offset.
360
+ *
361
+ * @param desc the builder
362
+ * @param binding the binding number
363
+ * @param buffer the buffer bound
364
+ * @param offset the byte offset into buffer
365
+ * @param size the bytes bound, or 0 for the rest of the buffer
366
+ * @returns 0, or -1 once the builder holds 16
367
+ */
368
+ export declare function nishgfx_bind_group_desc_buffer(desc: NishGfxBindGroupDesc, binding: u32, buffer: NishGfxBuffer, offset: u64, size: u64): i32
369
+ /**
370
+ * Build the bind group and free the builder, either way.
371
+ *
372
+ * @param device the device it lives on
373
+ * @param desc the builder, freed by this call
374
+ * @returns the bind group, or null when it cannot be built
375
+ */
376
+ export declare function nishgfx_bind_group_create(device: NishGfxDevice, desc: NishGfxBindGroupDesc): NishGfxBindGroup | null
377
+ /**
378
+ * Release a bind group.
379
+ *
380
+ * @param group the bind group to release
381
+ */
382
+ export declare function nishgfx_bind_group_release(group: NishGfxBindGroup): void
383
+ /**
384
+ * A command encoder on the device.
385
+ *
386
+ * @param device the device whose commands it records
387
+ * @returns the encoder, or null when wgpu-native or memory answers none
388
+ */
389
+ export declare function nishgfx_encoder_create(device: NishGfxDevice): NishGfxEncoder | null
390
+ /**
391
+ * Finish the encoder, submit it on the device's queue, and free it.
392
+ *
393
+ * @param device the device whose queue runs it
394
+ * @param encoder the encoder, freed by this call
395
+ */
396
+ export declare function nishgfx_encoder_submit(device: NishGfxDevice, encoder: NishGfxEncoder): void
397
+ /**
398
+ * A render pass on one color view. load != 0 keeps the view's contents;
399
+ * otherwise it is cleared to (r, g, b, a).
400
+ *
401
+ * @param encoder the encoder that records it
402
+ * @param view the color view it draws into
403
+ * @param load nonzero to keep the view's contents
404
+ * @param r the clear color's red, 0 to 1
405
+ * @param g the clear color's green, 0 to 1
406
+ * @param b the clear color's blue, 0 to 1
407
+ * @param a the clear color's alpha, 0 to 1
408
+ * @returns the pass, or null for a null encoder or view or when it cannot begin
409
+ */
410
+ export declare function nishgfx_pass_begin(encoder: NishGfxEncoder, view: NishGfxView, load: u32, r: f64, g: f64, b: f64, a: f64): NishGfxPass | null
411
+ /**
412
+ * Set the pass's pipeline.
413
+ *
414
+ * @param pass the pass
415
+ * @param pipeline the pipeline the next draws use
416
+ */
417
+ export declare function nishgfx_pass_set_pipeline(pass: NishGfxPass, pipeline: NishGfxPipeline): void
418
+ /**
419
+ * Set a bind group of the pass.
420
+ *
421
+ * @param pass the pass
422
+ * @param index the group's index in the pipeline's layout
423
+ * @param group the bind group, or null
424
+ */
425
+ export declare function nishgfx_pass_set_bind_group(pass: NishGfxPass, index: u32, group: NishGfxBindGroup | null): void
426
+ /**
427
+ * Set a vertex buffer of the pass. size 0 binds the rest of the buffer from
428
+ * offset.
429
+ *
430
+ * @param pass the pass
431
+ * @param slot the vertex buffer slot
432
+ * @param buffer the buffer, or null
433
+ * @param offset the byte offset into buffer
434
+ * @param size the bytes bound, or 0 for the rest of the buffer
435
+ */
436
+ export declare function nishgfx_pass_set_vertex_buffer(pass: NishGfxPass, slot: u32, buffer: NishGfxBuffer | null, offset: u64, size: u64): void
437
+ /**
438
+ * Draw vertices with the pass's pipeline.
439
+ *
440
+ * @param pass the pass
441
+ * @param vertices how many vertices to draw
442
+ * @param instances how many instances to draw
443
+ * @param first_vertex the first vertex's index
444
+ * @param first_instance the first instance's index
445
+ */
446
+ export declare function nishgfx_pass_draw(pass: NishGfxPass, vertices: u32, instances: u32, first_vertex: u32, first_instance: u32): void
447
+ /**
448
+ * End the pass and free it.
449
+ *
450
+ * @param pass the pass, freed by this call
451
+ */
452
+ export declare function nishgfx_pass_end(pass: NishGfxPass): void
453
+ /**
454
+ * A width x height RGBA8Unorm render target with readback; needs no window
455
+ * and initialises no SDL video.
456
+ *
457
+ * @param device the device it lives on
458
+ * @param width the width in pixels, 1 to 16384
459
+ * @param height the height in pixels, 1 to 16384
460
+ * @returns the target, or null for a side outside 1 to 16384 or when the
461
+ * device answers none
462
+ */
463
+ export declare function nishgfx_offscreen_create(device: NishGfxDevice, width: u32, height: u32): NishGfxOffscreen | null
464
+ /**
465
+ * Release an offscreen target.
466
+ *
467
+ * @param offscreen the target to release
468
+ */
469
+ export declare function nishgfx_offscreen_release(offscreen: NishGfxOffscreen): void
470
+ /**
471
+ * The target's view, valid until the offscreen is released.
472
+ *
473
+ * @param offscreen the target
474
+ * @returns the view, or null for a null target
475
+ */
476
+ export declare function nishgfx_offscreen_view(offscreen: NishGfxOffscreen): NishGfxView | null
477
+ /**
478
+ * Copy the target's pixels, width * 4 bytes per row, top row first, into dst.
479
+ *
480
+ * @param offscreen the target to read
481
+ * @param dst the buffer the pixels are copied into
482
+ * @param cap the bytes dst holds
483
+ * @returns 0; -1 when cap < width * height * 4 (dst untouched); -2 when the
484
+ * map fails (an error is queued on the device)
485
+ */
486
+ export declare function nishgfx_offscreen_read(offscreen: NishGfxOffscreen, dst: u8[], cap: u64): i32
487
+
488
+ /* Not bound:
489
+ * NISH_GFX_H: an empty macro
490
+ */
package/std/json-equal.ts CHANGED
@@ -89,16 +89,15 @@ const jsonEqualSetAt = (a: i32[], i: i32, x: i32): void => {
89
89
  }
90
90
 
91
91
  /**
92
- * The member positions of object `v` in key order, with every key put
93
- * in `keys` by its position. A bottom-up merge sort: `n log n` comparisons and
94
- * no recursion. Keys in one object are distinct, so the order is total.
92
+ * The member positions of an object in key order, given its `keys` by
93
+ * position. A bottom-up merge sort: `n log n` comparisons and no recursion.
94
+ * Keys in one object are distinct, so the order is total.
95
95
  */
96
- const jsonEqualSortedMembers = (doc: JsonDocument, v: i32, keys: string[]): i32[] => {
97
- const n: i32 = doc.length(v)
96
+ const jsonEqualSortedMembers = (keys: string[]): i32[] => {
97
+ const n: i32 = toI32(keys.length)
98
98
  let order: i32[] = []
99
99
  let spare: i32[] = []
100
100
  for (let i: i32 = 0; i < n; i++) {
101
- keys.push(doc.keyAt(v, i))
102
101
  order.push(i)
103
102
  spare.push(i)
104
103
  }
@@ -165,13 +164,22 @@ export const jsonEqual = (da: JsonDocument, a: i32, db: JsonDocument, b: i32): b
165
164
  const left: i32[] = [a]
166
165
  const right: i32[] = [b]
167
166
  while (left.length > 0) {
168
- const x: i32 = left[left.length - 1]
167
+ // Never taken, as the loop's test says; the spelling is what proves the index and the pop.
168
+ const top: i32 = toI32(left.length) - 1
169
+ if (top < 0) {
170
+ break
171
+ }
172
+ const x: i32 = left[top]
169
173
  left.pop()
170
174
  // Never taken: the two stacks are pushed in pairs, so they empty together.
171
- if (right.length === 0) {
175
+ // The prover needs both halves, `rightTop` for the index and the length
176
+ // for the pop; it does not carry one to the other.
177
+ const rightTop: i32 = toI32(right.length) - 1
178
+ // biome-ignore lint/style/useExplicitLengthCheck: `< 1` is the form that proves `right.pop()` below
179
+ if (rightTop < 0 || right.length < 1) {
172
180
  return false
173
181
  }
174
- const y: i32 = right[right.length - 1]
182
+ const y: i32 = right[rightTop]
175
183
  right.pop()
176
184
  const kind: i32 = da.kind(x)
177
185
  if (kind === JSON_VALUE_NONE || kind !== db.kind(y)) {
@@ -200,10 +208,10 @@ export const jsonEqual = (da: JsonDocument, a: i32, db: JsonDocument, b: i32): b
200
208
  right.push(db.at(y, i))
201
209
  }
202
210
  } else {
203
- const keysX: string[] = []
204
- const keysY: string[] = []
205
- const orderX: i32[] = jsonEqualSortedMembers(da, x, keysX)
206
- const orderY: i32[] = jsonEqualSortedMembers(db, y, keysY)
211
+ const keysX: string[] = da.keys(x)
212
+ const keysY: string[] = db.keys(y)
213
+ const orderX: i32[] = jsonEqualSortedMembers(keysX)
214
+ const orderY: i32[] = jsonEqualSortedMembers(keysY)
207
215
  for (let i: i32 = 0; i < n; i++) {
208
216
  const mx: i32 = jsonEqualAt(orderX, i)
209
217
  const my: i32 = jsonEqualAt(orderY, i)
@@ -251,13 +259,20 @@ const jsonEqualCanonicalText = (doc: JsonDocument, v: i32): string => {
251
259
  const tasks: i32[] = [v]
252
260
  const keyStack: string[] = []
253
261
  while (tasks.length > 0) {
254
- const x: i32 = tasks[tasks.length - 1]
262
+ // Never taken, as the loop's test says; the spelling is what proves the index and the pop.
263
+ const top: i32 = toI32(tasks.length) - 1
264
+ if (top < 0) {
265
+ break
266
+ }
267
+ const x: i32 = tasks[top]
255
268
  tasks.pop()
256
269
  if (x === JSON_EQUAL_KEY_TASK) {
257
270
  // Each key task is pushed with its key, so the key stack holds one here.
258
- if (keyStack.length > 0) {
259
- jsonEqualPutText(out, keyStack[keyStack.length - 1])
271
+ const keyTop: i32 = toI32(keyStack.length) - 1
272
+ if (keyTop >= 0 && keyStack.length > 0) {
273
+ const key: string = keyStack[keyTop]
260
274
  keyStack.pop()
275
+ jsonEqualPutText(out, key)
261
276
  }
262
277
  continue
263
278
  }
@@ -280,8 +295,8 @@ const jsonEqualCanonicalText = (doc: JsonDocument, v: i32): string => {
280
295
  } else {
281
296
  const n: i32 = doc.length(x)
282
297
  jsonEqualPut(out, `o${n}:`)
283
- const keys: string[] = []
284
- const order: i32[] = jsonEqualSortedMembers(doc, x, keys)
298
+ const keys: string[] = doc.keys(x)
299
+ const order: i32[] = jsonEqualSortedMembers(keys)
285
300
  // Pushed last member first, each value before its key, so the key pops first.
286
301
  for (let i: i32 = n; i > 0; i--) {
287
302
  const m: i32 = jsonEqualAt(order, i - 1)
@@ -129,6 +129,25 @@ const JF_QUERY: i32 = 5 // the fragment's set, and `iprivate` in an IRI
129
129
  */
130
130
  const jfUnitAt = (s: string, i: i32): i32 => (i >= 0 && i < toI32(s.length) ? toI32(s.charCodeAt(i)) : -1)
131
131
 
132
+ /**
133
+ * Where the `w` units of `s` from `i` end, `i + w`, or -1 when either is
134
+ * negative or they run past `s`. The widths the grammar counts are units of
135
+ * `s`, so a caller never sees -1; it is spelled as differences, each of which
136
+ * `src/bounds.ts` proves, so the step needs no overflow check.
137
+ */
138
+ const jfStep = (s: string, i: i32, w: i32): i32 => {
139
+ const length: i32 = toI32(s.length)
140
+ if (i < 0 || w < 0) {
141
+ return -1
142
+ }
143
+ const room: i32 = length - i
144
+ if (room < 0) {
145
+ return -1
146
+ }
147
+ const gap: i32 = room - w
148
+ return gap < 0 ? -1 : length - gap
149
+ }
150
+
132
151
  const jfIsDigit = (c: i32): boolean => c >= 48 && c <= 57
133
152
 
134
153
  const jfIsAlpha = (c: i32): boolean => (c >= 65 && c <= 90) || (c >= 97 && c <= 122)
@@ -796,8 +815,10 @@ const jfUriRun = (s: string, from: i32, to: i32, set: i32, iri: boolean): boolea
796
815
  if (w === 0) {
797
816
  return false
798
817
  }
799
- // The `w` units are in `s`, so the `u32` sum is at most its length.
800
- i = toI32(toU32(i) + toU32(w))
818
+ i = jfStep(s, i, w)
819
+ if (i < 0) {
820
+ return false
821
+ }
801
822
  }
802
823
  return i === to
803
824
  }
@@ -1016,8 +1037,10 @@ const jfExpressionEnd = (s: string, open: i32): i32 => {
1016
1037
  if (w === 0) {
1017
1038
  return -1
1018
1039
  }
1019
- // `jfVarchar` counts only units of `s`, so the sum is at most its length.
1020
- i = toI32(toU32(i) + toU32(w))
1040
+ i = jfStep(s, i, w)
1041
+ if (i < 0) {
1042
+ return -1
1043
+ }
1021
1044
  while (i < length) {
1022
1045
  if (jfUnitAt(s, i) === 46) {
1023
1046
  const name = i + 1
@@ -1025,13 +1048,19 @@ const jfExpressionEnd = (s: string, open: i32): i32 => {
1025
1048
  if (w === 0) {
1026
1049
  return -1
1027
1050
  }
1028
- i = toI32(toU32(name) + toU32(w))
1051
+ i = jfStep(s, name, w)
1052
+ if (i < 0) {
1053
+ return -1
1054
+ }
1029
1055
  } else {
1030
1056
  w = jfVarchar(s, i)
1031
1057
  if (w === 0) {
1032
1058
  break
1033
1059
  }
1034
- i = toI32(toU32(i) + toU32(w))
1060
+ i = jfStep(s, i, w)
1061
+ if (i < 0) {
1062
+ return -1
1063
+ }
1035
1064
  }
1036
1065
  }
1037
1066
  // An expression ends with a `}`, so running out of text is not one.
@@ -1124,8 +1153,10 @@ export const isUriTemplate = (s: string): boolean => {
1124
1153
  if (w === 0) {
1125
1154
  return false
1126
1155
  }
1127
- // `jfUcsWidth` counts only units of `s`, so the sum is at most its length.
1128
- i = toI32(toU32(i) + toU32(w))
1156
+ i = jfStep(s, i, w)
1157
+ if (i < 0) {
1158
+ return false
1159
+ }
1129
1160
  }
1130
1161
  }
1131
1162
  return true