@solidrt/core 0.0.30 → 0.0.32

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/AGENTS.md CHANGED
@@ -84,7 +84,7 @@ tsconfig.json - the two load-bearing lines are jsx + jsxImportSource:
84
84
  ```
85
85
 
86
86
  Peer deps @solidjs/signals and @solidjs/universal must match (currently
87
- 2.0.0-beta.17); bun resolves them from peerDependencies.
87
+ 2.0.0-beta.20); bun resolves them from peerDependencies.
88
88
 
89
89
  ## Element model (the parts that are easy to get wrong)
90
90
 
@@ -34,6 +34,9 @@ for the element/prop model see `@solidrt/core/AGENTS.md`.
34
34
  - `inline-image.tsx` - bytes already in memory: `decodeImage` + `createTexture` (both synchronous) show an image with no `<Loading>` boundary. The sync counterpart to `image.tsx`.
35
35
  - `gpu-shader.tsx` - a GLSL fragment shader rendered to a texture, animated by driving its `iTime` uniform declaratively through the `<texture params={{...}}>` prop.
36
36
 
37
+ ## Sound
38
+ - `sound.tsx` - `createSound`: decode a clip once from bytes (here a binary import), replay cheaply; `overlap` stacking vs single-voice, `playing()` signal, release on unmount. Points to `createSoundStream` for long tracks streamed from a path.
39
+
37
40
  ## Vector graphics
38
41
  - `svg.tsx` - `<svg src={...}>` draws a whole SVG *document string* (not HTML/JSX children); multi-color fills vs a `currentColor` icon recolored by the `color` prop. This is how to use existing icon libraries (Lucide, Heroicons, etc.) - hand their SVG source to `src`.
39
42
 
Binary file
@@ -0,0 +1,48 @@
1
+ // createSound decodes an encoded clip (Ogg/Vorbis or WAV) once, then every
2
+ // play() starts a voice with no re-decode - cheap enough for rapid SFX. It is
3
+ // reactive-owned: the decoded clip is released and its voices stopped when the
4
+ // owning component unmounts, so there is nothing to clean up by hand.
5
+ //
6
+ // The source is a Uint8Array of encoded bytes. Here they come from a
7
+ // `with { type: "binary" }` import (see binary-import.tsx), so the clip is
8
+ // baked into the bundle and available synchronously. Bytes loaded at runtime
9
+ // (flux:fs, fetch) work the same once you have them.
10
+ //
11
+ // overlap defaults to true: tapping faster than the clip length stacks voices
12
+ // instead of restarting. The second sound sets overlap: false - each play()
13
+ // cuts off the previous voice, the single-voice behavior you want for e.g. a
14
+ // selection tick. playing() is a signal: true from play() until stop() (it
15
+ // does not flip back when a clip ends naturally).
16
+ //
17
+ // For a long track (music, ambience) do not load bytes at all: pass a file
18
+ // path to createSoundStream from the same module, which decodes from disk on
19
+ // demand and stays off the heap. Same play()/stop()/playing() surface,
20
+ // always single-voice.
21
+ import { render } from "@solidrt/core"
22
+ import { createSound } from "@solidrt/core/sound"
23
+ import blipBytes from "./blip.wav" with { type: "binary" }
24
+
25
+ function Button(props: { label: string; onTap: () => void }) {
26
+ return (
27
+ <view onPointerDown={props.onTap} padding={12} clipRadius={8}>
28
+ <d-rect color="#333" />
29
+ <text color="#e6e6e6">{props.label}</text>
30
+ </view>
31
+ )
32
+ }
33
+
34
+ function App() {
35
+ let blip = createSound(blipBytes, { gain: 0.8 })
36
+ let tick = createSound(blipBytes, { overlap: false })
37
+
38
+ return (
39
+ <window padding={20} gap={8} alignItems="flex-start">
40
+ <Button label="Blip (tap fast to stack voices)" onTap={() => blip.play()} />
41
+ <Button label="Tick (overlap: false, restarts)" onTap={() => tick.play()} />
42
+ <Button label="Stop" onTap={() => { blip.stop(); tick.stop() }} />
43
+ <text color="#888">{blip.playing() || tick.playing() ? "playing" : "silent"}</text>
44
+ </window>
45
+ )
46
+ }
47
+
48
+ render(() => <App />)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/core",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "license": "MIT",
5
5
  "author": "Antoine van Wel",
6
6
  "type": "module",
@@ -27,11 +27,11 @@
27
27
  "colord": "^2.9.3"
28
28
  },
29
29
  "devDependencies": {
30
- "@solidrt/flux-types": "0.0.30"
30
+ "@solidrt/flux-types": "0.0.32"
31
31
  },
32
32
  "peerDependencies": {
33
- "@solidjs/signals": "2.0.0-beta.17",
34
- "@solidjs/universal": "2.0.0-beta.17",
35
- "solid-js": "2.0.0-beta.17"
33
+ "@solidjs/signals": "2.0.0-beta.20",
34
+ "@solidjs/universal": "2.0.0-beta.20",
35
+ "solid-js": "2.0.0-beta.20"
36
36
  }
37
37
  }