Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ FIXES_SUMMARY.md
RESEARCH.md
COMPARISON.md
CLAUDE.md
KLIBS_IO_INFO.md
MAVEN_CENTRAL_SETUP.md
PUBLISH_SUMMARY.md
RELEASE_v*_NOTES.md
*_NOTES.md
NOTES.md
TODO.md
PERSONAL_*.md

# Deployment bundles
*-bundle.zip
Expand Down
8 changes: 4 additions & 4 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🏗️ KMP Worker Architecture
# 🏗️ KMP WorkManager Architecture

This document provides a comprehensive overview of the architecture, design decisions, and implementation details of KMP Worker.
This document provides a comprehensive overview of the architecture, design decisions, and implementation details of KMP WorkManager.

## 📐 High-Level Architecture

Expand All @@ -15,7 +15,7 @@ This document provides a comprehensive overview of the architecture, design deci
└───────────────────────────────┼─────────────────────────────────┘
┌───────────────▼───────────────┐
KMP Worker Library
│ KMP WorkManager Library │
│ (Kotlin Multiplatform) │
└───────────────┬───────────────┘
Expand Down Expand Up @@ -91,7 +91,7 @@ kmpworkmanager/
│ │ └── LoggerPlatform.ios.kt (actual)
│ └── KoinModule.ios.kt
└── commonTest/
└── io/brewkits/kmpworkmanager/
└── dev.brewkits/kmpworkmanager/
├── ContractsTest.kt
├── TaskChainTest.kt
├── UtilsTest.kt
Expand Down
129 changes: 128 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,133 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.1.0] - 2026-01-16

### 🎉 Major Enhancement: DI-Agnostic Architecture

KMP WorkManager is now **dependency injection framework agnostic**! Koin is optional.

### Added

#### Core Library (Zero DI Dependencies)
- **WorkerManagerConfig**: Global service locator for DI-agnostic factory registration
- **WorkerManagerInitializer**: Unified initialization API (expect/actual pattern)
- Manual initialization without any DI framework
- Platform-specific setup (Android Context, iOS task IDs)
- **AndroidWorkerFactoryProvider** / **IosWorkerFactoryProvider**: Type-safe factory accessors
- **IosTaskHandlerRegistry**: Lazy-initialized task executors for iOS

#### Extension Modules
- **kmpworkmanager-koin** (v2.1.0): Optional Koin integration extension
- 100% backward compatible with v2.0.0
- Same API, just add the dependency
- **kmpworkmanager-hilt** (v2.1.0): Optional Hilt/Dagger integration (Android only)
- Native Hilt support for Android apps

### Changed

- **Core library**: Removed Koin dependencies (koin-core, koin-android)
- **KmpWorker** / **KmpHeavyWorker**: Use `AndroidWorkerFactoryProvider` instead of Koin injection
- **Version**: 2.0.0 → 2.1.0 (minor version bump - non-breaking)

### Deprecated

- **KoinModule files** in core library: Moved to `kmpworkmanager-koin` extension
- Old code still works with extension dependency
- Will be removed in v3.0.0

### Migration

**For existing Koin users** (100% backward compatible):
```kotlin
// Just add one dependency - code stays the same
implementation("dev.brewkits:kmpworkmanager:2.1.0")
implementation("dev.brewkits:kmpworkmanager-koin:2.1.0") // ADD THIS
```

**For new projects** (manual initialization):
```kotlin
// Android
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
WorkerManagerInitializer.initialize(
workerFactory = MyWorkerFactory(),
context = this
)
}
}

// iOS
fun initializeWorkManager() {
WorkerManagerInitializer.initialize(
workerFactory = MyWorkerFactory(),
iosTaskIds = setOf("my-task")
)
}
```

See [docs/migration-v2.1.0.md](docs/migration-v2.1.0.md) for complete migration guide.

### Benefits

