local-translate-addon 1.0.4 → 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/index.d.ts +10 -3
- package/index.js +3 -1
- package/package.json +4 -7
package/index.d.ts
CHANGED
|
@@ -15,17 +15,19 @@ export const enum TranslateErrorCode {
|
|
|
15
15
|
* `ERR_TRANSLATE_UNSUPPORTED_OS_VERSION`,
|
|
16
16
|
* `ERR_TRANSLATE_LANGUAGE_PAIR_NOT_INSTALLED`, or `ERR_TRANSLATE_FAILED`.
|
|
17
17
|
*/
|
|
18
|
-
export declare function translateText(text: string, targetLang: string): Promise<
|
|
18
|
+
export declare function translateText(text: string, targetLang: string): Promise<string>
|
|
19
|
+
/** Check whether the current macOS version supports headless local translation. */
|
|
20
|
+
export declare function isTranslateTextSupport(): boolean
|
|
19
21
|
/**
|
|
20
22
|
* Request authorization to use speech recognition.
|
|
21
23
|
* Returns "authorized" | "denied" | "restricted" | "notDetermined".
|
|
22
24
|
*/
|
|
23
|
-
export declare function requestSpeechPermission(): Promise<
|
|
25
|
+
export declare function requestSpeechPermission(): Promise<string>
|
|
24
26
|
export interface SpeechRecognitionOptions {
|
|
25
27
|
onDeviceOnly?: boolean
|
|
26
28
|
}
|
|
27
29
|
/** Recognize speech from an audio file, optionally requiring the system's local model. */
|
|
28
|
-
export declare function recognizeSpeech(filePath: string, lang: string, options?: SpeechRecognitionOptions | undefined | null): Promise<
|
|
30
|
+
export declare function recognizeSpeech(filePath: string, lang: string, options?: SpeechRecognitionOptions | undefined | null): Promise<string>
|
|
29
31
|
export interface SpeechRecognitionCapabilities {
|
|
30
32
|
isAvailable: boolean
|
|
31
33
|
supportsOnDeviceRecognition: boolean
|
|
@@ -33,3 +35,8 @@ export interface SpeechRecognitionCapabilities {
|
|
|
33
35
|
}
|
|
34
36
|
/** Check whether the selected locale currently supports system speech recognition. */
|
|
35
37
|
export declare function getSpeechRecognitionCapabilities(lang: string): SpeechRecognitionCapabilities
|
|
38
|
+
/**
|
|
39
|
+
* Check whether `recognizeSpeech` can run for the locale and options.
|
|
40
|
+
* Authorization is not checked; use `requestSpeechPermission` for that.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isRecognizeSpeechSupport(lang: string, options?: SpeechRecognitionOptions | undefined | null): boolean
|
package/index.js
CHANGED
|
@@ -310,10 +310,12 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { TranslateErrorCode, translateText, requestSpeechPermission, recognizeSpeech, getSpeechRecognitionCapabilities } = nativeBinding
|
|
313
|
+
const { TranslateErrorCode, translateText, isTranslateTextSupport, requestSpeechPermission, recognizeSpeech, getSpeechRecognitionCapabilities, isRecognizeSpeechSupport } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.TranslateErrorCode = TranslateErrorCode
|
|
316
316
|
module.exports.translateText = translateText
|
|
317
|
+
module.exports.isTranslateTextSupport = isTranslateTextSupport
|
|
317
318
|
module.exports.requestSpeechPermission = requestSpeechPermission
|
|
318
319
|
module.exports.recognizeSpeech = recognizeSpeech
|
|
319
320
|
module.exports.getSpeechRecognitionCapabilities = getSpeechRecognitionCapabilities
|
|
321
|
+
module.exports.isRecognizeSpeechSupport = isRecognizeSpeechSupport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "local-translate-addon",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "macOS Translation.framework via napi-rs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -15,15 +15,14 @@
|
|
|
15
15
|
"prepublishOnly": "napi prepublish -t npm",
|
|
16
16
|
"universal": "napi universal",
|
|
17
17
|
"version": "napi version",
|
|
18
|
-
"test": "node --test __test__/test.mjs"
|
|
18
|
+
"test": "node --test __test__/test.mjs",
|
|
19
|
+
"build:universal": "napi build --platform --release --target aarch64-apple-darwin && napi build --platform --release --target x86_64-apple-darwin && napi universal -d ."
|
|
19
20
|
},
|
|
20
21
|
"napi": {
|
|
21
22
|
"name": "local-translate-addon",
|
|
22
23
|
"triples": {
|
|
23
24
|
"defaults": false,
|
|
24
25
|
"additional": [
|
|
25
|
-
"aarch64-apple-darwin",
|
|
26
|
-
"x86_64-apple-darwin",
|
|
27
26
|
"universal-apple-darwin"
|
|
28
27
|
]
|
|
29
28
|
}
|
|
@@ -36,8 +35,6 @@
|
|
|
36
35
|
"@napi-rs/cli": "^2.18.4"
|
|
37
36
|
},
|
|
38
37
|
"optionalDependencies": {
|
|
39
|
-
"local-translate-addon-darwin-
|
|
40
|
-
"local-translate-addon-darwin-x64": "1.0.4",
|
|
41
|
-
"local-translate-addon-darwin-universal": "1.0.4"
|
|
38
|
+
"local-translate-addon-darwin-universal": "1.1.0"
|
|
42
39
|
}
|
|
43
40
|
}
|