@capgo/capacitor-light-sensor 8.0.0 → 8.1.2
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
CHANGED
|
@@ -314,4 +314,4 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to contribute to thi
|
|
|
314
314
|
|
|
315
315
|
## Credits
|
|
316
316
|
|
|
317
|
-
This SDK has been inspired by [Expo light sensor](https://docs.expo.dev/versions/latest/sdk/light-sensor/)
|
|
317
|
+
This SDK has been inspired by [Expo light sensor](https://docs.expo.dev/versions/latest/sdk/light-sensor/).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Result of a permission request or check.\n *\n * @since 0.0.1\n */\nexport interface PermissionStatus {\n /**\n * Whether the high sampling rate sensor permission is granted.\n * On Android 12+, this permission is required for update intervals below 200ms.\n *\n * @since 0.0.1\n */\n highSamplingRate: 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';\n}\n\n/**\n * A single light sensor measurement.\n *\n * @since 0.0.1\n */\nexport interface LightSensorMeasurement {\n /**\n * Ambient light level in lux (lx).\n *\n * @since 0.0.1\n */\n illuminance: number;\n\n /**\n * Timestamp of the measurement in seconds since epoch.\n *\n * @since 0.0.1\n */\n timestamp: number;\n}\n\n/**\n * Options for starting the light sensor listener.\n *\n * @since 0.0.1\n */\nexport interface StartOptions {\n /**\n * The desired interval between sensor updates in milliseconds.\n * On Android 12+, there's a minimum interval of 200ms unless the app\n * has the HIGH_SAMPLING_RATE_SENSORS permission.\n *\n * @default 200\n * @since 0.0.1\n */\n updateInterval?: number;\n}\n\n/**\n * Result indicating whether the sensor is available.\n *\n * @since 0.0.1\n */\nexport interface IsAvailableResult {\n /**\n * Whether the light sensor is available on this device.\n * Always false on iOS as the light sensor API is not available.\n *\n * @since 0.0.1\n */\n available: boolean;\n}\n\n/**\n * Plugin version information.\n *\n * @since 0.0.1\n */\nexport interface VersionResult {\n /**\n * The current version of the plugin.\n *\n * @since 0.0.1\n */\n version: string;\n}\n\n/**\n * Callback function for light sensor updates.\n *\n * @since 0.0.1\n */\nexport type LightSensorCallback = (measurement: LightSensorMeasurement) => void;\n\n/**\n * Capacitor plugin for accessing the device's ambient light sensor.\n *\n * @since 0.0.1\n */\nexport interface LightSensorPlugin {\n /**\n * Check if the light sensor is available on the current device.\n * You should always check sensor availability before attempting to use it.\n *\n * @returns Promise resolving to availability status\n * @since 0.0.1\n * @example\n * ```typescript\n * const { available } = await LightSensor.isAvailable();\n * ```\n */\n isAvailable(): Promise<IsAvailableResult>;\n\n /**\n * Start listening to light sensor updates.\n * This will begin sensor measurements at the specified interval.\n * Use `addListener` to receive the sensor data.\n *\n * @param options - Configuration options for the sensor\n * @returns Promise that resolves when the sensor has started\n * @since 0.0.1\n * @example\n * ```typescript\n * await LightSensor.start({ updateInterval: 500 });\n * ```\n */\n start(options?: StartOptions): Promise<void>;\n\n /**\n * Stop listening to light sensor updates.\n * This will stop the sensor and conserve battery.\n *\n * @returns Promise that resolves when the sensor has stopped\n * @since 0.0.1\n * @example\n * ```typescript\n * await LightSensor.stop();\n * ```\n */\n stop(): Promise<void>;\n\n /**\n * Add a listener for light sensor change events.\n * The listener will be called whenever new sensor data is available.\n *\n * @param eventName - Must be 'lightSensorChange'\n * @param listenerFunc - Callback function to receive sensor data\n * @returns Promise resolving to a handle for removing the listener\n * @since 0.0.1\n * @example\n * ```typescript\n * const handle = await LightSensor.addListener('lightSensorChange', (data) => {\n * console.log('Illuminance:', data.illuminance);\n * });\n * ```\n */\n addListener(
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Result of a permission request or check.\n *\n * @since 0.0.1\n */\nexport interface PermissionStatus {\n /**\n * Whether the high sampling rate sensor permission is granted.\n * On Android 12+, this permission is required for update intervals below 200ms.\n *\n * @since 0.0.1\n */\n highSamplingRate: 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';\n}\n\n/**\n * A single light sensor measurement.\n *\n * @since 0.0.1\n */\nexport interface LightSensorMeasurement {\n /**\n * Ambient light level in lux (lx).\n *\n * @since 0.0.1\n */\n illuminance: number;\n\n /**\n * Timestamp of the measurement in seconds since epoch.\n *\n * @since 0.0.1\n */\n timestamp: number;\n}\n\n/**\n * Options for starting the light sensor listener.\n *\n * @since 0.0.1\n */\nexport interface StartOptions {\n /**\n * The desired interval between sensor updates in milliseconds.\n * On Android 12+, there's a minimum interval of 200ms unless the app\n * has the HIGH_SAMPLING_RATE_SENSORS permission.\n *\n * @default 200\n * @since 0.0.1\n */\n updateInterval?: number;\n}\n\n/**\n * Result indicating whether the sensor is available.\n *\n * @since 0.0.1\n */\nexport interface IsAvailableResult {\n /**\n * Whether the light sensor is available on this device.\n * Always false on iOS as the light sensor API is not available.\n *\n * @since 0.0.1\n */\n available: boolean;\n}\n\n/**\n * Plugin version information.\n *\n * @since 0.0.1\n */\nexport interface VersionResult {\n /**\n * The current version of the plugin.\n *\n * @since 0.0.1\n */\n version: string;\n}\n\n/**\n * Callback function for light sensor updates.\n *\n * @since 0.0.1\n */\nexport type LightSensorCallback = (measurement: LightSensorMeasurement) => void;\n\n/**\n * Capacitor plugin for accessing the device's ambient light sensor.\n *\n * @since 0.0.1\n */\nexport interface LightSensorPlugin {\n /**\n * Check if the light sensor is available on the current device.\n * You should always check sensor availability before attempting to use it.\n *\n * @returns Promise resolving to availability status\n * @since 0.0.1\n * @example\n * ```typescript\n * const { available } = await LightSensor.isAvailable();\n * ```\n */\n isAvailable(): Promise<IsAvailableResult>;\n\n /**\n * Start listening to light sensor updates.\n * This will begin sensor measurements at the specified interval.\n * Use `addListener` to receive the sensor data.\n *\n * @param options - Configuration options for the sensor\n * @returns Promise that resolves when the sensor has started\n * @since 0.0.1\n * @example\n * ```typescript\n * await LightSensor.start({ updateInterval: 500 });\n * ```\n */\n start(options?: StartOptions): Promise<void>;\n\n /**\n * Stop listening to light sensor updates.\n * This will stop the sensor and conserve battery.\n *\n * @returns Promise that resolves when the sensor has stopped\n * @since 0.0.1\n * @example\n * ```typescript\n * await LightSensor.stop();\n * ```\n */\n stop(): Promise<void>;\n\n /**\n * Add a listener for light sensor change events.\n * The listener will be called whenever new sensor data is available.\n *\n * @param eventName - Must be 'lightSensorChange'\n * @param listenerFunc - Callback function to receive sensor data\n * @returns Promise resolving to a handle for removing the listener\n * @since 0.0.1\n * @example\n * ```typescript\n * const handle = await LightSensor.addListener('lightSensorChange', (data) => {\n * console.log('Illuminance:', data.illuminance);\n * });\n * ```\n */\n addListener(eventName: 'lightSensorChange', listenerFunc: LightSensorCallback): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for light sensor events.\n *\n * @returns Promise that resolves when all listeners have been removed\n * @since 0.0.1\n * @example\n * ```typescript\n * await LightSensor.removeAllListeners();\n * ```\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Check the current permission status for high sampling rate sensors.\n * On Android 12+, the HIGH_SAMPLING_RATE_SENSORS permission is required\n * for sensor update intervals below 200ms.\n *\n * @returns Promise resolving to the current permission status\n * @since 0.0.1\n * @example\n * ```typescript\n * const status = await LightSensor.checkPermissions();\n * ```\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request permission for high sampling rate sensors.\n * On Android 12+, this requests the HIGH_SAMPLING_RATE_SENSORS permission.\n *\n * @returns Promise resolving to the updated permission status\n * @since 0.0.1\n * @example\n * ```typescript\n * const status = await LightSensor.requestPermissions();\n * ```\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Get the current version of the plugin.\n *\n * @returns Promise resolving to the plugin version\n * @since 0.0.1\n * @example\n * ```typescript\n * const { version } = await LightSensor.getPluginVersion();\n * ```\n */\n getPluginVersion(): Promise<VersionResult>;\n}\n"]}
|
|
@@ -2,15 +2,6 @@ import XCTest
|
|
|
2
2
|
@testable import CapgoLightSensorPlugin
|
|
3
3
|
|
|
4
4
|
class CapgoLightSensorPluginTests: XCTestCase {
|
|
5
|
-
override func setUp() {
|
|
6
|
-
super.setUp()
|
|
7
|
-
// Setup code
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
override func tearDown() {
|
|
11
|
-
// Teardown code
|
|
12
|
-
super.tearDown()
|
|
13
|
-
}
|
|
14
5
|
|
|
15
6
|
func testIsAvailableReturnsFalse() {
|
|
16
7
|
// Light sensor should not be available on iOS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-light-sensor",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.2",
|
|
4
4
|
"description": "Capacitor plugin for accessing the device light sensor (Android only)",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"bugs": {
|
|
28
28
|
"url": "https://github.com/Cap-go/capacitor-light-sensor/issues"
|
|
29
29
|
},
|
|
30
|
+
"homepage": "https://capgo.app/docs/plugins/light-sensor/",
|
|
30
31
|
"keywords": [
|
|
31
32
|
"capacitor",
|
|
32
33
|
"plugin",
|