@capawesome/capacitor-wallet 0.0.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.
Files changed (36) hide show
  1. package/CapawesomeCapacitorWallet.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +28 -0
  4. package/README.md +215 -0
  5. package/android/build.gradle +58 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/wallet/Wallet.java +30 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/wallet/WalletPlugin.java +78 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/wallet/classes/CustomException.java +20 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/wallet/classes/CustomExceptions.java +6 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/wallet/classes/options/SaveToGoogleWalletOptions.java +29 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/wallet/interfaces/Callback.java +5 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/wallet/interfaces/EmptyCallback.java +5 -0
  14. package/android/src/main/res/.gitkeep +0 -0
  15. package/dist/docs.json +157 -0
  16. package/dist/esm/definitions.d.ts +96 -0
  17. package/dist/esm/definitions.js +23 -0
  18. package/dist/esm/definitions.js.map +1 -0
  19. package/dist/esm/index.d.ts +4 -0
  20. package/dist/esm/index.js +7 -0
  21. package/dist/esm/index.js.map +1 -0
  22. package/dist/esm/web.d.ts +7 -0
  23. package/dist/esm/web.js +13 -0
  24. package/dist/esm/web.js.map +1 -0
  25. package/dist/plugin.cjs.js +50 -0
  26. package/dist/plugin.cjs.js.map +1 -0
  27. package/dist/plugin.js +53 -0
  28. package/dist/plugin.js.map +1 -0
  29. package/ios/Plugin/Classes/Options/AddPassesOptions.swift +17 -0
  30. package/ios/Plugin/Classes/Results/CanAddPassesResult.swift +16 -0
  31. package/ios/Plugin/Enums/CustomError.swift +34 -0
  32. package/ios/Plugin/Info.plist +24 -0
  33. package/ios/Plugin/Protocols/Result.swift +5 -0
  34. package/ios/Plugin/Wallet.swift +53 -0
  35. package/ios/Plugin/WalletPlugin.swift +80 -0
  36. package/package.json +91 -0
