@sigx/lynx-camera 0.1.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/LICENSE +21 -0
- package/README.md +72 -0
- package/android/com/sigx/camera/CameraModule.kt +49 -0
- package/dist/camera.d.ts +44 -0
- package/dist/camera.d.ts.map +1 -0
- package/dist/camera.js +33 -0
- package/dist/camera.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/ios/CameraModule.swift +127 -0
- package/package.json +33 -0
- package/sigx-module.json +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Andreas Ekdahl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @sigx/lynx-camera
|
|
2
|
+
|
|
3
|
+
Photo capture via the system camera for sigx-lynx. iOS uses `UIImagePickerController`; Android uses an `ACTION_IMAGE_CAPTURE` intent fed by a `FileProvider` URI (the cache-path is wired by the app template's manifest).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @sigx/lynx-camera
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// sigx.lynx.config.ts
|
|
13
|
+
export default defineLynxConfig({
|
|
14
|
+
modules: ['@sigx/lynx-camera'],
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`sigx prebuild` auto-links the native module, injects `android.permission.CAMERA`, and adds the iOS usage descriptions:
|
|
19
|
+
|
|
20
|
+
- `NSCameraUsageDescription`
|
|
21
|
+
- `NSMicrophoneUsageDescription`
|
|
22
|
+
- `NSPhotoLibraryAddUsageDescription`
|
|
23
|
+
|
|
24
|
+
Override the prompts in your `sigx.lynx.config.ts` under `ios.usageDescriptions` if you want app-specific copy.
|
|
25
|
+
|
|
26
|
+
> **Android pairs with `@sigx/lynx-permissions`** — that's where the runtime permission prompt + Activity Result wiring lives. Add it to your modules list (or anything that depends on it does, transitively).
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { Camera } from '@sigx/lynx-camera';
|
|
32
|
+
|
|
33
|
+
const { status } = await Camera.requestPermission();
|
|
34
|
+
if (status === 'granted') {
|
|
35
|
+
const photo = await Camera.takePicture({ quality: 0.8, facing: 'back' });
|
|
36
|
+
console.log(photo.uri, photo.width, photo.height);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
| Method | Notes |
|
|
43
|
+
| --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
44
|
+
| `takePicture(options?: CameraOptions): Promise<PhotoResult>` | Opens the system camera. Returns the captured photo's file URI + dimensions. Throws if cancelled or denied. |
|
|
45
|
+
| `requestPermission(): Promise<PermissionResponse>` | Shows the OS permission dialog if needed. Re-call to surface the dialog again on first denial. |
|
|
46
|
+
| `getPermissionStatus(): Promise<PermissionResponse>` | Read-only check — no prompt. |
|
|
47
|
+
| `isAvailable(): boolean` | Whether the native module is registered in the current build. |
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
interface CameraOptions {
|
|
51
|
+
facing?: 'front' | 'back'; // default: 'back'
|
|
52
|
+
quality?: number; // 0..1
|
|
53
|
+
maxWidth?: number; // pixels
|
|
54
|
+
maxHeight?: number; // pixels
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface PhotoResult {
|
|
58
|
+
uri: string; // file:// URI
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
base64?: string; // populated only if requested
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Gotchas
|
|
66
|
+
|
|
67
|
+
- **Android FileProvider** — the auto-injected `<provider>` in the app template's `AndroidManifest.xml` exposes the cache directory under `${applicationId}.fileprovider`. If you customize the manifest, keep that authority intact or the camera intent won't have a valid write target.
|
|
68
|
+
- **iOS simulator camera** — the simulator has a synthetic camera feed, not a real one. Test capture on a physical device.
|
|
69
|
+
|
|
70
|
+
## Reference app
|
|
71
|
+
|
|
72
|
+
`examples/lynx-one/my-sigx-app/src/cards/CameraCard.tsx` covers permission + capture + display flows end-to-end.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
package com.sigx.camera
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import com.lynx.jsbridge.LynxMethod
|
|
6
|
+
import com.lynx.jsbridge.LynxModule
|
|
7
|
+
import com.lynx.react.bridge.Callback
|
|
8
|
+
import com.lynx.react.bridge.JavaOnlyMap
|
|
9
|
+
import com.sigx.permissions.PermissionHelper
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Camera capture module using system camera intent.
|
|
13
|
+
* JS usage: NativeModules.Camera.takePicture({ quality: 0.8 }, callback)
|
|
14
|
+
*/
|
|
15
|
+
class CameraModule(context: Context) : LynxModule(context) {
|
|
16
|
+
|
|
17
|
+
companion object {
|
|
18
|
+
private const val TAG = "CameraModule"
|
|
19
|
+
const val REQUEST_IMAGE_CAPTURE = 9001
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@LynxMethod
|
|
23
|
+
fun takePicture(options: com.lynx.react.bridge.ReadableMap?, callback: Callback?) {
|
|
24
|
+
// Delegates to MediaCapture (in @sigx/lynx-permissions) which holds
|
|
25
|
+
// the ActivityResultContracts.TakePicture launcher registered at
|
|
26
|
+
// MainActivity.onCreate. On success, the JS callback receives
|
|
27
|
+
// { uri: "content://...", canceled: false } pointing at a JPEG in
|
|
28
|
+
// the app's cacheDir. Quality option is currently ignored — the
|
|
29
|
+
// system camera picks its own settings; we'll plumb it through
|
|
30
|
+
// when we add a CameraX-based custom-UI module.
|
|
31
|
+
com.sigx.permissions.MediaCapture.takePicture(mContext) { result ->
|
|
32
|
+
callback?.invoke(result)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@LynxMethod
|
|
37
|
+
fun requestPermission(callback: Callback?) {
|
|
38
|
+
PermissionHelper.requestPermission(mContext, "camera") { result ->
|
|
39
|
+
callback?.invoke(result)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@LynxMethod
|
|
44
|
+
fun getPermissionStatus(callback: Callback?) {
|
|
45
|
+
val result = PermissionHelper.checkPermission(mContext, "camera")
|
|
46
|
+
callback?.invoke(result)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
package/dist/camera.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PermissionResponse } from '@sigx/lynx-core';
|
|
2
|
+
export interface CameraOptions {
|
|
3
|
+
/** 'front' or 'back' camera */
|
|
4
|
+
facing?: 'front' | 'back';
|
|
5
|
+
/** Image quality 0-1 */
|
|
6
|
+
quality?: number;
|
|
7
|
+
/** Max width in pixels */
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
/** Max height in pixels */
|
|
10
|
+
maxHeight?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface PhotoResult {
|
|
13
|
+
/** File URI of the captured photo */
|
|
14
|
+
uri: string;
|
|
15
|
+
/** Width in pixels */
|
|
16
|
+
width: number;
|
|
17
|
+
/** Height in pixels */
|
|
18
|
+
height: number;
|
|
19
|
+
/** Base64-encoded image data (if requested) */
|
|
20
|
+
base64?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Camera capture APIs.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { Camera } from '@sigx/lynx-camera';
|
|
28
|
+
*
|
|
29
|
+
* const { status } = await Camera.requestPermission();
|
|
30
|
+
* if (status === 'granted') {
|
|
31
|
+
* const photo = await Camera.takePicture({ quality: 0.8 });
|
|
32
|
+
* console.log(photo.uri);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const Camera: {
|
|
37
|
+
readonly takePicture: (options?: CameraOptions) => Promise<PhotoResult>;
|
|
38
|
+
/** Request camera permission, showing the OS dialog if needed. */
|
|
39
|
+
readonly requestPermission: () => Promise<PermissionResponse>;
|
|
40
|
+
/** Check current camera permission status without prompting. */
|
|
41
|
+
readonly getPermissionStatus: () => Promise<PermissionResponse>;
|
|
42
|
+
readonly isAvailable: () => boolean;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=camera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI1D,MAAM,WAAW,aAAa;IAC1B,+BAA+B;IAC/B,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IACxB,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM;qCACM,aAAa,KAAQ,OAAO,CAAC,WAAW,CAAC;IAI9D,kEAAkE;sCAC7C,OAAO,CAAC,kBAAkB,CAAC;IAIhD,gEAAgE;wCACzC,OAAO,CAAC,kBAAkB,CAAC;gCAInC,OAAO;CAGhB,CAAC"}
|
package/dist/camera.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { callAsync, isModuleAvailable } from '@sigx/lynx-core';
|
|
2
|
+
const MODULE = 'Camera';
|
|
3
|
+
/**
|
|
4
|
+
* Camera capture APIs.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Camera } from '@sigx/lynx-camera';
|
|
9
|
+
*
|
|
10
|
+
* const { status } = await Camera.requestPermission();
|
|
11
|
+
* if (status === 'granted') {
|
|
12
|
+
* const photo = await Camera.takePicture({ quality: 0.8 });
|
|
13
|
+
* console.log(photo.uri);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const Camera = {
|
|
18
|
+
takePicture(options = {}) {
|
|
19
|
+
return callAsync(MODULE, 'takePicture', options);
|
|
20
|
+
},
|
|
21
|
+
/** Request camera permission, showing the OS dialog if needed. */
|
|
22
|
+
requestPermission() {
|
|
23
|
+
return callAsync(MODULE, 'requestPermission');
|
|
24
|
+
},
|
|
25
|
+
/** Check current camera permission status without prompting. */
|
|
26
|
+
getPermissionStatus() {
|
|
27
|
+
return callAsync(MODULE, 'getPermissionStatus');
|
|
28
|
+
},
|
|
29
|
+
isAvailable() {
|
|
30
|
+
return isModuleAvailable(MODULE);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=camera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAG/D,MAAM,MAAM,GAAG,QAAQ,CAAC;AAwBxB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,WAAW,CAAC,UAAyB,EAAE;QACnC,OAAO,SAAS,CAAc,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,kEAAkE;IAClE,iBAAiB;QACb,OAAO,SAAS,CAAqB,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACtE,CAAC;IAED,gEAAgE;IAChE,mBAAmB;QACf,OAAO,SAAS,CAAqB,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACxE,CAAC;IAED,WAAW;QACP,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACK,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import AVFoundation
|
|
3
|
+
import Lynx
|
|
4
|
+
|
|
5
|
+
/// Camera capture module.
|
|
6
|
+
/// JS usage: NativeModules.Camera.takePicture({ quality: 0.8 }, callback)
|
|
7
|
+
class CameraModule: NSObject, LynxModule, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
|
|
8
|
+
|
|
9
|
+
@objc static var name: String { "Camera" }
|
|
10
|
+
|
|
11
|
+
@objc static var methodLookup: [String: String] {
|
|
12
|
+
[
|
|
13
|
+
"takePicture": NSStringFromSelector(#selector(takePicture(_:callback:))),
|
|
14
|
+
"requestPermission": NSStringFromSelector(#selector(requestPermission(_:))),
|
|
15
|
+
"getPermissionStatus": NSStringFromSelector(#selector(getPermissionStatus(_:))),
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private var pendingCallback: LynxCallbackBlock?
|
|
20
|
+
|
|
21
|
+
required override init() { super.init() }
|
|
22
|
+
required init(param: Any) { super.init() }
|
|
23
|
+
|
|
24
|
+
@objc func takePicture(_ options: [String: Any]?, callback: LynxCallbackBlock?) {
|
|
25
|
+
guard UIImagePickerController.isSourceTypeAvailable(.camera) else {
|
|
26
|
+
callback?(["error": "Camera not available on this device"])
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
|
31
|
+
guard status == .authorized else {
|
|
32
|
+
if status == .notDetermined {
|
|
33
|
+
AVCaptureDevice.requestAccess(for: .video) { [weak self] granted in
|
|
34
|
+
if granted {
|
|
35
|
+
self?.presentCamera(options: options, callback: callback)
|
|
36
|
+
} else {
|
|
37
|
+
callback?(["error": "Camera permission denied"])
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
callback?(["error": "Camera permission not granted"])
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
presentCamera(options: options, callback: callback)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@objc func requestPermission(_ callback: LynxCallbackBlock?) {
|
|
50
|
+
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
|
51
|
+
if status == .notDetermined {
|
|
52
|
+
AVCaptureDevice.requestAccess(for: .video) { granted in
|
|
53
|
+
callback?(["status": granted ? "granted" : "denied"])
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
callback?(["status": permissionString(for: status)])
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@objc func getPermissionStatus(_ callback: LynxCallbackBlock?) {
|
|
61
|
+
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
|
62
|
+
callback?(["status": permissionString(for: status)])
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private func presentCamera(options: [String: Any]?, callback: LynxCallbackBlock?) {
|
|
66
|
+
DispatchQueue.main.async { [weak self] in
|
|
67
|
+
guard let self = self else { return }
|
|
68
|
+
self.pendingCallback = callback
|
|
69
|
+
|
|
70
|
+
let picker = UIImagePickerController()
|
|
71
|
+
picker.sourceType = .camera
|
|
72
|
+
picker.delegate = self
|
|
73
|
+
picker.allowsEditing = false
|
|
74
|
+
|
|
75
|
+
UIApplication.shared.windows.first?.rootViewController?.present(picker, animated: true)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
|
|
80
|
+
picker.dismiss(animated: true)
|
|
81
|
+
|
|
82
|
+
guard let image = info[.originalImage] as? UIImage else {
|
|
83
|
+
pendingCallback?(["error": "Failed to capture image"])
|
|
84
|
+
pendingCallback = nil
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let quality: CGFloat = 0.8
|
|
89
|
+
guard let data = image.jpegData(compressionQuality: quality) else {
|
|
90
|
+
pendingCallback?(["error": "Failed to compress image"])
|
|
91
|
+
pendingCallback = nil
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let fileName = "camera_\(UUID().uuidString).jpg"
|
|
96
|
+
let tempPath = NSTemporaryDirectory() + fileName
|
|
97
|
+
do {
|
|
98
|
+
try data.write(to: URL(fileURLWithPath: tempPath))
|
|
99
|
+
let result: [String: Any] = [
|
|
100
|
+
"uri": tempPath,
|
|
101
|
+
"width": Int(image.size.width),
|
|
102
|
+
"height": Int(image.size.height),
|
|
103
|
+
"fileSize": data.count,
|
|
104
|
+
]
|
|
105
|
+
pendingCallback?(result)
|
|
106
|
+
} catch {
|
|
107
|
+
pendingCallback?(["error": error.localizedDescription])
|
|
108
|
+
}
|
|
109
|
+
pendingCallback = nil
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
|
113
|
+
picker.dismiss(animated: true)
|
|
114
|
+
pendingCallback?(["cancelled": true])
|
|
115
|
+
pendingCallback = nil
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private func permissionString(for status: AVAuthorizationStatus) -> String {
|
|
119
|
+
switch status {
|
|
120
|
+
case .notDetermined: return "undetermined"
|
|
121
|
+
case .restricted: return "restricted"
|
|
122
|
+
case .denied: return "denied"
|
|
123
|
+
case .authorized: return "granted"
|
|
124
|
+
@unknown default: return "unknown"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sigx/lynx-camera",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Camera capture for sigx-lynx",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./sigx-module.json": "./sigx-module.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"ios",
|
|
18
|
+
"android",
|
|
19
|
+
"sigx-module.json"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@sigx/lynx-core": "^0.1.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"typescript": "^5.9.3"
|
|
26
|
+
},
|
|
27
|
+
"author": "Andreas Ekdahl",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"dev": "tsc --watch"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/sigx-module.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Camera",
|
|
3
|
+
"package": "@sigx/lynx-camera",
|
|
4
|
+
"description": "Photo/video capture",
|
|
5
|
+
"platforms": ["android", "ios"],
|
|
6
|
+
"ios": {
|
|
7
|
+
"moduleClass": "CameraModule",
|
|
8
|
+
"sourceDir": "ios",
|
|
9
|
+
"methods": ["takePicture","requestPermission","getPermissionStatus"],
|
|
10
|
+
"usageDescriptions": {
|
|
11
|
+
"NSCameraUsageDescription": "Allow camera access to take photos and videos.",
|
|
12
|
+
"NSMicrophoneUsageDescription": "Allow microphone access to record video with audio.",
|
|
13
|
+
"NSPhotoLibraryAddUsageDescription": "Allow access to save captured photos to your library."
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"android": {
|
|
17
|
+
"moduleClass": "com.sigx.camera.CameraModule",
|
|
18
|
+
"sourceDir": "android",
|
|
19
|
+
"permissions": ["android.permission.CAMERA"]
|
|
20
|
+
}
|
|
21
|
+
}
|