react-native-share 12.1.1 → 12.1.2

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/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": "12.1.1",
4
+ "version": "12.1.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/react-native-community/react-native-share.git"
@@ -98,7 +98,7 @@
98
98
  "start": "react-native start",
99
99
  "start:android": "react-native run-android",
100
100
  "start:ios": "react-native run-ios",
101
- "lint": "eslint \"src/**/*.{js,ts,tsx}\" --max-warnings=0",
101
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\" \"plugin/src/**/*.{js,ts,tsx}\" --max-warnings=0",
102
102
  "typescript": "tsc --noEmit",
103
103
  "build:expo-plugin": "tsc --project ./plugin/tsconfig.json",
104
104
  "validate": "yarn lint && yarn typescript",
@@ -1,4 +1,9 @@
1
1
  import { ExportedConfig } from '@expo/config-plugins';
2
+ /**
3
+ * Currently there are noway to get manifest queries config directly
4
+ * So we parse AndroidManifest.xml to get the queries packages.
5
+ */
6
+ export declare function getManifestQueriesPackagesSync(manifestPath: string): string[];
2
7
  declare const _default: (config: ExportedConfig, props: {
3
8
  enableBase64ShareAndroid?: boolean;
4
9
  android?: string[];
@@ -1,5 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getManifestQueriesPackagesSync = void 0;
27
+ const fs = __importStar(require("fs"));
3
28
  const expo_build_properties_1 = require("expo-build-properties");
4
29
  /**
5
30
  * Handles for edge case when LSApplicationQueriesSchemes is an object or undefined.
@@ -9,7 +34,41 @@ const getIOSQuerySchemes = (config) => {
9
34
  ? config.ios?.infoPlist?.LSApplicationQueriesSchemes ?? []
10
35
  : [];
11
36
  };
37
+ /**
38
+ * Currently there are noway to get manifest queries config directly
39
+ * So we parse AndroidManifest.xml to get the queries packages.
40
+ */
41
+ function getManifestQueriesPackagesSync(manifestPath) {
42
+ if (!fs.existsSync(manifestPath))
43
+ return [];
44
+ const xml = fs.readFileSync(manifestPath, 'utf8');
45
+ const queriesSection = xml.match(/<queries>[\s\S]*?<\/queries>/);
46
+ if (!queriesSection)
47
+ return [];
48
+ const matches = [...queriesSection[0].matchAll(/<package[^>]*android:name="([^"]+)"[^>]*\/>/g)];
49
+ return matches.map((m) => m[1]);
50
+ }
51
+ exports.getManifestQueriesPackagesSync = getManifestQueriesPackagesSync;
12
52
  exports.default = (config, props) => {
53
+ let manifestPath = './android/app/src/main/AndroidManifest.xml';
54
+ if (config.android?.publishManifestPath) {
55
+ manifestPath = config.android.publishManifestPath;
56
+ }
57
+ const currentManifestQueries = getManifestQueriesPackagesSync(manifestPath);
58
+ const updatedManifestQueries = (props.android ?? []).filter((p) => !currentManifestQueries.includes(p));
59
+ const propConfig = {
60
+ android: {},
61
+ };
62
+ /**
63
+ * manifestQueries.package = [] would crashes the prebuild
64
+ */
65
+ if (updatedManifestQueries.length > 0) {
66
+ propConfig.android = {
67
+ manifestQueries: {
68
+ package: updatedManifestQueries,
69
+ },
70
+ };
71
+ }
13
72
  return (0, expo_build_properties_1.withBuildProperties)({
14
73
  ...config,
15
74
  android: {
@@ -32,11 +91,5 @@ exports.default = (config, props) => {
32
91
  LSApplicationQueriesSchemes: [...getIOSQuerySchemes(config), ...(props?.ios ?? [])],
33
92
  },
34
93
  },
35
- }, {
36
- android: {
37
- manifestQueries: {
38
- package: props.android ?? [],
39
- },
40
- },
41
- });
94
+ }, propConfig);
42
95
  };
@@ -1,3 +1,5 @@
1
+ import * as fs from 'fs';
2
+
1
3
  import { ExportedConfig } from '@expo/config-plugins';
2
4
  import { withBuildProperties } from 'expo-build-properties';
3
5
 
@@ -10,6 +12,19 @@ const getIOSQuerySchemes = (config: ExportedConfig): string[] => {
10
12
  : [];
11
13
  };
12
14
 
15
+ /**
16
+ * Currently there are noway to get manifest queries config directly
17
+ * So we parse AndroidManifest.xml to get the queries packages.
18
+ */
19
+ export function getManifestQueriesPackagesSync(manifestPath: string): string[] {
20
+ if (!fs.existsSync(manifestPath)) return [];
21
+ const xml = fs.readFileSync(manifestPath, 'utf8');
22
+ const queriesSection = xml.match(/<queries>[\s\S]*?<\/queries>/);
23
+ if (!queriesSection) return [];
24
+ const matches = [...queriesSection[0].matchAll(/<package[^>]*android:name="([^"]+)"[^>]*\/>/g)];
25
+ return matches.map((m) => m[1]);
26
+ }
27
+
13
28
  export default (
14
29
  config: ExportedConfig,
15
30
  props: {
@@ -18,6 +33,30 @@ export default (
18
33
  ios?: string[];
19
34
  },
20
35
  ) => {
36
+ let manifestPath = './android/app/src/main/AndroidManifest.xml';
37
+ if (config.android?.publishManifestPath) {
38
+ manifestPath = config.android.publishManifestPath;
39
+ }
40
+ const currentManifestQueries = getManifestQueriesPackagesSync(manifestPath);
41
+ const updatedManifestQueries = (props.android ?? []).filter(
42
+ (p) => !currentManifestQueries.includes(p),
43
+ );
44
+
45
+ const propConfig = {
46
+ android: {},
47
+ };
48
+
49
+ /**
50
+ * manifestQueries.package = [] would crashes the prebuild
51
+ */
52
+ if (updatedManifestQueries.length > 0) {
53
+ propConfig.android = {
54
+ manifestQueries: {
55
+ package: updatedManifestQueries,
56
+ },
57
+ };
58
+ }
59
+
21
60
  return withBuildProperties(
22
61
  {
23
62
  ...config,
@@ -42,12 +81,6 @@ export default (
42
81
  },
43
82
  },
44
83
  },
45
- {
46
- android: {
47
- manifestQueries: {
48
- package: props.android ?? [],
49
- },
50
- },
51
- },
84
+ propConfig,
52
85
  );
53
86
  };