@@ -0,0 +1,80 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ @objc(WalletPlugin)
5
+ public class WalletPlugin: CAPPlugin, CAPBridgedPlugin {
6
+ public let identifier = "WalletPlugin"
7
+ public let jsName = "Wallet"
8
+ public let pluginMethods: [CAPPluginMethod] = [
9
+ CAPPluginMethod(name: "addPasses", returnType: CAPPluginReturnPromise),
10
+ CAPPluginMethod(name: "canAddPasses", returnType: CAPPluginReturnPromise),
11
+ CAPPluginMethod(name: "saveToGoogleWallet", returnType: CAPPluginReturnPromise)
12
+ ]
13
+
14
+ public static let tag = "WalletPlugin"
15
+
16
+ private var implementation: Wallet?
17
+
18
+ override public func load() {
19
+ self.implementation = Wallet(plugin: self)
20
+ }
21
+
22
+ @objc func addPasses(_ call: CAPPluginCall) {
23
+ do {
24
+ let options = try AddPassesOptions(call)
25
+ implementation?.addPasses(options, completion: { error in
26
+ if let error = error {
27
+ if let customError = error as? CustomError, case .unavailable = customError {
28
+ self.rejectCallAsUnavailable(call)
29
+ } else {
30
+ self.rejectCall(call, error)
31
+ }
32
+ return
33
+ }
34
+ self.resolveCall(call)
35
+ })
36
+ } catch {
37
+ self.rejectCall(call, error)
38
+ }
39
+ }
40
+
41
+ @objc func canAddPasses(_ call: CAPPluginCall) {
42
+ implementation?.canAddPasses(completion: { result, error in
43
+ if let error = error {
44
+ self.rejectCall(call, error)
45
+ return
46
+ }
47
+ self.resolveCall(call, result)
48
+ })
49
+ }
50
+
51
+ @objc func saveToGoogleWallet(_ call: CAPPluginCall) {
52
+ rejectCallAsUnimplemented(call)
53
+ }
54
+
55
+ private func rejectCall(_ call: CAPPluginCall, _ error: Error) {
56
+ CAPLog.print("[", WalletPlugin.tag, "] ", error)
57
+ let code = (error as? CustomError)?.code
58
+ call.reject(error.localizedDescription, code)
59
+ }
60
+
61
+ private func rejectCallAsUnavailable(_ call: CAPPluginCall) {
62
+ call.unavailable("Passes cannot be added to Apple Wallet on this device.")
63
+ }
64
+
65
+ private func rejectCallAsUnimplemented(_ call: CAPPluginCall) {
66
+ call.unimplemented("This method is not available on this platform.")
67
+ }
68
+
69
+ private func resolveCall(_ call: CAPPluginCall) {
70
+ call.resolve()
71
+ }
72
+
73
+ private func resolveCall(_ call: CAPPluginCall, _ result: Result?) {
74
+ if let result = result?.toJSObject() as? JSObject {
75
+ call.resolve(result)
76
+ } else {
77
+ call.resolve()
78
+ }
79
+ }
80
+ }
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@capawesome/capacitor-wallet",
3
+ "version": "0.0.1",
4
+ "description": "Capacitor plugin for adding passes to Apple Wallet and Google Wallet.",
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
+ "CapawesomeCapacitorWallet.podspec",
15
+ "Package.swift"
16
+ ],
17
+ "author": "Robin Genz <mail@robingenz.dev>",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/capawesome-team/capacitor-plugins.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/capawesome-team/capacitor-plugins/issues"
25
+ },
26
+ "funding": [
27
+ {
28
+ "type": "github",
29
+ "url": "https://github.com/sponsors/capawesome-team/"
30
+ },
31
+ {
32
+ "type": "opencollective",
33
+ "url": "https://opencollective.com/capawesome"
34
+ }
35
+ ],
36
+ "homepage": "https://capawesome.io/docs/plugins/wallet/",
37
+ "keywords": [
38
+ "capacitor",
39
+ "plugin",
40
+ "native"
41
+ ],
42
+ "scripts": {
43
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
44
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
45
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
46
+ "verify:web": "npm run build",
47
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
48
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
49
+ "eslint": "eslint . --ext ts",
50
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
51
+ "swiftlint": "node-swiftlint",
52
+ "docgen": "docgen --api WalletPlugin --output-readme README.md --output-json dist/docs.json",
53
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
54
+ "clean": "rimraf ./dist",
55
+ "watch": "tsc --watch",
56
+ "ios:pod:install": "cd ios && pod install --repo-update && cd ..",
57
+ "ios:spm:install": "cd ios && swift package resolve && cd ..",
58
+ "prepublishOnly": "npm run build"
59
+ },
60
+ "devDependencies": {
61
+ "@capacitor/android": "8.0.0",
62
+ "@capacitor/cli": "8.0.0",
63
+ "@capacitor/core": "8.0.0",
64
+ "@capacitor/docgen": "0.3.1",
65
+ "@capacitor/ios": "8.0.0",
66
+ "@ionic/eslint-config": "0.4.0",
67
+ "eslint": "8.57.0",
68
+ "prettier-plugin-java": "2.6.7",
69
+ "rimraf": "6.1.2",
70
+ "rollup": "4.53.3",
71
+ "swiftlint": "2.0.0",
72
+ "typescript": "5.9.3"
73
+ },
74
+ "peerDependencies": {
75
+ "@capacitor/core": ">=8.0.0"
76
+ },
77
+ "eslintConfig": {
78
+ "extends": "@ionic/eslint-config/recommended"
79
+ },
80
+ "capacitor": {
81
+ "ios": {
82
+ "src": "ios"
83
+ },
84
+ "android": {
85
+ "src": "android"
86
+ }
87
+ },
88
+ "publishConfig": {
89
+ "access": "public"
90
+ }
91
+ }