craft-native 0.0.247 → 0.0.249

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.
Files changed (41) hide show
  1. package/dist/android/src/index.d.ts +2 -0
  2. package/dist/android/src/index.js +22 -18
  3. package/dist/android/templates/CraftNative.kt.template +17 -0
  4. package/dist/android/templates/CraftNativeFlatList.kt.template +115 -40
  5. package/dist/android/templates/CraftNativeMapGoogle.kt.template +92 -5
  6. package/dist/android/templates/CraftNativeMapLibre.kt.template +90 -3
  7. package/dist/android/templates/CraftNativeMutation.kt.template +32 -0
  8. package/dist/android/templates/CraftNativeRefreshableFlatList.kt.template +7 -2
  9. package/dist/android/templates/CraftNativeServices.kt.template +25 -0
  10. package/dist/android/templates/CraftNativeShell.kt.template +41 -9
  11. package/dist/android/templates/MainActivityNative.kt.template +369 -69
  12. package/dist/android/templates/build.gradle.kts.project.template +1 -1
  13. package/dist/api/mobile.d.ts +37 -1
  14. package/dist/browser.js +9 -9
  15. package/dist/cli.js +90 -673
  16. package/dist/components/index.d.ts +50 -9
  17. package/dist/index.cjs +394 -438
  18. package/dist/index.d.cts +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +446 -493
  21. package/dist/ios/src/index.d.ts +2 -0
  22. package/dist/ios/src/index.js +54 -53
  23. package/dist/ios/templates/CraftApp.swift +44 -3
  24. package/dist/ios/templates/CraftHealth.swift +217 -0
  25. package/dist/ios/templates/CraftHeartRate.swift +6 -3
  26. package/dist/ios/templates/CraftHybrid.swift +30 -22
  27. package/dist/ios/templates/CraftLiveActivities.swift +1 -1
  28. package/dist/ios/templates/CraftNativeActions.swift +87 -8
  29. package/dist/ios/templates/CraftNativeFiles.swift +15 -3
  30. package/dist/ios/templates/CraftNativeFlatList.swift +18 -1
  31. package/dist/ios/templates/CraftNativeMutation.swift +36 -0
  32. package/dist/ios/templates/CraftNativeScreen.swift +826 -69
  33. package/dist/ios/templates/CraftNativeServices.swift +4 -2
  34. package/dist/ios/templates/CraftNativeUI.swift +10 -2
  35. package/dist/ios/templates/testing/DriverTests.swift.template +1 -0
  36. package/dist/ios/templates/testing/HostApp.swift +9 -2
  37. package/dist/macos/templates/CraftNativeMutation.swift +36 -0
  38. package/dist/macos/templates/native_layout.zig +226 -2
  39. package/dist/mobile-testing.js +2 -2
  40. package/dist/mobile.js +101 -63
  41. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  // Top-level build file where you can add configuration options common to all sub-projects/modules.
2
2
  plugins {
3
- id("com.android.application") version "8.9.1" apply false
3
+ id("com.android.application") version "8.10.1" apply false
4
4
  id("org.jetbrains.kotlin.android") version "2.2.10" apply false
5
5
  {{GOOGLE_SERVICES_PLUGIN}}
6
6
  }
@@ -1678,8 +1678,34 @@ export interface HealthHeartRateUpdatesOptions {
1678
1678
  /** Epoch milliseconds: samples that start at or after this. Defaults to two minutes ago. */
1679
1679
  since?: number;
1680
1680
  }
1681
+ export type HealthLiveWorkoutType = 'running' | 'walking' | 'hiking' | 'cycling' | 'swimming' | 'rowing' | 'elliptical' | 'strength' | 'hiit';
1682
+ export interface HealthLiveWorkoutOptions {
1683
+ type: HealthLiveWorkoutType;
1684
+ location?: 'indoor' | 'outdoor' | 'unknown';
1685
+ }
1686
+ export interface HealthLiveWorkoutStarted {
1687
+ id: string;
1688
+ type: HealthLiveWorkoutType;
1689
+ /** Epoch milliseconds. */
1690
+ startDate: number;
1691
+ }
1692
+ export interface HealthLiveWorkoutResult {
1693
+ id: string;
1694
+ workoutId: string;
1695
+ /** Epoch milliseconds. */
1696
+ endDate: number;
1697
+ durationSeconds: number;
1698
+ }
1699
+ export interface HealthLiveWorkoutEvent {
1700
+ id: string;
1701
+ event: 'state' | 'error';
1702
+ state?: 'notStarted' | 'prepared' | 'running' | 'paused' | 'stopped' | 'ended' | 'unknown';
1703
+ /** Epoch milliseconds for a state transition. */
1704
+ date?: number;
1705
+ message?: string;
1706
+ }
1681
1707
  /** The health reads and writes a host may or may not have, depending on the app build it runs in. */
