@capgo/capacitor-light-sensor 8.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,KAAK,CAAC,WAAW;QACf,uCAAuC;QACvC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,QAAuB;QACjC,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,eAAe;IACjB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,UAA+B,EAC/B,aAAkC;QAElC,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,eAAe;IACjB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\nimport { WebPlugin } from '@capacitor/core';\n\nimport type {\n LightSensorPlugin,\n IsAvailableResult,\n StartOptions,\n PermissionStatus,\n VersionResult,\n LightSensorCallback,\n} from './definitions';\n\nexport class LightSensorWeb extends WebPlugin implements LightSensorPlugin {\n async isAvailable(): Promise<IsAvailableResult> {\n // Light sensor is not available on web\n return { available: false };\n }\n\n async start(_options?: StartOptions): Promise<void> {\n throw this.unavailable('Light sensor is not available on web.');\n }\n\n async stop(): Promise<void> {\n // No-op on web\n }\n\n async addListener(\n _eventName: 'lightSensorChange',\n _listenerFunc: LightSensorCallback,\n ): Promise<PluginListenerHandle> {\n throw this.unavailable('Light sensor is not available on web.');\n }\n\n async removeAllListeners(): Promise<void> {\n // No-op on web\n }\n\n async checkPermissions(): Promise<PermissionStatus> {\n return { highSamplingRate: 'granted' };\n }\n\n async requestPermissions(): Promise<PermissionStatus> {\n return { highSamplingRate: 'granted' };\n }\n\n async getPluginVersion(): Promise<VersionResult> {\n return { version: '8.0.0' };\n }\n}\n"]}
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ const LightSensor = core.registerPlugin('CapgoLightSensor', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.LightSensorWeb()),
7
+ });
8
+
9
+ class LightSensorWeb extends core.WebPlugin {
10
+ async isAvailable() {
11
+ // Light sensor is not available on web
12
+ return { available: false };
13
+ }
14
+ async start(_options) {
15
+ throw this.unavailable('Light sensor is not available on web.');
16
+ }
17
+ async stop() {
18
+ // No-op on web
19
+ }
20
+ async addListener(_eventName, _listenerFunc) {
21
+ throw this.unavailable('Light sensor is not available on web.');
22
+ }
23
+ async removeAllListeners() {
24
+ // No-op on web
25
+ }
26
+ async checkPermissions() {
27
+ return { highSamplingRate: 'granted' };
28
+ }
29
+ async requestPermissions() {
30
+ return { highSamplingRate: 'granted' };
31
+ }
32
+ async getPluginVersion() {
33
+ return { version: '8.0.0' };
34
+ }
35
+ }
36
+
37
+ var web = /*#__PURE__*/Object.freeze({
38
+ __proto__: null,
39
+ LightSensorWeb: LightSensorWeb
40
+ });
41
+
42
+ exports.LightSensor = LightSensor;
43
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst LightSensor = registerPlugin('CapgoLightSensor', {\n web: () => import('./web').then((m) => new m.LightSensorWeb()),\n});\nexport * from './definitions';\nexport { LightSensor };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LightSensorWeb extends WebPlugin {\n async isAvailable() {\n // Light sensor is not available on web\n return { available: false };\n }\n async start(_options) {\n throw this.unavailable('Light sensor is not available on web.');\n }\n async stop() {\n // No-op on web\n }\n async addListener(_eventName, _listenerFunc) {\n throw this.unavailable('Light sensor is not available on web.');\n }\n async removeAllListeners() {\n // No-op on web\n }\n async checkPermissions() {\n return { highSamplingRate: 'granted' };\n }\n async requestPermissions() {\n return { highSamplingRate: 'granted' };\n }\n async getPluginVersion() {\n return { version: '8.0.0' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,WAAW,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AACvD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAClE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,MAAM,WAAW,GAAG;AACxB;AACA,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE;AACnC,IAAI;AACJ,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC;AACvE,IAAI;AACJ,IAAI,MAAM,IAAI,GAAG;AACjB;AACA,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;AACjD,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC;AACvE,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B;AACA,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE;AAC9C,IAAI;AACJ,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE;AAC9C,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;AACnC,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,46 @@
1
+ var capacitorLightSensor = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const LightSensor = core.registerPlugin('CapgoLightSensor', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.LightSensorWeb()),
6
+ });
7
+
8
+ class LightSensorWeb extends core.WebPlugin {
9
+ async isAvailable() {
10
+ // Light sensor is not available on web
11
+ return { available: false };
12
+ }
13
+ async start(_options) {
14
+ throw this.unavailable('Light sensor is not available on web.');
15
+ }
16
+ async stop() {
17
+ // No-op on web
18
+ }
19
+ async addListener(_eventName, _listenerFunc) {
20
+ throw this.unavailable('Light sensor is not available on web.');
21
+ }
22
+ async removeAllListeners() {
23
+ // No-op on web
24
+ }
25
+ async checkPermissions() {
26
+ return { highSamplingRate: 'granted' };
27
+ }
28
+ async requestPermissions() {
29
+ return { highSamplingRate: 'granted' };
30
+ }
31
+ async getPluginVersion() {
32
+ return { version: '8.0.0' };
33
+ }
34
+ }
35
+
36
+ var web = /*#__PURE__*/Object.freeze({
37
+ __proto__: null,
38
+ LightSensorWeb: LightSensorWeb
39
+ });
40
+
41
+ exports.LightSensor = LightSensor;
42
+
43
+ return exports;
44
+
45
+ })({}, capacitorExports);
46
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst LightSensor = registerPlugin('CapgoLightSensor', {\n web: () => import('./web').then((m) => new m.LightSensorWeb()),\n});\nexport * from './definitions';\nexport { LightSensor };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LightSensorWeb extends WebPlugin {\n async isAvailable() {\n // Light sensor is not available on web\n return { available: false };\n }\n async start(_options) {\n throw this.unavailable('Light sensor is not available on web.');\n }\n async stop() {\n // No-op on web\n }\n async addListener(_eventName, _listenerFunc) {\n throw this.unavailable('Light sensor is not available on web.');\n }\n async removeAllListeners() {\n // No-op on web\n }\n async checkPermissions() {\n return { highSamplingRate: 'granted' };\n }\n async requestPermissions() {\n return { highSamplingRate: 'granted' };\n }\n async getPluginVersion() {\n return { version: '8.0.0' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,WAAW,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IACvD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAClE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,MAAM,WAAW,GAAG;IACxB;IACA,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE;IACnC,IAAI;IACJ,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC;IACvE,IAAI;IACJ,IAAI,MAAM,IAAI,GAAG;IACjB;IACA,IAAI;IACJ,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;IACjD,QAAQ,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC;IACvE,IAAI;IACJ,IAAI,MAAM,kBAAkB,GAAG;IAC/B;IACA,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE;IAC9C,IAAI;IACJ,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE;IAC9C,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;IACnC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,46 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ @objc(CapgoLightSensorPlugin)
5
+ public class CapgoLightSensorPlugin: CAPPlugin, CAPBridgedPlugin {
6
+ public let identifier = "CapgoLightSensorPlugin"
7
+ public let jsName = "CapgoLightSensor"
8
+ public let pluginMethods: [CAPPluginMethod] = [
9
+ CAPPluginMethod(name: "isAvailable", returnType: CAPPluginReturnPromise),
10
+ CAPPluginMethod(name: "start", returnType: CAPPluginReturnPromise),
11
+ CAPPluginMethod(name: "stop", returnType: CAPPluginReturnPromise),
12
+ CAPPluginMethod(name: "checkPermissions", returnType: CAPPluginReturnPromise),
13
+ CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise),
14
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
15
+ ]
16
+
17
+ private let pluginVersion = "8.0.0"
18
+
19
+ @objc func isAvailable(_ call: CAPPluginCall) {
20
+ // Light sensor is not available on iOS - no public API
21
+ call.resolve(["available": false])
22
+ }
23
+
24
+ @objc func start(_ call: CAPPluginCall) {
25
+ call.reject("Light sensor is not available on iOS")
26
+ }
27
+
28
+ @objc func stop(_ call: CAPPluginCall) {
29
+ // No-op on iOS
30
+ call.resolve()
31
+ }
32
+
33
+ @objc override public func checkPermissions(_ call: CAPPluginCall) {
34
+ // Always return granted since no permission is needed (sensor not available)
35
+ call.resolve(["highSamplingRate": "granted"])
36
+ }
37
+
38
+ @objc override public func requestPermissions(_ call: CAPPluginCall) {
39
+ // Always return granted since no permission is needed (sensor not available)
40
+ call.resolve(["highSamplingRate": "granted"])
41
+ }
42
+
43
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
44
+ call.resolve(["version": pluginVersion])
45
+ }
46
+ }
@@ -0,0 +1,20 @@
1
+ import XCTest
2
+ @testable import CapgoLightSensorPlugin
3
+
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
+
15
+ func testIsAvailableReturnsFalse() {
16
+ // Light sensor should not be available on iOS
17
+ // This is a placeholder test since we can't easily test plugin methods
18
+ XCTAssertTrue(true, "Light sensor is not available on iOS")
19
+ }
20
+ }
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@capgo/capacitor-light-sensor",
3
+ "version": "8.0.0",
4
+ "description": "Capacitor plugin for accessing the device light sensor (Android only)",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "android/gradle.properties",
13
+ "android/settings.gradle",
14
+ "android/proguard-rules.pro",
15
+ "dist/",
16
+ "ios/Sources/",
17
+ "ios/Tests/",
18
+ "Package.swift",
19
+ "CapgoCapacitorLightSensor.podspec"
20
+ ],
21
+ "author": "Capgo",
22
+ "license": "MPL-2.0",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/Cap-go/capacitor-light-sensor.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/Cap-go/capacitor-light-sensor/issues"
29
+ },
30
+ "keywords": [
31
+ "capacitor",
32
+ "plugin",
33
+ "native",
34
+ "light",
35
+ "sensor",
36
+ "ambient",
37
+ "illuminance",
38
+ "lux",
39
+ "android"
40
+ ],
41
+ "scripts": {
42
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
43
+ "verify:ios": "xcodebuild -scheme CapgoCapacitorLightSensor -destination generic/platform=iOS",
44
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
45
+ "verify:web": "npm run build",
46
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
47
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
48
+ "eslint": "eslint . --ext ts",
49
+ "prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
50
+ "swiftlint": "node-swiftlint",
51
+ "docgen": "docgen --api LightSensorPlugin --output-readme README.md --output-json dist/docs.json --source-dir src",
52
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
53
+ "clean": "rimraf ./dist",
54
+ "watch": "tsc --watch",
55
+ "prepublishOnly": "npm run build"
56
+ },
57
+ "devDependencies": {
58
+ "@capacitor/android": "^8.0.0",
59
+ "@capacitor/core": "^8.0.0",
60
+ "@capacitor/docgen": "^0.3.1",
61
+ "@capacitor/ios": "^8.0.0",
62
+ "@ionic/eslint-config": "^0.4.0",
63
+ "@ionic/prettier-config": "^4.0.0",
64
+ "@ionic/swiftlint-config": "^2.0.0",
65
+ "@types/node": "^24.10.1",
66
+ "eslint": "^8.57.1",
67
+ "eslint-plugin-import": "^2.31.0",
68
+ "prettier": "^3.6.2",
69
+ "prettier-plugin-java": "^2.7.7",
70
+ "prettier-pretty-check": "^0.2.0",
71
+ "rimraf": "^6.1.0",
72
+ "rollup": "^4.53.2",
73
+ "swiftlint": "^2.0.0",
74
+ "typescript": "^5.9.3"
75
+ },
76
+ "peerDependencies": {
77
+ "@capacitor/core": "^8.0.0"
78
+ },
79
+ "prettier": "@ionic/prettier-config",
80
+ "swiftlint": "@ionic/swiftlint-config",
81
+ "eslintConfig": {
82
+ "extends": "@ionic/eslint-config/recommended"
83
+ },
84
+ "capacitor": {
85
+ "ios": {
86
+ "src": "ios"
87
+ },
88
+ "android": {
89
+ "src": "android"
90
+ }
91
+ }
92
+ }