@real-life-org/capacitor-zxing-scanner 1.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,18 @@
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 = 'CapacitorZxingScanner'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/CapacitorZxingScanner/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '15.0'
15
+ s.swift_version = '5.9'
16
+ s.dependency 'Capacitor'
17
+ s.frameworks = 'AVFoundation'
18
+ end
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Capacitor ZXing Scanner
2
+
3
+ An F-Droid compatible, drop-in replacement for the official `@capacitor/barcode-scanner` plugin.
4
+
5
+ ## Why this plugin?
6
+
7
+ The official `@capacitor/barcode-scanner` relies on Google's ML Kit for Android. While performant, ML Kit is a proprietary Google Mobile Service (GMS) and is **not compatible with F-Droid** or "de-Googled" Android devices.
8
+
9
+ This plugin solves that problem by using the open-source **ZXing** library on Android and native **AVFoundation** on iOS, ensuring your app can be distributed freely without relying on proprietary blob dependencies.
10
+
11
+ ## Features
12
+
13
+ * **F-Droid Compatible:** Uses ZXing on Android (no Google Play Services required).
14
+ * **Drop-in Replacement:** Exports the same API and names as `@capacitor/barcode-scanner`, allowing you to migrate by simply changing the import path.
15
+ * **Native Performance:** Utilizes CameraX on Android and AVFoundation on iOS.
16
+ * *Note: Web scanning is not supported. Please use a fallback like `html5-qrcode`.*
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @real-life-org/capacitor-zxing-scanner
22
+ npx cap sync
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ You can use the exported `CapacitorBarcodeScanner` exactly as you would the official plugin:
28
+
29
+ ```typescript
30
+ import { CapacitorBarcodeScanner } from '@real-life-org/capacitor-zxing-scanner';
31
+
32
+ const scanResult = await CapacitorBarcodeScanner.scanBarcode({
33
+ hint: 0 // Optional hint for barcode type
34
+ });
35
+
36
+ console.log('Scanned text:', scanResult.ScanResult);
37
+ ```
38
+
39
+ ## Limitations
40
+
41
+ * **Currently hardcoded to QR Codes:** While the API defines various formats, the underlying native implementations currently only scan for QR Codes.
42
+ * **Web Fallback:** No built-in web implementation.
43
+
44
+ ## Development
45
+
46
+ ```bash
47
+ # Install dependencies
48
+ npm install
49
+
50
+ # Build the plugin
51
+ npm run build
52
+
53
+ # Lint the code
54
+ npm run lint
55
+
56
+ # Format the code
57
+ npm run fmt
58
+ ```
59
+
60
+ ## License
61
+
62
+ MIT
@@ -0,0 +1,29 @@
1
+ apply plugin: 'com.android.library'
2
+
3
+ android {
4
+ namespace = "org.reallife.capacitor.zxingscanner"
5
+ compileSdk rootProject.ext.has('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
6
+ defaultConfig {
7
+ minSdk rootProject.ext.has('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
8
+ targetSdk rootProject.ext.has('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
9
+ }
10
+ buildTypes {
11
+ release {
12
+ minifyEnabled false
13
+ }
14
+ }
15
+ compileOptions {
16
+ sourceCompatibility JavaVersion.VERSION_21
17
+ targetCompatibility JavaVersion.VERSION_21
18
+ }
19
+ }
20
+
21
+ dependencies {
22
+ implementation 'com.google.zxing:core:3.5.3'
23
+ implementation 'androidx.camera:camera-camera2:1.5.1'
24
+ implementation 'androidx.camera:camera-lifecycle:1.5.1'
25
+ implementation 'androidx.camera:camera-view:1.5.1'
26
+ implementation 'androidx.activity:activity:1.11.0'
27
+ implementation project(':capacitor-android')
28
+ implementation "androidx.appcompat:appcompat:1.7.1"
29
+ }
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+ <uses-permission android:name="android.permission.CAMERA" />
5
+ <uses-feature android:name="android.hardware.camera" android:required="false" />
6
+
7
+ <application>
8
+ <activity
9
+ android:name="org.reallife.capacitor.zxingscanner.ScannerActivity"
10
+ android:exported="false"
11
+ android:theme="@style/Theme.AppCompat.NoActionBar"
12
+ android:screenOrientation="portrait" />
13
+ </application>
14
+
15
+ </manifest>
@@ -0,0 +1,154 @@
1
+ package org.reallife.capacitor.zxingscanner;
2
+
3
+ import android.content.Intent;
4
+ import android.graphics.ImageFormat;
5
+ import android.os.Bundle;
6
+ import android.util.Size;
7
+ import android.view.KeyEvent;
8
+ import android.widget.FrameLayout;
9
+
10
+ import androidx.annotation.NonNull;
11
+ import androidx.appcompat.app.AppCompatActivity;
12
+ import androidx.camera.core.CameraSelector;
13
+ import androidx.camera.core.ImageAnalysis;
14
+ import androidx.camera.core.ImageProxy;
15
+ import androidx.camera.core.Preview;
16
+ import androidx.camera.lifecycle.ProcessCameraProvider;
17
+ import androidx.camera.view.PreviewView;
18
+ import androidx.core.content.ContextCompat;
19
+
20
+ import com.google.common.util.concurrent.ListenableFuture;
21
+ import com.google.zxing.BarcodeFormat;
22
+ import com.google.zxing.BinaryBitmap;
23
+ import com.google.zxing.DecodeHintType;
24
+ import com.google.zxing.MultiFormatReader;
25
+ import com.google.zxing.NotFoundException;
26
+ import com.google.zxing.PlanarYUVLuminanceSource;
27
+ import com.google.zxing.Result;
28
+ import com.google.zxing.common.HybridBinarizer;
29
+
30
+ import java.nio.ByteBuffer;
31
+ import java.util.Collections;
32
+ import java.util.EnumMap;
33
+ import java.util.Map;
34
+ import java.util.concurrent.ExecutionException;
35
+ import java.util.concurrent.ExecutorService;
36
+ import java.util.concurrent.Executors;
37
+
38
+ public class ScannerActivity extends AppCompatActivity {
39
+
40
+ public static final String EXTRA_SCAN_RESULT = "SCAN_RESULT";
41
+
42
+ private ExecutorService cameraExecutor;
43
+ private volatile boolean resultDelivered = false;
44
+
45
+ @Override
46
+ protected void onCreate(Bundle savedInstanceState) {
47
+ super.onCreate(savedInstanceState);
48
+
49
+ PreviewView previewView = new PreviewView(this);
50
+ previewView.setLayoutParams(new FrameLayout.LayoutParams(
51
+ FrameLayout.LayoutParams.MATCH_PARENT,
52
+ FrameLayout.LayoutParams.MATCH_PARENT
53
+ ));
54
+ setContentView(previewView);
55
+
56
+ cameraExecutor = Executors.newSingleThreadExecutor();
57
+ startCamera(previewView);
58
+ }
59
+
60
+ private void startCamera(PreviewView previewView) {
61
+ ListenableFuture<ProcessCameraProvider> future = ProcessCameraProvider.getInstance(this);
62
+ future.addListener(() -> {
63
+ try {
64
+ ProcessCameraProvider cameraProvider = future.get();
65
+
66
+ Preview preview = new Preview.Builder().build();
67
+ preview.setSurfaceProvider(previewView.getSurfaceProvider());
68
+
69
+ ImageAnalysis imageAnalysis = new ImageAnalysis.Builder()
70
+ .setTargetResolution(new Size(1280, 720))
71
+ .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
72
+ .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888)
73
+ .build();
74
+
75
+ imageAnalysis.setAnalyzer(cameraExecutor, this::processImage);
76
+
77
+ cameraProvider.unbindAll();
78
+ cameraProvider.bindToLifecycle(
79
+ this,
80
+ CameraSelector.DEFAULT_BACK_CAMERA,
81
+ preview,
82
+ imageAnalysis
83
+ );
84
+ } catch (ExecutionException | InterruptedException e) {
85
+ deliverCancel();
86
+ }
87
+ }, ContextCompat.getMainExecutor(this));
88
+ }
89
+
90
+ private void processImage(@NonNull ImageProxy imageProxy) {
91
+ if (resultDelivered) {
92
+ imageProxy.close();
93
+ return;
94
+ }
95
+
96
+ ByteBuffer buffer = imageProxy.getPlanes()[0].getBuffer();
97
+ byte[] bytes = new byte[buffer.remaining()];
98
+ buffer.get(bytes);
99
+
100
+ int width = imageProxy.getWidth();
101
+ int height = imageProxy.getHeight();
102
+
103
+ PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(
104
+ bytes, width, height, 0, 0, width, height, false
105
+ );
106
+ BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
107
+
108
+ Map<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);
109
+ hints.put(DecodeHintType.POSSIBLE_FORMATS, Collections.singletonList(BarcodeFormat.QR_CODE));
110
+ hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
111
+
112
+ try {
113
+ Result result = new MultiFormatReader().decode(bitmap, hints);
114
+ deliverResult(result.getText());
115
+ } catch (NotFoundException e) {
116
+ // No barcode in this frame — continue scanning
117
+ } finally {
118
+ imageProxy.close();
119
+ }
120
+ }
121
+
122
+ private void deliverResult(String text) {
123
+ if (resultDelivered) return;
124
+ resultDelivered = true;
125
+ Intent intent = new Intent();
126
+ intent.putExtra(EXTRA_SCAN_RESULT, text);
127
+ setResult(RESULT_OK, intent);
128
+ finish();
129
+ }
130
+
131
+ private void deliverCancel() {
132
+ if (resultDelivered) return;
133
+ resultDelivered = true;
134
+ setResult(RESULT_CANCELED);
135
+ finish();
136
+ }
137
+
138
+ @Override
139
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
140
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
141
+ deliverCancel();
142
+ return true;
143
+ }
144
+ return super.onKeyDown(keyCode, event);
145
+ }
146
+
147
+ @Override
148
+ protected void onDestroy() {
149
+ super.onDestroy();
150
+ if (cameraExecutor != null) {
151
+ cameraExecutor.shutdown();
152
+ }
153
+ }
154
+ }
@@ -0,0 +1,65 @@
1
+ package org.reallife.capacitor.zxingscanner;
2
+
3
+ import android.Manifest;
4
+ import android.app.Activity;
5
+ import android.content.Intent;
6
+
7
+ import androidx.activity.result.ActivityResult;
8
+
9
+ import com.getcapacitor.JSObject;
10
+ import com.getcapacitor.Plugin;
11
+ import com.getcapacitor.PluginCall;
12
+ import com.getcapacitor.PluginMethod;
13
+ import com.getcapacitor.annotation.ActivityCallback;
14
+ import com.getcapacitor.annotation.CapacitorPlugin;
15
+ import com.getcapacitor.annotation.Permission;
16
+ import com.getcapacitor.annotation.PermissionCallback;
17
+
18
+ @CapacitorPlugin(
19
+ name = "CapacitorBarcodeScanner",
20
+ permissions = {
21
+ @Permission(strings = {Manifest.permission.CAMERA}, alias = "camera")
22
+ }
23
+ )
24
+ public class ZxingScannerPlugin extends Plugin {
25
+
26
+ @PluginMethod
27
+ public void scanBarcode(PluginCall call) {
28
+ if (getPermissionState("camera") != com.getcapacitor.PermissionState.GRANTED) {
29
+ requestPermissionForAlias("camera", call, "cameraPermissionCallback");
30
+ } else {
31
+ startScannerActivity(call);
32
+ }
33
+ }
34
+
35
+ @PermissionCallback
36
+ private void cameraPermissionCallback(PluginCall call) {
37
+ if (getPermissionState("camera") == com.getcapacitor.PermissionState.GRANTED) {
38
+ startScannerActivity(call);
39
+ } else {
40
+ call.reject("Camera permission denied");
41
+ }
42
+ }
43
+
44
+ private void startScannerActivity(PluginCall call) {
45
+ Intent intent = new Intent(getContext(), ScannerActivity.class);
46
+ startActivityForResult(call, intent, "scanBarcodeResult");
47
+ }
48
+
49
+ @ActivityCallback
50
+ private void scanBarcodeResult(PluginCall call, ActivityResult result) {
51
+ if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
52
+ String text = result.getData().getStringExtra(ScannerActivity.EXTRA_SCAN_RESULT);
53
+ if (text != null) {
54
+ JSObject ret = new JSObject();
55
+ ret.put("ScanResult", text);
56
+ ret.put("format", "QR_CODE");
57
+ call.resolve(ret);
58
+ } else {
59
+ call.reject("No scan result");
60
+ }
61
+ } else {
62
+ call.reject("Scanner cancelled");
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Compatible replacement for @capacitor/barcode-scanner.
3
+ * Exports the same names so existing code can change only the import path.
4
+ */
5
+ export declare enum CapacitorBarcodeScannerTypeHint {
6
+ QR_CODE = 0,
7
+ AZTEC = 1,
8
+ CODABAR = 2,
9
+ CODE_39 = 3,
10
+ CODE_93 = 4,
11
+ CODE_128 = 5,
12
+ DATA_MATRIX = 6,
13
+ EAN_8 = 7,
14
+ EAN_13 = 8,
15
+ ITF = 9,
16
+ MAXICODE = 10,
17
+ PDF_417 = 11,
18
+ RSS_14 = 12,
19
+ RSS_EXPANDED = 13,
20
+ UPC_A = 14,
21
+ UPC_E = 15,
22
+ UPC_EAN_EXTENSION = 16,
23
+ ALL = 17
24
+ }
25
+ export declare enum CapacitorBarcodeScannerCameraDirection {
26
+ BACK = 1,
27
+ FRONT = 2
28
+ }
29
+ export declare enum CapacitorBarcodeScannerAndroidScanningLibrary {
30
+ /** Uses ZXing (Apache 2.0, F-Droid compatible). */
31
+ ZXING = "zxing",
32
+ /** Alias for ZXING — MLKIT is not available in this plugin. Falls back silently. */
33
+ MLKIT = "mlkit"
34
+ }
35
+ export interface CapacitorBarcodeScannerAndroidOptions {
36
+ scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary;
37
+ }
38
+ export interface CapacitorBarcodeScannerOptions {
39
+ hint: CapacitorBarcodeScannerTypeHint;
40
+ cameraDirection?: CapacitorBarcodeScannerCameraDirection;
41
+ scanInstructions?: string;
42
+ scanButton?: boolean;
43
+ scanText?: string;
44
+ android?: CapacitorBarcodeScannerAndroidOptions;
45
+ }
46
+ export interface CapacitorBarcodeScannerScanResult {
47
+ ScanResult: string;
48
+ }
49
+ export interface CapacitorBarcodeScannerPlugin {
50
+ scanBarcode(options: CapacitorBarcodeScannerOptions): Promise<CapacitorBarcodeScannerScanResult>;
51
+ }
52
+ export declare const CapacitorBarcodeScanner: CapacitorBarcodeScannerPlugin;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Compatible replacement for @capacitor/barcode-scanner.
3
+ * Exports the same names so existing code can change only the import path.
4
+ */
5
+ export var CapacitorBarcodeScannerTypeHint;
6
+ (function (CapacitorBarcodeScannerTypeHint) {
7
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["QR_CODE"] = 0] = "QR_CODE";
8
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["AZTEC"] = 1] = "AZTEC";
9
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODABAR"] = 2] = "CODABAR";
10
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_39"] = 3] = "CODE_39";
11
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_93"] = 4] = "CODE_93";
12
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_128"] = 5] = "CODE_128";
13
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["DATA_MATRIX"] = 6] = "DATA_MATRIX";
14
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["EAN_8"] = 7] = "EAN_8";
15
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["EAN_13"] = 8] = "EAN_13";
16
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["ITF"] = 9] = "ITF";
17
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["MAXICODE"] = 10] = "MAXICODE";
18
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["PDF_417"] = 11] = "PDF_417";
19
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["RSS_14"] = 12] = "RSS_14";
20
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["RSS_EXPANDED"] = 13] = "RSS_EXPANDED";
21
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_A"] = 14] = "UPC_A";
22
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_E"] = 15] = "UPC_E";
23
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_EAN_EXTENSION"] = 16] = "UPC_EAN_EXTENSION";
24
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["ALL"] = 17] = "ALL";
25
+ })(CapacitorBarcodeScannerTypeHint || (CapacitorBarcodeScannerTypeHint = {}));
26
+ export var CapacitorBarcodeScannerCameraDirection;
27
+ (function (CapacitorBarcodeScannerCameraDirection) {
28
+ CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection["BACK"] = 1] = "BACK";
29
+ CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection["FRONT"] = 2] = "FRONT";
30
+ })(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));
31
+ export var CapacitorBarcodeScannerAndroidScanningLibrary;
32
+ (function (CapacitorBarcodeScannerAndroidScanningLibrary) {
33
+ /** Uses ZXing (Apache 2.0, F-Droid compatible). */
34
+ CapacitorBarcodeScannerAndroidScanningLibrary["ZXING"] = "zxing";
35
+ /** Alias for ZXING — MLKIT is not available in this plugin. Falls back silently. */
36
+ CapacitorBarcodeScannerAndroidScanningLibrary["MLKIT"] = "mlkit";
37
+ })(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));
@@ -0,0 +1,4 @@
1
+ import type { CapacitorBarcodeScannerPlugin } from './definitions';
2
+ export * from './definitions';
3
+ declare const CapacitorBarcodeScanner: CapacitorBarcodeScannerPlugin;
4
+ export { CapacitorBarcodeScanner };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ import { CapacitorBarcodeScannerWeb } from './web';
3
+ export * from './definitions';
4
+ const CapacitorBarcodeScanner = registerPlugin('CapacitorBarcodeScanner', {
5
+ web: () => new CapacitorBarcodeScannerWeb(),
6
+ });
7
+ export { CapacitorBarcodeScanner };
@@ -0,0 +1,5 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { CapacitorBarcodeScannerOptions, CapacitorBarcodeScannerPlugin, CapacitorBarcodeScannerScanResult } from './definitions';
3
+ export declare class CapacitorBarcodeScannerWeb extends WebPlugin implements CapacitorBarcodeScannerPlugin {
4
+ scanBarcode(_options: CapacitorBarcodeScannerOptions): Promise<CapacitorBarcodeScannerScanResult>;
5
+ }
@@ -0,0 +1,6 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class CapacitorBarcodeScannerWeb extends WebPlugin {
3
+ async scanBarcode(_options) {
4
+ throw this.unimplemented('ZXing scanner is not available on web. Use html5-qrcode or another web-based QR scanner as a fallback.');
5
+ }
6
+ }
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
6
+ async scanBarcode(_options) {
7
+ throw this.unimplemented('ZXing scanner is not available on web. Use html5-qrcode or another web-based QR scanner as a fallback.');
8
+ }
9
+ }
10
+
11
+ /**
12
+ * Compatible replacement for @capacitor/barcode-scanner.
13
+ * Exports the same names so existing code can change only the import path.
14
+ */
15
+ exports.CapacitorBarcodeScannerTypeHint = void 0;
16
+ (function (CapacitorBarcodeScannerTypeHint) {
17
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["QR_CODE"] = 0] = "QR_CODE";
18
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["AZTEC"] = 1] = "AZTEC";
19
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODABAR"] = 2] = "CODABAR";
20
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_39"] = 3] = "CODE_39";
21
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_93"] = 4] = "CODE_93";
22
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_128"] = 5] = "CODE_128";
23
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["DATA_MATRIX"] = 6] = "DATA_MATRIX";
24
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["EAN_8"] = 7] = "EAN_8";
25
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["EAN_13"] = 8] = "EAN_13";
26
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["ITF"] = 9] = "ITF";
27
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["MAXICODE"] = 10] = "MAXICODE";
28
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["PDF_417"] = 11] = "PDF_417";
29
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["RSS_14"] = 12] = "RSS_14";
30
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["RSS_EXPANDED"] = 13] = "RSS_EXPANDED";
31
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_A"] = 14] = "UPC_A";
32
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_E"] = 15] = "UPC_E";
33
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_EAN_EXTENSION"] = 16] = "UPC_EAN_EXTENSION";
34
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["ALL"] = 17] = "ALL";
35
+ })(exports.CapacitorBarcodeScannerTypeHint || (exports.CapacitorBarcodeScannerTypeHint = {}));
36
+ exports.CapacitorBarcodeScannerCameraDirection = void 0;
37
+ (function (CapacitorBarcodeScannerCameraDirection) {
38
+ CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection["BACK"] = 1] = "BACK";
39
+ CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection["FRONT"] = 2] = "FRONT";
40
+ })(exports.CapacitorBarcodeScannerCameraDirection || (exports.CapacitorBarcodeScannerCameraDirection = {}));
41
+ exports.CapacitorBarcodeScannerAndroidScanningLibrary = void 0;
42
+ (function (CapacitorBarcodeScannerAndroidScanningLibrary) {
43
+ /** Uses ZXing (Apache 2.0, F-Droid compatible). */
44
+ CapacitorBarcodeScannerAndroidScanningLibrary["ZXING"] = "zxing";
45
+ /** Alias for ZXING — MLKIT is not available in this plugin. Falls back silently. */
46
+ CapacitorBarcodeScannerAndroidScanningLibrary["MLKIT"] = "mlkit";
47
+ })(exports.CapacitorBarcodeScannerAndroidScanningLibrary || (exports.CapacitorBarcodeScannerAndroidScanningLibrary = {}));
48
+
49
+ const CapacitorBarcodeScanner = core.registerPlugin('CapacitorBarcodeScanner', {
50
+ web: () => new CapacitorBarcodeScannerWeb(),
51
+ });
52
+
53
+ exports.CapacitorBarcodeScanner = CapacitorBarcodeScanner;
54
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/web.js","esm/definitions.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n async scanBarcode(_options) {\n throw this.unimplemented('ZXing scanner is not available on web. Use html5-qrcode or another web-based QR scanner as a fallback.');\n }\n}\n","/**\n * Compatible replacement for @capacitor/barcode-scanner.\n * Exports the same names so existing code can change only the import path.\n */\nexport var CapacitorBarcodeScannerTypeHint;\n(function (CapacitorBarcodeScannerTypeHint) {\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"QR_CODE\"] = 0] = \"QR_CODE\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"AZTEC\"] = 1] = \"AZTEC\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODABAR\"] = 2] = \"CODABAR\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODE_39\"] = 3] = \"CODE_39\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODE_93\"] = 4] = \"CODE_93\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODE_128\"] = 5] = \"CODE_128\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"DATA_MATRIX\"] = 6] = \"DATA_MATRIX\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"EAN_8\"] = 7] = \"EAN_8\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"EAN_13\"] = 8] = \"EAN_13\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"ITF\"] = 9] = \"ITF\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"MAXICODE\"] = 10] = \"MAXICODE\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"PDF_417\"] = 11] = \"PDF_417\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"RSS_14\"] = 12] = \"RSS_14\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"RSS_EXPANDED\"] = 13] = \"RSS_EXPANDED\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"UPC_A\"] = 14] = \"UPC_A\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"UPC_E\"] = 15] = \"UPC_E\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"UPC_EAN_EXTENSION\"] = 16] = \"UPC_EAN_EXTENSION\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHint || (CapacitorBarcodeScannerTypeHint = {}));\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n /** Uses ZXing (Apache 2.0, F-Droid compatible). */\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n /** Alias for ZXING — MLKIT is not available in this plugin. Falls back silently. */\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n","import { registerPlugin } from '@capacitor/core';\nimport { CapacitorBarcodeScannerWeb } from './web';\nexport * from './definitions';\nconst CapacitorBarcodeScanner = registerPlugin('CapacitorBarcodeScanner', {\n web: () => new CapacitorBarcodeScannerWeb(),\n});\nexport { CapacitorBarcodeScanner };\n"],"names":["WebPlugin","CapacitorBarcodeScannerTypeHint","CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin"],"mappings":"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"}
package/dist/plugin.js ADDED
@@ -0,0 +1,57 @@
1
+ var capacitorZxingScanner = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
5
+ async scanBarcode(_options) {
6
+ throw this.unimplemented('ZXing scanner is not available on web. Use html5-qrcode or another web-based QR scanner as a fallback.');
7
+ }
8
+ }
9
+
10
+ /**
11
+ * Compatible replacement for @capacitor/barcode-scanner.
12
+ * Exports the same names so existing code can change only the import path.
13
+ */
14
+ exports.CapacitorBarcodeScannerTypeHint = void 0;
15
+ (function (CapacitorBarcodeScannerTypeHint) {
16
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["QR_CODE"] = 0] = "QR_CODE";
17
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["AZTEC"] = 1] = "AZTEC";
18
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODABAR"] = 2] = "CODABAR";
19
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_39"] = 3] = "CODE_39";
20
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_93"] = 4] = "CODE_93";
21
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["CODE_128"] = 5] = "CODE_128";
22
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["DATA_MATRIX"] = 6] = "DATA_MATRIX";
23
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["EAN_8"] = 7] = "EAN_8";
24
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["EAN_13"] = 8] = "EAN_13";
25
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["ITF"] = 9] = "ITF";
26
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["MAXICODE"] = 10] = "MAXICODE";
27
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["PDF_417"] = 11] = "PDF_417";
28
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["RSS_14"] = 12] = "RSS_14";
29
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["RSS_EXPANDED"] = 13] = "RSS_EXPANDED";
30
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_A"] = 14] = "UPC_A";
31
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_E"] = 15] = "UPC_E";
32
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["UPC_EAN_EXTENSION"] = 16] = "UPC_EAN_EXTENSION";
33
+ CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint["ALL"] = 17] = "ALL";
34
+ })(exports.CapacitorBarcodeScannerTypeHint || (exports.CapacitorBarcodeScannerTypeHint = {}));
35
+ exports.CapacitorBarcodeScannerCameraDirection = void 0;
36
+ (function (CapacitorBarcodeScannerCameraDirection) {
37
+ CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection["BACK"] = 1] = "BACK";
38
+ CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection["FRONT"] = 2] = "FRONT";
39
+ })(exports.CapacitorBarcodeScannerCameraDirection || (exports.CapacitorBarcodeScannerCameraDirection = {}));
40
+ exports.CapacitorBarcodeScannerAndroidScanningLibrary = void 0;
41
+ (function (CapacitorBarcodeScannerAndroidScanningLibrary) {
42
+ /** Uses ZXing (Apache 2.0, F-Droid compatible). */
43
+ CapacitorBarcodeScannerAndroidScanningLibrary["ZXING"] = "zxing";
44
+ /** Alias for ZXING — MLKIT is not available in this plugin. Falls back silently. */
45
+ CapacitorBarcodeScannerAndroidScanningLibrary["MLKIT"] = "mlkit";
46
+ })(exports.CapacitorBarcodeScannerAndroidScanningLibrary || (exports.CapacitorBarcodeScannerAndroidScanningLibrary = {}));
47
+
48
+ const CapacitorBarcodeScanner = core.registerPlugin('CapacitorBarcodeScanner', {
49
+ web: () => new CapacitorBarcodeScannerWeb(),
50
+ });
51
+
52
+ exports.CapacitorBarcodeScanner = CapacitorBarcodeScanner;
53
+
54
+ return exports;
55
+
56
+ })({}, capacitorExports);
57
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/web.js","esm/definitions.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n async scanBarcode(_options) {\n throw this.unimplemented('ZXing scanner is not available on web. Use html5-qrcode or another web-based QR scanner as a fallback.');\n }\n}\n","/**\n * Compatible replacement for @capacitor/barcode-scanner.\n * Exports the same names so existing code can change only the import path.\n */\nexport var CapacitorBarcodeScannerTypeHint;\n(function (CapacitorBarcodeScannerTypeHint) {\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"QR_CODE\"] = 0] = \"QR_CODE\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"AZTEC\"] = 1] = \"AZTEC\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODABAR\"] = 2] = \"CODABAR\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODE_39\"] = 3] = \"CODE_39\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODE_93\"] = 4] = \"CODE_93\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"CODE_128\"] = 5] = \"CODE_128\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"DATA_MATRIX\"] = 6] = \"DATA_MATRIX\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"EAN_8\"] = 7] = \"EAN_8\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"EAN_13\"] = 8] = \"EAN_13\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"ITF\"] = 9] = \"ITF\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"MAXICODE\"] = 10] = \"MAXICODE\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"PDF_417\"] = 11] = \"PDF_417\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"RSS_14\"] = 12] = \"RSS_14\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"RSS_EXPANDED\"] = 13] = \"RSS_EXPANDED\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"UPC_A\"] = 14] = \"UPC_A\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"UPC_E\"] = 15] = \"UPC_E\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"UPC_EAN_EXTENSION\"] = 16] = \"UPC_EAN_EXTENSION\";\n CapacitorBarcodeScannerTypeHint[CapacitorBarcodeScannerTypeHint[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHint || (CapacitorBarcodeScannerTypeHint = {}));\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n /** Uses ZXing (Apache 2.0, F-Droid compatible). */\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n /** Alias for ZXING — MLKIT is not available in this plugin. Falls back silently. */\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n","import { registerPlugin } from '@capacitor/core';\nimport { CapacitorBarcodeScannerWeb } from './web';\nexport * from './definitions';\nconst CapacitorBarcodeScanner = registerPlugin('CapacitorBarcodeScanner', {\n web: () => new CapacitorBarcodeScannerWeb(),\n});\nexport { CapacitorBarcodeScanner };\n"],"names":["WebPlugin","CapacitorBarcodeScannerTypeHint","CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin"],"mappings":"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"}
@@ -0,0 +1,25 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapacitorZxingScanner",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "CapacitorZxingScanner",
10
+ targets: ["CapacitorZxingScanner"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "6.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "CapacitorZxingScanner",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "Sources/CapacitorZxingScanner"
23
+ )
24
+ ]
25
+ )
@@ -0,0 +1,106 @@
1
+ import UIKit
2
+ import AVFoundation
3
+
4
+ final class ScannerViewController: UIViewController {
5
+
6
+ var completion: ((String?) -> Void)?
7
+
8
+ private var captureSession: AVCaptureSession?
9
+ private var previewLayer: AVCaptureVideoPreviewLayer?
10
+
11
+ override func viewDidLoad() {
12
+ super.viewDidLoad()
13
+ view.backgroundColor = .black
14
+ setupCamera()
15
+ setupCancelButton()
16
+ }
17
+
18
+ override func viewWillAppear(_ animated: Bool) {
19
+ super.viewWillAppear(animated)
20
+ DispatchQueue.global(qos: .userInitiated).async {
21
+ self.captureSession?.startRunning()
22
+ }
23
+ }
24
+
25
+ override func viewWillDisappear(_ animated: Bool) {
26
+ super.viewWillDisappear(animated)
27
+ captureSession?.stopRunning()
28
+ }
29
+
30
+ override func viewDidLayoutSubviews() {
31
+ super.viewDidLayoutSubviews()
32
+ previewLayer?.frame = view.layer.bounds
33
+ }
34
+
35
+ private func setupCamera() {
36
+ let session = AVCaptureSession()
37
+ session.sessionPreset = .high
38
+
39
+ guard
40
+ let device = AVCaptureDevice.default(for: .video),
41
+ let input = try? AVCaptureDeviceInput(device: device)
42
+ else {
43
+ DispatchQueue.main.async { self.completion?(nil) }
44
+ return
45
+ }
46
+
47
+ let metadataOutput = AVCaptureMetadataOutput()
48
+
49
+ guard session.canAddInput(input), session.canAddOutput(metadataOutput) else {
50
+ DispatchQueue.main.async { self.completion?(nil) }
51
+ return
52
+ }
53
+
54
+ session.addInput(input)
55
+ session.addOutput(metadataOutput)
56
+ metadataOutput.setMetadataObjectsDelegate(self, queue: .main)
57
+ metadataOutput.metadataObjectTypes = [.qr]
58
+
59
+ let preview = AVCaptureVideoPreviewLayer(session: session)
60
+ preview.videoGravity = .resizeAspectFill
61
+ preview.frame = view.layer.bounds
62
+ view.layer.addSublayer(preview)
63
+
64
+ captureSession = session
65
+ previewLayer = preview
66
+ }
67
+
68
+ private func setupCancelButton() {
69
+ let button = UIButton(type: .system)
70
+ button.setTitle("Cancel", for: .normal)
71
+ button.setTitleColor(.white, for: .normal)
72
+ button.titleLabel?.font = UIFont.systemFont(ofSize: 17, weight: .semibold)
73
+ button.addTarget(self, action: #selector(cancel), for: .touchUpInside)
74
+ button.translatesAutoresizingMaskIntoConstraints = false
75
+ view.addSubview(button)
76
+ NSLayoutConstraint.activate([
77
+ button.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16),
78
+ button.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16)
79
+ ])
80
+ }
81
+
82
+ @objc private func cancel() {
83
+ captureSession?.stopRunning()
84
+ dismiss(animated: true) { [weak self] in
85
+ self?.completion?(nil)
86
+ }
87
+ }
88
+ }
89
+
90
+ extension ScannerViewController: AVCaptureMetadataOutputObjectsDelegate {
91
+ func metadataOutput(
92
+ _ output: AVCaptureMetadataOutput,
93
+ didOutput metadataObjects: [AVMetadataObject],
94
+ from connection: AVCaptureConnection
95
+ ) {
96
+ guard
97
+ let object = metadataObjects.first as? AVMetadataMachineReadableCodeObject,
98
+ let text = object.stringValue
99
+ else { return }
100
+
101
+ captureSession?.stopRunning()
102
+ dismiss(animated: true) { [weak self] in
103
+ self?.completion?(text)
104
+ }
105
+ }
106
+ }
@@ -0,0 +1,39 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import AVFoundation
4
+
5
+ @objc(CapacitorBarcodeScannerPlugin)
6
+ public class ZxingScannerPlugin: CAPPlugin, CAPBridgedPlugin {
7
+ public let identifier = "CapacitorBarcodeScannerPlugin"
8
+ public let jsName = "CapacitorBarcodeScanner"
9
+ public let pluginMethods: [CAPPluginMethod] = [
10
+ CAPPluginMethod(name: "scanBarcode", returnType: CAPPluginReturnPromise)
11
+ ]
12
+
13
+ @objc func scanBarcode(_ call: CAPPluginCall) {
14
+ AVCaptureDevice.requestAccess(for: .video) { [weak self] granted in
15
+ guard let self = self else { return }
16
+ guard granted else {
17
+ call.reject("Camera permission denied")
18
+ return
19
+ }
20
+ DispatchQueue.main.async {
21
+ self.presentScanner(call)
22
+ }
23
+ }
24
+ }
25
+
26
+ private func presentScanner(_ call: CAPPluginCall) {
27
+ let scanner = ScannerViewController()
28
+ scanner.modalPresentationStyle = .fullScreen
29
+ scanner.completion = { [weak self] result in
30
+ guard let self = self else { return }
31
+ if let text = result {
32
+ call.resolve(["ScanResult": text, "format": "QR_CODE"])
33
+ } else {
34
+ call.reject("Scanner cancelled")
35
+ }
36
+ }
37
+ bridge?.viewController?.present(scanner, animated: true)
38
+ }
39
+ }
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@real-life-org/capacitor-zxing-scanner",
3
+ "version": "1.0.0",
4
+ "description": "Capacitor barcode scanner plugin using ZXing (Android) and AVFoundation (iOS) — F-Droid compatible",
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/AndroidManifest.xml",
13
+ "dist/",
14
+ "ios/Sources/",
15
+ "ios/Package.swift",
16
+ "CapacitorZxingScanner.podspec",
17
+ "package.json"
18
+ ],
19
+ "author": "real-life-org",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/real-life-org/capacitor-zxing-scanner"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/real-life-org/capacitor-zxing-scanner/issues"
27
+ },
28
+ "keywords": [
29
+ "capacitor",
30
+ "plugin",
31
+ "barcode",
32
+ "qr-code",
33
+ "zxing",
34
+ "scanner",
35
+ "fdroid",
36
+ "libre"
37
+ ],
38
+ "scripts": {
39
+ "build": "npm run clean && mkdir -p dist && tsc && rollup -c rollup.config.js",
40
+ "clean": "rimraf ./dist",
41
+ "docgen": "docgen --api CapacitorBarcodeScannerPlugin --output-json dist/docs.json",
42
+ "lint": "eslint . --ext ts",
43
+ "fmt": "prettier --write --parser typescript 'src/**/*.ts'",
44
+ "prepublishOnly": "npm run build"
45
+ },
46
+ "devDependencies": {
47
+ "@capacitor/android": "^8.0.0",
48
+ "@capacitor/core": "^8.3.0",
49
+ "@capacitor/docgen": "^0.2.2",
50
+ "@capacitor/ios": "^8.0.0",
51
+ "prettier": "^3.0.0",
52
+ "rimraf": "^5.0.10",
53
+ "rollup": "^3.30.0",
54
+ "typescript": "^5.9.3"
55
+ },
56
+ "peerDependencies": {
57
+ "@capacitor/core": ">=4.0.0"
58
+ },
59
+ "capacitor": {
60
+ "ios": {
61
+ "src": "ios"
62
+ },
63
+ "android": {
64
+ "src": "android"
65
+ }
66
+ }
67
+ }