@askrjs/askr 0.0.2 → 0.0.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/README.md +8 -5
- package/dist/chunk-64C7W2AE.js +43 -0
- package/dist/chunk-64C7W2AE.js.map +1 -0
- package/dist/chunk-6FLMH4EL.js +124 -0
- package/dist/chunk-6FLMH4EL.js.map +1 -0
- package/dist/chunk-FJUXFA72.js +16 -0
- package/dist/chunk-FJUXFA72.js.map +1 -0
- package/dist/chunk-SALJX5PZ.js +26 -0
- package/dist/{chunk-KR6HG7HF.js.map → chunk-SALJX5PZ.js.map} +1 -1
- package/dist/{chunk-RJWOOUYV.js → chunk-VRAEBIJ3.js} +7 -9
- package/dist/chunk-VRAEBIJ3.js.map +1 -0
- package/dist/chunk-WTFWRSHB.js +98 -0
- package/dist/chunk-WTFWRSHB.js.map +1 -0
- package/dist/chunk-XHKZGJE3.js +2907 -0
- package/dist/chunk-XHKZGJE3.js.map +1 -0
- package/dist/chunk-Z5ZSTLYF.js +420 -0
- package/dist/chunk-Z5ZSTLYF.js.map +1 -0
- package/dist/fx/index.cjs +1193 -0
- package/dist/fx/index.cjs.map +1 -0
- package/dist/fx/index.d.cts +186 -0
- package/dist/fx/index.d.ts +186 -0
- package/dist/fx/index.js +418 -0
- package/dist/fx/index.js.map +1 -0
- package/dist/index.cjs +3020 -3506
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -364
- package/dist/index.d.ts +74 -364
- package/dist/index.js +88 -656
- package/dist/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.cjs +1 -1
- package/dist/jsx/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx/jsx-dev-runtime.d.cts +3 -2
- package/dist/jsx/jsx-dev-runtime.d.ts +3 -2
- package/dist/jsx/jsx-dev-runtime.js +2 -5
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-runtime.d.cts +2 -1
- package/dist/jsx/jsx-runtime.d.ts +2 -1
- package/dist/jsx/jsx-runtime.js +2 -4
- package/dist/{types-DLTViI21.d.cts → jsx-AzPM8gMS.d.cts} +6 -21
- package/dist/{types-DLTViI21.d.ts → jsx-AzPM8gMS.d.ts} +6 -21
- package/dist/navigate-LUVYHYZZ.js +17 -0
- package/dist/resources/index.cjs +1200 -0
- package/dist/resources/index.cjs.map +1 -0
- package/dist/resources/index.d.cts +21 -0
- package/dist/resources/index.d.ts +21 -0
- package/dist/resources/index.js +278 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/{route-P5YQBT4T.js → route-BCND6MPK.js} +5 -4
- package/dist/router/index.cjs +3247 -0
- package/dist/router/index.cjs.map +1 -0
- package/dist/router/index.d.cts +64 -0
- package/dist/router/index.d.ts +64 -0
- package/dist/router/index.js +49 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router-DaGtH1Sq.d.cts +36 -0
- package/dist/router-DaGtH1Sq.d.ts +36 -0
- package/dist/ssr/index.cjs +4059 -0
- package/dist/ssr/index.cjs.map +1 -0
- package/dist/ssr/index.d.cts +123 -0
- package/dist/ssr/index.d.ts +123 -0
- package/dist/ssr/index.js +666 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/types-CZ5sWur5.d.cts +23 -0
- package/dist/types-CZHOAiC1.d.ts +23 -0
- package/package.json +21 -7
- package/src/jsx/types.ts +4 -17
- package/dist/chunk-KR6HG7HF.js +0 -38
- package/dist/chunk-MIPES65F.js +0 -3023
- package/dist/chunk-MIPES65F.js.map +0 -1
- package/dist/chunk-PFOLLB6A.js +0 -524
- package/dist/chunk-PFOLLB6A.js.map +0 -1
- package/dist/chunk-QECQ2TF6.js +0 -28
- package/dist/chunk-QECQ2TF6.js.map +0 -1
- package/dist/chunk-RJWOOUYV.js.map +0 -1
- package/dist/navigate-SDZNA2ZE.js +0 -16
- package/dist/ssr-65K3IJ6B.js +0 -28
- package/dist/ssr-65K3IJ6B.js.map +0 -1
- /package/dist/{navigate-SDZNA2ZE.js.map → navigate-LUVYHYZZ.js.map} +0 -0
- /package/dist/{route-P5YQBT4T.js.map → route-BCND6MPK.js.map} +0 -0
package/dist/fx/index.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCurrentComponentInstance,
|
|
3
|
+
globalScheduler,
|
|
4
|
+
logger
|
|
5
|
+
} from "../chunk-XHKZGJE3.js";
|
|
6
|
+
import "../chunk-SALJX5PZ.js";
|
|
7
|
+
import "../chunk-FJUXFA72.js";
|
|
8
|
+
|
|
9
|
+
// src/fx/timing.ts
|
|
10
|
+
function debounce(fn, ms, options) {
|
|
11
|
+
let timeoutId = null;
|
|
12
|
+
const { leading = false, trailing = true } = options || {};
|
|
13
|
+
let lastArgs = null;
|
|
14
|
+
let lastThis = null;
|
|
15
|
+
let lastCallTime = 0;
|
|
16
|
+
const debounced = function(...args) {
|
|
17
|
+
const callTime = Date.now();
|
|
18
|
+
lastArgs = args;
|
|
19
|
+
lastThis = this;
|
|
20
|
+
if (timeoutId !== null) {
|
|
21
|
+
clearTimeout(timeoutId);
|
|
22
|
+
}
|
|
23
|
+
if (leading && callTime - lastCallTime >= ms) {
|
|
24
|
+
fn.apply(this, args);
|
|
25
|
+
lastCallTime = callTime;
|
|
26
|
+
}
|
|
27
|
+
if (trailing) {
|
|
28
|
+
timeoutId = setTimeout(() => {
|
|
29
|
+
fn.apply(lastThis, lastArgs);
|
|
30
|
+
timeoutId = null;
|
|
31
|
+
lastCallTime = Date.now();
|
|
32
|
+
}, ms);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
debounced.cancel = () => {
|
|
36
|
+
if (timeoutId !== null) {
|
|
37
|
+
clearTimeout(timeoutId);
|
|
38
|
+
timeoutId = null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return debounced;
|
|
42
|
+
}
|
|
43
|
+
function throttle(fn, ms, options) {
|
|
44
|
+
let lastCallTime = 0;
|
|
45
|
+
let timeoutId = null;
|
|
46
|
+
const { leading = true, trailing = true } = options || {};
|
|
47
|
+
let lastArgs = null;
|
|
48
|
+
let lastThis = null;
|
|
49
|
+
const throttled = function(...args) {
|
|
50
|
+
const callTime = Date.now();
|
|
51
|
+
lastArgs = args;
|
|
52
|
+
lastThis = this;
|
|
53
|
+
if (leading && callTime - lastCallTime >= ms) {
|
|
54
|
+
fn.apply(this, args);
|
|
55
|
+
lastCallTime = callTime;
|
|
56
|
+
if (timeoutId !== null) {
|
|
57
|
+
clearTimeout(timeoutId);
|
|
58
|
+
timeoutId = null;
|
|
59
|
+
}
|
|
60
|
+
} else if (!leading && lastCallTime === 0) {
|
|
61
|
+
lastCallTime = callTime;
|
|
62
|
+
}
|
|
63
|
+
if (trailing && timeoutId === null) {
|
|
64
|
+
timeoutId = setTimeout(
|
|
65
|
+
() => {
|
|
66
|
+
fn.apply(lastThis, lastArgs);
|
|
67
|
+
lastCallTime = Date.now();
|
|
68
|
+
timeoutId = null;
|
|
69
|
+
},
|
|
70
|
+
ms - (callTime - lastCallTime)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
throttled.cancel = () => {
|
|
75
|
+
if (timeoutId !== null) {
|
|
76
|
+
clearTimeout(timeoutId);
|
|
77
|
+
timeoutId = null;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return throttled;
|
|
81
|
+
}
|
|
82
|
+
function once(fn) {
|
|
83
|
+
let called = false;
|
|
84
|
+
let result;
|
|
85
|
+
return ((...args) => {
|
|
86
|
+
if (!called) {
|
|
87
|
+
called = true;
|
|
88
|
+
result = fn(...args);
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function defer(fn) {
|
|
94
|
+
Promise.resolve().then(fn);
|
|
95
|
+
}
|
|
96
|
+
function raf(fn) {
|
|
97
|
+
let frameId = null;
|
|
98
|
+
let lastArgs = null;
|
|
99
|
+
let lastThis = null;
|
|
100
|
+
return function(...args) {
|
|
101
|
+
lastArgs = args;
|
|
102
|
+
lastThis = this;
|
|
103
|
+
if (frameId === null) {
|
|
104
|
+
frameId = requestAnimationFrame(() => {
|
|
105
|
+
fn.apply(lastThis, lastArgs);
|
|
106
|
+
frameId = null;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function idle(fn, options) {
|
|
112
|
+
if (typeof requestIdleCallback !== "undefined") {
|
|
113
|
+
requestIdleCallback(fn, options ? { timeout: options.timeout } : void 0);
|
|
114
|
+
} else {
|
|
115
|
+
Promise.resolve().then(() => {
|
|
116
|
+
setTimeout(fn, 0);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function timeout(ms) {
|
|
121
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
122
|
+
}
|
|
123
|
+
async function retry(fn, options) {
|
|
124
|
+
const {
|
|
125
|
+
maxAttempts = 3,
|
|
126
|
+
delayMs = 100,
|
|
127
|
+
backoff = (i) => delayMs * Math.pow(2, i)
|
|
128
|
+
} = options || {};
|
|
129
|
+
let lastError = null;
|
|
130
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
131
|
+
try {
|
|
132
|
+
return await fn();
|
|
133
|
+
} catch (error) {
|
|
134
|
+
lastError = error;
|
|
135
|
+
if (attempt < maxAttempts - 1) {
|
|
136
|
+
const delay = backoff(attempt);
|
|
137
|
+
await timeout(delay);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
throw lastError || new Error("Retry failed");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/fx/noop.ts
|
|
145
|
+
var noopEventListener = Object.assign((_ev) => {
|
|
146
|
+
}, { cancel() {
|
|
147
|
+
} });
|
|
148
|
+
var noopEventListenerWithFlush = Object.assign((_ev) => {
|
|
149
|
+
}, { cancel() {
|
|
150
|
+
}, flush() {
|
|
151
|
+
} });
|
|
152
|
+
|
|
153
|
+
// src/fx/fx.ts
|
|
154
|
+
function throwIfDuringRender() {
|
|
155
|
+
const inst = getCurrentComponentInstance();
|
|
156
|
+
if (inst !== null) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
"[Askr] calling FX handler during render is not allowed. Move calls to event handlers or effects."
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function enqueueUserCallback(fn) {
|
|
163
|
+
globalScheduler.enqueue(() => {
|
|
164
|
+
try {
|
|
165
|
+
fn();
|
|
166
|
+
} catch (err) {
|
|
167
|
+
logger.error("[Askr] FX handler error:", err);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function debounceEvent(ms, handler, options) {
|
|
172
|
+
const { leading = false, trailing = true } = options || {};
|
|
173
|
+
const inst = getCurrentComponentInstance();
|
|
174
|
+
if (inst && inst.ssr) {
|
|
175
|
+
return noopEventListenerWithFlush;
|
|
176
|
+
}
|
|
177
|
+
let timeoutId = null;
|
|
178
|
+
let lastEvent = null;
|
|
179
|
+
let lastCallTime = 0;
|
|
180
|
+
const debounced = function(ev) {
|
|
181
|
+
throwIfDuringRender();
|
|
182
|
+
const now = Date.now();
|
|
183
|
+
lastEvent = ev;
|
|
184
|
+
if (timeoutId !== null) {
|
|
185
|
+
clearTimeout(timeoutId);
|
|
186
|
+
timeoutId = null;
|
|
187
|
+
}
|
|
188
|
+
if (leading && now - lastCallTime >= ms) {
|
|
189
|
+
enqueueUserCallback(() => handler.call(null, ev));
|
|
190
|
+
lastCallTime = now;
|
|
191
|
+
}
|
|
192
|
+
if (trailing) {
|
|
193
|
+
timeoutId = setTimeout(() => {
|
|
194
|
+
if (lastEvent) {
|
|
195
|
+
enqueueUserCallback(() => handler.call(null, lastEvent));
|
|
196
|
+
}
|
|
197
|
+
timeoutId = null;
|
|
198
|
+
lastCallTime = Date.now();
|
|
199
|
+
}, ms);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
debounced.cancel = () => {
|
|
203
|
+
if (timeoutId !== null) {
|
|
204
|
+
clearTimeout(timeoutId);
|
|
205
|
+
timeoutId = null;
|
|
206
|
+
}
|
|
207
|
+
lastEvent = null;
|
|
208
|
+
};
|
|
209
|
+
debounced.flush = () => {
|
|
210
|
+
if (timeoutId !== null) {
|
|
211
|
+
clearTimeout(timeoutId);
|
|
212
|
+
const ev = lastEvent;
|
|
213
|
+
lastEvent = null;
|
|
214
|
+
timeoutId = null;
|
|
215
|
+
if (ev) enqueueUserCallback(() => handler.call(null, ev));
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
if (inst) {
|
|
219
|
+
inst.cleanupFns.push(() => {
|
|
220
|
+
debounced.cancel();
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return debounced;
|
|
224
|
+
}
|
|
225
|
+
function throttleEvent(ms, handler, options) {
|
|
226
|
+
const { leading = true, trailing = true } = options || {};
|
|
227
|
+
const inst = getCurrentComponentInstance();
|
|
228
|
+
if (inst && inst.ssr) {
|
|
229
|
+
return noopEventListener;
|
|
230
|
+
}
|
|
231
|
+
let lastCallTime = 0;
|
|
232
|
+
let timeoutId = null;
|
|
233
|
+
let lastEvent = null;
|
|
234
|
+
const throttled = function(ev) {
|
|
235
|
+
throwIfDuringRender();
|
|
236
|
+
const now = Date.now();
|
|
237
|
+
lastEvent = ev;
|
|
238
|
+
if (leading && now - lastCallTime >= ms) {
|
|
239
|
+
enqueueUserCallback(() => handler.call(null, ev));
|
|
240
|
+
lastCallTime = now;
|
|
241
|
+
if (timeoutId !== null) {
|
|
242
|
+
clearTimeout(timeoutId);
|
|
243
|
+
timeoutId = null;
|
|
244
|
+
}
|
|
245
|
+
} else if (!leading && lastCallTime === 0) {
|
|
246
|
+
lastCallTime = now;
|
|
247
|
+
}
|
|
248
|
+
if (trailing && timeoutId === null) {
|
|
249
|
+
const wait = ms - (now - lastCallTime);
|
|
250
|
+
timeoutId = setTimeout(
|
|
251
|
+
() => {
|
|
252
|
+
if (lastEvent)
|
|
253
|
+
enqueueUserCallback(() => handler.call(null, lastEvent));
|
|
254
|
+
lastCallTime = Date.now();
|
|
255
|
+
timeoutId = null;
|
|
256
|
+
},
|
|
257
|
+
Math.max(0, wait)
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
throttled.cancel = () => {
|
|
262
|
+
if (timeoutId !== null) {
|
|
263
|
+
clearTimeout(timeoutId);
|
|
264
|
+
timeoutId = null;
|
|
265
|
+
}
|
|
266
|
+
lastEvent = null;
|
|
267
|
+
};
|
|
268
|
+
if (inst) {
|
|
269
|
+
inst.cleanupFns.push(() => throttled.cancel());
|
|
270
|
+
}
|
|
271
|
+
return throttled;
|
|
272
|
+
}
|
|
273
|
+
function rafEvent(handler) {
|
|
274
|
+
const inst = getCurrentComponentInstance();
|
|
275
|
+
if (inst && inst.ssr) {
|
|
276
|
+
return noopEventListener;
|
|
277
|
+
}
|
|
278
|
+
let frameId = null;
|
|
279
|
+
let lastEvent = null;
|
|
280
|
+
const scheduleFrame = () => {
|
|
281
|
+
const rAF = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : (cb) => setTimeout(() => cb(Date.now()), 16);
|
|
282
|
+
frameId = rAF(() => {
|
|
283
|
+
frameId = null;
|
|
284
|
+
if (lastEvent) {
|
|
285
|
+
const ev = lastEvent;
|
|
286
|
+
lastEvent = null;
|
|
287
|
+
enqueueUserCallback(() => handler.call(null, ev));
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
const fn = function(ev) {
|
|
292
|
+
throwIfDuringRender();
|
|
293
|
+
lastEvent = ev;
|
|
294
|
+
if (frameId === null) scheduleFrame();
|
|
295
|
+
};
|
|
296
|
+
fn.cancel = () => {
|
|
297
|
+
if (frameId !== null) {
|
|
298
|
+
if (typeof cancelAnimationFrame !== "undefined" && typeof frameId === "number") {
|
|
299
|
+
cancelAnimationFrame(frameId);
|
|
300
|
+
} else {
|
|
301
|
+
clearTimeout(frameId);
|
|
302
|
+
}
|
|
303
|
+
frameId = null;
|
|
304
|
+
}
|
|
305
|
+
lastEvent = null;
|
|
306
|
+
};
|
|
307
|
+
if (inst) inst.cleanupFns.push(() => fn.cancel());
|
|
308
|
+
return fn;
|
|
309
|
+
}
|
|
310
|
+
function scheduleTimeout(ms, fn) {
|
|
311
|
+
throwIfDuringRender();
|
|
312
|
+
const inst = getCurrentComponentInstance();
|
|
313
|
+
if (inst && inst.ssr) {
|
|
314
|
+
return () => {
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
let id = setTimeout(() => {
|
|
318
|
+
id = null;
|
|
319
|
+
enqueueUserCallback(fn);
|
|
320
|
+
}, ms);
|
|
321
|
+
const cancel = () => {
|
|
322
|
+
if (id !== null) {
|
|
323
|
+
clearTimeout(id);
|
|
324
|
+
id = null;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
if (inst) inst.cleanupFns.push(cancel);
|
|
328
|
+
return cancel;
|
|
329
|
+
}
|
|
330
|
+
function scheduleIdle(fn, options) {
|
|
331
|
+
throwIfDuringRender();
|
|
332
|
+
const inst = getCurrentComponentInstance();
|
|
333
|
+
if (inst && inst.ssr) return () => {
|
|
334
|
+
};
|
|
335
|
+
let id = null;
|
|
336
|
+
let usingRIC = false;
|
|
337
|
+
if (typeof requestIdleCallback !== "undefined") {
|
|
338
|
+
usingRIC = true;
|
|
339
|
+
id = requestIdleCallback(() => {
|
|
340
|
+
id = null;
|
|
341
|
+
enqueueUserCallback(fn);
|
|
342
|
+
}, options);
|
|
343
|
+
} else {
|
|
344
|
+
id = setTimeout(() => {
|
|
345
|
+
id = null;
|
|
346
|
+
enqueueUserCallback(fn);
|
|
347
|
+
}, 0);
|
|
348
|
+
}
|
|
349
|
+
const cancel = () => {
|
|
350
|
+
if (id !== null) {
|
|
351
|
+
if (usingRIC && typeof cancelIdleCallback !== "undefined" && typeof id === "number") {
|
|
352
|
+
cancelIdleCallback(id);
|
|
353
|
+
} else {
|
|
354
|
+
clearTimeout(id);
|
|
355
|
+
}
|
|
356
|
+
id = null;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
if (inst) inst.cleanupFns.push(cancel);
|
|
360
|
+
return cancel;
|
|
361
|
+
}
|
|
362
|
+
function scheduleRetry(fn, options) {
|
|
363
|
+
throwIfDuringRender();
|
|
364
|
+
const inst = getCurrentComponentInstance();
|
|
365
|
+
if (inst && inst.ssr) return { cancel: () => {
|
|
366
|
+
} };
|
|
367
|
+
const {
|
|
368
|
+
maxAttempts = 3,
|
|
369
|
+
delayMs = 100,
|
|
370
|
+
backoff = (i) => delayMs * Math.pow(2, i)
|
|
371
|
+
} = options || {};
|
|
372
|
+
let cancelled = false;
|
|
373
|
+
const attempt = (index) => {
|
|
374
|
+
if (cancelled) return;
|
|
375
|
+
globalScheduler.enqueue(() => {
|
|
376
|
+
if (cancelled) return;
|
|
377
|
+
const p = fn();
|
|
378
|
+
p.then(
|
|
379
|
+
() => {
|
|
380
|
+
},
|
|
381
|
+
() => {
|
|
382
|
+
if (cancelled) return;
|
|
383
|
+
if (index + 1 < maxAttempts) {
|
|
384
|
+
const delay = backoff(index);
|
|
385
|
+
setTimeout(() => {
|
|
386
|
+
attempt(index + 1);
|
|
387
|
+
}, delay);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
).catch((e) => {
|
|
391
|
+
logger.error("[Askr] scheduleRetry error:", e);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
attempt(0);
|
|
396
|
+
const cancel = () => {
|
|
397
|
+
cancelled = true;
|
|
398
|
+
};
|
|
399
|
+
if (inst) inst.cleanupFns.push(cancel);
|
|
400
|
+
return { cancel };
|
|
401
|
+
}
|
|
402
|
+
export {
|
|
403
|
+
debounce,
|
|
404
|
+
debounceEvent,
|
|
405
|
+
defer,
|
|
406
|
+
idle,
|
|
407
|
+
once,
|
|
408
|
+
raf,
|
|
409
|
+
rafEvent,
|
|
410
|
+
retry,
|
|
411
|
+
scheduleIdle,
|
|
412
|
+
scheduleRetry,
|
|
413
|
+
scheduleTimeout,
|
|
414
|
+
throttle,
|
|
415
|
+
throttleEvent,
|
|
416
|
+
timeout
|
|
417
|
+
};
|
|
418
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/fx/timing.ts","../../src/fx/noop.ts","../../src/fx/fx.ts"],"sourcesContent":["/**\n * Timing utilities — pure helpers for common async patterns\n * No framework coupling. No lifecycle awareness.\n */\n\nexport interface DebounceOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\nexport interface ThrottleOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoff?: (attemptIndex: number) => number;\n}\n\n/**\n * Debounce — delay execution, coalesce rapid calls\n *\n * Useful for: text input, resize, autosave\n *\n * @param fn Function to debounce\n * @param ms Delay in milliseconds\n * @param options trailing (default true), leading\n * @returns Debounced function with cancel() method\n *\n * @example\n * ```ts\n * const save = debounce((text) => api.save(text), 500);\n * input.addEventListener('input', (e) => save(e.target.value));\n * save.cancel(); // stop any pending execution\n * ```\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(\n fn: T,\n ms: number,\n options?: DebounceOptions\n): T & { cancel(): void } {\n let timeoutId: NodeJS.Timeout | null = null;\n const { leading = false, trailing = true } = options || {};\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n let lastCallTime = 0;\n\n const debounced = function (this: unknown, ...args: unknown[]) {\n const callTime = Date.now();\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n if (leading && callTime - lastCallTime >= ms) {\n fn.apply(this, args);\n lastCallTime = callTime;\n }\n\n if (trailing) {\n timeoutId = setTimeout(() => {\n fn.apply(lastThis, lastArgs!);\n timeoutId = null;\n lastCallTime = Date.now();\n }, ms);\n }\n };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return debounced as T & { cancel(): void };\n}\n\n/**\n * Throttle — rate-limit execution, keep first/last\n *\n * Useful for: scroll, mouse move, high-frequency events\n *\n * @param fn Function to throttle\n * @param ms Minimum interval between calls in milliseconds\n * @param options leading (default true), trailing (default true)\n * @returns Throttled function with cancel() method\n *\n * @example\n * ```ts\n * const handleScroll = throttle(updateUI, 100);\n * window.addEventListener('scroll', handleScroll);\n * handleScroll.cancel();\n * ```\n */\nexport function throttle<T extends (...args: unknown[]) => unknown>(\n fn: T,\n ms: number,\n options?: ThrottleOptions\n): T & { cancel(): void } {\n let lastCallTime = 0;\n let timeoutId: NodeJS.Timeout | null = null;\n const { leading = true, trailing = true } = options || {};\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n\n const throttled = function (this: unknown, ...args: unknown[]) {\n const callTime = Date.now();\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (leading && callTime - lastCallTime >= ms) {\n fn.apply(this, args);\n lastCallTime = callTime;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n } else if (!leading && lastCallTime === 0) {\n lastCallTime = callTime;\n }\n\n if (trailing && timeoutId === null) {\n timeoutId = setTimeout(\n () => {\n fn.apply(lastThis, lastArgs!);\n lastCallTime = Date.now();\n timeoutId = null;\n },\n ms - (callTime - lastCallTime)\n );\n }\n };\n\n throttled.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n return throttled as T & { cancel(): void };\n}\n\n/**\n * Once — guard against double execution\n *\n * Useful for: init logic, event safety\n *\n * @param fn Function to call at most once\n * @returns Function that executes fn only on first call\n *\n * @example\n * ```ts\n * const init = once(setup);\n * init(); // runs\n * init(); // does nothing\n * init(); // does nothing\n * ```\n */\nexport function once<T extends (...args: unknown[]) => unknown>(fn: T): T {\n let called = false;\n let result: unknown;\n\n return ((...args: unknown[]) => {\n if (!called) {\n called = true;\n result = fn(...args);\n }\n return result;\n }) as T;\n}\n\n/**\n * Defer — schedule on microtask queue\n *\n * Useful for: run-after-current-stack logic\n * More reliable than setTimeout(..., 0)\n *\n * @param fn Function to defer\n *\n * @example\n * ```ts\n * defer(() => update()); // runs after current stack, before next macrotask\n * ```\n */\nexport function defer(fn: () => void): void {\n Promise.resolve().then(fn);\n}\n\n/**\n * RAF — coalesce multiple updates into single frame\n *\n * Useful for: animation, layout work, render updates\n *\n * @param fn Function to schedule on next animation frame\n * @returns Function that schedules fn on requestAnimationFrame\n *\n * @example\n * ```ts\n * const update = raf(render);\n * update(); // schedules on next frame\n * update(); // same frame, no duplicate\n * ```\n */\nexport function raf<T extends (...args: unknown[]) => unknown>(fn: T): T {\n let frameId: number | null = null;\n let lastArgs: unknown[] | null = null;\n let lastThis: unknown = null;\n\n return function (this: unknown, ...args: unknown[]) {\n lastArgs = args;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this;\n\n if (frameId === null) {\n frameId = requestAnimationFrame(() => {\n fn.apply(lastThis, lastArgs!);\n frameId = null;\n });\n }\n } as T;\n}\n\n/**\n * Idle — schedule low-priority work\n *\n * Useful for: background prep, non-urgent updates\n * Falls back to setTimeout if requestIdleCallback unavailable\n *\n * @param fn Function to call when idle\n * @param options timeout for fallback\n *\n * @example\n * ```ts\n * idle(() => prefetchData());\n * ```\n */\nexport function idle(fn: () => void, options?: { timeout?: number }): void {\n if (typeof requestIdleCallback !== 'undefined') {\n requestIdleCallback(fn, options ? { timeout: options.timeout } : undefined);\n } else {\n // Fallback: defer to microtask, then use setTimeout\n Promise.resolve().then(() => {\n setTimeout(fn, 0);\n });\n }\n}\n\n/**\n * Timeout — Promise-based delay\n *\n * Useful for: readable async code, waiting between retries\n *\n * @param ms Milliseconds to wait\n * @returns Promise that resolves after delay\n *\n * @example\n * ```ts\n * await timeout(300);\n * console.log('300ms later');\n * ```\n */\nexport function timeout(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Retry — attempt function with backoff\n *\n * Useful for: network calls, transient failures\n *\n * @param fn Async function to retry\n * @param options maxAttempts, delayMs, backoff function\n * @returns Promise with final result or error\n *\n * @example\n * ```ts\n * const data = await retry(() => fetch(url), {\n * maxAttempts: 3,\n * delayMs: 100,\n * });\n * ```\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options?: RetryOptions\n): Promise<T> {\n const {\n maxAttempts = 3,\n delayMs = 100,\n backoff = (i: number) => delayMs * Math.pow(2, i),\n } = options || {};\n\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n if (attempt < maxAttempts - 1) {\n const delay = backoff(attempt);\n await timeout(delay);\n }\n }\n }\n\n throw lastError || new Error('Retry failed');\n}\n","// Lightweight shared no-op helpers to avoid double-casts and duplicated definitions\n\nexport const noop: () => void = () => {};\n\nexport const noopEventListener: EventListener & { cancel(): void } =\n Object.assign((_ev?: Event) => {}, { cancel() {} });\n\nexport const noopEventListenerWithFlush: EventListener & {\n cancel(): void;\n flush(): void;\n} = Object.assign((_ev?: Event) => {}, { cancel() {}, flush() {} });\n\nexport const noopCancel: { cancel(): void } = { cancel() {} };\n","import { globalScheduler } from '../runtime/scheduler';\nimport { getCurrentComponentInstance } from '../runtime/component';\nimport { logger } from '../dev/logger';\nimport { noopEventListener, noopEventListenerWithFlush } from './noop';\n\nexport type CancelFn = () => void;\n\n// Platform-specific timer handle types\ntype TimeoutHandle = ReturnType<typeof setTimeout> | null;\n// rAF may fall back to setTimeout in some environments/tests, include both\ntype RafHandle =\n | ReturnType<typeof requestAnimationFrame>\n | ReturnType<typeof setTimeout>\n | null;\n// requestIdleCallback may be unavailable; allow setTimeout fallback handle\ntype IdleHandle =\n | ReturnType<typeof requestIdleCallback>\n | ReturnType<typeof setTimeout>\n | null;\n\nfunction throwIfDuringRender(): void {\n const inst = getCurrentComponentInstance();\n if (inst !== null) {\n throw new Error(\n '[Askr] calling FX handler during render is not allowed. Move calls to event handlers or effects.'\n );\n }\n}\n\n/**\n * Helper: schedule a user callback through the global scheduler\n */\nfunction enqueueUserCallback(fn: () => void) {\n globalScheduler.enqueue(() => {\n try {\n fn();\n } catch (err) {\n // Keep behavior consistent with other scheduler-queued work\n logger.error('[Askr] FX handler error:', err);\n }\n });\n}\n\n// ---------- Event handlers ----------\n\nexport function debounceEvent(\n ms: number,\n handler: EventListener,\n options?: { leading?: boolean; trailing?: boolean }\n): EventListener & { cancel(): void; flush(): void } {\n const { leading = false, trailing = true } = options || {};\n\n const inst = getCurrentComponentInstance();\n // On SSR, event handlers are inert\n if (inst && inst.ssr) {\n return noopEventListenerWithFlush;\n }\n\n let timeoutId: TimeoutHandle = null;\n let lastEvent: Event | null = null;\n let lastCallTime = 0;\n\n const debounced = function (this: unknown, ev: Event) {\n // Disallow using returned handler during render\n throwIfDuringRender();\n\n const now = Date.now();\n lastEvent = ev;\n\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n if (leading && now - lastCallTime >= ms) {\n enqueueUserCallback(() => handler.call(null, ev));\n lastCallTime = now;\n }\n\n if (trailing) {\n timeoutId = setTimeout(() => {\n // Schedule through scheduler\n if (lastEvent) {\n enqueueUserCallback(() => handler.call(null, lastEvent!));\n }\n timeoutId = null;\n lastCallTime = Date.now();\n }, ms);\n }\n } as EventListener & { cancel(): void; flush(): void };\n\n debounced.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastEvent = null;\n };\n\n debounced.flush = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n const ev = lastEvent;\n lastEvent = null;\n timeoutId = null;\n if (ev) enqueueUserCallback(() => handler.call(null, ev));\n }\n };\n\n // Auto-cleanup on component unmount\n if (inst) {\n inst.cleanupFns.push(() => {\n debounced.cancel();\n });\n }\n\n return debounced;\n}\n\nexport function throttleEvent(\n ms: number,\n handler: EventListener,\n options?: { leading?: boolean; trailing?: boolean }\n): EventListener & { cancel(): void } {\n const { leading = true, trailing = true } = options || {};\n\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return noopEventListener;\n }\n\n let lastCallTime = 0;\n let timeoutId: TimeoutHandle = null;\n let lastEvent: Event | null = null;\n\n const throttled = function (this: unknown, ev: Event) {\n throwIfDuringRender();\n\n const now = Date.now();\n lastEvent = ev;\n\n if (leading && now - lastCallTime >= ms) {\n enqueueUserCallback(() => handler.call(null, ev));\n lastCallTime = now;\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n } else if (!leading && lastCallTime === 0) {\n lastCallTime = now;\n }\n\n if (trailing && timeoutId === null) {\n const wait = ms - (now - lastCallTime);\n timeoutId = setTimeout(\n () => {\n if (lastEvent)\n enqueueUserCallback(() => handler.call(null, lastEvent!));\n lastCallTime = Date.now();\n timeoutId = null;\n },\n Math.max(0, wait)\n );\n }\n } as EventListener & { cancel(): void };\n\n throttled.cancel = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n lastEvent = null;\n };\n\n if (inst) {\n inst.cleanupFns.push(() => throttled.cancel());\n }\n\n return throttled;\n}\n\nexport function rafEvent(\n handler: EventListener\n): EventListener & { cancel(): void } {\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return noopEventListener;\n }\n\n let frameId: RafHandle = null;\n let lastEvent: Event | null = null;\n\n const scheduleFrame = () => {\n const rAF =\n typeof requestAnimationFrame !== 'undefined'\n ? requestAnimationFrame\n : (cb: FrameRequestCallback) => setTimeout(() => cb(Date.now()), 16);\n\n frameId = rAF(() => {\n frameId = null;\n if (lastEvent) {\n const ev = lastEvent;\n lastEvent = null;\n enqueueUserCallback(() => handler.call(null, ev));\n }\n });\n };\n\n const fn = function (this: unknown, ev: Event) {\n throwIfDuringRender();\n lastEvent = ev;\n if (frameId === null) scheduleFrame();\n } as EventListener & { cancel(): void };\n\n fn.cancel = () => {\n if (frameId !== null) {\n // If frameId is numeric and cancelAnimationFrame is available, use it;\n // otherwise fall back to clearTimeout for the setTimeout fallback.\n if (\n typeof cancelAnimationFrame !== 'undefined' &&\n typeof frameId === 'number'\n ) {\n cancelAnimationFrame(frameId);\n } else {\n clearTimeout(frameId as ReturnType<typeof setTimeout>);\n }\n frameId = null;\n }\n lastEvent = null;\n };\n\n if (inst) inst.cleanupFns.push(() => fn.cancel());\n\n return fn;\n}\n\n// ---------- Scheduled work ----------\n\nexport function scheduleTimeout(ms: number, fn: () => void): CancelFn {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) {\n return () => {};\n }\n\n let id: TimeoutHandle = setTimeout(() => {\n id = null;\n enqueueUserCallback(fn);\n }, ms);\n\n const cancel = () => {\n if (id !== null) {\n clearTimeout(id);\n id = null;\n }\n };\n\n if (inst) inst.cleanupFns.push(cancel);\n return cancel;\n}\n\nexport function scheduleIdle(\n fn: () => void,\n options?: { timeout?: number }\n): CancelFn {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) return () => {};\n\n let id: IdleHandle = null;\n let usingRIC = false;\n\n if (typeof requestIdleCallback !== 'undefined') {\n usingRIC = true;\n id = requestIdleCallback(() => {\n id = null;\n enqueueUserCallback(fn);\n }, options);\n } else {\n // Fallback: schedule on next macrotask\n id = setTimeout(() => {\n id = null;\n enqueueUserCallback(fn);\n }, 0);\n }\n\n const cancel = () => {\n if (id !== null) {\n // If using requestIdleCallback and available, call cancelIdleCallback for numeric ids.\n if (\n usingRIC &&\n typeof cancelIdleCallback !== 'undefined' &&\n typeof id === 'number'\n ) {\n cancelIdleCallback(id);\n } else {\n clearTimeout(id as ReturnType<typeof setTimeout>);\n }\n id = null;\n }\n };\n\n if (inst) inst.cleanupFns.push(cancel);\n return cancel;\n}\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoff?: (attemptIndex: number) => number;\n}\n\nexport function scheduleRetry<T>(\n fn: () => Promise<T>,\n options?: RetryOptions\n): { cancel(): void } {\n throwIfDuringRender();\n const inst = getCurrentComponentInstance();\n if (inst && inst.ssr) return { cancel: () => {} };\n\n const {\n maxAttempts = 3,\n delayMs = 100,\n backoff = (i: number) => delayMs * Math.pow(2, i),\n } = options || {};\n\n let cancelled = false;\n\n const attempt = (index: number) => {\n if (cancelled) return;\n // Run user fn inside scheduler\n globalScheduler.enqueue(() => {\n if (cancelled) return;\n // Call fn (it may be async)\n const p = fn();\n p.then(\n () => {\n // Completed successfully\n },\n () => {\n if (cancelled) return;\n if (index + 1 < maxAttempts) {\n const delay = backoff(index);\n // Schedule next attempt via setTimeout so it gets enqueued through scheduleTimeout\n setTimeout(() => {\n attempt(index + 1);\n }, delay);\n }\n }\n ).catch((e) => {\n logger.error('[Askr] scheduleRetry error:', e);\n });\n });\n };\n\n // Start first attempt\n attempt(0);\n\n const cancel = () => {\n cancelled = true;\n };\n\n if (inst) inst.cleanupFns.push(cancel);\n return { cancel };\n}\n"],"mappings":";;;;;;;;;AAsCO,SAAS,SACd,IACA,IACA,SACwB;AACxB,MAAI,YAAmC;AACvC,QAAM,EAAE,UAAU,OAAO,WAAW,KAAK,IAAI,WAAW,CAAC;AACzD,MAAI,WAA6B;AACjC,MAAI,WAAoB;AACxB,MAAI,eAAe;AAEnB,QAAM,YAAY,YAA4B,MAAiB;AAC7D,UAAM,WAAW,KAAK,IAAI;AAC1B,eAAW;AAEX,eAAW;AAEX,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AAAA,IACxB;AAEA,QAAI,WAAW,WAAW,gBAAgB,IAAI;AAC5C,SAAG,MAAM,MAAM,IAAI;AACnB,qBAAe;AAAA,IACjB;AAEA,QAAI,UAAU;AACZ,kBAAY,WAAW,MAAM;AAC3B,WAAG,MAAM,UAAU,QAAS;AAC5B,oBAAY;AACZ,uBAAe,KAA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