@runanywhere/core 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RunAnywhereCore.podspec +130 -0
- package/android/CMakeLists.txt +92 -0
- package/android/build.gradle +321 -0
- package/android/consumer-rules.pro +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +271 -0
- package/android/src/main/include/rac/backends/rac_llm_llamacpp.h +218 -0
- package/android/src/main/include/rac/backends/rac_stt_onnx.h +99 -0
- package/android/src/main/include/rac/backends/rac_stt_whispercpp.h +153 -0
- package/android/src/main/include/rac/backends/rac_tts_onnx.h +71 -0
- package/android/src/main/include/rac/backends/rac_vad_onnx.h +84 -0
- package/android/src/main/include/rac/core/capabilities/rac_lifecycle.h +290 -0
- package/android/src/main/include/rac/core/rac_analytics_events.h +610 -0
- package/android/src/main/include/rac/core/rac_audio_utils.h +88 -0
- package/android/src/main/include/rac/core/rac_component_types.h +160 -0
- package/android/src/main/include/rac/core/rac_core.h +331 -0
- package/android/src/main/include/rac/core/rac_error.h +469 -0
- package/android/src/main/include/rac/core/rac_events.h +334 -0
- package/android/src/main/include/rac/core/rac_logger.h +416 -0
- package/android/src/main/include/rac/core/rac_platform_adapter.h +340 -0
- package/android/src/main/include/rac/core/rac_sdk_state.h +292 -0
- package/android/src/main/include/rac/core/rac_structured_error.h +594 -0
- package/android/src/main/include/rac/core/rac_types.h +264 -0
- package/android/src/main/include/rac/features/llm/rac_llm.h +17 -0
- package/android/src/main/include/rac/features/llm/rac_llm_analytics.h +188 -0
- package/android/src/main/include/rac/features/llm/rac_llm_component.h +228 -0
- package/android/src/main/include/rac/features/llm/rac_llm_events.h +215 -0
- package/android/src/main/include/rac/features/llm/rac_llm_metrics.h +402 -0
- package/android/src/main/include/rac/features/llm/rac_llm_service.h +163 -0
- package/android/src/main/include/rac/features/llm/rac_llm_structured_output.h +141 -0
- package/android/src/main/include/rac/features/llm/rac_llm_types.h +384 -0
- package/android/src/main/include/rac/features/platform/rac_llm_platform.h +204 -0
- package/android/src/main/include/rac/features/platform/rac_tts_platform.h +197 -0
- package/android/src/main/include/rac/features/stt/rac_stt.h +17 -0
- package/android/src/main/include/rac/features/stt/rac_stt_analytics.h +204 -0
- package/android/src/main/include/rac/features/stt/rac_stt_component.h +162 -0
- package/android/src/main/include/rac/features/stt/rac_stt_events.h +62 -0
- package/android/src/main/include/rac/features/stt/rac_stt_service.h +154 -0
- package/android/src/main/include/rac/features/stt/rac_stt_types.h +389 -0
- package/android/src/main/include/rac/features/tts/rac_tts.h +17 -0
- package/android/src/main/include/rac/features/tts/rac_tts_analytics.h +181 -0
- package/android/src/main/include/rac/features/tts/rac_tts_component.h +158 -0
- package/android/src/main/include/rac/features/tts/rac_tts_events.h +54 -0
- package/android/src/main/include/rac/features/tts/rac_tts_service.h +162 -0
- package/android/src/main/include/rac/features/tts/rac_tts_types.h +374 -0
- package/android/src/main/include/rac/features/vad/rac_vad.h +17 -0
- package/android/src/main/include/rac/features/vad/rac_vad_analytics.h +236 -0
- package/android/src/main/include/rac/features/vad/rac_vad_component.h +185 -0
- package/android/src/main/include/rac/features/vad/rac_vad_energy.h +443 -0
- package/android/src/main/include/rac/features/vad/rac_vad_events.h +76 -0
- package/android/src/main/include/rac/features/vad/rac_vad_service.h +167 -0
- package/android/src/main/include/rac/features/vad/rac_vad_types.h +244 -0
- package/android/src/main/include/rac/features/voice_agent/rac_voice_agent.h +612 -0
- package/android/src/main/include/rac/infrastructure/device/rac_device_manager.h +176 -0
- package/android/src/main/include/rac/infrastructure/download/rac_download.h +418 -0
- package/android/src/main/include/rac/infrastructure/events/rac_events.h +177 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_assignment.h +169 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_paths.h +258 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_registry.h +357 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_strategy.h +374 -0
- package/android/src/main/include/rac/infrastructure/model_management/rac_model_types.h +613 -0
- package/android/src/main/include/rac/infrastructure/network/rac_api_types.h +335 -0
- package/android/src/main/include/rac/infrastructure/network/rac_auth_manager.h +252 -0
- package/android/src/main/include/rac/infrastructure/network/rac_dev_config.h +85 -0
- package/android/src/main/include/rac/infrastructure/network/rac_endpoints.h +102 -0
- package/android/src/main/include/rac/infrastructure/network/rac_environment.h +220 -0
- package/android/src/main/include/rac/infrastructure/network/rac_http_client.h +233 -0
- package/android/src/main/include/rac/infrastructure/storage/rac_storage_analyzer.h +286 -0
- package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_manager.h +206 -0
- package/android/src/main/include/rac/infrastructure/telemetry/rac_telemetry_types.h +234 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/ArchiveUtility.kt +308 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfo.kt +229 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/PlatformAdapterBridge.kt +392 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/RunAnywhereCorePackage.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/SDKLogger.kt +357 -0
- package/android/src/main/java/com/margelo/nitro/runanywhere/SecureStorageManager.kt +147 -0
- package/android/src/main/jniLibs/arm64-v8a/libc++_shared.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libomp.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librac_commons.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/librunanywhere_jni.so +0 -0
- package/cpp/HybridRunAnywhereCore.cpp +2505 -0
- package/cpp/HybridRunAnywhereCore.hpp +271 -0
- package/cpp/bridges/AuthBridge.cpp +209 -0
- package/cpp/bridges/AuthBridge.hpp +157 -0
- package/cpp/bridges/DeviceBridge.cpp +257 -0
- package/cpp/bridges/DeviceBridge.hpp +155 -0
- package/cpp/bridges/DownloadBridge.cpp +299 -0
- package/cpp/bridges/DownloadBridge.hpp +197 -0
- package/cpp/bridges/EventBridge.cpp +125 -0
- package/cpp/bridges/EventBridge.hpp +139 -0
- package/cpp/bridges/HTTPBridge.cpp +96 -0
- package/cpp/bridges/HTTPBridge.hpp +144 -0
- package/cpp/bridges/InitBridge.cpp +1273 -0
- package/cpp/bridges/InitBridge.hpp +306 -0
- package/cpp/bridges/ModelRegistryBridge.cpp +394 -0
- package/cpp/bridges/ModelRegistryBridge.hpp +177 -0
- package/cpp/bridges/StorageBridge.cpp +269 -0
- package/cpp/bridges/StorageBridge.hpp +172 -0
- package/cpp/bridges/TelemetryBridge.cpp +352 -0
- package/cpp/bridges/TelemetryBridge.hpp +126 -0
- package/ios/.testlocal +0 -0
- package/ios/ArchiveUtility.swift +526 -0
- package/ios/ArchiveUtilityBridge.m +52 -0
- package/ios/AudioDecoder.h +38 -0
- package/ios/AudioDecoder.m +162 -0
- package/ios/Binaries/RACommons.xcframework/Info.plist +44 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/RACommons.h +67 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_analytics_events.h +610 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_api_types.h +335 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_audio_utils.h +88 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_auth_manager.h +252 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_component_types.h +160 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_core.h +331 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_dev_config.h +85 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_device_manager.h +176 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_download.h +418 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_endpoints.h +102 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_environment.h +220 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_error.h +469 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_events.h +177 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_http_client.h +233 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_lifecycle.h +290 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_component.h +228 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_events.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_platform.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_service.h +163 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_llm_types.h +384 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_logger.h +416 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_assignment.h +169 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_paths.h +258 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_registry.h +357 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_strategy.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_model_types.h +613 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_sdk_state.h +292 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_structured_error.h +594 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_component.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_events.h +62 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_service.h +154 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_types.h +389 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_component.h +158 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_events.h +54 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_platform.h +197 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_service.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_tts_types.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_types.h +264 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_component.h +185 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_energy.h +443 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_events.h +76 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_service.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_vad_types.h +244 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Headers/rac_voice_agent.h +612 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Info.plist +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/Modules/module.modulemap +5 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64/RACommons.framework/RACommons +0 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/RACommons.h +67 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_analytics_events.h +610 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_api_types.h +335 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_audio_utils.h +88 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_auth_manager.h +252 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_component_types.h +160 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_core.h +331 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_dev_config.h +85 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_device_manager.h +176 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_download.h +418 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_endpoints.h +102 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_environment.h +220 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_error.h +469 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_events.h +177 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_http_client.h +233 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_lifecycle.h +290 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_analytics.h +188 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_component.h +228 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_events.h +215 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_llamacpp.h +218 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_metrics.h +402 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_platform.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_service.h +163 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_structured_output.h +141 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_llm_types.h +384 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_logger.h +416 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_assignment.h +169 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_paths.h +258 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_registry.h +357 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_strategy.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_model_types.h +613 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_platform_adapter.h +340 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_sdk_state.h +292 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_storage_analyzer.h +286 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_structured_error.h +594 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_analytics.h +204 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_component.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_events.h +62 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_onnx.h +99 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_service.h +154 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_types.h +389 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_stt_whispercpp.h +153 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_manager.h +206 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_telemetry_types.h +234 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_analytics.h +181 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_component.h +158 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_events.h +54 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_onnx.h +71 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_platform.h +197 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_service.h +162 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_tts_types.h +374 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_types.h +264 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad.h +17 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_analytics.h +236 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_component.h +185 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_energy.h +443 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_events.h +76 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_onnx.h +84 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_service.h +167 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_vad_types.h +244 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Headers/rac_voice_agent.h +612 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Info.plist +11 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/Modules/module.modulemap +5 -0
- package/ios/Binaries/RACommons.xcframework/ios-arm64_x86_64-simulator/RACommons.framework/RACommons +0 -0
- package/ios/HybridRunAnywhereDeviceInfo.swift +214 -0
- package/ios/KeychainManager.swift +116 -0
- package/ios/PlatformAdapter.swift +100 -0
- package/ios/PlatformAdapterBridge.h +152 -0
- package/ios/PlatformAdapterBridge.m +570 -0
- package/ios/RNSDKLoggerBridge.h +41 -0
- package/ios/RNSDKLoggerBridge.m +66 -0
- package/ios/SDKLogger.swift +329 -0
- package/nitro.json +20 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.cpp +257 -0
- package/nitrogen/generated/android/c++/JHybridRunAnywhereDeviceInfoSpec.hpp +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/HybridRunAnywhereDeviceInfoSpec.kt +106 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/runanywhere/runanywherecoreOnLoad.kt +35 -0
- package/nitrogen/generated/android/runanywherecore+autolinking.cmake +82 -0
- package/nitrogen/generated/android/runanywherecore+autolinking.gradle +27 -0
- package/nitrogen/generated/android/runanywherecoreOnLoad.cpp +54 -0
- package/nitrogen/generated/android/runanywherecoreOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/RunAnywhereCore+autolinking.rb +60 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.cpp +65 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Bridge.hpp +197 -0
- package/nitrogen/generated/ios/RunAnywhereCore-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.mm +43 -0
- package/nitrogen/generated/ios/RunAnywhereCoreAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridRunAnywhereDeviceInfoSpecSwift.hpp +173 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec.swift +68 -0
- package/nitrogen/generated/ios/swift/HybridRunAnywhereDeviceInfoSpec_cxx.swift +366 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.cpp +92 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereCoreSpec.hpp +138 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.cpp +33 -0
- package/nitrogen/generated/shared/c++/HybridRunAnywhereDeviceInfoSpec.hpp +75 -0
- package/package.json +76 -0
- package/react-native.config.js +14 -0
- package/src/Features/VoiceSession/AudioCaptureManager.ts +286 -0
- package/src/Features/VoiceSession/AudioPlaybackManager.ts +300 -0
- package/src/Features/VoiceSession/VoiceSessionHandle.ts +530 -0
- package/src/Features/VoiceSession/index.ts +20 -0
- package/src/Features/index.ts +7 -0
- package/src/Foundation/Constants/SDKConstants.ts +47 -0
- package/src/Foundation/Constants/index.ts +8 -0
- package/src/Foundation/DependencyInjection/ServiceContainer.ts +154 -0
- package/src/Foundation/DependencyInjection/ServiceRegistry.ts +51 -0
- package/src/Foundation/DependencyInjection/index.ts +6 -0
- package/src/Foundation/ErrorTypes/ErrorCategory.ts +184 -0
- package/src/Foundation/ErrorTypes/ErrorCodes.ts +151 -0
- package/src/Foundation/ErrorTypes/ErrorContext.ts +201 -0
- package/src/Foundation/ErrorTypes/SDKError.ts +507 -0
- package/src/Foundation/ErrorTypes/index.ts +57 -0
- package/src/Foundation/Initialization/InitializationPhase.ts +85 -0
- package/src/Foundation/Initialization/InitializationState.ts +168 -0
- package/src/Foundation/Initialization/index.ts +26 -0
- package/src/Foundation/Logging/Destinations/NativeLogBridge.ts +147 -0
- package/src/Foundation/Logging/Destinations/SentryDestination.ts +209 -0
- package/src/Foundation/Logging/Logger/SDKLogger.ts +232 -0
- package/src/Foundation/Logging/Models/LogLevel.ts +36 -0
- package/src/Foundation/Logging/Models/LoggingConfiguration.ts +117 -0
- package/src/Foundation/Logging/Services/LoggingManager.ts +407 -0
- package/src/Foundation/Logging/index.ts +59 -0
- package/src/Foundation/Security/DeviceIdentity.ts +92 -0
- package/src/Foundation/Security/SecureStorageError.ts +132 -0
- package/src/Foundation/Security/SecureStorageKeys.ts +35 -0
- package/src/Foundation/Security/SecureStorageService.ts +449 -0
- package/src/Foundation/Security/index.ts +17 -0
- package/src/Foundation/index.ts +26 -0
- package/src/Infrastructure/Events/EventPublisher.ts +165 -0
- package/src/Infrastructure/Events/SDKEvent.ts +214 -0
- package/src/Infrastructure/Events/index.ts +15 -0
- package/src/Infrastructure/index.ts +9 -0
- package/src/Public/Events/EventBus.ts +488 -0
- package/src/Public/Events/index.ts +8 -0
- package/src/Public/Extensions/RunAnywhere+Logging.ts +51 -0
- package/src/Public/Extensions/RunAnywhere+Models.ts +392 -0
- package/src/Public/Extensions/RunAnywhere+STT.ts +424 -0
- package/src/Public/Extensions/RunAnywhere+Storage.ts +151 -0
- package/src/Public/Extensions/RunAnywhere+StructuredOutput.ts +316 -0
- package/src/Public/Extensions/RunAnywhere+TTS.ts +430 -0
- package/src/Public/Extensions/RunAnywhere+TextGeneration.ts +320 -0
- package/src/Public/Extensions/RunAnywhere+VAD.ts +359 -0
- package/src/Public/Extensions/RunAnywhere+VoiceAgent.ts +225 -0
- package/src/Public/Extensions/RunAnywhere+VoiceSession.ts +155 -0
- package/src/Public/Extensions/index.ts +126 -0
- package/src/Public/RunAnywhere.ts +695 -0
- package/src/index.ts +238 -0
- package/src/native/NativeRunAnywhereCore.ts +291 -0
- package/src/native/NativeRunAnywhereModule.ts +32 -0
- package/src/native/index.ts +21 -0
- package/src/services/DownloadService.ts +282 -0
- package/src/services/FileSystem.ts +810 -0
- package/src/services/ModelRegistry.ts +246 -0
- package/src/services/Network/APIEndpoints.ts +84 -0
- package/src/services/Network/HTTPService.ts +479 -0
- package/src/services/Network/NetworkConfiguration.ts +130 -0
- package/src/services/Network/TelemetryService.ts +318 -0
- package/src/services/Network/index.ts +29 -0
- package/src/services/SystemTTSService.ts +130 -0
- package/src/services/index.ts +66 -0
- package/src/specs/RunAnywhereCore.nitro.ts +627 -0
- package/src/specs/RunAnywhereDeviceInfo.nitro.ts +73 -0
- package/src/types/LLMTypes.ts +127 -0
- package/src/types/STTTypes.ts +124 -0
- package/src/types/StructuredOutputTypes.ts +156 -0
- package/src/types/TTSTypes.ts +126 -0
- package/src/types/VADTypes.ts +70 -0
- package/src/types/VoiceAgentTypes.ts +182 -0
- package/src/types/enums.ts +258 -0
- package/src/types/events.ts +337 -0
- package/src/types/external.d.ts +142 -0
- package/src/types/index.ts +146 -0
- package/src/types/models.ts +579 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiveUtility.swift
|
|
3
|
+
*
|
|
4
|
+
* Native archive extraction utility for React Native.
|
|
5
|
+
* Uses Apple's native Compression framework for gzip decompression (fast)
|
|
6
|
+
* and pure Swift tar extraction.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the implementation from:
|
|
9
|
+
* sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Download/Utilities/ArchiveUtility.swift
|
|
10
|
+
*
|
|
11
|
+
* Supports: tar.gz, zip
|
|
12
|
+
* Note: All models should use tar.gz from RunanywhereAI/sherpa-onnx fork for best performance
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import Compression
|
|
16
|
+
import Foundation
|
|
17
|
+
|
|
18
|
+
/// Archive extraction errors
|
|
19
|
+
public enum ArchiveError: Error, LocalizedError {
|
|
20
|
+
case invalidArchive(String)
|
|
21
|
+
case decompressionFailed(String)
|
|
22
|
+
case extractionFailed(String)
|
|
23
|
+
case unsupportedFormat(String)
|
|
24
|
+
case fileNotFound(String)
|
|
25
|
+
|
|
26
|
+
public var errorDescription: String? {
|
|
27
|
+
switch self {
|
|
28
|
+
case .invalidArchive(let msg): return "Invalid archive: \(msg)"
|
|
29
|
+
case .decompressionFailed(let msg): return "Decompression failed: \(msg)"
|
|
30
|
+
case .extractionFailed(let msg): return "Extraction failed: \(msg)"
|
|
31
|
+
case .unsupportedFormat(let msg): return "Unsupported format: \(msg)"
|
|
32
|
+
case .fileNotFound(let msg): return "File not found: \(msg)"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// Utility for handling archive extraction
|
|
38
|
+
@objc public final class ArchiveUtility: NSObject {
|
|
39
|
+
|
|
40
|
+
// MARK: - Public API
|
|
41
|
+
|
|
42
|
+
/// Extract an archive to a destination directory
|
|
43
|
+
/// - Parameters:
|
|
44
|
+
/// - archivePath: Path to the archive file
|
|
45
|
+
/// - destinationPath: Destination directory path
|
|
46
|
+
/// - Returns: true if extraction succeeded
|
|
47
|
+
@objc public static func extract(
|
|
48
|
+
archivePath: String,
|
|
49
|
+
to destinationPath: String
|
|
50
|
+
) -> Bool {
|
|
51
|
+
do {
|
|
52
|
+
try extractArchive(archivePath: archivePath, to: destinationPath)
|
|
53
|
+
return true
|
|
54
|
+
} catch {
|
|
55
|
+
SDKLogger.archive.logError(error, additionalInfo: "Extraction failed")
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// Extract an archive to a destination directory (throwing version)
|
|
61
|
+
public static func extractArchive(
|
|
62
|
+
archivePath: String,
|
|
63
|
+
to destinationPath: String,
|
|
64
|
+
progressHandler: ((Double) -> Void)? = nil
|
|
65
|
+
) throws {
|
|
66
|
+
let archiveURL = URL(fileURLWithPath: archivePath)
|
|
67
|
+
let destinationURL = URL(fileURLWithPath: destinationPath)
|
|
68
|
+
|
|
69
|
+
// Ensure archive exists
|
|
70
|
+
guard FileManager.default.fileExists(atPath: archivePath) else {
|
|
71
|
+
throw ArchiveError.fileNotFound("Archive not found: \(archivePath)")
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Detect archive type by magic bytes (more reliable than file extension)
|
|
75
|
+
let archiveType = try detectArchiveTypeByMagicBytes(archivePath)
|
|
76
|
+
SDKLogger.archive.info("Detected archive type: \(archiveType) for: \(archivePath)")
|
|
77
|
+
|
|
78
|
+
switch archiveType {
|
|
79
|
+
case .gzip:
|
|
80
|
+
try extractTarGz(from: archiveURL, to: destinationURL, progressHandler: progressHandler)
|
|
81
|
+
case .zip:
|
|
82
|
+
try extractZip(from: archiveURL, to: destinationURL, progressHandler: progressHandler)
|
|
83
|
+
case .bzip2:
|
|
84
|
+
throw ArchiveError.unsupportedFormat("tar.bz2 not supported. Use tar.gz from RunanywhereAI/sherpa-onnx fork.")
|
|
85
|
+
case .xz:
|
|
86
|
+
throw ArchiveError.unsupportedFormat("tar.xz not supported. Use tar.gz from RunanywhereAI/sherpa-onnx fork.")
|
|
87
|
+
case .unknown:
|
|
88
|
+
// Fallback to file extension check
|
|
89
|
+
let lowercased = archivePath.lowercased()
|
|
90
|
+
if lowercased.hasSuffix(".tar.gz") || lowercased.hasSuffix(".tgz") {
|
|
91
|
+
try extractTarGz(from: archiveURL, to: destinationURL, progressHandler: progressHandler)
|
|
92
|
+
} else if lowercased.hasSuffix(".zip") {
|
|
93
|
+
try extractZip(from: archiveURL, to: destinationURL, progressHandler: progressHandler)
|
|
94
|
+
} else {
|
|
95
|
+
throw ArchiveError.unsupportedFormat("Unknown archive format: \(archivePath)")
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// Archive type detected by magic bytes
|
|
101
|
+
private enum DetectedArchiveType {
|
|
102
|
+
case gzip
|
|
103
|
+
case zip
|
|
104
|
+
case bzip2
|
|
105
|
+
case xz
|
|
106
|
+
case unknown
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// Detect archive type by reading magic bytes from file header
|
|
110
|
+
private static func detectArchiveTypeByMagicBytes(_ path: String) throws -> DetectedArchiveType {
|
|
111
|
+
guard let fileHandle = FileHandle(forReadingAtPath: path) else {
|
|
112
|
+
throw ArchiveError.fileNotFound("Cannot open file: \(path)")
|
|
113
|
+
}
|
|
114
|
+
defer { try? fileHandle.close() }
|
|
115
|
+
|
|
116
|
+
// Read first 6 bytes for magic number detection
|
|
117
|
+
guard let headerData = try? fileHandle.read(upToCount: 6), headerData.count >= 2 else {
|
|
118
|
+
return .unknown
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Check for gzip: 0x1f 0x8b
|
|
122
|
+
if headerData[0] == 0x1f && headerData[1] == 0x8b {
|
|
123
|
+
return .gzip
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Check for zip: 0x50 0x4b 0x03 0x04 ("PK\x03\x04")
|
|
127
|
+
if headerData.count >= 4 &&
|
|
128
|
+
headerData[0] == 0x50 && headerData[1] == 0x4b &&
|
|
129
|
+
headerData[2] == 0x03 && headerData[3] == 0x04 {
|
|
130
|
+
return .zip
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Check for bzip2: 0x42 0x5a ("BZ")
|
|
134
|
+
if headerData[0] == 0x42 && headerData[1] == 0x5a {
|
|
135
|
+
return .bzip2
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Check for xz: 0xfd 0x37 0x7a 0x58 0x5a 0x00
|
|
139
|
+
if headerData.count >= 6 &&
|
|
140
|
+
headerData[0] == 0xfd && headerData[1] == 0x37 &&
|
|
141
|
+
headerData[2] == 0x7a && headerData[3] == 0x58 &&
|
|
142
|
+
headerData[4] == 0x5a && headerData[5] == 0x00 {
|
|
143
|
+
return .xz
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return .unknown
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// MARK: - tar.gz Extraction (Native Compression Framework)
|
|
150
|
+
|
|
151
|
+
/// Extract a tar.gz archive using Apple's native Compression framework
|
|
152
|
+
private static func extractTarGz(
|
|
153
|
+
from sourceURL: URL,
|
|
154
|
+
to destinationURL: URL,
|
|
155
|
+
progressHandler: ((Double) -> Void)?
|
|
156
|
+
) throws {
|
|
157
|
+
let overallStart = Date()
|
|
158
|
+
SDKLogger.archive.info("Extracting tar.gz: \(sourceURL.lastPathComponent)")
|
|
159
|
+
progressHandler?(0.0)
|
|
160
|
+
|
|
161
|
+
// Step 1: Read compressed data
|
|
162
|
+
let readStart = Date()
|
|
163
|
+
let compressedData = try Data(contentsOf: sourceURL)
|
|
164
|
+
let readTime = Date().timeIntervalSince(readStart)
|
|
165
|
+
SDKLogger.archive.info("Read \(formatBytes(compressedData.count)) in \(String(format: "%.2f", readTime))s")
|
|
166
|
+
progressHandler?(0.05)
|
|
167
|
+
|
|
168
|
+
// Step 2: Decompress gzip using NATIVE Compression framework
|
|
169
|
+
let decompressStart = Date()
|
|
170
|
+
SDKLogger.archive.info("Starting native gzip decompression...")
|
|
171
|
+
let tarData = try decompressGzipNative(compressedData)
|
|
172
|
+
let decompressTime = Date().timeIntervalSince(decompressStart)
|
|
173
|
+
SDKLogger.archive.info("Decompressed to \(formatBytes(tarData.count)) in \(String(format: "%.2f", decompressTime))s")
|
|
174
|
+
progressHandler?(0.3)
|
|
175
|
+
|
|
176
|
+
// Step 3: Extract tar archive
|
|
177
|
+
let extractStart = Date()
|
|
178
|
+
SDKLogger.archive.info("Extracting tar data...")
|
|
179
|
+
try extractTarData(tarData, to: destinationURL, progressHandler: { progress in
|
|
180
|
+
progressHandler?(0.3 + progress * 0.7)
|
|
181
|
+
})
|
|
182
|
+
let extractTime = Date().timeIntervalSince(extractStart)
|
|
183
|
+
SDKLogger.archive.info("Tar extract completed in \(String(format: "%.2f", extractTime))s")
|
|
184
|
+
|
|
185
|
+
let totalTime = Date().timeIntervalSince(overallStart)
|
|
186
|
+
SDKLogger.archive.info("Total extraction time: \(String(format: "%.2f", totalTime))s")
|
|
187
|
+
progressHandler?(1.0)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// Decompress gzip data using Apple's native Compression framework
|
|
191
|
+
private static func decompressGzipNative(_ compressedData: Data) throws -> Data {
|
|
192
|
+
// Gzip header validation
|
|
193
|
+
guard compressedData.count >= 10 else {
|
|
194
|
+
throw ArchiveError.invalidArchive("Gzip data too short")
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
guard compressedData[0] == 0x1f && compressedData[1] == 0x8b else {
|
|
198
|
+
throw ArchiveError.invalidArchive("Invalid gzip magic number")
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
guard compressedData[2] == 8 else {
|
|
202
|
+
throw ArchiveError.invalidArchive("Unsupported gzip compression method")
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let flags = compressedData[3]
|
|
206
|
+
var headerSize = 10
|
|
207
|
+
|
|
208
|
+
// Handle optional fields
|
|
209
|
+
if (flags & 0x04) != 0 { // FEXTRA
|
|
210
|
+
guard compressedData.count > headerSize + 2 else {
|
|
211
|
+
throw ArchiveError.invalidArchive("Truncated gzip header (FEXTRA)")
|
|
212
|
+
}
|
|
213
|
+
let extraLen = Int(compressedData[headerSize]) | (Int(compressedData[headerSize + 1]) << 8)
|
|
214
|
+
headerSize += 2 + extraLen
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (flags & 0x08) != 0 { // FNAME
|
|
218
|
+
while headerSize < compressedData.count && compressedData[headerSize] != 0 {
|
|
219
|
+
headerSize += 1
|
|
220
|
+
}
|
|
221
|
+
headerSize += 1
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (flags & 0x10) != 0 { // FCOMMENT
|
|
225
|
+
while headerSize < compressedData.count && compressedData[headerSize] != 0 {
|
|
226
|
+
headerSize += 1
|
|
227
|
+
}
|
|
228
|
+
headerSize += 1
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (flags & 0x02) != 0 { // FHCRC
|
|
232
|
+
headerSize += 2
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Extract raw deflate stream (skip header and 8-byte trailer)
|
|
236
|
+
guard compressedData.count > headerSize + 8 else {
|
|
237
|
+
throw ArchiveError.invalidArchive("Invalid gzip structure")
|
|
238
|
+
}
|
|
239
|
+
let deflateData = compressedData.subdata(in: headerSize..<(compressedData.count - 8))
|
|
240
|
+
|
|
241
|
+
// Use native Compression framework to decompress
|
|
242
|
+
// Start with a reasonable estimate (model files typically compress 3-5x)
|
|
243
|
+
var destinationBufferSize = deflateData.count * 10
|
|
244
|
+
var decompressedData = Data(count: destinationBufferSize)
|
|
245
|
+
|
|
246
|
+
let decompressedSize = deflateData.withUnsafeBytes { (srcPtr: UnsafeRawBufferPointer) -> Int in
|
|
247
|
+
guard let sourceAddress = srcPtr.baseAddress else { return 0 }
|
|
248
|
+
|
|
249
|
+
return decompressedData.withUnsafeMutableBytes { (destPtr: UnsafeMutableRawBufferPointer) -> Int in
|
|
250
|
+
guard let destAddress = destPtr.baseAddress else { return 0 }
|
|
251
|
+
|
|
252
|
+
return compression_decode_buffer(
|
|
253
|
+
destAddress.assumingMemoryBound(to: UInt8.self),
|
|
254
|
+
destinationBufferSize,
|
|
255
|
+
sourceAddress.assumingMemoryBound(to: UInt8.self),
|
|
256
|
+
deflateData.count,
|
|
257
|
+
nil,
|
|
258
|
+
COMPRESSION_ZLIB
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// If buffer was too small, try again with a larger buffer
|
|
264
|
+
if decompressedSize == 0 || decompressedSize == destinationBufferSize {
|
|
265
|
+
destinationBufferSize = deflateData.count * 30
|
|
266
|
+
decompressedData = Data(count: destinationBufferSize)
|
|
267
|
+
|
|
268
|
+
let retrySize = deflateData.withUnsafeBytes { (srcPtr: UnsafeRawBufferPointer) -> Int in
|
|
269
|
+
guard let sourceAddress = srcPtr.baseAddress else { return 0 }
|
|
270
|
+
|
|
271
|
+
return decompressedData.withUnsafeMutableBytes { (destPtr: UnsafeMutableRawBufferPointer) -> Int in
|
|
272
|
+
guard let destAddress = destPtr.baseAddress else { return 0 }
|
|
273
|
+
|
|
274
|
+
return compression_decode_buffer(
|
|
275
|
+
destAddress.assumingMemoryBound(to: UInt8.self),
|
|
276
|
+
destinationBufferSize,
|
|
277
|
+
sourceAddress.assumingMemoryBound(to: UInt8.self),
|
|
278
|
+
deflateData.count,
|
|
279
|
+
nil,
|
|
280
|
+
COMPRESSION_ZLIB
|
|
281
|
+
)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
guard retrySize > 0 && retrySize < destinationBufferSize else {
|
|
286
|
+
throw ArchiveError.decompressionFailed("Native decompression failed - buffer too small or corrupted data")
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
decompressedData.count = retrySize
|
|
290
|
+
return decompressedData
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
decompressedData.count = decompressedSize
|
|
294
|
+
return decompressedData
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// MARK: - ZIP Extraction (Pure Swift using Foundation)
|
|
298
|
+
|
|
299
|
+
private static func extractZip(
|
|
300
|
+
from sourceURL: URL,
|
|
301
|
+
to destinationURL: URL,
|
|
302
|
+
progressHandler: ((Double) -> Void)?
|
|
303
|
+
) throws {
|
|
304
|
+
SDKLogger.archive.info("Extracting zip: \(sourceURL.lastPathComponent)")
|
|
305
|
+
progressHandler?(0.0)
|
|
306
|
+
|
|
307
|
+
// Create destination directory
|
|
308
|
+
try FileManager.default.createDirectory(at: destinationURL, withIntermediateDirectories: true)
|
|
309
|
+
|
|
310
|
+
// Read zip file
|
|
311
|
+
guard let archive = try? Data(contentsOf: sourceURL) else {
|
|
312
|
+
throw ArchiveError.fileNotFound("Cannot read zip file: \(sourceURL.path)")
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Parse and extract ZIP using pure Swift
|
|
316
|
+
var offset = 0
|
|
317
|
+
var fileCount = 0
|
|
318
|
+
let totalSize = archive.count
|
|
319
|
+
|
|
320
|
+
while offset < archive.count - 4 {
|
|
321
|
+
// Check for local file header signature (0x04034b50 = PK\x03\x04)
|
|
322
|
+
let sig0 = archive[offset]
|
|
323
|
+
let sig1 = archive[offset + 1]
|
|
324
|
+
let sig2 = archive[offset + 2]
|
|
325
|
+
let sig3 = archive[offset + 3]
|
|
326
|
+
|
|
327
|
+
if sig0 == 0x50 && sig1 == 0x4b && sig2 == 0x03 && sig3 == 0x04 {
|
|
328
|
+
// Local file header
|
|
329
|
+
let compressionMethod = UInt16(archive[offset + 8]) | (UInt16(archive[offset + 9]) << 8)
|
|
330
|
+
let compressedSize = UInt32(archive[offset + 18]) |
|
|
331
|
+
(UInt32(archive[offset + 19]) << 8) |
|
|
332
|
+
(UInt32(archive[offset + 20]) << 16) |
|
|
333
|
+
(UInt32(archive[offset + 21]) << 24)
|
|
334
|
+
let uncompressedSize = UInt32(archive[offset + 22]) |
|
|
335
|
+
(UInt32(archive[offset + 23]) << 8) |
|
|
336
|
+
(UInt32(archive[offset + 24]) << 16) |
|
|
337
|
+
(UInt32(archive[offset + 25]) << 24)
|
|
338
|
+
let fileNameLength = UInt16(archive[offset + 26]) | (UInt16(archive[offset + 27]) << 8)
|
|
339
|
+
let extraFieldLength = UInt16(archive[offset + 28]) | (UInt16(archive[offset + 29]) << 8)
|
|
340
|
+
|
|
341
|
+
let headerEnd = offset + 30
|
|
342
|
+
let fileNameData = archive.subdata(in: headerEnd..<(headerEnd + Int(fileNameLength)))
|
|
343
|
+
let fileName = String(data: fileNameData, encoding: .utf8) ?? ""
|
|
344
|
+
|
|
345
|
+
let dataStart = headerEnd + Int(fileNameLength) + Int(extraFieldLength)
|
|
346
|
+
let dataEnd = dataStart + Int(compressedSize)
|
|
347
|
+
|
|
348
|
+
let filePath = destinationURL.appendingPathComponent(fileName)
|
|
349
|
+
|
|
350
|
+
if fileName.hasSuffix("/") {
|
|
351
|
+
// Directory
|
|
352
|
+
try FileManager.default.createDirectory(at: filePath, withIntermediateDirectories: true)
|
|
353
|
+
} else if !fileName.isEmpty && !fileName.hasPrefix("__MACOSX") {
|
|
354
|
+
// File
|
|
355
|
+
try FileManager.default.createDirectory(at: filePath.deletingLastPathComponent(), withIntermediateDirectories: true)
|
|
356
|
+
|
|
357
|
+
if compressionMethod == 0 {
|
|
358
|
+
// Stored (no compression)
|
|
359
|
+
let fileData = archive.subdata(in: dataStart..<dataEnd)
|
|
360
|
+
try fileData.write(to: filePath)
|
|
361
|
+
} else if compressionMethod == 8 {
|
|
362
|
+
// Deflate compression - use native decompression
|
|
363
|
+
let compressedData = archive.subdata(in: dataStart..<dataEnd)
|
|
364
|
+
if let decompressed = decompressDeflateDataForZip(compressedData, uncompressedSize: Int(uncompressedSize)) {
|
|
365
|
+
try decompressed.write(to: filePath)
|
|
366
|
+
} else {
|
|
367
|
+
SDKLogger.archive.warning("Failed to decompress \(fileName)")
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
SDKLogger.archive.warning("Unsupported compression method \(compressionMethod) for \(fileName)")
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
fileCount += 1
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
offset = dataEnd
|
|
377
|
+
progressHandler?(Double(offset) / Double(totalSize))
|
|
378
|
+
} else if sig0 == 0x50 && sig1 == 0x4b && sig2 == 0x01 && sig3 == 0x02 {
|
|
379
|
+
// Central directory - we're done with files
|
|
380
|
+
break
|
|
381
|
+
} else if sig0 == 0x50 && sig1 == 0x4b && sig2 == 0x05 && sig3 == 0x06 {
|
|
382
|
+
// End of central directory
|
|
383
|
+
break
|
|
384
|
+
} else {
|
|
385
|
+
offset += 1
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
SDKLogger.archive.info("Extracted \(fileCount) files from zip")
|
|
390
|
+
progressHandler?(1.0)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/// Decompress deflate data for ZIP files
|
|
394
|
+
private static func decompressDeflateDataForZip(_ data: Data, uncompressedSize: Int) -> Data? {
|
|
395
|
+
var destinationBufferSize = max(uncompressedSize, data.count * 4)
|
|
396
|
+
var decompressedData = Data(count: destinationBufferSize)
|
|
397
|
+
|
|
398
|
+
let decompressedSize = data.withUnsafeBytes { (srcPtr: UnsafeRawBufferPointer) -> Int in
|
|
399
|
+
guard let sourceAddress = srcPtr.baseAddress else { return 0 }
|
|
400
|
+
|
|
401
|
+
return decompressedData.withUnsafeMutableBytes { (destPtr: UnsafeMutableRawBufferPointer) -> Int in
|
|
402
|
+
guard let destAddress = destPtr.baseAddress else { return 0 }
|
|
403
|
+
|
|
404
|
+
// Use COMPRESSION_ZLIB for raw deflate
|
|
405
|
+
return compression_decode_buffer(
|
|
406
|
+
destAddress.assumingMemoryBound(to: UInt8.self),
|
|
407
|
+
destinationBufferSize,
|
|
408
|
+
sourceAddress.assumingMemoryBound(to: UInt8.self),
|
|
409
|
+
data.count,
|
|
410
|
+
nil,
|
|
411
|
+
COMPRESSION_ZLIB
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
guard decompressedSize > 0 else { return nil }
|
|
417
|
+
decompressedData.count = decompressedSize
|
|
418
|
+
return decompressedData
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// MARK: - TAR Extraction (Pure Swift)
|
|
422
|
+
|
|
423
|
+
/// Extract tar data to destination directory
|
|
424
|
+
private static func extractTarData(
|
|
425
|
+
_ tarData: Data,
|
|
426
|
+
to destinationURL: URL,
|
|
427
|
+
progressHandler: ((Double) -> Void)?
|
|
428
|
+
) throws {
|
|
429
|
+
// Create destination directory
|
|
430
|
+
try FileManager.default.createDirectory(at: destinationURL, withIntermediateDirectories: true)
|
|
431
|
+
|
|
432
|
+
var offset = 0
|
|
433
|
+
let totalSize = tarData.count
|
|
434
|
+
var fileCount = 0
|
|
435
|
+
|
|
436
|
+
while offset + 512 <= tarData.count {
|
|
437
|
+
// Read tar header (512 bytes)
|
|
438
|
+
let headerData = tarData.subdata(in: offset..<(offset + 512))
|
|
439
|
+
|
|
440
|
+
// Check for end of archive (two consecutive zero blocks)
|
|
441
|
+
if headerData.allSatisfy({ $0 == 0 }) {
|
|
442
|
+
break
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Parse header
|
|
446
|
+
let nameData = headerData.subdata(in: 0..<100)
|
|
447
|
+
let sizeData = headerData.subdata(in: 124..<136)
|
|
448
|
+
let typeFlag = headerData[156]
|
|
449
|
+
let prefixData = headerData.subdata(in: 345..<500)
|
|
450
|
+
|
|
451
|
+
// Get file name
|
|
452
|
+
let name = extractNullTerminatedString(from: nameData)
|
|
453
|
+
let prefix = extractNullTerminatedString(from: prefixData)
|
|
454
|
+
let fullName = prefix.isEmpty ? name : "\(prefix)/\(name)"
|
|
455
|
+
|
|
456
|
+
// Skip if name is empty or is macOS resource fork
|
|
457
|
+
guard !fullName.isEmpty, !fullName.hasPrefix("._") else {
|
|
458
|
+
offset += 512
|
|
459
|
+
continue
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// Parse file size (octal)
|
|
463
|
+
let sizeString = extractNullTerminatedString(from: sizeData).trimmingCharacters(in: .whitespaces)
|
|
464
|
+
let fileSize = Int(sizeString, radix: 8) ?? 0
|
|
465
|
+
|
|
466
|
+
offset += 512 // Move past header
|
|
467
|
+
|
|
468
|
+
let filePath = destinationURL.appendingPathComponent(fullName)
|
|
469
|
+
|
|
470
|
+
// Handle different entry types
|
|
471
|
+
if typeFlag == 0x35 || (typeFlag == 0x30 && fullName.hasSuffix("/")) { // Directory
|
|
472
|
+
try FileManager.default.createDirectory(at: filePath, withIntermediateDirectories: true)
|
|
473
|
+
} else if typeFlag == 0x30 || typeFlag == 0 { // Regular file
|
|
474
|
+
// Ensure parent directory exists
|
|
475
|
+
try FileManager.default.createDirectory(at: filePath.deletingLastPathComponent(), withIntermediateDirectories: true)
|
|
476
|
+
|
|
477
|
+
// Extract file data
|
|
478
|
+
if fileSize > 0 && offset + fileSize <= tarData.count {
|
|
479
|
+
let fileData = tarData.subdata(in: offset..<(offset + fileSize))
|
|
480
|
+
try fileData.write(to: filePath)
|
|
481
|
+
} else {
|
|
482
|
+
// Create empty file
|
|
483
|
+
FileManager.default.createFile(atPath: filePath.path, contents: nil)
|
|
484
|
+
}
|
|
485
|
+
fileCount += 1
|
|
486
|
+
} else if typeFlag == 0x32 { // Symbolic link
|
|
487
|
+
let linkName = extractNullTerminatedString(from: headerData.subdata(in: 157..<257))
|
|
488
|
+
if !linkName.isEmpty {
|
|
489
|
+
try FileManager.default.createDirectory(at: filePath.deletingLastPathComponent(), withIntermediateDirectories: true)
|
|
490
|
+
try? FileManager.default.createSymbolicLink(atPath: filePath.path, withDestinationPath: linkName)
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// Move to next entry (file data + padding to 512-byte boundary)
|
|
495
|
+
offset += fileSize
|
|
496
|
+
let padding = (512 - (fileSize % 512)) % 512
|
|
497
|
+
offset += padding
|
|
498
|
+
|
|
499
|
+
// Report progress
|
|
500
|
+
progressHandler?(Double(offset) / Double(totalSize))
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
SDKLogger.archive.info("Extracted \(fileCount) files")
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// MARK: - Helpers
|
|
507
|
+
|
|
508
|
+
private static func extractNullTerminatedString(from data: Data) -> String {
|
|
509
|
+
if let nullIndex = data.firstIndex(of: 0) {
|
|
510
|
+
return String(data: data.subdata(in: 0..<nullIndex), encoding: .utf8) ?? ""
|
|
511
|
+
}
|
|
512
|
+
return String(data: data, encoding: .utf8) ?? ""
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
private static func formatBytes(_ bytes: Int) -> String {
|
|
516
|
+
if bytes < 1024 {
|
|
517
|
+
return "\(bytes) B"
|
|
518
|
+
} else if bytes < 1024 * 1024 {
|
|
519
|
+
return String(format: "%.1f KB", Double(bytes) / 1024)
|
|
520
|
+
} else if bytes < 1024 * 1024 * 1024 {
|
|
521
|
+
return String(format: "%.1f MB", Double(bytes) / (1024 * 1024))
|
|
522
|
+
} else {
|
|
523
|
+
return String(format: "%.2f GB", Double(bytes) / (1024 * 1024 * 1024))
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiveUtilityBridge.m
|
|
3
|
+
*
|
|
4
|
+
* C bridge to call Swift ArchiveUtility from C++.
|
|
5
|
+
* This bridge is necessary because C++ cannot directly call Swift code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import "RNSDKLoggerBridge.h"
|
|
10
|
+
|
|
11
|
+
static NSString * const kLogCategory = @"ArchiveBridge";
|
|
12
|
+
|
|
13
|
+
// Import the generated Swift header from the pod
|
|
14
|
+
#if __has_include(<RunAnywhereCore/RunAnywhereCore-Swift.h>)
|
|
15
|
+
#import <RunAnywhereCore/RunAnywhereCore-Swift.h>
|
|
16
|
+
#elif __has_include("RunAnywhereCore-Swift.h")
|
|
17
|
+
#import "RunAnywhereCore-Swift.h"
|
|
18
|
+
#else
|
|
19
|
+
// Forward declare the Swift class if header not found
|
|
20
|
+
@interface ArchiveUtility : NSObject
|
|
21
|
+
+ (BOOL)extractWithArchivePath:(NSString * _Nonnull)archivePath to:(NSString * _Nonnull)destinationPath;
|
|
22
|
+
@end
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Extract an archive to a destination directory
|
|
27
|
+
* Called from C++ HybridRunAnywhereCore::extractArchive
|
|
28
|
+
*/
|
|
29
|
+
bool ArchiveUtility_extract(const char* archivePath, const char* destinationPath) {
|
|
30
|
+
@autoreleasepool {
|
|
31
|
+
if (archivePath == NULL || destinationPath == NULL) {
|
|
32
|
+
RN_LOG_ERROR(kLogCategory, @"Invalid null path");
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
NSString* archivePathStr = [NSString stringWithUTF8String:archivePath];
|
|
37
|
+
NSString* destinationPathStr = [NSString stringWithUTF8String:destinationPath];
|
|
38
|
+
|
|
39
|
+
if (archivePathStr == nil || destinationPathStr == nil) {
|
|
40
|
+
RN_LOG_ERROR(kLogCategory, @"Failed to create NSString from path");
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@try {
|
|
45
|
+
BOOL result = [ArchiveUtility extractWithArchivePath:archivePathStr to:destinationPathStr];
|
|
46
|
+
return result;
|
|
47
|
+
} @catch (NSException *exception) {
|
|
48
|
+
RN_LOG_ERROR(kLogCategory, @"Exception: %@", exception);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AudioDecoder.h
|
|
3
|
+
*
|
|
4
|
+
* iOS audio file decoder using built-in AudioToolbox.
|
|
5
|
+
* Converts any audio format (M4A, CAF, WAV, etc.) to PCM float32 samples.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#ifndef AudioDecoder_h
|
|
9
|
+
#define AudioDecoder_h
|
|
10
|
+
|
|
11
|
+
#include <stddef.h>
|
|
12
|
+
|
|
13
|
+
#ifdef __cplusplus
|
|
14
|
+
extern "C" {
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Decode an audio file to PCM float32 samples at 16kHz mono
|
|
19
|
+
* Works with any iOS-supported audio format (M4A, CAF, WAV, MP3, etc.)
|
|
20
|
+
*
|
|
21
|
+
* @param filePath Path to the audio file (null-terminated C string)
|
|
22
|
+
* @param samples Output: pointer to float array (caller must free with ra_free_audio_samples)
|
|
23
|
+
* @param numSamples Output: number of samples
|
|
24
|
+
* @param sampleRate Output: sample rate (will be 16000 Hz)
|
|
25
|
+
* @return 1 on success, 0 on failure
|
|
26
|
+
*/
|
|
27
|
+
int ra_decode_audio_file(const char* filePath, float** samples, size_t* numSamples, int* sampleRate);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Free samples allocated by ra_decode_audio_file
|
|
31
|
+
*/
|
|
32
|
+
void ra_free_audio_samples(float* samples);
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif /* AudioDecoder_h */
|