@logixjs/react 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +1 -1
- package/dist/Hooks.cjs +190 -256
- package/dist/Hooks.d.cts +6 -6
- package/dist/Hooks.d.ts +6 -6
- package/dist/Hooks.js +2 -2
- package/dist/{ModuleRef-wZSQ3Wwo.d.cts → ModuleRef-gZmL6Zvb.d.cts} +8 -3
- package/dist/{ModuleRef-wZSQ3Wwo.d.ts → ModuleRef-gZmL6Zvb.d.ts} +8 -3
- package/dist/ModuleScope.cjs +241 -294
- package/dist/ModuleScope.d.cts +4 -4
- package/dist/ModuleScope.d.ts +4 -4
- package/dist/ModuleScope.js +3 -3
- package/dist/ReactPlatform.cjs +200 -250
- package/dist/ReactPlatform.d.cts +2 -2
- package/dist/ReactPlatform.d.ts +2 -2
- package/dist/ReactPlatform.js +4 -4
- package/dist/RuntimeProvider.cjs +23 -7
- package/dist/RuntimeProvider.js +1 -1
- package/dist/{chunk-JXAJTWSZ.js → chunk-2M6MDNVT.js} +23 -7
- package/dist/{chunk-UFFCJGSZ.js → chunk-G2LX7WWQ.js} +161 -225
- package/dist/{chunk-4G7H66OY.js → chunk-JC3R6GII.js} +3 -3
- package/dist/{chunk-G5MRIFKK.js → chunk-STTE4SOJ.js} +3 -6
- package/dist/{chunk-PYWHL7TA.js → chunk-WOTNVLCD.js} +1 -1
- package/dist/index.cjs +231 -284
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/{useDispatch-BnzYVkRE.d.ts → useDispatch-CiDimIYZ.d.ts} +13 -15
- package/dist/{useDispatch-CnO5-66H.d.cts → useDispatch-DiwQQAfC.d.cts} +13 -15
- package/package.json +6 -3
package/dist/Hooks.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Layer, ManagedRuntime, Effect } from 'effect';
|
|
2
|
-
export { c as useDispatch, a as useLocalModule, u as useModule, b as useSelector } from './useDispatch-
|
|
2
|
+
export { c as useDispatch, a as useLocalModule, u as useModule, b as useSelector } from './useDispatch-DiwQQAfC.cjs';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import * as Logix from '@logixjs/core';
|
|
5
|
-
import {
|
|
6
|
-
export { M as ModuleActions, a as ModuleDispatchers } from './ModuleRef-
|
|
5
|
+
import { d as ModuleRef, h as ModuleRefOfTag } from './ModuleRef-gZmL6Zvb.cjs';
|
|
6
|
+
export { c as ModuleActionTagsOfShape, M as ModuleActions, a as ModuleDispatchers, b as ModuleDispatchersOfShape, f as ModuleRefOfDef, g as ModuleRefOfModule, e as ModuleRefOfShape } from './ModuleRef-gZmL6Zvb.cjs';
|
|
7
7
|
|
|
8
8
|
interface UseRuntimeOptions {
|
|
9
9
|
readonly layer?: Layer.Layer<any, any, never>;
|
|
@@ -19,7 +19,7 @@ declare function useRuntime(options: UseRuntimeOptions): ManagedRuntime.ManagedR
|
|
|
19
19
|
* - On the effect side, you already built the full Layer via `Module.live(initial, ...logics)`.
|
|
20
20
|
* - A React component wants to "just consume" that Layer without caring about initial/logics details.
|
|
21
21
|
*/
|
|
22
|
-
declare function useLayerModule<Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>, layer: Layer.Layer<Logix.
|
|
22
|
+
declare function useLayerModule<Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>, layer: Layer.Layer<Logix.ModuleRuntimeOfShape<Sh>, never, any>, deps?: React.DependencyList): ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A hook to manage a dynamic list of Module instances.
|
|
@@ -41,7 +41,7 @@ declare function useModuleList<T, M>(items: T[], keyFn: (item: T) => string, fac
|
|
|
41
41
|
* - const query = useImportedModule(host, SearchQuery.tag)
|
|
42
42
|
* - const status = useSelector(query, s => s.search.status)
|
|
43
43
|
*/
|
|
44
|
-
declare function useImportedModule<Id extends string, Sh extends Logix.AnyModuleShape>(parent: Logix.ModuleRuntime<any, any> | ModuleRef<any, any>, module: Logix.ModuleTagType<Id, Sh>):
|
|
44
|
+
declare function useImportedModule<Id extends string, Sh extends Logix.AnyModuleShape>(parent: Logix.ModuleRuntime<any, any> | ModuleRef<any, any>, module: Logix.ModuleTagType<Id, Sh>): ModuleRefOfTag<Id, Sh>;
|
|
45
45
|
|
|
46
46
|
interface UseProcessesOptions {
|
|
47
47
|
/**
|
|
@@ -74,4 +74,4 @@ declare function useProcesses(processes: ReadonlyArray<Effect.Effect<void, any,
|
|
|
74
74
|
*/
|
|
75
75
|
declare const shallow: <T>(previous: T, next: T) => boolean;
|
|
76
76
|
|
|
77
|
-
export {
|
|
77
|
+
export { ModuleRef, ModuleRefOfTag, type UseProcessesOptions, type UseRuntimeOptions, shallow, useImportedModule, useLayerModule, useModuleList, useProcesses, useRuntime };
|
package/dist/Hooks.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Layer, ManagedRuntime, Effect } from 'effect';
|
|
2
|
-
export { c as useDispatch, a as useLocalModule, u as useModule, b as useSelector } from './useDispatch-
|
|
2
|
+
export { c as useDispatch, a as useLocalModule, u as useModule, b as useSelector } from './useDispatch-CiDimIYZ.js';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import * as Logix from '@logixjs/core';
|
|
5
|
-
import {
|
|
6
|
-
export { M as ModuleActions, a as ModuleDispatchers } from './ModuleRef-
|
|
5
|
+
import { d as ModuleRef, h as ModuleRefOfTag } from './ModuleRef-gZmL6Zvb.js';
|
|
6
|
+
export { c as ModuleActionTagsOfShape, M as ModuleActions, a as ModuleDispatchers, b as ModuleDispatchersOfShape, f as ModuleRefOfDef, g as ModuleRefOfModule, e as ModuleRefOfShape } from './ModuleRef-gZmL6Zvb.js';
|
|
7
7
|
|
|
8
8
|
interface UseRuntimeOptions {
|
|
9
9
|
readonly layer?: Layer.Layer<any, any, never>;
|
|
@@ -19,7 +19,7 @@ declare function useRuntime(options: UseRuntimeOptions): ManagedRuntime.ManagedR
|
|
|
19
19
|
* - On the effect side, you already built the full Layer via `Module.live(initial, ...logics)`.
|
|
20
20
|
* - A React component wants to "just consume" that Layer without caring about initial/logics details.
|
|
21
21
|
*/
|
|
22
|
-
declare function useLayerModule<Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>, layer: Layer.Layer<Logix.
|
|
22
|
+
declare function useLayerModule<Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>, layer: Layer.Layer<Logix.ModuleRuntimeOfShape<Sh>, never, any>, deps?: React.DependencyList): ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A hook to manage a dynamic list of Module instances.
|
|
@@ -41,7 +41,7 @@ declare function useModuleList<T, M>(items: T[], keyFn: (item: T) => string, fac
|
|
|
41
41
|
* - const query = useImportedModule(host, SearchQuery.tag)
|
|
42
42
|
* - const status = useSelector(query, s => s.search.status)
|
|
43
43
|
*/
|
|
44
|
-
declare function useImportedModule<Id extends string, Sh extends Logix.AnyModuleShape>(parent: Logix.ModuleRuntime<any, any> | ModuleRef<any, any>, module: Logix.ModuleTagType<Id, Sh>):
|
|
44
|
+
declare function useImportedModule<Id extends string, Sh extends Logix.AnyModuleShape>(parent: Logix.ModuleRuntime<any, any> | ModuleRef<any, any>, module: Logix.ModuleTagType<Id, Sh>): ModuleRefOfTag<Id, Sh>;
|
|
45
45
|
|
|
46
46
|
interface UseProcessesOptions {
|
|
47
47
|
/**
|
|
@@ -74,4 +74,4 @@ declare function useProcesses(processes: ReadonlyArray<Effect.Effect<void, any,
|
|
|
74
74
|
*/
|
|
75
75
|
declare const shallow: <T>(previous: T, next: T) => boolean;
|
|
76
76
|
|
|
77
|
-
export {
|
|
77
|
+
export { ModuleRef, ModuleRefOfTag, type UseProcessesOptions, type UseRuntimeOptions, shallow, useImportedModule, useLayerModule, useModuleList, useProcesses, useRuntime };
|
package/dist/Hooks.js
CHANGED
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
useLocalModule,
|
|
6
6
|
useModuleList,
|
|
7
7
|
useProcesses
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WOTNVLCD.js";
|
|
9
9
|
import {
|
|
10
10
|
shallow,
|
|
11
11
|
useModule,
|
|
12
12
|
useRuntime,
|
|
13
13
|
useSelector
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-G2LX7WWQ.js";
|
|
15
15
|
import "./chunk-2WFULYPJ.js";
|
|
16
16
|
export {
|
|
17
17
|
shallow,
|
|
@@ -21,6 +21,11 @@ type ActionPayload<A, K> = Extract<A, {
|
|
|
21
21
|
} ? P : never;
|
|
22
22
|
type AnyActionToken = Logix.Action.ActionToken<string, any, any>;
|
|
23
23
|
type ModuleDispatchersOfShape<Sh extends Logix.AnyModuleShape> = Sh['actionMap'];
|
|
24
|
+
type ModuleActionTagsOfShape<Sh extends Logix.AnyModuleShape> = keyof Sh['actionMap'] & string;
|
|
25
|
+
type ModuleRefOfShape<Sh extends Logix.AnyModuleShape, Def = unknown, Dispatchers = ModuleDispatchersOfShape<Sh>> = ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>, ModuleActionTagsOfShape<Sh>, Def, Dispatchers>;
|
|
26
|
+
type ModuleRefOfTag<Id extends string, Sh extends Logix.AnyModuleShape> = ModuleRefOfShape<Sh, Logix.ModuleTagType<Id, Sh>, ModuleDispatchersOfShape<Sh>>;
|
|
27
|
+
type ModuleRefOfModule<Id extends string, Sh extends Logix.AnyModuleShape, Ext extends object = {}, R = never> = ModuleRefOfShape<Sh, Logix.Module.Module<Id, Sh, Ext, R>, ModuleDispatchersOfShape<Sh>> & Ext;
|
|
28
|
+
type ModuleRefOfDef<Id extends string, Sh extends Logix.AnyModuleShape, Ext extends object = {}> = ModuleRefOfShape<Sh, Logix.Module.ModuleDef<Id, Sh, Ext>, ModuleDispatchersOfShape<Sh>> & Ext;
|
|
24
29
|
type ModuleActions<A, Tags extends string = ActionTags<A>> = {
|
|
25
30
|
readonly dispatch: Dispatch<A>;
|
|
26
31
|
} & ([ActionTags<A>] extends [never] ? {} : {
|
|
@@ -45,7 +50,7 @@ type ModuleDispatchers<A, Tags extends string = ActionTags<A>, Def = unknown> =
|
|
|
45
50
|
}>>;
|
|
46
51
|
};
|
|
47
52
|
interface ModuleImports {
|
|
48
|
-
readonly get: <Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>) =>
|
|
53
|
+
readonly get: <Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>) => ModuleRefOfTag<Id, Sh>;
|
|
49
54
|
}
|
|
50
55
|
interface ModuleRef<S, A, Tags extends string = ActionTags<A>, Def = unknown, Dispatchers = ModuleDispatchers<A, Tags, Def>> {
|
|
51
56
|
/**
|
|
@@ -59,7 +64,7 @@ interface ModuleRef<S, A, Tags extends string = ActionTags<A>, Def = unknown, Di
|
|
|
59
64
|
readonly dispatchers: Dispatchers;
|
|
60
65
|
/**
|
|
61
66
|
* Fractal module imports sugar:
|
|
62
|
-
* - host.imports.get(ChildModule) resolves a child module instance within the host instance scope.
|
|
67
|
+
* - host.imports.get(ChildModule.tag) resolves a child module instance within the host instance scope.
|
|
63
68
|
* - strict by default: throws when scope is missing, avoiding accidentally routing to a global instance.
|
|
64
69
|
*/
|
|
65
70
|
readonly imports: ModuleImports;
|
|
@@ -70,4 +75,4 @@ interface ModuleRef<S, A, Tags extends string = ActionTags<A>, Def = unknown, Di
|
|
|
70
75
|
readonly ref: Logix.ModuleRuntime<S, A>['ref'];
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
export type { Dispatch as D, ModuleActions as M, ModuleDispatchers as a, ModuleDispatchersOfShape as b,
|
|
78
|
+
export type { Dispatch as D, ModuleActions as M, ModuleDispatchers as a, ModuleDispatchersOfShape as b, ModuleActionTagsOfShape as c, ModuleRef as d, ModuleRefOfShape as e, ModuleRefOfDef as f, ModuleRefOfModule as g, ModuleRefOfTag as h };
|
|
@@ -21,6 +21,11 @@ type ActionPayload<A, K> = Extract<A, {
|
|
|
21
21
|
} ? P : never;
|
|
22
22
|
type AnyActionToken = Logix.Action.ActionToken<string, any, any>;
|
|
23
23
|
type ModuleDispatchersOfShape<Sh extends Logix.AnyModuleShape> = Sh['actionMap'];
|
|
24
|
+
type ModuleActionTagsOfShape<Sh extends Logix.AnyModuleShape> = keyof Sh['actionMap'] & string;
|
|
25
|
+
type ModuleRefOfShape<Sh extends Logix.AnyModuleShape, Def = unknown, Dispatchers = ModuleDispatchersOfShape<Sh>> = ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>, ModuleActionTagsOfShape<Sh>, Def, Dispatchers>;
|
|
26
|
+
type ModuleRefOfTag<Id extends string, Sh extends Logix.AnyModuleShape> = ModuleRefOfShape<Sh, Logix.ModuleTagType<Id, Sh>, ModuleDispatchersOfShape<Sh>>;
|
|
27
|
+
type ModuleRefOfModule<Id extends string, Sh extends Logix.AnyModuleShape, Ext extends object = {}, R = never> = ModuleRefOfShape<Sh, Logix.Module.Module<Id, Sh, Ext, R>, ModuleDispatchersOfShape<Sh>> & Ext;
|
|
28
|
+
type ModuleRefOfDef<Id extends string, Sh extends Logix.AnyModuleShape, Ext extends object = {}> = ModuleRefOfShape<Sh, Logix.Module.ModuleDef<Id, Sh, Ext>, ModuleDispatchersOfShape<Sh>> & Ext;
|
|
24
29
|
type ModuleActions<A, Tags extends string = ActionTags<A>> = {
|
|
25
30
|
readonly dispatch: Dispatch<A>;
|
|
26
31
|
} & ([ActionTags<A>] extends [never] ? {} : {
|
|
@@ -45,7 +50,7 @@ type ModuleDispatchers<A, Tags extends string = ActionTags<A>, Def = unknown> =
|
|
|
45
50
|
}>>;
|
|
46
51
|
};
|
|
47
52
|
interface ModuleImports {
|
|
48
|
-
readonly get: <Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>) =>
|
|
53
|
+
readonly get: <Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>) => ModuleRefOfTag<Id, Sh>;
|
|
49
54
|
}
|
|
50
55
|
interface ModuleRef<S, A, Tags extends string = ActionTags<A>, Def = unknown, Dispatchers = ModuleDispatchers<A, Tags, Def>> {
|
|
51
56
|
/**
|
|
@@ -59,7 +64,7 @@ interface ModuleRef<S, A, Tags extends string = ActionTags<A>, Def = unknown, Di
|
|
|
59
64
|
readonly dispatchers: Dispatchers;
|
|
60
65
|
/**
|
|
61
66
|
* Fractal module imports sugar:
|
|
62
|
-
* - host.imports.get(ChildModule) resolves a child module instance within the host instance scope.
|
|
67
|
+
* - host.imports.get(ChildModule.tag) resolves a child module instance within the host instance scope.
|
|
63
68
|
* - strict by default: throws when scope is missing, avoiding accidentally routing to a global instance.
|
|
64
69
|
*/
|
|
65
70
|
readonly imports: ModuleImports;
|
|
@@ -70,4 +75,4 @@ interface ModuleRef<S, A, Tags extends string = ActionTags<A>, Def = unknown, Di
|
|
|
70
75
|
readonly ref: Logix.ModuleRuntime<S, A>['ref'];
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
export type { Dispatch as D, ModuleActions as M, ModuleDispatchers as a, ModuleDispatchersOfShape as b,
|
|
78
|
+
export type { Dispatch as D, ModuleActions as M, ModuleDispatchers as a, ModuleDispatchersOfShape as b, ModuleActionTagsOfShape as c, ModuleRef as d, ModuleRefOfShape as e, ModuleRefOfDef as f, ModuleRefOfModule as g, ModuleRefOfTag as h };
|