- 🎯 **Zero dependencies**: Core library has no DI framework requirements
- 🔌 **Flexible integration**: Choose your DI solution (Koin, Hilt, manual, or others)
- 📦 **Smaller binary size**: Only include DI framework if you need it
- 🧪 **Easier testing**: Simple manual initialization for tests
- ♻️ **Backward compatible**: Existing Koin code works with extension module

---

## [2.0.0] - 2026-01-15

### BREAKING CHANGES

**Group ID Migration: `io.brewkits` → `dev.brewkits`**

This version introduces a breaking change to align with domain ownership for Maven Central.

**What Changed:**
- Maven artifact: `io.brewkits:kmpworkmanager` → `dev.brewkits:kmpworkmanager`
- Package namespace: `io.brewkits.kmpworkmanager.*` → `dev.brewkits.kmpworkmanager.*`
- All source files (117 files) updated with new package structure

**Migration Required:**
```kotlin
// Old (v1.x)
implementation("io.brewkits:kmpworkmanager:1.1.0")
import io.brewkits.kmpworkmanager.*

// New (v2.0+)
implementation("dev.brewkits:kmpworkmanager:2.0.0")
import dev.brewkits.kmpworkmanager.*
```

**Why?**
- Aligns with owned domain `brewkits.dev`
- Proper Maven Central ownership verification
- Long-term namespace stability

See [DEPRECATED_README.md](DEPRECATED_README.md) for detailed migration guide.

## [1.1.0] - 2026-01-14

### Added
- Real-time worker progress tracking with `WorkerProgress` and `TaskProgressBus`
- iOS chain state restoration - resume from last completed step after interruptions
- Windowed task trigger support (execute within time window)
- Comprehensive iOS test suite (38+ tests for ChainProgress, ChainExecutor, IosFileStorage)

### Improved
- iOS retry logic with max retry limits (prevents infinite loops)
- Enhanced iOS batch processing for efficient BGTask usage
- Production-grade error handling and logging improvements

### Documentation
- iOS best practices guide
- iOS migration guide
- Updated API examples with v1.1.0 features

## [1.0.0] - 2026-01-13

### Added
Expand All @@ -25,7 +152,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Rebranded from `kmpworker` to `kmpworkmanager`
- Migrated package from `io.kmp.worker` to `io.brewkits.kmpworkmanager`
- Migrated package from `io.kmp.worker` to `dev.brewkits.kmpworkmanager`
- Project organization moved to brewkits/kmpworkmanager

### Documentation
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🤝 Contributing to KMP Worker
# 🤝 Contributing to KMP WorkManager

Thank you for your interest in contributing to KMP Worker! This guide will help you get started with contributing to the project.
Thank you for your interest in contributing to KMP WorkManager! This guide will help you get started with contributing to the project.

## 📋 Table of Contents

Expand Down Expand Up @@ -101,7 +101,7 @@ KMPWorker/
./gradlew test

# Run specific test file
./gradlew :kmpworkmanager:testDebugUnitTest --tests "io.brewkits.kmpworkmanager.ContractsTest"
./gradlew :kmpworkmanager:testDebugUnitTest --tests "dev.brewkits.kmpworkmanager.ContractsTest"

# Run with coverage
./gradlew test jacocoTestReport
Expand All @@ -112,7 +112,7 @@ KMPWorker/
**Android:**
```bash
./gradlew :composeApp:installDebug
adb shell am start -n io.brewkits.kmpworkmanager.sample/.MainActivity
adb shell am start -n dev.brewkits.kmpworkmanager.sample/.MainActivity
```

**iOS:**
Expand Down
84 changes: 73 additions & 11 deletions DEMO_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# 🚀 KMP Task Manager Demo App Guide
# 🚀 KMP WorkManager Demo App Guide

This guide explains how to test and use the comprehensive demo app included in this project.

## 📱 Demo App Overview

The demo app showcases all features of KMP Task Manager across **6 interactive tabs**:
The demo app showcases all features of **KMP WorkManager - Enterprise-grade Background Manager** across **6 interactive tabs**:

