@navios/di-react 1.0.0-alpha.3 → 2.0.0-alpha.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/README.md +45 -665
  3. package/lib/index.cjs +573 -0
  4. package/lib/index.cjs.map +1 -0
  5. package/lib/index.d.cts +262 -0
  6. package/lib/index.d.cts.map +1 -0
  7. package/lib/index.d.mts +159 -140
  8. package/lib/index.d.mts.map +1 -1
  9. package/lib/index.mjs +371 -381
  10. package/lib/index.mjs.map +1 -1
  11. package/package.json +32 -18
  12. package/coverage/base.css +0 -224
  13. package/coverage/block-navigation.js +0 -87
  14. package/coverage/clover.xml +0 -270
  15. package/coverage/coverage-final.json +0 -10
  16. package/coverage/favicon.png +0 -0
  17. package/coverage/hooks/index.html +0 -191
  18. package/coverage/hooks/use-container.mts.html +0 -268
  19. package/coverage/hooks/use-invalidate.mts.html +0 -208
  20. package/coverage/hooks/use-optional-service.mts.html +0 -910
  21. package/coverage/hooks/use-scope.mts.html +0 -346
  22. package/coverage/hooks/use-service.mts.html +0 -760
  23. package/coverage/hooks/use-suspense-service.mts.html +0 -784
  24. package/coverage/index.html +0 -131
  25. package/coverage/prettify.css +0 -1
  26. package/coverage/prettify.js +0 -2
  27. package/coverage/providers/container-provider.mts.html +0 -139
  28. package/coverage/providers/context.mts.html +0 -130
  29. package/coverage/providers/index.html +0 -146
  30. package/coverage/providers/scope-provider.mts.html +0 -355
  31. package/coverage/sort-arrow-sprite.png +0 -0
  32. package/coverage/sorter.js +0 -210
  33. package/lib/index.d.ts +0 -243
  34. package/lib/index.d.ts.map +0 -1
  35. package/lib/index.js +0 -582
  36. package/lib/index.js.map +0 -1
  37. package/project.json +0 -61
  38. package/src/hooks/__tests__/use-container.spec.mts +0 -143
  39. package/src/hooks/__tests__/use-invalidate.spec.mts +0 -80
  40. package/src/hooks/__tests__/use-optional-service.spec.mts +0 -233
  41. package/src/hooks/__tests__/use-scope.spec.mts +0 -293
  42. package/src/hooks/__tests__/use-service.spec.mts +0 -212
  43. package/src/hooks/__tests__/use-suspense-service.spec.mts +0 -286
  44. package/src/hooks/index.mts +0 -14
  45. package/src/hooks/use-container.mts +0 -61
  46. package/src/hooks/use-invalidate.mts +0 -41
  47. package/src/hooks/use-optional-service.mts +0 -275
  48. package/src/hooks/use-scope.mts +0 -87
  49. package/src/hooks/use-service.mts +0 -225
  50. package/src/hooks/use-suspense-service.mts +0 -233
  51. package/src/index.mts +0 -8
  52. package/src/providers/__tests__/scope-provider.spec.mts +0 -366
  53. package/src/providers/container-provider.mts +0 -18
  54. package/src/providers/context.mts +0 -15
  55. package/src/providers/index.mts +0 -5
  56. package/src/providers/scope-provider.mts +0 -90
  57. package/src/types.mts +0 -21
  58. package/tsconfig.json +0 -13
  59. package/tsdown.config.mts +0 -14
  60. package/vitest.config.mts +0 -12
