react-native-executorch 0.5.8 → 0.5.9
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/hooks/general/useExecutorchModule.js +1 -3
- package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/general/useExecutorchModule.ts +1 -1
- package/lib/Error.js +0 -53
- package/lib/ThreadPool.d.ts +0 -10
- package/lib/ThreadPool.js +0 -28
- package/lib/common/Logger.d.ts +0 -8
- package/lib/common/Logger.js +0 -19
- package/lib/constants/directories.js +0 -2
- package/lib/constants/llmDefaults.d.ts +0 -6
- package/lib/constants/llmDefaults.js +0 -16
- package/lib/constants/modelUrls.d.ts +0 -223
- package/lib/constants/modelUrls.js +0 -322
- package/lib/constants/ocr/models.d.ts +0 -882
- package/lib/constants/ocr/models.js +0 -182
- package/lib/constants/ocr/symbols.js +0 -139
- package/lib/constants/sttDefaults.d.ts +0 -28
- package/lib/constants/sttDefaults.js +0 -68
- package/lib/controllers/LLMController.d.ts +0 -47
- package/lib/controllers/LLMController.js +0 -213
- package/lib/controllers/OCRController.js +0 -67
- package/lib/controllers/SpeechToTextController.d.ts +0 -56
- package/lib/controllers/SpeechToTextController.js +0 -349
- package/lib/controllers/VerticalOCRController.js +0 -70
- package/lib/hooks/computer_vision/useClassification.d.ts +0 -15
- package/lib/hooks/computer_vision/useClassification.js +0 -7
- package/lib/hooks/computer_vision/useImageEmbeddings.d.ts +0 -15
- package/lib/hooks/computer_vision/useImageEmbeddings.js +0 -7
- package/lib/hooks/computer_vision/useImageSegmentation.d.ts +0 -38
- package/lib/hooks/computer_vision/useImageSegmentation.js +0 -7
- package/lib/hooks/computer_vision/useOCR.d.ts +0 -20
- package/lib/hooks/computer_vision/useOCR.js +0 -41
- package/lib/hooks/computer_vision/useObjectDetection.d.ts +0 -15
- package/lib/hooks/computer_vision/useObjectDetection.js +0 -7
- package/lib/hooks/computer_vision/useStyleTransfer.d.ts +0 -15
- package/lib/hooks/computer_vision/useStyleTransfer.js +0 -7
- package/lib/hooks/computer_vision/useVerticalOCR.d.ts +0 -21
- package/lib/hooks/computer_vision/useVerticalOCR.js +0 -43
- package/lib/hooks/general/useExecutorchModule.d.ts +0 -13
- package/lib/hooks/general/useExecutorchModule.js +0 -7
- package/lib/hooks/natural_language_processing/useLLM.d.ts +0 -10
- package/lib/hooks/natural_language_processing/useLLM.js +0 -78
- package/lib/hooks/natural_language_processing/useSpeechToText.d.ts +0 -27
- package/lib/hooks/natural_language_processing/useSpeechToText.js +0 -49
- package/lib/hooks/natural_language_processing/useTextEmbeddings.d.ts +0 -16
- package/lib/hooks/natural_language_processing/useTextEmbeddings.js +0 -7
- package/lib/hooks/natural_language_processing/useTokenizer.d.ts +0 -17
- package/lib/hooks/natural_language_processing/useTokenizer.js +0 -52
- package/lib/hooks/useModule.js +0 -45
- package/lib/hooks/useNonStaticModule.d.ts +0 -20
- package/lib/hooks/useNonStaticModule.js +0 -49
- package/lib/index.d.ts +0 -48
- package/lib/index.js +0 -58
- package/lib/modules/BaseModule.js +0 -25
- package/lib/modules/BaseNonStaticModule.js +0 -14
- package/lib/modules/computer_vision/ClassificationModule.d.ts +0 -8
- package/lib/modules/computer_vision/ClassificationModule.js +0 -17
- package/lib/modules/computer_vision/ImageEmbeddingsModule.d.ts +0 -8
- package/lib/modules/computer_vision/ImageEmbeddingsModule.js +0 -17
- package/lib/modules/computer_vision/ImageSegmentationModule.d.ts +0 -11
- package/lib/modules/computer_vision/ImageSegmentationModule.js +0 -27
- package/lib/modules/computer_vision/OCRModule.d.ts +0 -14
- package/lib/modules/computer_vision/OCRModule.js +0 -17
- package/lib/modules/computer_vision/ObjectDetectionModule.d.ts +0 -9
- package/lib/modules/computer_vision/ObjectDetectionModule.js +0 -17
- package/lib/modules/computer_vision/StyleTransferModule.d.ts +0 -8
- package/lib/modules/computer_vision/StyleTransferModule.js +0 -17
- package/lib/modules/computer_vision/VerticalOCRModule.d.ts +0 -14
- package/lib/modules/computer_vision/VerticalOCRModule.js +0 -19
- package/lib/modules/general/ExecutorchModule.d.ts +0 -7
- package/lib/modules/general/ExecutorchModule.js +0 -14
- package/lib/modules/natural_language_processing/LLMModule.d.ts +0 -28
- package/lib/modules/natural_language_processing/LLMModule.js +0 -45
- package/lib/modules/natural_language_processing/SpeechToTextModule.d.ts +0 -24
- package/lib/modules/natural_language_processing/SpeechToTextModule.js +0 -36
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.d.ts +0 -9
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.js +0 -21
- package/lib/modules/natural_language_processing/TokenizerModule.d.ts +0 -12
- package/lib/modules/natural_language_processing/TokenizerModule.js +0 -30
- package/lib/native/NativeETInstaller.js +0 -2
- package/lib/native/NativeOCR.js +0 -2
- package/lib/native/NativeVerticalOCR.js +0 -2
- package/lib/native/RnExecutorchModules.d.ts +0 -7
- package/lib/native/RnExecutorchModules.js +0 -18
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/common.d.ts +0 -32
- package/lib/types/common.js +0 -25
- package/lib/types/imageSegmentation.js +0 -26
- package/lib/types/llm.d.ts +0 -46
- package/lib/types/llm.js +0 -9
- package/lib/types/objectDetection.js +0 -94
- package/lib/types/ocr.js +0 -1
- package/lib/types/stt.d.ts +0 -94
- package/lib/types/stt.js +0 -85
- package/lib/utils/ResourceFetcher.d.ts +0 -24
- package/lib/utils/ResourceFetcher.js +0 -305
- package/lib/utils/ResourceFetcherUtils.d.ts +0 -54
- package/lib/utils/ResourceFetcherUtils.js +0 -127
- package/lib/utils/llm.d.ts +0 -6
- package/lib/utils/llm.js +0 -72
- package/lib/utils/stt.js +0 -21
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
var CocoLabel;
|
|
2
|
-
(function (CocoLabel) {
|
|
3
|
-
CocoLabel[CocoLabel["PERSON"] = 1] = "PERSON";
|
|
4
|
-
CocoLabel[CocoLabel["BICYCLE"] = 2] = "BICYCLE";
|
|
5
|
-
CocoLabel[CocoLabel["CAR"] = 3] = "CAR";
|
|
6
|
-
CocoLabel[CocoLabel["MOTORCYCLE"] = 4] = "MOTORCYCLE";
|
|
7
|
-
CocoLabel[CocoLabel["AIRPLANE"] = 5] = "AIRPLANE";
|
|
8
|
-
CocoLabel[CocoLabel["BUS"] = 6] = "BUS";
|
|
9
|
-
CocoLabel[CocoLabel["TRAIN"] = 7] = "TRAIN";
|
|
10
|
-
CocoLabel[CocoLabel["TRUCK"] = 8] = "TRUCK";
|
|
11
|
-
CocoLabel[CocoLabel["BOAT"] = 9] = "BOAT";
|
|
12
|
-
CocoLabel[CocoLabel["TRAFFIC_LIGHT"] = 10] = "TRAFFIC_LIGHT";
|
|
13
|
-
CocoLabel[CocoLabel["FIRE_HYDRANT"] = 11] = "FIRE_HYDRANT";
|
|
14
|
-
CocoLabel[CocoLabel["STREET_SIGN"] = 12] = "STREET_SIGN";
|
|
15
|
-
CocoLabel[CocoLabel["STOP_SIGN"] = 13] = "STOP_SIGN";
|
|
16
|
-
CocoLabel[CocoLabel["PARKING"] = 14] = "PARKING";
|
|
17
|
-
CocoLabel[CocoLabel["BENCH"] = 15] = "BENCH";
|
|
18
|
-
CocoLabel[CocoLabel["BIRD"] = 16] = "BIRD";
|
|
19
|
-
CocoLabel[CocoLabel["CAT"] = 17] = "CAT";
|
|
20
|
-
CocoLabel[CocoLabel["DOG"] = 18] = "DOG";
|
|
21
|
-
CocoLabel[CocoLabel["HORSE"] = 19] = "HORSE";
|
|
22
|
-
CocoLabel[CocoLabel["SHEEP"] = 20] = "SHEEP";
|
|
23
|
-
CocoLabel[CocoLabel["COW"] = 21] = "COW";
|
|
24
|
-
CocoLabel[CocoLabel["ELEPHANT"] = 22] = "ELEPHANT";
|
|
25
|
-
CocoLabel[CocoLabel["BEAR"] = 23] = "BEAR";
|
|
26
|
-
CocoLabel[CocoLabel["ZEBRA"] = 24] = "ZEBRA";
|
|
27
|
-
CocoLabel[CocoLabel["GIRAFFE"] = 25] = "GIRAFFE";
|
|
28
|
-
CocoLabel[CocoLabel["HAT"] = 26] = "HAT";
|
|
29
|
-
CocoLabel[CocoLabel["BACKPACK"] = 27] = "BACKPACK";
|
|
30
|
-
CocoLabel[CocoLabel["UMBRELLA"] = 28] = "UMBRELLA";
|
|
31
|
-
CocoLabel[CocoLabel["SHOE"] = 29] = "SHOE";
|
|
32
|
-
CocoLabel[CocoLabel["EYE"] = 30] = "EYE";
|
|
33
|
-
CocoLabel[CocoLabel["HANDBAG"] = 31] = "HANDBAG";
|
|
34
|
-
CocoLabel[CocoLabel["TIE"] = 32] = "TIE";
|
|
35
|
-
CocoLabel[CocoLabel["SUITCASE"] = 33] = "SUITCASE";
|
|
36
|
-
CocoLabel[CocoLabel["FRISBEE"] = 34] = "FRISBEE";
|
|
37
|
-
CocoLabel[CocoLabel["SKIS"] = 35] = "SKIS";
|
|
38
|
-
CocoLabel[CocoLabel["SNOWBOARD"] = 36] = "SNOWBOARD";
|
|
39
|
-
CocoLabel[CocoLabel["SPORTS"] = 37] = "SPORTS";
|
|
40
|
-
CocoLabel[CocoLabel["KITE"] = 38] = "KITE";
|
|
41
|
-
CocoLabel[CocoLabel["BASEBALL"] = 39] = "BASEBALL";
|
|
42
|
-
CocoLabel[CocoLabel["SKATEBOARD"] = 41] = "SKATEBOARD";
|
|
43
|
-
CocoLabel[CocoLabel["SURFBOARD"] = 42] = "SURFBOARD";
|
|
44
|
-
CocoLabel[CocoLabel["TENNIS_RACKET"] = 43] = "TENNIS_RACKET";
|
|
45
|
-
CocoLabel[CocoLabel["BOTTLE"] = 44] = "BOTTLE";
|
|
46
|
-
CocoLabel[CocoLabel["PLATE"] = 45] = "PLATE";
|
|
47
|
-
CocoLabel[CocoLabel["WINE_GLASS"] = 46] = "WINE_GLASS";
|
|
48
|
-
CocoLabel[CocoLabel["CUP"] = 47] = "CUP";
|
|
49
|
-
CocoLabel[CocoLabel["FORK"] = 48] = "FORK";
|
|
50
|
-
CocoLabel[CocoLabel["KNIFE"] = 49] = "KNIFE";
|
|
51
|
-
CocoLabel[CocoLabel["SPOON"] = 50] = "SPOON";
|
|
52
|
-
CocoLabel[CocoLabel["BOWL"] = 51] = "BOWL";
|
|
53
|
-
CocoLabel[CocoLabel["BANANA"] = 52] = "BANANA";
|
|
54
|
-
CocoLabel[CocoLabel["APPLE"] = 53] = "APPLE";
|
|
55
|
-
CocoLabel[CocoLabel["SANDWICH"] = 54] = "SANDWICH";
|
|
56
|
-
CocoLabel[CocoLabel["ORANGE"] = 55] = "ORANGE";
|
|
57
|
-
CocoLabel[CocoLabel["BROCCOLI"] = 56] = "BROCCOLI";
|
|
58
|
-
CocoLabel[CocoLabel["CARROT"] = 57] = "CARROT";
|
|
59
|
-
CocoLabel[CocoLabel["HOT_DOG"] = 58] = "HOT_DOG";
|
|
60
|
-
CocoLabel[CocoLabel["PIZZA"] = 59] = "PIZZA";
|
|
61
|
-
CocoLabel[CocoLabel["DONUT"] = 60] = "DONUT";
|
|
62
|
-
CocoLabel[CocoLabel["CAKE"] = 61] = "CAKE";
|
|
63
|
-
CocoLabel[CocoLabel["CHAIR"] = 62] = "CHAIR";
|
|
64
|
-
CocoLabel[CocoLabel["COUCH"] = 63] = "COUCH";
|
|
65
|
-
CocoLabel[CocoLabel["POTTED_PLANT"] = 64] = "POTTED_PLANT";
|
|
66
|
-
CocoLabel[CocoLabel["BED"] = 65] = "BED";
|
|
67
|
-
CocoLabel[CocoLabel["MIRROR"] = 66] = "MIRROR";
|
|
68
|
-
CocoLabel[CocoLabel["DINING_TABLE"] = 67] = "DINING_TABLE";
|
|
69
|
-
CocoLabel[CocoLabel["WINDOW"] = 68] = "WINDOW";
|
|
70
|
-
CocoLabel[CocoLabel["DESK"] = 69] = "DESK";
|
|
71
|
-
CocoLabel[CocoLabel["TOILET"] = 70] = "TOILET";
|
|
72
|
-
CocoLabel[CocoLabel["DOOR"] = 71] = "DOOR";
|
|
73
|
-
CocoLabel[CocoLabel["TV"] = 72] = "TV";
|
|
74
|
-
CocoLabel[CocoLabel["LAPTOP"] = 73] = "LAPTOP";
|
|
75
|
-
CocoLabel[CocoLabel["MOUSE"] = 74] = "MOUSE";
|
|
76
|
-
CocoLabel[CocoLabel["REMOTE"] = 75] = "REMOTE";
|
|
77
|
-
CocoLabel[CocoLabel["KEYBOARD"] = 76] = "KEYBOARD";
|
|
78
|
-
CocoLabel[CocoLabel["CELL_PHONE"] = 77] = "CELL_PHONE";
|
|
79
|
-
CocoLabel[CocoLabel["MICROWAVE"] = 78] = "MICROWAVE";
|
|
80
|
-
CocoLabel[CocoLabel["OVEN"] = 79] = "OVEN";
|
|
81
|
-
CocoLabel[CocoLabel["TOASTER"] = 80] = "TOASTER";
|
|
82
|
-
CocoLabel[CocoLabel["SINK"] = 81] = "SINK";
|
|
83
|
-
CocoLabel[CocoLabel["REFRIGERATOR"] = 82] = "REFRIGERATOR";
|
|
84
|
-
CocoLabel[CocoLabel["BLENDER"] = 83] = "BLENDER";
|
|
85
|
-
CocoLabel[CocoLabel["BOOK"] = 84] = "BOOK";
|
|
86
|
-
CocoLabel[CocoLabel["CLOCK"] = 85] = "CLOCK";
|
|
87
|
-
CocoLabel[CocoLabel["VASE"] = 86] = "VASE";
|
|
88
|
-
CocoLabel[CocoLabel["SCISSORS"] = 87] = "SCISSORS";
|
|
89
|
-
CocoLabel[CocoLabel["TEDDY_BEAR"] = 88] = "TEDDY_BEAR";
|
|
90
|
-
CocoLabel[CocoLabel["HAIR_DRIER"] = 89] = "HAIR_DRIER";
|
|
91
|
-
CocoLabel[CocoLabel["TOOTHBRUSH"] = 90] = "TOOTHBRUSH";
|
|
92
|
-
CocoLabel[CocoLabel["HAIR_BRUSH"] = 91] = "HAIR_BRUSH";
|
|
93
|
-
})(CocoLabel || (CocoLabel = {}));
|
|
94
|
-
export {};
|
package/lib/types/ocr.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/types/stt.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
export interface ModelConfig {
|
|
2
|
-
sources: {
|
|
3
|
-
encoder: string;
|
|
4
|
-
decoder: string;
|
|
5
|
-
};
|
|
6
|
-
tokenizer: {
|
|
7
|
-
source: string;
|
|
8
|
-
bos: number;
|
|
9
|
-
eos: number;
|
|
10
|
-
};
|
|
11
|
-
isMultilingual: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare enum SpeechToTextLanguage {
|
|
14
|
-
Afrikaans = "af",
|
|
15
|
-
Albanian = "sq",
|
|
16
|
-
Arabic = "ar",
|
|
17
|
-
Armenian = "hy",
|
|
18
|
-
Azerbaijani = "az",
|
|
19
|
-
Basque = "eu",
|
|
20
|
-
Belarusian = "be",
|
|
21
|
-
Bengali = "bn",
|
|
22
|
-
Bosnian = "bs",
|
|
23
|
-
Bulgarian = "bg",
|
|
24
|
-
Burmese = "my",
|
|
25
|
-
Catalan = "ca",
|
|
26
|
-
Chinese = "zh",
|
|
27
|
-
Croatian = "hr",
|
|
28
|
-
Czech = "cs",
|
|
29
|
-
Danish = "da",
|
|
30
|
-
Dutch = "nl",
|
|
31
|
-
Estonian = "et",
|
|
32
|
-
English = "en",
|
|
33
|
-
Finnish = "fi",
|
|
34
|
-
French = "fr",
|
|
35
|
-
Galician = "gl",
|
|
36
|
-
Georgian = "ka",
|
|
37
|
-
German = "de",
|
|
38
|
-
Greek = "el",
|
|
39
|
-
Gujarati = "gu",
|
|
40
|
-
HaitianCreole = "ht",
|
|
41
|
-
Hebrew = "he",
|
|
42
|
-
Hindi = "hi",
|
|
43
|
-
Hungarian = "hu",
|
|
44
|
-
Icelandic = "is",
|
|
45
|
-
Indonesian = "id",
|
|
46
|
-
Italian = "it",
|
|
47
|
-
Japanese = "ja",
|
|
48
|
-
Kannada = "kn",
|
|
49
|
-
Kazakh = "kk",
|
|
50
|
-
Khmer = "km",
|
|
51
|
-
Korean = "ko",
|
|
52
|
-
Lao = "lo",
|
|
53
|
-
Latvian = "lv",
|
|
54
|
-
Lithuanian = "lt",
|
|
55
|
-
Macedonian = "mk",
|
|
56
|
-
Malagasy = "mg",
|
|
57
|
-
Malay = "ms",
|
|
58
|
-
Malayalam = "ml",
|
|
59
|
-
Maltese = "mt",
|
|
60
|
-
Marathi = "mr",
|
|
61
|
-
Nepali = "ne",
|
|
62
|
-
Norwegian = "no",
|
|
63
|
-
Persian = "fa",
|
|
64
|
-
Polish = "pl",
|
|
65
|
-
Portuguese = "pt",
|
|
66
|
-
Punjabi = "pa",
|
|
67
|
-
Romanian = "ro",
|
|
68
|
-
Russian = "ru",
|
|
69
|
-
Serbian = "sr",
|
|
70
|
-
Sinhala = "si",
|
|
71
|
-
Slovak = "sk",
|
|
72
|
-
Slovenian = "sl",
|
|
73
|
-
Spanish = "es",
|
|
74
|
-
Sundanese = "su",
|
|
75
|
-
Swahili = "sw",
|
|
76
|
-
Swedish = "sv",
|
|
77
|
-
Tagalog = "tl",
|
|
78
|
-
Tajik = "tg",
|
|
79
|
-
Tamil = "ta",
|
|
80
|
-
Telugu = "te",
|
|
81
|
-
Thai = "th",
|
|
82
|
-
Turkish = "tr",
|
|
83
|
-
Ukrainian = "uk",
|
|
84
|
-
Urdu = "ur",
|
|
85
|
-
Uzbek = "uz",
|
|
86
|
-
Vietnamese = "vi",
|
|
87
|
-
Welsh = "cy",
|
|
88
|
-
Yiddish = "yi"
|
|
89
|
-
}
|
|
90
|
-
export declare enum AvailableModels {
|
|
91
|
-
WHISPER = "whisper",
|
|
92
|
-
MOONSHINE = "moonshine",
|
|
93
|
-
WHISPER_MULTILINGUAL = "whisperMultilingual"
|
|
94
|
-
}
|
package/lib/types/stt.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// Those languages are supported just by whisper multilingual
|
|
2
|
-
export var SpeechToTextLanguage;
|
|
3
|
-
(function (SpeechToTextLanguage) {
|
|
4
|
-
SpeechToTextLanguage["Afrikaans"] = "af";
|
|
5
|
-
SpeechToTextLanguage["Albanian"] = "sq";
|
|
6
|
-
SpeechToTextLanguage["Arabic"] = "ar";
|
|
7
|
-
SpeechToTextLanguage["Armenian"] = "hy";
|
|
8
|
-
SpeechToTextLanguage["Azerbaijani"] = "az";
|
|
9
|
-
SpeechToTextLanguage["Basque"] = "eu";
|
|
10
|
-
SpeechToTextLanguage["Belarusian"] = "be";
|
|
11
|
-
SpeechToTextLanguage["Bengali"] = "bn";
|
|
12
|
-
SpeechToTextLanguage["Bosnian"] = "bs";
|
|
13
|
-
SpeechToTextLanguage["Bulgarian"] = "bg";
|
|
14
|
-
SpeechToTextLanguage["Burmese"] = "my";
|
|
15
|
-
SpeechToTextLanguage["Catalan"] = "ca";
|
|
16
|
-
SpeechToTextLanguage["Chinese"] = "zh";
|
|
17
|
-
SpeechToTextLanguage["Croatian"] = "hr";
|
|
18
|
-
SpeechToTextLanguage["Czech"] = "cs";
|
|
19
|
-
SpeechToTextLanguage["Danish"] = "da";
|
|
20
|
-
SpeechToTextLanguage["Dutch"] = "nl";
|
|
21
|
-
SpeechToTextLanguage["Estonian"] = "et";
|
|
22
|
-
SpeechToTextLanguage["English"] = "en";
|
|
23
|
-
SpeechToTextLanguage["Finnish"] = "fi";
|
|
24
|
-
SpeechToTextLanguage["French"] = "fr";
|
|
25
|
-
SpeechToTextLanguage["Galician"] = "gl";
|
|
26
|
-
SpeechToTextLanguage["Georgian"] = "ka";
|
|
27
|
-
SpeechToTextLanguage["German"] = "de";
|
|
28
|
-
SpeechToTextLanguage["Greek"] = "el";
|
|
29
|
-
SpeechToTextLanguage["Gujarati"] = "gu";
|
|
30
|
-
SpeechToTextLanguage["HaitianCreole"] = "ht";
|
|
31
|
-
SpeechToTextLanguage["Hebrew"] = "he";
|
|
32
|
-
SpeechToTextLanguage["Hindi"] = "hi";
|
|
33
|
-
SpeechToTextLanguage["Hungarian"] = "hu";
|
|
34
|
-
SpeechToTextLanguage["Icelandic"] = "is";
|
|
35
|
-
SpeechToTextLanguage["Indonesian"] = "id";
|
|
36
|
-
SpeechToTextLanguage["Italian"] = "it";
|
|
37
|
-
SpeechToTextLanguage["Japanese"] = "ja";
|
|
38
|
-
SpeechToTextLanguage["Kannada"] = "kn";
|
|
39
|
-
SpeechToTextLanguage["Kazakh"] = "kk";
|
|
40
|
-
SpeechToTextLanguage["Khmer"] = "km";
|
|
41
|
-
SpeechToTextLanguage["Korean"] = "ko";
|
|
42
|
-
SpeechToTextLanguage["Lao"] = "lo";
|
|
43
|
-
SpeechToTextLanguage["Latvian"] = "lv";
|
|
44
|
-
SpeechToTextLanguage["Lithuanian"] = "lt";
|
|
45
|
-
SpeechToTextLanguage["Macedonian"] = "mk";
|
|
46
|
-
SpeechToTextLanguage["Malagasy"] = "mg";
|
|
47
|
-
SpeechToTextLanguage["Malay"] = "ms";
|
|
48
|
-
SpeechToTextLanguage["Malayalam"] = "ml";
|
|
49
|
-
SpeechToTextLanguage["Maltese"] = "mt";
|
|
50
|
-
SpeechToTextLanguage["Marathi"] = "mr";
|
|
51
|
-
SpeechToTextLanguage["Nepali"] = "ne";
|
|
52
|
-
SpeechToTextLanguage["Norwegian"] = "no";
|
|
53
|
-
SpeechToTextLanguage["Persian"] = "fa";
|
|
54
|
-
SpeechToTextLanguage["Polish"] = "pl";
|
|
55
|
-
SpeechToTextLanguage["Portuguese"] = "pt";
|
|
56
|
-
SpeechToTextLanguage["Punjabi"] = "pa";
|
|
57
|
-
SpeechToTextLanguage["Romanian"] = "ro";
|
|
58
|
-
SpeechToTextLanguage["Russian"] = "ru";
|
|
59
|
-
SpeechToTextLanguage["Serbian"] = "sr";
|
|
60
|
-
SpeechToTextLanguage["Sinhala"] = "si";
|
|
61
|
-
SpeechToTextLanguage["Slovak"] = "sk";
|
|
62
|
-
SpeechToTextLanguage["Slovenian"] = "sl";
|
|
63
|
-
SpeechToTextLanguage["Spanish"] = "es";
|
|
64
|
-
SpeechToTextLanguage["Sundanese"] = "su";
|
|
65
|
-
SpeechToTextLanguage["Swahili"] = "sw";
|
|
66
|
-
SpeechToTextLanguage["Swedish"] = "sv";
|
|
67
|
-
SpeechToTextLanguage["Tagalog"] = "tl";
|
|
68
|
-
SpeechToTextLanguage["Tajik"] = "tg";
|
|
69
|
-
SpeechToTextLanguage["Tamil"] = "ta";
|
|
70
|
-
SpeechToTextLanguage["Telugu"] = "te";
|
|
71
|
-
SpeechToTextLanguage["Thai"] = "th";
|
|
72
|
-
SpeechToTextLanguage["Turkish"] = "tr";
|
|
73
|
-
SpeechToTextLanguage["Ukrainian"] = "uk";
|
|
74
|
-
SpeechToTextLanguage["Urdu"] = "ur";
|
|
75
|
-
SpeechToTextLanguage["Uzbek"] = "uz";
|
|
76
|
-
SpeechToTextLanguage["Vietnamese"] = "vi";
|
|
77
|
-
SpeechToTextLanguage["Welsh"] = "cy";
|
|
78
|
-
SpeechToTextLanguage["Yiddish"] = "yi";
|
|
79
|
-
})(SpeechToTextLanguage || (SpeechToTextLanguage = {}));
|
|
80
|
-
export var AvailableModels;
|
|
81
|
-
(function (AvailableModels) {
|
|
82
|
-
AvailableModels["WHISPER"] = "whisper";
|
|
83
|
-
AvailableModels["MOONSHINE"] = "moonshine";
|
|
84
|
-
AvailableModels["WHISPER_MULTILINGUAL"] = "whisperMultilingual";
|
|
85
|
-
})(AvailableModels || (AvailableModels = {}));
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ResourceSource } from '../types/common';
|
|
2
|
-
import { DownloadResource } from './ResourceFetcherUtils';
|
|
3
|
-
export declare class ResourceFetcher {
|
|
4
|
-
static downloads: Map<ResourceSource, DownloadResource>;
|
|
5
|
-
static fetch(callback?: (downloadProgress: number) => void, ...sources: ResourceSource[]): Promise<string[] | null>;
|
|
6
|
-
private static singleFetch;
|
|
7
|
-
private static returnOrStartNext;
|
|
8
|
-
private static pause;
|
|
9
|
-
private static resume;
|
|
10
|
-
private static cancel;
|
|
11
|
-
static pauseFetching(...sources: ResourceSource[]): Promise<void>;
|
|
12
|
-
static resumeFetching(...sources: ResourceSource[]): Promise<void>;
|
|
13
|
-
static cancelFetching(...sources: ResourceSource[]): Promise<void>;
|
|
14
|
-
private static findActive;
|
|
15
|
-
static listDownloadedFiles(): Promise<string[]>;
|
|
16
|
-
static listDownloadedModels(): Promise<string[]>;
|
|
17
|
-
static deleteResources(...sources: ResourceSource[]): Promise<void>;
|
|
18
|
-
static getFilesTotalSize(...sources: ResourceSource[]): Promise<number>;
|
|
19
|
-
private static handleObject;
|
|
20
|
-
private static handleLocalFile;
|
|
21
|
-
private static handleReleaseModeFile;
|
|
22
|
-
private static handleDevModeFile;
|
|
23
|
-
private static handleRemoteFile;
|
|
24
|
-
}
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resource Fetcher
|
|
3
|
-
*
|
|
4
|
-
* Provides an interface for downloading files (via `ResourceFetcher.fetch()`)
|
|
5
|
-
*
|
|
6
|
-
* Key functionality:
|
|
7
|
-
* - Download control: pause, resume, and cancel operations through:
|
|
8
|
-
* - Single file: `.pauseFetching()`, `.resumeFetching()`, `.cancelFetching()`
|
|
9
|
-
* - Downloaded file management:
|
|
10
|
-
* - `.getFilesTotalSize()`, `.listDownloadedFiles()`, `.listDownloadedModels()`, `.deleteResources()`
|
|
11
|
-
*
|
|
12
|
-
* Remark: The pausing/resuming/canceling works only for fetching remote resources.
|
|
13
|
-
*
|
|
14
|
-
* Most exported functions accept:
|
|
15
|
-
* - Multiple `ResourceSource` arguments, (union type of string, number or object)
|
|
16
|
-
*
|
|
17
|
-
* Method `.fetch()` takes argument as callback that reports download progress.
|
|
18
|
-
* Method`.fetch()` returns array of paths to successfully saved files or null if the download was paused or cancelled (then resume functions can return paths).
|
|
19
|
-
*
|
|
20
|
-
* Technical Implementation:
|
|
21
|
-
* - Maintains a `downloads` Map instance that tracks:
|
|
22
|
-
* - Currently downloading resources
|
|
23
|
-
* - Paused downloads
|
|
24
|
-
* - Successful downloads are automatically removed from the `downloads` Map
|
|
25
|
-
* - Uses the `ResourceSourceExtended` interface to enable pause/resume functionality:
|
|
26
|
-
* - Wraps user-provided `ResourceSource` elements
|
|
27
|
-
* - Implements linked list behavior via the `.next` attribute
|
|
28
|
-
* - Automatically processes subsequent downloads when `.next` contains a valid resource
|
|
29
|
-
*/
|
|
30
|
-
import { cacheDirectory, createDownloadResumable, moveAsync, FileSystemSessionType, writeAsStringAsync, EncodingType, deleteAsync, readDirectoryAsync, } from 'expo-file-system';
|
|
31
|
-
import { Asset } from 'expo-asset';
|
|
32
|
-
import { RNEDirectory } from '../constants/directories';
|
|
33
|
-
import { ResourceFetcherUtils, } from './ResourceFetcherUtils';
|
|
34
|
-
export class ResourceFetcher {
|
|
35
|
-
static downloads = new Map(); //map of currently downloading (or paused) files, if the download was started by .fetch() method.
|
|
36
|
-
static async fetch(callback = () => { }, ...sources) {
|
|
37
|
-
if (sources.length === 0) {
|
|
38
|
-
throw new Error('Empty list given as an argument!');
|
|
39
|
-
}
|
|
40
|
-
const { results: info, totalLength } = await ResourceFetcherUtils.getFilesSizes(sources);
|
|
41
|
-
const head = {
|
|
42
|
-
source: info[0].source,
|
|
43
|
-
sourceType: info[0].type,
|
|
44
|
-
callback: info[0].type === 4 /* SourceType.REMOTE_FILE */
|
|
45
|
-
? ResourceFetcherUtils.calculateDownloadProgress(totalLength, info[0].previousFilesTotalLength, info[0].length, callback)
|
|
46
|
-
: () => { },
|
|
47
|
-
results: [],
|
|
48
|
-
};
|
|
49
|
-
let node = head;
|
|
50
|
-
for (let idx = 1; idx < sources.length; idx++) {
|
|
51
|
-
node.next = {
|
|
52
|
-
source: info[idx].source,
|
|
53
|
-
sourceType: info[idx].type,
|
|
54
|
-
callback: info[idx].type === 4 /* SourceType.REMOTE_FILE */
|
|
55
|
-
? ResourceFetcherUtils.calculateDownloadProgress(totalLength, info[idx].previousFilesTotalLength, info[idx].length, callback)
|
|
56
|
-
: () => { },
|
|
57
|
-
results: [],
|
|
58
|
-
};
|
|
59
|
-
node = node.next;
|
|
60
|
-
}
|
|
61
|
-
return this.singleFetch(head);
|
|
62
|
-
}
|
|
63
|
-
static async singleFetch(sourceExtended) {
|
|
64
|
-
const source = sourceExtended.source;
|
|
65
|
-
switch (sourceExtended.sourceType) {
|
|
66
|
-
case 0 /* SourceType.OBJECT */: {
|
|
67
|
-
return this.returnOrStartNext(sourceExtended, await this.handleObject(source));
|
|
68
|
-
}
|
|
69
|
-
case 1 /* SourceType.LOCAL_FILE */: {
|
|
70
|
-
return this.returnOrStartNext(sourceExtended, this.handleLocalFile(source));
|
|
71
|
-
}
|
|
72
|
-
case 2 /* SourceType.RELEASE_MODE_FILE */: {
|
|
73
|
-
return this.returnOrStartNext(sourceExtended, await this.handleReleaseModeFile(sourceExtended));
|
|
74
|
-
}
|
|
75
|
-
case 3 /* SourceType.DEV_MODE_FILE */: {
|
|
76
|
-
const result = await this.handleDevModeFile(sourceExtended);
|
|
77
|
-
if (result !== null) {
|
|
78
|
-
return this.returnOrStartNext(sourceExtended, result);
|
|
79
|
-
}
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
default: {
|
|
83
|
-
//case SourceType.REMOTE_FILE
|
|
84
|
-
const result = await this.handleRemoteFile(sourceExtended);
|
|
85
|
-
if (result !== null) {
|
|
86
|
-
return this.returnOrStartNext(sourceExtended, result);
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
//if any download ends successfully this function is called - it checks whether it should trigger next download or return list of paths.
|
|
93
|
-
static returnOrStartNext(sourceExtended, result) {
|
|
94
|
-
sourceExtended.results.push(result);
|
|
95
|
-
if (sourceExtended.next) {
|
|
96
|
-
const nextSource = sourceExtended.next;
|
|
97
|
-
nextSource.results.push(...sourceExtended.results);
|
|
98
|
-
return this.singleFetch(nextSource);
|
|
99
|
-
}
|
|
100
|
-
sourceExtended.callback(1);
|
|
101
|
-
return sourceExtended.results;
|
|
102
|
-
}
|
|
103
|
-
static async pause(source) {
|
|
104
|
-
const resource = this.downloads.get(source);
|
|
105
|
-
switch (resource.status) {
|
|
106
|
-
case 1 /* DownloadStatus.PAUSED */:
|
|
107
|
-
throw new Error("The file download is currently paused. Can't pause the download of the same file twice.");
|
|
108
|
-
default: {
|
|
109
|
-
resource.status = 1 /* DownloadStatus.PAUSED */;
|
|
110
|
-
await resource.downloadResumable.pauseAsync();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
static async resume(source) {
|
|
115
|
-
const resource = this.downloads.get(source);
|
|
116
|
-
if (!resource.extendedInfo.fileUri ||
|
|
117
|
-
!resource.extendedInfo.cacheFileUri ||
|
|
118
|
-
!resource.extendedInfo.uri) {
|
|
119
|
-
throw new Error('Something went wrong. File uri info is not specified!');
|
|
120
|
-
}
|
|
121
|
-
switch (resource.status) {
|
|
122
|
-
case 0 /* DownloadStatus.ONGOING */:
|
|
123
|
-
throw new Error("The file download is currently ongoing. Can't resume the ongoing download.");
|
|
124
|
-
default: {
|
|
125
|
-
resource.status = 0 /* DownloadStatus.ONGOING */;
|
|
126
|
-
const result = await resource.downloadResumable.resumeAsync();
|
|
127
|
-
if (!this.downloads.has(source) ||
|
|
128
|
-
this.downloads.get(source).status === 1 /* DownloadStatus.PAUSED */) {
|
|
129
|
-
//if canceled or paused after earlier resuming.
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
if (!result ||
|
|
133
|
-
(result.status !== 200 /* HTTP_CODE.OK */ &&
|
|
134
|
-
result.status !== 206 /* HTTP_CODE.PARTIAL_CONTENT */)) {
|
|
135
|
-
throw new Error(`Failed to fetch resource from '${resource.extendedInfo.uri}'`);
|
|
136
|
-
}
|
|
137
|
-
await moveAsync({
|
|
138
|
-
from: resource.extendedInfo.cacheFileUri,
|
|
139
|
-
to: resource.extendedInfo.fileUri,
|
|
140
|
-
});
|
|
141
|
-
this.downloads.delete(source);
|
|
142
|
-
ResourceFetcherUtils.triggerHuggingFaceDownloadCounter(resource.extendedInfo.uri);
|
|
143
|
-
return this.returnOrStartNext(resource.extendedInfo, ResourceFetcherUtils.removeFilePrefix(resource.extendedInfo.fileUri));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
static async cancel(source) {
|
|
148
|
-
const resource = this.downloads.get(source);
|
|
149
|
-
await resource.downloadResumable.cancelAsync();
|
|
150
|
-
this.downloads.delete(source);
|
|
151
|
-
}
|
|
152
|
-
static async pauseFetching(...sources) {
|
|
153
|
-
const source = this.findActive(sources);
|
|
154
|
-
await this.pause(source);
|
|
155
|
-
}
|
|
156
|
-
static async resumeFetching(...sources) {
|
|
157
|
-
const source = this.findActive(sources);
|
|
158
|
-
await this.resume(source);
|
|
159
|
-
}
|
|
160
|
-
static async cancelFetching(...sources) {
|
|
161
|
-
const source = this.findActive(sources);
|
|
162
|
-
await this.cancel(source);
|
|
163
|
-
}
|
|
164
|
-
static findActive(sources) {
|
|
165
|
-
for (const source of sources) {
|
|
166
|
-
if (this.downloads.has(source)) {
|
|
167
|
-
return source;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
throw new Error('None of given sources are currently during downloading process.');
|
|
171
|
-
}
|
|
172
|
-
static async listDownloadedFiles() {
|
|
173
|
-
const files = await readDirectoryAsync(RNEDirectory);
|
|
174
|
-
return files.map((file) => `${RNEDirectory}${file}`);
|
|
175
|
-
}
|
|
176
|
-
static async listDownloadedModels() {
|
|
177
|
-
const files = await this.listDownloadedFiles();
|
|
178
|
-
return files.filter((file) => file.endsWith('.pte'));
|
|
179
|
-
}
|
|
180
|
-
static async deleteResources(...sources) {
|
|
181
|
-
for (const source of sources) {
|
|
182
|
-
const filename = ResourceFetcherUtils.getFilenameFromUri(source);
|
|
183
|
-
const fileUri = `${RNEDirectory}${filename}`;
|
|
184
|
-
if (await ResourceFetcherUtils.checkFileExists(fileUri)) {
|
|
185
|
-
await deleteAsync(fileUri);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
static async getFilesTotalSize(...sources) {
|
|
190
|
-
return (await ResourceFetcherUtils.getFilesSizes(sources)).totalLength;
|
|
191
|
-
}
|
|
192
|
-
static async handleObject(source) {
|
|
193
|
-
if (typeof source !== 'object') {
|
|
194
|
-
throw new Error('Source is expected to be object!');
|
|
195
|
-
}
|
|
196
|
-
const jsonString = JSON.stringify(source);
|
|
197
|
-
const digest = ResourceFetcherUtils.hashObject(jsonString);
|
|
198
|
-
const filename = `${digest}.json`;
|
|
199
|
-
const path = `${RNEDirectory}${filename}`;
|
|
200
|
-
if (await ResourceFetcherUtils.checkFileExists(path)) {
|
|
201
|
-
return ResourceFetcherUtils.removeFilePrefix(path);
|
|
202
|
-
}
|
|
203
|
-
await ResourceFetcherUtils.createDirectoryIfNoExists();
|
|
204
|
-
await writeAsStringAsync(path, jsonString, {
|
|
205
|
-
encoding: EncodingType.UTF8,
|
|
206
|
-
});
|
|
207
|
-
return ResourceFetcherUtils.removeFilePrefix(path);
|
|
208
|
-
}
|
|
209
|
-
static handleLocalFile(source) {
|
|
210
|
-
if (typeof source !== 'string') {
|
|
211
|
-
throw new Error('Source is expected to be string.');
|
|
212
|
-
}
|
|
213
|
-
return ResourceFetcherUtils.removeFilePrefix(source);
|
|
214
|
-
}
|
|
215
|
-
static async handleReleaseModeFile(sourceExtended) {
|
|
216
|
-
const source = sourceExtended.source;
|
|
217
|
-
if (typeof source !== 'number') {
|
|
218
|
-
throw new Error('Source is expected to be string.');
|
|
219
|
-
}
|
|
220
|
-
const asset = Asset.fromModule(source);
|
|
221
|
-
const uri = asset.uri;
|
|
222
|
-
const filename = ResourceFetcherUtils.getFilenameFromUri(uri);
|
|
223
|
-
const fileUri = `${RNEDirectory}${filename}`;
|
|
224
|
-
const fileUriWithType = `${fileUri}.${asset.type}`;
|
|
225
|
-
if (await ResourceFetcherUtils.checkFileExists(fileUri)) {
|
|
226
|
-
return ResourceFetcherUtils.removeFilePrefix(fileUri);
|
|
227
|
-
}
|
|
228
|
-
await ResourceFetcherUtils.createDirectoryIfNoExists();
|
|
229
|
-
await asset.downloadAsync();
|
|
230
|
-
if (!asset.localUri) {
|
|
231
|
-
throw new Error(`Asset local URI is not available for ${source}`);
|
|
232
|
-
}
|
|
233
|
-
await moveAsync({ from: asset.localUri, to: fileUriWithType });
|
|
234
|
-
return ResourceFetcherUtils.removeFilePrefix(fileUriWithType);
|
|
235
|
-
}
|
|
236
|
-
static async handleDevModeFile(sourceExtended) {
|
|
237
|
-
const source = sourceExtended.source;
|
|
238
|
-
if (typeof source !== 'number') {
|
|
239
|
-
throw new Error('Source is expected to be a number.');
|
|
240
|
-
}
|
|
241
|
-
sourceExtended.uri = Asset.fromModule(source).uri;
|
|
242
|
-
return await this.handleRemoteFile(sourceExtended);
|
|
243
|
-
}
|
|
244
|
-
static async handleRemoteFile(sourceExtended) {
|
|
245
|
-
const source = sourceExtended.source;
|
|
246
|
-
if (typeof source === 'object') {
|
|
247
|
-
throw new Error('Source is expected to be a string or a number.');
|
|
248
|
-
}
|
|
249
|
-
if (this.downloads.has(source)) {
|
|
250
|
-
const resource = this.downloads.get(source);
|
|
251
|
-
if (resource.status === 1 /* DownloadStatus.PAUSED */) {
|
|
252
|
-
// if the download is paused, `fetch` is treated like `resume`
|
|
253
|
-
this.resume(source);
|
|
254
|
-
}
|
|
255
|
-
// if the download is ongoing, throw error.
|
|
256
|
-
throw new Error('Already downloading this file.');
|
|
257
|
-
}
|
|
258
|
-
if (typeof source === 'number' && !sourceExtended.uri) {
|
|
259
|
-
throw new Error('Source Uri is expected to be available here.');
|
|
260
|
-
}
|
|
261
|
-
if (typeof source === 'string') {
|
|
262
|
-
sourceExtended.uri = source;
|
|
263
|
-
}
|
|
264
|
-
const uri = sourceExtended.uri;
|
|
265
|
-
const filename = ResourceFetcherUtils.getFilenameFromUri(uri);
|
|
266
|
-
sourceExtended.fileUri = `${RNEDirectory}${filename}`;
|
|
267
|
-
sourceExtended.cacheFileUri = `${cacheDirectory}${filename}`;
|
|
268
|
-
if (await ResourceFetcherUtils.checkFileExists(sourceExtended.fileUri)) {
|
|
269
|
-
return ResourceFetcherUtils.removeFilePrefix(sourceExtended.fileUri);
|
|
270
|
-
}
|
|
271
|
-
await ResourceFetcherUtils.createDirectoryIfNoExists();
|
|
272
|
-
const downloadResumable = createDownloadResumable(uri, sourceExtended.cacheFileUri, { sessionType: FileSystemSessionType.BACKGROUND }, ({ totalBytesWritten, totalBytesExpectedToWrite }) => {
|
|
273
|
-
if (totalBytesExpectedToWrite === -1) {
|
|
274
|
-
// If totalBytesExpectedToWrite is -1, it means the server does not provide content length.
|
|
275
|
-
sourceExtended.callback(0);
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
sourceExtended.callback(totalBytesWritten / totalBytesExpectedToWrite);
|
|
279
|
-
});
|
|
280
|
-
//create value for the this.download Map
|
|
281
|
-
const downloadResource = {
|
|
282
|
-
downloadResumable: downloadResumable,
|
|
283
|
-
status: 0 /* DownloadStatus.ONGOING */,
|
|
284
|
-
extendedInfo: sourceExtended,
|
|
285
|
-
};
|
|
286
|
-
//add key-value pair to map
|
|
287
|
-
this.downloads.set(source, downloadResource);
|
|
288
|
-
const result = await downloadResumable.downloadAsync();
|
|
289
|
-
if (!this.downloads.has(source) ||
|
|
290
|
-
this.downloads.get(source).status === 1 /* DownloadStatus.PAUSED */) {
|
|
291
|
-
// if canceled or paused during the download
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
if (!result || result.status !== 200 /* HTTP_CODE.OK */) {
|
|
295
|
-
throw new Error(`Failed to fetch resource from '${source}'`);
|
|
296
|
-
}
|
|
297
|
-
await moveAsync({
|
|
298
|
-
from: sourceExtended.cacheFileUri,
|
|
299
|
-
to: sourceExtended.fileUri,
|
|
300
|
-
});
|
|
301
|
-
this.downloads.delete(source);
|
|
302
|
-
ResourceFetcherUtils.triggerHuggingFaceDownloadCounter(uri);
|
|
303
|
-
return ResourceFetcherUtils.removeFilePrefix(sourceExtended.fileUri);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
import { DownloadResumable } from 'expo-file-system';
|
|
5
|
-
import { ResourceSource } from '../types/common';
|
|
6
|
-
export declare const enum HTTP_CODE {
|
|
7
|
-
OK = 200,
|
|
8
|
-
PARTIAL_CONTENT = 206
|
|
9
|
-
}
|
|
10
|
-
export declare const enum DownloadStatus {
|
|
11
|
-
ONGOING = 0,
|
|
12
|
-
PAUSED = 1
|
|
13
|
-
}
|
|
14
|
-
export declare const enum SourceType {
|
|
15
|
-
OBJECT = 0,
|
|
16
|
-
LOCAL_FILE = 1,
|
|
17
|
-
RELEASE_MODE_FILE = 2,
|
|
18
|
-
DEV_MODE_FILE = 3,
|
|
19
|
-
REMOTE_FILE = 4
|
|
20
|
-
}
|
|
21
|
-
export interface ResourceSourceExtended {
|
|
22
|
-
source: ResourceSource;
|
|
23
|
-
sourceType: SourceType;
|
|
24
|
-
callback?: (downloadProgress: number) => void;
|
|
25
|
-
results: string[];
|
|
26
|
-
uri?: string;
|
|
27
|
-
fileUri?: string;
|
|
28
|
-
cacheFileUri?: string;
|
|
29
|
-
next?: ResourceSourceExtended;
|
|
30
|
-
}
|
|
31
|
-
export interface DownloadResource {
|
|
32
|
-
downloadResumable: DownloadResumable;
|
|
33
|
-
status: DownloadStatus;
|
|
34
|
-
extendedInfo: ResourceSourceExtended;
|
|
35
|
-
}
|
|
36
|
-
export declare namespace ResourceFetcherUtils {
|
|
37
|
-
function getType(source: ResourceSource): SourceType;
|
|
38
|
-
function getFilesSizes(sources: ResourceSource[]): Promise<{
|
|
39
|
-
results: {
|
|
40
|
-
source: ResourceSource;
|
|
41
|
-
type: SourceType;
|
|
42
|
-
length: number;
|
|
43
|
-
previousFilesTotalLength: number;
|
|
44
|
-
}[];
|
|
45
|
-
totalLength: number;
|
|
46
|
-
}>;
|
|
47
|
-
function removeFilePrefix(uri: string): string;
|
|
48
|
-
function hashObject(jsonString: string): string;
|
|
49
|
-
function calculateDownloadProgress(totalLength: number, previousFilesTotalLength: number, currentFileLength: number, setProgress: (downloadProgress: number) => void): (progress: number) => void;
|
|
50
|
-
function triggerHuggingFaceDownloadCounter(uri: string): Promise<void>;
|
|
51
|
-
function createDirectoryIfNoExists(): Promise<void>;
|
|
52
|
-
function checkFileExists(fileUri: string): Promise<boolean>;
|
|
53
|
-
function getFilenameFromUri(uri: string): string;
|
|
54
|
-
}
|