@wirestate/lit 0.6.0

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 (37) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/LICENSE +21 -0
  3. package/README.md +23 -0
  4. package/cjs/development/index.js +162 -0
  5. package/cjs/development/index.js.map +1 -0
  6. package/cjs/production/index.js +1 -0
  7. package/cjs/production/index.js.map +1 -0
  8. package/esm/development/consumption/injection.js +37 -0
  9. package/esm/development/consumption/injection.js.map +1 -0
  10. package/esm/development/consumption/use-injection.js +23 -0
  11. package/esm/development/consumption/use-injection.js.map +1 -0
  12. package/esm/development/context/ioc-context.js +7 -0
  13. package/esm/development/context/ioc-context.js.map +1 -0
  14. package/esm/development/index.js +7 -0
  15. package/esm/development/index.js.map +1 -0
  16. package/esm/development/provision/container-provider-controller.js +41 -0
  17. package/esm/development/provision/container-provider-controller.js.map +1 -0
  18. package/esm/development/provision/services-provider-controller.js +63 -0
  19. package/esm/development/provision/services-provider-controller.js.map +1 -0
  20. package/esm/development/provision/use-container-provision.js +9 -0
  21. package/esm/development/provision/use-container-provision.js.map +1 -0
  22. package/esm/production/consumption/injection.js +1 -0
  23. package/esm/production/consumption/injection.js.map +1 -0
  24. package/esm/production/consumption/use-injection.js +1 -0
  25. package/esm/production/consumption/use-injection.js.map +1 -0
  26. package/esm/production/context/ioc-context.js +1 -0
  27. package/esm/production/context/ioc-context.js.map +1 -0
  28. package/esm/production/index.js +1 -0
  29. package/esm/production/index.js.map +1 -0
  30. package/esm/production/provision/container-provider-controller.js +1 -0
  31. package/esm/production/provision/container-provider-controller.js.map +1 -0
  32. package/esm/production/provision/services-provider-controller.js +1 -0
  33. package/esm/production/provision/services-provider-controller.js.map +1 -0
  34. package/esm/production/provision/use-container-provision.js +1 -0
  35. package/esm/production/provision/use-container-provision.js.map +1 -0
  36. package/index.d.ts +96 -0
  37. package/package.json +57 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ ## 0.6.3
