@flexsurfer/reflex 0.1.2 → 0.1.4
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 +10 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +9 -2
- package/package.json +10 -4
package/dist/index.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(src_exports, {
|
|
|
43
43
|
enableTracePrint: () => enableTracePrint,
|
|
44
44
|
enableTracing: () => enableTracing,
|
|
45
45
|
getGlobalInterceptors: () => getGlobalInterceptors,
|
|
46
|
+
getSubscriptionValue: () => getSubscriptionValue,
|
|
46
47
|
initAppDb: () => initAppDb,
|
|
47
48
|
isDebugEnabled: () => isDebugEnabled,
|
|
48
49
|
regCoeffect: () => regCoeffect,
|
|
@@ -440,6 +441,9 @@ var EventQueue = class {
|
|
|
440
441
|
let n = this.queue.length;
|
|
441
442
|
while (n > 0) {
|
|
442
443
|
const nextEvent = this.queue[0];
|
|
444
|
+
if (!nextEvent || this.queue.length === 0) {
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
443
447
|
const metaKeys = nextEvent.meta ? Object.keys(nextEvent.meta) : [];
|
|
444
448
|
const laterKey = metaKeys.find((k) => laterFns[k]);
|
|
445
449
|
if (laterKey) {
|
|
@@ -1063,6 +1067,10 @@ function getOrCreateReaction(subVector) {
|
|
|
1063
1067
|
setReaction(subVectorKey, reaction);
|
|
1064
1068
|
return reaction;
|
|
1065
1069
|
}
|
|
1070
|
+
function getSubscriptionValue(subVector) {
|
|
1071
|
+
const reaction = getOrCreateReaction(subVector);
|
|
1072
|
+
return reaction ? reaction.getValue() : void 0;
|
|
1073
|
+
}
|
|
1066
1074
|
|
|
1067
1075
|
// src/debounce.ts
|
|
1068
1076
|
var timeout = /* @__PURE__ */ new Map();
|
|
@@ -1098,8 +1106,7 @@ function throttleAndDispatch(event, durationMs) {
|
|
|
1098
1106
|
var import_react = require("react");
|
|
1099
1107
|
function useSubscription(subVector, componentName = "react component") {
|
|
1100
1108
|
const [val, setVal] = (0, import_react.useState)(() => {
|
|
1101
|
-
|
|
1102
|
-
return reaction ? reaction.getValue() : void 0;
|
|
1109
|
+
return getSubscriptionValue(subVector);
|
|
1103
1110
|
});
|
|
1104
1111
|
(0, import_react.useEffect)(() => {
|
|
1105
1112
|
const reaction = getOrCreateReaction(subVector);
|
|
@@ -1199,6 +1206,7 @@ function HotReloadWrapper({ children }) {
|
|
|
1199
1206
|
enableTracePrint,
|
|
1200
1207
|
enableTracing,
|
|
1201
1208
|
getGlobalInterceptors,
|
|
1209
|
+
getSubscriptionValue,
|
|
1202
1210
|
initAppDb,
|
|
1203
1211
|
isDebugEnabled,
|
|
1204
1212
|
regCoeffect,
|
package/dist/index.d.cts
CHANGED
|
@@ -79,6 +79,7 @@ declare function defaultErrorHandler(originalError: Error, reFrameError: Error &
|
|
|
79
79
|
}): void;
|
|
80
80
|
|
|
81
81
|
declare function regSub<R>(id: Id, computeFn?: (...values: any[]) => R, depsFn?: (...params: any[]) => SubVector[]): void;
|
|
82
|
+
declare function getSubscriptionValue<T>(subVector: SubVector): T;
|
|
82
83
|
|
|
83
84
|
declare function regEffect(id: string, handler: EffectHandler): void;
|
|
84
85
|
|
|
@@ -199,4 +200,4 @@ declare function disableTracing(): void;
|
|
|
199
200
|
declare function registerTraceCb(key: string, cb: TraceCallback): void;
|
|
200
201
|
declare function enableTracePrint(): void;
|
|
201
202
|
|
|
202
|
-
export { CoEffectHandler, CoEffects, Context, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getGlobalInterceptors, initAppDb, isDebugEnabled, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setDebugEnabled, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
|
203
|
+
export { CoEffectHandler, CoEffects, Context, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getGlobalInterceptors, getSubscriptionValue, initAppDb, isDebugEnabled, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setDebugEnabled, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ declare function defaultErrorHandler(originalError: Error, reFrameError: Error &
|
|
|
79
79
|
}): void;
|
|
80
80
|
|
|
81
81
|
declare function regSub<R>(id: Id, computeFn?: (...values: any[]) => R, depsFn?: (...params: any[]) => SubVector[]): void;
|
|
82
|
+
declare function getSubscriptionValue<T>(subVector: SubVector): T;
|
|
82
83
|
|
|
83
84
|
declare function regEffect(id: string, handler: EffectHandler): void;
|
|
84
85
|
|
|
@@ -199,4 +200,4 @@ declare function disableTracing(): void;
|
|
|
199
200
|
declare function registerTraceCb(key: string, cb: TraceCallback): void;
|
|
200
201
|
declare function enableTracePrint(): void;
|
|
201
202
|
|
|
202
|
-
export { CoEffectHandler, CoEffects, Context, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getGlobalInterceptors, initAppDb, isDebugEnabled, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setDebugEnabled, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
|
203
|
+
export { CoEffectHandler, CoEffects, Context, Db, DispatchLaterEffect, EffectHandler, Effects, ErrorHandler, EventHandler, EventVector, HotReloadWrapper, Id, Interceptor, SubVector, clearGlobalInterceptors, clearHandlers, clearHotReloadCallbacks, clearReactions, clearSubs, debounceAndDispatch, defaultErrorHandler, disableTracing, dispatch, enableTracePrint, enableTracing, getGlobalInterceptors, getSubscriptionValue, initAppDb, isDebugEnabled, regCoeffect, regEffect, regEvent, regEventErrorHandler, regGlobalInterceptor, regSub, registerHotReloadCallback, registerTraceCb, setDebugEnabled, setupSubsHotReload, throttleAndDispatch, triggerHotReload, useHotReload, useHotReloadKey, useSubscription };
|
package/dist/index.mjs
CHANGED
|
@@ -375,6 +375,9 @@ var EventQueue = class {
|
|
|
375
375
|
let n = this.queue.length;
|
|
376
376
|
while (n > 0) {
|
|
377
377
|
const nextEvent = this.queue[0];
|
|
378
|
+
if (!nextEvent || this.queue.length === 0) {
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
378
381
|
const metaKeys = nextEvent.meta ? Object.keys(nextEvent.meta) : [];
|
|
379
382
|
const laterKey = metaKeys.find((k) => laterFns[k]);
|
|
380
383
|
if (laterKey) {
|
|
@@ -998,6 +1001,10 @@ function getOrCreateReaction(subVector) {
|
|
|
998
1001
|
setReaction(subVectorKey, reaction);
|
|
999
1002
|
return reaction;
|
|
1000
1003
|
}
|
|
1004
|
+
function getSubscriptionValue(subVector) {
|
|
1005
|
+
const reaction = getOrCreateReaction(subVector);
|
|
1006
|
+
return reaction ? reaction.getValue() : void 0;
|
|
1007
|
+
}
|
|
1001
1008
|
|
|
1002
1009
|
// src/debounce.ts
|
|
1003
1010
|
var timeout = /* @__PURE__ */ new Map();
|
|
@@ -1033,8 +1040,7 @@ function throttleAndDispatch(event, durationMs) {
|
|
|
1033
1040
|
import { useEffect, useState } from "react";
|
|
1034
1041
|
function useSubscription(subVector, componentName = "react component") {
|
|
1035
1042
|
const [val, setVal] = useState(() => {
|
|
1036
|
-
|
|
1037
|
-
return reaction ? reaction.getValue() : void 0;
|
|
1043
|
+
return getSubscriptionValue(subVector);
|
|
1038
1044
|
});
|
|
1039
1045
|
useEffect(() => {
|
|
1040
1046
|
const reaction = getOrCreateReaction(subVector);
|
|
@@ -1133,6 +1139,7 @@ export {
|
|
|
1133
1139
|
enableTracePrint,
|
|
1134
1140
|
enableTracing,
|
|
1135
1141
|
getGlobalInterceptors,
|
|
1142
|
+
getSubscriptionValue,
|
|
1136
1143
|
initAppDb,
|
|
1137
1144
|
isDebugEnabled,
|
|
1138
1145
|
regCoeffect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flexsurfer/reflex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,8 +11,14 @@
|
|
|
11
11
|
"module": "dist/index.mjs",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
|
-
"import":
|
|
15
|
-
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
16
22
|
},
|
|
17
23
|
"files": [
|
|
18
24
|
"dist",
|
|
@@ -62,4 +68,4 @@
|
|
|
62
68
|
"pubsub",
|
|
63
69
|
"handler"
|
|
64
70
|
]
|
|
65
|
-
}
|
|
71
|
+
}
|