@wirestate/react 0.7.0-experimental.2 → 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/cjs/development/index.js +69 -79
- package/cjs/development/index.js.map +1 -1
- package/cjs/development/lib.js +24 -27
- package/cjs/development/lib.js.map +1 -1
- package/cjs/development/test-utils.js +2 -5
- package/cjs/development/test-utils.js.map +1 -1
- package/cjs/production/index.js +1 -1
- package/cjs/production/index.js.map +1 -1
- package/cjs/production/lib.js +1 -1
- package/cjs/production/lib.js.map +1 -1
- package/cjs/production/test-utils.js +1 -1
- package/cjs/production/test-utils.js.map +1 -1
- package/esm/development/commands/use-command-caller.js +2 -2
- package/esm/development/commands/use-command-caller.js.map +1 -1
- package/esm/development/commands/use-command-handler.js +5 -7
- package/esm/development/commands/use-command-handler.js.map +1 -1
- package/esm/development/commands/use-optional-command-caller.js +2 -2
- package/esm/development/commands/use-optional-command-caller.js.map +1 -1
- package/esm/development/context/container-context.js +1 -1
- package/esm/development/context/container-context.js.map +1 -1
- package/esm/development/context/use-container.js +1 -1
- package/esm/development/context/use-container.js.map +1 -1
- package/esm/development/context/use-root-container.js +2 -2
- package/esm/development/context/use-root-container.js.map +1 -1
- package/esm/development/context/use-scope.js +2 -2
- package/esm/development/context/use-scope.js.map +1 -1
- package/esm/development/error/error-code.js +1 -1
- package/esm/development/error/error-code.js.map +1 -1
- package/esm/development/events/use-event-emitter.js +5 -5
- package/esm/development/events/use-event-emitter.js.map +1 -1
- package/esm/development/events/use-event.js +7 -8
- package/esm/development/events/use-event.js.map +1 -1
- package/esm/development/events/use-events-handler.js +6 -7
- package/esm/development/events/use-events-handler.js.map +1 -1
- package/esm/development/events/use-events.js +7 -8
- package/esm/development/events/use-events.js.map +1 -1
- package/esm/development/injection/use-injection.js +2 -2
- package/esm/development/injection/use-injection.js.map +1 -1
- package/esm/development/injection/use-optional-injection.js +2 -2
- package/esm/development/injection/use-optional-injection.js.map +1 -1
- package/esm/development/provision/container-activator.js +4 -6
- package/esm/development/provision/container-activator.js.map +1 -1
- package/esm/development/provision/container-provider.js +7 -9
- package/esm/development/provision/container-provider.js.map +1 -1
- package/esm/development/provision/sub-container-provider.js +8 -9
- package/esm/development/provision/sub-container-provider.js.map +1 -1
- package/esm/development/provision/use-container-provision-state.js +15 -16
- package/esm/development/provision/use-container-provision-state.js.map +1 -1
- package/esm/development/queries/use-optional-query-caller.js +2 -2
- package/esm/development/queries/use-optional-query-caller.js.map +1 -1
- package/esm/development/queries/use-optional-sync-query-caller.js +2 -2
- package/esm/development/queries/use-optional-sync-query-caller.js.map +1 -1
- package/esm/development/queries/use-query-caller.js +2 -2
- package/esm/development/queries/use-query-caller.js.map +1 -1
- package/esm/development/queries/use-query-handler.js +5 -7
- package/esm/development/queries/use-query-handler.js.map +1 -1
- package/esm/development/queries/use-sync-query-caller.js +2 -2
- package/esm/development/queries/use-sync-query-caller.js.map +1 -1
- package/esm/development/test-utils/with-container-provider.js +2 -5
- package/esm/development/test-utils/with-container-provider.js.map +1 -1
- package/esm/development/utils/shallow-equal-arrays.js +1 -1
- package/esm/production/commands/use-command-caller.js +1 -1
- package/esm/production/commands/use-command-caller.js.map +1 -1
- package/esm/production/commands/use-command-handler.js +1 -1
- package/esm/production/commands/use-command-handler.js.map +1 -1
- package/esm/production/commands/use-optional-command-caller.js +1 -1
- package/esm/production/commands/use-optional-command-caller.js.map +1 -1
- package/esm/production/context/container-context.js +1 -1
- package/esm/production/context/container-context.js.map +1 -1
- package/esm/production/context/use-container.js +1 -1
- package/esm/production/context/use-container.js.map +1 -1
- package/esm/production/context/use-root-container.js +1 -1
- package/esm/production/context/use-root-container.js.map +1 -1
- package/esm/production/context/use-scope.js +1 -1
- package/esm/production/context/use-scope.js.map +1 -1
- package/esm/production/error/error-code.js +1 -1
- package/esm/production/error/error-code.js.map +1 -1
- package/esm/production/events/use-event-emitter.js +1 -1
- package/esm/production/events/use-event-emitter.js.map +1 -1
- package/esm/production/events/use-event.js +1 -1
- package/esm/production/events/use-event.js.map +1 -1
- package/esm/production/events/use-events-handler.js +1 -1
- package/esm/production/events/use-events-handler.js.map +1 -1
- package/esm/production/events/use-events.js +1 -1
- package/esm/production/events/use-events.js.map +1 -1
- package/esm/production/injection/use-injection.js +1 -1
- package/esm/production/injection/use-injection.js.map +1 -1
- package/esm/production/injection/use-optional-injection.js +1 -1
- package/esm/production/injection/use-optional-injection.js.map +1 -1
- package/esm/production/provision/container-activator.js +1 -1
- package/esm/production/provision/container-activator.js.map +1 -1
- package/esm/production/provision/container-provider.js +1 -1
- package/esm/production/provision/container-provider.js.map +1 -1
- package/esm/production/provision/sub-container-provider.js +1 -1
- package/esm/production/provision/sub-container-provider.js.map +1 -1
- package/esm/production/provision/use-container-provision-state.js +1 -1
- package/esm/production/provision/use-container-provision-state.js.map +1 -1
- package/esm/production/queries/use-optional-query-caller.js +1 -1
- package/esm/production/queries/use-optional-query-caller.js.map +1 -1
- package/esm/production/queries/use-optional-sync-query-caller.js +1 -1
- package/esm/production/queries/use-optional-sync-query-caller.js.map +1 -1
- package/esm/production/queries/use-query-caller.js +1 -1
- package/esm/production/queries/use-query-caller.js.map +1 -1
- package/esm/production/queries/use-query-handler.js +1 -1
- package/esm/production/queries/use-query-handler.js.map +1 -1
- package/esm/production/queries/use-sync-query-caller.js +1 -1
- package/esm/production/queries/use-sync-query-caller.js.map +1 -1
- package/esm/production/test-utils/with-container-provider.js +1 -1
- package/esm/production/test-utils/with-container-provider.js.map +1 -1
- package/esm/production/utils/shallow-equal-arrays.js +1 -1
- package/package.json +1 -1
package/cjs/production/lib.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@wirestate/core"),n=require("react")
|
|
1
|
+
"use strict";var e=require("@wirestate/core"),n=require("react");const r=n.createContext(null);function t(e,n){if(e.length!==n.length)return!1;for(let r=0;r<n.length;r++)if(e[r]!==n[r])return!1;return!0}function o(e,r){const{create:t,label:o,reuse:u}=r,i=n.useRef(null),a=n.useRef(new WeakSet),[,s]=n.useState(0),l=i.current,f=l&&u(l,e,a.current)?l:function(e,n,r,t,o){e?.owned&&c(e.container,t);return r(n)}(l,e,t,a.current);return i.current=f,n.useEffect((()=>{let e=f;return e.owned&&a.current.has(e.container)&&(e=t(e.source),i.current=e,s((e=>e+1))),()=>{e.owned&&c(e.container,a.current)}}),[t,o,f]),f}function c(e,n,r){n.has(e)||(e.unbindAll(),n.add(e))}function u(n,r,o){return r instanceof e.Container?!n.owned&&n.container===r:n.owned&&!o.has(n.container)&&t(r.entries??[],n.source instanceof e.Container?[]:n.source.entries??[])}function i(n){if(n instanceof e.Container)return{source:n,container:n,owned:!1};return{source:n,container:e.createContainer(n),owned:!0}}r.displayName="ContainerContext",exports.C=r,exports.a=function(e){const t=o(e.container,{create:i,label:"ContainerProvider",reuse:u});return n.createElement(r.Provider,{value:t.container},e.children??null)},exports.s=t,exports.u=o;//# sourceMappingURL=lib.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sources":["../../../../../../../src/wirestate-react/context/container-context.ts","../../../../../../../src/wirestate-react/utils/shallow-equal-arrays.ts","../../../../../../../src/wirestate-react/provision/use-container-provision-state.ts","../../../../../../../src/wirestate-react/provision/container-provider.ts"],"sourcesContent":[null,null,null,null],"names":["core","require","react","ContainerReactContext","createContext","shallowEqualArrays","left","right","length","i","useContainerProvisionState","source","options","create","label","reuse","stateRef","useRef","disposedRef","WeakSet","forceUpdate","useState","current","state","disposed","owned","disposeContainerOnce","container","replaceContainerState","useEffect","active","has","version","unbindAll","add","canReuseContainerState","Container","
|
|
1
|
+
{"version":3,"file":"lib.js","sources":["../../../../../../../src/wirestate-react/context/container-context.ts","../../../../../../../src/wirestate-react/utils/shallow-equal-arrays.ts","../../../../../../../src/wirestate-react/provision/use-container-provision-state.ts","../../../../../../../src/wirestate-react/provision/container-provider.ts"],"sourcesContent":[null,null,null,null],"names":["core","require","react","ContainerReactContext","createContext","shallowEqualArrays","left","right","length","i","useContainerProvisionState","source","options","create","label","reuse","stateRef","useRef","disposedRef","WeakSet","forceUpdate","useState","current","state","disposed","owned","disposeContainerOnce","container","replaceContainerState","useEffect","active","has","version","unbindAll","add","canReuseContainerState","Container","entries","createContainerState","createContainer","displayName","exports","C","a","props","createElement","Provider","value","children","s","u"],"mappings":"AAKA,aAAA,IAAAA,EAAAC,QAAA,mBAAAC,EAAAD,QAAA,eASaE,EAAsDC,EAAAA,cAAmC,MCAhG,SAAUC,EAAmBC,EAA8BC,GAC/D,GAAID,EAAKE,SAAWD,EAAMC,OACxB,OAAO,EAGT,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAMC,OAAQC,IAChC,GAAIH,EAAKG,KAAOF,EAAME,GACpB,OAAO,EAIX,OAAO,CACT,CCwBM,SAAUC,EACdC,EACAC,GAEA,MAAMC,OAAEA,EAAMC,MAAEA,EAAKC,MAAEA,GAAUH,EAC3BI,EAAWC,EAAAA,OAAyB,MACpCC,EAAcD,EAAAA,OAA2B,IAAIE,WAC1CC,GAAeC,EAAAA,SAAiB,GAEnCC,EAA4BN,EAASM,QAErCC,EACJD,GAAWP,EAAMO,EAASX,EAAQO,EAAYI,SAC1CA,EAoDR,SACEA,EACAX,EACAE,EACAW,EACAV,GAEIQ,GAASG,OACXC,EAAqBJ,EAAQK,UAAWH,GAG1C,OAAOX,EAAOF,EAChB,CA/DQiB,CAAsBN,EAASX,EAAQE,EAAQK,EAAYI,SAoCjE,OAlCAN,EAASM,QAAUC,EAEnBM,EAAAA,WAAU,KACR,IAAIC,EAAiBP,EAmBrB,OAZIO,EAAOL,OAASP,EAAYI,QAAQS,IAAID,EAAOH,aAMjDG,EAASjB,EAAOiB,EAAOnB,QACvBK,EAASM,QAAUQ,EAEnBV,GAAaY,GAAoBA,EAAU,KAGtC,KAMDF,EAAOL,OACTC,EAAqBI,EAAOH,UAAWT,EAAYI,QACrD,CACD,GACA,CAACT,EAAQC,EAAOS,IAEZA,CACT,CAqCA,SAASG,EAAqBC,EAAsBH,EAA8BV,GAC5EU,EAASO,IAAIJ,KAQjBA,EAAUM,YAEVT,EAASU,IAAIP,GACf,CCjEA,SAASQ,EACPb,EACAX,EACAa,GAEA,OAAIb,aAAkByB,EAAAA,WACZd,EAAQG,OAASH,EAAQK,YAAchB,EAI/CW,EAAQG,QACPD,EAASO,IAAIT,EAAQK,YACtBtB,EAAmBM,EAAO0B,SAAW,GAAIf,EAAQX,kBAAkByB,EAAAA,UAAY,GAAMd,EAAQX,OAAO0B,SAAW,GAEnH,CAQA,SAASC,EAAqB3B,GAC5B,GAAIA,aAAkByB,EAAAA,UAKpB,MAAO,CACLzB,SACAgB,UAAWhB,EACXc,OAAO,GAST,MAAO,CACLd,SACAgB,UAJ2BY,EAAAA,gBAAgB5B,GAK3Cc,OAAO,EAGb,CHnHAtB,EAAsBqC,YAAc,mBGmHpCC,QAAAC,EAAAvC,EAAAsC,QAAAE,EAhEM,SAA4BC,GAChC,MAAMrB,EAAgCb,EAA2BkC,EAAMjB,UAAW,CAChFd,OAAQyB,EACRxB,MAAO,oBACPC,MAAOoB,IAGT,OAAOU,EAAAA,cAAc1C,EAAsB2C,SAAU,CAAEC,MAAOxB,EAAMI,WAAaiB,EAAMI,UAAY,KACrG,EAwDAP,QAAAQ,EAAA5C,EAAAoC,QAAAS,EAAAxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@wirestate/core/test-utils"),r=require("react"),t=require("./lib.js");require("@wirestate/core"),exports.withContainerProvider=function(i,n
|
|
1
|
+
"use strict";var e=require("@wirestate/core/test-utils"),r=require("react"),t=require("./lib.js");require("@wirestate/core"),exports.withContainerProvider=function(i,n=e.mockContainer()){return r.createElement(t.a,{container:n},i)};//# sourceMappingURL=test-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.js","sources":["../../../../../../../src/wirestate-react/test-utils/with-container-provider.ts"],"sourcesContent":[null],"names":["testUtils","require","react","containerProvider","exports","withContainerProvider","children","container","mockContainer","createElement","ContainerProvider"],"mappings":"AAMA,aAAA,IAAAA,EAAAC,QAAA,8BAAAC,EAAAD,QAAA,SAAAE,EAAAF,QAAA,YAAAA,QAAA,mBAsBAG,QAAAC,
|
|
1
|
+
{"version":3,"file":"test-utils.js","sources":["../../../../../../../src/wirestate-react/test-utils/with-container-provider.ts"],"sourcesContent":[null],"names":["testUtils","require","react","containerProvider","exports","withContainerProvider","children","container","mockContainer","createElement","ContainerProvider"],"mappings":"AAMA,aAAA,IAAAA,EAAAC,QAAA,8BAAAC,EAAAD,QAAA,SAAAE,EAAAF,QAAA,YAAAA,QAAA,mBAsBAG,QAAAC,+BAFsCC,EAAqBC,EAAuBC,EAAAA,iBAChF,OAAOC,EAAAA,cAAcC,EAAAA,EAAmB,CAAEH,aAAaD,EACzD"}
|
|
@@ -21,8 +21,8 @@ import { useContainer } from '../context/use-container.js';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function useCommandCaller() {
|
|
24
|
-
|
|
25
|
-
return useCallback(
|
|
24
|
+
const container = useContainer();
|
|
25
|
+
return useCallback((type, data) => {
|
|
26
26
|
return container.get(CommandBus).command(type, data);
|
|
27
27
|
}, [container]);
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-caller.ts"],"sourcesContent":[null],"names":["useCommandCaller","container","useContainer","useCallback","type","data","get","CommandBus","command"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;AAiBG;SACaA,gBAAgBA,GAAA;AAC9B,EAAA,
|
|
1
|
+
{"version":3,"file":"use-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-caller.ts"],"sourcesContent":[null],"names":["useCommandCaller","container","useContainer","useCallback","type","data","get","CommandBus","command"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;AAiBG;SACaA,gBAAgBA,GAAA;AAC9B,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,CAAgEC,IAAO,EAAEC,IAAQ,KAA0B;AAMzG,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,UAAU,CAAC,CAACC,OAAO,CAAOJ,IAAI,EAAEC,IAAI,CAAC;AAC5D,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACZ;AACH;;;;"}
|
|
@@ -27,16 +27,14 @@ import { useContainer } from '../context/use-container.js';
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
function useCommandHandler(type, handler) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const container = useContainer();
|
|
31
|
+
const handlerRef = useRef(handler);
|
|
32
32
|
// Sync ref with the latest closure on every render.
|
|
33
|
-
useEffect(
|
|
33
|
+
useEffect(() => {
|
|
34
34
|
handlerRef.current = handler;
|
|
35
35
|
});
|
|
36
|
-
useEffect(
|
|
37
|
-
return container.get(CommandBus).register(type,
|
|
38
|
-
return handlerRef.current(data);
|
|
39
|
-
});
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
return container.get(CommandBus).register(type, data => handlerRef.current(data));
|
|
40
38
|
}, [container, type]);
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-command-handler.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-handler.ts"],"sourcesContent":[null],"names":["useCommandHandler","type","handler","container","useContainer","handlerRef","useRef","useEffect","current","get","CommandBus","register","data"],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,iBAAiBA,CAA2BC,IAAiB,EAAEC,OAA6B,EAAA;AAC1G,EAAA,
|
|
1
|
+
{"version":3,"file":"use-command-handler.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-handler.ts"],"sourcesContent":[null],"names":["useCommandHandler","type","handler","container","useContainer","handlerRef","useRef","useEffect","current","get","CommandBus","register","data"],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,iBAAiBA,CAA2BC,IAAiB,EAAEC,OAA6B,EAAA;AAC1G,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;AAC3C,EAAA,MAAMC,UAAU,GAAGC,MAAM,CAAuBJ,OAAO,CAAC;AAExD;AACAK,EAAAA,SAAS,CAAC,MAAK;IACbF,UAAU,CAACG,OAAO,GAAGN,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFK,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,OAAOJ,SAAS,CAACM,GAAG,CAACC,UAAU,CAAC,CAACC,QAAQ,CAAOV,IAAI,EAAGW,IAAI,IAAKP,UAAU,CAACG,OAAO,CAACI,IAAI,CAAC,CAAC;AAC3F,EAAA,CAAC,EAAE,CAACT,SAAS,EAAEF,IAAI,CAAC,CAAC;AACvB;;;;"}
|
|
@@ -25,8 +25,8 @@ import { useContainer } from '../context/use-container.js';
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
function useOptionalCommandCaller() {
|
|
28
|
-
|
|
29
|
-
return useCallback(
|
|
28
|
+
const container = useContainer();
|
|
29
|
+
return useCallback((type, data) => {
|
|
30
30
|
return container.get(CommandBus).commandOptional(type, data);
|
|
31
31
|
}, [container]);
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-optional-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-optional-command-caller.ts"],"sourcesContent":[null],"names":["useOptionalCommandCaller","container","useContainer","useCallback","type","data","get","CommandBus","commandOptional"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;AAqBG;SACaA,wBAAwBA,GAAA;AACtC,EAAA,
|
|
1
|
+
{"version":3,"file":"use-optional-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-optional-command-caller.ts"],"sourcesContent":[null],"names":["useOptionalCommandCaller","container","useContainer","useCallback","type","data","get","CommandBus","commandOptional"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;;AAqBG;SACaA,wBAAwBA,GAAA;AACtC,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,CAAgEC,IAAO,EAAEC,IAAQ,KAAiC;AAMhH,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,UAAU,CAAC,CAACC,eAAe,CAAOJ,IAAI,EAAEC,IAAI,CAAC;AACpE,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACZ;AACH;;;;"}
|
|
@@ -9,7 +9,7 @@ import { createContext } from 'react';
|
|
|
9
9
|
*
|
|
10
10
|
* @group Context
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const ContainerReactContext = createContext(null);
|
|
13
13
|
ContainerReactContext.displayName = "ContainerContext";
|
|
14
14
|
|
|
15
15
|
export { ContainerReactContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-context.js","sources":["../../../../../../../../src/wirestate-react/context/container-context.ts"],"sourcesContent":[null],"names":["ContainerReactContext","createContext","displayName"],"mappings":";;AAKA;;;;;;;;AAQG;
|
|
1
|
+
{"version":3,"file":"container-context.js","sources":["../../../../../../../../src/wirestate-react/context/container-context.ts"],"sourcesContent":[null],"names":["ContainerReactContext","createContext","displayName"],"mappings":";;AAKA;;;;;;;;AAQG;MACUA,qBAAqB,GAAiCC,aAAa,CAAsB,IAAI;AAE1GD,qBAAqB,CAACE,WAAW,GAAG,kBAAkB;;;;"}
|
|
@@ -22,7 +22,7 @@ import { ContainerReactContext } from './container-context.js';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
function useContainer() {
|
|
25
|
-
|
|
25
|
+
const value = useContext(ContainerReactContext);
|
|
26
26
|
if (!value) {
|
|
27
27
|
throw new WirestateError(ERROR_CODE_INVALID_CONTEXT, "Trying to access container context from React subtree not wrapped in <ContainerProvider>.");
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-container.js","sources":["../../../../../../../../src/wirestate-react/context/use-container.ts"],"sourcesContent":[null],"names":["useContainer","value","useContext","ContainerReactContext","WirestateError","ERROR_CODE_INVALID_CONTEXT"],"mappings":";;;;;AAQA;;;;;;;;;;;;;;;;;AAiBG;SACaA,YAAYA,GAAA;AAC1B,EAAA,
|
|
1
|
+
{"version":3,"file":"use-container.js","sources":["../../../../../../../../src/wirestate-react/context/use-container.ts"],"sourcesContent":[null],"names":["useContainer","value","useContext","ContainerReactContext","WirestateError","ERROR_CODE_INVALID_CONTEXT"],"mappings":";;;;;AAQA;;;;;;;;;;;;;;;;;AAiBG;SACaA,YAAYA,GAAA;AAC1B,EAAA,MAAMC,KAAK,GAAwBC,UAAU,CAACC,qBAAqB,CAAC;EAEpE,IAAI,CAACF,KAAK,EAAE;AACV,IAAA,MAAM,IAAIG,cAAc,CACtBC,0BAA0B,EAC1B,2FAA2F,CAC5F;AACH,EAAA;AAEA,EAAA,OAAOJ,KAAK;AACd;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-root-container.js","sources":["../../../../../../../../src/wirestate-react/context/use-root-container.ts"],"sourcesContent":[null],"names":["useRootContainer","factory","deps","useMemo","container"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,gBAAgBA,CAACC,OAAwB,EAAEC,IAAoB,EAAA;EAC7E,OAAOC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"use-root-container.js","sources":["../../../../../../../../src/wirestate-react/context/use-root-container.ts"],"sourcesContent":[null],"names":["useRootContainer","factory","deps","useMemo","container"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,gBAAgBA,CAACC,OAAwB,EAAEC,IAAoB,EAAA;EAC7E,OAAOC,OAAO,CAAC,MAAK;AAClB,IAAA,MAAMC,SAAS,GAAcH,OAAO,EAAE;AAItC,IAAA,OAAOG,SAAS;EAClB,CAAC,EAAEF,IAAI,CAAC;AACV;;;;"}
|
|
@@ -21,8 +21,8 @@ import { useContainer } from './use-container.js';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function useScope() {
|
|
24
|
-
|
|
25
|
-
return useMemo(
|
|
24
|
+
const container = useContainer();
|
|
25
|
+
return useMemo(() => {
|
|
26
26
|
return container.get(WireScope);
|
|
27
27
|
}, [container]);
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-scope.js","sources":["../../../../../../../../src/wirestate-react/context/use-scope.ts"],"sourcesContent":[null],"names":["useScope","container","useContainer","useMemo","get","WireScope"],"mappings":";;;;AAQA;;;;;;;;;;;;;;;;;AAiBG;SACaA,QAAQA,GAAA;AACtB,EAAA,
|
|
1
|
+
{"version":3,"file":"use-scope.js","sources":["../../../../../../../../src/wirestate-react/context/use-scope.ts"],"sourcesContent":[null],"names":["useScope","container","useContainer","useMemo","get","WireScope"],"mappings":";;;;AAQA;;;;;;;;;;;;;;;;;AAiBG;SACaA,QAAQA,GAAA;AACtB,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;EAE3C,OAAOC,OAAO,CAAC,MAAK;AAKlB,IAAA,OAAOF,SAAS,CAACG,GAAG,CAAYC,SAAS,CAAC;AAC5C,EAAA,CAAC,EAAE,CAACJ,SAAS,CAAC,CAAC;AACjB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-code.js","sources":["../../../../../../../../src/wirestate-react/error/error-code.ts"],"sourcesContent":[null],"names":["ERROR_CODE_INVALID_CONTEXT"],"mappings":"AACO,
|
|
1
|
+
{"version":3,"file":"error-code.js","sources":["../../../../../../../../src/wirestate-react/error/error-code.ts"],"sourcesContent":[null],"names":["ERROR_CODE_INVALID_CONTEXT"],"mappings":"AACO,MAAMA,0BAA0B,GAAW;;;;"}
|
|
@@ -24,12 +24,12 @@ import { useContainer } from '../context/use-container.js';
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
function useEventEmitter() {
|
|
27
|
-
|
|
28
|
-
return useCallback(
|
|
27
|
+
const container = useContainer();
|
|
28
|
+
return useCallback((type, payload, from) => {
|
|
29
29
|
container.get(EventBus).emit({
|
|
30
|
-
type
|
|
31
|
-
payload
|
|
32
|
-
from
|
|
30
|
+
type,
|
|
31
|
+
payload,
|
|
32
|
+
from
|
|
33
33
|
});
|
|
34
34
|
}, [container]);
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-emitter.js","sources":["../../../../../../../../src/wirestate-react/events/use-event-emitter.ts"],"sourcesContent":[null],"names":["useEventEmitter","container","useContainer","useCallback","type","payload","from","get","EventBus","emit"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;SACaA,eAAeA,GAAA;AAC7B,EAAA,
|
|
1
|
+
{"version":3,"file":"use-event-emitter.js","sources":["../../../../../../../../src/wirestate-react/events/use-event-emitter.ts"],"sourcesContent":[null],"names":["useEventEmitter","container","useContainer","useCallback","type","payload","from","get","EventBus","emit"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;SACaA,eAAeA,GAAA;AAC7B,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;EAE3C,OAAOC,WAAW,CAChB,CAAyBC,IAAO,EAAEC,OAAW,EAAEC,IAAc,KAAI;AAO/DL,IAAAA,SAAS,CAACM,GAAG,CAACC,QAAQ,CAAC,CAACC,IAAI,CAAC;MAAEL,IAAI;MAAEC,OAAO;AAAEC,MAAAA;AAAI,KAAE,CAAC;AACvD,EAAA,CAAC,EACD,CAACL,SAAS,CAAC,CACZ;AACH;;;;"}
|
|
@@ -23,18 +23,17 @@ import { useContainer } from '../context/use-container.js';
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
function useEvent(type, handler) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
useEffect(
|
|
26
|
+
const typeRef = useRef(type);
|
|
27
|
+
const handlerRef = useRef(handler);
|
|
28
|
+
const container = useContainer();
|
|
29
|
+
useEffect(() => {
|
|
30
30
|
typeRef.current = type;
|
|
31
31
|
handlerRef.current = handler;
|
|
32
32
|
});
|
|
33
|
-
useEffect(
|
|
34
|
-
return container.get(EventBus).subscribe(
|
|
35
|
-
var _a;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
return container.get(EventBus).subscribe(event => {
|
|
36
35
|
if (event.type === typeRef.current) {
|
|
37
|
-
|
|
36
|
+
handlerRef.current?.(event);
|
|
38
37
|
}
|
|
39
38
|
});
|
|
40
39
|
}, [container, type]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event.js","sources":["../../../../../../../../src/wirestate-react/events/use-event.ts"],"sourcesContent":[null],"names":["useEvent","type","handler","typeRef","useRef","handlerRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event"
|
|
1
|
+
{"version":3,"file":"use-event.js","sources":["../../../../../../../../src/wirestate-react/events/use-event.ts"],"sourcesContent":[null],"names":["useEvent","type","handler","typeRef","useRef","handlerRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event"],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,QAAQA,CAACC,IAAe,EAAEC,OAAqB,EAAA;AAC7D,EAAA,MAAMC,OAAO,GAAgCC,MAAM,CAACH,IAAI,CAAC;AACzD,EAAA,MAAMI,UAAU,GAAmCD,MAAM,CAACF,OAAO,CAAC;AAClE,EAAA,MAAMI,SAAS,GAAcC,YAAY,EAAE;AAE3CC,EAAAA,SAAS,CAAC,MAAK;IACbL,OAAO,CAACM,OAAO,GAAGR,IAAI;IACtBI,UAAU,CAACI,OAAO,GAAGP,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFM,EAAAA,SAAS,CAAC,MAAK;IACb,OAAOF,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,SAAS,CAAEC,KAAK,IAAI;AACjD,MAAA,IAAIA,KAAK,CAACZ,IAAI,KAAKE,OAAO,CAACM,OAAO,EAAE;AAClCJ,QAAAA,UAAU,CAACI,OAAO,GAAGI,KAAK,CAAC;AAC7B,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA,CAAC,EAAE,CAACP,SAAS,EAAEL,IAAI,CAAC,CAAC;AACvB;;;;"}
|
|
@@ -23,15 +23,14 @@ import { useContainer } from '../context/use-container.js';
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
function useEventsHandler(handler) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
useEffect(
|
|
26
|
+
const handlerRef = useRef(handler);
|
|
27
|
+
const container = useContainer();
|
|
28
|
+
useEffect(() => {
|
|
29
29
|
handlerRef.current = handler;
|
|
30
30
|
});
|
|
31
|
-
useEffect(
|
|
32
|
-
return container.get(EventBus).subscribe(
|
|
33
|
-
|
|
34
|
-
(_a = handlerRef.current) === null || _a === void 0 ? void 0 : _a.call(handlerRef, event);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
return container.get(EventBus).subscribe(event => {
|
|
33
|
+
handlerRef.current?.(event);
|
|
35
34
|
});
|
|
36
35
|
}, [container]);
|
|
37
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-events-handler.js","sources":["../../../../../../../../src/wirestate-react/events/use-events-handler.ts"],"sourcesContent":[null],"names":["useEventsHandler","handler","handlerRef","useRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event"
|
|
1
|
+
{"version":3,"file":"use-events-handler.js","sources":["../../../../../../../../src/wirestate-react/events/use-events-handler.ts"],"sourcesContent":[null],"names":["useEventsHandler","handler","handlerRef","useRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event"],"mappings":";;;;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,gBAAgBA,CAACC,OAAqB,EAAA;AACpD,EAAA,MAAMC,UAAU,GAA0CC,MAAM,CAACF,OAAO,CAAC;AACzE,EAAA,MAAMG,SAAS,GAAcC,YAAY,EAAE;AAE3CC,EAAAA,SAAS,CAAC,MAAK;IACbJ,UAAU,CAACK,OAAO,GAAGN,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFK,EAAAA,SAAS,CAAC,MAAK;IACb,OAAOF,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,SAAS,CAAEC,KAAK,IAAI;AACjDT,MAAAA,UAAU,CAACK,OAAO,GAAGI,KAAK,CAAC;AAC7B,IAAA,CAAC,CAAC;AACJ,EAAA,CAAC,EAAE,CAACP,SAAS,CAAC,CAAC;AACjB;;;;"}
|
|
@@ -23,18 +23,17 @@ import { useContainer } from '../context/use-container.js';
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
function useEvents(types, handler) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
useEffect(
|
|
26
|
+
const typesRef = useRef(types);
|
|
27
|
+
const handlerRef = useRef(handler);
|
|
28
|
+
const container = useContainer();
|
|
29
|
+
useEffect(() => {
|
|
30
30
|
typesRef.current = types;
|
|
31
31
|
handlerRef.current = handler;
|
|
32
32
|
});
|
|
33
|
-
useEffect(
|
|
34
|
-
return container.get(EventBus).subscribe(
|
|
35
|
-
var _a;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
return container.get(EventBus).subscribe(event => {
|
|
36
35
|
if (typesRef.current.includes(event.type)) {
|
|
37
|
-
|
|
36
|
+
handlerRef.current?.(event);
|
|
38
37
|
}
|
|
39
38
|
});
|
|
40
39
|
}, [container]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-events.js","sources":["../../../../../../../../src/wirestate-react/events/use-events.ts"],"sourcesContent":[null],"names":["useEvents","types","handler","typesRef","useRef","handlerRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event","includes","type"
|
|
1
|
+
{"version":3,"file":"use-events.js","sources":["../../../../../../../../src/wirestate-react/events/use-events.ts"],"sourcesContent":[null],"names":["useEvents","types","handler","typesRef","useRef","handlerRef","container","useContainer","useEffect","current","get","EventBus","subscribe","event","includes","type"],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,SAASA,CAACC,KAA+B,EAAEC,OAAqB,EAAA;AAC9E,EAAA,MAAMC,QAAQ,GAA+CC,MAAM,CAACH,KAAK,CAAC;AAC1E,EAAA,MAAMI,UAAU,GAAmCD,MAAM,CAACF,OAAO,CAAC;AAClE,EAAA,MAAMI,SAAS,GAAcC,YAAY,EAAE;AAE3CC,EAAAA,SAAS,CAAC,MAAK;IACbL,QAAQ,CAACM,OAAO,GAAGR,KAAK;IACxBI,UAAU,CAACI,OAAO,GAAGP,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFM,EAAAA,SAAS,CAAC,MAAK;IACb,OAAOF,SAAS,CAACI,GAAG,CAACC,QAAQ,CAAC,CAACC,SAAS,CAAEC,KAAK,IAAI;MACjD,IAAIV,QAAQ,CAACM,OAAO,CAACK,QAAQ,CAACD,KAAK,CAACE,IAAI,CAAC,EAAE;AACzCV,QAAAA,UAAU,CAACI,OAAO,GAAGI,KAAK,CAAC;AAC7B,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA,CAAC,EAAE,CAACP,SAAS,CAAC,CAAC;AACjB;;;;"}
|
|
@@ -25,9 +25,9 @@ import { useContainer } from '../context/use-container.js';
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
function useInjection(injectionId) {
|
|
28
|
-
|
|
28
|
+
const container = useContainer();
|
|
29
29
|
// Revision bump causes a container reset; force re-resolution to drop stale instances.
|
|
30
|
-
return useMemo(
|
|
30
|
+
return useMemo(() => {
|
|
31
31
|
return container.get(injectionId);
|
|
32
32
|
}, [container, injectionId]);
|
|
33
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-injection.js","sources":["../../../../../../../../src/wirestate-react/injection/use-injection.ts"],"sourcesContent":[null],"names":["useInjection","injectionId","container","useContainer","useMemo","get"],"mappings":";;;AASA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAUA,YAAYA,CAAIC,WAAiC,EAAA;AAC/D,EAAA,
|
|
1
|
+
{"version":3,"file":"use-injection.js","sources":["../../../../../../../../src/wirestate-react/injection/use-injection.ts"],"sourcesContent":[null],"names":["useInjection","injectionId","container","useContainer","useMemo","get"],"mappings":";;;AASA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAUA,YAAYA,CAAIC,WAAiC,EAAA;AAC/D,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C;EACA,OAAOC,OAAO,CAAC,MAAK;AAOlB,IAAA,OAAOF,SAAS,CAACG,GAAG,CAAIJ,WAAW,CAAC;AACtC,EAAA,CAAC,EAAE,CAACC,SAAS,EAAED,WAAW,CAAC,CAAC;AAC9B;;;;"}
|
|
@@ -23,9 +23,9 @@ import { useContainer } from '../context/use-container.js';
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
function useOptionalInjection(injectionId, onFallback) {
|
|
26
|
-
|
|
26
|
+
const container = useContainer();
|
|
27
27
|
// Revision bump forces a container reset; force re-resolution to drop stale instances.
|
|
28
|
-
return useMemo(
|
|
28
|
+
return useMemo(() => {
|
|
29
29
|
if (container.isBound(injectionId)) {
|
|
30
30
|
return container.get(injectionId);
|
|
31
31
|
} else if (onFallback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-optional-injection.js","sources":["../../../../../../../../src/wirestate-react/injection/use-optional-injection.ts"],"sourcesContent":[null],"names":["useOptionalInjection","injectionId","onFallback","container","useContainer","useMemo","isBound","get"],"mappings":";;;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAUA,oBAAoBA,CAClCC,WAAiC,EACjCC,UAAwC,EAAA;AAExC,EAAA,
|
|
1
|
+
{"version":3,"file":"use-optional-injection.js","sources":["../../../../../../../../src/wirestate-react/injection/use-optional-injection.ts"],"sourcesContent":[null],"names":["useOptionalInjection","injectionId","onFallback","container","useContainer","useMemo","isBound","get"],"mappings":";;;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAUA,oBAAoBA,CAClCC,WAAiC,EACjCC,UAAwC,EAAA;AAExC,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C;EACA,OAAOC,OAAO,CAAC,MAAK;AAClB,IAAA,IAAIF,SAAS,CAACG,OAAO,CAACL,WAAW,CAAC,EAAE;AAQlC,MAAA,OAAOE,SAAS,CAACI,GAAG,CAAIN,WAAW,CAAC;IACtC,CAAC,MAAM,IAAIC,UAAU,EAAE;MAQrB,OAAOA,UAAU,CAACC,SAAS,CAAC;AAC9B,IAAA,CAAC,MAAM;AAQL,MAAA,OAAO,IAAI;AACb,IAAA;AACF,EAAA,CAAC,EAAE,CAACA,SAAS,EAAEF,WAAW,CAAC,CAAC;AAC9B;;;;"}
|
|
@@ -16,17 +16,15 @@ import { useContainer } from '../context/use-container.js';
|
|
|
16
16
|
* @returns React children after activation side effect is applied.
|
|
17
17
|
*/
|
|
18
18
|
function ContainerActivator(props) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var activatedContainerRef = useRef(null);
|
|
19
|
+
const container = useContainer();
|
|
20
|
+
const activatedContainerRef = useRef(null);
|
|
22
21
|
if (activatedContainerRef.current !== container) {
|
|
23
22
|
activatedContainerRef.current = container;
|
|
24
|
-
for (
|
|
25
|
-
var entry = _b[_i];
|
|
23
|
+
for (const entry of props.activate) {
|
|
26
24
|
container.get(entry);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
return
|
|
27
|
+
return props.children ?? null;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
export { ContainerActivator };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-activator.js","sources":["../../../../../../../../src/wirestate-react/provision/container-activator.ts"],"sourcesContent":[null],"names":["ContainerActivator","props","container","useContainer","activatedContainerRef","useRef","current","
|
|
1
|
+
{"version":3,"file":"container-activator.js","sources":["../../../../../../../../src/wirestate-react/provision/container-activator.ts"],"sourcesContent":[null],"names":["ContainerActivator","props","container","useContainer","activatedContainerRef","useRef","current","entry","activate","get","children"],"mappings":";;;AA0BA;;;;;;;;;;;;;AAaG;AACG,SAAUA,kBAAkBA,CAACC,KAA8B,EAAA;AAC/D,EAAA,MAAMC,SAAS,GAAcC,YAAY,EAAE;AAC3C,EAAA,MAAMC,qBAAqB,GAA0CC,MAAM,CAAC,IAAI,CAAC;AAEjF,EAAA,IAAID,qBAAqB,CAACE,OAAO,KAAKJ,SAAS,EAAE;IAC/CE,qBAAqB,CAACE,OAAO,GAAGJ,SAAS;AAEzC,IAAA,KAAK,MAAMK,KAAK,IAAIN,KAAK,CAACO,QAAQ,EAAE;AAClCN,MAAAA,SAAS,CAACO,GAAG,CAACF,KAAK,CAAC;AACtB,IAAA;AACF,EAAA;AAEA,EAAA,OAAQN,KAAK,CAACS,QAAyB,IAAI,IAAI;AACjD;;;;"}
|
|
@@ -22,15 +22,14 @@ import { useContainerProvisionState } from './use-container-provision-state.js';
|
|
|
22
22
|
* @returns A React context provider for the active container.
|
|
23
23
|
*/
|
|
24
24
|
function ContainerProvider(props) {
|
|
25
|
-
|
|
26
|
-
var state = useContainerProvisionState(props.container, {
|
|
25
|
+
const state = useContainerProvisionState(props.container, {
|
|
27
26
|
create: createContainerState,
|
|
28
27
|
label: "ContainerProvider",
|
|
29
28
|
reuse: canReuseContainerState
|
|
30
29
|
});
|
|
31
30
|
return createElement(ContainerReactContext.Provider, {
|
|
32
31
|
value: state.container
|
|
33
|
-
},
|
|
32
|
+
}, props.children ?? null);
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
35
|
* Selects the provider state that should be exposed for the current source.
|
|
@@ -41,11 +40,10 @@ function ContainerProvider(props) {
|
|
|
41
40
|
* @returns `true` when current state can be reused.
|
|
42
41
|
*/
|
|
43
42
|
function canReuseContainerState(current, source, disposed) {
|
|
44
|
-
var _a, _b;
|
|
45
43
|
if (source instanceof Container) {
|
|
46
44
|
return !current.owned && current.container === source;
|
|
47
45
|
}
|
|
48
|
-
return current.owned && !disposed.has(current.container) && shallowEqualArrays(
|
|
46
|
+
return current.owned && !disposed.has(current.container) && shallowEqualArrays(source.entries ?? [], current.source instanceof Container ? [] : current.source.entries ?? []);
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
51
49
|
* Creates provider state for an external or managed container source.
|
|
@@ -56,15 +54,15 @@ function canReuseContainerState(current, source, disposed) {
|
|
|
56
54
|
function createContainerState(source) {
|
|
57
55
|
if (source instanceof Container) {
|
|
58
56
|
return {
|
|
59
|
-
source
|
|
57
|
+
source,
|
|
60
58
|
container: source,
|
|
61
59
|
owned: false
|
|
62
60
|
};
|
|
63
61
|
} else {
|
|
64
|
-
|
|
62
|
+
const container = createContainer(source);
|
|
65
63
|
return {
|
|
66
|
-
source
|
|
67
|
-
container
|
|
64
|
+
source,
|
|
65
|
+
container,
|
|
68
66
|
owned: true
|
|
69
67
|
};
|
|
70
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container-provider.js","sources":["../../../../../../../../src/wirestate-react/provision/container-provider.ts"],"sourcesContent":[null],"names":["ContainerProvider","props","state","useContainerProvisionState","container","create","createContainerState","label","reuse","canReuseContainerState","createElement","ContainerReactContext","Provider","value","
|
|
1
|
+
{"version":3,"file":"container-provider.js","sources":["../../../../../../../../src/wirestate-react/provision/container-provider.ts"],"sourcesContent":[null],"names":["ContainerProvider","props","state","useContainerProvisionState","container","create","createContainerState","label","reuse","canReuseContainerState","createElement","ContainerReactContext","Provider","value","children","current","source","disposed","Container","owned","has","shallowEqualArrays","entries","createContainer"],"mappings":";;;;;;AAkDA;;;;;;;;;;;;;;;;AAgBG;AACG,SAAUA,iBAAiBA,CAACC,KAA6B,EAAA;AAC7D,EAAA,MAAMC,KAAK,GAA2BC,0BAA0B,CAACF,KAAK,CAACG,SAAS,EAAE;AAChFC,IAAAA,MAAM,EAAEC,oBAAoB;AAC5BC,IAAAA,KAAK,EAAE,mBAAmB;AAC1BC,IAAAA,KAAK,EAAEC;AACR,GAAA,CAAC;AAEF,EAAA,OAAOC,aAAa,CAACC,qBAAqB,CAACC,QAAQ,EAAE;IAAEC,KAAK,EAAEX,KAAK,CAACE;AAAS,GAAE,EAAEH,KAAK,CAACa,QAAQ,IAAI,IAAI,CAAC;AAC1G;AAEA;;;;;;;AAOG;AACH,SAASL,sBAAsBA,CAC7BM,OAA+B,EAC/BC,MAA+B,EAC/BC,QAA4B,EAAA;EAE5B,IAAID,MAAM,YAAYE,SAAS,EAAE;IAC/B,OAAO,CAACH,OAAO,CAACI,KAAK,IAAIJ,OAAO,CAACX,SAAS,KAAKY,MAAM;AACvD,EAAA;AAEA,EAAA,OACED,OAAO,CAACI,KAAK,IACb,CAACF,QAAQ,CAACG,GAAG,CAACL,OAAO,CAACX,SAAS,CAAC,IAChCiB,kBAAkB,CAACL,MAAM,CAACM,OAAO,IAAI,EAAE,EAAEP,OAAO,CAACC,MAAM,YAAYE,SAAS,GAAG,EAAE,GAAIH,OAAO,CAACC,MAAM,CAACM,OAAO,IAAI,EAAG,CAAC;AAEvH;AAEA;;;;;AAKG;AACH,SAAShB,oBAAoBA,CAACU,MAA+B,EAAA;EAC3D,IAAIA,MAAM,YAAYE,SAAS,EAAE;IAK/B,OAAO;MACLF,MAAM;AACNZ,MAAAA,SAAS,EAAEY,MAAM;AACjBG,MAAAA,KAAK,EAAE;KACR;AACH,EAAA,CAAC,MAAM;AAKL,IAAA,MAAMf,SAAS,GAAcmB,eAAe,CAACP,MAAM,CAAC;IAEpD,OAAO;MACLA,MAAM;MACNZ,SAAS;AACTe,MAAAA,KAAK,EAAE;KACR;AACH,EAAA;AACF;;;;"}
|
|
@@ -19,21 +19,20 @@ import { useContainerProvisionState } from './use-container-provision-state.js';
|
|
|
19
19
|
* @returns A React context provider for the child container.
|
|
20
20
|
*/
|
|
21
21
|
function SubContainerProvider(props) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var source = {
|
|
22
|
+
const parent = useContainer();
|
|
23
|
+
const source = {
|
|
25
24
|
entries: props.entries,
|
|
26
|
-
parent
|
|
25
|
+
parent,
|
|
27
26
|
seeds: props.seeds
|
|
28
27
|
};
|
|
29
|
-
|
|
28
|
+
const state = useContainerProvisionState(source, {
|
|
30
29
|
create: createSubContainerState,
|
|
31
30
|
label: "SubContainerProvider",
|
|
32
31
|
reuse: canReuseSubContainerState
|
|
33
32
|
});
|
|
34
33
|
return createElement(ContainerReactContext.Provider, {
|
|
35
34
|
value: state.container
|
|
36
|
-
},
|
|
35
|
+
}, props.children ?? null);
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* Selects the child-container state that should be exposed for this render.
|
|
@@ -53,14 +52,14 @@ function canReuseSubContainerState(current, source, disposed) {
|
|
|
53
52
|
* @returns Child-container state ready for context.
|
|
54
53
|
*/
|
|
55
54
|
function createSubContainerState(source) {
|
|
56
|
-
|
|
55
|
+
const container = createContainer({
|
|
57
56
|
entries: source.entries,
|
|
58
57
|
parent: source.parent,
|
|
59
58
|
seeds: source.seeds
|
|
60
59
|
});
|
|
61
60
|
return {
|
|
62
|
-
source
|
|
63
|
-
container
|
|
61
|
+
source,
|
|
62
|
+
container,
|
|
64
63
|
owned: true
|
|
65
64
|
};
|
|
66
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-container-provider.js","sources":["../../../../../../../../src/wirestate-react/provision/sub-container-provider.ts"],"sourcesContent":[null],"names":["SubContainerProvider","props","parent","useContainer","source","entries","seeds","state","useContainerProvisionState","create","createSubContainerState","label","reuse","canReuseSubContainerState","createElement","ContainerReactContext","Provider","value","container","
|
|
1
|
+
{"version":3,"file":"sub-container-provider.js","sources":["../../../../../../../../src/wirestate-react/provision/sub-container-provider.ts"],"sourcesContent":[null],"names":["SubContainerProvider","props","parent","useContainer","source","entries","seeds","state","useContainerProvisionState","create","createSubContainerState","label","reuse","canReuseSubContainerState","createElement","ContainerReactContext","Provider","value","container","children","current","disposed","has","shallowEqualArrays","createContainer","owned"],"mappings":";;;;;;;AA6DA;;;;;;;;;;;;AAYG;AACG,SAAUA,oBAAoBA,CAACC,KAAgC,EAAA;AACnE,EAAA,MAAMC,MAAM,GAAcC,YAAY,EAAE;AAExC,EAAA,MAAMC,MAAM,GAAuB;IACjCC,OAAO,EAAEJ,KAAK,CAACI,OAAO;IACtBH,MAAM;IACNI,KAAK,EAAEL,KAAK,CAACK;GACd;AAED,EAAA,MAAMC,KAAK,GAAsBC,0BAA0B,CAACJ,MAAM,EAAE;AAClEK,IAAAA,MAAM,EAAEC,uBAAuB;AAC/BC,IAAAA,KAAK,EAAE,sBAAsB;AAC7BC,IAAAA,KAAK,EAAEC;AACR,GAAA,CAAC;AAEF,EAAA,OAAOC,aAAa,CAACC,qBAAqB,CAACC,QAAQ,EAAE;IAAEC,KAAK,EAAEV,KAAK,CAACW;AAAS,GAAE,EAAEjB,KAAK,CAACkB,QAAQ,IAAI,IAAI,CAAC;AAC1G;AAEA;;;;;;;AAOG;AACH,SAASN,yBAAyBA,CAChCO,OAA0B,EAC1BhB,MAA0B,EAC1BiB,QAA4B,EAAA;AAE5B,EAAA,OACE,CAACA,QAAQ,CAACC,GAAG,CAACF,OAAO,CAACF,SAAS,CAAC,IAChCE,OAAO,CAAChB,MAAM,CAACF,MAAM,KAAKE,MAAM,CAACF,MAAM,IACvCqB,kBAAkB,CAACnB,MAAM,CAACC,OAAO,EAAEe,OAAO,CAAChB,MAAM,CAACC,OAAO,CAAC;AAE9D;AAEA;;;;;AAKG;AACH,SAASK,uBAAuBA,CAACN,MAA0B,EAAA;EACzD,MAAMc,SAAS,GAAcM,eAAe,CAAC;IAC3CnB,OAAO,EAAED,MAAM,CAACC,OAAO;IACvBH,MAAM,EAAEE,MAAM,CAACF,MAAM;IACrBI,KAAK,EAAEF,MAAM,CAACE;AACf,GAAA,CAAC;EASF,OAAO;IACLF,MAAM;IACNc,SAAS;AACTO,IAAAA,KAAK,EAAE;GACR;AACH;;;;"}
|
|
@@ -10,26 +10,25 @@ import { useRef, useState, useEffect } from 'react';
|
|
|
10
10
|
* @returns Current provider state.
|
|
11
11
|
*/
|
|
12
12
|
function useContainerProvisionState(source, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const {
|
|
14
|
+
create,
|
|
15
|
+
label,
|
|
16
|
+
reuse
|
|
17
|
+
} = options;
|
|
18
|
+
const stateRef = useRef(null);
|
|
19
|
+
const disposedRef = useRef(new WeakSet());
|
|
20
|
+
const [, forceUpdate] = useState(0);
|
|
21
|
+
const current = stateRef.current;
|
|
22
|
+
const state = current && reuse(current, source, disposedRef.current) ? current : replaceContainerState(current, source, create, disposedRef.current);
|
|
22
23
|
stateRef.current = state;
|
|
23
|
-
useEffect(
|
|
24
|
-
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
let active = state;
|
|
25
26
|
if (active.owned && disposedRef.current.has(active.container)) {
|
|
26
27
|
active = create(active.source);
|
|
27
28
|
stateRef.current = active;
|
|
28
|
-
forceUpdate(
|
|
29
|
-
return version + 1;
|
|
30
|
-
});
|
|
29
|
+
forceUpdate(version => version + 1);
|
|
31
30
|
}
|
|
32
|
-
return
|
|
31
|
+
return () => {
|
|
33
32
|
if (active.owned) {
|
|
34
33
|
disposeContainerOnce(active.container, disposedRef.current);
|
|
35
34
|
}
|
|
@@ -50,7 +49,7 @@ function useContainerProvisionState(source, options) {
|
|
|
50
49
|
* @returns Newly created provider state.
|
|
51
50
|
*/
|
|
52
51
|
function replaceContainerState(current, source, create, disposed, label) {
|
|
53
|
-
if (current
|
|
52
|
+
if (current?.owned) {
|
|
54
53
|
disposeContainerOnce(current.container, disposed);
|
|
55
54
|
}
|
|
56
55
|
return create(source);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-container-provision-state.js","sources":["../../../../../../../../src/wirestate-react/provision/use-container-provision-state.ts"],"sourcesContent":[null],"names":["useContainerProvisionState","source","options","create","label","reuse","stateRef","useRef","disposedRef","WeakSet","
|
|
1
|
+
{"version":3,"file":"use-container-provision-state.js","sources":["../../../../../../../../src/wirestate-react/provision/use-container-provision-state.ts"],"sourcesContent":[null],"names":["useContainerProvisionState","source","options","create","label","reuse","stateRef","useRef","disposedRef","WeakSet","forceUpdate","useState","current","state","replaceContainerState","useEffect","active","owned","has","container","version","disposeContainerOnce","disposed","unbindAll","add"],"mappings":";;AAyCA;;;;;;;;AAQG;AACG,SAAUA,0BAA0BA,CACxCC,MAAe,EACfC,OAA2D,EAAA;EAE3D,MAAM;IAAEC,MAAM;IAAEC,KAAK;AAAEC,IAAAA;AAAK,GAAE,GAAGH,OAAO;AACxC,EAAA,MAAMI,QAAQ,GAAGC,MAAM,CAAmB,IAAI,CAAC;EAC/C,MAAMC,WAAW,GAAGD,MAAM,CAAqB,IAAIE,OAAO,EAAa,CAAC;AACxE,EAAA,MAAM,GAAGC,WAAW,CAAC,GAAGC,QAAQ,CAAS,CAAC,CAAC;AAE3C,EAAA,MAAMC,OAAO,GAAqBN,QAAQ,CAACM,OAAO;AAElD,EAAA,MAAMC,KAAK,GACTD,OAAO,IAAIP,KAAK,CAACO,OAAO,EAAEX,MAAM,EAAEO,WAAW,CAACI,OAAO,CAAC,GAClDA,OAAO,GACPE,qBAAqB,CAACF,OAAO,EAAEX,MAAM,EAAEE,MAAM,EAAEK,WAAW,CAACI,OAAc,CAAC;EAEhFN,QAAQ,CAACM,OAAO,GAAGC,KAAK;AAExBE,EAAAA,SAAS,CAAC,MAAK;IACb,IAAIC,MAAM,GAAWH,KAAK;AAO1B,IAAA,IAAIG,MAAM,CAACC,KAAK,IAAIT,WAAW,CAACI,OAAO,CAACM,GAAG,CAACF,MAAM,CAACG,SAAS,CAAC,EAAE;AAM7DH,MAAAA,MAAM,GAAGb,MAAM,CAACa,MAAM,CAACf,MAAM,CAAC;MAC9BK,QAAQ,CAACM,OAAO,GAAGI,MAAM;AAEzBN,MAAAA,WAAW,CAAEU,OAAe,IAAKA,OAAO,GAAG,CAAC,CAAC;AAC/C,IAAA;AAEA,IAAA,OAAO,MAAK;MAMV,IAAIJ,MAAM,CAACC,KAAK,EAAE;QAChBI,oBAAoB,CAACL,MAAM,CAACG,SAAS,EAAEX,WAAW,CAACI,OAAc,CAAC;AACpE,MAAA;IACF,CAAC;EACH,CAAC,EAAE,CAACT,MAAM,EAAEC,KAAK,EAAES,KAAK,CAAC,CAAC;AAE1B,EAAA,OAAOA,KAAK;AACd;AAEA;;;;;;;;;;;AAWG;AACH,SAASC,qBAAqBA,CAC5BF,OAAyB,EACzBX,MAAe,EACfE,MAAmC,EACnCmB,QAA4B,EAC5BlB,KAAa,EAAA;EAEb,IAAIQ,OAAO,EAAEK,KAAK,EAAE;IAClBI,oBAAoB,CAACT,OAAO,CAACO,SAAS,EAAEG,QAAe,CAAC;AAC1D,EAAA;EAEA,OAAOnB,MAAM,CAACF,MAAM,CAAC;AACvB;AAEA;;;;;;;;AAQG;AACH,SAASoB,oBAAoBA,CAACF,SAAoB,EAAEG,QAA4B,EAAElB,KAAa,EAAA;AAC7F,EAAA,IAAIkB,QAAQ,CAACJ,GAAG,CAACC,SAAS,CAAC,EAAE;AAC3B,IAAA;AACF,EAAA;EAMAA,SAAS,CAACI,SAAS,EAAE;AAErBD,EAAAA,QAAQ,CAACE,GAAG,CAACL,SAAS,CAAC;AACzB;;;;"}
|
|
@@ -21,8 +21,8 @@ import { useContainer } from '../context/use-container.js';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function useOptionalQueryCaller() {
|
|
24
|
-
|
|
25
|
-
return useCallback(
|
|
24
|
+
const container = useContainer();
|
|
25
|
+
return useCallback((type, data) => {
|
|
26
26
|
return container.get(QueryBus).queryOptional(type, data);
|
|
27
27
|
}, [container]);
|
|
28
28
|
}
|