@symbiote-native/sensors 0.2.0 → 0.3.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/README.md +5 -5
- package/build/angular/services/accelerometer.service/index.js +7 -12
- package/build/angular/services/barometer.service/index.js +7 -12
- package/build/angular/services/device-motion.service/index.js +7 -12
- package/build/angular/services/gyroscope.service/index.js +7 -12
- package/build/angular/services/light-sensor.service/index.js +7 -12
- package/build/angular/services/magnetometer-uncalibrated.service/index.js +8 -12
- package/build/angular/services/magnetometer.service/index.js +7 -12
- package/build/angular/services/pedometer.service/index.js +6 -10
- package/build/core/device-motion.js +3 -4
- package/build/svelte/index.d.ts +16 -0
- package/build/svelte/index.js +14 -0
- package/build/svelte/runes/use-accelerometer.svelte.d.ts +4 -0
- package/build/svelte/runes/use-accelerometer.svelte.js +31 -0
- package/build/svelte/runes/use-barometer.svelte.d.ts +4 -0
- package/build/svelte/runes/use-barometer.svelte.js +22 -0
- package/build/svelte/runes/use-device-motion.svelte.d.ts +4 -0
- package/build/svelte/runes/use-device-motion.svelte.js +22 -0
- package/build/svelte/runes/use-gyroscope.svelte.d.ts +4 -0
- package/build/svelte/runes/use-gyroscope.svelte.js +22 -0
- package/build/svelte/runes/use-light-sensor.svelte.d.ts +4 -0
- package/build/svelte/runes/use-light-sensor.svelte.js +22 -0
- package/build/svelte/runes/use-magnetometer-uncalibrated.svelte.d.ts +4 -0
- package/build/svelte/runes/use-magnetometer-uncalibrated.svelte.js +22 -0
- package/build/svelte/runes/use-magnetometer.svelte.d.ts +4 -0
- package/build/svelte/runes/use-magnetometer.svelte.js +22 -0
- package/build/svelte/runes/use-pedometer.svelte.d.ts +4 -0
- package/build/svelte/runes/use-pedometer.svelte.js +20 -0
- package/build-ngc/angular/services/accelerometer.service/index.js +10 -15
- package/build-ngc/angular/services/accelerometer.service/index.js.map +1 -1
- package/build-ngc/angular/services/barometer.service/index.js +10 -15
- package/build-ngc/angular/services/barometer.service/index.js.map +1 -1
- package/build-ngc/angular/services/device-motion.service/index.js +10 -15
- package/build-ngc/angular/services/device-motion.service/index.js.map +1 -1
- package/build-ngc/angular/services/gyroscope.service/index.js +10 -15
- package/build-ngc/angular/services/gyroscope.service/index.js.map +1 -1
- package/build-ngc/angular/services/light-sensor.service/index.js +10 -15
- package/build-ngc/angular/services/light-sensor.service/index.js.map +1 -1
- package/build-ngc/angular/services/magnetometer-uncalibrated.service/index.js +11 -15
- package/build-ngc/angular/services/magnetometer-uncalibrated.service/index.js.map +1 -1
- package/build-ngc/angular/services/magnetometer.service/index.js +10 -15
- package/build-ngc/angular/services/magnetometer.service/index.js.map +1 -1
- package/build-ngc/angular/services/pedometer.service/index.js +9 -13
- package/build-ngc/angular/services/pedometer.service/index.js.map +1 -1
- package/build-ngc/core/device-motion.js +3 -4
- package/build-ngc/core/device-motion.js.map +1 -1
- package/native-link.json +52 -0
- package/package.json +31 -13
- package/src/angular/services/accelerometer.service/index.ts +7 -12
- package/src/angular/services/barometer.service/index.ts +7 -12
- package/src/angular/services/device-motion.service/index.ts +7 -12
- package/src/angular/services/gyroscope.service/index.ts +7 -12
- package/src/angular/services/light-sensor.service/index.ts +7 -12
- package/src/angular/services/magnetometer-uncalibrated.service/index.ts +8 -12
- package/src/angular/services/magnetometer.service/index.ts +7 -12
- package/src/angular/services/pedometer.service/index.ts +6 -10
- package/src/core/device-motion.ts +3 -4
- package/src/svelte/index.ts +29 -0
- package/src/svelte/runes/use-accelerometer.svelte.ts +36 -0
- package/src/svelte/runes/use-barometer.svelte.ts +27 -0
- package/src/svelte/runes/use-device-motion.svelte.ts +27 -0
- package/src/svelte/runes/use-gyroscope.svelte.ts +27 -0
- package/src/svelte/runes/use-light-sensor.svelte.ts +27 -0
- package/src/svelte/runes/use-magnetometer-uncalibrated.svelte.ts +31 -0
- package/src/svelte/runes/use-magnetometer.svelte.ts +27 -0
- package/src/svelte/runes/use-pedometer.svelte.ts +23 -0
- package/src/svelte/svelte-ambient.d.ts +6 -0
- package/src/angular/services/accelerometer.service/accelerometer.service.test.ts +0 -118
- package/src/angular/services/barometer.service/barometer.service.test.ts +0 -122
- package/src/angular/services/device-motion.service/device-motion.service.test.ts +0 -125
- package/src/angular/services/gyroscope.service/gyroscope.service.test.ts +0 -118
- package/src/angular/services/light-sensor.service/light-sensor.service.test.ts +0 -118
- package/src/angular/services/magnetometer-uncalibrated.service/magnetometer-uncalibrated.service.test.ts +0 -123
- package/src/angular/services/magnetometer.service/magnetometer.service.test.ts +0 -118
- package/src/angular/services/pedometer.service/pedometer.service.test.ts +0 -86
- package/src/core/accelerometer.test.ts +0 -49
- package/src/core/barometer.test.ts +0 -46
- package/src/core/device-motion.test.ts +0 -60
- package/src/core/device-sensor.test.ts +0 -76
- package/src/core/gyroscope.test.ts +0 -46
- package/src/core/light-sensor.test.ts +0 -49
- package/src/core/magnetometer-uncalibrated.test.ts +0 -49
- package/src/core/magnetometer.test.ts +0 -49
- package/src/core/pedometer.test.ts +0 -118
- package/src/react/hooks/use-accelerometer/use-accelerometer.test.tsx +0 -81
- package/src/react/hooks/use-barometer/use-barometer.test.tsx +0 -83
- package/src/react/hooks/use-device-motion/use-device-motion.test.tsx +0 -88
- package/src/react/hooks/use-gyroscope/use-gyroscope.test.tsx +0 -79
- package/src/react/hooks/use-light-sensor/use-light-sensor.test.tsx +0 -79
- package/src/react/hooks/use-magnetometer/use-magnetometer.test.tsx +0 -81
- package/src/react/hooks/use-magnetometer-uncalibrated/use-magnetometer-uncalibrated.test.tsx +0 -88
- package/src/react/hooks/use-pedometer/use-pedometer.test.tsx +0 -69
- package/src/vue/composables/use-accelerometer/use-accelerometer.test.ts +0 -96
- package/src/vue/composables/use-barometer/use-barometer.test.ts +0 -100
- package/src/vue/composables/use-device-motion/use-device-motion.test.ts +0 -104
- package/src/vue/composables/use-gyroscope/use-gyroscope.test.ts +0 -96
- package/src/vue/composables/use-light-sensor/use-light-sensor.test.ts +0 -96
- package/src/vue/composables/use-magnetometer/use-magnetometer.test.ts +0 -96
- package/src/vue/composables/use-magnetometer-uncalibrated/use-magnetometer-uncalibrated.test.ts +0 -103
- package/src/vue/composables/use-pedometer/use-pedometer.test.ts +0 -77
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Svelte lifecycle wiring over the framework-agnostic watchStepCount free function (core/) —
|
|
2
|
+
// mirrors use-accelerometer.svelte.ts's shape. Pedometer has no setUpdateInterval, so unlike
|
|
3
|
+
// useAccelerometer there is no interval param to apply at subscribe time. See
|
|
4
|
+
// use-accelerometer.svelte.ts's header for why this lives in `runes/` with a `.svelte.ts`
|
|
5
|
+
// extension and returns a boxed getter object.
|
|
6
|
+
import { watchStepCount } from '../../core/index.js';
|
|
7
|
+
export function usePedometer() {
|
|
8
|
+
let result = $state(null);
|
|
9
|
+
$effect(() => {
|
|
10
|
+
const subscription = watchStepCount(next => {
|
|
11
|
+
result = next;
|
|
12
|
+
});
|
|
13
|
+
return () => subscription.remove();
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
get current() {
|
|
17
|
+
return result;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { Accelerometer } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `useAccelerometer` hook
|
|
5
|
-
// Angular has no per-instance hook
|
|
6
|
-
//
|
|
7
|
-
// inside an injection context).
|
|
4
|
+
// Angular twin of React's `useAccelerometer` hook / Vue's `useAccelerometer` composable.
|
|
5
|
+
// Angular has no per-instance hook, so `connect()` stands in: call it ONCE, inside an injection
|
|
6
|
+
// context (typically a component's field initializer).
|
|
8
7
|
//
|
|
9
8
|
// readonly measurement = inject(AccelerometerService).connect();
|
|
10
9
|
// // template: {{ measurement()?.x }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike HideAnimationService.connect(), there is no per-render config to re-sync — the
|
|
13
|
-
// subscription doesn't depend on anything the caller's own signals could change between
|
|
14
|
-
// renders — so a single effect() that subscribes once and cleans up once is enough; no
|
|
15
|
-
// `updateConfig`-style effect that re-runs on every read is needed here.
|
|
16
10
|
export class AccelerometerService {
|
|
17
|
-
// Captured in the constructor (
|
|
18
|
-
//
|
|
19
|
-
// code that is not, on its own, an active injection context — mirrors HideAnimationService.
|
|
11
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
12
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
20
13
|
injector = inject(Injector);
|
|
21
14
|
connect(updateIntervalMs) {
|
|
22
15
|
const measurement = signal(null, /* @ts-ignore */
|
|
23
16
|
...(ngDevMode ? [{ debugName: "measurement" }] : /* istanbul ignore next */ []));
|
|
24
17
|
effect(onCleanup => {
|
|
18
|
+
// updateIntervalMs applies once, at connect time — the effect has no reactive read to
|
|
19
|
+
// re-run on, so a later change is not picked up.
|
|
25
20
|
if (updateIntervalMs !== undefined) {
|
|
26
21
|
Accelerometer.setUpdateInterval(updateIntervalMs);
|
|
27
22
|
}
|
|
@@ -30,10 +25,10 @@ export class AccelerometerService {
|
|
|
30
25
|
}, { injector: this.injector });
|
|
31
26
|
return measurement.asReadonly();
|
|
32
27
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
34
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AccelerometerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
29
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AccelerometerService, providedIn: 'root' });
|
|
35
30
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: AccelerometerService, decorators: [{
|
|
37
32
|
type: Injectable,
|
|
38
33
|
args: [{ providedIn: 'root' }]
|
|
39
34
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/accelerometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAkC,MAAM,eAAe,CAAC;;AAE9E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/accelerometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAkC,MAAM,eAAe,CAAC;;AAE9E,yFAAyF;AACzF,gGAAgG;AAChG,uDAAuD;AACvD,EAAE;AACF,mEAAmE;AACnE,wCAAwC;AAExC,MAAM,OAAO,oBAAoB;IAC/B,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CAAC,gBAAyB;QAC/B,MAAM,WAAW,GAAG,MAAM,CAAmC,IAAI;wFAAC,CAAC;QAEnE,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,sFAAsF;YACtF,iDAAiD;YACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,aAAa,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YACpD,CAAC;YACD,MAAM,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9E,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;uGAtBU,oBAAoB;2GAApB,oBAAoB,cADP,MAAM;;2FACnB,oBAAoB;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { Barometer } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `useBarometer` hook
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// inside an injection context).
|
|
4
|
+
// Angular twin of React's `useBarometer` hook / Vue's `useBarometer` composable. Angular has no
|
|
5
|
+
// per-instance hook, so `connect()` stands in: call it ONCE, inside an injection context
|
|
6
|
+
// (typically a component's field initializer).
|
|
8
7
|
//
|
|
9
8
|
// readonly measurement = inject(BarometerService).connect();
|
|
10
9
|
// // template: {{ measurement()?.pressure }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike HideAnimationService.connect(), there is no per-render config to re-sync — the
|
|
13
|
-
// subscription doesn't depend on anything the caller's own signals could change between
|
|
14
|
-
// renders — so a single effect() that subscribes once and cleans up once is enough; no
|
|
15
|
-
// `updateConfig`-style effect that re-runs on every read is needed here.
|
|
16
10
|
export class BarometerService {
|
|
17
|
-
// Captured in the constructor (
|
|
18
|
-
//
|
|
19
|
-
// code that is not, on its own, an active injection context — mirrors HideAnimationService.
|
|
11
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
12
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
20
13
|
injector = inject(Injector);
|
|
21
14
|
connect(updateIntervalMs) {
|
|
22
15
|
const measurement = signal(null, /* @ts-ignore */
|
|
23
16
|
...(ngDevMode ? [{ debugName: "measurement" }] : /* istanbul ignore next */ []));
|
|
24
17
|
effect(onCleanup => {
|
|
18
|
+
// updateIntervalMs applies once, at connect time — the effect has no reactive read to
|
|
19
|
+
// re-run on, so a later change is not picked up.
|
|
25
20
|
if (updateIntervalMs !== undefined) {
|
|
26
21
|
Barometer.setUpdateInterval(updateIntervalMs);
|
|
27
22
|
}
|
|
@@ -30,10 +25,10 @@ export class BarometerService {
|
|
|
30
25
|
}, { injector: this.injector });
|
|
31
26
|
return measurement.asReadonly();
|
|
32
27
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
34
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BarometerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
29
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BarometerService, providedIn: 'root' });
|
|
35
30
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BarometerService, decorators: [{
|
|
37
32
|
type: Injectable,
|
|
38
33
|
args: [{ providedIn: 'root' }]
|
|
39
34
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/barometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,SAAS,EAA8B,MAAM,eAAe,CAAC;;AAEtE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/barometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,SAAS,EAA8B,MAAM,eAAe,CAAC;;AAEtE,gGAAgG;AAChG,yFAAyF;AACzF,+CAA+C;AAC/C,EAAE;AACF,+DAA+D;AAC/D,+CAA+C;AAE/C,MAAM,OAAO,gBAAgB;IAC3B,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CAAC,gBAAyB;QAC/B,MAAM,WAAW,GAAG,MAAM,CAA+B,IAAI;wFAAC,CAAC;QAE/D,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,sFAAsF;YACtF,iDAAiD;YACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,SAAS,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YAChD,CAAC;YACD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1E,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;uGAtBU,gBAAgB;2GAAhB,gBAAgB,cADH,MAAM;;2FACnB,gBAAgB;kBAD5B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { DeviceMotion } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `useDeviceMotion` hook
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// inside an injection context).
|
|
4
|
+
// Angular twin of React's `useDeviceMotion` hook / Vue's `useDeviceMotion` composable. Angular
|
|
5
|
+
// has no per-instance hook, so `connect()` stands in: call it ONCE, inside an injection context
|
|
6
|
+
// (typically a component's field initializer).
|
|
8
7
|
//
|
|
9
8
|
// readonly measurement = inject(DeviceMotionService).connect();
|
|
10
9
|
// // template: {{ measurement()?.rotation?.alpha }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike HideAnimationService.connect(), there is no per-render config to re-sync — the
|
|
13
|
-
// subscription doesn't depend on anything the caller's own signals could change between
|
|
14
|
-
// renders — so a single effect() that subscribes once and cleans up once is enough; no
|
|
15
|
-
// `updateConfig`-style effect that re-runs on every read is needed here.
|
|
16
10
|
export class DeviceMotionService {
|
|
17
|
-
// Captured in the constructor (
|
|
18
|
-
//
|
|
19
|
-
// code that is not, on its own, an active injection context — mirrors HideAnimationService.
|
|
11
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
12
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
20
13
|
injector = inject(Injector);
|
|
21
14
|
connect(updateIntervalMs) {
|
|
22
15
|
const measurement = signal(null, /* @ts-ignore */
|
|
23
16
|
...(ngDevMode ? [{ debugName: "measurement" }] : /* istanbul ignore next */ []));
|
|
24
17
|
effect(onCleanup => {
|
|
18
|
+
// updateIntervalMs applies once, at connect time — the effect has no reactive read to
|
|
19
|
+
// re-run on, so a later change is not picked up.
|
|
25
20
|
if (updateIntervalMs !== undefined) {
|
|
26
21
|
DeviceMotion.setUpdateInterval(updateIntervalMs);
|
|
27
22
|
}
|
|
@@ -30,10 +25,10 @@ export class DeviceMotionService {
|
|
|
30
25
|
}, { injector: this.injector });
|
|
31
26
|
return measurement.asReadonly();
|
|
32
27
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
34
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: DeviceMotionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
29
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: DeviceMotionService, providedIn: 'root' });
|
|
35
30
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: DeviceMotionService, decorators: [{
|
|
37
32
|
type: Injectable,
|
|
38
33
|
args: [{ providedIn: 'root' }]
|
|
39
34
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/device-motion.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAiC,MAAM,eAAe,CAAC;;AAE5E
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/device-motion.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAiC,MAAM,eAAe,CAAC;;AAE5E,+FAA+F;AAC/F,gGAAgG;AAChG,+CAA+C;AAC/C,EAAE;AACF,kEAAkE;AAClE,sDAAsD;AAEtD,MAAM,OAAO,mBAAmB;IAC9B,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CAAC,gBAAyB;QAC/B,MAAM,WAAW,GAAG,MAAM,CAAkC,IAAI;wFAAC,CAAC;QAElE,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,sFAAsF;YACtF,iDAAiD;YACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,YAAY,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YACnD,CAAC;YACD,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7E,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;uGAtBU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { Gyroscope } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `useGyroscope` hook
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// inside an injection context).
|
|
4
|
+
// Angular twin of React's `useGyroscope` hook / Vue's `useGyroscope` composable. Angular has no
|
|
5
|
+
// per-instance hook, so `connect()` stands in: call it ONCE, inside an injection context
|
|
6
|
+
// (typically a component's field initializer).
|
|
8
7
|
//
|
|
9
8
|
// readonly measurement = inject(GyroscopeService).connect();
|
|
10
9
|
// // template: {{ measurement()?.x }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike HideAnimationService.connect(), there is no per-render config to re-sync — the
|
|
13
|
-
// subscription doesn't depend on anything the caller's own signals could change between
|
|
14
|
-
// renders — so a single effect() that subscribes once and cleans up once is enough; no
|
|
15
|
-
// `updateConfig`-style effect that re-runs on every read is needed here.
|
|
16
10
|
export class GyroscopeService {
|
|
17
|
-
// Captured in the constructor (
|
|
18
|
-
//
|
|
19
|
-
// code that is not, on its own, an active injection context — mirrors HideAnimationService.
|
|
11
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
12
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
20
13
|
injector = inject(Injector);
|
|
21
14
|
connect(updateIntervalMs) {
|
|
22
15
|
const measurement = signal(null, /* @ts-ignore */
|
|
23
16
|
...(ngDevMode ? [{ debugName: "measurement" }] : /* istanbul ignore next */ []));
|
|
24
17
|
effect(onCleanup => {
|
|
18
|
+
// updateIntervalMs applies once, at connect time — the effect has no reactive read to
|
|
19
|
+
// re-run on, so a later change is not picked up.
|
|
25
20
|
if (updateIntervalMs !== undefined) {
|
|
26
21
|
Gyroscope.setUpdateInterval(updateIntervalMs);
|
|
27
22
|
}
|
|
@@ -30,10 +25,10 @@ export class GyroscopeService {
|
|
|
30
25
|
}, { injector: this.injector });
|
|
31
26
|
return measurement.asReadonly();
|
|
32
27
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
34
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: GyroscopeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
29
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: GyroscopeService, providedIn: 'root' });
|
|
35
30
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: GyroscopeService, decorators: [{
|
|
37
32
|
type: Injectable,
|
|
38
33
|
args: [{ providedIn: 'root' }]
|
|
39
34
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/gyroscope.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,SAAS,EAA8B,MAAM,eAAe,CAAC;;AAEtE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/gyroscope.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,SAAS,EAA8B,MAAM,eAAe,CAAC;;AAEtE,gGAAgG;AAChG,yFAAyF;AACzF,+CAA+C;AAC/C,EAAE;AACF,+DAA+D;AAC/D,wCAAwC;AAExC,MAAM,OAAO,gBAAgB;IAC3B,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CAAC,gBAAyB;QAC/B,MAAM,WAAW,GAAG,MAAM,CAA+B,IAAI;wFAAC,CAAC;QAE/D,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,sFAAsF;YACtF,iDAAiD;YACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,SAAS,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YAChD,CAAC;YACD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1E,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;uGAtBU,gBAAgB;2GAAhB,gBAAgB,cADH,MAAM;;2FACnB,gBAAgB;kBAD5B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { LightSensor } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `useLightSensor` hook
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// inside an injection context).
|
|
4
|
+
// Angular twin of React's `useLightSensor` hook / Vue's `useLightSensor` composable. Angular
|
|
5
|
+
// has no per-instance hook, so `connect()` stands in: call it ONCE, inside an injection context
|
|
6
|
+
// (typically a component's field initializer).
|
|
8
7
|
//
|
|
9
8
|
// readonly measurement = inject(LightSensorService).connect();
|
|
10
9
|
// // template: {{ measurement()?.illuminance }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike HideAnimationService.connect(), there is no per-render config to re-sync — the
|
|
13
|
-
// subscription doesn't depend on anything the caller's own signals could change between
|
|
14
|
-
// renders — so a single effect() that subscribes once and cleans up once is enough; no
|
|
15
|
-
// `updateConfig`-style effect that re-runs on every read is needed here.
|
|
16
10
|
export class LightSensorService {
|
|
17
|
-
// Captured in the constructor (
|
|
18
|
-
//
|
|
19
|
-
// code that is not, on its own, an active injection context — mirrors HideAnimationService.
|
|
11
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
12
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
20
13
|
injector = inject(Injector);
|
|
21
14
|
connect(updateIntervalMs) {
|
|
22
15
|
const measurement = signal(null, /* @ts-ignore */
|
|
23
16
|
...(ngDevMode ? [{ debugName: "measurement" }] : /* istanbul ignore next */ []));
|
|
24
17
|
effect(onCleanup => {
|
|
18
|
+
// updateIntervalMs applies once, at connect time — the effect has no reactive read to
|
|
19
|
+
// re-run on, so a later change is not picked up.
|
|
25
20
|
if (updateIntervalMs !== undefined) {
|
|
26
21
|
LightSensor.setUpdateInterval(updateIntervalMs);
|
|
27
22
|
}
|
|
@@ -30,10 +25,10 @@ export class LightSensorService {
|
|
|
30
25
|
}, { injector: this.injector });
|
|
31
26
|
return measurement.asReadonly();
|
|
32
27
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
34
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LightSensorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
29
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LightSensorService, providedIn: 'root' });
|
|
35
30
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LightSensorService, decorators: [{
|
|
37
32
|
type: Injectable,
|
|
38
33
|
args: [{ providedIn: 'root' }]
|
|
39
34
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/light-sensor.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAgC,MAAM,eAAe,CAAC;;AAE1E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/light-sensor.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAgC,MAAM,eAAe,CAAC;;AAE1E,6FAA6F;AAC7F,gGAAgG;AAChG,+CAA+C;AAC/C,EAAE;AACF,iEAAiE;AACjE,kDAAkD;AAElD,MAAM,OAAO,kBAAkB;IAC7B,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CAAC,gBAAyB;QAC/B,MAAM,WAAW,GAAG,MAAM,CAAiC,IAAI;wFAAC,CAAC;QAEjE,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,sFAAsF;YACtF,iDAAiD;YACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,WAAW,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YAClD,CAAC;YACD,MAAM,YAAY,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC5E,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;uGAtBU,kBAAkB;2GAAlB,kBAAkB,cADL,MAAM;;2FACnB,kBAAkB;kBAD9B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { MagnetometerUncalibrated } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `useMagnetometerUncalibrated` hook
|
|
5
|
-
// `useMagnetometerUncalibrated` composable. Angular has no per-instance hook
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// Angular twin of React's `useMagnetometerUncalibrated` hook / Vue's
|
|
5
|
+
// `useMagnetometerUncalibrated` composable. Angular has no per-instance hook, so `connect()`
|
|
6
|
+
// stands in: call it ONCE, inside an injection context (typically a component's field
|
|
7
|
+
// initializer).
|
|
8
8
|
//
|
|
9
9
|
// readonly measurement = inject(MagnetometerUncalibratedService).connect();
|
|
10
10
|
// // template: {{ measurement()?.x }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike HideAnimationService.connect(), there is no per-render config to re-sync — the
|
|
13
|
-
// subscription doesn't depend on anything the caller's own signals could change between
|
|
14
|
-
// renders — so a single effect() that subscribes once and cleans up once is enough; no
|
|
15
|
-
// `updateConfig`-style effect that re-runs on every read is needed here.
|
|
16
11
|
export class MagnetometerUncalibratedService {
|
|
17
|
-
// Captured in the constructor (
|
|
18
|
-
//
|
|
19
|
-
// code that is not, on its own, an active injection context — mirrors HideAnimationService.
|
|
12
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
13
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
20
14
|
injector = inject(Injector);
|
|
21
15
|
connect(updateIntervalMs) {
|
|
22
16
|
const measurement = signal(null, /* @ts-ignore */
|
|
23
17
|
...(ngDevMode ? [{ debugName: "measurement" }] : /* istanbul ignore next */ []));
|
|
24
18
|
effect(onCleanup => {
|
|
19
|
+
// updateIntervalMs applies once, at connect time — the effect has no reactive read to
|
|
20
|
+
// re-run on, so a later change is not picked up.
|
|
25
21
|
if (updateIntervalMs !== undefined) {
|
|
26
22
|
MagnetometerUncalibrated.setUpdateInterval(updateIntervalMs);
|
|
27
23
|
}
|
|
@@ -30,10 +26,10 @@ export class MagnetometerUncalibratedService {
|
|
|
30
26
|
}, { injector: this.injector });
|
|
31
27
|
return measurement.asReadonly();
|
|
32
28
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
34
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
29
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: MagnetometerUncalibratedService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
30
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: MagnetometerUncalibratedService, providedIn: 'root' });
|
|
35
31
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
32
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: MagnetometerUncalibratedService, decorators: [{
|
|
37
33
|
type: Injectable,
|
|
38
34
|
args: [{ providedIn: 'root' }]
|
|
39
35
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/magnetometer-uncalibrated.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,wBAAwB,EAA6C,MAAM,eAAe,CAAC;;AAEpG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/magnetometer-uncalibrated.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,wBAAwB,EAA6C,MAAM,eAAe,CAAC;;AAEpG,qEAAqE;AACrE,6FAA6F;AAC7F,sFAAsF;AACtF,gBAAgB;AAChB,EAAE;AACF,8EAA8E;AAC9E,wCAAwC;AAExC,MAAM,OAAO,+BAA+B;IAC1C,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CAAC,gBAAyB;QAC/B,MAAM,WAAW,GAAG,MAAM,CAA8C,IAAI;wFAAC,CAAC;QAE9E,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,sFAAsF;YACtF,iDAAiD;YACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,wBAAwB,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YAC/D,CAAC;YACD,MAAM,YAAY,GAAG,wBAAwB,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YACzF,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;uGAtBU,+BAA+B;2GAA/B,+BAA+B,cADlB,MAAM;;2FACnB,+BAA+B;kBAD3C,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { Magnetometer } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `useMagnetometer` hook
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// inside an injection context).
|
|
4
|
+
// Angular twin of React's `useMagnetometer` hook / Vue's `useMagnetometer` composable. Angular
|
|
5
|
+
// has no per-instance hook, so `connect()` stands in: call it ONCE, inside an injection context
|
|
6
|
+
// (typically a component's field initializer).
|
|
8
7
|
//
|
|
9
8
|
// readonly measurement = inject(MagnetometerService).connect();
|
|
10
9
|
// // template: {{ measurement()?.x }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike HideAnimationService.connect(), there is no per-render config to re-sync — the
|
|
13
|
-
// subscription doesn't depend on anything the caller's own signals could change between
|
|
14
|
-
// renders — so a single effect() that subscribes once and cleans up once is enough; no
|
|
15
|
-
// `updateConfig`-style effect that re-runs on every read is needed here.
|
|
16
10
|
export class MagnetometerService {
|
|
17
|
-
// Captured in the constructor (
|
|
18
|
-
//
|
|
19
|
-
// code that is not, on its own, an active injection context — mirrors HideAnimationService.
|
|
11
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
12
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
20
13
|
injector = inject(Injector);
|
|
21
14
|
connect(updateIntervalMs) {
|
|
22
15
|
const measurement = signal(null, /* @ts-ignore */
|
|
23
16
|
...(ngDevMode ? [{ debugName: "measurement" }] : /* istanbul ignore next */ []));
|
|
24
17
|
effect(onCleanup => {
|
|
18
|
+
// updateIntervalMs applies once, at connect time — the effect has no reactive read to
|
|
19
|
+
// re-run on, so a later change is not picked up.
|
|
25
20
|
if (updateIntervalMs !== undefined) {
|
|
26
21
|
Magnetometer.setUpdateInterval(updateIntervalMs);
|
|
27
22
|
}
|
|
@@ -30,10 +25,10 @@ export class MagnetometerService {
|
|
|
30
25
|
}, { injector: this.injector });
|
|
31
26
|
return measurement.asReadonly();
|
|
32
27
|
}
|
|
33
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
34
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: MagnetometerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
29
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: MagnetometerService, providedIn: 'root' });
|
|
35
30
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: MagnetometerService, decorators: [{
|
|
37
32
|
type: Injectable,
|
|
38
33
|
args: [{ providedIn: 'root' }]
|
|
39
34
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/magnetometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAiC,MAAM,eAAe,CAAC;;AAE5E
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/magnetometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAiC,MAAM,eAAe,CAAC;;AAE5E,+FAA+F;AAC/F,gGAAgG;AAChG,+CAA+C;AAC/C,EAAE;AACF,kEAAkE;AAClE,wCAAwC;AAExC,MAAM,OAAO,mBAAmB;IAC9B,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO,CAAC,gBAAyB;QAC/B,MAAM,WAAW,GAAG,MAAM,CAAkC,IAAI;wFAAC,CAAC;QAElE,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,sFAAsF;YACtF,iDAAiD;YACjD,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACnC,YAAY,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YACnD,CAAC;YACD,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7E,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;uGAtBU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { effect, inject, Injectable, Injector, signal } from '@angular/core';
|
|
2
2
|
import { watchStepCount } from '../../../core';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
-
// Angular twin of React's `usePedometer` hook
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// Angular twin of React's `usePedometer` hook / Vue's `usePedometer` composable. Angular has no
|
|
5
|
+
// per-instance hook, so `connect()` stands in: call it ONCE, inside an injection context
|
|
6
|
+
// (typically a component's field initializer). Pedometer has no setUpdateInterval, unlike the
|
|
7
|
+
// other sensor services, so there is no interval param here.
|
|
8
8
|
//
|
|
9
9
|
// readonly result = inject(PedometerService).connect();
|
|
10
10
|
// // template: {{ result()?.steps }}
|
|
11
|
-
//
|
|
12
|
-
// Unlike AccelerometerService.connect(), there is no updateIntervalMs to apply — Pedometer has
|
|
13
|
-
// no setUpdateInterval — so a single effect() that subscribes once and cleans up once is enough.
|
|
14
11
|
export class PedometerService {
|
|
15
|
-
// Captured in the constructor (
|
|
16
|
-
//
|
|
17
|
-
// code that is not, on its own, an active injection context — mirrors AccelerometerService.
|
|
12
|
+
// Captured in the constructor (always an injection context) so `connect()` can build an
|
|
13
|
+
// `effect()` even when called from a field initializer that isn't one on its own.
|
|
18
14
|
injector = inject(Injector);
|
|
19
15
|
connect() {
|
|
20
16
|
const result = signal(null, /* @ts-ignore */
|
|
@@ -25,10 +21,10 @@ export class PedometerService {
|
|
|
25
21
|
}, { injector: this.injector });
|
|
26
22
|
return result.asReadonly();
|
|
27
23
|
}
|
|
28
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.
|
|
29
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.
|
|
24
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: PedometerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
25
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: PedometerService, providedIn: 'root' });
|
|
30
26
|
}
|
|
31
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.
|
|
27
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: PedometerService, decorators: [{
|
|
32
28
|
type: Injectable,
|
|
33
29
|
args: [{ providedIn: 'root' }]
|
|
34
30
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/pedometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAyB,MAAM,eAAe,CAAC;;AAEtE
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/pedometer.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAyB,MAAM,eAAe,CAAC;;AAEtE,gGAAgG;AAChG,yFAAyF;AACzF,8FAA8F;AAC9F,6DAA6D;AAC7D,EAAE;AACF,0DAA0D;AAC1D,uCAAuC;AAEvC,MAAM,OAAO,gBAAgB;IAC3B,wFAAwF;IACxF,kFAAkF;IACjE,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO;QACL,MAAM,MAAM,GAAG,MAAM,CAA0B,IAAI;mFAAC,CAAC;QAErD,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9D,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;uGAjBU,gBAAgB;2GAAhB,gBAAgB,cADH,MAAM;;2FACnB,gBAAgB;kBAD5B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
|
|
@@ -10,13 +10,12 @@ export var DeviceMotionOrientation;
|
|
|
10
10
|
})(DeviceMotionOrientation || (DeviceMotionOrientation = {}));
|
|
11
11
|
export class DeviceMotionSensor extends DeviceSensor {
|
|
12
12
|
// Standard gravitational acceleration for Earth (m/s^2), read off the native module rather
|
|
13
|
-
// than hardcoded — mirrors upstream's dual exposure as
|
|
14
|
-
// standalone
|
|
13
|
+
// than hardcoded — mirrors upstream's dual exposure as an instance property and this
|
|
14
|
+
// standalone export.
|
|
15
15
|
gravity = exponentDeviceMotion.Gravity;
|
|
16
16
|
}
|
|
17
17
|
const DEVICE_MOTION_DID_UPDATE_EVENT_NAME = 'deviceMotionDidUpdate';
|
|
18
18
|
export const DeviceMotion = new DeviceMotionSensor(exponentDeviceMotion, DEVICE_MOTION_DID_UPDATE_EVENT_NAME);
|
|
19
|
-
//
|
|
20
|
-
// constant and not the full sensor singleton.
|
|
19
|
+
// Same value as `DeviceMotion.gravity`, for callers that only need the constant.
|
|
21
20
|
export const gravity = exponentDeviceMotion.Gravity;
|
|
22
21
|
//# sourceMappingURL=device-motion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-motion.js","sourceRoot":"","sources":["../../src/core/device-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAevE,+CAA+C;AAC/C,MAAM,CAAN,IAAY,uBAKX;AALD,WAAY,uBAAuB;IACjC,6EAAY,CAAA;IACZ,0FAAmB,CAAA;IACnB,mFAAgB,CAAA;IAChB,yFAAmB,CAAA;AACrB,CAAC,EALW,uBAAuB,KAAvB,uBAAuB,QAKlC;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAAsC;IAC5E,2FAA2F;IAC3F,
|
|
1
|
+
{"version":3,"file":"device-motion.js","sourceRoot":"","sources":["../../src/core/device-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAevE,+CAA+C;AAC/C,MAAM,CAAN,IAAY,uBAKX;AALD,WAAY,uBAAuB;IACjC,6EAAY,CAAA;IACZ,0FAAmB,CAAA;IACnB,mFAAgB,CAAA;IAChB,yFAAmB,CAAA;AACrB,CAAC,EALW,uBAAuB,KAAvB,uBAAuB,QAKlC;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAAsC;IAC5E,2FAA2F;IAC3F,qFAAqF;IACrF,qBAAqB;IACZ,OAAO,GAAW,oBAAoB,CAAC,OAAO,CAAC;CACzD;AAED,MAAM,mCAAmC,GAAG,uBAAuB,CAAC;AAEpE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,kBAAkB,CAChD,oBAAoB,EACpB,mCAAmC,CACpC,CAAC;AAEF,iFAAiF;AACjF,MAAM,CAAC,MAAM,OAAO,GAAW,oBAAoB,CAAC,OAAO,CAAC"}
|
package/native-link.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"android": {
|
|
3
|
+
"gradleProjectName": "expo-sensors",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"importPath": "expo.modules.sensors.modules.AccelerometerModule",
|
|
7
|
+
"className": "AccelerometerModule",
|
|
8
|
+
"nativeName": "ExponentAccelerometer"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"importPath": "expo.modules.sensors.modules.BarometerModule",
|
|
12
|
+
"className": "BarometerModule",
|
|
13
|
+
"nativeName": "ExpoBarometer"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"importPath": "expo.modules.sensors.modules.DeviceMotionModule",
|
|
17
|
+
"className": "DeviceMotionModule",
|
|
18
|
+
"nativeName": "ExponentDeviceMotion"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"importPath": "expo.modules.sensors.modules.GyroscopeModule",
|
|
22
|
+
"className": "GyroscopeModule",
|
|
23
|
+
"nativeName": "ExponentGyroscope"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"importPath": "expo.modules.sensors.modules.LightSensorModule",
|
|
27
|
+
"className": "LightSensorModule",
|
|
28
|
+
"nativeName": "ExpoLightSensor"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"importPath": "expo.modules.sensors.modules.MagnetometerModule",
|
|
32
|
+
"className": "MagnetometerModule",
|
|
33
|
+
"nativeName": "ExponentMagnetometer"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"importPath": "expo.modules.sensors.modules.MagnetometerUncalibratedModule",
|
|
37
|
+
"className": "MagnetometerUncalibratedModule",
|
|
38
|
+
"nativeName": "ExponentMagnetometerUncalibrated"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"importPath": "expo.modules.sensors.modules.PedometerModule",
|
|
42
|
+
"className": "PedometerModule",
|
|
43
|
+
"nativeName": "ExponentPedometer"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"ios": {
|
|
48
|
+
"infoPlistKeys": {
|
|
49
|
+
"NSMotionUsageDescription": "This app uses motion sensor data."
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|