@qwik.dev/utils 2.0.0-beta.39
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/LICENSE +22 -0
- package/lib/assets/BqrDAOEV-bundle-graph.json +1 -0
- package/lib/index.qwik.mjs +22 -0
- package/lib/q-manifest.json +39 -0
- package/lib/types/index.qwik.d.ts +1 -0
- package/lib/types/use-poll.d.ts +14 -0
- package/lib/types/use-poll.unit.d.ts +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 QwikDev
|
|
4
|
+
Copyright (c) 2021 BuilderIO
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useVisibleTaskQrl, inlinedQrl, _captures } from "@qwik.dev/core";
|
|
2
|
+
const MIN_EXPIRES_MS = 5;
|
|
3
|
+
const usePoll = (signal, expires) => {
|
|
4
|
+
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(({ track, cleanup }) => {
|
|
5
|
+
const expires2 = _captures[0], signal2 = _captures[1];
|
|
6
|
+
const pending = track(() => signal2.pending);
|
|
7
|
+
track(() => signal2.error);
|
|
8
|
+
if (!pending) {
|
|
9
|
+
const intervalId = setInterval(() => signal2.invalidate(), Math.max(expires2, MIN_EXPIRES_MS));
|
|
10
|
+
cleanup(() => clearInterval(intervalId));
|
|
11
|
+
}
|
|
12
|
+
}, "usePoll_useVisibleTask_UBz9ZdQcfUQ", [
|
|
13
|
+
expires,
|
|
14
|
+
signal
|
|
15
|
+
]), {
|
|
16
|
+
strategy: "document-idle"
|
|
17
|
+
});
|
|
18
|
+
return signal;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
usePoll
|
|
22
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1",
|
|
3
|
+
"manifestHash": "f2nlsn",
|
|
4
|
+
"options": {
|
|
5
|
+
"target": "lib",
|
|
6
|
+
"buildMode": "development",
|
|
7
|
+
"entryStrategy": {
|
|
8
|
+
"type": "inline"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"bundleGraphAsset": "assets/BqrDAOEV-bundle-graph.json",
|
|
12
|
+
"injections": [],
|
|
13
|
+
"mapping": {},
|
|
14
|
+
"bundles": {
|
|
15
|
+
"../index.qwik.mjs": {
|
|
16
|
+
"size": 685,
|
|
17
|
+
"total": 685,
|
|
18
|
+
"origins": [
|
|
19
|
+
"src/index.qwik.ts",
|
|
20
|
+
"src/use-poll.ts"
|
|
21
|
+
],
|
|
22
|
+
"interactivity": 0
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"assets": {
|
|
26
|
+
"assets/BqrDAOEV-bundle-graph.json": {
|
|
27
|
+
"name": "bundle-graph.json",
|
|
28
|
+
"size": 0
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"symbols": {},
|
|
32
|
+
"platform": {
|
|
33
|
+
"vite": "",
|
|
34
|
+
"rollup": "4.61.0",
|
|
35
|
+
"env": "node",
|
|
36
|
+
"os": "linux",
|
|
37
|
+
"node": "24.12.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { usePoll } from './use-poll';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ComputedSignal } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Poll a computed/async signal: invalidate it every `expires` milliseconds so it recomputes. The
|
|
4
|
+
* signal is returned so it can be wrapped inline.
|
|
5
|
+
*
|
|
6
|
+
* Polling starts once the document is idle and is client-only. The timer resets whenever a new
|
|
7
|
+
* result lands (the `pending` flip), so `expires` counts from the last result, not from mount.
|
|
8
|
+
* Polling continues after a failed computation. `expires` is clamped to 5ms.
|
|
9
|
+
*
|
|
10
|
+
* Multiple components may call `usePoll` on the same signal; the redundant timers are harmless.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare const usePoll: <T>(signal: ComputedSignal<T>, expires: number) => ComputedSignal<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qwik.dev/utils",
|
|
3
|
+
"description": "Useful but less common utilities for Qwik applications",
|
|
4
|
+
"version": "2.0.0-beta.39",
|
|
5
|
+
"bugs": "https://github.com/QwikDev/qwik/issues",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"typescript": "5.9.3",
|
|
8
|
+
"vite": "7.3.5",
|
|
9
|
+
"@qwik.dev/core": "2.0.0-beta.39"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./lib/types/index.qwik.d.ts",
|
|
17
|
+
"import": "./lib/index.qwik.mjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"lib"
|
|
22
|
+
],
|
|
23
|
+
"homepage": "https://qwik.dev/",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"main": "./lib/index.qwik.mjs",
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@qwik.dev/core": "^2.0.0-beta.39"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"qwik": "./lib/index.qwik.mjs",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/QwikDev/qwik.git",
|
|
36
|
+
"directory": "packages/qwik-utils"
|
|
37
|
+
},
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"type": "module",
|
|
40
|
+
"types": "./lib/types/index.qwik.d.ts",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "vite build --mode lib",
|
|
43
|
+
"fmt": "prettier --write .",
|
|
44
|
+
"fmt.check": "prettier --check .",
|
|
45
|
+
"lint": "eslint \"src/**/*.ts*\"",
|
|
46
|
+
"typecheck": "tsc --noEmit"
|
|
47
|
+
}
|
|
48
|
+
}
|