controlled-machine 0.1.1 → 0.1.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/dist/index.d.cts +113 -143
- package/dist/index.d.ts +113 -143
- package/dist/index.d.ts.map +1 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +8 -100
- package/dist/react.d.ts +8 -100
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,143 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
* - always: Auto-evaluated rules on context change
|
|
115
|
-
*/
|
|
116
|
-
export declare type Rule<TContext, TPayload = undefined, TActions extends string = string> = {
|
|
117
|
-
when?: (context: TContext, payload: TPayload) => boolean;
|
|
118
|
-
do: TActions | TActions[];
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export declare type Send<TEvents extends EventsConfig> = <K extends keyof TEvents>(event: K, ...args: TEvents[K] extends undefined ? [] : [payload: TEvents[K]]) => void;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Shallow comparison function - for composite watch support
|
|
125
|
-
*
|
|
126
|
-
* Arrays: length + === comparison for each element
|
|
127
|
-
* Others: === comparison
|
|
128
|
-
*/
|
|
129
|
-
export declare function shallowEqual(a: unknown, b: unknown): boolean;
|
|
130
|
-
|
|
131
|
-
export declare type State<T extends MachineTypes> = T['state'] extends string ? T['state'] : string;
|
|
132
|
-
|
|
133
|
-
export declare type StateConfig<TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
134
|
-
on?: {
|
|
135
|
-
[K in keyof TEvents]?: Handler<TContext, TEvents[K], TActions>;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export declare type StatesConfig<TState extends string, TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
140
|
-
[K in TState]?: StateConfig<TContext, TEvents, TActions>;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Controlled Machine
|
|
3
|
+
*
|
|
4
|
+
* A controlled state machine where state lives outside the machine.
|
|
5
|
+
*
|
|
6
|
+
* - input: External data passed in
|
|
7
|
+
* - computed: Derived values from input
|
|
8
|
+
* - context: input + computed (full context available in handlers)
|
|
9
|
+
* - on: Event → conditional actions
|
|
10
|
+
* - effects: Watch-based side effects
|
|
11
|
+
* - always: Auto-evaluated rules on context change
|
|
12
|
+
*/
|
|
13
|
+
export type Rule<TContext, TPayload = undefined, TActions extends string = string> = {
|
|
14
|
+
when?: (context: TContext, payload: TPayload) => boolean;
|
|
15
|
+
do: TActions | TActions[];
|
|
16
|
+
};
|
|
17
|
+
export type Handler<TContext, TPayload = undefined, TActions extends string = string> = TActions | TActions[] | Rule<TContext, TPayload, TActions>[];
|
|
18
|
+
export type EffectHelpers<TEvents extends EventsConfig> = {
|
|
19
|
+
send: Send<TEvents>;
|
|
20
|
+
};
|
|
21
|
+
export type Cleanup = () => void;
|
|
22
|
+
export type Effect<TContext, TEvents extends EventsConfig, TWatched = unknown> = {
|
|
23
|
+
watch: (context: TContext) => TWatched;
|
|
24
|
+
enter?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup | Promise<void>;
|
|
25
|
+
exit?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
26
|
+
change?: (context: TContext, prev: TWatched | undefined, curr: TWatched, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
27
|
+
};
|
|
28
|
+
/** Helper for inferring prev/curr types from watch return type */
|
|
29
|
+
export declare function effect<TContext, TEvents extends EventsConfig, TWatched>(config: Effect<TContext, TEvents, TWatched>): Effect<TContext, TEvents, TWatched>;
|
|
30
|
+
export type EventsConfig = Record<string, unknown>;
|
|
31
|
+
export type ComputedConfig = Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Object-based generic types - specify only needed types in any order
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* createMachine<{
|
|
37
|
+
* input: MyInput
|
|
38
|
+
* events: MyEvents
|
|
39
|
+
* actions: 'foo' | 'bar'
|
|
40
|
+
* }>({...})
|
|
41
|
+
*/
|
|
42
|
+
export type MachineTypes = {
|
|
43
|
+
input?: unknown;
|
|
44
|
+
events?: EventsConfig;
|
|
45
|
+
computed?: ComputedConfig;
|
|
46
|
+
actions?: string;
|
|
47
|
+
state?: string;
|
|
48
|
+
};
|
|
49
|
+
export type Input<T extends MachineTypes> = T['input'];
|
|
50
|
+
export type Events<T extends MachineTypes> = T['events'] extends EventsConfig ? T['events'] : Record<string, undefined>;
|
|
51
|
+
export type Computed<T extends MachineTypes> = T['computed'] extends ComputedConfig ? T['computed'] : Record<string, never>;
|
|
52
|
+
export type Actions<T extends MachineTypes> = T['actions'] extends string ? T['actions'] : string;
|
|
53
|
+
export type State<T extends MachineTypes> = T['state'] extends string ? T['state'] : string;
|
|
54
|
+
export type Context<T extends MachineTypes> = Input<T> & Computed<T>;
|
|
55
|
+
export type StateConfig<TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
56
|
+
on?: {
|
|
57
|
+
[K in keyof TEvents]?: Handler<TContext, TEvents[K], TActions>;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type StatesConfig<TState extends string, TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
61
|
+
[K in TState]?: StateConfig<TContext, TEvents, TActions>;
|
|
62
|
+
};
|
|
63
|
+
export type Machine<T extends MachineTypes> = {
|
|
64
|
+
computed?: {
|
|
65
|
+
[K in keyof Computed<T>]: (input: Input<T>) => Computed<T>[K];
|
|
66
|
+
};
|
|
67
|
+
on?: {
|
|
68
|
+
[K in keyof Events<T>]?: Handler<Context<T>, Events<T>[K], Actions<T>>;
|
|
69
|
+
};
|
|
70
|
+
states?: StatesConfig<State<T>, Context<T>, Events<T>, Actions<T>>;
|
|
71
|
+
always?: Rule<Context<T>, undefined, Actions<T>>[];
|
|
72
|
+
effects?: Effect<Context<T>, Events<T>, any>[];
|
|
73
|
+
actions?: {
|
|
74
|
+
[K in Actions<T>]: (context: Context<T>, payload?: any) => void;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export type Send<TEvents extends EventsConfig> = <K extends keyof TEvents>(event: K, ...args: TEvents[K] extends undefined ? [] : [payload: TEvents[K]]) => void;
|
|
78
|
+
export type MachineInstance<T extends MachineTypes> = Machine<T> & {
|
|
79
|
+
send: <K extends keyof Events<T>>(event: K, input: Input<T>, ...args: Events<T>[K] extends undefined ? [] : [payload: Events<T>[K]]) => void;
|
|
80
|
+
evaluate: (input: Input<T>) => void;
|
|
81
|
+
getComputed: (input: Input<T>) => Computed<T>;
|
|
82
|
+
cleanup: () => void;
|
|
83
|
+
};
|
|
84
|
+
export declare function executeActions<TContext, TPayload>(actionNames: string | string[], actions: Record<string, (context: TContext, payload?: TPayload) => void>, context: TContext, payload: TPayload): void;
|
|
85
|
+
export declare function isRuleArray<TContext, TPayload, TActions extends string>(handler: Handler<TContext, TPayload, TActions>): handler is Rule<TContext, TPayload, TActions>[];
|
|
86
|
+
export declare function executeHandler<TContext, TPayload>(handler: Handler<TContext, TPayload>, actions: Record<string, (context: TContext, payload?: TPayload) => void>, context: TContext, payload: TPayload): void;
|
|
87
|
+
export declare function computeValues<TContext, TComputed extends ComputedConfig>(context: TContext, computed?: {
|
|
88
|
+
[K in keyof TComputed]: (context: TContext) => TComputed[K];
|
|
89
|
+
}): TContext & TComputed;
|
|
90
|
+
/**
|
|
91
|
+
* Shallow comparison function - for composite watch support
|
|
92
|
+
*
|
|
93
|
+
* Arrays: length + === comparison for each element
|
|
94
|
+
* Others: === comparison
|
|
95
|
+
*/
|
|
96
|
+
export declare function shallowEqual(a: unknown, b: unknown): boolean;
|
|
97
|
+
export type EffectStore = {
|
|
98
|
+
watchedValues: Map<number, unknown>;
|
|
99
|
+
enterCleanups: Map<number, () => void>;
|
|
100
|
+
changeCleanups: Map<number, () => void>;
|
|
101
|
+
exitCleanups: Map<number, () => void>;
|
|
102
|
+
};
|
|
103
|
+
export declare function createEffectStore(): EffectStore;
|
|
104
|
+
/**
|
|
105
|
+
* Common effects processing logic
|
|
106
|
+
*/
|
|
107
|
+
export declare function processEffects<TContext, TEvents extends EventsConfig>(effects: Effect<TContext, TEvents, any>[] | undefined, context: TContext, effectHelpers: EffectHelpers<TEvents>, store: EffectStore): void;
|
|
108
|
+
/**
|
|
109
|
+
* Clear effect store
|
|
110
|
+
*/
|
|
111
|
+
export declare function clearEffectStore(store: EffectStore): void;
|
|
112
|
+
export declare function createMachine<T extends MachineTypes>(config: Machine<T>): MachineInstance<T>;
|
|
113
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,143 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
* - always: Auto-evaluated rules on context change
|
|
115
|
-
*/
|
|
116
|
-
export declare type Rule<TContext, TPayload = undefined, TActions extends string = string> = {
|
|
117
|
-
when?: (context: TContext, payload: TPayload) => boolean;
|
|
118
|
-
do: TActions | TActions[];
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export declare type Send<TEvents extends EventsConfig> = <K extends keyof TEvents>(event: K, ...args: TEvents[K] extends undefined ? [] : [payload: TEvents[K]]) => void;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Shallow comparison function - for composite watch support
|
|
125
|
-
*
|
|
126
|
-
* Arrays: length + === comparison for each element
|
|
127
|
-
* Others: === comparison
|
|
128
|
-
*/
|
|
129
|
-
export declare function shallowEqual(a: unknown, b: unknown): boolean;
|
|
130
|
-
|
|
131
|
-
export declare type State<T extends MachineTypes> = T['state'] extends string ? T['state'] : string;
|
|
132
|
-
|
|
133
|
-
export declare type StateConfig<TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
134
|
-
on?: {
|
|
135
|
-
[K in keyof TEvents]?: Handler<TContext, TEvents[K], TActions>;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export declare type StatesConfig<TState extends string, TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
140
|
-
[K in TState]?: StateConfig<TContext, TEvents, TActions>;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Controlled Machine
|
|
3
|
+
*
|
|
4
|
+
* A controlled state machine where state lives outside the machine.
|
|
5
|
+
*
|
|
6
|
+
* - input: External data passed in
|
|
7
|
+
* - computed: Derived values from input
|
|
8
|
+
* - context: input + computed (full context available in handlers)
|
|
9
|
+
* - on: Event → conditional actions
|
|
10
|
+
* - effects: Watch-based side effects
|
|
11
|
+
* - always: Auto-evaluated rules on context change
|
|
12
|
+
*/
|
|
13
|
+
export type Rule<TContext, TPayload = undefined, TActions extends string = string> = {
|
|
14
|
+
when?: (context: TContext, payload: TPayload) => boolean;
|
|
15
|
+
do: TActions | TActions[];
|
|
16
|
+
};
|
|
17
|
+
export type Handler<TContext, TPayload = undefined, TActions extends string = string> = TActions | TActions[] | Rule<TContext, TPayload, TActions>[];
|
|
18
|
+
export type EffectHelpers<TEvents extends EventsConfig> = {
|
|
19
|
+
send: Send<TEvents>;
|
|
20
|
+
};
|
|
21
|
+
export type Cleanup = () => void;
|
|
22
|
+
export type Effect<TContext, TEvents extends EventsConfig, TWatched = unknown> = {
|
|
23
|
+
watch: (context: TContext) => TWatched;
|
|
24
|
+
enter?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup | Promise<void>;
|
|
25
|
+
exit?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
26
|
+
change?: (context: TContext, prev: TWatched | undefined, curr: TWatched, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
27
|
+
};
|
|
28
|
+
/** Helper for inferring prev/curr types from watch return type */
|
|
29
|
+
export declare function effect<TContext, TEvents extends EventsConfig, TWatched>(config: Effect<TContext, TEvents, TWatched>): Effect<TContext, TEvents, TWatched>;
|
|
30
|
+
export type EventsConfig = Record<string, unknown>;
|
|
31
|
+
export type ComputedConfig = Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Object-based generic types - specify only needed types in any order
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* createMachine<{
|
|
37
|
+
* input: MyInput
|
|
38
|
+
* events: MyEvents
|
|
39
|
+
* actions: 'foo' | 'bar'
|
|
40
|
+
* }>({...})
|
|
41
|
+
*/
|
|
42
|
+
export type MachineTypes = {
|
|
43
|
+
input?: unknown;
|
|
44
|
+
events?: EventsConfig;
|
|
45
|
+
computed?: ComputedConfig;
|
|
46
|
+
actions?: string;
|
|
47
|
+
state?: string;
|
|
48
|
+
};
|
|
49
|
+
export type Input<T extends MachineTypes> = T['input'];
|
|
50
|
+
export type Events<T extends MachineTypes> = T['events'] extends EventsConfig ? T['events'] : Record<string, undefined>;
|
|
51
|
+
export type Computed<T extends MachineTypes> = T['computed'] extends ComputedConfig ? T['computed'] : Record<string, never>;
|
|
52
|
+
export type Actions<T extends MachineTypes> = T['actions'] extends string ? T['actions'] : string;
|
|
53
|
+
export type State<T extends MachineTypes> = T['state'] extends string ? T['state'] : string;
|
|
54
|
+
export type Context<T extends MachineTypes> = Input<T> & Computed<T>;
|
|
55
|
+
export type StateConfig<TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
56
|
+
on?: {
|
|
57
|
+
[K in keyof TEvents]?: Handler<TContext, TEvents[K], TActions>;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type StatesConfig<TState extends string, TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
61
|
+
[K in TState]?: StateConfig<TContext, TEvents, TActions>;
|
|
62
|
+
};
|
|
63
|
+
export type Machine<T extends MachineTypes> = {
|
|
64
|
+
computed?: {
|
|
65
|
+
[K in keyof Computed<T>]: (input: Input<T>) => Computed<T>[K];
|
|
66
|
+
};
|
|
67
|
+
on?: {
|
|
68
|
+
[K in keyof Events<T>]?: Handler<Context<T>, Events<T>[K], Actions<T>>;
|
|
69
|
+
};
|
|
70
|
+
states?: StatesConfig<State<T>, Context<T>, Events<T>, Actions<T>>;
|
|
71
|
+
always?: Rule<Context<T>, undefined, Actions<T>>[];
|
|
72
|
+
effects?: Effect<Context<T>, Events<T>, any>[];
|
|
73
|
+
actions?: {
|
|
74
|
+
[K in Actions<T>]: (context: Context<T>, payload?: any) => void;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export type Send<TEvents extends EventsConfig> = <K extends keyof TEvents>(event: K, ...args: TEvents[K] extends undefined ? [] : [payload: TEvents[K]]) => void;
|
|
78
|
+
export type MachineInstance<T extends MachineTypes> = Machine<T> & {
|
|
79
|
+
send: <K extends keyof Events<T>>(event: K, input: Input<T>, ...args: Events<T>[K] extends undefined ? [] : [payload: Events<T>[K]]) => void;
|
|
80
|
+
evaluate: (input: Input<T>) => void;
|
|
81
|
+
getComputed: (input: Input<T>) => Computed<T>;
|
|
82
|
+
cleanup: () => void;
|
|
83
|
+
};
|
|
84
|
+
export declare function executeActions<TContext, TPayload>(actionNames: string | string[], actions: Record<string, (context: TContext, payload?: TPayload) => void>, context: TContext, payload: TPayload): void;
|
|
85
|
+
export declare function isRuleArray<TContext, TPayload, TActions extends string>(handler: Handler<TContext, TPayload, TActions>): handler is Rule<TContext, TPayload, TActions>[];
|
|
86
|
+
export declare function executeHandler<TContext, TPayload>(handler: Handler<TContext, TPayload>, actions: Record<string, (context: TContext, payload?: TPayload) => void>, context: TContext, payload: TPayload): void;
|
|
87
|
+
export declare function computeValues<TContext, TComputed extends ComputedConfig>(context: TContext, computed?: {
|
|
88
|
+
[K in keyof TComputed]: (context: TContext) => TComputed[K];
|
|
89
|
+
}): TContext & TComputed;
|
|
90
|
+
/**
|
|
91
|
+
* Shallow comparison function - for composite watch support
|
|
92
|
+
*
|
|
93
|
+
* Arrays: length + === comparison for each element
|
|
94
|
+
* Others: === comparison
|
|
95
|
+
*/
|
|
96
|
+
export declare function shallowEqual(a: unknown, b: unknown): boolean;
|
|
97
|
+
export type EffectStore = {
|
|
98
|
+
watchedValues: Map<number, unknown>;
|
|
99
|
+
enterCleanups: Map<number, () => void>;
|
|
100
|
+
changeCleanups: Map<number, () => void>;
|
|
101
|
+
exitCleanups: Map<number, () => void>;
|
|
102
|
+
};
|
|
103
|
+
export declare function createEffectStore(): EffectStore;
|
|
104
|
+
/**
|
|
105
|
+
* Common effects processing logic
|
|
106
|
+
*/
|
|
107
|
+
export declare function processEffects<TContext, TEvents extends EventsConfig>(effects: Effect<TContext, TEvents, any>[] | undefined, context: TContext, effectHelpers: EffectHelpers<TEvents>, store: EffectStore): void;
|
|
108
|
+
/**
|
|
109
|
+
* Clear effect store
|
|
110
|
+
*/
|
|
111
|
+
export declare function clearEffectStore(store: EffectStore): void;
|
|
112
|
+
export declare function createMachine<T extends MachineTypes>(config: Machine<T>): MachineInstance<T>;
|
|
113
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,MAAM,IAAI,CACd,QAAQ,EACR,QAAQ,GAAG,SAAS,EACpB,QAAQ,SAAS,MAAM,GAAG,MAAM,IAC9B;IACF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAA;IACxD,EAAE,EAAE,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Ac,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAA;IACvC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAA;CACtC,CAAA;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAO/C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,SAAS,YAAY,EAEnE,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,SAAS,EACrD,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,EACrC,KAAK,EAAE,WAAW,GACjB,IAAI,CAsDN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAQzD;AAMD,wBAAgB,aAAa,CAAC,CAAC,SAAS,YAAY,EAClD,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GACjB,eAAe,CAAC,CAAC,CAAC,CA0EpB"}
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.cjs","sources":["../src/react.ts"],"sourcesContent":["/**\n * Controlled Machine - React Integration\n *\n * React hook for using controlled-machine in React components.\n */\n\nimport { useCallback, useRef, useEffect, useMemo } from 'react'\nimport {\n type MachineTypes,\n type
|
|
1
|
+
{"version":3,"file":"react.cjs","sources":["../src/react.ts"],"sourcesContent":["/**\n * Controlled Machine - React Integration\n *\n * React hook for using controlled-machine in React components.\n */\n\nimport { useCallback, useRef, useEffect, useMemo } from 'react'\nimport {\n type MachineTypes,\n type Events,\n type Computed,\n type State,\n type Send,\n type EffectHelpers,\n type EffectStore,\n type Context,\n computeValues,\n executeActions,\n executeHandler,\n processEffects,\n clearEffectStore,\n MachineInstance,\n} from './index'\n\n// ============================================\n// React Hook\n// ============================================\n\nexport function useMachine<T extends MachineTypes>(\n machine: MachineInstance<T>,\n input: T['input'],\n): { send: Send<Events<T>>; computed: Computed<T>; state: State<T> } {\n // refs for stable callbacks\n const inputRef = useRef(input)\n const machineRef = useRef(machine)\n const isMountedRef = useRef(true)\n\n inputRef.current = input\n machineRef.current = machine\n\n // compute values\n const { computed: computedDef } = machine\n const context = useMemo(\n () => computeValues(input, computedDef),\n [input, computedDef],\n )\n\n // extract computed only\n const computed = useMemo(() => {\n if (!computedDef) return {} as Computed<T>\n const result = {} as Computed<T>\n for (const key in computedDef) {\n result[key] = context[key]\n }\n return result\n }, [context, computedDef])\n\n const contextRef = useRef(context)\n contextRef.current = context\n\n const prevContextRef = useRef<Context<T>>(context)\n const effectStoreRef = useRef<EffectStore>({\n watchedValues: new Map(),\n enterCleanups: new Map(),\n changeCleanups: new Map(),\n exitCleanups: new Map(),\n })\n\n // always: auto-evaluate when context changes (synchronous, during render)\n const { always, actions } = machine\n if (prevContextRef.current !== context && always && actions) {\n const actionsMap = actions as Record<string, (context: Context<T>) => void>\n for (const rule of always) {\n if (!rule.when || rule.when(context, undefined)) {\n executeActions(rule.do, actionsMap, context, undefined)\n break\n }\n }\n }\n prevContextRef.current = context\n\n // send: stable function (no deps, uses refs)\n const send: Send<Events<T>> = useCallback(\n <K extends keyof Events<T>>(\n event: K,\n ...args: Events<T>[K] extends undefined ? [] : [payload: Events<T>[K]]\n ) => {\n const currentMachine = machineRef.current\n const currentInput = inputRef.current\n const currentContext = computeValues(\n currentInput,\n currentMachine.computed,\n )\n const payload = args[0] as Events<T>[K]\n\n // 1. State-specific handler first\n const state = (currentContext as { state?: State<T> }).state\n if (state && currentMachine.states?.[state]?.on?.[event]) {\n const stateHandler = currentMachine.states[state].on![event]!\n executeHandler(\n stateHandler,\n currentMachine.actions ?? {},\n currentContext,\n payload,\n )\n }\n\n // 2. Global handler\n const globalHandler = currentMachine.on?.[event]\n if (globalHandler) {\n executeHandler(\n globalHandler,\n currentMachine.actions ?? {},\n currentContext,\n payload,\n )\n }\n },\n [], // no dependencies - uses refs\n )\n\n // safeSend: won't be called after unmount\n const safeSend: Send<Events<T>> = useCallback(\n <K extends keyof Events<T>>(\n event: K,\n ...args: Events<T>[K] extends undefined ? [] : [payload: Events<T>[K]]\n ) => {\n if (!isMountedRef.current) return\n send(event, ...args)\n },\n [send],\n )\n\n // effect helpers\n const effectHelpers: EffectHelpers<Events<T>> = useMemo(\n () => ({ send: safeSend }),\n [safeSend],\n )\n\n // effects: detect watch value changes\n const { effects } = machine\n useEffect(() => {\n processEffects(effects, context, effectHelpers, effectStoreRef.current)\n }, [context, effects, effectHelpers])\n\n // mount/unmount management\n useEffect(() => {\n isMountedRef.current = true\n const store = effectStoreRef.current\n return () => {\n isMountedRef.current = false\n clearEffectStore(store)\n }\n }, [])\n\n // state from context (default to empty string if not provided)\n const state = (context as { state?: State<T> }).state ?? ('' as State<T>)\n\n return { send, computed, state }\n}\n\n// Re-export types for convenience\nexport type { Send } from './index'\n"],"names":["useRef","useMemo","computeValues","executeActions","useCallback","state","executeHandler","useEffect","processEffects","clearEffectStore"],"mappings":";;;;AA4BO,SAAS,WACd,SACA,OACmE;AAEnE,QAAM,WAAWA,MAAAA,OAAO,KAAK;AAC7B,QAAM,aAAaA,MAAAA,OAAO,OAAO;AACjC,QAAM,eAAeA,MAAAA,OAAO,IAAI;AAEhC,WAAS,UAAU;AACnB,aAAW,UAAU;AAGrB,QAAM,EAAE,UAAU,YAAA,IAAgB;AAClC,QAAM,UAAUC,MAAAA;AAAAA,IACd,MAAMC,MAAAA,cAAc,OAAO,WAAW;AAAA,IACtC,CAAC,OAAO,WAAW;AAAA,EAAA;AAIrB,QAAM,WAAWD,MAAAA,QAAQ,MAAM;AAC7B,QAAI,CAAC,YAAa,QAAO,CAAA;AACzB,UAAM,SAAS,CAAA;AACf,eAAW,OAAO,aAAa;AAC7B,aAAO,GAAG,IAAI,QAAQ,GAAG;AAAA,IAC3B;AACA,WAAO;AAAA,EACT,GAAG,CAAC,SAAS,WAAW,CAAC;AAEzB,QAAM,aAAaD,MAAAA,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IAChC,CACE,UACG,SACA;AACH,UAAI,CAAC,aAAa,QAAS;AAC3B,WAAK,OAAO,GAAG,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,IAAI;AAAA,EAAA;AAIP,QAAM,gBAA0CH,MAAAA;AAAAA,IAC9C,OAAO,EAAE,MAAM;IACf,CAAC,QAAQ;AAAA,EAAA;AAIX,QAAM,EAAE,YAAY;AACpBM,QAAAA,UAAU,MAAM;AACdC,UAAAA,eAAe,SAAS,SAAS,eAAe,eAAe,OAAO;AAAA,EACxE,GAAG,CAAC,SAAS,SAAS,aAAa,CAAC;AAGpCD,QAAAA,UAAU,MAAM;AACd,iBAAa,UAAU;AACvB,UAAM,QAAQ,eAAe;AAC7B,WAAO,MAAM;AACX,mBAAa,UAAU;AACvBE,YAAAA,iBAAiB,KAAK;AAAA,IACxB;AAAA,EACF,GAAG,CAAA,CAAE;AAGL,QAAM,QAAS,QAAiC,SAAU;AAE1D,SAAO,EAAE,MAAM,UAAU,MAAA;AAC3B;;"}
|
package/dist/react.d.cts
CHANGED
|
@@ -1,100 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare type Context<T extends MachineTypes> = Input<T> & Computed<T>;
|
|
10
|
-
|
|
11
|
-
declare type Effect<TContext, TEvents extends EventsConfig, TWatched = unknown> = {
|
|
12
|
-
watch: (context: TContext) => TWatched;
|
|
13
|
-
enter?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup | Promise<void>;
|
|
14
|
-
exit?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
15
|
-
change?: (context: TContext, prev: TWatched | undefined, curr: TWatched, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
declare type EffectHelpers<TEvents extends EventsConfig> = {
|
|
19
|
-
send: Send<TEvents>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
declare type Events<T extends MachineTypes> = T['events'] extends EventsConfig ? T['events'] : Record<string, undefined>;
|
|
23
|
-
|
|
24
|
-
declare type EventsConfig = Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
declare type Handler<TContext, TPayload = undefined, TActions extends string = string> = TActions | TActions[] | Rule<TContext, TPayload, TActions>[];
|
|
27
|
-
|
|
28
|
-
declare type Input<T extends MachineTypes> = T['input'];
|
|
29
|
-
|
|
30
|
-
declare type Machine<T extends MachineTypes> = {
|
|
31
|
-
computed?: {
|
|
32
|
-
[K in keyof Computed<T>]: (input: Input<T>) => Computed<T>[K];
|
|
33
|
-
};
|
|
34
|
-
on?: {
|
|
35
|
-
[K in keyof Events<T>]?: Handler<Context<T>, Events<T>[K], Actions<T>>;
|
|
36
|
-
};
|
|
37
|
-
states?: StatesConfig<State<T>, Context<T>, Events<T>, Actions<T>>;
|
|
38
|
-
always?: Rule<Context<T>, undefined, Actions<T>>[];
|
|
39
|
-
effects?: Effect<Context<T>, Events<T>, any>[];
|
|
40
|
-
actions?: {
|
|
41
|
-
[K in Actions<T>]: (context: Context<T>, payload?: any) => void;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Object-based generic types - specify only needed types in any order
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* createMachine<{
|
|
50
|
-
* input: MyInput
|
|
51
|
-
* events: MyEvents
|
|
52
|
-
* actions: 'foo' | 'bar'
|
|
53
|
-
* }>({...})
|
|
54
|
-
*/
|
|
55
|
-
declare type MachineTypes = {
|
|
56
|
-
input?: unknown;
|
|
57
|
-
events?: EventsConfig;
|
|
58
|
-
computed?: ComputedConfig;
|
|
59
|
-
actions?: string;
|
|
60
|
-
state?: string;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Controlled Machine
|
|
65
|
-
*
|
|
66
|
-
* A controlled state machine where state lives outside the machine.
|
|
67
|
-
*
|
|
68
|
-
* - input: External data passed in
|
|
69
|
-
* - computed: Derived values from input
|
|
70
|
-
* - context: input + computed (full context available in handlers)
|
|
71
|
-
* - on: Event → conditional actions
|
|
72
|
-
* - effects: Watch-based side effects
|
|
73
|
-
* - always: Auto-evaluated rules on context change
|
|
74
|
-
*/
|
|
75
|
-
declare type Rule<TContext, TPayload = undefined, TActions extends string = string> = {
|
|
76
|
-
when?: (context: TContext, payload: TPayload) => boolean;
|
|
77
|
-
do: TActions | TActions[];
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export declare type Send<TEvents extends EventsConfig> = <K extends keyof TEvents>(event: K, ...args: TEvents[K] extends undefined ? [] : [payload: TEvents[K]]) => void;
|
|
81
|
-
|
|
82
|
-
declare type State<T extends MachineTypes> = T['state'] extends string ? T['state'] : string;
|
|
83
|
-
|
|
84
|
-
declare type StateConfig<TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
85
|
-
on?: {
|
|
86
|
-
[K in keyof TEvents]?: Handler<TContext, TEvents[K], TActions>;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
declare type StatesConfig<TState extends string, TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
91
|
-
[K in TState]?: StateConfig<TContext, TEvents, TActions>;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export declare function useMachine<T extends MachineTypes>(machine: Machine<T>, input: T['input']): {
|
|
95
|
-
send: Send<Events<T>>;
|
|
96
|
-
computed: Computed<T>;
|
|
97
|
-
state: State<T>;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export { }
|
|
1
|
+
import { MachineTypes, Events, Computed, State, Send, MachineInstance } from './index';
|
|
2
|
+
export declare function useMachine<T extends MachineTypes>(machine: MachineInstance<T>, input: T['input']): {
|
|
3
|
+
send: Send<Events<T>>;
|
|
4
|
+
computed: Computed<T>;
|
|
5
|
+
state: State<T>;
|
|
6
|
+
};
|
|
7
|
+
export type { Send } from './index';
|
|
8
|
+
//# sourceMappingURL=react.d.ts.map
|
package/dist/react.d.ts
CHANGED
|
@@ -1,100 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare type Context<T extends MachineTypes> = Input<T> & Computed<T>;
|
|
10
|
-
|
|
11
|
-
declare type Effect<TContext, TEvents extends EventsConfig, TWatched = unknown> = {
|
|
12
|
-
watch: (context: TContext) => TWatched;
|
|
13
|
-
enter?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup | Promise<void>;
|
|
14
|
-
exit?: (context: TContext, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
15
|
-
change?: (context: TContext, prev: TWatched | undefined, curr: TWatched, helpers: EffectHelpers<TEvents>) => void | Cleanup;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
declare type EffectHelpers<TEvents extends EventsConfig> = {
|
|
19
|
-
send: Send<TEvents>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
declare type Events<T extends MachineTypes> = T['events'] extends EventsConfig ? T['events'] : Record<string, undefined>;
|
|
23
|
-
|
|
24
|
-
declare type EventsConfig = Record<string, unknown>;
|
|
25
|
-
|
|
26
|
-
declare type Handler<TContext, TPayload = undefined, TActions extends string = string> = TActions | TActions[] | Rule<TContext, TPayload, TActions>[];
|
|
27
|
-
|
|
28
|
-
declare type Input<T extends MachineTypes> = T['input'];
|
|
29
|
-
|
|
30
|
-
declare type Machine<T extends MachineTypes> = {
|
|
31
|
-
computed?: {
|
|
32
|
-
[K in keyof Computed<T>]: (input: Input<T>) => Computed<T>[K];
|
|
33
|
-
};
|
|
34
|
-
on?: {
|
|
35
|
-
[K in keyof Events<T>]?: Handler<Context<T>, Events<T>[K], Actions<T>>;
|
|
36
|
-
};
|
|
37
|
-
states?: StatesConfig<State<T>, Context<T>, Events<T>, Actions<T>>;
|
|
38
|
-
always?: Rule<Context<T>, undefined, Actions<T>>[];
|
|
39
|
-
effects?: Effect<Context<T>, Events<T>, any>[];
|
|
40
|
-
actions?: {
|
|
41
|
-
[K in Actions<T>]: (context: Context<T>, payload?: any) => void;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Object-based generic types - specify only needed types in any order
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* createMachine<{
|
|
50
|
-
* input: MyInput
|
|
51
|
-
* events: MyEvents
|
|
52
|
-
* actions: 'foo' | 'bar'
|
|
53
|
-
* }>({...})
|
|
54
|
-
*/
|
|
55
|
-
declare type MachineTypes = {
|
|
56
|
-
input?: unknown;
|
|
57
|
-
events?: EventsConfig;
|
|
58
|
-
computed?: ComputedConfig;
|
|
59
|
-
actions?: string;
|
|
60
|
-
state?: string;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Controlled Machine
|
|
65
|
-
*
|
|
66
|
-
* A controlled state machine where state lives outside the machine.
|
|
67
|
-
*
|
|
68
|
-
* - input: External data passed in
|
|
69
|
-
* - computed: Derived values from input
|
|
70
|
-
* - context: input + computed (full context available in handlers)
|
|
71
|
-
* - on: Event → conditional actions
|
|
72
|
-
* - effects: Watch-based side effects
|
|
73
|
-
* - always: Auto-evaluated rules on context change
|
|
74
|
-
*/
|
|
75
|
-
declare type Rule<TContext, TPayload = undefined, TActions extends string = string> = {
|
|
76
|
-
when?: (context: TContext, payload: TPayload) => boolean;
|
|
77
|
-
do: TActions | TActions[];
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export declare type Send<TEvents extends EventsConfig> = <K extends keyof TEvents>(event: K, ...args: TEvents[K] extends undefined ? [] : [payload: TEvents[K]]) => void;
|
|
81
|
-
|
|
82
|
-
declare type State<T extends MachineTypes> = T['state'] extends string ? T['state'] : string;
|
|
83
|
-
|
|
84
|
-
declare type StateConfig<TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
85
|
-
on?: {
|
|
86
|
-
[K in keyof TEvents]?: Handler<TContext, TEvents[K], TActions>;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
declare type StatesConfig<TState extends string, TContext, TEvents extends EventsConfig, TActions extends string = string> = {
|
|
91
|
-
[K in TState]?: StateConfig<TContext, TEvents, TActions>;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export declare function useMachine<T extends MachineTypes>(machine: Machine<T>, input: T['input']): {
|
|
95
|
-
send: Send<Events<T>>;
|
|
96
|
-
computed: Computed<T>;
|
|
97
|
-
state: State<T>;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export { }
|
|
1
|
+
import { MachineTypes, Events, Computed, State, Send, MachineInstance } from './index';
|
|
2
|
+
export declare function useMachine<T extends MachineTypes>(machine: MachineInstance<T>, input: T['input']): {
|
|
3
|
+
send: Send<Events<T>>;
|
|
4
|
+
computed: Computed<T>;
|
|
5
|
+
state: State<T>;
|
|
6
|
+
};
|
|
7
|
+
export type { Send } from './index';
|
|
8
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,IAAI,EAST,eAAe,EAChB,MAAM,SAAS,CAAA;AAMhB,wBAAgB,UAAU,CAAC,CAAC,SAAS,YAAY,EAC/C,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAC3B,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,GAChB;IAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;CAAE,CAgInE;AAGD,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sources":["../src/react.ts"],"sourcesContent":["/**\n * Controlled Machine - React Integration\n *\n * React hook for using controlled-machine in React components.\n */\n\nimport { useCallback, useRef, useEffect, useMemo } from 'react'\nimport {\n type MachineTypes,\n type
|
|
1
|
+
{"version":3,"file":"react.js","sources":["../src/react.ts"],"sourcesContent":["/**\n * Controlled Machine - React Integration\n *\n * React hook for using controlled-machine in React components.\n */\n\nimport { useCallback, useRef, useEffect, useMemo } from 'react'\nimport {\n type MachineTypes,\n type Events,\n type Computed,\n type State,\n type Send,\n type EffectHelpers,\n type EffectStore,\n type Context,\n computeValues,\n executeActions,\n executeHandler,\n processEffects,\n clearEffectStore,\n MachineInstance,\n} from './index'\n\n// ============================================\n// React Hook\n// ============================================\n\nexport function useMachine<T extends MachineTypes>(\n machine: MachineInstance<T>,\n input: T['input'],\n): { send: Send<Events<T>>; computed: Computed<T>; state: State<T> } {\n // refs for stable callbacks\n const inputRef = useRef(input)\n const machineRef = useRef(machine)\n const isMountedRef = useRef(true)\n\n inputRef.current = input\n machineRef.current = machine\n\n // compute values\n const { computed: computedDef } = machine\n const context = useMemo(\n () => computeValues(input, computedDef),\n [input, computedDef],\n )\n\n // extract computed only\n const computed = useMemo(() => {\n if (!computedDef) return {} as Computed<T>\n const result = {} as Computed<T>\n for (const key in computedDef) {\n result[key] = context[key]\n }\n return result\n }, [context, computedDef])\n\n const contextRef = useRef(context)\n contextRef.current = context\n\n const prevContextRef = useRef<Context<T>>(context)\n const effectStoreRef = useRef<EffectStore>({\n watchedValues: new Map(),\n enterCleanups: new Map(),\n changeCleanups: new Map(),\n exitCleanups: new Map(),\n })\n\n // always: auto-evaluate when context changes (synchronous, during render)\n const { always, actions } = machine\n if (prevContextRef.current !== context && always && actions) {\n const actionsMap = actions as Record<string, (context: Context<T>) => void>\n for (const rule of always) {\n if (!rule.when || rule.when(context, undefined)) {\n executeActions(rule.do, actionsMap, context, undefined)\n break\n }\n }\n }\n prevContextRef.current = context\n\n // send: stable function (no deps, uses refs)\n const send: Send<Events<T>> = useCallback(\n <K extends keyof Events<T>>(\n event: K,\n ...args: Events<T>[K] extends undefined ? [] : [payload: Events<T>[K]]\n ) => {\n const currentMachine = machineRef.current\n const currentInput = inputRef.current\n const currentContext = computeValues(\n currentInput,\n currentMachine.computed,\n )\n const payload = args[0] as Events<T>[K]\n\n // 1. State-specific handler first\n const state = (currentContext as { state?: State<T> }).state\n if (state && currentMachine.states?.[state]?.on?.[event]) {\n const stateHandler = currentMachine.states[state].on![event]!\n executeHandler(\n stateHandler,\n currentMachine.actions ?? {},\n currentContext,\n payload,\n )\n }\n\n // 2. Global handler\n const globalHandler = currentMachine.on?.[event]\n if (globalHandler) {\n executeHandler(\n globalHandler,\n currentMachine.actions ?? {},\n currentContext,\n payload,\n )\n }\n },\n [], // no dependencies - uses refs\n )\n\n // safeSend: won't be called after unmount\n const safeSend: Send<Events<T>> = useCallback(\n <K extends keyof Events<T>>(\n event: K,\n ...args: Events<T>[K] extends undefined ? [] : [payload: Events<T>[K]]\n ) => {\n if (!isMountedRef.current) return\n send(event, ...args)\n },\n [send],\n )\n\n // effect helpers\n const effectHelpers: EffectHelpers<Events<T>> = useMemo(\n () => ({ send: safeSend }),\n [safeSend],\n )\n\n // effects: detect watch value changes\n const { effects } = machine\n useEffect(() => {\n processEffects(effects, context, effectHelpers, effectStoreRef.current)\n }, [context, effects, effectHelpers])\n\n // mount/unmount management\n useEffect(() => {\n isMountedRef.current = true\n const store = effectStoreRef.current\n return () => {\n isMountedRef.current = false\n clearEffectStore(store)\n }\n }, [])\n\n // state from context (default to empty string if not provided)\n const state = (context as { state?: State<T> }).state ?? ('' as State<T>)\n\n return { send, computed, state }\n}\n\n// Re-export types for convenience\nexport type { Send } from './index'\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AU,KAAK,CAAC;AAGtB,YAAMA,SAAS,eAAwC;AACvD,UAAIA,UAAS,eAAe,SAASA,MAAK,GAAG,KAAK,KAAK,GAAG;AACxD,cAAM,eAAe,eAAe,OAAOA,MAAK,EAAE,GAAI,KAAK;AAC3D;AAAA,UACE;AAAA,UACA,eAAe,WAAW,CAAA;AAAA,UAC1B;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AAGA,YAAM,gBAAgB,eAAe,KAAK,KAAK;AAC/C,UAAI,eAAe;AACjB;AAAA,UACE;AAAA,UACA,eAAe,WAAW,CAAA;AAAA,UAC1B;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AAAA,IACF;AAAA,IACA,CAAA;AAAA;AAAA,EAAC;AAIH,QAAM,WAA4B;AAAA,IAChC,CACE,UACG,SACA;AACH,UAAI,CAAC,aAAa,QAAS;AAC3B,WAAK,OAAO,GAAG,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,IAAI;AAAA,EAAA;AAIP,QAAM,gBAA0C;AAAA,IAC9C,OAAO,EAAE,MAAM;IACf,CAAC,QAAQ;AAAA,EAAA;AAIX,QAAM,EAAE,YAAY;AACpB,YAAU,MAAM;AACd,mBAAe,SAAS,SAAS,eAAe,eAAe,OAAO;AAAA,EACxE,GAAG,CAAC,SAAS,SAAS,aAAa,CAAC;AAGpC,YAAU,MAAM;AACd,iBAAa,UAAU;AACvB,UAAM,QAAQ,eAAe;AAC7B,WAAO,MAAM;AACX,mBAAa,UAAU;AACvB,uBAAiB,KAAK;AAAA,IACxB;AAAA,EACF,GAAG,CAAA,CAAE;AAGL,QAAM,QAAS,QAAiC,SAAU;AAE1D,SAAO,EAAE,MAAM,UAAU,MAAA;AAC3B;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "controlled-machine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A controlled state machine where state lives outside the machine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -71,5 +71,6 @@
|
|
|
71
71
|
"vite": "^7.3.1",
|
|
72
72
|
"vite-plugin-dts": "^4.5.4",
|
|
73
73
|
"vitest": "^4.0.16"
|
|
74
|
-
}
|
|
74
|
+
},
|
|
75
|
+
"packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
|
|
75
76
|
}
|