react-native-executorch 0.4.7 → 0.4.8
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/module/Error.js +6 -6
- package/lib/module/Error.js.map +1 -1
- package/lib/module/modules/general/ExecutorchModule.js +7 -7
- package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
- package/lib/typescript/Error.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Error.ts +6 -10
- package/src/modules/general/ExecutorchModule.ts +7 -7
package/lib/module/Error.js
CHANGED
|
@@ -8,7 +8,7 @@ export let ETError = /*#__PURE__*/function (ETError) {
|
|
|
8
8
|
ETError[ETError["ModelGenerating"] = 104] = "ModelGenerating";
|
|
9
9
|
ETError[ETError["LanguageNotSupported"] = 105] = "LanguageNotSupported";
|
|
10
10
|
ETError[ETError["InvalidModelSource"] = 255] = "InvalidModelSource";
|
|
11
|
-
//SpeechToText errors
|
|
11
|
+
// SpeechToText errors
|
|
12
12
|
ETError[ETError["MultilingualConfiguration"] = 160] = "MultilingualConfiguration";
|
|
13
13
|
ETError[ETError["MissingDataChunk"] = 161] = "MissingDataChunk";
|
|
14
14
|
ETError[ETError["StreamingNotStarted"] = 162] = "StreamingNotStarted";
|
|
@@ -38,15 +38,15 @@ export let ETError = /*#__PURE__*/function (ETError) {
|
|
|
38
38
|
}({});
|
|
39
39
|
export const getError = e => {
|
|
40
40
|
if (typeof e === 'number') {
|
|
41
|
-
|
|
42
|
-
return ETError[ETError.UndefinedError];
|
|
41
|
+
return ETError[e] ?? ETError[ETError.UndefinedError];
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
// try to extract number from message (can contain false positives)
|
|
46
45
|
const error = e;
|
|
47
46
|
const errorCode = parseInt(error.message, 10);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
if (Number.isNaN(errorCode)) {
|
|
48
|
+
return error.message;
|
|
49
|
+
}
|
|
50
|
+
return ETError[errorCode] ?? ETError[ETError.UndefinedError];
|
|
51
51
|
};
|
|
52
52
|
//# sourceMappingURL=Error.js.map
|
package/lib/module/Error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ETError","getError","e","UndefinedError","error","errorCode","parseInt","message","Number","isNaN"
|
|
1
|
+
{"version":3,"names":["ETError","getError","e","UndefinedError","error","errorCode","parseInt","message","Number","isNaN"],"sourceRoot":"../../src","sources":["Error.ts"],"mappings":";;AAAA,WAAYA,OAAO,0BAAPA,OAAO;EACjB;EADUA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EASjB;EATUA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAcjB;EACA;EACA;EAhBUA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAsBjB;EAtBUA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EA6BjB;EA7BUA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAmCjB;EAnCUA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAPA,OAAO,CAAPA,OAAO;EAAA,OAAPA,OAAO;AAAA;AAyCnB,OAAO,MAAMC,QAAQ,GAAIC,CAA4B,IAAa;EAChE,IAAI,OAAOA,CAAC,KAAK,QAAQ,EAAE;IACzB,OAAOF,OAAO,CAACE,CAAC,CAAC,IAAIF,OAAO,CAACA,OAAO,CAACG,cAAc,CAAC;EACtD;;EAEA;EACA,MAAMC,KAAK,GAAGF,CAAU;EACxB,MAAMG,SAAS,GAAGC,QAAQ,CAACF,KAAK,CAACG,OAAO,EAAE,EAAE,CAAC;EAE7C,IAAIC,MAAM,CAACC,KAAK,CAACJ,SAAS,CAAC,EAAE;IAC3B,OAAOD,KAAK,CAACG,OAAO;EACtB;EAEA,OAAOP,OAAO,CAACK,SAAS,CAAC,IAAIL,OAAO,CAACA,OAAO,CAACG,cAAc,CAAC;AAC9D,CAAC","ignoreList":[]}
|
|
@@ -13,15 +13,15 @@ export class ExecutorchModule extends BaseModule {
|
|
|
13
13
|
if (!Array.isArray(input)) {
|
|
14
14
|
input = [input];
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for (
|
|
19
|
-
|
|
20
|
-
if (
|
|
16
|
+
const inputTypeIdentifiers = [];
|
|
17
|
+
const modelInputs = [];
|
|
18
|
+
for (const subInput of input) {
|
|
19
|
+
const typeIdentifier = getTypeIdentifier(subInput);
|
|
20
|
+
if (typeIdentifier === -1) {
|
|
21
21
|
throw new Error(getError(ETError.InvalidArgument));
|
|
22
22
|
}
|
|
23
|
-
inputTypeIdentifiers.push(
|
|
24
|
-
modelInputs.push(
|
|
23
|
+
inputTypeIdentifiers.push(typeIdentifier);
|
|
24
|
+
modelInputs.push(Array.from(subInput, x => Number(x)));
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
27
|
return await this.nativeModule.forward(modelInputs, shape, inputTypeIdentifiers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ETError","getError","ETModuleNativeModule","getTypeIdentifier","BaseModule","ExecutorchModule","nativeModule","load","modelSource","forward","input","shape","Array","isArray","inputTypeIdentifiers","modelInputs","
|
|
1
|
+
{"version":3,"names":["ETError","getError","ETModuleNativeModule","getTypeIdentifier","BaseModule","ExecutorchModule","nativeModule","load","modelSource","forward","input","shape","Array","isArray","inputTypeIdentifiers","modelInputs","subInput","typeIdentifier","Error","InvalidArgument","push","from","x","Number","e","loadMethod","methodName","loadForward"],"sourceRoot":"../../../../src","sources":["modules/general/ExecutorchModule.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,aAAa;AAC/C,SAASC,oBAAoB,QAAQ,kCAAkC;AAGvE,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,UAAU,QAAQ,eAAe;AAE1C,OAAO,MAAMC,gBAAgB,SAASD,UAAU,CAAC;EAC/C,OAA0BE,YAAY,GAAGJ,oBAAoB;EAE7D,aAAsBK,IAAIA,CAACC,WAA2B,EAAE;IACtD,OAAO,MAAM,KAAK,CAACD,IAAI,CAACC,WAAW,CAAC;EACtC;EAEA,aAAsBC,OAAOA,CAACC,KAA0B,EAAEC,KAAiB,EAAE;IAC3E,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;MACzBA,KAAK,GAAG,CAACA,KAAK,CAAC;IACjB;IAEA,MAAMI,oBAA8B,GAAG,EAAE;IACzC,MAAMC,WAAuB,GAAG,EAAE;IAElC,KAAK,MAAMC,QAAQ,IAAIN,KAAK,EAAE;MAC5B,MAAMO,cAAc,GAAGd,iBAAiB,CAACa,QAAQ,CAAC;MAClD,IAAIC,cAAc,KAAK,CAAC,CAAC,EAAE;QACzB,MAAM,IAAIC,KAAK,CAACjB,QAAQ,CAACD,OAAO,CAACmB,eAAe,CAAC,CAAC;MACpD;MACAL,oBAAoB,CAACM,IAAI,CAACH,cAAc,CAAC;MACzCF,WAAW,CAACK,IAAI,CAACR,KAAK,CAACS,IAAI,CAACL,QAAQ,EAAGM,CAAkB,IAAKC,MAAM,CAACD,CAAC,CAAC,CAAC,CAAC;IAC3E;IAEA,IAAI;MACF,OAAO,MAAM,IAAI,CAAChB,YAAY,CAACG,OAAO,CACpCM,WAAW,EACXJ,KAAK,EACLG,oBACF,CAAC;IACH,CAAC,CAAC,OAAOU,CAAC,EAAE;MACV,MAAM,IAAIN,KAAK,CAACjB,QAAQ,CAACuB,CAAC,CAAC,CAAC;IAC9B;EACF;EAEA,aAAaC,UAAUA,CAACC,UAAkB,EAAE;IAC1C,IAAI;MACF,MAAM,IAAI,CAACpB,YAAY,CAACmB,UAAU,CAACC,UAAU,CAAC;IAChD,CAAC,CAAC,OAAOF,CAAC,EAAE;MACV,MAAM,IAAIN,KAAK,CAACjB,QAAQ,CAACuB,CAAC,CAAC,CAAC;IAC9B;EACF;EAEA,aAAaG,WAAWA,CAAA,EAAG;IACzB,MAAM,IAAI,CAACF,UAAU,CAAC,SAAS,CAAC;EAClC;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IAEjB,cAAc,MAAO;IACrB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,oBAAoB,MAAO;IAC3B,kBAAkB,MAAO;IAGzB,yBAAyB,MAAO;IAChC,gBAAgB,MAAO;IACvB,mBAAmB,MAAO;IAK1B,EAAE,IAAO;IACT,QAAQ,IAAO;IACf,YAAY,IAAO;IACnB,WAAW,IAAO;IAGlB,YAAY,KAAO;IACnB,cAAc,KAAO;IACrB,eAAe,KAAO;IACtB,WAAW,KAAO;IAClB,eAAe,KAAO;IAGtB,QAAQ,KAAO;IACf,sBAAsB,KAAO;IAC7B,YAAY,KAAO;IACnB,cAAc,KAAO;IAGrB,4BAA4B,KAAO;IACnC,8BAA8B,KAAO;IACrC,qBAAqB,KAAO;CAC7B;AAED,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,KAAG,
|
|
1
|
+
{"version":3,"file":"Error.d.ts","sourceRoot":"","sources":["../../src/Error.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IAEjB,cAAc,MAAO;IACrB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,eAAe,MAAO;IACtB,oBAAoB,MAAO;IAC3B,kBAAkB,MAAO;IAGzB,yBAAyB,MAAO;IAChC,gBAAgB,MAAO;IACvB,mBAAmB,MAAO;IAK1B,EAAE,IAAO;IACT,QAAQ,IAAO;IACf,YAAY,IAAO;IACnB,WAAW,IAAO;IAGlB,YAAY,KAAO;IACnB,cAAc,KAAO;IACrB,eAAe,KAAO;IACtB,WAAW,KAAO;IAClB,eAAe,KAAO;IAGtB,QAAQ,KAAO;IACf,sBAAsB,KAAO;IAC7B,YAAY,KAAO;IACnB,cAAc,KAAO;IAGrB,4BAA4B,KAAO;IACnC,8BAA8B,KAAO;IACrC,qBAAqB,KAAO;CAC7B;AAED,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,KAAG,MAcvD,CAAC"}
|
package/package.json
CHANGED
package/src/Error.ts
CHANGED
|
@@ -7,7 +7,7 @@ export enum ETError {
|
|
|
7
7
|
LanguageNotSupported = 0x69,
|
|
8
8
|
InvalidModelSource = 0xff,
|
|
9
9
|
|
|
10
|
-
//SpeechToText errors
|
|
10
|
+
// SpeechToText errors
|
|
11
11
|
MultilingualConfiguration = 0xa0,
|
|
12
12
|
MissingDataChunk = 0xa1,
|
|
13
13
|
StreamingNotStarted = 0xa2,
|
|
@@ -41,20 +41,16 @@ export enum ETError {
|
|
|
41
41
|
|
|
42
42
|
export const getError = (e: unknown | ETError | Error): string => {
|
|
43
43
|
if (typeof e === 'number') {
|
|
44
|
-
|
|
45
|
-
return ETError[ETError.UndefinedError] as string;
|
|
44
|
+
return ETError[e] ?? ETError[ETError.UndefinedError];
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
// try to extract number from message (can contain false positives)
|
|
49
48
|
const error = e as Error;
|
|
50
49
|
const errorCode = parseInt(error.message, 10);
|
|
51
|
-
const message = Number.isNaN(errorCode)
|
|
52
|
-
? error.message
|
|
53
|
-
: ' ' + error.message.slice(`${errorCode}`.length).trimStart();
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
if (Number.isNaN(errorCode)) {
|
|
52
|
+
return error.message;
|
|
53
|
+
}
|
|
58
54
|
|
|
59
|
-
return
|
|
55
|
+
return ETError[errorCode] ?? ETError[ETError.UndefinedError];
|
|
60
56
|
};
|
|
@@ -17,16 +17,16 @@ export class ExecutorchModule extends BaseModule {
|
|
|
17
17
|
input = [input];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const inputTypeIdentifiers: number[] = [];
|
|
21
|
+
const modelInputs: number[][] = [];
|
|
22
22
|
|
|
23
|
-
for (
|
|
24
|
-
|
|
25
|
-
if (
|
|
23
|
+
for (const subInput of input) {
|
|
24
|
+
const typeIdentifier = getTypeIdentifier(subInput);
|
|
25
|
+
if (typeIdentifier === -1) {
|
|
26
26
|
throw new Error(getError(ETError.InvalidArgument));
|
|
27
27
|
}
|
|
28
|
-
inputTypeIdentifiers.push(
|
|
29
|
-
modelInputs.push(
|
|
28
|
+
inputTypeIdentifiers.push(typeIdentifier);
|
|
29
|
+
modelInputs.push(Array.from(subInput, (x: number | BigInt) => Number(x)));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
try {
|