expo-speech-recognition 0.2.21 → 0.2.22

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 jamsch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -58,23 +58,29 @@ npm install expo-speech-recognition
58
58
 
59
59
  > The config plugin updates the Android App Manifest to include package visibility filtering for `com.google.android.googlequicksearchbox` (Google's Speech Recognition) along with the required permissions for Android and iOS.
60
60
 
61
+ To configure `androidSpeechServicePackages`, add additional speech service packages here that aren't listed under the `forceQueryable` section when running the command: `adb shell dumpsys package queries`.
62
+
61
63
  ```js
62
64
  // app.json
63
65
  {
64
66
  "expo": {
65
67
  "plugins": [
68
+ "plugin-one",
69
+ "plugin-two",
70
+
71
+ // no config (v0.2.22+)
72
+ "expo-speech-recognition",
73
+
74
+ // or with config
66
75
  [
67
76
  "expo-speech-recognition",
68
77
  {
69
78
  "microphonePermission": "Allow $(PRODUCT_NAME) to use the microphone.",
70
79
  "speechRecognitionPermission": "Allow $(PRODUCT_NAME) to use speech recognition.",
71
- // Add additional speech service packages here that aren't listed
72
- // under the `forceQueryable` section when running the command:
73
- // "adb shell dumpsys package queries"
74
- // default: ["com.google.android.googlequicksearchbox"]
75
80
  "androidSpeechServicePackages": ["com.google.android.googlequicksearchbox"]
76
81
  }
77
82
  ]
83
+ // rest of your plugins
78
84
  ]
79
85
  }
80
86
  }
package/app.plugin.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  const {
2
3
  withAndroidManifest,
3
4
  AndroidConfig,
@@ -6,7 +7,7 @@ const {
6
7
  } = require("expo/config-plugins");
7
8
 
8
9
  /**
9
- * @type {import("expo/config-plugins").ConfigPlugin<{ packages: string[] }>}
10
+ * @type {import("expo/config-plugins").ConfigPlugin<{ packages?: string[] }>}
10
11
  */
11
12
  const withAndroidPackageVisibilityFiltering = (config, { packages = [] }) => {
12
13
  return withAndroidManifest(config, (config) => {
@@ -35,22 +36,27 @@ const withAndroidPackageVisibilityFiltering = (config, { packages = [] }) => {
35
36
  </intent>
36
37
  </queries>
37
38
  */
38
- allPackages.forEach((pkg) => {
39
+
40
+ for (const pkg of allPackages) {
39
41
  if (
40
42
  !config.modResults.manifest.queries.some(
41
43
  (query) => query.package?.[0]?.$?.["android:name"] === pkg,
42
44
  )
43
45
  ) {
44
46
  config.modResults.manifest.queries.push({
45
- package: { $: { "android:name": pkg } },
46
- intent: {
47
- action: {
48
- $: { "android:name": "android.speech.RecognitionService" },
47
+ package: [{ $: { "android:name": pkg } }],
48
+ intent: [
49
+ {
50
+ action: [
51
+ {
52
+ $: { "android:name": "android.speech.RecognitionService" },
53
+ },
54
+ ],
49
55
  },
50
- },
56
+ ],
51
57
  });
52
58
  }
53
- });
59
+ }
54
60
 
55
61
  return config;
56
62
  });
@@ -61,7 +67,7 @@ const withAndroidPackageVisibilityFiltering = (config, { packages = [] }) => {
61
67
  * microphonePermission?: string;
62
68
  * speechRecognitionPermission?: string;
63
69
  * androidSpeechServicePackages?: string[];
64
- * }>}
70
+ * }|undefined>}
65
71
  */
66
72
  const withExpoSpeechRecognition = (config, props) => {
67
73
  if (!config.ios) {
@@ -73,12 +79,12 @@ const withExpoSpeechRecognition = (config, props) => {
73
79
  }
74
80
 
75
81
  config.ios.infoPlist.NSSpeechRecognitionUsageDescription =
76
- props.speechRecognitionPermission ||
82
+ props?.speechRecognitionPermission ||
77
83
  config.ios.infoPlist.NSSpeechRecognitionUsageDescription ||
78
84
  "Allow $(PRODUCT_NAME) to use speech recognition.";
79
85
 
80
86
  config.ios.infoPlist.NSMicrophoneUsageDescription =
81
- props.microphonePermission ||
87
+ props?.microphonePermission ||
82
88
  config.ios.infoPlist.NSMicrophoneUsageDescription ||
83
89
  "Allow $(PRODUCT_NAME) to use the microphone.";
84
90
 
@@ -92,7 +98,7 @@ const withExpoSpeechRecognition = (config, props) => {
92
98
  [
93
99
  withAndroidPackageVisibilityFiltering,
94
100
  {
95
- packages: props.androidSpeechServicePackages,
101
+ packages: props?.androidSpeechServicePackages,
96
102
  },
97
103
  ],
98
104
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-speech-recognition",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "Speech Recognition for React Native Expo projects",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",