react-native-executorch 0.5.1 → 0.5.3
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/android/CMakeLists.txt +24 -0
- package/android/build.gradle +1 -0
- package/android/src/main/cpp/CMakeLists.txt +25 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +1 -13
- package/common/rnexecutorch/RnExecutorchInstaller.cpp +52 -18
- package/common/rnexecutorch/RnExecutorchInstaller.h +0 -25
- package/common/rnexecutorch/TokenizerModule.cpp +1 -1
- package/common/rnexecutorch/TokenizerModule.h +4 -1
- package/common/rnexecutorch/data_processing/FileUtils.h +2 -2
- package/common/rnexecutorch/data_processing/ImageProcessing.cpp +5 -5
- package/common/rnexecutorch/data_processing/ImageProcessing.h +2 -2
- package/common/rnexecutorch/data_processing/Numerical.cpp +13 -0
- package/common/rnexecutorch/host_objects/JsiConversions.h +43 -62
- package/common/rnexecutorch/host_objects/ModelHostObject.h +43 -24
- package/common/rnexecutorch/metaprogramming/ConstructorHelpers.h +8 -6
- package/common/rnexecutorch/metaprogramming/FunctionHelpers.h +1 -1
- package/common/rnexecutorch/models/BaseModel.cpp +2 -2
- package/common/rnexecutorch/models/BaseModel.h +5 -0
- package/common/rnexecutorch/models/EncoderDecoderBase.cpp +2 -2
- package/common/rnexecutorch/models/EncoderDecoderBase.h +2 -2
- package/common/rnexecutorch/models/classification/Classification.cpp +6 -6
- package/common/rnexecutorch/models/classification/Classification.h +5 -0
- package/common/rnexecutorch/models/classification/Constants.h +3 -3
- package/common/rnexecutorch/models/embeddings/BaseEmbeddings.cpp +2 -2
- package/common/rnexecutorch/models/embeddings/BaseEmbeddings.h +2 -2
- package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.cpp +3 -3
- package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.h +5 -0
- package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +2 -2
- package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.h +6 -1
- package/common/rnexecutorch/models/image_segmentation/Constants.h +3 -3
- package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp +6 -5
- package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.h +8 -1
- package/common/rnexecutorch/models/llm/LLM.cpp +58 -0
- package/common/rnexecutorch/models/llm/LLM.h +35 -0
- package/common/rnexecutorch/models/object_detection/Constants.h +3 -3
- package/common/rnexecutorch/models/object_detection/ObjectDetection.cpp +8 -8
- package/common/rnexecutorch/models/object_detection/ObjectDetection.h +11 -5
- package/common/rnexecutorch/models/object_detection/Types.h +13 -0
- package/common/rnexecutorch/models/object_detection/Utils.cpp +13 -11
- package/common/rnexecutorch/models/object_detection/Utils.h +7 -13
- package/common/rnexecutorch/models/ocr/CTCLabelConverter.cpp +2 -2
- package/common/rnexecutorch/models/ocr/CTCLabelConverter.h +2 -2
- package/common/rnexecutorch/models/ocr/Constants.h +33 -26
- package/common/rnexecutorch/models/ocr/Detector.cpp +20 -22
- package/common/rnexecutorch/models/ocr/Detector.h +4 -4
- package/common/rnexecutorch/models/ocr/OCR.cpp +9 -8
- package/common/rnexecutorch/models/ocr/OCR.h +11 -3
- package/common/rnexecutorch/models/ocr/RecognitionHandler.cpp +20 -19
- package/common/rnexecutorch/models/ocr/RecognitionHandler.h +9 -7
- package/common/rnexecutorch/models/ocr/Recognizer.cpp +7 -7
- package/common/rnexecutorch/models/ocr/Recognizer.h +2 -2
- package/common/rnexecutorch/models/ocr/Types.h +4 -6
- package/common/rnexecutorch/models/ocr/{DetectorUtils.cpp → utils/DetectorUtils.cpp} +70 -63
- package/common/rnexecutorch/models/ocr/{DetectorUtils.h → utils/DetectorUtils.h} +12 -11
- package/common/rnexecutorch/models/ocr/{RecognitionHandlerUtils.cpp → utils/RecognitionHandlerUtils.cpp} +14 -11
- package/common/rnexecutorch/models/ocr/{RecognitionHandlerUtils.h → utils/RecognitionHandlerUtils.h} +5 -5
- package/common/rnexecutorch/models/ocr/{RecognizerUtils.cpp → utils/RecognizerUtils.cpp} +28 -26
- package/common/rnexecutorch/models/ocr/{RecognizerUtils.h → utils/RecognizerUtils.h} +15 -14
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +2 -2
- package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +9 -2
- package/common/rnexecutorch/models/speech_to_text/SpeechToTextStrategy.h +2 -2
- package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.cpp +2 -2
- package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.h +2 -2
- package/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp +5 -5
- package/common/rnexecutorch/models/style_transfer/StyleTransfer.h +6 -0
- package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.cpp +23 -22
- package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.h +4 -4
- package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.cpp +34 -34
- package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.h +27 -20
- package/{third-party/ios/ExecutorchLib/ExecutorchLib/sampler → common/runner}/sampler.cpp +3 -2
- package/{third-party/ios/ExecutorchLib/ExecutorchLib/sampler → common/runner}/sampler.h +3 -2
- package/ios/libs/executorch/libbackend_coreml_ios.a +0 -0
- package/ios/libs/executorch/libbackend_coreml_simulator.a +0 -0
- package/{third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64 → ios/libs/executorch}/libbackend_mps_ios.a +0 -0
- package/{third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64-simulator → ios/libs/executorch}/libbackend_mps_simulator.a +0 -0
- package/ios/libs/executorch/libbackend_xnnpack_ios.a +0 -0
- package/ios/libs/executorch/libbackend_xnnpack_simulator.a +0 -0
- package/ios/libs/executorch/libexecutorch_ios.a +0 -0
- package/ios/libs/executorch/libexecutorch_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_custom_ios.a +0 -0
- package/ios/libs/executorch/libkernels_custom_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_optimized_ios.a +0 -0
- package/ios/libs/executorch/libkernels_optimized_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_portable_ios.a +0 -0
- package/ios/libs/executorch/libkernels_portable_simulator.a +0 -0
- package/ios/libs/executorch/libkernels_quantized_ios.a +0 -0
- package/ios/libs/executorch/libkernels_quantized_simulator.a +0 -0
- package/ios/libs/tokenizers-cpp/physical-arm64-release/libsentencepiece.a +0 -0
- package/ios/{ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib → libs/tokenizers-cpp/physical-arm64-release/libtokenizers_c.a} +0 -0
- package/ios/libs/tokenizers-cpp/physical-arm64-release/libtokenizers_cpp.a +0 -0
- package/ios/libs/tokenizers-cpp/simulator-arm64-debug/libsentencepiece.a +0 -0
- package/ios/{ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib → libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_c.a} +0 -0
- package/ios/libs/tokenizers-cpp/simulator-arm64-debug/libtokenizers_cpp.a +0 -0
- package/lib/Error.js +53 -0
- package/lib/ThreadPool.d.ts +10 -0
- package/lib/ThreadPool.js +28 -0
- package/lib/common/Logger.d.ts +8 -0
- package/lib/common/Logger.js +19 -0
- package/lib/constants/directories.js +2 -0
- package/lib/constants/llmDefaults.d.ts +6 -0
- package/lib/constants/llmDefaults.js +16 -0
- package/lib/constants/modelUrls.d.ts +223 -0
- package/lib/constants/modelUrls.js +322 -0
- package/lib/constants/ocr/models.d.ts +882 -0
- package/lib/constants/ocr/models.js +182 -0
- package/lib/constants/ocr/symbols.js +139 -0
- package/lib/constants/sttDefaults.d.ts +28 -0
- package/lib/constants/sttDefaults.js +68 -0
- package/lib/controllers/LLMController.d.ts +47 -0
- package/lib/controllers/LLMController.js +213 -0
- package/lib/controllers/OCRController.js +67 -0
- package/lib/controllers/SpeechToTextController.d.ts +56 -0
- package/lib/controllers/SpeechToTextController.js +349 -0
- package/lib/controllers/VerticalOCRController.js +70 -0
- package/lib/hooks/computer_vision/useClassification.d.ts +15 -0
- package/lib/hooks/computer_vision/useClassification.js +7 -0
- package/lib/hooks/computer_vision/useImageEmbeddings.d.ts +15 -0
- package/lib/hooks/computer_vision/useImageEmbeddings.js +7 -0
- package/lib/hooks/computer_vision/useImageSegmentation.d.ts +38 -0
- package/lib/hooks/computer_vision/useImageSegmentation.js +7 -0
- package/lib/hooks/computer_vision/useOCR.d.ts +20 -0
- package/lib/hooks/computer_vision/useOCR.js +41 -0
- package/lib/hooks/computer_vision/useObjectDetection.d.ts +15 -0
- package/lib/hooks/computer_vision/useObjectDetection.js +7 -0
- package/lib/hooks/computer_vision/useStyleTransfer.d.ts +15 -0
- package/lib/hooks/computer_vision/useStyleTransfer.js +7 -0
- package/lib/hooks/computer_vision/useVerticalOCR.d.ts +21 -0
- package/lib/hooks/computer_vision/useVerticalOCR.js +43 -0
- package/lib/hooks/general/useExecutorchModule.d.ts +13 -0
- package/lib/hooks/general/useExecutorchModule.js +7 -0
- package/lib/hooks/natural_language_processing/useLLM.d.ts +10 -0
- package/lib/hooks/natural_language_processing/useLLM.js +78 -0
- package/lib/hooks/natural_language_processing/useSpeechToText.d.ts +27 -0
- package/lib/hooks/natural_language_processing/useSpeechToText.js +49 -0
- package/lib/hooks/natural_language_processing/useTextEmbeddings.d.ts +16 -0
- package/lib/hooks/natural_language_processing/useTextEmbeddings.js +7 -0
- package/lib/hooks/natural_language_processing/useTokenizer.d.ts +17 -0
- package/lib/hooks/natural_language_processing/useTokenizer.js +52 -0
- package/lib/hooks/useModule.js +45 -0
- package/lib/hooks/useNonStaticModule.d.ts +20 -0
- package/lib/hooks/useNonStaticModule.js +49 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.js +58 -0
- package/lib/module/controllers/LLMController.js +6 -10
- package/lib/module/controllers/LLMController.js.map +1 -1
- package/lib/module/hooks/computer_vision/useClassification.js +2 -2
- package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageEmbeddings.js +2 -2
- package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageSegmentation.js +2 -2
- package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
- package/lib/module/hooks/computer_vision/useObjectDetection.js +2 -2
- package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
- package/lib/module/hooks/computer_vision/useStyleTransfer.js +2 -2
- package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
- package/lib/module/hooks/general/useExecutorchModule.js +2 -2
- package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +2 -2
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
- package/lib/module/hooks/useModule.js +13 -9
- package/lib/module/hooks/useModule.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/BaseModule.js +9 -17
- package/lib/module/modules/BaseModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ClassificationModule.js +2 -2
- package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +2 -2
- package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js +2 -2
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js +2 -2
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
- package/lib/module/modules/computer_vision/StyleTransferModule.js +2 -2
- package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
- package/lib/module/modules/general/ExecutorchModule.js +2 -2
- package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +2 -2
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
- package/lib/module/native/RnExecutorchModules.js +1 -2
- package/lib/module/native/RnExecutorchModules.js.map +1 -1
- package/lib/module/utils/ResourceFetcher.js +6 -8
- package/lib/module/utils/ResourceFetcher.js.map +1 -1
- package/lib/module/utils/ResourceFetcherUtils.js +20 -20
- package/lib/module/utils/ResourceFetcherUtils.js.map +1 -1
- package/lib/module/utils/SpeechToTextModule/ASR.js +3 -3
- package/lib/module/utils/SpeechToTextModule/ASR.js.map +1 -1
- package/lib/modules/BaseModule.js +25 -0
- package/lib/modules/BaseNonStaticModule.js +14 -0
- package/lib/modules/computer_vision/ClassificationModule.d.ts +8 -0
- package/lib/modules/computer_vision/ClassificationModule.js +17 -0
- package/lib/modules/computer_vision/ImageEmbeddingsModule.d.ts +8 -0
- package/lib/modules/computer_vision/ImageEmbeddingsModule.js +17 -0
- package/lib/modules/computer_vision/ImageSegmentationModule.d.ts +11 -0
- package/lib/modules/computer_vision/ImageSegmentationModule.js +27 -0
- package/lib/modules/computer_vision/OCRModule.d.ts +14 -0
- package/lib/modules/computer_vision/OCRModule.js +17 -0
- package/lib/modules/computer_vision/ObjectDetectionModule.d.ts +9 -0
- package/lib/modules/computer_vision/ObjectDetectionModule.js +17 -0
- package/lib/modules/computer_vision/StyleTransferModule.d.ts +8 -0
- package/lib/modules/computer_vision/StyleTransferModule.js +17 -0
- package/lib/modules/computer_vision/VerticalOCRModule.d.ts +14 -0
- package/lib/modules/computer_vision/VerticalOCRModule.js +19 -0
- package/lib/modules/general/ExecutorchModule.d.ts +7 -0
- package/lib/modules/general/ExecutorchModule.js +14 -0
- package/lib/modules/natural_language_processing/LLMModule.d.ts +28 -0
- package/lib/modules/natural_language_processing/LLMModule.js +45 -0
- package/lib/modules/natural_language_processing/SpeechToTextModule.d.ts +24 -0
- package/lib/modules/natural_language_processing/SpeechToTextModule.js +36 -0
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.d.ts +9 -0
- package/lib/modules/natural_language_processing/TextEmbeddingsModule.js +21 -0
- package/lib/modules/natural_language_processing/TokenizerModule.d.ts +12 -0
- package/lib/modules/natural_language_processing/TokenizerModule.js +30 -0
- package/lib/native/NativeETInstaller.js +2 -0
- package/lib/native/NativeOCR.js +2 -0
- package/lib/native/NativeVerticalOCR.js +2 -0
- package/lib/native/RnExecutorchModules.d.ts +7 -0
- package/lib/native/RnExecutorchModules.js +18 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/common.d.ts +32 -0
- package/lib/types/common.js +25 -0
- package/lib/types/imageSegmentation.js +26 -0
- package/lib/types/llm.d.ts +46 -0
- package/lib/types/llm.js +9 -0
- package/lib/types/objectDetection.js +94 -0
- package/lib/types/ocr.js +1 -0
- package/lib/types/stt.d.ts +94 -0
- package/lib/types/stt.js +85 -0
- package/lib/typescript/controllers/LLMController.d.ts +1 -1
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
- package/lib/typescript/hooks/useModule.d.ts +8 -5
- package/lib/typescript/hooks/useModule.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/BaseModule.d.ts +7 -6
- package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +2 -2
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
- package/lib/typescript/modules/general/ExecutorchModule.d.ts +2 -2
- package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +2 -2
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
- package/lib/typescript/native/RnExecutorchModules.d.ts +1 -3
- package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
- package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
- package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -1
- package/lib/utils/ResourceFetcher.d.ts +24 -0
- package/lib/utils/ResourceFetcher.js +305 -0
- package/lib/utils/ResourceFetcherUtils.d.ts +54 -0
- package/lib/utils/ResourceFetcherUtils.js +127 -0
- package/lib/utils/llm.d.ts +6 -0
- package/lib/utils/llm.js +72 -0
- package/lib/utils/stt.js +21 -0
- package/package.json +1 -2
- package/react-native-executorch.podspec +47 -44
- package/src/controllers/LLMController.ts +8 -13
- package/src/hooks/computer_vision/useClassification.ts +2 -2
- package/src/hooks/computer_vision/useImageEmbeddings.ts +2 -2
- package/src/hooks/computer_vision/useImageSegmentation.ts +2 -2
- package/src/hooks/computer_vision/useObjectDetection.ts +2 -2
- package/src/hooks/computer_vision/useStyleTransfer.ts +2 -2
- package/src/hooks/general/useExecutorchModule.ts +2 -2
- package/src/hooks/natural_language_processing/useTextEmbeddings.ts +2 -2
- package/src/hooks/useModule.ts +23 -13
- package/src/index.ts +3 -2
- package/src/modules/BaseModule.ts +17 -28
- package/src/modules/computer_vision/ClassificationModule.ts +2 -2
- package/src/modules/computer_vision/ImageEmbeddingsModule.ts +2 -2
- package/src/modules/computer_vision/ImageSegmentationModule.ts +2 -2
- package/src/modules/computer_vision/ObjectDetectionModule.ts +2 -2
- package/src/modules/computer_vision/StyleTransferModule.ts +2 -2
- package/src/modules/general/ExecutorchModule.ts +2 -2
- package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +2 -2
- package/src/native/RnExecutorchModules.ts +1 -5
- package/src/utils/ResourceFetcher.ts +9 -7
- package/src/utils/ResourceFetcherUtils.ts +15 -17
- package/src/utils/SpeechToTextModule/ASR.ts +4 -4
- package/third-party/android/libs/cpuinfo/arm64-v8a/libcpuinfo.so +0 -0
- package/third-party/android/libs/pthreadpool/arm64-v8a/libpthreadpool.so +0 -0
- package/third-party/include/cpuinfo/cpuinfo.h +2305 -0
- package/third-party/include/executorch/extension/threadpool/cpuinfo_utils.h +26 -0
- package/third-party/include/executorch/extension/threadpool/threadpool.h +94 -0
- package/third-party/include/pthreadpool/pthreadpool.h +2236 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +0 -63
- package/ios/ExecutorchLib.xcframework/Info.plist +0 -43
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/ETModel.h +0 -27
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +0 -14
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/LLaMARunner.h +0 -32
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/ETModel.h +0 -27
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +0 -14
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/LLaMARunner.h +0 -32
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/RnExecutorch/LLM.h +0 -5
- package/ios/RnExecutorch/LLM.mm +0 -78
- package/ios/RnExecutorch.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RnExecutorch.xcodeproj/project.xcworkspace/xcuserdata/jakubchmura.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RnExecutorch.xcodeproj/xcuserdata/jakubchmura.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/lib/module/modules/BaseNonStaticModule.js +0 -17
- package/lib/module/modules/BaseNonStaticModule.js.map +0 -1
- package/lib/module/native/NativeLLM.js +0 -5
- package/lib/module/native/NativeLLM.js.map +0 -1
- package/lib/typescript/modules/BaseNonStaticModule.d.ts +0 -10
- package/lib/typescript/modules/BaseNonStaticModule.d.ts.map +0 -1
- package/lib/typescript/native/NativeLLM.d.ts +0 -12
- package/lib/typescript/native/NativeLLM.d.ts.map +0 -1
- package/src/modules/BaseNonStaticModule.ts +0 -26
- package/src/native/NativeLLM.ts +0 -14
- package/third-party/include/tokenizers-cpp/tokenizers_c.h +0 -61
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.h +0 -27
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm +0 -249
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.h +0 -14
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.mm +0 -80
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.h +0 -32
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.mm +0 -95
- package/third-party/ios/ExecutorchLib/ExecutorchLib/InputType.h +0 -12
- package/third-party/ios/ExecutorchLib/ExecutorchLib/Utils.hpp +0 -217
- package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.cpp +0 -11
- package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.h +0 -11
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/base64.h +0 -202
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.cpp +0 -313
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.h +0 -57
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.cpp +0 -78
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.h +0 -23
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.cpp +0 -427
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.h +0 -87
- package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tokenizer.h +0 -76
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.pbxproj +0 -683
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/xcuserdata/jakubchmura.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/xcuserdata/jakubchmura.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/third-party/ios/ExecutorchLib/build.sh +0 -44
- package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64/libbackend_coreml_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64-simulator/libbackend_coreml_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64/libbackend_xnnpack_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64-simulator/libbackend_xnnpack_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/Info.plist +0 -47
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Macros.h +0 -497
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-inl.h +0 -342
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-math.h +0 -266
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16.h +0 -125
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half-inl.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/TypeSafeSignMath.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/bit_cast.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/floating_point_utils.h +0 -33
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorch.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchError.h +0 -16
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchLog.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchModule.h +0 -286
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchTensor.h +0 -742
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchValue.h +0 -219
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/module/module.h +0 -492
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_accessor.h +0 -190
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr_maker.h +0 -653
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_execution_context.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_init_context.h +0 -72
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/interface.h +0 -166
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/array_ref.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/data_loader.h +0 -136
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/defines.h +0 -20
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/error.h +0 -229
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/evalue.h +0 -521
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer.h +0 -565
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks.h +0 -323
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +0 -197
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/exec_aten.h +0 -147
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +0 -263
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +0 -1331
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +0 -21
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +0 -69
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +0 -1250
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/freeable_buffer.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/hierarchical_allocator.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/memory_allocator.h +0 -198
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/named_data_map.h +0 -86
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +0 -14
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bits_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +0 -497
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +0 -342
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +0 -266
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +0 -125
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +0 -33
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/complex.h +0 -44
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/device.h +0 -70
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/half.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/optional.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/qint_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar.h +0 -110
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar_type.h +0 -154
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/string_view.h +0 -29
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor.h +0 -142
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_impl.h +0 -261
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_options.h +0 -60
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/result.h +0 -258
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/span.h +0 -93
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tag.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_layout.h +0 -79
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_shape_dynamism.h +0 -39
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/memory_manager.h +0 -113
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method.h +0 -387
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method_meta.h +0 -251
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/program.h +0 -320
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/pte_data_map.h +0 -144
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/tensor_parser.h +0 -156
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/kernel_runtime_context.h +0 -122
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/operator_registry.h +0 -278
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/abort.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/assert.h +0 -119
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/clock.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compat_unistd.h +0 -75
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compiler.h +0 -191
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/log.h +0 -177
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/platform.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/profiler.h +0 -292
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/runtime.h +0 -35
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/system.h +0 -49
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/types.h +0 -24
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/schema/extended_header.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/module.modulemap +0 -5
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/libexecutorch_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Macros.h +0 -497
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-inl.h +0 -342
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-math.h +0 -266
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16.h +0 -125
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half-inl.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/TypeSafeSignMath.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/bit_cast.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/floating_point_utils.h +0 -33
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorch.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchError.h +0 -16
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchLog.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchModule.h +0 -286
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchTensor.h +0 -742
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchValue.h +0 -219
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/module/module.h +0 -492
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor.h +0 -13
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_accessor.h +0 -190
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr_maker.h +0 -653
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_execution_context.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_init_context.h +0 -72
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/interface.h +0 -166
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/array_ref.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/data_loader.h +0 -136
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/defines.h +0 -20
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/error.h +0 -229
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/evalue.h +0 -521
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer.h +0 -565
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks.h +0 -323
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +0 -197
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/exec_aten.h +0 -147
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +0 -263
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +0 -1331
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +0 -21
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +0 -69
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +0 -1250
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/freeable_buffer.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/hierarchical_allocator.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/memory_allocator.h +0 -198
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/named_data_map.h +0 -86
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +0 -14
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bits_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +0 -163
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +0 -497
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +0 -342
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +0 -266
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +0 -125
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +0 -347
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +0 -416
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +0 -33
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +0 -107
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/complex.h +0 -44
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/device.h +0 -70
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/half.h +0 -27
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/optional.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/qint_types.h +0 -83
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar.h +0 -110
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar_type.h +0 -154
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/string_view.h +0 -29
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor.h +0 -142
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_impl.h +0 -261
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_options.h +0 -60
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/result.h +0 -258
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/span.h +0 -93
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tag.h +0 -71
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_layout.h +0 -79
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_shape_dynamism.h +0 -39
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/memory_manager.h +0 -113
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method.h +0 -387
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method_meta.h +0 -251
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/program.h +0 -320
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/pte_data_map.h +0 -144
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/tensor_parser.h +0 -156
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/kernel_runtime_context.h +0 -122
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/operator_registry.h +0 -278
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/abort.h +0 -36
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/assert.h +0 -119
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/clock.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compat_unistd.h +0 -75
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compiler.h +0 -191
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/log.h +0 -177
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/platform.h +0 -133
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/profiler.h +0 -292
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/runtime.h +0 -35
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/system.h +0 -49
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/types.h +0 -24
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/schema/extended_header.h +0 -76
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/module.modulemap +0 -5
- package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/libexecutorch_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64/libkernels_custom_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64-simulator/libkernels_custom_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64/libkernels_optimized_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64-simulator/libkernels_optimized_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64/libkernels_portable_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64-simulator/libkernels_portable_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64/libkernels_quantized_ios.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64-simulator/libkernels_quantized_simulator.a +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/Info.plist +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/bitmap256.h +0 -82
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/filtered_re2.h +0 -111
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/pod_array.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter.h +0 -130
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter_tree.h +0 -139
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prog.h +0 -483
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/re2.h +0 -994
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/regexp.h +0 -692
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/set.h +0 -85
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_array.h +0 -367
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_set.h +0 -241
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/stringpiece.h +0 -205
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_casefold.h +0 -78
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_groups.h +0 -64
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/walker-inl.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Info.plist +0 -26
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/re2 +0 -0
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/bitmap256.h +0 -82
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/filtered_re2.h +0 -111
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/pod_array.h +0 -43
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter.h +0 -130
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter_tree.h +0 -139
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prog.h +0 -483
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/re2.h +0 -994
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/regexp.h +0 -692
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/set.h +0 -85
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_array.h +0 -367
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_set.h +0 -241
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/stringpiece.h +0 -205
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_casefold.h +0 -78
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_groups.h +0 -64
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/walker-inl.h +0 -235
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Info.plist +0 -26
- package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/re2 +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/irunner.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/runner.cpp +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/runner.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/stats.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_decoder_runner.cpp +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_decoder_runner.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_prefiller.cpp +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_prefiller.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/text_token_generator.h +0 -0
- /package/{third-party/ios/ExecutorchLib/ExecutorchLib → common}/runner/util.h +0 -0
|
@@ -0,0 +1,305 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
import { getInfoAsync, makeDirectoryAsync, } from 'expo-file-system';
|
|
5
|
+
import { RNEDirectory } from '../constants/directories';
|
|
6
|
+
import { Asset } from 'expo-asset';
|
|
7
|
+
import { Logger } from '../common/Logger';
|
|
8
|
+
export var ResourceFetcherUtils;
|
|
9
|
+
(function (ResourceFetcherUtils) {
|
|
10
|
+
function getType(source) {
|
|
11
|
+
if (typeof source === 'object') {
|
|
12
|
+
return 0 /* SourceType.OBJECT */;
|
|
13
|
+
}
|
|
14
|
+
else if (typeof source === 'number') {
|
|
15
|
+
const uri = Asset.fromModule(source).uri;
|
|
16
|
+
if (!uri.includes('://')) {
|
|
17
|
+
return 2 /* SourceType.RELEASE_MODE_FILE */;
|
|
18
|
+
}
|
|
19
|
+
return 3 /* SourceType.DEV_MODE_FILE */;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// typeof source == 'string'
|
|
23
|
+
if (source.startsWith('file://')) {
|
|
24
|
+
return 1 /* SourceType.LOCAL_FILE */;
|
|
25
|
+
}
|
|
26
|
+
return 4 /* SourceType.REMOTE_FILE */;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
ResourceFetcherUtils.getType = getType;
|
|
30
|
+
async function getFilesSizes(sources) {
|
|
31
|
+
const results = [];
|
|
32
|
+
let totalLength = 0;
|
|
33
|
+
let previousFilesTotalLength = 0;
|
|
34
|
+
for (const source of sources) {
|
|
35
|
+
const type = await ResourceFetcherUtils.getType(source);
|
|
36
|
+
let length = 0;
|
|
37
|
+
if (type === 4 /* SourceType.REMOTE_FILE */ && typeof source === 'string') {
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetch(source, { method: 'HEAD' });
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
Logger.warn(`Failed to fetch HEAD for ${source}: ${response.status}`);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const contentLength = response.headers.get('content-length');
|
|
45
|
+
if (!contentLength) {
|
|
46
|
+
Logger.warn(`No content-length header for ${source}`);
|
|
47
|
+
}
|
|
48
|
+
length = contentLength ? parseInt(contentLength, 10) : 0;
|
|
49
|
+
previousFilesTotalLength = totalLength;
|
|
50
|
+
totalLength += length;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
Logger.warn(`Error fetching HEAD for ${source}:`, error);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
results.push({ source, type, length, previousFilesTotalLength });
|
|
58
|
+
}
|
|
59
|
+
return { results, totalLength };
|
|
60
|
+
}
|
|
61
|
+
ResourceFetcherUtils.getFilesSizes = getFilesSizes;
|
|
62
|
+
function removeFilePrefix(uri) {
|
|
63
|
+
return uri.startsWith('file://') ? uri.slice(7) : uri;
|
|
64
|
+
}
|
|
65
|
+
ResourceFetcherUtils.removeFilePrefix = removeFilePrefix;
|
|
66
|
+
function hashObject(jsonString) {
|
|
67
|
+
let hash = 0;
|
|
68
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
69
|
+
// eslint-disable-next-line no-bitwise
|
|
70
|
+
hash = (hash << 5) - hash + jsonString.charCodeAt(i);
|
|
71
|
+
// eslint-disable-next-line no-bitwise
|
|
72
|
+
hash |= 0;
|
|
73
|
+
}
|
|
74
|
+
// eslint-disable-next-line no-bitwise
|
|
75
|
+
return (hash >>> 0).toString();
|
|
76
|
+
}
|
|
77
|
+
ResourceFetcherUtils.hashObject = hashObject;
|
|
78
|
+
function calculateDownloadProgress(totalLength, previousFilesTotalLength, currentFileLength, setProgress) {
|
|
79
|
+
return (progress) => {
|
|
80
|
+
if (progress === 1 &&
|
|
81
|
+
previousFilesTotalLength === totalLength - currentFileLength) {
|
|
82
|
+
setProgress(1);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Avoid division by zero
|
|
86
|
+
if (totalLength === 0) {
|
|
87
|
+
setProgress(0);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const baseProgress = previousFilesTotalLength / totalLength;
|
|
91
|
+
const scaledProgress = progress * (currentFileLength / totalLength);
|
|
92
|
+
const updatedProgress = baseProgress + scaledProgress;
|
|
93
|
+
setProgress(updatedProgress);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
ResourceFetcherUtils.calculateDownloadProgress = calculateDownloadProgress;
|
|
97
|
+
/*
|
|
98
|
+
* Increments the Hugging Face download counter if the URI points to a Software Mansion Hugging Face repo.
|
|
99
|
+
* More information: https://huggingface.co/docs/hub/models-download-stats
|
|
100
|
+
*/
|
|
101
|
+
async function triggerHuggingFaceDownloadCounter(uri) {
|
|
102
|
+
const url = new URL(uri);
|
|
103
|
+
if (url.host === 'huggingface.co' &&
|
|
104
|
+
url.pathname.startsWith('/software-mansion/')) {
|
|
105
|
+
const baseUrl = `${url.protocol}//${url.host}${url.pathname.split('resolve')[0]}`;
|
|
106
|
+
fetch(`${baseUrl}resolve/main/config.json`, { method: 'HEAD' });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
ResourceFetcherUtils.triggerHuggingFaceDownloadCounter = triggerHuggingFaceDownloadCounter;
|
|
110
|
+
async function createDirectoryIfNoExists() {
|
|
111
|
+
if (!(await checkFileExists(RNEDirectory))) {
|
|
112
|
+
await makeDirectoryAsync(RNEDirectory, { intermediates: true });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
ResourceFetcherUtils.createDirectoryIfNoExists = createDirectoryIfNoExists;
|
|
116
|
+
async function checkFileExists(fileUri) {
|
|
117
|
+
const fileInfo = await getInfoAsync(fileUri);
|
|
118
|
+
return fileInfo.exists;
|
|
119
|
+
}
|
|
120
|
+
ResourceFetcherUtils.checkFileExists = checkFileExists;
|
|
121
|
+
function getFilenameFromUri(uri) {
|
|
122
|
+
let cleanUri = uri.replace(/^https?:\/\//, '');
|
|
123
|
+
cleanUri = cleanUri.split('#')?.[0] ?? cleanUri;
|
|
124
|
+
return cleanUri.replace(/[^a-zA-Z0-9._-]/g, '_');
|
|
125
|
+
}
|
|
126
|
+
ResourceFetcherUtils.getFilenameFromUri = getFilenameFromUri;
|
|
127
|
+
})(ResourceFetcherUtils || (ResourceFetcherUtils = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ToolCall } from '../types/llm';
|
|
2
|
+
import { Schema } from 'jsonschema';
|
|
3
|
+
import * as zCore from 'zod/v4/core';
|
|
4
|
+
export declare const parseToolCall: (message: string) => ToolCall[];
|
|
5
|
+
export declare const getStructuredOutputPrompt: <T extends zCore.$ZodType>(responseSchema: T | Schema) => string;
|
|
6
|
+
export declare const fixAndValidateStructuredOutput: <T extends zCore.$ZodType>(output: string, responseSchema: T | Schema) => zCore.output<T>;
|
package/lib/utils/llm.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { Validator } from 'jsonschema';
|
|
3
|
+
import { jsonrepair } from 'jsonrepair';
|
|
4
|
+
import { DEFAULT_STRUCTURED_OUTPUT_PROMPT } from '../constants/llmDefaults';
|
|
5
|
+
import * as zCore from 'zod/v4/core';
|
|
6
|
+
import { Logger } from '../common/Logger';
|
|
7
|
+
export const parseToolCall = (message) => {
|
|
8
|
+
try {
|
|
9
|
+
const unparsedToolCalls = message.match('\\[(.|\\s)*\\]');
|
|
10
|
+
if (!unparsedToolCalls) {
|
|
11
|
+
throw Error('Regex did not match array.');
|
|
12
|
+
}
|
|
13
|
+
const parsedMessage = JSON.parse(unparsedToolCalls[0]);
|
|
14
|
+
const results = [];
|
|
15
|
+
for (const tool of parsedMessage) {
|
|
16
|
+
if ('name' in tool &&
|
|
17
|
+
typeof tool.name === 'string' &&
|
|
18
|
+
'arguments' in tool &&
|
|
19
|
+
tool.arguments !== null &&
|
|
20
|
+
typeof tool.arguments === 'object') {
|
|
21
|
+
results.push({
|
|
22
|
+
toolName: tool.name,
|
|
23
|
+
arguments: tool.arguments,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return results;
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
Logger.error(e);
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const filterObjectKeys = (obj, keysToRemove) => {
|
|
35
|
+
const entries = Object.entries(obj);
|
|
36
|
+
const filteredEntries = entries.filter(([key, _]) => !keysToRemove.includes(key));
|
|
37
|
+
return Object.fromEntries(filteredEntries);
|
|
38
|
+
};
|
|
39
|
+
export const getStructuredOutputPrompt = (responseSchema) => {
|
|
40
|
+
const schemaObject = responseSchema instanceof zCore.$ZodType
|
|
41
|
+
? filterObjectKeys(z.toJSONSchema(responseSchema), [
|
|
42
|
+
'$schema',
|
|
43
|
+
'additionalProperties',
|
|
44
|
+
])
|
|
45
|
+
: responseSchema;
|
|
46
|
+
const schemaString = JSON.stringify(schemaObject);
|
|
47
|
+
return DEFAULT_STRUCTURED_OUTPUT_PROMPT(schemaString);
|
|
48
|
+
};
|
|
49
|
+
const extractBetweenBrackets = (text) => {
|
|
50
|
+
const startIndex = text.search(/[\\{\\[]/); // First occurrence of either { or [
|
|
51
|
+
const openingBracket = text[startIndex];
|
|
52
|
+
const closingBracket = openingBracket === '{' ? '}' : ']';
|
|
53
|
+
if (!openingBracket)
|
|
54
|
+
throw Error("Couldn't find JSON in text");
|
|
55
|
+
return text.slice(text.indexOf(openingBracket), text.lastIndexOf(closingBracket) + 1);
|
|
56
|
+
};
|
|
57
|
+
// this is a bit hacky typing
|
|
58
|
+
export const fixAndValidateStructuredOutput = (output, responseSchema) => {
|
|
59
|
+
const extractedOutput = extractBetweenBrackets(output);
|
|
60
|
+
const repairedOutput = jsonrepair(extractedOutput);
|
|
61
|
+
const outputJSON = JSON.parse(repairedOutput);
|
|
62
|
+
if (responseSchema instanceof zCore.$ZodType) {
|
|
63
|
+
return z.parse(responseSchema, outputJSON);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const validator = new Validator();
|
|
67
|
+
validator.validate(outputJSON, responseSchema, {
|
|
68
|
+
throwAll: true,
|
|
69
|
+
});
|
|
70
|
+
return outputJSON;
|
|
71
|
+
}
|
|
72
|
+
};
|
package/lib/utils/stt.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const longCommonInfPref = (seq1, seq2, hammingDistThreshold) => {
|
|
2
|
+
let maxInd = 0;
|
|
3
|
+
let maxLength = 0;
|
|
4
|
+
for (let i = 0; i < seq1.length; i++) {
|
|
5
|
+
let j = 0;
|
|
6
|
+
let hammingDist = 0;
|
|
7
|
+
while (j < seq2.length &&
|
|
8
|
+
i + j < seq1.length &&
|
|
9
|
+
(seq1[i + j] === seq2[j] || hammingDist < hammingDistThreshold)) {
|
|
10
|
+
if (seq1[i + j] !== seq2[j]) {
|
|
11
|
+
hammingDist++;
|
|
12
|
+
}
|
|
13
|
+
j++;
|
|
14
|
+
}
|
|
15
|
+
if (j >= maxLength) {
|
|
16
|
+
maxLength = j;
|
|
17
|
+
maxInd = i;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return maxInd;
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-executorch",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "An easy way to run AI models in React Native with ExecuTorch",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"lib",
|
|
13
13
|
"android",
|
|
14
14
|
"ios",
|
|
15
|
-
"!ios/libs",
|
|
16
15
|
"cpp",
|
|
17
16
|
"common",
|
|
18
17
|
"*.podspec",
|