@navios/di-react 0.1.1 → 0.2.1
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/CHANGELOG.md +44 -0
- package/README.md +609 -28
- package/lib/index.d.mts +297 -18
- package/lib/index.d.mts.map +1 -0
- package/lib/index.d.ts +297 -18
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +536 -335
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +533 -334
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -8
- package/project.json +2 -2
- package/src/hooks/__tests__/use-service.spec.mts +1 -1
- package/src/hooks/index.mts +8 -2
- package/src/hooks/use-container.mts +47 -2
- package/src/hooks/use-invalidate.mts +3 -3
- package/src/hooks/use-optional-service.mts +59 -34
- package/src/hooks/use-scope.mts +66 -5
- package/src/hooks/use-service.mts +44 -18
- package/src/hooks/use-suspense-service.mts +48 -29
- package/src/providers/__tests__/scope-provider.spec.mts +84 -1
- package/src/providers/context.mts +11 -1
- package/src/providers/index.mts +2 -2
- package/src/providers/scope-provider.mts +34 -22
- package/{tsup.config.mts → tsdown.config.mts} +4 -3
- package/lib/_tsup-dts-rollup.d.mts +0 -304
- package/lib/_tsup-dts-rollup.d.ts +0 -304
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.1] - 2025-12-20
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Fixed package.json exports to use correct CommonJS file extensions (`.cjs` and `.d.cts`)
|
|
13
|
+
|
|
14
|
+
## [0.2.0] - 2025-01-XX
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **Initial Release**: React integration for `@navios/di` dependency injection container
|
|
19
|
+
- **ContainerProvider**: React context provider for DI container access
|
|
20
|
+
- **ScopeProvider**: Provider for request-scoped service isolation
|
|
21
|
+
- **useContainer**: Hook to access the DI container from React context
|
|
22
|
+
- **useRootContainer**: Hook to access the root container regardless of scope
|
|
23
|
+
- **useService**: Hook for fetching services with loading/error states and automatic invalidation subscription
|
|
24
|
+
- **useSuspenseService**: Hook for fetching services using React Suspense
|
|
25
|
+
- **useOptionalService**: Hook for optionally loading services that may not be registered
|
|
26
|
+
- **useInvalidate**: Hook for invalidating services by token
|
|
27
|
+
- **useInvalidateInstance**: Hook for invalidating services by instance
|
|
28
|
+
- **useScope**: Hook to get the current scope ID
|
|
29
|
+
- **useScopeOrThrow**: Hook to get the current scope ID with error if not in scope
|
|
30
|
+
- **useScopedContainer**: Hook to get the current ScopedContainer
|
|
31
|
+
- **useScopedContainerOrThrow**: Hook to get the current ScopedContainer with error if not in scope
|
|
32
|
+
- **useScopeMetadata**: Hook to access scope metadata
|
|
33
|
+
- **Automatic Invalidation Subscription**: `useService` and `useSuspenseService` automatically subscribe to service invalidation events
|
|
34
|
+
- **Type-safe API**: Full TypeScript support with compile-time type checking
|
|
35
|
+
- **React 18 & 19 Support**: Compatible with both React 18 and React 19
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
- Automatic service re-fetching when services are invalidated
|
|
40
|
+
- Support for injection tokens with Zod schema validation
|
|
41
|
+
- Request-scoped service isolation via `ScopeProvider`
|
|
42
|
+
- Synchronous instance resolution when available (optimization)
|
|
43
|
+
- React Suspense integration for declarative loading states
|
|
44
|
+
- Optional service loading for feature flags and plugins
|