Commit Graph

380 Commits

Author SHA1 Message Date
Sergey Penkovsky
81f14f5231 chore(release): publish packages
- cherrypick@3.0.0
 - cherrypick_annotations@3.0.0
 - cherrypick_flutter@3.0.0
 - cherrypick_generator@3.0.0
 - talker_cherrypick_logger@3.0.0
cherrypick_generator-v3.0.0 talker_cherrypick_logger-v3.0.0 cherrypick-v3.0.0 cherrypick_annotations-v3.0.0 cherrypick_flutter-v3.0.0
2025-09-08 17:17:50 +03:00
Sergey Penkovsky
a9101513e1 Add CI/CD badges to package README files
- Added Melos + FVM CI badges to all package README.md files
- Standardized badge formatting across all packages
- Improved project visibility with build status indicators
2025-09-08 17:16:51 +03:00
Sergey Penkovsky
f1cf1d054f Merge pull request #22 from pese-git/develop
# Release - CherryPick 3.x

> **CherryPick** — a lightweight and modular DI framework for Dart and Flutter that solves dependency injection through strong typing, code generation, and dependency control.

Version **3.x** was recently released with significant improvements.

## Main Changes in 3.x

* **O(1) dependency resolution** — thanks to Map indexing of bindings, performance does not depend on the size of the scope in the DI graph. This provides noticeable speedup in large projects.
* **Protection against circular dependencies** — checking works both within a single scope and across the entire hierarchy. When a cycle is detected, an informative exception with the dependency chain is thrown.
* **Integration with Talker** — all DI events (registration, creation, deletion, errors) are logged and can be displayed in the console or UI.
* **Automatic resource cleanup** — objects implementing `Disposable` are properly released when the scope is closed.
* **Stabilized declarative approach support** — annotations and code generation now work more reliably and are more convenient for use in projects.

## Resource Cleanup Example

```dart
class MyServiceWithSocket implements Disposable {
  @override
  Future<void> dispose() async {
    await socket.close();
    print('Socket closed!');
  }
}

class AppModule extends Module {
  @override
  void builder(Scope currentScope) {
    // singleton Api
    bind<MyServiceWithSocket>()
      .toProvide(() => MyServiceWithSocket())
      .singleton();
  }
}

scope.installModules([AppModule()]);

await CherryPick.closeRootScope(); // will wait for async dispose to complete
```

## Circular Dependency Checking

One of the new features in CherryPick 3.x is built-in cycle protection.
This helps catch situations early where services start depending on each other recursively.

### How to Enable Checking

For checking within a single scope:

```dart
final scope = CherryPick.openRootScope();
scope.enableCycleDetection();
```

For global checking across the entire hierarchy:

```dart
CherryPick.enableGlobalCycleDetection();
CherryPick.enableGlobalCrossScopeCycleDetection();
final rootScope = CherryPick.openRootScope();
```

### How a Cycle Can Occur

Suppose we have two services that depend on each other:

```dart
class UserService {
  final OrderService orderService;
  UserService(this.orderService);
}

class OrderService {
  final UserService userService;
  OrderService(this.userService);
}
```

If we register them in the same scope:

```dart
class AppModule extends Module {
  @override
  void builder(Scope currentScope) {
    bind<UserService>().toProvide(() => UserService(scope.resolve()));
    bind<OrderService>().toProvide(() => OrderService(scope.resolve()));
  }
}

final scope = CherryPick.openRootScope()
  ..enableCycleDetection()
  ..installModules([AppModule()]);

scope.resolve<UserService>();
```

Then when trying to resolve the dependency, an exception will be thrown:

```bash
 Circular dependency detected for UserService
Dependency chain: UserService -> OrderService -> UserService
```

This way, the error is detected immediately, not "somewhere in runtime".

## Integration with Talker

