rn-native-wrapper 1.0.0 → 1.0.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/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +26 -1
- package/lib/utils/permissions.d.ts +52 -0
- package/lib/utils/permissions.d.ts.map +1 -0
- package/lib/utils/permissions.js +73 -0
- package/package.json +2 -1
- package/src/index.ts +15 -0
- package/src/utils/permissions.ts +92 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as RNNativeDatePicker } from './components/RNNativeDatePicker';
|
|
2
2
|
export { default } from './components/RNNativeDatePicker';
|
|
3
|
+
export { checkSpeechRecognitionPermissions, requestSpeechRecognitionPermissions, checkMicrophonePermission, requestMicrophonePermission, checkSpeechRecognizerPermission, requestSpeechRecognizerPermission, ensureSpeechRecognitionPermissions, type SpeechRecognitionPermissionResult, } from './utils/permissions';
|
|
4
|
+
export * from 'expo-speech-recognition';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAG1D,OAAO,EACL,iCAAiC,EACjC,mCAAmC,EACnC,yBAAyB,EACzB,2BAA2B,EAC3B,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EAClC,KAAK,iCAAiC,GACvC,MAAM,qBAAqB,CAAC;AAG7B,cAAc,yBAAyB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
18
|
};
|
|
5
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = exports.RNNativeDatePicker = void 0;
|
|
20
|
+
exports.ensureSpeechRecognitionPermissions = exports.requestSpeechRecognizerPermission = exports.checkSpeechRecognizerPermission = exports.requestMicrophonePermission = exports.checkMicrophonePermission = exports.requestSpeechRecognitionPermissions = exports.checkSpeechRecognitionPermissions = exports.default = exports.RNNativeDatePicker = void 0;
|
|
7
21
|
var RNNativeDatePicker_1 = require("./components/RNNativeDatePicker");
|
|
8
22
|
Object.defineProperty(exports, "RNNativeDatePicker", { enumerable: true, get: function () { return __importDefault(RNNativeDatePicker_1).default; } });
|
|
9
23
|
var RNNativeDatePicker_2 = require("./components/RNNativeDatePicker");
|
|
10
24
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(RNNativeDatePicker_2).default; } });
|
|
25
|
+
// Internal permission helpers (single place for all permission handling)
|
|
26
|
+
var permissions_1 = require("./utils/permissions");
|
|
27
|
+
Object.defineProperty(exports, "checkSpeechRecognitionPermissions", { enumerable: true, get: function () { return permissions_1.checkSpeechRecognitionPermissions; } });
|
|
28
|
+
Object.defineProperty(exports, "requestSpeechRecognitionPermissions", { enumerable: true, get: function () { return permissions_1.requestSpeechRecognitionPermissions; } });
|
|
29
|
+
Object.defineProperty(exports, "checkMicrophonePermission", { enumerable: true, get: function () { return permissions_1.checkMicrophonePermission; } });
|
|
30
|
+
Object.defineProperty(exports, "requestMicrophonePermission", { enumerable: true, get: function () { return permissions_1.requestMicrophonePermission; } });
|
|
31
|
+
Object.defineProperty(exports, "checkSpeechRecognizerPermission", { enumerable: true, get: function () { return permissions_1.checkSpeechRecognizerPermission; } });
|
|
32
|
+
Object.defineProperty(exports, "requestSpeechRecognizerPermission", { enumerable: true, get: function () { return permissions_1.requestSpeechRecognizerPermission; } });
|
|
33
|
+
Object.defineProperty(exports, "ensureSpeechRecognitionPermissions", { enumerable: true, get: function () { return permissions_1.ensureSpeechRecognitionPermissions; } });
|
|
34
|
+
// Export all from expo-speech-recognition
|
|
35
|
+
__exportStar(require("expo-speech-recognition"), exports);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Raw permission response shape from get/request APIs (expo-modules-core PermissionResponse). */
|
|
2
|
+
type PermissionResponseLike = {
|
|
3
|
+
status: string;
|
|
4
|
+
granted?: boolean;
|
|
5
|
+
canAskAgain?: boolean;
|
|
6
|
+
expires?: 'never' | number;
|
|
7
|
+
restricted?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Result of our internal permission check/request.
|
|
11
|
+
* Use this to decide whether to start speech recognition or prompt the user.
|
|
12
|
+
*/
|
|
13
|
+
export type SpeechRecognitionPermissionResult = {
|
|
14
|
+
granted: boolean;
|
|
15
|
+
canAskAgain: boolean;
|
|
16
|
+
status: 'granted' | 'denied' | 'undetermined';
|
|
17
|
+
/** Raw response from the native module (e.g. for logging or custom handling). */
|
|
18
|
+
response: PermissionResponseLike;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Checks if all permissions required for speech recognition are granted.
|
|
22
|
+
* Does not prompt the user.
|
|
23
|
+
*/
|
|
24
|
+
export declare function checkSpeechRecognitionPermissions(): Promise<SpeechRecognitionPermissionResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Requests all permissions required for speech recognition (microphone + speech recognizer).
|
|
27
|
+
* Shows the system permission dialog if not yet determined.
|
|
28
|
+
*/
|
|
29
|
+
export declare function requestSpeechRecognitionPermissions(): Promise<SpeechRecognitionPermissionResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Checks microphone permission only. Does not prompt.
|
|
32
|
+
*/
|
|
33
|
+
export declare function checkMicrophonePermission(): Promise<SpeechRecognitionPermissionResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Requests microphone permission only. Shows system dialog if needed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function requestMicrophonePermission(): Promise<SpeechRecognitionPermissionResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Checks speech recognizer permission only (iOS meaningful). Does not prompt.
|
|
40
|
+
*/
|
|
41
|
+
export declare function checkSpeechRecognizerPermission(): Promise<SpeechRecognitionPermissionResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Requests speech recognizer permission only (iOS). Shows system dialog if needed.
|
|
44
|
+
*/
|
|
45
|
+
export declare function requestSpeechRecognizerPermission(): Promise<SpeechRecognitionPermissionResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Ensures speech recognition can be used: checks first, requests if not granted.
|
|
48
|
+
* Returns whether permissions are granted after this call (so you can start recognition or show settings hint).
|
|
49
|
+
*/
|
|
50
|
+
export declare function ensureSpeechRecognitionPermissions(): Promise<SpeechRecognitionPermissionResult>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/utils/permissions.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,cAAc,CAAC;IAC9C,iFAAiF;IACjF,QAAQ,EAAE,sBAAsB,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,wBAAsB,iCAAiC,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAGpG;AAED;;;GAGG;AACH,wBAAsB,mCAAmC,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAGtG;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAG5F;AAED;;GAEG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAG9F;AAED;;GAEG;AACH,wBAAsB,+BAA+B,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAGlG;AAED;;GAEG;AACH,wBAAsB,iCAAiC,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAGpG;AAED;;;GAGG;AACH,wBAAsB,kCAAkC,IAAI,OAAO,CAAC,iCAAiC,CAAC,CAIrG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkSpeechRecognitionPermissions = checkSpeechRecognitionPermissions;
|
|
4
|
+
exports.requestSpeechRecognitionPermissions = requestSpeechRecognitionPermissions;
|
|
5
|
+
exports.checkMicrophonePermission = checkMicrophonePermission;
|
|
6
|
+
exports.requestMicrophonePermission = requestMicrophonePermission;
|
|
7
|
+
exports.checkSpeechRecognizerPermission = checkSpeechRecognizerPermission;
|
|
8
|
+
exports.requestSpeechRecognizerPermission = requestSpeechRecognizerPermission;
|
|
9
|
+
exports.ensureSpeechRecognitionPermissions = ensureSpeechRecognitionPermissions;
|
|
10
|
+
const expo_speech_recognition_1 = require("expo-speech-recognition");
|
|
11
|
+
/**
|
|
12
|
+
* Checks if all permissions required for speech recognition are granted.
|
|
13
|
+
* Does not prompt the user.
|
|
14
|
+
*/
|
|
15
|
+
async function checkSpeechRecognitionPermissions() {
|
|
16
|
+
const response = await expo_speech_recognition_1.ExpoSpeechRecognitionModule.getPermissionsAsync();
|
|
17
|
+
return toPermissionResult(response);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Requests all permissions required for speech recognition (microphone + speech recognizer).
|
|
21
|
+
* Shows the system permission dialog if not yet determined.
|
|
22
|
+
*/
|
|
23
|
+
async function requestSpeechRecognitionPermissions() {
|
|
24
|
+
const response = await expo_speech_recognition_1.ExpoSpeechRecognitionModule.requestPermissionsAsync();
|
|
25
|
+
return toPermissionResult(response);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks microphone permission only. Does not prompt.
|
|
29
|
+
*/
|
|
30
|
+
async function checkMicrophonePermission() {
|
|
31
|
+
const response = await expo_speech_recognition_1.ExpoSpeechRecognitionModule.getMicrophonePermissionsAsync();
|
|
32
|
+
return toPermissionResult(response);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Requests microphone permission only. Shows system dialog if needed.
|
|
36
|
+
*/
|
|
37
|
+
async function requestMicrophonePermission() {
|
|
38
|
+
const response = await expo_speech_recognition_1.ExpoSpeechRecognitionModule.requestMicrophonePermissionsAsync();
|
|
39
|
+
return toPermissionResult(response);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks speech recognizer permission only (iOS meaningful). Does not prompt.
|
|
43
|
+
*/
|
|
44
|
+
async function checkSpeechRecognizerPermission() {
|
|
45
|
+
const response = await expo_speech_recognition_1.ExpoSpeechRecognitionModule.getSpeechRecognizerPermissionsAsync();
|
|
46
|
+
return toPermissionResult(response);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Requests speech recognizer permission only (iOS). Shows system dialog if needed.
|
|
50
|
+
*/
|
|
51
|
+
async function requestSpeechRecognizerPermission() {
|
|
52
|
+
const response = await expo_speech_recognition_1.ExpoSpeechRecognitionModule.requestSpeechRecognizerPermissionsAsync();
|
|
53
|
+
return toPermissionResult(response);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Ensures speech recognition can be used: checks first, requests if not granted.
|
|
57
|
+
* Returns whether permissions are granted after this call (so you can start recognition or show settings hint).
|
|
58
|
+
*/
|
|
59
|
+
async function ensureSpeechRecognitionPermissions() {
|
|
60
|
+
const current = await checkSpeechRecognitionPermissions();
|
|
61
|
+
if (current.granted)
|
|
62
|
+
return current;
|
|
63
|
+
return requestSpeechRecognitionPermissions();
|
|
64
|
+
}
|
|
65
|
+
function toPermissionResult(response) {
|
|
66
|
+
const status = response.status;
|
|
67
|
+
return {
|
|
68
|
+
granted: response.granted ?? status === 'granted',
|
|
69
|
+
canAskAgain: response.canAskAgain ?? true,
|
|
70
|
+
status,
|
|
71
|
+
response,
|
|
72
|
+
};
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rn-native-wrapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "React Native wrapper for native date picker component",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"clean": "rm -rf lib"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"expo-speech-recognition": "^3.1.0",
|
|
35
36
|
"react-native-date-picker": "^5.0.13"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
export { default as RNNativeDatePicker } from './components/RNNativeDatePicker';
|
|
2
2
|
export { default } from './components/RNNativeDatePicker';
|
|
3
|
+
|
|
4
|
+
// Internal permission helpers (single place for all permission handling)
|
|
5
|
+
export {
|
|
6
|
+
checkSpeechRecognitionPermissions,
|
|
7
|
+
requestSpeechRecognitionPermissions,
|
|
8
|
+
checkMicrophonePermission,
|
|
9
|
+
requestMicrophonePermission,
|
|
10
|
+
checkSpeechRecognizerPermission,
|
|
11
|
+
requestSpeechRecognizerPermission,
|
|
12
|
+
ensureSpeechRecognitionPermissions,
|
|
13
|
+
type SpeechRecognitionPermissionResult,
|
|
14
|
+
} from './utils/permissions';
|
|
15
|
+
|
|
16
|
+
// Export all from expo-speech-recognition
|
|
17
|
+
export * from 'expo-speech-recognition';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ExpoSpeechRecognitionModule } from 'expo-speech-recognition';
|
|
2
|
+
|
|
3
|
+
/** Raw permission response shape from get/request APIs (expo-modules-core PermissionResponse). */
|
|
4
|
+
type PermissionResponseLike = {
|
|
5
|
+
status: string;
|
|
6
|
+
granted?: boolean;
|
|
7
|
+
canAskAgain?: boolean;
|
|
8
|
+
expires?: 'never' | number;
|
|
9
|
+
restricted?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Result of our internal permission check/request.
|
|
14
|
+
* Use this to decide whether to start speech recognition or prompt the user.
|
|
15
|
+
*/
|
|
16
|
+
export type SpeechRecognitionPermissionResult = {
|
|
17
|
+
granted: boolean;
|
|
18
|
+
canAskAgain: boolean;
|
|
19
|
+
status: 'granted' | 'denied' | 'undetermined';
|
|
20
|
+
/** Raw response from the native module (e.g. for logging or custom handling). */
|
|
21
|
+
response: PermissionResponseLike;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks if all permissions required for speech recognition are granted.
|
|
26
|
+
* Does not prompt the user.
|
|
27
|
+
*/
|
|
28
|
+
export async function checkSpeechRecognitionPermissions(): Promise<SpeechRecognitionPermissionResult> {
|
|
29
|
+
const response = await ExpoSpeechRecognitionModule.getPermissionsAsync();
|
|
30
|
+
return toPermissionResult(response);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Requests all permissions required for speech recognition (microphone + speech recognizer).
|
|
35
|
+
* Shows the system permission dialog if not yet determined.
|
|
36
|
+
*/
|
|
37
|
+
export async function requestSpeechRecognitionPermissions(): Promise<SpeechRecognitionPermissionResult> {
|
|
38
|
+
const response = await ExpoSpeechRecognitionModule.requestPermissionsAsync();
|
|
39
|
+
return toPermissionResult(response);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Checks microphone permission only. Does not prompt.
|
|
44
|
+
*/
|
|
45
|
+
export async function checkMicrophonePermission(): Promise<SpeechRecognitionPermissionResult> {
|
|
46
|
+
const response = await ExpoSpeechRecognitionModule.getMicrophonePermissionsAsync();
|
|
47
|
+
return toPermissionResult(response);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Requests microphone permission only. Shows system dialog if needed.
|
|
52
|
+
*/
|
|
53
|
+
export async function requestMicrophonePermission(): Promise<SpeechRecognitionPermissionResult> {
|
|
54
|
+
const response = await ExpoSpeechRecognitionModule.requestMicrophonePermissionsAsync();
|
|
55
|
+
return toPermissionResult(response);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Checks speech recognizer permission only (iOS meaningful). Does not prompt.
|
|
60
|
+
*/
|
|
61
|
+
export async function checkSpeechRecognizerPermission(): Promise<SpeechRecognitionPermissionResult> {
|
|
62
|
+
const response = await ExpoSpeechRecognitionModule.getSpeechRecognizerPermissionsAsync();
|
|
63
|
+
return toPermissionResult(response);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Requests speech recognizer permission only (iOS). Shows system dialog if needed.
|
|
68
|
+
*/
|
|
69
|
+
export async function requestSpeechRecognizerPermission(): Promise<SpeechRecognitionPermissionResult> {
|
|
70
|
+
const response = await ExpoSpeechRecognitionModule.requestSpeechRecognizerPermissionsAsync();
|
|
71
|
+
return toPermissionResult(response);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Ensures speech recognition can be used: checks first, requests if not granted.
|
|
76
|
+
* Returns whether permissions are granted after this call (so you can start recognition or show settings hint).
|
|
77
|
+
*/
|
|
78
|
+
export async function ensureSpeechRecognitionPermissions(): Promise<SpeechRecognitionPermissionResult> {
|
|
79
|
+
const current = await checkSpeechRecognitionPermissions();
|
|
80
|
+
if (current.granted) return current;
|
|
81
|
+
return requestSpeechRecognitionPermissions();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function toPermissionResult(response: PermissionResponseLike): SpeechRecognitionPermissionResult {
|
|
85
|
+
const status = response.status as 'granted' | 'denied' | 'undetermined';
|
|
86
|
+
return {
|
|
87
|
+
granted: response.granted ?? status === 'granted',
|
|
88
|
+
canAskAgain: response.canAskAgain ?? true,
|
|
89
|
+
status,
|
|
90
|
+
response,
|
|
91
|
+
};
|
|
92
|
+
}
|