react-native-share 11.1.0 → 12.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.
package/README.md CHANGED
@@ -6,6 +6,67 @@ React Native Share, is a simple tool for sharing messages and files with other a
6
6
 
7
7
  ---
8
8
 
9
+ ## Expo Managed Workflow
10
+
11
+ For Expo projects, you will need to be on a managed workflow and use the following command:
12
+
13
+ ```shell
14
+ npx expo install react-native-share
15
+ ```
16
+
17
+ Configure you `app.config.ts` or `app.json` to use the permissions needed by the library:
18
+
19
+ ```json
20
+ {
21
+ "plugins": [
22
+ [
23
+ "react-native-share",
24
+ {
25
+ "ios": [
26
+ "fb",
27
+ "instagram",
28
+ "twitter",
29
+ "tiktoksharesdk",
30
+ ],
31
+ "android": [
32
+ "com.facebook.katana",
33
+ "com.instagram.android",
34
+ "com.twitter.android",
35
+ "com.zhiliaoapp.musically",
36
+ ]
37
+ }
38
+ ]
39
+ ]
40
+ }
41
+ ```
42
+
43
+ `ios` parameter will take care of adding queries (LSApplicationQueriesSchemes) to the Info.plist.
44
+
45
+ ```xml
46
+ <key>LSApplicationQueriesSchemes</key>
47
+ <array>
48
+ <string>fb</string>
49
+ <string>instagram</string>
50
+ <string>twitter</string>
51
+ <string>tiktoksharesdk</string>
52
+ </array>
53
+ ```
54
+
55
+ `android` parameter will take care of adding queries to the AndroidManifest.xml.
56
+
57
+ ```xml
58
+ <queries>
59
+ <package android:name="com.facebook.katana" />
60
+ <package android:name="com.instagram.android" />
61
+ <package android:name="com.twitter.android" />
62
+ <package android:name="com.zhiliaoapp.musically" />
63
+ </queries>
64
+ ```
65
+
66
+ And prebuild the project with `expo prebuild`.
67
+
68
+ ## Bare React Native
69
+
9
70
  If you are using `react-native >= 0.7X` and/or the new arch you just need to do a simple:
10
71
 
11
72
  ```shell
@@ -22,6 +83,8 @@ After that, we need to install the dependencies to use the project on iOS(you ca
22
83
 
23
84
  Now run a simple: `npx pod-install` or `cd ios && pod install`. After that, you should be able to use the library on both Platforms, iOS and Android.
24
85
 
86
+ # Usage
87
+
25
88
  Then simply import:
26
89
 
27
90
  ```js
package/app.plugin.js ADDED
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line no-undef, import/no-commonjs
2
+ module.exports = require('./plugin/build');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-share",
3
3
  "description": "Social share, sending simple data to other apps.",
4
- "version": "11.1.0",
4
+ "version": "12.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/react-native-community/react-native-share.git"
@@ -22,7 +22,9 @@
22
22
  "RNShare.podspec",
23
23
  "!**/__tests__",
24
24
  "!**/__fixtures__",
25
- "!**/__mocks__"
25
+ "!**/__mocks__",
26
+ "app.plugin.js",
27
+ "plugin"
26
28
  ],
27
29
  "devDependencies": {
28
30
  "@babel/core": "^7.23.3",
@@ -30,6 +32,7 @@
30
32
  "@babel/runtime": "^7.23.2",
31
33
  "@commitlint/cli": "^11.0.0",
32
34
  "@commitlint/config-conventional": "^11.0.0",
35
+ "@expo/config-plugins": "^9.0.10",
33
36
  "@react-native/eslint-config": "^0.74.0",
34
37
  "@react-native/metro-config": "^0.73.2",
35
38
  "@semantic-release/commit-analyzer": "^11.1.0",
@@ -37,6 +40,7 @@
37
40
  "@semantic-release/github": "^9.2.1",
38
41
  "@semantic-release/npm": "^11.0.1",
39
42
  "@semantic-release/release-notes-generator": "^12.1.0",
43
+ "@tsconfig/node-lts": "^22.0.0",
40
44
  "@tsconfig/react-native": "^3.0.2",
41
45
  "@types/react": "^18.2.37",
42
46
  "@types/react-native": "^0.72.6",
@@ -60,7 +64,9 @@
60
64
  "typescript": "^5.2.2"
61
65
  },
62
66
  "resolutions": {
63
- "eslint-plugin-prettier": "5.0.1"
67
+ "eslint-plugin-prettier": "5.0.1",
68
+ "wrap-ansi": "7.0.0",
69
+ "string-width": "4.1.0"
64
70
  },
65
71
  "keywords": [
66
72
  "react-native",
@@ -90,9 +96,10 @@
90
96
  "start:ios": "react-native run-ios",
91
97
  "lint": "eslint \"src/**/*.{js,ts,tsx}\" --max-warnings=0",
92
98
  "typescript": "tsc --noEmit",
99
+ "build:expo-plugin": "tsc --project ./plugin/tsconfig.json",
93
100
  "validate": "yarn lint && yarn typescript",
94
101
  "ci:publish": "npx semantic-release",
95
- "prepare": "bob build",
102
+ "prepare": "bob build && yarn build:expo-plugin",
96
103
  "windows": "react-native run-windows"
97
104
  },
