@solidrt/flux-types 0.0.23 → 0.0.25

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 CHANGED
@@ -47,7 +47,7 @@ rely on must be named.
47
47
  - `Flux` global (`version`, `capabilities`).
48
48
  - `flux:*` modules: `flux:http`, `flux:fs`, `flux:sqlite`, `flux:subprocess`,
49
49
  `flux:p2p`, `flux:process`, `flux:path`, and (on a gui-enabled runtime)
50
- `flux:camera`, `flux:microphone`, `flux:gpu`.
50
+ `flux:camera`, `flux:microphone`, `flux:audio`, `flux:gpu`.
51
51
  - Web-standard globals: `console`, `fetch` + `Headers`/`Request`/`Response`,
52
52
  `setTimeout`/`setInterval`/`queueMicrotask`, `performance`, `WebSocket`,
53
53
  `TextEncoder`/`TextDecoder`. These are deliberate subsets matching exactly what
package/gui/audio.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ // Sound playback (gui-enabled runtime only). The imperative primitive; `play`
2
+ // decodes and starts a clip in one call, while `load` decodes once so a clip can
3
+ // be replayed cheaply. Handles carry a `stop()` bound to just that voice, so the
4
+ // raw track id never leaves the runtime.
5
+
6
+ declare module "flux:audio" {
7
+ /** Options for {@link play} and {@link LoadedSound.play}. */
8
+ type PlayOptions = {
9
+ /** Repeat the clip until stopped. Defaults to false. */
10
+ loop?: boolean
11
+ /** Volume scale, 1.0 leaves the clip unchanged. Defaults to 1.0. */
12
+ gain?: number
13
+ }
14
+
15
+ /** A playing voice with controls bound to it. */
16
+ type SoundHandle = {
17
+ /** Stop this voice. A no-op if it already finished. */
18
+ stop(): void
19
+ }
20
+
21
+ /** A decoded clip that can be replayed without re-decoding. */
22
+ type LoadedSound = {
23
+ /** Start a fresh overlapping voice for this clip. */
24
+ play(options?: PlayOptions): SoundHandle
25
+ /** Release the decoded clip. Voices already playing keep going. */
26
+ unload(): void
27
+ }
28
+
29
+ /**
30
+ * Decode and start an encoded audio clip (Ogg/Vorbis or WAV). Returns
31
+ * immediately; the sound plays on the mixer's own thread. Use {@link load} to
32
+ * replay a clip repeatedly without decoding it each time.
33
+ */
34
+ export function play(bytes: Uint8Array, options?: PlayOptions): SoundHandle
35
+ /**
36
+ * Decode an encoded clip (Ogg/Vorbis or WAV) once and keep it in memory so it
37
+ * can be replayed cheaply. Call `unload()` on the result when done.
38
+ */
39
+ export function load(bytes: Uint8Array): LoadedSound
40
+ /**
41
+ * Open a clip for streaming: it is decoded on demand instead of loaded fully
42
+ * into memory, so a large track needs little RAM. Takes a `file()` from
43
+ * `flux:fs` (not a path), so the source rides the `file()` proxy override - a
44
+ * dev-server-proxied file streams from the server. Play the result as a single
45
+ * voice; do not overlap a stream with itself. Call `unload()` when done.
46
+ */
47
+ export function stream(source: ReturnType<typeof import("flux:fs").file>): LoadedSound
48
+ /** Stop every playing sound. */
49
+ export function stop(): void
50
+ }
package/gui/gpu.d.ts CHANGED
@@ -36,4 +36,21 @@ declare module "flux:gpu" {
36
36
  ): number
37
37
  /** Update a shader texture's float uniforms by name and re-render it. */
38
38
  export function setShaderParams(id: number, params: Record<string, number>): void
39
+ /**
40
+ * Capture a render-tree node's subtree into a new GPU texture, resolving once
41
+ * it has been rendered on the next paint pass. The node must be attached to
42
+ * the live tree (a detached node is never painted, so its capture rejects).
43
+ * Rendered at the current display scale, so `width`/`height` are the texture's
44
+ * actual pixel dimensions (ceil(logicalSize * displayScale)), not logical
45
+ * points. Each call returns an independent id you must {@link destroyTexture}
46
+ * when done. Use the returned id anywhere a texture id is accepted
47
+ * (`<texture src>`, a shader sampler input, {@link readTexture}).
48
+ */
49
+ export function captureSnapshot(nodeId: number): Promise<{ id: number; width: number; height: number }>
50
+ /**
51
+ * Read back a registered texture's current pixels as RGBA8 (tightly packed,
52
+ * top-to-bottom rows), for any texture id whatever created it (createTexture,
53
+ * createShader, captureSnapshot). Synchronous. Throws if the id is unknown.
54
+ */
55
+ export function readTexture(id: number): { width: number; height: number; data: Uint8Array }
39
56
  }
package/index.d.ts CHANGED
@@ -25,6 +25,7 @@
25
25
  /// <reference path="./gui/rendertree.d.ts" />
26
26
  /// <reference path="./gui/camera.d.ts" />
27
27
  /// <reference path="./gui/microphone.d.ts" />
28
+ /// <reference path="./gui/audio.d.ts" />
28
29
  /// <reference path="./gui/gpu.d.ts" />
29
30
  /// <reference path="./gui/raf.d.ts" />
30
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/flux-types",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "license": "MIT",
5
5
  "author": "Antoine van Wel",
6
6
  "types": "index.d.ts",