tsdf 11.1.1 → 11.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/main.cjs +22 -5
- package/dist/main.d.ts +1 -1
- package/dist/main.js +18 -5
- package/package.json +6 -6
package/dist/main.cjs
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -103,7 +107,7 @@ function createFetchOrquestrator({
|
|
|
103
107
|
const id = getAutoIncrementId();
|
|
104
108
|
lastFetchIdStarted = id;
|
|
105
109
|
lastFetchWasAborted = false;
|
|
106
|
-
fetchs.a = { startTime, onEnd: [] };
|
|
110
|
+
fetchs.a = { startTime, onEnd: [], rtuOnEnd: null };
|
|
107
111
|
const prevFetchStartTime = lastFetchStartTime;
|
|
108
112
|
lastFetchStartTime = startTime;
|
|
109
113
|
function shouldAbort() {
|
|
@@ -111,6 +115,10 @@ function createFetchOrquestrator({
|
|
|
111
115
|
lastFetchWasAborted = abort;
|
|
112
116
|
return abort;
|
|
113
117
|
}
|
|
118
|
+
if (fetchs.b) {
|
|
119
|
+
clearTimeout(fetchs.b.timeoutId);
|
|
120
|
+
fetchs.b = null;
|
|
121
|
+
}
|
|
114
122
|
const success = await fetchFn(
|
|
115
123
|
{
|
|
116
124
|
shouldAbort,
|
|
@@ -126,15 +134,20 @@ function createFetchOrquestrator({
|
|
|
126
134
|
if (success) {
|
|
127
135
|
lastFetchDuration = Date.now() - startTime;
|
|
128
136
|
}
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
const rtScheduled = fetchs.b;
|
|
138
|
+
if (rtScheduled) {
|
|
139
|
+
clearTimeout(rtScheduled.timeoutId);
|
|
131
140
|
fetchs.b = null;
|
|
132
141
|
}
|
|
133
142
|
const onEnd = currentFetchs.a.onEnd;
|
|
143
|
+
const rtuOnEnd = currentFetchs.a.rtuOnEnd;
|
|
134
144
|
currentFetchs.a = null;
|
|
135
145
|
if (onEnd.length > 0) {
|
|
136
146
|
onEnd.forEach((cb) => cb());
|
|
137
147
|
}
|
|
148
|
+
if (rtuOnEnd) {
|
|
149
|
+
rtuOnEnd();
|
|
150
|
+
}
|
|
138
151
|
flushScheduledFetch();
|
|
139
152
|
return true;
|
|
140
153
|
}
|
|
@@ -213,9 +226,9 @@ function createFetchOrquestrator({
|
|
|
213
226
|
return true;
|
|
214
227
|
}
|
|
215
228
|
if (fetchs.a) {
|
|
216
|
-
fetchs.a.
|
|
229
|
+
fetchs.a.rtuOnEnd = () => {
|
|
217
230
|
addDelayedRTU(Date.now(), params);
|
|
218
|
-
}
|
|
231
|
+
};
|
|
219
232
|
return true;
|
|
220
233
|
} else if (mutationIsInProgress) {
|
|
221
234
|
onMutationEnd.push(() => {
|
|
@@ -547,6 +560,8 @@ function newTSDFDocumentStore({
|
|
|
547
560
|
return useModifyResult(storeState);
|
|
548
561
|
}
|
|
549
562
|
function updateState(produceNewData) {
|
|
563
|
+
if (!store.state.data)
|
|
564
|
+
return false;
|
|
550
565
|
store.setKey(
|
|
551
566
|
"data",
|
|
552
567
|
(current) => {
|
|
@@ -556,6 +571,7 @@ function newTSDFDocumentStore({
|
|
|
556
571
|
},
|
|
557
572
|
{ action: "update-state" }
|
|
558
573
|
);
|
|
574
|
+
return true;
|
|
559
575
|
}
|
|
560
576
|
return {
|
|
561
577
|
store,
|
|
@@ -919,6 +935,7 @@ function newTSDFCollectionStore({
|
|
|
919
935
|
itemStateKey: "",
|
|
920
936
|
isLoading: false
|
|
921
937
|
},
|
|
938
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
922
939
|
[item]
|
|
923
940
|
);
|
|
924
941
|
const [useModifyResult, emitIsLoadedEvt] = useEnsureIsLoaded(
|
package/dist/main.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ d
|
|
|
49
49
|
ensureIsLoaded?: boolean | undefined;
|
|
50
50
|
returnRefetchingStatus?: boolean | undefined;
|
|
51
51
|
}) => Readonly<TSDFUseDocumentReturn<Selected, NError>>;
|
|
52
|
-
updateState: (produceNewData: (draftData: State) => State | void | undefined) =>
|
|
52
|
+
updateState: (produceNewData: (draftData: State) => State | void | undefined) => boolean;
|
|
53
53
|
startMutation: () => () => boolean;
|
|
54
54
|
};
|
|
55
55
|
type TSDFDocumentStore<State extends ValidStoreState, NError> = ReturnType<typeof newTSDFDocumentStore<State, NError>>;
|
package/dist/main.js
CHANGED
|
@@ -69,7 +69,7 @@ function createFetchOrquestrator({
|
|
|
69
69
|
const id = getAutoIncrementId();
|
|
70
70
|
lastFetchIdStarted = id;
|
|
71
71
|
lastFetchWasAborted = false;
|
|
72
|
-
fetchs.a = { startTime, onEnd: [] };
|
|
72
|
+
fetchs.a = { startTime, onEnd: [], rtuOnEnd: null };
|
|
73
73
|
const prevFetchStartTime = lastFetchStartTime;
|
|
74
74
|
lastFetchStartTime = startTime;
|
|
75
75
|
function shouldAbort() {
|
|
@@ -77,6 +77,10 @@ function createFetchOrquestrator({
|
|
|
77
77
|
lastFetchWasAborted = abort;
|
|
78
78
|
return abort;
|
|
79
79
|
}
|
|
80
|
+
if (fetchs.b) {
|
|
81
|
+
clearTimeout(fetchs.b.timeoutId);
|
|
82
|
+
fetchs.b = null;
|
|
83
|
+
}
|
|
80
84
|
const success = await fetchFn(
|
|
81
85
|
{
|
|
82
86
|
shouldAbort,
|
|
@@ -92,15 +96,20 @@ function createFetchOrquestrator({
|
|
|
92
96
|
if (success) {
|
|
93
97
|
lastFetchDuration = Date.now() - startTime;
|
|
94
98
|
}
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
const rtScheduled = fetchs.b;
|
|
100
|
+
if (rtScheduled) {
|
|
101
|
+
clearTimeout(rtScheduled.timeoutId);
|
|
97
102
|
fetchs.b = null;
|
|
98
103
|
}
|
|
99
104
|
const onEnd = currentFetchs.a.onEnd;
|
|
105
|
+
const rtuOnEnd = currentFetchs.a.rtuOnEnd;
|
|
100
106
|
currentFetchs.a = null;
|
|
101
107
|
if (onEnd.length > 0) {
|
|
102
108
|
onEnd.forEach((cb) => cb());
|
|
103
109
|
}
|
|
110
|
+
if (rtuOnEnd) {
|
|
111
|
+
rtuOnEnd();
|
|
112
|
+
}
|
|
104
113
|
flushScheduledFetch();
|
|
105
114
|
return true;
|
|
106
115
|
}
|
|
@@ -179,9 +188,9 @@ function createFetchOrquestrator({
|
|
|
179
188
|
return true;
|
|
180
189
|
}
|
|
181
190
|
if (fetchs.a) {
|
|
182
|
-
fetchs.a.
|
|
191
|
+
fetchs.a.rtuOnEnd = () => {
|
|
183
192
|
addDelayedRTU(Date.now(), params);
|
|
184
|
-
}
|
|
193
|
+
};
|
|
185
194
|
return true;
|
|
186
195
|
} else if (mutationIsInProgress) {
|
|
187
196
|
onMutationEnd.push(() => {
|
|
@@ -513,6 +522,8 @@ function newTSDFDocumentStore({
|
|
|
513
522
|
return useModifyResult(storeState);
|
|
514
523
|
}
|
|
515
524
|
function updateState(produceNewData) {
|
|
525
|
+
if (!store.state.data)
|
|
526
|
+
return false;
|
|
516
527
|
store.setKey(
|
|
517
528
|
"data",
|
|
518
529
|
(current) => {
|
|
@@ -522,6 +533,7 @@ function newTSDFDocumentStore({
|
|
|
522
533
|
},
|
|
523
534
|
{ action: "update-state" }
|
|
524
535
|
);
|
|
536
|
+
return true;
|
|
525
537
|
}
|
|
526
538
|
return {
|
|
527
539
|
store,
|
|
@@ -885,6 +897,7 @@ function newTSDFCollectionStore({
|
|
|
885
897
|
itemStateKey: "",
|
|
886
898
|
isLoading: false
|
|
887
899
|
},
|
|
900
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
888
901
|
[item]
|
|
889
902
|
);
|
|
890
903
|
const [useModifyResult, emitIsLoadedEvt] = useEnsureIsLoaded(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsdf",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.3",
|
|
4
4
|
"description": "A data fetching solution based on t-state",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lucas Santos",
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"react-dom": "^18.2.0",
|
|
59
59
|
"tiny-glob": "^0.2.9",
|
|
60
60
|
"tsm": "^2.3.0",
|
|
61
|
-
"tsup": "^6.
|
|
62
|
-
"typescript": "^
|
|
63
|
-
"vite": "^4.
|
|
64
|
-
"vitest": "^0.
|
|
61
|
+
"tsup": "^6.7.0",
|
|
62
|
+
"typescript": "^5.0.4",
|
|
63
|
+
"vite": "^4.2.1",
|
|
64
|
+
"vitest": "^0.30.1"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"immer": "^9.0.17",
|
|
68
68
|
"klona": "^2.0.6",
|
|
69
69
|
"mitt": "^3.0.0",
|
|
70
|
-
"t-state": "^8.
|
|
70
|
+
"t-state": "^8.3.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"react": "^18.0.0",
|