1682
- export type HealthReadMethod = 'getWorkouts' | 'getDailyStatistics' | 'getHeartRateSamples' | 'getSleepIntervals' | 'saveData' | 'saveMindfulSession' | 'getMindfulSessions' | 'startHeartRateUpdates' | 'stopHeartRateUpdates';
1708
+ export type HealthReadMethod = 'getWorkouts' | 'getDailyStatistics' | 'getHeartRateSamples' | 'getSleepIntervals' | 'saveData' | 'saveMindfulSession' | 'getMindfulSessions' | 'startHeartRateUpdates' | 'stopHeartRateUpdates' | 'startWorkout' | 'pauseWorkout' | 'resumeWorkout' | 'endWorkout';
1683
1709
  export declare const health: {
1684
1710
  /**
1685
1711
  * Whether this app build answers `method`. An app installed before a read
@@ -1724,6 +1750,16 @@ export declare const health: {
1724
1750
  startHeartRateUpdates(options?: HealthHeartRateUpdatesOptions): Promise<boolean>;
1725
1751
  /** Stops the stream `startHeartRateUpdates` started; true also when none ran. */
1726
1752
  stopHeartRateUpdates(): Promise<boolean>;
1753
+ /** Starts an OS-owned live workout session (iOS 26+ for now). */
1754
+ startWorkout(options: HealthLiveWorkoutOptions): Promise<HealthLiveWorkoutStarted>;
1755
+ /** Pauses the current live workout. */
1756
+ pauseWorkout(): Promise<boolean>;
1757
+ /** Resumes the current live workout. */
1758
+ resumeWorkout(): Promise<boolean>;
1759
+ /** Ends and saves the current live workout. */
1760
+ endWorkout(): Promise<HealthLiveWorkoutResult>;
1761
+ /** Receives OS workout state transitions; returns the unsubscribe. */
1762
+ onWorkout(callback: (event: HealthLiveWorkoutEvent) => void): () => void;
1727
1763
  /**
1728
1764
  * Each batch of new heart-rate samples while `startHeartRateUpdates` runs,
1729
1765
  * oldest first, every sample once. Returns the unsubscribe; off a phone, or
package/dist/browser.js CHANGED
@@ -379,11 +379,11 @@ async function createBrowserPlatform(options = {}) {
379
379
  const sounds = new Map;
380
380
  const fades = new Map;
381
381
  const cancelFade = (sound) => {
382
- const fade2 = fades.get(sound);
383
- if (fade2) {
384
- cancelAnimationFrame(fade2.frame);
382
+ const fade = fades.get(sound);
383
+ if (fade) {
384
+ cancelAnimationFrame(fade.frame);
385
385
  fades.delete(sound);
386
- fade2.done();
386
+ fade.done();
387
387
  }
388
388
  };
389
389
  const fade = (sound, volume, milliseconds) => {
@@ -805,10 +805,10 @@ async function createBrowserPlatform(options = {}) {
805
805
  mediaTransfers = new AbortController;
806
806
  const name = cacheName();
807
807
  return writeMedia(async () => {
808
- const cache2 = await caches.open(name);
808
+ const cache = await caches.open(name);
809
809
  let removed = 0;
810
- for (const entry of await cache2.keys()) {
811
- if (await cache2.delete(entry))
810
+ for (const entry of await cache.keys()) {
811
+ if (await cache.delete(entry))
812
812
  removed++;
813
813
  const local = mediaURLs.get(entry.url);
814
814
  if (local)
@@ -896,6 +896,6 @@ async function createBrowserPlatform(options = {}) {
896
896
  return platform;
897
897
  }
898
898
  export {
899
- createBrowserPlatform,
900
- browserHapticPattern
899
+ browserHapticPattern,
900
+ createBrowserPlatform
901
901
  };