react-native-asleep 1.0.14 → 1.0.17

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/AGENTS.md DELETED
@@ -1,107 +0,0 @@
1
- # AGENTS.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- React Native SDK for Asleep's AI-powered sleep tracking technology. This SDK provides non-invasive sleep tracking through audio analysis without requiring wearable devices.
8
-
9
- ## Development Commands
10
-
11
- ### Building and Testing
12
- ```bash
13
- # Build the SDK
14
- yarn build
15
-
16
- # Clean build artifacts
17
- yarn clean
18
-
19
- # Run linting
20
- yarn lint
21
-
22
- # Run tests
23
- yarn test
24
-
25
- # Prepare the module
26
- yarn prepare
27
- ```
28
-
29
- ### Example App Commands
30
- ```bash
31
- # In the example directory
32
- yarn start # Start Expo development server
33
- yarn android # Run on Android
34
- yarn ios # Run on iOS
35
- ```
36
-
37
- ### Publishing and Release
38
- ```bash
39
- # Manual release via GitHub Actions
40
- # Go to Actions > Release > Run workflow
41
-
42
- # Automatic semantic release
43
- yarn semantic-release
44
- ```
45
-
46
- ## Architecture
47
-
48
- ### Core Components
49
-
50
- 1. **Native Modules** (`ios/AsleepModule.swift`, `android/.../AsleepModule.kt`)
51
- - Platform-specific implementations wrapping native Asleep SDKs
52
- - Handle audio recording, permission management, and sleep tracking
53
- - iOS SDK version: 3.1.8, Android SDK version: 3.1.5
54
-
55
- 2. **State Management** (`src/AsleepStore.ts`)
56
- - Zustand store with singleton pattern for consistent state across app
57
- - Handles all SDK state including tracking status, session management, and error handling
58
- - Provides event listener initialization and cleanup
59
-
60
- 3. **API Surface** (`src/index.ts`)
61
- - `useAsleep` hook for React components
62
- - `AsleepSDK` singleton for non-React contexts
63
- - Event-driven architecture with automatic state updates
64
-
65
- 4. **Type Definitions** (`src/Asleep.types.ts`)
66
- - TypeScript interfaces for all API responses and configurations
67
- - Comprehensive sleep report and session structures
68
-
69
- ### Key Features
70
-
71
- - **Setup Methods**: Two initialization approaches - `setup()` for ODA (On-Device Analysis) and `initAsleepConfig()` for standard mode
72
- - **Real-time Tracking**: Start/stop tracking with automatic microphone permission handling
73
- - **Report Generation**: Fetch detailed sleep analysis reports with comprehensive metrics
74
- - **Event System**: Automatic event handling through EventEmitter with state synchronization
75
- - **Platform Differences**:
76
- - Android: Returns analysis results immediately from `requestAnalysis()`
77
- - iOS: Returns acknowledgment only, results come via `onAnalysisResult` event
78
-
79
- ### Native Integration Points
80
-
81
- - **iOS**: Swift module using Expo modules, requires audio background mode
82
- - **Android**: Kotlin module with foreground service for long-running tracking
83
- - **Permissions**: Microphone access required on both platforms, battery optimization exemption recommended on Android
84
-
85
- ## Development Guidelines
86
-
87
- ### State Management Pattern
88
- - Always use store actions for state updates
89
- - Check `isSetupInProgress` and `isTracking` flags to prevent duplicate operations
90
- - Handle platform differences in analysis result handling
91
-
92
- ### Error Handling
93
- - All async operations should be wrapped in try-catch blocks
94
- - Errors are automatically stored in the state and accessible via the `error` property
95
- - Use the `addLog` function for debug logging when `enableLog(true)` is set
96
-
97
- ### Testing Changes
98
- - Test on both iOS and Android platforms
99
- - Verify permission handling flows
100
- - Test background tracking scenarios
101
- - Ensure state consistency across tracking lifecycle
102
-
103
- ### Release Process
104
- - Uses semantic-release with custom configuration
105
- - All commits trigger patch releases
106
- - Changelog automatically generated
107
- - NPM publishing handled by GitHub Actions
@@ -1,36 +0,0 @@
1
- # Publishing Guide
2
-
3
- This package uses [semantic-release](https://semantic-release.gitbook.io/) for automated version management and package publishing.
4
-
5
- ## Automated Release Process
6
-
7
- Releases are triggered automatically via GitHub Actions when changes are pushed to the `main` branch:
8
-
9
- 1. Push changes to `main` branch
10
- 2. GitHub Actions runs the Release workflow
11
- 3. semantic-release analyzes commits and determines version bump
12
- 4. Automatically publishes to npm if needed
13
-
14
- ## Manual Release
15
-
16
- To trigger a release manually:
17
-
18
- ```bash
19
- # From GitHub UI
20
- # Go to Actions → Release → Run workflow
21
-
22
- # Or using GitHub CLI
23
- gh workflow run release.yml --ref main
24
- ```
25
-
26
- ## Important Notes
27
-
28
- - **DO NOT** add a custom `publish` script to package.json
29
- - **DO NOT** run `npm publish` manually
30
- - All releases must go through semantic-release to maintain version consistency
31
-
32
- ## Configuration
33
-
34
- - Release configuration: `.releaserc.js`
35
- - Publish settings: `package.json` → `publishConfig`
36
- - Workflow: `.github/workflows/release.yml`
@@ -1,45 +0,0 @@
1
- import AVFoundation
2
- import ObjectiveC
3
-
4
- // MARK: - Temporary Audio Session Swizzling for Bluetooth Support
5
- //
6
- // PURPOSE: Enable recording from phone microphone while playing audio through AirPods/Bluetooth
7
- // This allows users to track sleep sounds while listening to white noise through Bluetooth devices.
8
- //
9
- // IMPACT:
10
- // - Adds Bluetooth A2DP as an available audio route option (doesn't force its use)
11
- // - Will be removed when AsleepSDK natively supports this configuration
12
- //
13
- // TODO: Remove this entire file when AsleepSDK iOS implements proper audio configuration
14
-
15
- extension AVAudioSession {
16
- private static let swizzleOnce: () = {
17
- let originalSelector = #selector(AVAudioSession.setCategory(_:mode:options:))
18
- let swizzledSelector = #selector(AVAudioSession.swizzled_setCategory(_:mode:options:))
19
-
20
- guard let originalMethod = class_getInstanceMethod(AVAudioSession.self, originalSelector),
21
- let swizzledMethod = class_getInstanceMethod(AVAudioSession.self, swizzledSelector) else {
22
- // Using assertionFailure will crash in debug builds if swizzling fails,
23
- // making the issue immediately obvious, while being a no-op in release builds.
24
- assertionFailure("Failed to swizzle AVAudioSession.setCategory. Bluetooth audio may not work as expected.")
25
- return
26
- }
27
-
28
- method_exchangeImplementations(originalMethod, swizzledMethod)
29
- }()
30
-
31
- static func swizzleSetCategory() {
32
- // This triggers the lazy initialization of swizzleOnce, ensuring the
33
- // swizzling code is executed exactly once in a thread-safe manner.
34
- _ = swizzleOnce
35
- }
36
-
37
- @objc private func swizzled_setCategory(_ category: AVAudioSession.Category, mode: AVAudioSession.Mode, options: AVAudioSession.CategoryOptions) throws {
38
- // Always add allowBluetoothA2DP to the options
39
- var modifiedOptions = options
40
- modifiedOptions.insert(.allowBluetoothA2DP)
41
-
42
- // Call the original implementation with modified options
43
- try swizzled_setCategory(category, mode: mode, options: modifiedOptions)
44
- }
45
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- // @generated by expo-module-scripts
2
- {
3
- "extends": "expo-module-scripts/tsconfig.base",
4
- "compilerOptions": {
5
- "outDir": "./build"
6
- },
7
- "include": ["./src"],
8
- "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
- }
File without changes