@qwik.dev/utils 2.0.0-beta.39 → 2.0.0-beta.41
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/lib/index.qwik.mjs +25 -21
- package/lib/q-manifest.json +5 -5
- package/package.json +4 -4
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { _captures, inlinedQrl, useVisibleTaskQrl } from "@qwik.dev/core";
|
|
2
|
+
/** Smallest allowed poll interval, so a `0` or negative `expires` can't spin the event loop. */ var MIN_EXPIRES_MS = 5;
|
|
3
|
+
/**
|
|
4
|
+
* Poll a computed/async signal: invalidate it every `expires` milliseconds so it recomputes. The
|
|
5
|
+
* signal is returned so it can be wrapped inline.
|
|
6
|
+
*
|
|
7
|
+
* Polling starts once the document is idle and is client-only. The timer resets whenever a new
|
|
8
|
+
* result lands (the `pending` flip), so `expires` counts from the last result, not from mount.
|
|
9
|
+
* Polling continues after a failed computation. `expires` is clamped to 5ms.
|
|
10
|
+
*
|
|
11
|
+
* Multiple components may call `usePoll` on the same signal; the redundant timers are harmless.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/ var usePoll = (signal, expires) => {
|
|
15
|
+
useVisibleTaskQrl(/*#__PURE__*/ inlinedQrl(({ track, cleanup }) => {
|
|
16
|
+
const expires = _captures[0], signal = _captures[1];
|
|
17
|
+
const pending = track(() => signal.pending);
|
|
18
|
+
track(() => signal.error);
|
|
19
|
+
if (!pending) {
|
|
20
|
+
const intervalId = setInterval(() => signal.invalidate(), Math.max(expires, MIN_EXPIRES_MS));
|
|
21
|
+
cleanup(() => clearInterval(intervalId));
|
|
22
|
+
}
|
|
23
|
+
}, "usePoll_useVisibleTask_UBz9ZdQcfUQ", [expires, signal]), { strategy: "document-idle" });
|
|
24
|
+
return signal;
|
|
22
25
|
};
|
|
26
|
+
export { usePoll };
|
package/lib/q-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1",
|
|
3
|
-
"manifestHash": "
|
|
3
|
+
"manifestHash": "eammkx",
|
|
4
4
|
"options": {
|
|
5
5
|
"target": "lib",
|
|
6
6
|
"buildMode": "development",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"mapping": {},
|
|
14
14
|
"bundles": {
|
|
15
15
|
"../index.qwik.mjs": {
|
|
16
|
-
"size":
|
|
17
|
-
"total":
|
|
16
|
+
"size": 1264,
|
|
17
|
+
"total": 1264,
|
|
18
18
|
"origins": [
|
|
19
19
|
"src/index.qwik.ts",
|
|
20
20
|
"src/use-poll.ts"
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"symbols": {},
|
|
32
32
|
"platform": {
|
|
33
33
|
"vite": "",
|
|
34
|
-
"rollup": "4.
|
|
34
|
+
"rollup": "4.23.0",
|
|
35
35
|
"env": "node",
|
|
36
36
|
"os": "linux",
|
|
37
|
-
"node": "24.
|
|
37
|
+
"node": "24.15.0"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwik.dev/utils",
|
|
3
3
|
"description": "Useful but less common utilities for Qwik applications",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.41",
|
|
5
5
|
"bugs": "https://github.com/QwikDev/qwik/issues",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"typescript": "5.9.3",
|
|
8
|
-
"vite": "
|
|
9
|
-
"@qwik.dev/core": "2.0.0-beta.
|
|
8
|
+
"vite": "8.2.1",
|
|
9
|
+
"@qwik.dev/core": "2.0.0-beta.41"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"main": "./lib/index.qwik.mjs",
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@qwik.dev/core": "
|
|
27
|
+
"@qwik.dev/core": "2.0.0-beta.41"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|