CherryPick 3.x allows logging all DI events through [Talker](https://pub.dev/packages/talker): registration, object creation, deletion, and errors. This is convenient for debugging and diagnosing the dependency graph.

Connection example:

```dart
final talker = Talker();
final observer = TalkerCherryPickObserver(talker);
CherryPick.setGlobalObserver(observer);
```

After this, DI events will be displayed in the console or UI:

```bash
┌───────────────────────────────────────────────────────────────
│ [info]    9:41:33  | [scope opened][CherryPick] scope_1757054493089_7072
└───────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────
│ [verbose] 9:41:33  | [diagnostic][CherryPick] Scope created: scope_1757054493089_7072 {type: Scope, name: scope_1757054493089_7072, description: scope created}
└───────────────────────────────────────────────────────────────
```

In the log, you can see when scopes are created, which objects are registered and deleted, and catch errors and cycles in real time.


## Declarative Approach with Annotations

In addition to fully programmatic module descriptions, CherryPick supports **declarative DI style through annotations**.  
This allows minimizing manual code and automatically generating modules and mixins for automatic dependency injection.

Example of a declarative module:

```dart
@module()
abstract class AppModule extends Module {
  @provide()
  @singleton()
  Api api() => Api();

  @provide()
  Repo repo(Api api) => Repo(api);
}
````

After code generation, you can automatically inject dependencies into widgets or services:

```dart
@injectable()
class MyScreen extends StatelessWidget with _$MyScreen {
  @inject()
  late final Repo repo;

  MyScreen() {
    _inject(this);
  }
}
```

This way you can choose a convenient style: either **purely programmatic** or **declarative with annotations**.


## Who Might Find CherryPick Useful?

* Projects where it's important to guarantee **no cycles in the dependency graph**;
* Teams that want to **minimize manual DI code** and use a declarative style with annotations;
* Applications that require **automatic resource cleanup** (sockets, controllers, streams).

## Useful Links

* 📦 Package: [pub.dev/packages/cherrypick](https://pub.dev/packages/cherrypick)
* 💻 Code: [github.com/pese-git/cherrypick](https://github.com/pese-git/cherrypick)
* 📖 Documentation: [cherrypick-di.netlify.app](https://cherrypick-di.netlify.app/)
2025-09-08 17:04:48 +03:00
Sergey Penkovsky
f1ad1c42b5 Add ignore comment for deprecated member warning in binding.dart
- Added // ignore: deprecated_member_use_from_same_package comment
- This suppresses the warning about deprecated toProvideAsync method
- The comment is needed to maintain code quality while keeping backward compatibility
2025-09-08 16:50:45 +03:00
Sergey Penkovsky
be7f3e0392 Add release notes for CherryPick 3.x in both Russian and English
- Added comprehensive release notes for CherryPick 3.x
- Includes new features: O(1) dependency resolution, circular dependency protection
- Added Talker integration and automatic resource cleanup examples
- Added declarative approach with annotations section
- Both Russian and English versions included
2025-09-08 16:48:12 +03:00
Sergey Penkovsky
1b0615810d add presentation 2025-09-08 15:48:58 +03:00
Sergey Penkovsky
ef04f464da Update README.md 2025-09-08 15:40:09 +03:00
Sergey Penkovsky
6826f0f62c chore: synchronize package versions to 3.0.0-dev.X across all packages
- Unified MAJOR.MINOR versioning across all cherrypick ecosystem packages
- Updated cherrypick_annotations from 1.1.2-dev.2 to 3.0.0-dev.0
- Updated cherrypick_generator from 2.0.0-dev.2 to 3.0.0-dev.0
- Updated cherrypick_flutter from 1.1.3-dev.12 to 3.0.0-dev.1
- Updated documentation URLs from .dev to .netlify.app domain
- Maintained semantic versioning consistency for mono-repository management

This change ensures:
- Clear compatibility signaling between interdependent packages
- Simplified dependency management for consumers
- Consistent release versioning across the ecosystem
2025-09-08 15:06:19 +03:00
Sergey Penkovsky
9e517d047f chore(release): publish packages
- cherrypick@3.0.0-dev.13
 - cherrypick_flutter@3.0.0-dev.1
 - talker_cherrypick_logger@3.0.0-dev.1
cherrypick-v3.0.0-dev.13 cherrypick_flutter-v3.0.0-dev.1 talker_cherrypick_logger-v3.0.0-dev.1
2025-09-08 14:58:37 +03:00
Sergey Penkovsky
68a16aaa0c chore(release): publish packages
- talker_cherrypick_logger@3.0.0-dev.0
talker_cherrypick_logger-v3.0.0-dev.0
2025-09-08 14:57:29 +03:00
Sergey Penkovsky
679b2b87b7 chore(release): publish packages
- cherrypick_flutter@3.0.0-dev.0
cherrypick_flutter-v3.0.0-dev.0
2025-09-08 14:56:44 +03:00
Sergey Penkovsky
dbdae94673 chore(release): publish packages
- cherrypick_generator@3.0.0-dev.0
cherrypick_generator-v3.0.0-dev.0
2025-09-08 14:55:04 +03:00
Sergey Penkovsky
4220967447 chore(release): publish packages
- cherrypick_annotations@3.0.0-dev.0
cherrypick_annotations-v3.0.0-dev.0
2025-09-08 14:53:10 +03:00
Sergey Penkovsky
dfe16fb10f chore: add yarn.lock file to track exact dependency versions 2025-09-08 14:42:46 +03:00
Sergey Penkovsky
ce2e770cbe docs: add important warnings about toInstance limitations and singleton behavior with params
- Add detailed warning about toInstance usage restrictions in module builders
- Explain singleton behavior with parameterized providers
- Clarify singleton() usage with toInstance() calls
- Update both English and Russian documentation versions
2025-09-08 14:07:48 +03:00
Sergey Penkovsky
7f5f5c4064 Merge pull request #21 from pese-git/website
Implement Website
2025-09-08 13:09:46 +03:00
Sergey Penkovsky
04ecb6d3a6 docs: update contributors list with GitHub links and add new contributor 2025-09-08 10:50:42 +03:00
Sergey Penkovsky
484061148d docs(binding,docs): clarify .singleton() with .toInstance() behavior in docs and API
- Add an explicit note and warning about the effect (or lack thereof) of calling `.singleton()` after `.toInstance()`:
  - in singleton() API doc-comment in binding.dart,
  - in README.md (after all binding usage patterns),
  - in full_tutorial_en.md and full_tutorial_ru.md.
- Explain that `.singleton()` has no effect on objects registered with `.toInstance()` — they are always single instance.
- Recommend `.singleton()` only for providers (toProvide/toProvideAsync), not direct instances.
- Improves clarity and prevents misuse/confusion for end users and future maintainers.
2025-09-08 10:46:20 +03:00
Sergey Penkovsky
b5b672765e docs(binding,docs): explain .singleton() + parametric provider behavior
- Add an explicit warning and usage examples for .singleton() combined with toProvideWithParams/toProvideAsyncWithParams:
  - in API doc-comment for singleton() in binding.dart,
  - in README.md and both full tutorials (EN/RU).
- Show correct and incorrect usage/pitfalls for parameterized providers and singleton.
- Help users avoid unintended singleton caching when using providers with parameters.
- Motivation: Prevent common confusion, make advanced DI scenarios safer and more obvious.
2025-09-08 10:18:19 +03:00
Sergey Penkovsky
482b7b0f5f docs(binding): clarify registration limitation in API doc
- Add an explicit warning and usage pattern examples to the toInstance() method doc-comment.
- Explain why resolving dependencies registered with toInstance inside the same Module.builder does not work.
- Reference safe and unsafe code samples for users navigating via IDE and API documentation.
2025-09-08 09:51:40 +03:00
Sergey Penkovsky
722a4d7980 docs(di): clarify 'toInstance' binding limitations in builder
- Add explicit note for users about the impossibility to use scope.resolve<T>() for just-to-be-registered types inside Module.builder when registering chained dependencies via toInstance.
- Show correct and incorrect usage patterns, functional and anti-pattern Dart examples in RU and EN full tutorials.
- Add the warning to the main README after core concept bindings block, improving discoverability for users starting with the library.
- Motivation: Prevent common misuse and hard-to-debug runtime errors for users who construct chains using toInstance/resolve inside the builder.
2025-09-08 09:23:00 +03:00
Sergey Penkovsky
16cd7199aa fix: fix examples 2025-09-05 09:37:24 +03:00
Sergey Penkovsky
1cbcce5b38 chore(release): publish packages
- cherrypick_annotations@1.1.2-dev.2
 - cherrypick_generator@2.0.0-dev.2
cherrypick_annotations-v1.1.2-dev.2 cherrypick_generator-v2.0.0-dev.2
2025-08-22 14:39:33 +03:00
Sergey Penkovsky
264c4bbb88 docs(annotations): improve API documentation and usage example
- Add detailed English doc comments for all main annotations (inject, injectable, instance, provide, scope, etc)
- Add fully documented example/example.dart illustrating real-world DI scenario
- Clarify stub sections (Module class, generated mixins)
- Aligns package with pub.dev quality and best practice requirements

No breaking changes.
2025-08-22 09:39:25 +03:00
Sergey Penkovsky
cbb5dcc3a0 docs(benchmark_di): update reports with extended analysis, peak memory and revised recommendations 2025-08-20 08:50:14 +03:00
Sergey Penkovsky
d281c18a75 feat(benchmark_di): add yx_scope DI adapter and CLI integration 2025-08-20 07:49:10 +03:00
Sergey Penkovsky
8ef12e990f chore(release): publish packages
- cherrypick@3.0.0-dev.12
 - cherrypick_flutter@1.1.3-dev.12
 - talker_cherrypick_logger@1.1.0-dev.7
cherrypick-v3.0.0-dev.12 cherrypick_flutter-v1.1.3-dev.12 talker_cherrypick_logger-v1.1.0-dev.7
2025-08-19 10:48:20 +03:00
Sergey Penkovsky
5c57370755 fix(benchmark) - hide warning 2025-08-19 10:47:53 +03:00
Sergey Penkovsky
8711dc83d0 docs(benchmark_di): update benchmark results and add test parameters for all DI in REPORT.md/RU.md 2025-08-19 10:29:53 +03:00
Sergey Penkovsky
043737e2c9 fix(scope): prevent concurrent modification in dispose()
- Create defensive copies of _scopeMap and _disposables
- Remove redundant try-catch blocks
- Improve memory safety during teardown
2025-08-19 09:57:02 +03:00
Sergey Penkovsky
ed65e3c23d fix(benchmark): improve CherryPickAdapter teardown reliability
- Add error handling for scope disposal
- Add null check for _scope variable
- Prevent concurrent modification exceptions
2025-08-19 09:22:45 +03:00
Sergey Penkovsky
a897c1b31b feat(benchmark_di): add Kiwi DI adapter and CLI integration 2025-08-18 18:40:07 +03:00
Sergey Penkovsky
dd9c3faa62 fix(binding): fix unterminated string literal and syntax issues in binding.dart 2025-08-18 18:35:41 +03:00
Sergey Penkovsky
846d55b124 feat(i18n): localize main page and enable i18n for homepage texts
- Updated index.tsx to use <Translate> and translate() for all main texts (title, subtitle, CTA, description) — now fully i18n-ready.
- Added new translation files (code.json, navbar.json, footer.json, etc.) to support Russian language for homepage and UI.
- Enables seamless language switching and correct translations of homepage elements.
2025-08-15 15:09:55 +03:00
Sergey Penkovsky
4f91d442af feat(i18n): localize FeatureList on homepage with <Translate> component
- Updated HomepageFeatures/index.tsx to use Docusaurus <Translate> component and unique ids for each feature title and description.
- Enables full i18n support for FeatureList (English & Russian).
- All feature texts are now ready for integration with Docusaurus translation workflow.
2025-08-15 14:40:33 +03:00
Sergey Penkovsky
d0c3870af6 feat(i18n): add Russian translation for docs intro page
- Added the initial Russian localizable version for the documentation introduction section ().
- Makes the first step of the CherryPick documentation available to Russian-speaking users.
- Ensures the /ru/docs/intro route is available and translated.
2025-08-15 10:10:37 +03:00
Sergey Penkovsky
c8292035b6 chore(docs): update editUrl for docs to project repository
- Changed docs.editUrl in docusaurus.config.ts to point to the actual GitHub repository (https://github.com/pese-git/cherrypick/tree/website/website).
- Allows users to edit documentation directly in this project's repo via the 'Edit this page' links.
2025-08-15 09:28:37 +03:00
Sergey Penkovsky
63ee3a9966 chore(config): remove blog preset block from docusaurus.config.ts
- Deleted all blog-related configuration from docusaurus.config.ts
- Intended for disabling or cleaning up unused blog features
2025-08-15 09:24:46 +03:00
Sergey Penkovsky
a4c5fd922e chore(release): publish packages
- cherrypick@3.0.0-dev.10
 - cherrypick_annotations@1.1.2-dev.1
 - cherrypick_flutter@1.1.3-dev.10
 - cherrypick_generator@2.0.0-dev.1
 - talker_cherrypick_logger@1.1.0-dev.5
cherrypick_annotations-v1.1.2-dev.1 cherrypick_flutter-v1.1.3-dev.10 cherrypick_generator-v2.0.0-dev.1 talker_cherrypick_logger-v1.1.0-dev.5 cherrypick-v3.0.0-dev.10
2025-08-15 09:06:46 +03:00
Sergey Penkovsky
8870b8ce54 docs(pub): update homepage and documentation URLs in pubspec.yaml to new official site 2025-08-15 09:04:39 +03:00
Sergey Penkovsky
1f7e1d120d fix: update logo icon 2025-08-15 08:58:08 +03:00
Sergey Penkovsky
bcc5278c83 Fix Netlify SPA routing 2025-08-14 17:34:18 +03:00
Sergey Penkovsky
8863b10cbe feat: update dns 2025-08-14 16:57:25 +03:00
Sergey Penkovsky
e0a5ae66f6 fix(docs): comment out all broken links to allow successful Docusaurus build
- Commented out references to non-existent files and examples in both English and Russian documentation:
  - circular-dependency-detection.md
  - logging.md
  - documentation-links.md
  - using-annotations.md
- This fix prevents build failures caused by unresolved links in Docusaurus for both locales.
- All offending links are now non-blocking comments, allowing the site to build and deploy successfully until the related pages are added.
2025-08-14 16:24:57 +03:00
Sergey Penkovsky
9fee26c524 feat(i18n): add initial Russian localization for documentation and site config
- Added full Russian translations for all main documentation sections () into .
- Sections translated include: key features, installation, getting started, all core concepts, advanced features, API reference, FAQ, links, additional modules, contributing, and license.
- Updated  to ensure language switching is available and Russian locale is active.
- Each Russian file preserves the structure and formatting of the original Markdown, with machine-aided draft translation for immediate use.
- Lays the groundwork for UI language switching (en/ru) and enables further manual translation refinement and review.
2025-08-14 15:46:53 +03:00
Sergey Penkovsky
248bf4c8c5 feat(website): update home page to showcase CherryPick DI documentation
- Replaced the main action button text with 'Explore CherryPick Documentation 🍒' instead of 'Docusaurus Tutorial'.
- Updated the button link to target /docs/intro (main docs entry point).
- Changed <Layout> props:
  - Page title now uses project title only (siteConfig.title)
  - Added a CherryPick-related site description for better SEO and context.
- The homepage is now tailored to reflect CherryPick's purpose as a Dart & Flutter DI library instead of Docusaurus boilerplate.
2025-08-14 13:41:54 +03:00
Sergey Penkovsky
f4c4fe49a0 init: docusaurus website project 2025-08-13 18:19:25 +03:00
Sergey Penkovsky
298cb65ac8 chore(release): publish packages
- talker_cherrypick_logger@1.1.0-dev.4
talker_cherrypick_logger-v1.1.0-dev.4
2025-08-13 15:58:08 +03:00
Sergey Penkovsky
1b9db31c13 docs(readme): update install instructions to use pub.dev as default method and remove obsolete git example
The main installation guide now recommends pub.dev with ^latest tags. Removed the outdated GitHub install block for clarity and simplicity. No functional code changes.
2025-08-13 15:57:28 +03:00
Sergey Penkovsky
ca3cd2c8fd Merge pull request #20 from pese-git/code-format
style: reformat codebase using melos format
2025-08-13 15:46:05 +03:00