@solidrt/core 0.0.73 → 0.0.74

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
@@ -118,16 +118,21 @@ tsconfig.json - the two load-bearing lines are jsx + jsxImportSource:
118
118
  Peer deps @solidjs/signals and @solidjs/universal must match (currently
119
119
  2.0.0-rc.14); bun resolves them from peerDependencies. On a version bump,
120
120
  `bun install` only warns ("incorrect peer dependency") and keeps the old
121
- ones, and `bun update solid-js @solidjs/signals @solidjs/universal` does
122
- not read the pin either: it adds all three to package.json at registry
123
- latest (solid-js 1.x, off Solid 2.0 entirely). The recipe that works
124
- deletes the installed copies and leaves the lockfile alone:
125
- `rm -rf node_modules/solid-js node_modules/@solidjs && bun install`
126
- (delete any nested `node_modules/@solidjs` too, or the old copy keeps
127
- resolving). Removing the directories is what forces re-resolution. Do not
128
- delete `bun.lock` to force it: that re-resolves every unrelated dependency
129
- as well, and a package that floats elsewhere fails the typecheck in a way
130
- that reads exactly like Solid fallout.
121
+ ones, and so does deleting their node_modules copies first (bun 1.3.14
122
+ reinstalls them from bun.lock). `bun update solid-js @solidjs/signals
123
+ @solidjs/universal` does not read the pin either: it adds all three to
124
+ package.json at registry latest (solid-js 1.x, off Solid 2.0 entirely).
125
+ The recipe that works pins all three explicitly at the new version:
126
+ `bun add solid-js@2.0.0-rc.14 @solidjs/signals@2.0.0-rc.14 @solidjs/universal@2.0.0-rc.14`.
127
+ It moves exactly those three lock entries and nothing else. An app `sol
128
+ init` wrote has the three pinned in package.json already (the scaffold
129
+ carries them, and release.yml takes the pins from core's peerDependencies
130
+ at publish), so there the upgrade is the pins edited and `bun install`.
131
+ Do not delete `bun.lock` or its entries to force it: bun then re-resolves
132
+ every dependency, and a package that floats elsewhere fails the typecheck
133
+ in a way that reads exactly like Solid fallout. A Solid bump in this repo
134
+ moves core's peerDependencies and the scaffold's pins
135
+ (packages/cli/src/init/scaffold/package.json) together.
131
136
 
132
137
  ## Element model (the parts that are easy to get wrong)
133
138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/core",
3
- "version": "0.0.73",
3
+ "version": "0.0.74",
4
4
  "license": "MIT",
5
5
  "funding": "https://github.com/sponsors/wellawaretech",
6
6
  "author": "Antoine van Wel",
@@ -33,8 +33,8 @@
33
33
  "AGENTS.md"
34
34
  ],
