@wirestate/lit 0.7.0-experimental.1 → 0.7.0-experimental.3
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 +8 -2
- package/README.md +49 -31
- package/cjs/development/index.js +420 -362
- package/cjs/development/index.js.map +1 -1
- package/cjs/production/index.js +1 -1
- package/cjs/production/index.js.map +1 -1
- package/esm/development/commands/on-command-controller.js +19 -22
- package/esm/development/commands/on-command-controller.js.map +1 -1
- package/esm/development/commands/on-command.js +4 -9
- package/esm/development/commands/on-command.js.map +1 -1
- package/esm/development/commands/use-on-command.js +4 -3
- package/esm/development/commands/use-on-command.js.map +1 -1
- package/esm/development/consumption/injection.js +14 -13
- package/esm/development/consumption/injection.js.map +1 -1
- package/esm/development/consumption/use-container.js +40 -0
- package/esm/development/consumption/use-container.js.map +1 -0
- package/esm/development/consumption/use-injection.js +12 -10
- package/esm/development/consumption/use-injection.js.map +1 -1
- package/esm/development/consumption/use-scope.js +44 -0
- package/esm/development/consumption/use-scope.js.map +1 -0
- package/esm/development/context/container-context.js +17 -0
- package/esm/development/context/container-context.js.map +1 -0
- package/esm/development/error/error-code.js +1 -1
- package/esm/development/error/error-code.js.map +1 -1
- package/esm/development/events/on-event-controller.js +22 -26
- package/esm/development/events/on-event-controller.js.map +1 -1
- package/esm/development/events/on-event.js +5 -11
- package/esm/development/events/on-event.js.map +1 -1
- package/esm/development/events/use-on-events.js +5 -5
- package/esm/development/events/use-on-events.js.map +1 -1
- package/esm/development/index.js +9 -7
- package/esm/development/index.js.map +1 -1
- package/esm/development/provision/container-provide.js +68 -0
- package/esm/development/provision/container-provide.js.map +1 -0
- package/esm/development/provision/container-provider.js +68 -0
- package/esm/development/provision/container-provider.js.map +1 -0
- package/esm/development/provision/sub-container-provide.js +56 -0
- package/esm/development/provision/sub-container-provide.js.map +1 -0
- package/esm/development/provision/sub-container-provider.js +90 -0
- package/esm/development/provision/sub-container-provider.js.map +1 -0
- package/esm/development/provision/use-container-provision.js +44 -0
- package/esm/development/provision/use-container-provision.js.map +1 -0
- package/esm/development/provision/use-sub-container-provider.js +34 -0
- package/esm/development/provision/use-sub-container-provider.js.map +1 -0
- package/esm/development/queries/on-query-controller.js +19 -22
- package/esm/development/queries/on-query-controller.js.map +1 -1
- package/esm/development/queries/on-query.js +4 -9
- package/esm/development/queries/on-query.js.map +1 -1
- package/esm/development/queries/use-on-query.js +4 -3
- package/esm/development/queries/use-on-query.js.map +1 -1
- package/esm/production/commands/on-command-controller.js +1 -1
- package/esm/production/commands/on-command-controller.js.map +1 -1
- package/esm/production/commands/on-command.js +1 -1
- package/esm/production/commands/on-command.js.map +1 -1
- package/esm/production/commands/use-on-command.js +1 -1
- package/esm/production/commands/use-on-command.js.map +1 -1
- package/esm/production/consumption/injection.js +1 -1
- package/esm/production/consumption/injection.js.map +1 -1
- package/esm/production/consumption/use-container.js +1 -0
- package/esm/production/consumption/use-container.js.map +1 -0
- package/esm/production/consumption/use-injection.js +1 -1
- package/esm/production/consumption/use-injection.js.map +1 -1
- package/esm/production/consumption/use-scope.js +1 -0
- package/esm/production/consumption/use-scope.js.map +1 -0
- package/esm/production/context/container-context.js +1 -0
- package/esm/production/context/container-context.js.map +1 -0
- package/esm/production/error/error-code.js +1 -1
- package/esm/production/error/error-code.js.map +1 -1
- package/esm/production/events/on-event-controller.js +1 -1
- package/esm/production/events/on-event-controller.js.map +1 -1
- package/esm/production/events/on-event.js +1 -1
- package/esm/production/events/on-event.js.map +1 -1
- package/esm/production/events/use-on-events.js +1 -1
- package/esm/production/events/use-on-events.js.map +1 -1
- package/esm/production/index.js +1 -1
- package/esm/production/provision/container-provide.js +1 -0
- package/esm/production/provision/container-provide.js.map +1 -0
- package/esm/production/provision/container-provider.js +1 -0
- package/esm/production/provision/container-provider.js.map +1 -0
- package/esm/production/provision/sub-container-provide.js +1 -0
- package/esm/production/provision/sub-container-provide.js.map +1 -0
- package/esm/production/provision/sub-container-provider.js +1 -0
- package/esm/production/provision/sub-container-provider.js.map +1 -0
- package/esm/production/provision/use-container-provision.js +1 -0
- package/esm/production/provision/use-container-provision.js.map +1 -0
- package/esm/production/provision/use-sub-container-provider.js +1 -0
- package/esm/production/provision/use-sub-container-provider.js.map +1 -0
- package/esm/production/queries/on-query-controller.js +1 -1
- package/esm/production/queries/on-query-controller.js.map +1 -1
- package/esm/production/queries/on-query.js +1 -1
- package/esm/production/queries/on-query.js.map +1 -1
- package/esm/production/queries/use-on-query.js +1 -1
- package/esm/production/queries/use-on-query.js.map +1 -1
- package/index.d.ts +271 -176
- package/package.json +2 -2
- package/esm/development/context/ioc-context.js +0 -17
- package/esm/development/context/ioc-context.js.map +0 -1
- package/esm/development/provision/injectables-provide.js +0 -47
- package/esm/development/provision/injectables-provide.js.map +0 -1
- package/esm/development/provision/injectables-provider-controller.js +0 -123
- package/esm/development/provision/injectables-provider-controller.js.map +0 -1
- package/esm/development/provision/ioc-provide.js +0 -58
- package/esm/development/provision/ioc-provide.js.map +0 -1
- package/esm/development/provision/ioc-provider-controller.js +0 -75
- package/esm/development/provision/ioc-provider-controller.js.map +0 -1
- package/esm/development/provision/use-injectables-provider.js +0 -27
- package/esm/development/provision/use-injectables-provider.js.map +0 -1
- package/esm/development/provision/use-ioc-provision.js +0 -27
- package/esm/development/provision/use-ioc-provision.js.map +0 -1
- package/esm/production/context/ioc-context.js +0 -1
- package/esm/production/context/ioc-context.js.map +0 -1
- package/esm/production/provision/injectables-provide.js +0 -1
- package/esm/production/provision/injectables-provide.js.map +0 -1
- package/esm/production/provision/injectables-provider-controller.js +0 -1
- package/esm/production/provision/injectables-provider-controller.js.map +0 -1
- package/esm/production/provision/ioc-provide.js +0 -1
- package/esm/production/provision/ioc-provide.js.map +0 -1
- package/esm/production/provision/ioc-provider-controller.js +0 -1
- package/esm/production/provision/ioc-provider-controller.js.map +0 -1
- package/esm/production/provision/use-injectables-provider.js +0 -1
- package/esm/production/provision/use-injectables-provider.js.map +0 -1
- package/esm/production/provision/use-ioc-provision.js +0 -1
- package/esm/production/provision/use-ioc-provision.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Unreleased
|
|
2
2
|
|
|
3
3
|
- Add `useScope` in `@wirestate/react`
|
|
4
4
|
- New lit elements modules - `@wirestate/lit` and `@wirestate/lit-signals`
|
|
@@ -10,13 +10,19 @@
|
|
|
10
10
|
- Export more alias / methods from `@wirestate/react-mobx`
|
|
11
11
|
- Export missing methods typing for `@wirestate/core`
|
|
12
12
|
- Extensive JSDoc coverage for wirestate packages
|
|
13
|
-
- `createIocContainer`:
|
|
13
|
+
- `createIocContainer`: Removed in favor of `createContainer`
|
|
14
|
+
- `createContainer`: Added ability to instantly provide and activate entries, targeted seeds
|
|
14
15
|
- `createInjectablesProvider`: Removed.
|
|
15
16
|
- `IocProvider`: Removed
|
|
16
17
|
- `useRootContainer`: Added separate hook for store management in React tree
|
|
17
18
|
- `ContainerProvider`: Simpler provider for containers.
|
|
18
19
|
- `SubContainerProvider`: Added component solving problems of removed `createInjectablesProvider`
|
|
19
20
|
- `ContainerActivator`: Added separate activation component
|
|
21
|
+
- Replace IoC-context provision APIs with `ContainerContext`, `containerProvide`, `ContainerProvider`, and `useContainerProvision`
|
|
22
|
+
- Replace injectables-provider APIs with `subContainerProvide`, `SubContainerProvider`, and `useSubContainerProvider`
|
|
23
|
+
- Provide plain `Container` values through Lit context instead of wrapper objects
|
|
24
|
+
- Recreate managed child containers when the parent container context changes
|
|
25
|
+
- Add `useContainer` and `useScope` consumers in `@wirestate/lit`
|
|
20
26
|
|
|
21
27
|
## 0.6.3
|
|
22
28
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@wirestate/lit)
|
|
4
4
|
[](https://github.com/Neloreck/wirestate/blob/master/LICENSE)
|
|
5
5
|
|
|
6
|
-
Lit elements integration for wirestate. Provides dependency injection and messaging for Lit components.
|
|
6
|
+
Lit elements integration for wirestate. Provides container provisioning, dependency injection, and messaging for Lit components.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -18,25 +18,31 @@ npm install @wirestate/core @wirestate/lit lit reflect-metadata
|
|
|
18
18
|
- **Events**: Subscribe to events from the global event bus using `@onEvent` or `useOnEvents`.
|
|
19
19
|
- **Commands**: Register command handlers using `@onCommand` or `useOnCommand`.
|
|
20
20
|
- **Queries**: Register query handlers using `@onQuery` or `useOnQuery`.
|
|
21
|
-
- **Container Provisioning**: Provide and manage
|
|
22
|
-
- **
|
|
21
|
+
- **Container Provisioning**: Provide and manage containers within the Lit component tree using `@containerProvide` or `useContainerProvision`.
|
|
22
|
+
- **Sub-containers**: Create managed child containers derived from the parent context using `@subContainerProvide`, `useSubContainerProvider`, or `SubContainerProvider`.
|
|
23
23
|
- **Test Utilities**: Simplified setup for unit testing components with IoC dependencies.
|
|
24
24
|
|
|
25
25
|
## Provisioning
|
|
26
26
|
|
|
27
|
-
### `@
|
|
27
|
+
### `@containerProvide(options)` / `useContainerProvision(host, options)`
|
|
28
28
|
|
|
29
|
-
Provides
|
|
29
|
+
Provides a container to the component tree. It uses Lit Context to propagate the container to child elements.
|
|
30
|
+
|
|
31
|
+
Pass `container` to expose an existing container, or pass `options` to create and manage one for the host lifecycle.
|
|
30
32
|
|
|
31
33
|
```typescript
|
|
32
34
|
import { LitElement, html } from "lit";
|
|
33
35
|
import { customElement } from "lit/decorators.js";
|
|
34
|
-
import {
|
|
36
|
+
import { containerProvide, ContainerProvider } from "@wirestate/lit";
|
|
35
37
|
|
|
36
38
|
@customElement("my-app")
|
|
37
39
|
class MyApp extends LitElement {
|
|
38
|
-
@
|
|
39
|
-
|
|
40
|
+
@containerProvide({
|
|
41
|
+
options: {
|
|
42
|
+
seed: { someData: "value" },
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
private containerProvider!: ContainerProvider;
|
|
40
46
|
|
|
41
47
|
render() {
|
|
42
48
|
return html`<my-component></my-component>`;
|
|
@@ -44,23 +50,28 @@ class MyApp extends LitElement {
|
|
|
44
50
|
}
|
|
45
51
|
```
|
|
46
52
|
|
|
47
|
-
### `@
|
|
53
|
+
### `@subContainerProvide(options)` / `useSubContainerProvider(host, options)`
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
Creates a managed child container derived from the nearest parent container for the host element's lifetime. The child container is recreated when the parent container changes and destroyed when the host disconnects.
|
|
50
56
|
|
|
51
57
|
Using the decorator (accessor):
|
|
52
58
|
|
|
53
59
|
```typescript
|
|
54
60
|
import { LitElement } from "lit";
|
|
55
61
|
import { customElement } from "lit/decorators.js";
|
|
56
|
-
import {
|
|
62
|
+
import { subContainerProvide, SubContainerProvider } from "@wirestate/lit";
|
|
57
63
|
|
|
58
64
|
import { AuthService, UserService } from "./services";
|
|
59
65
|
|
|
60
66
|
@customElement("my-app")
|
|
61
67
|
class MyApp extends LitElement {
|
|
62
|
-
@
|
|
63
|
-
|
|
68
|
+
@subContainerProvide({
|
|
69
|
+
options: {
|
|
70
|
+
entries: [AuthService, UserService],
|
|
71
|
+
activate: [AuthService],
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
public containerProvider!: SubContainerProvider;
|
|
64
75
|
}
|
|
65
76
|
```
|
|
66
77
|
|
|
@@ -68,45 +79,52 @@ Using the hook:
|
|
|
68
79
|
|
|
69
80
|
```typescript
|
|
70
81
|
import { LitElement } from "lit";
|
|
71
|
-
import {
|
|
82
|
+
import { useSubContainerProvider } from "@wirestate/lit";
|
|
72
83
|
|
|
73
84
|
import { AuthService, UserService } from "./services";
|
|
74
85
|
|
|
75
86
|
class MyApp extends LitElement {
|
|
76
|
-
private
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
private container = useSubContainerProvider(this, {
|
|
88
|
+
options: {
|
|
89
|
+
entries: [AuthService, UserService],
|
|
90
|
+
activate: [AuthService],
|
|
91
|
+
},
|
|
79
92
|
});
|
|
80
93
|
}
|
|
81
94
|
```
|
|
82
95
|
|
|
83
|
-
Using the
|
|
96
|
+
Using the provider directly:
|
|
84
97
|
|
|
85
98
|
```typescript
|
|
86
99
|
import { LitElement } from "lit";
|
|
87
|
-
import {
|
|
100
|
+
import { SubContainerProvider } from "@wirestate/lit";
|
|
88
101
|
|
|
89
102
|
import { AuthService, UserService } from "./services";
|
|
90
103
|
|
|
91
104
|
class MyApp extends LitElement {
|
|
92
|
-
private
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
private containerProvider: SubContainerProvider = new SubContainerProvider(this, {
|
|
106
|
+
options: {
|
|
107
|
+
entries: [AuthService, UserService],
|
|
108
|
+
activate: [AuthService],
|
|
109
|
+
},
|
|
95
110
|
});
|
|
96
111
|
}
|
|
97
112
|
```
|
|
98
113
|
|
|
99
|
-
To
|
|
114
|
+
To seed the child container during creation, pass `seeds` inside `options`:
|
|
100
115
|
|
|
101
116
|
```typescript
|
|
102
117
|
import { LitElement } from "lit";
|
|
103
|
-
import {
|
|
118
|
+
import { useSubContainerProvider } from "@wirestate/lit";
|
|
104
119
|
|
|
105
120
|
import { AuthService, UserService } from "./services";
|
|
106
121
|
|
|
107
122
|
class MyApp extends LitElement {
|
|
108
|
-
private
|
|
109
|
-
|
|
123
|
+
private provider: SubContainerProvider = useSubContainerProvider(this, {
|
|
124
|
+
options: {
|
|
125
|
+
entries: [AuthService, UserService],
|
|
126
|
+
seeds: [[AuthService, { role: "admin" }]],
|
|
127
|
+
},
|
|
110
128
|
});
|
|
111
129
|
}
|
|
112
130
|
```
|
|
@@ -115,7 +133,7 @@ class MyApp extends LitElement {
|
|
|
115
133
|
|
|
116
134
|
### `@injection(optionsOrId)` / `useInjection(host, optionsOrId)`
|
|
117
135
|
|
|
118
|
-
Injects a service from the nearest
|
|
136
|
+
Injects a service from the nearest parent container. Supports both options object and direct service identifier.
|
|
119
137
|
|
|
120
138
|
```typescript
|
|
121
139
|
import { LitElement, html } from "lit";
|
|
@@ -140,7 +158,7 @@ class MyComponent extends LitElement {
|
|
|
140
158
|
}
|
|
141
159
|
```
|
|
142
160
|
|
|
143
|
-
Using the
|
|
161
|
+
Using the hook:
|
|
144
162
|
|
|
145
163
|
```typescript
|
|
146
164
|
import { LitElement, html } from "lit";
|
|
@@ -165,7 +183,7 @@ class MyComponent extends LitElement {
|
|
|
165
183
|
|
|
166
184
|
### Events
|
|
167
185
|
|
|
168
|
-
Subscribe to events from the event bus using `@onEvent` decorator or `useOnEvents` controller.
|
|
186
|
+
Subscribe to events from the event bus using `@onEvent` decorator or `useOnEvents` controller. Handlers follow the active container context when the nearest container changes.
|
|
169
187
|
|
|
170
188
|
```typescript
|
|
171
189
|
import { LitElement } from "lit";
|
|
@@ -196,7 +214,7 @@ class MyListener extends LitElement {
|
|
|
196
214
|
|
|
197
215
|
### Commands
|
|
198
216
|
|
|
199
|
-
Register a handler for a specific command type.
|
|
217
|
+
Register a handler for a specific command type. Handlers follow the active container context when the nearest container changes.
|
|
200
218
|
|
|
201
219
|
```typescript
|
|
202
220
|
import { LitElement } from "lit";
|
|
@@ -212,7 +230,7 @@ class MyCommander extends LitElement {
|
|
|
212
230
|
|
|
213
231
|
### Queries
|
|
214
232
|
|
|
215
|
-
Register a handler for a specific query type.
|
|
233
|
+
Register a handler for a specific query type. Handlers follow the active container context when the nearest container changes.
|
|
216
234
|
|
|
217
235
|
```typescript
|
|
218
236
|
import { LitElement } from "lit";
|