@livx.cc/native-kit 0.39.0 → 0.40.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livx.cc/native-kit",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "Isomorphic native-capabilities kit for PWAs — same API in browser and in an appwrap native shell. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Elya Livshitz",
@@ -332,9 +332,15 @@ export class WebAdapter implements NativeKitAdapter {
332
332
  last = now;
333
333
  const a = e.accelerationIncludingGravity;
334
334
  const r = e.rotationRate;
335
+ // Map DOM → kit contract. Two corrections vs the raw event, BOTH load-bearing:
336
+ // 1. UNITS: the DOM reports rotationRate in deg/s; the kit contract (and both native
337
+ // handlers — CoreMotion + Android TYPE_GYROSCOPE) is rad/s. Convert, or web is 57× off.
338
+ // 2. AXES: DOM alpha/beta/gamma are the rates about Z/X/Y respectively — NOT x/y/z in
339
+ // order. So rx=beta, ry=gamma, rz=alpha; a naive alpha→rx puts the Z-rate on X.
340
+ const toRad = (d?: number | null) => (d == null ? undefined : (d * Math.PI) / 180);
335
341
  this.emit('motion.data', {
336
342
  ax: a?.x ?? 0, ay: a?.y ?? 0, az: a?.z ?? 0,
337
- rx: r?.alpha ?? undefined, ry: r?.beta ?? undefined, rz: r?.gamma ?? undefined,
343
+ rx: toRad(r?.beta), ry: toRad(r?.gamma), rz: toRad(r?.alpha),
338
344
  });
339
345
  };
340
346
  window.addEventListener('devicemotion', this.motionHandler);