@solidrt/flux-types 0.0.45 → 0.0.46
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/gui/gpu.d.ts +87 -40
- package/index.d.ts +1 -0
- package/modules/image.d.ts +24 -0
- package/modules/process.d.ts +4 -2
- package/package.json +1 -1
package/gui/gpu.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ declare module "flux:gpu" {
|
|
|
123
123
|
* messages, so a chain of targets reads as "bloom-h samples particle-verts"
|
|
124
124
|
* instead of anonymous ids. Not unique, never interpreted; set at create,
|
|
125
125
|
* kept across id-stable resizes ({@link resizeTexture},
|
|
126
|
-
* {@link
|
|
126
|
+
* {@link setTargetSize}).
|
|
127
127
|
*/
|
|
128
128
|
export type LabelOption = { label?: string }
|
|
129
129
|
/**
|
|
@@ -186,8 +186,8 @@ declare module "flux:gpu" {
|
|
|
186
186
|
* working, and shaders sampling the texture re-render. `data` seeds the new
|
|
187
187
|
* contents and, like {@link createMutableTexture}, must hold at least one
|
|
188
188
|
* frame at the id's format (which survives the resize, like the sampler
|
|
189
|
-
* state).
|
|
190
|
-
* {@link
|
|
189
|
+
* state). Render target ids are rejected - resize those with
|
|
190
|
+
* {@link setTargetSize}.
|
|
191
191
|
*/
|
|
192
192
|
export function resizeTexture(id: TextureId, data: Uint8Array, width: number, height: number): void
|
|
193
193
|
/**
|
|
@@ -205,7 +205,7 @@ declare module "flux:gpu" {
|
|
|
205
205
|
* for the value shapes and the validation contract - a typo'd name throws
|
|
206
206
|
* here, at the create). It is its own argument, not an option, because it
|
|
207
207
|
* is the initial value of a live channel - the same values the `<texture
|
|
208
|
-
* params>` prop and {@link
|
|
208
|
+
* params>` prop and {@link setTargetParams} drive later; pass `null` (or
|
|
209
209
|
* omit it) for a shader with none. `opts.textures` binds sampler2D
|
|
210
210
|
* uniforms to texture ids - any texture id, including another
|
|
211
211
|
* shader/pipeline target's output, under a name that must be an active
|
|
@@ -328,8 +328,8 @@ declare module "flux:gpu" {
|
|
|
328
328
|
* Create a render target over a {@link createRenderPipeline} pipeline and
|
|
329
329
|
* render it once: the target half of {@link createPipelineTexture}. Returns
|
|
330
330
|
* a texture id exactly like the fused creates do (drive uniforms
|
|
331
|
-
* via the `params` prop or {@link
|
|
332
|
-
* {@link
|
|
331
|
+
* via the `params` prop or {@link setTargetParams}, resize with
|
|
332
|
+
* {@link setTargetSize}, destroy with {@link destroyTexture}). Many targets
|
|
333
333
|
* may share one pipeline, and creating a target compiles nothing. `buffer`
|
|
334
334
|
* supplies the concrete vertex buffer the pipeline's attribute layout
|
|
335
335
|
* describes (required when the pipeline declares attributes), and
|
|
@@ -385,36 +385,6 @@ declare module "flux:gpu" {
|
|
|
385
385
|
* immediately.
|
|
386
386
|
*/
|
|
387
387
|
export function destroyProgram(id: ProgramId): void
|
|
388
|
-
/**
|
|
389
|
-
* Update a shader texture's uniforms by name and re-render it (see
|
|
390
|
-
* {@link ShaderParams} for the value shapes and the validation contract -
|
|
391
|
-
* an unknown name or a mismatched length throws here, on the line that
|
|
392
|
-
* wrote it). On a manual target nothing renders here; the values apply at
|
|
393
|
-
* its next {@link renderTarget}.
|
|
394
|
-
*/
|
|
395
|
-
export function setShaderParams(id: TextureId, params: ShaderParams): void
|
|
396
|
-
/**
|
|
397
|
-
* Rebind a shader texture's sampler2D inputs by uniform name and re-render
|
|
398
|
-
* it with its last-applied params - the sampler analog of
|
|
399
|
-
* {@link setShaderParams}. Bindings not named keep their current source, so
|
|
400
|
-
* a single input can be retargeted (post-process source swap, ping-pong
|
|
401
|
-
* between two data textures) without recompiling the shader. Throws if the
|
|
402
|
-
* shader or a source texture id is unknown, if a binding names anything
|
|
403
|
-
* but an active `sampler2D` uniform, if it names the shader's own target
|
|
404
|
-
* (same-pass feedback), or if it would close a sampling cycle among
|
|
405
|
-
* runtime-rendered targets. A cycle through a
|
|
406
|
-
* `render: "manual"` target is legal - the runtime never renders one, so
|
|
407
|
-
* the loop only steps when the app calls {@link renderTarget}.
|
|
408
|
-
*/
|
|
409
|
-
export function setShaderTextures(id: TextureId, textures: Record<string, TextureId>): void
|
|
410
|
-
/**
|
|
411
|
-
* Resize a shader or pipeline target texture in place and re-render it: the
|
|
412
|
-
* id, compiled program, last-applied params, and sampler bindings all carry
|
|
413
|
-
* over; only the output size changes. The setDraw analog for output
|
|
414
|
-
* size.
|
|
415
|
-
*/
|
|
416
|
-
export function setShaderSize(id: TextureId, width: number, height: number): void
|
|
417
|
-
|
|
418
388
|
export type Topology = "points" | "lines" | "line-strip" | "triangles" | "triangle-strip"
|
|
419
389
|
/**
|
|
420
390
|
* Blending for a pipeline's own draw. "none" (default) overwrites:
|
|
@@ -526,7 +496,7 @@ declare module "flux:gpu" {
|
|
|
526
496
|
* {@link renderTarget}, and `loadOp: "load"` (manual-only) keeps the
|
|
527
497
|
* previous contents under each draw.
|
|
528
498
|
* Returns a texture id: display it with `<texture src>`, drive uniforms via
|
|
529
|
-
* the `params` prop or {@link
|
|
499
|
+
* the `params` prop or {@link setTargetParams}, destroy with
|
|
530
500
|
* {@link destroyTexture}.
|
|
531
501
|
*/
|
|
532
502
|
export function createPipelineTexture(
|
|
@@ -605,6 +575,15 @@ declare module "flux:gpu" {
|
|
|
605
575
|
* entry tests/writes depth is its pipeline's `depth`/`depthWrite` state,
|
|
606
576
|
* and adding a depth-testing pipeline to a target without storage throws.
|
|
607
577
|
*
|
|
578
|
+
* `params` seeds the target's SHARED params - the target-level values
|
|
579
|
+
* every entry reads, the same live channel {@link setTargetParams} drives
|
|
580
|
+
* later (positional like every create's params; see there for the
|
|
581
|
+
* precedence and validation contract). `opts.textures` seeds the shared
|
|
582
|
+
* sampler bindings the same way, the channel {@link setTargetTextures}
|
|
583
|
+
* drives (in opts like every create's textures). At creation there are no
|
|
584
|
+
* entries to validate against, so names are accepted as-is and simply
|
|
585
|
+
* apply to whichever later entries' programs declare them.
|
|
586
|
+
*
|
|
608
587
|
* The render contract is unchanged: the list is input data like params, so
|
|
609
588
|
* "render twice = render once" still holds and the default `render:
|
|
610
589
|
* "auto"` target re-renders exactly when its entries or their inputs
|
|
@@ -618,8 +597,10 @@ declare module "flux:gpu" {
|
|
|
618
597
|
export function createDrawTarget(
|
|
619
598
|
width: number,
|
|
620
599
|
height: number,
|
|
600
|
+
params?: ShaderParams | null,
|
|
621
601
|
opts?: {
|
|
622
602
|
depth?: boolean
|
|
603
|
+
textures?: Record<string, TextureId>
|
|
623
604
|
clearColor?: [number, number, number, number]
|
|
624
605
|
render?: "auto" | "manual"
|
|
625
606
|
loadOp?: "clear" | "load"
|
|
@@ -646,6 +627,14 @@ declare module "flux:gpu" {
|
|
|
646
627
|
* `instanceBuffer` supplies the per-instance records the pipeline's
|
|
647
628
|
* `instanceAttributes` describe (required exactly when it declares any);
|
|
648
629
|
* `instanceCount` then defaults to one instance per record.
|
|
630
|
+
*
|
|
631
|
+
* Seed every uniform the entry's program declares - here, via the
|
|
632
|
+
* target's shared params, or with a later write. GL uniform state lives
|
|
633
|
+
* on the program object, so a declared name nothing writes holds
|
|
634
|
+
* whatever the last draw through that program applied, from any entry
|
|
635
|
+
* or target sharing it - not zero (only a freshly linked program reads
|
|
636
|
+
* the link-time zero). Coverage is deliberately not validated here:
|
|
637
|
+
* adding entries first and setting shared values after is legal.
|
|
649
638
|
*/
|
|
650
639
|
export function addDraw(
|
|
651
640
|
target: TextureId,
|
|
@@ -665,15 +654,73 @@ declare module "flux:gpu" {
|
|
|
665
654
|
*/
|
|
666
655
|
export function removeDraw(target: TextureId, draw: DrawId): void
|
|
667
656
|
/**
|
|
668
|
-
* Update one draw entry's uniforms by name: {@link
|
|
657
|
+
* Update one draw entry's uniforms by name: {@link setTargetParams}
|
|
669
658
|
* addressed to a single entry, same merge and validation contract. The
|
|
670
659
|
* per-object hot path - a moved mesh is one setDrawParams with its new
|
|
671
660
|
* model matrix.
|
|
672
661
|
*/
|
|
673
662
|
export function setDrawParams(target: TextureId, draw: DrawId, params: ShaderParams): void
|
|
663
|
+
/**
|
|
664
|
+
* Update a target's target-level uniforms by name, on any target kind,
|
|
665
|
+
* with the usual merge-by-name (see {@link ShaderParams} for value shapes;
|
|
666
|
+
* a bad name or a mismatched length throws here, on the line that wrote
|
|
667
|
+
* it). On a single-program target (a fragment texture or a pipeline
|
|
668
|
+
* target) the target level IS its one pass: every name validates against
|
|
669
|
+
* that program and the target re-renders. On a manual target nothing
|
|
670
|
+
* renders here; the values apply at its next {@link renderTarget}.
|
|
671
|
+
*
|
|
672
|
+
* On a draw target these are the SHARED params: values every entry reads
|
|
673
|
+
* - a camera's view-projection above all - written once per target
|
|
674
|
+
* instead of once per entry. Shared values apply at render before each
|
|
675
|
+
* entry's own params, so an entry naming the same uniform overrides the
|
|
676
|
+
* shared value (specific beats general), and they are target state: entry
|
|
677
|
+
* add/remove/rebuild cannot lose them. A draw target legitimately mixes
|
|
678
|
+
* material classes, so coverage may be partial: a name only some entries'
|
|
679
|
+
* programs declare is applied where declared and skipped elsewhere.
|
|
680
|
+
* Validation follows: each name must be an active settable uniform of at
|
|
681
|
+
* least ONE current entry's program (with the matching arity everywhere it
|
|
682
|
+
* is declared) - a name no entry declares throws. With no entries yet,
|
|
683
|
+
* names are accepted as-is; an entry added later whose program lacks an
|
|
684
|
+
* already-set name is never a retroactive error, the value just skips it.
|
|
685
|
+
*/
|
|
686
|
+
export function setTargetParams(target: TextureId, params: ShaderParams): void
|
|
687
|
+
/**
|
|
688
|
+
* Rebind a target's target-level sampler2D inputs by uniform name, on any
|
|
689
|
+
* target kind - {@link setTargetParams}'s sampler analog. Bindings not
|
|
690
|
+
* named keep their current source, so a single input can be retargeted
|
|
691
|
+
* (post-process source swap, ping-pong between two data textures) without
|
|
692
|
+
* recompiling anything. Bound sources are live dependencies: the target
|
|
693
|
+
* re-renders when one changes. Every path throws if the target or a
|
|
694
|
+
* source texture id is unknown, if a binding names the target's own
|
|
695
|
+
* texture (same-pass feedback), or if it would close a sampling cycle
|
|
696
|
+
* among runtime-rendered targets; a cycle through a `render: "manual"`
|
|
697
|
+
* target is legal - the runtime never renders one, so the loop only steps
|
|
698
|
+
* when the app calls {@link renderTarget}. On a single-program target each
|
|
699
|
+
* name must be an active `sampler2D` of its one program.
|
|
700
|
+
*
|
|
701
|
+
* On a draw target these are the SHARED bindings: sources every entry
|
|
702
|
+
* reads - an environment map, a shadow map, a LUT - bound once per
|
|
703
|
+
* target, with the shared-params rules throughout: an entry's own binding
|
|
704
|
+
* for the same name wins; a name only some entries' programs declare
|
|
705
|
+
* binds where declared and is skipped elsewhere; shared bindings are
|
|
706
|
+
* target state that entry add/remove/rebuild cannot lose. Each name must
|
|
707
|
+
* be an active sampler2D of at least ONE current entry's program (with no
|
|
708
|
+
* entries yet names are accepted as-is, and a later entry never
|
|
709
|
+
* retroactively errors), and each entry's effective inputs (its own plus
|
|
710
|
+
* the applicable shared ones) must fit the device's texture units.
|
|
711
|
+
*/
|
|
712
|
+
export function setTargetTextures(target: TextureId, textures: Record<string, TextureId>): void
|
|
713
|
+
/**
|
|
714
|
+
* Resize a render target of any kind in place and re-render it: the id,
|
|
715
|
+
* compiled programs, last-applied params, sampler bindings, and draw
|
|
716
|
+
* state all carry over; only the output size changes. The setDraw analog
|
|
717
|
+
* for output size. (Pixel textures resize with {@link resizeTexture},
|
|
718
|
+
* which carries seed pixels instead.)
|
|
719
|
+
*/
|
|
720
|
+
export function setTargetSize(id: TextureId, width: number, height: number): void
|
|
674
721
|
/**
|
|
675
722
|
* Rebind one draw entry's sampler2D inputs by uniform name:
|
|
676
|
-
* {@link
|
|
723
|
+
* {@link setTargetTextures} addressed to a single entry, same merge,
|
|
677
724
|
* validation, and cycle rules. Entries bind independently - two entries
|
|
678
725
|
* may bind the same uniform name to different sources.
|
|
679
726
|
*/
|
|
@@ -698,7 +745,7 @@ declare module "flux:gpu" {
|
|
|
698
745
|
export function setDrawOrder(target: TextureId, order: DrawId[]): void
|
|
699
746
|
/**
|
|
700
747
|
* Render a `render: "manual"` target once, now. Renders land in call order
|
|
701
|
-
* relative to every other GPU call: a `
|
|
748
|
+
* relative to every other GPU call: a `setTargetParams`/`writeBuffer`
|
|
702
749
|
* issued before is visible to the pass, a {@link readTexture} issued after
|
|
703
750
|
* observes it, and two renders run the pass twice in order. Inputs are
|
|
704
751
|
* fresh: pending runtime-driven renders of sampled targets resolve first.
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/// <reference path="./modules/sqlite.d.ts" />
|
|
6
6
|
/// <reference path="./modules/subprocess.d.ts" />
|
|
7
7
|
/// <reference path="./modules/svg.d.ts" />
|
|
8
|
+
/// <reference path="./modules/image.d.ts" />
|
|
8
9
|
/// <reference path="./modules/p2p.d.ts" />
|
|
9
10
|
/// <reference path="./modules/net.d.ts" />
|
|
10
11
|
/// <reference path="./modules/mdns.d.ts" />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare module "flux:image" {
|
|
2
|
+
/** Decoded pixels: tightly-packed RGBA8 plus the pixel dimensions. */
|
|
3
|
+
export type DecodedImage = {
|
|
4
|
+
data: Uint8Array
|
|
5
|
+
width: number
|
|
6
|
+
height: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Decodes encoded image bytes (png, jpeg, webp, gif, bmp, ico) into raw
|
|
11
|
+
* RGBA8 pixels plus the decoded dimensions. Synchronous, pure CPU. Throws
|
|
12
|
+
* when the bytes are not a decodable image.
|
|
13
|
+
*/
|
|
14
|
+
export function decodeImage(bytes: Uint8Array): DecodedImage
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Encodes raw RGBA8 pixels into an image file, the reverse of `decodeImage`
|
|
18
|
+
* (`encodeImage(decodeImage(bytes))` round-trips). `format` defaults to
|
|
19
|
+
* `"png"` (lossless, keeps alpha); `"jpeg"` drops the alpha channel and
|
|
20
|
+
* takes `quality` in 0..1 (default 0.9, ignored for png). Throws when
|
|
21
|
+
* `data.length` does not match `width * height * 4`.
|
|
22
|
+
*/
|
|
23
|
+
export function encodeImage(img: DecodedImage, options?: { format?: "png" | "jpeg"; quality?: number }): Uint8Array
|
|
24
|
+
}
|
package/modules/process.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
declare module "flux:process" {
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
4
|
-
*
|
|
3
|
+
* The arguments the app was started with; empty when there are none.
|
|
4
|
+
* App arguments only: no executable path, no script path (deliberately
|
|
5
|
+
* simpler than Node/Bun's two leading entries), so `argv[0]` is the first
|
|
6
|
+
* argument.
|
|
5
7
|
*/
|
|
6
8
|
export let argv: string[]
|
|
7
9
|
/** The host OS: "darwin", "win32", "linux", "android", ... */
|