1. **Test & Demo** - Quick tests that work instantly in foreground
2. **Tasks** - Schedule background tasks with various triggers
Expand Down Expand Up @@ -162,15 +162,15 @@ The demo app showcases all features of KMP Task Manager across **6 interactive t
```bash
# Using adb
adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE \
-n io.brewkits.kmpworkmanager.sample/.push.PushReceiver \
-n dev.brewkits.kmpworkmanager.sample/.push.PushReceiver \
--es notification-type silent
```

#### Test on iOS:
```bash
# 1. Create push.apns file:
{
"Simulator Target Bundle": "io.brewkits.kmpworkmanager.sample",
"Simulator Target Bundle": "dev.brewkits.kmpworkmanager.sample",
"aps": {
"content-available": 1,
"alert": {
Expand All @@ -181,7 +181,7 @@ adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE \
}

# 2. Send push to simulator:
xcrun simctl push booted io.brewkits.kmpworkmanager.sample push.apns
xcrun simctl push booted dev.brewkits.kmpworkmanager.sample push.apns
```

## 🔐 Tab 5: Permissions
Expand Down Expand Up @@ -341,17 +341,79 @@ Use this checklist to verify all features:
- [ ] Refresh updates task list correctly
- [ ] Task status changes are reflected (ENQUEUED → RUNNING → SUCCEEDED)

## 💡 Enterprise Features in Demo

### Progress Tracking (v1.1.0+)
The demo app demonstrates real-time progress tracking for long-running operations:

**In Workers**:
- Workers can report progress percentage (0-100%)
- Support for step-based tracking ("Step 3/5")
- Human-readable status messages

**In UI**:
- Real-time progress updates via `TaskProgressBus`
- Reactive UI with Flow/StateFlow
- Progress bars and status text

**Example in Demo**:
```kotlin
// See HeavyProcessingWorker for progress tracking implementation
progressListener?.onProgressUpdate(
WorkerProgress(
progress = (step * 100 / totalSteps),
message = "Processing step $step of $totalSteps",
currentStep = step,
totalSteps = totalSteps
)
)
```

### Chain State Restoration (iOS)
The demo showcases iOS chain state restoration:

**What it demonstrates**:
- Chains resume from last completed step after interruptions
- Retry logic with configurable max retries
- Progress preservation across BGTask invocations

**How to test**:
1. Schedule a multi-step chain
2. Force background app during execution
3. Wait for BGTask timeout
4. App resumes chain from last completed step (not from beginning)

### Windowed Task Support (v1.1.0+)
Schedule tasks to run within a specific time window:

**Android**: Both `earliest` and `latest` times enforced
**iOS**: Only `earliest` time enforced (BGTaskScheduler limitation)

**Example**:
```kotlin
scheduler.enqueue(
id = "maintenance",
trigger = TaskTrigger.Windowed(
earliest = System.currentTimeMillis() + 3600_000,
latest = System.currentTimeMillis() + 7200_000
),
workerClassName = "MaintenanceWorker"
)
```

## 🎓 Learning Outcomes

After testing this demo, you should understand:

1. **Differences between Android and iOS background execution**
2. **How to schedule tasks with various triggers**
3. **Task chains for complex workflows**
4. **Constraint-based execution**
5. **Permission handling for notifications and alarms**
6. **EventBus pattern for worker-UI communication**
7. **Platform-specific limitations and workarounds**
2. **How to schedule tasks with various triggers (OneTime, Periodic, Windowed, Exact)**
3. **Task chains for complex workflows with state restoration**
4. **Real-time progress tracking for long-running operations**
5. **Constraint-based execution**
6. **Permission handling for notifications and alarms**
7. **EventBus pattern for worker-UI communication**
8. **Platform-specific limitations and workarounds**
9. **Enterprise features: Progress tracking, chain restoration, retry logic**

## 🚀 Next Steps

Expand Down
Loading
Loading