@craft-native/android 0.0.436 → 0.0.442
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/dist/index.d.ts +8 -0
- package/dist/index.js +18 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/templates/CraftHealthServices.kt.template +2 -0
- package/templates/CraftNativeCapabilities.kt.template +42 -1
- package/templates/CraftNativeMotion.kt.template +269 -0
- package/templates/CraftNativeServices.kt.template +6 -1
- package/templates/CraftPassiveSteps.kt.template +159 -0
- package/templates/CraftRecordingPressure.kt.template +156 -0
- package/templates/LocationRecordingService.kt.template +77 -9
- package/templates/MainActivityNative.kt.template +129 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type { AndroidMapProvider } from './native-map.js';
|
|
|
7
7
|
* well as the one-file bundle, and the app runs each screen from its own
|
|
8
8
|
* route's file. Stacks asks for route bundles only when this is true.
|
|
9
9
|
*/
|
|
10
|
+
/** Build-time proof for Stacks capability mappings, including unreleased source builds. */
|
|
11
|
+
export declare const nativeSensorCapabilities: readonly ['motionSensors', 'barometer', 'pedometer'];
|
|
10
12
|
export declare const nativeRouteBundles = true;
|
|
11
13
|
/**
|
|
12
14
|
* The app evaluates stx's shared runtime (`__runtime.js`, stx's
|
|
@@ -65,6 +67,12 @@ export interface CraftAndroidConfig {
|
|
|
65
67
|
enableSecureStorage?: boolean;
|
|
66
68
|
enableGeolocation?: boolean;
|
|
67
69
|
enableBackgroundLocation?: boolean;
|
|
70
|
+
/** Foreground raw Android sensors on native screens; separate from iOS fused motion. */
|
|
71
|
+
enableMotionSensors?: boolean;
|
|
72
|
+
/** Foreground pressure and session-relative altitude; does not enable background recording. */
|
|
73
|
+
enableBarometer?: boolean;
|
|
74
|
+
/** Foreground hardware step counters/detectors; requires activity recognition on Android 10+. */
|
|
75
|
+
enablePedometer?: boolean;
|
|
68
76
|
enableBluetooth?: boolean;
|
|
69
77
|
/**
|
|
70
78
|
* A Bluetooth heart-rate strap, or a watch broadcasting its heart rate (the
|
package/dist/index.js
CHANGED
|
@@ -549,6 +549,7 @@ function compressNativeSources(target) {
|
|
|
549
549
|
if (packed.length < bytes.length)
|
|
550
550
|
writeFileSync(target, packed);
|
|
551
551
|
}
|
|
552
|
+
var nativeSensorCapabilities = ["motionSensors", "barometer", "pedometer"];
|
|
552
553
|
var nativeRouteBundles = true;
|
|
553
554
|
var nativeRouteRuntime = true;
|
|
554
555
|
var nativeMessages = true;
|
|
@@ -715,6 +716,9 @@ var DEFAULT_CONFIG = {
|
|
|
715
716
|
enableSecureStorage: false,
|
|
716
717
|
enableGeolocation: false,
|
|
717
718
|
enableBackgroundLocation: false,
|
|
719
|
+
enableMotionSensors: false,
|
|
720
|
+
enableBarometer: false,
|
|
721
|
+
enablePedometer: false,
|
|
718
722
|
enableBluetooth: false,
|
|
719
723
|
enableHeartRate: false,
|
|
720
724
|
enableHealthConnect: false,
|
|
@@ -1013,10 +1017,14 @@ function renderAndroidPermissions(config) {
|
|
|
1013
1017
|
}
|
|
1014
1018
|
if (config.enablePushNotifications)
|
|
1015
1019
|
permissions.add("android.permission.POST_NOTIFICATIONS");
|
|
1016
|
-
if (config.enableKeepAwake)
|
|
1020
|
+
if (config.enableKeepAwake || config.enableBarometer && config.enableBackgroundLocation)
|
|
1017
1021
|
permissions.add("android.permission.WAKE_LOCK");
|
|
1018
1022
|
if (config.enableHealthConnect)
|
|
1019
1023
|
healthConnectPermissions(config).forEach((permission) => permissions.add(permission));
|
|
1024
|
+
if (config.enablePedometer)
|
|
1025
|
+
permissions.add("android.permission.ACTIVITY_RECOGNITION");
|
|
1026
|
+
if (config.enablePedometer && config.enableHealthServices)
|
|
1027
|
+
permissions.add("android.permission.RECEIVE_BOOT_COMPLETED");
|
|
1020
1028
|
if (config.renderer === "native" && config.backgroundRefresh?.enabled)
|
|
1021
1029
|
permissions.add("android.permission.RECEIVE_BOOT_COMPLETED");
|
|
1022
1030
|
if (config.enableHeartRate) {
|
|
@@ -1056,13 +1064,16 @@ function writeNativeShellSources(output, packagePath, packageName, config) {
|
|
|
1056
1064
|
write("CraftSnapshotFile.kt.template", "CraftSnapshotFile.kt");
|
|
1057
1065
|
write("CraftNativeImageCache.kt.template", "CraftNativeImageCache.kt");
|
|
1058
1066
|
write("CraftNativeHaptics.kt.template", "CraftNativeHaptics.kt");
|
|
1067
|
+
write("CraftNativeMotion.kt.template", "CraftNativeMotion.kt");
|
|
1059
1068
|
write("CraftNativeBackground.kt.template", "CraftNativeBackground.kt");
|
|
1060
1069
|
write(config.enableHealthConnect ? "CraftNativeHealth.kt.template" : "CraftNativeHealthStub.kt.template", "CraftNativeHealth.kt");
|
|
1061
1070
|
write(config.enableHealthServices ? "CraftHealthServices.kt.template" : "CraftHealthServicesStub.kt.template", "CraftHealthServices.kt");
|
|
1062
1071
|
if (config.enableHealthServices) {
|
|
1063
1072
|
write("CraftHealthServicesService.kt.template", "CraftHealthServicesService.kt");
|
|
1073
|
+
write("CraftPassiveSteps.kt.template", "CraftPassiveSteps.kt");
|
|
1064
1074
|
} else {
|
|
1065
1075
|
rmSync2(join3(javaDir, "CraftHealthServicesService.kt"), { force: true });
|
|
1076
|
+
rmSync2(join3(javaDir, "CraftPassiveSteps.kt"), { force: true });
|
|
1066
1077
|
}
|
|
1067
1078
|
write("CraftNativeServices.kt.template", "CraftNativeServices.kt", (source) => source.replace("{{NATIVE_PUSH_IMPORTS}}", config.enablePushNotifications ? "import com.google.firebase.messaging.FirebaseMessaging" : "").replace("{{NATIVE_WALLET_IMPORTS}}", config.enableWallet ? `import com.google.android.gms.pay.Pay
|
|
1068
1079
|
import com.google.android.gms.pay.PayApiAvailabilityStatus
|
|
@@ -1348,6 +1359,7 @@ async function init(options) {
|
|
|
1348
1359
|
const nativeDir = join3(output, "app/src/main/java/com/craft/runtime");
|
|
1349
1360
|
mkdirSync2(nativeDir, { recursive: true });
|
|
1350
1361
|
writeFileSync(join3(nativeDir, "CraftNative.kt"), craftNative);
|
|
1362
|
+
writeFileSync(join3(nativeDir, "CraftRecordingPressure.kt"), readFileSync2(join3(TEMPLATES_DIR, "CraftRecordingPressure.kt.template"), "utf-8"));
|
|
1351
1363
|
const serviceTemplate = readFileSync2(join3(TEMPLATES_DIR, "LocationRecordingService.kt.template"), "utf-8");
|
|
1352
1364
|
writeFileSync(join3(nativeDir, "LocationRecordingService.kt"), serviceTemplate.replace(/\{\{PACKAGE_NAME\}\}/g, finalPackageName));
|
|
1353
1365
|
const healthTemplate = readFileSync2(join3(TEMPLATES_DIR, config.enableHealthConnect ? "CraftHealthConnect.kt.template" : "CraftHealthConnectStub.kt.template"), "utf-8");
|
|
@@ -1356,7 +1368,9 @@ async function init(options) {
|
|
|
1356
1368
|
writeFileSync(join3(output, "app/src/main/java", packagePath, file), readFileSync2(join3(TEMPLATES_DIR, template), "utf8").replace(/\{\{PACKAGE_NAME\}\}/g, finalPackageName));
|
|
1357
1369
|
}
|
|
1358
1370
|
const manifestTemplate = readFileSync2(join3(TEMPLATES_DIR, "AndroidManifest.xml.template"), "utf-8");
|
|
1359
|
-
const manifest = manifestTemplate.replace(/\{\{PACKAGE_NAME\}\}/g, finalPackageName).replace(/\{\{APP_NAME\}\}/g, name).replace(/\{\{PERMISSIONS\}\}/g, renderAndroidPermissions(config)).replace(/\{\{USES_CLEARTEXT\}\}/g, config.devServerURL?.startsWith("http://") || config.enableLocalNetwork ? "true" : "false").replace(/\{\{DEEP_LINK_INTENT_FILTERS\}\}/g, renderAndroidDeepLinks(config)).replace(/\{\{BACKGROUND_SERVICE\}\}/g, config.enableBackgroundLocation ? ' <service android:name="com.craft.runtime.LocationRecordingService" android:exported="false" android:foregroundServiceType="location" android:stopWithTask="false" />' : "").replace(/\{\{HEART_RATE_SERVICE\}\}/g, config.enableHeartRate ? ' <service android:name=".CraftHeartRateService" android:exported="false" android:foregroundServiceType="connectedDevice" />' : "").replace(/\{\{HEALTH_SERVICES_SERVICE\}\}/g, config.enableHealthServices ? ' <service android:name=".CraftHealthServicesService" android:exported="false" android:foregroundServiceType="health" android:stopWithTask="false" />'
|
|
1371
|
+
const manifest = manifestTemplate.replace(/\{\{PACKAGE_NAME\}\}/g, finalPackageName).replace(/\{\{APP_NAME\}\}/g, name).replace(/\{\{PERMISSIONS\}\}/g, renderAndroidPermissions(config)).replace(/\{\{USES_CLEARTEXT\}\}/g, config.devServerURL?.startsWith("http://") || config.enableLocalNetwork ? "true" : "false").replace(/\{\{DEEP_LINK_INTENT_FILTERS\}\}/g, renderAndroidDeepLinks(config)).replace(/\{\{BACKGROUND_SERVICE\}\}/g, config.enableBackgroundLocation ? ' <service android:name="com.craft.runtime.LocationRecordingService" android:exported="false" android:foregroundServiceType="location" android:stopWithTask="false" />' : "").replace(/\{\{HEART_RATE_SERVICE\}\}/g, config.enableHeartRate ? ' <service android:name=".CraftHeartRateService" android:exported="false" android:foregroundServiceType="connectedDevice" />' : "").replace(/\{\{HEALTH_SERVICES_SERVICE\}\}/g, config.enableHealthServices ? ' <service android:name=".CraftHealthServicesService" android:exported="false" android:foregroundServiceType="health" android:stopWithTask="false" />' + (config.enablePedometer ? `
|
|
1372
|
+
<service android:name=".CraftPassiveStepsService" android:exported="true" android:permission="com.google.android.wearable.healthservices.permission.PASSIVE_DATA_BINDING" />
|
|
1373
|
+
<receiver android:name=".CraftPassiveStepsBootReceiver" android:exported="true"><intent-filter><action android:name="android.intent.action.BOOT_COMPLETED" /></intent-filter></receiver>` : "") : "").replace(/\{\{NATIVE_NOTIFICATION_RECEIVER\}\}/g, config.renderer === "native" ? renderNativeShellManifest(config) : "").replace(/\{\{CRASH_REPORTER_PROVIDER\}\}/g, ` <provider android:name=".CraftCrashReporterInit" android:authorities="\${applicationId}.craft-crash" android:exported="false" android:initOrder="1000" />`).replace(/\{\{GOOGLE_MAPS_API_KEY\}\}/g, config.mapProvider !== "maplibre" && config.mapsApiKey ? ` <meta-data android:name="com.google.android.geo.API_KEY" android:value="${escapeXml(config.mapsApiKey)}" />` : "").replace(/\{\{HEALTH_CONNECT_QUERIES\}\}/g, config.enableHealthConnect ? ` <queries>
|
|
1360
1374
|
<package android:name="com.google.android.apps.healthdata" />
|
|
1361
1375
|
</queries>` : "").replace(/\{\{HEALTH_CONNECT_RATIONALE\}\}/g, config.enableHealthConnect ? ` <intent-filter>
|
|
1362
1376
|
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
|
|
@@ -1704,6 +1718,7 @@ export {
|
|
|
1704
1718
|
nativeMessages,
|
|
1705
1719
|
nativeRouteBundles,
|
|
1706
1720
|
nativeRouteRuntime,
|
|
1721
|
+
nativeSensorCapabilities,
|
|
1707
1722
|
open,
|
|
1708
1723
|
renderAndroidDeepLinks,
|
|
1709
1724
|
renderAndroidPermissions,
|
|
@@ -1715,4 +1730,4 @@ export {
|
|
|
1715
1730
|
syncNativeFonts
|
|
1716
1731
|
};
|
|
1717
1732
|
|
|
1718
|
-
//# debugId=
|
|
1733
|
+
//# debugId=4DE134DA887683DE64756E2164756E21
|