@wirestate/lit 0.6.1 → 0.7.0-experimental.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 +10 -1
- package/README.md +44 -44
- package/cjs/development/index.js +136 -129
- 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 +7 -6
- package/esm/development/commands/on-command-controller.js.map +1 -1
- package/esm/development/commands/on-command.js +7 -6
- package/esm/development/commands/on-command.js.map +1 -1
- package/esm/development/commands/use-on-command.js +7 -7
- package/esm/development/consumption/injection.js +6 -6
- package/esm/development/consumption/injection.js.map +1 -1
- package/esm/development/consumption/use-injection.js +7 -7
- package/esm/development/consumption/use-injection.js.map +1 -1
- package/esm/development/context/ioc-context.js +6 -6
- package/esm/development/context/ioc-context.js.map +1 -1
- package/esm/development/events/on-event-controller.js +10 -8
- package/esm/development/events/on-event-controller.js.map +1 -1
- package/esm/development/events/on-event.js +11 -8
- package/esm/development/events/on-event.js.map +1 -1
- package/esm/development/events/use-on-events.js +8 -8
- package/esm/development/index.js +1 -1
- package/esm/development/provision/injectables-provide.js +5 -5
- package/esm/development/provision/injectables-provide.js.map +1 -1
- package/esm/development/provision/injectables-provider-controller.js +14 -14
- package/esm/development/provision/injectables-provider-controller.js.map +1 -1
- package/esm/development/provision/ioc-provide.js +10 -7
- package/esm/development/provision/ioc-provide.js.map +1 -1
- package/esm/development/provision/ioc-provider-controller.js +13 -10
- package/esm/development/provision/ioc-provider-controller.js.map +1 -1
- package/esm/development/provision/use-injectables-provider.js +5 -11
- package/esm/development/provision/use-injectables-provider.js.map +1 -1
- package/esm/development/provision/use-ioc-provision.js +6 -8
- package/esm/development/provision/use-ioc-provision.js.map +1 -1
- package/esm/development/queries/on-query-controller.js +8 -7
- package/esm/development/queries/on-query-controller.js.map +1 -1
- package/esm/development/queries/on-query.js +7 -6
- package/esm/development/queries/on-query.js.map +1 -1
- package/esm/development/queries/use-on-query.js +7 -7
- 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.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-injection.js +1 -1
- package/esm/production/consumption/use-injection.js.map +1 -1
- package/esm/production/context/ioc-context.js +1 -1
- package/esm/production/context/ioc-context.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.map +1 -1
- package/esm/production/index.js +1 -1
- package/esm/production/provision/injectables-provide.js.map +1 -1
- package/esm/production/provision/injectables-provider-controller.js +1 -1
- package/esm/production/provision/injectables-provider-controller.js.map +1 -1
- package/esm/production/provision/ioc-provide.js.map +1 -1
- package/esm/production/provision/ioc-provider-controller.js +1 -1
- package/esm/production/provision/ioc-provider-controller.js.map +1 -1
- package/esm/production/provision/use-injectables-provider.js.map +1 -1
- package/esm/production/provision/use-ioc-provision.js.map +1 -1
- 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.map +1 -1
- package/index.d.ts +199 -172
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
- `WireScope`: add new event/command/query subscribe-unsubscribe methods
|
|
9
9
|
- Export more alias / methods from `@wirestate/core`
|
|
10
10
|
- Export more alias / methods from `@wirestate/react-mobx`
|
|
11
|
+
- Export missing methods typing for `@wirestate/core`
|
|
12
|
+
- Extensive JSDoc coverage for wirestate packages
|
|
13
|
+
- `createIocContainer`: Added ability to instantly provide and activate entries, targeted seeds
|
|
14
|
+
- `createInjectablesProvider`: Removed.
|
|
15
|
+
- `IocProvider`: Removed
|
|
16
|
+
- `useRootContainer`: Added separate hook for store management in React tree
|
|
17
|
+
- `ContainerProvider`: Simpler provider for containers.
|
|
18
|
+
- `SubContainerProvider`: Added component solving problems of removed `createInjectablesProvider`
|
|
19
|
+
- `ContainerActivator`: Added separate activation component
|
|
11
20
|
|
|
12
21
|
## 0.6.3
|
|
13
22
|
|
|
@@ -70,6 +79,6 @@
|
|
|
70
79
|
- useService -> useInjection
|
|
71
80
|
- AbstractService::getService -> AbstractService::resolve
|
|
72
81
|
|
|
73
|
-
## 0.1.
|
|
82
|
+
## 0.1.0
|
|
74
83
|
|
|
75
84
|
- Initial release
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @wirestate/lit
|
|
1
|
+
# @wirestate/lit [[monorepo](https://github.com/Neloreck/wirestate)] [[docs](https://neloreck.github.io/wirestate/)]
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@wirestate/lit)
|
|
4
4
|
[](https://github.com/Neloreck/wirestate/blob/master/LICENSE)
|
|
@@ -29,11 +29,11 @@ npm install @wirestate/core @wirestate/lit lit reflect-metadata
|
|
|
29
29
|
Provides an IoC container to the component tree. It uses Lit Context to propagate the container to child elements.
|
|
30
30
|
|
|
31
31
|
```typescript
|
|
32
|
-
import { LitElement, html } from
|
|
33
|
-
import { customElement } from
|
|
34
|
-
import { iocProvide, IocProviderController } from
|
|
32
|
+
import { LitElement, html } from "lit";
|
|
33
|
+
import { customElement } from "lit/decorators.js";
|
|
34
|
+
import { iocProvide, IocProviderController } from "@wirestate/lit";
|
|
35
35
|
|
|
36
|
-
@customElement(
|
|
36
|
+
@customElement("my-app")
|
|
37
37
|
class MyApp extends LitElement {
|
|
38
38
|
@iocProvide()
|
|
39
39
|
private ioc!: IocProviderController;
|
|
@@ -51,13 +51,13 @@ Binds a set of injectables to the nearest IoC container for the host element's l
|
|
|
51
51
|
Using the decorator (accessor):
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
|
-
import { LitElement } from
|
|
55
|
-
import { customElement } from
|
|
56
|
-
import { injectablesProvide, InjectablesProviderController } from
|
|
54
|
+
import { LitElement } from "lit";
|
|
55
|
+
import { customElement } from "lit/decorators.js";
|
|
56
|
+
import { injectablesProvide, InjectablesProviderController } from "@wirestate/lit";
|
|
57
57
|
|
|
58
|
-
import { AuthService, UserService } from
|
|
58
|
+
import { AuthService, UserService } from "./services";
|
|
59
59
|
|
|
60
|
-
@customElement(
|
|
60
|
+
@customElement("my-app")
|
|
61
61
|
class MyApp extends LitElement {
|
|
62
62
|
@injectablesProvide({ entries: [AuthService, UserService], activate: [AuthService] })
|
|
63
63
|
public services!: InjectablesProviderController<MyApp>;
|
|
@@ -67,10 +67,10 @@ class MyApp extends LitElement {
|
|
|
67
67
|
Using the hook:
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
|
-
import { LitElement } from
|
|
71
|
-
import { useInjectablesProvider } from
|
|
70
|
+
import { LitElement } from "lit";
|
|
71
|
+
import { useInjectablesProvider } from "@wirestate/lit";
|
|
72
72
|
|
|
73
|
-
import { AuthService, UserService } from
|
|
73
|
+
import { AuthService, UserService } from "./services";
|
|
74
74
|
|
|
75
75
|
class MyApp extends LitElement {
|
|
76
76
|
private services = useInjectablesProvider(this, {
|
|
@@ -83,10 +83,10 @@ class MyApp extends LitElement {
|
|
|
83
83
|
Using the controller directly:
|
|
84
84
|
|
|
85
85
|
```typescript
|
|
86
|
-
import { LitElement } from
|
|
87
|
-
import { InjectablesProviderController } from
|
|
86
|
+
import { LitElement } from "lit";
|
|
87
|
+
import { InjectablesProviderController } from "@wirestate/lit";
|
|
88
88
|
|
|
89
|
-
import { AuthService, UserService } from
|
|
89
|
+
import { AuthService, UserService } from "./services";
|
|
90
90
|
|
|
91
91
|
class MyApp extends LitElement {
|
|
92
92
|
private services = new InjectablesProviderController(this, {
|
|
@@ -99,10 +99,10 @@ class MyApp extends LitElement {
|
|
|
99
99
|
To bind into a specific container instead of the nearest provider context, pass the `into` option:
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
|
-
import { LitElement } from
|
|
103
|
-
import { useInjectablesProvider } from
|
|
102
|
+
import { LitElement } from "lit";
|
|
103
|
+
import { useInjectablesProvider } from "@wirestate/lit";
|
|
104
104
|
|
|
105
|
-
import { AuthService, UserService } from
|
|
105
|
+
import { AuthService, UserService } from "./services";
|
|
106
106
|
|
|
107
107
|
class MyApp extends LitElement {
|
|
108
108
|
private services = useInjectablesProvider(this, {
|
|
@@ -118,13 +118,13 @@ class MyApp extends LitElement {
|
|
|
118
118
|
Injects a service from the nearest IoC container. Supports both options object and direct service identifier.
|
|
119
119
|
|
|
120
120
|
```typescript
|
|
121
|
-
import { LitElement, html } from
|
|
122
|
-
import { customElement } from
|
|
123
|
-
import { injection } from
|
|
121
|
+
import { LitElement, html } from "lit";
|
|
122
|
+
import { customElement } from "lit/decorators.js";
|
|
123
|
+
import { injection } from "@wirestate/lit";
|
|
124
124
|
|
|
125
|
-
import { MyService } from
|
|
125
|
+
import { MyService } from "./services";
|
|
126
126
|
|
|
127
|
-
@customElement(
|
|
127
|
+
@customElement("my-component")
|
|
128
128
|
class MyComponent extends LitElement {
|
|
129
129
|
// Using identifier:
|
|
130
130
|
@injection(MyService)
|
|
@@ -143,10 +143,10 @@ class MyComponent extends LitElement {
|
|
|
143
143
|
Using the controller:
|
|
144
144
|
|
|
145
145
|
```typescript
|
|
146
|
-
import { LitElement, html } from
|
|
147
|
-
import { useInjection } from
|
|
146
|
+
import { LitElement, html } from "lit";
|
|
147
|
+
import { useInjection } from "@wirestate/lit";
|
|
148
148
|
|
|
149
|
-
import { MyService } from
|
|
149
|
+
import { MyService } from "./services";
|
|
150
150
|
|
|
151
151
|
class MyComponent extends LitElement {
|
|
152
152
|
// Using identifier:
|
|
@@ -168,15 +168,15 @@ class MyComponent extends LitElement {
|
|
|
168
168
|
Subscribe to events from the event bus using `@onEvent` decorator or `useOnEvents` controller.
|
|
169
169
|
|
|
170
170
|
```typescript
|
|
171
|
-
import { LitElement } from
|
|
172
|
-
import { onEvent } from
|
|
171
|
+
import { LitElement } from "lit";
|
|
172
|
+
import { onEvent } from "@wirestate/lit";
|
|
173
173
|
|
|
174
|
-
import { UserLoggedInEvent } from
|
|
174
|
+
import { UserLoggedInEvent } from "./events";
|
|
175
175
|
|
|
176
176
|
class MyListener extends LitElement {
|
|
177
177
|
@onEvent("USER_LOGGED_IN")
|
|
178
178
|
private handleLogin(event: UserLoggedInEvent) {
|
|
179
|
-
console.log(
|
|
179
|
+
console.log("User logged in:", event.payload);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
```
|
|
@@ -184,12 +184,12 @@ class MyListener extends LitElement {
|
|
|
184
184
|
Using the controller:
|
|
185
185
|
|
|
186
186
|
```typescript
|
|
187
|
-
import { LitElement } from
|
|
188
|
-
import { useOnEvents } from
|
|
187
|
+
import { LitElement } from "lit";
|
|
188
|
+
import { useOnEvents } from "@wirestate/lit";
|
|
189
189
|
|
|
190
190
|
class MyListener extends LitElement {
|
|
191
191
|
private events = useOnEvents(this, {
|
|
192
|
-
handler: (event) => console.log(
|
|
192
|
+
handler: (event) => console.log("Event received:", event),
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
```
|
|
@@ -199,11 +199,11 @@ class MyListener extends LitElement {
|
|
|
199
199
|
Register a handler for a specific command type.
|
|
200
200
|
|
|
201
201
|
```typescript
|
|
202
|
-
import { LitElement } from
|
|
203
|
-
import { onCommand } from
|
|
202
|
+
import { LitElement } from "lit";
|
|
203
|
+
import { onCommand } from "@wirestate/lit";
|
|
204
204
|
|
|
205
205
|
class MyCommander extends LitElement {
|
|
206
|
-
@onCommand(
|
|
206
|
+
@onCommand("RESET_STATE")
|
|
207
207
|
private handleReset() {
|
|
208
208
|
// perform reset
|
|
209
209
|
}
|
|
@@ -215,11 +215,11 @@ class MyCommander extends LitElement {
|
|
|
215
215
|
Register a handler for a specific query type.
|
|
216
216
|
|
|
217
217
|
```typescript
|
|
218
|
-
import { LitElement } from
|
|
219
|
-
import { onQuery } from
|
|
218
|
+
import { LitElement } from "lit";
|
|
219
|
+
import { onQuery } from "@wirestate/lit";
|
|
220
220
|
|
|
221
221
|
class MyQuerier extends LitElement {
|
|
222
|
-
@onQuery(
|
|
222
|
+
@onQuery("GET_VIEW_PORT")
|
|
223
223
|
private handleGetViewport() {
|
|
224
224
|
return { width: window.innerWidth, height: window.innerHeight };
|
|
225
225
|
}
|
|
@@ -233,9 +233,9 @@ class MyQuerier extends LitElement {
|
|
|
233
233
|
Creates a test fixture with a provider element and an IoC container. Useful for unit testing components that use injections.
|
|
234
234
|
|
|
235
235
|
```typescript
|
|
236
|
-
import { createLitProvision } from
|
|
236
|
+
import { createLitProvision } from "@wirestate/lit/test-utils";
|
|
237
237
|
|
|
238
|
-
describe(
|
|
238
|
+
describe("MyComponent", () => {
|
|
239
239
|
let fixture: ReturnType<typeof createLitProvision>;
|
|
240
240
|
|
|
241
241
|
beforeEach(() => {
|
|
@@ -246,8 +246,8 @@ describe('MyComponent', () => {
|
|
|
246
246
|
fixture.cleanup();
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
it(
|
|
250
|
-
const el = document.createElement(
|
|
249
|
+
it("should work", () => {
|
|
250
|
+
const el = document.createElement("my-component");
|
|
251
251
|
fixture.provider.appendChild(el);
|
|
252
252
|
// ...
|
|
253
253
|
});
|