@capacitor/share 1.0.7 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.1.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/share@1.0.7...@capacitor/share@1.1.0) (2022-01-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * **share:** Add canShare method to check availability ([#748](https://github.com/ionic-team/capacitor-plugins/issues/748)) ([3883d82](https://github.com/ionic-team/capacitor-plugins/commit/3883d82952a4453797b86c562af27f9b05e82a18))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [1.0.7](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/share@1.0.6...@capacitor/share@1.0.7) (2021-11-03)
7
18
 
8
19
  **Note:** Version bump only for package @capacitor/share
package/README.md CHANGED
@@ -31,6 +31,7 @@ Each platform uses a different set of fields, but you should supply them all.
31
31
 
32
32
  <docgen-index>
33
33
 
34
+ * [`canShare()`](#canshare)
34
35
  * [`share(...)`](#share)
35
36
  * [Interfaces](#interfaces)
36
37
 
@@ -39,6 +40,21 @@ Each platform uses a different set of fields, but you should supply them all.
39
40
  <docgen-api>
40
41
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
41
42
 
43
+ ### canShare()
44
+
45
+ ```typescript
46
+ canShare() => Promise<CanShareResult>
47
+ ```
48
+
49
+ Check if sharing is supported.
50
+
51
+ **Returns:** <code>Promise&lt;<a href="#canshareresult">CanShareResult</a>&gt;</code>
52
+
53
+ **Since:** 1.1.0
54
+
55
+ --------------------
56
+
57
+
42
58
  ### share(...)
43
59
 
44
60
  ```typescript
@@ -61,6 +77,13 @@ Show a Share modal for sharing content with other apps
61
77
  ### Interfaces
62
78
 
63
79
 
80
+ #### CanShareResult
81
+
82
+ | Prop | Type | Description | Since |
83
+ | ----------- | -------------------- | ------------------------------------ | ----- |
84
+ | **`value`** | <code>boolean</code> | Whether sharing is supported or not. | 1.1.0 |
85
+
86
+
64
87
  #### ShareResult
65
88
 
66
89
  | Prop | Type | Description | Since |
@@ -50,6 +50,13 @@ public class SharePlugin extends Plugin {
50
50
  isPresenting = false;
51
51
  }
52
52
 
53
+ @PluginMethod
54
+ public void canShare(PluginCall call) {
55
+ JSObject callResult = new JSObject();
56
+ callResult.put("value", true);
57
+ call.resolve(callResult);
58
+ }
59
+
53
60
  @PluginMethod
54
61
  public void share(PluginCall call) {
55
62
  if (!isPresenting) {
package/dist/docs.json CHANGED
@@ -5,6 +5,23 @@
5
5
  "docs": "",
6
6
  "tags": [],
7
7
  "methods": [
8
+ {
9
+ "name": "canShare",
10
+ "signature": "() => Promise<CanShareResult>",
11
+ "parameters": [],
12
+ "returns": "Promise<CanShareResult>",
13
+ "tags": [
14
+ {
15
+ "name": "since",
16
+ "text": "1.1.0"
17
+ }
18
+ ],
19
+ "docs": "Check if sharing is supported.",
20
+ "complexTypes": [
21
+ "CanShareResult"
22
+ ],
23
+ "slug": "canshare"
24
+ },
8
25
  {
9
26
  "name": "share",
10
27
  "signature": "(options: ShareOptions) => Promise<ShareResult>",
@@ -33,6 +50,27 @@
33
50
  "properties": []
34
51
  },
35
52
  "interfaces": [
53
+ {
54
+ "name": "CanShareResult",
55
+ "slug": "canshareresult",
56
+ "docs": "",
57
+ "tags": [],
58
+ "methods": [],
59
+ "properties": [
60
+ {
61
+ "name": "value",
62
+ "tags": [
63
+ {
64
+ "text": "1.1.0",
65
+ "name": "since"
66
+ }
67
+ ],
68
+ "docs": "Whether sharing is supported or not.",
69
+ "complexTypes": [],
70
+ "type": "boolean"
71
+ }
72
+ ]
73
+ },
36
74
  {
37
75
  "name": "ShareResult",
38
76
  "slug": "shareresult",
@@ -37,7 +37,21 @@ export interface ShareResult {
37
37
  */
38
38
  activityType?: string;
39
39
  }
40
+ export interface CanShareResult {
41
+ /**
42
+ * Whether sharing is supported or not.
43
+ *
44
+ * @since 1.1.0
45
+ */
46
+ value: boolean;
47
+ }
40
48
  export interface SharePlugin {
49
+ /**
50
+ * Check if sharing is supported.
51
+ *
52
+ * @since 1.1.0
53
+ */
54
+ canShare(): Promise<CanShareResult>;
41
55
  /**
42
56
  * Show a Share modal for sharing content with other apps
43
57
  *
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { ShareOptions, SharePlugin, ShareResult } from './definitions';
2
+ import type { CanShareResult, ShareOptions, SharePlugin, ShareResult } from './definitions';
3
3
  export declare class ShareWeb extends WebPlugin implements SharePlugin {
4
+ canShare(): Promise<CanShareResult>;
4
5
  share(options: ShareOptions): Promise<ShareResult>;
5
6
  }
package/dist/esm/web.js CHANGED
@@ -1,5 +1,13 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  export class ShareWeb extends WebPlugin {
3
+ async canShare() {
4
+ if (typeof navigator === 'undefined' || !navigator.share) {
5
+ return { value: false };
6
+ }
7
+ else {
8
+ return { value: true };
9
+ }
10
+ }
3
11
  async share(options) {
4
12
  if (typeof navigator === 'undefined' || !navigator.share) {
5
13
  throw this.unavailable('Share API not available in this browser');
@@ -1 +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,QAAS,SAAQ,SAAS;IACrC,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;YACxD,MAAM,IAAI,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC;SACnE;QAED,MAAM,SAAS,CAAC,KAAK,CAAC;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,QAAS,SAAQ,SAAS;IACrC,KAAK,CAAC,QAAQ;QACZ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;YACxD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;SACzB;aAAM;YACL,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SACxB;IACH,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;YACxD,MAAM,IAAI,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC;SACnE;QAED,MAAM,SAAS,CAAC,KAAK,CAAC;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
@@ -9,6 +9,14 @@ const Share = core.registerPlugin('Share', {
9
9
  });
10
10
 
11
11
  class ShareWeb extends core.WebPlugin {
12
+ async canShare() {
13
+ if (typeof navigator === 'undefined' || !navigator.share) {
14
+ return { value: false };
15
+ }
16
+ else {
17
+ return { value: true };
18
+ }
19
+ }
12
20
  async share(options) {
13
21
  if (typeof navigator === 'undefined' || !navigator.share) {
14
22
  throw this.unavailable('Share API not available in this browser');
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Share = registerPlugin('Share', {\n web: () => import('./web').then(m => new m.ShareWeb()),\n});\nexport * from './definitions';\nexport { Share };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ShareWeb extends WebPlugin {\n async share(options) {\n if (typeof navigator === 'undefined' || !navigator.share) {\n throw this.unavailable('Share API not available in this browser');\n }\n await navigator.share({\n title: options.title,\n text: options.text,\n url: options.url,\n });\n return {};\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,KAAK,GAAGA,mBAAc,CAAC,OAAO,EAAE;AACtC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC1D,CAAC;;ACFM,MAAM,QAAQ,SAASC,cAAS,CAAC;AACxC,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;AAClE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC;AAC9E,SAAS;AACT,QAAQ,MAAM,SAAS,CAAC,KAAK,CAAC;AAC9B,YAAY,KAAK,EAAE,OAAO,CAAC,KAAK;AAChC,YAAY,IAAI,EAAE,OAAO,CAAC,IAAI;AAC9B,YAAY,GAAG,EAAE,OAAO,CAAC,GAAG;AAC5B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Share = registerPlugin('Share', {\n web: () => import('./web').then(m => new m.ShareWeb()),\n});\nexport * from './definitions';\nexport { Share };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ShareWeb extends WebPlugin {\n async canShare() {\n if (typeof navigator === 'undefined' || !navigator.share) {\n return { value: false };\n }\n else {\n return { value: true };\n }\n }\n async share(options) {\n if (typeof navigator === 'undefined' || !navigator.share) {\n throw this.unavailable('Share API not available in this browser');\n }\n await navigator.share({\n title: options.title,\n text: options.text,\n url: options.url,\n });\n return {};\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,KAAK,GAAGA,mBAAc,CAAC,OAAO,EAAE;AACtC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC1D,CAAC;;ACFM,MAAM,QAAQ,SAASC,cAAS,CAAC;AACxC,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;AAClE,YAAY,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACpC,SAAS;AACT,aAAa;AACb,YAAY,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACnC,SAAS;AACT,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;AAClE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC;AAC9E,SAAS;AACT,QAAQ,MAAM,SAAS,CAAC,KAAK,CAAC;AAC9B,YAAY,KAAK,EAAE,OAAO,CAAC,KAAK;AAChC,YAAY,IAAI,EAAE,OAAO,CAAC,IAAI;AAC9B,YAAY,GAAG,EAAE,OAAO,CAAC,GAAG;AAC5B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -6,6 +6,14 @@ var capacitorShare = (function (exports, core) {
6
6
  });
7
7
 
8
8
  class ShareWeb extends core.WebPlugin {
9
+ async canShare() {
10
+ if (typeof navigator === 'undefined' || !navigator.share) {
11
+ return { value: false };
12
+ }
13
+ else {
14
+ return { value: true };
15
+ }
16
+ }
9
17
  async share(options) {
10
18
  if (typeof navigator === 'undefined' || !navigator.share) {
11
19
  throw this.unavailable('Share API not available in this browser');
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Share = registerPlugin('Share', {\n web: () => import('./web').then(m => new m.ShareWeb()),\n});\nexport * from './definitions';\nexport { Share };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ShareWeb extends WebPlugin {\n async share(options) {\n if (typeof navigator === 'undefined' || !navigator.share) {\n throw this.unavailable('Share API not available in this browser');\n }\n await navigator.share({\n title: options.title,\n text: options.text,\n url: options.url,\n });\n return {};\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,KAAK,GAAGA,mBAAc,CAAC,OAAO,EAAE;IACtC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC;;ICFM,MAAM,QAAQ,SAASC,cAAS,CAAC;IACxC,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;IAClE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC;IAC9E,SAAS;IACT,QAAQ,MAAM,SAAS,CAAC,KAAK,CAAC;IAC9B,YAAY,KAAK,EAAE,OAAO,CAAC,KAAK;IAChC,YAAY,IAAI,EAAE,OAAO,CAAC,IAAI;IAC9B,YAAY,GAAG,EAAE,OAAO,CAAC,GAAG;IAC5B,SAAS,CAAC,CAAC;IACX,QAAQ,OAAO,EAAE,CAAC;IAClB,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Share = registerPlugin('Share', {\n web: () => import('./web').then(m => new m.ShareWeb()),\n});\nexport * from './definitions';\nexport { Share };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ShareWeb extends WebPlugin {\n async canShare() {\n if (typeof navigator === 'undefined' || !navigator.share) {\n return { value: false };\n }\n else {\n return { value: true };\n }\n }\n async share(options) {\n if (typeof navigator === 'undefined' || !navigator.share) {\n throw this.unavailable('Share API not available in this browser');\n }\n await navigator.share({\n title: options.title,\n text: options.text,\n url: options.url,\n });\n return {};\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,KAAK,GAAGA,mBAAc,CAAC,OAAO,EAAE;IACtC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC;;ICFM,MAAM,QAAQ,SAASC,cAAS,CAAC;IACxC,IAAI,MAAM,QAAQ,GAAG;IACrB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;IAClE,YAAY,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACpC,SAAS;IACT,aAAa;IACb,YAAY,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACnC,SAAS;IACT,KAAK;IACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;IAClE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC;IAC9E,SAAS;IACT,QAAQ,MAAM,SAAS,CAAC,KAAK,CAAC;IAC9B,YAAY,KAAK,EAAE,OAAO,CAAC,KAAK;IAChC,YAAY,IAAI,EAAE,OAAO,CAAC,IAAI;IAC9B,YAAY,GAAG,EAAE,OAAO,CAAC,GAAG;IAC5B,SAAS,CAAC,CAAC;IACX,QAAQ,OAAO,EAAE,CAAC;IAClB,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -4,5 +4,6 @@
4
4
  // Define the plugin using the CAP_PLUGIN Macro, and
5
5
  // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
6
  CAP_PLUGIN(SharePlugin, "Share",
7
+ CAP_PLUGIN_METHOD(canShare, CAPPluginReturnPromise);
7
8
  CAP_PLUGIN_METHOD(share, CAPPluginReturnPromise);
8
9
  )
@@ -4,6 +4,12 @@ import Capacitor
4
4
  @objc(SharePlugin)
5
5
  public class SharePlugin: CAPPlugin {
6
6
 
7
+ @objc func canShare(_ call: CAPPluginCall) {
8
+ call.resolve([
9
+ "value": true
10
+ ])
11
+ }
12
+
7
13
  @objc func share(_ call: CAPPluginCall) {
8
14
  var items = [Any]()
9
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/share",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "description": "The Share API provides methods for sharing content in any sharing-enabled apps the user may have installed.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "64df93225736e9dfad336562f5e53e5a2243052b"
82
+ "gitHead": "e5b333320426ee120d4504c68c02bd5538b21c51"
83
83
  }