@solidrt/flux-types 0.0.24 → 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/gui/audio.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  // Sound playback (gui-enabled runtime only). The imperative primitive; `play`
2
- // decodes an encoded clip (Ogg/Vorbis or WAV) and returns a handle whose
3
- // `stop()` halts just that sound, so the raw track id never leaves the runtime.
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.
4
5
 
5
6
  declare module "flux:audio" {
6
- /** Options for {@link play}. */
7
+ /** Options for {@link play} and {@link LoadedSound.play}. */
7
8
  type PlayOptions = {
8
9
  /** Repeat the clip until stopped. Defaults to false. */
9
10
  loop?: boolean
@@ -11,17 +12,39 @@ declare module "flux:audio" {
11
12
  gain?: number
12
13
  }
13
14
 
14
- /** A playing sound with controls bound to it. */
15
+ /** A playing voice with controls bound to it. */
15
16
  type SoundHandle = {
16
- /** Stop this sound. A no-op if it already finished. */
17
+ /** Stop this voice. A no-op if it already finished. */
17
18
  stop(): void
18
19
  }
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
+
20
29
  /**
21
30
  * Decode and start an encoded audio clip (Ogg/Vorbis or WAV). Returns
22
- * immediately; the sound plays on the mixer's own thread.
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.
23
33
  */
24
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
25
48
  /** Stop every playing sound. */
26
- export function stopAll(): void
49
+ export function stop(): void
27
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/flux-types",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "license": "MIT",
5
5
  "author": "Antoine van Wel",
6
6
  "types": "index.d.ts",