98
105
  "husky": {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,77 @@
1
+ import { withAndroidManifest, createRunOncePlugin, } from '@expo/config-plugins';
2
+ // eslint-disable-next-line import/no-commonjs, @typescript-eslint/no-var-requires
3
+ const pkg = require('../../package.json');
4
+ /**
5
+ * @type {import('./types').ManifestQueries}
6
+ * what we are trying to add:
7
+ * <queries>
8
+ <package android:name="com.facebook.katana"/>
9
+ <package android:name="com.instagram.android"/>
10
+ <package android:name="com.twitter.android"/>
11
+ <package android:name="com.zhiliaoapp.musically"/>
12
+ <intent></intent>
13
+ <action android:name="android.intent.action.VIEW"/>
14
+ <category android:name="android.intent.category.BROWSABLE"/>
15
+ <data android:scheme="https"/>
16
+ </intent>
17
+ </queries>
18
+ */
19
+ /**
20
+ * @param {import('@expo/config-plugins').ExportedConfig} config
21
+ */
22
+ const withAndroidManifestService = (config, props) => {
23
+ return withAndroidManifest(config, (config) => {
24
+ config.modResults.manifest = {
25
+ ...config.modResults.manifest,
26
+ queries: {
27
+ package: props?.android?.map((social) => ({
28
+ $: {
29
+ 'android:name': social,
30
+ },
31
+ })),
32
+ intent: [
33
+ {
34
+ action: {
35
+ $: {
36
+ 'android:name': 'android.intent.action.VIEW',
37
+ },
38
+ },
39
+ category: {
40
+ $: {
41
+ 'android:name': 'android.intent.category.BROWSABLE',
42
+ },
43
+ },
44
+ data: {
45
+ $: {
46
+ 'android:scheme': 'https',
47
+ },
48
+ },
49
+ },
50
+ ],
51
+ },
52
+ };
53
+ return config;
54
+ });
55
+ };
56
+ const withInfoPlist = (config, props) => {
57
+ return {
58
+ ...config,
59
+ ios: {
60
+ ...config.ios,
61
+ infoPlist: {
62
+ ...config.ios?.infoPlist,
63
+ LSApplicationQueriesSchemes: {
64
+ ...config.ios?.infoPlist?.LSApplicationQueriesSchemes,
65
+ ...props?.ios,
66
+ },
67
+ },
68
+ },
69
+ };
70
+ };
71
+ function withSocialShare(config, props) {
72
+ config = withAndroidManifestService(config, props); // Android
73
+ config = withInfoPlist(config, props); // iOS
74
+ return config;
75
+ }
76
+ // eslint-disable-next-line import/no-commonjs
77
+ module.exports = createRunOncePlugin(withSocialShare, pkg.name, pkg.version);
@@ -0,0 +1,94 @@
1
+ import {
2
+ withAndroidManifest,
3
+ createRunOncePlugin,
4
+ ExportedConfigWithProps,
5
+ ExportedConfig,
6
+ } from '@expo/config-plugins';
7
+
8
+ // eslint-disable-next-line import/no-commonjs, @typescript-eslint/no-var-requires
9
+ const pkg = require('../../package.json');
10
+
11
+ /**
12
+ * @type {import('./types').ManifestQueries}
13
+ * what we are trying to add:
14
+ * <queries>
15
+ <package android:name="com.facebook.katana"/>
16
+ <package android:name="com.instagram.android"/>
17
+ <package android:name="com.twitter.android"/>
18
+ <package android:name="com.zhiliaoapp.musically"/>
19
+ <intent></intent>
20
+ <action android:name="android.intent.action.VIEW"/>
21
+ <category android:name="android.intent.category.BROWSABLE"/>
22
+ <data android:scheme="https"/>
23
+ </intent>
24
+ </queries>
25
+ */
26
+
27
+ /**
28
+ * @param {import('@expo/config-plugins').ExportedConfig} config
29
+ */
30
+ const withAndroidManifestService = (config: ExportedConfig, props: WithSocialShareProps) => {
31
+ return withAndroidManifest(config, (config: ExportedConfigWithProps) => {
32
+ config.modResults.manifest = {
33
+ ...config.modResults.manifest,
34
+ queries: {
35
+ package: props?.android?.map((social) => ({
36
+ $: {
37
+ 'android:name': social,
38
+ },
39
+ })),
40
+ intent: [
41
+ {
42
+ action: {
43
+ $: {
44
+ 'android:name': 'android.intent.action.VIEW',
45
+ },
46
+ },
47
+ category: {
48
+ $: {
49
+ 'android:name': 'android.intent.category.BROWSABLE',
50
+ },
51
+ },
52
+ data: {
53
+ $: {
54
+ 'android:scheme': 'https',
55
+ },
56
+ },
57
+ },
58
+ ],
59
+ },
60
+ };
61
+
62
+ return config;
63
+ });
64
+ };
65
+
66
+ const withInfoPlist = (config: ExportedConfig, props: WithSocialShareProps) => {
67
+ return {
68
+ ...config,
69
+ ios: {
70
+ ...config.ios,
71
+ infoPlist: {
72
+ ...config.ios?.infoPlist,
73
+ LSApplicationQueriesSchemes: {
74
+ ...config.ios?.infoPlist?.LSApplicationQueriesSchemes,
75
+ ...props?.ios,
76
+ },
77
+ },
78
+ },
79
+ };
80
+ };
81
+
82
+ type WithSocialShareProps = {
83
+ ios: string[];
84
+ android: string[];
85
+ };
86
+
87
+ function withSocialShare(config: ExportedConfig, props: WithSocialShareProps) {
88
+ config = withAndroidManifestService(config, props); // Android
89
+ config = withInfoPlist(config, props); // iOS
90
+ return config;
91
+ }
92
+
93
+ // eslint-disable-next-line import/no-commonjs
94
+ module.exports = createRunOncePlugin(withSocialShare, pkg.name, pkg.version);
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "build",
5
+ "rootDir": "src",
6
+ "declaration": true
7
+ },
8
+ "include": ["./src"]
9
+ }