@iternio/react-native-auto-play 0.6.0 → 0.7.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/README.md +59 -10
- package/android/src/automotive/AndroidManifest-nonnav.xml +0 -2
- package/android/src/automotive/AndroidManifest.xml +0 -2
- package/android/src/main/AndroidManifest-nonnav.xml +0 -2
- package/android/src/main/AndroidManifest.xml +0 -2
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoService.kt +3 -27
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlayTiming.kt +122 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/Parser.kt +49 -14
- package/installTimers.ts +3 -0
- package/installTimers.web.ts +2 -0
- package/ios/hybrid/HybridAutoPlayTiming.swift +123 -0
- package/jest.js +2 -0
- package/lib/components/SafeAreaView.js +1 -1
- package/lib/hybrid/HybridAutoPlayTiming.d.ts +2 -0
- package/lib/hybrid/HybridAutoPlayTiming.js +2 -0
- package/lib/hybrid/HybridVoice.js +2 -2
- package/lib/index.js +0 -2
- package/lib/index.web.d.ts +75 -0
- package/lib/index.web.js +72 -1
- package/lib/installTimers.d.ts +1 -0
- package/lib/installTimers.js +8 -0
- package/lib/installTimers.web.d.ts +1 -0
- package/lib/installTimers.web.js +2 -0
- package/lib/scenes/CarPlayDashboardScene.d.ts +3 -3
- package/lib/specs/AutoPlayTiming.nitro.d.ts +27 -0
- package/lib/specs/AutoPlayTiming.nitro.js +1 -0
- package/lib/types/Image.d.ts +6 -1
- package/lib/types/Telemetry.d.ts +1 -1
- package/lib/utils/AutoPlayTimers.d.ts +21 -0
- package/lib/utils/AutoPlayTimers.js +45 -0
- package/lib/utils/NitroColor.d.ts +1 -0
- package/lib/utils/NitroColor.js +8 -0
- package/lib/utils/NitroImage.d.ts +5 -2
- package/lib/utils/NitroImage.js +2 -2
- package/lib/utils/NitroManeuver.js +1 -3
- package/lib-cjs/Constants.js +9 -0
- package/lib-cjs/components/MapTemplateContext.js +10 -0
- package/lib-cjs/components/SafeAreaInsetsContext.js +21 -0
- package/lib-cjs/components/SafeAreaView.js +22 -0
- package/lib-cjs/components/WindowInformationWrapper.js +20 -0
- package/lib-cjs/hooks/useAndroidAutoTelemetry.js +115 -0
- package/lib-cjs/hooks/useFocusedEffect.js +35 -0
- package/lib-cjs/hooks/useMapTemplate.js +13 -0
- package/lib-cjs/hooks/useSafeAreaInsets.js +9 -0
- package/lib-cjs/hooks/useVoiceInput.js +42 -0
- package/lib-cjs/hybrid/HybridAndroidAutoTelemetry.js +4 -0
- package/lib-cjs/hybrid/HybridAndroidWindowInformation.js +4 -0
- package/lib-cjs/hybrid/HybridAutoPlay.js +5 -0
- package/lib-cjs/hybrid/HybridVoice.js +61 -0
- package/lib-cjs/index.js +71 -0
- package/lib-cjs/index.web.js +98 -0
- package/lib-cjs/scenes/AutoPlayCluster.js +140 -0
- package/lib-cjs/scenes/CarPlayDashboardScene.js +100 -0
- package/lib-cjs/specs/AndroidAutoTelemetry.nitro.js +2 -0
- package/lib-cjs/specs/AndroidAutomotive.nitro.js +16 -0
- package/lib-cjs/specs/AndroidWindowInformation.nitro.js +2 -0
- package/lib-cjs/specs/AutoPlay.nitro.js +2 -0
- package/lib-cjs/specs/CarPlayDashboard.nitro.js +2 -0
- package/lib-cjs/specs/Cluster.nitro.js +2 -0
- package/lib-cjs/specs/GridTemplate.nitro.js +2 -0
- package/lib-cjs/specs/InformationTemplate.nitro.js +2 -0
- package/lib-cjs/specs/ListTemplate.nitro.js +2 -0
- package/lib-cjs/specs/MapTemplate.nitro.js +2 -0
- package/lib-cjs/specs/MessageTemplate.nitro.js +2 -0
- package/lib-cjs/specs/SearchTemplate.nitro.js +2 -0
- package/lib-cjs/specs/SignInTemplate.nitro.js +2 -0
- package/lib-cjs/specs/Voice.nitro.js +2 -0
- package/lib-cjs/templates/GridTemplate.js +41 -0
- package/lib-cjs/templates/InformationTemplate.js +49 -0
- package/lib-cjs/templates/ListTemplate.js +33 -0
- package/lib-cjs/templates/MapTemplate.js +168 -0
- package/lib-cjs/templates/MessageTemplate.js +50 -0
- package/lib-cjs/templates/SearchTemplate.js +32 -0
- package/lib-cjs/templates/SignInTemplate.js +55 -0
- package/lib-cjs/templates/Template.js +40 -0
- package/lib-cjs/types/Button.js +12 -0
- package/lib-cjs/types/Event.js +2 -0
- package/lib-cjs/types/Image.js +2 -0
- package/lib-cjs/types/Maneuver.js +77 -0
- package/lib-cjs/types/RootComponent.js +2 -0
- package/lib-cjs/types/SignInMethod.js +22 -0
- package/lib-cjs/types/Telemetry.js +24 -0
- package/lib-cjs/types/Text.js +8 -0
- package/lib-cjs/types/Trip.js +2 -0
- package/lib-cjs/types/Voice.js +2 -0
- package/lib-cjs/utils/ErrorUtil.js +34 -0
- package/lib-cjs/utils/NitroAction.js +129 -0
- package/lib-cjs/utils/NitroAlert.js +19 -0
- package/lib-cjs/utils/NitroAttributedString.js +14 -0
- package/lib-cjs/utils/NitroColor.js +32 -0
- package/lib-cjs/utils/NitroGrid.js +12 -0
- package/lib-cjs/utils/NitroImage.js +97 -0
- package/lib-cjs/utils/NitroManeuver.js +79 -0
- package/lib-cjs/utils/NitroMapButton.js +33 -0
- package/lib-cjs/utils/NitroOptionsPanel.js +66 -0
- package/lib-cjs/utils/NitroSection.js +112 -0
- package/nitro.json +10 -0
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +2 -0
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +16 -0
- package/nitrogen/generated/android/c++/JActiveCarUxRestrictions.hpp +1 -1
- package/nitrogen/generated/android/c++/JAlertActionStyle.hpp +1 -1
- package/nitrogen/generated/android/c++/JAlertDismissalReason.hpp +1 -1
- package/nitrogen/generated/android/c++/JAppFocusState.hpp +1 -1
- package/nitrogen/generated/android/c++/JAssetImage.hpp +18 -18
- package/nitrogen/generated/android/c++/JAutoText.hpp +1 -1
- package/nitrogen/generated/android/c++/JBooleanTelemetryItem.hpp +1 -1
- package/nitrogen/generated/android/c++/JCarUxRestrictions.hpp +1 -1
- package/nitrogen/generated/android/c++/JChargingConnector.hpp +1 -1
- package/nitrogen/generated/android/c++/JClusterEventName.hpp +1 -1
- package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
- package/nitrogen/generated/android/c++/JDistance.hpp +1 -1
- package/nitrogen/generated/android/c++/JDistanceUnits.hpp +1 -1
- package/nitrogen/generated/android/c++/JDurationWithTimeZone.hpp +1 -1
- package/nitrogen/generated/android/c++/JEventName.hpp +1 -1
- package/nitrogen/generated/android/c++/JForkType.hpp +1 -1
- package/nitrogen/generated/android/c++/JGlyphImage.hpp +1 -1
- package/nitrogen/generated/android/c++/JGoogleSignIn.hpp +1 -1
- package/nitrogen/generated/android/c++/JGoogleSignInAccount.hpp +1 -1
- package/nitrogen/generated/android/c++/JGridImageSize.hpp +1 -1
- package/nitrogen/generated/android/c++/JGridTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridAutoPlayTimingSpec.cpp +59 -0
- package/nitrogen/generated/android/c++/JHybridAutoPlayTimingSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JImageLane.hpp +1 -1
- package/nitrogen/generated/android/c++/JInformationTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JInputSignIn.hpp +1 -1
- package/nitrogen/generated/android/c++/JKeepType.hpp +1 -1
- package/nitrogen/generated/android/c++/JKeyboardType.hpp +1 -1
- package/nitrogen/generated/android/c++/JLaneGuidance.hpp +1 -1
- package/nitrogen/generated/android/c++/JListImageType.hpp +1 -1
- package/nitrogen/generated/android/c++/JListTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JLocation.hpp +1 -1
- package/nitrogen/generated/android/c++/JManeuverState.hpp +1 -1
- package/nitrogen/generated/android/c++/JManeuverType.hpp +1 -1
- package/nitrogen/generated/android/c++/JMapTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JMessageTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JNavigationAlertAction.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroAction.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroActionType.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroAlignment.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroAttributedString.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroAttributedStringImage.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroBaseMapTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroButtonStyle.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroChargerLocation.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroChargerOutlet.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroColor.hpp +9 -5
- package/nitrogen/generated/android/c++/JNitroGridButton.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroLoadingManeuver.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroMapButton.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroMapButtonType.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroMessageManeuver.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroNavigationAlert.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroOptionsPanelChargerSection.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroOptionsPanelConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroOptionsPanelGridSection.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroRoutingManeuver.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroRow.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroSection.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroSectionType.hpp +1 -1
- package/nitrogen/generated/android/c++/JNumericTelemetryItem.hpp +1 -1
- package/nitrogen/generated/android/c++/JOffRampType.hpp +1 -1
- package/nitrogen/generated/android/c++/JOnRampType.hpp +1 -1
- package/nitrogen/generated/android/c++/JPermissionRequestResult.hpp +1 -1
- package/nitrogen/generated/android/c++/JPinSignIn.hpp +1 -1
- package/nitrogen/generated/android/c++/JPoint.hpp +1 -1
- package/nitrogen/generated/android/c++/JPreferredImageLane.hpp +1 -1
- package/nitrogen/generated/android/c++/JQrSignIn.hpp +1 -1
- package/nitrogen/generated/android/c++/JRemoteImage.hpp +1 -1
- package/nitrogen/generated/android/c++/JRouteChoice.hpp +1 -1
- package/nitrogen/generated/android/c++/JSafeAreaInsets.hpp +1 -1
- package/nitrogen/generated/android/c++/JSearchTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JSignInMethods.hpp +1 -1
- package/nitrogen/generated/android/c++/JSignInTemplateConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JStringTelemetryItem.hpp +1 -1
- package/nitrogen/generated/android/c++/JTelemetry.hpp +1 -1
- package/nitrogen/generated/android/c++/JTextInputType.hpp +1 -1
- package/nitrogen/generated/android/c++/JTrafficSide.hpp +1 -1
- package/nitrogen/generated/android/c++/JTravelEstimates.hpp +1 -1
- package/nitrogen/generated/android/c++/JTripConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JTripPoint.hpp +1 -1
- package/nitrogen/generated/android/c++/JTripPreviewTextConfiguration.hpp +1 -1
- package/nitrogen/generated/android/c++/JTripSelectorCallback.hpp +1 -1
- package/nitrogen/generated/android/c++/JTripsConfig.hpp +1 -1
- package/nitrogen/generated/android/c++/JTurnType.hpp +1 -1
- package/nitrogen/generated/android/c++/JVehicleTelemetryItem.hpp +1 -1
- package/nitrogen/generated/android/c++/JVisibilityState.hpp +1 -1
- package/nitrogen/generated/android/c++/JVisibleTravelEstimate.hpp +1 -1
- package/nitrogen/generated/android/c++/JVoiceAudioEncoding.hpp +1 -1
- package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +1 -1
- package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +1 -1
- package/nitrogen/generated/android/c++/JWaypointCoordinate.hpp +1 -1
- package/nitrogen/generated/android/c++/JWindowInformation.hpp +1 -1
- package/nitrogen/generated/android/c++/JZoomEvent.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AssetImage.kt +15 -15
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_ActiveCarUxRestrictions.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_AlertDismissalReason.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_AppFocusState.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_ColorScheme.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_Point.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_Point_double.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_Point_std__optional_Point_.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_SafeAreaInsets.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VisibilityState.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_WindowInformation.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_bool.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__optional_Location__std__optional_std__string_.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__optional_Telemetry_.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__optional_bool_.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__optional_std__string__std__optional_GoogleSignInAccount_.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__string.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__string_ColorScheme.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__string_ZoomEvent.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__string_bool.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__string_std__string.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutoTelemetrySpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotiveSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidWindowInformationSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlayTimingSpec.kt +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridClusterSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridGridTemplateSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridInformationTemplateSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridListTemplateSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMapTemplateSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridMessageTemplateSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridSearchTemplateSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridSignInTemplateSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroColor.kt +9 -4
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +35 -9
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +5 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +8 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridAutoPlayTimingSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridAutoPlayTimingSpecSwift.hpp +88 -0
- package/nitrogen/generated/ios/swift/AssetImage.swift +13 -13
- package/nitrogen/generated/ios/swift/HybridAutoPlayTimingSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridAutoPlayTimingSpec_cxx.swift +154 -0
- package/nitrogen/generated/ios/swift/NitroColor.swift +20 -2
- package/nitrogen/generated/shared/c++/AssetImage.hpp +18 -18
- package/nitrogen/generated/shared/c++/HybridAutoPlayTimingSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlayTimingSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/NitroColor.hpp +7 -3
- package/package.json +12 -6
- package/src/components/SafeAreaView.tsx +1 -1
- package/src/hybrid/HybridAutoPlayTiming.ts +5 -0
- package/src/hybrid/HybridVoice.ts +2 -2
- package/src/index.ts +0 -3
- package/src/index.web.ts +166 -0
- package/src/installTimers.ts +9 -0
- package/src/installTimers.web.ts +2 -0
- package/src/specs/AutoPlayTiming.nitro.ts +25 -0
- package/src/types/Image.ts +6 -1
- package/src/types/Telemetry.ts +1 -1
- package/src/utils/AutoPlayTimers.ts +60 -0
- package/src/utils/NitroColor.ts +10 -1
- package/src/utils/NitroImage.ts +14 -8
- package/src/utils/NitroManeuver.ts +1 -4
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HeadlessTaskService.kt +0 -36
- package/lib/AutoPlayHeadlessJsTask.d.ts +0 -5
- package/lib/AutoPlayHeadlessJsTask.js +0 -14
- package/src/AutoPlayHeadlessJsTask.ts +0 -22
package/src/index.web.ts
CHANGED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// Web/Jest stub for the native CarPlay/Android Auto surface. Nothing here talks to a real native
|
|
2
|
+
// module — every function call resolves to `undefined` (or an already-resolved promise, which is
|
|
3
|
+
// indistinguishable from `undefined` to an `await`er) rather than throwing. Types are preserved by
|
|
4
|
+
// casting against the real exports, so callers still get full type-checking/autocomplete.
|
|
5
|
+
//
|
|
6
|
+
// Anything below that's already safe as-is (pure types, plain enums, or modules that neither
|
|
7
|
+
// create native objects nor import anything that does) is re-exported directly instead of stubbed.
|
|
8
|
+
|
|
9
|
+
import { createElement } from 'react';
|
|
10
|
+
import { View, type ViewProps } from 'react-native';
|
|
11
|
+
import type { AndroidAutomotive } from './specs/AndroidAutomotive.nitro';
|
|
12
|
+
import type { AutoPlay } from './specs/AutoPlay.nitro';
|
|
13
|
+
import type { Voice } from './specs/Voice.nitro';
|
|
14
|
+
import type { GridTemplate as RealGridTemplate } from './templates/GridTemplate';
|
|
15
|
+
import type { InformationTemplate as RealInformationTemplate } from './templates/InformationTemplate';
|
|
16
|
+
import type { ListTemplate as RealListTemplate } from './templates/ListTemplate';
|
|
17
|
+
import type { MapTemplate as RealMapTemplate } from './templates/MapTemplate';
|
|
18
|
+
import type { MessageTemplate as RealMessageTemplate } from './templates/MessageTemplate';
|
|
19
|
+
import type { SearchTemplate as RealSearchTemplate } from './templates/SearchTemplate';
|
|
20
|
+
import type { SignInTemplate as RealSignInTemplate } from './templates/SignInTemplate';
|
|
21
|
+
import type { Template as RealTemplate } from './templates/Template';
|
|
22
|
+
import type { SafeAreaInsets } from './types/Event';
|
|
23
|
+
import type { Telemetry } from './types/Telemetry';
|
|
24
|
+
|
|
25
|
+
function noop() {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Any property access returns a no-op function, so any method call is safe regardless of name. */
|
|
30
|
+
function createNoopObject<T>(): T {
|
|
31
|
+
return new Proxy(
|
|
32
|
+
{},
|
|
33
|
+
{
|
|
34
|
+
get: (_target, prop) => (prop === 'then' || prop === 'toJSON' ? undefined : noop),
|
|
35
|
+
}
|
|
36
|
+
) as T;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createNoopClass<T>(): new (...args: never[]) => T {
|
|
40
|
+
function NoopInstance() {
|
|
41
|
+
return createNoopObject<T>();
|
|
42
|
+
}
|
|
43
|
+
return NoopInstance as unknown as new (
|
|
44
|
+
...args: never[]
|
|
45
|
+
) => T;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export * from './Constants';
|
|
49
|
+
export * from './hooks/useMapTemplate';
|
|
50
|
+
export type {
|
|
51
|
+
ActiveCarUxRestrictions,
|
|
52
|
+
AppFocusState,
|
|
53
|
+
} from './specs/AndroidAutomotive.nitro';
|
|
54
|
+
export { CarUxRestrictions } from './specs/AndroidAutomotive.nitro';
|
|
55
|
+
export type { GridImageSize, GridTemplateConfig } from './templates/GridTemplate';
|
|
56
|
+
export type { InformationItems, InformationTemplateConfig } from './templates/InformationTemplate';
|
|
57
|
+
export type {
|
|
58
|
+
DefaultRow,
|
|
59
|
+
ListImageType,
|
|
60
|
+
ListTemplateConfig,
|
|
61
|
+
MultiSection,
|
|
62
|
+
RadioRow,
|
|
63
|
+
Section,
|
|
64
|
+
SingleSection,
|
|
65
|
+
TextRow,
|
|
66
|
+
ToggleRow,
|
|
67
|
+
WaypointCoordinate,
|
|
68
|
+
WaypointRow,
|
|
69
|
+
} from './templates/ListTemplate';
|
|
70
|
+
export type {
|
|
71
|
+
BaseMapTemplateConfig,
|
|
72
|
+
ChargerLocation,
|
|
73
|
+
ChargerOutlet,
|
|
74
|
+
ChargingConnector,
|
|
75
|
+
HeaderActionsAndroidMap,
|
|
76
|
+
MapButtons,
|
|
77
|
+
MapHeaderActions,
|
|
78
|
+
MapTemplateConfig,
|
|
79
|
+
OptionsPanelChargerSection,
|
|
80
|
+
OptionsPanelConfig,
|
|
81
|
+
OptionsPanelGridSection,
|
|
82
|
+
OptionsPanelListSection,
|
|
83
|
+
OptionsPanelSection,
|
|
84
|
+
PanelActionsIos,
|
|
85
|
+
PanelHeaderActions,
|
|
86
|
+
Point,
|
|
87
|
+
TripSelectorCallback,
|
|
88
|
+
VisibleTravelEstimate,
|
|
89
|
+
} from './templates/MapTemplate';
|
|
90
|
+
export type { MessageTemplateConfig } from './templates/MessageTemplate';
|
|
91
|
+
export type { SearchSection, SearchTemplateConfig } from './templates/SearchTemplate';
|
|
92
|
+
export type { SignInTemplateConfig } from './templates/SignInTemplate';
|
|
93
|
+
export type {
|
|
94
|
+
ActionButton,
|
|
95
|
+
HeaderActions,
|
|
96
|
+
HeaderActionsAndroid,
|
|
97
|
+
HeaderActionsIos,
|
|
98
|
+
NitroBaseMapTemplateConfig,
|
|
99
|
+
NitroTemplateConfig,
|
|
100
|
+
TemplateConfig,
|
|
101
|
+
} from './templates/Template';
|
|
102
|
+
export * from './types/Button';
|
|
103
|
+
export * from './types/Event';
|
|
104
|
+
export * from './types/Image';
|
|
105
|
+
export * from './types/Maneuver';
|
|
106
|
+
export * from './types/RootComponent';
|
|
107
|
+
export * from './types/SignInMethod';
|
|
108
|
+
export * from './types/Telemetry';
|
|
109
|
+
export * from './types/Text';
|
|
110
|
+
export * from './types/Trip';
|
|
111
|
+
export type { VoiceInputChunk, VoiceInputOptions, VoiceInputResult } from './types/Voice';
|
|
112
|
+
export * from './utils/ErrorUtil';
|
|
113
|
+
export type {
|
|
114
|
+
AlertPriority,
|
|
115
|
+
NavigationAlert as Alert,
|
|
116
|
+
NavigationAlertAction as AlertAction,
|
|
117
|
+
} from './utils/NitroAlert';
|
|
118
|
+
export type { ThemedColor } from './utils/NitroColor';
|
|
119
|
+
export type { GridButton } from './utils/NitroGrid';
|
|
120
|
+
|
|
121
|
+
export enum AutoPlayModules {
|
|
122
|
+
App = 'main',
|
|
123
|
+
AutoPlayRoot = 'AutoPlayRoot',
|
|
124
|
+
CarPlayDashboard = 'CarPlayDashboard',
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const NO_INSETS: SafeAreaInsets = { top: 0, bottom: 0, left: 0, right: 0 };
|
|
128
|
+
export const useSafeAreaInsets = () => NO_INSETS;
|
|
129
|
+
export const SafeAreaView = (props: ViewProps) => createElement(View, props);
|
|
130
|
+
|
|
131
|
+
export function setIconFont(_name: string, _glyphMap?: Record<string, number>): void {}
|
|
132
|
+
|
|
133
|
+
export const useFocusedEffect = () => {};
|
|
134
|
+
|
|
135
|
+
export const useVoiceInput = () => ({
|
|
136
|
+
voiceInputResult: undefined,
|
|
137
|
+
resetVoiceInputResult: () => {},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export const useAndroidAutoTelemetry = (): {
|
|
141
|
+
permissionsGranted: boolean | null;
|
|
142
|
+
telemetry: Telemetry | undefined;
|
|
143
|
+
error: string | undefined;
|
|
144
|
+
} => ({
|
|
145
|
+
permissionsGranted: null,
|
|
146
|
+
telemetry: undefined,
|
|
147
|
+
error: undefined,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export const AutoPlayCluster = createNoopObject<Record<string, unknown>>();
|
|
151
|
+
export const CarPlayDashboard = createNoopObject<Record<string, unknown>>();
|
|
152
|
+
|
|
153
|
+
export const HybridAndroidAutomotive: AndroidAutomotive | null = null;
|
|
154
|
+
export { HybridAndroidAutoTelemetry } from './hybrid/HybridAndroidAutoTelemetry';
|
|
155
|
+
export { HybridAndroidWindowInformation } from './hybrid/HybridAndroidWindowInformation';
|
|
156
|
+
export const HybridAutoPlay = createNoopObject<AutoPlay>();
|
|
157
|
+
export const HybridVoice = createNoopObject<Voice>();
|
|
158
|
+
|
|
159
|
+
export const Template = createNoopClass<InstanceType<typeof RealTemplate>>();
|
|
160
|
+
export const ListTemplate = createNoopClass<RealListTemplate>();
|
|
161
|
+
export const GridTemplate = createNoopClass<RealGridTemplate>();
|
|
162
|
+
export const InformationTemplate = createNoopClass<RealInformationTemplate>();
|
|
163
|
+
export const MessageTemplate = createNoopClass<RealMessageTemplate>();
|
|
164
|
+
export const MapTemplate = createNoopClass<RealMapTemplate>();
|
|
165
|
+
export const SearchTemplate = createNoopClass<RealSearchTemplate>();
|
|
166
|
+
export const SignInTemplate = createNoopClass<RealSignInTemplate>();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Side-effect-only entry point, re-exported at the package root as `installTimers` (see
|
|
2
|
+
// ../installTimers.ts) for `import '@iternio/react-native-auto-play/installTimers';` as the
|
|
3
|
+
// app's first import. installAutoPlayTimers() itself isn't part of the public API -- funneling
|
|
4
|
+
// installation through this one module is what actually guarantees "runs before anything else
|
|
5
|
+
// captures the original globals" (see the README) instead of just documenting it as a rule
|
|
6
|
+
// callers have to get right.
|
|
7
|
+
import { installAutoPlayTimers } from './utils/AutoPlayTimers';
|
|
8
|
+
|
|
9
|
+
installAutoPlayTimers();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Backs setTimeout/setInterval with a scheduler that never pauses -- unlike RN's own JS
|
|
5
|
+
* timers, which RN throttles or pauses whenever the app backgrounds, regardless of whether
|
|
6
|
+
* the process is actually still running.
|
|
7
|
+
*
|
|
8
|
+
* iOS: CarPlay keeps this app's process alive and driving the external screen even when the
|
|
9
|
+
* phone's own screen is off, but RN's own RCTTiming still pauses in that state regardless.
|
|
10
|
+
*
|
|
11
|
+
* Android: JavaTimerManager only keeps ticking while the host is resumed *or* a headless JS
|
|
12
|
+
* task is running -- previously satisfied by registering a permanent no-op headless task
|
|
13
|
+
* (see AutoPlayHeadlessJsTask), which this replaces.
|
|
14
|
+
*
|
|
15
|
+
* All due-time bookkeeping lives here natively (mirroring RCTTiming's/JavaTimerManager's own
|
|
16
|
+
* architecture) so JS only crosses the bridge when a timer actually fires, not on every tick.
|
|
17
|
+
*/
|
|
18
|
+
export interface AutoPlayTiming extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
19
|
+
/**
|
|
20
|
+
* Schedules `callback` to run after `durationMs`, repeating every `durationMs` if `repeats`
|
|
21
|
+
* is true. Returns an id to pass to `deleteTimer`.
|
|
22
|
+
*/
|
|
23
|
+
createTimer(callback: () => void, durationMs: number, repeats: boolean): number;
|
|
24
|
+
deleteTimer(id: number): void;
|
|
25
|
+
}
|
package/src/types/Image.ts
CHANGED
|
@@ -24,7 +24,8 @@ export type GlyphMapKey = keyof AutoPlayGlyphMap extends never
|
|
|
24
24
|
type GlyphStyleFields = {
|
|
25
25
|
/**
|
|
26
26
|
* Sets the icon dark and light mode color or a single color for both.
|
|
27
|
-
* Defaults to white for dark mode and black for light mode
|
|
27
|
+
* Defaults to `'default'` if not specified, which is white for dark mode and black for light mode.
|
|
28
|
+
* On Android Auto the host tint that follows the template is not applied when `backgroundColor` is not transparent.
|
|
28
29
|
* Might not get applied everywhere like MapTemplate buttons on Android.
|
|
29
30
|
*/
|
|
30
31
|
color?: ThemedColor | string;
|
|
@@ -61,6 +62,8 @@ export type AutoImage =
|
|
|
61
62
|
/**
|
|
62
63
|
* if specified the image gets tinted, if not it will just use the original image
|
|
63
64
|
* Might not get applied everywhere like MapTemplate buttons on Android.
|
|
65
|
+
* Use `'default'` for monochrome icons that must stay readable on both dark and light
|
|
66
|
+
* Android Auto templates (17.8+), see README.
|
|
64
67
|
*/
|
|
65
68
|
color?: ThemedColor | string;
|
|
66
69
|
type: 'asset';
|
|
@@ -70,6 +73,8 @@ export type AutoImage =
|
|
|
70
73
|
uri: string;
|
|
71
74
|
/**
|
|
72
75
|
* if specified the image gets tinted, if not it will just use the original image
|
|
76
|
+
* Use `'default'` for monochrome icons that must stay readable on both dark and light
|
|
77
|
+
* Android Auto templates (17.8+), see README.
|
|
73
78
|
*/
|
|
74
79
|
color?: ThemedColor | string;
|
|
75
80
|
/**
|
package/src/types/Telemetry.ts
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { HybridAutoPlayTiming } from '../hybrid/HybridAutoPlayTiming';
|
|
2
|
+
|
|
3
|
+
type TimerCallback = (...args: unknown[]) => void;
|
|
4
|
+
|
|
5
|
+
let installed = false;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Replaces the global `setTimeout`/`setInterval`/`clearTimeout`/`clearInterval` and
|
|
9
|
+
* `requestAnimationFrame`/`cancelAnimationFrame` with implementations backed by the native
|
|
10
|
+
* `AutoPlayTiming` module, so they keep running while the app is actively driving a car
|
|
11
|
+
* surface even though the phone itself is backgrounded or its screen is locked. React
|
|
12
|
+
* Native's own timers throttle or pause in that state regardless of whether the process is
|
|
13
|
+
* actually still alive, which would otherwise stall ETA updates and telemetry polling.
|
|
14
|
+
*
|
|
15
|
+
* `requestIdleCallback`/`cancelIdleCallback` are deliberately not covered: bridgeless RN
|
|
16
|
+
* backs those with a separate native module unrelated to `setTimeout`/`requestAnimationFrame`
|
|
17
|
+
* (and its own callback delivery path is an unimplemented stub on iOS), so there is nothing
|
|
18
|
+
* for this library to intercept there.
|
|
19
|
+
*
|
|
20
|
+
* All due-time bookkeeping happens natively -- this is a thin pass-through, so JS only
|
|
21
|
+
* crosses the bridge when a timer actually fires, not on some fixed interval.
|
|
22
|
+
*
|
|
23
|
+
* Call this **once**, as early as possible in your app -- ideally the first line of your
|
|
24
|
+
* entry file, before any other import -- so nothing else has already captured a reference to
|
|
25
|
+
* the original globals. Safe to call more than once; only the first call has any effect.
|
|
26
|
+
*/
|
|
27
|
+
export function installAutoPlayTimers(): void {
|
|
28
|
+
if (installed || HybridAutoPlayTiming == null) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
installed = true;
|
|
32
|
+
|
|
33
|
+
const timing = HybridAutoPlayTiming;
|
|
34
|
+
|
|
35
|
+
const schedule =
|
|
36
|
+
(repeats: boolean) =>
|
|
37
|
+
(callback: TimerCallback, delay?: number, ...args: unknown[]): number =>
|
|
38
|
+
timing.createTimer(() => callback(...args), delay ?? 0, repeats);
|
|
39
|
+
|
|
40
|
+
const clear = (id: unknown): void => {
|
|
41
|
+
if (typeof id === 'number') {
|
|
42
|
+
timing.deleteTimer(id);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
globalThis.setTimeout = schedule(false) as unknown as typeof setTimeout;
|
|
47
|
+
globalThis.setInterval = schedule(true) as unknown as typeof setInterval;
|
|
48
|
+
globalThis.clearTimeout = clear as unknown as typeof clearTimeout;
|
|
49
|
+
globalThis.clearInterval = clear as unknown as typeof clearInterval;
|
|
50
|
+
|
|
51
|
+
// Mirrors bridgeless RN's own implementation: requestAnimationFrame is setTimeout(0) with
|
|
52
|
+
// a performance.now() timestamp handed to the callback, and cancelAnimationFrame deletes
|
|
53
|
+
// the same underlying timer clearTimeout would.
|
|
54
|
+
const now = () =>
|
|
55
|
+
(globalThis as { performance?: { now(): number } }).performance?.now() ?? Date.now();
|
|
56
|
+
|
|
57
|
+
globalThis.requestAnimationFrame = ((callback: (timestamp: number) => void): number =>
|
|
58
|
+
timing.createTimer(() => callback(now()), 0, false)) as unknown as typeof requestAnimationFrame;
|
|
59
|
+
globalThis.cancelAnimationFrame = clear as unknown as typeof cancelAnimationFrame;
|
|
60
|
+
}
|
package/src/utils/NitroColor.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { processColor } from 'react-native';
|
|
2
2
|
|
|
3
|
-
export type NitroColor = { lightColor: number; darkColor: number };
|
|
3
|
+
export type NitroColor = { lightColor: number; darkColor: number; isDefault?: boolean };
|
|
4
4
|
export type ThemedColor = { lightColor: string; darkColor: string };
|
|
5
5
|
|
|
6
|
+
const DefaultNitroColor = {
|
|
7
|
+
darkColor: convertColor('white'),
|
|
8
|
+
lightColor: convertColor('black'),
|
|
9
|
+
isDefault: true,
|
|
10
|
+
};
|
|
11
|
+
|
|
6
12
|
function convertColor(color: string): number;
|
|
7
13
|
function convertColor(color?: string): number | undefined;
|
|
8
14
|
function convertColor(color?: string): number | undefined {
|
|
@@ -18,6 +24,9 @@ function convert(color?: ThemedColor | string): NitroColor | undefined {
|
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
if (typeof color === 'string') {
|
|
27
|
+
if (color === 'default') {
|
|
28
|
+
return DefaultNitroColor;
|
|
29
|
+
}
|
|
21
30
|
const convertedColor = convertColor(color);
|
|
22
31
|
return { darkColor: convertedColor, lightColor: convertedColor };
|
|
23
32
|
}
|
package/src/utils/NitroImage.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Image
|
|
1
|
+
import { Image } from 'react-native';
|
|
2
2
|
import type { AutoImage } from '../types/Image';
|
|
3
3
|
import { type NitroColor, NitroColorUtil } from './NitroColor';
|
|
4
4
|
|
|
@@ -64,7 +64,11 @@ function resolveGlyph(image: Extract<AutoImage, { type: 'glyph' }>): number {
|
|
|
64
64
|
throw new Error('Glyph image must provide either `name` or `codepoint`.');
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
interface AssetImage
|
|
67
|
+
interface AssetImage {
|
|
68
|
+
uri: string;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
scale: number;
|
|
68
72
|
color?: NitroColor;
|
|
69
73
|
packager_asset: boolean;
|
|
70
74
|
}
|
|
@@ -96,11 +100,7 @@ function convert(image?: AutoImage): NitroImage | undefined {
|
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
if (image.type === 'glyph') {
|
|
99
|
-
const {
|
|
100
|
-
color = { darkColor: 'white', lightColor: 'black' },
|
|
101
|
-
fontScale,
|
|
102
|
-
backgroundColor = 'transparent',
|
|
103
|
-
} = image;
|
|
103
|
+
const { color = 'default', fontScale, backgroundColor = 'transparent' } = image;
|
|
104
104
|
|
|
105
105
|
return {
|
|
106
106
|
glyph: resolveGlyph(image),
|
|
@@ -123,7 +123,13 @@ function convert(image?: AutoImage): NitroImage | undefined {
|
|
|
123
123
|
// so the input allows all optional parameters which are returned as is even though
|
|
124
124
|
// the return type claims to not have any optional parameters...
|
|
125
125
|
// we specify some default values to not crash because of proper typing required by nitro-modules
|
|
126
|
-
const {
|
|
126
|
+
const {
|
|
127
|
+
height = 0,
|
|
128
|
+
scale = 0,
|
|
129
|
+
uri = '',
|
|
130
|
+
width = 0,
|
|
131
|
+
...rest
|
|
132
|
+
} = Image.resolveAssetSource(image.image) ?? {};
|
|
127
133
|
|
|
128
134
|
const assetImage: AssetImage = {
|
|
129
135
|
height,
|
|
@@ -71,10 +71,7 @@ function convertManeuverImage(image?: ManeuverImage): NitroImage | undefined {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (image.type === 'glyph') {
|
|
74
|
-
const color =
|
|
75
|
-
typeof image.color === 'string'
|
|
76
|
-
? image.color
|
|
77
|
-
: (image.color ?? { darkColor: 'white', lightColor: 'black' });
|
|
74
|
+
const color = typeof image.color === 'string' ? image.color : (image.color ?? 'default');
|
|
78
75
|
return NitroImageUtil.convert({
|
|
79
76
|
...image,
|
|
80
77
|
color: color,
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
2
|
-
|
|
3
|
-
import android.content.Intent
|
|
4
|
-
import android.os.Binder
|
|
5
|
-
import android.os.IBinder
|
|
6
|
-
import com.facebook.react.HeadlessJsTaskService
|
|
7
|
-
import com.facebook.react.bridge.Arguments
|
|
8
|
-
import com.facebook.react.bridge.UiThreadUtil
|
|
9
|
-
import com.facebook.react.jstasks.HeadlessJsTaskConfig
|
|
10
|
-
|
|
11
|
-
class HeadlessTaskService : HeadlessJsTaskService() {
|
|
12
|
-
// we use a bound service so it will never be killed when Android Auto is active
|
|
13
|
-
inner class LocalBinder : Binder() {
|
|
14
|
-
fun getService() = this@HeadlessTaskService
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private val mBinder = LocalBinder()
|
|
18
|
-
|
|
19
|
-
override fun getTaskConfig(intent: Intent?): HeadlessJsTaskConfig {
|
|
20
|
-
val data = intent?.extras?.let {
|
|
21
|
-
Arguments.fromBundle(it)
|
|
22
|
-
} ?: Arguments.createMap()
|
|
23
|
-
|
|
24
|
-
return HeadlessJsTaskConfig(
|
|
25
|
-
taskKey = "AndroidAutoHeadlessJsTask", data = data, isAllowedInForeground = true
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
override fun onBind(intent: Intent): IBinder? {
|
|
30
|
-
// Start the headless task when bound
|
|
31
|
-
UiThreadUtil.runOnUiThread {
|
|
32
|
-
startTask(getTaskConfig(intent))
|
|
33
|
-
}
|
|
34
|
-
return mBinder
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AppRegistry, Platform } from 'react-native';
|
|
2
|
-
const createTaskProvider = (hybridAutoPlay) => () => () => new Promise((resolve) => {
|
|
3
|
-
const remove = hybridAutoPlay.addListener('didDisconnect', () => {
|
|
4
|
-
resolve();
|
|
5
|
-
remove();
|
|
6
|
-
});
|
|
7
|
-
});
|
|
8
|
-
const registerHeadlessTask = (hybridAutoPlay) => {
|
|
9
|
-
if (Platform.OS !== 'android') {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
AppRegistry.registerHeadlessTask('AndroidAutoHeadlessJsTask', createTaskProvider(hybridAutoPlay));
|
|
13
|
-
};
|
|
14
|
-
export default { registerHeadlessTask };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { AppRegistry, Platform, type Task, type TaskProvider } from 'react-native';
|
|
2
|
-
import type { AutoPlay as NitroAutoPlay } from './specs/AutoPlay.nitro';
|
|
3
|
-
|
|
4
|
-
const createTaskProvider =
|
|
5
|
-
(hybridAutoPlay: NitroAutoPlay): TaskProvider =>
|
|
6
|
-
(): Task =>
|
|
7
|
-
() =>
|
|
8
|
-
new Promise((resolve) => {
|
|
9
|
-
const remove = hybridAutoPlay.addListener('didDisconnect', () => {
|
|
10
|
-
resolve();
|
|
11
|
-
remove();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const registerHeadlessTask = (hybridAutoPlay: NitroAutoPlay) => {
|
|
16
|
-
if (Platform.OS !== 'android') {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
AppRegistry.registerHeadlessTask('AndroidAutoHeadlessJsTask', createTaskProvider(hybridAutoPlay));
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default { registerHeadlessTask };
|