com-easystep2-datawedge-plugin-intent-capacitor 4.4.1 → 5.1.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/android/build.gradle +0 -1
- package/android/src/main/AndroidManifest.xml +11 -4
- package/android/src/main/java/com/easystep2/datawedge/plugin/intent/IntentShimPlugin.java +311 -34
- package/com-easystep2-datawedge-plugin-intent-capacitor-5.1.1.tgz +0 -0
- package/esm/web.js +7 -7
- package/esm/web.js.map +1 -1
- package/package.json +1 -1
- package/com-easystep2-datawedge-plugin-intent-capacitor-4.4.1.tgz +0 -0
package/android/build.gradle
CHANGED
|
@@ -48,7 +48,6 @@ repositories {
|
|
|
48
48
|
|
|
49
49
|
dependencies {
|
|
50
50
|
implementation project(':capacitor-android')
|
|
51
|
-
}
|
|
52
51
|
testImplementation "junit:junit:$junitVersion"
|
|
53
52
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
54
53
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
3
|
package="com.easystep2.datawedge.plugin.intent">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
|
|
5
|
+
<application>
|
|
6
|
+
<activity>
|
|
7
|
+
<intent-filter>
|
|
8
|
+
<action android:name="${applicationId}.ACTION" />
|
|
9
|
+
<category android:name="android.intent.category.DEFAULT" />
|
|
10
|
+
</intent-filter>
|
|
11
|
+
</activity>
|
|
12
|
+
</application>
|
|
13
|
+
|
|
14
|
+
</manifest>
|
|
@@ -2,23 +2,29 @@ package com.easystep2.datawedge.plugin.intent;
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
import android.content.BroadcastReceiver;
|
|
5
|
+
import android.content.ComponentName;
|
|
5
6
|
import android.content.Context;
|
|
6
7
|
import android.content.Intent;
|
|
7
8
|
import android.content.IntentFilter;
|
|
8
9
|
import android.content.pm.PackageManager;
|
|
9
10
|
import android.net.Uri;
|
|
11
|
+
import android.os.Build;
|
|
10
12
|
import android.os.Bundle;
|
|
13
|
+
import android.text.Html;
|
|
11
14
|
import android.util.Log;
|
|
12
15
|
|
|
13
16
|
import com.getcapacitor.JSObject;
|
|
14
17
|
import com.getcapacitor.Plugin;
|
|
15
18
|
import com.getcapacitor.PluginCall;
|
|
16
19
|
import com.getcapacitor.PluginMethod;
|
|
20
|
+
import com.getcapacitor.annotation.ActivityCallback;
|
|
17
21
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
18
22
|
|
|
23
|
+
import org.json.JSONArray;
|
|
19
24
|
import org.json.JSONException;
|
|
20
25
|
import org.json.JSONObject;
|
|
21
26
|
|
|
27
|
+
import java.lang.reflect.Array;
|
|
22
28
|
import java.util.ArrayList;
|
|
23
29
|
import java.util.HashMap;
|
|
24
30
|
import java.util.Iterator;
|
|
@@ -26,71 +32,342 @@ import java.util.Map;
|
|
|
26
32
|
|
|
27
33
|
@CapacitorPlugin(name = "IntentShim")
|
|
28
34
|
public class IntentShimPlugin extends Plugin {
|
|
29
|
-
private static final String TAG = "IntentShim";
|
|
30
|
-
private BroadcastReceiver broadcastReceiver = null;
|
|
31
|
-
private boolean debugEnabled = false;
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ret.put("value", value);
|
|
38
|
-
call.resolve(ret);
|
|
39
|
-
}
|
|
36
|
+
private static final String LOG_TAG = "IntentShimPlugin";
|
|
37
|
+
private final Map<BroadcastReceiver, PluginCall> receiverCalls = new HashMap<>();
|
|
38
|
+
private PluginCall onNewIntentCall = null;
|
|
39
|
+
private Intent deferredIntent = null;
|
|
40
40
|
|
|
41
|
-
@
|
|
42
|
-
public void
|
|
43
|
-
|
|
41
|
+
@Override
|
|
42
|
+
public void handleOnNewIntent(Intent intent) {
|
|
43
|
+
super.handleOnNewIntent(intent);
|
|
44
|
+
if (onNewIntentCall != null) {
|
|
45
|
+
fireOnNewIntent(intent);
|
|
46
|
+
} else {
|
|
47
|
+
this.deferredIntent = intent;
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
@PluginMethod
|
|
47
|
-
public void
|
|
48
|
-
|
|
51
|
+
@PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
|
|
52
|
+
public void onIntent(PluginCall call) {
|
|
53
|
+
call.setKeepAlive(true);
|
|
54
|
+
this.onNewIntentCall = call;
|
|
55
|
+
if (this.deferredIntent != null) {
|
|
56
|
+
fireOnNewIntent(this.deferredIntent);
|
|
57
|
+
this.deferredIntent = null;
|
|
58
|
+
}
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
@PluginMethod
|
|
52
62
|
public void sendBroadcast(PluginCall call) {
|
|
53
|
-
|
|
63
|
+
try {
|
|
64
|
+
Intent intent = populateIntent(call.getData());
|
|
65
|
+
getContext().sendBroadcast(intent);
|
|
66
|
+
call.resolve();
|
|
67
|
+
} catch (JSONException e) {
|
|
68
|
+
call.reject("Error creating intent: " + e.getMessage());
|
|
69
|
+
}
|
|
54
70
|
}
|
|
55
71
|
|
|
56
72
|
@PluginMethod
|
|
57
73
|
public void startActivity(PluginCall call) {
|
|
58
|
-
|
|
74
|
+
try {
|
|
75
|
+
Intent intent = populateIntent(call.getData());
|
|
76
|
+
getContext().startActivity(intent);
|
|
77
|
+
call.resolve();
|
|
78
|
+
} catch (JSONException e) {
|
|
79
|
+
call.reject("Error creating intent: " + e.getMessage());
|
|
80
|
+
}
|
|
59
81
|
}
|
|
60
82
|
|
|
61
83
|
@PluginMethod
|
|
62
|
-
public void
|
|
63
|
-
|
|
84
|
+
public void startActivityForResult(PluginCall call) {
|
|
85
|
+
try {
|
|
86
|
+
Intent intent = populateIntent(call.getData());
|
|
87
|
+
int requestCode = call.getInt("requestCode", 1);
|
|
88
|
+
startActivityForResult(call, intent, "activityResult");
|
|
89
|
+
} catch (JSONException e) {
|
|
90
|
+
call.reject("Error creating intent: " + e.getMessage());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@ActivityCallback
|
|
95
|
+
private void activityResult(PluginCall call, ActivityResult result) {
|
|
96
|
+
if (call == null) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
Intent intent = result.getData();
|
|
100
|
+
JSObject intentJson = getIntentJson(intent);
|
|
101
|
+
intentJson.put("requestCode", result.getRequestCode());
|
|
102
|
+
intentJson.put("resultCode", result.getResultCode());
|
|
103
|
+
call.resolve(intentJson);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
|
|
107
|
+
public void registerBroadcastReceiver(PluginCall call) {
|
|
108
|
+
call.setKeepAlive(true);
|
|
109
|
+
|
|
110
|
+
JSObject filters = call.getData();
|
|
111
|
+
JSONArray filterActions = filters.getArray("filterActions");
|
|
112
|
+
|
|
113
|
+
if (filterActions == null || filterActions.length() == 0) {
|
|
114
|
+
call.reject("filterActions argument is required.");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
IntentFilter filter = new IntentFilter();
|
|
119
|
+
try {
|
|
120
|
+
for (int i = 0; i < filterActions.length(); i++) {
|
|
121
|
+
filter.addAction(filterActions.getString(i));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
JSONArray filterCategories = filters.getArray("filterCategories");
|
|
125
|
+
if (filterCategories != null) {
|
|
126
|
+
for (int i = 0; i < filterCategories.length(); i++) {
|
|
127
|
+
filter.addCategory(filterCategories.getString(i));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
JSONArray filterDataSchemes = filters.getArray("filterDataSchemes");
|
|
132
|
+
if (filterDataSchemes != null) {
|
|
133
|
+
for (int i = 0; i < filterDataSchemes.length(); i++) {
|
|
134
|
+
filter.addDataScheme(filterDataSchemes.getString(i));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch (JSONException e) {
|
|
138
|
+
call.reject("Error parsing filters: " + e.getMessage());
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
BroadcastReceiver receiver = new BroadcastReceiver() {
|
|
143
|
+
@Override
|
|
144
|
+
public void onReceive(Context context, Intent intent) {
|
|
145
|
+
PluginCall savedCall = receiverCalls.get(this);
|
|
146
|
+
if (savedCall != null) {
|
|
147
|
+
savedCall.resolve(getIntentJson(intent));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
getContext().registerReceiver(receiver, filter);
|
|
153
|
+
receiverCalls.put(receiver, call);
|
|
64
154
|
}
|
|
65
155
|
|
|
66
156
|
@PluginMethod
|
|
67
|
-
public void
|
|
68
|
-
|
|
157
|
+
public void unregisterBroadcastReceiver(PluginCall call) {
|
|
158
|
+
for (BroadcastReceiver receiver : receiverCalls.keySet()) {
|
|
159
|
+
try {
|
|
160
|
+
getContext().unregisterReceiver(receiver);
|
|
161
|
+
} catch (Exception e) {
|
|
162
|
+
Log.e(LOG_TAG, "Error unregistering broadcast receiver: " + e.getMessage());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
receiverCalls.clear();
|
|
166
|
+
call.resolve();
|
|
69
167
|
}
|
|
70
168
|
|
|
71
169
|
@PluginMethod
|
|
72
|
-
public void
|
|
73
|
-
|
|
170
|
+
public void getIntent(PluginCall call) {
|
|
171
|
+
Intent intent;
|
|
172
|
+
if (this.deferredIntent != null) {
|
|
173
|
+
intent = this.deferredIntent;
|
|
174
|
+
this.deferredIntent = null;
|
|
175
|
+
} else {
|
|
176
|
+
intent = getActivity().getIntent();
|
|
177
|
+
}
|
|
178
|
+
call.resolve(getIntentJson(intent));
|
|
74
179
|
}
|
|
75
180
|
|
|
76
181
|
@PluginMethod
|
|
77
|
-
public void
|
|
78
|
-
|
|
182
|
+
public void sendResult(PluginCall call) {
|
|
183
|
+
Intent result = new Intent();
|
|
184
|
+
JSObject data = call.getData();
|
|
185
|
+
if (data != null && data.has("extras")) {
|
|
186
|
+
try {
|
|
187
|
+
result.putExtras(toBundle(data.getJSObject("extras")));
|
|
188
|
+
} catch (JSONException e) {
|
|
189
|
+
Log.e(LOG_TAG, "Error converting extras to bundle: " + e.getMessage());
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
getActivity().setResult(Activity.RESULT_OK, result);
|
|
193
|
+
getActivity().finish();
|
|
194
|
+
call.resolve();
|
|
79
195
|
}
|
|
80
196
|
|
|
81
197
|
@PluginMethod
|
|
82
198
|
public void packageExists(PluginCall call) {
|
|
83
|
-
|
|
199
|
+
String packageName = call.getString("package");
|
|
200
|
+
if (packageName == null) {
|
|
201
|
+
call.reject("package argument is required");
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
getContext().getPackageManager().getPackageInfo(packageName, 0);
|
|
206
|
+
call.resolve(new JSObject().put("exists", true));
|
|
207
|
+
} catch (PackageManager.NameNotFoundException e) {
|
|
208
|
+
call.resolve(new JSObject().put("exists", false));
|
|
209
|
+
}
|
|
84
210
|
}
|
|
85
211
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
212
|
+
private Intent populateIntent(JSObject obj) throws JSONException {
|
|
213
|
+
Intent intent = new Intent();
|
|
214
|
+
|
|
215
|
+
if (obj.has("action")) {
|
|
216
|
+
intent.setAction(obj.getString("action"));
|
|
217
|
+
}
|
|
218
|
+
if (obj.has("type")) {
|
|
219
|
+
intent.setType(obj.getString("type"));
|
|
220
|
+
}
|
|
221
|
+
if (obj.has("url")) {
|
|
222
|
+
intent.setData(Uri.parse(obj.getString("url")));
|
|
223
|
+
}
|
|
224
|
+
if (obj.has("package")) {
|
|
225
|
+
intent.setPackage(obj.getString("package"));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (obj.has("component")) {
|
|
229
|
+
JSObject component = obj.getJSObject("component");
|
|
230
|
+
String pkg = component.getString("package");
|
|
231
|
+
String cls = component.getString("class");
|
|
232
|
+
if (pkg != null && cls != null) {
|
|
233
|
+
intent.setComponent(new ComponentName(pkg, cls));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (obj.has("flags")) {
|
|
238
|
+
JSONArray flags = obj.getJSONArray("flags");
|
|
239
|
+
for (int i = 0; i < flags.length(); i++) {
|
|
240
|
+
intent.addFlags(flags.getInt(i));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (obj.has("extras")) {
|
|
245
|
+
intent.putExtras(toBundle(obj.getJSObject("extras")));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return intent;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private void fireOnNewIntent(Intent intent) {
|
|
252
|
+
if (this.onNewIntentCall != null) {
|
|
253
|
+
JSObject intentJson = getIntentJson(intent);
|
|
254
|
+
this.onNewIntentCall.resolve(intentJson);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private JSObject getIntentJson(Intent intent) {
|
|
259
|
+
JSObject json = new JSObject();
|
|
260
|
+
if (intent == null) {
|
|
261
|
+
return json;
|
|
262
|
+
}
|
|
263
|
+
try {
|
|
264
|
+
json.put("action", intent.getAction());
|
|
265
|
+
json.put("data", intent.getDataString());
|
|
266
|
+
json.put("type", intent.getType());
|
|
267
|
+
json.put("package", intent.getPackage());
|
|
268
|
+
json.put("extras", toJsonObject(intent.getExtras()));
|
|
269
|
+
if (intent.getComponent() != null) {
|
|
270
|
+
json.put("component", intent.getComponent().flattenToString());
|
|
271
|
+
}
|
|
272
|
+
} catch (Exception e) {
|
|
273
|
+
Log.e(LOG_TAG, "Error converting intent to JSON: " + e.getMessage());
|
|
274
|
+
}
|
|
275
|
+
return json;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private static JSObject toJsonObject(Bundle bundle) {
|
|
279
|
+
JSObject json = new JSObject();
|
|
280
|
+
if (bundle == null) {
|
|
281
|
+
return json;
|
|
282
|
+
}
|
|
283
|
+
for (String key : bundle.keySet()) {
|
|
284
|
+
try {
|
|
285
|
+
json.put(key, toJsonValue(bundle.get(key)));
|
|
286
|
+
} catch (JSONException e) {
|
|
287
|
+
Log.e(LOG_TAG, "Cannot convert bundle to JSON: " + e.getMessage(), e);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return json;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private static Object toJsonValue(final Object value) throws JSONException {
|
|
294
|
+
if (value == null) {
|
|
295
|
+
return JSONObject.NULL;
|
|
296
|
+
} else if (value instanceof Bundle) {
|
|
297
|
+
return toJsonObject((Bundle) value);
|
|
298
|
+
} else if (value.getClass().isArray()) {
|
|
299
|
+
JSONArray result = new JSONArray();
|
|
300
|
+
int length = Array.getLength(value);
|
|
301
|
+
for (int i = 0; i < length; ++i) {
|
|
302
|
+
result.put(toJsonValue(Array.get(value, i)));
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
305
|
+
} else if (value instanceof ArrayList<?>) {
|
|
306
|
+
JSONArray result = new JSONArray();
|
|
307
|
+
for (Object item : (ArrayList<?>) value) {
|
|
308
|
+
result.put(toJsonValue(item));
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
} else if (value instanceof String ||
|
|
312
|
+
value instanceof Boolean ||
|
|
313
|
+
value instanceof Integer ||
|
|
314
|
+
value instanceof Long ||
|
|
315
|
+
value instanceof Double) {
|
|
316
|
+
return value;
|
|
317
|
+
} else {
|
|
318
|
+
return String.valueOf(value);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private Bundle toBundle(JSObject obj) throws JSONException {
|
|
323
|
+
Bundle bundle = new Bundle();
|
|
324
|
+
if (obj == null) {
|
|
325
|
+
return bundle;
|
|
326
|
+
}
|
|
327
|
+
Iterator<String> keys = obj.keys();
|
|
328
|
+
while (keys.hasNext()) {
|
|
329
|
+
String key = keys.next();
|
|
330
|
+
Object value = obj.get(key);
|
|
331
|
+
|
|
332
|
+
if (value instanceof String) {
|
|
333
|
+
bundle.putString(key, (String) value);
|
|
334
|
+
} else if (value instanceof Boolean) {
|
|
335
|
+
bundle.putBoolean(key, (Boolean) value);
|
|
336
|
+
} else if (value instanceof Integer) {
|
|
337
|
+
bundle.putInt(key, (Integer) value);
|
|
338
|
+
} else if (value instanceof Long) {
|
|
339
|
+
bundle.putLong(key, (Long) value);
|
|
340
|
+
} else if (value instanceof Double) {
|
|
341
|
+
bundle.putDouble(key, (Double) value);
|
|
342
|
+
} else if (value instanceof JSObject) {
|
|
343
|
+
bundle.putBundle(key, toBundle((JSObject) value));
|
|
344
|
+
} else if (value instanceof JSONArray) {
|
|
345
|
+
// This part is complex; simplified for common cases
|
|
346
|
+
// For DataWedge, string arrays or parcelable arrays are common
|
|
347
|
+
ArrayList list = toArrayList((JSONArray) value);
|
|
348
|
+
// Heuristic to determine array type
|
|
349
|
+
if (!list.isEmpty()) {
|
|
350
|
+
if (list.get(0) instanceof String) {
|
|
351
|
+
bundle.putStringArrayList(key, list);
|
|
352
|
+
} else if (list.get(0) instanceof Bundle) {
|
|
353
|
+
bundle.putParcelableArrayList(key, list);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return bundle;
|
|
89
359
|
}
|
|
90
360
|
|
|
91
|
-
private
|
|
92
|
-
|
|
93
|
-
|
|
361
|
+
private ArrayList toArrayList(JSONArray array) throws JSONException {
|
|
362
|
+
ArrayList list = new ArrayList();
|
|
363
|
+
for (int i = 0; i < array.length(); i++) {
|
|
364
|
+
Object value = array.get(i);
|
|
365
|
+
if (value instanceof JSONObject) {
|
|
366
|
+
list.add(toBundle(new JSObject(value.toString())));
|
|
367
|
+
} else {
|
|
368
|
+
list.add(value);
|
|
369
|
+
}
|
|
94
370
|
}
|
|
371
|
+
return list;
|
|
95
372
|
}
|
|
96
|
-
}
|
|
373
|
+
}
|
|
Binary file
|
package/esm/web.js
CHANGED
|
@@ -18,19 +18,19 @@ export class IntentShimWeb extends WebPlugin {
|
|
|
18
18
|
registerBroadcastReceiver(options) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
this.log(`IntentShim Web: registerBroadcastReceiver with filters ${JSON.stringify(options.filterActions)}`);
|
|
21
|
-
throw this.
|
|
21
|
+
throw this.unimplemented('Not available in web environment');
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
unregisterBroadcastReceiver() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
this.log('IntentShim Web: unregisterBroadcastReceiver');
|
|
27
|
-
throw this.
|
|
27
|
+
throw this.unimplemented('Not available in web environment');
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
sendBroadcast(options) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
this.log(`IntentShim Web: sendBroadcast ${options.action}`);
|
|
33
|
-
throw this.
|
|
33
|
+
throw this.unimplemented('Not available in web environment');
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
startActivity(options) {
|
|
@@ -41,25 +41,25 @@ export class IntentShimWeb extends WebPlugin {
|
|
|
41
41
|
window.open(options.url, '_blank');
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
throw this.
|
|
44
|
+
throw this.unimplemented('Full intent functionality not available in web environment');
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
getIntent() {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
this.log('IntentShim Web: getIntent');
|
|
50
|
-
throw this.
|
|
50
|
+
throw this.unimplemented('Not available in web environment');
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
startActivityForResult(options) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
this.log(`IntentShim Web: startActivityForResult ${options.action}`);
|
|
56
|
-
throw this.
|
|
56
|
+
throw this.unimplemented('Not available in web environment');
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
sendResult(options) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
this.log(`IntentShim Web: sendResult with resultCode ${options.resultCode || 'none'} and extras ${JSON.stringify(options.extras || {})}`);
|
|
62
|
-
throw this.
|
|
62
|
+
throw this.unimplemented('Not available in web environment');
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
onIntent(callback) {
|
package/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/capacitor/web.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAIxC;QACI,KAAK,EAAE,CAAC;QAJJ,oBAAe,GAAuC,EAAE,CAAC;QACzD,UAAK,GAAY,KAAK,CAAC;QAI3B,IAAI,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC5C,CAAC;IAEK,yBAAyB,CAAC,OAAoC;;YAChE,IAAI,CAAC,GAAG,CAAC,0DAA0D,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAC5G,MAAM,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/capacitor/web.ts"],"names":[],"mappings":"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","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { IntentShimPlugin, IntentResult } from './definitions';\n\nexport class IntentShimWeb extends WebPlugin implements IntentShimPlugin {\n private intentListeners: ((intent: IntentResult) => void)[] = [];\n private debug: boolean = false;\n\n constructor() {\n super();\n this.log('IntentShim Web: Initialized');\n }\n\n async registerBroadcastReceiver(options: { filterActions: string[] }): Promise<void> {\n this.log(`IntentShim Web: registerBroadcastReceiver with filters ${JSON.stringify(options.filterActions)}`);\n throw this.unimplemented('Not available in web environment');\n }\n\n async unregisterBroadcastReceiver(): Promise<void> {\n this.log('IntentShim Web: unregisterBroadcastReceiver');\n throw this.unimplemented('Not available in web environment');\n }\n\n async sendBroadcast(options: { action: string; extras?: any }): Promise<void> {\n this.log(`IntentShim Web: sendBroadcast ${options.action}`);\n throw this.unimplemented('Not available in web environment');\n }\n\n async startActivity(options: { action: string; url?: string; type?: string; extras?: any }): Promise<void> {\n this.log(`IntentShim Web: startActivity ${options.action}`);\n // For web, we can at least try to open URLs\n if (options.url && options.action === 'android.intent.action.VIEW') {\n window.open(options.url, '_blank');\n return;\n }\n throw this.unimplemented('Full intent functionality not available in web environment');\n }\n\n async getIntent(): Promise<{ action: string; data: string; type: string; extras: any }> {\n this.log('IntentShim Web: getIntent');\n throw this.unimplemented('Not available in web environment');\n }\n\n async startActivityForResult(options: {\n action: string; url?: string; type?: string; extras?: any; requestCode: number\n }): Promise<void> {\n this.log(`IntentShim Web: startActivityForResult ${options.action}`);\n throw this.unimplemented('Not available in web environment');\n }\n\n async sendResult(options: { extras?: any; resultCode?: number }): Promise<void> {\n this.log(`IntentShim Web: sendResult with resultCode ${options.resultCode || 'none'} and extras ${JSON.stringify(options.extras || {})}`);\n throw this.unimplemented('Not available in web environment');\n }\n\n onIntent(callback: (intent: IntentResult) => void): void {\n this.log('IntentShim Web: onIntent listener registered');\n this.intentListeners.push(callback);\n }\n\n async packageExists(packageName: string): Promise<{ exists: boolean }> {\n this.log(`IntentShim Web: packageExists ${packageName}`);\n return { exists: false };\n }\n\n async setDebugMode(options: { enabled: boolean }): Promise<void> {\n this.debug = options.enabled;\n this.log(`IntentShim Web: Debug mode ${options.enabled ? 'enabled' : 'disabled'}`);\n }\n\n private log(message: string): void {\n if (this.debug) {\n console.log(message);\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
Binary file
|