@capacitor/barcode-scanner 1.0.0-alpha.1

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,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
@@ -0,0 +1,19 @@
1
+ import OSBarcodeLib
2
+
3
+ protocol OSBARCArgumentMappable {
4
+ static func map(value: Int) -> Self
5
+ }
6
+
7
+ extension OSBARCCameraModel: OSBARCArgumentMappable {
8
+ static func map(value: Int) -> OSBARCCameraModel { value == 1 ? .back : .front }
9
+ }
10
+
11
+ extension OSBARCOrientationModel: OSBARCArgumentMappable {
12
+ static func map(value: Int) -> OSBARCOrientationModel {
13
+ switch value {
14
+ case 1: return .portrait
15
+ case 2: return .landscape
16
+ default: return .adaptive
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,30 @@
1
+ import Foundation
2
+
3
+ private struct OSBarcodeErrorLabels {
4
+ static let code = "code"
5
+ static let codeFormat = "OS-PLUG-BARC-"
6
+ static let message = "message"
7
+ }
8
+
9
+ enum OSBarcodeError: Int, CustomNSError, LocalizedError {
10
+ case scanningError = 4
11
+ case scanningCancelled = 6
12
+ case cameraAccessDenied = 7
13
+ case scanInputArgumentsIssue = 8
14
+
15
+ var errorDescription: String? {
16
+ switch self {
17
+ case .scanningError: return "Error while trying to scan code."
18
+ case .scanningCancelled: return "Couldn’t scan because the process was cancelled."
19
+ case .cameraAccessDenied: return "Couldn’t scan because camera access wasn’t provided. Check your camera permissions and try again."
20
+ case .scanInputArgumentsIssue: return "Scanning parameters are invalid."
21
+ }
22
+ }
23
+
24
+ var errorDictionary: [String: String] {
25
+ [
26
+ OSBarcodeErrorLabels.code: "\(OSBarcodeErrorLabels.codeFormat)\(String(format: "%04d", self.rawValue))",
27
+ OSBarcodeErrorLabels.message: self.errorDescription ?? ""
28
+ ]
29
+ }
30
+ }
@@ -0,0 +1,44 @@
1
+ import Foundation
2
+ import OSBarcodeLib
3
+
4
+ struct OSBarcodeScanArgumentsModel: Decodable {
5
+ let scanInstructions: String
6
+ let scanButtonText: String?
7
+ let cameraDirection: OSBARCCameraModel
8
+ let scanOrientation: OSBARCOrientationModel
9
+
10
+ enum CodingKeys: CodingKey {
11
+ case scanButton
12
+ case scanInstructions
13
+ case scanText
14
+ case cameraDirection
15
+ case scanOrientation
16
+ }
17
+
18
+ init(from decoder: Decoder) throws {
19
+ let container = try decoder.container(keyedBy: CodingKeys.self)
20
+
21
+ let scanInstructions = try container.decode(String.self, forKey: .scanInstructions)
22
+
23
+ var scanButtonText: String? // property is set based on `scanButton` and `scanText`.
24
+ let scanButton = try container.decode(Bool.self, forKey: .scanButton)
25
+ if scanButton { // only set `scanButtonText` if `scanButton` is enabled
26
+ scanButtonText = try container.decode(String.self, forKey: .scanText)
27
+ }
28
+
29
+ let cameraDirectionInt = try container.decode(Int.self, forKey: .cameraDirection)
30
+ let cameraDirection = OSBARCCameraModel.map(value: cameraDirectionInt)
31
+
32
+ let scanOrientationInt = try container.decode(Int.self, forKey: .scanOrientation)
33
+ let scanOrientation = OSBARCOrientationModel.map(value: scanOrientationInt)
34
+
35
+ self.init(scanInstructions, scanButtonText, cameraDirection, scanOrientation)
36
+ }
37
+
38
+ private init(_ scanInstructions: String, _ scanButtonText: String?, _ cameraDirection: OSBARCCameraModel, _ scanOrientation: OSBARCOrientationModel) {
39
+ self.scanInstructions = scanInstructions
40
+ self.scanButtonText = scanButtonText
41
+ self.cameraDirection = cameraDirection
42
+ self.scanOrientation = scanOrientation
43
+ }
44
+ }
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@capacitor/barcode-scanner",
3
+ "version": "1.0.0-alpha.1",
4
+ "description": "Capacitor plugin using Outsystems Barcode libs",
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
+ "dist/",
13
+ "ios/Plugin/",
14
+ "CapacitorBarcodeScanner.podspec",
15
+ "scripts/"
16
+ ],
17
+ "author": "OutSystems",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+github.com/ionic-team/capacitor-barcode-scanner.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/ionic-team/capacitor-barcode-scanner/issues"
25
+ },
26
+ "keywords": [
27
+ "capacitor",
28
+ "plugin",
29
+ "native"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
36
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
37
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
38
+ "verify:web": "npm run build",
39
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
40
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
41
+ "eslint": "eslint . --ext ts",
42
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
43
+ "swiftlint": "node-swiftlint",
44
+ "docgen": "docgen --api CapacitorBarcodeScannerPlugin --output-readme README.md --output-json dist/docs.json",
45
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
46
+ "clean": "rimraf ./dist",
47
+ "watch": "tsc --watch",
48
+ "prepublishOnly": "npm run build"
49
+ },
50
+ "dependencies": {
51
+ "html5-qrcode": "2.3.8"
52
+ },
53
+ "devDependencies": {
54
+ "@capacitor/android": "^6.0.0",
55
+ "@capacitor/core": "^6.0.0",
56
+ "@capacitor/docgen": "^0.2.2",
57
+ "@capacitor/ios": "^6.0.0",
58
+ "@ionic/swiftlint-config": "^1.1.2",
59
+ "@types/node": "~20.12.4",
60
+ "@typescript-eslint/eslint-plugin": "^5.59.2",
61
+ "@typescript-eslint/parser": "^5.59.2",
62
+ "eslint": "^8.57.0",
63
+ "eslint-config-prettier": "^8.8.0",
64
+ "prettier": "^2.8.8",
65
+ "prettier-plugin-java": "~2.1.0",
66
+ "rimraf": "^3.0.2",
67
+ "rollup": "^2.78.1",
68
+ "swiftlint": "^1.0.2",
69
+ "typescript": "^5.4.2"
70
+ },
71
+ "peerDependencies": {
72
+ "@capacitor/core": "^6.0.0"
73
+ },
74
+ "swiftlint": "@ionic/swiftlint-config",
75
+ "capacitor": {
76
+ "ios": {
77
+ "src": "ios"
78
+ },
79
+ "android": {
80
+ "src": "android"
81
+ }
82
+ },
83
+ "gitHead": "fa274b7425edaf7c252c91cdeee0fea6ff1885e1"
84
+ }