35
35
  "devDependencies": {
36
- "@solidrt/flux-types": "0.0.73",
37
- "@solidrt/test": "0.0.73"
36
+ "@solidrt/flux-types": "0.0.74",
37
+ "@solidrt/test": "0.0.74"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@solidjs/signals": "2.0.0-rc.14",
package/src/microphone.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  // Microphone capture, reactive (SolidJS) layer. A session delivers raw mono
2
2
  // float32 samples at the requested sample rate (the device format is converted
3
- // by SDL); read() drains whatever was captured since the last call. Captured
4
- // audio buffers until read, so poll read() regularly (e.g. once per frame) while
5
- // open.
3
+ // by SDL); read() drains whatever was captured since the last call, out of a
4
+ // 10 s window the session keeps, so nothing has to poll: read when the app
5
+ // wants samples, and a runtime module that works on the audio reads the same
6
+ // session on its own thread, given id(). Opening the microphone IS the
7
+ // permission request (SDL semantics): it resolves once capture runs and
8
+ // rejects if the user denies access.
6
9
  //
7
10
  // The imperative primitive lives in the `flux:microphone` module; import
8
11
  // { open, listMicrophones } from "flux:microphone" for non-reactive use.
@@ -17,33 +20,48 @@ export type MicrophoneOptions = {
17
20
  sampleRate?: number
18
21
  }
19
22
 
20
- /** A live microphone with reactive lifecycle. */
23
+ /** A live microphone as reactive accessors. */
21
24
  export type MicrophoneStream = {
22
- /** Sample rate of read() samples (0 if opening failed). */
25
+ /** The session id to hand a runtime module that reads this microphone, undefined while opening or if opening failed. */
26
+ id(): number | undefined
27
+ /** Sample rate of read() samples, 0 while opening or if opening failed. */
23
28
  sampleRate(): number
24
29
  /** Drain the mono float32 samples captured since the last read (empty if not open). */
25
30
  read(): Float32Array
26
- /** Set if opening failed. */
31
+ /** Set if opening failed (e.g. permission denied). */
27
32
  error(): Error | undefined
28
33
  }
29
34
 
30
35
  /**
31
- * Opens a microphone and owns its lifecycle: closes when the reactive owner is
32
- * disposed. Capture stays pull-based, so read() drains samples on demand (e.g.
33
- * once per frame). For imperative use, call open() from "flux:microphone".
36
+ * Opens a microphone and exposes it as reactive signals: id() and
37
+ * sampleRate() are set once capture runs, error() if the open failed or the
38
+ * user denied the permission. Closes automatically when the reactive owner
39
+ * is disposed (e.g. the component unmounts). Capture stays pull-based:
40
+ * read() drains the samples captured since the last read, out of the
41
+ * session's 10 s window. For imperative use, call open() from
42
+ * "flux:microphone".
34
43
  */
35
44
  export function createMicrophone(options: MicrophoneOptions = {}): MicrophoneStream {
45
+ let [id, setId] = createSignal<number | undefined>(undefined)
46
+ let [sampleRate, setSampleRate] = createSignal(0)
36
47
  let [error, setError] = createSignal<Error | undefined>(undefined)
37
- let session: ReturnType<typeof open> | undefined
38
- let rate = 0
39
- try {
40
- session = open(options)
41
- rate = session.sampleRate
42
- } catch (e) {
43
- setError(e instanceof Error ? e : new Error(String(e)))
44
- }
48
+ let session: Awaited<ReturnType<typeof open>> | undefined
49
+ let disposed = false
50
+
51
+ open(options)
52
+ .then((mic) => {
53
+ if (disposed) {
54
+ mic.close()
55
+ return
56
+ }
57
+ session = mic
58
+ setId(mic.id)
59
+ setSampleRate(mic.sampleRate)
60
+ })
61
+ .catch((e) => setError(e instanceof Error ? e : new Error(String(e))))
45
62
 
46
63
  onCleanup(() => {
64
+ disposed = true
47
65
  if (session) {
48
66
  session.close()
49
67
  session = undefined
@@ -51,7 +69,8 @@ export function createMicrophone(options: MicrophoneOptions = {}): MicrophoneStr
51
69
  })
52
70
 
53
71
  return {
54
- sampleRate: () => rate,
72
+ id,
73
+ sampleRate,
55
74
  read: () => (session ? session.read() : new Float32Array(0)),
56
75
  error,
57
76
  }
@@ -258,6 +258,13 @@ declare module "sol:test" {
258
258
  * Throws on a size that does not match the pixels.
259
259
  */
260
260
  export function camera(width: number, height: number, pixels: Uint8Array): void
261
+ /**
262
+ * Installs a mono float clip at `sampleRate` Hz as the microphone: every
263
+ * microphone the app opens at that rate from now on holds it from the
264
+ * open, with no device, and an open one hears it now. Throws on a rate of
265
+ * 0 or one that differs from an open test microphone's.
266
+ */
267
+ export function microphone(sampleRate: number, samples: Float32Array): void
261
268
  /**
262
269
  * Runs one frame: timers due by its time fire, then frame callbacks and
263
270
  * the flush, then the draw if anything demanded one. Fulfills once the