local-translate-addon 1.0.3 → 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.
Files changed (3) hide show
  1. package/index.d.ts +37 -1
  2. package/index.js +7 -1
  3. package/package.json +4 -7
package/index.d.ts CHANGED
@@ -3,4 +3,40 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- export declare function translateText(text: string, targetLang: string): Promise<unknown>
6
+ export const enum TranslateErrorCode {
7
+ UNSUPPORT_OS_VERSION = 'ERR_TRANSLATE_UNSUPPORTED_OS_VERSION',
8
+ LANGUAGE_PAIR_NOT_INSTALLED = 'ERR_TRANSLATE_LANGUAGE_PAIR_NOT_INSTALLED',
9
+ FAILED = 'ERR_TRANSLATE_FAILED'
10
+ }
11
+ /**
12
+ * Translate text with the system's installed language models.
13
+ *
14
+ * Rejects with an Error whose code is one of:
15
+ * `ERR_TRANSLATE_UNSUPPORTED_OS_VERSION`,
16
+ * `ERR_TRANSLATE_LANGUAGE_PAIR_NOT_INSTALLED`, or `ERR_TRANSLATE_FAILED`.
17
+ */
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
21
+ /**
22
+ * Request authorization to use speech recognition.
23
+ * Returns "authorized" | "denied" | "restricted" | "notDetermined".
24
+ */
25
+ export declare function requestSpeechPermission(): Promise<string>
26
+ export interface SpeechRecognitionOptions {
27
+ onDeviceOnly?: boolean
28
+ }
29
+ /** Recognize speech from an audio file, optionally requiring the system's local model. */
30
+ export declare function recognizeSpeech(filePath: string, lang: string, options?: SpeechRecognitionOptions | undefined | null): Promise<string>
31
+ export interface SpeechRecognitionCapabilities {
32
+ isAvailable: boolean
33
+ supportsOnDeviceRecognition: boolean
34
+ isAuthorized: boolean
35
+ }
36
+ /** Check whether the selected locale currently supports system speech recognition. */
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,6 +310,12 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { translateText } = nativeBinding
313
+ const { TranslateErrorCode, translateText, isTranslateTextSupport, requestSpeechPermission, recognizeSpeech, getSpeechRecognitionCapabilities, isRecognizeSpeechSupport } = nativeBinding
314
314
 
315
+ module.exports.TranslateErrorCode = TranslateErrorCode
315
316
  module.exports.translateText = translateText
317
+ module.exports.isTranslateTextSupport = isTranslateTextSupport
318
+ module.exports.requestSpeechPermission = requestSpeechPermission
319
+ module.exports.recognizeSpeech = recognizeSpeech
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",
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-arm64": "1.0.3",
40
- "local-translate-addon-darwin-x64": "1.0.3",
41
- "local-translate-addon-darwin-universal": "1.0.3"
38
+ "local-translate-addon-darwin-universal": "1.1.0"
42
39
  }
43
40
  }