@solidrt/flux-types 0.0.46 → 0.0.48

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 CHANGED
@@ -95,7 +95,10 @@ declare module "flux:gpu" {
95
95
  * Shader uniform values by name. A number drives a scalar uniform (`float`,
96
96
  * or `int`/`bool`, truncated); a flat number array drives a typed uniform
97
97
  * whose declared GLSL type sets the expected length: 2/3/4 for
98
- * `vec2`/`vec3`/`vec4`, 16 (column-major) for `mat4`. Dispatch follows the
98
+ * `vec2`/`vec3`/`vec4`, 16 (column-major) for `mat4`. An array uniform
99
+ * (`vec3 uLight[4]`) goes by its bare name and takes one flat array of
100
+ * element length times array size (12 here; a light list or palette is one
101
+ * write). Dispatch follows the
99
102
  * shader's own declaration, and every write is validated against it at the
100
103
  * call site: a name with no active uniform, a value whose length does not
101
104
  * fit the declared type, a `sampler2D` named here (samplers bind via
@@ -676,12 +679,14 @@ declare module "flux:gpu" {
676
679
  * shared value (specific beats general), and they are target state: entry
677
680
  * add/remove/rebuild cannot lose them. A draw target legitimately mixes
678
681
  * 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.
682
+ * programs declare is applied where declared and skipped elsewhere - down
683
+ * to zero coverage: a name no current entry declares is stored and skips
684
+ * everywhere until a declaring entry arrives, so shared state does not
685
+ * depend on write order (a seed before entries and a write after are the
686
+ * same state). Validation is arity where declared: a name must match the
687
+ * declared component count in every entry program that declares it; an
688
+ * entry added later whose program lacks an already-set name is never a
689
+ * retroactive error, the value just skips it.
685
690
  */
686
691
  export function setTargetParams(target: TextureId, params: ShaderParams): void
687
692
  /**
@@ -702,12 +707,12 @@ declare module "flux:gpu" {
702
707
  * reads - an environment map, a shadow map, a LUT - bound once per
703
708
  * target, with the shared-params rules throughout: an entry's own binding
704
709
  * 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.
710
+ * binds where declared and is skipped elsewhere, down to zero coverage
711
+ * (an undeclared name is stored, joins the sampler graph, and binds when
712
+ * a declaring entry arrives); shared bindings are target state that entry
713
+ * add/remove/rebuild cannot lose. Each name must be a sampler2D
714
+ * everywhere it is declared, and each entry's effective inputs (its own
715
+ * plus the applicable shared ones) must fit the device's texture units.
711
716
  */
712
717
  export function setTargetTextures(target: TextureId, textures: Record<string, TextureId>): void
713
718
  /**
@@ -773,7 +778,8 @@ declare module "flux:gpu" {
773
778
  */
774
779
  export function copyTexture(src: TextureId, dst: TextureId): void
775
780
  /**
776
- * Capture a render-tree node's subtree into a new GPU texture, resolving once
781
+ * Capture a render-tree node's subtree as RGBA8 pixels (tightly packed,
782
+ * top-to-bottom rows - the {@link readTexture} result shape), resolving once
777
783
  * it has been rendered on the next paint pass. The node must be attached to
778
784
  * the live tree (an unmounted node is never painted, so its capture rejects)
779
785
  * and paint a non-zero box. A laid-out node captures its layout box. A `d-*`
@@ -781,34 +787,32 @@ declare module "flux:gpu" {
781
787
  * painted box instead: its own `w`/`h` when set, else the nearest laid-out
782
788
  * ancestor's box (the same box the render tree reports for it), with its
783
789
  * `x`/`y` paint offset mapped to the texture origin.
784
- * Rendered at the current display scale, so `width`/`height` are the texture's
785
- * actual pixel dimensions (ceil(logicalSize * displayScale)), not logical
786
- * points. Each call returns an independent id you must {@link destroyTexture}
787
- * when done. Use the returned id anywhere a texture id is accepted
788
- * (`<texture src>`, a shader sampler input, {@link readTexture}).
790
+ * Rendered at the current display scale, so `width`/`height` are actual
791
+ * pixel dimensions (ceil(logicalSize * displayScale)), not logical points.
792
+ * No texture is created and there is nothing to free; to display or sample
793
+ * the result, upload it with {@link createTexture}.
789
794
  *
790
795
  * Intended for one-shot bakes and inspection: turning something the engine
791
796
  * can draw but the app cannot compute - shaped text, an SVG, a themed view -
792
- * into pixels, usually to hand to {@link readTexture} and process on the CPU.
793
- * Baking a glyph atlas by laying out cells, capturing them and keeping the
794
- * coverage channel is the worked example. Tests and freeze-frames are the
795
- * same shape.
797
+ * into pixels the app processes on the CPU. Baking a glyph atlas by laying
798
+ * out cells, capturing them and keeping the coverage channel is the worked
799
+ * example. Tests and freeze-frames are the same shape.
796
800
  *
797
801
  * Not a rendering primitive. Every call rasterizes the subtree into a fresh
798
- * offscreen MSAA target, reads the pixels back to the CPU and uploads them
799
- * again as a new texture: a full GPU -> CPU -> GPU round trip plus a paint
800
- * pass of latency, per call, with nothing incremental about it. Batch what
801
- * you capture (many nodes captured together are serviced by one paint pass),
802
- * and do not drive it per frame or reach for it to feed live content into a
803
- * shader - an effect over what is beneath it, a backdrop filter. Content that
804
- * must stay current has to come from a source that updates in place: another
805
- * pipeline's render target, a camera texture, a mutable texture.
802
+ * offscreen MSAA target and reads the pixels back to the CPU: a GPU -> CPU
803
+ * readback stall plus a paint pass of latency, per call, with nothing
804
+ * incremental about it. Batch what you capture (many nodes captured together
805
+ * are serviced by one paint pass), and do not drive it per frame or reach
806
+ * for it to feed live content into a shader - an effect over what is beneath
807
+ * it, a backdrop filter. Content that must stay current has to come from a
808
+ * source that updates in place: another pipeline's render target, a camera
809
+ * texture, a mutable texture.
806
810
  */
807
- export function captureSnapshot(nodeId: number): Promise<{ id: TextureId; width: number; height: number }>
811
+ export function captureSnapshot(nodeId: number): Promise<{ width: number; height: number; data: Uint8Array }>
808
812
  /**
809
813
  * Read back a registered texture's current pixels as RGBA8 (tightly packed,
810
814
  * top-to-bottom rows), for any texture id whatever created it (createTexture,
811
- * createShaderTexture, captureSnapshot). Synchronous. Throws if the id is
815
+ * createShaderTexture, a render target). Synchronous. Throws if the id is
812
816
  * unknown.
813
817
  */
814
818
  export function readTexture(id: TextureId): { width: number; height: number; data: Uint8Array }
@@ -28,7 +28,13 @@ declare module "flux:rendertree" {
28
28
  export function detachNode(parentId: number, nodeId: number): void
29
29
  /** Free `nodeId` and its whole subtree. Call after {@link detachNode}. */
30
30
  export function destroyNode(nodeId: number): void
31
- /** Write a single property on a node; `value` is marshalled per property. */
31
+ /**
32
+ * Write a single property on a node; `value` is marshalled per property.
33
+ * Throws an `Error` for an unknown property name (message starts with
34
+ * "Unknown property") or a value that does not decode; it never aborts the
35
+ * runtime. Core's renderer warns-and-continues on the name-level rejections
36
+ * and rethrows value errors.
37
+ */
32
38
  export function setProperty(nodeId: number, name: string, value: unknown): void
33
39
  /**
34
40
  * Declare which pointer deliveries the node's handlers want, as a bitmask
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/flux-types",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "license": "MIT",
5
5
  "author": "Antoine van Wel",
6
6
  "types": "index.d.ts",
@@ -10,7 +10,8 @@
10
10
  declare function btoa(data: string): string
11
11
  /**
12
12
  * Base64-decode to a binary string: each decoded byte becomes one char code
13
- * (read the bytes back with `charCodeAt`). ASCII whitespace in the input is
14
- * ignored; anything else that is not valid base64 throws.
13
+ * (read the bytes back with `charCodeAt`). Forgiving per WHATWG: ASCII
14
+ * whitespace is ignored and missing `=` padding is tolerated; anything else
15
+ * that is not valid base64 throws.
15
16
  */
16
17
  declare function atob(data: string): string
@@ -4,12 +4,16 @@
4
4
  // Grouped in one file because the four share BodyInit/HeadersInit and reference
5
5
  // each other.
6
6
 
7
- /** Header initializer: a plain name -> value object, or another Headers. */
7
+ /**
8
+ * Header initializer: a plain name -> value object, or another Headers.
9
+ * Values must be strings: a non-string value throws (the web stringifies it).
10
+ */
8
11
  type HeadersInit = Record<string, string> | Headers
9
12
 
10
13
  /**
11
14
  * A message body: a string, raw bytes, or an async-iterable of string/byte
12
- * chunks (e.g. an `async function*`), which is sent as a stream.
15
+ * chunks (e.g. an `async function*`), which is sent as a stream. Any other
16
+ * value throws (the web stringifies it).
13
17
  */
14
18
  type BodyInit = string | Uint8Array | AsyncIterable<string | Uint8Array>
15
19
 
@@ -1,6 +1,15 @@
1
1
  // Timers, microtask scheduling, and the monotonic clock. flux's timers differ
2
2
  // from the browser in two ways: the delay is required, and no extra callback
3
3
  // arguments are forwarded.
4
+ //
5
+ // In a GUI runtime the whole time surface here is FRAME-STEPPED: timers and
6
+ // performance.now() march on the same paced timeline as onFrame and
7
+ // requestAnimationFrame, quantized to frames. So timer resolution is one
8
+ // frame (~16 ms at 60 Hz; a setTimeout of 0 runs on the next frame), an
9
+ // interval fires at most once per frame, and pausing the runtime clock (the
10
+ // dev tools' set_time_scale 0) freezes all of it together deterministically.
11
+ // Date.now() is the wall-clock escape hatch: it always reports real calendar
12
+ // time. Headless flux (scripts, servers) keeps ordinary wall-clock timers.
4
13
 
5
14
  /**
6
15
  * Run `callback` after at least `ms` milliseconds. Returns a timer id for
@@ -25,7 +34,16 @@ declare function queueMicrotask(callback: () => void): void
25
34
  declare let performance: {
26
35
  /**
27
36
  * Milliseconds since a monotonic origin (high-resolution, not wall-clock). Use
28
- * for measuring durations, not for calendar time.
37
+ * for measuring durations, not for calendar time. In a GUI runtime this is
38
+ * the paced frame timeline (same clock as the onFrame/requestAnimationFrame
39
+ * timestamps, frozen while the runtime clock is paused); for real elapsed
40
+ * wall time use Date.now().
29
41
  */
30
42
  now(): number
43
+ /**
44
+ * Wall-clock time (ms since the Unix epoch) when the runtime started. Unlike
45
+ * the browser, timeOrigin + now() is not the current wall-clock time: now()
46
+ * runs on the paced runtime timeline, which can be frozen or scaled.
47
+ */
48
+ readonly timeOrigin: number
31
49
  }