@flexsurfer/reflex 0.1.15 → 0.1.17
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.cjs +16 -7
- package/dist/index.d.cts +39 -1
- package/dist/index.d.ts +39 -1
- package/dist/index.mjs +15 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -50,6 +50,7 @@ __export(src_exports, {
|
|
|
50
50
|
getAppDb: () => getAppDb,
|
|
51
51
|
getGlobalInterceptors: () => getGlobalInterceptors,
|
|
52
52
|
getHandler: () => getHandler,
|
|
53
|
+
getReactions: () => getReactions,
|
|
53
54
|
getSubscriptionValue: () => getSubscriptionValue,
|
|
54
55
|
initAppDb: () => initAppDb,
|
|
55
56
|
original: () => original,
|
|
@@ -139,6 +140,9 @@ var reactionsRegistry = /* @__PURE__ */ new Map();
|
|
|
139
140
|
function getReaction(key) {
|
|
140
141
|
return reactionsRegistry.get(key);
|
|
141
142
|
}
|
|
143
|
+
function getReactions() {
|
|
144
|
+
return reactionsRegistry;
|
|
145
|
+
}
|
|
142
146
|
function setReaction(key, reaction) {
|
|
143
147
|
reactionsRegistry.set(key, reaction);
|
|
144
148
|
}
|
|
@@ -858,11 +862,14 @@ var Reaction = class _Reaction {
|
|
|
858
862
|
static create(fn, deps) {
|
|
859
863
|
return new _Reaction(fn, deps);
|
|
860
864
|
}
|
|
861
|
-
|
|
865
|
+
computeValue() {
|
|
862
866
|
this.ensureDirty();
|
|
863
867
|
this.recomputeIfNeeded(false);
|
|
864
868
|
return this.value;
|
|
865
869
|
}
|
|
870
|
+
getValue() {
|
|
871
|
+
return this.value;
|
|
872
|
+
}
|
|
866
873
|
getDepValue(notifyWatchers = true) {
|
|
867
874
|
this.recomputeIfNeeded(notifyWatchers);
|
|
868
875
|
return [this.value, this.version];
|
|
@@ -978,8 +985,6 @@ var Reaction = class _Reaction {
|
|
|
978
985
|
disposeIfUnused() {
|
|
979
986
|
if (this.isAlive)
|
|
980
987
|
return;
|
|
981
|
-
this.value = void 0;
|
|
982
|
-
this.version = 0;
|
|
983
988
|
this.depsVersions = [];
|
|
984
989
|
this.dirty = false;
|
|
985
990
|
this.scheduled = false;
|
|
@@ -1008,21 +1013,24 @@ var Reaction = class _Reaction {
|
|
|
1008
1013
|
getId() {
|
|
1009
1014
|
return this.id;
|
|
1010
1015
|
}
|
|
1016
|
+
getVersion() {
|
|
1017
|
+
return this.version;
|
|
1018
|
+
}
|
|
1011
1019
|
getSubVector() {
|
|
1012
1020
|
return this.subVector;
|
|
1013
1021
|
}
|
|
1014
1022
|
setSubVector(subVector) {
|
|
1015
1023
|
this.subVector = subVector;
|
|
1016
1024
|
}
|
|
1017
|
-
get isAlive() {
|
|
1018
|
-
return this.hasWatchers || this.hasDependents;
|
|
1019
|
-
}
|
|
1020
1025
|
get hasWatchers() {
|
|
1021
1026
|
return this.watchers.length > 0;
|
|
1022
1027
|
}
|
|
1023
1028
|
get hasDependents() {
|
|
1024
1029
|
return this.dependents.size > 0;
|
|
1025
1030
|
}
|
|
1031
|
+
get isAlive() {
|
|
1032
|
+
return this.hasWatchers || this.hasDependents;
|
|
1033
|
+
}
|
|
1026
1034
|
get isDirty() {
|
|
1027
1035
|
return this.dirty;
|
|
1028
1036
|
}
|
|
@@ -1088,7 +1096,7 @@ function getOrCreateReaction(subVector) {
|
|
|
1088
1096
|
}
|
|
1089
1097
|
function getSubscriptionValue(subVector) {
|
|
1090
1098
|
const reaction = getOrCreateReaction(subVector);
|
|
1091
|
-
return reaction ? reaction.
|
|
1099
|
+
return reaction ? reaction.computeValue() : void 0;
|
|
1092
1100
|
}
|
|
1093
1101
|
|
|
1094
1102
|
// src/debounce.ts
|
|
@@ -1231,6 +1239,7 @@ function HotReloadWrapper({ children }) {
|
|
|
1231
1239
|
getAppDb,
|
|
1232
1240
|
getGlobalInterceptors,
|
|
1233
1241
|
getHandler,
|
|
1242
|
+
getReactions,
|
|
1234
1243
|
getSubscriptionValue,
|
|
1235
1244
|
initAppDb,
|
|
1236
1245
|
original,
|
package/dist/index.d.cts
CHANGED
|
@@ -98,6 +98,43 @@ declare function defaultErrorHandler(originalError: Error, reflexError: Error &
|
|
|
98
98
|
data: any;
|
|
99
99
|
}): void;
|
|
100
100
|
|
|
101
|
+
declare class Reaction<T> {
|
|
102
|
+
private id;
|
|
103
|
+
private computeFn;
|
|
104
|
+
private deps;
|
|
105
|
+
private dependents;
|
|
106
|
+
private watchers;
|
|
107
|
+
private dirty;
|
|
108
|
+
private scheduled;
|
|
109
|
+
private value;
|
|
110
|
+
private version;
|
|
111
|
+
private depsVersions;
|
|
112
|
+
private subVector;
|
|
113
|
+
constructor(computeFn: (...depValues: any[]) => T, deps?: Reaction<any>[]);
|
|
114
|
+
static create<R>(fn: (...values: any[]) => R, deps?: Reaction<any>[]): Reaction<R>;
|
|
115
|
+
computeValue(): T;
|
|
116
|
+
getValue(): T;
|
|
117
|
+
getDepValue(notifyWatchers?: boolean): [T, number];
|
|
118
|
+
watch(callback: (val: T) => void, componentName?: string): void;
|
|
119
|
+
unwatch(fn: (v: T) => void): void;
|
|
120
|
+
markDirty(): void;
|
|
121
|
+
private scheduleRecompute;
|
|
122
|
+
private recomputeIfNeeded;
|
|
123
|
+
private ensureDirty;
|
|
124
|
+
private ensureAliveWith;
|
|
125
|
+
private disposeIfUnused;
|
|
126
|
+
setId(id: Id): void;
|
|
127
|
+
getId(): Id;
|
|
128
|
+
getVersion(): number;
|
|
129
|
+
getSubVector(): SubVector | undefined;
|
|
130
|
+
setSubVector(subVector: SubVector): void;
|
|
131
|
+
get hasWatchers(): boolean;
|
|
132
|
+
get hasDependents(): boolean;
|
|
133
|
+
get isAlive(): boolean;
|
|
134
|
+
get isDirty(): boolean;
|
|
135
|
+
get isRoot(): boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
101
138
|
declare function regSub<R>(id: Id, computeFn?: (...values: any[]) => R, depsFn?: (...params: any[]) => SubVector[]): void;
|
|
102
139
|
declare function getSubscriptionValue<T>(subVector: SubVector): T;
|
|
103
140
|
|
|
@@ -129,6 +166,7 @@ declare function getHandler<T extends RegistryHandler = RegistryHandler>(kind: K
|
|
|
129
166
|
declare function clearHandlers(): void;
|
|
130
167
|
declare function clearHandlers(kind: Kind): void;
|
|
131
168
|
declare function clearHandlers(kind: Kind, id: string): void;
|
|
169
|
+
declare function getReactions(): Map<string, Reaction<any>> | undefined;
|
|
132
170
|
declare function clearReactions(): void;
|
|
133
171
|
declare function clearReactions(id: string): void;
|
|
134
172
|
declare function clearSubs(): void;
|
|
@@ -215,4 +253,4 @@ declare function disableTracing(): void;
|
|
|
215
253
|
declare function registerTraceCb(key: string, cb: TraceCallback): void;
|
|
216
254
|
declare function enableTracePrint(): void;
|
|
217
255
|
|
|
218
|
-
export { CoEffectHandler, CoEffects, Context, DISPATCH, DISPATCH_LATER, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, NOW, RANDOM, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, current, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getAppDb, getGlobalInterceptors, getHandler, getSubscriptionValue, initAppDb, original, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
|
256
|
+
export { CoEffectHandler, CoEffects, Context, DISPATCH, DISPATCH_LATER, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, NOW, RANDOM, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, current, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getAppDb, getGlobalInterceptors, getHandler, getReactions, getSubscriptionValue, initAppDb, original, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,43 @@ declare function defaultErrorHandler(originalError: Error, reflexError: Error &
|
|
|
98
98
|
data: any;
|
|
99
99
|
}): void;
|
|
100
100
|
|
|
101
|
+
declare class Reaction<T> {
|
|
102
|
+
private id;
|
|
103
|
+
private computeFn;
|
|
104
|
+
private deps;
|
|
105
|
+
private dependents;
|
|
106
|
+
private watchers;
|
|
107
|
+
private dirty;
|
|
108
|
+
private scheduled;
|
|
109
|
+
private value;
|
|
110
|
+
private version;
|
|
111
|
+
private depsVersions;
|
|
112
|
+
private subVector;
|
|
113
|
+
constructor(computeFn: (...depValues: any[]) => T, deps?: Reaction<any>[]);
|
|
114
|
+
static create<R>(fn: (...values: any[]) => R, deps?: Reaction<any>[]): Reaction<R>;
|
|
115
|
+
computeValue(): T;
|
|
116
|
+
getValue(): T;
|
|
117
|
+
getDepValue(notifyWatchers?: boolean): [T, number];
|
|
118
|
+
watch(callback: (val: T) => void, componentName?: string): void;
|
|
119
|
+
unwatch(fn: (v: T) => void): void;
|
|
120
|
+
markDirty(): void;
|
|
121
|
+
private scheduleRecompute;
|
|
122
|
+
private recomputeIfNeeded;
|
|
123
|
+
private ensureDirty;
|
|
124
|
+
private ensureAliveWith;
|
|
125
|
+
private disposeIfUnused;
|
|
126
|
+
setId(id: Id): void;
|
|
127
|
+
getId(): Id;
|
|
128
|
+
getVersion(): number;
|
|
129
|
+
getSubVector(): SubVector | undefined;
|
|
130
|
+
setSubVector(subVector: SubVector): void;
|
|
131
|
+
get hasWatchers(): boolean;
|
|
132
|
+
get hasDependents(): boolean;
|
|
133
|
+
get isAlive(): boolean;
|
|
134
|
+
get isDirty(): boolean;
|
|
135
|
+
get isRoot(): boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
101
138
|
declare function regSub<R>(id: Id, computeFn?: (...values: any[]) => R, depsFn?: (...params: any[]) => SubVector[]): void;
|
|
102
139
|
declare function getSubscriptionValue<T>(subVector: SubVector): T;
|
|
103
140
|
|
|
@@ -129,6 +166,7 @@ declare function getHandler<T extends RegistryHandler = RegistryHandler>(kind: K
|
|
|
129
166
|
declare function clearHandlers(): void;
|
|
130
167
|
declare function clearHandlers(kind: Kind): void;
|
|
131
168
|
declare function clearHandlers(kind: Kind, id: string): void;
|
|
169
|
+
declare function getReactions(): Map<string, Reaction<any>> | undefined;
|
|
132
170
|
declare function clearReactions(): void;
|
|
133
171
|
declare function clearReactions(id: string): void;
|
|
134
172
|
declare function clearSubs(): void;
|
|
@@ -215,4 +253,4 @@ declare function disableTracing(): void;
|
|
|
215
253
|
declare function registerTraceCb(key: string, cb: TraceCallback): void;
|
|
216
254
|
declare function enableTracePrint(): void;
|
|
217
255
|
|
|
218
|
-
export { CoEffectHandler, CoEffects, Context, DISPATCH, DISPATCH_LATER, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, NOW, RANDOM, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, current, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getAppDb, getGlobalInterceptors, getHandler, getSubscriptionValue, initAppDb, original, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
|
256
|
+
export { CoEffectHandler, CoEffects, Context, DISPATCH, DISPATCH_LATER, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, NOW, RANDOM, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, current, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getAppDb, getGlobalInterceptors, getHandler, getReactions, getSubscriptionValue, initAppDb, original, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
package/dist/index.mjs
CHANGED
|
@@ -67,6 +67,9 @@ var reactionsRegistry = /* @__PURE__ */ new Map();
|
|
|
67
67
|
function getReaction(key) {
|
|
68
68
|
return reactionsRegistry.get(key);
|
|
69
69
|
}
|
|
70
|
+
function getReactions() {
|
|
71
|
+
return reactionsRegistry;
|
|
72
|
+
}
|
|
70
73
|
function setReaction(key, reaction) {
|
|
71
74
|
reactionsRegistry.set(key, reaction);
|
|
72
75
|
}
|
|
@@ -786,11 +789,14 @@ var Reaction = class _Reaction {
|
|
|
786
789
|
static create(fn, deps) {
|
|
787
790
|
return new _Reaction(fn, deps);
|
|
788
791
|
}
|
|
789
|
-
|
|
792
|
+
computeValue() {
|
|
790
793
|
this.ensureDirty();
|
|
791
794
|
this.recomputeIfNeeded(false);
|
|
792
795
|
return this.value;
|
|
793
796
|
}
|
|
797
|
+
getValue() {
|
|
798
|
+
return this.value;
|
|
799
|
+
}
|
|
794
800
|
getDepValue(notifyWatchers = true) {
|
|
795
801
|
this.recomputeIfNeeded(notifyWatchers);
|
|
796
802
|
return [this.value, this.version];
|
|
@@ -906,8 +912,6 @@ var Reaction = class _Reaction {
|
|
|
906
912
|
disposeIfUnused() {
|
|
907
913
|
if (this.isAlive)
|
|
908
914
|
return;
|
|
909
|
-
this.value = void 0;
|
|
910
|
-
this.version = 0;
|
|
911
915
|
this.depsVersions = [];
|
|
912
916
|
this.dirty = false;
|
|
913
917
|
this.scheduled = false;
|
|
@@ -936,21 +940,24 @@ var Reaction = class _Reaction {
|
|
|
936
940
|
getId() {
|
|
937
941
|
return this.id;
|
|
938
942
|
}
|
|
943
|
+
getVersion() {
|
|
944
|
+
return this.version;
|
|
945
|
+
}
|
|
939
946
|
getSubVector() {
|
|
940
947
|
return this.subVector;
|
|
941
948
|
}
|
|
942
949
|
setSubVector(subVector) {
|
|
943
950
|
this.subVector = subVector;
|
|
944
951
|
}
|
|
945
|
-
get isAlive() {
|
|
946
|
-
return this.hasWatchers || this.hasDependents;
|
|
947
|
-
}
|
|
948
952
|
get hasWatchers() {
|
|
949
953
|
return this.watchers.length > 0;
|
|
950
954
|
}
|
|
951
955
|
get hasDependents() {
|
|
952
956
|
return this.dependents.size > 0;
|
|
953
957
|
}
|
|
958
|
+
get isAlive() {
|
|
959
|
+
return this.hasWatchers || this.hasDependents;
|
|
960
|
+
}
|
|
954
961
|
get isDirty() {
|
|
955
962
|
return this.dirty;
|
|
956
963
|
}
|
|
@@ -1016,7 +1023,7 @@ function getOrCreateReaction(subVector) {
|
|
|
1016
1023
|
}
|
|
1017
1024
|
function getSubscriptionValue(subVector) {
|
|
1018
1025
|
const reaction = getOrCreateReaction(subVector);
|
|
1019
|
-
return reaction ? reaction.
|
|
1026
|
+
return reaction ? reaction.computeValue() : void 0;
|
|
1020
1027
|
}
|
|
1021
1028
|
|
|
1022
1029
|
// src/debounce.ts
|
|
@@ -1158,6 +1165,7 @@ export {
|
|
|
1158
1165
|
getAppDb,
|
|
1159
1166
|
getGlobalInterceptors,
|
|
1160
1167
|
getHandler,
|
|
1168
|
+
getReactions,
|
|
1161
1169
|
getSubscriptionValue,
|
|
1162
1170
|
initAppDb,
|
|
1163
1171
|
original,
|