@droponio/capacitor-intent-fragment 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.
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorIntent'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # capacitor-intent
2
+
3
+ Capacitor Js plugin for receveing and sending intents
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install capacitor-intent
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`registerBroadcastReceiver(...)`](#registerbroadcastreceiver)
17
+ * [`unregisterBroadcastReceiver(...)`](#unregisterbroadcastreceiver)
18
+ * [`sendBroadcastIntent(...)`](#sendbroadcastintent)
19
+
20
+ </docgen-index>
21
+
22
+ <docgen-api>
23
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
24
+
25
+ ### registerBroadcastReceiver(...)
26
+
27
+ ```typescript
28
+ registerBroadcastReceiver(options: { filters: string[]; }, callback: (data: { [key: string]: any; }) => void) => Promise<string>
29
+ ```
30
+
31
+ | Param | Type |
32
+ | -------------- | ------------------------------------------------------- |
33
+ | **`options`** | <code>{ filters: string[]; }</code> |
34
+ | **`callback`** | <code>(data: { [key: string]: any; }) =&gt; void</code> |
35
+
36
+ **Returns:** <code>Promise&lt;string&gt;</code>
37
+
38
+ --------------------
39
+
40
+
41
+ ### unregisterBroadcastReceiver(...)
42
+
43
+ ```typescript
44
+ unregisterBroadcastReceiver(options: { id: string; }) => Promise<void>
45
+ ```
46
+
47
+ | Param | Type |
48
+ | ------------- | ---------------------------- |
49
+ | **`options`** | <code>{ id: string; }</code> |
50
+
51
+ --------------------
52
+
53
+
54
+ ### sendBroadcastIntent(...)
55
+
56
+ ```typescript
57
+ sendBroadcastIntent(options: { action: string; value: { [key: string]: any; }; }) => Promise<void>
58
+ ```
59
+
60
+ | Param | Type |
61
+ | ------------- | ---------------------------------------------------------------- |
62
+ | **`options`** | <code>{ action: string; value: { [key: string]: any; }; }</code> |
63
+
64
+ --------------------
65
+
66
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "io.dropon.capacitor.intent"
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_11
41
+ targetCompatibility JavaVersion.VERSION_11
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,215 @@
1
+ package io.dropon.capacitor.intent;
2
+
3
+ import android.content.BroadcastReceiver;
4
+ import android.content.ClipData;
5
+ import android.content.ContentResolver;
6
+ import android.content.Context;
7
+ import android.content.Intent;
8
+ import android.content.IntentFilter;
9
+ import android.os.Build;
10
+ import android.os.Bundle;
11
+ import android.util.Log;
12
+ import android.webkit.MimeTypeMap;
13
+ import com.getcapacitor.JSArray;
14
+ import com.getcapacitor.JSObject;
15
+ import com.getcapacitor.Plugin;
16
+ import com.getcapacitor.PluginCall;
17
+ import com.getcapacitor.PluginMethod;
18
+ import com.getcapacitor.annotation.CapacitorPlugin;
19
+ import java.lang.reflect.Array;
20
+ import java.util.ArrayList;
21
+ import java.util.Arrays;
22
+ import java.util.HashMap;
23
+ import java.util.Map;
24
+ import org.json.JSONArray;
25
+ import org.json.JSONException;
26
+ import org.json.JSONObject;
27
+
28
+ @CapacitorPlugin(name = "CapacitorIntent")
29
+ public class CapacitorIntentPlugin extends Plugin {
30
+
31
+ private static final String LOG_TAG = "Capacitor Intents";
32
+ private Map<String, PluginCall> watchingCalls = new HashMap<>();
33
+ private Map<String, BroadcastReceiver> receiverMap = new HashMap<>();
34
+
35
+ @PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
36
+ public void registerBroadcastReceiver(PluginCall call) throws JSONException {
37
+ call.setKeepAlive(true);
38
+ requestBroadcastUpdates(call);
39
+ watchingCalls.put(call.getCallbackId(), call);
40
+ }
41
+
42
+ @PluginMethod
43
+ public void unregisterBroadcastReceiver(PluginCall call) {
44
+ String callbackId = call.getString("id");
45
+ if (callbackId != null) {
46
+ PluginCall removed = watchingCalls.remove(callbackId);
47
+ if (removed != null) {
48
+ removeReceiver(callbackId);
49
+ removed.release(bridge);
50
+ }
51
+ }
52
+ call.resolve();
53
+ }
54
+
55
+ @PluginMethod
56
+ public void sendBroadcastIntent(PluginCall call) {
57
+ String actionToUse = call.getString("action");
58
+ JSObject passingData = call.getObject("value");
59
+ Intent intended = new Intent(actionToUse);
60
+ intended.putExtra("value", passingData.toString());
61
+ this.getContext().sendBroadcast(intended);
62
+ call.resolve();
63
+ }
64
+
65
+ private void requestBroadcastUpdates(final PluginCall call) throws JSONException {
66
+ final String callBackID = call.getCallbackId();
67
+ IntentFilter ifilt = new IntentFilter();
68
+ JSArray jsArr = call.getArray("filters");
69
+ if (jsArr.length() >= 1) {
70
+ for (int i = 0; i < jsArr.length(); i++) {
71
+ ifilt.addAction(jsArr.getString(i));
72
+ }
73
+ receiverMap.put(
74
+ callBackID,
75
+ new BroadcastReceiver() {
76
+ @Override
77
+ public void onReceive(Context context, Intent intent) {
78
+ PluginCall refCall = watchingCalls.get(callBackID);
79
+ if (refCall != null) {
80
+ JSObject jsO = null;
81
+ try {
82
+ jsO = JSObject.fromJSONObject(getIntentJson(intent));
83
+ refCall.resolve(jsO);
84
+ } catch (JSONException e) {
85
+ e.printStackTrace();
86
+ }
87
+ }
88
+ }
89
+ }
90
+ );
91
+
92
+ this.getContext().registerReceiver(receiverMap.get(callBackID), ifilt);
93
+ } else {
94
+ call.reject("Filters are required: at least 1 entry");
95
+ }
96
+ }
97
+
98
+ private void removeReceiver(String callBackID) {
99
+ this.getContext().unregisterReceiver(receiverMap.get(callBackID));
100
+ this.receiverMap.remove(callBackID);
101
+ }
102
+
103
+ private static Object toJsonValue(final Object value) throws JSONException {
104
+ // Credit: https://github.com/napolitano/cordova-plugin-intent
105
+ if (value == null) {
106
+ return null;
107
+ } else if (value instanceof Bundle) {
108
+ final Bundle bundle = (Bundle) value;
109
+ final JSONObject result = new JSONObject();
110
+ for (final String key : bundle.keySet()) {
111
+ result.put(key, toJsonValue(bundle.get(key)));
112
+ }
113
+ return result;
114
+ } else if ((value.getClass().isArray())) {
115
+ final JSONArray result = new JSONArray();
116
+ int length = Array.getLength(value);
117
+ for (int i = 0; i < length; ++i) {
118
+ result.put(i, toJsonValue(Array.get(value, i)));
119
+ }
120
+ return result;
121
+ } else if (value instanceof ArrayList<?>) {
122
+ final ArrayList arrayList = (ArrayList<?>) value;
123
+ final JSONArray result = new JSONArray();
124
+ for (int i = 0; i < arrayList.size(); i++) result.put(toJsonValue(arrayList.get(i)));
125
+ return result;
126
+ } else if (
127
+ value instanceof String ||
128
+ value instanceof Boolean ||
129
+ value instanceof Integer ||
130
+ value instanceof Long ||
131
+ value instanceof Double
132
+ ) {
133
+ return value;
134
+ } else {
135
+ return String.valueOf(value);
136
+ }
137
+ }
138
+
139
+ private static JSONObject toJsonObject(Bundle bundle) {
140
+ // Credit: https://github.com/napolitano/cordova-plugin-intent
141
+ try {
142
+ return (JSONObject) toJsonValue(bundle);
143
+ } catch (JSONException e) {
144
+ throw new IllegalArgumentException("Cannot convert bundle to JSON: " + e.getMessage(), e);
145
+ }
146
+ }
147
+
148
+ private JSONObject getIntentJson(Intent intent) {
149
+ // Credit: https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent
150
+ JSONObject intentJSON = null;
151
+ ClipData clipData = null;
152
+ JSONObject[] items = null;
153
+ ContentResolver cR = this.getContext().getContentResolver();
154
+ MimeTypeMap mime = MimeTypeMap.getSingleton();
155
+
156
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
157
+ clipData = intent.getClipData();
158
+ if (clipData != null) {
159
+ int clipItemCount = clipData.getItemCount();
160
+ items = new JSONObject[clipItemCount];
161
+
162
+ for (int i = 0; i < clipItemCount; i++) {
163
+ ClipData.Item item = clipData.getItemAt(i);
164
+
165
+ try {
166
+ items[i] = new JSONObject();
167
+ items[i].put("htmlText", item.getHtmlText());
168
+ items[i].put("intent", item.getIntent());
169
+ items[i].put("text", item.getText());
170
+ items[i].put("uri", item.getUri());
171
+
172
+ if (item.getUri() != null) {
173
+ String type = cR.getType(item.getUri());
174
+ String extension = mime.getExtensionFromMimeType(cR.getType(item.getUri()));
175
+
176
+ items[i].put("type", type);
177
+ items[i].put("extension", extension);
178
+ }
179
+ } catch (JSONException e) {
180
+ Log.d(LOG_TAG, " Error thrown during intent > JSON conversion");
181
+ Log.d(LOG_TAG, e.getMessage());
182
+ Log.d(LOG_TAG, Arrays.toString(e.getStackTrace()));
183
+ }
184
+ }
185
+ }
186
+ }
187
+
188
+ try {
189
+ intentJSON = new JSONObject();
190
+
191
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
192
+ if (items != null) {
193
+ intentJSON.put("clipItems", new JSONArray(items));
194
+ }
195
+ }
196
+
197
+ intentJSON.put("type", intent.getType());
198
+ intentJSON.put("extras", toJsonObject(intent.getExtras()));
199
+ intentJSON.put("action", intent.getAction());
200
+ intentJSON.put("categories", intent.getCategories());
201
+ intentJSON.put("flags", intent.getFlags());
202
+ intentJSON.put("component", intent.getComponent());
203
+ intentJSON.put("data", intent.getData());
204
+ intentJSON.put("package", intent.getPackage());
205
+
206
+ return intentJSON;
207
+ } catch (JSONException e) {
208
+ Log.d(LOG_TAG, " Error thrown during intent > JSON conversion");
209
+ Log.d(LOG_TAG, e.getMessage());
210
+ Log.d(LOG_TAG, Arrays.toString(e.getStackTrace()));
211
+
212
+ return null;
213
+ }
214
+ }
215
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "api": {
3
+ "name": "CapacitorIntentPlugin",
4
+ "slug": "capacitorintentplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "registerBroadcastReceiver",
10
+ "signature": "(options: { filters: string[]; }, callback: (data: { [key: string]: any; }) => void) => Promise<string>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "{ filters: string[]; }"
16
+ },
17
+ {
18
+ "name": "callback",
19
+ "docs": "",
20
+ "type": "(data: { [key: string]: any; }) => void"
21
+ }
22
+ ],
23
+ "returns": "Promise<string>",
24
+ "tags": [],
25
+ "docs": "",
26
+ "complexTypes": [],
27
+ "slug": "registerbroadcastreceiver"
28
+ },
29
+ {
30
+ "name": "unregisterBroadcastReceiver",
31
+ "signature": "(options: { id: string; }) => Promise<void>",
32
+ "parameters": [
33
+ {
34
+ "name": "options",
35
+ "docs": "",
36
+ "type": "{ id: string; }"
37
+ }
38
+ ],
39
+ "returns": "Promise<void>",
40
+ "tags": [],
41
+ "docs": "",
42
+ "complexTypes": [],
43
+ "slug": "unregisterbroadcastreceiver"
44
+ },
45
+ {
46
+ "name": "sendBroadcastIntent",
47
+ "signature": "(options: { action: string; value: { [key: string]: any; }; }) => Promise<void>",
48
+ "parameters": [
49
+ {
50
+ "name": "options",
51
+ "docs": "",
52
+ "type": "{ action: string; value: { [key: string]: any; }; }"
53
+ }
54
+ ],
55
+ "returns": "Promise<void>",
56
+ "tags": [],
57
+ "docs": "",
58
+ "complexTypes": [],
59
+ "slug": "sendbroadcastintent"
60
+ }
61
+ ],
62
+ "properties": []
63
+ },
64
+ "interfaces": [],
65
+ "enums": [],
66
+ "typeAliases": [],
67
+ "pluginConfigs": []
68
+ }
@@ -0,0 +1,16 @@
1
+ export interface CapacitorIntentPlugin {
2
+ registerBroadcastReceiver(options: {
3
+ filters: string[];
4
+ }, callback: (data: {
5
+ [key: string]: any;
6
+ }) => void): Promise<string>;
7
+ unregisterBroadcastReceiver(options: {
8
+ id: string;
9
+ }): Promise<void>;
10
+ sendBroadcastIntent(options: {
11
+ action: string;
12
+ value: {
13
+ [key: string]: any;
14
+ };
15
+ }): Promise<void>;
16
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CapacitorIntentPlugin {\n registerBroadcastReceiver(\n options: { filters: string[] },\n callback: (data: { [key: string]: any }) => void\n ): Promise<string>;\n\n unregisterBroadcastReceiver(options: { id: string }): Promise<void>;\n\n sendBroadcastIntent(options: { action: string; value: { [key: string]: any } }): Promise<void>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { CapacitorIntentPlugin } from './definitions';
2
+ declare const CapacitorIntent: CapacitorIntentPlugin;
3
+ export * from './definitions';
4
+ export { CapacitorIntent };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const CapacitorIntent = registerPlugin('CapacitorIntent', {
3
+ web: () => import('./web').then(m => new m.CapacitorIntentWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { CapacitorIntent };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,eAAe,GAAG,cAAc,CACpC,iBAAiB,EACjB;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;CACjE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorIntentPlugin } from './definitions';\n\nconst CapacitorIntent = registerPlugin<CapacitorIntentPlugin>(\n 'CapacitorIntent',\n {\n web: () => import('./web').then(m => new m.CapacitorIntentWeb()),\n },\n);\n\nexport * from './definitions';\nexport { CapacitorIntent };\n"]}
@@ -0,0 +1,18 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { CapacitorIntentPlugin } from './definitions';
3
+ export declare class CapacitorIntentWeb extends WebPlugin implements CapacitorIntentPlugin {
4
+ registerBroadcastReceiver(_options: {
5
+ filters: string[];
6
+ }, _callback: (data: {
7
+ [key: string]: any;
8
+ }) => void): Promise<string>;
9
+ unregisterBroadcastReceiver(_options: {
10
+ id: string;
11
+ }): Promise<void>;
12
+ sendBroadcastIntent(_options: {
13
+ action: string;
14
+ value: {
15
+ [key: string]: any;
16
+ };
17
+ }): Promise<void>;
18
+ }
@@ -0,0 +1,13 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class CapacitorIntentWeb extends WebPlugin {
3
+ async registerBroadcastReceiver(_options, _callback) {
4
+ throw new Error('Feature not implemented in web.');
5
+ }
6
+ async unregisterBroadcastReceiver(_options) {
7
+ throw new Error('Feature not implemented in web.');
8
+ }
9
+ async sendBroadcastIntent(_options) {
10
+ throw new Error('Feature not implemented in web.');
11
+ }
12
+ }
13
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,yBAAyB,CAC3B,QAA+B,EAC/B,SAAiD;QAEnD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,QAAwB;QACxD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,QAA2D;QACnF,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorIntentPlugin } from './definitions';\n\nexport class CapacitorIntentWeb\n extends WebPlugin\n implements CapacitorIntentPlugin\n{\n async registerBroadcastReceiver(\n _options: { filters: string[] },\n _callback: (data: { [key: string]: any }) => void\n ): Promise<string> {\n throw new Error('Feature not implemented in web.');\n }\n\n async unregisterBroadcastReceiver(_options: { id: string }) {\n throw new Error('Feature not implemented in web.');\n }\n\n async sendBroadcastIntent(_options: { action: string; value: { [key: string]: any } }): Promise<void> {\n throw new Error('Feature not implemented in web.');\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const CapacitorIntent = core.registerPlugin('CapacitorIntent', {
8
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorIntentWeb()),
9
+ });
10
+
11
+ class CapacitorIntentWeb extends core.WebPlugin {
12
+ async registerBroadcastReceiver(_options, _callback) {
13
+ throw new Error('Feature not implemented in web.');
14
+ }
15
+ async unregisterBroadcastReceiver(_options) {
16
+ throw new Error('Feature not implemented in web.');
17
+ }
18
+ async sendBroadcastIntent(_options) {
19
+ throw new Error('Feature not implemented in web.');
20
+ }
21
+ }
22
+
23
+ var web = /*#__PURE__*/Object.freeze({
24
+ __proto__: null,
25
+ CapacitorIntentWeb: CapacitorIntentWeb
26
+ });
27
+
28
+ exports.CapacitorIntent = CapacitorIntent;
29
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorIntent = registerPlugin('CapacitorIntent', {\n web: () => import('./web').then(m => new m.CapacitorIntentWeb()),\n});\nexport * from './definitions';\nexport { CapacitorIntent };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorIntentWeb extends WebPlugin {\n async registerBroadcastReceiver(_options, _callback) {\n throw new Error('Feature not implemented in web.');\n }\n async unregisterBroadcastReceiver(_options) {\n throw new Error('Feature not implemented in web.');\n }\n async sendBroadcastIntent(_options) {\n throw new Error('Feature not implemented in web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;AAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,kBAAkB,SAASC,cAAS,CAAC;AAClD,IAAI,MAAM,yBAAyB,CAAC,QAAQ,EAAE,SAAS,EAAE;AACzD,QAAQ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAC3D,KAAK;AACL,IAAI,MAAM,2BAA2B,CAAC,QAAQ,EAAE;AAChD,QAAQ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAC3D,KAAK;AACL,IAAI,MAAM,mBAAmB,CAAC,QAAQ,EAAE;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAC3D,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,32 @@
1
+ var capacitorCapacitorIntent = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const CapacitorIntent = core.registerPlugin('CapacitorIntent', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorIntentWeb()),
6
+ });
7
+
8
+ class CapacitorIntentWeb extends core.WebPlugin {
9
+ async registerBroadcastReceiver(_options, _callback) {
10
+ throw new Error('Feature not implemented in web.');
11
+ }
12
+ async unregisterBroadcastReceiver(_options) {
13
+ throw new Error('Feature not implemented in web.');
14
+ }
15
+ async sendBroadcastIntent(_options) {
16
+ throw new Error('Feature not implemented in web.');
17
+ }
18
+ }
19
+
20
+ var web = /*#__PURE__*/Object.freeze({
21
+ __proto__: null,
22
+ CapacitorIntentWeb: CapacitorIntentWeb
23
+ });
24
+
25
+ exports.CapacitorIntent = CapacitorIntent;
26
+
27
+ Object.defineProperty(exports, '__esModule', { value: true });
28
+
29
+ return exports;
30
+
31
+ })({}, capacitorExports);
32
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorIntent = registerPlugin('CapacitorIntent', {\n web: () => import('./web').then(m => new m.CapacitorIntentWeb()),\n});\nexport * from './definitions';\nexport { CapacitorIntent };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorIntentWeb extends WebPlugin {\n async registerBroadcastReceiver(_options, _callback) {\n throw new Error('Feature not implemented in web.');\n }\n async unregisterBroadcastReceiver(_options) {\n throw new Error('Feature not implemented in web.');\n }\n async sendBroadcastIntent(_options) {\n throw new Error('Feature not implemented in web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,eAAe,GAAGA,mBAAc,CAAC,iBAAiB,EAAE;IAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,kBAAkB,SAASC,cAAS,CAAC;IAClD,IAAI,MAAM,yBAAyB,CAAC,QAAQ,EAAE,SAAS,EAAE;IACzD,QAAQ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC3D,KAAK;IACL,IAAI,MAAM,2BAA2B,CAAC,QAAQ,EAAE;IAChD,QAAQ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC3D,KAAK;IACL,IAAI,MAAM,mBAAmB,CAAC,QAAQ,EAAE;IACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC3D,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class CapacitorIntent: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(CapacitorIntentPlugin, "CapacitorIntent",
7
+ CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
+ )
@@ -0,0 +1,18 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(CapacitorIntentPlugin)
9
+ public class CapacitorIntentPlugin: CAPPlugin {
10
+ private let implementation = CapacitorIntent()
11
+
12
+ @objc func echo(_ call: CAPPluginCall) {
13
+ let value = call.getString("value") ?? ""
14
+ call.resolve([
15
+ "value": implementation.echo(value)
16
+ ])
17
+ }
18
+ }
@@ -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>
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@droponio/capacitor-intent-fragment",
3
+ "version": "0.0.1",
4
+ "description": "Capacitor Js plugin for receveing and sending intents",
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
+ "CapacitorIntent.podspec"
15
+ ],
16
+ "author": "dropon",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/dropon/capacitor-intent-fragment.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/dropon/capacitor-intent/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "native"
29
+ ],
30
+ "scripts": {
31
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
32
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
33
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
+ "verify:web": "npm run build",
35
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
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}\"",
39
+ "swiftlint": "node-swiftlint",
40
+ "docgen": "docgen --api CapacitorIntentPlugin --output-readme README.md --output-json dist/docs.json",
41
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
42
+ "clean": "rimraf ./dist",
43
+ "watch": "tsc --watch",
44
+ "publish": "npm publish --access public",
45
+ "prepublishOnly": "npm run build"
46
+ },
47
+ "devDependencies": {
48
+ "@capacitor/android": "^5.0.0",
49
+ "@capacitor/core": "^5.0.0",
50
+ "@capacitor/docgen": "^0.0.18",
51
+ "@capacitor/ios": "^5.0.0",
52
+ "@ionic/eslint-config": "^0.3.0",
53
+ "@ionic/prettier-config": "^1.0.1",
54
+ "@ionic/swiftlint-config": "^1.1.2",
55
+ "eslint": "^7.11.0",
56
+ "prettier": "~2.3.0",
57
+ "prettier-plugin-java": "~1.0.2",
58
+ "rimraf": "^3.0.2",
59
+ "rollup": "^2.32.0",
60
+ "swiftlint": "^1.0.1",
61
+ "typescript": "~4.1.5"
62
+ },
63
+ "peerDependencies": {
64
+ "@capacitor/core": "^5.0.0"
65
+ },
66
+ "prettier": "@ionic/prettier-config",
67
+ "swiftlint": "@ionic/swiftlint-config",
68
+ "eslintConfig": {
69
+ "extends": "@ionic/eslint-config/recommended"
70
+ },
71
+ "capacitor": {
72
+ "ios": {
73
+ "src": "ios"
74
+ },
75
+ "android": {
76
+ "src": "android"
77
+ }
78
+ }
79
+ }