@livx.cc/native-kit 0.35.0 → 0.35.1
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 +1 -1
- package/package.json +1 -1
- package/src/modules/motion.ts +4 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Isomorphic native-capabilities kit for PWAs — the **same API in the browser and inside an [appwrap](https://github.com/Livshitz/appwrap) native shell**. Zero dependencies.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
bun add @livx.cc/native-kit
|
|
6
|
+
bun add @livx.cc/native-kit
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livx.cc/native-kit",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.1",
|
|
4
4
|
"description": "Isomorphic native-capabilities kit for PWAs \u2014 same API in browser and in an appwrap native shell. Zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Elya Livshitz",
|
package/src/modules/motion.ts
CHANGED
|
@@ -19,11 +19,12 @@ export class MotionModule {
|
|
|
19
19
|
return this.kit.capability('motion');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
/** Stream motion samples
|
|
23
|
-
|
|
22
|
+
/** Stream motion samples; resolves an unsubscribe once streaming starts. `opts.hz` sets the emit
|
|
23
|
+
* rate (default 10, clamped 5–60 native-side) — bump it for crisp tilt (e.g. a game asks 60). */
|
|
24
|
+
async watch(cb: (sample: MotionSample) => void, opts?: { hz?: number }): Promise<Unsubscribe> {
|
|
24
25
|
const off = this.kit.on('motion.data', (p) => cb(p as MotionSample));
|
|
25
26
|
try {
|
|
26
|
-
await this.kit.invoke('motion.start');
|
|
27
|
+
await this.kit.invoke('motion.start', opts?.hz ? { hz: opts.hz } : undefined);
|
|
27
28
|
} catch (e) {
|
|
28
29
|
off();
|
|
29
30
|
throw e;
|