@glissade/react 0.1.0 → 0.2.0
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/dist/index.d.ts +14 -2
- package/dist/index.js +14 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReadonlySignal } from "@glissade/core";
|
|
1
|
+
import { ReadonlySignal, Signal } from "@glissade/core";
|
|
2
2
|
import { Player } from "@glissade/player";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
@@ -13,5 +13,17 @@ declare function usePlayerState(player: Player): {
|
|
|
13
13
|
time: number;
|
|
14
14
|
duration: number;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Machine hooks (v2 §C.6): the machine's active state and inputs are signals,
|
|
18
|
+
* so the §4.3 contract already covers them. Typed structurally — react never
|
|
19
|
+
* imports @glissade/interact; any object with this shape works.
|
|
20
|
+
*/
|
|
21
|
+
declare function useMachineState(machine: {
|
|
22
|
+
current: ReadonlySignal<string>;
|
|
23
|
+
}): string;
|
|
24
|
+
/** A machine input as React state: [value, set]. */
|
|
25
|
+
declare function useInput<T extends boolean | number>(machine: {
|
|
26
|
+
input(name: string): Signal<T>;
|
|
27
|
+
}, name: string): [T, (value: T) => void];
|
|
16
28
|
//#endregion
|
|
17
|
-
export { usePlayerState, usePlayhead, useSignalValue };
|
|
29
|
+
export { useInput, useMachineState, usePlayerState, usePlayhead, useSignalValue };
|
package/dist/index.js
CHANGED
|
@@ -26,5 +26,18 @@ function usePlayerState(player) {
|
|
|
26
26
|
duration: player.duration
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Machine hooks (v2 §C.6): the machine's active state and inputs are signals,
|
|
31
|
+
* so the §4.3 contract already covers them. Typed structurally — react never
|
|
32
|
+
* imports @glissade/interact; any object with this shape works.
|
|
33
|
+
*/
|
|
34
|
+
function useMachineState(machine) {
|
|
35
|
+
return useSignalValue(machine.current);
|
|
36
|
+
}
|
|
37
|
+
/** A machine input as React state: [value, set]. */
|
|
38
|
+
function useInput(machine, name) {
|
|
39
|
+
const sig = machine.input(name);
|
|
40
|
+
return [useSignalValue(sig), useCallback((v) => sig.set(v), [sig])];
|
|
41
|
+
}
|
|
29
42
|
//#endregion
|
|
30
|
-
export { usePlayerState, usePlayhead, useSignalValue };
|
|
43
|
+
export { useInput, useMachineState, usePlayerState, usePlayhead, useSignalValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissade/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "glissade React bindings: signals via useSyncExternalStore, player hooks.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@glissade/core": "0.
|
|
19
|
-
"@glissade/player": "0.
|
|
18
|
+
"@glissade/core": "0.2.0",
|
|
19
|
+
"@glissade/player": "0.2.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": ">=18"
|