@wirestate/react 0.6.3 → 0.7.0-experimental.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/README.md +109 -25
- package/cjs/development/index.js +462 -222
- package/cjs/development/index.js.map +1 -1
- package/cjs/development/lib.js +167 -45
- package/cjs/development/lib.js.map +1 -1
- package/cjs/development/test-utils.js +22 -11
- 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 +16 -3
- package/esm/development/commands/use-command-caller.js.map +1 -1
- package/esm/development/commands/use-command-handler.js +20 -4
- package/esm/development/commands/use-command-handler.js.map +1 -1
- package/esm/development/commands/use-optional-command-caller.js +20 -4
- package/esm/development/commands/use-optional-command-caller.js.map +1 -1
- package/esm/development/context/container-context.js +16 -0
- package/esm/development/context/container-context.js.map +1 -0
- package/esm/development/context/use-container.js +33 -0
- package/esm/development/context/use-container.js.map +1 -0
- package/esm/development/context/use-root-container.js +35 -0
- package/esm/development/context/use-root-container.js.map +1 -0
- package/esm/development/context/use-scope.js +31 -0
- package/esm/development/context/use-scope.js.map +1 -0
- package/esm/development/error/error-code.js +1 -3
- package/esm/development/error/error-code.js.map +1 -1
- package/esm/development/events/use-event-emitter.js +20 -4
- package/esm/development/events/use-event-emitter.js.map +1 -1
- package/esm/development/events/use-event.js +18 -4
- package/esm/development/events/use-event.js.map +1 -1
- package/esm/development/events/use-events-handler.js +18 -3
- package/esm/development/events/use-events-handler.js.map +1 -1
- package/esm/development/events/use-events.js +18 -4
- package/esm/development/events/use-events.js.map +1 -1
- package/esm/development/index.js +12 -10
- package/esm/development/index.js.map +1 -1
- package/esm/development/injection/use-injection.js +36 -0
- package/esm/development/injection/use-injection.js.map +1 -0
- package/esm/development/injection/use-optional-injection.js +40 -0
- package/esm/development/injection/use-optional-injection.js.map +1 -0
- package/esm/development/provision/container-activator.js +33 -0
- package/esm/development/provision/container-activator.js.map +1 -0
- package/esm/development/provision/container-provider.js +74 -0
- package/esm/development/provision/container-provider.js.map +1 -0
- package/esm/development/provision/sub-container-provider.js +69 -0
- package/esm/development/provision/sub-container-provider.js.map +1 -0
- package/esm/development/provision/use-container-provision-state.js +76 -0
- package/esm/development/provision/use-container-provision-state.js.map +1 -0
- package/esm/development/queries/use-optional-query-caller.js +16 -4
- package/esm/development/queries/use-optional-query-caller.js.map +1 -1
- package/esm/development/queries/use-optional-sync-query-caller.js +14 -3
- package/esm/development/queries/use-optional-sync-query-caller.js.map +1 -1
- package/esm/development/queries/use-query-caller.js +15 -3
- package/esm/development/queries/use-query-caller.js.map +1 -1
- package/esm/development/queries/use-query-handler.js +21 -5
- package/esm/development/queries/use-query-handler.js.map +1 -1
- package/esm/development/queries/use-sync-query-caller.js +15 -3
- package/esm/development/queries/use-sync-query-caller.js.map +1 -1
- package/esm/development/test-utils/with-container-provider.js +35 -0
- package/esm/development/test-utils/with-container-provider.js.map +1 -0
- package/esm/development/test-utils.js +1 -1
- package/esm/development/utils/shallow-equal-arrays.js +28 -0
- package/esm/development/utils/shallow-equal-arrays.js.map +1 -0
- 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 -0
- package/esm/production/context/container-context.js.map +1 -0
- package/esm/production/context/use-container.js +1 -0
- package/esm/production/context/use-container.js.map +1 -0
- package/esm/production/context/use-root-container.js +1 -0
- package/esm/production/context/use-root-container.js.map +1 -0
- package/esm/production/context/use-scope.js +1 -0
- package/esm/production/context/use-scope.js.map +1 -0
- package/esm/production/error/error-code.js +1 -1
- package/esm/production/error/error-code.js.map +1 -1
- package/esm/production/events/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/index.js +1 -1
- package/esm/production/injection/use-injection.js +1 -0
- package/esm/production/injection/use-injection.js.map +1 -0
- package/esm/production/injection/use-optional-injection.js +1 -0
- package/esm/production/injection/use-optional-injection.js.map +1 -0
- package/esm/production/provision/container-activator.js +1 -0
- package/esm/production/provision/container-activator.js.map +1 -0
- package/esm/production/provision/container-provider.js +1 -0
- package/esm/production/provision/container-provider.js.map +1 -0
- package/esm/production/provision/sub-container-provider.js +1 -0
- package/esm/production/provision/sub-container-provider.js.map +1 -0
- package/esm/production/provision/use-container-provision-state.js +1 -0
- package/esm/production/provision/use-container-provision-state.js.map +1 -0
- 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 -0
- package/esm/production/test-utils/with-container-provider.js.map +1 -0
- package/esm/production/test-utils.js +1 -1
- package/esm/production/utils/shallow-equal-arrays.js +1 -0
- package/esm/production/utils/shallow-equal-arrays.js.map +1 -0
- package/index.d.ts +554 -137
- package/package.json +2 -2
- package/test-utils.d.ts +19 -8
- package/esm/development/provision/create-injectables-provider.js +0 -101
- package/esm/development/provision/create-injectables-provider.js.map +0 -1
- package/esm/development/provision/ioc-context.js +0 -11
- package/esm/development/provision/ioc-context.js.map +0 -1
- package/esm/development/provision/ioc-provider.js +0 -50
- package/esm/development/provision/ioc-provider.js.map +0 -1
- package/esm/development/provision/use-container-revision.js +0 -13
- package/esm/development/provision/use-container-revision.js.map +0 -1
- package/esm/development/provision/use-container.js +0 -13
- package/esm/development/provision/use-container.js.map +0 -1
- package/esm/development/provision/use-injection.js +0 -22
- package/esm/development/provision/use-injection.js.map +0 -1
- package/esm/development/provision/use-ioc-context.js +0 -21
- package/esm/development/provision/use-ioc-context.js.map +0 -1
- package/esm/development/provision/use-optional-injection.js +0 -29
- package/esm/development/provision/use-optional-injection.js.map +0 -1
- package/esm/development/test-utils/with-ioc-provider.js +0 -24
- package/esm/development/test-utils/with-ioc-provider.js.map +0 -1
- package/esm/production/provision/create-injectables-provider.js +0 -1
- package/esm/production/provision/create-injectables-provider.js.map +0 -1
- package/esm/production/provision/ioc-context.js +0 -1
- package/esm/production/provision/ioc-context.js.map +0 -1
- package/esm/production/provision/ioc-provider.js +0 -1
- package/esm/production/provision/ioc-provider.js.map +0 -1
- package/esm/production/provision/use-container-revision.js +0 -1
- package/esm/production/provision/use-container-revision.js.map +0 -1
- package/esm/production/provision/use-container.js +0 -1
- package/esm/production/provision/use-container.js.map +0 -1
- package/esm/production/provision/use-injection.js +0 -1
- package/esm/production/provision/use-injection.js.map +0 -1
- package/esm/production/provision/use-ioc-context.js +0 -1
- package/esm/production/provision/use-ioc-context.js.map +0 -1
- package/esm/production/provision/use-optional-injection.js +0 -1
- package/esm/production/provision/use-optional-injection.js.map +0 -1
- package/esm/production/test-utils/with-ioc-provider.js +0 -1
- package/esm/production/test-utils/with-ioc-provider.js.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createContainer } from '@wirestate/core';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { ContainerReactContext } from '../context/container-context.js';
|
|
4
|
+
import { useContainer } from '../context/use-container.js';
|
|
5
|
+
import { shallowEqualArrays } from '../utils/shallow-equal-arrays.js';
|
|
6
|
+
import { useContainerProvisionState } from './use-container-provision-state.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Provides a child container derived from the nearest parent container.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* The provider owns the child container. It disposes the previous child before
|
|
13
|
+
* exposing a replacement, recreates on parent or `entries` changes, and revives
|
|
14
|
+
* a cleaned child after React development remount cleanup.
|
|
15
|
+
*
|
|
16
|
+
* @group Provision
|
|
17
|
+
*
|
|
18
|
+
* @param props - Provider props.
|
|
19
|
+
* @returns A React context provider for the child container.
|
|
20
|
+
*/
|
|
21
|
+
function SubContainerProvider(props) {
|
|
22
|
+
var _a;
|
|
23
|
+
var parent = useContainer();
|
|
24
|
+
var source = {
|
|
25
|
+
entries: props.entries,
|
|
26
|
+
parent: parent,
|
|
27
|
+
seeds: props.seeds
|
|
28
|
+
};
|
|
29
|
+
var state = useContainerProvisionState(source, {
|
|
30
|
+
create: createSubContainerState,
|
|
31
|
+
label: "SubContainerProvider",
|
|
32
|
+
reuse: canReuseSubContainerState
|
|
33
|
+
});
|
|
34
|
+
return createElement(ContainerReactContext.Provider, {
|
|
35
|
+
value: state.container
|
|
36
|
+
}, (_a = props.children) !== null && _a !== void 0 ? _a : null);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Selects the child-container state that should be exposed for this render.
|
|
40
|
+
*
|
|
41
|
+
* @param current - Previously exposed state, if any.
|
|
42
|
+
* @param source - Current provider source.
|
|
43
|
+
* @param disposed - Child containers already disposed by this provider.
|
|
44
|
+
* @returns Existing or replacement child-container state.
|
|
45
|
+
*/
|
|
46
|
+
function canReuseSubContainerState(current, source, disposed) {
|
|
47
|
+
return !disposed.has(current.container) && current.source.parent === source.parent && shallowEqualArrays(source.entries, current.source.entries);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a child container, applies seeds, and binds entries.
|
|
51
|
+
*
|
|
52
|
+
* @param source - Parent container plus child bindings.
|
|
53
|
+
* @returns Child-container state ready for context.
|
|
54
|
+
*/
|
|
55
|
+
function createSubContainerState(source) {
|
|
56
|
+
var container = createContainer({
|
|
57
|
+
entries: source.entries,
|
|
58
|
+
parent: source.parent,
|
|
59
|
+
seeds: source.seeds
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
source: source,
|
|
63
|
+
container: container,
|
|
64
|
+
owned: true
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { SubContainerProvider };
|
|
69
|
+
//# sourceMappingURL=sub-container-provider.js.map
|
|
@@ -0,0 +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","_a","children","current","disposed","has","shallowEqualArrays","createContainer","owned"],"mappings":";;;;;;;AA6DA;;;;;;;;;;;;AAYG;AACG,SAAUA,oBAAoBA,CAACC,KAAgC,EAAA;;AACnE,EAAA,IAAMC,MAAM,GAAcC,YAAY,EAAE;AAExC,EAAA,IAAMC,MAAM,GAAuB;IACjCC,OAAO,EAAEJ,KAAK,CAACI,OAAO;AACtBH,IAAAA,MAAM,EAAAA,MAAA;IACNI,KAAK,EAAEL,KAAK,CAACK;GACd;AAED,EAAA,IAAMC,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,EAAE,CAAAC,EAAA,GAAAlB,KAAK,CAACmB,QAAQ,MAAA,IAAA,IAAAD,EAAA,KAAA,MAAA,GAAAA,EAAA,GAAI,IAAI,CAAC;AAC1G;AAEA;;;;;;;AAOG;AACH,SAASN,yBAAyBA,CAChCQ,OAA0B,EAC1BjB,MAA0B,EAC1BkB,QAA4B,EAAA;AAE5B,EAAA,OACE,CAACA,QAAQ,CAACC,GAAG,CAACF,OAAO,CAACH,SAAS,CAAC,IAChCG,OAAO,CAACjB,MAAM,CAACF,MAAM,KAAKE,MAAM,CAACF,MAAM,IACvCsB,kBAAkB,CAACpB,MAAM,CAACC,OAAO,EAAEgB,OAAO,CAACjB,MAAM,CAACC,OAAO,CAAC;AAE9D;AAEA;;;;;AAKG;AACH,SAASK,uBAAuBA,CAACN,MAA0B,EAAA;EACzD,IAAMc,SAAS,GAAcO,eAAe,CAAC;IAC3CpB,OAAO,EAAED,MAAM,CAACC,OAAO;IACvBH,MAAM,EAAEE,MAAM,CAACF,MAAM;IACrBI,KAAK,EAAEF,MAAM,CAACE;AACf,GAAA,CAAC;EASF,OAAO;AACLF,IAAAA,MAAM,EAAAA,MAAA;AACNc,IAAAA,SAAS,EAAAA,SAAA;AACTQ,IAAAA,KAAK,EAAE;GACR;AACH;;;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reconciles provider-owned container state and revives it after development cleanup.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*
|
|
8
|
+
* @param source - Current provider source.
|
|
9
|
+
* @param options - Reconciliation rules.
|
|
10
|
+
* @returns Current provider state.
|
|
11
|
+
*/
|
|
12
|
+
function useContainerProvisionState(source, options) {
|
|
13
|
+
var create = options.create,
|
|
14
|
+
label = options.label,
|
|
15
|
+
reuse = options.reuse;
|
|
16
|
+
var stateRef = useRef(null);
|
|
17
|
+
var disposedRef = useRef(new WeakSet());
|
|
18
|
+
var _a = useState(0),
|
|
19
|
+
forceUpdate = _a[1];
|
|
20
|
+
var current = stateRef.current;
|
|
21
|
+
var state = current && reuse(current, source, disposedRef.current) ? current : replaceContainerState(current, source, create, disposedRef.current);
|
|
22
|
+
stateRef.current = state;
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
var active = state;
|
|
25
|
+
if (active.owned && disposedRef.current.has(active.container)) {
|
|
26
|
+
active = create(active.source);
|
|
27
|
+
stateRef.current = active;
|
|
28
|
+
forceUpdate(function (version) {
|
|
29
|
+
return version + 1;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return function () {
|
|
33
|
+
if (active.owned) {
|
|
34
|
+
disposeContainerOnce(active.container, disposedRef.current);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, [create, label, state]);
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Replaces current provider state with a newly created one.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*
|
|
45
|
+
* @param current - Currently exposed provider state.
|
|
46
|
+
* @param source - Source for next state.
|
|
47
|
+
* @param create - State factory.
|
|
48
|
+
* @param disposed - Set of containers already disposed by this provider.
|
|
49
|
+
* @param label - Debug prefix used for lifecycle logging.
|
|
50
|
+
* @returns Newly created provider state.
|
|
51
|
+
*/
|
|
52
|
+
function replaceContainerState(current, source, create, disposed, label) {
|
|
53
|
+
if (current === null || current === void 0 ? void 0 : current.owned) {
|
|
54
|
+
disposeContainerOnce(current.container, disposed);
|
|
55
|
+
}
|
|
56
|
+
return create(source);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Disposes a provider-owned container once.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*
|
|
63
|
+
* @param container - Container to dispose.
|
|
64
|
+
* @param disposed - Set of containers already disposed by this provider.
|
|
65
|
+
* @param label - Debug prefix used for lifecycle logging.
|
|
66
|
+
*/
|
|
67
|
+
function disposeContainerOnce(container, disposed, label) {
|
|
68
|
+
if (disposed.has(container)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
container.unbindAll();
|
|
72
|
+
disposed.add(container);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { useContainerProvisionState };
|
|
76
|
+
//# sourceMappingURL=use-container-provision-state.js.map
|
|
@@ -0,0 +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","_a","useState","forceUpdate","current","state","replaceContainerState","useEffect","active","owned","has","container","version","disposeContainerOnce","disposed","unbindAll","add"],"mappings":";;AAyCA;;;;;;;;AAQG;AACG,SAAUA,0BAA0BA,CACxCC,MAAe,EACfC,OAA2D,EAAA;AAEnD,EAAA,IAAAC,MAAM,GAAmBD,OAAO,CAAAC,MAA1B;IAAEC,KAAK,GAAYF,OAAO,CAAAE,KAAnB;IAAEC,KAAK,GAAKH,OAAO,MAAZ;AAC5B,EAAA,IAAMI,QAAQ,GAAGC,MAAM,CAAmB,IAAI,CAAC;EAC/C,IAAMC,WAAW,GAAGD,MAAM,CAAqB,IAAIE,OAAO,EAAa,CAAC;AAClE,EAAA,IAAAC,EAAA,GAAkBC,QAAQ,CAAS,CAAC,CAAC;AAAlCC,IAAAA,WAAW,QAAuB;AAE3C,EAAA,IAAMC,OAAO,GAAqBP,QAAQ,CAACO,OAAO;AAElD,EAAA,IAAMC,KAAK,GACTD,OAAO,IAAIR,KAAK,CAACQ,OAAO,EAAEZ,MAAM,EAAEO,WAAW,CAACK,OAAO,CAAC,GAClDA,OAAO,GACPE,qBAAqB,CAACF,OAAO,EAAEZ,MAAM,EAAEE,MAAM,EAAEK,WAAW,CAACK,OAAc,CAAC;EAEhFP,QAAQ,CAACO,OAAO,GAAGC,KAAK;AAExBE,EAAAA,SAAS,CAAC,YAAA;IACR,IAAIC,MAAM,GAAWH,KAAK;AAO1B,IAAA,IAAIG,MAAM,CAACC,KAAK,IAAIV,WAAW,CAACK,OAAO,CAACM,GAAG,CAACF,MAAM,CAACG,SAAS,CAAC,EAAE;AAM7DH,MAAAA,MAAM,GAAGd,MAAM,CAACc,MAAM,CAAChB,MAAM,CAAC;MAC9BK,QAAQ,CAACO,OAAO,GAAGI,MAAM;MAEzBL,WAAW,CAAC,UAACS,OAAe,EAAA;QAAK,OAAAA,OAAO,GAAG,CAAC;AAAX,MAAA,CAAW,CAAC;AAC/C,IAAA;AAEA,IAAA,OAAO,YAAA;MAML,IAAIJ,MAAM,CAACC,KAAK,EAAE;QAChBI,oBAAoB,CAACL,MAAM,CAACG,SAAS,EAAEZ,WAAW,CAACK,OAAc,CAAC;AACpE,MAAA;IACF,CAAC;EACH,CAAC,EAAE,CAACV,MAAM,EAAEC,KAAK,EAAEU,KAAK,CAAC,CAAC;AAE1B,EAAA,OAAOA,KAAK;AACd;AAEA;;;;;;;;;;;AAWG;AACH,SAASC,qBAAqBA,CAC5BF,OAAyB,EACzBZ,MAAe,EACfE,MAAmC,EACnCoB,QAA4B,EAC5BnB,KAAa,EAAA;AAEb,EAAA,IAAIS,OAAO,aAAPA,OAAO,KAAA,MAAA,GAAA,MAAA,GAAPA,OAAO,CAAEK,KAAK,EAAE;IAClBI,oBAAoB,CAACT,OAAO,CAACO,SAAS,EAAEG,QAAe,CAAC;AAC1D,EAAA;EAEA,OAAOpB,MAAM,CAACF,MAAM,CAAC;AACvB;AAEA;;;;;;;;AAQG;AACH,SAASqB,oBAAoBA,CAACF,SAAoB,EAAEG,QAA4B,EAAEnB,KAAa,EAAA;AAC7F,EAAA,IAAImB,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;;;;"}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { QueryBus } from '@wirestate/core';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { useContainer } from '../
|
|
3
|
+
import { useContainer } from '../context/use-container.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Returns a function to dispatch optional queries on the active container.
|
|
7
|
-
* Returns null instead of throwing when no handler is registered.
|
|
6
|
+
* Returns a stable function to dispatch optional queries on the active container.
|
|
8
7
|
*
|
|
9
|
-
* @
|
|
8
|
+
* @remarks
|
|
9
|
+
* The returned dispatcher is memoized using `useCallback` and stays stable
|
|
10
|
+
* for the lifetime of the container. It returns `null` instead of throwing
|
|
11
|
+
* if no handler is registered.
|
|
12
|
+
*
|
|
13
|
+
* @group Queries
|
|
14
|
+
*
|
|
15
|
+
* @returns An optional query dispatcher function.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const queryOptional: OptionalQueryCaller = useOptionalQueryCaller();
|
|
20
|
+
* const settings: UserSettings | null = await queryOptional(GET_USER_SETTINGS, { id: 1 });
|
|
21
|
+
* ```
|
|
10
22
|
*/
|
|
11
23
|
function useOptionalQueryCaller() {
|
|
12
24
|
var container = useContainer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-optional-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-optional-query-caller.ts"],"sourcesContent":[null],"names":["useOptionalQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","queryOptional"],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"use-optional-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-optional-query-caller.ts"],"sourcesContent":[null],"names":["useOptionalQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","queryOptional"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;AAiBG;SACaA,sBAAsBA,GAAA;AACpC,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,aAAa,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAC1D,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACW;AAC1B;;;;"}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { QueryBus } from '@wirestate/core';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { useContainer } from '../
|
|
3
|
+
import { useContainer } from '../context/use-container.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns a stable function to dispatch synchronous optional queries.
|
|
7
|
-
* Returns null instead of throwing when no handler is registered.
|
|
8
7
|
*
|
|
9
|
-
* @
|
|
8
|
+
* @remarks
|
|
9
|
+
* Similar to {@link useOptionalQueryCaller}, but returns the value directly
|
|
10
|
+
* (synchronously) from the handler. Returns `null` if no handler is registered.
|
|
11
|
+
*
|
|
12
|
+
* @group Queries
|
|
13
|
+
*
|
|
14
|
+
* @returns An optional synchronous query dispatcher function.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const querySyncOptional: OptionalSyncQueryCaller = useOptionalSyncQueryCaller();
|
|
19
|
+
* const value: ThemePreference | null = querySyncOptional(GET_THEME_PREFERENCE);
|
|
20
|
+
* ```
|
|
10
21
|
*/
|
|
11
22
|
function useOptionalSyncQueryCaller() {
|
|
12
23
|
var container = useContainer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-optional-sync-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-optional-sync-query-caller.ts"],"sourcesContent":[null],"names":["useOptionalSyncQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","queryOptional"],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"use-optional-sync-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-optional-sync-query-caller.ts"],"sourcesContent":[null],"names":["useOptionalSyncQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","queryOptional"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;AAgBG;SACaA,0BAA0BA,GAAA;AACxC,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,aAAa,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAC1D,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACe;AAC9B;;;;"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { QueryBus } from '@wirestate/core';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { useContainer } from '../
|
|
3
|
+
import { useContainer } from '../context/use-container.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Returns a function to dispatch queries on the active container.
|
|
6
|
+
* Returns a stable function to dispatch queries on the active container.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @remarks
|
|
9
|
+
* The returned dispatcher is memoized using `useCallback` and stays stable
|
|
10
|
+
* for the lifetime of the container. It uses {@link QueryBus.query} internally.
|
|
11
|
+
*
|
|
12
|
+
* @group Queries
|
|
13
|
+
*
|
|
14
|
+
* @returns A query dispatcher function.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const query: QueryCaller = useQueryCaller();
|
|
19
|
+
* const result: UserProfile = await query(GET_USER_PROFILE, { id: 123 });
|
|
20
|
+
* ```
|
|
9
21
|
*/
|
|
10
22
|
function useQueryCaller() {
|
|
11
23
|
var container = useContainer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-query-caller.ts"],"sourcesContent":[null],"names":["useQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","query"],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"use-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-query-caller.ts"],"sourcesContent":[null],"names":["useQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","query"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;AAgBG;SACaA,cAAcA,GAAA;AAC5B,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,KAAK,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAClD,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACG;AAClB;;;;"}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { QueryBus } from '@wirestate/core';
|
|
2
2
|
import { useRef, useEffect } from 'react';
|
|
3
|
-
import { useContainer } from '../
|
|
3
|
+
import { useContainer } from '../context/use-container.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Registers a query handler for the component's lifetime.
|
|
7
|
-
* The handler is stored in a ref to avoid manual memoization.
|
|
8
|
-
* Only one handler is active per type; newer registrations shadow older ones.
|
|
9
7
|
*
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* The handler is stored in a `useRef` and synced on every render to avoid stale
|
|
10
|
+
* closures. Only one handler is active per type; newer registrations shadow older ones.
|
|
11
|
+
* The handler is automatically unregistered when the component unmounts.
|
|
12
|
+
*
|
|
13
|
+
* @group Queries
|
|
14
|
+
*
|
|
15
|
+
* @template R - Result type of the query.
|
|
16
|
+
* @template D - Data/payload type of the query.
|
|
17
|
+
* @template T - Query identifier type.
|
|
18
|
+
*
|
|
19
|
+
* @param type - Query identifier (string or symbol).
|
|
20
|
+
* @param handler - Function that responds to the query.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* useQueryHandler("GET_DATA", (data) => {
|
|
25
|
+
* return { id: data.id, value: "Resolved" };
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
12
28
|
*/
|
|
13
29
|
function useQueryHandler(type, handler) {
|
|
14
30
|
var container = useContainer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-query-handler.js","sources":["../../../../../../../../src/wirestate-react/queries/use-query-handler.ts"],"sourcesContent":[null],"names":["useQueryHandler","type","handler","container","useContainer","handlerRef","useRef","useEffect","current","get","QueryBus","register","data"],"mappings":";;;;AAKA
|
|
1
|
+
{"version":3,"file":"use-query-handler.js","sources":["../../../../../../../../src/wirestate-react/queries/use-query-handler.ts"],"sourcesContent":[null],"names":["useQueryHandler","type","handler","container","useContainer","handlerRef","useRef","useEffect","current","get","QueryBus","register","data"],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,eAAeA,CAC7BC,IAAO,EACPC,OAA2B,EAAA;AAE3B,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAC3C,EAAA,IAAMC,UAAU,GAAGC,MAAM,CAAqBJ,OAAO,CAAC;AAEtDK,EAAAA,SAAS,CAAC,YAAA;IACRF,UAAU,CAACG,OAAO,GAAGN,OAAO;AAC9B,EAAA,CAAC,CAAC;AAEFK,EAAAA,SAAS,CAAC,YAAA;AACR,IAAA,OAAOJ,SAAS,CAACM,GAAG,CAACC,QAAQ,CAAC,CAACC,QAAQ,CAAOV,IAAI,EAAE,UAACW,IAAI,EAAA;AAAK,MAAA,OAAAP,UAAU,CAACG,OAAO,CAACI,IAAI,CAAC;AAAxB,IAAA,CAAwB,CAAC;AACzF,EAAA,CAAC,EAAE,CAACT,SAAS,EAAEF,IAAI,CAAC,CAAC;AACvB;;;;"}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { QueryBus } from '@wirestate/core';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { useContainer } from '../
|
|
3
|
+
import { useContainer } from '../context/use-container.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns a stable function to dispatch synchronous queries.
|
|
7
|
-
* Returns the value directly from the handler.
|
|
8
7
|
*
|
|
9
|
-
* @
|
|
8
|
+
* @remarks
|
|
9
|
+
* The returned dispatcher returns the value directly from the handler
|
|
10
|
+
* instead of a Promise (unless the handler itself returns a Promise).
|
|
11
|
+
* Memoized using `useCallback`.
|
|
12
|
+
*
|
|
13
|
+
* @group Queries
|
|
14
|
+
*
|
|
15
|
+
* @returns A synchronous query dispatcher function.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const querySync: SyncQueryCaller = useSyncQueryCaller();
|
|
20
|
+
* const config: ApplicationConfig = querySync("GET_APP_CONFIG");
|
|
21
|
+
* ```
|
|
10
22
|
*/
|
|
11
23
|
function useSyncQueryCaller() {
|
|
12
24
|
var container = useContainer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-sync-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-sync-query-caller.ts"],"sourcesContent":[null],"names":["useSyncQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","query"],"mappings":";;;;AASA
|
|
1
|
+
{"version":3,"file":"use-sync-query-caller.js","sources":["../../../../../../../../src/wirestate-react/queries/use-sync-query-caller.ts"],"sourcesContent":[null],"names":["useSyncQueryCaller","container","useContainer","useCallback","type","data","get","QueryBus","query"],"mappings":";;;;AASA;;;;;;;;;;;;;;;;;AAiBG;SACaA,kBAAkBA,GAAA;AAChC,EAAA,IAAMC,SAAS,GAAcC,YAAY,EAAE;AAE3C,EAAA,OAAOC,WAAW,CAChB,UAACC,IAAe,EAAEC,IAAc,EAAA;AAM9B;AACA,IAAA,OAAOJ,SAAS,CAACK,GAAG,CAACC,QAAQ,CAAC,CAACC,KAAK,CAACJ,IAAI,EAAEC,IAAI,CAAC;AAClD,EAAA,CAAC,EACD,CAACJ,SAAS,CAAC,CACO;AACtB;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mockContainer } from '@wirestate/core/test-utils';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { ContainerProvider } from '../provision/container-provider.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a React element tree with {@link ContainerProvider} for testing purposes.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This utility simplifies setting up the IoC context in unit tests. It automatically
|
|
10
|
+
* creates a {@link mockContainer} if none is provided.
|
|
11
|
+
*
|
|
12
|
+
* @group Test-utils
|
|
13
|
+
*
|
|
14
|
+
* @param children - The React tree to be wrapped.
|
|
15
|
+
* @param container - An optional Inversify container. Defaults to a new {@link mockContainer}.
|
|
16
|
+
* @returns A React element wrapped in an {@link ContainerProvider}.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const container: Container = mockContainer();
|
|
21
|
+
*
|
|
22
|
+
* render(withIocProvider(<MyComponent />, container));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function withContainerProvider(children, container) {
|
|
26
|
+
if (container === void 0) {
|
|
27
|
+
container = mockContainer();
|
|
28
|
+
}
|
|
29
|
+
return createElement(ContainerProvider, {
|
|
30
|
+
container: container
|
|
31
|
+
}, children);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { withContainerProvider };
|
|
35
|
+
//# sourceMappingURL=with-container-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-container-provider.js","sources":["../../../../../../../../src/wirestate-react/test-utils/with-container-provider.ts"],"sourcesContent":[null],"names":["withContainerProvider","children","container","mockContainer","createElement","ContainerProvider"],"mappings":";;;;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,qBAAqBA,CAACC,QAAmB,EAAEC,SAAsC,EAAA;AAAtC,EAAA,IAAAA,SAAA,KAAA,MAAA,EAAA;IAAAA,SAAA,GAAuBC,aAAa,EAAE;AAAA,EAAA;EAC/F,OAAOC,aAAa,CAACC,iBAAiB,EAAE;AAAEH,IAAAA,SAAS,EAAAA;GAAE,EAAED,QAAQ,CAAC;AAClE;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { withContainerProvider } from './test-utils/with-container-provider.js';
|
|
2
2
|
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether two arrays are shallowly equal.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Arrays are considered equal when they have the same length and each item
|
|
6
|
+
* at the same index is strictly equal (`===`).
|
|
7
|
+
*
|
|
8
|
+
* @group Utils
|
|
9
|
+
* @internal
|
|
10
|
+
*
|
|
11
|
+
* @param left - First array to compare.
|
|
12
|
+
* @param right - Second array to compare.
|
|
13
|
+
* @returns `true` when arrays are shallowly equal, otherwise `false`.
|
|
14
|
+
*/
|
|
15
|
+
function shallowEqualArrays(left, right) {
|
|
16
|
+
if (left.length !== right.length) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
for (var i = 0; i < right.length; i++) {
|
|
20
|
+
if (left[i] !== right[i]) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { shallowEqualArrays };
|
|
28
|
+
//# sourceMappingURL=shallow-equal-arrays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shallow-equal-arrays.js","sources":["../../../../../../../../src/wirestate-react/utils/shallow-equal-arrays.ts"],"sourcesContent":[null],"names":["shallowEqualArrays","left","right","length","i"],"mappings":"AAAA;;;;;;;;;;;;;AAaG;AACG,SAAUA,kBAAkBA,CAACC,IAA4B,EAAEC,KAA6B,EAAA;AAC5F,EAAA,IAAID,IAAI,CAACE,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;AAChC,IAAA,OAAO,KAAK;AACd,EAAA;AAEA,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,KAAK,CAACC,MAAM,EAAEC,CAAC,EAAE,EAAE;IACrC,IAAIH,IAAI,CAACG,CAAC,CAAC,KAAKF,KAAK,CAACE,CAAC,CAAC,EAAE;AACxB,MAAA,OAAO,KAAK;AACd,IAAA;AACF,EAAA;AAEA,EAAA,OAAO,IAAI;AACb;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CommandBus as r}from"@wirestate/core";import{useCallback as
|
|
1
|
+
import{CommandBus as r}from"@wirestate/core";import{useCallback as t}from"react";import{useContainer as o}from"../context/use-container.js";function e(){var e=o();return t((function(t,o){return e.get(r).command(t,o)}),[e])}export{e as useCommandCaller};//# sourceMappingURL=use-command-caller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-caller.ts"],"sourcesContent":[null],"names":["CommandBus","useCallback","useContainer","useCommandCaller","container","type","data","get","command"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-caller.ts"],"sourcesContent":[null],"names":["CommandBus","useCallback","useContainer","useCommandCaller","container","type","data","get","command"],"mappings":"qBASAA,MAAA,wCAAAC,MAAA,+BAAAC,MAAA,uCAkBgBC,IACd,IAAMC,EAAuBF,IAE7B,OAAOD,GACL,SAAgEI,EAASC,GAMvE,OAAOF,EAAUG,IAAIP,GAAYQ,QAAcH,EAAMC,EACvD,GACA,CAACF,GAEL,QAAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CommandBus as r}from"@wirestate/core";import{useRef as t,useEffect as
|
|
1
|
+
import{CommandBus as r}from"@wirestate/core";import{useRef as t,useEffect as e}from"react";import{useContainer as n}from"../context/use-container.js";function o(o,c){var i=n(),u=t(c);e((function(){u.current=c})),e((function(){return i.get(r).register(o,(function(r){return u.current(r)}))}),[i,o])}export{o as useCommandHandler};//# sourceMappingURL=use-command-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-command-handler.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-handler.ts"],"sourcesContent":[null],"names":["CommandBus","useRef","useEffect","useContainer","useCommandHandler","type","handler","container","handlerRef","current","get","register","data"],"mappings":"qBAKAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,
|
|
1
|
+
{"version":3,"file":"use-command-handler.js","sources":["../../../../../../../../src/wirestate-react/commands/use-command-handler.ts"],"sourcesContent":[null],"names":["CommandBus","useRef","useEffect","useContainer","useCommandHandler","type","handler","container","handlerRef","current","get","register","data"],"mappings":"qBAKAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,8BAwBM,SAAUC,EAA4CC,EAAmBC,GAC7E,IAAMC,EAAuBJ,IACvBK,EAAaP,EAA6BK,GAGhDJ,GAAU,WACRM,EAAWC,QAAUH,CACvB,IAEAJ,GAAU,WACR,OAAOK,EAAUG,IAAIV,GAAYW,SAAeN,GAAM,SAACO,GAAS,OAAAJ,EAAWC,QAAQG,EAAnB,GAClE,GAAG,CAACL,EAAWF,GACjB,QAAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CommandBus as r}from"@wirestate/core";import{useCallback as
|
|
1
|
+
import{CommandBus as r}from"@wirestate/core";import{useCallback as t}from"react";import{useContainer as o}from"../context/use-container.js";function e(){var e=o();return t((function(t,o){return e.get(r).commandOptional(t,o)}),[e])}export{e as useOptionalCommandCaller};//# sourceMappingURL=use-optional-command-caller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-optional-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-optional-command-caller.ts"],"sourcesContent":[null],"names":["CommandBus","useCallback","useContainer","useOptionalCommandCaller","container","type","data","get","commandOptional"],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-optional-command-caller.js","sources":["../../../../../../../../src/wirestate-react/commands/use-optional-command-caller.ts"],"sourcesContent":[null],"names":["CommandBus","useCallback","useContainer","useOptionalCommandCaller","container","type","data","get","commandOptional"],"mappings":"qBASAA,MAAA,wCAAAC,MAAA,+BAAAC,MAAA,uCAsBgBC,IACd,IAAMC,EAAuBF,IAE7B,OAAOD,GACL,SAAgEI,EAASC,GAMvE,OAAOF,EAAUG,IAAIP,GAAYQ,gBAAsBH,EAAMC,EAC/D,GACA,CAACF,GAEL,QAAAD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as r}from"react";var t=r(null);t.displayName="ContainerContext";export{t as ContainerReactContext};//# sourceMappingURL=container-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-context.js","sources":["../../../../../../../../src/wirestate-react/context/container-context.ts"],"sourcesContent":[null],"names":["createContext","ContainerReactContext","displayName"],"mappings":"wBAKAA,MAAA,YASaC,EAAsDD,EAAmC,MAEtGC,EAAsBC,YAAc,0BAAkBD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{WirestateError as r}from"@wirestate/core";import{useContext as o}from"react";import{ERROR_CODE_INVALID_CONTEXT as t}from"../error/error-code.js";import{ContainerReactContext as e}from"./container-context.js";function n(){var n=o(e);if(!n)throw new r(t,"Trying to access container context from React subtree not wrapped in <ContainerProvider>.");return n}export{n as useContainer};//# sourceMappingURL=use-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-container.js","sources":["../../../../../../../../src/wirestate-react/context/use-container.ts"],"sourcesContent":[null],"names":["WirestateError","useContext","ERROR_CODE_INVALID_CONTEXT","ContainerReactContext","useContainer","value"],"mappings":"yBAQAA,MAAA,uCAAAC,MAAA,6CAAAC,MAAA,yDAAAC,MAAA,kCAkBgBC,IACd,IAAMC,EAA6BJ,EAAWE,GAE9C,IAAKE,EACH,MAAM,IAAIL,EACRE,EACA,6FAIJ,OAAOG,CACT,QAAAD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as r}from"react";function t(t,n){return r((function(){return t()}),n)}export{t as useRootContainer};//# sourceMappingURL=use-root-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-root-container.js","sources":["../../../../../../../../src/wirestate-react/context/use-root-container.ts"],"sourcesContent":[null],"names":["useMemo","useRootContainer","factory","deps"],"mappings":"kBAMAA,MAAA,QAwBM,SAAUC,EAAiBC,EAA0BC,GACzD,OAAOH,GAAQ,WAKb,OAJ6BE,GAK/B,GAAGC,EACL,QAAAF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{WireScope as r}from"@wirestate/core";import{useMemo as t}from"react";import{useContainer as o}from"./use-container.js";function e(){var e=o();return t((function(){return e.get(r)}),[e])}export{e as useScope};//# sourceMappingURL=use-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-scope.js","sources":["../../../../../../../../src/wirestate-react/context/use-scope.ts"],"sourcesContent":[null],"names":["WireScope","useMemo","useContainer","useScope","container","get"],"mappings":"oBAQAA,MAAA,oCAAAC,MAAA,+BAAAC,MAAA,8BAkBgBC,IACd,IAAMC,EAAuBF,IAE7B,OAAOD,GAAQ,WAKb,OAAOG,EAAUC,IAAeL,EAClC,GAAG,CAACI,GACN,QAAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=
|
|
1
|
+
var r=1052;export{r as ERROR_CODE_INVALID_CONTEXT};//# sourceMappingURL=error-code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-code.js","sources":["../../../../../../../../src/wirestate-react/error/error-code.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"error-code.js","sources":["../../../../../../../../src/wirestate-react/error/error-code.ts"],"sourcesContent":[null],"names":["ERROR_CODE_INVALID_CONTEXT"],"mappings":"AACO,IAAMA,EAAqC,YAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventBus as
|
|
1
|
+
import{EventBus as t}from"@wirestate/core";import{useCallback as r}from"react";import{useContainer as o}from"../context/use-container.js";function e(){var e=o();return r((function(r,o,i){e.get(t).emit({type:r,payload:o,from:i})}),[e])}export{e as useEventEmitter};//# sourceMappingURL=use-event-emitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event-emitter.js","sources":["../../../../../../../../src/wirestate-react/events/use-event-emitter.ts"],"sourcesContent":[null],"names":["EventBus","useCallback","
|
|
1
|
+
{"version":3,"file":"use-event-emitter.js","sources":["../../../../../../../../src/wirestate-react/events/use-event-emitter.ts"],"sourcesContent":[null],"names":["EventBus","useCallback","useContainer","useEventEmitter","container","type","payload","from","get","emit"],"mappings":"mBASAA,MAAA,wCAAAC,MAAA,+BAAAC,MAAA,uCAqBgBC,IACd,IAAMC,EAAuBF,IAE7B,OAAOD,GACL,SAAyBI,EAASC,EAAaC,GAO7CH,EAAUI,IAAIR,GAAUS,KAAK,CAAEJ,KAAIA,EAAEC,QAAOA,EAAEC,KAAIA,GACpD,GACA,CAACH,GAEL,QAAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventBus as r}from"@wirestate/core";import{useRef as t,useEffect as n}from"react";import{useContainer as
|
|
1
|
+
import{EventBus as r}from"@wirestate/core";import{useRef as t,useEffect as n}from"react";import{useContainer as e}from"../context/use-container.js";function o(o,c){var u=t(o),i=t(c),f=e();n((function(){u.current=o,i.current=c})),n((function(){return f.get(r).subscribe((function(r){var t;r.type===u.current&&(null===(t=i.current)||void 0===t||t.call(i,r))}))}),[f,o])}export{o as useEvent};//# sourceMappingURL=use-event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-event.js","sources":["../../../../../../../../src/wirestate-react/events/use-event.ts"],"sourcesContent":[null],"names":["EventBus","useRef","useEffect","useContainer","useEvent","type","handler","typeRef","handlerRef","container","current","get","subscribe","event","_a","call"],"mappings":"mBAKAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,
|
|
1
|
+
{"version":3,"file":"use-event.js","sources":["../../../../../../../../src/wirestate-react/events/use-event.ts"],"sourcesContent":[null],"names":["EventBus","useRef","useEffect","useContainer","useEvent","type","handler","typeRef","handlerRef","container","current","get","subscribe","event","_a","call"],"mappings":"mBAKAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,8BAoBM,SAAUC,EAASC,EAAiBC,GACxC,IAAMC,EAAuCN,EAAOI,GAC9CG,EAA6CP,EAAOK,GACpDG,EAAuBN,IAE7BD,GAAU,WACRK,EAAQG,QAAUL,EAClBG,EAAWE,QAAUJ,CACvB,IAEAJ,GAAU,WACR,OAAOO,EAAUE,IAAIX,GAAUY,WAAU,SAACC,SACpCA,EAAMR,OAASE,EAAQG,UACP,QAAlBI,EAAAN,EAAWE,eAAO,IAAAI,GAAAA,EAAAC,KAAAP,EAAGK,GAEzB,GACF,GAAG,CAACJ,EAAWJ,GACjB,QAAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventBus as r}from"@wirestate/core";import{useRef as
|
|
1
|
+
import{EventBus as r}from"@wirestate/core";import{useRef as t,useEffect as n}from"react";import{useContainer as o}from"../context/use-container.js";function e(e){var c=t(e),i=o();n((function(){c.current=e})),n((function(){return i.get(r).subscribe((function(r){var t;null===(t=c.current)||void 0===t||t.call(c,r)}))}),[i])}export{e as useEventsHandler};//# sourceMappingURL=use-events-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-events-handler.js","sources":["../../../../../../../../src/wirestate-react/events/use-events-handler.ts"],"sourcesContent":[null],"names":["EventBus","useRef","useEffect","useContainer","useEventsHandler","handler","handlerRef","container","current","get","subscribe","event","_a","call"],"mappings":"mBAMAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,
|
|
1
|
+
{"version":3,"file":"use-events-handler.js","sources":["../../../../../../../../src/wirestate-react/events/use-events-handler.ts"],"sourcesContent":[null],"names":["EventBus","useRef","useEffect","useContainer","useEventsHandler","handler","handlerRef","container","current","get","subscribe","event","_a","call"],"mappings":"mBAMAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,8BAoBM,SAAUC,EAAiBC,GAC/B,IAAMC,EAAoDL,EAAOI,GAC3DE,EAAuBJ,IAE7BD,GAAU,WACRI,EAAWE,QAAUH,CACvB,IAEAH,GAAU,WACR,OAAOK,EAAUE,IAAIT,GAAUU,WAAU,SAACC,SACtB,QAAlBC,EAAAN,EAAWE,eAAO,IAAAI,GAAAA,EAAAC,KAAAP,EAAGK,EACvB,GACF,GAAG,CAACJ,GACN,QAAAH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventBus as r}from"@wirestate/core";import{useRef as t,useEffect as n}from"react";import{useContainer as e}from"../
|
|
1
|
+
import{EventBus as r}from"@wirestate/core";import{useRef as t,useEffect as n}from"react";import{useContainer as e}from"../context/use-container.js";function c(c,o){var u=t(c),i=t(o),f=e();n((function(){u.current=c,i.current=o})),n((function(){return f.get(r).subscribe((function(r){var t;u.current.includes(r.type)&&(null===(t=i.current)||void 0===t||t.call(i,r))}))}),[f])}export{c as useEvents};//# sourceMappingURL=use-events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-events.js","sources":["../../../../../../../../src/wirestate-react/events/use-events.ts"],"sourcesContent":[null],"names":["EventBus","useRef","useEffect","useContainer","useEvents","types","handler","typesRef","handlerRef","container","current","get","subscribe","event","includes","type","_a","call"],"mappings":"mBAKAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,
|
|
1
|
+
{"version":3,"file":"use-events.js","sources":["../../../../../../../../src/wirestate-react/events/use-events.ts"],"sourcesContent":[null],"names":["EventBus","useRef","useEffect","useContainer","useEvents","types","handler","typesRef","handlerRef","container","current","get","subscribe","event","includes","type","_a","call"],"mappings":"mBAKAA,MAAA,mCAAAC,eAAAC,MAAA,+BAAAC,MAAA,8BAoBM,SAAUC,EAAUC,EAAiCC,GACzD,IAAMC,EAAuDN,EAAOI,GAC9DG,EAA6CP,EAAOK,GACpDG,EAAuBN,IAE7BD,GAAU,WACRK,EAASG,QAAUL,EACnBG,EAAWE,QAAUJ,CACvB,IAEAJ,GAAU,WACR,OAAOO,EAAUE,IAAIX,GAAUY,WAAU,SAACC,SACpCN,EAASG,QAAQI,SAASD,EAAME,QAChB,QAAlBC,EAAAR,EAAWE,eAAO,IAAAM,GAAAA,EAAAC,KAAAT,EAAGK,GAEzB,GACF,GAAG,CAACJ,GACN,QAAAL"}
|
package/esm/production/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{useCommandCaller}from"./commands/use-command-caller.js";export{useOptionalCommandCaller}from"./commands/use-optional-command-caller.js";export{useCommandHandler}from"./commands/use-command-handler.js";export{
|
|
1
|
+
export{useCommandCaller}from"./commands/use-command-caller.js";export{useOptionalCommandCaller}from"./commands/use-optional-command-caller.js";export{useCommandHandler}from"./commands/use-command-handler.js";export{useContainer}from"./context/use-container.js";export{useRootContainer}from"./context/use-root-container.js";export{useScope}from"./context/use-scope.js";export{useEvent}from"./events/use-event.js";export{useEvents}from"./events/use-events.js";export{useEventsHandler}from"./events/use-events-handler.js";export{useEventEmitter}from"./events/use-event-emitter.js";export{useInjection}from"./injection/use-injection.js";export{useOptionalInjection}from"./injection/use-optional-injection.js";export{SubContainerProvider}from"./provision/sub-container-provider.js";export{ContainerActivator}from"./provision/container-activator.js";export{ContainerProvider}from"./provision/container-provider.js";export{useQueryCaller}from"./queries/use-query-caller.js";export{useOptionalQueryCaller}from"./queries/use-optional-query-caller.js";export{useQueryHandler}from"./queries/use-query-handler.js";export{useSyncQueryCaller}from"./queries/use-sync-query-caller.js";export{useOptionalSyncQueryCaller}from"./queries/use-optional-sync-query-caller.js";//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as r}from"react";import{useContainer as t}from"../context/use-container.js";function n(n){var o=t();return r((function(){return o.get(n)}),[o,n])}export{n as useInjection};//# sourceMappingURL=use-injection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-injection.js","sources":["../../../../../../../../src/wirestate-react/injection/use-injection.ts"],"sourcesContent":[null],"names":["useMemo","useContainer","useInjection","injectionId","container","get"],"mappings":"kBASAA,MAAA,+BAAAC,MAAA,8BAuBM,SAAUC,EAAgBC,GAC9B,IAAMC,EAAuBH,IAG7B,OAAOD,GAAQ,WAOb,OAAOI,EAAUC,IAAOF,EAC1B,GAAG,CAACC,EAAWD,GACjB,QAAAD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as r}from"react";import{useContainer as t}from"../context/use-container.js";function n(n,o){var e=t();return r((function(){return e.isBound(n)?e.get(n):o?o(e):null}),[e,n])}export{n as useOptionalInjection};//# sourceMappingURL=use-optional-injection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-optional-injection.js","sources":["../../../../../../../../src/wirestate-react/injection/use-optional-injection.ts"],"sourcesContent":[null],"names":["useMemo","useContainer","useOptionalInjection","injectionId","onFallback","container","isBound","get"],"mappings":"kBASAA,MAAA,+BAAAC,MAAA,8BAqBM,SAAUC,EACdC,EACAC,GAEA,IAAMC,EAAuBJ,IAG7B,OAAOD,GAAQ,WACb,OAAIK,EAAUC,QAAQH,GAQbE,EAAUE,IAAOJ,GACfC,EAQFA,EAAWC,GASX,IAEX,GAAG,CAACA,EAAWF,GACjB,QAAAD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as r}from"react";import{useContainer as t}from"../context/use-container.js";function n(n){var e,o=t(),c=r(null);if(c.current!==o){c.current=o;for(var i=0,l=n.activate;i<l.length;i++){var u=l[i];o.get(u)}}return null!==(e=n.children)&&void 0!==e?e:null}export{n as ContainerActivator};//# sourceMappingURL=container-activator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-activator.js","sources":["../../../../../../../../src/wirestate-react/provision/container-activator.ts"],"sourcesContent":[null],"names":["useRef","useContainer","ContainerActivator","props","container","activatedContainerRef","current","_i","_b","activate","length","entry","get","children","_a"],"mappings":"iBA0BAA,MAAA,+BAAAC,MAAA,8BAcM,SAAUC,EAAmBC,SAC3BC,EAAuBH,IACvBI,EAA+DL,EAAO,MAE5E,GAAIK,EAAsBC,UAAYF,EAAW,CAC/CC,EAAsBC,QAAUF,EAEhC,IAAoB,IAAAG,EAAA,EAAAC,EAAAL,EAAMM,SAANF,EAAAC,EAAAE,OAAAH,IAAgB,CAA/B,IAAMI,EAAKH,EAAAD,GACdH,EAAUQ,IAAID,EAChB,CACF,CAEA,OAAuC,UAA/BR,EAAMU,gBAAyB,IAAAC,EAAAA,EAAI,IAC7C,QAAAZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Container as n,createContainer as r}from"@wirestate/core";import{createElement as e}from"react";import{ContainerReactContext as o}from"../context/container-context.js";import{shallowEqualArrays as t}from"../utils/shallow-equal-arrays.js";import{useContainerProvisionState as i}from"./use-container-provision-state.js";function a(n){var r,t=i(n.container,{create:s,label:"ContainerProvider",reuse:c});return e(o.Provider,{value:t.container},null!==(r=n.children)&&void 0!==r?r:null)}function c(r,e,o){var i,a;return e instanceof n?!r.owned&&r.container===e:r.owned&&!o.has(r.container)&&t(null!==(i=e.entries)&&void 0!==i?i:[],r.source instanceof n?[]:null!==(a=r.source.entries)&&void 0!==a?a:[])}function s(e){return e instanceof n?{source:e,container:e,owned:!1}:{source:e,container:r(e),owned:!0}}export{a as ContainerProvider};//# sourceMappingURL=container-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-provider.js","sources":["../../../../../../../../src/wirestate-react/provision/container-provider.ts"],"sourcesContent":[null],"names":["Container","createContainer","createElement","ContainerReactContext","shallowEqualArrays","useContainerProvisionState","ContainerProvider","props","state","container","create","createContainerState","label","reuse","canReuseContainerState","Provider","value","_a","children","current","source","disposed","owned","has","entries","_b"],"mappings":"oBAkDAA,qBAAAC,MAAA,0CAAAC,MAAA,wCAAAC,MAAA,+DAAAC,MAAA,wEAAAC,MAAA,qCAiBM,SAAUC,EAAkBC,SAC1BC,EAAgCH,EAA2BE,EAAME,UAAW,CAChFC,OAAQC,EACRC,MAAO,oBACPC,MAAOC,IAGT,OAAOZ,EAAcC,EAAsBY,SAAU,CAAEC,MAAOR,EAAMC,WAA2B,QAAdQ,EAAAV,EAAMW,gBAAQ,IAAAD,EAAAA,EAAI,KACrG,CAUA,SAASH,EACPK,EACAC,EACAC,WAEA,OAAID,aAAkBpB,GACZmB,EAAQG,OAASH,EAAQV,YAAcW,EAI/CD,EAAQG,QACPD,EAASE,IAAIJ,EAAQV,YACtBL,EAAiC,QAAda,EAAAG,EAAOI,eAAO,IAAAP,EAAAA,EAAI,GAAIE,EAAQC,kBAAkBpB,EAAY,GAA4B,QAAtByB,EAAAN,EAAQC,OAAOI,eAAO,IAAAC,EAAAA,EAAI,GAEnH,CAQA,SAASd,EAAqBS,GAC5B,OAAIA,aAAkBpB,EAKb,CACLoB,OAAMA,EACNX,UAAWW,EACXE,OAAO,GASF,CACLF,OAAMA,EACNX,UAJ2BR,EAAgBmB,GAK3CE,OAAO,EAGb,QAAAhB"}
|