@automattic/jetpack-boost-score-api 0.1.3 → 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/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/src/utils/poll-promise.ts +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.4] - 2023-07-11
|
|
9
|
+
### Changed
|
|
10
|
+
- Updated package dependencies. [#31785]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Fix type declarations for vars holding returns from `setTimeout`, `setInterval`. [#31769]
|
|
14
|
+
|
|
8
15
|
## [0.1.3] - 2023-07-05
|
|
9
16
|
### Changed
|
|
10
17
|
- Updated package dependencies. [#31659]
|
|
@@ -24,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
24
31
|
### Added
|
|
25
32
|
- Create package for the boost score bar API [#30781]
|
|
26
33
|
|
|
34
|
+
[0.1.4]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.3...v0.1.4
|
|
27
35
|
[0.1.3]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.2...v0.1.3
|
|
28
36
|
[0.1.2]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.1...v0.1.2
|
|
29
37
|
[0.1.1]: https://github.com/Automattic/jetpack-boost-score-api/compare/v0.1.0...v0.1.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-boost-score-api",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "A package to get the Jetpack Boost score of a site",
|
|
5
5
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/boost-score-api/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test": "jest tests"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@wordpress/i18n": "4.
|
|
23
|
+
"@wordpress/i18n": "4.37.0",
|
|
24
24
|
"zod": "3.20.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
|
|
3
|
-
type Resolve<
|
|
3
|
+
type Resolve< RetType = void > = ( value: RetType | PromiseLike< RetType > ) => void;
|
|
4
4
|
|
|
5
|
-
type PollPromiseArgs<
|
|
5
|
+
type PollPromiseArgs< RetType = void > = {
|
|
6
6
|
interval: number;
|
|
7
7
|
timeout: number;
|
|
8
8
|
timeoutError?: string;
|
|
9
|
-
callback: ( resolve: Resolve<
|
|
9
|
+
callback: ( resolve: Resolve< RetType > ) => Promise< void > | void;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -16,23 +16,24 @@ type PollPromiseArgs< ReturnType = void > = {
|
|
|
16
16
|
*
|
|
17
17
|
* Rejects with a timeout after <timeout> milliseconds.
|
|
18
18
|
*
|
|
19
|
-
* @template
|
|
19
|
+
* @template RetType
|
|
20
20
|
* @param {object} obj - Arguments object.
|
|
21
21
|
* @param {number} obj.interval - Milliseconds between calling callback
|
|
22
22
|
* @param {number} obj.timeout - Milliseconds before rejecting w/ a timeout
|
|
23
23
|
* @param {Function} obj.callback - Callback to call every <interval> ms.
|
|
24
24
|
* @param {string} obj.timeoutError - Message to throw on timeout.
|
|
25
|
-
* @returns {Promise<
|
|
25
|
+
* @returns {Promise< RetType >} - A promise which resolves to the value resolved() inside callback.
|
|
26
26
|
*/
|
|
27
|
-
export default async function pollPromise<
|
|
27
|
+
export default async function pollPromise< RetType = void >( {
|
|
28
28
|
interval,
|
|
29
29
|
callback,
|
|
30
30
|
timeout,
|
|
31
31
|
timeoutError,
|
|
32
|
-
}: PollPromiseArgs<
|
|
33
|
-
let timeoutHandle:
|
|
32
|
+
}: PollPromiseArgs< RetType > ): Promise< RetType > {
|
|
33
|
+
let timeoutHandle: ReturnType< typeof setTimeout >,
|
|
34
|
+
intervalHandle: ReturnType< typeof setInterval >;
|
|
34
35
|
|
|
35
|
-
return new Promise<
|
|
36
|
+
return new Promise< RetType >( ( resolve, reject ) => {
|
|
36
37
|
timeoutHandle = setTimeout( () => {
|
|
37
38
|
reject( new Error( timeoutError || __( 'Timed out', 'boost-score-api' ) ) );
|
|
38
39
|
}, timeout || 2 * 60 * 1000 );
|