react-native-neuroscan 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 +20 -0
- package/Neuroscan.podspec +29 -0
- package/README.md +233 -0
- package/android/app/build/generated/source/codegen/RCTAppDependencyProvider.h +25 -0
- package/android/app/build/generated/source/codegen/RCTAppDependencyProvider.mm +35 -0
- package/android/app/build/generated/source/codegen/RCTModuleProviders.h +16 -0
- package/android/app/build/generated/source/codegen/RCTModuleProviders.mm +51 -0
- package/android/app/build/generated/source/codegen/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/android/app/build/generated/source/codegen/RCTModulesConformingToProtocolsProvider.mm +54 -0
- package/android/app/build/generated/source/codegen/RCTThirdPartyComponentsProvider.h +16 -0
- package/android/app/build/generated/source/codegen/RCTThirdPartyComponentsProvider.mm +30 -0
- package/android/app/build/generated/source/codegen/ReactAppDependencyProvider.podspec +34 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeNeuroscanSpec.java +67 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/NeuroScanCameraViewManagerDelegate.java +72 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/NeuroScanCameraViewManagerInterface.java +29 -0
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
- package/android/app/build/generated/source/codegen/jni/RNNeuroScanSpec-generated.cpp +74 -0
- package/android/app/build/generated/source/codegen/jni/RNNeuroScanSpec.h +31 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/ComponentDescriptors.cpp +22 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/ComponentDescriptors.h +24 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/EventEmitters.cpp +62 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/EventEmitters.h +54 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/Props.cpp +32 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/Props.h +34 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/RNNeuroScanSpecJSI-generated.cpp +80 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/RNNeuroScanSpecJSI.h +134 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/ShadowNodes.cpp +17 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/ShadowNodes.h +32 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/States.cpp +16 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNNeuroScanSpec/States.h +29 -0
- package/android/build.gradle +73 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/neuroscan/NeuroscanModule.kt +342 -0
- package/android/src/main/java/com/neuroscan/NeuroscanPackage.kt +36 -0
- package/ios/DocumentScannerController.swift +115 -0
- package/ios/NeuroScanImpl.swift +226 -0
- package/ios/Neuroscan.h +5 -0
- package/ios/Neuroscan.mm +118 -0
- package/lib/module/NativeNeuroscan.js +5 -0
- package/lib/module/NativeNeuroscan.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeNeuroscan.d.ts +47 -0
- package/lib/typescript/src/NativeNeuroscan.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +126 -0
- package/src/NativeNeuroscan.ts +52 -0
- package/src/index.tsx +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dmytro
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "Neuroscan"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "16.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/dmytro/react-native-neuroscan.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
s.swift_version = "5.9"
|
|
19
|
+
|
|
20
|
+
s.frameworks = "VisionKit", "UIKit"
|
|
21
|
+
|
|
22
|
+
s.pod_target_xcconfig = {
|
|
23
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
24
|
+
"GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited)",
|
|
25
|
+
"CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES" => "YES"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
install_modules_dependencies(s)
|
|
29
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# react-native-neuroscan
|
|
2
|
+
|
|
3
|
+
High-performance native document scanner for React Native with automatic edge detection, perspective correction, and advanced image processing. Built as a TurboModule for the New Architecture.
|
|
4
|
+
|
|
5
|
+
- **iOS** — Apple VisionKit (`VNDocumentCameraViewController`)
|
|
6
|
+
- **Android** — Google ML Kit Document Scanner
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- Native document camera UI with real-time edge detection
|
|
11
|
+
- Automatic perspective correction
|
|
12
|
+
- Multi-page scanning with configurable page limits
|
|
13
|
+
- Gallery import support (Android)
|
|
14
|
+
- Post-processing filters: brightness, contrast, sharpness, rotation, crop
|
|
15
|
+
- Grayscale and black & white document modes with threshold control
|
|
16
|
+
- JPEG / PNG output with adjustable quality
|
|
17
|
+
- Temporary file management with cleanup API
|
|
18
|
+
- Full TypeScript support
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
| Platform | Minimum Version |
|
|
23
|
+
|----------|----------------|
|
|
24
|
+
| iOS | 16.0 |
|
|
25
|
+
| Android | SDK 24 (Android 7.0) |
|
|
26
|
+
| React Native | 0.76+ (New Architecture) |
|
|
27
|
+
|
|
28
|
+
**Android note:** requires Google Play Services (ML Kit). Devices without GMS (e.g. Huawei) are not currently supported.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npm install react-native-neuroscan
|
|
34
|
+
# or
|
|
35
|
+
yarn add react-native-neuroscan
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### iOS
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
cd ios && pod install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Add camera permission to `Info.plist`:
|
|
45
|
+
|
|
46
|
+
```xml
|
|
47
|
+
<key>NSCameraUsageDescription</key>
|
|
48
|
+
<string>We need camera access to scan documents</string>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Android
|
|
52
|
+
|
|
53
|
+
Camera permission is declared in the library's `AndroidManifest.xml` and will be merged automatically. No additional setup required.
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### Scan documents
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { NeuroScan } from 'react-native-neuroscan';
|
|
61
|
+
|
|
62
|
+
async function scan() {
|
|
63
|
+
try {
|
|
64
|
+
const result = await NeuroScan.scanDocument({
|
|
65
|
+
maxPages: 5,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
console.log(`Scanned ${result.pageCount} pages`);
|
|
69
|
+
console.log(result.imageUrls); // ['file:///...page1.jpg', ...]
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (error.code === 'SCANNER_CANCELLED') {
|
|
72
|
+
// User dismissed the scanner
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
console.error(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Process images
|
|
81
|
+
|
|
82
|
+
Apply filters to scanned images. Filters are applied in order: **crop > rotate > brightness/contrast > sharpen > grayscale/threshold**.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
const processed = await NeuroScan.processImage({
|
|
86
|
+
imageUrl: result.imageUrls[0],
|
|
87
|
+
brightness: 10,
|
|
88
|
+
contrast: 20,
|
|
89
|
+
sharpness: 50,
|
|
90
|
+
rotation: 90,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
console.log(processed.imageUrl); // 'file:///...processed.jpg'
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Black & white document mode
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
const bw = await NeuroScan.processImage({
|
|
100
|
+
imageUrl: result.imageUrls[0],
|
|
101
|
+
threshold: 128, // 0-255, converts to pure black & white
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Crop with normalized coordinates
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
const cropped = await NeuroScan.processImage({
|
|
109
|
+
imageUrl: result.imageUrls[0],
|
|
110
|
+
cropX: 0.1, // 10% from left
|
|
111
|
+
cropY: 0.1, // 10% from top
|
|
112
|
+
cropWidth: 0.8, // 80% of width
|
|
113
|
+
cropHeight: 0.8, // 80% of height
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Cleanup temporary files
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
await NeuroScan.cleanupTempFiles();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## API Reference
|
|
124
|
+
|
|
125
|
+
### `scanDocument(options?)`
|
|
126
|
+
|
|
127
|
+
Opens the native document scanner UI.
|
|
128
|
+
|
|
129
|
+
#### Options
|
|
130
|
+
|
|
131
|
+
| Parameter | Type | Default | Description |
|
|
132
|
+
|-----------|------|---------|-------------|
|
|
133
|
+
| `maxPages` | `number` | `0` | Maximum pages to scan. `0` = unlimited |
|
|
134
|
+
| `enableAutoCapture` | `boolean` | `true` | Enable automatic capture mode |
|
|
135
|
+
|
|
136
|
+
#### Returns
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
Promise<{
|
|
140
|
+
imageUrls: string[]; // Array of file:// URIs (JPEG)
|
|
141
|
+
pageCount: number; // Number of scanned pages
|
|
142
|
+
}>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### `processImage(options)`
|
|
148
|
+
|
|
149
|
+
Applies post-processing filters to an image. Returns a new file URI — the original is not modified.
|
|
150
|
+
|
|
151
|
+
#### Options
|
|
152
|
+
|
|
153
|
+
| Parameter | Type | Range | Default | Description |
|
|
154
|
+
|-----------|------|-------|---------|-------------|
|
|
155
|
+
| `imageUrl` | `string` | — | **required** | `file://` URI of the source image |
|
|
156
|
+
| `brightness` | `number` | -100 to 100 | `0` | Brightness adjustment |
|
|
157
|
+
| `contrast` | `number` | -100 to 100 | `0` | Contrast adjustment |
|
|
158
|
+
| `sharpness` | `number` | 0 to 100 | `0` | Sharpening intensity |
|
|
159
|
+
| `rotation` | `number` | 0, 90, 180, 270 | `0` | Rotation in degrees |
|
|
160
|
+
| `grayscale` | `boolean` | — | `false` | Convert to grayscale |
|
|
161
|
+
| `threshold` | `number` | 0 to 255 | `0` | B&W threshold (`0` = disabled) |
|
|
162
|
+
| `cropX` | `number` | 0 to 1 | — | Normalized crop X offset |
|
|
163
|
+
| `cropY` | `number` | 0 to 1 | — | Normalized crop Y offset |
|
|
164
|
+
| `cropWidth` | `number` | 0 to 1 | — | Normalized crop width |
|
|
165
|
+
| `cropHeight` | `number` | 0 to 1 | — | Normalized crop height |
|
|
166
|
+
| `outputFormat` | `string` | `"jpeg"`, `"png"` | `"jpeg"` | Output image format |
|
|
167
|
+
| `quality` | `number` | 1 to 100 | `90` | Compression quality |
|
|
168
|
+
|
|
169
|
+
#### Returns
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
Promise<{
|
|
173
|
+
imageUrl: string; // file:// URI of the processed image
|
|
174
|
+
}>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### `cleanupTempFiles()`
|
|
180
|
+
|
|
181
|
+
Removes all temporary files created by the scanner and image processor.
|
|
182
|
+
|
|
183
|
+
#### Returns
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
Promise<boolean> // true on success
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Error Codes
|
|
190
|
+
|
|
191
|
+
| Code | Description |
|
|
192
|
+
|------|-------------|
|
|
193
|
+
| `CAMERA_UNAVAILABLE` | Camera or scanner UI is not available on this device |
|
|
194
|
+
| `SCANNER_CANCELLED` | User dismissed the scanner |
|
|
195
|
+
| `SCANNER_FAILED` | Scanner initialization or execution error |
|
|
196
|
+
| `PROCESS_FAILED` | Image processing error |
|
|
197
|
+
| `CLEANUP_FAILED` | Failed to remove temporary files |
|
|
198
|
+
|
|
199
|
+
## Example
|
|
200
|
+
|
|
201
|
+
A full working example app is included in the [`example/`](./example) directory. It demonstrates scanning, page gallery, and an image editor with all available filters.
|
|
202
|
+
|
|
203
|
+
```sh
|
|
204
|
+
# Clone the repo
|
|
205
|
+
git clone https://github.com/nicklvsa/react-native-neuroscan.git
|
|
206
|
+
cd react-native-neuroscan
|
|
207
|
+
|
|
208
|
+
# Install dependencies
|
|
209
|
+
yarn install
|
|
210
|
+
|
|
211
|
+
# Run the example
|
|
212
|
+
yarn example ios
|
|
213
|
+
# or
|
|
214
|
+
yarn example android
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## How It Works
|
|
218
|
+
|
|
219
|
+
### iOS
|
|
220
|
+
|
|
221
|
+
Uses Apple's `VNDocumentCameraViewController` from the VisionKit framework. Edge detection and perspective correction are handled natively by the system. Image processing uses Core Image filters (`CIColorControls`, `CISharpenLuminance`, `CIPhotoEffectMono`, `CIColorThreshold`).
|
|
222
|
+
|
|
223
|
+
### Android
|
|
224
|
+
|
|
225
|
+
Uses Google ML Kit Document Scanner API in full scanner mode with gallery import support. Image processing uses Android's `ColorMatrix` for color adjustments and convolution kernels for sharpening. All processing runs on coroutines with the IO dispatcher.
|
|
226
|
+
|
|
227
|
+
## Contributing
|
|
228
|
+
|
|
229
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow details.
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
|
|
11
|
+
#if __has_include(<React-RCTAppDelegate/RCTDependencyProvider.h>)
|
|
12
|
+
#import <React-RCTAppDelegate/RCTDependencyProvider.h>
|
|
13
|
+
#elif __has_include(<React_RCTAppDelegate/RCTDependencyProvider.h>)
|
|
14
|
+
#import <React_RCTAppDelegate/RCTDependencyProvider.h>
|
|
15
|
+
#else
|
|
16
|
+
#import "RCTDependencyProvider.h"
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
20
|
+
|
|
21
|
+
@interface RCTAppDependencyProvider : NSObject <RCTDependencyProvider>
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#import "RCTAppDependencyProvider.h"
|
|
9
|
+
#import <ReactCodegen/RCTModulesConformingToProtocolsProvider.h>
|
|
10
|
+
#import <ReactCodegen/RCTThirdPartyComponentsProvider.h>
|
|
11
|
+
#import <ReactCodegen/RCTModuleProviders.h>
|
|
12
|
+
|
|
13
|
+
@implementation RCTAppDependencyProvider
|
|
14
|
+
|
|
15
|
+
- (nonnull NSArray<NSString *> *)URLRequestHandlerClassNames {
|
|
16
|
+
return RCTModulesConformingToProtocolsProvider.URLRequestHandlerClassNames;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
- (nonnull NSArray<NSString *> *)imageDataDecoderClassNames {
|
|
20
|
+
return RCTModulesConformingToProtocolsProvider.imageDataDecoderClassNames;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
- (nonnull NSArray<NSString *> *)imageURLLoaderClassNames {
|
|
24
|
+
return RCTModulesConformingToProtocolsProvider.imageURLLoaderClassNames;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (nonnull NSDictionary<NSString *,Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents {
|
|
28
|
+
return RCTThirdPartyComponentsProvider.thirdPartyFabricComponents;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (nonnull NSDictionary<NSString *, id<RCTModuleProvider>> *)moduleProviders {
|
|
32
|
+
return RCTModuleProviders.moduleProviders;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
|
|
10
|
+
@protocol RCTModuleProvider;
|
|
11
|
+
|
|
12
|
+
@interface RCTModuleProviders: NSObject
|
|
13
|
+
|
|
14
|
+
+ (NSDictionary<NSString *, id<RCTModuleProvider>> *)moduleProviders;
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
|
|
10
|
+
#import "RCTModuleProviders.h"
|
|
11
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
12
|
+
#import <React/RCTLog.h>
|
|
13
|
+
|
|
14
|
+
@implementation RCTModuleProviders
|
|
15
|
+
|
|
16
|
+
+ (NSDictionary<NSString *, id<RCTModuleProvider>> *)moduleProviders
|
|
17
|
+
{
|
|
18
|
+
static NSDictionary<NSString *, id<RCTModuleProvider>> *providers = nil;
|
|
19
|
+
static dispatch_once_t onceToken;
|
|
20
|
+
|
|
21
|
+
dispatch_once(&onceToken, ^{
|
|
22
|
+
NSDictionary<NSString *, NSString *> * moduleMapping = @{
|
|
23
|
+
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:moduleMapping.count];
|
|
27
|
+
|
|
28
|
+
for (NSString *key in moduleMapping) {
|
|
29
|
+
NSString * moduleProviderName = moduleMapping[key];
|
|
30
|
+
Class klass = NSClassFromString(moduleProviderName);
|
|
31
|
+
if (!klass) {
|
|
32
|
+
RCTLogError(@"Module provider %@ cannot be found in the runtime", moduleProviderName);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
id instance = [klass new];
|
|
37
|
+
if (![instance respondsToSelector:@selector(getTurboModule:)]) {
|
|
38
|
+
RCTLogError(@"Module provider %@ does not conform to RCTModuleProvider", moduleProviderName);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[dict setObject:instance forKey:key];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
providers = dict;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return providers;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
|
|
10
|
+
@interface RCTModulesConformingToProtocolsProvider: NSObject
|
|
11
|
+
|
|
12
|
+
+(NSArray<NSString *> *)imageURLLoaderClassNames;
|
|
13
|
+
|
|
14
|
+
+(NSArray<NSString *> *)imageDataDecoderClassNames;
|
|
15
|
+
|
|
16
|
+
+(NSArray<NSString *> *)URLRequestHandlerClassNames;
|
|
17
|
+
|
|
18
|
+
@end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#import "RCTModulesConformingToProtocolsProvider.h"
|
|
9
|
+
|
|
10
|
+
@implementation RCTModulesConformingToProtocolsProvider
|
|
11
|
+
|
|
12
|
+
+(NSArray<NSString *> *)imageURLLoaderClassNames
|
|
13
|
+
{
|
|
14
|
+
static NSArray<NSString *> *classNames = nil;
|
|
15
|
+
static dispatch_once_t onceToken;
|
|
16
|
+
|
|
17
|
+
dispatch_once(&onceToken, ^{
|
|
18
|
+
classNames = @[
|
|
19
|
+
|
|
20
|
+
];
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return classNames;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
+(NSArray<NSString *> *)imageDataDecoderClassNames
|
|
27
|
+
{
|
|
28
|
+
static NSArray<NSString *> *classNames = nil;
|
|
29
|
+
static dispatch_once_t onceToken;
|
|
30
|
+
|
|
31
|
+
dispatch_once(&onceToken, ^{
|
|
32
|
+
classNames = @[
|
|
33
|
+
|
|
34
|
+
];
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return classNames;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+(NSArray<NSString *> *)URLRequestHandlerClassNames
|
|
41
|
+
{
|
|
42
|
+
static NSArray<NSString *> *classNames = nil;
|
|
43
|
+
static dispatch_once_t onceToken;
|
|
44
|
+
|
|
45
|
+
dispatch_once(&onceToken, ^{
|
|
46
|
+
classNames = @[
|
|
47
|
+
|
|
48
|
+
];
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return classNames;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
|
|
10
|
+
@protocol RCTComponentViewProtocol;
|
|
11
|
+
|
|
12
|
+
@interface RCTThirdPartyComponentsProvider: NSObject
|
|
13
|
+
|
|
14
|
+
+ (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents;
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
|
|
11
|
+
#import "RCTThirdPartyComponentsProvider.h"
|
|
12
|
+
#import <React/RCTComponentViewProtocol.h>
|
|
13
|
+
|
|
14
|
+
@implementation RCTThirdPartyComponentsProvider
|
|
15
|
+
|
|
16
|
+
+ (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
|
|
17
|
+
{
|
|
18
|
+
static NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *thirdPartyComponents = nil;
|
|
19
|
+
static dispatch_once_t nativeComponentsToken;
|
|
20
|
+
|
|
21
|
+
dispatch_once(&nativeComponentsToken, ^{
|
|
22
|
+
thirdPartyComponents = @{
|
|
23
|
+
@"NeuroScanCameraView": NSClassFromString(@"NeuroScanCameraViewComponentView"), // react-native-neuroscan
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return thirdPartyComponents;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
version = "0.79.0"
|
|
7
|
+
source = { :git => 'https://github.com/facebook/react-native.git' }
|
|
8
|
+
if version == '1000.0.0'
|
|
9
|
+
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
|
10
|
+
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
|
|
11
|
+
else
|
|
12
|
+
source[:tag] = "v#{version}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Pod::Spec.new do |s|
|
|
16
|
+
s.name = "ReactAppDependencyProvider"
|
|
17
|
+
s.version = version
|
|
18
|
+
s.summary = "The third party dependency provider for the app"
|
|
19
|
+
s.homepage = "https://reactnative.dev/"
|
|
20
|
+
s.documentation_url = "https://reactnative.dev/"
|
|
21
|
+
s.license = "MIT"
|
|
22
|
+
s.author = "Meta Platforms, Inc. and its affiliates"
|
|
23
|
+
s.platforms = min_supported_versions
|
|
24
|
+
s.source = source
|
|
25
|
+
s.source_files = "**/RCTAppDependencyProvider.{h,mm}"
|
|
26
|
+
|
|
27
|
+
# This guard prevent to install the dependencies when we run `pod install` in the old architecture.
|
|
28
|
+
s.pod_target_xcconfig = {
|
|
29
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
30
|
+
"DEFINES_MODULE" => "YES"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
s.dependency "ReactCodegen"
|
|
34
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.facebook.fbreact.specs;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
22
|
+
import javax.annotation.Nonnull;
|
|
23
|
+
|
|
24
|
+
public abstract class NativeNeuroscanSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
25
|
+
public static final String NAME = "Neuroscan";
|
|
26
|
+
|
|
27
|
+
public NativeNeuroscanSpec(ReactApplicationContext reactContext) {
|
|
28
|
+
super(reactContext);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public @Nonnull String getName() {
|
|
33
|
+
return NAME;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactMethod
|
|
37
|
+
@DoNotStrip
|
|
38
|
+
public abstract void scanDocument(ReadableMap options, Promise promise);
|
|
39
|
+
|
|
40
|
+
@ReactMethod
|
|
41
|
+
@DoNotStrip
|
|
42
|
+
public abstract void detectEdges(String imageUri, Promise promise);
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
public abstract void cropDocument(String imageUri, ReadableMap corners, Promise promise);
|
|
47
|
+
|
|
48
|
+
@ReactMethod
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
public abstract void processImage(String imageUri, ReadableMap options, Promise promise);
|
|
51
|
+
|
|
52
|
+
@ReactMethod
|
|
53
|
+
@DoNotStrip
|
|
54
|
+
public abstract void scanAndProcess(String imageUri, ReadableMap processOptions, Promise promise);
|
|
55
|
+
|
|
56
|
+
@ReactMethod
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
public abstract void cleanupTempFiles(Promise promise);
|
|
59
|
+
|
|
60
|
+
@ReactMethod
|
|
61
|
+
@DoNotStrip
|
|
62
|
+
public abstract void addListener(String eventType);
|
|
63
|
+
|
|
64
|
+
@ReactMethod
|
|
65
|
+
@DoNotStrip
|
|
66
|
+
public abstract void removeListeners(double count);
|
|
67
|
+
}
|