@vpmedia/simplify 1.57.0 โ 1.58.0
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 +19 -0
- package/package.json +2 -2
- package/src/pagelifecycle/util.js +6 -6
- package/src/util/fetch.js +3 -8
- package/src/util/fetch.test.js +1 -1
- package/types/util/fetch.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [1.58.0] - 2026-01-13
|
|
2
|
+
|
|
3
|
+
### ๐ผ Other
|
|
4
|
+
|
|
5
|
+
- *(deps)* Bump dependency versions
|
|
6
|
+
|
|
7
|
+
### ๐ Refactor
|
|
8
|
+
|
|
9
|
+
- Use globalThis instead of window
|
|
10
|
+
|
|
11
|
+
### ๐งช Testing
|
|
12
|
+
|
|
13
|
+
- Fixed failing test
|
|
14
|
+
|
|
15
|
+
### โ๏ธ Miscellaneous Tasks
|
|
16
|
+
|
|
17
|
+
- Release
|
|
18
|
+
- Adjusted error message
|
|
19
|
+
- *(release)* V1.58.0
|
|
1
20
|
## [1.57.0] - 2026-01-12
|
|
2
21
|
|
|
3
22
|
### ๐ Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/simplify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"description": "@vpmedia/simplify",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@commitlint/cli": "^20.3.1",
|
|
29
29
|
"@commitlint/config-conventional": "^20.3.1",
|
|
30
30
|
"@eslint/js": "^9.39.2",
|
|
31
|
-
"@types/node": "^25.0.
|
|
31
|
+
"@types/node": "^25.0.7",
|
|
32
32
|
"@vitest/coverage-v8": "^4.0.17",
|
|
33
33
|
"eslint": "^9.39.2",
|
|
34
34
|
"eslint-plugin-jsdoc": "^62.0.0",
|
|
@@ -104,13 +104,13 @@ export const initPageLifecycle = () => {
|
|
|
104
104
|
onDocumentStateChange(document.readyState);
|
|
105
105
|
const options = { capture: true };
|
|
106
106
|
document.addEventListener('visibilitychange', () => onPageLifecycleStateChange(detectPageLifecycleState()), options);
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// globalThis.addEventListener('popstate', () => onPageLifecycleStateChange(detectPageLifecycleState()), options);
|
|
108
|
+
globalThis.addEventListener('pageshow', () => onPageLifecycleStateChange(detectPageLifecycleState()), options);
|
|
109
|
+
globalThis.addEventListener('focus', () => onPageLifecycleStateChange(detectPageLifecycleState()), options);
|
|
110
|
+
globalThis.addEventListener('blur', () => onPageLifecycleStateChange(detectPageLifecycleState()), options);
|
|
111
111
|
document.addEventListener('resume', () => onPageLifecycleStateChange(detectPageLifecycleState()), options);
|
|
112
112
|
document.addEventListener('freeze', () => onPageLifecycleStateChange(PAGE_LIFECYCLE_STATE_FROZEN), options);
|
|
113
|
-
|
|
113
|
+
globalThis.addEventListener(
|
|
114
114
|
'pagehide',
|
|
115
115
|
(event) =>
|
|
116
116
|
onPageLifecycleStateChange(event.persisted ? PAGE_LIFECYCLE_STATE_FROZEN : PAGE_LIFECYCLE_STATE_TERMINATED),
|
|
@@ -118,7 +118,7 @@ export const initPageLifecycle = () => {
|
|
|
118
118
|
);
|
|
119
119
|
document.addEventListener('DOMContentLoaded', () => onDocumentStateChange(DOCUMENT_STATE_DOM_LOADED), options);
|
|
120
120
|
document.addEventListener('readystatechange', () => onDocumentStateChange(document.readyState), options);
|
|
121
|
-
|
|
121
|
+
globalThis.addEventListener('load', () => onDocumentStateChange(DOCUMENT_STATE_FULLY_LOADED), options);
|
|
122
122
|
isInitialized = true;
|
|
123
123
|
};
|
|
124
124
|
|
package/src/util/fetch.js
CHANGED
|
@@ -54,17 +54,12 @@ export const fetchRetry = async (resource, fetchOptions, retryOptions) => {
|
|
|
54
54
|
while (retryOptions.numTries > 0) {
|
|
55
55
|
logger.info('request', { resource, fetchOptions, retryOptions });
|
|
56
56
|
const controller = new AbortController();
|
|
57
|
-
const timeoutId = setTimeout(() => controller.abort('Fetch
|
|
57
|
+
const timeoutId = setTimeout(() => controller.abort('Fetch timed out'), retryOptions.timeout);
|
|
58
58
|
fetchOptions.signal = controller.signal;
|
|
59
59
|
try {
|
|
60
60
|
const response = await fetch(resource, fetchOptions);
|
|
61
61
|
if (!response.ok) {
|
|
62
|
-
throw new FetchError(
|
|
63
|
-
`fetch ${response.url} returned status ${response.status}`,
|
|
64
|
-
resource,
|
|
65
|
-
fetchOptions,
|
|
66
|
-
response
|
|
67
|
-
);
|
|
62
|
+
throw new FetchError(`Fetch error ${response.status}`, resource, fetchOptions, response);
|
|
68
63
|
}
|
|
69
64
|
logger.info('response', response);
|
|
70
65
|
return response;
|
|
@@ -86,5 +81,5 @@ export const fetchRetry = async (resource, fetchOptions, retryOptions) => {
|
|
|
86
81
|
clearTimeout(timeoutId);
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
|
-
throw new Error('Fetch
|
|
84
|
+
throw new Error('Fetch failed');
|
|
90
85
|
};
|
package/src/util/fetch.test.js
CHANGED
|
@@ -45,7 +45,7 @@ describe('fetchRetry', () => {
|
|
|
45
45
|
const typedError = error instanceof Error ? error : new Error(String(error));
|
|
46
46
|
expect(typedError).toBeInstanceOf(FetchError);
|
|
47
47
|
if (typedError instanceof FetchError) {
|
|
48
|
-
expect(typedError.message).toBe('
|
|
48
|
+
expect(typedError.message).toBe('Fetch error 404');
|
|
49
49
|
expect(typedError.response.status).toBe(HTTP_404_NOT_FOUND);
|
|
50
50
|
expect(typedError.cause).toBe(HTTP_404_NOT_FOUND);
|
|
51
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/util/fetch.js"],"names":[],"mappings":"AAeA,yBAA0B,CAAC,CAAC;AAE5B;IACE;;;;;;OAMG;IACH,qBALW,MAAM,YACN,MAAM,GAAG,GAAG,GAAG,OAAO,gBACtB,WAAW,YACX,QAAQ,EASlB;IAJC,iCAAwB;IACxB,0BAAgC;IAChC,mBAAwB;IACxB,cAAqC;CAExC;AASM,qCALI,MAAM,GAAG,GAAG,GAAG,OAAO,gBACtB,WAAW,iBACX;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAC9E,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/util/fetch.js"],"names":[],"mappings":"AAeA,yBAA0B,CAAC,CAAC;AAE5B;IACE;;;;;;OAMG;IACH,qBALW,MAAM,YACN,MAAM,GAAG,GAAG,GAAG,OAAO,gBACtB,WAAW,YACX,QAAQ,EASlB;IAJC,iCAAwB;IACxB,0BAAgC;IAChC,mBAAwB;IACxB,cAAqC;CAExC;AASM,qCALI,MAAM,GAAG,GAAG,GAAG,OAAO,gBACtB,WAAW,iBACX;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAC9E,OAAO,CAAC,QAAQ,CAAC,CA4C7B"}
|