2
+
3
+ - Update readme files for each module
4
+
5
+ ## 0.6.2
6
+
7
+ - Corrected build system, react package structure
8
+
9
+ ## 0.6.1
10
+
11
+ - React related types moved to react lib
12
+ - Avoid prefixed I/T types
13
+
14
+ ## 0.6.0
15
+
16
+ - Split wirestate as separate @wirestate packages
17
+
18
+ ## 0.5.0
19
+
20
+ - Add default initial state param on creation of containers
21
+ - Explicit typing for query callers, export new types
22
+ - For wire-scope add missing optional query/command/resolve methods
23
+ - Add sourcemaps in lib bundles
24
+ - Add `signals` entry for variants of storage usage without mobx
25
+
26
+ ## 0.4.0
27
+
28
+ - Add `OnActivated` decorator
29
+ - Add `OnDeactivated` decorator
30
+ - `initialState` -> `seed`
31
+ - `type` -> `bindingType`
32
+ - `scopeType` -> `bindingScopeType`
33
+ - Emit events with two params instead of manually composed object, signal `from`
34
+ - Add commands module
35
+ - Add WireScope shared class for managing of wirestate events, queries and commands
36
+ - Remove abstract service in favor of WireScope usage
37
+ - Signals -> events
38
+ - `useOptionalInjection` -> add fallback handler
39
+
40
+ ## 0.3.0
41
+
42
+ - Rename `createServicesProvider` to `createInjectablesProvider`
43
+ - Add `useSignals`, `useSignalHandler` hooks for better signal handling ergonomics
44
+ - Add `useOptionalInjection` hook for safe resolution of optional dependencies
45
+ - Support optional queries via `queryOptional`, `useOptionalQueryCaller`, and `useOptionalSyncQueryCaller`
46
+ - Support merging of initial states when multiple providers co-exist
47
+ - Add more re-exports from `mobx` and `inversify` for easier consumer usage
48
+ - Improve test coverage, extend test utilities
49
+ - Correctly notify about `IS_DISPOSED` after deactivation of services
50
+
51
+ ## 0.2.0
52
+
53
+ - Activate and deactivate services in stack ordering
54
+ - Portable libs will not fail with react compiler builds
55
+ - Extend test-utils
56
+ - Increasing test coverage
57
+ - Error handling / custom error class
58
+ - Allow addition of constant bindings in the IOC container
59
+ - useService -> useInjection
60
+ - AbstractService::getService -> AbstractService::resolve
61
+
62
+ ## 0.1.1
63
+
64
+ - Initial release
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Syrotenko Igor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @wirestate/lit
2
+
3
+ [![npm](https://img.shields.io/npm/v/@wirestate/lit.svg?style=flat-square)](https://www.npmjs.com/package/@wirestate/lit)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/Neloreck/wirestate/blob/master/LICENSE)
5
+
6
+ Lit elements integration for wirestate.
7
+ Planned — not yet implemented.
8
+
9
+ ## Planned scope
10
+
11
+ - Base `LitElement` classes and mixins for resolving services from the wirestate DI container
12
+ - Lit-compatible equivalents of the React providers from `@wirestate/react`
13
+ - Lifecycle integration: activate/deactivate services on element connect/disconnect
14
+
15
+ ## Installation (upcoming)
16
+
17
+ ```bash
18
+ npm install @wirestate/core @wirestate/lit lit reflect-metadata
19
+ ```
20
+
21
+ ## License
22
+
23
+ MIT
@@ -0,0 +1,162 @@
1
+ 'use strict';
2
+
3
+ var context = require('@lit/context');
4
+ var core = require('@wirestate/core');
5
+
6
+ var IOC_CONTAINER_KEY = Symbol("ContainerContext");
7
+ var ContainerContext = context.createContext(IOC_CONTAINER_KEY);
8
+
9
+ function injection(_a) {
10
+ var injectionId = _a.injectionId,
11
+ subscribe = _a.subscribe;
12
+ return function (protoOrTarget, nameOrContext) {
13
+ // Standard decorators branch.
14
+ if (typeof nameOrContext === "object") {
15
+ nameOrContext.addInitializer(function () {
16
+ var _this = this;
17
+ new context.ContextConsumer(this, {
18
+ context: ContainerContext,
19
+ callback: function (it) {
20
+ protoOrTarget.set.call(_this, it.container.get(injectionId));
21
+ },
22
+ subscribe: subscribe
23
+ });
24
+ });
25
+ } else {
26
+ // Experimental decorators branch.
27
+ protoOrTarget.constructor.addInitializer(function (element) {
28
+ new context.ContextConsumer(element, {
29
+ context: ContainerContext,
30
+ callback: function (it) {
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ element[nameOrContext] = it.container.get(injectionId);
33
+ },
34
+ subscribe: subscribe
35
+ });
36
+ });
37
+ }
38
+ };
39
+ }
40
+
41
+ function useInjection(host, _a) {
42
+ var once = _a.once,
43
+ injectionId = _a.injectionId,
44
+ value = _a.value;
45
+ var current = {
46
+ value: value,
47
+ injectionId: injectionId
48
+ };
49
+ new context.ContextConsumer(host, {
50
+ context: ContainerContext,
51
+ subscribe: !once,
52
+ callback: function (it) {
53
+ current.value = it.container.get(injectionId);
54
+ }
55
+ });
56
+ return current;
57
+ }
58
+
59
+ var ContainerProviderController = /** @class */function () {
60
+ function ContainerProviderController(host, container) {
61
+ var _this = this;
62
+ this.host = host;
63
+ this.revision = 1;
64
+ this.host.addController(this);
65
+ this.container = container !== null && container !== void 0 ? container : core.createIocContainer();
66
+ this.provider = new context.ContextProvider(host, {
67
+ context: ContainerContext,
68
+ initialValue: {
69
+ container: this.container,
70
+ revision: this.revision,
71
+ nextRevision: function () {
72
+ return _this.nextRevision();
73
+ }
74
+ }
75
+ });
76
+ }
77
+ ContainerProviderController.prototype.hostConnected = function () {};
78
+ ContainerProviderController.prototype.hostDisconnected = function () {};
79
+ ContainerProviderController.prototype.nextRevision = function () {
80
+ var _this = this;
81
+ this.revision += 1;
82
+ this.provider.setValue({
83
+ container: this.container,
84
+ revision: this.revision,
85
+ nextRevision: function () {
86
+ return _this.nextRevision();
87
+ }
88
+ });
89
+ return this.revision;
90
+ };
91
+ return ContainerProviderController;
92
+ }();
93
+
94
+ var ServicesProviderController = /** @class */function () {
95
+ function ServicesProviderController(host, options) {
96
+ this.host = host;
97
+ this.host.addController(this);
98
+ this.entries = options.entries;
99
+ this.activate = options.activate;
100
+ this.seeds = options.seeds;
101
+ this.into = options.into;
102
+ this.consumer = new context.ContextConsumer(host, {
103
+ context: ContainerContext,
104
+ subscribe: true,
105
+ callback: function (it) {
106
+ return;
107
+ }
108
+ });
109
+ }
110
+ ServicesProviderController.prototype.hostConnected = function () {
111
+ var context = this.into ? typeof this.into === "function" ? this.into() : this.into : this.consumer.value;
112
+ if (!context) {
113
+ if (this.consumer["provided"] === false) {
114
+ throw new Error("not provided");
115
+ }
116
+ throw new Error("todo");
117
+ }
118
+ // Seed must be applied BEFORE binding so @Inject(INITIAL_STATE_TOKEN) works during activation.
119
+ if (this.seeds) {
120
+ core.applySeeds(context.container, this.seeds);
121
+ }
122
+ for (var _i = 0, _a = this.entries; _i < _a.length; _i++) {
123
+ var entry = _a[_i];
124
+ core.bindEntry(context.container, entry);
125
+ }
126
+ if (this.activate) {
127
+ for (var _b = 0, _c = this.activate; _b < _c.length; _b++) {
128
+ var eager = _c[_b];
129
+ context.container.get(eager);
130
+ }
131
+ }
132
+ };
133
+ ServicesProviderController.prototype.hostDisconnected = function () {
134
+ var context = this.into ? typeof this.into === "function" ? this.into() : this.into : this.consumer.value;
135
+ if (!context) {
136
+ throw new Error("todo");
137
+ }
138
+ for (var _i = 0, _a = this.entries; _i < _a.length; _i++) {
139
+ var entry = _a[_i];
140
+ var token = core.getEntryToken(entry);
141
+ context.container.unbind(token);
142
+ }
143
+ // Remove only this provider's targeted initial state entries.
144
+ if (this.seeds) {
145
+ core.unapplySeeds(context.container, this.seeds);
146
+ }
147
+ };
148
+ return ServicesProviderController;
149
+ }();
150
+
151
+ function useContainerProvision(host, _a) {
152
+ var container = _a.container;
153
+ return new ContainerProviderController(host, container);
154
+ }
155
+
156
+ exports.ContainerContext = ContainerContext;
157
+ exports.ContainerProviderController = ContainerProviderController;
158
+ exports.ServicesProviderController = ServicesProviderController;
159
+ exports.injection = injection;
160
+ exports.useContainerProvision = useContainerProvision;
161
+ exports.useInjection = useInjection;
162
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../../src/wirestate-lit/context/ioc-context.ts","../../../../../../../src/wirestate-lit/consumption/injection.ts","../../../../../../../src/wirestate-lit/consumption/use-injection.ts","../../../../../../../src/wirestate-lit/provision/container-provider-controller.ts","../../../../../../../src/wirestate-lit/provision/services-provider-controller.ts","../../../../../../../src/wirestate-lit/provision/use-container-provision.ts"],"sourcesContent":[null,null,null,null,null,null],"names":["IOC_CONTAINER_KEY","Symbol","ContainerContext","createContext","injection","_a","injectionId","subscribe","protoOrTarget","nameOrContext","addInitializer","_this","ContextConsumer","context","callback","it","set","call","container","get","constructor","element","useInjection","host","once","value","current","ContainerProviderController","revision","addController","createIocContainer","provider","ContextProvider","initialValue","nextRevision","prototype","hostConnected","hostDisconnected","setValue","ServicesProviderController","options","entries","activate","seeds","into","consumer","Error","applySeeds","_i","length","entry","bindEntry","_b","_c","eager","token","getEntryToken","unbind","unapplySeeds","useContainerProvision"],"mappings":";;;;;AAGO,IAAMA,iBAAiB,GAAGC,MAAM,CAAC,kBAAkB,CAAC;IAiB9CC,gBAAgB,GAAGC,qBAAa,CAAaH,iBAAiB;;ACKrE,SAAUI,SAASA,CAAIC,E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I,CAACA,IAAI,EAAE,GACX,IAAI,CAACA,IAAI,GACX,IAAI,CAACC,QAAQ,CAACpB,KAAK;IAQvB,IAAI,CAACZ,OAAO,EAAE;AACZ,MAAA,MAAM,IAAIiC,KAAK,CAAC,MAAM,CAAC;AACzB,IAAA;AAEA,IAAA,KAAoB,IAAAE,EAAA,GAAA,CAAY,EAAZ3C,EAAA,GAAA,IAAI,CAACoC,OAAO,EAAZO,EAAA,GAAA3C,EAAA,CAAA4C,MAAY,EAAZD,EAAA,EAAY,EAAE;AAA7B,MAAA,IAAME,KAAK,GAAA7C,EAAA,CAAA2C,EAAA,CAAA;AACd,MAAA,IAAMO,KAAK,GAAsBC,kBAAa,CAACN,KAAK,CAAC;AAErDrC,MAAAA,OAAO,CAACK,SAAS,CAACuC,MAAM,CAACF,KAAK,CAAC;AACjC,IAAA;AAEA;IACA,IAAI,IAAI,CAACZ,KAAK,EAAE;MACde,iBAAY,CAAC7C,OAAO,CAACK,SAAS,EAAE,IAAI,CAACyB,KAAK,CAAC;AAC7C,IAAA;EACF,CAAC;AACH,EAAA,OAAAJ,0BAAC;AAAD,CAAC;;ACpHK,SAAUoB,qBAAqBA,CACnCpC,IAAO,EACPlB,EAA2C,EAAA;AAAzC,EAAA,IAAAa,SAAS,GAAAb,EAAA,CAAAa,SAAA;AAEX,EAAA,OAAO,IAAIS,2BAA2B,CAACJ,IAAI,EAAEL,SAAS,CAAC;AACzD;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ "use strict";var t=require("@lit/context"),n=require("@wirestate/core"),e=Symbol("ContainerContext"),i=t.createContext(e);var o=function(){function e(e,o){var r=this;this.host=e,this.revision=1,this.host.addController(this),this.container=null!=o?o:n.createIocContainer(),this.provider=new t.ContextProvider(e,{context:i,initialValue:{container:this.container,revision:this.revision,nextRevision:function(){return r.nextRevision()}}})}return e.prototype.hostConnected=function(){},e.prototype.hostDisconnected=function(){},e.prototype.nextRevision=function(){var t=this;return this.revision+=1,this.provider.setValue({container:this.container,revision:this.revision,nextRevision:function(){return t.nextRevision()}}),this.revision},e}(),r=function(){function e(n,e){this.host=n,this.host.addController(this),this.entries=e.entries,this.activate=e.activate,this.seeds=e.seeds,this.into=e.into,this.consumer=new t.ContextConsumer(n,{context:i,subscribe:!0,callback:function(t){}})}return e.prototype.hostConnected=function(){var t=this.into?"function"==typeof this.into?this.into():this.into:this.consumer.value;if(!t){if(!1===this.consumer.provided)throw new Error("not provided");throw new Error("todo")}this.seeds&&n.applySeeds(t.container,this.seeds);for(var e=0,i=this.entries;e<i.length;e++){var o=i[e];n.bindEntry(t.container,o)}if(this.activate)for(var r=0,s=this.activate;r<s.length;r++){var c=s[r];t.container.get(c)}},e.prototype.hostDisconnected=function(){var t=this.into?"function"==typeof this.into?this.into():this.into:this.consumer.value;if(!t)throw new Error("todo");for(var e=0,i=this.entries;e<i.length;e++){var o=i[e],r=n.getEntryToken(o);t.container.unbind(r)}this.seeds&&n.unapplySeeds(t.container,this.seeds)},e}();exports.ContainerContext=i,exports.ContainerProviderController=o,exports.ServicesProviderController=r,exports.injection=function(n){var e=n.injectionId,o=n.subscribe;return function(n,r){"object"==typeof r?r.addInitializer((function(){var r=this;new t.ContextConsumer(this,{context:i,callback:function(t){n.set.call(r,t.container.get(e))},subscribe:o})})):n.constructor.addInitializer((function(n){new t.ContextConsumer(n,{context:i,callback:function(t){n[r]=t.container.get(e)},subscribe:o})}))}},exports.useContainerProvision=function(t,n){var e=n.container;return new o(t,e)},exports.useInjection=function(n,e){var o=e.once,r=e.injectionId,s={value:e.value,injectionId:r};return new t.ContextConsumer(n,{context:i,subscribe:!o,callback:function(t){s.value=t.container.get(r)}}),s};//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../../src/wirestate-lit/context/ioc-context.ts","../../../../../../../src/wirestate-lit/provision/container-provider-controller.ts","../../../../../../../src/wirestate-lit/provision/services-provider-controller.ts","../../../../../../../src/wirestate-lit/provision/use-container-provision.ts","../../../../../../../src/wirestate-lit/consumption/injection.ts","../../../../../../../src/wirestate-lit/consumption/use-injection.ts"],"sourcesContent":[null,null,null,null,null,null],"names":["context","require","core","IOC_CONTAINER_KEY","Symbol","ContainerContext","createContext","ContainerProviderController","host","container","_this","this","revision","addController","createIocContainer","provider","ContextProvider","initialValue","nextRevision","prototype","hostConnected","hostDisconnected","setValue","ServicesProviderController","options","entries","activate","seeds","into","consumer","ContextConsumer","subscribe","callback","it","value","Error","applySeeds","_i","_a","length","entry","bindEntry","_b","_c","eager","get","token","getEntryToken","unbind","unapplySeeds","exports","injection","injectionId","protoOrTarget","nameOrContext","addInitializer","set","call","constructor","element","useContainerProvision","useInjection","once","current"],"mappings":"AAGO,aAAA,IAAAA,EAAAC,QAAA,gBAAAC,EAAAD,QAAA,mBAAME,EAAoBC,OAAO,oBAiB3BC,EAAmBC,EAAAA,cAA0BH,GCV1D,IAAAI,EAAA,WAME,SAAAA,EACmBC,EACjBC,GAFF,IAAAC,EAAAC,KACmBA,KAAAH,KAAAA,EALTG,KAAAC,SAAmB,EAQ3BD,KAAKH,KAAKK,cAAcF,MAExBA,KAAKF,UAAYA,QAAAA,EAAaK,uBAS9BH,KAAKI,SAAW,IAAIC,EAAAA,gBAAgBR,EAAM,CACxCR,QAASK,EACTY,aAAc,CACZR,UAAWE,KAAKF,UAChBG,SAAUD,KAAKC,SACfM,aAAc,WAAM,OAAAR,EAAKQ,cAAL,IAG1B,CA4BF,OA1BSX,EAAAY,UAAAC,cAAP,WAEA,EAEOb,EAAAY,UAAAE,iBAAP,WAEA,EAEOd,EAAAY,UAAAD,aAAP,WAAA,IAAAR,EAAAC,KAgBE,OARAA,KAAKC,UAAY,EAEjBD,KAAKI,SAASO,SAAS,CACrBb,UAAWE,KAAKF,UAChBG,SAAUD,KAAKC,SACfM,aAAc,WAAM,OAAAR,EAAKQ,cAAL,IAGfP,KAAKC,QACd,EACFL,CAAA,CAzDA,GCiBAgB,EAAA,WAQE,SAAAA,EACmBf,EACjB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S,EAA2BC,EAAAA,cAAcP,GAE/CxC,EAAQS,UAAUuC,OAAOF,EAC3B,CAGInC,KAAKgB,OACPsB,EAAAA,aAAajD,EAAQS,UAAWE,KAAKgB,MAEzC,EACFJ,CAAA,CAlGA,GCbA2B,QAAA7C,iBAAAA,EAAA6C,QAAA3C,4BAAAA,EAAA2C,QAAA3B,2BAAAA,EAAA2B,QAAAC,UCWM,SAAuBb,OAAEc,EAAWd,EAAAc,YAAErB,EAASO,EAAAP,UACnD,OAAQ,SACNsB,EACAC,GAG6B,iBAAlBA,EACTA,EAAcC,gBAAe,WAAA,IAAA7C,EAAAC,KAC3B,IAAImB,EAAAA,gBAAgBnB,KAAM,CACxBX,QAASK,EACT2B,SAAU,SAACC,GACToB,EAAcG,IAAIC,KAAK/C,EAAMuB,EAAGxB,UAAUoC,IAAIO,GAChD,EACArB,UAASA,GAEb,IAGCsB,EAAcK,YAAuCH,gBAAe,SAACI,GACpE,IAAI7B,EAAAA,gBAAgB6B,EAAS,CAC3B3D,QAASK,EACT2B,SAAU,SAACC,GAER0B,EAAgBL,GAAiBrB,EAAGxB,UAAUoC,IAAIO,EACrD,EACArB,UAASA,GAEb,GAEJ,CACF,EDzCAmB,QAAAU,sBALM,SACJpD,EACA8B,GAAE,IAAA7B,EAAS6B,EAAA7B,UAEX,OAAO,IAAIF,EAA4BC,EAAMC,EAC/C,EAAAyC,QAAAW,aEOM,SACJrD,EACA8B,GAAE,IAAAwB,SAAMV,EAAWd,EAAAc,YAQbW,EAAgC,CAAE7B,MARdI,EAAAJ,MAQ4CkB,YAAWA,GAUjF,OARA,IAAItB,EAAAA,gBAAgBtB,EAAM,CACxBR,QAASK,EACT0B,WAAY+B,EACZ9B,SAAU,SAACC,GACT8B,EAAQ7B,MAAQD,EAAGxB,UAAUoC,IAAIO,EACnC,IAGKW,CACT"}
@@ -0,0 +1,37 @@
1
+ import { ContextConsumer } from '@lit/context';
2
+ import { ContainerContext } from '../context/ioc-context.js';
3
+
4
+ function injection(_a) {
5
+ var injectionId = _a.injectionId,
6
+ subscribe = _a.subscribe;
7
+ return function (protoOrTarget, nameOrContext) {
8
+ // Standard decorators branch.
9
+ if (typeof nameOrContext === "object") {
10
+ nameOrContext.addInitializer(function () {
11
+ var _this = this;
12
+ new ContextConsumer(this, {
13
+ context: ContainerContext,
14
+ callback: function (it) {
15
+ protoOrTarget.set.call(_this, it.container.get(injectionId));
16
+ },
17
+ subscribe: subscribe
18
+ });
19
+ });
20
+ } else {
21
+ // Experimental decorators branch.
22
+ protoOrTarget.constructor.addInitializer(function (element) {
23
+ new ContextConsumer(element, {
24
+ context: ContainerContext,
25
+ callback: function (it) {
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ element[nameOrContext] = it.container.get(injectionId);
28
+ },
29
+ subscribe: subscribe
30
+ });
31
+ });
32
+ }
33
+ };
34
+ }
35
+
36
+ export { injection };
37
+ //# sourceMappingURL=injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injection.js","sources":["../../../../../../../../src/wirestate-lit/consumption/injection.ts"],"sourcesContent":[null],"names":["injection","_a","injectionId","subscribe","protoOrTarget","nameOrContext","addInitializer","_this","ContextConsumer","context","ContainerContext","callback","it","set","call","container","get","constructor","element"],"mappings":";;;AAyBM,SAAUA,SAASA,CAAIC,EAA+C,EAAA;MAA7CC,WAAW,GAAAD,EAAA,CAAAC,WAAA;IAAEC,SAAS,GAAAF,EAAA,CAAAE,SAAA;AACnD,EAAA,OAAQ,UACNC,aAA+D,EAC/DC,aAA8E,EAAA;AAE9E;AACA,IAAA,IAAI,OAAOA,aAAa,KAAK,QAAQ,EAAE;MACrCA,aAAa,CAACC,cAAc,CAAC,YAAA;QAAA,IAAAC,KAAA,GAAA,IAAA;QAC3B,IAAIC,eAAe,CAAC,IAAI,EAAE;AACxBC,UAAAA,OAAO,EAAEC,gBAAgB;AACzBC,UAAAA,QAAQ,EAAE,UAACC,EAAE,EAAA;AACXR,YAAAA,aAAa,CAACS,GAAG,CAACC,IAAI,CAACP,KAAI,EAAEK,EAAE,CAACG,SAAS,CAACC,GAAG,CAACd,WAAW,CAAC,CAAC;UAC7D,CAAC;AACDC,UAAAA,SAAS,EAAAA;AACV,SAAA,CAAC;AACJ,MAAA,CAAC,CAAC;AACJ,IAAA,CAAC,MAAM;AACL;AACCC,MAAAA,aAAa,CAACa,WAAsC,CAACX,cAAc,CAAC,UAACY,OAAwB,EAAA;QAC5F,IAAIV,eAAe,CAACU,OAAO,EAAE;AAC3BT,UAAAA,OAAO,EAAEC,gBAAgB;AACzBC,UAAAA,QAAQ,EAAE,UAACC,EAAE,EAAA;AACX;YACCM,OAAe,CAACb,aAAa,CAAC,GAAGO,EAAE,CAACG,SAAS,CAACC,GAAG,CAACd,WAAW,CAAC;UACjE,CAAC;AACDC,UAAAA,SAAS,EAAAA;AACV,SAAA,CAAC;AACJ,MAAA,CAAC,CAAC;AACJ,IAAA;EACF,CAAC;AACH;;;;"}
@@ -0,0 +1,23 @@
1
+ import { ContextConsumer } from '@lit/context';
2
+ import { ContainerContext } from '../context/ioc-context.js';
3
+
4
+ function useInjection(host, _a) {
5
+ var once = _a.once,
6
+ injectionId = _a.injectionId,
7
+ value = _a.value;
8
+ var current = {
9
+ value: value,
10
+ injectionId: injectionId
11
+ };
12
+ new ContextConsumer(host, {
13
+ context: ContainerContext,
14
+ subscribe: !once,
15
+ callback: function (it) {
16
+ current.value = it.container.get(injectionId);
17
+ }
18
+ });
19
+ return current;
20
+ }
21
+
22
+ export { useInjection };
23
+ //# sourceMappingURL=use-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-injection.js","sources":["../../../../../../../../src/wirestate-lit/consumption/use-injection.ts"],"sourcesContent":[null],"names":["useInjection","host","_a","once","injectionId","value","current","ContextConsumer","context","ContainerContext","subscribe","callback","it","container","get"],"mappings":";;;AAqBM,SAAUA,YAAYA,CAC1BC,IAAO,EACPC,EAAoD,EAAA;AAAlD,EAAA,IAAAC,IAAI,UAAA;IAAEC,WAAW,GAAAF,EAAA,CAAAE,WAAA;IAAEC,KAAK,GAAAH,EAAA,CAAAG,KAAA;AAQ1B,EAAA,IAAMC,OAAO,GAAyB;AAAED,IAAAA,KAAK,EAAEA,KAAqB;AAAED,IAAAA,WAAW,EAAAA;GAAE;EAEnF,IAAIG,eAAe,CAACN,IAAI,EAAE;AACxBO,IAAAA,OAAO,EAAEC,gBAAgB;IACzBC,SAAS,EAAE,CAACP,IAAI;AAChBQ,IAAAA,QAAQ,EAAE,UAACC,EAAE,EAAA;MACXN,OAAO,CAACD,KAAK,GAAGO,EAAE,CAACC,SAAS,CAACC,GAAG,CAACV,WAAW,CAAC;AAC/C,IAAA;AACD,GAAA,CAAC;AAEF,EAAA,OAAOE,OAAO;AAChB;;;;"}
@@ -0,0 +1,7 @@
1
+ import { createContext } from '@lit/context';
2
+
3
+ var IOC_CONTAINER_KEY = Symbol("ContainerContext");
4
+ var ContainerContext = createContext(IOC_CONTAINER_KEY);
5
+
6
+ export { ContainerContext, IOC_CONTAINER_KEY };
7
+ //# sourceMappingURL=ioc-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ioc-context.js","sources":["../../../../../../../../src/wirestate-lit/context/ioc-context.ts"],"sourcesContent":[null],"names":["IOC_CONTAINER_KEY","Symbol","ContainerContext","createContext"],"mappings":";;IAGaA,iBAAiB,GAAGC,MAAM,CAAC,kBAAkB;IAiB7CC,gBAAgB,GAAGC,aAAa,CAAaH,iBAAiB;;;;"}
@@ -0,0 +1,7 @@
1
+ export { injection } from './consumption/injection.js';
2
+ export { useInjection } from './consumption/use-injection.js';
3
+ export { ContainerContext } from './context/ioc-context.js';
4
+ export { ContainerProviderController } from './provision/container-provider-controller.js';
5
+ export { ServicesProviderController } from './provision/services-provider-controller.js';
6
+ export { useContainerProvision } from './provision/use-container-provision.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,41 @@
1
+ import { ContextProvider } from '@lit/context';
2
+ import { createIocContainer } from '@wirestate/core';
3
+ import { ContainerContext } from '../context/ioc-context.js';
4
+
5
+ var ContainerProviderController = /** @class */function () {
6
+ function ContainerProviderController(host, container) {
7
+ var _this = this;
8
+ this.host = host;
9
+ this.revision = 1;
10
+ this.host.addController(this);
11
+ this.container = container !== null && container !== void 0 ? container : createIocContainer();
12
+ this.provider = new ContextProvider(host, {
13
+ context: ContainerContext,
14
+ initialValue: {
15
+ container: this.container,
16
+ revision: this.revision,
17
+ nextRevision: function () {
18
+ return _this.nextRevision();
19
+ }
20
+ }
21
+ });
22
+ }
23
+ ContainerProviderController.prototype.hostConnected = function () {};
24
+ ContainerProviderController.prototype.hostDisconnected = function () {};
25
+ ContainerProviderController.prototype.nextRevision = function () {
26
+ var _this = this;
27
+ this.revision += 1;
28
+ this.provider.setValue({
29
+ container: this.container,
30
+ revision: this.revision,
31
+ nextRevision: function () {
32
+ return _this.nextRevision();
33
+ }
34
+ });
35
+ return this.revision;
36
+ };
37
+ return ContainerProviderController;
38
+ }();
39
+
40
+ export { ContainerProviderController };
41
+ //# sourceMappingURL=container-provider-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-provider-controller.js","sources":["../../../../../../../../src/wirestate-lit/provision/container-provider-controller.ts"],"sourcesContent":[null],"names":["ContainerProviderController","host","container","_this","revision","addController","createIocContainer","provider","ContextProvider","context","ContainerContext","initialValue","nextRevision","prototype","hostConnected","hostDisconnected","setValue"],"mappings":";;;;AAUA,IAAAA,2BAAA,gBAAA,YAAA;AAME,EAAA,SAAAA,2BAAAA,CACmBC,IAA0C,EAC3DC,SAA4B,EAAA;IAF9B,IAAAC,KAAA,GAAA,IAAA;IACmB,IAAA,CAAAF,IAAI,GAAJA,IAAI;IALb,IAAA,CAAAG,QAAQ,GAAW,CAAC;AAQ5B,IAAA,IAAI,CAACH,IAAI,CAACI,aAAa,CAAC,IAAI,CAAC;AAE7B,IAAA,IAAI,CAACH,SAAS,GAAGA,SAAS,KAAA,IAAA,IAATA,SAAS,KAAA,MAAA,GAATA,SAAS,GAAII,kBAAkB,EAAE;AASlD,IAAA,IAAI,CAACC,QAAQ,GAAG,IAAIC,eAAe,CAACP,IAAI,EAAE;AACxCQ,MAAAA,OAAO,EAAEC,gBAAgB;AACzBC,MAAAA,YAAY,EAAE;QACZT,SAAS,EAAE,IAAI,CAACA,SAAS;QACzBE,QAAQ,EAAE,IAAI,CAACA,QAAQ;QACvBQ,YAAY,EAAE;AAAM,UAAA,OAAAT,KAAI,CAACS,YAAY,EAAE;AAAnB,QAAA;AACrB;AACF,KAAA,CAAC;AACJ,EAAA;AAEOZ,EAAAA,2BAAA,CAAAa,SAAA,CAAAC,aAAa,GAApB,YAAA,CAEA,CAAC;AAEMd,EAAAA,2BAAA,CAAAa,SAAA,CAAAE,gBAAgB,GAAvB,YAAA,CAEA,CAAC;AAEMf,EAAAA,2BAAA,CAAAa,SAAA,CAAAD,YAAY,GAAnB,YAAA;IAAA,IAAAT,KAAA,GAAA,IAAA;IAQE,IAAI,CAACC,QAAQ,IAAI,CAAC;AAElB,IAAA,IAAI,CAACG,QAAQ,CAACS,QAAQ,CAAC;MACrBd,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBE,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBQ,YAAY,EAAE;AAAM,QAAA,OAAAT,KAAI,CAACS,YAAY,EAAE;AAAnB,MAAA;AACrB,KAAA,CAAC;IAEF,OAAO,IAAI,CAACR,QAAQ;EACtB,CAAC;AACH,EAAA,OAAAJ,2BAAC;AAAD,CAAC;;;;"}
@@ -0,0 +1,63 @@
1
+ import { ContextConsumer } from '@lit/context';
2
+ import { applySeeds, bindEntry, getEntryToken, unapplySeeds } from '@wirestate/core';
3
+ import { ContainerContext } from '../context/ioc-context.js';
4
+
5
+ var ServicesProviderController = /** @class */function () {
6
+ function ServicesProviderController(host, options) {
7
+ this.host = host;
8
+ this.host.addController(this);
9
+ this.entries = options.entries;
10
+ this.activate = options.activate;
11
+ this.seeds = options.seeds;
12
+ this.into = options.into;
13
+ this.consumer = new ContextConsumer(host, {
14
+ context: ContainerContext,
15
+ subscribe: true,
16
+ callback: function (it) {
17
+ return;
18
+ }
19
+ });
20
+ }
21
+ ServicesProviderController.prototype.hostConnected = function () {
22
+ var context = this.into ? typeof this.into === "function" ? this.into() : this.into : this.consumer.value;
23
+ if (!context) {
24
+ if (this.consumer["provided"] === false) {
25
+ throw new Error("not provided");
26
+ }
27
+ throw new Error("todo");
28
+ }
29
+ // Seed must be applied BEFORE binding so @Inject(INITIAL_STATE_TOKEN) works during activation.
30
+ if (this.seeds) {
31
+ applySeeds(context.container, this.seeds);
32
+ }
33
+ for (var _i = 0, _a = this.entries; _i < _a.length; _i++) {
34
+ var entry = _a[_i];
35
+ bindEntry(context.container, entry);
36
+ }
37
+ if (this.activate) {
38
+ for (var _b = 0, _c = this.activate; _b < _c.length; _b++) {
39
+ var eager = _c[_b];
40
+ context.container.get(eager);
41
+ }
42
+ }
43
+ };
44
+ ServicesProviderController.prototype.hostDisconnected = function () {
45
+ var context = this.into ? typeof this.into === "function" ? this.into() : this.into : this.consumer.value;
46
+ if (!context) {
47
+ throw new Error("todo");
48
+ }
49
+ for (var _i = 0, _a = this.entries; _i < _a.length; _i++) {
50
+ var entry = _a[_i];
51
+ var token = getEntryToken(entry);
52
+ context.container.unbind(token);
53
+ }
54
+ // Remove only this provider's targeted initial state entries.
55
+ if (this.seeds) {
56
+ unapplySeeds(context.container, this.seeds);
57
+ }
58
+ };
59
+ return ServicesProviderController;
60
+ }();
61
+
62
+ export { ServicesProviderController };
63
+ //# sourceMappingURL=services-provider-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services-provider-controller.js","sources":["../../../../../../../../src/wirestate-lit/provision/services-provider-controller.ts"],"sourcesContent":[null],"names":["ServicesProviderController","host","options","addController","entries","activate","seeds","into","consumer","ContextConsumer","context","ContainerContext","subscribe","callback","it","prototype","hostConnected","value","Error","applySeeds","container","_i","_a","length","entry","bindEntry","_b","_c","eager","get","hostDisconnected","token","getEntryToken","unbind","unapplySeeds"],"mappings":";;;;AA2BA,IAAAA,0BAAA,gBAAA,YAAA;AAQE,EAAA,SAAAA,0BAAAA,CACmBC,IAAO,EACxBC,OAA0C,EAAA;IADzB,IAAA,CAAAD,IAAI,GAAJA,IAAI;AAQrB,IAAA,IAAI,CAACA,IAAI,CAACE,aAAa,CAAC,IAAI,CAAC;AAE7B,IAAA,IAAI,CAACC,OAAO,GAAGF,OAAO,CAACE,OAAO;AAC9B,IAAA,IAAI,CAACC,QAAQ,GAAGH,OAAO,CAACG,QAAQ;AAChC,IAAA,IAAI,CAACC,KAAK,GAAGJ,OAAO,CAACI,KAAK;AAC1B,IAAA,IAAI,CAACC,IAAI,GAAGL,OAAO,CAACK,IAAI;AAExB,IAAA,IAAI,CAACC,QAAQ,GAAG,IAAIC,eAAe,CAACR,IAAI,EAAE;AACxCS,MAAAA,OAAO,EAAEC,gBAAgB;AACzBC,MAAAA,SAAS,EAAE,IAAI;AACfC,MAAAA,QAAQ,EAAE,UAACC,EAAE;AAAK,QAAA;AAAA,MAAA;AACnB,KAAA,CAAC;AACJ,EAAA;AAEOd,EAAAA,0BAAA,CAAAe,SAAA,CAAAC,aAAa,GAApB,YAAA;IACE,IAAMN,OAAO,GAAsB,IAAI,CAACH,IAAI,GACxC,OAAO,IAAI,CAACA,IAAI,KAAK,UAAU,GAC7B,IAAI,CAACA,IAAI,EAAE,GACX,IAAI,CAACA,IAAI,GACX,IAAI,CAACC,QAAQ,CAACS,KAAK;IAQvB,IAAI,CAACP,OAAO,EAAE;MACZ,IAAI,IAAI,CAACF,QAAQ,CAAC,UAAU,CAAC,KAAK,KAAK,EAAE;AACvC,QAAA,MAAM,IAAIU,KAAK,CAAC,cAAc,CAAC;AACjC,MAAA;AAEA,MAAA,MAAM,IAAIA,KAAK,CAAC,MAAM,CAAC;AACzB,IAAA;A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;AAA7B,MAAA,IAAMG,KAAK,GAAAF,EAAA,CAAAD,EAAA,CAAA;AACd,MAAA,IAAMU,KAAK,GAAsBC,aAAa,CAACR,KAAK,CAAC;AAErDd,MAAAA,OAAO,CAACU,SAAS,CAACa,MAAM,CAACF,KAAK,CAAC;AACjC,IAAA;AAEA;IACA,IAAI,IAAI,CAACzB,KAAK,EAAE;MACd4B,YAAY,CAACxB,OAAO,CAACU,SAAS,EAAE,IAAI,CAACd,KAAK,CAAC;AAC7C,IAAA;EACF,CAAC;AACH,EAAA,OAAAN,0BAAC;AAAD,CAAC;;;;"}
@@ -0,0 +1,9 @@
1
+ import { ContainerProviderController } from './container-provider-controller.js';
2
+
3
+ function useContainerProvision(host, _a) {
4
+ var container = _a.container;
5
+ return new ContainerProviderController(host, container);
6
+ }
7
+
8
+ export { useContainerProvision };
9
+ //# sourceMappingURL=use-container-provision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-container-provision.js","sources":["../../../../../../../../src/wirestate-lit/provision/use-container-provision.ts"],"sourcesContent":[null],"names":["useContainerProvision","host","_a","container","ContainerProviderController"],"mappings":";;AASM,SAAUA,qBAAqBA,CACnCC,IAAO,EACPC,EAA2C,EAAA;AAAzC,EAAA,IAAAC,SAAS,GAAAD,EAAA,CAAAC,SAAA;AAEX,EAAA,OAAO,IAAIC,2BAA2B,CAACH,IAAI,EAAEE,SAAS,CAAC;AACzD;;;;"}
@@ -0,0 +1 @@
1
+ import{ContextConsumer as t}from"@lit/context";import{ContainerContext as n}from"../context/ioc-context.js";function c(c){var i=c.injectionId,o=c.subscribe;return function(c,e){"object"==typeof e?e.addInitializer((function(){var e=this;new t(this,{context:n,callback:function(t){c.set.call(e,t.container.get(i))},subscribe:o})})):c.constructor.addInitializer((function(c){new t(c,{context:n,callback:function(t){c[e]=t.container.get(i)},subscribe:o})}))}}export{c as injection};//# sourceMappingURL=injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injection.js","sources":["../../../../../../../../src/wirestate-lit/consumption/injection.ts"],"sourcesContent":[null],"names":["injection","_a","injectionId","subscribe","protoOrTarget","nameOrContext","addInitializer","_this","this","ContextConsumer","context","ContainerContext","callback","it","set","call","container","get","constructor","element"],"mappings":"4GAyBM,SAAUA,EAAaC,OAAEC,EAAWD,EAAAC,YAAEC,EAASF,EAAAE,UACnD,OAAQ,SACNC,EACAC,GAG6B,iBAAlBA,EACTA,EAAcC,gBAAe,WAAA,IAAAC,EAAAC,KAC3B,IAAIC,EAAgBD,KAAM,CACxBE,QAASC,EACTC,SAAU,SAACC,GACTT,EAAcU,IAAIC,KAAKR,EAAMM,EAAGG,UAAUC,IAAIf,GAChD,EACAC,UAASA,GAEb,IAGCC,EAAcc,YAAuCZ,gBAAe,SAACa,GACpE,IAAIV,EAAgBU,EAAS,CAC3BT,QAASC,EACTC,SAAU,SAACC,GAERM,EAAgBd,GAAiBQ,EAAGG,UAAUC,IAAIf,EACrD,EACAC,UAASA,GAEb,GAEJ,CACF,QAAAH"}
@@ -0,0 +1 @@
1
+ import{ContextConsumer as t}from"@lit/context";import{ContainerContext as n}from"../context/ioc-context.js";function e(e,o){var c=o.once,i=o.injectionId,r={value:o.value,injectionId:i};return new t(e,{context:n,subscribe:!c,callback:function(t){r.value=t.container.get(i)}}),r}export{e as useInjection};//# sourceMappingURL=use-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-injection.js","sources":["../../../../../../../../src/wirestate-lit/consumption/use-injection.ts"],"sourcesContent":[null],"names":["ContextConsumer","ContainerContext","useInjection","host","_a","once","injectionId","current","value","context","subscribe","callback","it","container","get"],"mappings":"0BAqBMA,MAAA,0CAAAC,MAAA,4BAAA,SAAUC,EACdC,EACAC,GAAE,IAAAC,SAAMC,EAAWF,EAAAE,YAQbC,EAAgC,CAAEC,MARdJ,EAAAI,MAQ4CF,YAAWA,GAUjF,OARA,IAAIN,EAAgBG,EAAM,CACxBM,QAASR,EACTS,WAAYL,EACZM,SAAU,SAACC,GACTL,EAAQC,MAAQI,EAAGC,UAAUC,IAAIR,EACnC,IAGKC,CACT,QAAAL"}
@@ -0,0 +1 @@
1
+ import{createContext as t}from"@lit/context";var o=Symbol("ContainerContext"),r=t(o);export{r as ContainerContext,o as IOC_CONTAINER_KEY};//# sourceMappingURL=ioc-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ioc-context.js","sources":["../../../../../../../../src/wirestate-lit/context/ioc-context.ts"],"sourcesContent":[null],"names":["IOC_CONTAINER_KEY","Symbol","ContainerContext","createContext"],"mappings":"iDAGaA,EAAoBC,OAAO,oBAiB3BC,EAAmBC,EAA0BH,UAAiBE,sBAAAF"}
@@ -0,0 +1 @@
1
+ export{injection}from"./consumption/injection.js";export{useInjection}from"./consumption/use-injection.js";export{ContainerContext}from"./context/ioc-context.js";export{ContainerProviderController}from"./provision/container-provider-controller.js";export{ServicesProviderController}from"./provision/services-provider-controller.js";export{useContainerProvision}from"./provision/use-container-provision.js";//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{ContextProvider as t}from"@lit/context";import{createIocContainer as i}from"@wirestate/core";import{ContainerContext as n}from"../context/ioc-context.js";var o=function(){function o(o,e){var r=this;this.host=o,this.revision=1,this.host.addController(this),this.container=null!=e?e:i(),this.provider=new t(o,{context:n,initialValue:{container:this.container,revision:this.revision,nextRevision:function(){return r.nextRevision()}}})}return o.prototype.hostConnected=function(){},o.prototype.hostDisconnected=function(){},o.prototype.nextRevision=function(){var t=this;return this.revision+=1,this.provider.setValue({container:this.container,revision:this.revision,nextRevision:function(){return t.nextRevision()}}),this.revision},o}();export{o as ContainerProviderController};//# sourceMappingURL=container-provider-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-provider-controller.js","sources":["../../../../../../../../src/wirestate-lit/provision/container-provider-controller.ts"],"sourcesContent":[null],"names":["ContainerProviderController","host","container","_this","this","revision","addController","createIocContainer","provider","ContextProvider","context","ContainerContext","initialValue","nextRevision","prototype","hostConnected","hostDisconnected","setValue"],"mappings":"iKAUA,IAAAA,EAAA,WAME,SAAAA,EACmBC,EACjBC,GAFF,IAAAC,EAAAC,KACmBA,KAAAH,KAAAA,EALTG,KAAAC,SAAmB,EAQ3BD,KAAKH,KAAKK,cAAcF,MAExBA,KAAKF,UAAYA,QAAAA,EAAaK,IAS9BH,KAAKI,SAAW,IAAIC,EAAgBR,EAAM,CACxCS,QAASC,EACTC,aAAc,CACZV,UAAWE,KAAKF,UAChBG,SAAUD,KAAKC,SACfQ,aAAc,WAAM,OAAAV,EAAKU,cAAL,IAG1B,CA4BF,OA1BSb,EAAAc,UAAAC,cAAP,WAEA,EAEOf,EAAAc,UAAAE,iBAAP,WAEA,EAEOhB,EAAAc,UAAAD,aAAP,WAAA,IAAAV,EAAAC,KAgBE,OARAA,KAAKC,UAAY,EAEjBD,KAAKI,SAASS,SAAS,CACrBf,UAAWE,KAAKF,UAChBG,SAAUD,KAAKC,SACfQ,aAAc,WAAM,OAAAV,EAAKU,cAAL,IAGfT,KAAKC,QACd,EACFL,CAAA,CAzDA,UAyDCA"}
@@ -0,0 +1 @@
1
+ import{ContextConsumer as t}from"@lit/context";import{applySeeds as i,bindEntry as o,getEntryToken as e,unapplySeeds as n}from"@wirestate/core";import{ContainerContext as s}from"../context/ioc-context.js";var r=function(){function r(i,o){this.host=i,this.host.addController(this),this.entries=o.entries,this.activate=o.activate,this.seeds=o.seeds,this.into=o.into,this.consumer=new t(i,{context:s,subscribe:!0,callback:function(t){}})}return r.prototype.hostConnected=function(){var t=this.into?"function"==typeof this.into?this.into():this.into:this.consumer.value;if(!t){if(!1===this.consumer.provided)throw new Error("not provided");throw new Error("todo")}this.seeds&&i(t.container,this.seeds);for(var e=0,n=this.entries;e<n.length;e++){var s=n[e];o(t.container,s)}if(this.activate)for(var r=0,h=this.activate;r<h.length;r++){var c=h[r];t.container.get(c)}},r.prototype.hostDisconnected=function(){var t=this.into?"function"==typeof this.into?this.into():this.into:this.consumer.value;if(!t)throw new Error("todo");for(var i=0,o=this.entries;i<o.length;i++){var s=o[i],r=e(s);t.container.unbind(r)}this.seeds&&n(t.container,this.seeds)},r}();export{r as ServicesProviderController};//# sourceMappingURL=services-provider-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services-provider-controller.js","sources":["../../../../../../../../src/wirestate-lit/provision/services-provider-controller.ts"],"sourcesContent":[null],"names":["ServicesProviderController","host","options","this","addController","entries","activate","seeds","into","consumer","ContextConsumer","context","ContainerContext","subscribe","callback","it","prototype","hostConnected","value","Error","applySeeds","container","_i","_a","length","entry","bindEntry","_b","_c","eager","get","hostDisconnected","token","getEntryToken","unbind","unapplySeeds"],"mappings":"6MA2BA,IAAAA,EAAA,WAQE,SAAAA,EACmBC,EACjBC,GADiBC,KAAAF,KAAAA,EAQjBE,KAAKF,KAAKG,cAAcD,MAExBA,KAAKE,QAAUH,EAAQG,QACvBF,KAAKG,SAAWJ,EAAQI,SACxBH,KAAKI,MAAQL,EAAQK,MACrBJ,KAAKK,KAAON,EAAQM,KAEpBL,KAAKM,SAAW,IAAIC,EAAgBT,EAAM,CACxCU,QAASC,EACTC,WAAW,EACXC,SAAU,SAACC,GAAO,GAEtB,CAqEF,OAnESf,EAAAgB,UAAAC,cAAP,WACE,IAAMN,EAA6BR,KAAKK,KACf,mBAAdL,KAAKK,KACVL,KAAKK,OACLL,KAAKK,KACPL,KAAKM,SAASS,MAQlB,IAAKP,EAAS,CACZ,IAAkC,IAA9BR,KAAKM,SAAmB,SAC1B,MAAM,IAAIU,MAAM,gBAGlB,MAAM,IAAIA,MAAM,OAClB,CAKIhB,KAAKI,OACPa,EAAWT,EAAQU,UAAWlB,KAAKI,OAGrC,IAAoB,IAAAe,EAAA,EAAAC,EAAApB,KAAKE,QAALiB,EAAAC,EAAAC,OAAAF,IAAc,CAA7B,IAAMG,EAAKF,EAAAD,GACdI,EAAUf,EAAQU,UAAWI,EAC/B,CAEA,GAAItB,KAAKG,SACP,IAAoB,IAAAqB,EAAA,EAAAC,EAAAzB,KAAKG,SAALqB,EAAAC,EAAAJ,OAAAG,IAAe,CAA9B,IAAME,EAAKD,EAAAD,GACdhB,EAAQU,UAAUS,IAAID,EACxB,CAEJ,EAEO7B,EAAAgB,UAAAe,iBAAP,WACE,IAAMpB,EAA6BR,KAAKK,KACf,mBAAdL,KAAKK,KACVL,KAAKK,OACLL,KAAKK,KACPL,KAAKM,SAASS,MAQlB,IAAKP,EACH,MAAM,IAAIQ,MAAM,QAGlB,IAAoB,IAAAG,EAAA,EAAAC,EAAApB,KAAKE,QAALiB,EAAAC,EAAAC,OAAAF,IAAc,CAA7B,IAAMG,EAAKF,EAAAD,GACRU,EAA2BC,EAAcR,GAE/Cd,EAAQU,UAAUa,OAAOF,EAC3B,CAGI7B,KAAKI,OACP4B,EAAaxB,EAAQU,UAAWlB,KAAKI,MAEzC,EACFP,CAAA,CAlGA,UAkGCA"}
@@ -0,0 +1 @@
1
+ import{ContainerProviderController as r}from"./container-provider-controller.js";function n(n,o){var e=o.container;return new r(n,e)}export{n as useContainerProvision};//# sourceMappingURL=use-container-provision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-container-provision.js","sources":["../../../../../../../../src/wirestate-lit/provision/use-container-provision.ts"],"sourcesContent":[null],"names":["ContainerProviderController","useContainerProvision","host","_a","container"],"mappings":"sCASMA,MAAA,qCAAA,SAAUC,EACdC,EACAC,GAAE,IAAAC,EAASD,EAAAC,UAEX,OAAO,IAAIJ,EAA4BE,EAAME,EAC/C,QAAAH"}
package/index.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ import { ReactiveElement, ReactiveControllerHost, ReactiveController } from '@lit/reactive-element';
2
+ import { ServiceIdentifier, Container, Newable, InjectableDescriptor, SeedEntries } from '@wirestate/core';
3
+ import { ContextProvider, ContextConsumer } from '@lit/context';
4
+ import { Callable } from '@wirestate/core/types/general';
5
+
6
+ type Optional<T> = T | null;
7
+ type Maybe<T> = T | null | undefined;
8
+ type Interface<T> = {
9
+ [K in keyof T]: T[K];
10
+ };
11
+ type DecoratorReturn = void | any;
12
+ type FieldMustMatchProvidedType<Obj, Key extends PropertyKey, ProvidedType> = Obj extends Record<Key, infer ConsumingType> ? [ProvidedType] extends [ConsumingType] ? DecoratorReturn : {
13
+ message: "provided type not assignable to consuming field";
14
+ provided: ProvidedType;
15
+ consuming: ConsumingType;
16
+ } : Obj extends Partial<Record<Key, infer ConsumingType>> ? [ProvidedType] extends [ConsumingType | undefined] ? DecoratorReturn : {
17
+ message: "provided type not assignable to consuming field";
18
+ provided: ProvidedType;
19
+ consuming: ConsumingType | undefined;
20
+ } : DecoratorReturn;
21
+
22
+ type InjectionDecorator<ValueType> = {
23
+ <C extends Interface<Omit<ReactiveElement, "renderRoot">>, V extends ValueType>(value: ClassAccessorDecoratorTarget<C, V>, context: ClassAccessorDecoratorContext<C, V>): void;
24
+ <K extends PropertyKey, Proto extends Interface<Omit<ReactiveElement, "renderRoot">>>(protoOrDescriptor: Proto, name?: K): FieldMustMatchProvidedType<Proto, K, ValueType>;
25
+ };
26
+ interface InjectionOptions<T> {
27
+ injectionId: ServiceIdentifier<T>;
28
+ subscribe?: boolean;
29
+ }
30
+ declare function injection<T>({ injectionId, subscribe }: InjectionOptions<T>): InjectionDecorator<T>;
31
+
32
+ interface UseInjectionOptions<T> {
33
+ once?: boolean;
34
+ value?: Optional<T>;
35
+ injectionId: ServiceIdentifier<T>;
36
+ }
37
+ interface UseInjectionValue<T> {
38
+ injectionId: ServiceIdentifier<T>;
39
+ value: T;
40
+ }
41
+ declare function useInjection<T extends object, E extends ReactiveControllerHost & HTMLElement>(host: E, { once, injectionId, value }: UseInjectionOptions<T>): UseInjectionValue<T>;
42
+
43
+ interface IocContext {
44
+ /**
45
+ * Inversify container.
46
+ */
47
+ readonly container: Container;
48
+ /**
49
+ * Revision counter for cache invalidation.
50
+ */
51
+ readonly revision: number;
52
+ /**
53
+ * Forces a revision update.
54
+ */
55
+ readonly nextRevision: () => number;
56
+ }
57
+ declare const ContainerContext: {
58
+ __context__: IocContext;
59
+ };
60
+
61
+ declare class ContainerProviderController implements ReactiveController {
62
+ private readonly host;
63
+ protected provider: ContextProvider<typeof ContainerContext>;
64
+ protected revision: number;
65
+ container: Container;
66
+ constructor(host: ReactiveControllerHost & HTMLElement, container?: Maybe<Container>);
67
+ hostConnected(): void;
68
+ hostDisconnected(): void;
69
+ nextRevision(): number;
70
+ }
71
+
72
+ interface ServicesProviderControllerOptions {
73
+ entries: ReadonlyArray<Newable<object> | InjectableDescriptor>;
74
+ into?: IocContext | (() => IocContext);
75
+ activate?: ReadonlyArray<ServiceIdentifier>;
76
+ seeds?: SeedEntries;
77
+ }
78
+ declare class ServicesProviderController<E extends ReactiveControllerHost & HTMLElement> implements ReactiveController {
79
+ private readonly host;
80
+ readonly consumer: ContextConsumer<typeof ContainerContext, E>;
81
+ readonly entries: ReadonlyArray<Newable<object> | InjectableDescriptor>;
82
+ readonly activate: Maybe<ReadonlyArray<ServiceIdentifier>>;
83
+ readonly seeds: Maybe<SeedEntries>;
84
+ readonly into: Maybe<IocContext | Callable<IocContext>>;
85
+ constructor(host: E, options: ServicesProviderControllerOptions);
86
+ hostConnected(): void;
87
+ hostDisconnected(): void;
88
+ }
89
+
90
+ interface UseContainerProvisionOptions {
91
+ container?: Container;
92
+ }
93
+ declare function useContainerProvision<E extends ReactiveControllerHost & HTMLElement>(host: E, { container }: UseContainerProvisionOptions): UseContainerProvisionOptions;
94
+
95
+ export { ContainerContext, ContainerProviderController, ServicesProviderController, injection, useContainerProvision, useInjection };
96
+ export type { InjectionDecorator, UseInjectionOptions, UseInjectionValue };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@wirestate/lit",
3
+ "version": "0.6.0",
4
+ "description": "Lit elements integration for wirestate",
5
+ "sideEffects": false,
6
+ "author": "Syrotenko Igor",
7
+ "homepage": "https://github.com/neloreck/wirestate#readme",
8
+ "license": "MIT",
9
+ "main": "./cjs/development/index.js",
10
+ "module": "./esm/development/index.js",
11
+ "types": "./index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./index.d.ts",
15
+ "import": {
16
+ "production": "./esm/production/index.js",
17
+ "default": "./esm/development/index.js"
18
+ },
19
+ "require": {
20
+ "production": "./cjs/production/index.js",
21
+ "default": "./cjs/development/index.js"
22
+ }
23
+ }
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/neloreck/wirestate.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/neloreck/wirestate/issues"
31
+ },
32
+ "keywords": [
33
+ "class-based",
34
+ "declarative",
35
+ "management",
36
+ "manager",
37
+ "lit",
38
+ "lit-element",
39
+ "web-components",
40
+ "inversify",
41
+ "ioc",
42
+ "di",
43
+ "dependency-injection",
44
+ "state",
45
+ "store",
46
+ "typescript"
47
+ ],
48
+ "dependencies": {},
49
+ "peerDependencies": {
50
+ "@wirestate/core": ">=0.6.0",
51
+ "@lit/reactive-element": ">=2.0.0",
52
+ "@lit/context": ">=1.0.0",
53
+ "reflect-metadata": ">=0.2.0",
54
+ "tslib": ">=2.5.0"
55
+ },
56
+ "optionalDependencies": {}
57
+ }