package/CHANGELOG.md CHANGED
@@ -5,6 +5,52 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.0-alpha.1] - Unreleased
9
+
10
+ ### Added
11
+
12
+ - **`ServiceHook<K>` and `ServiceHookResults<T>`**: the overloads the service hooks share, as one type. `useService` is a `ServiceHook<'service'>`, `useOptionalService` a `ServiceHook<'optional'>` and `useSuspenseService` a `ServiceHook<'suspense'>`. The hooks are declared as constants of that type; what they accept and return is unchanged.
13
+
14
+ ### Changed
15
+
16
+ - **Breaking:** `useService` and `useOptionalService` report `isLoading: true` on the first render when the container does not hold the instance yet. That render used to have every flag `false`.
17
+ - **Breaking:** `useService` reports an error the container raises while reading the token on the first render (an alias cycle, args that contain themselves, a value that is not a token) in `error`. It used to throw during render.
18
+ - **`refetch()` of `useOptionalService`** works like the one of `useService`: it re-renders through `isLoading` and returns `undefined` instead of a promise.
19
+
20
+ ### Fixed
21
+
22
+ - **Instance destroyed before the hook listened for it**: `useService` and `useOptionalService` returned an instance the container already held on the first render and subscribed to its invalidation in an effect. An invalidation between the two went unnoticed, and the component kept the destroyed instance. The effect now compares what the container holds and resolves again. A resolution subscribes before it asks for the instance, so an invalidation right after it is not missed either; the hook therefore also resolves again from `error` or `isNotFound` when an instance for its token and args is destroyed.
23
+ - **`useSuspenseService` and an instance the container already held**: the same gap. The cache entry now listens from the render that created it.
24
+ - **`useSuspenseService` cache growth**: a resolved cache entry and its `onInvalidate` listener stayed for the lifetime of the container, one per token and args ever rendered. An entry is dropped one timer turn after the last component that shows it unmounts or changes its args. An entry that was rendered and never mounted, or that is still pending when its component unmounts, stays until the container is collected.
25
+ - **Stale instance in `useOptionalService` after an args change**: a resolution for the previous args that finished after the one for the current args replaced its instance.
26
+ - **`useOptionalService` after `refetch()`**: an instance it resolved after a failure or `isNotFound` was not subscribed to, so invalidating it did not resolve again.
27
+ - **`useSuspenseService` retries after a failure**: a rejected resolution stayed cached for the container, token and args, so resetting the error boundary or mounting the component again threw the same error without another attempt. The error still reaches the error boundary; the next render resolves again. A failure is resolved once per attempt also when the component renders slowly: the entry is dropped two timer turns after the last render that threw.
28
+
29
+ ### Removed
30
+
31
+ - **Breaking:** the types `UnionToArray` and `Join`. No hook used them, and `UnionToArray` evaluated to `never` for every input.
32
+
33
+ ## [2.0.0-alpha.0] - 2026-11-26
34
+
35
+ ### Fixed
36
+
37
+ - **`ScopeProvider` under `<StrictMode>`**: The scope survives the unmount and re-mount React simulates in development
38
+ - Disposal now waits one microtask and is cancelled by a re-mount; a real unmount and a `key` change still dispose the scope
39
+ - A provider shown again by `<Activity>` after its scope was disposed starts a new scope
40
+ - **Inline args in `useService` and `useOptionalService`**: Args are compared by their JSON form, like `useSuspenseService`, which now tells apart `Map`, `Set`, `RegExp` and `bigint` values
41
+ - An object literal written in the call no longer restarts the hook on every render
42
+ - Changed args still resolve again
43
+ - **Stale instance after an args change**: A hook that read its first instance synchronously kept it when the args, token or container changed
44
+ - **Extra constructor run on dependency invalidation**: `useService` and `useOptionalService` resolve one microtask after the invalidation event, so a dependent is not constructed against a dependency that is still being destroyed
45
+
46
+ ### Removed
47
+
48
+ - Development warning about args "that look the same but are different instances": such args are now treated as unchanged
49
+
50
+ ### Documentation
51
+
52
+ - README: `useContainer()` return type, examples that used `data` before checking it, Standard Schema wording, reserved `metadata.scopeId`, memoization advice
53
+
8
54
  ## [1.0.0-alpha.3] - 2026-01-08
9
55
 
10
56
  ### Added
@@ -86,7 +132,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
86
132
 
87
133
  - Fixed package.json exports to use correct CommonJS file extensions (`.cjs` and `.d.cts`)
88
134
 
89
- ## [0.2.0] - 2025-01-XX
135
+ ## [0.2.0] - 2025-12-18
90
136
 
91
137
  ### Added
92
138