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.
- package/LeapCapacitor.podspec +1 -1
- package/README.md +35 -52
- package/android/build.gradle +3 -3
- package/android/src/main/java/is/leap/capacitor/LeapPlugin.java +44 -0
- package/dist/docs.json +50 -841
- package/dist/esm/definitions.d.ts +8 -1
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/LeapPlugin.m +1 -0
- package/ios/Plugin/LeapPlugin.swift +34 -0
- package/package.json +24 -19
package/LeapCapacitor.podspec
CHANGED
package/README.md
CHANGED
|
@@ -23,8 +23,10 @@ npx cap sync
|
|
|
23
23
|
* [`disable()`](#disable)
|
|
24
24
|
* [`logout()`](#logout)
|
|
25
25
|
* [`setAppLocale(...)`](#setapplocale)
|
|
26
|
+
* [`registerExceptionCallback(...)`](#registerexceptioncallback)
|
|
26
27
|
* [`addListener('leapCallbacks', ...)`](#addlistenerleapcallbacks)
|
|
27
28
|
* [`addListener('leapElementActionCallbacks', ...)`](#addlistenerleapelementactioncallbacks)
|
|
29
|
+
* [`addListener('leapExceptionCallbacks', ...)`](#addlistenerleapexceptioncallbacks)
|
|
28
30
|
* [Interfaces](#interfaces)
|
|
29
31
|
|
|
30
32
|
</docgen-index>
|
|
@@ -113,7 +115,7 @@ embedProject(options: { projectId: string; }) => Promise<void>
|
|
|
113
115
|
### offlineSync(...)
|
|
114
116
|
|
|
115
117
|
```typescript
|
|
116
|
-
offlineSync(options: { projectIds:
|
|
118
|
+
offlineSync(options: { projectIds: string[]; }) => Promise<void>
|
|
117
119
|
```
|
|
118
120
|
|
|
119
121
|
| Param | Type |
|
|
@@ -154,6 +156,19 @@ setAppLocale(options: { localeCode: string; }) => Promise<void>
|
|
|
154
156
|
--------------------
|
|
155
157
|
|
|
156
158
|
|
|
159
|
+
### registerExceptionCallback(...)
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
registerExceptionCallback(options: { callbackLevels: string[]; }) => Promise<void>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
| Param | Type |
|
|
166
|
+
| ------------- | ------------------------------------------ |
|
|
167
|
+
| **`options`** | <code>{ callbackLevels: string[]; }</code> |
|
|
168
|
+
|
|
169
|
+
--------------------
|
|
170
|
+
|
|
171
|
+
|
|
157
172
|
### addListener('leapCallbacks', ...)
|
|
158
173
|
|
|
159
174
|
```typescript
|
|
@@ -186,61 +201,26 @@ addListener(eventName: 'leapElementActionCallbacks', listenerFunc: (event: LeapE
|
|
|
186
201
|
--------------------
|
|
187
202
|
|
|
188
203
|
|
|
189
|
-
###
|
|
204
|
+
### addListener('leapExceptionCallbacks', ...)
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
addListener(eventName: 'leapExceptionCallbacks', listenerFunc: (event: LeapExceptionCallbacks) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
208
|
+
```
|
|
190
209
|
|
|
210
|
+
| Param | Type |
|
|
211
|
+
| ------------------ | --------------------------------------------------------------------------------------------- |
|
|
212
|
+
| **`eventName`** | <code>'leapExceptionCallbacks'</code> |
|
|
213
|
+
| **`listenerFunc`** | <code>(event: <a href="#leapexceptioncallbacks">LeapExceptionCallbacks</a>) => void</code> |
|
|
191
214
|
|
|
192
|
-
|
|
215
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
216
|
+
|
|
217
|
+
--------------------
|
|
193
218
|
|
|
194
219
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
| **`length`** | <code>number</code> | Gets or sets the length of the array. This is a number one higher than the highest index in the array. |
|
|
200
|
-
|
|
201
|
-
| Method | Signature | Description |
|
|
202
|
-
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
203
|
-
| **toString** | () => string | Returns a string representation of an array. |
|
|
204
|
-
| **toLocaleString** | () => string | Returns a string representation of an array. The elements are converted to string using their toLocalString methods. |
|
|
205
|
-
| **pop** | () => T \| undefined | Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified. |
|
|
206
|
-
| **push** | (...items: T[]) => number | Appends new elements to the end of an array, and returns the new length of the array. |
|
|
207
|
-
| **concat** | (...items: <a href="#concatarray">ConcatArray</a><T>[]) => T[] | Combines two or more arrays. This method returns a new array without modifying any existing arrays. |
|
|
208
|
-
| **concat** | (...items: (T \| <a href="#concatarray">ConcatArray</a><T>)[]) => T[] | Combines two or more arrays. This method returns a new array without modifying any existing arrays. |
|
|
209
|
-
| **join** | (separator?: string \| undefined) => string | Adds all the elements of an array into a string, separated by the specified separator string. |
|
|
210
|
-
| **reverse** | () => T[] | Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array. |
|
|
211
|
-
| **shift** | () => T \| undefined | Removes the first element from an array and returns it. If the array is empty, undefined is returned and the array is not modified. |
|
|
212
|
-
| **slice** | (start?: number \| undefined, end?: number \| undefined) => T[] | Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. |
|
|
213
|
-
| **sort** | (compareFn?: ((a: T, b: T) => number) \| undefined) => this | Sorts an array in place. This method mutates the array and returns a reference to the same array. |
|
|
214
|
-
| **splice** | (start: number, deleteCount?: number \| undefined) => T[] | Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. |
|
|
215
|
-
| **splice** | (start: number, deleteCount: number, ...items: T[]) => T[] | Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. |
|
|
216
|
-
| **unshift** | (...items: T[]) => number | Inserts new elements at the start of an array, and returns the new length of the array. |
|
|
217
|
-
| **indexOf** | (searchElement: T, fromIndex?: number \| undefined) => number | Returns the index of the first occurrence of a value in an array, or -1 if it is not present. |
|
|
218
|
-
| **lastIndexOf** | (searchElement: T, fromIndex?: number \| undefined) => number | Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present. |
|
|
219
|
-
| **every** | <S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any) => this is S[] | Determines whether all the members of an array satisfy the specified test. |
|
|
220
|
-
| **every** | (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any) => boolean | Determines whether all the members of an array satisfy the specified test. |
|
|
221
|
-
| **some** | (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any) => boolean | Determines whether the specified callback function returns true for any element of an array. |
|
|
222
|
-
| **forEach** | (callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any) => void | Performs the specified action for each element in an array. |
|
|
223
|
-
| **map** | <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[] | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
|
|
224
|
-
| **filter** | <S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any) => S[] | Returns the elements of an array that meet the condition specified in a callback function. |
|
|
225
|
-
| **filter** | (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any) => T[] | Returns the elements of an array that meet the condition specified in a callback function. |
|
|
226
|
-
| **reduce** | (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T) => T | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
227
|
-
| **reduce** | (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T) => T | |
|
|
228
|
-
| **reduce** | <U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U) => U | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
229
|
-
| **reduceRight** | (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T) => T | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
230
|
-
| **reduceRight** | (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T) => T | |
|
|
231
|
-
| **reduceRight** | <U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U) => U | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
#### ConcatArray
|
|
235
|
-
|
|
236
|
-
| Prop | Type |
|
|
237
|
-
| ------------ | ------------------- |
|
|
238
|
-
| **`length`** | <code>number</code> |
|
|
239
|
-
|
|
240
|
-
| Method | Signature |
|
|
241
|
-
| --------- | ------------------------------------------------------------------ |
|
|
242
|
-
| **join** | (separator?: string \| undefined) => string |
|
|
243
|
-
| **slice** | (start?: number \| undefined, end?: number \| undefined) => T[] |
|
|
220
|
+
### Interfaces
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
#### UserProperty
|
|
244
224
|
|
|
245
225
|
|
|
246
226
|
#### PluginListenerHandle
|
|
@@ -255,4 +235,7 @@ addListener(eventName: 'leapElementActionCallbacks', listenerFunc: (event: LeapE
|
|
|
255
235
|
|
|
256
236
|
#### LeapElementActionCallbacks
|
|
257
237
|
|
|
238
|
+
|
|
239
|
+
#### LeapExceptionCallbacks
|
|
240
|
+
|
|
258
241
|
</docgen-api>
|
package/android/build.gradle
CHANGED
|
@@ -37,8 +37,8 @@ android {
|
|
|
37
37
|
abortOnError false
|
|
38
38
|
}
|
|
39
39
|
compileOptions {
|
|
40
|
-
sourceCompatibility JavaVersion.
|
|
41
|
-
targetCompatibility JavaVersion.
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -51,7 +51,7 @@ repositories {
|
|
|
51
51
|
dependencies {
|
|
52
52
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
53
|
implementation project(':capacitor-android')
|
|
54
|
-
implementation 'is.leap.android:sdk:2.
|
|
54
|
+
implementation 'is.leap.android:sdk:2.2.4'
|
|
55
55
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
56
|
testImplementation "junit:junit:$junitVersion"
|
|
57
57
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
@@ -10,6 +10,7 @@ import com.getcapacitor.PluginMethod;
|
|
|
10
10
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
11
11
|
import com.getcapacitor.annotation.Permission;
|
|
12
12
|
|
|
13
|
+
import org.json.JSONArray;
|
|
13
14
|
import org.json.JSONException;
|
|
14
15
|
import org.json.JSONObject;
|
|
15
16
|
|
|
@@ -24,6 +25,7 @@ import java.util.Map;
|
|
|
24
25
|
import java.util.TimeZone;
|
|
25
26
|
|
|
26
27
|
import is.leap.android.LeapEventCallbacks;
|
|
28
|
+
import is.leap.android.LeapExceptionCallbackLevel;
|
|
27
29
|
import is.leap.android.aui.Leap;
|
|
28
30
|
import is.leap.android.core.LeapElementActionCallbacks;
|
|
29
31
|
|
|
@@ -50,7 +52,9 @@ public class LeapPlugin extends Plugin {
|
|
|
50
52
|
public static final String UNIQUE_USER_ID = "uniqueUserId";
|
|
51
53
|
public static final String PROJECT_ID = "projectId";
|
|
52
54
|
public static final String RESET_PROJECT = "resetProject";
|
|
55
|
+
public static final String CALLBACK_LEVELS = "callbackLevels";
|
|
53
56
|
public static final String LEAP_CALLBACKS = "leapCallbacks";
|
|
57
|
+
public static final String LEAP_EXCEPTION_CALLBACKS = "leapExceptionCallbacks";
|
|
54
58
|
public static final String LEAP_ELEMENT_ACTION_CALLBACKS = "leapElementActionCallbacks";
|
|
55
59
|
public static final String PLUGIN_NAME = "LeapPlugin";
|
|
56
60
|
public static final String INTERNET_PERMISSION_ALIAS = "Internet";
|
|
@@ -182,6 +186,34 @@ public class LeapPlugin extends Plugin {
|
|
|
182
186
|
call.resolve();
|
|
183
187
|
}
|
|
184
188
|
|
|
189
|
+
@PluginMethod
|
|
190
|
+
public void registerExceptionCallback(PluginCall call) {
|
|
191
|
+
JSONArray levelsArray = call.getArray(CALLBACK_LEVELS);
|
|
192
|
+
if (levelsArray == null) {
|
|
193
|
+
call.reject("Levels are required");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Convert JSON array to enum list
|
|
198
|
+
LeapExceptionCallbackLevel[] enumLevels = toExceptionCallbackLevelArray(levelsArray);
|
|
199
|
+
|
|
200
|
+
// Register callback with Leap SDK
|
|
201
|
+
Leap.registerExceptionCallback(enumLevels, exception -> {
|
|
202
|
+
if (exception == null) return;
|
|
203
|
+
|
|
204
|
+
JSObject jsObject = null;
|
|
205
|
+
try {
|
|
206
|
+
JSONObject exceptionJson = new JSONObject(exception);
|
|
207
|
+
jsObject = new JSObject(exceptionJson.toString());
|
|
208
|
+
} catch (JSONException ignored) {
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
if(jsObject == null) return;
|
|
212
|
+
notifyListeners(LEAP_EXCEPTION_CALLBACKS, jsObject);
|
|
213
|
+
});
|
|
214
|
+
call.resolve();
|
|
215
|
+
}
|
|
216
|
+
|
|
185
217
|
public static Date getDate(String dateValue) {
|
|
186
218
|
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_SDF, Locale.ENGLISH);
|
|
187
219
|
sdf.setTimeZone(TimeZone.getTimeZone(TIMEZONE_GMT));
|
|
@@ -222,4 +254,16 @@ public class LeapPlugin extends Plugin {
|
|
|
222
254
|
Leap.addLeapElementActionCallbacks(eventActionListener);
|
|
223
255
|
}
|
|
224
256
|
|
|
257
|
+
private LeapExceptionCallbackLevel[] toExceptionCallbackLevelArray(JSONArray array) {
|
|
258
|
+
LeapExceptionCallbackLevel[] result = new LeapExceptionCallbackLevel[array.length()];
|
|
259
|
+
for (int i = 0; i < array.length(); i++) {
|
|
260
|
+
try {
|
|
261
|
+
String name = array.getString(i);
|
|
262
|
+
result[i] = LeapExceptionCallbackLevel.valueOf(name);
|
|
263
|
+
} catch (Exception ignore) {
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
|
|
225
269
|
}
|