leap-capacitor 2.0.19 → 2.2.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.
@@ -8,6 +8,9 @@ export interface LeapCallbacks {
8
8
  export interface LeapElementActionCallbacks {
9
9
  [key: string]: any;
10
10
  }
11
+ export interface LeapExceptionCallbacks {
12
+ [key: string]: any;
13
+ }
11
14
  export interface LeapPluginInterface {
12
15
  start(options: {
13
16
  apiKey: string;
@@ -30,13 +33,17 @@ export interface LeapPluginInterface {
30
33
  projectId: string;
31
34
  }): Promise<void>;
32
35
  offlineSync(options: {
33
- projectIds: Array<string>;
36
+ projectIds: string[];
34
37
  }): Promise<void>;
35
38
  disable(): Promise<void>;
36
39
  logout(): Promise<void>;
37
40
  setAppLocale(options: {
38
41
  localeCode: string;
39
42
  }): Promise<void>;
43
+ registerExceptionCallback(options: {
44
+ callbackLevels: string[];
45
+ }): Promise<void>;
40
46
  addListener(eventName: 'leapCallbacks', listenerFunc: (event: LeapCallbacks) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
41
47
  addListener(eventName: 'leapElementActionCallbacks', listenerFunc: (event: LeapElementActionCallbacks) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
48
+ addListener(eventName: 'leapExceptionCallbacks', listenerFunc: (event: LeapExceptionCallbacks) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
42
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["\nimport type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface UserProperty {\n [key: string]: string | number\n}\n\nexport interface LeapCallbacks {\n [key: string]: string\n}\n\nexport interface LeapElementActionCallbacks {\n [key: string]: any\n}\n\nexport interface LeapPluginInterface {\n start(options: { apiKey: string }): Promise<void>;\n startWithSelfHostingEnabled(options:{apiKey: string,baseUrl: string}):Promise<void>;\n flushProperties(options: { properties: UserProperty }): Promise<void>;\n setUniqueUserId(options: { uniqueUserId: string }): Promise<void>;\n startProject(options: { projectId: string, resetProject?: boolean }): Promise<void>;\n embedProject(options: { projectId: string }): Promise<void>;\n offlineSync(options: { projectIds: Array<string> }): Promise<void>;\n disable(): Promise<void>;\n logout(): Promise<void>;\n setAppLocale(options: {localeCode: string}): Promise<void>;\n\n addListener(\n eventName: 'leapCallbacks',\n listenerFunc: (event: LeapCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n addListener(\n eventName: 'leapElementActionCallbacks',\n listenerFunc: (event: LeapElementActionCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["\nimport type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface UserProperty {\n [key: string]: string | number\n}\n\nexport interface LeapCallbacks {\n [key: string]: string\n}\n\nexport interface LeapElementActionCallbacks {\n [key: string]: any\n}\n\nexport interface LeapExceptionCallbacks {\n [key: string]: any\n}\n\nexport interface LeapPluginInterface {\n start(options: { apiKey: string }): Promise<void>;\n startWithSelfHostingEnabled(options:{apiKey: string,baseUrl: string}):Promise<void>;\n flushProperties(options: { properties: UserProperty }): Promise<void>;\n setUniqueUserId(options: { uniqueUserId: string }): Promise<void>;\n startProject(options: { projectId: string, resetProject?: boolean }): Promise<void>;\n embedProject(options: { projectId: string }): Promise<void>;\n offlineSync(options: { projectIds: string[] }): Promise<void>;\n disable(): Promise<void>;\n logout(): Promise<void>;\n setAppLocale(options: {localeCode: string}): Promise<void>;\n registerExceptionCallback(options:{ callbackLevels: string[]}):Promise<void>;\n\n addListener(\n eventName: 'leapCallbacks',\n listenerFunc: (event: LeapCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n addListener(\n eventName: 'leapElementActionCallbacks',\n listenerFunc: (event: LeapElementActionCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n addListener(\n eventName: 'leapExceptionCallbacks',\n listenerFunc: (event: LeapExceptionCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n // addListener(\n // eventName: 'leapExceptionCallbacks',\n // listenerFunc: (event: LeapExceptionCallbacks) => void,\n // ): Promise<PluginListenerHandle> & PluginListenerHandle\n}\n"]}
@@ -14,4 +14,5 @@ CAP_PLUGIN(LeapPlugin, "LeapPlugin",
14
14
  CAP_PLUGIN_METHOD(offlineSync, CAPPluginReturnPromise);
15
15
  CAP_PLUGIN_METHOD(disable, CAPPluginReturnPromise);
16
16
  CAP_PLUGIN_METHOD(logout, CAPPluginReturnPromise);
17
+ CAP_PLUGIN_METHOD(registerExceptionCallback, CAPPluginReturnPromise);
17
18
  )
@@ -13,7 +13,9 @@ let RESET_PROJECT = "resetProject"
13
13
  let PROJECT_IDS = "projectIds"
14
14
  let DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
15
15
  let DATE_LOCALE = "en_US_POSIX"
16
+ let CALLBACKLEVELS = "callbackLevels"
16
17
  let LEAP_CALLBACKS = "leapCallbacks"
18
+ let LEAP_EXCEPTION_CALLBACKS = "leapExceptionCallbacks"
17
19
 
18
20
  /**
19
21
  * Please read the Capacitor iOS Plugin Development Guide
@@ -23,6 +25,8 @@ let LEAP_CALLBACKS = "leapCallbacks"
23
25
 
24
26
  public class LeapPlugin: CAPPlugin {
25
27
 
28
+ var exceptionCall:CAPPluginCall?
29
+
26
30
  @objc public func start(_ call: CAPPluginCall) {
27
31
  let apiKey = call.getString(API_KEY) ?? ""
28
32
  DispatchQueue.main.async {
@@ -106,6 +110,28 @@ public class LeapPlugin: CAPPlugin {
106
110
  }
107
111
  call.resolve()
108
112
  }
113
+
114
+ @objc public func registerExceptionCallback(_ call: CAPPluginCall) {
115
+ let callbackLevelStrings:[String] = call.getArray(CALLBACKLEVELS) as? [String] ?? []
116
+ let callbackLevels:[LeapExceptionCallBackTypes] = callbackLevelStrings.compactMap { callbackLevelString in
117
+ switch callbackLevelString{
118
+ case "MEMORY":
119
+ return .MEMORY
120
+ case "AUI":
121
+ return .AUI
122
+ case "JS":
123
+ return .JS
124
+ case "CRASH":
125
+ return .CRASH
126
+ case "PUBLIC_METHOD":
127
+ return .PUBLIC_METHOD
128
+ default:
129
+ return nil
130
+ }
131
+ }
132
+ Leap.shared.registerExceptionCallback(self, callbackLevels: callbackLevels.count == 0 ? nil : callbackLevels)
133
+ call.resolve()
134
+ }
109
135
 
110
136
  func addProperties(properties:[String:AnyHashable]) {
111
137
  properties.forEach { key, value in
@@ -142,3 +168,11 @@ extension LeapPlugin: LeapCallback {
142
168
  }
143
169
  }
144
170
  }
171
+
172
+ extension LeapPlugin: LeapExceptionCallBack {
173
+ public func exceptionCallbackEvent(eventInfo: [String: Any], exceptionType: LeapSDK.LeapExceptionCallBackTypes) {
174
+ DispatchQueue.main.async { [weak self] in
175
+ self?.notifyListeners(LEAP_EXCEPTION_CALLBACKS, data: eventInfo)
176
+ }
177
+ }
178
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leap-capacitor",
3
- "version": "2.0.19",
3
+ "version": "2.2.1",
4
4
  "description": "Plugin for Leap",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -34,39 +34,38 @@
34
34
  "verify:web": "npm run build",
35
35
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
36
36
  "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
37
- "eslint": "eslint . --ext ts",
38
- "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
37
+ "eslint": "eslint .",
38
+ "prettier": "prettier --check \"**/*.{css,html,ts,js,java}\"",
39
39
  "swiftlint": "node-swiftlint",
40
40
  "docgen": "docgen --api LeapPluginInterface --output-readme README.md --output-json dist/docs.json",
41
- "build": "yarn && yarn clean && yarn && yarn docgen && tsc && rollup -c rollup.config.js",
42
- "clean": "rimraf ./dist",
41
+ "build": "npm ci && npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
42
+ "clean": "rimraf dist",
43
43
  "watch": "tsc --watch",
44
- "prepublishOnly": "yarn build"
44
+ "prepublishOnly": "npm run build"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@capacitor/android": "^3.0.0",
48
48
  "@capacitor/core": "^3.0.0",
49
49
  "@capacitor/docgen": "^0.0.18",
50
50
  "@capacitor/ios": "^3.0.0",
51
- "@ionic/eslint-config": "^0.3.0",
52
- "@ionic/prettier-config": "^1.0.1",
53
- "@ionic/swiftlint-config": "^1.1.2",
54
- "eslint": "^7.11.0",
55
- "prettier": "~2.2.0",
56
- "prettier-plugin-java": "~1.0.0",
57
- "rimraf": "^3.0.2",
51
+ "@ionic/eslint-config": "^0.4.0",
52
+ "@ionic/prettier-config": "^4.0.0",
53
+ "@ionic/swiftlint-config": "^2.0.0",
54
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
55
+ "@typescript-eslint/parser": "^8.54.0",
56
+ "eslint": "^9.39.2",
57
+ "prettier": "^3.8.1",
58
+ "prettier-plugin-java": "^2.8.1",
59
+ "rimraf": "^5.0.0",
58
60
  "rollup": "^2.32.0",
59
61
  "swiftlint": "^1.0.1",
60
- "typescript": "~4.0.3"
62
+ "typescript": "^5.9.3"
61
63
  },
62
64
  "peerDependencies": {
63
65
  "@capacitor/core": ">=3.0.0"
64
66
  },
65
67
  "prettier": "@ionic/prettier-config",
66
- "swiftlint": "@ionic/swiftlint-config",
67
- "eslintConfig": {
68
- "extends": "@ionic/eslint-config/recommended"
69
- },
68
+ "swiftlint": "@ionic/swiftlint-config",
70
69
  "capacitor": {
71
70
  "ios": {
72
71
  "src": "ios"
@@ -74,5 +73,11 @@
74
73
  "android": {
75
74
  "src": "android"
76
75
  }
76
+ },
77
+ "overrides": {
78
+ "lodash": "^4.17.21",
79
+ "lodash-es": "^4.17.21",
80
+ "glob": "^10.0.0",
81
+ "rimraf": "^5.0.0"
77
82
  }
78
- }
83
+ }